diff --git a/playground/playground.go b/playground/playground.go index 8fd9ff7a..ca3c183e 100644 --- a/playground/playground.go +++ b/playground/playground.go @@ -19,7 +19,7 @@ type Line map[string]string var output []Line func main() { - app := angularjs.NewModule("playground", nil, nil) + app := angularjs.NewModule("playground", nil) app.NewController("PlaygroundCtrl", func(scope *angularjs.Scope) { scope.Set("code", "package main\n\nimport (\n\t\"fmt\"\n\t\"github.com/gopherjs/gopherjs/js\"\n)\n\nfunc main() {\n\tfmt.Println(\"Hello, playground\")\n\tjs.Global.Call(\"alert\", \"Hello, JavaScript\")\n\tprintln(\"Hello, JS console\")\n}\n") diff --git a/playground/playground.js b/playground/playground.js index 638210d6..2ca769b6 100644 --- a/playground/playground.js +++ b/playground/playground.js @@ -4113,123 +4113,13 @@ $packages["bytes"] = (function() { }; return $pkg; })(); -$packages["github.com/gopherjs/go-angularjs"] = (function() { - var $pkg = {}, js = $packages["github.com/gopherjs/gopherjs/js"], Module, Scope, JQueryElement, Event, HttpService, NewModule, ElementById, Service; - Module = $pkg.Module = $newType(0, "Struct", "angularjs.Module", "Module", "github.com/gopherjs/go-angularjs", function(Object_) { - this.$val = this; - this.Object = Object_ !== undefined ? Object_ : $ifaceNil; - }); - Scope = $pkg.Scope = $newType(0, "Struct", "angularjs.Scope", "Scope", "github.com/gopherjs/go-angularjs", function(Object_) { - this.$val = this; - this.Object = Object_ !== undefined ? Object_ : $ifaceNil; - }); - JQueryElement = $pkg.JQueryElement = $newType(0, "Struct", "angularjs.JQueryElement", "JQueryElement", "github.com/gopherjs/go-angularjs", function(Object_) { - this.$val = this; - this.Object = Object_ !== undefined ? Object_ : $ifaceNil; - }); - Event = $pkg.Event = $newType(0, "Struct", "angularjs.Event", "Event", "github.com/gopherjs/go-angularjs", function(Object_, KeyCode_) { - this.$val = this; - this.Object = Object_ !== undefined ? Object_ : $ifaceNil; - this.KeyCode = KeyCode_ !== undefined ? KeyCode_ : 0; - }); - HttpService = $pkg.HttpService = $newType(0, "Struct", "angularjs.HttpService", "HttpService", "github.com/gopherjs/go-angularjs", function() { - this.$val = this; - }); - Module.Ptr.prototype.NewController = function(name, constructor) { - var m; - m = this; - m.Object.controller($externalize(name, $String), $externalize((function($scope) { - constructor(new Scope.Ptr($scope)); - }), ($funcType([js.Object], [], false)))); - }; - Module.prototype.NewController = function(name, constructor) { return this.$val.NewController(name, constructor); }; - Scope.Ptr.prototype.Apply = function(f) { - var s; - s = this; - s.Object.$apply($externalize(f, ($funcType([], [], false)))); - }; - Scope.prototype.Apply = function(f) { return this.$val.Apply(f); }; - Scope.Ptr.prototype.EvalAsync = function(f) { - var s; - s = this; - s.Object.$evalAsync($externalize(f, ($funcType([], [], false)))); - }; - Scope.prototype.EvalAsync = function(f) { return this.$val.EvalAsync(f); }; - JQueryElement.Ptr.prototype.Prop = function(name) { - var e; - e = this; - return e.Object.prop($externalize(name, $String)); - }; - JQueryElement.prototype.Prop = function(name) { return this.$val.Prop(name); }; - JQueryElement.Ptr.prototype.SetProp = function(name, value) { - var e; - e = this; - e.Object.prop($externalize(name, $emptyInterface), $externalize(value, $emptyInterface)); - }; - JQueryElement.prototype.SetProp = function(name, value) { return this.$val.SetProp(name, value); }; - JQueryElement.Ptr.prototype.On = function(events, handler) { - var e; - e = this; - e.Object.on($externalize(events, $String), $externalize((function(e$1) { - handler(new Event.Ptr(e$1, 0)); - }), ($funcType([js.Object], [], false)))); - }; - JQueryElement.prototype.On = function(events, handler) { return this.$val.On(events, handler); }; - JQueryElement.Ptr.prototype.Val = function() { - var e; - e = this; - return e.Object.val(); - }; - JQueryElement.prototype.Val = function() { return this.$val.Val(); }; - JQueryElement.Ptr.prototype.SetVal = function(value) { - var e; - e = this; - e.Object.val($externalize(value, $emptyInterface)); - }; - JQueryElement.prototype.SetVal = function(value) { return this.$val.SetVal(value); }; - Event.Ptr.prototype.PreventDefault = function() { - var e; - e = this; - e.Object.preventDefault(); - }; - Event.prototype.PreventDefault = function() { return this.$val.PreventDefault(); }; - NewModule = $pkg.NewModule = function(name, requires, configFn) { - return new Module.Ptr($global.angular.module($externalize(name, $String), $externalize(requires, ($sliceType($String))), $externalize(configFn, ($funcType([], [], false))))); - }; - ElementById = $pkg.ElementById = function(id) { - return new JQueryElement.Ptr($global.angular.element($global.document.getElementById($externalize(id, $String)))); - }; - Service = $pkg.Service = function(name) { - return $global.angular.element($global.document).injector().get($externalize(name, $String)); - }; - HttpService.Ptr.prototype.Get = function(url, callback) { - var s, future; - s = this; - future = Service("$http").get($externalize(url, $String)); - future.success($externalize((function(data, status, headers, config) { - callback(data, status); - }), ($funcType([$String, $Int, js.Object, js.Object], [], false)))); - future.error($externalize((function(data, status, headers, config) { - callback(data, status); - }), ($funcType([$String, $Int, js.Object, js.Object], [], false)))); - }; - HttpService.prototype.Get = function(url, callback) { return this.$val.Get(url, callback); }; +$packages["encoding"] = (function() { + var $pkg = {}, TextMarshaler, TextUnmarshaler; + TextMarshaler = $pkg.TextMarshaler = $newType(8, "Interface", "encoding.TextMarshaler", "TextMarshaler", "encoding", null); + TextUnmarshaler = $pkg.TextUnmarshaler = $newType(8, "Interface", "encoding.TextUnmarshaler", "TextUnmarshaler", "encoding", null); $pkg.$init = function() { - Module.methods = [["Bool", "Bool", "", $funcType([], [$Bool], false), 0], ["Call", "Call", "", $funcType([$String, ($sliceType($emptyInterface))], [js.Object], true), 0], ["Delete", "Delete", "", $funcType([$String], [], false), 0], ["Float", "Float", "", $funcType([], [$Float64], false), 0], ["Get", "Get", "", $funcType([$String], [js.Object], false), 0], ["Index", "Index", "", $funcType([$Int], [js.Object], false), 0], ["Int", "Int", "", $funcType([], [$Int], false), 0], ["Int64", "Int64", "", $funcType([], [$Int64], false), 0], ["Interface", "Interface", "", $funcType([], [$emptyInterface], false), 0], ["Invoke", "Invoke", "", $funcType([($sliceType($emptyInterface))], [js.Object], true), 0], ["IsNull", "IsNull", "", $funcType([], [$Bool], false), 0], ["IsUndefined", "IsUndefined", "", $funcType([], [$Bool], false), 0], ["Length", "Length", "", $funcType([], [$Int], false), 0], ["New", "New", "", $funcType([($sliceType($emptyInterface))], [js.Object], true), 0], ["Set", "Set", "", $funcType([$String, $emptyInterface], [], false), 0], ["SetIndex", "SetIndex", "", $funcType([$Int, $emptyInterface], [], false), 0], ["Str", "Str", "", $funcType([], [$String], false), 0], ["Uint64", "Uint64", "", $funcType([], [$Uint64], false), 0], ["Unsafe", "Unsafe", "", $funcType([], [$Uintptr], false), 0]]; - ($ptrType(Module)).methods = [["Bool", "Bool", "", $funcType([], [$Bool], false), 0], ["Call", "Call", "", $funcType([$String, ($sliceType($emptyInterface))], [js.Object], true), 0], ["Delete", "Delete", "", $funcType([$String], [], false), 0], ["Float", "Float", "", $funcType([], [$Float64], false), 0], ["Get", "Get", "", $funcType([$String], [js.Object], false), 0], ["Index", "Index", "", $funcType([$Int], [js.Object], false), 0], ["Int", "Int", "", $funcType([], [$Int], false), 0], ["Int64", "Int64", "", $funcType([], [$Int64], false), 0], ["Interface", "Interface", "", $funcType([], [$emptyInterface], false), 0], ["Invoke", "Invoke", "", $funcType([($sliceType($emptyInterface))], [js.Object], true), 0], ["IsNull", "IsNull", "", $funcType([], [$Bool], false), 0], ["IsUndefined", "IsUndefined", "", $funcType([], [$Bool], false), 0], ["Length", "Length", "", $funcType([], [$Int], false), 0], ["New", "New", "", $funcType([($sliceType($emptyInterface))], [js.Object], true), 0], ["NewController", "NewController", "", $funcType([$String, ($funcType([($ptrType(Scope))], [], false))], [], false), -1], ["Set", "Set", "", $funcType([$String, $emptyInterface], [], false), 0], ["SetIndex", "SetIndex", "", $funcType([$Int, $emptyInterface], [], false), 0], ["Str", "Str", "", $funcType([], [$String], false), 0], ["Uint64", "Uint64", "", $funcType([], [$Uint64], false), 0], ["Unsafe", "Unsafe", "", $funcType([], [$Uintptr], false), 0]]; - Module.init([["Object", "", "", js.Object, ""]]); - Scope.methods = [["Bool", "Bool", "", $funcType([], [$Bool], false), 0], ["Call", "Call", "", $funcType([$String, ($sliceType($emptyInterface))], [js.Object], true), 0], ["Delete", "Delete", "", $funcType([$String], [], false), 0], ["Float", "Float", "", $funcType([], [$Float64], false), 0], ["Get", "Get", "", $funcType([$String], [js.Object], false), 0], ["Index", "Index", "", $funcType([$Int], [js.Object], false), 0], ["Int", "Int", "", $funcType([], [$Int], false), 0], ["Int64", "Int64", "", $funcType([], [$Int64], false), 0], ["Interface", "Interface", "", $funcType([], [$emptyInterface], false), 0], ["Invoke", "Invoke", "", $funcType([($sliceType($emptyInterface))], [js.Object], true), 0], ["IsNull", "IsNull", "", $funcType([], [$Bool], false), 0], ["IsUndefined", "IsUndefined", "", $funcType([], [$Bool], false), 0], ["Length", "Length", "", $funcType([], [$Int], false), 0], ["New", "New", "", $funcType([($sliceType($emptyInterface))], [js.Object], true), 0], ["Set", "Set", "", $funcType([$String, $emptyInterface], [], false), 0], ["SetIndex", "SetIndex", "", $funcType([$Int, $emptyInterface], [], false), 0], ["Str", "Str", "", $funcType([], [$String], false), 0], ["Uint64", "Uint64", "", $funcType([], [$Uint64], false), 0], ["Unsafe", "Unsafe", "", $funcType([], [$Uintptr], false), 0]]; - ($ptrType(Scope)).methods = [["Apply", "Apply", "", $funcType([($funcType([], [], false))], [], false), -1], ["Bool", "Bool", "", $funcType([], [$Bool], false), 0], ["Call", "Call", "", $funcType([$String, ($sliceType($emptyInterface))], [js.Object], true), 0], ["Delete", "Delete", "", $funcType([$String], [], false), 0], ["EvalAsync", "EvalAsync", "", $funcType([($funcType([], [], false))], [], false), -1], ["Float", "Float", "", $funcType([], [$Float64], false), 0], ["Get", "Get", "", $funcType([$String], [js.Object], false), 0], ["Index", "Index", "", $funcType([$Int], [js.Object], false), 0], ["Int", "Int", "", $funcType([], [$Int], false), 0], ["Int64", "Int64", "", $funcType([], [$Int64], false), 0], ["Interface", "Interface", "", $funcType([], [$emptyInterface], false), 0], ["Invoke", "Invoke", "", $funcType([($sliceType($emptyInterface))], [js.Object], true), 0], ["IsNull", "IsNull", "", $funcType([], [$Bool], false), 0], ["IsUndefined", "IsUndefined", "", $funcType([], [$Bool], false), 0], ["Length", "Length", "", $funcType([], [$Int], false), 0], ["New", "New", "", $funcType([($sliceType($emptyInterface))], [js.Object], true), 0], ["Set", "Set", "", $funcType([$String, $emptyInterface], [], false), 0], ["SetIndex", "SetIndex", "", $funcType([$Int, $emptyInterface], [], false), 0], ["Str", "Str", "", $funcType([], [$String], false), 0], ["Uint64", "Uint64", "", $funcType([], [$Uint64], false), 0], ["Unsafe", "Unsafe", "", $funcType([], [$Uintptr], false), 0]]; - Scope.init([["Object", "", "", js.Object, ""]]); - JQueryElement.methods = [["Bool", "Bool", "", $funcType([], [$Bool], false), 0], ["Call", "Call", "", $funcType([$String, ($sliceType($emptyInterface))], [js.Object], true), 0], ["Delete", "Delete", "", $funcType([$String], [], false), 0], ["Float", "Float", "", $funcType([], [$Float64], false), 0], ["Get", "Get", "", $funcType([$String], [js.Object], false), 0], ["Index", "Index", "", $funcType([$Int], [js.Object], false), 0], ["Int", "Int", "", $funcType([], [$Int], false), 0], ["Int64", "Int64", "", $funcType([], [$Int64], false), 0], ["Interface", "Interface", "", $funcType([], [$emptyInterface], false), 0], ["Invoke", "Invoke", "", $funcType([($sliceType($emptyInterface))], [js.Object], true), 0], ["IsNull", "IsNull", "", $funcType([], [$Bool], false), 0], ["IsUndefined", "IsUndefined", "", $funcType([], [$Bool], false), 0], ["Length", "Length", "", $funcType([], [$Int], false), 0], ["New", "New", "", $funcType([($sliceType($emptyInterface))], [js.Object], true), 0], ["Set", "Set", "", $funcType([$String, $emptyInterface], [], false), 0], ["SetIndex", "SetIndex", "", $funcType([$Int, $emptyInterface], [], false), 0], ["Str", "Str", "", $funcType([], [$String], false), 0], ["Uint64", "Uint64", "", $funcType([], [$Uint64], false), 0], ["Unsafe", "Unsafe", "", $funcType([], [$Uintptr], false), 0]]; - ($ptrType(JQueryElement)).methods = [["Bool", "Bool", "", $funcType([], [$Bool], false), 0], ["Call", "Call", "", $funcType([$String, ($sliceType($emptyInterface))], [js.Object], true), 0], ["Delete", "Delete", "", $funcType([$String], [], false), 0], ["Float", "Float", "", $funcType([], [$Float64], false), 0], ["Get", "Get", "", $funcType([$String], [js.Object], false), 0], ["Index", "Index", "", $funcType([$Int], [js.Object], false), 0], ["Int", "Int", "", $funcType([], [$Int], false), 0], ["Int64", "Int64", "", $funcType([], [$Int64], false), 0], ["Interface", "Interface", "", $funcType([], [$emptyInterface], false), 0], ["Invoke", "Invoke", "", $funcType([($sliceType($emptyInterface))], [js.Object], true), 0], ["IsNull", "IsNull", "", $funcType([], [$Bool], false), 0], ["IsUndefined", "IsUndefined", "", $funcType([], [$Bool], false), 0], ["Length", "Length", "", $funcType([], [$Int], false), 0], ["New", "New", "", $funcType([($sliceType($emptyInterface))], [js.Object], true), 0], ["On", "On", "", $funcType([$String, ($funcType([($ptrType(Event))], [], false))], [], false), -1], ["Prop", "Prop", "", $funcType([$String], [js.Object], false), -1], ["Set", "Set", "", $funcType([$String, $emptyInterface], [], false), 0], ["SetIndex", "SetIndex", "", $funcType([$Int, $emptyInterface], [], false), 0], ["SetProp", "SetProp", "", $funcType([$emptyInterface, $emptyInterface], [], false), -1], ["SetVal", "SetVal", "", $funcType([$emptyInterface], [], false), -1], ["Str", "Str", "", $funcType([], [$String], false), 0], ["Uint64", "Uint64", "", $funcType([], [$Uint64], false), 0], ["Unsafe", "Unsafe", "", $funcType([], [$Uintptr], false), 0], ["Val", "Val", "", $funcType([], [js.Object], false), -1]]; - JQueryElement.init([["Object", "", "", js.Object, ""]]); - Event.methods = [["Bool", "Bool", "", $funcType([], [$Bool], false), 0], ["Call", "Call", "", $funcType([$String, ($sliceType($emptyInterface))], [js.Object], true), 0], ["Delete", "Delete", "", $funcType([$String], [], false), 0], ["Float", "Float", "", $funcType([], [$Float64], false), 0], ["Get", "Get", "", $funcType([$String], [js.Object], false), 0], ["Index", "Index", "", $funcType([$Int], [js.Object], false), 0], ["Int", "Int", "", $funcType([], [$Int], false), 0], ["Int64", "Int64", "", $funcType([], [$Int64], false), 0], ["Interface", "Interface", "", $funcType([], [$emptyInterface], false), 0], ["Invoke", "Invoke", "", $funcType([($sliceType($emptyInterface))], [js.Object], true), 0], ["IsNull", "IsNull", "", $funcType([], [$Bool], false), 0], ["IsUndefined", "IsUndefined", "", $funcType([], [$Bool], false), 0], ["Length", "Length", "", $funcType([], [$Int], false), 0], ["New", "New", "", $funcType([($sliceType($emptyInterface))], [js.Object], true), 0], ["Set", "Set", "", $funcType([$String, $emptyInterface], [], false), 0], ["SetIndex", "SetIndex", "", $funcType([$Int, $emptyInterface], [], false), 0], ["Str", "Str", "", $funcType([], [$String], false), 0], ["Uint64", "Uint64", "", $funcType([], [$Uint64], false), 0], ["Unsafe", "Unsafe", "", $funcType([], [$Uintptr], false), 0]]; - ($ptrType(Event)).methods = [["Bool", "Bool", "", $funcType([], [$Bool], false), 0], ["Call", "Call", "", $funcType([$String, ($sliceType($emptyInterface))], [js.Object], true), 0], ["Delete", "Delete", "", $funcType([$String], [], false), 0], ["Float", "Float", "", $funcType([], [$Float64], false), 0], ["Get", "Get", "", $funcType([$String], [js.Object], false), 0], ["Index", "Index", "", $funcType([$Int], [js.Object], false), 0], ["Int", "Int", "", $funcType([], [$Int], false), 0], ["Int64", "Int64", "", $funcType([], [$Int64], false), 0], ["Interface", "Interface", "", $funcType([], [$emptyInterface], false), 0], ["Invoke", "Invoke", "", $funcType([($sliceType($emptyInterface))], [js.Object], true), 0], ["IsNull", "IsNull", "", $funcType([], [$Bool], false), 0], ["IsUndefined", "IsUndefined", "", $funcType([], [$Bool], false), 0], ["Length", "Length", "", $funcType([], [$Int], false), 0], ["New", "New", "", $funcType([($sliceType($emptyInterface))], [js.Object], true), 0], ["PreventDefault", "PreventDefault", "", $funcType([], [], false), -1], ["Set", "Set", "", $funcType([$String, $emptyInterface], [], false), 0], ["SetIndex", "SetIndex", "", $funcType([$Int, $emptyInterface], [], false), 0], ["Str", "Str", "", $funcType([], [$String], false), 0], ["Uint64", "Uint64", "", $funcType([], [$Uint64], false), 0], ["Unsafe", "Unsafe", "", $funcType([], [$Uintptr], false), 0]]; - Event.init([["Object", "", "", js.Object, ""], ["KeyCode", "KeyCode", "", $Int, "js:\"keyCode\""]]); - ($ptrType(HttpService)).methods = [["Get", "Get", "", $funcType([$String, ($funcType([$String, $Int], [], false))], [], false), -1]]; - HttpService.init([]); - $pkg.HTTP = new HttpService.Ptr(); + TextMarshaler.init([["MarshalText", "MarshalText", "", $funcType([], [($sliceType($Uint8)), $error], false)]]); + TextUnmarshaler.init([["UnmarshalText", "UnmarshalText", "", $funcType([($sliceType($Uint8))], [$error], false)]]); }; return $pkg; })(); @@ -4471,44620 +4361,45286 @@ $packages["math"] = (function() { }; return $pkg; })(); -$packages["syscall"] = (function() { - var $pkg = {}, bytes = $packages["bytes"], js = $packages["github.com/gopherjs/gopherjs/js"], sync = $packages["sync"], runtime = $packages["runtime"], errors = $packages["errors"], attrList, mmapper, Errno, _C_int, Timespec, Stat_t, Dirent, warningPrinted, lineBuffer, syscallModule, alreadyTriedToLoad, minusOne, envOnce, envLock, env, envs, mapper, errors$1, printWarning, printToConsole, init, syscall, Syscall, Syscall6, BytePtrFromString, copyenv, Getenv, CloseOnExec, itoa, ByteSliceFromString, ReadDirent, Sysctl, Getwd, nametomib, ParseDirent, getAttrList, Read, Write, sysctl, fcntl, Close, Exit, Fchdir, Fchmod, Fchown, Fstat, Fsync, Ftruncate, Getdirentries, Lstat, Open, Pread, Pwrite, read, Readlink, Seek, Stat, write, mmap, munmap; - attrList = $pkg.attrList = $newType(0, "Struct", "syscall.attrList", "attrList", "syscall", function(bitmapCount_, _$1_, CommonAttr_, VolAttr_, DirAttr_, FileAttr_, Forkattr_) { +$packages["strconv"] = (function() { + var $pkg = {}, math = $packages["math"], errors = $packages["errors"], utf8 = $packages["unicode/utf8"], NumError, decimal, leftCheat, extFloat, floatInfo, decimalSlice, optimize, powtab, float64pow10, float32pow10, leftcheats, smallPowersOfTen, powersOfTen, uint64pow10, float32info, float64info, isPrint16, isNotPrint16, isPrint32, isNotPrint32, shifts, ParseBool, FormatBool, equalIgnoreCase, special, readFloat, atof64exact, atof32exact, atof32, atof64, ParseFloat, syntaxError, rangeError, cutoff64, ParseUint, ParseInt, Atoi, digitZero, trim, rightShift, prefixIsLessThan, leftShift, shouldRoundUp, frexp10Many, adjustLastDigitFixed, adjustLastDigit, FormatFloat, AppendFloat, genericFtoa, bigFtoa, formatDigits, roundShortest, fmtE, fmtF, fmtB, max, FormatUint, FormatInt, Itoa, AppendInt, AppendUint, formatBits, quoteWith, Quote, QuoteToASCII, QuoteRune, AppendQuoteRune, QuoteRuneToASCII, AppendQuoteRuneToASCII, CanBackquote, unhex, UnquoteChar, Unquote, contains, bsearch16, bsearch32, IsPrint; + NumError = $pkg.NumError = $newType(0, "Struct", "strconv.NumError", "NumError", "strconv", function(Func_, Num_, Err_) { this.$val = this; - this.bitmapCount = bitmapCount_ !== undefined ? bitmapCount_ : 0; - this._$1 = _$1_ !== undefined ? _$1_ : 0; - this.CommonAttr = CommonAttr_ !== undefined ? CommonAttr_ : 0; - this.VolAttr = VolAttr_ !== undefined ? VolAttr_ : 0; - this.DirAttr = DirAttr_ !== undefined ? DirAttr_ : 0; - this.FileAttr = FileAttr_ !== undefined ? FileAttr_ : 0; - this.Forkattr = Forkattr_ !== undefined ? Forkattr_ : 0; + this.Func = Func_ !== undefined ? Func_ : ""; + this.Num = Num_ !== undefined ? Num_ : ""; + this.Err = Err_ !== undefined ? Err_ : $ifaceNil; }); - mmapper = $pkg.mmapper = $newType(0, "Struct", "syscall.mmapper", "mmapper", "syscall", function(Mutex_, active_, mmap_, munmap_) { + decimal = $pkg.decimal = $newType(0, "Struct", "strconv.decimal", "decimal", "strconv", function(d_, nd_, dp_, neg_, trunc_) { this.$val = this; - this.Mutex = Mutex_ !== undefined ? Mutex_ : new sync.Mutex.Ptr(); - this.active = active_ !== undefined ? active_ : false; - this.mmap = mmap_ !== undefined ? mmap_ : $throwNilPointerError; - this.munmap = munmap_ !== undefined ? munmap_ : $throwNilPointerError; + this.d = d_ !== undefined ? d_ : ($arrayType($Uint8, 800)).zero(); + this.nd = nd_ !== undefined ? nd_ : 0; + this.dp = dp_ !== undefined ? dp_ : 0; + this.neg = neg_ !== undefined ? neg_ : false; + this.trunc = trunc_ !== undefined ? trunc_ : false; }); - Errno = $pkg.Errno = $newType(4, "Uintptr", "syscall.Errno", "Errno", "syscall", null); - _C_int = $pkg._C_int = $newType(4, "Int32", "syscall._C_int", "_C_int", "syscall", null); - Timespec = $pkg.Timespec = $newType(0, "Struct", "syscall.Timespec", "Timespec", "syscall", function(Sec_, Nsec_) { + leftCheat = $pkg.leftCheat = $newType(0, "Struct", "strconv.leftCheat", "leftCheat", "strconv", function(delta_, cutoff_) { this.$val = this; - this.Sec = Sec_ !== undefined ? Sec_ : new $Int64(0, 0); - this.Nsec = Nsec_ !== undefined ? Nsec_ : new $Int64(0, 0); + this.delta = delta_ !== undefined ? delta_ : 0; + this.cutoff = cutoff_ !== undefined ? cutoff_ : ""; }); - Stat_t = $pkg.Stat_t = $newType(0, "Struct", "syscall.Stat_t", "Stat_t", "syscall", function(Dev_, Mode_, Nlink_, Ino_, Uid_, Gid_, Rdev_, Pad_cgo_0_, Atimespec_, Mtimespec_, Ctimespec_, Birthtimespec_, Size_, Blocks_, Blksize_, Flags_, Gen_, Lspare_, Qspare_) { + extFloat = $pkg.extFloat = $newType(0, "Struct", "strconv.extFloat", "extFloat", "strconv", function(mant_, exp_, neg_) { this.$val = this; - this.Dev = Dev_ !== undefined ? Dev_ : 0; - this.Mode = Mode_ !== undefined ? Mode_ : 0; - this.Nlink = Nlink_ !== undefined ? Nlink_ : 0; - this.Ino = Ino_ !== undefined ? Ino_ : new $Uint64(0, 0); - this.Uid = Uid_ !== undefined ? Uid_ : 0; - this.Gid = Gid_ !== undefined ? Gid_ : 0; - this.Rdev = Rdev_ !== undefined ? Rdev_ : 0; - this.Pad_cgo_0 = Pad_cgo_0_ !== undefined ? Pad_cgo_0_ : ($arrayType($Uint8, 4)).zero(); - this.Atimespec = Atimespec_ !== undefined ? Atimespec_ : new Timespec.Ptr(); - this.Mtimespec = Mtimespec_ !== undefined ? Mtimespec_ : new Timespec.Ptr(); - this.Ctimespec = Ctimespec_ !== undefined ? Ctimespec_ : new Timespec.Ptr(); - this.Birthtimespec = Birthtimespec_ !== undefined ? Birthtimespec_ : new Timespec.Ptr(); - this.Size = Size_ !== undefined ? Size_ : new $Int64(0, 0); - this.Blocks = Blocks_ !== undefined ? Blocks_ : new $Int64(0, 0); - this.Blksize = Blksize_ !== undefined ? Blksize_ : 0; - this.Flags = Flags_ !== undefined ? Flags_ : 0; - this.Gen = Gen_ !== undefined ? Gen_ : 0; - this.Lspare = Lspare_ !== undefined ? Lspare_ : 0; - this.Qspare = Qspare_ !== undefined ? Qspare_ : ($arrayType($Int64, 2)).zero(); + this.mant = mant_ !== undefined ? mant_ : new $Uint64(0, 0); + this.exp = exp_ !== undefined ? exp_ : 0; + this.neg = neg_ !== undefined ? neg_ : false; }); - Dirent = $pkg.Dirent = $newType(0, "Struct", "syscall.Dirent", "Dirent", "syscall", function(Ino_, Seekoff_, Reclen_, Namlen_, Type_, Name_, Pad_cgo_0_) { + floatInfo = $pkg.floatInfo = $newType(0, "Struct", "strconv.floatInfo", "floatInfo", "strconv", function(mantbits_, expbits_, bias_) { this.$val = this; - this.Ino = Ino_ !== undefined ? Ino_ : new $Uint64(0, 0); - this.Seekoff = Seekoff_ !== undefined ? Seekoff_ : new $Uint64(0, 0); - this.Reclen = Reclen_ !== undefined ? Reclen_ : 0; - this.Namlen = Namlen_ !== undefined ? Namlen_ : 0; - this.Type = Type_ !== undefined ? Type_ : 0; - this.Name = Name_ !== undefined ? Name_ : ($arrayType($Int8, 1024)).zero(); - this.Pad_cgo_0 = Pad_cgo_0_ !== undefined ? Pad_cgo_0_ : ($arrayType($Uint8, 3)).zero(); + this.mantbits = mantbits_ !== undefined ? mantbits_ : 0; + this.expbits = expbits_ !== undefined ? expbits_ : 0; + this.bias = bias_ !== undefined ? bias_ : 0; }); - printWarning = function() { - if (!warningPrinted) { - console.log("warning: system calls not available, see https://github.com/gopherjs/gopherjs/blob/master/doc/syscalls.md"); + decimalSlice = $pkg.decimalSlice = $newType(0, "Struct", "strconv.decimalSlice", "decimalSlice", "strconv", function(d_, nd_, dp_, neg_) { + this.$val = this; + this.d = d_ !== undefined ? d_ : ($sliceType($Uint8)).nil; + this.nd = nd_ !== undefined ? nd_ : 0; + this.dp = dp_ !== undefined ? dp_ : 0; + this.neg = neg_ !== undefined ? neg_ : false; + }); + ParseBool = $pkg.ParseBool = function(str) { + var value = false, err = $ifaceNil, _ref, _tmp, _tmp$1, _tmp$2, _tmp$3, _tmp$4, _tmp$5; + _ref = str; + if (_ref === "1" || _ref === "t" || _ref === "T" || _ref === "true" || _ref === "TRUE" || _ref === "True") { + _tmp = true; _tmp$1 = $ifaceNil; value = _tmp; err = _tmp$1; + return [value, err]; + } else if (_ref === "0" || _ref === "f" || _ref === "F" || _ref === "false" || _ref === "FALSE" || _ref === "False") { + _tmp$2 = false; _tmp$3 = $ifaceNil; value = _tmp$2; err = _tmp$3; + return [value, err]; } - warningPrinted = true; + _tmp$4 = false; _tmp$5 = syntaxError("ParseBool", str); value = _tmp$4; err = _tmp$5; + return [value, err]; }; - printToConsole = function(b) { - var goPrintToConsole, i; - goPrintToConsole = $global.goPrintToConsole; - if (!(goPrintToConsole === undefined)) { - goPrintToConsole(b); - return; - } - lineBuffer = $appendSlice(lineBuffer, b); - while (true) { - i = bytes.IndexByte(lineBuffer, 10); - if (i === -1) { - break; - } - $global.console.log($externalize($bytesToString($subslice(lineBuffer, 0, i)), $String)); - lineBuffer = $subslice(lineBuffer, (i + 1 >> 0)); + FormatBool = $pkg.FormatBool = function(b) { + if (b) { + return "true"; } + return "false"; }; - init = function() { - var process, jsEnv, envkeys, i, key; - process = $global.process; - if (!(process === undefined)) { - jsEnv = process.env; - envkeys = $global.Object.keys(jsEnv); - envs = ($sliceType($String)).make($parseInt(envkeys.length)); - i = 0; - while (i < $parseInt(envkeys.length)) { - key = $internalize(envkeys[i], $String); - (i < 0 || i >= envs.$length) ? $throwRuntimeError("index out of range") : envs.$array[envs.$offset + i] = key + "=" + $internalize(jsEnv[$externalize(key, $String)], $String); - i = i + (1) >> 0; - } + equalIgnoreCase = function(s1, s2) { + var i, c1, c2; + if (!((s1.length === s2.length))) { + return false; } - }; - syscall = function(name) { - var $deferred = [], $err = null, require; - /* */ try { $deferFrames.push($deferred); - $deferred.push([(function() { - $recover(); - }), []]); - if (syscallModule === $ifaceNil) { - if (alreadyTriedToLoad) { - return $ifaceNil; + i = 0; + while (i < s1.length) { + c1 = s1.charCodeAt(i); + if (65 <= c1 && c1 <= 90) { + c1 = c1 + (32) << 24 >>> 24; } - alreadyTriedToLoad = true; - require = $global.require; - if (require === undefined) { - $panic(new $String("")); + c2 = s2.charCodeAt(i); + if (65 <= c2 && c2 <= 90) { + c2 = c2 + (32) << 24 >>> 24; } - syscallModule = require($externalize("syscall", $String)); - } - return syscallModule[$externalize(name, $String)]; - /* */ } catch(err) { $err = err; return $ifaceNil; } finally { $deferFrames.pop(); $callDeferred($deferred, $err); } - }; - Syscall = $pkg.Syscall = function(trap, a1, a2, a3) { - var r1 = 0, r2 = 0, err = 0, f, r, _tmp, _tmp$1, _tmp$2, array, slice, _tmp$3, _tmp$4, _tmp$5, _tmp$6, _tmp$7, _tmp$8; - f = syscall("Syscall"); - if (!(f === $ifaceNil)) { - r = f(trap, a1, a2, a3); - _tmp = (($parseInt(r[0]) >> 0) >>> 0); _tmp$1 = (($parseInt(r[1]) >> 0) >>> 0); _tmp$2 = (($parseInt(r[2]) >> 0) >>> 0); r1 = _tmp; r2 = _tmp$1; err = _tmp$2; - return [r1, r2, err]; - } - if ((trap === 4) && ((a1 === 1) || (a1 === 2))) { - array = a2; - slice = ($sliceType($Uint8)).make($parseInt(array.length)); - slice.$array = array; - printToConsole(slice); - _tmp$3 = ($parseInt(array.length) >>> 0); _tmp$4 = 0; _tmp$5 = 0; r1 = _tmp$3; r2 = _tmp$4; err = _tmp$5; - return [r1, r2, err]; + if (!((c1 === c2))) { + return false; + } + i = i + (1) >> 0; } - printWarning(); - _tmp$6 = (minusOne >>> 0); _tmp$7 = 0; _tmp$8 = 13; r1 = _tmp$6; r2 = _tmp$7; err = _tmp$8; - return [r1, r2, err]; + return true; }; - Syscall6 = $pkg.Syscall6 = function(trap, a1, a2, a3, a4, a5, a6) { - var r1 = 0, r2 = 0, err = 0, f, r, _tmp, _tmp$1, _tmp$2, _tmp$3, _tmp$4, _tmp$5; - f = syscall("Syscall6"); - if (!(f === $ifaceNil)) { - r = f(trap, a1, a2, a3, a4, a5, a6); - _tmp = (($parseInt(r[0]) >> 0) >>> 0); _tmp$1 = (($parseInt(r[1]) >> 0) >>> 0); _tmp$2 = (($parseInt(r[2]) >> 0) >>> 0); r1 = _tmp; r2 = _tmp$1; err = _tmp$2; - return [r1, r2, err]; - } - if (!((trap === 202))) { - printWarning(); + special = function(s) { + var f = 0, ok = false, _ref, _tmp, _tmp$1, _tmp$2, _tmp$3, _tmp$4, _tmp$5, _tmp$6, _tmp$7; + if (s.length === 0) { + return [f, ok]; } - _tmp$3 = (minusOne >>> 0); _tmp$4 = 0; _tmp$5 = 13; r1 = _tmp$3; r2 = _tmp$4; err = _tmp$5; - return [r1, r2, err]; - }; - BytePtrFromString = $pkg.BytePtrFromString = function(s) { - var array, _ref, _i, i, b; - array = new ($global.Uint8Array)(s.length + 1 >> 0); - _ref = new ($sliceType($Uint8))($stringToBytes(s)); - _i = 0; - while (_i < _ref.$length) { - i = _i; - b = ((_i < 0 || _i >= _ref.$length) ? $throwRuntimeError("index out of range") : _ref.$array[_ref.$offset + _i]); - if (b === 0) { - return [($ptrType($Uint8)).nil, new Errno(22)]; + _ref = s.charCodeAt(0); + if (_ref === 43) { + if (equalIgnoreCase(s, "+inf") || equalIgnoreCase(s, "+infinity")) { + _tmp = math.Inf(1); _tmp$1 = true; f = _tmp; ok = _tmp$1; + return [f, ok]; } - array[i] = b; - _i++; - } - array[s.length] = 0; - return [array, $ifaceNil]; - }; - copyenv = function() { - var _ref, _i, i, s, j, key, _tuple, _entry, ok, _key; - env = new $Map(); - _ref = envs; - _i = 0; - while (_i < _ref.$length) { - i = _i; - s = ((_i < 0 || _i >= _ref.$length) ? $throwRuntimeError("index out of range") : _ref.$array[_ref.$offset + _i]); - j = 0; - while (j < s.length) { - if (s.charCodeAt(j) === 61) { - key = s.substring(0, j); - _tuple = (_entry = env[key], _entry !== undefined ? [_entry.v, true] : [0, false]); ok = _tuple[1]; - if (!ok) { - _key = key; (env || $throwRuntimeError("assignment to entry in nil map"))[_key] = { k: _key, v: i }; - } - break; - } - j = j + (1) >> 0; + } else if (_ref === 45) { + if (equalIgnoreCase(s, "-inf") || equalIgnoreCase(s, "-infinity")) { + _tmp$2 = math.Inf(-1); _tmp$3 = true; f = _tmp$2; ok = _tmp$3; + return [f, ok]; } - _i++; - } - }; - Getenv = $pkg.Getenv = function(key) { - var value = "", found = false, $deferred = [], $err = null, _tmp, _tmp$1, _tuple, _entry, i, ok, _tmp$2, _tmp$3, s, i$1, _tmp$4, _tmp$5, _tmp$6, _tmp$7; - /* */ try { $deferFrames.push($deferred); - envOnce.Do(copyenv); - if (key.length === 0) { - _tmp = ""; _tmp$1 = false; value = _tmp; found = _tmp$1; - return [value, found]; - } - envLock.RLock(); - $deferred.push([$methodVal(envLock, "RUnlock"), []]); - _tuple = (_entry = env[key], _entry !== undefined ? [_entry.v, true] : [0, false]); i = _tuple[0]; ok = _tuple[1]; - if (!ok) { - _tmp$2 = ""; _tmp$3 = false; value = _tmp$2; found = _tmp$3; - return [value, found]; - } - s = ((i < 0 || i >= envs.$length) ? $throwRuntimeError("index out of range") : envs.$array[envs.$offset + i]); - i$1 = 0; - while (i$1 < s.length) { - if (s.charCodeAt(i$1) === 61) { - _tmp$4 = s.substring((i$1 + 1 >> 0)); _tmp$5 = true; value = _tmp$4; found = _tmp$5; - return [value, found]; + } else if (_ref === 110 || _ref === 78) { + if (equalIgnoreCase(s, "nan")) { + _tmp$4 = math.NaN(); _tmp$5 = true; f = _tmp$4; ok = _tmp$5; + return [f, ok]; } - i$1 = i$1 + (1) >> 0; - } - _tmp$6 = ""; _tmp$7 = false; value = _tmp$6; found = _tmp$7; - return [value, found]; - /* */ } catch(err) { $err = err; } finally { $deferFrames.pop(); $callDeferred($deferred, $err); return [value, found]; } - }; - CloseOnExec = $pkg.CloseOnExec = function(fd) { - fcntl(fd, 2, 1); - }; - itoa = function(val) { - var buf, i, _r, _q; - if (val < 0) { - return "-" + itoa(-val); - } - buf = ($arrayType($Uint8, 32)).zero(); $copy(buf, ($arrayType($Uint8, 32)).zero(), ($arrayType($Uint8, 32))); - i = 31; - while (val >= 10) { - (i < 0 || i >= buf.length) ? $throwRuntimeError("index out of range") : buf[i] = (((_r = val % 10, _r === _r ? _r : $throwRuntimeError("integer divide by zero")) + 48 >> 0) << 24 >>> 24); - i = i - (1) >> 0; - val = (_q = val / (10), (_q === _q && _q !== 1/0 && _q !== -1/0) ? _q >> 0 : $throwRuntimeError("integer divide by zero")); - } - (i < 0 || i >= buf.length) ? $throwRuntimeError("index out of range") : buf[i] = ((val + 48 >> 0) << 24 >>> 24); - return $bytesToString($subslice(new ($sliceType($Uint8))(buf), i)); - }; - ByteSliceFromString = $pkg.ByteSliceFromString = function(s) { - var i, a; - i = 0; - while (i < s.length) { - if (s.charCodeAt(i) === 0) { - return [($sliceType($Uint8)).nil, new Errno(22)]; + } else if (_ref === 105 || _ref === 73) { + if (equalIgnoreCase(s, "inf") || equalIgnoreCase(s, "infinity")) { + _tmp$6 = math.Inf(1); _tmp$7 = true; f = _tmp$6; ok = _tmp$7; + return [f, ok]; } - i = i + (1) >> 0; - } - a = ($sliceType($Uint8)).make((s.length + 1 >> 0)); - $copyString(a, s); - return [a, $ifaceNil]; - }; - Timespec.Ptr.prototype.Unix = function() { - var sec = new $Int64(0, 0), nsec = new $Int64(0, 0), ts, _tmp, _tmp$1; - ts = this; - _tmp = ts.Sec; _tmp$1 = ts.Nsec; sec = _tmp; nsec = _tmp$1; - return [sec, nsec]; - }; - Timespec.prototype.Unix = function() { return this.$val.Unix(); }; - Timespec.Ptr.prototype.Nano = function() { - var ts, x, x$1; - ts = this; - return (x = $mul64(ts.Sec, new $Int64(0, 1000000000)), x$1 = ts.Nsec, new $Int64(x.$high + x$1.$high, x.$low + x$1.$low)); - }; - Timespec.prototype.Nano = function() { return this.$val.Nano(); }; - ReadDirent = $pkg.ReadDirent = function(fd, buf) { - var n = 0, err = $ifaceNil, base, _tuple; - base = new Uint8Array(8); - _tuple = Getdirentries(fd, buf, base); n = _tuple[0]; err = _tuple[1]; - return [n, err]; - }; - Sysctl = $pkg.Sysctl = function(name) { - var value = "", err = $ifaceNil, _tuple, mib, _tmp, _tmp$1, n, _tmp$2, _tmp$3, _tmp$4, _tmp$5, buf, _tmp$6, _tmp$7, x, _tmp$8, _tmp$9; - _tuple = nametomib(name); mib = _tuple[0]; err = _tuple[1]; - if (!($interfaceIsEqual(err, $ifaceNil))) { - _tmp = ""; _tmp$1 = err; value = _tmp; err = _tmp$1; - return [value, err]; - } - n = 0; - err = sysctl(mib, ($ptrType($Uint8)).nil, new ($ptrType($Uintptr))(function() { return n; }, function($v) { n = $v; }), ($ptrType($Uint8)).nil, 0); - if (!($interfaceIsEqual(err, $ifaceNil))) { - _tmp$2 = ""; _tmp$3 = err; value = _tmp$2; err = _tmp$3; - return [value, err]; - } - if (n === 0) { - _tmp$4 = ""; _tmp$5 = $ifaceNil; value = _tmp$4; err = _tmp$5; - return [value, err]; - } - buf = ($sliceType($Uint8)).make(n); - err = sysctl(mib, new ($ptrType($Uint8))(function() { return ((0 < 0 || 0 >= this.$target.$length) ? $throwRuntimeError("index out of range") : this.$target.$array[this.$target.$offset + 0]); }, function($v) { (0 < 0 || 0 >= this.$target.$length) ? $throwRuntimeError("index out of range") : this.$target.$array[this.$target.$offset + 0] = $v; }, buf), new ($ptrType($Uintptr))(function() { return n; }, function($v) { n = $v; }), ($ptrType($Uint8)).nil, 0); - if (!($interfaceIsEqual(err, $ifaceNil))) { - _tmp$6 = ""; _tmp$7 = err; value = _tmp$6; err = _tmp$7; - return [value, err]; - } - if (n > 0 && ((x = n - 1 >>> 0, ((x < 0 || x >= buf.$length) ? $throwRuntimeError("index out of range") : buf.$array[buf.$offset + x])) === 0)) { - n = n - (1) >>> 0; + } else { + return [f, ok]; } - _tmp$8 = $bytesToString($subslice(buf, 0, n)); _tmp$9 = $ifaceNil; value = _tmp$8; err = _tmp$9; - return [value, err]; + return [f, ok]; }; - Getwd = $pkg.Getwd = function() { - var buf, _tuple, attrs, err, wd; - buf = ($sliceType($Uint8)).make(2048); - _tuple = getAttrList(".", new attrList.Ptr(0, 0, 134217728, 0, 0, 0, 0), buf, 0); attrs = _tuple[0]; err = _tuple[1]; - if ($interfaceIsEqual(err, $ifaceNil) && (attrs.$length === 1) && ((0 < 0 || 0 >= attrs.$length) ? $throwRuntimeError("index out of range") : attrs.$array[attrs.$offset + 0]).$length >= 2) { - wd = $bytesToString(((0 < 0 || 0 >= attrs.$length) ? $throwRuntimeError("index out of range") : attrs.$array[attrs.$offset + 0])); - if ((wd.charCodeAt(0) === 47) && (wd.charCodeAt((wd.length - 1 >> 0)) === 0)) { - return [wd.substring(0, (wd.length - 1 >> 0)), $ifaceNil]; - } - } - return ["", new Errno(45)]; - }; - nametomib = function(name) { - var mib = ($sliceType(_C_int)).nil, err = $ifaceNil, buf, n, p, _tuple, bytes$1, _tmp, _tmp$1, _tmp$2, _tmp$3, _tmp$4, _q, _tmp$5; - buf = ($arrayType(_C_int, 14)).zero(); $copy(buf, ($arrayType(_C_int, 14)).zero(), ($arrayType(_C_int, 14))); - n = 48; - p = $sliceToArray(new ($sliceType($Uint8))(buf)); - _tuple = ByteSliceFromString(name); bytes$1 = _tuple[0]; err = _tuple[1]; - if (!($interfaceIsEqual(err, $ifaceNil))) { - _tmp = ($sliceType(_C_int)).nil; _tmp$1 = err; mib = _tmp; err = _tmp$1; - return [mib, err]; + decimal.Ptr.prototype.set = function(s) { + var ok = false, b, i, sawdot, sawdigits, x, x$1, esign, e; + b = this; + i = 0; + b.neg = false; + b.trunc = false; + if (i >= s.length) { + return ok; } - err = sysctl(new ($sliceType(_C_int))([0, 3]), p, new ($ptrType($Uintptr))(function() { return n; }, function($v) { n = $v; }), new ($ptrType($Uint8))(function() { return ((0 < 0 || 0 >= this.$target.$length) ? $throwRuntimeError("index out of range") : this.$target.$array[this.$target.$offset + 0]); }, function($v) { (0 < 0 || 0 >= this.$target.$length) ? $throwRuntimeError("index out of range") : this.$target.$array[this.$target.$offset + 0] = $v; }, bytes$1), (name.length >>> 0)); - if (!($interfaceIsEqual(err, $ifaceNil))) { - _tmp$2 = ($sliceType(_C_int)).nil; _tmp$3 = err; mib = _tmp$2; err = _tmp$3; - return [mib, err]; + if (s.charCodeAt(i) === 43) { + i = i + (1) >> 0; + } else if (s.charCodeAt(i) === 45) { + b.neg = true; + i = i + (1) >> 0; } - _tmp$4 = $subslice(new ($sliceType(_C_int))(buf), 0, (_q = n / 4, (_q === _q && _q !== 1/0 && _q !== -1/0) ? _q >>> 0 : $throwRuntimeError("integer divide by zero"))); _tmp$5 = $ifaceNil; mib = _tmp$4; err = _tmp$5; - return [mib, err]; - }; - ParseDirent = $pkg.ParseDirent = function(buf, max, names) { - var consumed = 0, count = 0, newnames = ($sliceType($String)).nil, origlen, dirent, _array, _struct, _view, x, bytes$1, name, _tmp, _tmp$1, _tmp$2; - origlen = buf.$length; - while (!((max === 0)) && buf.$length > 0) { - dirent = [undefined]; - dirent[0] = (_array = $sliceToArray(buf), _struct = new Dirent.Ptr(), _view = new DataView(_array.buffer, _array.byteOffset), _struct.Ino = new $Uint64(_view.getUint32(4, true), _view.getUint32(0, true)), _struct.Seekoff = new $Uint64(_view.getUint32(12, true), _view.getUint32(8, true)), _struct.Reclen = _view.getUint16(16, true), _struct.Namlen = _view.getUint16(18, true), _struct.Type = _view.getUint8(20, true), _struct.Name = new ($nativeArray("Int8"))(_array.buffer, $min(_array.byteOffset + 21, _array.buffer.byteLength)), _struct.Pad_cgo_0 = new ($nativeArray("Uint8"))(_array.buffer, $min(_array.byteOffset + 1045, _array.buffer.byteLength)), _struct); - if (dirent[0].Reclen === 0) { - buf = ($sliceType($Uint8)).nil; - break; - } - buf = $subslice(buf, dirent[0].Reclen); - if ((x = dirent[0].Ino, (x.$high === 0 && x.$low === 0))) { + sawdot = false; + sawdigits = false; + while (i < s.length) { + if (s.charCodeAt(i) === 46) { + if (sawdot) { + return ok; + } + sawdot = true; + b.dp = b.nd; + i = i + (1) >> 0; continue; - } - bytes$1 = $sliceToArray(new ($sliceType($Uint8))(dirent[0].Name)); - name = $bytesToString($subslice(new ($sliceType($Uint8))(bytes$1), 0, dirent[0].Namlen)); - if (name === "." || name === "..") { + } else if (48 <= s.charCodeAt(i) && s.charCodeAt(i) <= 57) { + sawdigits = true; + if ((s.charCodeAt(i) === 48) && (b.nd === 0)) { + b.dp = b.dp - (1) >> 0; + i = i + (1) >> 0; + continue; + } + if (b.nd < 800) { + (x = b.d, x$1 = b.nd, (x$1 < 0 || x$1 >= x.length) ? $throwRuntimeError("index out of range") : x[x$1] = s.charCodeAt(i)); + b.nd = b.nd + (1) >> 0; + } else if (!((s.charCodeAt(i) === 48))) { + b.trunc = true; + } + i = i + (1) >> 0; continue; } - max = max - (1) >> 0; - count = count + (1) >> 0; - names = $append(names, name); - } - _tmp = origlen - buf.$length >> 0; _tmp$1 = count; _tmp$2 = names; consumed = _tmp; count = _tmp$1; newnames = _tmp$2; - return [consumed, count, newnames]; - }; - getAttrList = function(path, attrList$1, attrBuf, options) { - var attrs = ($sliceType(($sliceType($Uint8)))).nil, err = $ifaceNil, _tmp, _tmp$1, _p0, _tuple, _tmp$2, _tmp$3, _tuple$1, _array, _struct, _view, e1, _tmp$4, _tmp$5, size, dat, i, header, _tmp$6, _tmp$7, datOff, attrLen, _tmp$8, _tmp$9, end, _r, r; - if (attrBuf.$length < 4) { - _tmp = ($sliceType(($sliceType($Uint8)))).nil; _tmp$1 = errors.New("attrBuf too small"); attrs = _tmp; err = _tmp$1; - return [attrs, err]; - } - attrList$1.bitmapCount = 5; - _p0 = ($ptrType($Uint8)).nil; - _tuple = BytePtrFromString(path); _p0 = _tuple[0]; err = _tuple[1]; - if (!($interfaceIsEqual(err, $ifaceNil))) { - _tmp$2 = ($sliceType(($sliceType($Uint8)))).nil; _tmp$3 = err; attrs = _tmp$2; err = _tmp$3; - return [attrs, err]; + break; } - _array = new Uint8Array(24); - _tuple$1 = Syscall6(220, _p0, _array, $sliceToArray(attrBuf), (attrBuf.$length >>> 0), (options >>> 0), 0); e1 = _tuple$1[2]; - _struct = attrList$1, _view = new DataView(_array.buffer, _array.byteOffset), _struct.bitmapCount = _view.getUint16(0, true), _struct._$1 = _view.getUint16(2, true), _struct.CommonAttr = _view.getUint32(4, true), _struct.VolAttr = _view.getUint32(8, true), _struct.DirAttr = _view.getUint32(12, true), _struct.FileAttr = _view.getUint32(16, true), _struct.Forkattr = _view.getUint32(20, true); - if (!((e1 === 0))) { - _tmp$4 = ($sliceType(($sliceType($Uint8)))).nil; _tmp$5 = new Errno(e1); attrs = _tmp$4; err = _tmp$5; - return [attrs, err]; + if (!sawdigits) { + return ok; } - size = ((0 < 0 || 0 >= attrBuf.$length) ? $throwRuntimeError("index out of range") : attrBuf.$array[attrBuf.$offset + 0]); - dat = attrBuf; - if ((size >> 0) < attrBuf.$length) { - dat = $subslice(dat, 0, size); + if (!sawdot) { + b.dp = b.nd; } - dat = $subslice(dat, 4); - i = 0; - while ((i >> 0) < dat.$length) { - header = [undefined]; - header[0] = $subslice(dat, i); - if (header[0].$length < 8) { - _tmp$6 = attrs; _tmp$7 = errors.New("truncated attribute header"); attrs = _tmp$6; err = _tmp$7; - return [attrs, err]; + if (i < s.length && ((s.charCodeAt(i) === 101) || (s.charCodeAt(i) === 69))) { + i = i + (1) >> 0; + if (i >= s.length) { + return ok; } - datOff = ((0 < 0 || 0 >= header[0].$length) ? $throwRuntimeError("index out of range") : header[0].$array[header[0].$offset + 0]); - attrLen = ((4 < 0 || 4 >= header[0].$length) ? $throwRuntimeError("index out of range") : header[0].$array[header[0].$offset + 4]); - if (datOff < 0 || ((datOff >>> 0) + attrLen >>> 0) > (dat.$length >>> 0)) { - _tmp$8 = attrs; _tmp$9 = errors.New("truncated results; attrBuf too small"); attrs = _tmp$8; err = _tmp$9; - return [attrs, err]; + esign = 1; + if (s.charCodeAt(i) === 43) { + i = i + (1) >> 0; + } else if (s.charCodeAt(i) === 45) { + i = i + (1) >> 0; + esign = -1; + } + if (i >= s.length || s.charCodeAt(i) < 48 || s.charCodeAt(i) > 57) { + return ok; } - end = (datOff >>> 0) + attrLen >>> 0; - attrs = $append(attrs, $subslice(dat, datOff, end)); - i = end; - r = (_r = i % 4, _r === _r ? _r : $throwRuntimeError("integer divide by zero")); - if (!((r === 0))) { - i = i + (((4 - r >>> 0))) >>> 0; + e = 0; + while (i < s.length && 48 <= s.charCodeAt(i) && s.charCodeAt(i) <= 57) { + if (e < 10000) { + e = (((((e >>> 16 << 16) * 10 >> 0) + (e << 16 >>> 16) * 10) >> 0) + (s.charCodeAt(i) >> 0) >> 0) - 48 >> 0; + } + i = i + (1) >> 0; } + b.dp = b.dp + (((((e >>> 16 << 16) * esign >> 0) + (e << 16 >>> 16) * esign) >> 0)) >> 0; } - return [attrs, err]; - }; - mmapper.Ptr.prototype.Mmap = function(fd, offset, length, prot, flags) { - var data = ($sliceType($Uint8)).nil, err = $ifaceNil, $deferred = [], $err = null, m, _tmp, _tmp$1, _tuple, addr, errno, _tmp$2, _tmp$3, sl, b, x, x$1, p, _key, _tmp$4, _tmp$5; - /* */ try { $deferFrames.push($deferred); - m = this; - if (length <= 0) { - _tmp = ($sliceType($Uint8)).nil; _tmp$1 = new Errno(22); data = _tmp; err = _tmp$1; - return [data, err]; + if (!((i === s.length))) { + return ok; } - _tuple = m.mmap(0, (length >>> 0), prot, flags, fd, offset); addr = _tuple[0]; errno = _tuple[1]; - if (!($interfaceIsEqual(errno, $ifaceNil))) { - _tmp$2 = ($sliceType($Uint8)).nil; _tmp$3 = errno; data = _tmp$2; err = _tmp$3; - return [data, err]; + ok = true; + return ok; + }; + decimal.prototype.set = function(s) { return this.$val.set(s); }; + readFloat = function(s) { + var mantissa = new $Uint64(0, 0), exp = 0, neg = false, trunc = false, ok = false, i, sawdot, sawdigits, nd, ndMant, dp, c, _ref, x, esign, e; + i = 0; + if (i >= s.length) { + return [mantissa, exp, neg, trunc, ok]; } - sl = new ($structType([["addr", "addr", "syscall", $Uintptr, ""], ["len", "len", "syscall", $Int, ""], ["cap", "cap", "syscall", $Int, ""]])).Ptr(addr, length, length); - b = sl; - p = new ($ptrType($Uint8))(function() { return (x$1 = b.$capacity - 1 >> 0, ((x$1 < 0 || x$1 >= this.$target.$length) ? $throwRuntimeError("index out of range") : this.$target.$array[this.$target.$offset + x$1])); }, function($v) { (x = b.$capacity - 1 >> 0, (x < 0 || x >= this.$target.$length) ? $throwRuntimeError("index out of range") : this.$target.$array[this.$target.$offset + x] = $v); }, b); - m.Mutex.Lock(); - $deferred.push([$methodVal(m, "Unlock"), []]); - _key = p; (m.active || $throwRuntimeError("assignment to entry in nil map"))[_key.$key()] = { k: _key, v: b }; - _tmp$4 = b; _tmp$5 = $ifaceNil; data = _tmp$4; err = _tmp$5; - return [data, err]; - /* */ } catch(err) { $err = err; } finally { $deferFrames.pop(); $callDeferred($deferred, $err); return [data, err]; } - }; - mmapper.prototype.Mmap = function(fd, offset, length, prot, flags) { return this.$val.Mmap(fd, offset, length, prot, flags); }; - mmapper.Ptr.prototype.Munmap = function(data) { - var err = $ifaceNil, $deferred = [], $err = null, m, x, x$1, p, _entry, b, errno; - /* */ try { $deferFrames.push($deferred); - m = this; - if ((data.$length === 0) || !((data.$length === data.$capacity))) { - err = new Errno(22); - return err; - } - p = new ($ptrType($Uint8))(function() { return (x$1 = data.$capacity - 1 >> 0, ((x$1 < 0 || x$1 >= this.$target.$length) ? $throwRuntimeError("index out of range") : this.$target.$array[this.$target.$offset + x$1])); }, function($v) { (x = data.$capacity - 1 >> 0, (x < 0 || x >= this.$target.$length) ? $throwRuntimeError("index out of range") : this.$target.$array[this.$target.$offset + x] = $v); }, data); - m.Mutex.Lock(); - $deferred.push([$methodVal(m, "Unlock"), []]); - b = (_entry = m.active[p.$key()], _entry !== undefined ? _entry.v : ($sliceType($Uint8)).nil); - if (b === ($sliceType($Uint8)).nil || !($sliceIsEqual(b, 0, data, 0))) { - err = new Errno(22); - return err; - } - errno = m.munmap($sliceToArray(b), (b.$length >>> 0)); - if (!($interfaceIsEqual(errno, $ifaceNil))) { - err = errno; - return err; + if (s.charCodeAt(i) === 43) { + i = i + (1) >> 0; + } else if (s.charCodeAt(i) === 45) { + neg = true; + i = i + (1) >> 0; } - delete m.active[p.$key()]; - err = $ifaceNil; - return err; - /* */ } catch(err) { $err = err; } finally { $deferFrames.pop(); $callDeferred($deferred, $err); return err; } - }; - mmapper.prototype.Munmap = function(data) { return this.$val.Munmap(data); }; - Errno.prototype.Error = function() { - var e, s; - e = this.$val !== undefined ? this.$val : this; - if (0 <= (e >> 0) && (e >> 0) < 106) { - s = ((e < 0 || e >= errors$1.length) ? $throwRuntimeError("index out of range") : errors$1[e]); - if (!(s === "")) { - return s; + sawdot = false; + sawdigits = false; + nd = 0; + ndMant = 0; + dp = 0; + while (i < s.length) { + c = s.charCodeAt(i); + _ref = true; + if (_ref === (c === 46)) { + if (sawdot) { + return [mantissa, exp, neg, trunc, ok]; + } + sawdot = true; + dp = nd; + i = i + (1) >> 0; + continue; + } else if (_ref === 48 <= c && c <= 57) { + sawdigits = true; + if ((c === 48) && (nd === 0)) { + dp = dp - (1) >> 0; + i = i + (1) >> 0; + continue; + } + nd = nd + (1) >> 0; + if (ndMant < 19) { + mantissa = $mul64(mantissa, (new $Uint64(0, 10))); + mantissa = (x = new $Uint64(0, (c - 48 << 24 >>> 24)), new $Uint64(mantissa.$high + x.$high, mantissa.$low + x.$low)); + ndMant = ndMant + (1) >> 0; + } else if (!((s.charCodeAt(i) === 48))) { + trunc = true; + } + i = i + (1) >> 0; + continue; } + break; } - return "errno " + itoa((e >> 0)); - }; - $ptrType(Errno).prototype.Error = function() { return new Errno(this.$get()).Error(); }; - Errno.prototype.Temporary = function() { - var e; - e = this.$val !== undefined ? this.$val : this; - return (e === 4) || (e === 24) || (new Errno(e)).Timeout(); - }; - $ptrType(Errno).prototype.Temporary = function() { return new Errno(this.$get()).Temporary(); }; - Errno.prototype.Timeout = function() { - var e; - e = this.$val !== undefined ? this.$val : this; - return (e === 35) || (e === 35) || (e === 60); - }; - $ptrType(Errno).prototype.Timeout = function() { return new Errno(this.$get()).Timeout(); }; - Read = $pkg.Read = function(fd, p) { - var n = 0, err = $ifaceNil, _tuple; - _tuple = read(fd, p); n = _tuple[0]; err = _tuple[1]; - return [n, err]; - }; - Write = $pkg.Write = function(fd, p) { - var n = 0, err = $ifaceNil, _tuple; - _tuple = write(fd, p); n = _tuple[0]; err = _tuple[1]; - return [n, err]; - }; - sysctl = function(mib, old, oldlen, new$1, newlen) { - var err = $ifaceNil, _p0, _tuple, e1; - _p0 = 0; - if (mib.$length > 0) { - _p0 = $sliceToArray(mib); - } else { - _p0 = new Uint8Array(0); + if (!sawdigits) { + return [mantissa, exp, neg, trunc, ok]; } - _tuple = Syscall6(202, _p0, (mib.$length >>> 0), old, oldlen, new$1, newlen); e1 = _tuple[2]; - if (!((e1 === 0))) { - err = new Errno(e1); + if (!sawdot) { + dp = nd; } - return err; - }; - fcntl = function(fd, cmd, arg) { - var val = 0, err = $ifaceNil, _tuple, r0, e1; - _tuple = Syscall(92, (fd >>> 0), (cmd >>> 0), (arg >>> 0)); r0 = _tuple[0]; e1 = _tuple[2]; - val = (r0 >> 0); - if (!((e1 === 0))) { - err = new Errno(e1); + if (i < s.length && ((s.charCodeAt(i) === 101) || (s.charCodeAt(i) === 69))) { + i = i + (1) >> 0; + if (i >= s.length) { + return [mantissa, exp, neg, trunc, ok]; + } + esign = 1; + if (s.charCodeAt(i) === 43) { + i = i + (1) >> 0; + } else if (s.charCodeAt(i) === 45) { + i = i + (1) >> 0; + esign = -1; + } + if (i >= s.length || s.charCodeAt(i) < 48 || s.charCodeAt(i) > 57) { + return [mantissa, exp, neg, trunc, ok]; + } + e = 0; + while (i < s.length && 48 <= s.charCodeAt(i) && s.charCodeAt(i) <= 57) { + if (e < 10000) { + e = (((((e >>> 16 << 16) * 10 >> 0) + (e << 16 >>> 16) * 10) >> 0) + (s.charCodeAt(i) >> 0) >> 0) - 48 >> 0; + } + i = i + (1) >> 0; + } + dp = dp + (((((e >>> 16 << 16) * esign >> 0) + (e << 16 >>> 16) * esign) >> 0)) >> 0; } - return [val, err]; - }; - Close = $pkg.Close = function(fd) { - var err = $ifaceNil, _tuple, e1; - _tuple = Syscall(6, (fd >>> 0), 0, 0); e1 = _tuple[2]; - if (!((e1 === 0))) { - err = new Errno(e1); + if (!((i === s.length))) { + return [mantissa, exp, neg, trunc, ok]; } - return err; - }; - Exit = $pkg.Exit = function(code) { - Syscall(1, (code >>> 0), 0, 0); - return; + exp = dp - ndMant >> 0; + ok = true; + return [mantissa, exp, neg, trunc, ok]; }; - Fchdir = $pkg.Fchdir = function(fd) { - var err = $ifaceNil, _tuple, e1; - _tuple = Syscall(13, (fd >>> 0), 0, 0); e1 = _tuple[2]; - if (!((e1 === 0))) { - err = new Errno(e1); + decimal.Ptr.prototype.floatBits = function(flt) { + var $this = this, $args = arguments, b = new $Uint64(0, 0), overflow = false, $s = 0, d, exp, mant, n, x, n$1, x$1, n$2, y, x$2, y$1, x$3, x$4, y$2, x$5, x$6, bits, x$7, y$3, x$8, _tmp, _tmp$1; + /* */ while (true) { switch ($s) { case 0: + d = $this; + exp = 0; + mant = new $Uint64(0, 0); + /* if (d.nd === 0) { */ if (d.nd === 0) {} else { $s = 3; continue; } + mant = new $Uint64(0, 0); + exp = flt.bias; + /* goto out */ $s = 1; continue; + /* } */ case 3: + /* if (d.dp > 310) { */ if (d.dp > 310) {} else { $s = 4; continue; } + /* goto overflow */ $s = 2; continue; + /* } */ case 4: + /* if (d.dp < -330) { */ if (d.dp < -330) {} else { $s = 5; continue; } + mant = new $Uint64(0, 0); + exp = flt.bias; + /* goto out */ $s = 1; continue; + /* } */ case 5: + exp = 0; + while (d.dp > 0) { + n = 0; + if (d.dp >= powtab.$length) { + n = 27; + } else { + n = (x = d.dp, ((x < 0 || x >= powtab.$length) ? $throwRuntimeError("index out of range") : powtab.$array[powtab.$offset + x])); + } + d.Shift(-n); + exp = exp + (n) >> 0; } - return err; - }; - Fchmod = $pkg.Fchmod = function(fd, mode) { - var err = $ifaceNil, _tuple, e1; - _tuple = Syscall(124, (fd >>> 0), (mode >>> 0), 0); e1 = _tuple[2]; - if (!((e1 === 0))) { - err = new Errno(e1); + while (d.dp < 0 || (d.dp === 0) && d.d[0] < 53) { + n$1 = 0; + if (-d.dp >= powtab.$length) { + n$1 = 27; + } else { + n$1 = (x$1 = -d.dp, ((x$1 < 0 || x$1 >= powtab.$length) ? $throwRuntimeError("index out of range") : powtab.$array[powtab.$offset + x$1])); + } + d.Shift(n$1); + exp = exp - (n$1) >> 0; } - return err; - }; - Fchown = $pkg.Fchown = function(fd, uid, gid) { - var err = $ifaceNil, _tuple, e1; - _tuple = Syscall(123, (fd >>> 0), (uid >>> 0), (gid >>> 0)); e1 = _tuple[2]; - if (!((e1 === 0))) { - err = new Errno(e1); + exp = exp - (1) >> 0; + if (exp < (flt.bias + 1 >> 0)) { + n$2 = (flt.bias + 1 >> 0) - exp >> 0; + d.Shift(-n$2); + exp = exp + (n$2) >> 0; } - return err; - }; - Fstat = $pkg.Fstat = function(fd, stat) { - var err = $ifaceNil, _tuple, _array, _struct, _view, e1; - _array = new Uint8Array(144); - _tuple = Syscall(339, (fd >>> 0), _array, 0); e1 = _tuple[2]; - _struct = stat, _view = new DataView(_array.buffer, _array.byteOffset), _struct.Dev = _view.getInt32(0, true), _struct.Mode = _view.getUint16(4, true), _struct.Nlink = _view.getUint16(6, true), _struct.Ino = new $Uint64(_view.getUint32(12, true), _view.getUint32(8, true)), _struct.Uid = _view.getUint32(16, true), _struct.Gid = _view.getUint32(20, true), _struct.Rdev = _view.getInt32(24, true), _struct.Pad_cgo_0 = new ($nativeArray("Uint8"))(_array.buffer, $min(_array.byteOffset + 28, _array.buffer.byteLength)), _struct.Atimespec.Sec = new $Int64(_view.getUint32(36, true), _view.getUint32(32, true)), _struct.Atimespec.Nsec = new $Int64(_view.getUint32(44, true), _view.getUint32(40, true)), _struct.Mtimespec.Sec = new $Int64(_view.getUint32(52, true), _view.getUint32(48, true)), _struct.Mtimespec.Nsec = new $Int64(_view.getUint32(60, true), _view.getUint32(56, true)), _struct.Ctimespec.Sec = new $Int64(_view.getUint32(68, true), _view.getUint32(64, true)), _struct.Ctimespec.Nsec = new $Int64(_view.getUint32(76, true), _view.getUint32(72, true)), _struct.Birthtimespec.Sec = new $Int64(_view.getUint32(84, true), _view.getUint32(80, true)), _struct.Birthtimespec.Nsec = new $Int64(_view.getUint32(92, true), _view.getUint32(88, true)), _struct.Size = new $Int64(_view.getUint32(100, true), _view.getUint32(96, true)), _struct.Blocks = new $Int64(_view.getUint32(108, true), _view.getUint32(104, true)), _struct.Blksize = _view.getInt32(112, true), _struct.Flags = _view.getUint32(116, true), _struct.Gen = _view.getUint32(120, true), _struct.Lspare = _view.getInt32(124, true), _struct.Qspare = new ($nativeArray("Int64"))(_array.buffer, $min(_array.byteOffset + 128, _array.buffer.byteLength)); - if (!((e1 === 0))) { - err = new Errno(e1); + /* if ((exp - flt.bias >> 0) >= (((y = flt.expbits, y < 32 ? (1 << y) : 0) >> 0) - 1 >> 0)) { */ if ((exp - flt.bias >> 0) >= (((y = flt.expbits, y < 32 ? (1 << y) : 0) >> 0) - 1 >> 0)) {} else { $s = 6; continue; } + /* goto overflow */ $s = 2; continue; + /* } */ case 6: + d.Shift(((1 + flt.mantbits >>> 0) >> 0)); + mant = d.RoundedInteger(); + /* if ((x$2 = $shiftLeft64(new $Uint64(0, 2), flt.mantbits), (mant.$high === x$2.$high && mant.$low === x$2.$low))) { */ if ((x$2 = $shiftLeft64(new $Uint64(0, 2), flt.mantbits), (mant.$high === x$2.$high && mant.$low === x$2.$low))) {} else { $s = 7; continue; } + mant = $shiftRightUint64(mant, (1)); + exp = exp + (1) >> 0; + /* if ((exp - flt.bias >> 0) >= (((y$1 = flt.expbits, y$1 < 32 ? (1 << y$1) : 0) >> 0) - 1 >> 0)) { */ if ((exp - flt.bias >> 0) >= (((y$1 = flt.expbits, y$1 < 32 ? (1 << y$1) : 0) >> 0) - 1 >> 0)) {} else { $s = 8; continue; } + /* goto overflow */ $s = 2; continue; + /* } */ case 8: + /* } */ case 7: + if ((x$3 = (x$4 = $shiftLeft64(new $Uint64(0, 1), flt.mantbits), new $Uint64(mant.$high & x$4.$high, (mant.$low & x$4.$low) >>> 0)), (x$3.$high === 0 && x$3.$low === 0))) { + exp = flt.bias; } - return err; - }; - Fsync = $pkg.Fsync = function(fd) { - var err = $ifaceNil, _tuple, e1; - _tuple = Syscall(95, (fd >>> 0), 0, 0); e1 = _tuple[2]; - if (!((e1 === 0))) { - err = new Errno(e1); + /* goto out */ $s = 1; continue; + /* overflow: */ case 2: + mant = new $Uint64(0, 0); + exp = (((y$2 = flt.expbits, y$2 < 32 ? (1 << y$2) : 0) >> 0) - 1 >> 0) + flt.bias >> 0; + overflow = true; + /* out: */ case 1: + bits = (x$5 = (x$6 = $shiftLeft64(new $Uint64(0, 1), flt.mantbits), new $Uint64(x$6.$high - 0, x$6.$low - 1)), new $Uint64(mant.$high & x$5.$high, (mant.$low & x$5.$low) >>> 0)); + bits = (x$7 = $shiftLeft64(new $Uint64(0, (((exp - flt.bias >> 0)) & ((((y$3 = flt.expbits, y$3 < 32 ? (1 << y$3) : 0) >> 0) - 1 >> 0)))), flt.mantbits), new $Uint64(bits.$high | x$7.$high, (bits.$low | x$7.$low) >>> 0)); + if (d.neg) { + bits = (x$8 = $shiftLeft64($shiftLeft64(new $Uint64(0, 1), flt.mantbits), flt.expbits), new $Uint64(bits.$high | x$8.$high, (bits.$low | x$8.$low) >>> 0)); } - return err; + _tmp = bits; _tmp$1 = overflow; b = _tmp; overflow = _tmp$1; + return [b, overflow]; + /* */ case -1: } return; } }; - Ftruncate = $pkg.Ftruncate = function(fd, length) { - var err = $ifaceNil, _tuple, e1; - _tuple = Syscall(201, (fd >>> 0), (length.$low >>> 0), 0); e1 = _tuple[2]; - if (!((e1 === 0))) { - err = new Errno(e1); + decimal.prototype.floatBits = function(flt) { return this.$val.floatBits(flt); }; + atof64exact = function(mantissa, exp, neg) { + var f = 0, ok = false, x, _tmp, _tmp$1, x$1, _tmp$2, _tmp$3, _tmp$4, x$2, _tmp$5; + if (!((x = $shiftRightUint64(mantissa, float64info.mantbits), (x.$high === 0 && x.$low === 0)))) { + return [f, ok]; } - return err; - }; - Getdirentries = $pkg.Getdirentries = function(fd, buf, basep) { - var n = 0, err = $ifaceNil, _p0, _tuple, r0, e1; - _p0 = 0; - if (buf.$length > 0) { - _p0 = $sliceToArray(buf); - } else { - _p0 = new Uint8Array(0); + f = $flatten64(mantissa); + if (neg) { + f = -f; } - _tuple = Syscall6(344, (fd >>> 0), _p0, (buf.$length >>> 0), basep, 0, 0); r0 = _tuple[0]; e1 = _tuple[2]; - n = (r0 >> 0); - if (!((e1 === 0))) { - err = new Errno(e1); + if (exp === 0) { + _tmp = f; _tmp$1 = true; f = _tmp; ok = _tmp$1; + return [f, ok]; + } else if (exp > 0 && exp <= 37) { + if (exp > 22) { + f = f * ((x$1 = exp - 22 >> 0, ((x$1 < 0 || x$1 >= float64pow10.$length) ? $throwRuntimeError("index out of range") : float64pow10.$array[float64pow10.$offset + x$1]))); + exp = 22; + } + if (f > 1e+15 || f < -1e+15) { + return [f, ok]; + } + _tmp$2 = f * ((exp < 0 || exp >= float64pow10.$length) ? $throwRuntimeError("index out of range") : float64pow10.$array[float64pow10.$offset + exp]); _tmp$3 = true; f = _tmp$2; ok = _tmp$3; + return [f, ok]; + } else if (exp < 0 && exp >= -22) { + _tmp$4 = f / (x$2 = -exp, ((x$2 < 0 || x$2 >= float64pow10.$length) ? $throwRuntimeError("index out of range") : float64pow10.$array[float64pow10.$offset + x$2])); _tmp$5 = true; f = _tmp$4; ok = _tmp$5; + return [f, ok]; } - return [n, err]; + return [f, ok]; }; - Lstat = $pkg.Lstat = function(path, stat) { - var err = $ifaceNil, _p0, _tuple, _tuple$1, _array, _struct, _view, e1; - _p0 = ($ptrType($Uint8)).nil; - _tuple = BytePtrFromString(path); _p0 = _tuple[0]; err = _tuple[1]; - if (!($interfaceIsEqual(err, $ifaceNil))) { - return err; - } - _array = new Uint8Array(144); - _tuple$1 = Syscall(340, _p0, _array, 0); e1 = _tuple$1[2]; - _struct = stat, _view = new DataView(_array.buffer, _array.byteOffset), _struct.Dev = _view.getInt32(0, true), _struct.Mode = _view.getUint16(4, true), _struct.Nlink = _view.getUint16(6, true), _struct.Ino = new $Uint64(_view.getUint32(12, true), _view.getUint32(8, true)), _struct.Uid = _view.getUint32(16, true), _struct.Gid = _view.getUint32(20, true), _struct.Rdev = _view.getInt32(24, true), _struct.Pad_cgo_0 = new ($nativeArray("Uint8"))(_array.buffer, $min(_array.byteOffset + 28, _array.buffer.byteLength)), _struct.Atimespec.Sec = new $Int64(_view.getUint32(36, true), _view.getUint32(32, true)), _struct.Atimespec.Nsec = new $Int64(_view.getUint32(44, true), _view.getUint32(40, true)), _struct.Mtimespec.Sec = new $Int64(_view.getUint32(52, true), _view.getUint32(48, true)), _struct.Mtimespec.Nsec = new $Int64(_view.getUint32(60, true), _view.getUint32(56, true)), _struct.Ctimespec.Sec = new $Int64(_view.getUint32(68, true), _view.getUint32(64, true)), _struct.Ctimespec.Nsec = new $Int64(_view.getUint32(76, true), _view.getUint32(72, true)), _struct.Birthtimespec.Sec = new $Int64(_view.getUint32(84, true), _view.getUint32(80, true)), _struct.Birthtimespec.Nsec = new $Int64(_view.getUint32(92, true), _view.getUint32(88, true)), _struct.Size = new $Int64(_view.getUint32(100, true), _view.getUint32(96, true)), _struct.Blocks = new $Int64(_view.getUint32(108, true), _view.getUint32(104, true)), _struct.Blksize = _view.getInt32(112, true), _struct.Flags = _view.getUint32(116, true), _struct.Gen = _view.getUint32(120, true), _struct.Lspare = _view.getInt32(124, true), _struct.Qspare = new ($nativeArray("Int64"))(_array.buffer, $min(_array.byteOffset + 128, _array.buffer.byteLength)); - if (!((e1 === 0))) { - err = new Errno(e1); + atof32exact = function(mantissa, exp, neg) { + var f = 0, ok = false, x, _tmp, _tmp$1, x$1, _tmp$2, _tmp$3, _tmp$4, x$2, _tmp$5; + if (!((x = $shiftRightUint64(mantissa, float32info.mantbits), (x.$high === 0 && x.$low === 0)))) { + return [f, ok]; } - return err; - }; - Open = $pkg.Open = function(path, mode, perm) { - var fd = 0, err = $ifaceNil, _p0, _tuple, _tuple$1, r0, e1; - _p0 = ($ptrType($Uint8)).nil; - _tuple = BytePtrFromString(path); _p0 = _tuple[0]; err = _tuple[1]; - if (!($interfaceIsEqual(err, $ifaceNil))) { - return [fd, err]; + f = $flatten64(mantissa); + if (neg) { + f = -f; } - _tuple$1 = Syscall(5, _p0, (mode >>> 0), (perm >>> 0)); r0 = _tuple$1[0]; e1 = _tuple$1[2]; - fd = (r0 >> 0); - if (!((e1 === 0))) { - err = new Errno(e1); + if (exp === 0) { + _tmp = f; _tmp$1 = true; f = _tmp; ok = _tmp$1; + return [f, ok]; + } else if (exp > 0 && exp <= 17) { + if (exp > 10) { + f = f * ((x$1 = exp - 10 >> 0, ((x$1 < 0 || x$1 >= float32pow10.$length) ? $throwRuntimeError("index out of range") : float32pow10.$array[float32pow10.$offset + x$1]))); + exp = 10; + } + if (f > 1e+07 || f < -1e+07) { + return [f, ok]; + } + _tmp$2 = f * ((exp < 0 || exp >= float32pow10.$length) ? $throwRuntimeError("index out of range") : float32pow10.$array[float32pow10.$offset + exp]); _tmp$3 = true; f = _tmp$2; ok = _tmp$3; + return [f, ok]; + } else if (exp < 0 && exp >= -10) { + _tmp$4 = f / (x$2 = -exp, ((x$2 < 0 || x$2 >= float32pow10.$length) ? $throwRuntimeError("index out of range") : float32pow10.$array[float32pow10.$offset + x$2])); _tmp$5 = true; f = _tmp$4; ok = _tmp$5; + return [f, ok]; } - return [fd, err]; + return [f, ok]; }; - Pread = $pkg.Pread = function(fd, p, offset) { - var n = 0, err = $ifaceNil, _p0, _tuple, r0, e1; - _p0 = 0; - if (p.$length > 0) { - _p0 = $sliceToArray(p); - } else { - _p0 = new Uint8Array(0); + atof32 = function(s) { + var f = 0, err = $ifaceNil, _tuple, val, ok, _tmp, _tmp$1, _tuple$1, mantissa, exp, neg, trunc, ok$1, _tuple$2, f$1, ok$2, _tmp$2, _tmp$3, ext, ok$3, _tuple$3, b, ovf, _tmp$4, _tmp$5, d, _tmp$6, _tmp$7, _tuple$4, b$1, ovf$1, _tmp$8, _tmp$9; + _tuple = special(s); val = _tuple[0]; ok = _tuple[1]; + if (ok) { + _tmp = val; _tmp$1 = $ifaceNil; f = _tmp; err = _tmp$1; + return [f, err]; } - _tuple = Syscall6(153, (fd >>> 0), _p0, (p.$length >>> 0), (offset.$low >>> 0), 0, 0); r0 = _tuple[0]; e1 = _tuple[2]; - n = (r0 >> 0); - if (!((e1 === 0))) { - err = new Errno(e1); + if (optimize) { + _tuple$1 = readFloat(s); mantissa = _tuple$1[0]; exp = _tuple$1[1]; neg = _tuple$1[2]; trunc = _tuple$1[3]; ok$1 = _tuple$1[4]; + if (ok$1) { + if (!trunc) { + _tuple$2 = atof32exact(mantissa, exp, neg); f$1 = _tuple$2[0]; ok$2 = _tuple$2[1]; + if (ok$2) { + _tmp$2 = f$1; _tmp$3 = $ifaceNil; f = _tmp$2; err = _tmp$3; + return [f, err]; + } + } + ext = new extFloat.Ptr(); + ok$3 = ext.AssignDecimal(mantissa, exp, neg, trunc, float32info); + if (ok$3) { + _tuple$3 = ext.floatBits(float32info); b = _tuple$3[0]; ovf = _tuple$3[1]; + f = math.Float32frombits((b.$low >>> 0)); + if (ovf) { + err = rangeError("ParseFloat", s); + } + _tmp$4 = f; _tmp$5 = err; f = _tmp$4; err = _tmp$5; + return [f, err]; + } + } } - return [n, err]; - }; - Pwrite = $pkg.Pwrite = function(fd, p, offset) { - var n = 0, err = $ifaceNil, _p0, _tuple, r0, e1; - _p0 = 0; - if (p.$length > 0) { - _p0 = $sliceToArray(p); - } else { - _p0 = new Uint8Array(0); + d = new decimal.Ptr(); $copy(d, new decimal.Ptr(), decimal); + if (!d.set(s)) { + _tmp$6 = 0; _tmp$7 = syntaxError("ParseFloat", s); f = _tmp$6; err = _tmp$7; + return [f, err]; } - _tuple = Syscall6(154, (fd >>> 0), _p0, (p.$length >>> 0), (offset.$low >>> 0), 0, 0); r0 = _tuple[0]; e1 = _tuple[2]; - n = (r0 >> 0); - if (!((e1 === 0))) { - err = new Errno(e1); + _tuple$4 = d.floatBits(float32info); b$1 = _tuple$4[0]; ovf$1 = _tuple$4[1]; + f = math.Float32frombits((b$1.$low >>> 0)); + if (ovf$1) { + err = rangeError("ParseFloat", s); } - return [n, err]; + _tmp$8 = f; _tmp$9 = err; f = _tmp$8; err = _tmp$9; + return [f, err]; }; - read = function(fd, p) { - var n = 0, err = $ifaceNil, _p0, _tuple, r0, e1; - _p0 = 0; - if (p.$length > 0) { - _p0 = $sliceToArray(p); - } else { - _p0 = new Uint8Array(0); - } - _tuple = Syscall(3, (fd >>> 0), _p0, (p.$length >>> 0)); r0 = _tuple[0]; e1 = _tuple[2]; - n = (r0 >> 0); - if (!((e1 === 0))) { - err = new Errno(e1); + atof64 = function(s) { + var f = 0, err = $ifaceNil, _tuple, val, ok, _tmp, _tmp$1, _tuple$1, mantissa, exp, neg, trunc, ok$1, _tuple$2, f$1, ok$2, _tmp$2, _tmp$3, ext, ok$3, _tuple$3, b, ovf, _tmp$4, _tmp$5, d, _tmp$6, _tmp$7, _tuple$4, b$1, ovf$1, _tmp$8, _tmp$9; + _tuple = special(s); val = _tuple[0]; ok = _tuple[1]; + if (ok) { + _tmp = val; _tmp$1 = $ifaceNil; f = _tmp; err = _tmp$1; + return [f, err]; } - return [n, err]; - }; - Readlink = $pkg.Readlink = function(path, buf) { - var n = 0, err = $ifaceNil, _p0, _tuple, _p1, _tuple$1, r0, e1; - _p0 = ($ptrType($Uint8)).nil; - _tuple = BytePtrFromString(path); _p0 = _tuple[0]; err = _tuple[1]; - if (!($interfaceIsEqual(err, $ifaceNil))) { - return [n, err]; + if (optimize) { + _tuple$1 = readFloat(s); mantissa = _tuple$1[0]; exp = _tuple$1[1]; neg = _tuple$1[2]; trunc = _tuple$1[3]; ok$1 = _tuple$1[4]; + if (ok$1) { + if (!trunc) { + _tuple$2 = atof64exact(mantissa, exp, neg); f$1 = _tuple$2[0]; ok$2 = _tuple$2[1]; + if (ok$2) { + _tmp$2 = f$1; _tmp$3 = $ifaceNil; f = _tmp$2; err = _tmp$3; + return [f, err]; + } + } + ext = new extFloat.Ptr(); + ok$3 = ext.AssignDecimal(mantissa, exp, neg, trunc, float64info); + if (ok$3) { + _tuple$3 = ext.floatBits(float64info); b = _tuple$3[0]; ovf = _tuple$3[1]; + f = math.Float64frombits(b); + if (ovf) { + err = rangeError("ParseFloat", s); + } + _tmp$4 = f; _tmp$5 = err; f = _tmp$4; err = _tmp$5; + return [f, err]; + } + } } - _p1 = 0; - if (buf.$length > 0) { - _p1 = $sliceToArray(buf); - } else { - _p1 = new Uint8Array(0); + d = new decimal.Ptr(); $copy(d, new decimal.Ptr(), decimal); + if (!d.set(s)) { + _tmp$6 = 0; _tmp$7 = syntaxError("ParseFloat", s); f = _tmp$6; err = _tmp$7; + return [f, err]; } - _tuple$1 = Syscall(58, _p0, _p1, (buf.$length >>> 0)); r0 = _tuple$1[0]; e1 = _tuple$1[2]; - n = (r0 >> 0); - if (!((e1 === 0))) { - err = new Errno(e1); + _tuple$4 = d.floatBits(float64info); b$1 = _tuple$4[0]; ovf$1 = _tuple$4[1]; + f = math.Float64frombits(b$1); + if (ovf$1) { + err = rangeError("ParseFloat", s); } - return [n, err]; + _tmp$8 = f; _tmp$9 = err; f = _tmp$8; err = _tmp$9; + return [f, err]; }; - Seek = $pkg.Seek = function(fd, offset, whence) { - var newoffset = new $Int64(0, 0), err = $ifaceNil, _tuple, r0, e1; - _tuple = Syscall(199, (fd >>> 0), (offset.$low >>> 0), (whence >>> 0)); r0 = _tuple[0]; e1 = _tuple[2]; - newoffset = new $Int64(0, r0.constructor === Number ? r0 : 1); - if (!((e1 === 0))) { - err = new Errno(e1); + ParseFloat = $pkg.ParseFloat = function(s, bitSize) { + var f = 0, err = $ifaceNil, _tuple, f1, err1, _tmp, _tmp$1, _tuple$1, f1$1, err1$1, _tmp$2, _tmp$3; + if (bitSize === 32) { + _tuple = atof32(s); f1 = _tuple[0]; err1 = _tuple[1]; + _tmp = $coerceFloat32(f1); _tmp$1 = err1; f = _tmp; err = _tmp$1; + return [f, err]; } - return [newoffset, err]; + _tuple$1 = atof64(s); f1$1 = _tuple$1[0]; err1$1 = _tuple$1[1]; + _tmp$2 = f1$1; _tmp$3 = err1$1; f = _tmp$2; err = _tmp$3; + return [f, err]; }; - Stat = $pkg.Stat = function(path, stat) { - var err = $ifaceNil, _p0, _tuple, _tuple$1, _array, _struct, _view, e1; - _p0 = ($ptrType($Uint8)).nil; - _tuple = BytePtrFromString(path); _p0 = _tuple[0]; err = _tuple[1]; - if (!($interfaceIsEqual(err, $ifaceNil))) { - return err; - } - _array = new Uint8Array(144); - _tuple$1 = Syscall(338, _p0, _array, 0); e1 = _tuple$1[2]; - _struct = stat, _view = new DataView(_array.buffer, _array.byteOffset), _struct.Dev = _view.getInt32(0, true), _struct.Mode = _view.getUint16(4, true), _struct.Nlink = _view.getUint16(6, true), _struct.Ino = new $Uint64(_view.getUint32(12, true), _view.getUint32(8, true)), _struct.Uid = _view.getUint32(16, true), _struct.Gid = _view.getUint32(20, true), _struct.Rdev = _view.getInt32(24, true), _struct.Pad_cgo_0 = new ($nativeArray("Uint8"))(_array.buffer, $min(_array.byteOffset + 28, _array.buffer.byteLength)), _struct.Atimespec.Sec = new $Int64(_view.getUint32(36, true), _view.getUint32(32, true)), _struct.Atimespec.Nsec = new $Int64(_view.getUint32(44, true), _view.getUint32(40, true)), _struct.Mtimespec.Sec = new $Int64(_view.getUint32(52, true), _view.getUint32(48, true)), _struct.Mtimespec.Nsec = new $Int64(_view.getUint32(60, true), _view.getUint32(56, true)), _struct.Ctimespec.Sec = new $Int64(_view.getUint32(68, true), _view.getUint32(64, true)), _struct.Ctimespec.Nsec = new $Int64(_view.getUint32(76, true), _view.getUint32(72, true)), _struct.Birthtimespec.Sec = new $Int64(_view.getUint32(84, true), _view.getUint32(80, true)), _struct.Birthtimespec.Nsec = new $Int64(_view.getUint32(92, true), _view.getUint32(88, true)), _struct.Size = new $Int64(_view.getUint32(100, true), _view.getUint32(96, true)), _struct.Blocks = new $Int64(_view.getUint32(108, true), _view.getUint32(104, true)), _struct.Blksize = _view.getInt32(112, true), _struct.Flags = _view.getUint32(116, true), _struct.Gen = _view.getUint32(120, true), _struct.Lspare = _view.getInt32(124, true), _struct.Qspare = new ($nativeArray("Int64"))(_array.buffer, $min(_array.byteOffset + 128, _array.buffer.byteLength)); - if (!((e1 === 0))) { - err = new Errno(e1); - } - return err; + NumError.Ptr.prototype.Error = function() { + var e; + e = this; + return "strconv." + e.Func + ": " + "parsing " + Quote(e.Num) + ": " + e.Err.Error(); }; - write = function(fd, p) { - var n = 0, err = $ifaceNil, _p0, _tuple, r0, e1; - _p0 = 0; - if (p.$length > 0) { - _p0 = $sliceToArray(p); - } else { - _p0 = new Uint8Array(0); - } - _tuple = Syscall(4, (fd >>> 0), _p0, (p.$length >>> 0)); r0 = _tuple[0]; e1 = _tuple[2]; - n = (r0 >> 0); - if (!((e1 === 0))) { - err = new Errno(e1); - } - return [n, err]; + NumError.prototype.Error = function() { return this.$val.Error(); }; + syntaxError = function(fn, str) { + return new NumError.Ptr(fn, str, $pkg.ErrSyntax); }; - mmap = function(addr, length, prot, flag, fd, pos) { - var ret = 0, err = $ifaceNil, _tuple, r0, e1; - _tuple = Syscall6(197, addr, length, (prot >>> 0), (flag >>> 0), (fd >>> 0), (pos.$low >>> 0)); r0 = _tuple[0]; e1 = _tuple[2]; - ret = r0; - if (!((e1 === 0))) { - err = new Errno(e1); - } - return [ret, err]; + rangeError = function(fn, str) { + return new NumError.Ptr(fn, str, $pkg.ErrRange); }; - munmap = function(addr, length) { - var err = $ifaceNil, _tuple, e1; - _tuple = Syscall(73, addr, length, 0); e1 = _tuple[2]; - if (!((e1 === 0))) { - err = new Errno(e1); + cutoff64 = function(base) { + var x; + if (base < 2) { + return new $Uint64(0, 0); } - return err; - }; - $pkg.$init = function() { - attrList.init([["bitmapCount", "bitmapCount", "syscall", $Uint16, ""], ["_$1", "_", "syscall", $Uint16, ""], ["CommonAttr", "CommonAttr", "", $Uint32, ""], ["VolAttr", "VolAttr", "", $Uint32, ""], ["DirAttr", "DirAttr", "", $Uint32, ""], ["FileAttr", "FileAttr", "", $Uint32, ""], ["Forkattr", "Forkattr", "", $Uint32, ""]]); - ($ptrType(mmapper)).methods = [["Lock", "Lock", "", $funcType([], [], false), 0], ["Mmap", "Mmap", "", $funcType([$Int, $Int64, $Int, $Int, $Int], [($sliceType($Uint8)), $error], false), -1], ["Munmap", "Munmap", "", $funcType([($sliceType($Uint8))], [$error], false), -1], ["Unlock", "Unlock", "", $funcType([], [], false), 0]]; - mmapper.init([["Mutex", "", "", sync.Mutex, ""], ["active", "active", "syscall", ($mapType(($ptrType($Uint8)), ($sliceType($Uint8)))), ""], ["mmap", "mmap", "syscall", ($funcType([$Uintptr, $Uintptr, $Int, $Int, $Int, $Int64], [$Uintptr, $error], false)), ""], ["munmap", "munmap", "syscall", ($funcType([$Uintptr, $Uintptr], [$error], false)), ""]]); - Errno.methods = [["Error", "Error", "", $funcType([], [$String], false), -1], ["Temporary", "Temporary", "", $funcType([], [$Bool], false), -1], ["Timeout", "Timeout", "", $funcType([], [$Bool], false), -1]]; - ($ptrType(Errno)).methods = [["Error", "Error", "", $funcType([], [$String], false), -1], ["Temporary", "Temporary", "", $funcType([], [$Bool], false), -1], ["Timeout", "Timeout", "", $funcType([], [$Bool], false), -1]]; - ($ptrType(Timespec)).methods = [["Nano", "Nano", "", $funcType([], [$Int64], false), -1], ["Unix", "Unix", "", $funcType([], [$Int64, $Int64], false), -1]]; - Timespec.init([["Sec", "Sec", "", $Int64, ""], ["Nsec", "Nsec", "", $Int64, ""]]); - Stat_t.init([["Dev", "Dev", "", $Int32, ""], ["Mode", "Mode", "", $Uint16, ""], ["Nlink", "Nlink", "", $Uint16, ""], ["Ino", "Ino", "", $Uint64, ""], ["Uid", "Uid", "", $Uint32, ""], ["Gid", "Gid", "", $Uint32, ""], ["Rdev", "Rdev", "", $Int32, ""], ["Pad_cgo_0", "Pad_cgo_0", "", ($arrayType($Uint8, 4)), ""], ["Atimespec", "Atimespec", "", Timespec, ""], ["Mtimespec", "Mtimespec", "", Timespec, ""], ["Ctimespec", "Ctimespec", "", Timespec, ""], ["Birthtimespec", "Birthtimespec", "", Timespec, ""], ["Size", "Size", "", $Int64, ""], ["Blocks", "Blocks", "", $Int64, ""], ["Blksize", "Blksize", "", $Int32, ""], ["Flags", "Flags", "", $Uint32, ""], ["Gen", "Gen", "", $Uint32, ""], ["Lspare", "Lspare", "", $Int32, ""], ["Qspare", "Qspare", "", ($arrayType($Int64, 2)), ""]]); - Dirent.init([["Ino", "Ino", "", $Uint64, ""], ["Seekoff", "Seekoff", "", $Uint64, ""], ["Reclen", "Reclen", "", $Uint16, ""], ["Namlen", "Namlen", "", $Uint16, ""], ["Type", "Type", "", $Uint8, ""], ["Name", "Name", "", ($arrayType($Int8, 1024)), ""], ["Pad_cgo_0", "Pad_cgo_0", "", ($arrayType($Uint8, 3)), ""]]); - lineBuffer = ($sliceType($Uint8)).nil; - syscallModule = $ifaceNil; - envOnce = new sync.Once.Ptr(); - envLock = new sync.RWMutex.Ptr(); - env = false; - envs = ($sliceType($String)).nil; - warningPrinted = false; - alreadyTriedToLoad = false; - minusOne = -1; - $pkg.Stdin = 0; - $pkg.Stdout = 1; - $pkg.Stderr = 2; - errors$1 = $toNativeArray("String", ["", "operation not permitted", "no such file or directory", "no such process", "interrupted system call", "input/output error", "device not configured", "argument list too long", "exec format error", "bad file descriptor", "no child processes", "resource deadlock avoided", "cannot allocate memory", "permission denied", "bad address", "block device required", "resource busy", "file exists", "cross-device link", "operation not supported by device", "not a directory", "is a directory", "invalid argument", "too many open files in system", "too many open files", "inappropriate ioctl for device", "text file busy", "file too large", "no space left on device", "illegal seek", "read-only file system", "too many links", "broken pipe", "numerical argument out of domain", "result too large", "resource temporarily unavailable", "operation now in progress", "operation already in progress", "socket operation on non-socket", "destination address required", "message too long", "protocol wrong type for socket", "protocol not available", "protocol not supported", "socket type not supported", "operation not supported", "protocol family not supported", "address family not supported by protocol family", "address already in use", "can't assign requested address", "network is down", "network is unreachable", "network dropped connection on reset", "software caused connection abort", "connection reset by peer", "no buffer space available", "socket is already connected", "socket is not connected", "can't send after socket shutdown", "too many references: can't splice", "operation timed out", "connection refused", "too many levels of symbolic links", "file name too long", "host is down", "no route to host", "directory not empty", "too many processes", "too many users", "disc quota exceeded", "stale NFS file handle", "too many levels of remote in path", "RPC struct is bad", "RPC version wrong", "RPC prog. not avail", "program version wrong", "bad procedure for program", "no locks available", "function not implemented", "inappropriate file type or format", "authentication error", "need authenticator", "device power is off", "device error", "value too large to be stored in data type", "bad executable (or shared library)", "bad CPU type in executable", "shared library version mismatch", "malformed Mach-o file", "operation canceled", "identifier removed", "no message of desired type", "illegal byte sequence", "attribute not found", "bad message", "EMULTIHOP (Reserved)", "no message available on STREAM", "ENOLINK (Reserved)", "no STREAM resources", "not a STREAM", "protocol error", "STREAM ioctl timeout", "operation not supported on socket", "policy not found", "state not recoverable", "previous owner died"]); - mapper = new mmapper.Ptr(new sync.Mutex.Ptr(), new $Map(), mmap, munmap); - init(); - }; - return $pkg; -})(); -$packages["strings"] = (function() { - var $pkg = {}, js = $packages["github.com/gopherjs/gopherjs/js"], errors = $packages["errors"], io = $packages["io"], utf8 = $packages["unicode/utf8"], unicode = $packages["unicode"], Reader, IndexByte, NewReader, explode, hashstr, Count, Contains, ContainsRune, Index, LastIndex, IndexRune, IndexAny, genSplit, Split, Fields, FieldsFunc, Join, HasPrefix, HasSuffix, Map, Repeat, ToUpper, ToLower, TrimLeftFunc, TrimRightFunc, TrimFunc, IndexFunc, indexFunc, lastIndexFunc, TrimSpace, TrimSuffix, Replace; - Reader = $pkg.Reader = $newType(0, "Struct", "strings.Reader", "Reader", "strings", function(s_, i_, prevRune_) { - this.$val = this; - this.s = s_ !== undefined ? s_ : ""; - this.i = i_ !== undefined ? i_ : new $Int64(0, 0); - this.prevRune = prevRune_ !== undefined ? prevRune_ : 0; - }); - IndexByte = $pkg.IndexByte = function(s, c) { - return $parseInt(s.indexOf($global.String.fromCharCode(c))) >> 0; + return (x = $div64(new $Uint64(4294967295, 4294967295), new $Uint64(0, base), false), new $Uint64(x.$high + 0, x.$low + 1)); }; - Reader.Ptr.prototype.Len = function() { - var r, x, x$1, x$2, x$3, x$4; - r = this; - if ((x = r.i, x$1 = new $Int64(0, r.s.length), (x.$high > x$1.$high || (x.$high === x$1.$high && x.$low >= x$1.$low)))) { - return 0; + ParseUint = $pkg.ParseUint = function(s, base, bitSize) { + var $this = this, $args = arguments, n = new $Uint64(0, 0), err = $ifaceNil, $s = 0, _tmp, _tmp$1, cutoff, maxVal, s0, x, i, v, d, x$1, n1, _tmp$2, _tmp$3, _tmp$4, _tmp$5; + /* */ while (true) { switch ($s) { case 0: + _tmp = new $Uint64(0, 0); _tmp$1 = new $Uint64(0, 0); cutoff = _tmp; maxVal = _tmp$1; + if (bitSize === 0) { + bitSize = 32; } - return ((x$2 = (x$3 = new $Int64(0, r.s.length), x$4 = r.i, new $Int64(x$3.$high - x$4.$high, x$3.$low - x$4.$low)), x$2.$low + ((x$2.$high >> 31) * 4294967296)) >> 0); + s0 = s; + /* if (s.length < 1) { */ if (s.length < 1) {} else if (2 <= base && base <= 36) { $s = 2; continue; } else if (base === 0) { $s = 3; continue; } else { $s = 4; continue; } + err = $pkg.ErrSyntax; + /* goto Error */ $s = 1; continue; + /* } else if (2 <= base && base <= 36) { */ $s = 5; continue; case 2: + /* } else if (base === 0) { */ $s = 5; continue; case 3: + /* if ((s.charCodeAt(0) === 48) && s.length > 1 && ((s.charCodeAt(1) === 120) || (s.charCodeAt(1) === 88))) { */ if ((s.charCodeAt(0) === 48) && s.length > 1 && ((s.charCodeAt(1) === 120) || (s.charCodeAt(1) === 88))) {} else if (s.charCodeAt(0) === 48) { $s = 6; continue; } else { $s = 7; continue; } + base = 16; + s = s.substring(2); + /* if (s.length < 1) { */ if (s.length < 1) {} else { $s = 9; continue; } + err = $pkg.ErrSyntax; + /* goto Error */ $s = 1; continue; + /* } */ case 9: + /* } else if (s.charCodeAt(0) === 48) { */ $s = 8; continue; case 6: + base = 8; + /* } else { */ $s = 8; continue; case 7: + base = 10; + /* } */ case 8: + /* } else { */ $s = 5; continue; case 4: + err = errors.New("invalid base " + Itoa(base)); + /* goto Error */ $s = 1; continue; + /* } */ case 5: + n = new $Uint64(0, 0); + cutoff = cutoff64(base); + maxVal = (x = $shiftLeft64(new $Uint64(0, 1), (bitSize >>> 0)), new $Uint64(x.$high - 0, x.$low - 1)); + i = 0; + /* while (i < s.length) { */ case 10: if(!(i < s.length)) { $s = 11; continue; } + v = 0; + d = s.charCodeAt(i); + /* if (48 <= d && d <= 57) { */ if (48 <= d && d <= 57) {} else if (97 <= d && d <= 122) { $s = 12; continue; } else if (65 <= d && d <= 90) { $s = 13; continue; } else { $s = 14; continue; } + v = d - 48 << 24 >>> 24; + /* } else if (97 <= d && d <= 122) { */ $s = 15; continue; case 12: + v = (d - 97 << 24 >>> 24) + 10 << 24 >>> 24; + /* } else if (65 <= d && d <= 90) { */ $s = 15; continue; case 13: + v = (d - 65 << 24 >>> 24) + 10 << 24 >>> 24; + /* } else { */ $s = 15; continue; case 14: + n = new $Uint64(0, 0); + err = $pkg.ErrSyntax; + /* goto Error */ $s = 1; continue; + /* } */ case 15: + /* if ((v >> 0) >= base) { */ if ((v >> 0) >= base) {} else { $s = 16; continue; } + n = new $Uint64(0, 0); + err = $pkg.ErrSyntax; + /* goto Error */ $s = 1; continue; + /* } */ case 16: + /* if ((n.$high > cutoff.$high || (n.$high === cutoff.$high && n.$low >= cutoff.$low))) { */ if ((n.$high > cutoff.$high || (n.$high === cutoff.$high && n.$low >= cutoff.$low))) {} else { $s = 17; continue; } + n = new $Uint64(4294967295, 4294967295); + err = $pkg.ErrRange; + /* goto Error */ $s = 1; continue; + /* } */ case 17: + n = $mul64(n, (new $Uint64(0, base))); + n1 = (x$1 = new $Uint64(0, v), new $Uint64(n.$high + x$1.$high, n.$low + x$1.$low)); + /* if ((n1.$high < n.$high || (n1.$high === n.$high && n1.$low < n.$low)) || (n1.$high > maxVal.$high || (n1.$high === maxVal.$high && n1.$low > maxVal.$low))) { */ if ((n1.$high < n.$high || (n1.$high === n.$high && n1.$low < n.$low)) || (n1.$high > maxVal.$high || (n1.$high === maxVal.$high && n1.$low > maxVal.$low))) {} else { $s = 18; continue; } + n = new $Uint64(4294967295, 4294967295); + err = $pkg.ErrRange; + /* goto Error */ $s = 1; continue; + /* } */ case 18: + n = n1; + i = i + (1) >> 0; + /* } */ $s = 10; continue; case 11: + _tmp$2 = n; _tmp$3 = $ifaceNil; n = _tmp$2; err = _tmp$3; + return [n, err]; + /* Error: */ case 1: + _tmp$4 = n; _tmp$5 = new NumError.Ptr("ParseUint", s0, err); n = _tmp$4; err = _tmp$5; + return [n, err]; + /* */ case -1: } return; } }; - Reader.prototype.Len = function() { return this.$val.Len(); }; - Reader.Ptr.prototype.Read = function(b) { - var n = 0, err = $ifaceNil, r, _tmp, _tmp$1, x, x$1, _tmp$2, _tmp$3, x$2, x$3; - r = this; - if (b.$length === 0) { - _tmp = 0; _tmp$1 = $ifaceNil; n = _tmp; err = _tmp$1; - return [n, err]; + ParseInt = $pkg.ParseInt = function(s, base, bitSize) { + var i = new $Int64(0, 0), err = $ifaceNil, _tmp, _tmp$1, s0, neg, un, _tuple, _tmp$2, _tmp$3, cutoff, _tmp$4, x, _tmp$5, _tmp$6, x$1, _tmp$7, n, _tmp$8, _tmp$9; + if (bitSize === 0) { + bitSize = 32; } - if ((x = r.i, x$1 = new $Int64(0, r.s.length), (x.$high > x$1.$high || (x.$high === x$1.$high && x.$low >= x$1.$low)))) { - _tmp$2 = 0; _tmp$3 = io.EOF; n = _tmp$2; err = _tmp$3; - return [n, err]; + if (s.length === 0) { + _tmp = new $Int64(0, 0); _tmp$1 = syntaxError("ParseInt", s); i = _tmp; err = _tmp$1; + return [i, err]; } - r.prevRune = -1; - n = $copyString(b, r.s.substring($flatten64(r.i))); - r.i = (x$2 = r.i, x$3 = new $Int64(0, n), new $Int64(x$2.$high + x$3.$high, x$2.$low + x$3.$low)); - return [n, err]; - }; - Reader.prototype.Read = function(b) { return this.$val.Read(b); }; - Reader.Ptr.prototype.ReadAt = function(b, off) { - var n = 0, err = $ifaceNil, r, _tmp, _tmp$1, x, _tmp$2, _tmp$3; - r = this; - if ((off.$high < 0 || (off.$high === 0 && off.$low < 0))) { - _tmp = 0; _tmp$1 = errors.New("strings.Reader.ReadAt: negative offset"); n = _tmp; err = _tmp$1; - return [n, err]; + s0 = s; + neg = false; + if (s.charCodeAt(0) === 43) { + s = s.substring(1); + } else if (s.charCodeAt(0) === 45) { + neg = true; + s = s.substring(1); } - if ((x = new $Int64(0, r.s.length), (off.$high > x.$high || (off.$high === x.$high && off.$low >= x.$low)))) { - _tmp$2 = 0; _tmp$3 = io.EOF; n = _tmp$2; err = _tmp$3; - return [n, err]; + un = new $Uint64(0, 0); + _tuple = ParseUint(s, base, bitSize); un = _tuple[0]; err = _tuple[1]; + if (!($interfaceIsEqual(err, $ifaceNil)) && !($interfaceIsEqual($assertType(err, ($ptrType(NumError))).Err, $pkg.ErrRange))) { + $assertType(err, ($ptrType(NumError))).Func = "ParseInt"; + $assertType(err, ($ptrType(NumError))).Num = s0; + _tmp$2 = new $Int64(0, 0); _tmp$3 = err; i = _tmp$2; err = _tmp$3; + return [i, err]; } - n = $copyString(b, r.s.substring($flatten64(off))); - if (n < b.$length) { - err = io.EOF; + cutoff = $shiftLeft64(new $Uint64(0, 1), ((bitSize - 1 >> 0) >>> 0)); + if (!neg && (un.$high > cutoff.$high || (un.$high === cutoff.$high && un.$low >= cutoff.$low))) { + _tmp$4 = (x = new $Uint64(cutoff.$high - 0, cutoff.$low - 1), new $Int64(x.$high, x.$low)); _tmp$5 = rangeError("ParseInt", s0); i = _tmp$4; err = _tmp$5; + return [i, err]; } - return [n, err]; - }; - Reader.prototype.ReadAt = function(b, off) { return this.$val.ReadAt(b, off); }; - Reader.Ptr.prototype.ReadByte = function() { - var b = 0, err = $ifaceNil, r, x, x$1, _tmp, _tmp$1, x$2, x$3; - r = this; - r.prevRune = -1; - if ((x = r.i, x$1 = new $Int64(0, r.s.length), (x.$high > x$1.$high || (x.$high === x$1.$high && x.$low >= x$1.$low)))) { - _tmp = 0; _tmp$1 = io.EOF; b = _tmp; err = _tmp$1; - return [b, err]; + if (neg && (un.$high > cutoff.$high || (un.$high === cutoff.$high && un.$low > cutoff.$low))) { + _tmp$6 = (x$1 = new $Int64(cutoff.$high, cutoff.$low), new $Int64(-x$1.$high, -x$1.$low)); _tmp$7 = rangeError("ParseInt", s0); i = _tmp$6; err = _tmp$7; + return [i, err]; } - b = r.s.charCodeAt($flatten64(r.i)); - r.i = (x$2 = r.i, x$3 = new $Int64(0, 1), new $Int64(x$2.$high + x$3.$high, x$2.$low + x$3.$low)); - return [b, err]; - }; - Reader.prototype.ReadByte = function() { return this.$val.ReadByte(); }; - Reader.Ptr.prototype.UnreadByte = function() { - var r, x, x$1, x$2; - r = this; - r.prevRune = -1; - if ((x = r.i, (x.$high < 0 || (x.$high === 0 && x.$low <= 0)))) { - return errors.New("strings.Reader.UnreadByte: at beginning of string"); + n = new $Int64(un.$high, un.$low); + if (neg) { + n = new $Int64(-n.$high, -n.$low); } - r.i = (x$1 = r.i, x$2 = new $Int64(0, 1), new $Int64(x$1.$high - x$2.$high, x$1.$low - x$2.$low)); - return $ifaceNil; + _tmp$8 = n; _tmp$9 = $ifaceNil; i = _tmp$8; err = _tmp$9; + return [i, err]; }; - Reader.prototype.UnreadByte = function() { return this.$val.UnreadByte(); }; - Reader.Ptr.prototype.ReadRune = function() { - var ch = 0, size = 0, err = $ifaceNil, r, x, x$1, _tmp, _tmp$1, _tmp$2, x$2, c, x$3, x$4, _tmp$3, _tmp$4, _tmp$5, _tuple, x$5, x$6; - r = this; - if ((x = r.i, x$1 = new $Int64(0, r.s.length), (x.$high > x$1.$high || (x.$high === x$1.$high && x.$low >= x$1.$low)))) { - r.prevRune = -1; - _tmp = 0; _tmp$1 = 0; _tmp$2 = io.EOF; ch = _tmp; size = _tmp$1; err = _tmp$2; - return [ch, size, err]; + Atoi = $pkg.Atoi = function(s) { + var i = 0, err = $ifaceNil, _tuple, i64, _tmp, _tmp$1; + _tuple = ParseInt(s, 10, 0); i64 = _tuple[0]; err = _tuple[1]; + _tmp = ((i64.$low + ((i64.$high >> 31) * 4294967296)) >> 0); _tmp$1 = err; i = _tmp; err = _tmp$1; + return [i, err]; + }; + decimal.Ptr.prototype.String = function() { + var a, n, buf, w; + a = this; + n = 10 + a.nd >> 0; + if (a.dp > 0) { + n = n + (a.dp) >> 0; } - r.prevRune = ((x$2 = r.i, x$2.$low + ((x$2.$high >> 31) * 4294967296)) >> 0); - c = r.s.charCodeAt($flatten64(r.i)); - if (c < 128) { - r.i = (x$3 = r.i, x$4 = new $Int64(0, 1), new $Int64(x$3.$high + x$4.$high, x$3.$low + x$4.$low)); - _tmp$3 = (c >> 0); _tmp$4 = 1; _tmp$5 = $ifaceNil; ch = _tmp$3; size = _tmp$4; err = _tmp$5; - return [ch, size, err]; + if (a.dp < 0) { + n = n + (-a.dp) >> 0; } - _tuple = utf8.DecodeRuneInString(r.s.substring($flatten64(r.i))); ch = _tuple[0]; size = _tuple[1]; - r.i = (x$5 = r.i, x$6 = new $Int64(0, size), new $Int64(x$5.$high + x$6.$high, x$5.$low + x$6.$low)); - return [ch, size, err]; + buf = ($sliceType($Uint8)).make(n); + w = 0; + if (a.nd === 0) { + return "0"; + } else if (a.dp <= 0) { + (w < 0 || w >= buf.$length) ? $throwRuntimeError("index out of range") : buf.$array[buf.$offset + w] = 48; + w = w + (1) >> 0; + (w < 0 || w >= buf.$length) ? $throwRuntimeError("index out of range") : buf.$array[buf.$offset + w] = 46; + w = w + (1) >> 0; + w = w + (digitZero($subslice(buf, w, (w + -a.dp >> 0)))) >> 0; + w = w + ($copySlice($subslice(buf, w), $subslice(new ($sliceType($Uint8))(a.d), 0, a.nd))) >> 0; + } else if (a.dp < a.nd) { + w = w + ($copySlice($subslice(buf, w), $subslice(new ($sliceType($Uint8))(a.d), 0, a.dp))) >> 0; + (w < 0 || w >= buf.$length) ? $throwRuntimeError("index out of range") : buf.$array[buf.$offset + w] = 46; + w = w + (1) >> 0; + w = w + ($copySlice($subslice(buf, w), $subslice(new ($sliceType($Uint8))(a.d), a.dp, a.nd))) >> 0; + } else { + w = w + ($copySlice($subslice(buf, w), $subslice(new ($sliceType($Uint8))(a.d), 0, a.nd))) >> 0; + w = w + (digitZero($subslice(buf, w, ((w + a.dp >> 0) - a.nd >> 0)))) >> 0; + } + return $bytesToString($subslice(buf, 0, w)); }; - Reader.prototype.ReadRune = function() { return this.$val.ReadRune(); }; - Reader.Ptr.prototype.UnreadRune = function() { - var r; - r = this; - if (r.prevRune < 0) { - return errors.New("strings.Reader.UnreadRune: previous operation was not ReadRune"); + decimal.prototype.String = function() { return this.$val.String(); }; + digitZero = function(dst) { + var _ref, _i, i; + _ref = dst; + _i = 0; + while (_i < _ref.$length) { + i = _i; + (i < 0 || i >= dst.$length) ? $throwRuntimeError("index out of range") : dst.$array[dst.$offset + i] = 48; + _i++; } - r.i = new $Int64(0, r.prevRune); - r.prevRune = -1; - return $ifaceNil; + return dst.$length; }; - Reader.prototype.UnreadRune = function() { return this.$val.UnreadRune(); }; - Reader.Ptr.prototype.Seek = function(offset, whence) { - var r, abs, _ref, x, x$1; - r = this; - r.prevRune = -1; - abs = new $Int64(0, 0); - _ref = whence; - if (_ref === 0) { - abs = offset; - } else if (_ref === 1) { - abs = (x = r.i, new $Int64(x.$high + offset.$high, x.$low + offset.$low)); - } else if (_ref === 2) { - abs = (x$1 = new $Int64(0, r.s.length), new $Int64(x$1.$high + offset.$high, x$1.$low + offset.$low)); - } else { - return [new $Int64(0, 0), errors.New("strings.Reader.Seek: invalid whence")]; + trim = function(a) { + var x, x$1; + while (a.nd > 0 && ((x = a.d, x$1 = a.nd - 1 >> 0, ((x$1 < 0 || x$1 >= x.length) ? $throwRuntimeError("index out of range") : x[x$1])) === 48)) { + a.nd = a.nd - (1) >> 0; } - if ((abs.$high < 0 || (abs.$high === 0 && abs.$low < 0))) { - return [new $Int64(0, 0), errors.New("strings.Reader.Seek: negative position")]; + if (a.nd === 0) { + a.dp = 0; } - r.i = abs; - return [abs, $ifaceNil]; }; - Reader.prototype.Seek = function(offset, whence) { return this.$val.Seek(offset, whence); }; - Reader.Ptr.prototype.WriteTo = function(w) { - var n = new $Int64(0, 0), err = $ifaceNil, r, x, x$1, _tmp, _tmp$1, s, _tuple, m, x$2, x$3; - r = this; - r.prevRune = -1; - if ((x = r.i, x$1 = new $Int64(0, r.s.length), (x.$high > x$1.$high || (x.$high === x$1.$high && x.$low >= x$1.$low)))) { - _tmp = new $Int64(0, 0); _tmp$1 = $ifaceNil; n = _tmp; err = _tmp$1; - return [n, err]; - } - s = r.s.substring($flatten64(r.i)); - _tuple = io.WriteString(w, s); m = _tuple[0]; err = _tuple[1]; - if (m > s.length) { - $panic(new $String("strings.Reader.WriteTo: invalid WriteString count")); + decimal.Ptr.prototype.Assign = function(v) { + var a, buf, n, v1, x, x$1, x$2; + a = this; + buf = ($arrayType($Uint8, 24)).zero(); $copy(buf, ($arrayType($Uint8, 24)).zero(), ($arrayType($Uint8, 24))); + n = 0; + while ((v.$high > 0 || (v.$high === 0 && v.$low > 0))) { + v1 = $div64(v, new $Uint64(0, 10), false); + v = (x = $mul64(new $Uint64(0, 10), v1), new $Uint64(v.$high - x.$high, v.$low - x.$low)); + (n < 0 || n >= buf.length) ? $throwRuntimeError("index out of range") : buf[n] = (new $Uint64(v.$high + 0, v.$low + 48).$low << 24 >>> 24); + n = n + (1) >> 0; + v = v1; } - r.i = (x$2 = r.i, x$3 = new $Int64(0, m), new $Int64(x$2.$high + x$3.$high, x$2.$low + x$3.$low)); - n = new $Int64(0, m); - if (!((m === s.length)) && $interfaceIsEqual(err, $ifaceNil)) { - err = io.ErrShortWrite; + a.nd = 0; + n = n - (1) >> 0; + while (n >= 0) { + (x$1 = a.d, x$2 = a.nd, (x$2 < 0 || x$2 >= x$1.length) ? $throwRuntimeError("index out of range") : x$1[x$2] = ((n < 0 || n >= buf.length) ? $throwRuntimeError("index out of range") : buf[n])); + a.nd = a.nd + (1) >> 0; + n = n - (1) >> 0; } - return [n, err]; - }; - Reader.prototype.WriteTo = function(w) { return this.$val.WriteTo(w); }; - NewReader = $pkg.NewReader = function(s) { - return new Reader.Ptr(s, new $Int64(0, 0), -1); + a.dp = a.nd; + trim(a); }; - explode = function(s, n) { - var l, a, size, ch, _tmp, _tmp$1, i, cur, _tuple; - if (n === 0) { - return ($sliceType($String)).nil; + decimal.prototype.Assign = function(v) { return this.$val.Assign(v); }; + rightShift = function(a, k) { + var r, w, n, x, c, x$1, c$1, dig, y, x$2, dig$1, y$1, x$3; + r = 0; + w = 0; + n = 0; + while (((n >> $min(k, 31)) >> 0) === 0) { + if (r >= a.nd) { + if (n === 0) { + a.nd = 0; + return; + } + while (((n >> $min(k, 31)) >> 0) === 0) { + n = (((n >>> 16 << 16) * 10 >> 0) + (n << 16 >>> 16) * 10) >> 0; + r = r + (1) >> 0; + } + break; + } + c = ((x = a.d, ((r < 0 || r >= x.length) ? $throwRuntimeError("index out of range") : x[r])) >> 0); + n = (((((n >>> 16 << 16) * 10 >> 0) + (n << 16 >>> 16) * 10) >> 0) + c >> 0) - 48 >> 0; + r = r + (1) >> 0; } - l = utf8.RuneCountInString(s); - if (n <= 0 || n > l) { - n = l; + a.dp = a.dp - ((r - 1 >> 0)) >> 0; + while (r < a.nd) { + c$1 = ((x$1 = a.d, ((r < 0 || r >= x$1.length) ? $throwRuntimeError("index out of range") : x$1[r])) >> 0); + dig = (n >> $min(k, 31)) >> 0; + n = n - (((y = k, y < 32 ? (dig << y) : 0) >> 0)) >> 0; + (x$2 = a.d, (w < 0 || w >= x$2.length) ? $throwRuntimeError("index out of range") : x$2[w] = ((dig + 48 >> 0) << 24 >>> 24)); + w = w + (1) >> 0; + n = (((((n >>> 16 << 16) * 10 >> 0) + (n << 16 >>> 16) * 10) >> 0) + c$1 >> 0) - 48 >> 0; + r = r + (1) >> 0; } - a = ($sliceType($String)).make(n); - size = 0; - ch = 0; - _tmp = 0; _tmp$1 = 0; i = _tmp; cur = _tmp$1; - while ((i + 1 >> 0) < n) { - _tuple = utf8.DecodeRuneInString(s.substring(cur)); ch = _tuple[0]; size = _tuple[1]; - if (ch === 65533) { - (i < 0 || i >= a.$length) ? $throwRuntimeError("index out of range") : a.$array[a.$offset + i] = "\xEF\xBF\xBD"; - } else { - (i < 0 || i >= a.$length) ? $throwRuntimeError("index out of range") : a.$array[a.$offset + i] = s.substring(cur, (cur + size >> 0)); + while (n > 0) { + dig$1 = (n >> $min(k, 31)) >> 0; + n = n - (((y$1 = k, y$1 < 32 ? (dig$1 << y$1) : 0) >> 0)) >> 0; + if (w < 800) { + (x$3 = a.d, (w < 0 || w >= x$3.length) ? $throwRuntimeError("index out of range") : x$3[w] = ((dig$1 + 48 >> 0) << 24 >>> 24)); + w = w + (1) >> 0; + } else if (dig$1 > 0) { + a.trunc = true; } - cur = cur + (size) >> 0; - i = i + (1) >> 0; - } - if (cur < s.length) { - (i < 0 || i >= a.$length) ? $throwRuntimeError("index out of range") : a.$array[a.$offset + i] = s.substring(cur); + n = (((n >>> 16 << 16) * 10 >> 0) + (n << 16 >>> 16) * 10) >> 0; } - return a; + a.nd = w; + trim(a); }; - hashstr = function(sep) { - var hash, i, _tmp, _tmp$1, pow, sq, i$1, x, x$1; - hash = 0; + prefixIsLessThan = function(b, s) { + var i; i = 0; - while (i < sep.length) { - hash = ((((hash >>> 16 << 16) * 16777619 >>> 0) + (hash << 16 >>> 16) * 16777619) >>> 0) + (sep.charCodeAt(i) >>> 0) >>> 0; - i = i + (1) >> 0; - } - _tmp = 1; _tmp$1 = 16777619; pow = _tmp; sq = _tmp$1; - i$1 = sep.length; - while (i$1 > 0) { - if (!(((i$1 & 1) === 0))) { - pow = (x = sq, (((pow >>> 16 << 16) * x >>> 0) + (pow << 16 >>> 16) * x) >>> 0); + while (i < s.length) { + if (i >= b.$length) { + return true; } - sq = (x$1 = sq, (((sq >>> 16 << 16) * x$1 >>> 0) + (sq << 16 >>> 16) * x$1) >>> 0); - i$1 = (i$1 >> $min((1), 31)) >> 0; + if (!((((i < 0 || i >= b.$length) ? $throwRuntimeError("index out of range") : b.$array[b.$offset + i]) === s.charCodeAt(i)))) { + return ((i < 0 || i >= b.$length) ? $throwRuntimeError("index out of range") : b.$array[b.$offset + i]) < s.charCodeAt(i); + } + i = i + (1) >> 0; } - return [hash, pow]; + return false; }; - Count = $pkg.Count = function(s, sep) { - var n, c, i, _tuple, hashsep, pow, h, i$1, lastmatch, i$2, x, x$1; + leftShift = function(a, k) { + var delta, r, w, n, y, x, _q, quo, rem, x$1, _q$1, quo$1, rem$1, x$2; + delta = ((k < 0 || k >= leftcheats.$length) ? $throwRuntimeError("index out of range") : leftcheats.$array[leftcheats.$offset + k]).delta; + if (prefixIsLessThan($subslice(new ($sliceType($Uint8))(a.d), 0, a.nd), ((k < 0 || k >= leftcheats.$length) ? $throwRuntimeError("index out of range") : leftcheats.$array[leftcheats.$offset + k]).cutoff)) { + delta = delta - (1) >> 0; + } + r = a.nd; + w = a.nd + delta >> 0; n = 0; - if (sep.length === 0) { - return utf8.RuneCountInString(s) + 1 >> 0; - } else if (sep.length === 1) { - c = sep.charCodeAt(0); - i = 0; - while (i < s.length) { - if (s.charCodeAt(i) === c) { - n = n + (1) >> 0; - } - i = i + (1) >> 0; - } - return n; - } else if (sep.length > s.length) { - return 0; - } else if (sep.length === s.length) { - if (sep === s) { - return 1; + r = r - (1) >> 0; + while (r >= 0) { + n = n + (((y = k, y < 32 ? (((((x = a.d, ((r < 0 || r >= x.length) ? $throwRuntimeError("index out of range") : x[r])) >> 0) - 48 >> 0)) << y) : 0) >> 0)) >> 0; + quo = (_q = n / 10, (_q === _q && _q !== 1/0 && _q !== -1/0) ? _q >> 0 : $throwRuntimeError("integer divide by zero")); + rem = n - ((((10 >>> 16 << 16) * quo >> 0) + (10 << 16 >>> 16) * quo) >> 0) >> 0; + w = w - (1) >> 0; + if (w < 800) { + (x$1 = a.d, (w < 0 || w >= x$1.length) ? $throwRuntimeError("index out of range") : x$1[w] = ((rem + 48 >> 0) << 24 >>> 24)); + } else if (!((rem === 0))) { + a.trunc = true; } - return 0; - } - _tuple = hashstr(sep); hashsep = _tuple[0]; pow = _tuple[1]; - h = 0; - i$1 = 0; - while (i$1 < sep.length) { - h = ((((h >>> 16 << 16) * 16777619 >>> 0) + (h << 16 >>> 16) * 16777619) >>> 0) + (s.charCodeAt(i$1) >>> 0) >>> 0; - i$1 = i$1 + (1) >> 0; - } - lastmatch = 0; - if ((h === hashsep) && s.substring(0, sep.length) === sep) { - n = n + (1) >> 0; - lastmatch = sep.length; + n = quo; + r = r - (1) >> 0; } - i$2 = sep.length; - while (i$2 < s.length) { - h = (x = 16777619, (((h >>> 16 << 16) * x >>> 0) + (h << 16 >>> 16) * x) >>> 0); - h = h + ((s.charCodeAt(i$2) >>> 0)) >>> 0; - h = h - ((x$1 = (s.charCodeAt((i$2 - sep.length >> 0)) >>> 0), (((pow >>> 16 << 16) * x$1 >>> 0) + (pow << 16 >>> 16) * x$1) >>> 0)) >>> 0; - i$2 = i$2 + (1) >> 0; - if ((h === hashsep) && lastmatch <= (i$2 - sep.length >> 0) && s.substring((i$2 - sep.length >> 0), i$2) === sep) { - n = n + (1) >> 0; - lastmatch = i$2; + while (n > 0) { + quo$1 = (_q$1 = n / 10, (_q$1 === _q$1 && _q$1 !== 1/0 && _q$1 !== -1/0) ? _q$1 >> 0 : $throwRuntimeError("integer divide by zero")); + rem$1 = n - ((((10 >>> 16 << 16) * quo$1 >> 0) + (10 << 16 >>> 16) * quo$1) >> 0) >> 0; + w = w - (1) >> 0; + if (w < 800) { + (x$2 = a.d, (w < 0 || w >= x$2.length) ? $throwRuntimeError("index out of range") : x$2[w] = ((rem$1 + 48 >> 0) << 24 >>> 24)); + } else if (!((rem$1 === 0))) { + a.trunc = true; } + n = quo$1; } - return n; - }; - Contains = $pkg.Contains = function(s, substr) { - return Index(s, substr) >= 0; - }; - ContainsRune = $pkg.ContainsRune = function(s, r) { - return IndexRune(s, r) >= 0; + a.nd = a.nd + (delta) >> 0; + if (a.nd >= 800) { + a.nd = 800; + } + a.dp = a.dp + (delta) >> 0; + trim(a); }; - Index = $pkg.Index = function(s, sep) { - var n, _tuple, hashsep, pow, h, i, i$1, x, x$1; - n = sep.length; - if (n === 0) { - return 0; - } else if (n === 1) { - return IndexByte(s, sep.charCodeAt(0)); - } else if (n === s.length) { - if (sep === s) { - return 0; + decimal.Ptr.prototype.Shift = function(k) { + var a; + a = this; + if (a.nd === 0) { + } else if (k > 0) { + while (k > 27) { + leftShift(a, 27); + k = k - (27) >> 0; } - return -1; - } else if (n > s.length) { - return -1; - } - _tuple = hashstr(sep); hashsep = _tuple[0]; pow = _tuple[1]; - h = 0; - i = 0; - while (i < n) { - h = ((((h >>> 16 << 16) * 16777619 >>> 0) + (h << 16 >>> 16) * 16777619) >>> 0) + (s.charCodeAt(i) >>> 0) >>> 0; - i = i + (1) >> 0; - } - if ((h === hashsep) && s.substring(0, n) === sep) { - return 0; - } - i$1 = n; - while (i$1 < s.length) { - h = (x = 16777619, (((h >>> 16 << 16) * x >>> 0) + (h << 16 >>> 16) * x) >>> 0); - h = h + ((s.charCodeAt(i$1) >>> 0)) >>> 0; - h = h - ((x$1 = (s.charCodeAt((i$1 - n >> 0)) >>> 0), (((pow >>> 16 << 16) * x$1 >>> 0) + (pow << 16 >>> 16) * x$1) >>> 0)) >>> 0; - i$1 = i$1 + (1) >> 0; - if ((h === hashsep) && s.substring((i$1 - n >> 0), i$1) === sep) { - return i$1 - n >> 0; + leftShift(a, (k >>> 0)); + } else if (k < 0) { + while (k < -27) { + rightShift(a, 27); + k = k + (27) >> 0; } + rightShift(a, (-k >>> 0)); } - return -1; }; - LastIndex = $pkg.LastIndex = function(s, sep) { - var n, c, i, i$1; - n = sep.length; - if (n === 0) { - return s.length; - } - c = sep.charCodeAt(0); - if (n === 1) { - i = s.length - 1 >> 0; - while (i >= 0) { - if (s.charCodeAt(i) === c) { - return i; - } - i = i - (1) >> 0; - } - return -1; + decimal.prototype.Shift = function(k) { return this.$val.Shift(k); }; + shouldRoundUp = function(a, nd) { + var x, _r, x$1, x$2, x$3; + if (nd < 0 || nd >= a.nd) { + return false; } - i$1 = s.length - n >> 0; - while (i$1 >= 0) { - if ((s.charCodeAt(i$1) === c) && s.substring(i$1, (i$1 + n >> 0)) === sep) { - return i$1; + if (((x = a.d, ((nd < 0 || nd >= x.length) ? $throwRuntimeError("index out of range") : x[nd])) === 53) && ((nd + 1 >> 0) === a.nd)) { + if (a.trunc) { + return true; } - i$1 = i$1 - (1) >> 0; + return nd > 0 && !(((_r = (((x$1 = a.d, x$2 = nd - 1 >> 0, ((x$2 < 0 || x$2 >= x$1.length) ? $throwRuntimeError("index out of range") : x$1[x$2])) - 48 << 24 >>> 24)) % 2, _r === _r ? _r : $throwRuntimeError("integer divide by zero")) === 0)); } - return -1; + return (x$3 = a.d, ((nd < 0 || nd >= x$3.length) ? $throwRuntimeError("index out of range") : x$3[nd])) >= 53; }; - IndexRune = $pkg.IndexRune = function(s, r) { - var b, i, _ref, _i, _rune, i$1, c; - if (r < 128) { - b = (r << 24 >>> 24); - i = 0; - while (i < s.length) { - if (s.charCodeAt(i) === b) { - return i; - } - i = i + (1) >> 0; - } + decimal.Ptr.prototype.Round = function(nd) { + var a; + a = this; + if (nd < 0 || nd >= a.nd) { + return; + } + if (shouldRoundUp(a, nd)) { + a.RoundUp(nd); } else { - _ref = s; - _i = 0; - while (_i < _ref.length) { - _rune = $decodeRune(_ref, _i); - i$1 = _i; - c = _rune[0]; - if (c === r) { - return i$1; - } - _i += _rune[1]; - } + a.RoundDown(nd); } - return -1; }; - IndexAny = $pkg.IndexAny = function(s, chars) { - var _ref, _i, _rune, i, c, _ref$1, _i$1, _rune$1, m; - if (chars.length > 0) { - _ref = s; - _i = 0; - while (_i < _ref.length) { - _rune = $decodeRune(_ref, _i); - i = _i; - c = _rune[0]; - _ref$1 = chars; - _i$1 = 0; - while (_i$1 < _ref$1.length) { - _rune$1 = $decodeRune(_ref$1, _i$1); - m = _rune$1[0]; - if (c === m) { - return i; - } - _i$1 += _rune$1[1]; - } - _i += _rune[1]; - } + decimal.prototype.Round = function(nd) { return this.$val.Round(nd); }; + decimal.Ptr.prototype.RoundDown = function(nd) { + var a; + a = this; + if (nd < 0 || nd >= a.nd) { + return; } - return -1; + a.nd = nd; + trim(a); }; - genSplit = function(s, sep, sepSave, n) { - var c, start, a, na, i; - if (n === 0) { - return ($sliceType($String)).nil; + decimal.prototype.RoundDown = function(nd) { return this.$val.RoundDown(nd); }; + decimal.Ptr.prototype.RoundUp = function(nd) { + var a, i, x, c, _lhs, _index; + a = this; + if (nd < 0 || nd >= a.nd) { + return; } - if (sep === "") { - return explode(s, n); + i = nd - 1 >> 0; + while (i >= 0) { + c = (x = a.d, ((i < 0 || i >= x.length) ? $throwRuntimeError("index out of range") : x[i])); + if (c < 57) { + _lhs = a.d; _index = i; (_index < 0 || _index >= _lhs.length) ? $throwRuntimeError("index out of range") : _lhs[_index] = ((_index < 0 || _index >= _lhs.length) ? $throwRuntimeError("index out of range") : _lhs[_index]) + (1) << 24 >>> 24; + a.nd = i + 1 >> 0; + return; + } + i = i - (1) >> 0; } - if (n < 0) { - n = Count(s, sep) + 1 >> 0; + a.d[0] = 49; + a.nd = 1; + a.dp = a.dp + (1) >> 0; + }; + decimal.prototype.RoundUp = function(nd) { return this.$val.RoundUp(nd); }; + decimal.Ptr.prototype.RoundedInteger = function() { + var a, i, n, x, x$1, x$2, x$3; + a = this; + if (a.dp > 20) { + return new $Uint64(4294967295, 4294967295); } - c = sep.charCodeAt(0); - start = 0; - a = ($sliceType($String)).make(n); - na = 0; i = 0; - while ((i + sep.length >> 0) <= s.length && (na + 1 >> 0) < n) { - if ((s.charCodeAt(i) === c) && ((sep.length === 1) || s.substring(i, (i + sep.length >> 0)) === sep)) { - (na < 0 || na >= a.$length) ? $throwRuntimeError("index out of range") : a.$array[a.$offset + na] = s.substring(start, (i + sepSave >> 0)); - na = na + (1) >> 0; - start = i + sep.length >> 0; - i = i + ((sep.length - 1 >> 0)) >> 0; - } + n = new $Uint64(0, 0); + i = 0; + while (i < a.dp && i < a.nd) { + n = (x = $mul64(n, new $Uint64(0, 10)), x$1 = new $Uint64(0, ((x$2 = a.d, ((i < 0 || i >= x$2.length) ? $throwRuntimeError("index out of range") : x$2[i])) - 48 << 24 >>> 24)), new $Uint64(x.$high + x$1.$high, x.$low + x$1.$low)); i = i + (1) >> 0; } - (na < 0 || na >= a.$length) ? $throwRuntimeError("index out of range") : a.$array[a.$offset + na] = s.substring(start); - return $subslice(a, 0, (na + 1 >> 0)); - }; - Split = $pkg.Split = function(s, sep) { - return genSplit(s, sep, 0, -1); - }; - Fields = $pkg.Fields = function(s) { - return FieldsFunc(s, unicode.IsSpace); - }; - FieldsFunc = $pkg.FieldsFunc = function(s, f) { - var n, inField, _ref, _i, _rune, rune, wasInField, a, na, fieldStart, _ref$1, _i$1, _rune$1, i, rune$1; - n = 0; - inField = false; - _ref = s; - _i = 0; - while (_i < _ref.length) { - _rune = $decodeRune(_ref, _i); - rune = _rune[0]; - wasInField = inField; - inField = !f(rune); - if (inField && !wasInField) { - n = n + (1) >> 0; - } - _i += _rune[1]; - } - a = ($sliceType($String)).make(n); - na = 0; - fieldStart = -1; - _ref$1 = s; - _i$1 = 0; - while (_i$1 < _ref$1.length) { - _rune$1 = $decodeRune(_ref$1, _i$1); - i = _i$1; - rune$1 = _rune$1[0]; - if (f(rune$1)) { - if (fieldStart >= 0) { - (na < 0 || na >= a.$length) ? $throwRuntimeError("index out of range") : a.$array[a.$offset + na] = s.substring(fieldStart, i); - na = na + (1) >> 0; - fieldStart = -1; - } - } else if (fieldStart === -1) { - fieldStart = i; - } - _i$1 += _rune$1[1]; + while (i < a.dp) { + n = $mul64(n, (new $Uint64(0, 10))); + i = i + (1) >> 0; } - if (fieldStart >= 0) { - (na < 0 || na >= a.$length) ? $throwRuntimeError("index out of range") : a.$array[a.$offset + na] = s.substring(fieldStart); + if (shouldRoundUp(a, a.dp)) { + n = (x$3 = new $Uint64(0, 1), new $Uint64(n.$high + x$3.$high, n.$low + x$3.$low)); } - return a; + return n; }; - Join = $pkg.Join = function(a, sep) { - var x, x$1, n, i, b, bp, _ref, _i, s; - if (a.$length === 0) { - return ""; - } - if (a.$length === 1) { - return ((0 < 0 || 0 >= a.$length) ? $throwRuntimeError("index out of range") : a.$array[a.$offset + 0]); - } - n = (x = sep.length, x$1 = (a.$length - 1 >> 0), (((x >>> 16 << 16) * x$1 >> 0) + (x << 16 >>> 16) * x$1) >> 0); - i = 0; - while (i < a.$length) { - n = n + (((i < 0 || i >= a.$length) ? $throwRuntimeError("index out of range") : a.$array[a.$offset + i]).length) >> 0; - i = i + (1) >> 0; + decimal.prototype.RoundedInteger = function() { return this.$val.RoundedInteger(); }; + extFloat.Ptr.prototype.floatBits = function(flt) { + var bits = new $Uint64(0, 0), overflow = false, f, exp, n, mant, x, x$1, x$2, x$3, x$4, y, x$5, x$6, y$1, x$7, x$8, x$9, y$2, x$10; + f = this; + f.Normalize(); + exp = f.exp + 63 >> 0; + if (exp < (flt.bias + 1 >> 0)) { + n = (flt.bias + 1 >> 0) - exp >> 0; + f.mant = $shiftRightUint64(f.mant, ((n >>> 0))); + exp = exp + (n) >> 0; } - b = ($sliceType($Uint8)).make(n); - bp = $copyString(b, ((0 < 0 || 0 >= a.$length) ? $throwRuntimeError("index out of range") : a.$array[a.$offset + 0])); - _ref = $subslice(a, 1); - _i = 0; - while (_i < _ref.$length) { - s = ((_i < 0 || _i >= _ref.$length) ? $throwRuntimeError("index out of range") : _ref.$array[_ref.$offset + _i]); - bp = bp + ($copyString($subslice(b, bp), sep)) >> 0; - bp = bp + ($copyString($subslice(b, bp), s)) >> 0; - _i++; + mant = $shiftRightUint64(f.mant, ((63 - flt.mantbits >>> 0))); + if (!((x = (x$1 = f.mant, x$2 = $shiftLeft64(new $Uint64(0, 1), ((62 - flt.mantbits >>> 0))), new $Uint64(x$1.$high & x$2.$high, (x$1.$low & x$2.$low) >>> 0)), (x.$high === 0 && x.$low === 0)))) { + mant = (x$3 = new $Uint64(0, 1), new $Uint64(mant.$high + x$3.$high, mant.$low + x$3.$low)); } - return $bytesToString(b); - }; - HasPrefix = $pkg.HasPrefix = function(s, prefix) { - return s.length >= prefix.length && s.substring(0, prefix.length) === prefix; - }; - HasSuffix = $pkg.HasSuffix = function(s, suffix) { - return s.length >= suffix.length && s.substring((s.length - suffix.length >> 0)) === suffix; - }; - Map = $pkg.Map = function(mapping, s) { - var maxbytes, nbytes, b, _ref, _i, _rune, i, c, r, wid, nb; - maxbytes = s.length; - nbytes = 0; - b = ($sliceType($Uint8)).nil; - _ref = s; - _i = 0; - while (_i < _ref.length) { - _rune = $decodeRune(_ref, _i); - i = _i; - c = _rune[0]; - r = mapping(c); - if (b === ($sliceType($Uint8)).nil) { - if (r === c) { - _i += _rune[1]; - continue; - } - b = ($sliceType($Uint8)).make(maxbytes); - nbytes = $copyString(b, s.substring(0, i)); - } - if (r >= 0) { - wid = 1; - if (r >= 128) { - wid = utf8.RuneLen(r); - } - if ((nbytes + wid >> 0) > maxbytes) { - maxbytes = ((((maxbytes >>> 16 << 16) * 2 >> 0) + (maxbytes << 16 >>> 16) * 2) >> 0) + 4 >> 0; - nb = ($sliceType($Uint8)).make(maxbytes); - $copySlice(nb, $subslice(b, 0, nbytes)); - b = nb; - } - nbytes = nbytes + (utf8.EncodeRune($subslice(b, nbytes, maxbytes), r)) >> 0; - } - _i += _rune[1]; + if ((x$4 = $shiftLeft64(new $Uint64(0, 2), flt.mantbits), (mant.$high === x$4.$high && mant.$low === x$4.$low))) { + mant = $shiftRightUint64(mant, (1)); + exp = exp + (1) >> 0; } - if (b === ($sliceType($Uint8)).nil) { - return s; + if ((exp - flt.bias >> 0) >= (((y = flt.expbits, y < 32 ? (1 << y) : 0) >> 0) - 1 >> 0)) { + mant = new $Uint64(0, 0); + exp = (((y$1 = flt.expbits, y$1 < 32 ? (1 << y$1) : 0) >> 0) - 1 >> 0) + flt.bias >> 0; + overflow = true; + } else if ((x$5 = (x$6 = $shiftLeft64(new $Uint64(0, 1), flt.mantbits), new $Uint64(mant.$high & x$6.$high, (mant.$low & x$6.$low) >>> 0)), (x$5.$high === 0 && x$5.$low === 0))) { + exp = flt.bias; } - return $bytesToString($subslice(b, 0, nbytes)); - }; - Repeat = $pkg.Repeat = function(s, count) { - var x, b, bp, i; - b = ($sliceType($Uint8)).make((x = s.length, (((x >>> 16 << 16) * count >> 0) + (x << 16 >>> 16) * count) >> 0)); - bp = 0; - i = 0; - while (i < count) { - bp = bp + ($copyString($subslice(b, bp), s)) >> 0; - i = i + (1) >> 0; + bits = (x$7 = (x$8 = $shiftLeft64(new $Uint64(0, 1), flt.mantbits), new $Uint64(x$8.$high - 0, x$8.$low - 1)), new $Uint64(mant.$high & x$7.$high, (mant.$low & x$7.$low) >>> 0)); + bits = (x$9 = $shiftLeft64(new $Uint64(0, (((exp - flt.bias >> 0)) & ((((y$2 = flt.expbits, y$2 < 32 ? (1 << y$2) : 0) >> 0) - 1 >> 0)))), flt.mantbits), new $Uint64(bits.$high | x$9.$high, (bits.$low | x$9.$low) >>> 0)); + if (f.neg) { + bits = (x$10 = $shiftLeft64(new $Uint64(0, 1), ((flt.mantbits + flt.expbits >>> 0))), new $Uint64(bits.$high | x$10.$high, (bits.$low | x$10.$low) >>> 0)); } - return $bytesToString(b); - }; - ToUpper = $pkg.ToUpper = function(s) { - return Map(unicode.ToUpper, s); - }; - ToLower = $pkg.ToLower = function(s) { - return Map(unicode.ToLower, s); + return [bits, overflow]; }; - TrimLeftFunc = $pkg.TrimLeftFunc = function(s, f) { - var i; - i = indexFunc(s, f, false); - if (i === -1) { - return ""; + extFloat.prototype.floatBits = function(flt) { return this.$val.floatBits(flt); }; + extFloat.Ptr.prototype.AssignComputeBounds = function(mant, exp, neg, flt) { + var lower = new extFloat.Ptr(), upper = new extFloat.Ptr(), f, x, _tmp, _tmp$1, expBiased, x$1, x$2, x$3, x$4; + f = this; + f.mant = mant; + f.exp = exp - (flt.mantbits >> 0) >> 0; + f.neg = neg; + if (f.exp <= 0 && (x = $shiftLeft64(($shiftRightUint64(mant, (-f.exp >>> 0))), (-f.exp >>> 0)), (mant.$high === x.$high && mant.$low === x.$low))) { + f.mant = $shiftRightUint64(f.mant, ((-f.exp >>> 0))); + f.exp = 0; + _tmp = new extFloat.Ptr(); $copy(_tmp, f, extFloat); _tmp$1 = new extFloat.Ptr(); $copy(_tmp$1, f, extFloat); $copy(lower, _tmp, extFloat); $copy(upper, _tmp$1, extFloat); + return [lower, upper]; } - return s.substring(i); - }; - TrimRightFunc = $pkg.TrimRightFunc = function(s, f) { - var i, _tuple, wid; - i = lastIndexFunc(s, f, false); - if (i >= 0 && s.charCodeAt(i) >= 128) { - _tuple = utf8.DecodeRuneInString(s.substring(i)); wid = _tuple[1]; - i = i + (wid) >> 0; + expBiased = exp - flt.bias >> 0; + $copy(upper, new extFloat.Ptr((x$1 = $mul64(new $Uint64(0, 2), f.mant), new $Uint64(x$1.$high + 0, x$1.$low + 1)), f.exp - 1 >> 0, f.neg), extFloat); + if (!((x$2 = $shiftLeft64(new $Uint64(0, 1), flt.mantbits), (mant.$high === x$2.$high && mant.$low === x$2.$low))) || (expBiased === 1)) { + $copy(lower, new extFloat.Ptr((x$3 = $mul64(new $Uint64(0, 2), f.mant), new $Uint64(x$3.$high - 0, x$3.$low - 1)), f.exp - 1 >> 0, f.neg), extFloat); } else { - i = i + (1) >> 0; + $copy(lower, new extFloat.Ptr((x$4 = $mul64(new $Uint64(0, 4), f.mant), new $Uint64(x$4.$high - 0, x$4.$low - 1)), f.exp - 2 >> 0, f.neg), extFloat); } - return s.substring(0, i); - }; - TrimFunc = $pkg.TrimFunc = function(s, f) { - return TrimRightFunc(TrimLeftFunc(s, f), f); - }; - IndexFunc = $pkg.IndexFunc = function(s, f) { - return indexFunc(s, f, true); + return [lower, upper]; }; - indexFunc = function(s, f, truth) { - var start, wid, r, _tuple; - start = 0; - while (start < s.length) { - wid = 1; - r = (s.charCodeAt(start) >> 0); - if (r >= 128) { - _tuple = utf8.DecodeRuneInString(s.substring(start)); r = _tuple[0]; wid = _tuple[1]; - } - if (f(r) === truth) { - return start; - } - start = start + (wid) >> 0; + extFloat.prototype.AssignComputeBounds = function(mant, exp, neg, flt) { return this.$val.AssignComputeBounds(mant, exp, neg, flt); }; + extFloat.Ptr.prototype.Normalize = function() { + var shift = 0, f, _tmp, _tmp$1, mant, exp, x, x$1, x$2, x$3, x$4, x$5, _tmp$2, _tmp$3; + f = this; + _tmp = f.mant; _tmp$1 = f.exp; mant = _tmp; exp = _tmp$1; + if ((mant.$high === 0 && mant.$low === 0)) { + shift = 0; + return shift; } - return -1; - }; - lastIndexFunc = function(s, f, truth) { - var i, _tuple, r, size; - i = s.length; - while (i > 0) { - _tuple = utf8.DecodeLastRuneInString(s.substring(0, i)); r = _tuple[0]; size = _tuple[1]; - i = i - (size) >> 0; - if (f(r) === truth) { - return i; - } + if ((x = $shiftRightUint64(mant, 32), (x.$high === 0 && x.$low === 0))) { + mant = $shiftLeft64(mant, (32)); + exp = exp - (32) >> 0; } - return -1; - }; - TrimSpace = $pkg.TrimSpace = function(s) { - return TrimFunc(s, unicode.IsSpace); - }; - TrimSuffix = $pkg.TrimSuffix = function(s, suffix) { - if (HasSuffix(s, suffix)) { - return s.substring(0, (s.length - suffix.length >> 0)); + if ((x$1 = $shiftRightUint64(mant, 48), (x$1.$high === 0 && x$1.$low === 0))) { + mant = $shiftLeft64(mant, (16)); + exp = exp - (16) >> 0; } - return s; - }; - Replace = $pkg.Replace = function(s, old, new$1, n) { - var m, x, t, w, start, i, j, _tuple, wid; - if (old === new$1 || (n === 0)) { - return s; + if ((x$2 = $shiftRightUint64(mant, 56), (x$2.$high === 0 && x$2.$low === 0))) { + mant = $shiftLeft64(mant, (8)); + exp = exp - (8) >> 0; } - m = Count(s, old); - if (m === 0) { - return s; - } else if (n < 0 || m < n) { - n = m; + if ((x$3 = $shiftRightUint64(mant, 60), (x$3.$high === 0 && x$3.$low === 0))) { + mant = $shiftLeft64(mant, (4)); + exp = exp - (4) >> 0; } - t = ($sliceType($Uint8)).make((s.length + (x = (new$1.length - old.length >> 0), (((n >>> 16 << 16) * x >> 0) + (n << 16 >>> 16) * x) >> 0) >> 0)); - w = 0; - start = 0; - i = 0; - while (i < n) { - j = start; - if (old.length === 0) { - if (i > 0) { - _tuple = utf8.DecodeRuneInString(s.substring(start)); wid = _tuple[1]; - j = j + (wid) >> 0; - } - } else { - j = j + (Index(s.substring(start), old)) >> 0; - } - w = w + ($copyString($subslice(t, w), s.substring(start, j))) >> 0; - w = w + ($copyString($subslice(t, w), new$1)) >> 0; - start = j + old.length >> 0; - i = i + (1) >> 0; + if ((x$4 = $shiftRightUint64(mant, 62), (x$4.$high === 0 && x$4.$low === 0))) { + mant = $shiftLeft64(mant, (2)); + exp = exp - (2) >> 0; } - w = w + ($copyString($subslice(t, w), s.substring(start))) >> 0; - return $bytesToString($subslice(t, 0, w)); + if ((x$5 = $shiftRightUint64(mant, 63), (x$5.$high === 0 && x$5.$low === 0))) { + mant = $shiftLeft64(mant, (1)); + exp = exp - (1) >> 0; + } + shift = ((f.exp - exp >> 0) >>> 0); + _tmp$2 = mant; _tmp$3 = exp; f.mant = _tmp$2; f.exp = _tmp$3; + return shift; }; - $pkg.$init = function() { - ($ptrType(Reader)).methods = [["Len", "Len", "", $funcType([], [$Int], false), -1], ["Read", "Read", "", $funcType([($sliceType($Uint8))], [$Int, $error], false), -1], ["ReadAt", "ReadAt", "", $funcType([($sliceType($Uint8)), $Int64], [$Int, $error], false), -1], ["ReadByte", "ReadByte", "", $funcType([], [$Uint8, $error], false), -1], ["ReadRune", "ReadRune", "", $funcType([], [$Int32, $Int, $error], false), -1], ["Seek", "Seek", "", $funcType([$Int64, $Int], [$Int64, $error], false), -1], ["UnreadByte", "UnreadByte", "", $funcType([], [$error], false), -1], ["UnreadRune", "UnreadRune", "", $funcType([], [$error], false), -1], ["WriteTo", "WriteTo", "", $funcType([io.Writer], [$Int64, $error], false), -1]]; - Reader.init([["s", "s", "strings", $String, ""], ["i", "i", "strings", $Int64, ""], ["prevRune", "prevRune", "strings", $Int, ""]]); + extFloat.prototype.Normalize = function() { return this.$val.Normalize(); }; + extFloat.Ptr.prototype.Multiply = function(g) { + var f, _tmp, _tmp$1, fhi, flo, _tmp$2, _tmp$3, ghi, glo, cross1, cross2, x, x$1, x$2, x$3, x$4, x$5, x$6, x$7, rem, x$8, x$9, x$10; + f = this; + _tmp = $shiftRightUint64(f.mant, 32); _tmp$1 = new $Uint64(0, (f.mant.$low >>> 0)); fhi = _tmp; flo = _tmp$1; + _tmp$2 = $shiftRightUint64(g.mant, 32); _tmp$3 = new $Uint64(0, (g.mant.$low >>> 0)); ghi = _tmp$2; glo = _tmp$3; + cross1 = $mul64(fhi, glo); + cross2 = $mul64(flo, ghi); + f.mant = (x = (x$1 = $mul64(fhi, ghi), x$2 = $shiftRightUint64(cross1, 32), new $Uint64(x$1.$high + x$2.$high, x$1.$low + x$2.$low)), x$3 = $shiftRightUint64(cross2, 32), new $Uint64(x.$high + x$3.$high, x.$low + x$3.$low)); + rem = (x$4 = (x$5 = new $Uint64(0, (cross1.$low >>> 0)), x$6 = new $Uint64(0, (cross2.$low >>> 0)), new $Uint64(x$5.$high + x$6.$high, x$5.$low + x$6.$low)), x$7 = $shiftRightUint64(($mul64(flo, glo)), 32), new $Uint64(x$4.$high + x$7.$high, x$4.$low + x$7.$low)); + rem = (x$8 = new $Uint64(0, 2147483648), new $Uint64(rem.$high + x$8.$high, rem.$low + x$8.$low)); + f.mant = (x$9 = f.mant, x$10 = ($shiftRightUint64(rem, 32)), new $Uint64(x$9.$high + x$10.$high, x$9.$low + x$10.$low)); + f.exp = (f.exp + g.exp >> 0) + 64 >> 0; }; - return $pkg; -})(); -$packages["time"] = (function() { - var $pkg = {}, js = $packages["github.com/gopherjs/gopherjs/js"], strings = $packages["strings"], errors = $packages["errors"], syscall = $packages["syscall"], sync = $packages["sync"], runtime = $packages["runtime"], runtimeTimer, ParseError, Timer, Time, Month, Weekday, Duration, Location, zone, zoneTrans, std0x, longDayNames, shortDayNames, shortMonthNames, longMonthNames, atoiError, errBad, errLeadingInt, unitMap, months, days, daysBefore, utcLoc, localLoc, localOnce, zoneinfo, badData, zoneDirs, _map, _key, _tuple, initLocal, runtimeNano, now, startTimer, stopTimer, startsWithLowerCase, nextStdChunk, match, lookup, appendUint, atoi, formatNano, quote, isDigit, getnum, cutspace, skip, Parse, parse, parseTimeZone, parseGMT, parseNanoseconds, leadingInt, ParseDuration, when, AfterFunc, goFunc, absWeekday, absClock, fmtFrac, fmtInt, absDate, Now, Unix, isLeap, norm, Date, div, FixedZone; - runtimeTimer = $pkg.runtimeTimer = $newType(0, "Struct", "time.runtimeTimer", "runtimeTimer", "time", function(i_, when_, period_, f_, arg_, timeout_, active_) { - this.$val = this; - this.i = i_ !== undefined ? i_ : 0; - this.when = when_ !== undefined ? when_ : new $Int64(0, 0); - this.period = period_ !== undefined ? period_ : new $Int64(0, 0); - this.f = f_ !== undefined ? f_ : $throwNilPointerError; - this.arg = arg_ !== undefined ? arg_ : $ifaceNil; - this.timeout = timeout_ !== undefined ? timeout_ : $ifaceNil; - this.active = active_ !== undefined ? active_ : false; - }); - ParseError = $pkg.ParseError = $newType(0, "Struct", "time.ParseError", "ParseError", "time", function(Layout_, Value_, LayoutElem_, ValueElem_, Message_) { - this.$val = this; - this.Layout = Layout_ !== undefined ? Layout_ : ""; - this.Value = Value_ !== undefined ? Value_ : ""; - this.LayoutElem = LayoutElem_ !== undefined ? LayoutElem_ : ""; - this.ValueElem = ValueElem_ !== undefined ? ValueElem_ : ""; - this.Message = Message_ !== undefined ? Message_ : ""; - }); - Timer = $pkg.Timer = $newType(0, "Struct", "time.Timer", "Timer", "time", function(C_, r_) { - this.$val = this; - this.C = C_ !== undefined ? C_ : ($chanType(Time, false, true)).nil; - this.r = r_ !== undefined ? r_ : new runtimeTimer.Ptr(); - }); - Time = $pkg.Time = $newType(0, "Struct", "time.Time", "Time", "time", function(sec_, nsec_, loc_) { - this.$val = this; - this.sec = sec_ !== undefined ? sec_ : new $Int64(0, 0); - this.nsec = nsec_ !== undefined ? nsec_ : 0; - this.loc = loc_ !== undefined ? loc_ : ($ptrType(Location)).nil; - }); - Month = $pkg.Month = $newType(4, "Int", "time.Month", "Month", "time", null); - Weekday = $pkg.Weekday = $newType(4, "Int", "time.Weekday", "Weekday", "time", null); - Duration = $pkg.Duration = $newType(8, "Int64", "time.Duration", "Duration", "time", null); - Location = $pkg.Location = $newType(0, "Struct", "time.Location", "Location", "time", function(name_, zone_, tx_, cacheStart_, cacheEnd_, cacheZone_) { - this.$val = this; - this.name = name_ !== undefined ? name_ : ""; - this.zone = zone_ !== undefined ? zone_ : ($sliceType(zone)).nil; - this.tx = tx_ !== undefined ? tx_ : ($sliceType(zoneTrans)).nil; - this.cacheStart = cacheStart_ !== undefined ? cacheStart_ : new $Int64(0, 0); - this.cacheEnd = cacheEnd_ !== undefined ? cacheEnd_ : new $Int64(0, 0); - this.cacheZone = cacheZone_ !== undefined ? cacheZone_ : ($ptrType(zone)).nil; - }); - zone = $pkg.zone = $newType(0, "Struct", "time.zone", "zone", "time", function(name_, offset_, isDST_) { - this.$val = this; - this.name = name_ !== undefined ? name_ : ""; - this.offset = offset_ !== undefined ? offset_ : 0; - this.isDST = isDST_ !== undefined ? isDST_ : false; - }); - zoneTrans = $pkg.zoneTrans = $newType(0, "Struct", "time.zoneTrans", "zoneTrans", "time", function(when_, index_, isstd_, isutc_) { - this.$val = this; - this.when = when_ !== undefined ? when_ : new $Int64(0, 0); - this.index = index_ !== undefined ? index_ : 0; - this.isstd = isstd_ !== undefined ? isstd_ : false; - this.isutc = isutc_ !== undefined ? isutc_ : false; - }); - initLocal = function() { - var d, s, i, j, x; - d = new ($global.Date)(); - s = $internalize(d, $String); - i = strings.IndexByte(s, 40); - j = strings.IndexByte(s, 41); - if ((i === -1) || (j === -1)) { - localLoc.name = "UTC"; - return; + extFloat.prototype.Multiply = function(g) { return this.$val.Multiply(g); }; + extFloat.Ptr.prototype.AssignDecimal = function(mantissa, exp10, neg, trunc, flt) { + var ok = false, f, errors$1, _q, i, _r, adjExp, x, x$1, shift, y, denormalExp, extrabits, halfway, x$2, x$3, x$4, mant_extra, x$5, x$6, x$7, x$8, x$9, x$10, x$11, x$12; + f = this; + errors$1 = 0; + if (trunc) { + errors$1 = errors$1 + (4) >> 0; } - localLoc.name = s.substring((i + 1 >> 0), j); - localLoc.zone = new ($sliceType(zone))([new zone.Ptr(localLoc.name, (x = $parseInt(d.getTimezoneOffset()) >> 0, (((x >>> 16 << 16) * -60 >> 0) + (x << 16 >>> 16) * -60) >> 0), false)]); - }; - runtimeNano = function() { - return $mul64($internalize(new ($global.Date)().getTime(), $Int64), new $Int64(0, 1000000)); - }; - now = function() { - var sec = new $Int64(0, 0), nsec = 0, n, _tmp, _tmp$1, x; - n = runtimeNano(); - _tmp = $div64(n, new $Int64(0, 1000000000), false); _tmp$1 = ((x = $div64(n, new $Int64(0, 1000000000), true), x.$low + ((x.$high >> 31) * 4294967296)) >> 0); sec = _tmp; nsec = _tmp$1; - return [sec, nsec]; - }; - startTimer = function(t) { - var x, x$1, diff; - t.active = true; - diff = $div64(((x = t.when, x$1 = runtimeNano(), new $Int64(x.$high - x$1.$high, x.$low - x$1.$low))), new $Int64(0, 1000000), false); - if ((diff.$high > 0 || (diff.$high === 0 && diff.$low > 2147483647))) { - return; + f.mant = mantissa; + f.exp = 0; + f.neg = neg; + i = (_q = ((exp10 - -348 >> 0)) / 8, (_q === _q && _q !== 1/0 && _q !== -1/0) ? _q >> 0 : $throwRuntimeError("integer divide by zero")); + if (exp10 < -348 || i >= 87) { + ok = false; + return ok; } - if ((diff.$high < 0 || (diff.$high === 0 && diff.$low < 0))) { - diff = new $Int64(0, 0); + adjExp = (_r = ((exp10 - -348 >> 0)) % 8, _r === _r ? _r : $throwRuntimeError("integer divide by zero")); + if (adjExp < 19 && (x = (x$1 = 19 - adjExp >> 0, ((x$1 < 0 || x$1 >= uint64pow10.length) ? $throwRuntimeError("index out of range") : uint64pow10[x$1])), (mantissa.$high < x.$high || (mantissa.$high === x.$high && mantissa.$low < x.$low)))) { + f.mant = $mul64(f.mant, (((adjExp < 0 || adjExp >= uint64pow10.length) ? $throwRuntimeError("index out of range") : uint64pow10[adjExp]))); + f.Normalize(); + } else { + f.Normalize(); + f.Multiply($clone(((adjExp < 0 || adjExp >= smallPowersOfTen.length) ? $throwRuntimeError("index out of range") : smallPowersOfTen[adjExp]), extFloat)); + errors$1 = errors$1 + (4) >> 0; } - t.timeout = $global.setTimeout($externalize((function() { - var x$2, x$3, x$4; - t.active = false; - t.f(runtimeNano(), t.arg); - if (!((x$2 = t.period, (x$2.$high === 0 && x$2.$low === 0)))) { - t.when = (x$3 = t.when, x$4 = t.period, new $Int64(x$3.$high + x$4.$high, x$3.$low + x$4.$low)); - startTimer(t); - } - }), ($funcType([], [], false))), $externalize(diff, $Int64)); - }; - stopTimer = function(t) { - var wasActive; - $global.clearTimeout(t.timeout); - wasActive = t.active; - t.active = false; - return wasActive; - }; - startsWithLowerCase = function(str) { - var c; - if (str.length === 0) { - return false; + f.Multiply($clone(((i < 0 || i >= powersOfTen.length) ? $throwRuntimeError("index out of range") : powersOfTen[i]), extFloat)); + if (errors$1 > 0) { + errors$1 = errors$1 + (1) >> 0; } - c = str.charCodeAt(0); - return 97 <= c && c <= 122; - }; - nextStdChunk = function(layout) { - var prefix = "", std = 0, suffix = "", i, c, _ref, _tmp, _tmp$1, _tmp$2, _tmp$3, _tmp$4, _tmp$5, _tmp$6, _tmp$7, _tmp$8, _tmp$9, _tmp$10, _tmp$11, _tmp$12, _tmp$13, _tmp$14, _tmp$15, _tmp$16, x, _tmp$17, _tmp$18, _tmp$19, _tmp$20, _tmp$21, _tmp$22, _tmp$23, _tmp$24, _tmp$25, _tmp$26, _tmp$27, _tmp$28, _tmp$29, _tmp$30, _tmp$31, _tmp$32, _tmp$33, _tmp$34, _tmp$35, _tmp$36, _tmp$37, _tmp$38, _tmp$39, _tmp$40, _tmp$41, _tmp$42, _tmp$43, _tmp$44, _tmp$45, _tmp$46, _tmp$47, _tmp$48, _tmp$49, _tmp$50, _tmp$51, _tmp$52, _tmp$53, _tmp$54, _tmp$55, _tmp$56, _tmp$57, _tmp$58, _tmp$59, _tmp$60, _tmp$61, _tmp$62, _tmp$63, _tmp$64, _tmp$65, _tmp$66, _tmp$67, _tmp$68, _tmp$69, _tmp$70, _tmp$71, _tmp$72, _tmp$73, _tmp$74, ch, j, std$1, _tmp$75, _tmp$76, _tmp$77, _tmp$78, _tmp$79, _tmp$80; - i = 0; - while (i < layout.length) { - c = (layout.charCodeAt(i) >> 0); - _ref = c; - if (_ref === 74) { - if (layout.length >= (i + 3 >> 0) && layout.substring(i, (i + 3 >> 0)) === "Jan") { - if (layout.length >= (i + 7 >> 0) && layout.substring(i, (i + 7 >> 0)) === "January") { - _tmp = layout.substring(0, i); _tmp$1 = 257; _tmp$2 = layout.substring((i + 7 >> 0)); prefix = _tmp; std = _tmp$1; suffix = _tmp$2; - return [prefix, std, suffix]; - } - if (!startsWithLowerCase(layout.substring((i + 3 >> 0)))) { - _tmp$3 = layout.substring(0, i); _tmp$4 = 258; _tmp$5 = layout.substring((i + 3 >> 0)); prefix = _tmp$3; std = _tmp$4; suffix = _tmp$5; - return [prefix, std, suffix]; - } - } - } else if (_ref === 77) { - if (layout.length >= (i + 3 >> 0)) { - if (layout.substring(i, (i + 3 >> 0)) === "Mon") { - if (layout.length >= (i + 6 >> 0) && layout.substring(i, (i + 6 >> 0)) === "Monday") { - _tmp$6 = layout.substring(0, i); _tmp$7 = 261; _tmp$8 = layout.substring((i + 6 >> 0)); prefix = _tmp$6; std = _tmp$7; suffix = _tmp$8; - return [prefix, std, suffix]; - } - if (!startsWithLowerCase(layout.substring((i + 3 >> 0)))) { - _tmp$9 = layout.substring(0, i); _tmp$10 = 262; _tmp$11 = layout.substring((i + 3 >> 0)); prefix = _tmp$9; std = _tmp$10; suffix = _tmp$11; - return [prefix, std, suffix]; - } - } - if (layout.substring(i, (i + 3 >> 0)) === "MST") { - _tmp$12 = layout.substring(0, i); _tmp$13 = 21; _tmp$14 = layout.substring((i + 3 >> 0)); prefix = _tmp$12; std = _tmp$13; suffix = _tmp$14; - return [prefix, std, suffix]; - } - } - } else if (_ref === 48) { - if (layout.length >= (i + 2 >> 0) && 49 <= layout.charCodeAt((i + 1 >> 0)) && layout.charCodeAt((i + 1 >> 0)) <= 54) { - _tmp$15 = layout.substring(0, i); _tmp$16 = (x = layout.charCodeAt((i + 1 >> 0)) - 49 << 24 >>> 24, ((x < 0 || x >= std0x.length) ? $throwRuntimeError("index out of range") : std0x[x])); _tmp$17 = layout.substring((i + 2 >> 0)); prefix = _tmp$15; std = _tmp$16; suffix = _tmp$17; - return [prefix, std, suffix]; - } - } else if (_ref === 49) { - if (layout.length >= (i + 2 >> 0) && (layout.charCodeAt((i + 1 >> 0)) === 53)) { - _tmp$18 = layout.substring(0, i); _tmp$19 = 522; _tmp$20 = layout.substring((i + 2 >> 0)); prefix = _tmp$18; std = _tmp$19; suffix = _tmp$20; - return [prefix, std, suffix]; - } - _tmp$21 = layout.substring(0, i); _tmp$22 = 259; _tmp$23 = layout.substring((i + 1 >> 0)); prefix = _tmp$21; std = _tmp$22; suffix = _tmp$23; - return [prefix, std, suffix]; - } else if (_ref === 50) { - if (layout.length >= (i + 4 >> 0) && layout.substring(i, (i + 4 >> 0)) === "2006") { - _tmp$24 = layout.substring(0, i); _tmp$25 = 273; _tmp$26 = layout.substring((i + 4 >> 0)); prefix = _tmp$24; std = _tmp$25; suffix = _tmp$26; - return [prefix, std, suffix]; - } - _tmp$27 = layout.substring(0, i); _tmp$28 = 263; _tmp$29 = layout.substring((i + 1 >> 0)); prefix = _tmp$27; std = _tmp$28; suffix = _tmp$29; - return [prefix, std, suffix]; - } else if (_ref === 95) { - if (layout.length >= (i + 2 >> 0) && (layout.charCodeAt((i + 1 >> 0)) === 50)) { - _tmp$30 = layout.substring(0, i); _tmp$31 = 264; _tmp$32 = layout.substring((i + 2 >> 0)); prefix = _tmp$30; std = _tmp$31; suffix = _tmp$32; - return [prefix, std, suffix]; - } - } else if (_ref === 51) { - _tmp$33 = layout.substring(0, i); _tmp$34 = 523; _tmp$35 = layout.substring((i + 1 >> 0)); prefix = _tmp$33; std = _tmp$34; suffix = _tmp$35; - return [prefix, std, suffix]; - } else if (_ref === 52) { - _tmp$36 = layout.substring(0, i); _tmp$37 = 525; _tmp$38 = layout.substring((i + 1 >> 0)); prefix = _tmp$36; std = _tmp$37; suffix = _tmp$38; - return [prefix, std, suffix]; - } else if (_ref === 53) { - _tmp$39 = layout.substring(0, i); _tmp$40 = 527; _tmp$41 = layout.substring((i + 1 >> 0)); prefix = _tmp$39; std = _tmp$40; suffix = _tmp$41; - return [prefix, std, suffix]; - } else if (_ref === 80) { - if (layout.length >= (i + 2 >> 0) && (layout.charCodeAt((i + 1 >> 0)) === 77)) { - _tmp$42 = layout.substring(0, i); _tmp$43 = 531; _tmp$44 = layout.substring((i + 2 >> 0)); prefix = _tmp$42; std = _tmp$43; suffix = _tmp$44; - return [prefix, std, suffix]; - } - } else if (_ref === 112) { - if (layout.length >= (i + 2 >> 0) && (layout.charCodeAt((i + 1 >> 0)) === 109)) { - _tmp$45 = layout.substring(0, i); _tmp$46 = 532; _tmp$47 = layout.substring((i + 2 >> 0)); prefix = _tmp$45; std = _tmp$46; suffix = _tmp$47; - return [prefix, std, suffix]; - } - } else if (_ref === 45) { - if (layout.length >= (i + 7 >> 0) && layout.substring(i, (i + 7 >> 0)) === "-070000") { - _tmp$48 = layout.substring(0, i); _tmp$49 = 27; _tmp$50 = layout.substring((i + 7 >> 0)); prefix = _tmp$48; std = _tmp$49; suffix = _tmp$50; - return [prefix, std, suffix]; - } - if (layout.length >= (i + 9 >> 0) && layout.substring(i, (i + 9 >> 0)) === "-07:00:00") { - _tmp$51 = layout.substring(0, i); _tmp$52 = 30; _tmp$53 = layout.substring((i + 9 >> 0)); prefix = _tmp$51; std = _tmp$52; suffix = _tmp$53; - return [prefix, std, suffix]; - } - if (layout.length >= (i + 5 >> 0) && layout.substring(i, (i + 5 >> 0)) === "-0700") { - _tmp$54 = layout.substring(0, i); _tmp$55 = 26; _tmp$56 = layout.substring((i + 5 >> 0)); prefix = _tmp$54; std = _tmp$55; suffix = _tmp$56; - return [prefix, std, suffix]; - } - if (layout.length >= (i + 6 >> 0) && layout.substring(i, (i + 6 >> 0)) === "-07:00") { - _tmp$57 = layout.substring(0, i); _tmp$58 = 29; _tmp$59 = layout.substring((i + 6 >> 0)); prefix = _tmp$57; std = _tmp$58; suffix = _tmp$59; - return [prefix, std, suffix]; - } - if (layout.length >= (i + 3 >> 0) && layout.substring(i, (i + 3 >> 0)) === "-07") { - _tmp$60 = layout.substring(0, i); _tmp$61 = 28; _tmp$62 = layout.substring((i + 3 >> 0)); prefix = _tmp$60; std = _tmp$61; suffix = _tmp$62; - return [prefix, std, suffix]; - } - } else if (_ref === 90) { - if (layout.length >= (i + 7 >> 0) && layout.substring(i, (i + 7 >> 0)) === "Z070000") { - _tmp$63 = layout.substring(0, i); _tmp$64 = 23; _tmp$65 = layout.substring((i + 7 >> 0)); prefix = _tmp$63; std = _tmp$64; suffix = _tmp$65; - return [prefix, std, suffix]; - } - if (layout.length >= (i + 9 >> 0) && layout.substring(i, (i + 9 >> 0)) === "Z07:00:00") { - _tmp$66 = layout.substring(0, i); _tmp$67 = 25; _tmp$68 = layout.substring((i + 9 >> 0)); prefix = _tmp$66; std = _tmp$67; suffix = _tmp$68; - return [prefix, std, suffix]; - } - if (layout.length >= (i + 5 >> 0) && layout.substring(i, (i + 5 >> 0)) === "Z0700") { - _tmp$69 = layout.substring(0, i); _tmp$70 = 22; _tmp$71 = layout.substring((i + 5 >> 0)); prefix = _tmp$69; std = _tmp$70; suffix = _tmp$71; - return [prefix, std, suffix]; - } - if (layout.length >= (i + 6 >> 0) && layout.substring(i, (i + 6 >> 0)) === "Z07:00") { - _tmp$72 = layout.substring(0, i); _tmp$73 = 24; _tmp$74 = layout.substring((i + 6 >> 0)); prefix = _tmp$72; std = _tmp$73; suffix = _tmp$74; - return [prefix, std, suffix]; - } - } else if (_ref === 46) { - if ((i + 1 >> 0) < layout.length && ((layout.charCodeAt((i + 1 >> 0)) === 48) || (layout.charCodeAt((i + 1 >> 0)) === 57))) { - ch = layout.charCodeAt((i + 1 >> 0)); - j = i + 1 >> 0; - while (j < layout.length && (layout.charCodeAt(j) === ch)) { - j = j + (1) >> 0; - } - if (!isDigit(layout, j)) { - std$1 = 31; - if (layout.charCodeAt((i + 1 >> 0)) === 57) { - std$1 = 32; - } - std$1 = std$1 | ((((j - ((i + 1 >> 0)) >> 0)) << 16 >> 0)); - _tmp$75 = layout.substring(0, i); _tmp$76 = std$1; _tmp$77 = layout.substring(j); prefix = _tmp$75; std = _tmp$76; suffix = _tmp$77; - return [prefix, std, suffix]; - } - } - } - i = i + (1) >> 0; + errors$1 = errors$1 + (4) >> 0; + shift = f.Normalize(); + errors$1 = (y = (shift), y < 32 ? (errors$1 << y) : 0) >> 0; + denormalExp = flt.bias - 63 >> 0; + extrabits = 0; + if (f.exp <= denormalExp) { + extrabits = (((63 - flt.mantbits >>> 0) + 1 >>> 0) + ((denormalExp - f.exp >> 0) >>> 0) >>> 0); + } else { + extrabits = (63 - flt.mantbits >>> 0); } - _tmp$78 = layout; _tmp$79 = 0; _tmp$80 = ""; prefix = _tmp$78; std = _tmp$79; suffix = _tmp$80; - return [prefix, std, suffix]; - }; - match = function(s1, s2) { - var i, c1, c2; - i = 0; - while (i < s1.length) { - c1 = s1.charCodeAt(i); - c2 = s2.charCodeAt(i); - if (!((c1 === c2))) { - c1 = (c1 | (32)) >>> 0; - c2 = (c2 | (32)) >>> 0; - if (!((c1 === c2)) || c1 < 97 || c1 > 122) { - return false; - } - } - i = i + (1) >> 0; + halfway = $shiftLeft64(new $Uint64(0, 1), ((extrabits - 1 >>> 0))); + mant_extra = (x$2 = f.mant, x$3 = (x$4 = $shiftLeft64(new $Uint64(0, 1), extrabits), new $Uint64(x$4.$high - 0, x$4.$low - 1)), new $Uint64(x$2.$high & x$3.$high, (x$2.$low & x$3.$low) >>> 0)); + if ((x$5 = (x$6 = new $Int64(halfway.$high, halfway.$low), x$7 = new $Int64(0, errors$1), new $Int64(x$6.$high - x$7.$high, x$6.$low - x$7.$low)), x$8 = new $Int64(mant_extra.$high, mant_extra.$low), (x$5.$high < x$8.$high || (x$5.$high === x$8.$high && x$5.$low < x$8.$low))) && (x$9 = new $Int64(mant_extra.$high, mant_extra.$low), x$10 = (x$11 = new $Int64(halfway.$high, halfway.$low), x$12 = new $Int64(0, errors$1), new $Int64(x$11.$high + x$12.$high, x$11.$low + x$12.$low)), (x$9.$high < x$10.$high || (x$9.$high === x$10.$high && x$9.$low < x$10.$low)))) { + ok = false; + return ok; } - return true; + ok = true; + return ok; }; - lookup = function(tab, val) { - var _ref, _i, i, v; - _ref = tab; - _i = 0; - while (_i < _ref.$length) { - i = _i; - v = ((_i < 0 || _i >= _ref.$length) ? $throwRuntimeError("index out of range") : _ref.$array[_ref.$offset + _i]); - if (val.length >= v.length && match(val.substring(0, v.length), v)) { - return [i, val.substring(v.length), $ifaceNil]; + extFloat.prototype.AssignDecimal = function(mantissa, exp10, neg, trunc, flt) { return this.$val.AssignDecimal(mantissa, exp10, neg, trunc, flt); }; + extFloat.Ptr.prototype.frexp10 = function() { + var exp10 = 0, index = 0, f, _q, x, approxExp10, _q$1, i, exp, _tmp, _tmp$1; + f = this; + approxExp10 = (_q = (x = (-46 - f.exp >> 0), (((x >>> 16 << 16) * 28 >> 0) + (x << 16 >>> 16) * 28) >> 0) / 93, (_q === _q && _q !== 1/0 && _q !== -1/0) ? _q >> 0 : $throwRuntimeError("integer divide by zero")); + i = (_q$1 = ((approxExp10 - -348 >> 0)) / 8, (_q$1 === _q$1 && _q$1 !== 1/0 && _q$1 !== -1/0) ? _q$1 >> 0 : $throwRuntimeError("integer divide by zero")); + Loop: + while (true) { + exp = (f.exp + ((i < 0 || i >= powersOfTen.length) ? $throwRuntimeError("index out of range") : powersOfTen[i]).exp >> 0) + 64 >> 0; + if (exp < -60) { + i = i + (1) >> 0; + } else if (exp > -32) { + i = i - (1) >> 0; + } else { + break Loop; } - _i++; } - return [-1, val, errBad]; + f.Multiply($clone(((i < 0 || i >= powersOfTen.length) ? $throwRuntimeError("index out of range") : powersOfTen[i]), extFloat)); + _tmp = -((-348 + ((((i >>> 16 << 16) * 8 >> 0) + (i << 16 >>> 16) * 8) >> 0) >> 0)); _tmp$1 = i; exp10 = _tmp; index = _tmp$1; + return [exp10, index]; }; - appendUint = function(b, x, pad) { - var _q, _r, buf, n, _r$1, _q$1; - if (x < 10) { - if (!((pad === 0))) { - b = $append(b, pad); + extFloat.prototype.frexp10 = function() { return this.$val.frexp10(); }; + frexp10Many = function(a, b, c) { + var exp10 = 0, _tuple, i; + _tuple = c.frexp10(); exp10 = _tuple[0]; i = _tuple[1]; + a.Multiply($clone(((i < 0 || i >= powersOfTen.length) ? $throwRuntimeError("index out of range") : powersOfTen[i]), extFloat)); + b.Multiply($clone(((i < 0 || i >= powersOfTen.length) ? $throwRuntimeError("index out of range") : powersOfTen[i]), extFloat)); + return exp10; + }; + extFloat.Ptr.prototype.FixedDecimal = function(d, n) { + var f, x, _tuple, exp10, shift, integer, x$1, x$2, fraction, nonAsciiName, needed, integerDigits, pow10, _tmp, _tmp$1, i, pow, x$3, rest, x$4, _q, x$5, buf, pos, v, _q$1, v1, i$1, x$6, x$7, nd, x$8, x$9, digit, x$10, x$11, x$12, ok, i$2, x$13; + f = this; + if ((x = f.mant, (x.$high === 0 && x.$low === 0))) { + d.nd = 0; + d.dp = 0; + d.neg = f.neg; + return true; + } + if (n === 0) { + $panic(new $String("strconv: internal error: extFloat.FixedDecimal called with n == 0")); + } + f.Normalize(); + _tuple = f.frexp10(); exp10 = _tuple[0]; + shift = (-f.exp >>> 0); + integer = ($shiftRightUint64(f.mant, shift).$low >>> 0); + fraction = (x$1 = f.mant, x$2 = $shiftLeft64(new $Uint64(0, integer), shift), new $Uint64(x$1.$high - x$2.$high, x$1.$low - x$2.$low)); + nonAsciiName = new $Uint64(0, 1); + needed = n; + integerDigits = 0; + pow10 = new $Uint64(0, 1); + _tmp = 0; _tmp$1 = new $Uint64(0, 1); i = _tmp; pow = _tmp$1; + while (i < 20) { + if ((x$3 = new $Uint64(0, integer), (pow.$high > x$3.$high || (pow.$high === x$3.$high && pow.$low > x$3.$low)))) { + integerDigits = i; + break; } - return $append(b, ((48 + x >>> 0) << 24 >>> 24)); + pow = $mul64(pow, (new $Uint64(0, 10))); + i = i + (1) >> 0; } - if (x < 100) { - b = $append(b, ((48 + (_q = x / 10, (_q === _q && _q !== 1/0 && _q !== -1/0) ? _q >>> 0 : $throwRuntimeError("integer divide by zero")) >>> 0) << 24 >>> 24)); - b = $append(b, ((48 + (_r = x % 10, _r === _r ? _r : $throwRuntimeError("integer divide by zero")) >>> 0) << 24 >>> 24)); - return b; + rest = integer; + if (integerDigits > needed) { + pow10 = (x$4 = integerDigits - needed >> 0, ((x$4 < 0 || x$4 >= uint64pow10.length) ? $throwRuntimeError("index out of range") : uint64pow10[x$4])); + integer = (_q = integer / ((pow10.$low >>> 0)), (_q === _q && _q !== 1/0 && _q !== -1/0) ? _q >>> 0 : $throwRuntimeError("integer divide by zero")); + rest = rest - ((x$5 = (pow10.$low >>> 0), (((integer >>> 16 << 16) * x$5 >>> 0) + (integer << 16 >>> 16) * x$5) >>> 0)) >>> 0; + } else { + rest = 0; } buf = ($arrayType($Uint8, 32)).zero(); $copy(buf, ($arrayType($Uint8, 32)).zero(), ($arrayType($Uint8, 32))); - n = 32; - if (x === 0) { - return $append(b, 48); + pos = 32; + v = integer; + while (v > 0) { + v1 = (_q$1 = v / 10, (_q$1 === _q$1 && _q$1 !== 1/0 && _q$1 !== -1/0) ? _q$1 >>> 0 : $throwRuntimeError("integer divide by zero")); + v = v - (((((10 >>> 16 << 16) * v1 >>> 0) + (10 << 16 >>> 16) * v1) >>> 0)) >>> 0; + pos = pos - (1) >> 0; + (pos < 0 || pos >= buf.length) ? $throwRuntimeError("index out of range") : buf[pos] = ((v + 48 >>> 0) << 24 >>> 24); + v = v1; } - while (x >= 10) { - n = n - (1) >> 0; - (n < 0 || n >= buf.length) ? $throwRuntimeError("index out of range") : buf[n] = (((_r$1 = x % 10, _r$1 === _r$1 ? _r$1 : $throwRuntimeError("integer divide by zero")) + 48 >>> 0) << 24 >>> 24); - x = (_q$1 = x / (10), (_q$1 === _q$1 && _q$1 !== 1/0 && _q$1 !== -1/0) ? _q$1 >>> 0 : $throwRuntimeError("integer divide by zero")); + i$1 = pos; + while (i$1 < 32) { + (x$6 = d.d, x$7 = i$1 - pos >> 0, (x$7 < 0 || x$7 >= x$6.$length) ? $throwRuntimeError("index out of range") : x$6.$array[x$6.$offset + x$7] = ((i$1 < 0 || i$1 >= buf.length) ? $throwRuntimeError("index out of range") : buf[i$1])); + i$1 = i$1 + (1) >> 0; } - n = n - (1) >> 0; - (n < 0 || n >= buf.length) ? $throwRuntimeError("index out of range") : buf[n] = ((x + 48 >>> 0) << 24 >>> 24); - return $appendSlice(b, $subslice(new ($sliceType($Uint8))(buf), n)); - }; - atoi = function(s) { - var x = 0, err = $ifaceNil, neg, _tuple$1, q, rem, _tmp, _tmp$1, _tmp$2, _tmp$3; - neg = false; - if (!(s === "") && ((s.charCodeAt(0) === 45) || (s.charCodeAt(0) === 43))) { - neg = s.charCodeAt(0) === 45; - s = s.substring(1); + nd = 32 - pos >> 0; + d.nd = nd; + d.dp = integerDigits + exp10 >> 0; + needed = needed - (nd) >> 0; + if (needed > 0) { + if (!((rest === 0)) || !((pow10.$high === 0 && pow10.$low === 1))) { + $panic(new $String("strconv: internal error, rest != 0 but needed > 0")); + } + while (needed > 0) { + fraction = $mul64(fraction, (new $Uint64(0, 10))); + nonAsciiName = $mul64(nonAsciiName, (new $Uint64(0, 10))); + if ((x$8 = $mul64(new $Uint64(0, 2), nonAsciiName), x$9 = $shiftLeft64(new $Uint64(0, 1), shift), (x$8.$high > x$9.$high || (x$8.$high === x$9.$high && x$8.$low > x$9.$low)))) { + return false; + } + digit = $shiftRightUint64(fraction, shift); + (x$10 = d.d, (nd < 0 || nd >= x$10.$length) ? $throwRuntimeError("index out of range") : x$10.$array[x$10.$offset + nd] = (new $Uint64(digit.$high + 0, digit.$low + 48).$low << 24 >>> 24)); + fraction = (x$11 = $shiftLeft64(digit, shift), new $Uint64(fraction.$high - x$11.$high, fraction.$low - x$11.$low)); + nd = nd + (1) >> 0; + needed = needed - (1) >> 0; + } + d.nd = nd; } - _tuple$1 = leadingInt(s); q = _tuple$1[0]; rem = _tuple$1[1]; err = _tuple$1[2]; - x = ((q.$low + ((q.$high >> 31) * 4294967296)) >> 0); - if (!($interfaceIsEqual(err, $ifaceNil)) || !(rem === "")) { - _tmp = 0; _tmp$1 = atoiError; x = _tmp; err = _tmp$1; - return [x, err]; + ok = adjustLastDigitFixed(d, (x$12 = $shiftLeft64(new $Uint64(0, rest), shift), new $Uint64(x$12.$high | fraction.$high, (x$12.$low | fraction.$low) >>> 0)), pow10, shift, nonAsciiName); + if (!ok) { + return false; } - if (neg) { - x = -x; + i$2 = d.nd - 1 >> 0; + while (i$2 >= 0) { + if (!(((x$13 = d.d, ((i$2 < 0 || i$2 >= x$13.$length) ? $throwRuntimeError("index out of range") : x$13.$array[x$13.$offset + i$2])) === 48))) { + d.nd = i$2 + 1 >> 0; + break; + } + i$2 = i$2 - (1) >> 0; } - _tmp$2 = x; _tmp$3 = $ifaceNil; x = _tmp$2; err = _tmp$3; - return [x, err]; + return true; }; - formatNano = function(b, nanosec, n, trim) { - var u, buf, start, _r, _q, x; - u = nanosec; - buf = ($arrayType($Uint8, 9)).zero(); $copy(buf, ($arrayType($Uint8, 9)).zero(), ($arrayType($Uint8, 9))); - start = 9; - while (start > 0) { - start = start - (1) >> 0; - (start < 0 || start >= buf.length) ? $throwRuntimeError("index out of range") : buf[start] = (((_r = u % 10, _r === _r ? _r : $throwRuntimeError("integer divide by zero")) + 48 >>> 0) << 24 >>> 24); - u = (_q = u / (10), (_q === _q && _q !== 1/0 && _q !== -1/0) ? _q >>> 0 : $throwRuntimeError("integer divide by zero")); + extFloat.prototype.FixedDecimal = function(d, n) { return this.$val.FixedDecimal(d, n); }; + adjustLastDigitFixed = function(d, num, den, shift, nonAsciiName) { + var x, x$1, x$2, x$3, x$4, x$5, x$6, i, x$7, x$8, _lhs, _index; + if ((x = $shiftLeft64(den, shift), (num.$high > x.$high || (num.$high === x.$high && num.$low > x.$low)))) { + $panic(new $String("strconv: num > den< 9) { - n = 9; + if ((x$1 = $mul64(new $Uint64(0, 2), nonAsciiName), x$2 = $shiftLeft64(den, shift), (x$1.$high > x$2.$high || (x$1.$high === x$2.$high && x$1.$low > x$2.$low)))) { + $panic(new $String("strconv: \xCE\xB5 > (den< 0 && ((x = n - 1 >> 0, ((x < 0 || x >= buf.length) ? $throwRuntimeError("index out of range") : buf[x])) === 48)) { - n = n - (1) >> 0; + if ((x$3 = $mul64(new $Uint64(0, 2), (new $Uint64(num.$high + nonAsciiName.$high, num.$low + nonAsciiName.$low))), x$4 = $shiftLeft64(den, shift), (x$3.$high < x$4.$high || (x$3.$high === x$4.$high && x$3.$low < x$4.$low)))) { + return true; + } + if ((x$5 = $mul64(new $Uint64(0, 2), (new $Uint64(num.$high - nonAsciiName.$high, num.$low - nonAsciiName.$low))), x$6 = $shiftLeft64(den, shift), (x$5.$high > x$6.$high || (x$5.$high === x$6.$high && x$5.$low > x$6.$low)))) { + i = d.nd - 1 >> 0; + while (i >= 0) { + if ((x$7 = d.d, ((i < 0 || i >= x$7.$length) ? $throwRuntimeError("index out of range") : x$7.$array[x$7.$offset + i])) === 57) { + d.nd = d.nd - (1) >> 0; + } else { + break; + } + i = i - (1) >> 0; } - if (n === 0) { - return b; + if (i < 0) { + (x$8 = d.d, (0 < 0 || 0 >= x$8.$length) ? $throwRuntimeError("index out of range") : x$8.$array[x$8.$offset + 0] = 49); + d.nd = 1; + d.dp = d.dp + (1) >> 0; + } else { + _lhs = d.d; _index = i; (_index < 0 || _index >= _lhs.$length) ? $throwRuntimeError("index out of range") : _lhs.$array[_lhs.$offset + _index] = ((_index < 0 || _index >= _lhs.$length) ? $throwRuntimeError("index out of range") : _lhs.$array[_lhs.$offset + _index]) + (1) << 24 >>> 24; } + return true; } - b = $append(b, 46); - return $appendSlice(b, $subslice(new ($sliceType($Uint8))(buf), 0, n)); - }; - Time.Ptr.prototype.String = function() { - var t; - t = new Time.Ptr(); $copy(t, this, Time); - return t.Format("2006-01-02 15:04:05.999999999 -0700 MST"); + return false; }; - Time.prototype.String = function() { return this.$val.String(); }; - Time.Ptr.prototype.Format = function(layout) { - var t, _tuple$1, name, offset, abs, year, month, day, hour, min, sec, b, buf, max, _tuple$2, prefix, std, suffix, _tuple$3, _tuple$4, _ref, y, _r, y$1, m, s, _r$1, hr, _r$2, hr$1, _q, zone$1, absoffset, _q$1, _r$3, _r$4, _q$2, zone$2, _q$3, _r$5; - t = new Time.Ptr(); $copy(t, this, Time); - _tuple$1 = t.locabs(); name = _tuple$1[0]; offset = _tuple$1[1]; abs = _tuple$1[2]; - year = -1; - month = 0; - day = 0; - hour = -1; - min = 0; - sec = 0; - b = ($sliceType($Uint8)).nil; - buf = ($arrayType($Uint8, 64)).zero(); $copy(buf, ($arrayType($Uint8, 64)).zero(), ($arrayType($Uint8, 64))); - max = layout.length + 10 >> 0; - if (max <= 64) { - b = $subslice(new ($sliceType($Uint8))(buf), 0, 0); - } else { - b = ($sliceType($Uint8)).make(0, max); + extFloat.Ptr.prototype.ShortestDecimal = function(d, lower, upper) { + var f, x, buf, n, v, v1, x$1, nd, i, x$2, x$3, _tmp, _tmp$1, x$4, x$5, exp10, x$6, x$7, x$8, x$9, shift, integer, x$10, x$11, fraction, x$12, x$13, allowance, x$14, x$15, targetDiff, integerDigits, _tmp$2, _tmp$3, i$1, pow, x$16, i$2, x$17, pow$1, _q, digit, x$18, x$19, x$20, currentDiff, digit$1, multiplier, x$21, x$22, x$23, x$24; + f = this; + if ((x = f.mant, (x.$high === 0 && x.$low === 0))) { + d.nd = 0; + d.dp = 0; + d.neg = f.neg; + return true; } - while (!(layout === "")) { - _tuple$2 = nextStdChunk(layout); prefix = _tuple$2[0]; std = _tuple$2[1]; suffix = _tuple$2[2]; - if (!(prefix === "")) { - b = $appendSlice(b, new ($sliceType($Uint8))($stringToBytes(prefix))); + if ((f.exp === 0) && $equal(lower, f, extFloat) && $equal(lower, upper, extFloat)) { + buf = ($arrayType($Uint8, 24)).zero(); $copy(buf, ($arrayType($Uint8, 24)).zero(), ($arrayType($Uint8, 24))); + n = 23; + v = f.mant; + while ((v.$high > 0 || (v.$high === 0 && v.$low > 0))) { + v1 = $div64(v, new $Uint64(0, 10), false); + v = (x$1 = $mul64(new $Uint64(0, 10), v1), new $Uint64(v.$high - x$1.$high, v.$low - x$1.$low)); + (n < 0 || n >= buf.length) ? $throwRuntimeError("index out of range") : buf[n] = (new $Uint64(v.$high + 0, v.$low + 48).$low << 24 >>> 24); + n = n - (1) >> 0; + v = v1; } - if (std === 0) { + nd = (24 - n >> 0) - 1 >> 0; + i = 0; + while (i < nd) { + (x$3 = d.d, (i < 0 || i >= x$3.$length) ? $throwRuntimeError("index out of range") : x$3.$array[x$3.$offset + i] = (x$2 = (n + 1 >> 0) + i >> 0, ((x$2 < 0 || x$2 >= buf.length) ? $throwRuntimeError("index out of range") : buf[x$2]))); + i = i + (1) >> 0; + } + _tmp = nd; _tmp$1 = nd; d.nd = _tmp; d.dp = _tmp$1; + while (d.nd > 0 && ((x$4 = d.d, x$5 = d.nd - 1 >> 0, ((x$5 < 0 || x$5 >= x$4.$length) ? $throwRuntimeError("index out of range") : x$4.$array[x$4.$offset + x$5])) === 48)) { + d.nd = d.nd - (1) >> 0; + } + if (d.nd === 0) { + d.dp = 0; + } + d.neg = f.neg; + return true; + } + upper.Normalize(); + if (f.exp > upper.exp) { + f.mant = $shiftLeft64(f.mant, (((f.exp - upper.exp >> 0) >>> 0))); + f.exp = upper.exp; + } + if (lower.exp > upper.exp) { + lower.mant = $shiftLeft64(lower.mant, (((lower.exp - upper.exp >> 0) >>> 0))); + lower.exp = upper.exp; + } + exp10 = frexp10Many(lower, f, upper); + upper.mant = (x$6 = upper.mant, x$7 = new $Uint64(0, 1), new $Uint64(x$6.$high + x$7.$high, x$6.$low + x$7.$low)); + lower.mant = (x$8 = lower.mant, x$9 = new $Uint64(0, 1), new $Uint64(x$8.$high - x$9.$high, x$8.$low - x$9.$low)); + shift = (-upper.exp >>> 0); + integer = ($shiftRightUint64(upper.mant, shift).$low >>> 0); + fraction = (x$10 = upper.mant, x$11 = $shiftLeft64(new $Uint64(0, integer), shift), new $Uint64(x$10.$high - x$11.$high, x$10.$low - x$11.$low)); + allowance = (x$12 = upper.mant, x$13 = lower.mant, new $Uint64(x$12.$high - x$13.$high, x$12.$low - x$13.$low)); + targetDiff = (x$14 = upper.mant, x$15 = f.mant, new $Uint64(x$14.$high - x$15.$high, x$14.$low - x$15.$low)); + integerDigits = 0; + _tmp$2 = 0; _tmp$3 = new $Uint64(0, 1); i$1 = _tmp$2; pow = _tmp$3; + while (i$1 < 20) { + if ((x$16 = new $Uint64(0, integer), (pow.$high > x$16.$high || (pow.$high === x$16.$high && pow.$low > x$16.$low)))) { + integerDigits = i$1; break; } - layout = suffix; - if (year < 0 && !(((std & 256) === 0))) { - _tuple$3 = absDate(abs, true); year = _tuple$3[0]; month = _tuple$3[1]; day = _tuple$3[2]; + pow = $mul64(pow, (new $Uint64(0, 10))); + i$1 = i$1 + (1) >> 0; + } + i$2 = 0; + while (i$2 < integerDigits) { + pow$1 = (x$17 = (integerDigits - i$2 >> 0) - 1 >> 0, ((x$17 < 0 || x$17 >= uint64pow10.length) ? $throwRuntimeError("index out of range") : uint64pow10[x$17])); + digit = (_q = integer / (pow$1.$low >>> 0), (_q === _q && _q !== 1/0 && _q !== -1/0) ? _q >>> 0 : $throwRuntimeError("integer divide by zero")); + (x$18 = d.d, (i$2 < 0 || i$2 >= x$18.$length) ? $throwRuntimeError("index out of range") : x$18.$array[x$18.$offset + i$2] = ((digit + 48 >>> 0) << 24 >>> 24)); + integer = integer - ((x$19 = (pow$1.$low >>> 0), (((digit >>> 16 << 16) * x$19 >>> 0) + (digit << 16 >>> 16) * x$19) >>> 0)) >>> 0; + currentDiff = (x$20 = $shiftLeft64(new $Uint64(0, integer), shift), new $Uint64(x$20.$high + fraction.$high, x$20.$low + fraction.$low)); + if ((currentDiff.$high < allowance.$high || (currentDiff.$high === allowance.$high && currentDiff.$low < allowance.$low))) { + d.nd = i$2 + 1 >> 0; + d.dp = integerDigits + exp10 >> 0; + d.neg = f.neg; + return adjustLastDigit(d, currentDiff, targetDiff, allowance, $shiftLeft64(pow$1, shift), new $Uint64(0, 2)); } - if (hour < 0 && !(((std & 512) === 0))) { - _tuple$4 = absClock(abs); hour = _tuple$4[0]; min = _tuple$4[1]; sec = _tuple$4[2]; + i$2 = i$2 + (1) >> 0; + } + d.nd = integerDigits; + d.dp = d.nd + exp10 >> 0; + d.neg = f.neg; + digit$1 = 0; + multiplier = new $Uint64(0, 1); + while (true) { + fraction = $mul64(fraction, (new $Uint64(0, 10))); + multiplier = $mul64(multiplier, (new $Uint64(0, 10))); + digit$1 = ($shiftRightUint64(fraction, shift).$low >> 0); + (x$21 = d.d, x$22 = d.nd, (x$22 < 0 || x$22 >= x$21.$length) ? $throwRuntimeError("index out of range") : x$21.$array[x$21.$offset + x$22] = ((digit$1 + 48 >> 0) << 24 >>> 24)); + d.nd = d.nd + (1) >> 0; + fraction = (x$23 = $shiftLeft64(new $Uint64(0, digit$1), shift), new $Uint64(fraction.$high - x$23.$high, fraction.$low - x$23.$low)); + if ((x$24 = $mul64(allowance, multiplier), (fraction.$high < x$24.$high || (fraction.$high === x$24.$high && fraction.$low < x$24.$low)))) { + return adjustLastDigit(d, fraction, $mul64(targetDiff, multiplier), $mul64(allowance, multiplier), $shiftLeft64(new $Uint64(0, 1), shift), $mul64(multiplier, new $Uint64(0, 2))); } - _ref = std & 65535; - switch (0) { default: if (_ref === 274) { - y = year; - if (y < 0) { - y = -y; - } - b = appendUint(b, ((_r = y % 100, _r === _r ? _r : $throwRuntimeError("integer divide by zero")) >>> 0), 48); - } else if (_ref === 273) { - y$1 = year; - if (year <= -1000) { - b = $append(b, 45); - y$1 = -y$1; - } else if (year <= -100) { - b = $appendSlice(b, new ($sliceType($Uint8))($stringToBytes("-0"))); - y$1 = -y$1; - } else if (year <= -10) { - b = $appendSlice(b, new ($sliceType($Uint8))($stringToBytes("-00"))); - y$1 = -y$1; - } else if (year < 0) { - b = $appendSlice(b, new ($sliceType($Uint8))($stringToBytes("-000"))); - y$1 = -y$1; - } else if (year < 10) { - b = $appendSlice(b, new ($sliceType($Uint8))($stringToBytes("000"))); - } else if (year < 100) { - b = $appendSlice(b, new ($sliceType($Uint8))($stringToBytes("00"))); - } else if (year < 1000) { - b = $append(b, 48); - } - b = appendUint(b, (y$1 >>> 0), 0); - } else if (_ref === 258) { - b = $appendSlice(b, new ($sliceType($Uint8))($stringToBytes((new Month(month)).String().substring(0, 3)))); - } else if (_ref === 257) { - m = (new Month(month)).String(); - b = $appendSlice(b, new ($sliceType($Uint8))($stringToBytes(m))); - } else if (_ref === 259) { - b = appendUint(b, (month >>> 0), 0); - } else if (_ref === 260) { - b = appendUint(b, (month >>> 0), 48); - } else if (_ref === 262) { - b = $appendSlice(b, new ($sliceType($Uint8))($stringToBytes((new Weekday(absWeekday(abs))).String().substring(0, 3)))); - } else if (_ref === 261) { - s = (new Weekday(absWeekday(abs))).String(); - b = $appendSlice(b, new ($sliceType($Uint8))($stringToBytes(s))); - } else if (_ref === 263) { - b = appendUint(b, (day >>> 0), 0); - } else if (_ref === 264) { - b = appendUint(b, (day >>> 0), 32); - } else if (_ref === 265) { - b = appendUint(b, (day >>> 0), 48); - } else if (_ref === 522) { - b = appendUint(b, (hour >>> 0), 48); - } else if (_ref === 523) { - hr = (_r$1 = hour % 12, _r$1 === _r$1 ? _r$1 : $throwRuntimeError("integer divide by zero")); - if (hr === 0) { - hr = 12; - } - b = appendUint(b, (hr >>> 0), 0); - } else if (_ref === 524) { - hr$1 = (_r$2 = hour % 12, _r$2 === _r$2 ? _r$2 : $throwRuntimeError("integer divide by zero")); - if (hr$1 === 0) { - hr$1 = 12; - } - b = appendUint(b, (hr$1 >>> 0), 48); - } else if (_ref === 525) { - b = appendUint(b, (min >>> 0), 0); - } else if (_ref === 526) { - b = appendUint(b, (min >>> 0), 48); - } else if (_ref === 527) { - b = appendUint(b, (sec >>> 0), 0); - } else if (_ref === 528) { - b = appendUint(b, (sec >>> 0), 48); - } else if (_ref === 531) { - if (hour >= 12) { - b = $appendSlice(b, new ($sliceType($Uint8))($stringToBytes("PM"))); - } else { - b = $appendSlice(b, new ($sliceType($Uint8))($stringToBytes("AM"))); - } - } else if (_ref === 532) { - if (hour >= 12) { - b = $appendSlice(b, new ($sliceType($Uint8))($stringToBytes("pm"))); - } else { - b = $appendSlice(b, new ($sliceType($Uint8))($stringToBytes("am"))); - } - } else if (_ref === 22 || _ref === 24 || _ref === 23 || _ref === 25 || _ref === 26 || _ref === 29 || _ref === 27 || _ref === 30) { - if ((offset === 0) && ((std === 22) || (std === 24) || (std === 23) || (std === 25))) { - b = $append(b, 90); - break; - } - zone$1 = (_q = offset / 60, (_q === _q && _q !== 1/0 && _q !== -1/0) ? _q >> 0 : $throwRuntimeError("integer divide by zero")); - absoffset = offset; - if (zone$1 < 0) { - b = $append(b, 45); - zone$1 = -zone$1; - absoffset = -absoffset; - } else { - b = $append(b, 43); - } - b = appendUint(b, ((_q$1 = zone$1 / 60, (_q$1 === _q$1 && _q$1 !== 1/0 && _q$1 !== -1/0) ? _q$1 >> 0 : $throwRuntimeError("integer divide by zero")) >>> 0), 48); - if ((std === 24) || (std === 29)) { - b = $append(b, 58); - } - b = appendUint(b, ((_r$3 = zone$1 % 60, _r$3 === _r$3 ? _r$3 : $throwRuntimeError("integer divide by zero")) >>> 0), 48); - if ((std === 23) || (std === 27) || (std === 30) || (std === 25)) { - if ((std === 30) || (std === 25)) { - b = $append(b, 58); - } - b = appendUint(b, ((_r$4 = absoffset % 60, _r$4 === _r$4 ? _r$4 : $throwRuntimeError("integer divide by zero")) >>> 0), 48); - } - } else if (_ref === 21) { - if (!(name === "")) { - b = $appendSlice(b, new ($sliceType($Uint8))($stringToBytes(name))); - break; - } - zone$2 = (_q$2 = offset / 60, (_q$2 === _q$2 && _q$2 !== 1/0 && _q$2 !== -1/0) ? _q$2 >> 0 : $throwRuntimeError("integer divide by zero")); - if (zone$2 < 0) { - b = $append(b, 45); - zone$2 = -zone$2; - } else { - b = $append(b, 43); - } - b = appendUint(b, ((_q$3 = zone$2 / 60, (_q$3 === _q$3 && _q$3 !== 1/0 && _q$3 !== -1/0) ? _q$3 >> 0 : $throwRuntimeError("integer divide by zero")) >>> 0), 48); - b = appendUint(b, ((_r$5 = zone$2 % 60, _r$5 === _r$5 ? _r$5 : $throwRuntimeError("integer divide by zero")) >>> 0), 48); - } else if (_ref === 31 || _ref === 32) { - b = formatNano(b, (t.Nanosecond() >>> 0), std >> 16 >> 0, (std & 65535) === 32); - } } } - return $bytesToString(b); - }; - Time.prototype.Format = function(layout) { return this.$val.Format(layout); }; - quote = function(s) { - return "\"" + s + "\""; }; - ParseError.Ptr.prototype.Error = function() { - var e; - e = this; - if (e.Message === "") { - return "parsing time " + quote(e.Value) + " as " + quote(e.Layout) + ": cannot parse " + quote(e.ValueElem) + " as " + quote(e.LayoutElem); + extFloat.prototype.ShortestDecimal = function(d, lower, upper) { return this.$val.ShortestDecimal(d, lower, upper); }; + adjustLastDigit = function(d, currentDiff, targetDiff, maxDiff, ulpDecimal, ulpBinary) { + var x, x$1, x$2, x$3, _lhs, _index, x$4, x$5, x$6, x$7, x$8, x$9, x$10; + if ((x = $mul64(new $Uint64(0, 2), ulpBinary), (ulpDecimal.$high < x.$high || (ulpDecimal.$high === x.$high && ulpDecimal.$low < x.$low)))) { + return false; } - return "parsing time " + quote(e.Value) + e.Message; - }; - ParseError.prototype.Error = function() { return this.$val.Error(); }; - isDigit = function(s, i) { - var c; - if (s.length <= i) { + while ((x$1 = (x$2 = (x$3 = $div64(ulpDecimal, new $Uint64(0, 2), false), new $Uint64(currentDiff.$high + x$3.$high, currentDiff.$low + x$3.$low)), new $Uint64(x$2.$high + ulpBinary.$high, x$2.$low + ulpBinary.$low)), (x$1.$high < targetDiff.$high || (x$1.$high === targetDiff.$high && x$1.$low < targetDiff.$low)))) { + _lhs = d.d; _index = d.nd - 1 >> 0; (_index < 0 || _index >= _lhs.$length) ? $throwRuntimeError("index out of range") : _lhs.$array[_lhs.$offset + _index] = ((_index < 0 || _index >= _lhs.$length) ? $throwRuntimeError("index out of range") : _lhs.$array[_lhs.$offset + _index]) - (1) << 24 >>> 24; + currentDiff = (x$4 = ulpDecimal, new $Uint64(currentDiff.$high + x$4.$high, currentDiff.$low + x$4.$low)); + } + if ((x$5 = new $Uint64(currentDiff.$high + ulpDecimal.$high, currentDiff.$low + ulpDecimal.$low), x$6 = (x$7 = (x$8 = $div64(ulpDecimal, new $Uint64(0, 2), false), new $Uint64(targetDiff.$high + x$8.$high, targetDiff.$low + x$8.$low)), new $Uint64(x$7.$high + ulpBinary.$high, x$7.$low + ulpBinary.$low)), (x$5.$high < x$6.$high || (x$5.$high === x$6.$high && x$5.$low <= x$6.$low)))) { return false; } - c = s.charCodeAt(i); - return 48 <= c && c <= 57; + if ((currentDiff.$high < ulpBinary.$high || (currentDiff.$high === ulpBinary.$high && currentDiff.$low < ulpBinary.$low)) || (x$9 = new $Uint64(maxDiff.$high - ulpBinary.$high, maxDiff.$low - ulpBinary.$low), (currentDiff.$high > x$9.$high || (currentDiff.$high === x$9.$high && currentDiff.$low > x$9.$low)))) { + return false; + } + if ((d.nd === 1) && ((x$10 = d.d, ((0 < 0 || 0 >= x$10.$length) ? $throwRuntimeError("index out of range") : x$10.$array[x$10.$offset + 0])) === 48)) { + d.nd = 0; + d.dp = 0; + } + return true; }; - getnum = function(s, fixed) { - var x; - if (!isDigit(s, 0)) { - return [0, s, errBad]; + FormatFloat = $pkg.FormatFloat = function(f, fmt, prec, bitSize) { + return $bytesToString(genericFtoa(($sliceType($Uint8)).make(0, max(prec + 4 >> 0, 24)), f, fmt, prec, bitSize)); + }; + AppendFloat = $pkg.AppendFloat = function(dst, f, fmt, prec, bitSize) { + return genericFtoa(dst, f, fmt, prec, bitSize); + }; + genericFtoa = function(dst, val, fmt, prec, bitSize) { + var bits, flt, _ref, x, neg, y, exp, x$1, x$2, mant, _ref$1, y$1, s, x$3, digs, ok, shortest, f, _tuple, lower, upper, buf, _ref$2, digits, _ref$3, buf$1, f$1; + bits = new $Uint64(0, 0); + flt = ($ptrType(floatInfo)).nil; + _ref = bitSize; + if (_ref === 32) { + bits = new $Uint64(0, math.Float32bits(val)); + flt = float32info; + } else if (_ref === 64) { + bits = math.Float64bits(val); + flt = float64info; + } else { + $panic(new $String("strconv: illegal AppendFloat/FormatFloat bitSize")); } - if (!isDigit(s, 1)) { - if (fixed) { - return [0, s, errBad]; + neg = !((x = $shiftRightUint64(bits, ((flt.expbits + flt.mantbits >>> 0))), (x.$high === 0 && x.$low === 0))); + exp = ($shiftRightUint64(bits, flt.mantbits).$low >> 0) & ((((y = flt.expbits, y < 32 ? (1 << y) : 0) >> 0) - 1 >> 0)); + mant = (x$1 = (x$2 = $shiftLeft64(new $Uint64(0, 1), flt.mantbits), new $Uint64(x$2.$high - 0, x$2.$low - 1)), new $Uint64(bits.$high & x$1.$high, (bits.$low & x$1.$low) >>> 0)); + _ref$1 = exp; + if (_ref$1 === (((y$1 = flt.expbits, y$1 < 32 ? (1 << y$1) : 0) >> 0) - 1 >> 0)) { + s = ""; + if (!((mant.$high === 0 && mant.$low === 0))) { + s = "NaN"; + } else if (neg) { + s = "-Inf"; + } else { + s = "+Inf"; } - return [((s.charCodeAt(0) - 48 << 24 >>> 24) >> 0), s.substring(1), $ifaceNil]; + return $appendSlice(dst, new ($sliceType($Uint8))($stringToBytes(s))); + } else if (_ref$1 === 0) { + exp = exp + (1) >> 0; + } else { + mant = (x$3 = $shiftLeft64(new $Uint64(0, 1), flt.mantbits), new $Uint64(mant.$high | x$3.$high, (mant.$low | x$3.$low) >>> 0)); } - return [(x = ((s.charCodeAt(0) - 48 << 24 >>> 24) >> 0), (((x >>> 16 << 16) * 10 >> 0) + (x << 16 >>> 16) * 10) >> 0) + ((s.charCodeAt(1) - 48 << 24 >>> 24) >> 0) >> 0, s.substring(2), $ifaceNil]; - }; - cutspace = function(s) { - while (s.length > 0 && (s.charCodeAt(0) === 32)) { - s = s.substring(1); + exp = exp + (flt.bias) >> 0; + if (fmt === 98) { + return fmtB(dst, neg, mant, exp, flt); } - return s; - }; - skip = function(value, prefix) { - while (prefix.length > 0) { - if (prefix.charCodeAt(0) === 32) { - if (value.length > 0 && !((value.charCodeAt(0) === 32))) { - return [value, errBad]; + if (!optimize) { + return bigFtoa(dst, prec, fmt, neg, mant, exp, flt); + } + digs = new decimalSlice.Ptr(); $copy(digs, new decimalSlice.Ptr(), decimalSlice); + ok = false; + shortest = prec < 0; + if (shortest) { + f = new extFloat.Ptr(); + _tuple = f.AssignComputeBounds(mant, exp, neg, flt); lower = new extFloat.Ptr(); $copy(lower, _tuple[0], extFloat); upper = new extFloat.Ptr(); $copy(upper, _tuple[1], extFloat); + buf = ($arrayType($Uint8, 32)).zero(); $copy(buf, ($arrayType($Uint8, 32)).zero(), ($arrayType($Uint8, 32))); + digs.d = new ($sliceType($Uint8))(buf); + ok = f.ShortestDecimal(digs, lower, upper); + if (!ok) { + return bigFtoa(dst, prec, fmt, neg, mant, exp, flt); + } + _ref$2 = fmt; + if (_ref$2 === 101 || _ref$2 === 69) { + prec = digs.nd - 1 >> 0; + } else if (_ref$2 === 102) { + prec = max(digs.nd - digs.dp >> 0, 0); + } else if (_ref$2 === 103 || _ref$2 === 71) { + prec = digs.nd; + } + } else if (!((fmt === 102))) { + digits = prec; + _ref$3 = fmt; + if (_ref$3 === 101 || _ref$3 === 69) { + digits = digits + (1) >> 0; + } else if (_ref$3 === 103 || _ref$3 === 71) { + if (prec === 0) { + prec = 1; } - prefix = cutspace(prefix); - value = cutspace(value); - continue; + digits = prec; } - if ((value.length === 0) || !((value.charCodeAt(0) === prefix.charCodeAt(0)))) { - return [value, errBad]; + if (digits <= 15) { + buf$1 = ($arrayType($Uint8, 24)).zero(); $copy(buf$1, ($arrayType($Uint8, 24)).zero(), ($arrayType($Uint8, 24))); + digs.d = new ($sliceType($Uint8))(buf$1); + f$1 = new extFloat.Ptr(mant, exp - (flt.mantbits >> 0) >> 0, neg); + ok = f$1.FixedDecimal(digs, digits); } - prefix = prefix.substring(1); - value = value.substring(1); } - return [value, $ifaceNil]; - }; - Parse = $pkg.Parse = function(layout, value) { - return parse(layout, value, $pkg.UTC, $pkg.Local); + if (!ok) { + return bigFtoa(dst, prec, fmt, neg, mant, exp, flt); + } + return formatDigits(dst, shortest, neg, $clone(digs, decimalSlice), prec, fmt); }; - parse = function(layout, value, defaultLocation, local) { - var _tmp, _tmp$1, alayout, avalue, rangeErrString, amSet, pmSet, year, month, day, hour, min, sec, nsec, z, zoneOffset, zoneName, err, _tuple$1, prefix, std, suffix, stdstr, _tuple$2, p, _ref, _tmp$2, _tmp$3, _tuple$3, _tmp$4, _tmp$5, _tuple$4, _tuple$5, _tuple$6, _tuple$7, _tuple$8, _tuple$9, _tuple$10, _tuple$11, _tuple$12, _tuple$13, _tuple$14, _tuple$15, n, _tuple$16, _tmp$6, _tmp$7, _ref$1, _tmp$8, _tmp$9, _ref$2, _tmp$10, _tmp$11, _tmp$12, _tmp$13, sign, hour$1, min$1, seconds, _tmp$14, _tmp$15, _tmp$16, _tmp$17, _tmp$18, _tmp$19, _tmp$20, _tmp$21, _tmp$22, _tmp$23, _tmp$24, _tmp$25, _tmp$26, _tmp$27, _tmp$28, _tmp$29, _tmp$30, _tmp$31, _tmp$32, _tmp$33, _tmp$34, _tmp$35, _tmp$36, _tmp$37, _tmp$38, _tmp$39, _tmp$40, _tmp$41, hr, mm, ss, _tuple$17, _tuple$18, _tuple$19, x, _ref$3, _tuple$20, n$1, ok, _tmp$42, _tmp$43, ndigit, _tuple$21, i, _tuple$22, t, x$1, x$2, _tuple$23, x$3, name, offset, t$1, _tuple$24, x$4, offset$1, ok$1, x$5, x$6, _tuple$25, x$7; - _tmp = layout; _tmp$1 = value; alayout = _tmp; avalue = _tmp$1; - rangeErrString = ""; - amSet = false; - pmSet = false; - year = 0; - month = 1; - day = 1; - hour = 0; - min = 0; - sec = 0; - nsec = 0; - z = ($ptrType(Location)).nil; - zoneOffset = -1; - zoneName = ""; - while (true) { - err = $ifaceNil; - _tuple$1 = nextStdChunk(layout); prefix = _tuple$1[0]; std = _tuple$1[1]; suffix = _tuple$1[2]; - stdstr = layout.substring(prefix.length, (layout.length - suffix.length >> 0)); - _tuple$2 = skip(value, prefix); value = _tuple$2[0]; err = _tuple$2[1]; - if (!($interfaceIsEqual(err, $ifaceNil))) { - return [new Time.Ptr(new $Int64(0, 0), 0, ($ptrType(Location)).nil), new ParseError.Ptr(alayout, avalue, prefix, value, "")]; + bigFtoa = function(dst, prec, fmt, neg, mant, exp, flt) { + var d, digs, shortest, _ref, _ref$1; + d = new decimal.Ptr(); + d.Assign(mant); + d.Shift(exp - (flt.mantbits >> 0) >> 0); + digs = new decimalSlice.Ptr(); $copy(digs, new decimalSlice.Ptr(), decimalSlice); + shortest = prec < 0; + if (shortest) { + roundShortest(d, mant, exp, flt); + $copy(digs, new decimalSlice.Ptr(new ($sliceType($Uint8))(d.d), d.nd, d.dp, false), decimalSlice); + _ref = fmt; + if (_ref === 101 || _ref === 69) { + prec = digs.nd - 1 >> 0; + } else if (_ref === 102) { + prec = max(digs.nd - digs.dp >> 0, 0); + } else if (_ref === 103 || _ref === 71) { + prec = digs.nd; } - if (std === 0) { - if (!((value.length === 0))) { - return [new Time.Ptr(new $Int64(0, 0), 0, ($ptrType(Location)).nil), new ParseError.Ptr(alayout, avalue, "", value, ": extra text: " + value)]; + } else { + _ref$1 = fmt; + if (_ref$1 === 101 || _ref$1 === 69) { + d.Round(prec + 1 >> 0); + } else if (_ref$1 === 102) { + d.Round(d.dp + prec >> 0); + } else if (_ref$1 === 103 || _ref$1 === 71) { + if (prec === 0) { + prec = 1; } - break; + d.Round(prec); } - layout = suffix; - p = ""; - _ref = std & 65535; - switch (0) { default: if (_ref === 274) { - if (value.length < 2) { - err = errBad; - break; - } - _tmp$2 = value.substring(0, 2); _tmp$3 = value.substring(2); p = _tmp$2; value = _tmp$3; - _tuple$3 = atoi(p); year = _tuple$3[0]; err = _tuple$3[1]; - if (year >= 69) { - year = year + (1900) >> 0; - } else { - year = year + (2000) >> 0; - } - } else if (_ref === 273) { - if (value.length < 4 || !isDigit(value, 0)) { - err = errBad; - break; - } - _tmp$4 = value.substring(0, 4); _tmp$5 = value.substring(4); p = _tmp$4; value = _tmp$5; - _tuple$4 = atoi(p); year = _tuple$4[0]; err = _tuple$4[1]; - } else if (_ref === 258) { - _tuple$5 = lookup(shortMonthNames, value); month = _tuple$5[0]; value = _tuple$5[1]; err = _tuple$5[2]; - } else if (_ref === 257) { - _tuple$6 = lookup(longMonthNames, value); month = _tuple$6[0]; value = _tuple$6[1]; err = _tuple$6[2]; - } else if (_ref === 259 || _ref === 260) { - _tuple$7 = getnum(value, std === 260); month = _tuple$7[0]; value = _tuple$7[1]; err = _tuple$7[2]; - if (month <= 0 || 12 < month) { - rangeErrString = "month"; - } - } else if (_ref === 262) { - _tuple$8 = lookup(shortDayNames, value); value = _tuple$8[1]; err = _tuple$8[2]; - } else if (_ref === 261) { - _tuple$9 = lookup(longDayNames, value); value = _tuple$9[1]; err = _tuple$9[2]; - } else if (_ref === 263 || _ref === 264 || _ref === 265) { - if ((std === 264) && value.length > 0 && (value.charCodeAt(0) === 32)) { - value = value.substring(1); - } - _tuple$10 = getnum(value, std === 265); day = _tuple$10[0]; value = _tuple$10[1]; err = _tuple$10[2]; - if (day < 0 || 31 < day) { - rangeErrString = "day"; - } - } else if (_ref === 522) { - _tuple$11 = getnum(value, false); hour = _tuple$11[0]; value = _tuple$11[1]; err = _tuple$11[2]; - if (hour < 0 || 24 <= hour) { - rangeErrString = "hour"; - } - } else if (_ref === 523 || _ref === 524) { - _tuple$12 = getnum(value, std === 524); hour = _tuple$12[0]; value = _tuple$12[1]; err = _tuple$12[2]; - if (hour < 0 || 12 < hour) { - rangeErrString = "hour"; + $copy(digs, new decimalSlice.Ptr(new ($sliceType($Uint8))(d.d), d.nd, d.dp, false), decimalSlice); + } + return formatDigits(dst, shortest, neg, $clone(digs, decimalSlice), prec, fmt); + }; + formatDigits = function(dst, shortest, neg, digs, prec, fmt) { + var _ref, eprec, exp; + _ref = fmt; + if (_ref === 101 || _ref === 69) { + return fmtE(dst, neg, $clone(digs, decimalSlice), prec, fmt); + } else if (_ref === 102) { + return fmtF(dst, neg, $clone(digs, decimalSlice), prec); + } else if (_ref === 103 || _ref === 71) { + eprec = prec; + if (eprec > digs.nd && digs.nd >= digs.dp) { + eprec = digs.nd; + } + if (shortest) { + eprec = 6; + } + exp = digs.dp - 1 >> 0; + if (exp < -4 || exp >= eprec) { + if (prec > digs.nd) { + prec = digs.nd; } - } else if (_ref === 525 || _ref === 526) { - _tuple$13 = getnum(value, std === 526); min = _tuple$13[0]; value = _tuple$13[1]; err = _tuple$13[2]; - if (min < 0 || 60 <= min) { - rangeErrString = "minute"; - } - } else if (_ref === 527 || _ref === 528) { - _tuple$14 = getnum(value, std === 528); sec = _tuple$14[0]; value = _tuple$14[1]; err = _tuple$14[2]; - if (sec < 0 || 60 <= sec) { - rangeErrString = "second"; - } - if (value.length >= 2 && (value.charCodeAt(0) === 46) && isDigit(value, 1)) { - _tuple$15 = nextStdChunk(layout); std = _tuple$15[1]; - std = std & (65535); - if ((std === 31) || (std === 32)) { - break; - } - n = 2; - while (n < value.length && isDigit(value, n)) { - n = n + (1) >> 0; - } - _tuple$16 = parseNanoseconds(value, n); nsec = _tuple$16[0]; rangeErrString = _tuple$16[1]; err = _tuple$16[2]; - value = value.substring(n); - } - } else if (_ref === 531) { - if (value.length < 2) { - err = errBad; - break; - } - _tmp$6 = value.substring(0, 2); _tmp$7 = value.substring(2); p = _tmp$6; value = _tmp$7; - _ref$1 = p; - if (_ref$1 === "PM") { - pmSet = true; - } else if (_ref$1 === "AM") { - amSet = true; - } else { - err = errBad; - } - } else if (_ref === 532) { - if (value.length < 2) { - err = errBad; - break; - } - _tmp$8 = value.substring(0, 2); _tmp$9 = value.substring(2); p = _tmp$8; value = _tmp$9; - _ref$2 = p; - if (_ref$2 === "pm") { - pmSet = true; - } else if (_ref$2 === "am") { - amSet = true; - } else { - err = errBad; - } - } else if (_ref === 22 || _ref === 24 || _ref === 23 || _ref === 25 || _ref === 26 || _ref === 28 || _ref === 29 || _ref === 27 || _ref === 30) { - if (((std === 22) || (std === 24)) && value.length >= 1 && (value.charCodeAt(0) === 90)) { - value = value.substring(1); - z = $pkg.UTC; - break; - } - _tmp$10 = ""; _tmp$11 = ""; _tmp$12 = ""; _tmp$13 = ""; sign = _tmp$10; hour$1 = _tmp$11; min$1 = _tmp$12; seconds = _tmp$13; - if ((std === 24) || (std === 29)) { - if (value.length < 6) { - err = errBad; - break; - } - if (!((value.charCodeAt(3) === 58))) { - err = errBad; - break; - } - _tmp$14 = value.substring(0, 1); _tmp$15 = value.substring(1, 3); _tmp$16 = value.substring(4, 6); _tmp$17 = "00"; _tmp$18 = value.substring(6); sign = _tmp$14; hour$1 = _tmp$15; min$1 = _tmp$16; seconds = _tmp$17; value = _tmp$18; - } else if (std === 28) { - if (value.length < 3) { - err = errBad; - break; - } - _tmp$19 = value.substring(0, 1); _tmp$20 = value.substring(1, 3); _tmp$21 = "00"; _tmp$22 = "00"; _tmp$23 = value.substring(3); sign = _tmp$19; hour$1 = _tmp$20; min$1 = _tmp$21; seconds = _tmp$22; value = _tmp$23; - } else if ((std === 25) || (std === 30)) { - if (value.length < 9) { - err = errBad; - break; - } - if (!((value.charCodeAt(3) === 58)) || !((value.charCodeAt(6) === 58))) { - err = errBad; - break; - } - _tmp$24 = value.substring(0, 1); _tmp$25 = value.substring(1, 3); _tmp$26 = value.substring(4, 6); _tmp$27 = value.substring(7, 9); _tmp$28 = value.substring(9); sign = _tmp$24; hour$1 = _tmp$25; min$1 = _tmp$26; seconds = _tmp$27; value = _tmp$28; - } else if ((std === 23) || (std === 27)) { - if (value.length < 7) { - err = errBad; - break; - } - _tmp$29 = value.substring(0, 1); _tmp$30 = value.substring(1, 3); _tmp$31 = value.substring(3, 5); _tmp$32 = value.substring(5, 7); _tmp$33 = value.substring(7); sign = _tmp$29; hour$1 = _tmp$30; min$1 = _tmp$31; seconds = _tmp$32; value = _tmp$33; - } else { - if (value.length < 5) { - err = errBad; - break; - } - _tmp$34 = value.substring(0, 1); _tmp$35 = value.substring(1, 3); _tmp$36 = value.substring(3, 5); _tmp$37 = "00"; _tmp$38 = value.substring(5); sign = _tmp$34; hour$1 = _tmp$35; min$1 = _tmp$36; seconds = _tmp$37; value = _tmp$38; - } - _tmp$39 = 0; _tmp$40 = 0; _tmp$41 = 0; hr = _tmp$39; mm = _tmp$40; ss = _tmp$41; - _tuple$17 = atoi(hour$1); hr = _tuple$17[0]; err = _tuple$17[1]; - if ($interfaceIsEqual(err, $ifaceNil)) { - _tuple$18 = atoi(min$1); mm = _tuple$18[0]; err = _tuple$18[1]; - } - if ($interfaceIsEqual(err, $ifaceNil)) { - _tuple$19 = atoi(seconds); ss = _tuple$19[0]; err = _tuple$19[1]; - } - zoneOffset = (x = (((((hr >>> 16 << 16) * 60 >> 0) + (hr << 16 >>> 16) * 60) >> 0) + mm >> 0), (((x >>> 16 << 16) * 60 >> 0) + (x << 16 >>> 16) * 60) >> 0) + ss >> 0; - _ref$3 = sign.charCodeAt(0); - if (_ref$3 === 43) { - } else if (_ref$3 === 45) { - zoneOffset = -zoneOffset; - } else { - err = errBad; - } - } else if (_ref === 21) { - if (value.length >= 3 && value.substring(0, 3) === "UTC") { - z = $pkg.UTC; - value = value.substring(3); - break; - } - _tuple$20 = parseTimeZone(value); n$1 = _tuple$20[0]; ok = _tuple$20[1]; - if (!ok) { - err = errBad; - break; - } - _tmp$42 = value.substring(0, n$1); _tmp$43 = value.substring(n$1); zoneName = _tmp$42; value = _tmp$43; - } else if (_ref === 31) { - ndigit = 1 + ((std >> 16 >> 0)) >> 0; - if (value.length < ndigit) { - err = errBad; - break; - } - _tuple$21 = parseNanoseconds(value, ndigit); nsec = _tuple$21[0]; rangeErrString = _tuple$21[1]; err = _tuple$21[2]; - value = value.substring(ndigit); - } else if (_ref === 32) { - if (value.length < 2 || !((value.charCodeAt(0) === 46)) || value.charCodeAt(1) < 48 || 57 < value.charCodeAt(1)) { - break; - } - i = 0; - while (i < 9 && (i + 1 >> 0) < value.length && 48 <= value.charCodeAt((i + 1 >> 0)) && value.charCodeAt((i + 1 >> 0)) <= 57) { - i = i + (1) >> 0; - } - _tuple$22 = parseNanoseconds(value, 1 + i >> 0); nsec = _tuple$22[0]; rangeErrString = _tuple$22[1]; err = _tuple$22[2]; - value = value.substring((1 + i >> 0)); - } } - if (!(rangeErrString === "")) { - return [new Time.Ptr(new $Int64(0, 0), 0, ($ptrType(Location)).nil), new ParseError.Ptr(alayout, avalue, stdstr, value, ": " + rangeErrString + " out of range")]; + return fmtE(dst, neg, $clone(digs, decimalSlice), prec - 1 >> 0, (fmt + 101 << 24 >>> 24) - 103 << 24 >>> 24); } - if (!($interfaceIsEqual(err, $ifaceNil))) { - return [new Time.Ptr(new $Int64(0, 0), 0, ($ptrType(Location)).nil), new ParseError.Ptr(alayout, avalue, stdstr, value, "")]; + if (prec > digs.dp) { + prec = digs.nd; } + return fmtF(dst, neg, $clone(digs, decimalSlice), max(prec - digs.dp >> 0, 0)); } - if (pmSet && hour < 12) { - hour = hour + (12) >> 0; - } else if (amSet && (hour === 12)) { - hour = 0; + return $append(dst, 37, fmt); + }; + roundShortest = function(d, mant, exp, flt) { + var minexp, x, x$1, upper, x$2, mantlo, explo, x$3, x$4, lower, x$5, x$6, inclusive, i, _tmp, _tmp$1, _tmp$2, l, m, u, x$7, x$8, x$9, okdown, okup; + if ((mant.$high === 0 && mant.$low === 0)) { + d.nd = 0; + return; } - if (!(z === ($ptrType(Location)).nil)) { - return [Date(year, (month >> 0), day, hour, min, sec, nsec, z), $ifaceNil]; + minexp = flt.bias + 1 >> 0; + if (exp > minexp && (x = (d.dp - d.nd >> 0), (((332 >>> 16 << 16) * x >> 0) + (332 << 16 >>> 16) * x) >> 0) >= (x$1 = (exp - (flt.mantbits >> 0) >> 0), (((100 >>> 16 << 16) * x$1 >> 0) + (100 << 16 >>> 16) * x$1) >> 0)) { + return; } - if (!((zoneOffset === -1))) { - t = new Time.Ptr(); $copy(t, Date(year, (month >> 0), day, hour, min, sec, nsec, $pkg.UTC), Time); - t.sec = (x$1 = t.sec, x$2 = new $Int64(0, zoneOffset), new $Int64(x$1.$high - x$2.$high, x$1.$low - x$2.$low)); - _tuple$23 = local.lookup((x$3 = t.sec, new $Int64(x$3.$high + -15, x$3.$low + 2288912640))); name = _tuple$23[0]; offset = _tuple$23[1]; - if ((offset === zoneOffset) && (zoneName === "" || name === zoneName)) { - t.loc = local; - return [t, $ifaceNil]; - } - t.loc = FixedZone(zoneName, zoneOffset); - return [t, $ifaceNil]; + upper = new decimal.Ptr(); + upper.Assign((x$2 = $mul64(mant, new $Uint64(0, 2)), new $Uint64(x$2.$high + 0, x$2.$low + 1))); + upper.Shift((exp - (flt.mantbits >> 0) >> 0) - 1 >> 0); + mantlo = new $Uint64(0, 0); + explo = 0; + if ((x$3 = $shiftLeft64(new $Uint64(0, 1), flt.mantbits), (mant.$high > x$3.$high || (mant.$high === x$3.$high && mant.$low > x$3.$low))) || (exp === minexp)) { + mantlo = new $Uint64(mant.$high - 0, mant.$low - 1); + explo = exp; + } else { + mantlo = (x$4 = $mul64(mant, new $Uint64(0, 2)), new $Uint64(x$4.$high - 0, x$4.$low - 1)); + explo = exp - 1 >> 0; } - if (!(zoneName === "")) { - t$1 = new Time.Ptr(); $copy(t$1, Date(year, (month >> 0), day, hour, min, sec, nsec, $pkg.UTC), Time); - _tuple$24 = local.lookupName(zoneName, (x$4 = t$1.sec, new $Int64(x$4.$high + -15, x$4.$low + 2288912640))); offset$1 = _tuple$24[0]; ok$1 = _tuple$24[2]; - if (ok$1) { - t$1.sec = (x$5 = t$1.sec, x$6 = new $Int64(0, offset$1), new $Int64(x$5.$high - x$6.$high, x$5.$low - x$6.$low)); - t$1.loc = local; - return [t$1, $ifaceNil]; + lower = new decimal.Ptr(); + lower.Assign((x$5 = $mul64(mantlo, new $Uint64(0, 2)), new $Uint64(x$5.$high + 0, x$5.$low + 1))); + lower.Shift((explo - (flt.mantbits >> 0) >> 0) - 1 >> 0); + inclusive = (x$6 = $div64(mant, new $Uint64(0, 2), true), (x$6.$high === 0 && x$6.$low === 0)); + i = 0; + while (i < d.nd) { + _tmp = 0; _tmp$1 = 0; _tmp$2 = 0; l = _tmp; m = _tmp$1; u = _tmp$2; + if (i < lower.nd) { + l = (x$7 = lower.d, ((i < 0 || i >= x$7.length) ? $throwRuntimeError("index out of range") : x$7[i])); + } else { + l = 48; } - if (zoneName.length > 3 && zoneName.substring(0, 3) === "GMT") { - _tuple$25 = atoi(zoneName.substring(3)); offset$1 = _tuple$25[0]; - offset$1 = (x$7 = 3600, (((offset$1 >>> 16 << 16) * x$7 >> 0) + (offset$1 << 16 >>> 16) * x$7) >> 0); + m = (x$8 = d.d, ((i < 0 || i >= x$8.length) ? $throwRuntimeError("index out of range") : x$8[i])); + if (i < upper.nd) { + u = (x$9 = upper.d, ((i < 0 || i >= x$9.length) ? $throwRuntimeError("index out of range") : x$9[i])); + } else { + u = 48; } - t$1.loc = FixedZone(zoneName, offset$1); - return [t$1, $ifaceNil]; + okdown = !((l === m)) || (inclusive && (l === m) && ((i + 1 >> 0) === lower.nd)); + okup = !((m === u)) && (inclusive || (m + 1 << 24 >>> 24) < u || (i + 1 >> 0) < upper.nd); + if (okdown && okup) { + d.Round(i + 1 >> 0); + return; + } else if (okdown) { + d.RoundDown(i + 1 >> 0); + return; + } else if (okup) { + d.RoundUp(i + 1 >> 0); + return; + } + i = i + (1) >> 0; } - return [Date(year, (month >> 0), day, hour, min, sec, nsec, defaultLocation), $ifaceNil]; }; - parseTimeZone = function(value) { - var length = 0, ok = false, _tmp, _tmp$1, _tmp$2, _tmp$3, _tmp$4, _tmp$5, nUpper, c, _ref, _tmp$6, _tmp$7, _tmp$8, _tmp$9, _tmp$10, _tmp$11, _tmp$12, _tmp$13, _tmp$14, _tmp$15; - if (value.length < 3) { - _tmp = 0; _tmp$1 = false; length = _tmp; ok = _tmp$1; - return [length, ok]; - } - if (value.length >= 4 && (value.substring(0, 4) === "ChST" || value.substring(0, 4) === "MeST")) { - _tmp$2 = 4; _tmp$3 = true; length = _tmp$2; ok = _tmp$3; - return [length, ok]; - } - if (value.substring(0, 3) === "GMT") { - length = parseGMT(value); - _tmp$4 = length; _tmp$5 = true; length = _tmp$4; ok = _tmp$5; - return [length, ok]; + fmtE = function(dst, neg, d, prec, fmt) { + var ch, x, i, m, x$1, exp, buf, i$1, _r, _q, _ref; + if (neg) { + dst = $append(dst, 45); } - nUpper = 0; - nUpper = 0; - while (nUpper < 6) { - if (nUpper >= value.length) { - break; - } - c = value.charCodeAt(nUpper); - if (c < 65 || 90 < c) { - break; - } - nUpper = nUpper + (1) >> 0; + ch = 48; + if (!((d.nd === 0))) { + ch = (x = d.d, ((0 < 0 || 0 >= x.$length) ? $throwRuntimeError("index out of range") : x.$array[x.$offset + 0])); } - _ref = nUpper; - if (_ref === 0 || _ref === 1 || _ref === 2 || _ref === 6) { - _tmp$6 = 0; _tmp$7 = false; length = _tmp$6; ok = _tmp$7; - return [length, ok]; - } else if (_ref === 5) { - if (value.charCodeAt(4) === 84) { - _tmp$8 = 5; _tmp$9 = true; length = _tmp$8; ok = _tmp$9; - return [length, ok]; + dst = $append(dst, ch); + if (prec > 0) { + dst = $append(dst, 46); + i = 1; + m = ((d.nd + prec >> 0) + 1 >> 0) - max(d.nd, prec + 1 >> 0) >> 0; + while (i < m) { + dst = $append(dst, (x$1 = d.d, ((i < 0 || i >= x$1.$length) ? $throwRuntimeError("index out of range") : x$1.$array[x$1.$offset + i]))); + i = i + (1) >> 0; } - } else if (_ref === 4) { - if (value.charCodeAt(3) === 84) { - _tmp$10 = 4; _tmp$11 = true; length = _tmp$10; ok = _tmp$11; - return [length, ok]; + while (i <= prec) { + dst = $append(dst, 48); + i = i + (1) >> 0; } - } else if (_ref === 3) { - _tmp$12 = 3; _tmp$13 = true; length = _tmp$12; ok = _tmp$13; - return [length, ok]; - } - _tmp$14 = 0; _tmp$15 = false; length = _tmp$14; ok = _tmp$15; - return [length, ok]; - }; - parseGMT = function(value) { - var sign, _tuple$1, x, rem, err; - value = value.substring(3); - if (value.length === 0) { - return 3; } - sign = value.charCodeAt(0); - if (!((sign === 45)) && !((sign === 43))) { - return 3; + dst = $append(dst, fmt); + exp = d.dp - 1 >> 0; + if (d.nd === 0) { + exp = 0; } - _tuple$1 = leadingInt(value.substring(1)); x = _tuple$1[0]; rem = _tuple$1[1]; err = _tuple$1[2]; - if (!($interfaceIsEqual(err, $ifaceNil))) { - return 3; + if (exp < 0) { + ch = 45; + exp = -exp; + } else { + ch = 43; } - if (sign === 45) { - x = new $Int64(-x.$high, -x.$low); + dst = $append(dst, ch); + buf = ($arrayType($Uint8, 3)).zero(); $copy(buf, ($arrayType($Uint8, 3)).zero(), ($arrayType($Uint8, 3))); + i$1 = 3; + while (exp >= 10) { + i$1 = i$1 - (1) >> 0; + (i$1 < 0 || i$1 >= buf.length) ? $throwRuntimeError("index out of range") : buf[i$1] = (((_r = exp % 10, _r === _r ? _r : $throwRuntimeError("integer divide by zero")) + 48 >> 0) << 24 >>> 24); + exp = (_q = exp / (10), (_q === _q && _q !== 1/0 && _q !== -1/0) ? _q >> 0 : $throwRuntimeError("integer divide by zero")); } - if ((x.$high === 0 && x.$low === 0) || (x.$high < -1 || (x.$high === -1 && x.$low < 4294967282)) || (0 < x.$high || (0 === x.$high && 12 < x.$low))) { - return 3; + i$1 = i$1 - (1) >> 0; + (i$1 < 0 || i$1 >= buf.length) ? $throwRuntimeError("index out of range") : buf[i$1] = ((exp + 48 >> 0) << 24 >>> 24); + _ref = i$1; + if (_ref === 0) { + dst = $append(dst, buf[0], buf[1], buf[2]); + } else if (_ref === 1) { + dst = $append(dst, buf[1], buf[2]); + } else if (_ref === 2) { + dst = $append(dst, 48, buf[2]); } - return (3 + value.length >> 0) - rem.length >> 0; + return dst; }; - parseNanoseconds = function(value, nbytes) { - var ns = 0, rangeErrString = "", err = $ifaceNil, _tuple$1, scaleDigits, i, x; - if (!((value.charCodeAt(0) === 46))) { - err = errBad; - return [ns, rangeErrString, err]; - } - _tuple$1 = atoi(value.substring(1, nbytes)); ns = _tuple$1[0]; err = _tuple$1[1]; - if (!($interfaceIsEqual(err, $ifaceNil))) { - return [ns, rangeErrString, err]; - } - if (ns < 0 || 1000000000 <= ns) { - rangeErrString = "fractional second"; - return [ns, rangeErrString, err]; - } - scaleDigits = 10 - nbytes >> 0; - i = 0; - while (i < scaleDigits) { - ns = (x = 10, (((ns >>> 16 << 16) * x >> 0) + (ns << 16 >>> 16) * x) >> 0); - i = i + (1) >> 0; + fmtF = function(dst, neg, d, prec) { + var i, x, i$1, ch, j, x$1; + if (neg) { + dst = $append(dst, 45); } - return [ns, rangeErrString, err]; - }; - leadingInt = function(s) { - var x = new $Int64(0, 0), rem = "", err = $ifaceNil, i, c, _tmp, _tmp$1, _tmp$2, x$1, x$2, x$3, _tmp$3, _tmp$4, _tmp$5; - i = 0; - while (i < s.length) { - c = s.charCodeAt(i); - if (c < 48 || c > 57) { - break; + if (d.dp > 0) { + i = 0; + i = 0; + while (i < d.dp && i < d.nd) { + dst = $append(dst, (x = d.d, ((i < 0 || i >= x.$length) ? $throwRuntimeError("index out of range") : x.$array[x.$offset + i]))); + i = i + (1) >> 0; } - if ((x.$high > 214748364 || (x.$high === 214748364 && x.$low >= 3435973835))) { - _tmp = new $Int64(0, 0); _tmp$1 = ""; _tmp$2 = errLeadingInt; x = _tmp; rem = _tmp$1; err = _tmp$2; - return [x, rem, err]; + while (i < d.dp) { + dst = $append(dst, 48); + i = i + (1) >> 0; } - x = (x$1 = (x$2 = $mul64(x, new $Int64(0, 10)), x$3 = new $Int64(0, c), new $Int64(x$2.$high + x$3.$high, x$2.$low + x$3.$low)), new $Int64(x$1.$high - 0, x$1.$low - 48)); - i = i + (1) >> 0; + } else { + dst = $append(dst, 48); } - _tmp$3 = x; _tmp$4 = s.substring(i); _tmp$5 = $ifaceNil; x = _tmp$3; rem = _tmp$4; err = _tmp$5; - return [x, rem, err]; - }; - ParseDuration = $pkg.ParseDuration = function(s) { - var orig, f, neg, c, g, x, err, pl, _tuple$1, pre, post, pl$1, _tuple$2, scale, n, i, c$1, u, _tuple$3, _entry, unit, ok; - orig = s; - f = 0; - neg = false; - if (!(s === "")) { - c = s.charCodeAt(0); - if ((c === 45) || (c === 43)) { - neg = c === 45; - s = s.substring(1); + if (prec > 0) { + dst = $append(dst, 46); + i$1 = 0; + while (i$1 < prec) { + ch = 48; + j = d.dp + i$1 >> 0; + if (0 <= j && j < d.nd) { + ch = (x$1 = d.d, ((j < 0 || j >= x$1.$length) ? $throwRuntimeError("index out of range") : x$1.$array[x$1.$offset + j])); + } + dst = $append(dst, ch); + i$1 = i$1 + (1) >> 0; } } - if (s === "0") { - return [new Duration(0, 0), $ifaceNil]; + return dst; + }; + fmtB = function(dst, neg, mant, exp, flt) { + var buf, w, esign, n, _r, _q, x; + buf = ($arrayType($Uint8, 50)).zero(); $copy(buf, ($arrayType($Uint8, 50)).zero(), ($arrayType($Uint8, 50))); + w = 50; + exp = exp - ((flt.mantbits >> 0)) >> 0; + esign = 43; + if (exp < 0) { + esign = 45; + exp = -exp; } - if (s === "") { - return [new Duration(0, 0), errors.New("time: invalid duration " + orig)]; + n = 0; + while (exp > 0 || n < 1) { + n = n + (1) >> 0; + w = w - (1) >> 0; + (w < 0 || w >= buf.length) ? $throwRuntimeError("index out of range") : buf[w] = (((_r = exp % 10, _r === _r ? _r : $throwRuntimeError("integer divide by zero")) + 48 >> 0) << 24 >>> 24); + exp = (_q = exp / (10), (_q === _q && _q !== 1/0 && _q !== -1/0) ? _q >> 0 : $throwRuntimeError("integer divide by zero")); } - while (!(s === "")) { - g = 0; - x = new $Int64(0, 0); - err = $ifaceNil; - if (!((s.charCodeAt(0) === 46) || (48 <= s.charCodeAt(0) && s.charCodeAt(0) <= 57))) { - return [new Duration(0, 0), errors.New("time: invalid duration " + orig)]; - } - pl = s.length; - _tuple$1 = leadingInt(s); x = _tuple$1[0]; s = _tuple$1[1]; err = _tuple$1[2]; - if (!($interfaceIsEqual(err, $ifaceNil))) { - return [new Duration(0, 0), errors.New("time: invalid duration " + orig)]; - } - g = $flatten64(x); - pre = !((pl === s.length)); - post = false; - if (!(s === "") && (s.charCodeAt(0) === 46)) { - s = s.substring(1); - pl$1 = s.length; - _tuple$2 = leadingInt(s); x = _tuple$2[0]; s = _tuple$2[1]; err = _tuple$2[2]; - if (!($interfaceIsEqual(err, $ifaceNil))) { - return [new Duration(0, 0), errors.New("time: invalid duration " + orig)]; - } - scale = 1; - n = pl$1 - s.length >> 0; - while (n > 0) { - scale = scale * (10); - n = n - (1) >> 0; - } - g = g + ($flatten64(x) / scale); - post = !((pl$1 === s.length)); - } - if (!pre && !post) { - return [new Duration(0, 0), errors.New("time: invalid duration " + orig)]; - } - i = 0; - while (i < s.length) { - c$1 = s.charCodeAt(i); - if ((c$1 === 46) || (48 <= c$1 && c$1 <= 57)) { - break; - } - i = i + (1) >> 0; - } - if (i === 0) { - return [new Duration(0, 0), errors.New("time: missing unit in duration " + orig)]; - } - u = s.substring(0, i); - s = s.substring(i); - _tuple$3 = (_entry = unitMap[u], _entry !== undefined ? [_entry.v, true] : [0, false]); unit = _tuple$3[0]; ok = _tuple$3[1]; - if (!ok) { - return [new Duration(0, 0), errors.New("time: unknown unit " + u + " in duration " + orig)]; - } - f = f + (g * unit); + w = w - (1) >> 0; + (w < 0 || w >= buf.length) ? $throwRuntimeError("index out of range") : buf[w] = esign; + w = w - (1) >> 0; + (w < 0 || w >= buf.length) ? $throwRuntimeError("index out of range") : buf[w] = 112; + n = 0; + while ((mant.$high > 0 || (mant.$high === 0 && mant.$low > 0)) || n < 1) { + n = n + (1) >> 0; + w = w - (1) >> 0; + (w < 0 || w >= buf.length) ? $throwRuntimeError("index out of range") : buf[w] = ((x = $div64(mant, new $Uint64(0, 10), true), new $Uint64(x.$high + 0, x.$low + 48)).$low << 24 >>> 24); + mant = $div64(mant, (new $Uint64(0, 10)), false); } if (neg) { - f = -f; - } - if (f < -9.223372036854776e+18 || f > 9.223372036854776e+18) { - return [new Duration(0, 0), errors.New("time: overflow parsing duration")]; + w = w - (1) >> 0; + (w < 0 || w >= buf.length) ? $throwRuntimeError("index out of range") : buf[w] = 45; } - return [new Duration(0, f), $ifaceNil]; + return $appendSlice(dst, $subslice(new ($sliceType($Uint8))(buf), w)); }; - when = function(d) { - var x, x$1, t; - if ((d.$high < 0 || (d.$high === 0 && d.$low <= 0))) { - return runtimeNano(); - } - t = (x = runtimeNano(), x$1 = new $Int64(d.$high, d.$low), new $Int64(x.$high + x$1.$high, x.$low + x$1.$low)); - if ((t.$high < 0 || (t.$high === 0 && t.$low < 0))) { - t = new $Int64(2147483647, 4294967295); + max = function(a, b) { + if (a > b) { + return a; } - return t; - }; - Timer.Ptr.prototype.Stop = function() { - var t; - t = this; - return stopTimer(t.r); + return b; }; - Timer.prototype.Stop = function() { return this.$val.Stop(); }; - Timer.Ptr.prototype.Reset = function(d) { - var t, w, active; - t = this; - w = when(d); - active = stopTimer(t.r); - t.r.when = w; - startTimer(t.r); - return active; - }; - Timer.prototype.Reset = function(d) { return this.$val.Reset(d); }; - AfterFunc = $pkg.AfterFunc = function(d, f) { - var t; - t = new Timer.Ptr(($chanType(Time, false, true)).nil, new runtimeTimer.Ptr(0, when(d), new $Int64(0, 0), goFunc, new ($funcType([], [], false))(f), $ifaceNil, false)); - startTimer(t.r); - return t; - }; - goFunc = function(now$1, arg) { - $go($assertType(arg, ($funcType([], [], false))), []); - }; - Time.Ptr.prototype.After = function(u) { - var t, x, x$1, x$2, x$3; - t = new Time.Ptr(); $copy(t, this, Time); - return (x = t.sec, x$1 = u.sec, (x.$high > x$1.$high || (x.$high === x$1.$high && x.$low > x$1.$low))) || (x$2 = t.sec, x$3 = u.sec, (x$2.$high === x$3.$high && x$2.$low === x$3.$low)) && t.nsec > u.nsec; - }; - Time.prototype.After = function(u) { return this.$val.After(u); }; - Time.Ptr.prototype.Before = function(u) { - var t, x, x$1, x$2, x$3; - t = new Time.Ptr(); $copy(t, this, Time); - return (x = t.sec, x$1 = u.sec, (x.$high < x$1.$high || (x.$high === x$1.$high && x.$low < x$1.$low))) || (x$2 = t.sec, x$3 = u.sec, (x$2.$high === x$3.$high && x$2.$low === x$3.$low)) && t.nsec < u.nsec; + FormatUint = $pkg.FormatUint = function(i, base) { + var _tuple, s; + _tuple = formatBits(($sliceType($Uint8)).nil, i, base, false, false); s = _tuple[1]; + return s; }; - Time.prototype.Before = function(u) { return this.$val.Before(u); }; - Time.Ptr.prototype.Equal = function(u) { - var t, x, x$1; - t = new Time.Ptr(); $copy(t, this, Time); - return (x = t.sec, x$1 = u.sec, (x.$high === x$1.$high && x.$low === x$1.$low)) && (t.nsec === u.nsec); + FormatInt = $pkg.FormatInt = function(i, base) { + var _tuple, s; + _tuple = formatBits(($sliceType($Uint8)).nil, new $Uint64(i.$high, i.$low), base, (i.$high < 0 || (i.$high === 0 && i.$low < 0)), false); s = _tuple[1]; + return s; }; - Time.prototype.Equal = function(u) { return this.$val.Equal(u); }; - Month.prototype.String = function() { - var m, x; - m = this.$val !== undefined ? this.$val : this; - return (x = m - 1 >> 0, ((x < 0 || x >= months.length) ? $throwRuntimeError("index out of range") : months[x])); + Itoa = $pkg.Itoa = function(i) { + return FormatInt(new $Int64(0, i), 10); }; - $ptrType(Month).prototype.String = function() { return new Month(this.$get()).String(); }; - Weekday.prototype.String = function() { - var d; - d = this.$val !== undefined ? this.$val : this; - return ((d < 0 || d >= days.length) ? $throwRuntimeError("index out of range") : days[d]); + AppendInt = $pkg.AppendInt = function(dst, i, base) { + var _tuple; + _tuple = formatBits(dst, new $Uint64(i.$high, i.$low), base, (i.$high < 0 || (i.$high === 0 && i.$low < 0)), true); dst = _tuple[0]; + return dst; }; - $ptrType(Weekday).prototype.String = function() { return new Weekday(this.$get()).String(); }; - Time.Ptr.prototype.IsZero = function() { - var t, x; - t = new Time.Ptr(); $copy(t, this, Time); - return (x = t.sec, (x.$high === 0 && x.$low === 0)) && (t.nsec === 0); + AppendUint = $pkg.AppendUint = function(dst, i, base) { + var _tuple; + _tuple = formatBits(dst, i, base, false, true); dst = _tuple[0]; + return dst; }; - Time.prototype.IsZero = function() { return this.$val.IsZero(); }; - Time.Ptr.prototype.abs = function() { - var t, l, x, sec, x$1, x$2, x$3, _tuple$1, offset, x$4, x$5; - t = new Time.Ptr(); $copy(t, this, Time); - l = t.loc; - if (l === ($ptrType(Location)).nil || l === localLoc) { - l = l.get(); + formatBits = function(dst, u, base, neg, append_) { + var d = ($sliceType($Uint8)).nil, s = "", a, i, q, x, j, x$1, x$2, q$1, x$3, s$1, b, m, b$1; + if (base < 2 || base > 36) { + $panic(new $String("strconv: illegal AppendInt/FormatInt base")); } - sec = (x = t.sec, new $Int64(x.$high + -15, x.$low + 2288912640)); - if (!(l === utcLoc)) { - if (!(l.cacheZone === ($ptrType(zone)).nil) && (x$1 = l.cacheStart, (x$1.$high < sec.$high || (x$1.$high === sec.$high && x$1.$low <= sec.$low))) && (x$2 = l.cacheEnd, (sec.$high < x$2.$high || (sec.$high === x$2.$high && sec.$low < x$2.$low)))) { - sec = (x$3 = new $Int64(0, l.cacheZone.offset), new $Int64(sec.$high + x$3.$high, sec.$low + x$3.$low)); + a = ($arrayType($Uint8, 65)).zero(); $copy(a, ($arrayType($Uint8, 65)).zero(), ($arrayType($Uint8, 65))); + i = 65; + if (neg) { + u = new $Uint64(-u.$high, -u.$low); + } + if (base === 10) { + while ((u.$high > 0 || (u.$high === 0 && u.$low >= 100))) { + i = i - (2) >> 0; + q = $div64(u, new $Uint64(0, 100), false); + j = ((x = $mul64(q, new $Uint64(0, 100)), new $Uint64(u.$high - x.$high, u.$low - x.$low)).$low >>> 0); + (x$1 = i + 1 >> 0, (x$1 < 0 || x$1 >= a.length) ? $throwRuntimeError("index out of range") : a[x$1] = "0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789".charCodeAt(j)); + (x$2 = i + 0 >> 0, (x$2 < 0 || x$2 >= a.length) ? $throwRuntimeError("index out of range") : a[x$2] = "0000000000111111111122222222223333333333444444444455555555556666666666777777777788888888889999999999".charCodeAt(j)); + u = q; + } + if ((u.$high > 0 || (u.$high === 0 && u.$low >= 10))) { + i = i - (1) >> 0; + q$1 = $div64(u, new $Uint64(0, 10), false); + (i < 0 || i >= a.length) ? $throwRuntimeError("index out of range") : a[i] = "0123456789abcdefghijklmnopqrstuvwxyz".charCodeAt(((x$3 = $mul64(q$1, new $Uint64(0, 10)), new $Uint64(u.$high - x$3.$high, u.$low - x$3.$low)).$low >>> 0)); + u = q$1; + } + } else { + s$1 = ((base < 0 || base >= shifts.length) ? $throwRuntimeError("index out of range") : shifts[base]); + if (s$1 > 0) { + b = new $Uint64(0, base); + m = (b.$low >>> 0) - 1 >>> 0; + while ((u.$high > b.$high || (u.$high === b.$high && u.$low >= b.$low))) { + i = i - (1) >> 0; + (i < 0 || i >= a.length) ? $throwRuntimeError("index out of range") : a[i] = "0123456789abcdefghijklmnopqrstuvwxyz".charCodeAt((((u.$low >>> 0) & m) >>> 0)); + u = $shiftRightUint64(u, (s$1)); + } } else { - _tuple$1 = l.lookup(sec); offset = _tuple$1[1]; - sec = (x$4 = new $Int64(0, offset), new $Int64(sec.$high + x$4.$high, sec.$low + x$4.$low)); + b$1 = new $Uint64(0, base); + while ((u.$high > b$1.$high || (u.$high === b$1.$high && u.$low >= b$1.$low))) { + i = i - (1) >> 0; + (i < 0 || i >= a.length) ? $throwRuntimeError("index out of range") : a[i] = "0123456789abcdefghijklmnopqrstuvwxyz".charCodeAt(($div64(u, b$1, true).$low >>> 0)); + u = $div64(u, (b$1), false); + } } } - return (x$5 = new $Int64(sec.$high + 2147483646, sec.$low + 450480384), new $Uint64(x$5.$high, x$5.$low)); - }; - Time.prototype.abs = function() { return this.$val.abs(); }; - Time.Ptr.prototype.locabs = function() { - var name = "", offset = 0, abs = new $Uint64(0, 0), t, l, x, sec, x$1, x$2, _tuple$1, x$3, x$4; - t = new Time.Ptr(); $copy(t, this, Time); - l = t.loc; - if (l === ($ptrType(Location)).nil || l === localLoc) { - l = l.get(); + i = i - (1) >> 0; + (i < 0 || i >= a.length) ? $throwRuntimeError("index out of range") : a[i] = "0123456789abcdefghijklmnopqrstuvwxyz".charCodeAt((u.$low >>> 0)); + if (neg) { + i = i - (1) >> 0; + (i < 0 || i >= a.length) ? $throwRuntimeError("index out of range") : a[i] = 45; } - sec = (x = t.sec, new $Int64(x.$high + -15, x.$low + 2288912640)); - if (!(l === utcLoc)) { - if (!(l.cacheZone === ($ptrType(zone)).nil) && (x$1 = l.cacheStart, (x$1.$high < sec.$high || (x$1.$high === sec.$high && x$1.$low <= sec.$low))) && (x$2 = l.cacheEnd, (sec.$high < x$2.$high || (sec.$high === x$2.$high && sec.$low < x$2.$low)))) { - name = l.cacheZone.name; - offset = l.cacheZone.offset; - } else { - _tuple$1 = l.lookup(sec); name = _tuple$1[0]; offset = _tuple$1[1]; - } - sec = (x$3 = new $Int64(0, offset), new $Int64(sec.$high + x$3.$high, sec.$low + x$3.$low)); - } else { - name = "UTC"; + if (append_) { + d = $appendSlice(dst, $subslice(new ($sliceType($Uint8))(a), i)); + return [d, s]; } - abs = (x$4 = new $Int64(sec.$high + 2147483646, sec.$low + 450480384), new $Uint64(x$4.$high, x$4.$low)); - return [name, offset, abs]; - }; - Time.prototype.locabs = function() { return this.$val.locabs(); }; - Time.Ptr.prototype.Date = function() { - var year = 0, month = 0, day = 0, t, _tuple$1; - t = new Time.Ptr(); $copy(t, this, Time); - _tuple$1 = t.date(true); year = _tuple$1[0]; month = _tuple$1[1]; day = _tuple$1[2]; - return [year, month, day]; - }; - Time.prototype.Date = function() { return this.$val.Date(); }; - Time.Ptr.prototype.Year = function() { - var t, _tuple$1, year; - t = new Time.Ptr(); $copy(t, this, Time); - _tuple$1 = t.date(false); year = _tuple$1[0]; - return year; - }; - Time.prototype.Year = function() { return this.$val.Year(); }; - Time.Ptr.prototype.Month = function() { - var t, _tuple$1, month; - t = new Time.Ptr(); $copy(t, this, Time); - _tuple$1 = t.date(true); month = _tuple$1[1]; - return month; - }; - Time.prototype.Month = function() { return this.$val.Month(); }; - Time.Ptr.prototype.Day = function() { - var t, _tuple$1, day; - t = new Time.Ptr(); $copy(t, this, Time); - _tuple$1 = t.date(true); day = _tuple$1[2]; - return day; - }; - Time.prototype.Day = function() { return this.$val.Day(); }; - Time.Ptr.prototype.Weekday = function() { - var t; - t = new Time.Ptr(); $copy(t, this, Time); - return absWeekday(t.abs()); - }; - Time.prototype.Weekday = function() { return this.$val.Weekday(); }; - absWeekday = function(abs) { - var sec, _q; - sec = $div64((new $Uint64(abs.$high + 0, abs.$low + 86400)), new $Uint64(0, 604800), true); - return ((_q = (sec.$low >> 0) / 86400, (_q === _q && _q !== 1/0 && _q !== -1/0) ? _q >> 0 : $throwRuntimeError("integer divide by zero")) >> 0); + s = $bytesToString($subslice(new ($sliceType($Uint8))(a), i)); + return [d, s]; }; - Time.Ptr.prototype.ISOWeek = function() { - var year = 0, week = 0, t, _tuple$1, month, day, yday, _r, wday, _q, _r$1, jan1wday, _r$2, dec31wday; - t = new Time.Ptr(); $copy(t, this, Time); - _tuple$1 = t.date(true); year = _tuple$1[0]; month = _tuple$1[1]; day = _tuple$1[2]; yday = _tuple$1[3]; - wday = (_r = ((t.Weekday() + 6 >> 0) >> 0) % 7, _r === _r ? _r : $throwRuntimeError("integer divide by zero")); - week = (_q = (((yday - wday >> 0) + 7 >> 0)) / 7, (_q === _q && _q !== 1/0 && _q !== -1/0) ? _q >> 0 : $throwRuntimeError("integer divide by zero")); - jan1wday = (_r$1 = (((wday - yday >> 0) + 371 >> 0)) % 7, _r$1 === _r$1 ? _r$1 : $throwRuntimeError("integer divide by zero")); - if (1 <= jan1wday && jan1wday <= 3) { - week = week + (1) >> 0; - } - if (week === 0) { - year = year - (1) >> 0; - week = 52; - if ((jan1wday === 4) || ((jan1wday === 5) && isLeap(year))) { - week = week + (1) >> 0; + quoteWith = function(s, quote, ASCIIonly) { + var runeTmp, _q, x, buf, width, r, _tuple, n, _ref, s$1, s$2; + runeTmp = ($arrayType($Uint8, 4)).zero(); $copy(runeTmp, ($arrayType($Uint8, 4)).zero(), ($arrayType($Uint8, 4))); + buf = ($sliceType($Uint8)).make(0, (_q = (x = s.length, (((3 >>> 16 << 16) * x >> 0) + (3 << 16 >>> 16) * x) >> 0) / 2, (_q === _q && _q !== 1/0 && _q !== -1/0) ? _q >> 0 : $throwRuntimeError("integer divide by zero"))); + buf = $append(buf, quote); + width = 0; + while (s.length > 0) { + r = (s.charCodeAt(0) >> 0); + width = 1; + if (r >= 128) { + _tuple = utf8.DecodeRuneInString(s); r = _tuple[0]; width = _tuple[1]; } - } - if ((month === 12) && day >= 29 && wday < 3) { - dec31wday = (_r$2 = (((wday + 31 >> 0) - day >> 0)) % 7, _r$2 === _r$2 ? _r$2 : $throwRuntimeError("integer divide by zero")); - if (0 <= dec31wday && dec31wday <= 2) { - year = year + (1) >> 0; - week = 1; + if ((width === 1) && (r === 65533)) { + buf = $appendSlice(buf, new ($sliceType($Uint8))($stringToBytes("\\x"))); + buf = $append(buf, "0123456789abcdef".charCodeAt((s.charCodeAt(0) >>> 4 << 24 >>> 24))); + buf = $append(buf, "0123456789abcdef".charCodeAt(((s.charCodeAt(0) & 15) >>> 0))); + s = s.substring(width); + continue; + } + if ((r === (quote >> 0)) || (r === 92)) { + buf = $append(buf, 92); + buf = $append(buf, (r << 24 >>> 24)); + s = s.substring(width); + continue; + } + if (ASCIIonly) { + if (r < 128 && IsPrint(r)) { + buf = $append(buf, (r << 24 >>> 24)); + s = s.substring(width); + continue; + } + } else if (IsPrint(r)) { + n = utf8.EncodeRune(new ($sliceType($Uint8))(runeTmp), r); + buf = $appendSlice(buf, $subslice(new ($sliceType($Uint8))(runeTmp), 0, n)); + s = s.substring(width); + continue; + } + _ref = r; + if (_ref === 7) { + buf = $appendSlice(buf, new ($sliceType($Uint8))($stringToBytes("\\a"))); + } else if (_ref === 8) { + buf = $appendSlice(buf, new ($sliceType($Uint8))($stringToBytes("\\b"))); + } else if (_ref === 12) { + buf = $appendSlice(buf, new ($sliceType($Uint8))($stringToBytes("\\f"))); + } else if (_ref === 10) { + buf = $appendSlice(buf, new ($sliceType($Uint8))($stringToBytes("\\n"))); + } else if (_ref === 13) { + buf = $appendSlice(buf, new ($sliceType($Uint8))($stringToBytes("\\r"))); + } else if (_ref === 9) { + buf = $appendSlice(buf, new ($sliceType($Uint8))($stringToBytes("\\t"))); + } else if (_ref === 11) { + buf = $appendSlice(buf, new ($sliceType($Uint8))($stringToBytes("\\v"))); + } else { + if (r < 32) { + buf = $appendSlice(buf, new ($sliceType($Uint8))($stringToBytes("\\x"))); + buf = $append(buf, "0123456789abcdef".charCodeAt((s.charCodeAt(0) >>> 4 << 24 >>> 24))); + buf = $append(buf, "0123456789abcdef".charCodeAt(((s.charCodeAt(0) & 15) >>> 0))); + } else if (r > 1114111) { + r = 65533; + buf = $appendSlice(buf, new ($sliceType($Uint8))($stringToBytes("\\u"))); + s$1 = 12; + while (s$1 >= 0) { + buf = $append(buf, "0123456789abcdef".charCodeAt((((r >> $min((s$1 >>> 0), 31)) >> 0) & 15))); + s$1 = s$1 - (4) >> 0; + } + } else if (r < 65536) { + buf = $appendSlice(buf, new ($sliceType($Uint8))($stringToBytes("\\u"))); + s$1 = 12; + while (s$1 >= 0) { + buf = $append(buf, "0123456789abcdef".charCodeAt((((r >> $min((s$1 >>> 0), 31)) >> 0) & 15))); + s$1 = s$1 - (4) >> 0; + } + } else { + buf = $appendSlice(buf, new ($sliceType($Uint8))($stringToBytes("\\U"))); + s$2 = 28; + while (s$2 >= 0) { + buf = $append(buf, "0123456789abcdef".charCodeAt((((r >> $min((s$2 >>> 0), 31)) >> 0) & 15))); + s$2 = s$2 - (4) >> 0; + } + } } + s = s.substring(width); } - return [year, week]; - }; - Time.prototype.ISOWeek = function() { return this.$val.ISOWeek(); }; - Time.Ptr.prototype.Clock = function() { - var hour = 0, min = 0, sec = 0, t, _tuple$1; - t = new Time.Ptr(); $copy(t, this, Time); - _tuple$1 = absClock(t.abs()); hour = _tuple$1[0]; min = _tuple$1[1]; sec = _tuple$1[2]; - return [hour, min, sec]; - }; - Time.prototype.Clock = function() { return this.$val.Clock(); }; - absClock = function(abs) { - var hour = 0, min = 0, sec = 0, _q, _q$1; - sec = ($div64(abs, new $Uint64(0, 86400), true).$low >> 0); - hour = (_q = sec / 3600, (_q === _q && _q !== 1/0 && _q !== -1/0) ? _q >> 0 : $throwRuntimeError("integer divide by zero")); - sec = sec - (((((hour >>> 16 << 16) * 3600 >> 0) + (hour << 16 >>> 16) * 3600) >> 0)) >> 0; - min = (_q$1 = sec / 60, (_q$1 === _q$1 && _q$1 !== 1/0 && _q$1 !== -1/0) ? _q$1 >> 0 : $throwRuntimeError("integer divide by zero")); - sec = sec - (((((min >>> 16 << 16) * 60 >> 0) + (min << 16 >>> 16) * 60) >> 0)) >> 0; - return [hour, min, sec]; + buf = $append(buf, quote); + return $bytesToString(buf); }; - Time.Ptr.prototype.Hour = function() { - var t, _q; - t = new Time.Ptr(); $copy(t, this, Time); - return (_q = ($div64(t.abs(), new $Uint64(0, 86400), true).$low >> 0) / 3600, (_q === _q && _q !== 1/0 && _q !== -1/0) ? _q >> 0 : $throwRuntimeError("integer divide by zero")); + Quote = $pkg.Quote = function(s) { + return quoteWith(s, 34, false); }; - Time.prototype.Hour = function() { return this.$val.Hour(); }; - Time.Ptr.prototype.Minute = function() { - var t, _q; - t = new Time.Ptr(); $copy(t, this, Time); - return (_q = ($div64(t.abs(), new $Uint64(0, 3600), true).$low >> 0) / 60, (_q === _q && _q !== 1/0 && _q !== -1/0) ? _q >> 0 : $throwRuntimeError("integer divide by zero")); + QuoteToASCII = $pkg.QuoteToASCII = function(s) { + return quoteWith(s, 34, true); }; - Time.prototype.Minute = function() { return this.$val.Minute(); }; - Time.Ptr.prototype.Second = function() { - var t; - t = new Time.Ptr(); $copy(t, this, Time); - return ($div64(t.abs(), new $Uint64(0, 60), true).$low >> 0); + QuoteRune = $pkg.QuoteRune = function(r) { + return quoteWith($encodeRune(r), 39, false); }; - Time.prototype.Second = function() { return this.$val.Second(); }; - Time.Ptr.prototype.Nanosecond = function() { - var t; - t = new Time.Ptr(); $copy(t, this, Time); - return (t.nsec >> 0); + AppendQuoteRune = $pkg.AppendQuoteRune = function(dst, r) { + return $appendSlice(dst, new ($sliceType($Uint8))($stringToBytes(QuoteRune(r)))); }; - Time.prototype.Nanosecond = function() { return this.$val.Nanosecond(); }; - Time.Ptr.prototype.YearDay = function() { - var t, _tuple$1, yday; - t = new Time.Ptr(); $copy(t, this, Time); - _tuple$1 = t.date(false); yday = _tuple$1[3]; - return yday + 1 >> 0; + QuoteRuneToASCII = $pkg.QuoteRuneToASCII = function(r) { + return quoteWith($encodeRune(r), 39, true); }; - Time.prototype.YearDay = function() { return this.$val.YearDay(); }; - Duration.prototype.String = function() { - var d, buf, w, u, neg, prec, unit, x, _tuple$1, _tuple$2; - d = this; - buf = ($arrayType($Uint8, 32)).zero(); $copy(buf, ($arrayType($Uint8, 32)).zero(), ($arrayType($Uint8, 32))); - w = 32; - u = new $Uint64(d.$high, d.$low); - neg = (d.$high < 0 || (d.$high === 0 && d.$low < 0)); - if (neg) { - u = new $Uint64(-u.$high, -u.$low); - } - if ((u.$high < 0 || (u.$high === 0 && u.$low < 1000000000))) { - prec = 0; - unit = 0; - if ((u.$high === 0 && u.$low === 0)) { - return "0"; - } else if ((u.$high < 0 || (u.$high === 0 && u.$low < 1000))) { - prec = 0; - unit = 110; - } else if ((u.$high < 0 || (u.$high === 0 && u.$low < 1000000))) { - prec = 3; - unit = 117; - } else { - prec = 6; - unit = 109; - } - w = w - (2) >> 0; - (w < 0 || w >= buf.length) ? $throwRuntimeError("index out of range") : buf[w] = unit; - (x = w + 1 >> 0, (x < 0 || x >= buf.length) ? $throwRuntimeError("index out of range") : buf[x] = 115); - _tuple$1 = fmtFrac($subslice(new ($sliceType($Uint8))(buf), 0, w), u, prec); w = _tuple$1[0]; u = _tuple$1[1]; - w = fmtInt($subslice(new ($sliceType($Uint8))(buf), 0, w), u); - } else { - w = w - (1) >> 0; - (w < 0 || w >= buf.length) ? $throwRuntimeError("index out of range") : buf[w] = 115; - _tuple$2 = fmtFrac($subslice(new ($sliceType($Uint8))(buf), 0, w), u, 9); w = _tuple$2[0]; u = _tuple$2[1]; - w = fmtInt($subslice(new ($sliceType($Uint8))(buf), 0, w), $div64(u, new $Uint64(0, 60), true)); - u = $div64(u, (new $Uint64(0, 60)), false); - if ((u.$high > 0 || (u.$high === 0 && u.$low > 0))) { - w = w - (1) >> 0; - (w < 0 || w >= buf.length) ? $throwRuntimeError("index out of range") : buf[w] = 109; - w = fmtInt($subslice(new ($sliceType($Uint8))(buf), 0, w), $div64(u, new $Uint64(0, 60), true)); - u = $div64(u, (new $Uint64(0, 60)), false); - if ((u.$high > 0 || (u.$high === 0 && u.$low > 0))) { - w = w - (1) >> 0; - (w < 0 || w >= buf.length) ? $throwRuntimeError("index out of range") : buf[w] = 104; - w = fmtInt($subslice(new ($sliceType($Uint8))(buf), 0, w), u); - } - } - } - if (neg) { - w = w - (1) >> 0; - (w < 0 || w >= buf.length) ? $throwRuntimeError("index out of range") : buf[w] = 45; - } - return $bytesToString($subslice(new ($sliceType($Uint8))(buf), w)); + AppendQuoteRuneToASCII = $pkg.AppendQuoteRuneToASCII = function(dst, r) { + return $appendSlice(dst, new ($sliceType($Uint8))($stringToBytes(QuoteRuneToASCII(r)))); }; - $ptrType(Duration).prototype.String = function() { return this.$get().String(); }; - fmtFrac = function(buf, v, prec) { - var nw = 0, nv = new $Uint64(0, 0), w, print, i, digit, _tmp, _tmp$1; - w = buf.$length; - print = false; + CanBackquote = $pkg.CanBackquote = function(s) { + var i, c; i = 0; - while (i < prec) { - digit = $div64(v, new $Uint64(0, 10), true); - print = print || !((digit.$high === 0 && digit.$low === 0)); - if (print) { - w = w - (1) >> 0; - (w < 0 || w >= buf.$length) ? $throwRuntimeError("index out of range") : buf.$array[buf.$offset + w] = (digit.$low << 24 >>> 24) + 48 << 24 >>> 24; + while (i < s.length) { + c = s.charCodeAt(i); + if ((c < 32 && !((c === 9))) || (c === 96) || (c === 127)) { + return false; } - v = $div64(v, (new $Uint64(0, 10)), false); i = i + (1) >> 0; } - if (print) { - w = w - (1) >> 0; - (w < 0 || w >= buf.$length) ? $throwRuntimeError("index out of range") : buf.$array[buf.$offset + w] = 46; - } - _tmp = w; _tmp$1 = v; nw = _tmp; nv = _tmp$1; - return [nw, nv]; + return true; }; - fmtInt = function(buf, v) { - var w; - w = buf.$length; - if ((v.$high === 0 && v.$low === 0)) { - w = w - (1) >> 0; - (w < 0 || w >= buf.$length) ? $throwRuntimeError("index out of range") : buf.$array[buf.$offset + w] = 48; - } else { - while ((v.$high > 0 || (v.$high === 0 && v.$low > 0))) { - w = w - (1) >> 0; - (w < 0 || w >= buf.$length) ? $throwRuntimeError("index out of range") : buf.$array[buf.$offset + w] = ($div64(v, new $Uint64(0, 10), true).$low << 24 >>> 24) + 48 << 24 >>> 24; - v = $div64(v, (new $Uint64(0, 10)), false); - } + unhex = function(b) { + var v = 0, ok = false, c, _tmp, _tmp$1, _tmp$2, _tmp$3, _tmp$4, _tmp$5; + c = (b >> 0); + if (48 <= c && c <= 57) { + _tmp = c - 48 >> 0; _tmp$1 = true; v = _tmp; ok = _tmp$1; + return [v, ok]; + } else if (97 <= c && c <= 102) { + _tmp$2 = (c - 97 >> 0) + 10 >> 0; _tmp$3 = true; v = _tmp$2; ok = _tmp$3; + return [v, ok]; + } else if (65 <= c && c <= 70) { + _tmp$4 = (c - 65 >> 0) + 10 >> 0; _tmp$5 = true; v = _tmp$4; ok = _tmp$5; + return [v, ok]; } - return w; - }; - Duration.prototype.Nanoseconds = function() { - var d; - d = this; - return new $Int64(d.$high, d.$low); - }; - $ptrType(Duration).prototype.Nanoseconds = function() { return this.$get().Nanoseconds(); }; - Duration.prototype.Seconds = function() { - var d, sec, nsec; - d = this; - sec = $div64(d, new Duration(0, 1000000000), false); - nsec = $div64(d, new Duration(0, 1000000000), true); - return $flatten64(sec) + $flatten64(nsec) * 1e-09; - }; - $ptrType(Duration).prototype.Seconds = function() { return this.$get().Seconds(); }; - Duration.prototype.Minutes = function() { - var d, min, nsec; - d = this; - min = $div64(d, new Duration(13, 4165425152), false); - nsec = $div64(d, new Duration(13, 4165425152), true); - return $flatten64(min) + $flatten64(nsec) * 1.6666666666666667e-11; - }; - $ptrType(Duration).prototype.Minutes = function() { return this.$get().Minutes(); }; - Duration.prototype.Hours = function() { - var d, hour, nsec; - d = this; - hour = $div64(d, new Duration(838, 817405952), false); - nsec = $div64(d, new Duration(838, 817405952), true); - return $flatten64(hour) + $flatten64(nsec) * 2.777777777777778e-13; + return [v, ok]; }; - $ptrType(Duration).prototype.Hours = function() { return this.$get().Hours(); }; - Time.Ptr.prototype.Add = function(d) { - var t, x, x$1, x$2, x$3, nsec, x$4, x$5, x$6, x$7; - t = new Time.Ptr(); $copy(t, this, Time); - t.sec = (x = t.sec, x$1 = (x$2 = $div64(d, new Duration(0, 1000000000), false), new $Int64(x$2.$high, x$2.$low)), new $Int64(x.$high + x$1.$high, x.$low + x$1.$low)); - nsec = (t.nsec >> 0) + ((x$3 = $div64(d, new Duration(0, 1000000000), true), x$3.$low + ((x$3.$high >> 31) * 4294967296)) >> 0) >> 0; - if (nsec >= 1000000000) { - t.sec = (x$4 = t.sec, x$5 = new $Int64(0, 1), new $Int64(x$4.$high + x$5.$high, x$4.$low + x$5.$low)); - nsec = nsec - (1000000000) >> 0; - } else if (nsec < 0) { - t.sec = (x$6 = t.sec, x$7 = new $Int64(0, 1), new $Int64(x$6.$high - x$7.$high, x$6.$low - x$7.$low)); - nsec = nsec + (1000000000) >> 0; + UnquoteChar = $pkg.UnquoteChar = function(s, quote) { + var value = 0, multibyte = false, tail = "", err = $ifaceNil, c, _tuple, r, size, _tmp, _tmp$1, _tmp$2, _tmp$3, _tmp$4, _tmp$5, _tmp$6, _tmp$7, c$1, _ref, n, _ref$1, v, j, _tuple$1, x, ok, v$1, j$1, x$1; + c = s.charCodeAt(0); + if ((c === quote) && ((quote === 39) || (quote === 34))) { + err = $pkg.ErrSyntax; + return [value, multibyte, tail, err]; + } else if (c >= 128) { + _tuple = utf8.DecodeRuneInString(s); r = _tuple[0]; size = _tuple[1]; + _tmp = r; _tmp$1 = true; _tmp$2 = s.substring(size); _tmp$3 = $ifaceNil; value = _tmp; multibyte = _tmp$1; tail = _tmp$2; err = _tmp$3; + return [value, multibyte, tail, err]; + } else if (!((c === 92))) { + _tmp$4 = (s.charCodeAt(0) >> 0); _tmp$5 = false; _tmp$6 = s.substring(1); _tmp$7 = $ifaceNil; value = _tmp$4; multibyte = _tmp$5; tail = _tmp$6; err = _tmp$7; + return [value, multibyte, tail, err]; } - t.nsec = (nsec >>> 0); - return t; - }; - Time.prototype.Add = function(d) { return this.$val.Add(d); }; - Time.Ptr.prototype.Sub = function(u) { - var t, x, x$1, x$2, x$3, x$4, d; - t = new Time.Ptr(); $copy(t, this, Time); - d = (x = $mul64((x$1 = (x$2 = t.sec, x$3 = u.sec, new $Int64(x$2.$high - x$3.$high, x$2.$low - x$3.$low)), new Duration(x$1.$high, x$1.$low)), new Duration(0, 1000000000)), x$4 = new Duration(0, ((t.nsec >> 0) - (u.nsec >> 0) >> 0)), new Duration(x.$high + x$4.$high, x.$low + x$4.$low)); - if (u.Add(d).Equal($clone(t, Time))) { - return d; - } else if (t.Before($clone(u, Time))) { - return new Duration(-2147483648, 0); - } else { - return new Duration(2147483647, 4294967295); - } - }; - Time.prototype.Sub = function(u) { return this.$val.Sub(u); }; - Time.Ptr.prototype.AddDate = function(years, months$1, days$1) { - var t, _tuple$1, year, month, day, _tuple$2, hour, min, sec; - t = new Time.Ptr(); $copy(t, this, Time); - _tuple$1 = t.Date(); year = _tuple$1[0]; month = _tuple$1[1]; day = _tuple$1[2]; - _tuple$2 = t.Clock(); hour = _tuple$2[0]; min = _tuple$2[1]; sec = _tuple$2[2]; - return Date(year + years >> 0, month + (months$1 >> 0) >> 0, day + days$1 >> 0, hour, min, sec, (t.nsec >> 0), t.loc); - }; - Time.prototype.AddDate = function(years, months$1, days$1) { return this.$val.AddDate(years, months$1, days$1); }; - Time.Ptr.prototype.date = function(full) { - var year = 0, month = 0, day = 0, yday = 0, t, _tuple$1; - t = new Time.Ptr(); $copy(t, this, Time); - _tuple$1 = absDate(t.abs(), full); year = _tuple$1[0]; month = _tuple$1[1]; day = _tuple$1[2]; yday = _tuple$1[3]; - return [year, month, day, yday]; - }; - Time.prototype.date = function(full) { return this.$val.date(full); }; - absDate = function(abs, full) { - var year = 0, month = 0, day = 0, yday = 0, d, n, y, x, x$1, x$2, x$3, x$4, x$5, x$6, x$7, x$8, x$9, x$10, _q, x$11, end, begin; - d = $div64(abs, new $Uint64(0, 86400), false); - n = $div64(d, new $Uint64(0, 146097), false); - y = $mul64(new $Uint64(0, 400), n); - d = (x = $mul64(new $Uint64(0, 146097), n), new $Uint64(d.$high - x.$high, d.$low - x.$low)); - n = $div64(d, new $Uint64(0, 36524), false); - n = (x$1 = $shiftRightUint64(n, 2), new $Uint64(n.$high - x$1.$high, n.$low - x$1.$low)); - y = (x$2 = $mul64(new $Uint64(0, 100), n), new $Uint64(y.$high + x$2.$high, y.$low + x$2.$low)); - d = (x$3 = $mul64(new $Uint64(0, 36524), n), new $Uint64(d.$high - x$3.$high, d.$low - x$3.$low)); - n = $div64(d, new $Uint64(0, 1461), false); - y = (x$4 = $mul64(new $Uint64(0, 4), n), new $Uint64(y.$high + x$4.$high, y.$low + x$4.$low)); - d = (x$5 = $mul64(new $Uint64(0, 1461), n), new $Uint64(d.$high - x$5.$high, d.$low - x$5.$low)); - n = $div64(d, new $Uint64(0, 365), false); - n = (x$6 = $shiftRightUint64(n, 2), new $Uint64(n.$high - x$6.$high, n.$low - x$6.$low)); - y = (x$7 = n, new $Uint64(y.$high + x$7.$high, y.$low + x$7.$low)); - d = (x$8 = $mul64(new $Uint64(0, 365), n), new $Uint64(d.$high - x$8.$high, d.$low - x$8.$low)); - year = ((x$9 = (x$10 = new $Int64(y.$high, y.$low), new $Int64(x$10.$high + -69, x$10.$low + 4075721025)), x$9.$low + ((x$9.$high >> 31) * 4294967296)) >> 0); - yday = (d.$low >> 0); - if (!full) { - return [year, month, day, yday]; + if (s.length <= 1) { + err = $pkg.ErrSyntax; + return [value, multibyte, tail, err]; } - day = yday; - if (isLeap(year)) { - if (day > 59) { - day = day - (1) >> 0; - } else if (day === 59) { - month = 2; - day = 29; - return [year, month, day, yday]; + c$1 = s.charCodeAt(1); + s = s.substring(2); + _ref = c$1; + switch (0) { default: if (_ref === 97) { + value = 7; + } else if (_ref === 98) { + value = 8; + } else if (_ref === 102) { + value = 12; + } else if (_ref === 110) { + value = 10; + } else if (_ref === 114) { + value = 13; + } else if (_ref === 116) { + value = 9; + } else if (_ref === 118) { + value = 11; + } else if (_ref === 120 || _ref === 117 || _ref === 85) { + n = 0; + _ref$1 = c$1; + if (_ref$1 === 120) { + n = 2; + } else if (_ref$1 === 117) { + n = 4; + } else if (_ref$1 === 85) { + n = 8; } - } - month = ((_q = day / 31, (_q === _q && _q !== 1/0 && _q !== -1/0) ? _q >> 0 : $throwRuntimeError("integer divide by zero")) >> 0); - end = ((x$11 = month + 1 >> 0, ((x$11 < 0 || x$11 >= daysBefore.length) ? $throwRuntimeError("index out of range") : daysBefore[x$11])) >> 0); - begin = 0; - if (day >= end) { - month = month + (1) >> 0; - begin = end; + v = 0; + if (s.length < n) { + err = $pkg.ErrSyntax; + return [value, multibyte, tail, err]; + } + j = 0; + while (j < n) { + _tuple$1 = unhex(s.charCodeAt(j)); x = _tuple$1[0]; ok = _tuple$1[1]; + if (!ok) { + err = $pkg.ErrSyntax; + return [value, multibyte, tail, err]; + } + v = (v << 4 >> 0) | x; + j = j + (1) >> 0; + } + s = s.substring(n); + if (c$1 === 120) { + value = v; + break; + } + if (v > 1114111) { + err = $pkg.ErrSyntax; + return [value, multibyte, tail, err]; + } + value = v; + multibyte = true; + } else if (_ref === 48 || _ref === 49 || _ref === 50 || _ref === 51 || _ref === 52 || _ref === 53 || _ref === 54 || _ref === 55) { + v$1 = (c$1 >> 0) - 48 >> 0; + if (s.length < 2) { + err = $pkg.ErrSyntax; + return [value, multibyte, tail, err]; + } + j$1 = 0; + while (j$1 < 2) { + x$1 = (s.charCodeAt(j$1) >> 0) - 48 >> 0; + if (x$1 < 0 || x$1 > 7) { + err = $pkg.ErrSyntax; + return [value, multibyte, tail, err]; + } + v$1 = ((v$1 << 3 >> 0)) | x$1; + j$1 = j$1 + (1) >> 0; + } + s = s.substring(2); + if (v$1 > 255) { + err = $pkg.ErrSyntax; + return [value, multibyte, tail, err]; + } + value = v$1; + } else if (_ref === 92) { + value = 92; + } else if (_ref === 39 || _ref === 34) { + if (!((c$1 === quote))) { + err = $pkg.ErrSyntax; + return [value, multibyte, tail, err]; + } + value = (c$1 >> 0); } else { - begin = (((month < 0 || month >= daysBefore.length) ? $throwRuntimeError("index out of range") : daysBefore[month]) >> 0); - } - month = month + (1) >> 0; - day = (day - begin >> 0) + 1 >> 0; - return [year, month, day, yday]; - }; - Now = $pkg.Now = function() { - var _tuple$1, sec, nsec; - _tuple$1 = now(); sec = _tuple$1[0]; nsec = _tuple$1[1]; - return new Time.Ptr(new $Int64(sec.$high + 14, sec.$low + 2006054656), (nsec >>> 0), $pkg.Local); - }; - Time.Ptr.prototype.UTC = function() { - var t; - t = new Time.Ptr(); $copy(t, this, Time); - t.loc = $pkg.UTC; - return t; - }; - Time.prototype.UTC = function() { return this.$val.UTC(); }; - Time.Ptr.prototype.Local = function() { - var t; - t = new Time.Ptr(); $copy(t, this, Time); - t.loc = $pkg.Local; - return t; + err = $pkg.ErrSyntax; + return [value, multibyte, tail, err]; + } } + tail = s; + return [value, multibyte, tail, err]; }; - Time.prototype.Local = function() { return this.$val.Local(); }; - Time.Ptr.prototype.In = function(loc) { - var t; - t = new Time.Ptr(); $copy(t, this, Time); - if (loc === ($ptrType(Location)).nil) { - $panic(new $String("time: missing Location in call to Time.In")); + Unquote = $pkg.Unquote = function(s) { + var t = "", err = $ifaceNil, n, _tmp, _tmp$1, quote, _tmp$2, _tmp$3, _tmp$4, _tmp$5, _tmp$6, _tmp$7, _tmp$8, _tmp$9, _tmp$10, _tmp$11, _ref, _tmp$12, _tmp$13, _tuple, r, size, _tmp$14, _tmp$15, runeTmp, _q, x, buf, _tuple$1, c, multibyte, ss, err$1, _tmp$16, _tmp$17, n$1, _tmp$18, _tmp$19, _tmp$20, _tmp$21; + n = s.length; + if (n < 2) { + _tmp = ""; _tmp$1 = $pkg.ErrSyntax; t = _tmp; err = _tmp$1; + return [t, err]; } - t.loc = loc; - return t; - }; - Time.prototype.In = function(loc) { return this.$val.In(loc); }; - Time.Ptr.prototype.Location = function() { - var t, l; - t = new Time.Ptr(); $copy(t, this, Time); - l = t.loc; - if (l === ($ptrType(Location)).nil) { - l = $pkg.UTC; + quote = s.charCodeAt(0); + if (!((quote === s.charCodeAt((n - 1 >> 0))))) { + _tmp$2 = ""; _tmp$3 = $pkg.ErrSyntax; t = _tmp$2; err = _tmp$3; + return [t, err]; } - return l; - }; - Time.prototype.Location = function() { return this.$val.Location(); }; - Time.Ptr.prototype.Zone = function() { - var name = "", offset = 0, t, _tuple$1, x; - t = new Time.Ptr(); $copy(t, this, Time); - _tuple$1 = t.loc.lookup((x = t.sec, new $Int64(x.$high + -15, x.$low + 2288912640))); name = _tuple$1[0]; offset = _tuple$1[1]; - return [name, offset]; - }; - Time.prototype.Zone = function() { return this.$val.Zone(); }; - Time.Ptr.prototype.Unix = function() { - var t, x; - t = new Time.Ptr(); $copy(t, this, Time); - return (x = t.sec, new $Int64(x.$high + -15, x.$low + 2288912640)); - }; - Time.prototype.Unix = function() { return this.$val.Unix(); }; - Time.Ptr.prototype.UnixNano = function() { - var t, x, x$1, x$2, x$3; - t = new Time.Ptr(); $copy(t, this, Time); - return (x = $mul64(((x$1 = t.sec, new $Int64(x$1.$high + -15, x$1.$low + 2288912640))), new $Int64(0, 1000000000)), x$2 = (x$3 = t.nsec, new $Int64(0, x$3.constructor === Number ? x$3 : 1)), new $Int64(x.$high + x$2.$high, x.$low + x$2.$low)); - }; - Time.prototype.UnixNano = function() { return this.$val.UnixNano(); }; - Time.Ptr.prototype.MarshalBinary = function() { - var t, offsetMin, _tuple$1, offset, _r, _q, enc; - t = new Time.Ptr(); $copy(t, this, Time); - offsetMin = 0; - if (t.Location() === utcLoc) { - offsetMin = -1; - } else { - _tuple$1 = t.Zone(); offset = _tuple$1[1]; - if (!(((_r = offset % 60, _r === _r ? _r : $throwRuntimeError("integer divide by zero")) === 0))) { - return [($sliceType($Uint8)).nil, errors.New("Time.MarshalBinary: zone offset has fractional minute")]; - } - offset = (_q = offset / (60), (_q === _q && _q !== 1/0 && _q !== -1/0) ? _q >> 0 : $throwRuntimeError("integer divide by zero")); - if (offset < -32768 || (offset === -1) || offset > 32767) { - return [($sliceType($Uint8)).nil, errors.New("Time.MarshalBinary: unexpected zone offset")]; + s = s.substring(1, (n - 1 >> 0)); + if (quote === 96) { + if (contains(s, 96)) { + _tmp$4 = ""; _tmp$5 = $pkg.ErrSyntax; t = _tmp$4; err = _tmp$5; + return [t, err]; } - offsetMin = (offset << 16 >> 16); + _tmp$6 = s; _tmp$7 = $ifaceNil; t = _tmp$6; err = _tmp$7; + return [t, err]; } - enc = new ($sliceType($Uint8))([1, ($shiftRightInt64(t.sec, 56).$low << 24 >>> 24), ($shiftRightInt64(t.sec, 48).$low << 24 >>> 24), ($shiftRightInt64(t.sec, 40).$low << 24 >>> 24), ($shiftRightInt64(t.sec, 32).$low << 24 >>> 24), ($shiftRightInt64(t.sec, 24).$low << 24 >>> 24), ($shiftRightInt64(t.sec, 16).$low << 24 >>> 24), ($shiftRightInt64(t.sec, 8).$low << 24 >>> 24), (t.sec.$low << 24 >>> 24), ((t.nsec >>> 24 >>> 0) << 24 >>> 24), ((t.nsec >>> 16 >>> 0) << 24 >>> 24), ((t.nsec >>> 8 >>> 0) << 24 >>> 24), (t.nsec << 24 >>> 24), ((offsetMin >> 8 << 16 >> 16) << 24 >>> 24), (offsetMin << 24 >>> 24)]); - return [enc, $ifaceNil]; - }; - Time.prototype.MarshalBinary = function() { return this.$val.MarshalBinary(); }; - Time.Ptr.prototype.UnmarshalBinary = function(data$1) { - var t, buf, x, x$1, x$2, x$3, x$4, x$5, x$6, x$7, x$8, x$9, x$10, x$11, x$12, x$13, x$14, offset, _tuple$1, x$15, localoff; - t = this; - buf = data$1; - if (buf.$length === 0) { - return errors.New("Time.UnmarshalBinary: no data"); + if (!((quote === 34)) && !((quote === 39))) { + _tmp$8 = ""; _tmp$9 = $pkg.ErrSyntax; t = _tmp$8; err = _tmp$9; + return [t, err]; } - if (!((((0 < 0 || 0 >= buf.$length) ? $throwRuntimeError("index out of range") : buf.$array[buf.$offset + 0]) === 1))) { - return errors.New("Time.UnmarshalBinary: unsupported version"); + if (contains(s, 10)) { + _tmp$10 = ""; _tmp$11 = $pkg.ErrSyntax; t = _tmp$10; err = _tmp$11; + return [t, err]; } - if (!((buf.$length === 15))) { - return errors.New("Time.UnmarshalBinary: invalid length"); + if (!contains(s, 92) && !contains(s, quote)) { + _ref = quote; + if (_ref === 34) { + _tmp$12 = s; _tmp$13 = $ifaceNil; t = _tmp$12; err = _tmp$13; + return [t, err]; + } else if (_ref === 39) { + _tuple = utf8.DecodeRuneInString(s); r = _tuple[0]; size = _tuple[1]; + if ((size === s.length) && (!((r === 65533)) || !((size === 1)))) { + _tmp$14 = s; _tmp$15 = $ifaceNil; t = _tmp$14; err = _tmp$15; + return [t, err]; + } + } } - buf = $subslice(buf, 1); - t.sec = (x = (x$1 = (x$2 = (x$3 = (x$4 = (x$5 = (x$6 = new $Int64(0, ((7 < 0 || 7 >= buf.$length) ? $throwRuntimeError("index out of range") : buf.$array[buf.$offset + 7])), x$7 = $shiftLeft64(new $Int64(0, ((6 < 0 || 6 >= buf.$length) ? $throwRuntimeError("index out of range") : buf.$array[buf.$offset + 6])), 8), new $Int64(x$6.$high | x$7.$high, (x$6.$low | x$7.$low) >>> 0)), x$8 = $shiftLeft64(new $Int64(0, ((5 < 0 || 5 >= buf.$length) ? $throwRuntimeError("index out of range") : buf.$array[buf.$offset + 5])), 16), new $Int64(x$5.$high | x$8.$high, (x$5.$low | x$8.$low) >>> 0)), x$9 = $shiftLeft64(new $Int64(0, ((4 < 0 || 4 >= buf.$length) ? $throwRuntimeError("index out of range") : buf.$array[buf.$offset + 4])), 24), new $Int64(x$4.$high | x$9.$high, (x$4.$low | x$9.$low) >>> 0)), x$10 = $shiftLeft64(new $Int64(0, ((3 < 0 || 3 >= buf.$length) ? $throwRuntimeError("index out of range") : buf.$array[buf.$offset + 3])), 32), new $Int64(x$3.$high | x$10.$high, (x$3.$low | x$10.$low) >>> 0)), x$11 = $shiftLeft64(new $Int64(0, ((2 < 0 || 2 >= buf.$length) ? $throwRuntimeError("index out of range") : buf.$array[buf.$offset + 2])), 40), new $Int64(x$2.$high | x$11.$high, (x$2.$low | x$11.$low) >>> 0)), x$12 = $shiftLeft64(new $Int64(0, ((1 < 0 || 1 >= buf.$length) ? $throwRuntimeError("index out of range") : buf.$array[buf.$offset + 1])), 48), new $Int64(x$1.$high | x$12.$high, (x$1.$low | x$12.$low) >>> 0)), x$13 = $shiftLeft64(new $Int64(0, ((0 < 0 || 0 >= buf.$length) ? $throwRuntimeError("index out of range") : buf.$array[buf.$offset + 0])), 56), new $Int64(x.$high | x$13.$high, (x.$low | x$13.$low) >>> 0)); - buf = $subslice(buf, 8); - t.nsec = (((((((3 < 0 || 3 >= buf.$length) ? $throwRuntimeError("index out of range") : buf.$array[buf.$offset + 3]) >> 0) | ((((2 < 0 || 2 >= buf.$length) ? $throwRuntimeError("index out of range") : buf.$array[buf.$offset + 2]) >> 0) << 8 >> 0)) | ((((1 < 0 || 1 >= buf.$length) ? $throwRuntimeError("index out of range") : buf.$array[buf.$offset + 1]) >> 0) << 16 >> 0)) | ((((0 < 0 || 0 >= buf.$length) ? $throwRuntimeError("index out of range") : buf.$array[buf.$offset + 0]) >> 0) << 24 >> 0)) >>> 0); - buf = $subslice(buf, 4); - offset = (x$14 = (((((1 < 0 || 1 >= buf.$length) ? $throwRuntimeError("index out of range") : buf.$array[buf.$offset + 1]) << 16 >> 16) | ((((0 < 0 || 0 >= buf.$length) ? $throwRuntimeError("index out of range") : buf.$array[buf.$offset + 0]) << 16 >> 16) << 8 << 16 >> 16)) >> 0), (((x$14 >>> 16 << 16) * 60 >> 0) + (x$14 << 16 >>> 16) * 60) >> 0); - if (offset === -60) { - t.loc = utcLoc; - } else { - _tuple$1 = $pkg.Local.lookup((x$15 = t.sec, new $Int64(x$15.$high + -15, x$15.$low + 2288912640))); localoff = _tuple$1[1]; - if (offset === localoff) { - t.loc = $pkg.Local; + runeTmp = ($arrayType($Uint8, 4)).zero(); $copy(runeTmp, ($arrayType($Uint8, 4)).zero(), ($arrayType($Uint8, 4))); + buf = ($sliceType($Uint8)).make(0, (_q = (x = s.length, (((3 >>> 16 << 16) * x >> 0) + (3 << 16 >>> 16) * x) >> 0) / 2, (_q === _q && _q !== 1/0 && _q !== -1/0) ? _q >> 0 : $throwRuntimeError("integer divide by zero"))); + while (s.length > 0) { + _tuple$1 = UnquoteChar(s, quote); c = _tuple$1[0]; multibyte = _tuple$1[1]; ss = _tuple$1[2]; err$1 = _tuple$1[3]; + if (!($interfaceIsEqual(err$1, $ifaceNil))) { + _tmp$16 = ""; _tmp$17 = err$1; t = _tmp$16; err = _tmp$17; + return [t, err]; + } + s = ss; + if (c < 128 || !multibyte) { + buf = $append(buf, (c << 24 >>> 24)); } else { - t.loc = FixedZone("", offset); + n$1 = utf8.EncodeRune(new ($sliceType($Uint8))(runeTmp), c); + buf = $appendSlice(buf, $subslice(new ($sliceType($Uint8))(runeTmp), 0, n$1)); + } + if ((quote === 39) && !((s.length === 0))) { + _tmp$18 = ""; _tmp$19 = $pkg.ErrSyntax; t = _tmp$18; err = _tmp$19; + return [t, err]; } } - return $ifaceNil; - }; - Time.prototype.UnmarshalBinary = function(data$1) { return this.$val.UnmarshalBinary(data$1); }; - Time.Ptr.prototype.GobEncode = function() { - var t; - t = new Time.Ptr(); $copy(t, this, Time); - return t.MarshalBinary(); - }; - Time.prototype.GobEncode = function() { return this.$val.GobEncode(); }; - Time.Ptr.prototype.GobDecode = function(data$1) { - var t; - t = this; - return t.UnmarshalBinary(data$1); - }; - Time.prototype.GobDecode = function(data$1) { return this.$val.GobDecode(data$1); }; - Time.Ptr.prototype.MarshalJSON = function() { - var t, y; - t = new Time.Ptr(); $copy(t, this, Time); - y = t.Year(); - if (y < 0 || y >= 10000) { - return [($sliceType($Uint8)).nil, errors.New("Time.MarshalJSON: year outside of range [0,9999]")]; - } - return [new ($sliceType($Uint8))($stringToBytes(t.Format("\"2006-01-02T15:04:05.999999999Z07:00\""))), $ifaceNil]; - }; - Time.prototype.MarshalJSON = function() { return this.$val.MarshalJSON(); }; - Time.Ptr.prototype.UnmarshalJSON = function(data$1) { - var err = $ifaceNil, t, _tuple$1; - t = this; - _tuple$1 = Parse("\"2006-01-02T15:04:05Z07:00\"", $bytesToString(data$1)); $copy(t, _tuple$1[0], Time); err = _tuple$1[1]; - return err; + _tmp$20 = $bytesToString(buf); _tmp$21 = $ifaceNil; t = _tmp$20; err = _tmp$21; + return [t, err]; }; - Time.prototype.UnmarshalJSON = function(data$1) { return this.$val.UnmarshalJSON(data$1); }; - Time.Ptr.prototype.MarshalText = function() { - var t, y; - t = new Time.Ptr(); $copy(t, this, Time); - y = t.Year(); - if (y < 0 || y >= 10000) { - return [($sliceType($Uint8)).nil, errors.New("Time.MarshalText: year outside of range [0,9999]")]; + contains = function(s, c) { + var i; + i = 0; + while (i < s.length) { + if (s.charCodeAt(i) === c) { + return true; + } + i = i + (1) >> 0; } - return [new ($sliceType($Uint8))($stringToBytes(t.Format("2006-01-02T15:04:05.999999999Z07:00"))), $ifaceNil]; - }; - Time.prototype.MarshalText = function() { return this.$val.MarshalText(); }; - Time.Ptr.prototype.UnmarshalText = function(data$1) { - var err = $ifaceNil, t, _tuple$1; - t = this; - _tuple$1 = Parse("2006-01-02T15:04:05Z07:00", $bytesToString(data$1)); $copy(t, _tuple$1[0], Time); err = _tuple$1[1]; - return err; + return false; }; - Time.prototype.UnmarshalText = function(data$1) { return this.$val.UnmarshalText(data$1); }; - Unix = $pkg.Unix = function(sec, nsec) { - var n, x, x$1, x$2, x$3; - if ((nsec.$high < 0 || (nsec.$high === 0 && nsec.$low < 0)) || (nsec.$high > 0 || (nsec.$high === 0 && nsec.$low >= 1000000000))) { - n = $div64(nsec, new $Int64(0, 1000000000), false); - sec = (x = n, new $Int64(sec.$high + x.$high, sec.$low + x.$low)); - nsec = (x$1 = $mul64(n, new $Int64(0, 1000000000)), new $Int64(nsec.$high - x$1.$high, nsec.$low - x$1.$low)); - if ((nsec.$high < 0 || (nsec.$high === 0 && nsec.$low < 0))) { - nsec = (x$2 = new $Int64(0, 1000000000), new $Int64(nsec.$high + x$2.$high, nsec.$low + x$2.$low)); - sec = (x$3 = new $Int64(0, 1), new $Int64(sec.$high - x$3.$high, sec.$low - x$3.$low)); + bsearch16 = function(a, x) { + var _tmp, _tmp$1, i, j, _q, h; + _tmp = 0; _tmp$1 = a.$length; i = _tmp; j = _tmp$1; + while (i < j) { + h = i + (_q = ((j - i >> 0)) / 2, (_q === _q && _q !== 1/0 && _q !== -1/0) ? _q >> 0 : $throwRuntimeError("integer divide by zero")) >> 0; + if (((h < 0 || h >= a.$length) ? $throwRuntimeError("index out of range") : a.$array[a.$offset + h]) < x) { + i = h + 1 >> 0; + } else { + j = h; } } - return new Time.Ptr(new $Int64(sec.$high + 14, sec.$low + 2006054656), (nsec.$low >>> 0), $pkg.Local); - }; - isLeap = function(year) { - var _r, _r$1, _r$2; - return ((_r = year % 4, _r === _r ? _r : $throwRuntimeError("integer divide by zero")) === 0) && (!(((_r$1 = year % 100, _r$1 === _r$1 ? _r$1 : $throwRuntimeError("integer divide by zero")) === 0)) || ((_r$2 = year % 400, _r$2 === _r$2 ? _r$2 : $throwRuntimeError("integer divide by zero")) === 0)); + return i; }; - norm = function(hi, lo, base) { - var nhi = 0, nlo = 0, _q, n, _q$1, n$1, _tmp, _tmp$1; - if (lo < 0) { - n = (_q = ((-lo - 1 >> 0)) / base, (_q === _q && _q !== 1/0 && _q !== -1/0) ? _q >> 0 : $throwRuntimeError("integer divide by zero")) + 1 >> 0; - hi = hi - (n) >> 0; - lo = lo + (((((n >>> 16 << 16) * base >> 0) + (n << 16 >>> 16) * base) >> 0)) >> 0; - } - if (lo >= base) { - n$1 = (_q$1 = lo / base, (_q$1 === _q$1 && _q$1 !== 1/0 && _q$1 !== -1/0) ? _q$1 >> 0 : $throwRuntimeError("integer divide by zero")); - hi = hi + (n$1) >> 0; - lo = lo - (((((n$1 >>> 16 << 16) * base >> 0) + (n$1 << 16 >>> 16) * base) >> 0)) >> 0; + bsearch32 = function(a, x) { + var _tmp, _tmp$1, i, j, _q, h; + _tmp = 0; _tmp$1 = a.$length; i = _tmp; j = _tmp$1; + while (i < j) { + h = i + (_q = ((j - i >> 0)) / 2, (_q === _q && _q !== 1/0 && _q !== -1/0) ? _q >> 0 : $throwRuntimeError("integer divide by zero")) >> 0; + if (((h < 0 || h >= a.$length) ? $throwRuntimeError("index out of range") : a.$array[a.$offset + h]) < x) { + i = h + 1 >> 0; + } else { + j = h; + } } - _tmp = hi; _tmp$1 = lo; nhi = _tmp; nlo = _tmp$1; - return [nhi, nlo]; + return i; }; - Date = $pkg.Date = function(year, month, day, hour, min, sec, nsec, loc) { - var m, _tuple$1, _tuple$2, _tuple$3, _tuple$4, _tuple$5, x, x$1, y, n, x$2, d, x$3, x$4, x$5, x$6, x$7, x$8, x$9, x$10, x$11, abs, x$12, x$13, unix, _tuple$6, offset, start, end, x$14, utc, _tuple$7, _tuple$8, x$15; - if (loc === ($ptrType(Location)).nil) { - $panic(new $String("time: missing Location in call to Date")); - } - m = (month >> 0) - 1 >> 0; - _tuple$1 = norm(year, m, 12); year = _tuple$1[0]; m = _tuple$1[1]; - month = (m >> 0) + 1 >> 0; - _tuple$2 = norm(sec, nsec, 1000000000); sec = _tuple$2[0]; nsec = _tuple$2[1]; - _tuple$3 = norm(min, sec, 60); min = _tuple$3[0]; sec = _tuple$3[1]; - _tuple$4 = norm(hour, min, 60); hour = _tuple$4[0]; min = _tuple$4[1]; - _tuple$5 = norm(day, hour, 24); day = _tuple$5[0]; hour = _tuple$5[1]; - y = (x = (x$1 = new $Int64(0, year), new $Int64(x$1.$high - -69, x$1.$low - 4075721025)), new $Uint64(x.$high, x.$low)); - n = $div64(y, new $Uint64(0, 400), false); - y = (x$2 = $mul64(new $Uint64(0, 400), n), new $Uint64(y.$high - x$2.$high, y.$low - x$2.$low)); - d = $mul64(new $Uint64(0, 146097), n); - n = $div64(y, new $Uint64(0, 100), false); - y = (x$3 = $mul64(new $Uint64(0, 100), n), new $Uint64(y.$high - x$3.$high, y.$low - x$3.$low)); - d = (x$4 = $mul64(new $Uint64(0, 36524), n), new $Uint64(d.$high + x$4.$high, d.$low + x$4.$low)); - n = $div64(y, new $Uint64(0, 4), false); - y = (x$5 = $mul64(new $Uint64(0, 4), n), new $Uint64(y.$high - x$5.$high, y.$low - x$5.$low)); - d = (x$6 = $mul64(new $Uint64(0, 1461), n), new $Uint64(d.$high + x$6.$high, d.$low + x$6.$low)); - n = y; - d = (x$7 = $mul64(new $Uint64(0, 365), n), new $Uint64(d.$high + x$7.$high, d.$low + x$7.$low)); - d = (x$8 = new $Uint64(0, (x$9 = month - 1 >> 0, ((x$9 < 0 || x$9 >= daysBefore.length) ? $throwRuntimeError("index out of range") : daysBefore[x$9]))), new $Uint64(d.$high + x$8.$high, d.$low + x$8.$low)); - if (isLeap(year) && month >= 3) { - d = (x$10 = new $Uint64(0, 1), new $Uint64(d.$high + x$10.$high, d.$low + x$10.$low)); - } - d = (x$11 = new $Uint64(0, (day - 1 >> 0)), new $Uint64(d.$high + x$11.$high, d.$low + x$11.$low)); - abs = $mul64(d, new $Uint64(0, 86400)); - abs = (x$12 = new $Uint64(0, ((((((hour >>> 16 << 16) * 3600 >> 0) + (hour << 16 >>> 16) * 3600) >> 0) + ((((min >>> 16 << 16) * 60 >> 0) + (min << 16 >>> 16) * 60) >> 0) >> 0) + sec >> 0)), new $Uint64(abs.$high + x$12.$high, abs.$low + x$12.$low)); - unix = (x$13 = new $Int64(abs.$high, abs.$low), new $Int64(x$13.$high + -2147483647, x$13.$low + 3844486912)); - _tuple$6 = loc.lookup(unix); offset = _tuple$6[1]; start = _tuple$6[3]; end = _tuple$6[4]; - if (!((offset === 0))) { - utc = (x$14 = new $Int64(0, offset), new $Int64(unix.$high - x$14.$high, unix.$low - x$14.$low)); - if ((utc.$high < start.$high || (utc.$high === start.$high && utc.$low < start.$low))) { - _tuple$7 = loc.lookup(new $Int64(start.$high - 0, start.$low - 1)); offset = _tuple$7[1]; - } else if ((utc.$high > end.$high || (utc.$high === end.$high && utc.$low >= end.$low))) { - _tuple$8 = loc.lookup(end); offset = _tuple$8[1]; + IsPrint = $pkg.IsPrint = function(r) { + var _tmp, _tmp$1, _tmp$2, rr, isPrint, isNotPrint, i, x, x$1, j, _tmp$3, _tmp$4, _tmp$5, rr$1, isPrint$1, isNotPrint$1, i$1, x$2, x$3, j$1; + if (r <= 255) { + if (32 <= r && r <= 126) { + return true; } - unix = (x$15 = new $Int64(0, offset), new $Int64(unix.$high - x$15.$high, unix.$low - x$15.$low)); + if (161 <= r && r <= 255) { + return !((r === 173)); + } + return false; } - return new Time.Ptr(new $Int64(unix.$high + 14, unix.$low + 2006054656), (nsec >>> 0), loc); - }; - Time.Ptr.prototype.Truncate = function(d) { - var t, _tuple$1, r; - t = new Time.Ptr(); $copy(t, this, Time); - if ((d.$high < 0 || (d.$high === 0 && d.$low <= 0))) { - return t; + if (0 <= r && r < 65536) { + _tmp = (r << 16 >>> 16); _tmp$1 = isPrint16; _tmp$2 = isNotPrint16; rr = _tmp; isPrint = _tmp$1; isNotPrint = _tmp$2; + i = bsearch16(isPrint, rr); + if (i >= isPrint.$length || rr < (x = i & ~1, ((x < 0 || x >= isPrint.$length) ? $throwRuntimeError("index out of range") : isPrint.$array[isPrint.$offset + x])) || (x$1 = i | 1, ((x$1 < 0 || x$1 >= isPrint.$length) ? $throwRuntimeError("index out of range") : isPrint.$array[isPrint.$offset + x$1])) < rr) { + return false; + } + j = bsearch16(isNotPrint, rr); + return j >= isNotPrint.$length || !((((j < 0 || j >= isNotPrint.$length) ? $throwRuntimeError("index out of range") : isNotPrint.$array[isNotPrint.$offset + j]) === rr)); } - _tuple$1 = div($clone(t, Time), d); r = _tuple$1[1]; - return t.Add(new Duration(-r.$high, -r.$low)); - }; - Time.prototype.Truncate = function(d) { return this.$val.Truncate(d); }; - Time.Ptr.prototype.Round = function(d) { - var t, _tuple$1, r, x; - t = new Time.Ptr(); $copy(t, this, Time); - if ((d.$high < 0 || (d.$high === 0 && d.$low <= 0))) { - return t; + _tmp$3 = (r >>> 0); _tmp$4 = isPrint32; _tmp$5 = isNotPrint32; rr$1 = _tmp$3; isPrint$1 = _tmp$4; isNotPrint$1 = _tmp$5; + i$1 = bsearch32(isPrint$1, rr$1); + if (i$1 >= isPrint$1.$length || rr$1 < (x$2 = i$1 & ~1, ((x$2 < 0 || x$2 >= isPrint$1.$length) ? $throwRuntimeError("index out of range") : isPrint$1.$array[isPrint$1.$offset + x$2])) || (x$3 = i$1 | 1, ((x$3 < 0 || x$3 >= isPrint$1.$length) ? $throwRuntimeError("index out of range") : isPrint$1.$array[isPrint$1.$offset + x$3])) < rr$1) { + return false; } - _tuple$1 = div($clone(t, Time), d); r = _tuple$1[1]; - if ((x = new Duration(r.$high + r.$high, r.$low + r.$low), (x.$high < d.$high || (x.$high === d.$high && x.$low < d.$low)))) { - return t.Add(new Duration(-r.$high, -r.$low)); + if (r >= 131072) { + return true; } - return t.Add(new Duration(d.$high - r.$high, d.$low - r.$low)); + r = r - (65536) >> 0; + j$1 = bsearch16(isNotPrint$1, (r << 16 >>> 16)); + return j$1 >= isNotPrint$1.$length || !((((j$1 < 0 || j$1 >= isNotPrint$1.$length) ? $throwRuntimeError("index out of range") : isNotPrint$1.$array[isNotPrint$1.$offset + j$1]) === (r << 16 >>> 16))); }; - Time.prototype.Round = function(d) { return this.$val.Round(d); }; - div = function(t, d) { - var qmod2 = 0, r = new Duration(0, 0), neg, nsec, x, x$1, x$2, x$3, x$4, x$5, _q, _r, x$6, d1, x$7, x$8, x$9, x$10, x$11, sec, tmp, u1, u0, _tmp, _tmp$1, u0x, x$12, _tmp$2, _tmp$3, x$13, x$14, d1$1, x$15, d0, _tmp$4, _tmp$5, x$16, x$17, x$18, x$19; - neg = false; - nsec = (t.nsec >> 0); - if ((x = t.sec, (x.$high < 0 || (x.$high === 0 && x.$low < 0)))) { - neg = true; - t.sec = (x$1 = t.sec, new $Int64(-x$1.$high, -x$1.$low)); - nsec = -nsec; - if (nsec < 0) { - nsec = nsec + (1000000000) >> 0; - t.sec = (x$2 = t.sec, x$3 = new $Int64(0, 1), new $Int64(x$2.$high - x$3.$high, x$2.$low - x$3.$low)); - } + $pkg.$init = function() { + ($ptrType(NumError)).methods = [["Error", "Error", "", $funcType([], [$String], false), -1]]; + NumError.init([["Func", "Func", "", $String, ""], ["Num", "Num", "", $String, ""], ["Err", "Err", "", $error, ""]]); + ($ptrType(decimal)).methods = [["Assign", "Assign", "", $funcType([$Uint64], [], false), -1], ["Round", "Round", "", $funcType([$Int], [], false), -1], ["RoundDown", "RoundDown", "", $funcType([$Int], [], false), -1], ["RoundUp", "RoundUp", "", $funcType([$Int], [], false), -1], ["RoundedInteger", "RoundedInteger", "", $funcType([], [$Uint64], false), -1], ["Shift", "Shift", "", $funcType([$Int], [], false), -1], ["String", "String", "", $funcType([], [$String], false), -1], ["floatBits", "floatBits", "strconv", $funcType([($ptrType(floatInfo))], [$Uint64, $Bool], false), -1], ["set", "set", "strconv", $funcType([$String], [$Bool], false), -1]]; + decimal.init([["d", "d", "strconv", ($arrayType($Uint8, 800)), ""], ["nd", "nd", "strconv", $Int, ""], ["dp", "dp", "strconv", $Int, ""], ["neg", "neg", "strconv", $Bool, ""], ["trunc", "trunc", "strconv", $Bool, ""]]); + leftCheat.init([["delta", "delta", "strconv", $Int, ""], ["cutoff", "cutoff", "strconv", $String, ""]]); + ($ptrType(extFloat)).methods = [["AssignComputeBounds", "AssignComputeBounds", "", $funcType([$Uint64, $Int, $Bool, ($ptrType(floatInfo))], [extFloat, extFloat], false), -1], ["AssignDecimal", "AssignDecimal", "", $funcType([$Uint64, $Int, $Bool, $Bool, ($ptrType(floatInfo))], [$Bool], false), -1], ["FixedDecimal", "FixedDecimal", "", $funcType([($ptrType(decimalSlice)), $Int], [$Bool], false), -1], ["Multiply", "Multiply", "", $funcType([extFloat], [], false), -1], ["Normalize", "Normalize", "", $funcType([], [$Uint], false), -1], ["ShortestDecimal", "ShortestDecimal", "", $funcType([($ptrType(decimalSlice)), ($ptrType(extFloat)), ($ptrType(extFloat))], [$Bool], false), -1], ["floatBits", "floatBits", "strconv", $funcType([($ptrType(floatInfo))], [$Uint64, $Bool], false), -1], ["frexp10", "frexp10", "strconv", $funcType([], [$Int, $Int], false), -1]]; + extFloat.init([["mant", "mant", "strconv", $Uint64, ""], ["exp", "exp", "strconv", $Int, ""], ["neg", "neg", "strconv", $Bool, ""]]); + floatInfo.init([["mantbits", "mantbits", "strconv", $Uint, ""], ["expbits", "expbits", "strconv", $Uint, ""], ["bias", "bias", "strconv", $Int, ""]]); + decimalSlice.init([["d", "d", "strconv", ($sliceType($Uint8)), ""], ["nd", "nd", "strconv", $Int, ""], ["dp", "dp", "strconv", $Int, ""], ["neg", "neg", "strconv", $Bool, ""]]); + optimize = true; + powtab = new ($sliceType($Int))([1, 3, 6, 9, 13, 16, 19, 23, 26]); + float64pow10 = new ($sliceType($Float64))([1, 10, 100, 1000, 10000, 100000, 1e+06, 1e+07, 1e+08, 1e+09, 1e+10, 1e+11, 1e+12, 1e+13, 1e+14, 1e+15, 1e+16, 1e+17, 1e+18, 1e+19, 1e+20, 1e+21, 1e+22]); + float32pow10 = new ($sliceType($Float32))([1, 10, 100, 1000, 10000, 100000, 1e+06, 1e+07, 1e+08, 1e+09, 1e+10]); + $pkg.ErrRange = errors.New("value out of range"); + $pkg.ErrSyntax = errors.New("invalid syntax"); + leftcheats = new ($sliceType(leftCheat))([new leftCheat.Ptr(0, ""), new leftCheat.Ptr(1, "5"), new leftCheat.Ptr(1, "25"), new leftCheat.Ptr(1, "125"), new leftCheat.Ptr(2, "625"), new leftCheat.Ptr(2, "3125"), new leftCheat.Ptr(2, "15625"), new leftCheat.Ptr(3, "78125"), new leftCheat.Ptr(3, "390625"), new leftCheat.Ptr(3, "1953125"), new leftCheat.Ptr(4, "9765625"), new leftCheat.Ptr(4, "48828125"), new leftCheat.Ptr(4, "244140625"), new leftCheat.Ptr(4, "1220703125"), new leftCheat.Ptr(5, "6103515625"), new leftCheat.Ptr(5, "30517578125"), new leftCheat.Ptr(5, "152587890625"), new leftCheat.Ptr(6, "762939453125"), new leftCheat.Ptr(6, "3814697265625"), new leftCheat.Ptr(6, "19073486328125"), new leftCheat.Ptr(7, "95367431640625"), new leftCheat.Ptr(7, "476837158203125"), new leftCheat.Ptr(7, "2384185791015625"), new leftCheat.Ptr(7, "11920928955078125"), new leftCheat.Ptr(8, "59604644775390625"), new leftCheat.Ptr(8, "298023223876953125"), new leftCheat.Ptr(8, "1490116119384765625"), new leftCheat.Ptr(9, "7450580596923828125")]); + smallPowersOfTen = $toNativeArray("Struct", [new extFloat.Ptr(new $Uint64(2147483648, 0), -63, false), new extFloat.Ptr(new $Uint64(2684354560, 0), -60, false), new extFloat.Ptr(new $Uint64(3355443200, 0), -57, false), new extFloat.Ptr(new $Uint64(4194304000, 0), -54, false), new extFloat.Ptr(new $Uint64(2621440000, 0), -50, false), new extFloat.Ptr(new $Uint64(3276800000, 0), -47, false), new extFloat.Ptr(new $Uint64(4096000000, 0), -44, false), new extFloat.Ptr(new $Uint64(2560000000, 0), -40, false)]); + powersOfTen = $toNativeArray("Struct", [new extFloat.Ptr(new $Uint64(4203730336, 136053384), -1220, false), new extFloat.Ptr(new $Uint64(3132023167, 2722021238), -1193, false), new extFloat.Ptr(new $Uint64(2333539104, 810921078), -1166, false), new extFloat.Ptr(new $Uint64(3477244234, 1573795306), -1140, false), new extFloat.Ptr(new $Uint64(2590748842, 1432697645), -1113, false), new extFloat.Ptr(new $Uint64(3860516611, 1025131999), -1087, false), new extFloat.Ptr(new $Uint64(2876309015, 3348809418), -1060, false), new extFloat.Ptr(new $Uint64(4286034428, 3200048207), -1034, false), new extFloat.Ptr(new $Uint64(3193344495, 1097586188), -1007, false), new extFloat.Ptr(new $Uint64(2379227053, 2424306748), -980, false), new extFloat.Ptr(new $Uint64(3545324584, 827693699), -954, false), new extFloat.Ptr(new $Uint64(2641472655, 2913388981), -927, false), new extFloat.Ptr(new $Uint64(3936100983, 602835915), -901, false), new extFloat.Ptr(new $Uint64(2932623761, 1081627501), -874, false), new extFloat.Ptr(new $Uint64(2184974969, 1572261463), -847, false), new extFloat.Ptr(new $Uint64(3255866422, 1308317239), -821, false), new extFloat.Ptr(new $Uint64(2425809519, 944281679), -794, false), new extFloat.Ptr(new $Uint64(3614737867, 629291719), -768, false), new extFloat.Ptr(new $Uint64(2693189581, 2545915892), -741, false), new extFloat.Ptr(new $Uint64(4013165208, 388672741), -715, false), new extFloat.Ptr(new $Uint64(2990041083, 708162190), -688, false), new extFloat.Ptr(new $Uint64(2227754207, 3536207675), -661, false), new extFloat.Ptr(new $Uint64(3319612455, 450088378), -635, false), new extFloat.Ptr(new $Uint64(2473304014, 3139815830), -608, false), new extFloat.Ptr(new $Uint64(3685510180, 2103616900), -582, false), new extFloat.Ptr(new $Uint64(2745919064, 224385782), -555, false), new extFloat.Ptr(new $Uint64(4091738259, 3737383206), -529, false), new extFloat.Ptr(new $Uint64(3048582568, 2868871352), -502, false), new extFloat.Ptr(new $Uint64(2271371013, 1820084875), -475, false), new extFloat.Ptr(new $Uint64(3384606560, 885076051), -449, false), new extFloat.Ptr(new $Uint64(2521728396, 2444895829), -422, false), new extFloat.Ptr(new $Uint64(3757668132, 1881767613), -396, false), new extFloat.Ptr(new $Uint64(2799680927, 3102062735), -369, false), new extFloat.Ptr(new $Uint64(4171849679, 2289335700), -343, false), new extFloat.Ptr(new $Uint64(3108270227, 2410191823), -316, false), new extFloat.Ptr(new $Uint64(2315841784, 3205436779), -289, false), new extFloat.Ptr(new $Uint64(3450873173, 1697722806), -263, false), new extFloat.Ptr(new $Uint64(2571100870, 3497754540), -236, false), new extFloat.Ptr(new $Uint64(3831238852, 707476230), -210, false), new extFloat.Ptr(new $Uint64(2854495385, 1769181907), -183, false), new extFloat.Ptr(new $Uint64(4253529586, 2197867022), -157, false), new extFloat.Ptr(new $Uint64(3169126500, 2450594539), -130, false), new extFloat.Ptr(new $Uint64(2361183241, 1867548876), -103, false), new extFloat.Ptr(new $Uint64(3518437208, 3793315116), -77, false), new extFloat.Ptr(new $Uint64(2621440000, 0), -50, false), new extFloat.Ptr(new $Uint64(3906250000, 0), -24, false), new extFloat.Ptr(new $Uint64(2910383045, 2892103680), 3, false), new extFloat.Ptr(new $Uint64(2168404344, 4170451332), 30, false), new extFloat.Ptr(new $Uint64(3231174267, 3372684723), 56, false), new extFloat.Ptr(new $Uint64(2407412430, 2078956656), 83, false), new extFloat.Ptr(new $Uint64(3587324068, 2884206696), 109, false), new extFloat.Ptr(new $Uint64(2672764710, 395977285), 136, false), new extFloat.Ptr(new $Uint64(3982729777, 3569679143), 162, false), new extFloat.Ptr(new $Uint64(2967364920, 2361961896), 189, false), new extFloat.Ptr(new $Uint64(2210859150, 447440347), 216, false), new extFloat.Ptr(new $Uint64(3294436857, 1114709402), 242, false), new extFloat.Ptr(new $Uint64(2454546732, 2786846552), 269, false), new extFloat.Ptr(new $Uint64(3657559652, 443583978), 295, false), new extFloat.Ptr(new $Uint64(2725094297, 2599384906), 322, false), new extFloat.Ptr(new $Uint64(4060706939, 3028118405), 348, false), new extFloat.Ptr(new $Uint64(3025462433, 2044532855), 375, false), new extFloat.Ptr(new $Uint64(2254145170, 1536935362), 402, false), new extFloat.Ptr(new $Uint64(3358938053, 3365297469), 428, false), new extFloat.Ptr(new $Uint64(2502603868, 4204241075), 455, false), new extFloat.Ptr(new $Uint64(3729170365, 2577424355), 481, false), new extFloat.Ptr(new $Uint64(2778448436, 3677981733), 508, false), new extFloat.Ptr(new $Uint64(4140210802, 2744688476), 534, false), new extFloat.Ptr(new $Uint64(3084697427, 1424604878), 561, false), new extFloat.Ptr(new $Uint64(2298278679, 4062331362), 588, false), new extFloat.Ptr(new $Uint64(3424702107, 3546052773), 614, false), new extFloat.Ptr(new $Uint64(2551601907, 2065781727), 641, false), new extFloat.Ptr(new $Uint64(3802183132, 2535403578), 667, false), new extFloat.Ptr(new $Uint64(2832847187, 1558426518), 694, false), new extFloat.Ptr(new $Uint64(4221271257, 2762425404), 720, false), new extFloat.Ptr(new $Uint64(3145092172, 2812560400), 747, false), new extFloat.Ptr(new $Uint64(2343276271, 3057687578), 774, false), new extFloat.Ptr(new $Uint64(3491753744, 2790753324), 800, false), new extFloat.Ptr(new $Uint64(2601559269, 3918606633), 827, false), new extFloat.Ptr(new $Uint64(3876625403, 2711358621), 853, false), new extFloat.Ptr(new $Uint64(2888311001, 1648096297), 880, false), new extFloat.Ptr(new $Uint64(2151959390, 2057817989), 907, false), new extFloat.Ptr(new $Uint64(3206669376, 61660461), 933, false), new extFloat.Ptr(new $Uint64(2389154863, 1581580175), 960, false), new extFloat.Ptr(new $Uint64(3560118173, 2626467905), 986, false), new extFloat.Ptr(new $Uint64(2652494738, 3034782633), 1013, false), new extFloat.Ptr(new $Uint64(3952525166, 3135207385), 1039, false), new extFloat.Ptr(new $Uint64(2944860731, 2616258155), 1066, false)]); + uint64pow10 = $toNativeArray("Uint64", [new $Uint64(0, 1), new $Uint64(0, 10), new $Uint64(0, 100), new $Uint64(0, 1000), new $Uint64(0, 10000), new $Uint64(0, 100000), new $Uint64(0, 1000000), new $Uint64(0, 10000000), new $Uint64(0, 100000000), new $Uint64(0, 1000000000), new $Uint64(2, 1410065408), new $Uint64(23, 1215752192), new $Uint64(232, 3567587328), new $Uint64(2328, 1316134912), new $Uint64(23283, 276447232), new $Uint64(232830, 2764472320), new $Uint64(2328306, 1874919424), new $Uint64(23283064, 1569325056), new $Uint64(232830643, 2808348672), new $Uint64(2328306436, 2313682944)]); + float32info = new floatInfo.Ptr(23, 8, -127); + float64info = new floatInfo.Ptr(52, 11, -1023); + isPrint16 = new ($sliceType($Uint16))([32, 126, 161, 887, 890, 894, 900, 1319, 1329, 1366, 1369, 1418, 1423, 1479, 1488, 1514, 1520, 1524, 1542, 1563, 1566, 1805, 1808, 1866, 1869, 1969, 1984, 2042, 2048, 2093, 2096, 2139, 2142, 2142, 2208, 2220, 2276, 2444, 2447, 2448, 2451, 2482, 2486, 2489, 2492, 2500, 2503, 2504, 2507, 2510, 2519, 2519, 2524, 2531, 2534, 2555, 2561, 2570, 2575, 2576, 2579, 2617, 2620, 2626, 2631, 2632, 2635, 2637, 2641, 2641, 2649, 2654, 2662, 2677, 2689, 2745, 2748, 2765, 2768, 2768, 2784, 2787, 2790, 2801, 2817, 2828, 2831, 2832, 2835, 2873, 2876, 2884, 2887, 2888, 2891, 2893, 2902, 2903, 2908, 2915, 2918, 2935, 2946, 2954, 2958, 2965, 2969, 2975, 2979, 2980, 2984, 2986, 2990, 3001, 3006, 3010, 3014, 3021, 3024, 3024, 3031, 3031, 3046, 3066, 3073, 3129, 3133, 3149, 3157, 3161, 3168, 3171, 3174, 3183, 3192, 3199, 3202, 3257, 3260, 3277, 3285, 3286, 3294, 3299, 3302, 3314, 3330, 3386, 3389, 3406, 3415, 3415, 3424, 3427, 3430, 3445, 3449, 3455, 3458, 3478, 3482, 3517, 3520, 3526, 3530, 3530, 3535, 3551, 3570, 3572, 3585, 3642, 3647, 3675, 3713, 3716, 3719, 3722, 3725, 3725, 3732, 3751, 3754, 3773, 3776, 3789, 3792, 3801, 3804, 3807, 3840, 3948, 3953, 4058, 4096, 4295, 4301, 4301, 4304, 4685, 4688, 4701, 4704, 4749, 4752, 4789, 4792, 4805, 4808, 4885, 4888, 4954, 4957, 4988, 4992, 5017, 5024, 5108, 5120, 5788, 5792, 5872, 5888, 5908, 5920, 5942, 5952, 5971, 5984, 6003, 6016, 6109, 6112, 6121, 6128, 6137, 6144, 6157, 6160, 6169, 6176, 6263, 6272, 6314, 6320, 6389, 6400, 6428, 6432, 6443, 6448, 6459, 6464, 6464, 6468, 6509, 6512, 6516, 6528, 6571, 6576, 6601, 6608, 6618, 6622, 6683, 6686, 6780, 6783, 6793, 6800, 6809, 6816, 6829, 6912, 6987, 6992, 7036, 7040, 7155, 7164, 7223, 7227, 7241, 7245, 7295, 7360, 7367, 7376, 7414, 7424, 7654, 7676, 7957, 7960, 7965, 7968, 8005, 8008, 8013, 8016, 8061, 8064, 8147, 8150, 8175, 8178, 8190, 8208, 8231, 8240, 8286, 8304, 8305, 8308, 8348, 8352, 8378, 8400, 8432, 8448, 8585, 8592, 9203, 9216, 9254, 9280, 9290, 9312, 11084, 11088, 11097, 11264, 11507, 11513, 11559, 11565, 11565, 11568, 11623, 11631, 11632, 11647, 11670, 11680, 11835, 11904, 12019, 12032, 12245, 12272, 12283, 12289, 12438, 12441, 12543, 12549, 12589, 12593, 12730, 12736, 12771, 12784, 19893, 19904, 40908, 40960, 42124, 42128, 42182, 42192, 42539, 42560, 42647, 42655, 42743, 42752, 42899, 42912, 42922, 43000, 43051, 43056, 43065, 43072, 43127, 43136, 43204, 43214, 43225, 43232, 43259, 43264, 43347, 43359, 43388, 43392, 43481, 43486, 43487, 43520, 43574, 43584, 43597, 43600, 43609, 43612, 43643, 43648, 43714, 43739, 43766, 43777, 43782, 43785, 43790, 43793, 43798, 43808, 43822, 43968, 44013, 44016, 44025, 44032, 55203, 55216, 55238, 55243, 55291, 63744, 64109, 64112, 64217, 64256, 64262, 64275, 64279, 64285, 64449, 64467, 64831, 64848, 64911, 64914, 64967, 65008, 65021, 65024, 65049, 65056, 65062, 65072, 65131, 65136, 65276, 65281, 65470, 65474, 65479, 65482, 65487, 65490, 65495, 65498, 65500, 65504, 65518, 65532, 65533]); + isNotPrint16 = new ($sliceType($Uint16))([173, 907, 909, 930, 1376, 1416, 1424, 1757, 2111, 2209, 2303, 2424, 2432, 2436, 2473, 2481, 2526, 2564, 2601, 2609, 2612, 2615, 2621, 2653, 2692, 2702, 2706, 2729, 2737, 2740, 2758, 2762, 2820, 2857, 2865, 2868, 2910, 2948, 2961, 2971, 2973, 3017, 3076, 3085, 3089, 3113, 3124, 3141, 3145, 3159, 3204, 3213, 3217, 3241, 3252, 3269, 3273, 3295, 3312, 3332, 3341, 3345, 3397, 3401, 3460, 3506, 3516, 3541, 3543, 3715, 3721, 3736, 3744, 3748, 3750, 3756, 3770, 3781, 3783, 3912, 3992, 4029, 4045, 4294, 4681, 4695, 4697, 4745, 4785, 4799, 4801, 4823, 4881, 5760, 5901, 5997, 6001, 6751, 8024, 8026, 8028, 8030, 8117, 8133, 8156, 8181, 8335, 9984, 11311, 11359, 11558, 11687, 11695, 11703, 11711, 11719, 11727, 11735, 11743, 11930, 12352, 12687, 12831, 13055, 42895, 43470, 43815, 64311, 64317, 64319, 64322, 64325, 65107, 65127, 65141, 65511]); + isPrint32 = new ($sliceType($Uint32))([65536, 65613, 65616, 65629, 65664, 65786, 65792, 65794, 65799, 65843, 65847, 65930, 65936, 65947, 66000, 66045, 66176, 66204, 66208, 66256, 66304, 66339, 66352, 66378, 66432, 66499, 66504, 66517, 66560, 66717, 66720, 66729, 67584, 67589, 67592, 67640, 67644, 67644, 67647, 67679, 67840, 67867, 67871, 67897, 67903, 67903, 67968, 68023, 68030, 68031, 68096, 68102, 68108, 68147, 68152, 68154, 68159, 68167, 68176, 68184, 68192, 68223, 68352, 68405, 68409, 68437, 68440, 68466, 68472, 68479, 68608, 68680, 69216, 69246, 69632, 69709, 69714, 69743, 69760, 69825, 69840, 69864, 69872, 69881, 69888, 69955, 70016, 70088, 70096, 70105, 71296, 71351, 71360, 71369, 73728, 74606, 74752, 74850, 74864, 74867, 77824, 78894, 92160, 92728, 93952, 94020, 94032, 94078, 94095, 94111, 110592, 110593, 118784, 119029, 119040, 119078, 119081, 119154, 119163, 119261, 119296, 119365, 119552, 119638, 119648, 119665, 119808, 119967, 119970, 119970, 119973, 119974, 119977, 120074, 120077, 120134, 120138, 120485, 120488, 120779, 120782, 120831, 126464, 126500, 126503, 126523, 126530, 126530, 126535, 126548, 126551, 126564, 126567, 126619, 126625, 126651, 126704, 126705, 126976, 127019, 127024, 127123, 127136, 127150, 127153, 127166, 127169, 127199, 127232, 127242, 127248, 127339, 127344, 127386, 127462, 127490, 127504, 127546, 127552, 127560, 127568, 127569, 127744, 127776, 127792, 127868, 127872, 127891, 127904, 127946, 127968, 127984, 128000, 128252, 128256, 128317, 128320, 128323, 128336, 128359, 128507, 128576, 128581, 128591, 128640, 128709, 128768, 128883, 131072, 173782, 173824, 177972, 177984, 178205, 194560, 195101, 917760, 917999]); + isNotPrint32 = new ($sliceType($Uint16))([12, 39, 59, 62, 799, 926, 2057, 2102, 2134, 2564, 2580, 2584, 4285, 4405, 54357, 54429, 54445, 54458, 54460, 54468, 54534, 54549, 54557, 54586, 54591, 54597, 54609, 60932, 60960, 60963, 60968, 60979, 60984, 60986, 61000, 61002, 61004, 61008, 61011, 61016, 61018, 61020, 61022, 61024, 61027, 61035, 61043, 61048, 61053, 61055, 61066, 61092, 61098, 61648, 61743, 62262, 62405, 62527, 62529, 62712]); + shifts = $toNativeArray("Uint", [0, 0, 1, 0, 2, 0, 0, 0, 3, 0, 0, 0, 0, 0, 0, 0, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 5, 0, 0, 0, 0]); + }; + return $pkg; +})(); +$packages["strings"] = (function() { + var $pkg = {}, js = $packages["github.com/gopherjs/gopherjs/js"], errors = $packages["errors"], io = $packages["io"], utf8 = $packages["unicode/utf8"], unicode = $packages["unicode"], Reader, IndexByte, NewReader, explode, hashstr, Count, Contains, ContainsRune, Index, LastIndex, IndexRune, IndexAny, genSplit, Split, Fields, FieldsFunc, Join, HasPrefix, HasSuffix, Map, Repeat, ToUpper, ToLower, TrimLeftFunc, TrimRightFunc, TrimFunc, IndexFunc, indexFunc, lastIndexFunc, TrimSpace, TrimSuffix, Replace; + Reader = $pkg.Reader = $newType(0, "Struct", "strings.Reader", "Reader", "strings", function(s_, i_, prevRune_) { + this.$val = this; + this.s = s_ !== undefined ? s_ : ""; + this.i = i_ !== undefined ? i_ : new $Int64(0, 0); + this.prevRune = prevRune_ !== undefined ? prevRune_ : 0; + }); + IndexByte = $pkg.IndexByte = function(s, c) { + return $parseInt(s.indexOf($global.String.fromCharCode(c))) >> 0; + }; + Reader.Ptr.prototype.Len = function() { + var r, x, x$1, x$2, x$3, x$4; + r = this; + if ((x = r.i, x$1 = new $Int64(0, r.s.length), (x.$high > x$1.$high || (x.$high === x$1.$high && x.$low >= x$1.$low)))) { + return 0; } - if ((d.$high < 0 || (d.$high === 0 && d.$low < 1000000000)) && (x$4 = $div64(new Duration(0, 1000000000), (new Duration(d.$high + d.$high, d.$low + d.$low)), true), (x$4.$high === 0 && x$4.$low === 0))) { - qmod2 = ((_q = nsec / ((d.$low + ((d.$high >> 31) * 4294967296)) >> 0), (_q === _q && _q !== 1/0 && _q !== -1/0) ? _q >> 0 : $throwRuntimeError("integer divide by zero")) >> 0) & 1; - r = new Duration(0, (_r = nsec % ((d.$low + ((d.$high >> 31) * 4294967296)) >> 0), _r === _r ? _r : $throwRuntimeError("integer divide by zero"))); - } else if ((x$5 = $div64(d, new Duration(0, 1000000000), true), (x$5.$high === 0 && x$5.$low === 0))) { - d1 = (x$6 = $div64(d, new Duration(0, 1000000000), false), new $Int64(x$6.$high, x$6.$low)); - qmod2 = ((x$7 = $div64(t.sec, d1, false), x$7.$low + ((x$7.$high >> 31) * 4294967296)) >> 0) & 1; - r = (x$8 = $mul64((x$9 = $div64(t.sec, d1, true), new Duration(x$9.$high, x$9.$low)), new Duration(0, 1000000000)), x$10 = new Duration(0, nsec), new Duration(x$8.$high + x$10.$high, x$8.$low + x$10.$low)); - } else { - sec = (x$11 = t.sec, new $Uint64(x$11.$high, x$11.$low)); - tmp = $mul64(($shiftRightUint64(sec, 32)), new $Uint64(0, 1000000000)); - u1 = $shiftRightUint64(tmp, 32); - u0 = $shiftLeft64(tmp, 32); - tmp = $mul64(new $Uint64(sec.$high & 0, (sec.$low & 4294967295) >>> 0), new $Uint64(0, 1000000000)); - _tmp = u0; _tmp$1 = new $Uint64(u0.$high + tmp.$high, u0.$low + tmp.$low); u0x = _tmp; u0 = _tmp$1; - if ((u0.$high < u0x.$high || (u0.$high === u0x.$high && u0.$low < u0x.$low))) { - u1 = (x$12 = new $Uint64(0, 1), new $Uint64(u1.$high + x$12.$high, u1.$low + x$12.$low)); - } - _tmp$2 = u0; _tmp$3 = (x$13 = new $Uint64(0, nsec), new $Uint64(u0.$high + x$13.$high, u0.$low + x$13.$low)); u0x = _tmp$2; u0 = _tmp$3; - if ((u0.$high < u0x.$high || (u0.$high === u0x.$high && u0.$low < u0x.$low))) { - u1 = (x$14 = new $Uint64(0, 1), new $Uint64(u1.$high + x$14.$high, u1.$low + x$14.$low)); - } - d1$1 = new $Uint64(d.$high, d.$low); - while (!((x$15 = $shiftRightUint64(d1$1, 63), (x$15.$high === 0 && x$15.$low === 1)))) { - d1$1 = $shiftLeft64(d1$1, (1)); - } - d0 = new $Uint64(0, 0); - while (true) { - qmod2 = 0; - if ((u1.$high > d1$1.$high || (u1.$high === d1$1.$high && u1.$low > d1$1.$low)) || (u1.$high === d1$1.$high && u1.$low === d1$1.$low) && (u0.$high > d0.$high || (u0.$high === d0.$high && u0.$low >= d0.$low))) { - qmod2 = 1; - _tmp$4 = u0; _tmp$5 = new $Uint64(u0.$high - d0.$high, u0.$low - d0.$low); u0x = _tmp$4; u0 = _tmp$5; - if ((u0.$high > u0x.$high || (u0.$high === u0x.$high && u0.$low > u0x.$low))) { - u1 = (x$16 = new $Uint64(0, 1), new $Uint64(u1.$high - x$16.$high, u1.$low - x$16.$low)); - } - u1 = (x$17 = d1$1, new $Uint64(u1.$high - x$17.$high, u1.$low - x$17.$low)); - } - if ((d1$1.$high === 0 && d1$1.$low === 0) && (x$18 = new $Uint64(d.$high, d.$low), (d0.$high === x$18.$high && d0.$low === x$18.$low))) { - break; - } - d0 = $shiftRightUint64(d0, (1)); - d0 = (x$19 = $shiftLeft64((new $Uint64(d1$1.$high & 0, (d1$1.$low & 1) >>> 0)), 63), new $Uint64(d0.$high | x$19.$high, (d0.$low | x$19.$low) >>> 0)); - d1$1 = $shiftRightUint64(d1$1, (1)); - } - r = new Duration(u0.$high, u0.$low); + return ((x$2 = (x$3 = new $Int64(0, r.s.length), x$4 = r.i, new $Int64(x$3.$high - x$4.$high, x$3.$low - x$4.$low)), x$2.$low + ((x$2.$high >> 31) * 4294967296)) >> 0); + }; + Reader.prototype.Len = function() { return this.$val.Len(); }; + Reader.Ptr.prototype.Read = function(b) { + var n = 0, err = $ifaceNil, r, _tmp, _tmp$1, x, x$1, _tmp$2, _tmp$3, x$2, x$3; + r = this; + if (b.$length === 0) { + _tmp = 0; _tmp$1 = $ifaceNil; n = _tmp; err = _tmp$1; + return [n, err]; } - if (neg && !((r.$high === 0 && r.$low === 0))) { - qmod2 = (qmod2 ^ (1)) >> 0; - r = new Duration(d.$high - r.$high, d.$low - r.$low); + if ((x = r.i, x$1 = new $Int64(0, r.s.length), (x.$high > x$1.$high || (x.$high === x$1.$high && x.$low >= x$1.$low)))) { + _tmp$2 = 0; _tmp$3 = io.EOF; n = _tmp$2; err = _tmp$3; + return [n, err]; } - return [qmod2, r]; + r.prevRune = -1; + n = $copyString(b, r.s.substring($flatten64(r.i))); + r.i = (x$2 = r.i, x$3 = new $Int64(0, n), new $Int64(x$2.$high + x$3.$high, x$2.$low + x$3.$low)); + return [n, err]; }; - Location.Ptr.prototype.get = function() { - var l; - l = this; - if (l === ($ptrType(Location)).nil) { - return utcLoc; + Reader.prototype.Read = function(b) { return this.$val.Read(b); }; + Reader.Ptr.prototype.ReadAt = function(b, off) { + var n = 0, err = $ifaceNil, r, _tmp, _tmp$1, x, _tmp$2, _tmp$3; + r = this; + if ((off.$high < 0 || (off.$high === 0 && off.$low < 0))) { + _tmp = 0; _tmp$1 = errors.New("strings.Reader.ReadAt: negative offset"); n = _tmp; err = _tmp$1; + return [n, err]; } - if (l === localLoc) { - localOnce.Do(initLocal); + if ((x = new $Int64(0, r.s.length), (off.$high > x.$high || (off.$high === x.$high && off.$low >= x.$low)))) { + _tmp$2 = 0; _tmp$3 = io.EOF; n = _tmp$2; err = _tmp$3; + return [n, err]; } - return l; + n = $copyString(b, r.s.substring($flatten64(off))); + if (n < b.$length) { + err = io.EOF; + } + return [n, err]; }; - Location.prototype.get = function() { return this.$val.get(); }; - Location.Ptr.prototype.String = function() { - var l; - l = this; - return l.get().name; + Reader.prototype.ReadAt = function(b, off) { return this.$val.ReadAt(b, off); }; + Reader.Ptr.prototype.ReadByte = function() { + var b = 0, err = $ifaceNil, r, x, x$1, _tmp, _tmp$1, x$2, x$3; + r = this; + r.prevRune = -1; + if ((x = r.i, x$1 = new $Int64(0, r.s.length), (x.$high > x$1.$high || (x.$high === x$1.$high && x.$low >= x$1.$low)))) { + _tmp = 0; _tmp$1 = io.EOF; b = _tmp; err = _tmp$1; + return [b, err]; + } + b = r.s.charCodeAt($flatten64(r.i)); + r.i = (x$2 = r.i, x$3 = new $Int64(0, 1), new $Int64(x$2.$high + x$3.$high, x$2.$low + x$3.$low)); + return [b, err]; }; - Location.prototype.String = function() { return this.$val.String(); }; - FixedZone = $pkg.FixedZone = function(name, offset) { - var l, x; - l = new Location.Ptr(name, new ($sliceType(zone))([new zone.Ptr(name, offset, false)]), new ($sliceType(zoneTrans))([new zoneTrans.Ptr(new $Int64(-2147483648, 0), 0, false, false)]), new $Int64(-2147483648, 0), new $Int64(2147483647, 4294967295), ($ptrType(zone)).nil); - l.cacheZone = (x = l.zone, ((0 < 0 || 0 >= x.$length) ? $throwRuntimeError("index out of range") : x.$array[x.$offset + 0])); - return l; + Reader.prototype.ReadByte = function() { return this.$val.ReadByte(); }; + Reader.Ptr.prototype.UnreadByte = function() { + var r, x, x$1, x$2; + r = this; + r.prevRune = -1; + if ((x = r.i, (x.$high < 0 || (x.$high === 0 && x.$low <= 0)))) { + return errors.New("strings.Reader.UnreadByte: at beginning of string"); + } + r.i = (x$1 = r.i, x$2 = new $Int64(0, 1), new $Int64(x$1.$high - x$2.$high, x$1.$low - x$2.$low)); + return $ifaceNil; }; - Location.Ptr.prototype.lookup = function(sec) { - var name = "", offset = 0, isDST = false, start = new $Int64(0, 0), end = new $Int64(0, 0), l, zone$1, x, x$1, x$2, x$3, x$4, x$5, zone$2, x$6, tx, lo, hi, _q, m, lim, x$7, x$8, zone$3; - l = this; - l = l.get(); - if (l.zone.$length === 0) { - name = "UTC"; - offset = 0; - isDST = false; - start = new $Int64(-2147483648, 0); - end = new $Int64(2147483647, 4294967295); - return [name, offset, isDST, start, end]; + Reader.prototype.UnreadByte = function() { return this.$val.UnreadByte(); }; + Reader.Ptr.prototype.ReadRune = function() { + var ch = 0, size = 0, err = $ifaceNil, r, x, x$1, _tmp, _tmp$1, _tmp$2, x$2, c, x$3, x$4, _tmp$3, _tmp$4, _tmp$5, _tuple, x$5, x$6; + r = this; + if ((x = r.i, x$1 = new $Int64(0, r.s.length), (x.$high > x$1.$high || (x.$high === x$1.$high && x.$low >= x$1.$low)))) { + r.prevRune = -1; + _tmp = 0; _tmp$1 = 0; _tmp$2 = io.EOF; ch = _tmp; size = _tmp$1; err = _tmp$2; + return [ch, size, err]; } - zone$1 = l.cacheZone; - if (!(zone$1 === ($ptrType(zone)).nil) && (x = l.cacheStart, (x.$high < sec.$high || (x.$high === sec.$high && x.$low <= sec.$low))) && (x$1 = l.cacheEnd, (sec.$high < x$1.$high || (sec.$high === x$1.$high && sec.$low < x$1.$low)))) { - name = zone$1.name; - offset = zone$1.offset; - isDST = zone$1.isDST; - start = l.cacheStart; - end = l.cacheEnd; - return [name, offset, isDST, start, end]; + r.prevRune = ((x$2 = r.i, x$2.$low + ((x$2.$high >> 31) * 4294967296)) >> 0); + c = r.s.charCodeAt($flatten64(r.i)); + if (c < 128) { + r.i = (x$3 = r.i, x$4 = new $Int64(0, 1), new $Int64(x$3.$high + x$4.$high, x$3.$low + x$4.$low)); + _tmp$3 = (c >> 0); _tmp$4 = 1; _tmp$5 = $ifaceNil; ch = _tmp$3; size = _tmp$4; err = _tmp$5; + return [ch, size, err]; } - if ((l.tx.$length === 0) || (x$2 = (x$3 = l.tx, ((0 < 0 || 0 >= x$3.$length) ? $throwRuntimeError("index out of range") : x$3.$array[x$3.$offset + 0])).when, (sec.$high < x$2.$high || (sec.$high === x$2.$high && sec.$low < x$2.$low)))) { - zone$2 = (x$4 = l.zone, x$5 = l.lookupFirstZone(), ((x$5 < 0 || x$5 >= x$4.$length) ? $throwRuntimeError("index out of range") : x$4.$array[x$4.$offset + x$5])); - name = zone$2.name; - offset = zone$2.offset; - isDST = zone$2.isDST; - start = new $Int64(-2147483648, 0); - if (l.tx.$length > 0) { - end = (x$6 = l.tx, ((0 < 0 || 0 >= x$6.$length) ? $throwRuntimeError("index out of range") : x$6.$array[x$6.$offset + 0])).when; - } else { - end = new $Int64(2147483647, 4294967295); - } - return [name, offset, isDST, start, end]; + _tuple = utf8.DecodeRuneInString(r.s.substring($flatten64(r.i))); ch = _tuple[0]; size = _tuple[1]; + r.i = (x$5 = r.i, x$6 = new $Int64(0, size), new $Int64(x$5.$high + x$6.$high, x$5.$low + x$6.$low)); + return [ch, size, err]; + }; + Reader.prototype.ReadRune = function() { return this.$val.ReadRune(); }; + Reader.Ptr.prototype.UnreadRune = function() { + var r; + r = this; + if (r.prevRune < 0) { + return errors.New("strings.Reader.UnreadRune: previous operation was not ReadRune"); } - tx = l.tx; - end = new $Int64(2147483647, 4294967295); - lo = 0; - hi = tx.$length; - while ((hi - lo >> 0) > 1) { - m = lo + (_q = ((hi - lo >> 0)) / 2, (_q === _q && _q !== 1/0 && _q !== -1/0) ? _q >> 0 : $throwRuntimeError("integer divide by zero")) >> 0; - lim = ((m < 0 || m >= tx.$length) ? $throwRuntimeError("index out of range") : tx.$array[tx.$offset + m]).when; - if ((sec.$high < lim.$high || (sec.$high === lim.$high && sec.$low < lim.$low))) { - end = lim; - hi = m; + r.i = new $Int64(0, r.prevRune); + r.prevRune = -1; + return $ifaceNil; + }; + Reader.prototype.UnreadRune = function() { return this.$val.UnreadRune(); }; + Reader.Ptr.prototype.Seek = function(offset, whence) { + var r, abs, _ref, x, x$1; + r = this; + r.prevRune = -1; + abs = new $Int64(0, 0); + _ref = whence; + if (_ref === 0) { + abs = offset; + } else if (_ref === 1) { + abs = (x = r.i, new $Int64(x.$high + offset.$high, x.$low + offset.$low)); + } else if (_ref === 2) { + abs = (x$1 = new $Int64(0, r.s.length), new $Int64(x$1.$high + offset.$high, x$1.$low + offset.$low)); + } else { + return [new $Int64(0, 0), errors.New("strings.Reader.Seek: invalid whence")]; + } + if ((abs.$high < 0 || (abs.$high === 0 && abs.$low < 0))) { + return [new $Int64(0, 0), errors.New("strings.Reader.Seek: negative position")]; + } + r.i = abs; + return [abs, $ifaceNil]; + }; + Reader.prototype.Seek = function(offset, whence) { return this.$val.Seek(offset, whence); }; + Reader.Ptr.prototype.WriteTo = function(w) { + var n = new $Int64(0, 0), err = $ifaceNil, r, x, x$1, _tmp, _tmp$1, s, _tuple, m, x$2, x$3; + r = this; + r.prevRune = -1; + if ((x = r.i, x$1 = new $Int64(0, r.s.length), (x.$high > x$1.$high || (x.$high === x$1.$high && x.$low >= x$1.$low)))) { + _tmp = new $Int64(0, 0); _tmp$1 = $ifaceNil; n = _tmp; err = _tmp$1; + return [n, err]; + } + s = r.s.substring($flatten64(r.i)); + _tuple = io.WriteString(w, s); m = _tuple[0]; err = _tuple[1]; + if (m > s.length) { + $panic(new $String("strings.Reader.WriteTo: invalid WriteString count")); + } + r.i = (x$2 = r.i, x$3 = new $Int64(0, m), new $Int64(x$2.$high + x$3.$high, x$2.$low + x$3.$low)); + n = new $Int64(0, m); + if (!((m === s.length)) && $interfaceIsEqual(err, $ifaceNil)) { + err = io.ErrShortWrite; + } + return [n, err]; + }; + Reader.prototype.WriteTo = function(w) { return this.$val.WriteTo(w); }; + NewReader = $pkg.NewReader = function(s) { + return new Reader.Ptr(s, new $Int64(0, 0), -1); + }; + explode = function(s, n) { + var l, a, size, ch, _tmp, _tmp$1, i, cur, _tuple; + if (n === 0) { + return ($sliceType($String)).nil; + } + l = utf8.RuneCountInString(s); + if (n <= 0 || n > l) { + n = l; + } + a = ($sliceType($String)).make(n); + size = 0; + ch = 0; + _tmp = 0; _tmp$1 = 0; i = _tmp; cur = _tmp$1; + while ((i + 1 >> 0) < n) { + _tuple = utf8.DecodeRuneInString(s.substring(cur)); ch = _tuple[0]; size = _tuple[1]; + if (ch === 65533) { + (i < 0 || i >= a.$length) ? $throwRuntimeError("index out of range") : a.$array[a.$offset + i] = "\xEF\xBF\xBD"; } else { - lo = m; + (i < 0 || i >= a.$length) ? $throwRuntimeError("index out of range") : a.$array[a.$offset + i] = s.substring(cur, (cur + size >> 0)); } + cur = cur + (size) >> 0; + i = i + (1) >> 0; } - zone$3 = (x$7 = l.zone, x$8 = ((lo < 0 || lo >= tx.$length) ? $throwRuntimeError("index out of range") : tx.$array[tx.$offset + lo]).index, ((x$8 < 0 || x$8 >= x$7.$length) ? $throwRuntimeError("index out of range") : x$7.$array[x$7.$offset + x$8])); - name = zone$3.name; - offset = zone$3.offset; - isDST = zone$3.isDST; - start = ((lo < 0 || lo >= tx.$length) ? $throwRuntimeError("index out of range") : tx.$array[tx.$offset + lo]).when; - return [name, offset, isDST, start, end]; + if (cur < s.length) { + (i < 0 || i >= a.$length) ? $throwRuntimeError("index out of range") : a.$array[a.$offset + i] = s.substring(cur); + } + return a; }; - Location.prototype.lookup = function(sec) { return this.$val.lookup(sec); }; - Location.Ptr.prototype.lookupFirstZone = function() { - var l, x, x$1, x$2, x$3, zi, x$4, _ref, _i, zi$1, x$5; - l = this; - if (!l.firstZoneUsed()) { - return 0; + hashstr = function(sep) { + var hash, i, _tmp, _tmp$1, pow, sq, i$1, x, x$1; + hash = 0; + i = 0; + while (i < sep.length) { + hash = ((((hash >>> 16 << 16) * 16777619 >>> 0) + (hash << 16 >>> 16) * 16777619) >>> 0) + (sep.charCodeAt(i) >>> 0) >>> 0; + i = i + (1) >> 0; } - if (l.tx.$length > 0 && (x = l.zone, x$1 = (x$2 = l.tx, ((0 < 0 || 0 >= x$2.$length) ? $throwRuntimeError("index out of range") : x$2.$array[x$2.$offset + 0])).index, ((x$1 < 0 || x$1 >= x.$length) ? $throwRuntimeError("index out of range") : x.$array[x.$offset + x$1])).isDST) { - zi = ((x$3 = l.tx, ((0 < 0 || 0 >= x$3.$length) ? $throwRuntimeError("index out of range") : x$3.$array[x$3.$offset + 0])).index >> 0) - 1 >> 0; - while (zi >= 0) { - if (!(x$4 = l.zone, ((zi < 0 || zi >= x$4.$length) ? $throwRuntimeError("index out of range") : x$4.$array[x$4.$offset + zi])).isDST) { - return zi; + _tmp = 1; _tmp$1 = 16777619; pow = _tmp; sq = _tmp$1; + i$1 = sep.length; + while (i$1 > 0) { + if (!(((i$1 & 1) === 0))) { + pow = (x = sq, (((pow >>> 16 << 16) * x >>> 0) + (pow << 16 >>> 16) * x) >>> 0); + } + sq = (x$1 = sq, (((sq >>> 16 << 16) * x$1 >>> 0) + (sq << 16 >>> 16) * x$1) >>> 0); + i$1 = (i$1 >> $min((1), 31)) >> 0; + } + return [hash, pow]; + }; + Count = $pkg.Count = function(s, sep) { + var n, c, i, _tuple, hashsep, pow, h, i$1, lastmatch, i$2, x, x$1; + n = 0; + if (sep.length === 0) { + return utf8.RuneCountInString(s) + 1 >> 0; + } else if (sep.length === 1) { + c = sep.charCodeAt(0); + i = 0; + while (i < s.length) { + if (s.charCodeAt(i) === c) { + n = n + (1) >> 0; } - zi = zi - (1) >> 0; + i = i + (1) >> 0; + } + return n; + } else if (sep.length > s.length) { + return 0; + } else if (sep.length === s.length) { + if (sep === s) { + return 1; } + return 0; } - _ref = l.zone; - _i = 0; - while (_i < _ref.$length) { - zi$1 = _i; - if (!(x$5 = l.zone, ((zi$1 < 0 || zi$1 >= x$5.$length) ? $throwRuntimeError("index out of range") : x$5.$array[x$5.$offset + zi$1])).isDST) { - return zi$1; + _tuple = hashstr(sep); hashsep = _tuple[0]; pow = _tuple[1]; + h = 0; + i$1 = 0; + while (i$1 < sep.length) { + h = ((((h >>> 16 << 16) * 16777619 >>> 0) + (h << 16 >>> 16) * 16777619) >>> 0) + (s.charCodeAt(i$1) >>> 0) >>> 0; + i$1 = i$1 + (1) >> 0; + } + lastmatch = 0; + if ((h === hashsep) && s.substring(0, sep.length) === sep) { + n = n + (1) >> 0; + lastmatch = sep.length; + } + i$2 = sep.length; + while (i$2 < s.length) { + h = (x = 16777619, (((h >>> 16 << 16) * x >>> 0) + (h << 16 >>> 16) * x) >>> 0); + h = h + ((s.charCodeAt(i$2) >>> 0)) >>> 0; + h = h - ((x$1 = (s.charCodeAt((i$2 - sep.length >> 0)) >>> 0), (((pow >>> 16 << 16) * x$1 >>> 0) + (pow << 16 >>> 16) * x$1) >>> 0)) >>> 0; + i$2 = i$2 + (1) >> 0; + if ((h === hashsep) && lastmatch <= (i$2 - sep.length >> 0) && s.substring((i$2 - sep.length >> 0), i$2) === sep) { + n = n + (1) >> 0; + lastmatch = i$2; } - _i++; } - return 0; + return n; }; - Location.prototype.lookupFirstZone = function() { return this.$val.lookupFirstZone(); }; - Location.Ptr.prototype.firstZoneUsed = function() { - var l, _ref, _i, tx; - l = this; - _ref = l.tx; - _i = 0; - while (_i < _ref.$length) { - tx = new zoneTrans.Ptr(); $copy(tx, ((_i < 0 || _i >= _ref.$length) ? $throwRuntimeError("index out of range") : _ref.$array[_ref.$offset + _i]), zoneTrans); - if (tx.index === 0) { - return true; + Contains = $pkg.Contains = function(s, substr) { + return Index(s, substr) >= 0; + }; + ContainsRune = $pkg.ContainsRune = function(s, r) { + return IndexRune(s, r) >= 0; + }; + Index = $pkg.Index = function(s, sep) { + var n, _tuple, hashsep, pow, h, i, i$1, x, x$1; + n = sep.length; + if (n === 0) { + return 0; + } else if (n === 1) { + return IndexByte(s, sep.charCodeAt(0)); + } else if (n === s.length) { + if (sep === s) { + return 0; } - _i++; + return -1; + } else if (n > s.length) { + return -1; } - return false; + _tuple = hashstr(sep); hashsep = _tuple[0]; pow = _tuple[1]; + h = 0; + i = 0; + while (i < n) { + h = ((((h >>> 16 << 16) * 16777619 >>> 0) + (h << 16 >>> 16) * 16777619) >>> 0) + (s.charCodeAt(i) >>> 0) >>> 0; + i = i + (1) >> 0; + } + if ((h === hashsep) && s.substring(0, n) === sep) { + return 0; + } + i$1 = n; + while (i$1 < s.length) { + h = (x = 16777619, (((h >>> 16 << 16) * x >>> 0) + (h << 16 >>> 16) * x) >>> 0); + h = h + ((s.charCodeAt(i$1) >>> 0)) >>> 0; + h = h - ((x$1 = (s.charCodeAt((i$1 - n >> 0)) >>> 0), (((pow >>> 16 << 16) * x$1 >>> 0) + (pow << 16 >>> 16) * x$1) >>> 0)) >>> 0; + i$1 = i$1 + (1) >> 0; + if ((h === hashsep) && s.substring((i$1 - n >> 0), i$1) === sep) { + return i$1 - n >> 0; + } + } + return -1; }; - Location.prototype.firstZoneUsed = function() { return this.$val.firstZoneUsed(); }; - Location.Ptr.prototype.lookupName = function(name, unix) { - var offset = 0, isDST = false, ok = false, l, _ref, _i, i, x, zone$1, _tuple$1, x$1, nam, offset$1, isDST$1, _tmp, _tmp$1, _tmp$2, _ref$1, _i$1, i$1, x$2, zone$2, _tmp$3, _tmp$4, _tmp$5; - l = this; - l = l.get(); - _ref = l.zone; - _i = 0; - while (_i < _ref.$length) { - i = _i; - zone$1 = (x = l.zone, ((i < 0 || i >= x.$length) ? $throwRuntimeError("index out of range") : x.$array[x.$offset + i])); - if (zone$1.name === name) { - _tuple$1 = l.lookup((x$1 = new $Int64(0, zone$1.offset), new $Int64(unix.$high - x$1.$high, unix.$low - x$1.$low))); nam = _tuple$1[0]; offset$1 = _tuple$1[1]; isDST$1 = _tuple$1[2]; - if (nam === zone$1.name) { - _tmp = offset$1; _tmp$1 = isDST$1; _tmp$2 = true; offset = _tmp; isDST = _tmp$1; ok = _tmp$2; - return [offset, isDST, ok]; + LastIndex = $pkg.LastIndex = function(s, sep) { + var n, c, i, i$1; + n = sep.length; + if (n === 0) { + return s.length; + } + c = sep.charCodeAt(0); + if (n === 1) { + i = s.length - 1 >> 0; + while (i >= 0) { + if (s.charCodeAt(i) === c) { + return i; } + i = i - (1) >> 0; } - _i++; + return -1; } - _ref$1 = l.zone; - _i$1 = 0; - while (_i$1 < _ref$1.$length) { - i$1 = _i$1; - zone$2 = (x$2 = l.zone, ((i$1 < 0 || i$1 >= x$2.$length) ? $throwRuntimeError("index out of range") : x$2.$array[x$2.$offset + i$1])); - if (zone$2.name === name) { - _tmp$3 = zone$2.offset; _tmp$4 = zone$2.isDST; _tmp$5 = true; offset = _tmp$3; isDST = _tmp$4; ok = _tmp$5; - return [offset, isDST, ok]; + i$1 = s.length - n >> 0; + while (i$1 >= 0) { + if ((s.charCodeAt(i$1) === c) && s.substring(i$1, (i$1 + n >> 0)) === sep) { + return i$1; } - _i$1++; + i$1 = i$1 - (1) >> 0; } - return [offset, isDST, ok]; + return -1; }; - Location.prototype.lookupName = function(name, unix) { return this.$val.lookupName(name, unix); }; - $pkg.$init = function() { - runtimeTimer.init([["i", "i", "time", $Int32, ""], ["when", "when", "time", $Int64, ""], ["period", "period", "time", $Int64, ""], ["f", "f", "time", ($funcType([$Int64, $emptyInterface], [], false)), ""], ["arg", "arg", "time", $emptyInterface, ""], ["timeout", "timeout", "time", js.Object, ""], ["active", "active", "time", $Bool, ""]]); - ($ptrType(ParseError)).methods = [["Error", "Error", "", $funcType([], [$String], false), -1]]; - ParseError.init([["Layout", "Layout", "", $String, ""], ["Value", "Value", "", $String, ""], ["LayoutElem", "LayoutElem", "", $String, ""], ["ValueElem", "ValueElem", "", $String, ""], ["Message", "Message", "", $String, ""]]); - ($ptrType(Timer)).methods = [["Reset", "Reset", "", $funcType([Duration], [$Bool], false), -1], ["Stop", "Stop", "", $funcType([], [$Bool], false), -1]]; - Timer.init([["C", "C", "", ($chanType(Time, false, true)), ""], ["r", "r", "time", runtimeTimer, ""]]); - Time.methods = [["Add", "Add", "", $funcType([Duration], [Time], false), -1], ["AddDate", "AddDate", "", $funcType([$Int, $Int, $Int], [Time], false), -1], ["After", "After", "", $funcType([Time], [$Bool], false), -1], ["Before", "Before", "", $funcType([Time], [$Bool], false), -1], ["Clock", "Clock", "", $funcType([], [$Int, $Int, $Int], false), -1], ["Date", "Date", "", $funcType([], [$Int, Month, $Int], false), -1], ["Day", "Day", "", $funcType([], [$Int], false), -1], ["Equal", "Equal", "", $funcType([Time], [$Bool], false), -1], ["Format", "Format", "", $funcType([$String], [$String], false), -1], ["GobEncode", "GobEncode", "", $funcType([], [($sliceType($Uint8)), $error], false), -1], ["Hour", "Hour", "", $funcType([], [$Int], false), -1], ["ISOWeek", "ISOWeek", "", $funcType([], [$Int, $Int], false), -1], ["In", "In", "", $funcType([($ptrType(Location))], [Time], false), -1], ["IsZero", "IsZero", "", $funcType([], [$Bool], false), -1], ["Local", "Local", "", $funcType([], [Time], false), -1], ["Location", "Location", "", $funcType([], [($ptrType(Location))], false), -1], ["MarshalBinary", "MarshalBinary", "", $funcType([], [($sliceType($Uint8)), $error], false), -1], ["MarshalJSON", "MarshalJSON", "", $funcType([], [($sliceType($Uint8)), $error], false), -1], ["MarshalText", "MarshalText", "", $funcType([], [($sliceType($Uint8)), $error], false), -1], ["Minute", "Minute", "", $funcType([], [$Int], false), -1], ["Month", "Month", "", $funcType([], [Month], false), -1], ["Nanosecond", "Nanosecond", "", $funcType([], [$Int], false), -1], ["Round", "Round", "", $funcType([Duration], [Time], false), -1], ["Second", "Second", "", $funcType([], [$Int], false), -1], ["String", "String", "", $funcType([], [$String], false), -1], ["Sub", "Sub", "", $funcType([Time], [Duration], false), -1], ["Truncate", "Truncate", "", $funcType([Duration], [Time], false), -1], ["UTC", "UTC", "", $funcType([], [Time], false), -1], ["Unix", "Unix", "", $funcType([], [$Int64], false), -1], ["UnixNano", "UnixNano", "", $funcType([], [$Int64], false), -1], ["Weekday", "Weekday", "", $funcType([], [Weekday], false), -1], ["Year", "Year", "", $funcType([], [$Int], false), -1], ["YearDay", "YearDay", "", $funcType([], [$Int], false), -1], ["Zone", "Zone", "", $funcType([], [$String, $Int], false), -1], ["abs", "abs", "time", $funcType([], [$Uint64], false), -1], ["date", "date", "time", $funcType([$Bool], [$Int, Month, $Int, $Int], false), -1], ["locabs", "locabs", "time", $funcType([], [$String, $Int, $Uint64], false), -1]]; - ($ptrType(Time)).methods = [["Add", "Add", "", $funcType([Duration], [Time], false), -1], ["AddDate", "AddDate", "", $funcType([$Int, $Int, $Int], [Time], false), -1], ["After", "After", "", $funcType([Time], [$Bool], false), -1], ["Before", "Before", "", $funcType([Time], [$Bool], false), -1], ["Clock", "Clock", "", $funcType([], [$Int, $Int, $Int], false), -1], ["Date", "Date", "", $funcType([], [$Int, Month, $Int], false), -1], ["Day", "Day", "", $funcType([], [$Int], false), -1], ["Equal", "Equal", "", $funcType([Time], [$Bool], false), -1], ["Format", "Format", "", $funcType([$String], [$String], false), -1], ["GobDecode", "GobDecode", "", $funcType([($sliceType($Uint8))], [$error], false), -1], ["GobEncode", "GobEncode", "", $funcType([], [($sliceType($Uint8)), $error], false), -1], ["Hour", "Hour", "", $funcType([], [$Int], false), -1], ["ISOWeek", "ISOWeek", "", $funcType([], [$Int, $Int], false), -1], ["In", "In", "", $funcType([($ptrType(Location))], [Time], false), -1], ["IsZero", "IsZero", "", $funcType([], [$Bool], false), -1], ["Local", "Local", "", $funcType([], [Time], false), -1], ["Location", "Location", "", $funcType([], [($ptrType(Location))], false), -1], ["MarshalBinary", "MarshalBinary", "", $funcType([], [($sliceType($Uint8)), $error], false), -1], ["MarshalJSON", "MarshalJSON", "", $funcType([], [($sliceType($Uint8)), $error], false), -1], ["MarshalText", "MarshalText", "", $funcType([], [($sliceType($Uint8)), $error], false), -1], ["Minute", "Minute", "", $funcType([], [$Int], false), -1], ["Month", "Month", "", $funcType([], [Month], false), -1], ["Nanosecond", "Nanosecond", "", $funcType([], [$Int], false), -1], ["Round", "Round", "", $funcType([Duration], [Time], false), -1], ["Second", "Second", "", $funcType([], [$Int], false), -1], ["String", "String", "", $funcType([], [$String], false), -1], ["Sub", "Sub", "", $funcType([Time], [Duration], false), -1], ["Truncate", "Truncate", "", $funcType([Duration], [Time], false), -1], ["UTC", "UTC", "", $funcType([], [Time], false), -1], ["Unix", "Unix", "", $funcType([], [$Int64], false), -1], ["UnixNano", "UnixNano", "", $funcType([], [$Int64], false), -1], ["UnmarshalBinary", "UnmarshalBinary", "", $funcType([($sliceType($Uint8))], [$error], false), -1], ["UnmarshalJSON", "UnmarshalJSON", "", $funcType([($sliceType($Uint8))], [$error], false), -1], ["UnmarshalText", "UnmarshalText", "", $funcType([($sliceType($Uint8))], [$error], false), -1], ["Weekday", "Weekday", "", $funcType([], [Weekday], false), -1], ["Year", "Year", "", $funcType([], [$Int], false), -1], ["YearDay", "YearDay", "", $funcType([], [$Int], false), -1], ["Zone", "Zone", "", $funcType([], [$String, $Int], false), -1], ["abs", "abs", "time", $funcType([], [$Uint64], false), -1], ["date", "date", "time", $funcType([$Bool], [$Int, Month, $Int, $Int], false), -1], ["locabs", "locabs", "time", $funcType([], [$String, $Int, $Uint64], false), -1]]; - Time.init([["sec", "sec", "time", $Int64, ""], ["nsec", "nsec", "time", $Uintptr, ""], ["loc", "loc", "time", ($ptrType(Location)), ""]]); - Month.methods = [["String", "String", "", $funcType([], [$String], false), -1]]; - ($ptrType(Month)).methods = [["String", "String", "", $funcType([], [$String], false), -1]]; - Weekday.methods = [["String", "String", "", $funcType([], [$String], false), -1]]; - ($ptrType(Weekday)).methods = [["String", "String", "", $funcType([], [$String], false), -1]]; - Duration.methods = [["Hours", "Hours", "", $funcType([], [$Float64], false), -1], ["Minutes", "Minutes", "", $funcType([], [$Float64], false), -1], ["Nanoseconds", "Nanoseconds", "", $funcType([], [$Int64], false), -1], ["Seconds", "Seconds", "", $funcType([], [$Float64], false), -1], ["String", "String", "", $funcType([], [$String], false), -1]]; - ($ptrType(Duration)).methods = [["Hours", "Hours", "", $funcType([], [$Float64], false), -1], ["Minutes", "Minutes", "", $funcType([], [$Float64], false), -1], ["Nanoseconds", "Nanoseconds", "", $funcType([], [$Int64], false), -1], ["Seconds", "Seconds", "", $funcType([], [$Float64], false), -1], ["String", "String", "", $funcType([], [$String], false), -1]]; - ($ptrType(Location)).methods = [["String", "String", "", $funcType([], [$String], false), -1], ["firstZoneUsed", "firstZoneUsed", "time", $funcType([], [$Bool], false), -1], ["get", "get", "time", $funcType([], [($ptrType(Location))], false), -1], ["lookup", "lookup", "time", $funcType([$Int64], [$String, $Int, $Bool, $Int64, $Int64], false), -1], ["lookupFirstZone", "lookupFirstZone", "time", $funcType([], [$Int], false), -1], ["lookupName", "lookupName", "time", $funcType([$String, $Int64], [$Int, $Bool, $Bool], false), -1]]; - Location.init([["name", "name", "time", $String, ""], ["zone", "zone", "time", ($sliceType(zone)), ""], ["tx", "tx", "time", ($sliceType(zoneTrans)), ""], ["cacheStart", "cacheStart", "time", $Int64, ""], ["cacheEnd", "cacheEnd", "time", $Int64, ""], ["cacheZone", "cacheZone", "time", ($ptrType(zone)), ""]]); - zone.init([["name", "name", "time", $String, ""], ["offset", "offset", "time", $Int, ""], ["isDST", "isDST", "time", $Bool, ""]]); - zoneTrans.init([["when", "when", "time", $Int64, ""], ["index", "index", "time", $Uint8, ""], ["isstd", "isstd", "time", $Bool, ""], ["isutc", "isutc", "time", $Bool, ""]]); - localLoc = new Location.Ptr(); - localOnce = new sync.Once.Ptr(); - std0x = $toNativeArray("Int", [260, 265, 524, 526, 528, 274]); - longDayNames = new ($sliceType($String))(["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"]); - shortDayNames = new ($sliceType($String))(["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"]); - shortMonthNames = new ($sliceType($String))(["---", "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"]); - longMonthNames = new ($sliceType($String))(["---", "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"]); - atoiError = errors.New("time: invalid number"); - errBad = errors.New("bad value for field"); - errLeadingInt = errors.New("time: bad [0-9]*"); - months = $toNativeArray("String", ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"]); - days = $toNativeArray("String", ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"]); - unitMap = (_map = new $Map(), _key = "ns", _map[_key] = { k: _key, v: 1 }, _key = "us", _map[_key] = { k: _key, v: 1000 }, _key = "\xC2\xB5s", _map[_key] = { k: _key, v: 1000 }, _key = "\xCE\xBCs", _map[_key] = { k: _key, v: 1000 }, _key = "ms", _map[_key] = { k: _key, v: 1e+06 }, _key = "s", _map[_key] = { k: _key, v: 1e+09 }, _key = "m", _map[_key] = { k: _key, v: 6e+10 }, _key = "h", _map[_key] = { k: _key, v: 3.6e+12 }, _map); - daysBefore = $toNativeArray("Int32", [0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334, 365]); - utcLoc = new Location.Ptr("UTC", ($sliceType(zone)).nil, ($sliceType(zoneTrans)).nil, new $Int64(0, 0), new $Int64(0, 0), ($ptrType(zone)).nil); - $pkg.UTC = utcLoc; - $pkg.Local = localLoc; - _tuple = syscall.Getenv("ZONEINFO"); zoneinfo = _tuple[0]; - badData = errors.New("malformed time zone information"); - zoneDirs = new ($sliceType($String))(["/usr/share/zoneinfo/", "/usr/share/lib/zoneinfo/", "/usr/lib/locale/TZ/", runtime.GOROOT() + "/lib/time/zoneinfo.zip"]); + IndexRune = $pkg.IndexRune = function(s, r) { + var b, i, _ref, _i, _rune, i$1, c; + if (r < 128) { + b = (r << 24 >>> 24); + i = 0; + while (i < s.length) { + if (s.charCodeAt(i) === b) { + return i; + } + i = i + (1) >> 0; + } + } else { + _ref = s; + _i = 0; + while (_i < _ref.length) { + _rune = $decodeRune(_ref, _i); + i$1 = _i; + c = _rune[0]; + if (c === r) { + return i$1; + } + _i += _rune[1]; + } + } + return -1; }; - return $pkg; -})(); -$packages["os"] = (function() { - var $pkg = {}, js = $packages["github.com/gopherjs/gopherjs/js"], io = $packages["io"], syscall = $packages["syscall"], time = $packages["time"], errors = $packages["errors"], runtime = $packages["runtime"], atomic = $packages["sync/atomic"], sync = $packages["sync"], PathError, SyscallError, LinkError, File, file, dirInfo, FileInfo, FileMode, fileStat, lstat, getwdCache, useSyscallwd, supportsCloseOnExec, init, Getenv, NewSyscallError, IsNotExist, isNotExist, Open, sigpipe, Readlink, syscallMode, NewFile, epipecheck, OpenFile, Stat, Lstat, basename, Getwd, init$1, useSyscallwdDarwin, IsPathSeparator, Exit, sameFile, fileInfoFromStat, timespecToTime, init$2, SameFile; - PathError = $pkg.PathError = $newType(0, "Struct", "os.PathError", "PathError", "os", function(Op_, Path_, Err_) { - this.$val = this; - this.Op = Op_ !== undefined ? Op_ : ""; - this.Path = Path_ !== undefined ? Path_ : ""; - this.Err = Err_ !== undefined ? Err_ : $ifaceNil; - }); - SyscallError = $pkg.SyscallError = $newType(0, "Struct", "os.SyscallError", "SyscallError", "os", function(Syscall_, Err_) { - this.$val = this; - this.Syscall = Syscall_ !== undefined ? Syscall_ : ""; - this.Err = Err_ !== undefined ? Err_ : $ifaceNil; - }); - LinkError = $pkg.LinkError = $newType(0, "Struct", "os.LinkError", "LinkError", "os", function(Op_, Old_, New_, Err_) { - this.$val = this; - this.Op = Op_ !== undefined ? Op_ : ""; - this.Old = Old_ !== undefined ? Old_ : ""; - this.New = New_ !== undefined ? New_ : ""; - this.Err = Err_ !== undefined ? Err_ : $ifaceNil; - }); - File = $pkg.File = $newType(0, "Struct", "os.File", "File", "os", function(file_) { - this.$val = this; - this.file = file_ !== undefined ? file_ : ($ptrType(file)).nil; - }); - file = $pkg.file = $newType(0, "Struct", "os.file", "file", "os", function(fd_, name_, dirinfo_, nepipe_) { - this.$val = this; - this.fd = fd_ !== undefined ? fd_ : 0; - this.name = name_ !== undefined ? name_ : ""; - this.dirinfo = dirinfo_ !== undefined ? dirinfo_ : ($ptrType(dirInfo)).nil; - this.nepipe = nepipe_ !== undefined ? nepipe_ : 0; - }); - dirInfo = $pkg.dirInfo = $newType(0, "Struct", "os.dirInfo", "dirInfo", "os", function(buf_, nbuf_, bufp_) { - this.$val = this; - this.buf = buf_ !== undefined ? buf_ : ($sliceType($Uint8)).nil; - this.nbuf = nbuf_ !== undefined ? nbuf_ : 0; - this.bufp = bufp_ !== undefined ? bufp_ : 0; - }); - FileInfo = $pkg.FileInfo = $newType(8, "Interface", "os.FileInfo", "FileInfo", "os", null); - FileMode = $pkg.FileMode = $newType(4, "Uint32", "os.FileMode", "FileMode", "os", null); - fileStat = $pkg.fileStat = $newType(0, "Struct", "os.fileStat", "fileStat", "os", function(name_, size_, mode_, modTime_, sys_) { - this.$val = this; - this.name = name_ !== undefined ? name_ : ""; - this.size = size_ !== undefined ? size_ : new $Int64(0, 0); - this.mode = mode_ !== undefined ? mode_ : 0; - this.modTime = modTime_ !== undefined ? modTime_ : new time.Time.Ptr(); - this.sys = sys_ !== undefined ? sys_ : $ifaceNil; - }); - init = function() { - var process, args, i; - process = $global.process; - if (process === undefined) { - $pkg.Args = new ($sliceType($String))(["browser"]); - return; + IndexAny = $pkg.IndexAny = function(s, chars) { + var _ref, _i, _rune, i, c, _ref$1, _i$1, _rune$1, m; + if (chars.length > 0) { + _ref = s; + _i = 0; + while (_i < _ref.length) { + _rune = $decodeRune(_ref, _i); + i = _i; + c = _rune[0]; + _ref$1 = chars; + _i$1 = 0; + while (_i$1 < _ref$1.length) { + _rune$1 = $decodeRune(_ref$1, _i$1); + m = _rune$1[0]; + if (c === m) { + return i; + } + _i$1 += _rune$1[1]; + } + _i += _rune[1]; + } } - args = process.argv; - $pkg.Args = ($sliceType($String)).make(($parseInt(args.length) - 1 >> 0)); + return -1; + }; + genSplit = function(s, sep, sepSave, n) { + var c, start, a, na, i; + if (n === 0) { + return ($sliceType($String)).nil; + } + if (sep === "") { + return explode(s, n); + } + if (n < 0) { + n = Count(s, sep) + 1 >> 0; + } + c = sep.charCodeAt(0); + start = 0; + a = ($sliceType($String)).make(n); + na = 0; i = 0; - while (i < ($parseInt(args.length) - 1 >> 0)) { - (i < 0 || i >= $pkg.Args.$length) ? $throwRuntimeError("index out of range") : $pkg.Args.$array[$pkg.Args.$offset + i] = $internalize(args[(i + 1 >> 0)], $String); + while ((i + sep.length >> 0) <= s.length && (na + 1 >> 0) < n) { + if ((s.charCodeAt(i) === c) && ((sep.length === 1) || s.substring(i, (i + sep.length >> 0)) === sep)) { + (na < 0 || na >= a.$length) ? $throwRuntimeError("index out of range") : a.$array[a.$offset + na] = s.substring(start, (i + sepSave >> 0)); + na = na + (1) >> 0; + start = i + sep.length >> 0; + i = i + ((sep.length - 1 >> 0)) >> 0; + } i = i + (1) >> 0; } + (na < 0 || na >= a.$length) ? $throwRuntimeError("index out of range") : a.$array[a.$offset + na] = s.substring(start); + return $subslice(a, 0, (na + 1 >> 0)); }; - File.Ptr.prototype.readdirnames = function(n) { - var names = ($sliceType($String)).nil, err = $ifaceNil, f, d, size, errno, _tuple, _tmp, _tmp$1, _tmp$2, _tmp$3, nb, nc, _tuple$1, _tmp$4, _tmp$5, _tmp$6, _tmp$7; - f = this; - if (f.file.dirinfo === ($ptrType(dirInfo)).nil) { - f.file.dirinfo = new dirInfo.Ptr(); - f.file.dirinfo.buf = ($sliceType($Uint8)).make(4096); - } - d = f.file.dirinfo; - size = n; - if (size <= 0) { - size = 100; - n = -1; + Split = $pkg.Split = function(s, sep) { + return genSplit(s, sep, 0, -1); + }; + Fields = $pkg.Fields = function(s) { + return FieldsFunc(s, unicode.IsSpace); + }; + FieldsFunc = $pkg.FieldsFunc = function(s, f) { + var n, inField, _ref, _i, _rune, rune, wasInField, a, na, fieldStart, _ref$1, _i$1, _rune$1, i, rune$1; + n = 0; + inField = false; + _ref = s; + _i = 0; + while (_i < _ref.length) { + _rune = $decodeRune(_ref, _i); + rune = _rune[0]; + wasInField = inField; + inField = !f(rune); + if (inField && !wasInField) { + n = n + (1) >> 0; + } + _i += _rune[1]; } - names = ($sliceType($String)).make(0, size); - while (!((n === 0))) { - if (d.bufp >= d.nbuf) { - d.bufp = 0; - errno = $ifaceNil; - _tuple = syscall.ReadDirent(f.file.fd, d.buf); d.nbuf = _tuple[0]; errno = _tuple[1]; - if (!($interfaceIsEqual(errno, $ifaceNil))) { - _tmp = names; _tmp$1 = NewSyscallError("readdirent", errno); names = _tmp; err = _tmp$1; - return [names, err]; - } - if (d.nbuf <= 0) { - break; + a = ($sliceType($String)).make(n); + na = 0; + fieldStart = -1; + _ref$1 = s; + _i$1 = 0; + while (_i$1 < _ref$1.length) { + _rune$1 = $decodeRune(_ref$1, _i$1); + i = _i$1; + rune$1 = _rune$1[0]; + if (f(rune$1)) { + if (fieldStart >= 0) { + (na < 0 || na >= a.$length) ? $throwRuntimeError("index out of range") : a.$array[a.$offset + na] = s.substring(fieldStart, i); + na = na + (1) >> 0; + fieldStart = -1; } + } else if (fieldStart === -1) { + fieldStart = i; } - _tmp$2 = 0; _tmp$3 = 0; nb = _tmp$2; nc = _tmp$3; - _tuple$1 = syscall.ParseDirent($subslice(d.buf, d.bufp, d.nbuf), n, names); nb = _tuple$1[0]; nc = _tuple$1[1]; names = _tuple$1[2]; - d.bufp = d.bufp + (nb) >> 0; - n = n - (nc) >> 0; + _i$1 += _rune$1[1]; } - if (n >= 0 && (names.$length === 0)) { - _tmp$4 = names; _tmp$5 = io.EOF; names = _tmp$4; err = _tmp$5; - return [names, err]; + if (fieldStart >= 0) { + (na < 0 || na >= a.$length) ? $throwRuntimeError("index out of range") : a.$array[a.$offset + na] = s.substring(fieldStart); } - _tmp$6 = names; _tmp$7 = $ifaceNil; names = _tmp$6; err = _tmp$7; - return [names, err]; + return a; }; - File.prototype.readdirnames = function(n) { return this.$val.readdirnames(n); }; - File.Ptr.prototype.Readdir = function(n) { - var fi = ($sliceType(FileInfo)).nil, err = $ifaceNil, f, _tmp, _tmp$1, _tuple; - f = this; - if (f === ($ptrType(File)).nil) { - _tmp = ($sliceType(FileInfo)).nil; _tmp$1 = $pkg.ErrInvalid; fi = _tmp; err = _tmp$1; - return [fi, err]; + Join = $pkg.Join = function(a, sep) { + var x, x$1, n, i, b, bp, _ref, _i, s; + if (a.$length === 0) { + return ""; } - _tuple = f.readdir(n); fi = _tuple[0]; err = _tuple[1]; - return [fi, err]; - }; - File.prototype.Readdir = function(n) { return this.$val.Readdir(n); }; - File.Ptr.prototype.Readdirnames = function(n) { - var names = ($sliceType($String)).nil, err = $ifaceNil, f, _tmp, _tmp$1, _tuple; - f = this; - if (f === ($ptrType(File)).nil) { - _tmp = ($sliceType($String)).nil; _tmp$1 = $pkg.ErrInvalid; names = _tmp; err = _tmp$1; - return [names, err]; + if (a.$length === 1) { + return ((0 < 0 || 0 >= a.$length) ? $throwRuntimeError("index out of range") : a.$array[a.$offset + 0]); } - _tuple = f.readdirnames(n); names = _tuple[0]; err = _tuple[1]; - return [names, err]; - }; - File.prototype.Readdirnames = function(n) { return this.$val.Readdirnames(n); }; - Getenv = $pkg.Getenv = function(key) { - var _tuple, v; - _tuple = syscall.Getenv(key); v = _tuple[0]; - return v; + n = (x = sep.length, x$1 = (a.$length - 1 >> 0), (((x >>> 16 << 16) * x$1 >> 0) + (x << 16 >>> 16) * x$1) >> 0); + i = 0; + while (i < a.$length) { + n = n + (((i < 0 || i >= a.$length) ? $throwRuntimeError("index out of range") : a.$array[a.$offset + i]).length) >> 0; + i = i + (1) >> 0; + } + b = ($sliceType($Uint8)).make(n); + bp = $copyString(b, ((0 < 0 || 0 >= a.$length) ? $throwRuntimeError("index out of range") : a.$array[a.$offset + 0])); + _ref = $subslice(a, 1); + _i = 0; + while (_i < _ref.$length) { + s = ((_i < 0 || _i >= _ref.$length) ? $throwRuntimeError("index out of range") : _ref.$array[_ref.$offset + _i]); + bp = bp + ($copyString($subslice(b, bp), sep)) >> 0; + bp = bp + ($copyString($subslice(b, bp), s)) >> 0; + _i++; + } + return $bytesToString(b); }; - PathError.Ptr.prototype.Error = function() { - var e; - e = this; - return e.Op + " " + e.Path + ": " + e.Err.Error(); + HasPrefix = $pkg.HasPrefix = function(s, prefix) { + return s.length >= prefix.length && s.substring(0, prefix.length) === prefix; }; - PathError.prototype.Error = function() { return this.$val.Error(); }; - SyscallError.Ptr.prototype.Error = function() { - var e; - e = this; - return e.Syscall + ": " + e.Err.Error(); + HasSuffix = $pkg.HasSuffix = function(s, suffix) { + return s.length >= suffix.length && s.substring((s.length - suffix.length >> 0)) === suffix; }; - SyscallError.prototype.Error = function() { return this.$val.Error(); }; - NewSyscallError = $pkg.NewSyscallError = function(syscall$1, err) { - if ($interfaceIsEqual(err, $ifaceNil)) { - return $ifaceNil; + Map = $pkg.Map = function(mapping, s) { + var maxbytes, nbytes, b, _ref, _i, _rune, i, c, r, wid, nb; + maxbytes = s.length; + nbytes = 0; + b = ($sliceType($Uint8)).nil; + _ref = s; + _i = 0; + while (_i < _ref.length) { + _rune = $decodeRune(_ref, _i); + i = _i; + c = _rune[0]; + r = mapping(c); + if (b === ($sliceType($Uint8)).nil) { + if (r === c) { + _i += _rune[1]; + continue; + } + b = ($sliceType($Uint8)).make(maxbytes); + nbytes = $copyString(b, s.substring(0, i)); + } + if (r >= 0) { + wid = 1; + if (r >= 128) { + wid = utf8.RuneLen(r); + } + if ((nbytes + wid >> 0) > maxbytes) { + maxbytes = ((((maxbytes >>> 16 << 16) * 2 >> 0) + (maxbytes << 16 >>> 16) * 2) >> 0) + 4 >> 0; + nb = ($sliceType($Uint8)).make(maxbytes); + $copySlice(nb, $subslice(b, 0, nbytes)); + b = nb; + } + nbytes = nbytes + (utf8.EncodeRune($subslice(b, nbytes, maxbytes), r)) >> 0; + } + _i += _rune[1]; } - return new SyscallError.Ptr(syscall$1, err); - }; - IsNotExist = $pkg.IsNotExist = function(err) { - return isNotExist(err); + if (b === ($sliceType($Uint8)).nil) { + return s; + } + return $bytesToString($subslice(b, 0, nbytes)); }; - isNotExist = function(err) { - var pe, _ref; - _ref = err; - if (_ref === $ifaceNil) { - pe = _ref; - return false; - } else if ($assertType(_ref, ($ptrType(PathError)), true)[1]) { - pe = _ref.$val; - err = pe.Err; - } else if ($assertType(_ref, ($ptrType(LinkError)), true)[1]) { - pe = _ref.$val; - err = pe.Err; + Repeat = $pkg.Repeat = function(s, count) { + var x, b, bp, i; + b = ($sliceType($Uint8)).make((x = s.length, (((x >>> 16 << 16) * count >> 0) + (x << 16 >>> 16) * count) >> 0)); + bp = 0; + i = 0; + while (i < count) { + bp = bp + ($copyString($subslice(b, bp), s)) >> 0; + i = i + (1) >> 0; } - return $interfaceIsEqual(err, new syscall.Errno(2)) || $interfaceIsEqual(err, $pkg.ErrNotExist); + return $bytesToString(b); }; - File.Ptr.prototype.Name = function() { - var f; - f = this; - return f.file.name; + ToUpper = $pkg.ToUpper = function(s) { + return Map(unicode.ToUpper, s); }; - File.prototype.Name = function() { return this.$val.Name(); }; - LinkError.Ptr.prototype.Error = function() { - var e; - e = this; - return e.Op + " " + e.Old + " " + e.New + ": " + e.Err.Error(); + ToLower = $pkg.ToLower = function(s) { + return Map(unicode.ToLower, s); }; - LinkError.prototype.Error = function() { return this.$val.Error(); }; - File.Ptr.prototype.Read = function(b) { - var n = 0, err = $ifaceNil, f, _tmp, _tmp$1, _tuple, e, _tmp$2, _tmp$3, _tmp$4, _tmp$5; - f = this; - if (f === ($ptrType(File)).nil) { - _tmp = 0; _tmp$1 = $pkg.ErrInvalid; n = _tmp; err = _tmp$1; - return [n, err]; - } - _tuple = f.read(b); n = _tuple[0]; e = _tuple[1]; - if (n < 0) { - n = 0; - } - if ((n === 0) && b.$length > 0 && $interfaceIsEqual(e, $ifaceNil)) { - _tmp$2 = 0; _tmp$3 = io.EOF; n = _tmp$2; err = _tmp$3; - return [n, err]; - } - if (!($interfaceIsEqual(e, $ifaceNil))) { - err = new PathError.Ptr("read", f.file.name, e); + TrimLeftFunc = $pkg.TrimLeftFunc = function(s, f) { + var i; + i = indexFunc(s, f, false); + if (i === -1) { + return ""; } - _tmp$4 = n; _tmp$5 = err; n = _tmp$4; err = _tmp$5; - return [n, err]; + return s.substring(i); }; - File.prototype.Read = function(b) { return this.$val.Read(b); }; - File.Ptr.prototype.ReadAt = function(b, off) { - var n = 0, err = $ifaceNil, f, _tmp, _tmp$1, _tuple, m, e, _tmp$2, _tmp$3, x; - f = this; - if (f === ($ptrType(File)).nil) { - _tmp = 0; _tmp$1 = $pkg.ErrInvalid; n = _tmp; err = _tmp$1; - return [n, err]; + TrimRightFunc = $pkg.TrimRightFunc = function(s, f) { + var i, _tuple, wid; + i = lastIndexFunc(s, f, false); + if (i >= 0 && s.charCodeAt(i) >= 128) { + _tuple = utf8.DecodeRuneInString(s.substring(i)); wid = _tuple[1]; + i = i + (wid) >> 0; + } else { + i = i + (1) >> 0; } - while (b.$length > 0) { - _tuple = f.pread(b, off); m = _tuple[0]; e = _tuple[1]; - if ((m === 0) && $interfaceIsEqual(e, $ifaceNil)) { - _tmp$2 = n; _tmp$3 = io.EOF; n = _tmp$2; err = _tmp$3; - return [n, err]; + return s.substring(0, i); + }; + TrimFunc = $pkg.TrimFunc = function(s, f) { + return TrimRightFunc(TrimLeftFunc(s, f), f); + }; + IndexFunc = $pkg.IndexFunc = function(s, f) { + return indexFunc(s, f, true); + }; + indexFunc = function(s, f, truth) { + var start, wid, r, _tuple; + start = 0; + while (start < s.length) { + wid = 1; + r = (s.charCodeAt(start) >> 0); + if (r >= 128) { + _tuple = utf8.DecodeRuneInString(s.substring(start)); r = _tuple[0]; wid = _tuple[1]; } - if (!($interfaceIsEqual(e, $ifaceNil))) { - err = new PathError.Ptr("read", f.file.name, e); - break; + if (f(r) === truth) { + return start; } - n = n + (m) >> 0; - b = $subslice(b, m); - off = (x = new $Int64(0, m), new $Int64(off.$high + x.$high, off.$low + x.$low)); - } - return [n, err]; - }; - File.prototype.ReadAt = function(b, off) { return this.$val.ReadAt(b, off); }; - File.Ptr.prototype.Write = function(b) { - var n = 0, err = $ifaceNil, f, _tmp, _tmp$1, _tuple, e, _tmp$2, _tmp$3; - f = this; - if (f === ($ptrType(File)).nil) { - _tmp = 0; _tmp$1 = $pkg.ErrInvalid; n = _tmp; err = _tmp$1; - return [n, err]; - } - _tuple = f.write(b); n = _tuple[0]; e = _tuple[1]; - if (n < 0) { - n = 0; - } - if (!((n === b.$length))) { - err = io.ErrShortWrite; - } - epipecheck(f, e); - if (!($interfaceIsEqual(e, $ifaceNil))) { - err = new PathError.Ptr("write", f.file.name, e); + start = start + (wid) >> 0; } - _tmp$2 = n; _tmp$3 = err; n = _tmp$2; err = _tmp$3; - return [n, err]; + return -1; }; - File.prototype.Write = function(b) { return this.$val.Write(b); }; - File.Ptr.prototype.WriteAt = function(b, off) { - var n = 0, err = $ifaceNil, f, _tmp, _tmp$1, _tuple, m, e, x; - f = this; - if (f === ($ptrType(File)).nil) { - _tmp = 0; _tmp$1 = $pkg.ErrInvalid; n = _tmp; err = _tmp$1; - return [n, err]; - } - while (b.$length > 0) { - _tuple = f.pwrite(b, off); m = _tuple[0]; e = _tuple[1]; - if (!($interfaceIsEqual(e, $ifaceNil))) { - err = new PathError.Ptr("write", f.file.name, e); - break; + lastIndexFunc = function(s, f, truth) { + var i, _tuple, r, size; + i = s.length; + while (i > 0) { + _tuple = utf8.DecodeLastRuneInString(s.substring(0, i)); r = _tuple[0]; size = _tuple[1]; + i = i - (size) >> 0; + if (f(r) === truth) { + return i; } - n = n + (m) >> 0; - b = $subslice(b, m); - off = (x = new $Int64(0, m), new $Int64(off.$high + x.$high, off.$low + x.$low)); } - return [n, err]; + return -1; }; - File.prototype.WriteAt = function(b, off) { return this.$val.WriteAt(b, off); }; - File.Ptr.prototype.Seek = function(offset, whence) { - var ret = new $Int64(0, 0), err = $ifaceNil, f, _tmp, _tmp$1, _tuple, r, e, _tmp$2, _tmp$3, _tmp$4, _tmp$5; - f = this; - if (f === ($ptrType(File)).nil) { - _tmp = new $Int64(0, 0); _tmp$1 = $pkg.ErrInvalid; ret = _tmp; err = _tmp$1; - return [ret, err]; + TrimSpace = $pkg.TrimSpace = function(s) { + return TrimFunc(s, unicode.IsSpace); + }; + TrimSuffix = $pkg.TrimSuffix = function(s, suffix) { + if (HasSuffix(s, suffix)) { + return s.substring(0, (s.length - suffix.length >> 0)); } - _tuple = f.seek(offset, whence); r = _tuple[0]; e = _tuple[1]; - if ($interfaceIsEqual(e, $ifaceNil) && !(f.file.dirinfo === ($ptrType(dirInfo)).nil) && !((r.$high === 0 && r.$low === 0))) { - e = new syscall.Errno(21); + return s; + }; + Replace = $pkg.Replace = function(s, old, new$1, n) { + var m, x, t, w, start, i, j, _tuple, wid; + if (old === new$1 || (n === 0)) { + return s; } - if (!($interfaceIsEqual(e, $ifaceNil))) { - _tmp$2 = new $Int64(0, 0); _tmp$3 = new PathError.Ptr("seek", f.file.name, e); ret = _tmp$2; err = _tmp$3; - return [ret, err]; - } - _tmp$4 = r; _tmp$5 = $ifaceNil; ret = _tmp$4; err = _tmp$5; - return [ret, err]; - }; - File.prototype.Seek = function(offset, whence) { return this.$val.Seek(offset, whence); }; - File.Ptr.prototype.WriteString = function(s) { - var ret = 0, err = $ifaceNil, f, _tmp, _tmp$1, _tuple; - f = this; - if (f === ($ptrType(File)).nil) { - _tmp = 0; _tmp$1 = $pkg.ErrInvalid; ret = _tmp; err = _tmp$1; - return [ret, err]; - } - _tuple = f.Write(new ($sliceType($Uint8))($stringToBytes(s))); ret = _tuple[0]; err = _tuple[1]; - return [ret, err]; - }; - File.prototype.WriteString = function(s) { return this.$val.WriteString(s); }; - File.Ptr.prototype.Chdir = function() { - var f, e; - f = this; - if (f === ($ptrType(File)).nil) { - return $pkg.ErrInvalid; + m = Count(s, old); + if (m === 0) { + return s; + } else if (n < 0 || m < n) { + n = m; } - e = syscall.Fchdir(f.file.fd); - if (!($interfaceIsEqual(e, $ifaceNil))) { - return new PathError.Ptr("chdir", f.file.name, e); + t = ($sliceType($Uint8)).make((s.length + (x = (new$1.length - old.length >> 0), (((n >>> 16 << 16) * x >> 0) + (n << 16 >>> 16) * x) >> 0) >> 0)); + w = 0; + start = 0; + i = 0; + while (i < n) { + j = start; + if (old.length === 0) { + if (i > 0) { + _tuple = utf8.DecodeRuneInString(s.substring(start)); wid = _tuple[1]; + j = j + (wid) >> 0; + } + } else { + j = j + (Index(s.substring(start), old)) >> 0; + } + w = w + ($copyString($subslice(t, w), s.substring(start, j))) >> 0; + w = w + ($copyString($subslice(t, w), new$1)) >> 0; + start = j + old.length >> 0; + i = i + (1) >> 0; } - return $ifaceNil; + w = w + ($copyString($subslice(t, w), s.substring(start))) >> 0; + return $bytesToString($subslice(t, 0, w)); }; - File.prototype.Chdir = function() { return this.$val.Chdir(); }; - Open = $pkg.Open = function(name) { - var file$1 = ($ptrType(File)).nil, err = $ifaceNil, _tuple; - _tuple = OpenFile(name, 0, 0); file$1 = _tuple[0]; err = _tuple[1]; - return [file$1, err]; + $pkg.$init = function() { + ($ptrType(Reader)).methods = [["Len", "Len", "", $funcType([], [$Int], false), -1], ["Read", "Read", "", $funcType([($sliceType($Uint8))], [$Int, $error], false), -1], ["ReadAt", "ReadAt", "", $funcType([($sliceType($Uint8)), $Int64], [$Int, $error], false), -1], ["ReadByte", "ReadByte", "", $funcType([], [$Uint8, $error], false), -1], ["ReadRune", "ReadRune", "", $funcType([], [$Int32, $Int, $error], false), -1], ["Seek", "Seek", "", $funcType([$Int64, $Int], [$Int64, $error], false), -1], ["UnreadByte", "UnreadByte", "", $funcType([], [$error], false), -1], ["UnreadRune", "UnreadRune", "", $funcType([], [$error], false), -1], ["WriteTo", "WriteTo", "", $funcType([io.Writer], [$Int64, $error], false), -1]]; + Reader.init([["s", "s", "strings", $String, ""], ["i", "i", "strings", $Int64, ""], ["prevRune", "prevRune", "strings", $Int, ""]]); }; - sigpipe = function() { - $panic("Native function not implemented: os.sigpipe"); + return $pkg; +})(); +$packages["syscall"] = (function() { + var $pkg = {}, bytes = $packages["bytes"], js = $packages["github.com/gopherjs/gopherjs/js"], sync = $packages["sync"], runtime = $packages["runtime"], mmapper, Errno, Timespec, Stat_t, Dirent, warningPrinted, lineBuffer, syscallModule, alreadyTriedToLoad, minusOne, envOnce, envLock, env, envs, mapper, errors, printWarning, printToConsole, init, syscall, Syscall, Syscall6, BytePtrFromString, copyenv, Getenv, itoa, Open, Getwd, clen, ReadDirent, ParseDirent, Read, Write, open, Getcwd, Close, Exit, Fchdir, Fchmod, Fsync, Getdents, read, Readlink, write, munmap, Fchown, Fstat, Ftruncate, Lstat, Pread, Pwrite, Seek, Stat, mmap; + mmapper = $pkg.mmapper = $newType(0, "Struct", "syscall.mmapper", "mmapper", "syscall", function(Mutex_, active_, mmap_, munmap_) { + this.$val = this; + this.Mutex = Mutex_ !== undefined ? Mutex_ : new sync.Mutex.Ptr(); + this.active = active_ !== undefined ? active_ : false; + this.mmap = mmap_ !== undefined ? mmap_ : $throwNilPointerError; + this.munmap = munmap_ !== undefined ? munmap_ : $throwNilPointerError; + }); + Errno = $pkg.Errno = $newType(4, "Uintptr", "syscall.Errno", "Errno", "syscall", null); + Timespec = $pkg.Timespec = $newType(0, "Struct", "syscall.Timespec", "Timespec", "syscall", function(Sec_, Nsec_) { + this.$val = this; + this.Sec = Sec_ !== undefined ? Sec_ : new $Int64(0, 0); + this.Nsec = Nsec_ !== undefined ? Nsec_ : new $Int64(0, 0); + }); + Stat_t = $pkg.Stat_t = $newType(0, "Struct", "syscall.Stat_t", "Stat_t", "syscall", function(Dev_, Ino_, Nlink_, Mode_, Uid_, Gid_, X__pad0_, Rdev_, Size_, Blksize_, Blocks_, Atim_, Mtim_, Ctim_, X__unused_) { + this.$val = this; + this.Dev = Dev_ !== undefined ? Dev_ : new $Uint64(0, 0); + this.Ino = Ino_ !== undefined ? Ino_ : new $Uint64(0, 0); + this.Nlink = Nlink_ !== undefined ? Nlink_ : new $Uint64(0, 0); + this.Mode = Mode_ !== undefined ? Mode_ : 0; + this.Uid = Uid_ !== undefined ? Uid_ : 0; + this.Gid = Gid_ !== undefined ? Gid_ : 0; + this.X__pad0 = X__pad0_ !== undefined ? X__pad0_ : 0; + this.Rdev = Rdev_ !== undefined ? Rdev_ : new $Uint64(0, 0); + this.Size = Size_ !== undefined ? Size_ : new $Int64(0, 0); + this.Blksize = Blksize_ !== undefined ? Blksize_ : new $Int64(0, 0); + this.Blocks = Blocks_ !== undefined ? Blocks_ : new $Int64(0, 0); + this.Atim = Atim_ !== undefined ? Atim_ : new Timespec.Ptr(); + this.Mtim = Mtim_ !== undefined ? Mtim_ : new Timespec.Ptr(); + this.Ctim = Ctim_ !== undefined ? Ctim_ : new Timespec.Ptr(); + this.X__unused = X__unused_ !== undefined ? X__unused_ : ($arrayType($Int64, 3)).zero(); + }); + Dirent = $pkg.Dirent = $newType(0, "Struct", "syscall.Dirent", "Dirent", "syscall", function(Ino_, Off_, Reclen_, Type_, Name_, Pad_cgo_0_) { + this.$val = this; + this.Ino = Ino_ !== undefined ? Ino_ : new $Uint64(0, 0); + this.Off = Off_ !== undefined ? Off_ : new $Int64(0, 0); + this.Reclen = Reclen_ !== undefined ? Reclen_ : 0; + this.Type = Type_ !== undefined ? Type_ : 0; + this.Name = Name_ !== undefined ? Name_ : ($arrayType($Int8, 256)).zero(); + this.Pad_cgo_0 = Pad_cgo_0_ !== undefined ? Pad_cgo_0_ : ($arrayType($Uint8, 5)).zero(); + }); + printWarning = function() { + if (!warningPrinted) { + console.log("warning: system calls not available, see https://github.com/gopherjs/gopherjs/blob/master/doc/syscalls.md"); + } + warningPrinted = true; }; - Readlink = $pkg.Readlink = function(name) { - var len, b, _tuple, n, e, x; - len = 128; + printToConsole = function(b) { + var goPrintToConsole, i; + goPrintToConsole = $global.goPrintToConsole; + if (!(goPrintToConsole === undefined)) { + goPrintToConsole(b); + return; + } + lineBuffer = $appendSlice(lineBuffer, b); while (true) { - b = ($sliceType($Uint8)).make(len); - _tuple = syscall.Readlink(name, b); n = _tuple[0]; e = _tuple[1]; - if (!($interfaceIsEqual(e, $ifaceNil))) { - return ["", new PathError.Ptr("readlink", name, e)]; - } - if (n < len) { - return [$bytesToString($subslice(b, 0, n)), $ifaceNil]; + i = bytes.IndexByte(lineBuffer, 10); + if (i === -1) { + break; } - len = (x = 2, (((len >>> 16 << 16) * x >> 0) + (len << 16 >>> 16) * x) >> 0); + $global.console.log($externalize($bytesToString($subslice(lineBuffer, 0, i)), $String)); + lineBuffer = $subslice(lineBuffer, (i + 1 >> 0)); } }; - syscallMode = function(i) { - var o = 0; - o = (o | (((new FileMode(i)).Perm() >>> 0))) >>> 0; - if (!((((i & 8388608) >>> 0) === 0))) { - o = (o | (2048)) >>> 0; - } - if (!((((i & 4194304) >>> 0) === 0))) { - o = (o | (1024)) >>> 0; - } - if (!((((i & 1048576) >>> 0) === 0))) { - o = (o | (512)) >>> 0; + init = function() { + var process, jsEnv, envkeys, i, key; + process = $global.process; + if (!(process === undefined)) { + jsEnv = process.env; + envkeys = $global.Object.keys(jsEnv); + envs = ($sliceType($String)).make($parseInt(envkeys.length)); + i = 0; + while (i < $parseInt(envkeys.length)) { + key = $internalize(envkeys[i], $String); + (i < 0 || i >= envs.$length) ? $throwRuntimeError("index out of range") : envs.$array[envs.$offset + i] = key + "=" + $internalize(jsEnv[$externalize(key, $String)], $String); + i = i + (1) >> 0; + } } - return o; }; - File.Ptr.prototype.Chmod = function(mode) { - var f, e; - f = this; - if (f === ($ptrType(File)).nil) { - return $pkg.ErrInvalid; - } - e = syscall.Fchmod(f.file.fd, syscallMode(mode)); - if (!($interfaceIsEqual(e, $ifaceNil))) { - return new PathError.Ptr("chmod", f.file.name, e); + syscall = function(name) { + var $deferred = [], $err = null, require; + /* */ try { $deferFrames.push($deferred); + $deferred.push([(function() { + $recover(); + }), []]); + if (syscallModule === $ifaceNil) { + if (alreadyTriedToLoad) { + return $ifaceNil; + } + alreadyTriedToLoad = true; + require = $global.require; + if (require === undefined) { + $panic(new $String("")); + } + syscallModule = require($externalize("syscall", $String)); } - return $ifaceNil; + return syscallModule[$externalize(name, $String)]; + /* */ } catch(err) { $err = err; return $ifaceNil; } finally { $deferFrames.pop(); $callDeferred($deferred, $err); } }; - File.prototype.Chmod = function(mode) { return this.$val.Chmod(mode); }; - File.Ptr.prototype.Chown = function(uid, gid) { - var f, e; - f = this; - if (f === ($ptrType(File)).nil) { - return $pkg.ErrInvalid; + Syscall = $pkg.Syscall = function(trap, a1, a2, a3) { + var r1 = 0, r2 = 0, err = 0, f, r, _tmp, _tmp$1, _tmp$2, array, slice, _tmp$3, _tmp$4, _tmp$5, _tmp$6, _tmp$7, _tmp$8; + f = syscall("Syscall"); + if (!(f === $ifaceNil)) { + r = f(trap, a1, a2, a3); + _tmp = (($parseInt(r[0]) >> 0) >>> 0); _tmp$1 = (($parseInt(r[1]) >> 0) >>> 0); _tmp$2 = (($parseInt(r[2]) >> 0) >>> 0); r1 = _tmp; r2 = _tmp$1; err = _tmp$2; + return [r1, r2, err]; } - e = syscall.Fchown(f.file.fd, uid, gid); - if (!($interfaceIsEqual(e, $ifaceNil))) { - return new PathError.Ptr("chown", f.file.name, e); + if ((trap === 1) && ((a1 === 1) || (a1 === 2))) { + array = a2; + slice = ($sliceType($Uint8)).make($parseInt(array.length)); + slice.$array = array; + printToConsole(slice); + _tmp$3 = ($parseInt(array.length) >>> 0); _tmp$4 = 0; _tmp$5 = 0; r1 = _tmp$3; r2 = _tmp$4; err = _tmp$5; + return [r1, r2, err]; } - return $ifaceNil; + printWarning(); + _tmp$6 = (minusOne >>> 0); _tmp$7 = 0; _tmp$8 = 13; r1 = _tmp$6; r2 = _tmp$7; err = _tmp$8; + return [r1, r2, err]; }; - File.prototype.Chown = function(uid, gid) { return this.$val.Chown(uid, gid); }; - File.Ptr.prototype.Truncate = function(size) { - var f, e; - f = this; - if (f === ($ptrType(File)).nil) { - return $pkg.ErrInvalid; + Syscall6 = $pkg.Syscall6 = function(trap, a1, a2, a3, a4, a5, a6) { + var r1 = 0, r2 = 0, err = 0, f, r, _tmp, _tmp$1, _tmp$2, _tmp$3, _tmp$4, _tmp$5; + f = syscall("Syscall6"); + if (!(f === $ifaceNil)) { + r = f(trap, a1, a2, a3, a4, a5, a6); + _tmp = (($parseInt(r[0]) >> 0) >>> 0); _tmp$1 = (($parseInt(r[1]) >> 0) >>> 0); _tmp$2 = (($parseInt(r[2]) >> 0) >>> 0); r1 = _tmp; r2 = _tmp$1; err = _tmp$2; + return [r1, r2, err]; } - e = syscall.Ftruncate(f.file.fd, size); - if (!($interfaceIsEqual(e, $ifaceNil))) { - return new PathError.Ptr("truncate", f.file.name, e); + if (!((trap === 202))) { + printWarning(); } - return $ifaceNil; + _tmp$3 = (minusOne >>> 0); _tmp$4 = 0; _tmp$5 = 13; r1 = _tmp$3; r2 = _tmp$4; err = _tmp$5; + return [r1, r2, err]; }; - File.prototype.Truncate = function(size) { return this.$val.Truncate(size); }; - File.Ptr.prototype.Sync = function() { - var err = $ifaceNil, f, e; - f = this; - if (f === ($ptrType(File)).nil) { - err = $pkg.ErrInvalid; - return err; - } - e = syscall.Fsync(f.file.fd); - if (!($interfaceIsEqual(e, $ifaceNil))) { - err = NewSyscallError("fsync", e); - return err; + BytePtrFromString = $pkg.BytePtrFromString = function(s) { + var array, _ref, _i, i, b; + array = new ($global.Uint8Array)(s.length + 1 >> 0); + _ref = new ($sliceType($Uint8))($stringToBytes(s)); + _i = 0; + while (_i < _ref.$length) { + i = _i; + b = ((_i < 0 || _i >= _ref.$length) ? $throwRuntimeError("index out of range") : _ref.$array[_ref.$offset + _i]); + if (b === 0) { + return [($ptrType($Uint8)).nil, new Errno(22)]; + } + array[i] = b; + _i++; } - err = $ifaceNil; - return err; + array[s.length] = 0; + return [array, $ifaceNil]; }; - File.prototype.Sync = function() { return this.$val.Sync(); }; - File.Ptr.prototype.Fd = function() { - var f; - f = this; - if (f === ($ptrType(File)).nil) { - return 4294967295; + copyenv = function() { + var _ref, _i, i, s, j, key, _tuple, _entry, ok, _key; + env = new $Map(); + _ref = envs; + _i = 0; + while (_i < _ref.$length) { + i = _i; + s = ((_i < 0 || _i >= _ref.$length) ? $throwRuntimeError("index out of range") : _ref.$array[_ref.$offset + _i]); + j = 0; + while (j < s.length) { + if (s.charCodeAt(j) === 61) { + key = s.substring(0, j); + _tuple = (_entry = env[key], _entry !== undefined ? [_entry.v, true] : [0, false]); ok = _tuple[1]; + if (!ok) { + _key = key; (env || $throwRuntimeError("assignment to entry in nil map"))[_key] = { k: _key, v: i }; + } + break; + } + j = j + (1) >> 0; + } + _i++; } - return (f.file.fd >>> 0); }; - File.prototype.Fd = function() { return this.$val.Fd(); }; - NewFile = $pkg.NewFile = function(fd, name) { - var fdi, f; - fdi = (fd >> 0); - if (fdi < 0) { - return ($ptrType(File)).nil; + Getenv = $pkg.Getenv = function(key) { + var value = "", found = false, $deferred = [], $err = null, _tmp, _tmp$1, _tuple, _entry, i, ok, _tmp$2, _tmp$3, s, i$1, _tmp$4, _tmp$5, _tmp$6, _tmp$7; + /* */ try { $deferFrames.push($deferred); + envOnce.Do(copyenv); + if (key.length === 0) { + _tmp = ""; _tmp$1 = false; value = _tmp; found = _tmp$1; + return [value, found]; } - f = new File.Ptr(new file.Ptr(fdi, name, ($ptrType(dirInfo)).nil, 0)); - runtime.SetFinalizer(f.file, new ($funcType([($ptrType(file))], [$error], false))($methodExpr(($ptrType(file)).prototype.close))); - return f; - }; - epipecheck = function(file$1, e) { - if ($interfaceIsEqual(e, new syscall.Errno(32))) { - if (atomic.AddInt32(new ($ptrType($Int32))(function() { return this.$target.file.nepipe; }, function($v) { this.$target.file.nepipe = $v; }, file$1), 1) >= 10) { - sigpipe(); + envLock.RLock(); + $deferred.push([$methodVal(envLock, "RUnlock"), []]); + _tuple = (_entry = env[key], _entry !== undefined ? [_entry.v, true] : [0, false]); i = _tuple[0]; ok = _tuple[1]; + if (!ok) { + _tmp$2 = ""; _tmp$3 = false; value = _tmp$2; found = _tmp$3; + return [value, found]; + } + s = ((i < 0 || i >= envs.$length) ? $throwRuntimeError("index out of range") : envs.$array[envs.$offset + i]); + i$1 = 0; + while (i$1 < s.length) { + if (s.charCodeAt(i$1) === 61) { + _tmp$4 = s.substring((i$1 + 1 >> 0)); _tmp$5 = true; value = _tmp$4; found = _tmp$5; + return [value, found]; } - } else { - atomic.StoreInt32(new ($ptrType($Int32))(function() { return this.$target.file.nepipe; }, function($v) { this.$target.file.nepipe = $v; }, file$1), 0); + i$1 = i$1 + (1) >> 0; } + _tmp$6 = ""; _tmp$7 = false; value = _tmp$6; found = _tmp$7; + return [value, found]; + /* */ } catch(err) { $err = err; } finally { $deferFrames.pop(); $callDeferred($deferred, $err); return [value, found]; } }; - OpenFile = $pkg.OpenFile = function(name, flag, perm) { - var file$1 = ($ptrType(File)).nil, err = $ifaceNil, _tuple, r, e, _tmp, _tmp$1, _tmp$2, _tmp$3; - _tuple = syscall.Open(name, flag | 16777216, syscallMode(perm)); r = _tuple[0]; e = _tuple[1]; - if (!($interfaceIsEqual(e, $ifaceNil))) { - _tmp = ($ptrType(File)).nil; _tmp$1 = new PathError.Ptr("open", name, e); file$1 = _tmp; err = _tmp$1; - return [file$1, err]; + itoa = function(val) { + var buf, i, _r, _q; + if (val < 0) { + return "-" + itoa(-val); } - if (!supportsCloseOnExec) { - syscall.CloseOnExec(r); + buf = ($arrayType($Uint8, 32)).zero(); $copy(buf, ($arrayType($Uint8, 32)).zero(), ($arrayType($Uint8, 32))); + i = 31; + while (val >= 10) { + (i < 0 || i >= buf.length) ? $throwRuntimeError("index out of range") : buf[i] = (((_r = val % 10, _r === _r ? _r : $throwRuntimeError("integer divide by zero")) + 48 >> 0) << 24 >>> 24); + i = i - (1) >> 0; + val = (_q = val / (10), (_q === _q && _q !== 1/0 && _q !== -1/0) ? _q >> 0 : $throwRuntimeError("integer divide by zero")); } - _tmp$2 = NewFile((r >>> 0), name); _tmp$3 = $ifaceNil; file$1 = _tmp$2; err = _tmp$3; - return [file$1, err]; + (i < 0 || i >= buf.length) ? $throwRuntimeError("index out of range") : buf[i] = ((val + 48 >> 0) << 24 >>> 24); + return $bytesToString($subslice(new ($sliceType($Uint8))(buf), i)); }; - File.Ptr.prototype.Close = function() { - var f; - f = this; - if (f === ($ptrType(File)).nil) { - return $pkg.ErrInvalid; - } - return f.file.close(); + Timespec.Ptr.prototype.Unix = function() { + var sec = new $Int64(0, 0), nsec = new $Int64(0, 0), ts, _tmp, _tmp$1; + ts = this; + _tmp = ts.Sec; _tmp$1 = ts.Nsec; sec = _tmp; nsec = _tmp$1; + return [sec, nsec]; }; - File.prototype.Close = function() { return this.$val.Close(); }; - file.Ptr.prototype.close = function() { - var file$1, err, e; - file$1 = this; - if (file$1 === ($ptrType(file)).nil || file$1.fd < 0) { - return new syscall.Errno(22); - } - err = $ifaceNil; - e = syscall.Close(file$1.fd); - if (!($interfaceIsEqual(e, $ifaceNil))) { - err = new PathError.Ptr("close", file$1.name, e); - } - file$1.fd = -1; - runtime.SetFinalizer(file$1, $ifaceNil); - return err; + Timespec.prototype.Unix = function() { return this.$val.Unix(); }; + Timespec.Ptr.prototype.Nano = function() { + var ts, x, x$1; + ts = this; + return (x = $mul64(ts.Sec, new $Int64(0, 1000000000)), x$1 = ts.Nsec, new $Int64(x.$high + x$1.$high, x.$low + x$1.$low)); }; - file.prototype.close = function() { return this.$val.close(); }; - File.Ptr.prototype.Stat = function() { - var fi = $ifaceNil, err = $ifaceNil, f, _tmp, _tmp$1, stat, _tmp$2, _tmp$3, _tmp$4, _tmp$5; - f = this; - if (f === ($ptrType(File)).nil) { - _tmp = $ifaceNil; _tmp$1 = $pkg.ErrInvalid; fi = _tmp; err = _tmp$1; - return [fi, err]; - } - stat = new syscall.Stat_t.Ptr(); $copy(stat, new syscall.Stat_t.Ptr(), syscall.Stat_t); - err = syscall.Fstat(f.file.fd, stat); - if (!($interfaceIsEqual(err, $ifaceNil))) { - _tmp$2 = $ifaceNil; _tmp$3 = new PathError.Ptr("stat", f.file.name, err); fi = _tmp$2; err = _tmp$3; - return [fi, err]; - } - _tmp$4 = fileInfoFromStat(stat, f.file.name); _tmp$5 = $ifaceNil; fi = _tmp$4; err = _tmp$5; - return [fi, err]; + Timespec.prototype.Nano = function() { return this.$val.Nano(); }; + Open = $pkg.Open = function(path, mode, perm) { + var fd = 0, err = $ifaceNil, _tuple; + _tuple = open(path, mode | 0, perm); fd = _tuple[0]; err = _tuple[1]; + return [fd, err]; }; - File.prototype.Stat = function() { return this.$val.Stat(); }; - Stat = $pkg.Stat = function(name) { - var fi = $ifaceNil, err = $ifaceNil, stat, _tmp, _tmp$1, _tmp$2, _tmp$3; - stat = new syscall.Stat_t.Ptr(); $copy(stat, new syscall.Stat_t.Ptr(), syscall.Stat_t); - err = syscall.Stat(name, stat); + Getwd = $pkg.Getwd = function() { + var wd = "", err = $ifaceNil, buf, _tuple, n, _tmp, _tmp$1, x, _tmp$2, _tmp$3, _tmp$4, _tmp$5; + buf = ($arrayType($Uint8, 4096)).zero(); $copy(buf, ($arrayType($Uint8, 4096)).zero(), ($arrayType($Uint8, 4096))); + _tuple = Getcwd($subslice(new ($sliceType($Uint8))(buf), 0)); n = _tuple[0]; err = _tuple[1]; if (!($interfaceIsEqual(err, $ifaceNil))) { - _tmp = $ifaceNil; _tmp$1 = new PathError.Ptr("stat", name, err); fi = _tmp; err = _tmp$1; - return [fi, err]; + _tmp = ""; _tmp$1 = err; wd = _tmp; err = _tmp$1; + return [wd, err]; } - _tmp$2 = fileInfoFromStat(stat, name); _tmp$3 = $ifaceNil; fi = _tmp$2; err = _tmp$3; - return [fi, err]; - }; - Lstat = $pkg.Lstat = function(name) { - var fi = $ifaceNil, err = $ifaceNil, stat, _tmp, _tmp$1, _tmp$2, _tmp$3; - stat = new syscall.Stat_t.Ptr(); $copy(stat, new syscall.Stat_t.Ptr(), syscall.Stat_t); - err = syscall.Lstat(name, stat); - if (!($interfaceIsEqual(err, $ifaceNil))) { - _tmp = $ifaceNil; _tmp$1 = new PathError.Ptr("lstat", name, err); fi = _tmp; err = _tmp$1; - return [fi, err]; + if (n < 1 || n > 4096 || !(((x = n - 1 >> 0, ((x < 0 || x >= buf.length) ? $throwRuntimeError("index out of range") : buf[x])) === 0))) { + _tmp$2 = ""; _tmp$3 = new Errno(22); wd = _tmp$2; err = _tmp$3; + return [wd, err]; } - _tmp$2 = fileInfoFromStat(stat, name); _tmp$3 = $ifaceNil; fi = _tmp$2; err = _tmp$3; - return [fi, err]; + _tmp$4 = $bytesToString($subslice(new ($sliceType($Uint8))(buf), 0, (n - 1 >> 0))); _tmp$5 = $ifaceNil; wd = _tmp$4; err = _tmp$5; + return [wd, err]; }; - File.Ptr.prototype.readdir = function(n) { - var fi = ($sliceType(FileInfo)).nil, err = $ifaceNil, f, dirname, _tuple, names, _ref, _i, filename, _tuple$1, fip, lerr, _tmp, _tmp$1, _tmp$2, _tmp$3; - f = this; - dirname = f.file.name; - if (dirname === "") { - dirname = "."; - } - _tuple = f.Readdirnames(n); names = _tuple[0]; err = _tuple[1]; - fi = ($sliceType(FileInfo)).make(0, names.$length); - _ref = names; - _i = 0; - while (_i < _ref.$length) { - filename = ((_i < 0 || _i >= _ref.$length) ? $throwRuntimeError("index out of range") : _ref.$array[_ref.$offset + _i]); - _tuple$1 = lstat(dirname + "/" + filename); fip = _tuple$1[0]; lerr = _tuple$1[1]; - if (IsNotExist(lerr)) { - _i++; - continue; - } - if (!($interfaceIsEqual(lerr, $ifaceNil))) { - _tmp = fi; _tmp$1 = lerr; fi = _tmp; err = _tmp$1; - return [fi, err]; + clen = function(n) { + var i; + i = 0; + while (i < n.$length) { + if (((i < 0 || i >= n.$length) ? $throwRuntimeError("index out of range") : n.$array[n.$offset + i]) === 0) { + return i; } - fi = $append(fi, fip); - _i++; - } - _tmp$2 = fi; _tmp$3 = err; fi = _tmp$2; err = _tmp$3; - return [fi, err]; - }; - File.prototype.readdir = function(n) { return this.$val.readdir(n); }; - File.Ptr.prototype.read = function(b) { - var n = 0, err = $ifaceNil, f, _tuple; - f = this; - if (true && b.$length > 1073741824) { - b = $subslice(b, 0, 1073741824); + i = i + (1) >> 0; } - _tuple = syscall.Read(f.file.fd, b); n = _tuple[0]; err = _tuple[1]; - return [n, err]; + return n.$length; }; - File.prototype.read = function(b) { return this.$val.read(b); }; - File.Ptr.prototype.pread = function(b, off) { - var n = 0, err = $ifaceNil, f, _tuple; - f = this; - if (true && b.$length > 1073741824) { - b = $subslice(b, 0, 1073741824); - } - _tuple = syscall.Pread(f.file.fd, b, off); n = _tuple[0]; err = _tuple[1]; + ReadDirent = $pkg.ReadDirent = function(fd, buf) { + var n = 0, err = $ifaceNil, _tuple; + _tuple = Getdents(fd, buf); n = _tuple[0]; err = _tuple[1]; return [n, err]; }; - File.prototype.pread = function(b, off) { return this.$val.pread(b, off); }; - File.Ptr.prototype.write = function(b) { - var n = 0, err = $ifaceNil, f, bcap, _tuple, m, err$1, _tmp, _tmp$1; - f = this; - while (true) { - bcap = b; - if (true && bcap.$length > 1073741824) { - bcap = $subslice(bcap, 0, 1073741824); - } - _tuple = syscall.Write(f.file.fd, bcap); m = _tuple[0]; err$1 = _tuple[1]; - n = n + (m) >> 0; - if (0 < m && m < bcap.$length || $interfaceIsEqual(err$1, new syscall.Errno(4))) { - b = $subslice(b, m); + ParseDirent = $pkg.ParseDirent = function(buf, max, names) { + var consumed = 0, count = 0, newnames = ($sliceType($String)).nil, origlen, dirent, _array, _struct, _view, x, bytes$1, name, _tmp, _tmp$1, _tmp$2; + origlen = buf.$length; + count = 0; + while (!((max === 0)) && buf.$length > 0) { + dirent = [undefined]; + dirent[0] = (_array = $sliceToArray(buf), _struct = new Dirent.Ptr(), _view = new DataView(_array.buffer, _array.byteOffset), _struct.Ino = new $Uint64(_view.getUint32(4, true), _view.getUint32(0, true)), _struct.Off = new $Int64(_view.getUint32(12, true), _view.getUint32(8, true)), _struct.Reclen = _view.getUint16(16, true), _struct.Type = _view.getUint8(18, true), _struct.Name = new ($nativeArray("Int8"))(_array.buffer, $min(_array.byteOffset + 19, _array.buffer.byteLength)), _struct.Pad_cgo_0 = new ($nativeArray("Uint8"))(_array.buffer, $min(_array.byteOffset + 275, _array.buffer.byteLength)), _struct); + buf = $subslice(buf, dirent[0].Reclen); + if ((x = dirent[0].Ino, (x.$high === 0 && x.$low === 0))) { continue; } - if (true && !((bcap.$length === b.$length)) && $interfaceIsEqual(err$1, $ifaceNil)) { - b = $subslice(b, m); + bytes$1 = $sliceToArray(new ($sliceType($Uint8))(dirent[0].Name)); + name = $bytesToString($subslice(new ($sliceType($Uint8))(bytes$1), 0, clen(new ($sliceType($Uint8))(bytes$1)))); + if (name === "." || name === "..") { continue; } - _tmp = n; _tmp$1 = err$1; n = _tmp; err = _tmp$1; - return [n, err]; + max = max - (1) >> 0; + count = count + (1) >> 0; + names = $append(names, name); } + _tmp = origlen - buf.$length >> 0; _tmp$1 = count; _tmp$2 = names; consumed = _tmp; count = _tmp$1; newnames = _tmp$2; + return [consumed, count, newnames]; }; - File.prototype.write = function(b) { return this.$val.write(b); }; - File.Ptr.prototype.pwrite = function(b, off) { - var n = 0, err = $ifaceNil, f, _tuple; - f = this; - if (true && b.$length > 1073741824) { - b = $subslice(b, 0, 1073741824); + mmapper.Ptr.prototype.Mmap = function(fd, offset, length, prot, flags) { + var data = ($sliceType($Uint8)).nil, err = $ifaceNil, $deferred = [], $err = null, m, _tmp, _tmp$1, _tuple, addr, errno, _tmp$2, _tmp$3, sl, b, x, x$1, p, _key, _tmp$4, _tmp$5; + /* */ try { $deferFrames.push($deferred); + m = this; + if (length <= 0) { + _tmp = ($sliceType($Uint8)).nil; _tmp$1 = new Errno(22); data = _tmp; err = _tmp$1; + return [data, err]; } - _tuple = syscall.Pwrite(f.file.fd, b, off); n = _tuple[0]; err = _tuple[1]; - return [n, err]; - }; - File.prototype.pwrite = function(b, off) { return this.$val.pwrite(b, off); }; - File.Ptr.prototype.seek = function(offset, whence) { - var ret = new $Int64(0, 0), err = $ifaceNil, f, _tuple; - f = this; - _tuple = syscall.Seek(f.file.fd, offset, whence); ret = _tuple[0]; err = _tuple[1]; - return [ret, err]; - }; - File.prototype.seek = function(offset, whence) { return this.$val.seek(offset, whence); }; - basename = function(name) { - var i; - i = name.length - 1 >> 0; - while (i > 0 && (name.charCodeAt(i) === 47)) { - name = name.substring(0, i); - i = i - (1) >> 0; + _tuple = m.mmap(0, (length >>> 0), prot, flags, fd, offset); addr = _tuple[0]; errno = _tuple[1]; + if (!($interfaceIsEqual(errno, $ifaceNil))) { + _tmp$2 = ($sliceType($Uint8)).nil; _tmp$3 = errno; data = _tmp$2; err = _tmp$3; + return [data, err]; } - i = i - (1) >> 0; - while (i >= 0) { - if (name.charCodeAt(i) === 47) { - name = name.substring((i + 1 >> 0)); - break; - } - i = i - (1) >> 0; - } - return name; + sl = new ($structType([["addr", "addr", "syscall", $Uintptr, ""], ["len", "len", "syscall", $Int, ""], ["cap", "cap", "syscall", $Int, ""]])).Ptr(addr, length, length); + b = sl; + p = new ($ptrType($Uint8))(function() { return (x$1 = b.$capacity - 1 >> 0, ((x$1 < 0 || x$1 >= this.$target.$length) ? $throwRuntimeError("index out of range") : this.$target.$array[this.$target.$offset + x$1])); }, function($v) { (x = b.$capacity - 1 >> 0, (x < 0 || x >= this.$target.$length) ? $throwRuntimeError("index out of range") : this.$target.$array[this.$target.$offset + x] = $v); }, b); + m.Mutex.Lock(); + $deferred.push([$methodVal(m, "Unlock"), []]); + _key = p; (m.active || $throwRuntimeError("assignment to entry in nil map"))[_key.$key()] = { k: _key, v: b }; + _tmp$4 = b; _tmp$5 = $ifaceNil; data = _tmp$4; err = _tmp$5; + return [data, err]; + /* */ } catch(err) { $err = err; } finally { $deferFrames.pop(); $callDeferred($deferred, $err); return [data, err]; } }; - Getwd = $pkg.Getwd = function() { - var $this = this, $args = arguments, dir = "", err = $ifaceNil, $s = 0, _tuple, s, e, _tmp, _tmp$1, _tuple$1, dot, _tmp$2, _tmp$3, _tuple$2, d, err$1, _tmp$4, _tmp$5, _tuple$3, d$1, err$2, _tmp$6, _tmp$7, _tuple$4, root, _tmp$8, _tmp$9, _tmp$10, _tmp$11, parent, _tmp$12, _tmp$13, _tuple$5, fd, err$3, _tmp$14, _tmp$15, _tuple$6, names, err$4, _tmp$16, _tmp$17, _ref, _i, name, _tuple$7, d$2, _tuple$8, pd, _tmp$18, _tmp$19, _tmp$20, _tmp$21; - /* */ while (true) { switch ($s) { case 0: - _tuple = syscall.Getwd(); s = _tuple[0]; e = _tuple[1]; - if (useSyscallwd(e)) { - _tmp = s; _tmp$1 = NewSyscallError("getwd", e); dir = _tmp; err = _tmp$1; - return [dir, err]; + mmapper.prototype.Mmap = function(fd, offset, length, prot, flags) { return this.$val.Mmap(fd, offset, length, prot, flags); }; + mmapper.Ptr.prototype.Munmap = function(data) { + var err = $ifaceNil, $deferred = [], $err = null, m, x, x$1, p, _entry, b, errno; + /* */ try { $deferFrames.push($deferred); + m = this; + if ((data.$length === 0) || !((data.$length === data.$capacity))) { + err = new Errno(22); + return err; } - _tuple$1 = Stat("."); dot = _tuple$1[0]; err = _tuple$1[1]; - if (!($interfaceIsEqual(err, $ifaceNil))) { - _tmp$2 = ""; _tmp$3 = err; dir = _tmp$2; err = _tmp$3; - return [dir, err]; + p = new ($ptrType($Uint8))(function() { return (x$1 = data.$capacity - 1 >> 0, ((x$1 < 0 || x$1 >= this.$target.$length) ? $throwRuntimeError("index out of range") : this.$target.$array[this.$target.$offset + x$1])); }, function($v) { (x = data.$capacity - 1 >> 0, (x < 0 || x >= this.$target.$length) ? $throwRuntimeError("index out of range") : this.$target.$array[this.$target.$offset + x] = $v); }, data); + m.Mutex.Lock(); + $deferred.push([$methodVal(m, "Unlock"), []]); + b = (_entry = m.active[p.$key()], _entry !== undefined ? _entry.v : ($sliceType($Uint8)).nil); + if (b === ($sliceType($Uint8)).nil || !($sliceIsEqual(b, 0, data, 0))) { + err = new Errno(22); + return err; } - dir = Getenv("PWD"); - if (dir.length > 0 && (dir.charCodeAt(0) === 47)) { - _tuple$2 = Stat(dir); d = _tuple$2[0]; err$1 = _tuple$2[1]; - if ($interfaceIsEqual(err$1, $ifaceNil) && SameFile(dot, d)) { - _tmp$4 = dir; _tmp$5 = $ifaceNil; dir = _tmp$4; err = _tmp$5; - return [dir, err]; - } + errno = m.munmap($sliceToArray(b), (b.$length >>> 0)); + if (!($interfaceIsEqual(errno, $ifaceNil))) { + err = errno; + return err; } - getwdCache.Mutex.Lock(); - dir = getwdCache.dir; - getwdCache.Mutex.Unlock(); - if (dir.length > 0) { - _tuple$3 = Stat(dir); d$1 = _tuple$3[0]; err$2 = _tuple$3[1]; - if ($interfaceIsEqual(err$2, $ifaceNil) && SameFile(dot, d$1)) { - _tmp$6 = dir; _tmp$7 = $ifaceNil; dir = _tmp$6; err = _tmp$7; - return [dir, err]; + delete m.active[p.$key()]; + err = $ifaceNil; + return err; + /* */ } catch(err) { $err = err; } finally { $deferFrames.pop(); $callDeferred($deferred, $err); return err; } + }; + mmapper.prototype.Munmap = function(data) { return this.$val.Munmap(data); }; + Errno.prototype.Error = function() { + var e, s; + e = this.$val !== undefined ? this.$val : this; + if (0 <= (e >> 0) && (e >> 0) < 133) { + s = ((e < 0 || e >= errors.length) ? $throwRuntimeError("index out of range") : errors[e]); + if (!(s === "")) { + return s; } } - _tuple$4 = Stat("/"); root = _tuple$4[0]; err = _tuple$4[1]; + return "errno " + itoa((e >> 0)); + }; + $ptrType(Errno).prototype.Error = function() { return new Errno(this.$get()).Error(); }; + Errno.prototype.Temporary = function() { + var e; + e = this.$val !== undefined ? this.$val : this; + return (e === 4) || (e === 24) || (new Errno(e)).Timeout(); + }; + $ptrType(Errno).prototype.Temporary = function() { return new Errno(this.$get()).Temporary(); }; + Errno.prototype.Timeout = function() { + var e; + e = this.$val !== undefined ? this.$val : this; + return (e === 11) || (e === 11) || (e === 110); + }; + $ptrType(Errno).prototype.Timeout = function() { return new Errno(this.$get()).Timeout(); }; + Read = $pkg.Read = function(fd, p) { + var n = 0, err = $ifaceNil, _tuple; + _tuple = read(fd, p); n = _tuple[0]; err = _tuple[1]; + return [n, err]; + }; + Write = $pkg.Write = function(fd, p) { + var n = 0, err = $ifaceNil, _tuple; + _tuple = write(fd, p); n = _tuple[0]; err = _tuple[1]; + return [n, err]; + }; + open = function(path, mode, perm) { + var fd = 0, err = $ifaceNil, _p0, _tuple, _tuple$1, r0, e1; + _p0 = ($ptrType($Uint8)).nil; + _tuple = BytePtrFromString(path); _p0 = _tuple[0]; err = _tuple[1]; if (!($interfaceIsEqual(err, $ifaceNil))) { - _tmp$8 = ""; _tmp$9 = err; dir = _tmp$8; err = _tmp$9; - return [dir, err]; + return [fd, err]; } - if (SameFile(root, dot)) { - _tmp$10 = "/"; _tmp$11 = $ifaceNil; dir = _tmp$10; err = _tmp$11; - return [dir, err]; + _tuple$1 = Syscall(2, _p0, (mode >>> 0), (perm >>> 0)); r0 = _tuple$1[0]; e1 = _tuple$1[2]; + fd = (r0 >> 0); + if (!((e1 === 0))) { + err = new Errno(e1); } - dir = ""; - parent = ".."; - /* while (true) { */ case 2: if(!(true)) { $s = 3; continue; } - if (parent.length >= 1024) { - _tmp$12 = ""; _tmp$13 = new syscall.Errno(63); dir = _tmp$12; err = _tmp$13; - return [dir, err]; - } - _tuple$5 = Open(parent); fd = _tuple$5[0]; err$3 = _tuple$5[1]; - if (!($interfaceIsEqual(err$3, $ifaceNil))) { - _tmp$14 = ""; _tmp$15 = err$3; dir = _tmp$14; err = _tmp$15; - return [dir, err]; - } - /* while (true) { */ case 4: if(!(true)) { $s = 5; continue; } - _tuple$6 = fd.Readdirnames(100); names = _tuple$6[0]; err$4 = _tuple$6[1]; - if (!($interfaceIsEqual(err$4, $ifaceNil))) { - fd.Close(); - _tmp$16 = ""; _tmp$17 = err$4; dir = _tmp$16; err = _tmp$17; - return [dir, err]; - } - _ref = names; - _i = 0; - /* while (_i < _ref.$length) { */ case 6: if(!(_i < _ref.$length)) { $s = 7; continue; } - name = ((_i < 0 || _i >= _ref.$length) ? $throwRuntimeError("index out of range") : _ref.$array[_ref.$offset + _i]); - _tuple$7 = Lstat(parent + "/" + name); d$2 = _tuple$7[0]; - /* if (SameFile(d$2, dot)) { */ if (SameFile(d$2, dot)) {} else { $s = 8; continue; } - dir = "/" + name + dir; - /* goto Found */ $s = 1; continue; - /* } */ case 8: - _i++; - /* } */ $s = 6; continue; case 7: - /* } */ $s = 4; continue; case 5: - /* Found: */ case 1: - _tuple$8 = fd.Stat(); pd = _tuple$8[0]; err$3 = _tuple$8[1]; - if (!($interfaceIsEqual(err$3, $ifaceNil))) { - _tmp$18 = ""; _tmp$19 = err$3; dir = _tmp$18; err = _tmp$19; - return [dir, err]; - } - fd.Close(); - if (SameFile(pd, root)) { - /* break; */ $s = 3; continue; - } - dot = pd; - parent = "../" + parent; - /* } */ $s = 2; continue; case 3: - getwdCache.Mutex.Lock(); - getwdCache.dir = dir; - getwdCache.Mutex.Unlock(); - _tmp$20 = dir; _tmp$21 = $ifaceNil; dir = _tmp$20; err = _tmp$21; - return [dir, err]; - /* */ case -1: } return; } - }; - init$1 = function() { - useSyscallwd = useSyscallwdDarwin; + return [fd, err]; }; - useSyscallwdDarwin = function(err) { - return !($interfaceIsEqual(err, new syscall.Errno(45))); + Getcwd = $pkg.Getcwd = function(buf) { + var n = 0, err = $ifaceNil, _p0, _tuple, r0, e1; + _p0 = 0; + if (buf.$length > 0) { + _p0 = $sliceToArray(buf); + } else { + _p0 = new Uint8Array(0); + } + _tuple = Syscall(79, _p0, (buf.$length >>> 0), 0); r0 = _tuple[0]; e1 = _tuple[2]; + n = (r0 >> 0); + if (!((e1 === 0))) { + err = new Errno(e1); + } + return [n, err]; }; - IsPathSeparator = $pkg.IsPathSeparator = function(c) { - return 47 === c; + Close = $pkg.Close = function(fd) { + var err = $ifaceNil, _tuple, e1; + _tuple = Syscall(3, (fd >>> 0), 0, 0); e1 = _tuple[2]; + if (!((e1 === 0))) { + err = new Errno(e1); + } + return err; }; Exit = $pkg.Exit = function(code) { - syscall.Exit(code); + Syscall(231, (code >>> 0), 0, 0); + return; }; - sameFile = function(fs1, fs2) { - var stat1, stat2, x, x$1; - stat1 = $assertType(fs1.sys, ($ptrType(syscall.Stat_t))); - stat2 = $assertType(fs2.sys, ($ptrType(syscall.Stat_t))); - return (stat1.Dev === stat2.Dev) && (x = stat1.Ino, x$1 = stat2.Ino, (x.$high === x$1.$high && x.$low === x$1.$low)); + Fchdir = $pkg.Fchdir = function(fd) { + var err = $ifaceNil, _tuple, e1; + _tuple = Syscall(81, (fd >>> 0), 0, 0); e1 = _tuple[2]; + if (!((e1 === 0))) { + err = new Errno(e1); + } + return err; }; - fileInfoFromStat = function(st, name) { - var fs, _ref; - fs = new fileStat.Ptr(basename(name), st.Size, 0, timespecToTime($clone(st.Mtimespec, syscall.Timespec)), st); - fs.mode = (((st.Mode & 511) >>> 0) >>> 0); - _ref = (st.Mode & 61440) >>> 0; - if (_ref === 24576 || _ref === 57344) { - fs.mode = (fs.mode | (67108864)) >>> 0; - } else if (_ref === 8192) { - fs.mode = (fs.mode | (69206016)) >>> 0; - } else if (_ref === 16384) { - fs.mode = (fs.mode | (2147483648)) >>> 0; - } else if (_ref === 4096) { - fs.mode = (fs.mode | (33554432)) >>> 0; - } else if (_ref === 40960) { - fs.mode = (fs.mode | (134217728)) >>> 0; - } else if (_ref === 32768) { - } else if (_ref === 49152) { - fs.mode = (fs.mode | (16777216)) >>> 0; + Fchmod = $pkg.Fchmod = function(fd, mode) { + var err = $ifaceNil, _tuple, e1; + _tuple = Syscall(91, (fd >>> 0), (mode >>> 0), 0); e1 = _tuple[2]; + if (!((e1 === 0))) { + err = new Errno(e1); } - if (!((((st.Mode & 1024) >>> 0) === 0))) { - fs.mode = (fs.mode | (4194304)) >>> 0; + return err; + }; + Fsync = $pkg.Fsync = function(fd) { + var err = $ifaceNil, _tuple, e1; + _tuple = Syscall(74, (fd >>> 0), 0, 0); e1 = _tuple[2]; + if (!((e1 === 0))) { + err = new Errno(e1); } - if (!((((st.Mode & 2048) >>> 0) === 0))) { - fs.mode = (fs.mode | (8388608)) >>> 0; + return err; + }; + Getdents = $pkg.Getdents = function(fd, buf) { + var n = 0, err = $ifaceNil, _p0, _tuple, r0, e1; + _p0 = 0; + if (buf.$length > 0) { + _p0 = $sliceToArray(buf); + } else { + _p0 = new Uint8Array(0); } - if (!((((st.Mode & 512) >>> 0) === 0))) { - fs.mode = (fs.mode | (1048576)) >>> 0; + _tuple = Syscall(217, (fd >>> 0), _p0, (buf.$length >>> 0)); r0 = _tuple[0]; e1 = _tuple[2]; + n = (r0 >> 0); + if (!((e1 === 0))) { + err = new Errno(e1); } - return fs; + return [n, err]; }; - timespecToTime = function(ts) { - return time.Unix(ts.Sec, ts.Nsec); + read = function(fd, p) { + var n = 0, err = $ifaceNil, _p0, _tuple, r0, e1; + _p0 = 0; + if (p.$length > 0) { + _p0 = $sliceToArray(p); + } else { + _p0 = new Uint8Array(0); + } + _tuple = Syscall(0, (fd >>> 0), _p0, (p.$length >>> 0)); r0 = _tuple[0]; e1 = _tuple[2]; + n = (r0 >> 0); + if (!((e1 === 0))) { + err = new Errno(e1); + } + return [n, err]; }; - init$2 = function() { - var _tuple, osver, err, i, _ref, _i, _rune; - _tuple = syscall.Sysctl("kern.osrelease"); osver = _tuple[0]; err = _tuple[1]; + Readlink = $pkg.Readlink = function(path, buf) { + var n = 0, err = $ifaceNil, _p0, _tuple, _p1, _tuple$1, r0, e1; + _p0 = ($ptrType($Uint8)).nil; + _tuple = BytePtrFromString(path); _p0 = _tuple[0]; err = _tuple[1]; if (!($interfaceIsEqual(err, $ifaceNil))) { - return; + return [n, err]; } - i = 0; - _ref = osver; - _i = 0; - while (_i < _ref.length) { - _rune = $decodeRune(_ref, _i); - i = _i; - if (!((osver.charCodeAt(i) === 46))) { - _i += _rune[1]; - continue; - } - _i += _rune[1]; + _p1 = 0; + if (buf.$length > 0) { + _p1 = $sliceToArray(buf); + } else { + _p1 = new Uint8Array(0); } - if (i > 2 || (i === 2) && osver.charCodeAt(0) >= 49 && osver.charCodeAt(1) >= 49) { - supportsCloseOnExec = true; + _tuple$1 = Syscall(89, _p0, _p1, (buf.$length >>> 0)); r0 = _tuple$1[0]; e1 = _tuple$1[2]; + n = (r0 >> 0); + if (!((e1 === 0))) { + err = new Errno(e1); } + return [n, err]; }; - FileMode.prototype.String = function() { - var m, buf, w, _ref, _i, _rune, i, c, y, _ref$1, _i$1, _rune$1, i$1, c$1, y$1; - m = this.$val !== undefined ? this.$val : this; - buf = ($arrayType($Uint8, 32)).zero(); $copy(buf, ($arrayType($Uint8, 32)).zero(), ($arrayType($Uint8, 32))); - w = 0; - _ref = "dalTLDpSugct"; - _i = 0; - while (_i < _ref.length) { - _rune = $decodeRune(_ref, _i); - i = _i; - c = _rune[0]; - if (!((((m & (((y = ((31 - i >> 0) >>> 0), y < 32 ? (1 << y) : 0) >>> 0))) >>> 0) === 0))) { - (w < 0 || w >= buf.length) ? $throwRuntimeError("index out of range") : buf[w] = (c << 24 >>> 24); - w = w + (1) >> 0; - } - _i += _rune[1]; - } - if (w === 0) { - (w < 0 || w >= buf.length) ? $throwRuntimeError("index out of range") : buf[w] = 45; - w = w + (1) >> 0; + write = function(fd, p) { + var n = 0, err = $ifaceNil, _p0, _tuple, r0, e1; + _p0 = 0; + if (p.$length > 0) { + _p0 = $sliceToArray(p); + } else { + _p0 = new Uint8Array(0); } - _ref$1 = "rwxrwxrwx"; - _i$1 = 0; - while (_i$1 < _ref$1.length) { - _rune$1 = $decodeRune(_ref$1, _i$1); - i$1 = _i$1; - c$1 = _rune$1[0]; - if (!((((m & (((y$1 = ((8 - i$1 >> 0) >>> 0), y$1 < 32 ? (1 << y$1) : 0) >>> 0))) >>> 0) === 0))) { - (w < 0 || w >= buf.length) ? $throwRuntimeError("index out of range") : buf[w] = (c$1 << 24 >>> 24); - } else { - (w < 0 || w >= buf.length) ? $throwRuntimeError("index out of range") : buf[w] = 45; - } - w = w + (1) >> 0; - _i$1 += _rune$1[1]; + _tuple = Syscall(1, (fd >>> 0), _p0, (p.$length >>> 0)); r0 = _tuple[0]; e1 = _tuple[2]; + n = (r0 >> 0); + if (!((e1 === 0))) { + err = new Errno(e1); } - return $bytesToString($subslice(new ($sliceType($Uint8))(buf), 0, w)); + return [n, err]; }; - $ptrType(FileMode).prototype.String = function() { return new FileMode(this.$get()).String(); }; - FileMode.prototype.IsDir = function() { - var m; - m = this.$val !== undefined ? this.$val : this; - return !((((m & 2147483648) >>> 0) === 0)); + munmap = function(addr, length) { + var err = $ifaceNil, _tuple, e1; + _tuple = Syscall(11, addr, length, 0); e1 = _tuple[2]; + if (!((e1 === 0))) { + err = new Errno(e1); + } + return err; }; - $ptrType(FileMode).prototype.IsDir = function() { return new FileMode(this.$get()).IsDir(); }; - FileMode.prototype.IsRegular = function() { - var m; - m = this.$val !== undefined ? this.$val : this; - return ((m & 2399141888) >>> 0) === 0; + Fchown = $pkg.Fchown = function(fd, uid, gid) { + var err = $ifaceNil, _tuple, e1; + _tuple = Syscall(93, (fd >>> 0), (uid >>> 0), (gid >>> 0)); e1 = _tuple[2]; + if (!((e1 === 0))) { + err = new Errno(e1); + } + return err; }; - $ptrType(FileMode).prototype.IsRegular = function() { return new FileMode(this.$get()).IsRegular(); }; - FileMode.prototype.Perm = function() { - var m; - m = this.$val !== undefined ? this.$val : this; - return (m & 511) >>> 0; + Fstat = $pkg.Fstat = function(fd, stat) { + var err = $ifaceNil, _tuple, _array, _struct, _view, e1; + _array = new Uint8Array(144); + _tuple = Syscall(5, (fd >>> 0), _array, 0); e1 = _tuple[2]; + _struct = stat, _view = new DataView(_array.buffer, _array.byteOffset), _struct.Dev = new $Uint64(_view.getUint32(4, true), _view.getUint32(0, true)), _struct.Ino = new $Uint64(_view.getUint32(12, true), _view.getUint32(8, true)), _struct.Nlink = new $Uint64(_view.getUint32(20, true), _view.getUint32(16, true)), _struct.Mode = _view.getUint32(24, true), _struct.Uid = _view.getUint32(28, true), _struct.Gid = _view.getUint32(32, true), _struct.X__pad0 = _view.getInt32(36, true), _struct.Rdev = new $Uint64(_view.getUint32(44, true), _view.getUint32(40, true)), _struct.Size = new $Int64(_view.getUint32(52, true), _view.getUint32(48, true)), _struct.Blksize = new $Int64(_view.getUint32(60, true), _view.getUint32(56, true)), _struct.Blocks = new $Int64(_view.getUint32(68, true), _view.getUint32(64, true)), _struct.Atim.Sec = new $Int64(_view.getUint32(76, true), _view.getUint32(72, true)), _struct.Atim.Nsec = new $Int64(_view.getUint32(84, true), _view.getUint32(80, true)), _struct.Mtim.Sec = new $Int64(_view.getUint32(92, true), _view.getUint32(88, true)), _struct.Mtim.Nsec = new $Int64(_view.getUint32(100, true), _view.getUint32(96, true)), _struct.Ctim.Sec = new $Int64(_view.getUint32(108, true), _view.getUint32(104, true)), _struct.Ctim.Nsec = new $Int64(_view.getUint32(116, true), _view.getUint32(112, true)), _struct.X__unused = new ($nativeArray("Int64"))(_array.buffer, $min(_array.byteOffset + 120, _array.buffer.byteLength)); + if (!((e1 === 0))) { + err = new Errno(e1); + } + return err; }; - $ptrType(FileMode).prototype.Perm = function() { return new FileMode(this.$get()).Perm(); }; - fileStat.Ptr.prototype.Name = function() { - var fs; - fs = this; - return fs.name; + Ftruncate = $pkg.Ftruncate = function(fd, length) { + var err = $ifaceNil, _tuple, e1; + _tuple = Syscall(77, (fd >>> 0), (length.$low >>> 0), 0); e1 = _tuple[2]; + if (!((e1 === 0))) { + err = new Errno(e1); + } + return err; }; - fileStat.prototype.Name = function() { return this.$val.Name(); }; - fileStat.Ptr.prototype.IsDir = function() { - var fs; - fs = this; - return (new FileMode(fs.Mode())).IsDir(); + Lstat = $pkg.Lstat = function(path, stat) { + var err = $ifaceNil, _p0, _tuple, _tuple$1, _array, _struct, _view, e1; + _p0 = ($ptrType($Uint8)).nil; + _tuple = BytePtrFromString(path); _p0 = _tuple[0]; err = _tuple[1]; + if (!($interfaceIsEqual(err, $ifaceNil))) { + return err; + } + _array = new Uint8Array(144); + _tuple$1 = Syscall(6, _p0, _array, 0); e1 = _tuple$1[2]; + _struct = stat, _view = new DataView(_array.buffer, _array.byteOffset), _struct.Dev = new $Uint64(_view.getUint32(4, true), _view.getUint32(0, true)), _struct.Ino = new $Uint64(_view.getUint32(12, true), _view.getUint32(8, true)), _struct.Nlink = new $Uint64(_view.getUint32(20, true), _view.getUint32(16, true)), _struct.Mode = _view.getUint32(24, true), _struct.Uid = _view.getUint32(28, true), _struct.Gid = _view.getUint32(32, true), _struct.X__pad0 = _view.getInt32(36, true), _struct.Rdev = new $Uint64(_view.getUint32(44, true), _view.getUint32(40, true)), _struct.Size = new $Int64(_view.getUint32(52, true), _view.getUint32(48, true)), _struct.Blksize = new $Int64(_view.getUint32(60, true), _view.getUint32(56, true)), _struct.Blocks = new $Int64(_view.getUint32(68, true), _view.getUint32(64, true)), _struct.Atim.Sec = new $Int64(_view.getUint32(76, true), _view.getUint32(72, true)), _struct.Atim.Nsec = new $Int64(_view.getUint32(84, true), _view.getUint32(80, true)), _struct.Mtim.Sec = new $Int64(_view.getUint32(92, true), _view.getUint32(88, true)), _struct.Mtim.Nsec = new $Int64(_view.getUint32(100, true), _view.getUint32(96, true)), _struct.Ctim.Sec = new $Int64(_view.getUint32(108, true), _view.getUint32(104, true)), _struct.Ctim.Nsec = new $Int64(_view.getUint32(116, true), _view.getUint32(112, true)), _struct.X__unused = new ($nativeArray("Int64"))(_array.buffer, $min(_array.byteOffset + 120, _array.buffer.byteLength)); + if (!((e1 === 0))) { + err = new Errno(e1); + } + return err; }; - fileStat.prototype.IsDir = function() { return this.$val.IsDir(); }; - SameFile = $pkg.SameFile = function(fi1, fi2) { - var _tuple, fs1, ok1, _tuple$1, fs2, ok2; - _tuple = $assertType(fi1, ($ptrType(fileStat)), true); fs1 = _tuple[0]; ok1 = _tuple[1]; - _tuple$1 = $assertType(fi2, ($ptrType(fileStat)), true); fs2 = _tuple$1[0]; ok2 = _tuple$1[1]; - if (!ok1 || !ok2) { - return false; + Pread = $pkg.Pread = function(fd, p, offset) { + var n = 0, err = $ifaceNil, _p0, _tuple, r0, e1; + _p0 = 0; + if (p.$length > 0) { + _p0 = $sliceToArray(p); + } else { + _p0 = new Uint8Array(0); } - return sameFile(fs1, fs2); + _tuple = Syscall6(17, (fd >>> 0), _p0, (p.$length >>> 0), (offset.$low >>> 0), 0, 0); r0 = _tuple[0]; e1 = _tuple[2]; + n = (r0 >> 0); + if (!((e1 === 0))) { + err = new Errno(e1); + } + return [n, err]; }; - fileStat.Ptr.prototype.Size = function() { - var fs; - fs = this; - return fs.size; + Pwrite = $pkg.Pwrite = function(fd, p, offset) { + var n = 0, err = $ifaceNil, _p0, _tuple, r0, e1; + _p0 = 0; + if (p.$length > 0) { + _p0 = $sliceToArray(p); + } else { + _p0 = new Uint8Array(0); + } + _tuple = Syscall6(18, (fd >>> 0), _p0, (p.$length >>> 0), (offset.$low >>> 0), 0, 0); r0 = _tuple[0]; e1 = _tuple[2]; + n = (r0 >> 0); + if (!((e1 === 0))) { + err = new Errno(e1); + } + return [n, err]; }; - fileStat.prototype.Size = function() { return this.$val.Size(); }; - fileStat.Ptr.prototype.Mode = function() { - var fs; - fs = this; - return fs.mode; + Seek = $pkg.Seek = function(fd, offset, whence) { + var off = new $Int64(0, 0), err = $ifaceNil, _tuple, r0, e1; + _tuple = Syscall(8, (fd >>> 0), (offset.$low >>> 0), (whence >>> 0)); r0 = _tuple[0]; e1 = _tuple[2]; + off = new $Int64(0, r0.constructor === Number ? r0 : 1); + if (!((e1 === 0))) { + err = new Errno(e1); + } + return [off, err]; }; - fileStat.prototype.Mode = function() { return this.$val.Mode(); }; - fileStat.Ptr.prototype.ModTime = function() { - var fs; - fs = this; - return fs.modTime; + Stat = $pkg.Stat = function(path, stat) { + var err = $ifaceNil, _p0, _tuple, _tuple$1, _array, _struct, _view, e1; + _p0 = ($ptrType($Uint8)).nil; + _tuple = BytePtrFromString(path); _p0 = _tuple[0]; err = _tuple[1]; + if (!($interfaceIsEqual(err, $ifaceNil))) { + return err; + } + _array = new Uint8Array(144); + _tuple$1 = Syscall(4, _p0, _array, 0); e1 = _tuple$1[2]; + _struct = stat, _view = new DataView(_array.buffer, _array.byteOffset), _struct.Dev = new $Uint64(_view.getUint32(4, true), _view.getUint32(0, true)), _struct.Ino = new $Uint64(_view.getUint32(12, true), _view.getUint32(8, true)), _struct.Nlink = new $Uint64(_view.getUint32(20, true), _view.getUint32(16, true)), _struct.Mode = _view.getUint32(24, true), _struct.Uid = _view.getUint32(28, true), _struct.Gid = _view.getUint32(32, true), _struct.X__pad0 = _view.getInt32(36, true), _struct.Rdev = new $Uint64(_view.getUint32(44, true), _view.getUint32(40, true)), _struct.Size = new $Int64(_view.getUint32(52, true), _view.getUint32(48, true)), _struct.Blksize = new $Int64(_view.getUint32(60, true), _view.getUint32(56, true)), _struct.Blocks = new $Int64(_view.getUint32(68, true), _view.getUint32(64, true)), _struct.Atim.Sec = new $Int64(_view.getUint32(76, true), _view.getUint32(72, true)), _struct.Atim.Nsec = new $Int64(_view.getUint32(84, true), _view.getUint32(80, true)), _struct.Mtim.Sec = new $Int64(_view.getUint32(92, true), _view.getUint32(88, true)), _struct.Mtim.Nsec = new $Int64(_view.getUint32(100, true), _view.getUint32(96, true)), _struct.Ctim.Sec = new $Int64(_view.getUint32(108, true), _view.getUint32(104, true)), _struct.Ctim.Nsec = new $Int64(_view.getUint32(116, true), _view.getUint32(112, true)), _struct.X__unused = new ($nativeArray("Int64"))(_array.buffer, $min(_array.byteOffset + 120, _array.buffer.byteLength)); + if (!((e1 === 0))) { + err = new Errno(e1); + } + return err; }; - fileStat.prototype.ModTime = function() { return this.$val.ModTime(); }; - fileStat.Ptr.prototype.Sys = function() { - var fs; - fs = this; - return fs.sys; + mmap = function(addr, length, prot, flags, fd, offset) { + var xaddr = 0, err = $ifaceNil, _tuple, r0, e1; + _tuple = Syscall6(9, addr, length, (prot >>> 0), (flags >>> 0), (fd >>> 0), (offset.$low >>> 0)); r0 = _tuple[0]; e1 = _tuple[2]; + xaddr = r0; + if (!((e1 === 0))) { + err = new Errno(e1); + } + return [xaddr, err]; }; - fileStat.prototype.Sys = function() { return this.$val.Sys(); }; $pkg.$init = function() { - ($ptrType(PathError)).methods = [["Error", "Error", "", $funcType([], [$String], false), -1]]; - PathError.init([["Op", "Op", "", $String, ""], ["Path", "Path", "", $String, ""], ["Err", "Err", "", $error, ""]]); - ($ptrType(SyscallError)).methods = [["Error", "Error", "", $funcType([], [$String], false), -1]]; - SyscallError.init([["Syscall", "Syscall", "", $String, ""], ["Err", "Err", "", $error, ""]]); - ($ptrType(LinkError)).methods = [["Error", "Error", "", $funcType([], [$String], false), -1]]; - LinkError.init([["Op", "Op", "", $String, ""], ["Old", "Old", "", $String, ""], ["New", "New", "", $String, ""], ["Err", "Err", "", $error, ""]]); - File.methods = [["close", "close", "os", $funcType([], [$error], false), 0]]; - ($ptrType(File)).methods = [["Chdir", "Chdir", "", $funcType([], [$error], false), -1], ["Chmod", "Chmod", "", $funcType([FileMode], [$error], false), -1], ["Chown", "Chown", "", $funcType([$Int, $Int], [$error], false), -1], ["Close", "Close", "", $funcType([], [$error], false), -1], ["Fd", "Fd", "", $funcType([], [$Uintptr], false), -1], ["Name", "Name", "", $funcType([], [$String], false), -1], ["Read", "Read", "", $funcType([($sliceType($Uint8))], [$Int, $error], false), -1], ["ReadAt", "ReadAt", "", $funcType([($sliceType($Uint8)), $Int64], [$Int, $error], false), -1], ["Readdir", "Readdir", "", $funcType([$Int], [($sliceType(FileInfo)), $error], false), -1], ["Readdirnames", "Readdirnames", "", $funcType([$Int], [($sliceType($String)), $error], false), -1], ["Seek", "Seek", "", $funcType([$Int64, $Int], [$Int64, $error], false), -1], ["Stat", "Stat", "", $funcType([], [FileInfo, $error], false), -1], ["Sync", "Sync", "", $funcType([], [$error], false), -1], ["Truncate", "Truncate", "", $funcType([$Int64], [$error], false), -1], ["Write", "Write", "", $funcType([($sliceType($Uint8))], [$Int, $error], false), -1], ["WriteAt", "WriteAt", "", $funcType([($sliceType($Uint8)), $Int64], [$Int, $error], false), -1], ["WriteString", "WriteString", "", $funcType([$String], [$Int, $error], false), -1], ["close", "close", "os", $funcType([], [$error], false), 0], ["pread", "pread", "os", $funcType([($sliceType($Uint8)), $Int64], [$Int, $error], false), -1], ["pwrite", "pwrite", "os", $funcType([($sliceType($Uint8)), $Int64], [$Int, $error], false), -1], ["read", "read", "os", $funcType([($sliceType($Uint8))], [$Int, $error], false), -1], ["readdir", "readdir", "os", $funcType([$Int], [($sliceType(FileInfo)), $error], false), -1], ["readdirnames", "readdirnames", "os", $funcType([$Int], [($sliceType($String)), $error], false), -1], ["seek", "seek", "os", $funcType([$Int64, $Int], [$Int64, $error], false), -1], ["write", "write", "os", $funcType([($sliceType($Uint8))], [$Int, $error], false), -1]]; - File.init([["file", "", "os", ($ptrType(file)), ""]]); - ($ptrType(file)).methods = [["close", "close", "os", $funcType([], [$error], false), -1]]; - file.init([["fd", "fd", "os", $Int, ""], ["name", "name", "os", $String, ""], ["dirinfo", "dirinfo", "os", ($ptrType(dirInfo)), ""], ["nepipe", "nepipe", "os", $Int32, ""]]); - dirInfo.init([["buf", "buf", "os", ($sliceType($Uint8)), ""], ["nbuf", "nbuf", "os", $Int, ""], ["bufp", "bufp", "os", $Int, ""]]); - FileInfo.init([["IsDir", "IsDir", "", $funcType([], [$Bool], false)], ["ModTime", "ModTime", "", $funcType([], [time.Time], false)], ["Mode", "Mode", "", $funcType([], [FileMode], false)], ["Name", "Name", "", $funcType([], [$String], false)], ["Size", "Size", "", $funcType([], [$Int64], false)], ["Sys", "Sys", "", $funcType([], [$emptyInterface], false)]]); - FileMode.methods = [["IsDir", "IsDir", "", $funcType([], [$Bool], false), -1], ["IsRegular", "IsRegular", "", $funcType([], [$Bool], false), -1], ["Perm", "Perm", "", $funcType([], [FileMode], false), -1], ["String", "String", "", $funcType([], [$String], false), -1]]; - ($ptrType(FileMode)).methods = [["IsDir", "IsDir", "", $funcType([], [$Bool], false), -1], ["IsRegular", "IsRegular", "", $funcType([], [$Bool], false), -1], ["Perm", "Perm", "", $funcType([], [FileMode], false), -1], ["String", "String", "", $funcType([], [$String], false), -1]]; - ($ptrType(fileStat)).methods = [["IsDir", "IsDir", "", $funcType([], [$Bool], false), -1], ["ModTime", "ModTime", "", $funcType([], [time.Time], false), -1], ["Mode", "Mode", "", $funcType([], [FileMode], false), -1], ["Name", "Name", "", $funcType([], [$String], false), -1], ["Size", "Size", "", $funcType([], [$Int64], false), -1], ["Sys", "Sys", "", $funcType([], [$emptyInterface], false), -1]]; - fileStat.init([["name", "name", "os", $String, ""], ["size", "size", "os", $Int64, ""], ["mode", "mode", "os", FileMode, ""], ["modTime", "modTime", "os", time.Time, ""], ["sys", "sys", "os", $emptyInterface, ""]]); - getwdCache = new ($structType([["Mutex", "", "", sync.Mutex, ""], ["dir", "dir", "os", $String, ""]])).Ptr(); - $pkg.Args = ($sliceType($String)).nil; - supportsCloseOnExec = false; - $pkg.ErrInvalid = errors.New("invalid argument"); - $pkg.ErrPermission = errors.New("permission denied"); - $pkg.ErrExist = errors.New("file already exists"); - $pkg.ErrNotExist = errors.New("file does not exist"); - $pkg.Stdin = NewFile((syscall.Stdin >>> 0), "/dev/stdin"); - $pkg.Stdout = NewFile((syscall.Stdout >>> 0), "/dev/stdout"); - $pkg.Stderr = NewFile((syscall.Stderr >>> 0), "/dev/stderr"); - useSyscallwd = (function() { - return true; - }); - lstat = Lstat; + ($ptrType(mmapper)).methods = [["Lock", "Lock", "", $funcType([], [], false), 0], ["Mmap", "Mmap", "", $funcType([$Int, $Int64, $Int, $Int, $Int], [($sliceType($Uint8)), $error], false), -1], ["Munmap", "Munmap", "", $funcType([($sliceType($Uint8))], [$error], false), -1], ["Unlock", "Unlock", "", $funcType([], [], false), 0]]; + mmapper.init([["Mutex", "", "", sync.Mutex, ""], ["active", "active", "syscall", ($mapType(($ptrType($Uint8)), ($sliceType($Uint8)))), ""], ["mmap", "mmap", "syscall", ($funcType([$Uintptr, $Uintptr, $Int, $Int, $Int, $Int64], [$Uintptr, $error], false)), ""], ["munmap", "munmap", "syscall", ($funcType([$Uintptr, $Uintptr], [$error], false)), ""]]); + Errno.methods = [["Error", "Error", "", $funcType([], [$String], false), -1], ["Temporary", "Temporary", "", $funcType([], [$Bool], false), -1], ["Timeout", "Timeout", "", $funcType([], [$Bool], false), -1]]; + ($ptrType(Errno)).methods = [["Error", "Error", "", $funcType([], [$String], false), -1], ["Temporary", "Temporary", "", $funcType([], [$Bool], false), -1], ["Timeout", "Timeout", "", $funcType([], [$Bool], false), -1]]; + ($ptrType(Timespec)).methods = [["Nano", "Nano", "", $funcType([], [$Int64], false), -1], ["Unix", "Unix", "", $funcType([], [$Int64, $Int64], false), -1]]; + Timespec.init([["Sec", "Sec", "", $Int64, ""], ["Nsec", "Nsec", "", $Int64, ""]]); + Stat_t.init([["Dev", "Dev", "", $Uint64, ""], ["Ino", "Ino", "", $Uint64, ""], ["Nlink", "Nlink", "", $Uint64, ""], ["Mode", "Mode", "", $Uint32, ""], ["Uid", "Uid", "", $Uint32, ""], ["Gid", "Gid", "", $Uint32, ""], ["X__pad0", "X__pad0", "", $Int32, ""], ["Rdev", "Rdev", "", $Uint64, ""], ["Size", "Size", "", $Int64, ""], ["Blksize", "Blksize", "", $Int64, ""], ["Blocks", "Blocks", "", $Int64, ""], ["Atim", "Atim", "", Timespec, ""], ["Mtim", "Mtim", "", Timespec, ""], ["Ctim", "Ctim", "", Timespec, ""], ["X__unused", "X__unused", "", ($arrayType($Int64, 3)), ""]]); + Dirent.init([["Ino", "Ino", "", $Uint64, ""], ["Off", "Off", "", $Int64, ""], ["Reclen", "Reclen", "", $Uint16, ""], ["Type", "Type", "", $Uint8, ""], ["Name", "Name", "", ($arrayType($Int8, 256)), ""], ["Pad_cgo_0", "Pad_cgo_0", "", ($arrayType($Uint8, 5)), ""]]); + lineBuffer = ($sliceType($Uint8)).nil; + syscallModule = $ifaceNil; + envOnce = new sync.Once.Ptr(); + envLock = new sync.RWMutex.Ptr(); + env = false; + envs = ($sliceType($String)).nil; + warningPrinted = false; + alreadyTriedToLoad = false; + minusOne = -1; + $pkg.Stdin = 0; + $pkg.Stdout = 1; + $pkg.Stderr = 2; + errors = $toNativeArray("String", ["", "operation not permitted", "no such file or directory", "no such process", "interrupted system call", "input/output error", "no such device or address", "argument list too long", "exec format error", "bad file descriptor", "no child processes", "resource temporarily unavailable", "cannot allocate memory", "permission denied", "bad address", "block device required", "device or resource busy", "file exists", "invalid cross-device link", "no such device", "not a directory", "is a directory", "invalid argument", "too many open files in system", "too many open files", "inappropriate ioctl for device", "text file busy", "file too large", "no space left on device", "illegal seek", "read-only file system", "too many links", "broken pipe", "numerical argument out of domain", "numerical result out of range", "resource deadlock avoided", "file name too long", "no locks available", "function not implemented", "directory not empty", "too many levels of symbolic links", "", "no message of desired type", "identifier removed", "channel number out of range", "level 2 not synchronized", "level 3 halted", "level 3 reset", "link number out of range", "protocol driver not attached", "no CSI structure available", "level 2 halted", "invalid exchange", "invalid request descriptor", "exchange full", "no anode", "invalid request code", "invalid slot", "", "bad font file format", "device not a stream", "no data available", "timer expired", "out of streams resources", "machine is not on the network", "package not installed", "object is remote", "link has been severed", "advertise error", "srmount error", "communication error on send", "protocol error", "multihop attempted", "RFS specific error", "bad message", "value too large for defined data type", "name not unique on network", "file descriptor in bad state", "remote address changed", "can not access a needed shared library", "accessing a corrupted shared library", ".lib section in a.out corrupted", "attempting to link in too many shared libraries", "cannot exec a shared library directly", "invalid or incomplete multibyte or wide character", "interrupted system call should be restarted", "streams pipe error", "too many users", "socket operation on non-socket", "destination address required", "message too long", "protocol wrong type for socket", "protocol not available", "protocol not supported", "socket type not supported", "operation not supported", "protocol family not supported", "address family not supported by protocol", "address already in use", "cannot assign requested address", "network is down", "network is unreachable", "network dropped connection on reset", "software caused connection abort", "connection reset by peer", "no buffer space available", "transport endpoint is already connected", "transport endpoint is not connected", "cannot send after transport endpoint shutdown", "too many references: cannot splice", "connection timed out", "connection refused", "host is down", "no route to host", "operation already in progress", "operation now in progress", "stale NFS file handle", "structure needs cleaning", "not a XENIX named type file", "no XENIX semaphores available", "is a named type file", "remote I/O error", "disk quota exceeded", "no medium found", "wrong medium type", "operation canceled", "required key not available", "key has expired", "key has been revoked", "key was rejected by service", "owner died", "state not recoverable", "operation not possible due to RF-kill"]); + mapper = new mmapper.Ptr(new sync.Mutex.Ptr(), new $Map(), mmap, munmap); init(); - init$1(); - init$2(); }; return $pkg; })(); -$packages["strconv"] = (function() { - var $pkg = {}, math = $packages["math"], errors = $packages["errors"], utf8 = $packages["unicode/utf8"], NumError, decimal, leftCheat, extFloat, floatInfo, decimalSlice, optimize, powtab, float64pow10, float32pow10, leftcheats, smallPowersOfTen, powersOfTen, uint64pow10, float32info, float64info, isPrint16, isNotPrint16, isPrint32, isNotPrint32, shifts, ParseBool, FormatBool, equalIgnoreCase, special, readFloat, atof64exact, atof32exact, atof32, atof64, ParseFloat, syntaxError, rangeError, cutoff64, ParseUint, ParseInt, Atoi, digitZero, trim, rightShift, prefixIsLessThan, leftShift, shouldRoundUp, frexp10Many, adjustLastDigitFixed, adjustLastDigit, FormatFloat, AppendFloat, genericFtoa, bigFtoa, formatDigits, roundShortest, fmtE, fmtF, fmtB, max, FormatUint, FormatInt, Itoa, AppendInt, AppendUint, formatBits, quoteWith, Quote, QuoteToASCII, QuoteRune, AppendQuoteRune, QuoteRuneToASCII, AppendQuoteRuneToASCII, CanBackquote, unhex, UnquoteChar, Unquote, contains, bsearch16, bsearch32, IsPrint; - NumError = $pkg.NumError = $newType(0, "Struct", "strconv.NumError", "NumError", "strconv", function(Func_, Num_, Err_) { - this.$val = this; - this.Func = Func_ !== undefined ? Func_ : ""; - this.Num = Num_ !== undefined ? Num_ : ""; - this.Err = Err_ !== undefined ? Err_ : $ifaceNil; +$packages["time"] = (function() { + var $pkg = {}, js = $packages["github.com/gopherjs/gopherjs/js"], strings = $packages["strings"], errors = $packages["errors"], syscall = $packages["syscall"], sync = $packages["sync"], runtime = $packages["runtime"], runtimeTimer, ParseError, Timer, Time, Month, Weekday, Duration, Location, zone, zoneTrans, std0x, longDayNames, shortDayNames, shortMonthNames, longMonthNames, atoiError, errBad, errLeadingInt, unitMap, months, days, daysBefore, utcLoc, localLoc, localOnce, zoneinfo, badData, zoneDirs, _map, _key, _tuple, initLocal, runtimeNano, now, startTimer, stopTimer, startsWithLowerCase, nextStdChunk, match, lookup, appendUint, atoi, formatNano, quote, isDigit, getnum, cutspace, skip, Parse, parse, parseTimeZone, parseGMT, parseNanoseconds, leadingInt, ParseDuration, when, AfterFunc, goFunc, absWeekday, absClock, fmtFrac, fmtInt, absDate, Now, Unix, isLeap, norm, Date, div, FixedZone; + runtimeTimer = $pkg.runtimeTimer = $newType(0, "Struct", "time.runtimeTimer", "runtimeTimer", "time", function(i_, when_, period_, f_, arg_, timeout_, active_) { + this.$val = this; + this.i = i_ !== undefined ? i_ : 0; + this.when = when_ !== undefined ? when_ : new $Int64(0, 0); + this.period = period_ !== undefined ? period_ : new $Int64(0, 0); + this.f = f_ !== undefined ? f_ : $throwNilPointerError; + this.arg = arg_ !== undefined ? arg_ : $ifaceNil; + this.timeout = timeout_ !== undefined ? timeout_ : $ifaceNil; + this.active = active_ !== undefined ? active_ : false; }); - decimal = $pkg.decimal = $newType(0, "Struct", "strconv.decimal", "decimal", "strconv", function(d_, nd_, dp_, neg_, trunc_) { + ParseError = $pkg.ParseError = $newType(0, "Struct", "time.ParseError", "ParseError", "time", function(Layout_, Value_, LayoutElem_, ValueElem_, Message_) { this.$val = this; - this.d = d_ !== undefined ? d_ : ($arrayType($Uint8, 800)).zero(); - this.nd = nd_ !== undefined ? nd_ : 0; - this.dp = dp_ !== undefined ? dp_ : 0; - this.neg = neg_ !== undefined ? neg_ : false; - this.trunc = trunc_ !== undefined ? trunc_ : false; + this.Layout = Layout_ !== undefined ? Layout_ : ""; + this.Value = Value_ !== undefined ? Value_ : ""; + this.LayoutElem = LayoutElem_ !== undefined ? LayoutElem_ : ""; + this.ValueElem = ValueElem_ !== undefined ? ValueElem_ : ""; + this.Message = Message_ !== undefined ? Message_ : ""; }); - leftCheat = $pkg.leftCheat = $newType(0, "Struct", "strconv.leftCheat", "leftCheat", "strconv", function(delta_, cutoff_) { + Timer = $pkg.Timer = $newType(0, "Struct", "time.Timer", "Timer", "time", function(C_, r_) { this.$val = this; - this.delta = delta_ !== undefined ? delta_ : 0; - this.cutoff = cutoff_ !== undefined ? cutoff_ : ""; + this.C = C_ !== undefined ? C_ : ($chanType(Time, false, true)).nil; + this.r = r_ !== undefined ? r_ : new runtimeTimer.Ptr(); }); - extFloat = $pkg.extFloat = $newType(0, "Struct", "strconv.extFloat", "extFloat", "strconv", function(mant_, exp_, neg_) { + Time = $pkg.Time = $newType(0, "Struct", "time.Time", "Time", "time", function(sec_, nsec_, loc_) { this.$val = this; - this.mant = mant_ !== undefined ? mant_ : new $Uint64(0, 0); - this.exp = exp_ !== undefined ? exp_ : 0; - this.neg = neg_ !== undefined ? neg_ : false; + this.sec = sec_ !== undefined ? sec_ : new $Int64(0, 0); + this.nsec = nsec_ !== undefined ? nsec_ : 0; + this.loc = loc_ !== undefined ? loc_ : ($ptrType(Location)).nil; }); - floatInfo = $pkg.floatInfo = $newType(0, "Struct", "strconv.floatInfo", "floatInfo", "strconv", function(mantbits_, expbits_, bias_) { + Month = $pkg.Month = $newType(4, "Int", "time.Month", "Month", "time", null); + Weekday = $pkg.Weekday = $newType(4, "Int", "time.Weekday", "Weekday", "time", null); + Duration = $pkg.Duration = $newType(8, "Int64", "time.Duration", "Duration", "time", null); + Location = $pkg.Location = $newType(0, "Struct", "time.Location", "Location", "time", function(name_, zone_, tx_, cacheStart_, cacheEnd_, cacheZone_) { this.$val = this; - this.mantbits = mantbits_ !== undefined ? mantbits_ : 0; - this.expbits = expbits_ !== undefined ? expbits_ : 0; - this.bias = bias_ !== undefined ? bias_ : 0; + this.name = name_ !== undefined ? name_ : ""; + this.zone = zone_ !== undefined ? zone_ : ($sliceType(zone)).nil; + this.tx = tx_ !== undefined ? tx_ : ($sliceType(zoneTrans)).nil; + this.cacheStart = cacheStart_ !== undefined ? cacheStart_ : new $Int64(0, 0); + this.cacheEnd = cacheEnd_ !== undefined ? cacheEnd_ : new $Int64(0, 0); + this.cacheZone = cacheZone_ !== undefined ? cacheZone_ : ($ptrType(zone)).nil; }); - decimalSlice = $pkg.decimalSlice = $newType(0, "Struct", "strconv.decimalSlice", "decimalSlice", "strconv", function(d_, nd_, dp_, neg_) { + zone = $pkg.zone = $newType(0, "Struct", "time.zone", "zone", "time", function(name_, offset_, isDST_) { this.$val = this; - this.d = d_ !== undefined ? d_ : ($sliceType($Uint8)).nil; - this.nd = nd_ !== undefined ? nd_ : 0; - this.dp = dp_ !== undefined ? dp_ : 0; - this.neg = neg_ !== undefined ? neg_ : false; + this.name = name_ !== undefined ? name_ : ""; + this.offset = offset_ !== undefined ? offset_ : 0; + this.isDST = isDST_ !== undefined ? isDST_ : false; }); - ParseBool = $pkg.ParseBool = function(str) { - var value = false, err = $ifaceNil, _ref, _tmp, _tmp$1, _tmp$2, _tmp$3, _tmp$4, _tmp$5; - _ref = str; - if (_ref === "1" || _ref === "t" || _ref === "T" || _ref === "true" || _ref === "TRUE" || _ref === "True") { - _tmp = true; _tmp$1 = $ifaceNil; value = _tmp; err = _tmp$1; - return [value, err]; - } else if (_ref === "0" || _ref === "f" || _ref === "F" || _ref === "false" || _ref === "FALSE" || _ref === "False") { - _tmp$2 = false; _tmp$3 = $ifaceNil; value = _tmp$2; err = _tmp$3; - return [value, err]; + zoneTrans = $pkg.zoneTrans = $newType(0, "Struct", "time.zoneTrans", "zoneTrans", "time", function(when_, index_, isstd_, isutc_) { + this.$val = this; + this.when = when_ !== undefined ? when_ : new $Int64(0, 0); + this.index = index_ !== undefined ? index_ : 0; + this.isstd = isstd_ !== undefined ? isstd_ : false; + this.isutc = isutc_ !== undefined ? isutc_ : false; + }); + initLocal = function() { + var d, s, i, j, x; + d = new ($global.Date)(); + s = $internalize(d, $String); + i = strings.IndexByte(s, 40); + j = strings.IndexByte(s, 41); + if ((i === -1) || (j === -1)) { + localLoc.name = "UTC"; + return; } - _tmp$4 = false; _tmp$5 = syntaxError("ParseBool", str); value = _tmp$4; err = _tmp$5; - return [value, err]; + localLoc.name = s.substring((i + 1 >> 0), j); + localLoc.zone = new ($sliceType(zone))([new zone.Ptr(localLoc.name, (x = $parseInt(d.getTimezoneOffset()) >> 0, (((x >>> 16 << 16) * -60 >> 0) + (x << 16 >>> 16) * -60) >> 0), false)]); }; - FormatBool = $pkg.FormatBool = function(b) { - if (b) { - return "true"; + runtimeNano = function() { + return $mul64($internalize(new ($global.Date)().getTime(), $Int64), new $Int64(0, 1000000)); + }; + now = function() { + var sec = new $Int64(0, 0), nsec = 0, n, _tmp, _tmp$1, x; + n = runtimeNano(); + _tmp = $div64(n, new $Int64(0, 1000000000), false); _tmp$1 = ((x = $div64(n, new $Int64(0, 1000000000), true), x.$low + ((x.$high >> 31) * 4294967296)) >> 0); sec = _tmp; nsec = _tmp$1; + return [sec, nsec]; + }; + startTimer = function(t) { + var x, x$1, diff; + t.active = true; + diff = $div64(((x = t.when, x$1 = runtimeNano(), new $Int64(x.$high - x$1.$high, x.$low - x$1.$low))), new $Int64(0, 1000000), false); + if ((diff.$high > 0 || (diff.$high === 0 && diff.$low > 2147483647))) { + return; } - return "false"; + if ((diff.$high < 0 || (diff.$high === 0 && diff.$low < 0))) { + diff = new $Int64(0, 0); + } + t.timeout = $global.setTimeout($externalize((function() { + var x$2, x$3, x$4; + t.active = false; + t.f(runtimeNano(), t.arg); + if (!((x$2 = t.period, (x$2.$high === 0 && x$2.$low === 0)))) { + t.when = (x$3 = t.when, x$4 = t.period, new $Int64(x$3.$high + x$4.$high, x$3.$low + x$4.$low)); + startTimer(t); + } + }), ($funcType([], [], false))), $externalize(diff, $Int64)); }; - equalIgnoreCase = function(s1, s2) { - var i, c1, c2; - if (!((s1.length === s2.length))) { + stopTimer = function(t) { + var wasActive; + $global.clearTimeout(t.timeout); + wasActive = t.active; + t.active = false; + return wasActive; + }; + startsWithLowerCase = function(str) { + var c; + if (str.length === 0) { return false; } + c = str.charCodeAt(0); + return 97 <= c && c <= 122; + }; + nextStdChunk = function(layout) { + var prefix = "", std = 0, suffix = "", i, c, _ref, _tmp, _tmp$1, _tmp$2, _tmp$3, _tmp$4, _tmp$5, _tmp$6, _tmp$7, _tmp$8, _tmp$9, _tmp$10, _tmp$11, _tmp$12, _tmp$13, _tmp$14, _tmp$15, _tmp$16, x, _tmp$17, _tmp$18, _tmp$19, _tmp$20, _tmp$21, _tmp$22, _tmp$23, _tmp$24, _tmp$25, _tmp$26, _tmp$27, _tmp$28, _tmp$29, _tmp$30, _tmp$31, _tmp$32, _tmp$33, _tmp$34, _tmp$35, _tmp$36, _tmp$37, _tmp$38, _tmp$39, _tmp$40, _tmp$41, _tmp$42, _tmp$43, _tmp$44, _tmp$45, _tmp$46, _tmp$47, _tmp$48, _tmp$49, _tmp$50, _tmp$51, _tmp$52, _tmp$53, _tmp$54, _tmp$55, _tmp$56, _tmp$57, _tmp$58, _tmp$59, _tmp$60, _tmp$61, _tmp$62, _tmp$63, _tmp$64, _tmp$65, _tmp$66, _tmp$67, _tmp$68, _tmp$69, _tmp$70, _tmp$71, _tmp$72, _tmp$73, _tmp$74, ch, j, std$1, _tmp$75, _tmp$76, _tmp$77, _tmp$78, _tmp$79, _tmp$80; + i = 0; + while (i < layout.length) { + c = (layout.charCodeAt(i) >> 0); + _ref = c; + if (_ref === 74) { + if (layout.length >= (i + 3 >> 0) && layout.substring(i, (i + 3 >> 0)) === "Jan") { + if (layout.length >= (i + 7 >> 0) && layout.substring(i, (i + 7 >> 0)) === "January") { + _tmp = layout.substring(0, i); _tmp$1 = 257; _tmp$2 = layout.substring((i + 7 >> 0)); prefix = _tmp; std = _tmp$1; suffix = _tmp$2; + return [prefix, std, suffix]; + } + if (!startsWithLowerCase(layout.substring((i + 3 >> 0)))) { + _tmp$3 = layout.substring(0, i); _tmp$4 = 258; _tmp$5 = layout.substring((i + 3 >> 0)); prefix = _tmp$3; std = _tmp$4; suffix = _tmp$5; + return [prefix, std, suffix]; + } + } + } else if (_ref === 77) { + if (layout.length >= (i + 3 >> 0)) { + if (layout.substring(i, (i + 3 >> 0)) === "Mon") { + if (layout.length >= (i + 6 >> 0) && layout.substring(i, (i + 6 >> 0)) === "Monday") { + _tmp$6 = layout.substring(0, i); _tmp$7 = 261; _tmp$8 = layout.substring((i + 6 >> 0)); prefix = _tmp$6; std = _tmp$7; suffix = _tmp$8; + return [prefix, std, suffix]; + } + if (!startsWithLowerCase(layout.substring((i + 3 >> 0)))) { + _tmp$9 = layout.substring(0, i); _tmp$10 = 262; _tmp$11 = layout.substring((i + 3 >> 0)); prefix = _tmp$9; std = _tmp$10; suffix = _tmp$11; + return [prefix, std, suffix]; + } + } + if (layout.substring(i, (i + 3 >> 0)) === "MST") { + _tmp$12 = layout.substring(0, i); _tmp$13 = 21; _tmp$14 = layout.substring((i + 3 >> 0)); prefix = _tmp$12; std = _tmp$13; suffix = _tmp$14; + return [prefix, std, suffix]; + } + } + } else if (_ref === 48) { + if (layout.length >= (i + 2 >> 0) && 49 <= layout.charCodeAt((i + 1 >> 0)) && layout.charCodeAt((i + 1 >> 0)) <= 54) { + _tmp$15 = layout.substring(0, i); _tmp$16 = (x = layout.charCodeAt((i + 1 >> 0)) - 49 << 24 >>> 24, ((x < 0 || x >= std0x.length) ? $throwRuntimeError("index out of range") : std0x[x])); _tmp$17 = layout.substring((i + 2 >> 0)); prefix = _tmp$15; std = _tmp$16; suffix = _tmp$17; + return [prefix, std, suffix]; + } + } else if (_ref === 49) { + if (layout.length >= (i + 2 >> 0) && (layout.charCodeAt((i + 1 >> 0)) === 53)) { + _tmp$18 = layout.substring(0, i); _tmp$19 = 522; _tmp$20 = layout.substring((i + 2 >> 0)); prefix = _tmp$18; std = _tmp$19; suffix = _tmp$20; + return [prefix, std, suffix]; + } + _tmp$21 = layout.substring(0, i); _tmp$22 = 259; _tmp$23 = layout.substring((i + 1 >> 0)); prefix = _tmp$21; std = _tmp$22; suffix = _tmp$23; + return [prefix, std, suffix]; + } else if (_ref === 50) { + if (layout.length >= (i + 4 >> 0) && layout.substring(i, (i + 4 >> 0)) === "2006") { + _tmp$24 = layout.substring(0, i); _tmp$25 = 273; _tmp$26 = layout.substring((i + 4 >> 0)); prefix = _tmp$24; std = _tmp$25; suffix = _tmp$26; + return [prefix, std, suffix]; + } + _tmp$27 = layout.substring(0, i); _tmp$28 = 263; _tmp$29 = layout.substring((i + 1 >> 0)); prefix = _tmp$27; std = _tmp$28; suffix = _tmp$29; + return [prefix, std, suffix]; + } else if (_ref === 95) { + if (layout.length >= (i + 2 >> 0) && (layout.charCodeAt((i + 1 >> 0)) === 50)) { + _tmp$30 = layout.substring(0, i); _tmp$31 = 264; _tmp$32 = layout.substring((i + 2 >> 0)); prefix = _tmp$30; std = _tmp$31; suffix = _tmp$32; + return [prefix, std, suffix]; + } + } else if (_ref === 51) { + _tmp$33 = layout.substring(0, i); _tmp$34 = 523; _tmp$35 = layout.substring((i + 1 >> 0)); prefix = _tmp$33; std = _tmp$34; suffix = _tmp$35; + return [prefix, std, suffix]; + } else if (_ref === 52) { + _tmp$36 = layout.substring(0, i); _tmp$37 = 525; _tmp$38 = layout.substring((i + 1 >> 0)); prefix = _tmp$36; std = _tmp$37; suffix = _tmp$38; + return [prefix, std, suffix]; + } else if (_ref === 53) { + _tmp$39 = layout.substring(0, i); _tmp$40 = 527; _tmp$41 = layout.substring((i + 1 >> 0)); prefix = _tmp$39; std = _tmp$40; suffix = _tmp$41; + return [prefix, std, suffix]; + } else if (_ref === 80) { + if (layout.length >= (i + 2 >> 0) && (layout.charCodeAt((i + 1 >> 0)) === 77)) { + _tmp$42 = layout.substring(0, i); _tmp$43 = 531; _tmp$44 = layout.substring((i + 2 >> 0)); prefix = _tmp$42; std = _tmp$43; suffix = _tmp$44; + return [prefix, std, suffix]; + } + } else if (_ref === 112) { + if (layout.length >= (i + 2 >> 0) && (layout.charCodeAt((i + 1 >> 0)) === 109)) { + _tmp$45 = layout.substring(0, i); _tmp$46 = 532; _tmp$47 = layout.substring((i + 2 >> 0)); prefix = _tmp$45; std = _tmp$46; suffix = _tmp$47; + return [prefix, std, suffix]; + } + } else if (_ref === 45) { + if (layout.length >= (i + 7 >> 0) && layout.substring(i, (i + 7 >> 0)) === "-070000") { + _tmp$48 = layout.substring(0, i); _tmp$49 = 27; _tmp$50 = layout.substring((i + 7 >> 0)); prefix = _tmp$48; std = _tmp$49; suffix = _tmp$50; + return [prefix, std, suffix]; + } + if (layout.length >= (i + 9 >> 0) && layout.substring(i, (i + 9 >> 0)) === "-07:00:00") { + _tmp$51 = layout.substring(0, i); _tmp$52 = 30; _tmp$53 = layout.substring((i + 9 >> 0)); prefix = _tmp$51; std = _tmp$52; suffix = _tmp$53; + return [prefix, std, suffix]; + } + if (layout.length >= (i + 5 >> 0) && layout.substring(i, (i + 5 >> 0)) === "-0700") { + _tmp$54 = layout.substring(0, i); _tmp$55 = 26; _tmp$56 = layout.substring((i + 5 >> 0)); prefix = _tmp$54; std = _tmp$55; suffix = _tmp$56; + return [prefix, std, suffix]; + } + if (layout.length >= (i + 6 >> 0) && layout.substring(i, (i + 6 >> 0)) === "-07:00") { + _tmp$57 = layout.substring(0, i); _tmp$58 = 29; _tmp$59 = layout.substring((i + 6 >> 0)); prefix = _tmp$57; std = _tmp$58; suffix = _tmp$59; + return [prefix, std, suffix]; + } + if (layout.length >= (i + 3 >> 0) && layout.substring(i, (i + 3 >> 0)) === "-07") { + _tmp$60 = layout.substring(0, i); _tmp$61 = 28; _tmp$62 = layout.substring((i + 3 >> 0)); prefix = _tmp$60; std = _tmp$61; suffix = _tmp$62; + return [prefix, std, suffix]; + } + } else if (_ref === 90) { + if (layout.length >= (i + 7 >> 0) && layout.substring(i, (i + 7 >> 0)) === "Z070000") { + _tmp$63 = layout.substring(0, i); _tmp$64 = 23; _tmp$65 = layout.substring((i + 7 >> 0)); prefix = _tmp$63; std = _tmp$64; suffix = _tmp$65; + return [prefix, std, suffix]; + } + if (layout.length >= (i + 9 >> 0) && layout.substring(i, (i + 9 >> 0)) === "Z07:00:00") { + _tmp$66 = layout.substring(0, i); _tmp$67 = 25; _tmp$68 = layout.substring((i + 9 >> 0)); prefix = _tmp$66; std = _tmp$67; suffix = _tmp$68; + return [prefix, std, suffix]; + } + if (layout.length >= (i + 5 >> 0) && layout.substring(i, (i + 5 >> 0)) === "Z0700") { + _tmp$69 = layout.substring(0, i); _tmp$70 = 22; _tmp$71 = layout.substring((i + 5 >> 0)); prefix = _tmp$69; std = _tmp$70; suffix = _tmp$71; + return [prefix, std, suffix]; + } + if (layout.length >= (i + 6 >> 0) && layout.substring(i, (i + 6 >> 0)) === "Z07:00") { + _tmp$72 = layout.substring(0, i); _tmp$73 = 24; _tmp$74 = layout.substring((i + 6 >> 0)); prefix = _tmp$72; std = _tmp$73; suffix = _tmp$74; + return [prefix, std, suffix]; + } + } else if (_ref === 46) { + if ((i + 1 >> 0) < layout.length && ((layout.charCodeAt((i + 1 >> 0)) === 48) || (layout.charCodeAt((i + 1 >> 0)) === 57))) { + ch = layout.charCodeAt((i + 1 >> 0)); + j = i + 1 >> 0; + while (j < layout.length && (layout.charCodeAt(j) === ch)) { + j = j + (1) >> 0; + } + if (!isDigit(layout, j)) { + std$1 = 31; + if (layout.charCodeAt((i + 1 >> 0)) === 57) { + std$1 = 32; + } + std$1 = std$1 | ((((j - ((i + 1 >> 0)) >> 0)) << 16 >> 0)); + _tmp$75 = layout.substring(0, i); _tmp$76 = std$1; _tmp$77 = layout.substring(j); prefix = _tmp$75; std = _tmp$76; suffix = _tmp$77; + return [prefix, std, suffix]; + } + } + } + i = i + (1) >> 0; + } + _tmp$78 = layout; _tmp$79 = 0; _tmp$80 = ""; prefix = _tmp$78; std = _tmp$79; suffix = _tmp$80; + return [prefix, std, suffix]; + }; + match = function(s1, s2) { + var i, c1, c2; i = 0; while (i < s1.length) { c1 = s1.charCodeAt(i); - if (65 <= c1 && c1 <= 90) { - c1 = c1 + (32) << 24 >>> 24; - } c2 = s2.charCodeAt(i); - if (65 <= c2 && c2 <= 90) { - c2 = c2 + (32) << 24 >>> 24; - } if (!((c1 === c2))) { - return false; + c1 = (c1 | (32)) >>> 0; + c2 = (c2 | (32)) >>> 0; + if (!((c1 === c2)) || c1 < 97 || c1 > 122) { + return false; + } } i = i + (1) >> 0; } return true; }; - special = function(s) { - var f = 0, ok = false, _ref, _tmp, _tmp$1, _tmp$2, _tmp$3, _tmp$4, _tmp$5, _tmp$6, _tmp$7; - if (s.length === 0) { - return [f, ok]; - } - _ref = s.charCodeAt(0); - if (_ref === 43) { - if (equalIgnoreCase(s, "+inf") || equalIgnoreCase(s, "+infinity")) { - _tmp = math.Inf(1); _tmp$1 = true; f = _tmp; ok = _tmp$1; - return [f, ok]; - } - } else if (_ref === 45) { - if (equalIgnoreCase(s, "-inf") || equalIgnoreCase(s, "-infinity")) { - _tmp$2 = math.Inf(-1); _tmp$3 = true; f = _tmp$2; ok = _tmp$3; - return [f, ok]; - } - } else if (_ref === 110 || _ref === 78) { - if (equalIgnoreCase(s, "nan")) { - _tmp$4 = math.NaN(); _tmp$5 = true; f = _tmp$4; ok = _tmp$5; - return [f, ok]; - } - } else if (_ref === 105 || _ref === 73) { - if (equalIgnoreCase(s, "inf") || equalIgnoreCase(s, "infinity")) { - _tmp$6 = math.Inf(1); _tmp$7 = true; f = _tmp$6; ok = _tmp$7; - return [f, ok]; + lookup = function(tab, val) { + var _ref, _i, i, v; + _ref = tab; + _i = 0; + while (_i < _ref.$length) { + i = _i; + v = ((_i < 0 || _i >= _ref.$length) ? $throwRuntimeError("index out of range") : _ref.$array[_ref.$offset + _i]); + if (val.length >= v.length && match(val.substring(0, v.length), v)) { + return [i, val.substring(v.length), $ifaceNil]; } - } else { - return [f, ok]; + _i++; } - return [f, ok]; + return [-1, val, errBad]; }; - decimal.Ptr.prototype.set = function(s) { - var ok = false, b, i, sawdot, sawdigits, x, x$1, esign, e; - b = this; - i = 0; - b.neg = false; - b.trunc = false; - if (i >= s.length) { - return ok; - } - if (s.charCodeAt(i) === 43) { - i = i + (1) >> 0; - } else if (s.charCodeAt(i) === 45) { - b.neg = true; - i = i + (1) >> 0; - } - sawdot = false; - sawdigits = false; - while (i < s.length) { - if (s.charCodeAt(i) === 46) { - if (sawdot) { - return ok; - } - sawdot = true; - b.dp = b.nd; - i = i + (1) >> 0; - continue; - } else if (48 <= s.charCodeAt(i) && s.charCodeAt(i) <= 57) { - sawdigits = true; - if ((s.charCodeAt(i) === 48) && (b.nd === 0)) { - b.dp = b.dp - (1) >> 0; - i = i + (1) >> 0; - continue; - } - if (b.nd < 800) { - (x = b.d, x$1 = b.nd, (x$1 < 0 || x$1 >= x.length) ? $throwRuntimeError("index out of range") : x[x$1] = s.charCodeAt(i)); - b.nd = b.nd + (1) >> 0; - } else if (!((s.charCodeAt(i) === 48))) { - b.trunc = true; - } - i = i + (1) >> 0; - continue; + appendUint = function(b, x, pad) { + var _q, _r, buf, n, _r$1, _q$1; + if (x < 10) { + if (!((pad === 0))) { + b = $append(b, pad); } - break; - } - if (!sawdigits) { - return ok; + return $append(b, ((48 + x >>> 0) << 24 >>> 24)); } - if (!sawdot) { - b.dp = b.nd; + if (x < 100) { + b = $append(b, ((48 + (_q = x / 10, (_q === _q && _q !== 1/0 && _q !== -1/0) ? _q >>> 0 : $throwRuntimeError("integer divide by zero")) >>> 0) << 24 >>> 24)); + b = $append(b, ((48 + (_r = x % 10, _r === _r ? _r : $throwRuntimeError("integer divide by zero")) >>> 0) << 24 >>> 24)); + return b; } - if (i < s.length && ((s.charCodeAt(i) === 101) || (s.charCodeAt(i) === 69))) { - i = i + (1) >> 0; - if (i >= s.length) { - return ok; - } - esign = 1; - if (s.charCodeAt(i) === 43) { - i = i + (1) >> 0; - } else if (s.charCodeAt(i) === 45) { - i = i + (1) >> 0; - esign = -1; - } - if (i >= s.length || s.charCodeAt(i) < 48 || s.charCodeAt(i) > 57) { - return ok; - } - e = 0; - while (i < s.length && 48 <= s.charCodeAt(i) && s.charCodeAt(i) <= 57) { - if (e < 10000) { - e = (((((e >>> 16 << 16) * 10 >> 0) + (e << 16 >>> 16) * 10) >> 0) + (s.charCodeAt(i) >> 0) >> 0) - 48 >> 0; - } - i = i + (1) >> 0; - } - b.dp = b.dp + (((((e >>> 16 << 16) * esign >> 0) + (e << 16 >>> 16) * esign) >> 0)) >> 0; + buf = ($arrayType($Uint8, 32)).zero(); $copy(buf, ($arrayType($Uint8, 32)).zero(), ($arrayType($Uint8, 32))); + n = 32; + if (x === 0) { + return $append(b, 48); } - if (!((i === s.length))) { - return ok; + while (x >= 10) { + n = n - (1) >> 0; + (n < 0 || n >= buf.length) ? $throwRuntimeError("index out of range") : buf[n] = (((_r$1 = x % 10, _r$1 === _r$1 ? _r$1 : $throwRuntimeError("integer divide by zero")) + 48 >>> 0) << 24 >>> 24); + x = (_q$1 = x / (10), (_q$1 === _q$1 && _q$1 !== 1/0 && _q$1 !== -1/0) ? _q$1 >>> 0 : $throwRuntimeError("integer divide by zero")); } - ok = true; - return ok; + n = n - (1) >> 0; + (n < 0 || n >= buf.length) ? $throwRuntimeError("index out of range") : buf[n] = ((x + 48 >>> 0) << 24 >>> 24); + return $appendSlice(b, $subslice(new ($sliceType($Uint8))(buf), n)); }; - decimal.prototype.set = function(s) { return this.$val.set(s); }; - readFloat = function(s) { - var mantissa = new $Uint64(0, 0), exp = 0, neg = false, trunc = false, ok = false, i, sawdot, sawdigits, nd, ndMant, dp, c, _ref, x, esign, e; - i = 0; - if (i >= s.length) { - return [mantissa, exp, neg, trunc, ok]; + atoi = function(s) { + var x = 0, err = $ifaceNil, neg, _tuple$1, q, rem, _tmp, _tmp$1, _tmp$2, _tmp$3; + neg = false; + if (!(s === "") && ((s.charCodeAt(0) === 45) || (s.charCodeAt(0) === 43))) { + neg = s.charCodeAt(0) === 45; + s = s.substring(1); } - if (s.charCodeAt(i) === 43) { - i = i + (1) >> 0; - } else if (s.charCodeAt(i) === 45) { - neg = true; - i = i + (1) >> 0; + _tuple$1 = leadingInt(s); q = _tuple$1[0]; rem = _tuple$1[1]; err = _tuple$1[2]; + x = ((q.$low + ((q.$high >> 31) * 4294967296)) >> 0); + if (!($interfaceIsEqual(err, $ifaceNil)) || !(rem === "")) { + _tmp = 0; _tmp$1 = atoiError; x = _tmp; err = _tmp$1; + return [x, err]; } - sawdot = false; - sawdigits = false; - nd = 0; - ndMant = 0; - dp = 0; - while (i < s.length) { - c = s.charCodeAt(i); - _ref = true; - if (_ref === (c === 46)) { - if (sawdot) { - return [mantissa, exp, neg, trunc, ok]; - } - sawdot = true; - dp = nd; - i = i + (1) >> 0; - continue; - } else if (_ref === 48 <= c && c <= 57) { - sawdigits = true; - if ((c === 48) && (nd === 0)) { - dp = dp - (1) >> 0; - i = i + (1) >> 0; - continue; - } - nd = nd + (1) >> 0; - if (ndMant < 19) { - mantissa = $mul64(mantissa, (new $Uint64(0, 10))); - mantissa = (x = new $Uint64(0, (c - 48 << 24 >>> 24)), new $Uint64(mantissa.$high + x.$high, mantissa.$low + x.$low)); - ndMant = ndMant + (1) >> 0; - } else if (!((s.charCodeAt(i) === 48))) { - trunc = true; - } - i = i + (1) >> 0; - continue; - } - break; + if (neg) { + x = -x; } - if (!sawdigits) { - return [mantissa, exp, neg, trunc, ok]; + _tmp$2 = x; _tmp$3 = $ifaceNil; x = _tmp$2; err = _tmp$3; + return [x, err]; + }; + formatNano = function(b, nanosec, n, trim) { + var u, buf, start, _r, _q, x; + u = nanosec; + buf = ($arrayType($Uint8, 9)).zero(); $copy(buf, ($arrayType($Uint8, 9)).zero(), ($arrayType($Uint8, 9))); + start = 9; + while (start > 0) { + start = start - (1) >> 0; + (start < 0 || start >= buf.length) ? $throwRuntimeError("index out of range") : buf[start] = (((_r = u % 10, _r === _r ? _r : $throwRuntimeError("integer divide by zero")) + 48 >>> 0) << 24 >>> 24); + u = (_q = u / (10), (_q === _q && _q !== 1/0 && _q !== -1/0) ? _q >>> 0 : $throwRuntimeError("integer divide by zero")); } - if (!sawdot) { - dp = nd; + if (n > 9) { + n = 9; } - if (i < s.length && ((s.charCodeAt(i) === 101) || (s.charCodeAt(i) === 69))) { - i = i + (1) >> 0; - if (i >= s.length) { - return [mantissa, exp, neg, trunc, ok]; + if (trim) { + while (n > 0 && ((x = n - 1 >> 0, ((x < 0 || x >= buf.length) ? $throwRuntimeError("index out of range") : buf[x])) === 48)) { + n = n - (1) >> 0; } - esign = 1; - if (s.charCodeAt(i) === 43) { - i = i + (1) >> 0; - } else if (s.charCodeAt(i) === 45) { - i = i + (1) >> 0; - esign = -1; - } - if (i >= s.length || s.charCodeAt(i) < 48 || s.charCodeAt(i) > 57) { - return [mantissa, exp, neg, trunc, ok]; - } - e = 0; - while (i < s.length && 48 <= s.charCodeAt(i) && s.charCodeAt(i) <= 57) { - if (e < 10000) { - e = (((((e >>> 16 << 16) * 10 >> 0) + (e << 16 >>> 16) * 10) >> 0) + (s.charCodeAt(i) >> 0) >> 0) - 48 >> 0; - } - i = i + (1) >> 0; + if (n === 0) { + return b; } - dp = dp + (((((e >>> 16 << 16) * esign >> 0) + (e << 16 >>> 16) * esign) >> 0)) >> 0; - } - if (!((i === s.length))) { - return [mantissa, exp, neg, trunc, ok]; } - exp = dp - ndMant >> 0; - ok = true; - return [mantissa, exp, neg, trunc, ok]; + b = $append(b, 46); + return $appendSlice(b, $subslice(new ($sliceType($Uint8))(buf), 0, n)); }; - decimal.Ptr.prototype.floatBits = function(flt) { - var $this = this, $args = arguments, b = new $Uint64(0, 0), overflow = false, $s = 0, d, exp, mant, n, x, n$1, x$1, n$2, y, x$2, y$1, x$3, x$4, y$2, x$5, x$6, bits, x$7, y$3, x$8, _tmp, _tmp$1; - /* */ while (true) { switch ($s) { case 0: - d = $this; - exp = 0; - mant = new $Uint64(0, 0); - /* if (d.nd === 0) { */ if (d.nd === 0) {} else { $s = 3; continue; } - mant = new $Uint64(0, 0); - exp = flt.bias; - /* goto out */ $s = 1; continue; - /* } */ case 3: - /* if (d.dp > 310) { */ if (d.dp > 310) {} else { $s = 4; continue; } - /* goto overflow */ $s = 2; continue; - /* } */ case 4: - /* if (d.dp < -330) { */ if (d.dp < -330) {} else { $s = 5; continue; } - mant = new $Uint64(0, 0); - exp = flt.bias; - /* goto out */ $s = 1; continue; - /* } */ case 5: - exp = 0; - while (d.dp > 0) { - n = 0; - if (d.dp >= powtab.$length) { - n = 27; - } else { - n = (x = d.dp, ((x < 0 || x >= powtab.$length) ? $throwRuntimeError("index out of range") : powtab.$array[powtab.$offset + x])); - } - d.Shift(-n); - exp = exp + (n) >> 0; - } - while (d.dp < 0 || (d.dp === 0) && d.d[0] < 53) { - n$1 = 0; - if (-d.dp >= powtab.$length) { - n$1 = 27; - } else { - n$1 = (x$1 = -d.dp, ((x$1 < 0 || x$1 >= powtab.$length) ? $throwRuntimeError("index out of range") : powtab.$array[powtab.$offset + x$1])); - } - d.Shift(n$1); - exp = exp - (n$1) >> 0; - } - exp = exp - (1) >> 0; - if (exp < (flt.bias + 1 >> 0)) { - n$2 = (flt.bias + 1 >> 0) - exp >> 0; - d.Shift(-n$2); - exp = exp + (n$2) >> 0; - } - /* if ((exp - flt.bias >> 0) >= (((y = flt.expbits, y < 32 ? (1 << y) : 0) >> 0) - 1 >> 0)) { */ if ((exp - flt.bias >> 0) >= (((y = flt.expbits, y < 32 ? (1 << y) : 0) >> 0) - 1 >> 0)) {} else { $s = 6; continue; } - /* goto overflow */ $s = 2; continue; - /* } */ case 6: - d.Shift(((1 + flt.mantbits >>> 0) >> 0)); - mant = d.RoundedInteger(); - /* if ((x$2 = $shiftLeft64(new $Uint64(0, 2), flt.mantbits), (mant.$high === x$2.$high && mant.$low === x$2.$low))) { */ if ((x$2 = $shiftLeft64(new $Uint64(0, 2), flt.mantbits), (mant.$high === x$2.$high && mant.$low === x$2.$low))) {} else { $s = 7; continue; } - mant = $shiftRightUint64(mant, (1)); - exp = exp + (1) >> 0; - /* if ((exp - flt.bias >> 0) >= (((y$1 = flt.expbits, y$1 < 32 ? (1 << y$1) : 0) >> 0) - 1 >> 0)) { */ if ((exp - flt.bias >> 0) >= (((y$1 = flt.expbits, y$1 < 32 ? (1 << y$1) : 0) >> 0) - 1 >> 0)) {} else { $s = 8; continue; } - /* goto overflow */ $s = 2; continue; - /* } */ case 8: - /* } */ case 7: - if ((x$3 = (x$4 = $shiftLeft64(new $Uint64(0, 1), flt.mantbits), new $Uint64(mant.$high & x$4.$high, (mant.$low & x$4.$low) >>> 0)), (x$3.$high === 0 && x$3.$low === 0))) { - exp = flt.bias; - } - /* goto out */ $s = 1; continue; - /* overflow: */ case 2: - mant = new $Uint64(0, 0); - exp = (((y$2 = flt.expbits, y$2 < 32 ? (1 << y$2) : 0) >> 0) - 1 >> 0) + flt.bias >> 0; - overflow = true; - /* out: */ case 1: - bits = (x$5 = (x$6 = $shiftLeft64(new $Uint64(0, 1), flt.mantbits), new $Uint64(x$6.$high - 0, x$6.$low - 1)), new $Uint64(mant.$high & x$5.$high, (mant.$low & x$5.$low) >>> 0)); - bits = (x$7 = $shiftLeft64(new $Uint64(0, (((exp - flt.bias >> 0)) & ((((y$3 = flt.expbits, y$3 < 32 ? (1 << y$3) : 0) >> 0) - 1 >> 0)))), flt.mantbits), new $Uint64(bits.$high | x$7.$high, (bits.$low | x$7.$low) >>> 0)); - if (d.neg) { - bits = (x$8 = $shiftLeft64($shiftLeft64(new $Uint64(0, 1), flt.mantbits), flt.expbits), new $Uint64(bits.$high | x$8.$high, (bits.$low | x$8.$low) >>> 0)); - } - _tmp = bits; _tmp$1 = overflow; b = _tmp; overflow = _tmp$1; - return [b, overflow]; - /* */ case -1: } return; } + Time.Ptr.prototype.String = function() { + var t; + t = new Time.Ptr(); $copy(t, this, Time); + return t.Format("2006-01-02 15:04:05.999999999 -0700 MST"); }; - decimal.prototype.floatBits = function(flt) { return this.$val.floatBits(flt); }; - atof64exact = function(mantissa, exp, neg) { - var f = 0, ok = false, x, _tmp, _tmp$1, x$1, _tmp$2, _tmp$3, _tmp$4, x$2, _tmp$5; - if (!((x = $shiftRightUint64(mantissa, float64info.mantbits), (x.$high === 0 && x.$low === 0)))) { - return [f, ok]; - } - f = $flatten64(mantissa); - if (neg) { - f = -f; + Time.prototype.String = function() { return this.$val.String(); }; + Time.Ptr.prototype.Format = function(layout) { + var t, _tuple$1, name, offset, abs, year, month, day, hour, min, sec, b, buf, max, _tuple$2, prefix, std, suffix, _tuple$3, _tuple$4, _ref, y, _r, y$1, m, s, _r$1, hr, _r$2, hr$1, _q, zone$1, absoffset, _q$1, _r$3, _r$4, _q$2, zone$2, _q$3, _r$5; + t = new Time.Ptr(); $copy(t, this, Time); + _tuple$1 = t.locabs(); name = _tuple$1[0]; offset = _tuple$1[1]; abs = _tuple$1[2]; + year = -1; + month = 0; + day = 0; + hour = -1; + min = 0; + sec = 0; + b = ($sliceType($Uint8)).nil; + buf = ($arrayType($Uint8, 64)).zero(); $copy(buf, ($arrayType($Uint8, 64)).zero(), ($arrayType($Uint8, 64))); + max = layout.length + 10 >> 0; + if (max <= 64) { + b = $subslice(new ($sliceType($Uint8))(buf), 0, 0); + } else { + b = ($sliceType($Uint8)).make(0, max); } - if (exp === 0) { - _tmp = f; _tmp$1 = true; f = _tmp; ok = _tmp$1; - return [f, ok]; - } else if (exp > 0 && exp <= 37) { - if (exp > 22) { - f = f * ((x$1 = exp - 22 >> 0, ((x$1 < 0 || x$1 >= float64pow10.$length) ? $throwRuntimeError("index out of range") : float64pow10.$array[float64pow10.$offset + x$1]))); - exp = 22; + while (!(layout === "")) { + _tuple$2 = nextStdChunk(layout); prefix = _tuple$2[0]; std = _tuple$2[1]; suffix = _tuple$2[2]; + if (!(prefix === "")) { + b = $appendSlice(b, new ($sliceType($Uint8))($stringToBytes(prefix))); } - if (f > 1e+15 || f < -1e+15) { - return [f, ok]; + if (std === 0) { + break; } - _tmp$2 = f * ((exp < 0 || exp >= float64pow10.$length) ? $throwRuntimeError("index out of range") : float64pow10.$array[float64pow10.$offset + exp]); _tmp$3 = true; f = _tmp$2; ok = _tmp$3; - return [f, ok]; - } else if (exp < 0 && exp >= -22) { - _tmp$4 = f / (x$2 = -exp, ((x$2 < 0 || x$2 >= float64pow10.$length) ? $throwRuntimeError("index out of range") : float64pow10.$array[float64pow10.$offset + x$2])); _tmp$5 = true; f = _tmp$4; ok = _tmp$5; - return [f, ok]; - } - return [f, ok]; - }; - atof32exact = function(mantissa, exp, neg) { - var f = 0, ok = false, x, _tmp, _tmp$1, x$1, _tmp$2, _tmp$3, _tmp$4, x$2, _tmp$5; - if (!((x = $shiftRightUint64(mantissa, float32info.mantbits), (x.$high === 0 && x.$low === 0)))) { - return [f, ok]; - } - f = $flatten64(mantissa); - if (neg) { - f = -f; - } - if (exp === 0) { - _tmp = f; _tmp$1 = true; f = _tmp; ok = _tmp$1; - return [f, ok]; - } else if (exp > 0 && exp <= 17) { - if (exp > 10) { - f = f * ((x$1 = exp - 10 >> 0, ((x$1 < 0 || x$1 >= float32pow10.$length) ? $throwRuntimeError("index out of range") : float32pow10.$array[float32pow10.$offset + x$1]))); - exp = 10; + layout = suffix; + if (year < 0 && !(((std & 256) === 0))) { + _tuple$3 = absDate(abs, true); year = _tuple$3[0]; month = _tuple$3[1]; day = _tuple$3[2]; } - if (f > 1e+07 || f < -1e+07) { - return [f, ok]; + if (hour < 0 && !(((std & 512) === 0))) { + _tuple$4 = absClock(abs); hour = _tuple$4[0]; min = _tuple$4[1]; sec = _tuple$4[2]; } - _tmp$2 = f * ((exp < 0 || exp >= float32pow10.$length) ? $throwRuntimeError("index out of range") : float32pow10.$array[float32pow10.$offset + exp]); _tmp$3 = true; f = _tmp$2; ok = _tmp$3; - return [f, ok]; - } else if (exp < 0 && exp >= -10) { - _tmp$4 = f / (x$2 = -exp, ((x$2 < 0 || x$2 >= float32pow10.$length) ? $throwRuntimeError("index out of range") : float32pow10.$array[float32pow10.$offset + x$2])); _tmp$5 = true; f = _tmp$4; ok = _tmp$5; - return [f, ok]; - } - return [f, ok]; - }; - atof32 = function(s) { - var f = 0, err = $ifaceNil, _tuple, val, ok, _tmp, _tmp$1, _tuple$1, mantissa, exp, neg, trunc, ok$1, _tuple$2, f$1, ok$2, _tmp$2, _tmp$3, ext, ok$3, _tuple$3, b, ovf, _tmp$4, _tmp$5, d, _tmp$6, _tmp$7, _tuple$4, b$1, ovf$1, _tmp$8, _tmp$9; - _tuple = special(s); val = _tuple[0]; ok = _tuple[1]; - if (ok) { - _tmp = val; _tmp$1 = $ifaceNil; f = _tmp; err = _tmp$1; - return [f, err]; - } - if (optimize) { - _tuple$1 = readFloat(s); mantissa = _tuple$1[0]; exp = _tuple$1[1]; neg = _tuple$1[2]; trunc = _tuple$1[3]; ok$1 = _tuple$1[4]; - if (ok$1) { - if (!trunc) { - _tuple$2 = atof32exact(mantissa, exp, neg); f$1 = _tuple$2[0]; ok$2 = _tuple$2[1]; - if (ok$2) { - _tmp$2 = f$1; _tmp$3 = $ifaceNil; f = _tmp$2; err = _tmp$3; - return [f, err]; - } + _ref = std & 65535; + switch (0) { default: if (_ref === 274) { + y = year; + if (y < 0) { + y = -y; } - ext = new extFloat.Ptr(); - ok$3 = ext.AssignDecimal(mantissa, exp, neg, trunc, float32info); - if (ok$3) { - _tuple$3 = ext.floatBits(float32info); b = _tuple$3[0]; ovf = _tuple$3[1]; - f = math.Float32frombits((b.$low >>> 0)); - if (ovf) { - err = rangeError("ParseFloat", s); - } - _tmp$4 = f; _tmp$5 = err; f = _tmp$4; err = _tmp$5; - return [f, err]; + b = appendUint(b, ((_r = y % 100, _r === _r ? _r : $throwRuntimeError("integer divide by zero")) >>> 0), 48); + } else if (_ref === 273) { + y$1 = year; + if (year <= -1000) { + b = $append(b, 45); + y$1 = -y$1; + } else if (year <= -100) { + b = $appendSlice(b, new ($sliceType($Uint8))($stringToBytes("-0"))); + y$1 = -y$1; + } else if (year <= -10) { + b = $appendSlice(b, new ($sliceType($Uint8))($stringToBytes("-00"))); + y$1 = -y$1; + } else if (year < 0) { + b = $appendSlice(b, new ($sliceType($Uint8))($stringToBytes("-000"))); + y$1 = -y$1; + } else if (year < 10) { + b = $appendSlice(b, new ($sliceType($Uint8))($stringToBytes("000"))); + } else if (year < 100) { + b = $appendSlice(b, new ($sliceType($Uint8))($stringToBytes("00"))); + } else if (year < 1000) { + b = $append(b, 48); } - } - } - d = new decimal.Ptr(); $copy(d, new decimal.Ptr(), decimal); - if (!d.set(s)) { - _tmp$6 = 0; _tmp$7 = syntaxError("ParseFloat", s); f = _tmp$6; err = _tmp$7; - return [f, err]; - } - _tuple$4 = d.floatBits(float32info); b$1 = _tuple$4[0]; ovf$1 = _tuple$4[1]; - f = math.Float32frombits((b$1.$low >>> 0)); - if (ovf$1) { - err = rangeError("ParseFloat", s); - } - _tmp$8 = f; _tmp$9 = err; f = _tmp$8; err = _tmp$9; - return [f, err]; - }; - atof64 = function(s) { - var f = 0, err = $ifaceNil, _tuple, val, ok, _tmp, _tmp$1, _tuple$1, mantissa, exp, neg, trunc, ok$1, _tuple$2, f$1, ok$2, _tmp$2, _tmp$3, ext, ok$3, _tuple$3, b, ovf, _tmp$4, _tmp$5, d, _tmp$6, _tmp$7, _tuple$4, b$1, ovf$1, _tmp$8, _tmp$9; - _tuple = special(s); val = _tuple[0]; ok = _tuple[1]; - if (ok) { - _tmp = val; _tmp$1 = $ifaceNil; f = _tmp; err = _tmp$1; - return [f, err]; - } - if (optimize) { - _tuple$1 = readFloat(s); mantissa = _tuple$1[0]; exp = _tuple$1[1]; neg = _tuple$1[2]; trunc = _tuple$1[3]; ok$1 = _tuple$1[4]; - if (ok$1) { - if (!trunc) { - _tuple$2 = atof64exact(mantissa, exp, neg); f$1 = _tuple$2[0]; ok$2 = _tuple$2[1]; - if (ok$2) { - _tmp$2 = f$1; _tmp$3 = $ifaceNil; f = _tmp$2; err = _tmp$3; - return [f, err]; - } + b = appendUint(b, (y$1 >>> 0), 0); + } else if (_ref === 258) { + b = $appendSlice(b, new ($sliceType($Uint8))($stringToBytes((new Month(month)).String().substring(0, 3)))); + } else if (_ref === 257) { + m = (new Month(month)).String(); + b = $appendSlice(b, new ($sliceType($Uint8))($stringToBytes(m))); + } else if (_ref === 259) { + b = appendUint(b, (month >>> 0), 0); + } else if (_ref === 260) { + b = appendUint(b, (month >>> 0), 48); + } else if (_ref === 262) { + b = $appendSlice(b, new ($sliceType($Uint8))($stringToBytes((new Weekday(absWeekday(abs))).String().substring(0, 3)))); + } else if (_ref === 261) { + s = (new Weekday(absWeekday(abs))).String(); + b = $appendSlice(b, new ($sliceType($Uint8))($stringToBytes(s))); + } else if (_ref === 263) { + b = appendUint(b, (day >>> 0), 0); + } else if (_ref === 264) { + b = appendUint(b, (day >>> 0), 32); + } else if (_ref === 265) { + b = appendUint(b, (day >>> 0), 48); + } else if (_ref === 522) { + b = appendUint(b, (hour >>> 0), 48); + } else if (_ref === 523) { + hr = (_r$1 = hour % 12, _r$1 === _r$1 ? _r$1 : $throwRuntimeError("integer divide by zero")); + if (hr === 0) { + hr = 12; } - ext = new extFloat.Ptr(); - ok$3 = ext.AssignDecimal(mantissa, exp, neg, trunc, float64info); - if (ok$3) { - _tuple$3 = ext.floatBits(float64info); b = _tuple$3[0]; ovf = _tuple$3[1]; - f = math.Float64frombits(b); - if (ovf) { - err = rangeError("ParseFloat", s); + b = appendUint(b, (hr >>> 0), 0); + } else if (_ref === 524) { + hr$1 = (_r$2 = hour % 12, _r$2 === _r$2 ? _r$2 : $throwRuntimeError("integer divide by zero")); + if (hr$1 === 0) { + hr$1 = 12; + } + b = appendUint(b, (hr$1 >>> 0), 48); + } else if (_ref === 525) { + b = appendUint(b, (min >>> 0), 0); + } else if (_ref === 526) { + b = appendUint(b, (min >>> 0), 48); + } else if (_ref === 527) { + b = appendUint(b, (sec >>> 0), 0); + } else if (_ref === 528) { + b = appendUint(b, (sec >>> 0), 48); + } else if (_ref === 531) { + if (hour >= 12) { + b = $appendSlice(b, new ($sliceType($Uint8))($stringToBytes("PM"))); + } else { + b = $appendSlice(b, new ($sliceType($Uint8))($stringToBytes("AM"))); + } + } else if (_ref === 532) { + if (hour >= 12) { + b = $appendSlice(b, new ($sliceType($Uint8))($stringToBytes("pm"))); + } else { + b = $appendSlice(b, new ($sliceType($Uint8))($stringToBytes("am"))); + } + } else if (_ref === 22 || _ref === 24 || _ref === 23 || _ref === 25 || _ref === 26 || _ref === 29 || _ref === 27 || _ref === 30) { + if ((offset === 0) && ((std === 22) || (std === 24) || (std === 23) || (std === 25))) { + b = $append(b, 90); + break; + } + zone$1 = (_q = offset / 60, (_q === _q && _q !== 1/0 && _q !== -1/0) ? _q >> 0 : $throwRuntimeError("integer divide by zero")); + absoffset = offset; + if (zone$1 < 0) { + b = $append(b, 45); + zone$1 = -zone$1; + absoffset = -absoffset; + } else { + b = $append(b, 43); + } + b = appendUint(b, ((_q$1 = zone$1 / 60, (_q$1 === _q$1 && _q$1 !== 1/0 && _q$1 !== -1/0) ? _q$1 >> 0 : $throwRuntimeError("integer divide by zero")) >>> 0), 48); + if ((std === 24) || (std === 29)) { + b = $append(b, 58); + } + b = appendUint(b, ((_r$3 = zone$1 % 60, _r$3 === _r$3 ? _r$3 : $throwRuntimeError("integer divide by zero")) >>> 0), 48); + if ((std === 23) || (std === 27) || (std === 30) || (std === 25)) { + if ((std === 30) || (std === 25)) { + b = $append(b, 58); } - _tmp$4 = f; _tmp$5 = err; f = _tmp$4; err = _tmp$5; - return [f, err]; + b = appendUint(b, ((_r$4 = absoffset % 60, _r$4 === _r$4 ? _r$4 : $throwRuntimeError("integer divide by zero")) >>> 0), 48); } - } - } - d = new decimal.Ptr(); $copy(d, new decimal.Ptr(), decimal); - if (!d.set(s)) { - _tmp$6 = 0; _tmp$7 = syntaxError("ParseFloat", s); f = _tmp$6; err = _tmp$7; - return [f, err]; - } - _tuple$4 = d.floatBits(float64info); b$1 = _tuple$4[0]; ovf$1 = _tuple$4[1]; - f = math.Float64frombits(b$1); - if (ovf$1) { - err = rangeError("ParseFloat", s); + } else if (_ref === 21) { + if (!(name === "")) { + b = $appendSlice(b, new ($sliceType($Uint8))($stringToBytes(name))); + break; + } + zone$2 = (_q$2 = offset / 60, (_q$2 === _q$2 && _q$2 !== 1/0 && _q$2 !== -1/0) ? _q$2 >> 0 : $throwRuntimeError("integer divide by zero")); + if (zone$2 < 0) { + b = $append(b, 45); + zone$2 = -zone$2; + } else { + b = $append(b, 43); + } + b = appendUint(b, ((_q$3 = zone$2 / 60, (_q$3 === _q$3 && _q$3 !== 1/0 && _q$3 !== -1/0) ? _q$3 >> 0 : $throwRuntimeError("integer divide by zero")) >>> 0), 48); + b = appendUint(b, ((_r$5 = zone$2 % 60, _r$5 === _r$5 ? _r$5 : $throwRuntimeError("integer divide by zero")) >>> 0), 48); + } else if (_ref === 31 || _ref === 32) { + b = formatNano(b, (t.Nanosecond() >>> 0), std >> 16 >> 0, (std & 65535) === 32); + } } } - _tmp$8 = f; _tmp$9 = err; f = _tmp$8; err = _tmp$9; - return [f, err]; + return $bytesToString(b); }; - ParseFloat = $pkg.ParseFloat = function(s, bitSize) { - var f = 0, err = $ifaceNil, _tuple, f1, err1, _tmp, _tmp$1, _tuple$1, f1$1, err1$1, _tmp$2, _tmp$3; - if (bitSize === 32) { - _tuple = atof32(s); f1 = _tuple[0]; err1 = _tuple[1]; - _tmp = $coerceFloat32(f1); _tmp$1 = err1; f = _tmp; err = _tmp$1; - return [f, err]; - } - _tuple$1 = atof64(s); f1$1 = _tuple$1[0]; err1$1 = _tuple$1[1]; - _tmp$2 = f1$1; _tmp$3 = err1$1; f = _tmp$2; err = _tmp$3; - return [f, err]; + Time.prototype.Format = function(layout) { return this.$val.Format(layout); }; + quote = function(s) { + return "\"" + s + "\""; }; - NumError.Ptr.prototype.Error = function() { + ParseError.Ptr.prototype.Error = function() { var e; e = this; - return "strconv." + e.Func + ": " + "parsing " + Quote(e.Num) + ": " + e.Err.Error(); - }; - NumError.prototype.Error = function() { return this.$val.Error(); }; - syntaxError = function(fn, str) { - return new NumError.Ptr(fn, str, $pkg.ErrSyntax); + if (e.Message === "") { + return "parsing time " + quote(e.Value) + " as " + quote(e.Layout) + ": cannot parse " + quote(e.ValueElem) + " as " + quote(e.LayoutElem); + } + return "parsing time " + quote(e.Value) + e.Message; }; - rangeError = function(fn, str) { - return new NumError.Ptr(fn, str, $pkg.ErrRange); + ParseError.prototype.Error = function() { return this.$val.Error(); }; + isDigit = function(s, i) { + var c; + if (s.length <= i) { + return false; + } + c = s.charCodeAt(i); + return 48 <= c && c <= 57; }; - cutoff64 = function(base) { + getnum = function(s, fixed) { var x; - if (base < 2) { - return new $Uint64(0, 0); + if (!isDigit(s, 0)) { + return [0, s, errBad]; } - return (x = $div64(new $Uint64(4294967295, 4294967295), new $Uint64(0, base), false), new $Uint64(x.$high + 0, x.$low + 1)); - }; - ParseUint = $pkg.ParseUint = function(s, base, bitSize) { - var $this = this, $args = arguments, n = new $Uint64(0, 0), err = $ifaceNil, $s = 0, _tmp, _tmp$1, cutoff, maxVal, s0, x, i, v, d, x$1, n1, _tmp$2, _tmp$3, _tmp$4, _tmp$5; - /* */ while (true) { switch ($s) { case 0: - _tmp = new $Uint64(0, 0); _tmp$1 = new $Uint64(0, 0); cutoff = _tmp; maxVal = _tmp$1; - if (bitSize === 0) { - bitSize = 32; + if (!isDigit(s, 1)) { + if (fixed) { + return [0, s, errBad]; + } + return [((s.charCodeAt(0) - 48 << 24 >>> 24) >> 0), s.substring(1), $ifaceNil]; } - s0 = s; - /* if (s.length < 1) { */ if (s.length < 1) {} else if (2 <= base && base <= 36) { $s = 2; continue; } else if (base === 0) { $s = 3; continue; } else { $s = 4; continue; } - err = $pkg.ErrSyntax; - /* goto Error */ $s = 1; continue; - /* } else if (2 <= base && base <= 36) { */ $s = 5; continue; case 2: - /* } else if (base === 0) { */ $s = 5; continue; case 3: - /* if ((s.charCodeAt(0) === 48) && s.length > 1 && ((s.charCodeAt(1) === 120) || (s.charCodeAt(1) === 88))) { */ if ((s.charCodeAt(0) === 48) && s.length > 1 && ((s.charCodeAt(1) === 120) || (s.charCodeAt(1) === 88))) {} else if (s.charCodeAt(0) === 48) { $s = 6; continue; } else { $s = 7; continue; } - base = 16; - s = s.substring(2); - /* if (s.length < 1) { */ if (s.length < 1) {} else { $s = 9; continue; } - err = $pkg.ErrSyntax; - /* goto Error */ $s = 1; continue; - /* } */ case 9: - /* } else if (s.charCodeAt(0) === 48) { */ $s = 8; continue; case 6: - base = 8; - /* } else { */ $s = 8; continue; case 7: - base = 10; - /* } */ case 8: - /* } else { */ $s = 5; continue; case 4: - err = errors.New("invalid base " + Itoa(base)); - /* goto Error */ $s = 1; continue; - /* } */ case 5: - n = new $Uint64(0, 0); - cutoff = cutoff64(base); - maxVal = (x = $shiftLeft64(new $Uint64(0, 1), (bitSize >>> 0)), new $Uint64(x.$high - 0, x.$low - 1)); - i = 0; - /* while (i < s.length) { */ case 10: if(!(i < s.length)) { $s = 11; continue; } - v = 0; - d = s.charCodeAt(i); - /* if (48 <= d && d <= 57) { */ if (48 <= d && d <= 57) {} else if (97 <= d && d <= 122) { $s = 12; continue; } else if (65 <= d && d <= 90) { $s = 13; continue; } else { $s = 14; continue; } - v = d - 48 << 24 >>> 24; - /* } else if (97 <= d && d <= 122) { */ $s = 15; continue; case 12: - v = (d - 97 << 24 >>> 24) + 10 << 24 >>> 24; - /* } else if (65 <= d && d <= 90) { */ $s = 15; continue; case 13: - v = (d - 65 << 24 >>> 24) + 10 << 24 >>> 24; - /* } else { */ $s = 15; continue; case 14: - n = new $Uint64(0, 0); - err = $pkg.ErrSyntax; - /* goto Error */ $s = 1; continue; - /* } */ case 15: - /* if ((v >> 0) >= base) { */ if ((v >> 0) >= base) {} else { $s = 16; continue; } - n = new $Uint64(0, 0); - err = $pkg.ErrSyntax; - /* goto Error */ $s = 1; continue; - /* } */ case 16: - /* if ((n.$high > cutoff.$high || (n.$high === cutoff.$high && n.$low >= cutoff.$low))) { */ if ((n.$high > cutoff.$high || (n.$high === cutoff.$high && n.$low >= cutoff.$low))) {} else { $s = 17; continue; } - n = new $Uint64(4294967295, 4294967295); - err = $pkg.ErrRange; - /* goto Error */ $s = 1; continue; - /* } */ case 17: - n = $mul64(n, (new $Uint64(0, base))); - n1 = (x$1 = new $Uint64(0, v), new $Uint64(n.$high + x$1.$high, n.$low + x$1.$low)); - /* if ((n1.$high < n.$high || (n1.$high === n.$high && n1.$low < n.$low)) || (n1.$high > maxVal.$high || (n1.$high === maxVal.$high && n1.$low > maxVal.$low))) { */ if ((n1.$high < n.$high || (n1.$high === n.$high && n1.$low < n.$low)) || (n1.$high > maxVal.$high || (n1.$high === maxVal.$high && n1.$low > maxVal.$low))) {} else { $s = 18; continue; } - n = new $Uint64(4294967295, 4294967295); - err = $pkg.ErrRange; - /* goto Error */ $s = 1; continue; - /* } */ case 18: - n = n1; - i = i + (1) >> 0; - /* } */ $s = 10; continue; case 11: - _tmp$2 = n; _tmp$3 = $ifaceNil; n = _tmp$2; err = _tmp$3; - return [n, err]; - /* Error: */ case 1: - _tmp$4 = n; _tmp$5 = new NumError.Ptr("ParseUint", s0, err); n = _tmp$4; err = _tmp$5; - return [n, err]; - /* */ case -1: } return; } + return [(x = ((s.charCodeAt(0) - 48 << 24 >>> 24) >> 0), (((x >>> 16 << 16) * 10 >> 0) + (x << 16 >>> 16) * 10) >> 0) + ((s.charCodeAt(1) - 48 << 24 >>> 24) >> 0) >> 0, s.substring(2), $ifaceNil]; }; - ParseInt = $pkg.ParseInt = function(s, base, bitSize) { - var i = new $Int64(0, 0), err = $ifaceNil, _tmp, _tmp$1, s0, neg, un, _tuple, _tmp$2, _tmp$3, cutoff, _tmp$4, x, _tmp$5, _tmp$6, x$1, _tmp$7, n, _tmp$8, _tmp$9; - if (bitSize === 0) { - bitSize = 32; + cutspace = function(s) { + while (s.length > 0 && (s.charCodeAt(0) === 32)) { + s = s.substring(1); } - if (s.length === 0) { - _tmp = new $Int64(0, 0); _tmp$1 = syntaxError("ParseInt", s); i = _tmp; err = _tmp$1; - return [i, err]; + return s; + }; + skip = function(value, prefix) { + while (prefix.length > 0) { + if (prefix.charCodeAt(0) === 32) { + if (value.length > 0 && !((value.charCodeAt(0) === 32))) { + return [value, errBad]; + } + prefix = cutspace(prefix); + value = cutspace(value); + continue; + } + if ((value.length === 0) || !((value.charCodeAt(0) === prefix.charCodeAt(0)))) { + return [value, errBad]; + } + prefix = prefix.substring(1); + value = value.substring(1); } - s0 = s; - neg = false; - if (s.charCodeAt(0) === 43) { - s = s.substring(1); - } else if (s.charCodeAt(0) === 45) { - neg = true; - s = s.substring(1); + return [value, $ifaceNil]; + }; + Parse = $pkg.Parse = function(layout, value) { + return parse(layout, value, $pkg.UTC, $pkg.Local); + }; + parse = function(layout, value, defaultLocation, local) { + var _tmp, _tmp$1, alayout, avalue, rangeErrString, amSet, pmSet, year, month, day, hour, min, sec, nsec, z, zoneOffset, zoneName, err, _tuple$1, prefix, std, suffix, stdstr, _tuple$2, p, _ref, _tmp$2, _tmp$3, _tuple$3, _tmp$4, _tmp$5, _tuple$4, _tuple$5, _tuple$6, _tuple$7, _tuple$8, _tuple$9, _tuple$10, _tuple$11, _tuple$12, _tuple$13, _tuple$14, _tuple$15, n, _tuple$16, _tmp$6, _tmp$7, _ref$1, _tmp$8, _tmp$9, _ref$2, _tmp$10, _tmp$11, _tmp$12, _tmp$13, sign, hour$1, min$1, seconds, _tmp$14, _tmp$15, _tmp$16, _tmp$17, _tmp$18, _tmp$19, _tmp$20, _tmp$21, _tmp$22, _tmp$23, _tmp$24, _tmp$25, _tmp$26, _tmp$27, _tmp$28, _tmp$29, _tmp$30, _tmp$31, _tmp$32, _tmp$33, _tmp$34, _tmp$35, _tmp$36, _tmp$37, _tmp$38, _tmp$39, _tmp$40, _tmp$41, hr, mm, ss, _tuple$17, _tuple$18, _tuple$19, x, _ref$3, _tuple$20, n$1, ok, _tmp$42, _tmp$43, ndigit, _tuple$21, i, _tuple$22, t, x$1, x$2, _tuple$23, x$3, name, offset, t$1, _tuple$24, x$4, offset$1, ok$1, x$5, x$6, _tuple$25, x$7; + _tmp = layout; _tmp$1 = value; alayout = _tmp; avalue = _tmp$1; + rangeErrString = ""; + amSet = false; + pmSet = false; + year = 0; + month = 1; + day = 1; + hour = 0; + min = 0; + sec = 0; + nsec = 0; + z = ($ptrType(Location)).nil; + zoneOffset = -1; + zoneName = ""; + while (true) { + err = $ifaceNil; + _tuple$1 = nextStdChunk(layout); prefix = _tuple$1[0]; std = _tuple$1[1]; suffix = _tuple$1[2]; + stdstr = layout.substring(prefix.length, (layout.length - suffix.length >> 0)); + _tuple$2 = skip(value, prefix); value = _tuple$2[0]; err = _tuple$2[1]; + if (!($interfaceIsEqual(err, $ifaceNil))) { + return [new Time.Ptr(new $Int64(0, 0), 0, ($ptrType(Location)).nil), new ParseError.Ptr(alayout, avalue, prefix, value, "")]; + } + if (std === 0) { + if (!((value.length === 0))) { + return [new Time.Ptr(new $Int64(0, 0), 0, ($ptrType(Location)).nil), new ParseError.Ptr(alayout, avalue, "", value, ": extra text: " + value)]; + } + break; + } + layout = suffix; + p = ""; + _ref = std & 65535; + switch (0) { default: if (_ref === 274) { + if (value.length < 2) { + err = errBad; + break; + } + _tmp$2 = value.substring(0, 2); _tmp$3 = value.substring(2); p = _tmp$2; value = _tmp$3; + _tuple$3 = atoi(p); year = _tuple$3[0]; err = _tuple$3[1]; + if (year >= 69) { + year = year + (1900) >> 0; + } else { + year = year + (2000) >> 0; + } + } else if (_ref === 273) { + if (value.length < 4 || !isDigit(value, 0)) { + err = errBad; + break; + } + _tmp$4 = value.substring(0, 4); _tmp$5 = value.substring(4); p = _tmp$4; value = _tmp$5; + _tuple$4 = atoi(p); year = _tuple$4[0]; err = _tuple$4[1]; + } else if (_ref === 258) { + _tuple$5 = lookup(shortMonthNames, value); month = _tuple$5[0]; value = _tuple$5[1]; err = _tuple$5[2]; + } else if (_ref === 257) { + _tuple$6 = lookup(longMonthNames, value); month = _tuple$6[0]; value = _tuple$6[1]; err = _tuple$6[2]; + } else if (_ref === 259 || _ref === 260) { + _tuple$7 = getnum(value, std === 260); month = _tuple$7[0]; value = _tuple$7[1]; err = _tuple$7[2]; + if (month <= 0 || 12 < month) { + rangeErrString = "month"; + } + } else if (_ref === 262) { + _tuple$8 = lookup(shortDayNames, value); value = _tuple$8[1]; err = _tuple$8[2]; + } else if (_ref === 261) { + _tuple$9 = lookup(longDayNames, value); value = _tuple$9[1]; err = _tuple$9[2]; + } else if (_ref === 263 || _ref === 264 || _ref === 265) { + if ((std === 264) && value.length > 0 && (value.charCodeAt(0) === 32)) { + value = value.substring(1); + } + _tuple$10 = getnum(value, std === 265); day = _tuple$10[0]; value = _tuple$10[1]; err = _tuple$10[2]; + if (day < 0 || 31 < day) { + rangeErrString = "day"; + } + } else if (_ref === 522) { + _tuple$11 = getnum(value, false); hour = _tuple$11[0]; value = _tuple$11[1]; err = _tuple$11[2]; + if (hour < 0 || 24 <= hour) { + rangeErrString = "hour"; + } + } else if (_ref === 523 || _ref === 524) { + _tuple$12 = getnum(value, std === 524); hour = _tuple$12[0]; value = _tuple$12[1]; err = _tuple$12[2]; + if (hour < 0 || 12 < hour) { + rangeErrString = "hour"; + } + } else if (_ref === 525 || _ref === 526) { + _tuple$13 = getnum(value, std === 526); min = _tuple$13[0]; value = _tuple$13[1]; err = _tuple$13[2]; + if (min < 0 || 60 <= min) { + rangeErrString = "minute"; + } + } else if (_ref === 527 || _ref === 528) { + _tuple$14 = getnum(value, std === 528); sec = _tuple$14[0]; value = _tuple$14[1]; err = _tuple$14[2]; + if (sec < 0 || 60 <= sec) { + rangeErrString = "second"; + } + if (value.length >= 2 && (value.charCodeAt(0) === 46) && isDigit(value, 1)) { + _tuple$15 = nextStdChunk(layout); std = _tuple$15[1]; + std = std & (65535); + if ((std === 31) || (std === 32)) { + break; + } + n = 2; + while (n < value.length && isDigit(value, n)) { + n = n + (1) >> 0; + } + _tuple$16 = parseNanoseconds(value, n); nsec = _tuple$16[0]; rangeErrString = _tuple$16[1]; err = _tuple$16[2]; + value = value.substring(n); + } + } else if (_ref === 531) { + if (value.length < 2) { + err = errBad; + break; + } + _tmp$6 = value.substring(0, 2); _tmp$7 = value.substring(2); p = _tmp$6; value = _tmp$7; + _ref$1 = p; + if (_ref$1 === "PM") { + pmSet = true; + } else if (_ref$1 === "AM") { + amSet = true; + } else { + err = errBad; + } + } else if (_ref === 532) { + if (value.length < 2) { + err = errBad; + break; + } + _tmp$8 = value.substring(0, 2); _tmp$9 = value.substring(2); p = _tmp$8; value = _tmp$9; + _ref$2 = p; + if (_ref$2 === "pm") { + pmSet = true; + } else if (_ref$2 === "am") { + amSet = true; + } else { + err = errBad; + } + } else if (_ref === 22 || _ref === 24 || _ref === 23 || _ref === 25 || _ref === 26 || _ref === 28 || _ref === 29 || _ref === 27 || _ref === 30) { + if (((std === 22) || (std === 24)) && value.length >= 1 && (value.charCodeAt(0) === 90)) { + value = value.substring(1); + z = $pkg.UTC; + break; + } + _tmp$10 = ""; _tmp$11 = ""; _tmp$12 = ""; _tmp$13 = ""; sign = _tmp$10; hour$1 = _tmp$11; min$1 = _tmp$12; seconds = _tmp$13; + if ((std === 24) || (std === 29)) { + if (value.length < 6) { + err = errBad; + break; + } + if (!((value.charCodeAt(3) === 58))) { + err = errBad; + break; + } + _tmp$14 = value.substring(0, 1); _tmp$15 = value.substring(1, 3); _tmp$16 = value.substring(4, 6); _tmp$17 = "00"; _tmp$18 = value.substring(6); sign = _tmp$14; hour$1 = _tmp$15; min$1 = _tmp$16; seconds = _tmp$17; value = _tmp$18; + } else if (std === 28) { + if (value.length < 3) { + err = errBad; + break; + } + _tmp$19 = value.substring(0, 1); _tmp$20 = value.substring(1, 3); _tmp$21 = "00"; _tmp$22 = "00"; _tmp$23 = value.substring(3); sign = _tmp$19; hour$1 = _tmp$20; min$1 = _tmp$21; seconds = _tmp$22; value = _tmp$23; + } else if ((std === 25) || (std === 30)) { + if (value.length < 9) { + err = errBad; + break; + } + if (!((value.charCodeAt(3) === 58)) || !((value.charCodeAt(6) === 58))) { + err = errBad; + break; + } + _tmp$24 = value.substring(0, 1); _tmp$25 = value.substring(1, 3); _tmp$26 = value.substring(4, 6); _tmp$27 = value.substring(7, 9); _tmp$28 = value.substring(9); sign = _tmp$24; hour$1 = _tmp$25; min$1 = _tmp$26; seconds = _tmp$27; value = _tmp$28; + } else if ((std === 23) || (std === 27)) { + if (value.length < 7) { + err = errBad; + break; + } + _tmp$29 = value.substring(0, 1); _tmp$30 = value.substring(1, 3); _tmp$31 = value.substring(3, 5); _tmp$32 = value.substring(5, 7); _tmp$33 = value.substring(7); sign = _tmp$29; hour$1 = _tmp$30; min$1 = _tmp$31; seconds = _tmp$32; value = _tmp$33; + } else { + if (value.length < 5) { + err = errBad; + break; + } + _tmp$34 = value.substring(0, 1); _tmp$35 = value.substring(1, 3); _tmp$36 = value.substring(3, 5); _tmp$37 = "00"; _tmp$38 = value.substring(5); sign = _tmp$34; hour$1 = _tmp$35; min$1 = _tmp$36; seconds = _tmp$37; value = _tmp$38; + } + _tmp$39 = 0; _tmp$40 = 0; _tmp$41 = 0; hr = _tmp$39; mm = _tmp$40; ss = _tmp$41; + _tuple$17 = atoi(hour$1); hr = _tuple$17[0]; err = _tuple$17[1]; + if ($interfaceIsEqual(err, $ifaceNil)) { + _tuple$18 = atoi(min$1); mm = _tuple$18[0]; err = _tuple$18[1]; + } + if ($interfaceIsEqual(err, $ifaceNil)) { + _tuple$19 = atoi(seconds); ss = _tuple$19[0]; err = _tuple$19[1]; + } + zoneOffset = (x = (((((hr >>> 16 << 16) * 60 >> 0) + (hr << 16 >>> 16) * 60) >> 0) + mm >> 0), (((x >>> 16 << 16) * 60 >> 0) + (x << 16 >>> 16) * 60) >> 0) + ss >> 0; + _ref$3 = sign.charCodeAt(0); + if (_ref$3 === 43) { + } else if (_ref$3 === 45) { + zoneOffset = -zoneOffset; + } else { + err = errBad; + } + } else if (_ref === 21) { + if (value.length >= 3 && value.substring(0, 3) === "UTC") { + z = $pkg.UTC; + value = value.substring(3); + break; + } + _tuple$20 = parseTimeZone(value); n$1 = _tuple$20[0]; ok = _tuple$20[1]; + if (!ok) { + err = errBad; + break; + } + _tmp$42 = value.substring(0, n$1); _tmp$43 = value.substring(n$1); zoneName = _tmp$42; value = _tmp$43; + } else if (_ref === 31) { + ndigit = 1 + ((std >> 16 >> 0)) >> 0; + if (value.length < ndigit) { + err = errBad; + break; + } + _tuple$21 = parseNanoseconds(value, ndigit); nsec = _tuple$21[0]; rangeErrString = _tuple$21[1]; err = _tuple$21[2]; + value = value.substring(ndigit); + } else if (_ref === 32) { + if (value.length < 2 || !((value.charCodeAt(0) === 46)) || value.charCodeAt(1) < 48 || 57 < value.charCodeAt(1)) { + break; + } + i = 0; + while (i < 9 && (i + 1 >> 0) < value.length && 48 <= value.charCodeAt((i + 1 >> 0)) && value.charCodeAt((i + 1 >> 0)) <= 57) { + i = i + (1) >> 0; + } + _tuple$22 = parseNanoseconds(value, 1 + i >> 0); nsec = _tuple$22[0]; rangeErrString = _tuple$22[1]; err = _tuple$22[2]; + value = value.substring((1 + i >> 0)); + } } + if (!(rangeErrString === "")) { + return [new Time.Ptr(new $Int64(0, 0), 0, ($ptrType(Location)).nil), new ParseError.Ptr(alayout, avalue, stdstr, value, ": " + rangeErrString + " out of range")]; + } + if (!($interfaceIsEqual(err, $ifaceNil))) { + return [new Time.Ptr(new $Int64(0, 0), 0, ($ptrType(Location)).nil), new ParseError.Ptr(alayout, avalue, stdstr, value, "")]; + } } - un = new $Uint64(0, 0); - _tuple = ParseUint(s, base, bitSize); un = _tuple[0]; err = _tuple[1]; - if (!($interfaceIsEqual(err, $ifaceNil)) && !($interfaceIsEqual($assertType(err, ($ptrType(NumError))).Err, $pkg.ErrRange))) { - $assertType(err, ($ptrType(NumError))).Func = "ParseInt"; - $assertType(err, ($ptrType(NumError))).Num = s0; - _tmp$2 = new $Int64(0, 0); _tmp$3 = err; i = _tmp$2; err = _tmp$3; - return [i, err]; + if (pmSet && hour < 12) { + hour = hour + (12) >> 0; + } else if (amSet && (hour === 12)) { + hour = 0; } - cutoff = $shiftLeft64(new $Uint64(0, 1), ((bitSize - 1 >> 0) >>> 0)); - if (!neg && (un.$high > cutoff.$high || (un.$high === cutoff.$high && un.$low >= cutoff.$low))) { - _tmp$4 = (x = new $Uint64(cutoff.$high - 0, cutoff.$low - 1), new $Int64(x.$high, x.$low)); _tmp$5 = rangeError("ParseInt", s0); i = _tmp$4; err = _tmp$5; - return [i, err]; + if (!(z === ($ptrType(Location)).nil)) { + return [Date(year, (month >> 0), day, hour, min, sec, nsec, z), $ifaceNil]; } - if (neg && (un.$high > cutoff.$high || (un.$high === cutoff.$high && un.$low > cutoff.$low))) { - _tmp$6 = (x$1 = new $Int64(cutoff.$high, cutoff.$low), new $Int64(-x$1.$high, -x$1.$low)); _tmp$7 = rangeError("ParseInt", s0); i = _tmp$6; err = _tmp$7; - return [i, err]; + if (!((zoneOffset === -1))) { + t = new Time.Ptr(); $copy(t, Date(year, (month >> 0), day, hour, min, sec, nsec, $pkg.UTC), Time); + t.sec = (x$1 = t.sec, x$2 = new $Int64(0, zoneOffset), new $Int64(x$1.$high - x$2.$high, x$1.$low - x$2.$low)); + _tuple$23 = local.lookup((x$3 = t.sec, new $Int64(x$3.$high + -15, x$3.$low + 2288912640))); name = _tuple$23[0]; offset = _tuple$23[1]; + if ((offset === zoneOffset) && (zoneName === "" || name === zoneName)) { + t.loc = local; + return [t, $ifaceNil]; + } + t.loc = FixedZone(zoneName, zoneOffset); + return [t, $ifaceNil]; } - n = new $Int64(un.$high, un.$low); - if (neg) { - n = new $Int64(-n.$high, -n.$low); + if (!(zoneName === "")) { + t$1 = new Time.Ptr(); $copy(t$1, Date(year, (month >> 0), day, hour, min, sec, nsec, $pkg.UTC), Time); + _tuple$24 = local.lookupName(zoneName, (x$4 = t$1.sec, new $Int64(x$4.$high + -15, x$4.$low + 2288912640))); offset$1 = _tuple$24[0]; ok$1 = _tuple$24[2]; + if (ok$1) { + t$1.sec = (x$5 = t$1.sec, x$6 = new $Int64(0, offset$1), new $Int64(x$5.$high - x$6.$high, x$5.$low - x$6.$low)); + t$1.loc = local; + return [t$1, $ifaceNil]; + } + if (zoneName.length > 3 && zoneName.substring(0, 3) === "GMT") { + _tuple$25 = atoi(zoneName.substring(3)); offset$1 = _tuple$25[0]; + offset$1 = (x$7 = 3600, (((offset$1 >>> 16 << 16) * x$7 >> 0) + (offset$1 << 16 >>> 16) * x$7) >> 0); + } + t$1.loc = FixedZone(zoneName, offset$1); + return [t$1, $ifaceNil]; } - _tmp$8 = n; _tmp$9 = $ifaceNil; i = _tmp$8; err = _tmp$9; - return [i, err]; - }; - Atoi = $pkg.Atoi = function(s) { - var i = 0, err = $ifaceNil, _tuple, i64, _tmp, _tmp$1; - _tuple = ParseInt(s, 10, 0); i64 = _tuple[0]; err = _tuple[1]; - _tmp = ((i64.$low + ((i64.$high >> 31) * 4294967296)) >> 0); _tmp$1 = err; i = _tmp; err = _tmp$1; - return [i, err]; + return [Date(year, (month >> 0), day, hour, min, sec, nsec, defaultLocation), $ifaceNil]; }; - decimal.Ptr.prototype.String = function() { - var a, n, buf, w; - a = this; - n = 10 + a.nd >> 0; - if (a.dp > 0) { - n = n + (a.dp) >> 0; + parseTimeZone = function(value) { + var length = 0, ok = false, _tmp, _tmp$1, _tmp$2, _tmp$3, _tmp$4, _tmp$5, nUpper, c, _ref, _tmp$6, _tmp$7, _tmp$8, _tmp$9, _tmp$10, _tmp$11, _tmp$12, _tmp$13, _tmp$14, _tmp$15; + if (value.length < 3) { + _tmp = 0; _tmp$1 = false; length = _tmp; ok = _tmp$1; + return [length, ok]; } - if (a.dp < 0) { - n = n + (-a.dp) >> 0; + if (value.length >= 4 && (value.substring(0, 4) === "ChST" || value.substring(0, 4) === "MeST")) { + _tmp$2 = 4; _tmp$3 = true; length = _tmp$2; ok = _tmp$3; + return [length, ok]; } - buf = ($sliceType($Uint8)).make(n); - w = 0; - if (a.nd === 0) { - return "0"; - } else if (a.dp <= 0) { - (w < 0 || w >= buf.$length) ? $throwRuntimeError("index out of range") : buf.$array[buf.$offset + w] = 48; - w = w + (1) >> 0; - (w < 0 || w >= buf.$length) ? $throwRuntimeError("index out of range") : buf.$array[buf.$offset + w] = 46; - w = w + (1) >> 0; - w = w + (digitZero($subslice(buf, w, (w + -a.dp >> 0)))) >> 0; - w = w + ($copySlice($subslice(buf, w), $subslice(new ($sliceType($Uint8))(a.d), 0, a.nd))) >> 0; - } else if (a.dp < a.nd) { - w = w + ($copySlice($subslice(buf, w), $subslice(new ($sliceType($Uint8))(a.d), 0, a.dp))) >> 0; - (w < 0 || w >= buf.$length) ? $throwRuntimeError("index out of range") : buf.$array[buf.$offset + w] = 46; - w = w + (1) >> 0; - w = w + ($copySlice($subslice(buf, w), $subslice(new ($sliceType($Uint8))(a.d), a.dp, a.nd))) >> 0; - } else { - w = w + ($copySlice($subslice(buf, w), $subslice(new ($sliceType($Uint8))(a.d), 0, a.nd))) >> 0; - w = w + (digitZero($subslice(buf, w, ((w + a.dp >> 0) - a.nd >> 0)))) >> 0; + if (value.substring(0, 3) === "GMT") { + length = parseGMT(value); + _tmp$4 = length; _tmp$5 = true; length = _tmp$4; ok = _tmp$5; + return [length, ok]; } - return $bytesToString($subslice(buf, 0, w)); - }; - decimal.prototype.String = function() { return this.$val.String(); }; - digitZero = function(dst) { - var _ref, _i, i; - _ref = dst; - _i = 0; - while (_i < _ref.$length) { - i = _i; - (i < 0 || i >= dst.$length) ? $throwRuntimeError("index out of range") : dst.$array[dst.$offset + i] = 48; - _i++; + nUpper = 0; + nUpper = 0; + while (nUpper < 6) { + if (nUpper >= value.length) { + break; + } + c = value.charCodeAt(nUpper); + if (c < 65 || 90 < c) { + break; + } + nUpper = nUpper + (1) >> 0; } - return dst.$length; + _ref = nUpper; + if (_ref === 0 || _ref === 1 || _ref === 2 || _ref === 6) { + _tmp$6 = 0; _tmp$7 = false; length = _tmp$6; ok = _tmp$7; + return [length, ok]; + } else if (_ref === 5) { + if (value.charCodeAt(4) === 84) { + _tmp$8 = 5; _tmp$9 = true; length = _tmp$8; ok = _tmp$9; + return [length, ok]; + } + } else if (_ref === 4) { + if (value.charCodeAt(3) === 84) { + _tmp$10 = 4; _tmp$11 = true; length = _tmp$10; ok = _tmp$11; + return [length, ok]; + } + } else if (_ref === 3) { + _tmp$12 = 3; _tmp$13 = true; length = _tmp$12; ok = _tmp$13; + return [length, ok]; + } + _tmp$14 = 0; _tmp$15 = false; length = _tmp$14; ok = _tmp$15; + return [length, ok]; }; - trim = function(a) { - var x, x$1; - while (a.nd > 0 && ((x = a.d, x$1 = a.nd - 1 >> 0, ((x$1 < 0 || x$1 >= x.length) ? $throwRuntimeError("index out of range") : x[x$1])) === 48)) { - a.nd = a.nd - (1) >> 0; + parseGMT = function(value) { + var sign, _tuple$1, x, rem, err; + value = value.substring(3); + if (value.length === 0) { + return 3; } - if (a.nd === 0) { - a.dp = 0; + sign = value.charCodeAt(0); + if (!((sign === 45)) && !((sign === 43))) { + return 3; } - }; - decimal.Ptr.prototype.Assign = function(v) { - var a, buf, n, v1, x, x$1, x$2; - a = this; - buf = ($arrayType($Uint8, 24)).zero(); $copy(buf, ($arrayType($Uint8, 24)).zero(), ($arrayType($Uint8, 24))); - n = 0; - while ((v.$high > 0 || (v.$high === 0 && v.$low > 0))) { - v1 = $div64(v, new $Uint64(0, 10), false); - v = (x = $mul64(new $Uint64(0, 10), v1), new $Uint64(v.$high - x.$high, v.$low - x.$low)); - (n < 0 || n >= buf.length) ? $throwRuntimeError("index out of range") : buf[n] = (new $Uint64(v.$high + 0, v.$low + 48).$low << 24 >>> 24); - n = n + (1) >> 0; - v = v1; + _tuple$1 = leadingInt(value.substring(1)); x = _tuple$1[0]; rem = _tuple$1[1]; err = _tuple$1[2]; + if (!($interfaceIsEqual(err, $ifaceNil))) { + return 3; } - a.nd = 0; - n = n - (1) >> 0; - while (n >= 0) { - (x$1 = a.d, x$2 = a.nd, (x$2 < 0 || x$2 >= x$1.length) ? $throwRuntimeError("index out of range") : x$1[x$2] = ((n < 0 || n >= buf.length) ? $throwRuntimeError("index out of range") : buf[n])); - a.nd = a.nd + (1) >> 0; - n = n - (1) >> 0; + if (sign === 45) { + x = new $Int64(-x.$high, -x.$low); } - a.dp = a.nd; - trim(a); + if ((x.$high === 0 && x.$low === 0) || (x.$high < -1 || (x.$high === -1 && x.$low < 4294967282)) || (0 < x.$high || (0 === x.$high && 12 < x.$low))) { + return 3; + } + return (3 + value.length >> 0) - rem.length >> 0; }; - decimal.prototype.Assign = function(v) { return this.$val.Assign(v); }; - rightShift = function(a, k) { - var r, w, n, x, c, x$1, c$1, dig, y, x$2, dig$1, y$1, x$3; - r = 0; - w = 0; - n = 0; - while (((n >> $min(k, 31)) >> 0) === 0) { - if (r >= a.nd) { - if (n === 0) { - a.nd = 0; - return; - } - while (((n >> $min(k, 31)) >> 0) === 0) { - n = (((n >>> 16 << 16) * 10 >> 0) + (n << 16 >>> 16) * 10) >> 0; - r = r + (1) >> 0; - } - break; - } - c = ((x = a.d, ((r < 0 || r >= x.length) ? $throwRuntimeError("index out of range") : x[r])) >> 0); - n = (((((n >>> 16 << 16) * 10 >> 0) + (n << 16 >>> 16) * 10) >> 0) + c >> 0) - 48 >> 0; - r = r + (1) >> 0; + parseNanoseconds = function(value, nbytes) { + var ns = 0, rangeErrString = "", err = $ifaceNil, _tuple$1, scaleDigits, i, x; + if (!((value.charCodeAt(0) === 46))) { + err = errBad; + return [ns, rangeErrString, err]; } - a.dp = a.dp - ((r - 1 >> 0)) >> 0; - while (r < a.nd) { - c$1 = ((x$1 = a.d, ((r < 0 || r >= x$1.length) ? $throwRuntimeError("index out of range") : x$1[r])) >> 0); - dig = (n >> $min(k, 31)) >> 0; - n = n - (((y = k, y < 32 ? (dig << y) : 0) >> 0)) >> 0; - (x$2 = a.d, (w < 0 || w >= x$2.length) ? $throwRuntimeError("index out of range") : x$2[w] = ((dig + 48 >> 0) << 24 >>> 24)); - w = w + (1) >> 0; - n = (((((n >>> 16 << 16) * 10 >> 0) + (n << 16 >>> 16) * 10) >> 0) + c$1 >> 0) - 48 >> 0; - r = r + (1) >> 0; + _tuple$1 = atoi(value.substring(1, nbytes)); ns = _tuple$1[0]; err = _tuple$1[1]; + if (!($interfaceIsEqual(err, $ifaceNil))) { + return [ns, rangeErrString, err]; } - while (n > 0) { - dig$1 = (n >> $min(k, 31)) >> 0; - n = n - (((y$1 = k, y$1 < 32 ? (dig$1 << y$1) : 0) >> 0)) >> 0; - if (w < 800) { - (x$3 = a.d, (w < 0 || w >= x$3.length) ? $throwRuntimeError("index out of range") : x$3[w] = ((dig$1 + 48 >> 0) << 24 >>> 24)); - w = w + (1) >> 0; - } else if (dig$1 > 0) { - a.trunc = true; - } - n = (((n >>> 16 << 16) * 10 >> 0) + (n << 16 >>> 16) * 10) >> 0; + if (ns < 0 || 1000000000 <= ns) { + rangeErrString = "fractional second"; + return [ns, rangeErrString, err]; } - a.nd = w; - trim(a); - }; - prefixIsLessThan = function(b, s) { - var i; + scaleDigits = 10 - nbytes >> 0; i = 0; - while (i < s.length) { - if (i >= b.$length) { - return true; - } - if (!((((i < 0 || i >= b.$length) ? $throwRuntimeError("index out of range") : b.$array[b.$offset + i]) === s.charCodeAt(i)))) { - return ((i < 0 || i >= b.$length) ? $throwRuntimeError("index out of range") : b.$array[b.$offset + i]) < s.charCodeAt(i); - } + while (i < scaleDigits) { + ns = (x = 10, (((ns >>> 16 << 16) * x >> 0) + (ns << 16 >>> 16) * x) >> 0); i = i + (1) >> 0; } - return false; + return [ns, rangeErrString, err]; }; - leftShift = function(a, k) { - var delta, r, w, n, y, x, _q, quo, rem, x$1, _q$1, quo$1, rem$1, x$2; - delta = ((k < 0 || k >= leftcheats.$length) ? $throwRuntimeError("index out of range") : leftcheats.$array[leftcheats.$offset + k]).delta; - if (prefixIsLessThan($subslice(new ($sliceType($Uint8))(a.d), 0, a.nd), ((k < 0 || k >= leftcheats.$length) ? $throwRuntimeError("index out of range") : leftcheats.$array[leftcheats.$offset + k]).cutoff)) { - delta = delta - (1) >> 0; - } - r = a.nd; - w = a.nd + delta >> 0; - n = 0; - r = r - (1) >> 0; - while (r >= 0) { - n = n + (((y = k, y < 32 ? (((((x = a.d, ((r < 0 || r >= x.length) ? $throwRuntimeError("index out of range") : x[r])) >> 0) - 48 >> 0)) << y) : 0) >> 0)) >> 0; - quo = (_q = n / 10, (_q === _q && _q !== 1/0 && _q !== -1/0) ? _q >> 0 : $throwRuntimeError("integer divide by zero")); - rem = n - ((((10 >>> 16 << 16) * quo >> 0) + (10 << 16 >>> 16) * quo) >> 0) >> 0; - w = w - (1) >> 0; - if (w < 800) { - (x$1 = a.d, (w < 0 || w >= x$1.length) ? $throwRuntimeError("index out of range") : x$1[w] = ((rem + 48 >> 0) << 24 >>> 24)); - } else if (!((rem === 0))) { - a.trunc = true; + leadingInt = function(s) { + var x = new $Int64(0, 0), rem = "", err = $ifaceNil, i, c, _tmp, _tmp$1, _tmp$2, x$1, x$2, x$3, _tmp$3, _tmp$4, _tmp$5; + i = 0; + while (i < s.length) { + c = s.charCodeAt(i); + if (c < 48 || c > 57) { + break; } - n = quo; - r = r - (1) >> 0; + if ((x.$high > 214748364 || (x.$high === 214748364 && x.$low >= 3435973835))) { + _tmp = new $Int64(0, 0); _tmp$1 = ""; _tmp$2 = errLeadingInt; x = _tmp; rem = _tmp$1; err = _tmp$2; + return [x, rem, err]; + } + x = (x$1 = (x$2 = $mul64(x, new $Int64(0, 10)), x$3 = new $Int64(0, c), new $Int64(x$2.$high + x$3.$high, x$2.$low + x$3.$low)), new $Int64(x$1.$high - 0, x$1.$low - 48)); + i = i + (1) >> 0; } - while (n > 0) { - quo$1 = (_q$1 = n / 10, (_q$1 === _q$1 && _q$1 !== 1/0 && _q$1 !== -1/0) ? _q$1 >> 0 : $throwRuntimeError("integer divide by zero")); - rem$1 = n - ((((10 >>> 16 << 16) * quo$1 >> 0) + (10 << 16 >>> 16) * quo$1) >> 0) >> 0; - w = w - (1) >> 0; - if (w < 800) { - (x$2 = a.d, (w < 0 || w >= x$2.length) ? $throwRuntimeError("index out of range") : x$2[w] = ((rem$1 + 48 >> 0) << 24 >>> 24)); - } else if (!((rem$1 === 0))) { - a.trunc = true; + _tmp$3 = x; _tmp$4 = s.substring(i); _tmp$5 = $ifaceNil; x = _tmp$3; rem = _tmp$4; err = _tmp$5; + return [x, rem, err]; + }; + ParseDuration = $pkg.ParseDuration = function(s) { + var orig, f, neg, c, g, x, err, pl, _tuple$1, pre, post, pl$1, _tuple$2, scale, n, i, c$1, u, _tuple$3, _entry, unit, ok; + orig = s; + f = 0; + neg = false; + if (!(s === "")) { + c = s.charCodeAt(0); + if ((c === 45) || (c === 43)) { + neg = c === 45; + s = s.substring(1); } - n = quo$1; } - a.nd = a.nd + (delta) >> 0; - if (a.nd >= 800) { - a.nd = 800; + if (s === "0") { + return [new Duration(0, 0), $ifaceNil]; } - a.dp = a.dp + (delta) >> 0; - trim(a); - }; - decimal.Ptr.prototype.Shift = function(k) { - var a; - a = this; - if (a.nd === 0) { - } else if (k > 0) { - while (k > 27) { - leftShift(a, 27); - k = k - (27) >> 0; + if (s === "") { + return [new Duration(0, 0), errors.New("time: invalid duration " + orig)]; + } + while (!(s === "")) { + g = 0; + x = new $Int64(0, 0); + err = $ifaceNil; + if (!((s.charCodeAt(0) === 46) || (48 <= s.charCodeAt(0) && s.charCodeAt(0) <= 57))) { + return [new Duration(0, 0), errors.New("time: invalid duration " + orig)]; } - leftShift(a, (k >>> 0)); - } else if (k < 0) { - while (k < -27) { - rightShift(a, 27); - k = k + (27) >> 0; + pl = s.length; + _tuple$1 = leadingInt(s); x = _tuple$1[0]; s = _tuple$1[1]; err = _tuple$1[2]; + if (!($interfaceIsEqual(err, $ifaceNil))) { + return [new Duration(0, 0), errors.New("time: invalid duration " + orig)]; } - rightShift(a, (-k >>> 0)); + g = $flatten64(x); + pre = !((pl === s.length)); + post = false; + if (!(s === "") && (s.charCodeAt(0) === 46)) { + s = s.substring(1); + pl$1 = s.length; + _tuple$2 = leadingInt(s); x = _tuple$2[0]; s = _tuple$2[1]; err = _tuple$2[2]; + if (!($interfaceIsEqual(err, $ifaceNil))) { + return [new Duration(0, 0), errors.New("time: invalid duration " + orig)]; + } + scale = 1; + n = pl$1 - s.length >> 0; + while (n > 0) { + scale = scale * (10); + n = n - (1) >> 0; + } + g = g + ($flatten64(x) / scale); + post = !((pl$1 === s.length)); + } + if (!pre && !post) { + return [new Duration(0, 0), errors.New("time: invalid duration " + orig)]; + } + i = 0; + while (i < s.length) { + c$1 = s.charCodeAt(i); + if ((c$1 === 46) || (48 <= c$1 && c$1 <= 57)) { + break; + } + i = i + (1) >> 0; + } + if (i === 0) { + return [new Duration(0, 0), errors.New("time: missing unit in duration " + orig)]; + } + u = s.substring(0, i); + s = s.substring(i); + _tuple$3 = (_entry = unitMap[u], _entry !== undefined ? [_entry.v, true] : [0, false]); unit = _tuple$3[0]; ok = _tuple$3[1]; + if (!ok) { + return [new Duration(0, 0), errors.New("time: unknown unit " + u + " in duration " + orig)]; + } + f = f + (g * unit); } - }; - decimal.prototype.Shift = function(k) { return this.$val.Shift(k); }; - shouldRoundUp = function(a, nd) { - var x, _r, x$1, x$2, x$3; - if (nd < 0 || nd >= a.nd) { - return false; + if (neg) { + f = -f; } - if (((x = a.d, ((nd < 0 || nd >= x.length) ? $throwRuntimeError("index out of range") : x[nd])) === 53) && ((nd + 1 >> 0) === a.nd)) { - if (a.trunc) { - return true; - } - return nd > 0 && !(((_r = (((x$1 = a.d, x$2 = nd - 1 >> 0, ((x$2 < 0 || x$2 >= x$1.length) ? $throwRuntimeError("index out of range") : x$1[x$2])) - 48 << 24 >>> 24)) % 2, _r === _r ? _r : $throwRuntimeError("integer divide by zero")) === 0)); + if (f < -9.223372036854776e+18 || f > 9.223372036854776e+18) { + return [new Duration(0, 0), errors.New("time: overflow parsing duration")]; } - return (x$3 = a.d, ((nd < 0 || nd >= x$3.length) ? $throwRuntimeError("index out of range") : x$3[nd])) >= 53; + return [new Duration(0, f), $ifaceNil]; }; - decimal.Ptr.prototype.Round = function(nd) { - var a; - a = this; - if (nd < 0 || nd >= a.nd) { - return; + when = function(d) { + var x, x$1, t; + if ((d.$high < 0 || (d.$high === 0 && d.$low <= 0))) { + return runtimeNano(); } - if (shouldRoundUp(a, nd)) { - a.RoundUp(nd); - } else { - a.RoundDown(nd); + t = (x = runtimeNano(), x$1 = new $Int64(d.$high, d.$low), new $Int64(x.$high + x$1.$high, x.$low + x$1.$low)); + if ((t.$high < 0 || (t.$high === 0 && t.$low < 0))) { + t = new $Int64(2147483647, 4294967295); } + return t; }; - decimal.prototype.Round = function(nd) { return this.$val.Round(nd); }; - decimal.Ptr.prototype.RoundDown = function(nd) { - var a; - a = this; - if (nd < 0 || nd >= a.nd) { - return; - } - a.nd = nd; - trim(a); + Timer.Ptr.prototype.Stop = function() { + var t; + t = this; + return stopTimer(t.r); }; - decimal.prototype.RoundDown = function(nd) { return this.$val.RoundDown(nd); }; - decimal.Ptr.prototype.RoundUp = function(nd) { - var a, i, x, c, _lhs, _index; - a = this; - if (nd < 0 || nd >= a.nd) { - return; - } - i = nd - 1 >> 0; - while (i >= 0) { - c = (x = a.d, ((i < 0 || i >= x.length) ? $throwRuntimeError("index out of range") : x[i])); - if (c < 57) { - _lhs = a.d; _index = i; (_index < 0 || _index >= _lhs.length) ? $throwRuntimeError("index out of range") : _lhs[_index] = ((_index < 0 || _index >= _lhs.length) ? $throwRuntimeError("index out of range") : _lhs[_index]) + (1) << 24 >>> 24; - a.nd = i + 1 >> 0; - return; - } - i = i - (1) >> 0; - } - a.d[0] = 49; - a.nd = 1; - a.dp = a.dp + (1) >> 0; + Timer.prototype.Stop = function() { return this.$val.Stop(); }; + Timer.Ptr.prototype.Reset = function(d) { + var t, w, active; + t = this; + w = when(d); + active = stopTimer(t.r); + t.r.when = w; + startTimer(t.r); + return active; }; - decimal.prototype.RoundUp = function(nd) { return this.$val.RoundUp(nd); }; - decimal.Ptr.prototype.RoundedInteger = function() { - var a, i, n, x, x$1, x$2, x$3; - a = this; - if (a.dp > 20) { - return new $Uint64(4294967295, 4294967295); - } - i = 0; - n = new $Uint64(0, 0); - i = 0; - while (i < a.dp && i < a.nd) { - n = (x = $mul64(n, new $Uint64(0, 10)), x$1 = new $Uint64(0, ((x$2 = a.d, ((i < 0 || i >= x$2.length) ? $throwRuntimeError("index out of range") : x$2[i])) - 48 << 24 >>> 24)), new $Uint64(x.$high + x$1.$high, x.$low + x$1.$low)); - i = i + (1) >> 0; - } - while (i < a.dp) { - n = $mul64(n, (new $Uint64(0, 10))); - i = i + (1) >> 0; - } - if (shouldRoundUp(a, a.dp)) { - n = (x$3 = new $Uint64(0, 1), new $Uint64(n.$high + x$3.$high, n.$low + x$3.$low)); - } - return n; + Timer.prototype.Reset = function(d) { return this.$val.Reset(d); }; + AfterFunc = $pkg.AfterFunc = function(d, f) { + var t; + t = new Timer.Ptr(($chanType(Time, false, true)).nil, new runtimeTimer.Ptr(0, when(d), new $Int64(0, 0), goFunc, new ($funcType([], [], false))(f), $ifaceNil, false)); + startTimer(t.r); + return t; }; - decimal.prototype.RoundedInteger = function() { return this.$val.RoundedInteger(); }; - extFloat.Ptr.prototype.floatBits = function(flt) { - var bits = new $Uint64(0, 0), overflow = false, f, exp, n, mant, x, x$1, x$2, x$3, x$4, y, x$5, x$6, y$1, x$7, x$8, x$9, y$2, x$10; - f = this; - f.Normalize(); - exp = f.exp + 63 >> 0; - if (exp < (flt.bias + 1 >> 0)) { - n = (flt.bias + 1 >> 0) - exp >> 0; - f.mant = $shiftRightUint64(f.mant, ((n >>> 0))); - exp = exp + (n) >> 0; - } - mant = $shiftRightUint64(f.mant, ((63 - flt.mantbits >>> 0))); - if (!((x = (x$1 = f.mant, x$2 = $shiftLeft64(new $Uint64(0, 1), ((62 - flt.mantbits >>> 0))), new $Uint64(x$1.$high & x$2.$high, (x$1.$low & x$2.$low) >>> 0)), (x.$high === 0 && x.$low === 0)))) { - mant = (x$3 = new $Uint64(0, 1), new $Uint64(mant.$high + x$3.$high, mant.$low + x$3.$low)); - } - if ((x$4 = $shiftLeft64(new $Uint64(0, 2), flt.mantbits), (mant.$high === x$4.$high && mant.$low === x$4.$low))) { - mant = $shiftRightUint64(mant, (1)); - exp = exp + (1) >> 0; - } - if ((exp - flt.bias >> 0) >= (((y = flt.expbits, y < 32 ? (1 << y) : 0) >> 0) - 1 >> 0)) { - mant = new $Uint64(0, 0); - exp = (((y$1 = flt.expbits, y$1 < 32 ? (1 << y$1) : 0) >> 0) - 1 >> 0) + flt.bias >> 0; - overflow = true; - } else if ((x$5 = (x$6 = $shiftLeft64(new $Uint64(0, 1), flt.mantbits), new $Uint64(mant.$high & x$6.$high, (mant.$low & x$6.$low) >>> 0)), (x$5.$high === 0 && x$5.$low === 0))) { - exp = flt.bias; - } - bits = (x$7 = (x$8 = $shiftLeft64(new $Uint64(0, 1), flt.mantbits), new $Uint64(x$8.$high - 0, x$8.$low - 1)), new $Uint64(mant.$high & x$7.$high, (mant.$low & x$7.$low) >>> 0)); - bits = (x$9 = $shiftLeft64(new $Uint64(0, (((exp - flt.bias >> 0)) & ((((y$2 = flt.expbits, y$2 < 32 ? (1 << y$2) : 0) >> 0) - 1 >> 0)))), flt.mantbits), new $Uint64(bits.$high | x$9.$high, (bits.$low | x$9.$low) >>> 0)); - if (f.neg) { - bits = (x$10 = $shiftLeft64(new $Uint64(0, 1), ((flt.mantbits + flt.expbits >>> 0))), new $Uint64(bits.$high | x$10.$high, (bits.$low | x$10.$low) >>> 0)); - } - return [bits, overflow]; + goFunc = function(now$1, arg) { + $go($assertType(arg, ($funcType([], [], false))), []); }; - extFloat.prototype.floatBits = function(flt) { return this.$val.floatBits(flt); }; - extFloat.Ptr.prototype.AssignComputeBounds = function(mant, exp, neg, flt) { - var lower = new extFloat.Ptr(), upper = new extFloat.Ptr(), f, x, _tmp, _tmp$1, expBiased, x$1, x$2, x$3, x$4; - f = this; - f.mant = mant; - f.exp = exp - (flt.mantbits >> 0) >> 0; - f.neg = neg; - if (f.exp <= 0 && (x = $shiftLeft64(($shiftRightUint64(mant, (-f.exp >>> 0))), (-f.exp >>> 0)), (mant.$high === x.$high && mant.$low === x.$low))) { - f.mant = $shiftRightUint64(f.mant, ((-f.exp >>> 0))); - f.exp = 0; - _tmp = new extFloat.Ptr(); $copy(_tmp, f, extFloat); _tmp$1 = new extFloat.Ptr(); $copy(_tmp$1, f, extFloat); $copy(lower, _tmp, extFloat); $copy(upper, _tmp$1, extFloat); - return [lower, upper]; - } - expBiased = exp - flt.bias >> 0; - $copy(upper, new extFloat.Ptr((x$1 = $mul64(new $Uint64(0, 2), f.mant), new $Uint64(x$1.$high + 0, x$1.$low + 1)), f.exp - 1 >> 0, f.neg), extFloat); - if (!((x$2 = $shiftLeft64(new $Uint64(0, 1), flt.mantbits), (mant.$high === x$2.$high && mant.$low === x$2.$low))) || (expBiased === 1)) { - $copy(lower, new extFloat.Ptr((x$3 = $mul64(new $Uint64(0, 2), f.mant), new $Uint64(x$3.$high - 0, x$3.$low - 1)), f.exp - 1 >> 0, f.neg), extFloat); - } else { - $copy(lower, new extFloat.Ptr((x$4 = $mul64(new $Uint64(0, 4), f.mant), new $Uint64(x$4.$high - 0, x$4.$low - 1)), f.exp - 2 >> 0, f.neg), extFloat); - } - return [lower, upper]; + Time.Ptr.prototype.After = function(u) { + var t, x, x$1, x$2, x$3; + t = new Time.Ptr(); $copy(t, this, Time); + return (x = t.sec, x$1 = u.sec, (x.$high > x$1.$high || (x.$high === x$1.$high && x.$low > x$1.$low))) || (x$2 = t.sec, x$3 = u.sec, (x$2.$high === x$3.$high && x$2.$low === x$3.$low)) && t.nsec > u.nsec; }; - extFloat.prototype.AssignComputeBounds = function(mant, exp, neg, flt) { return this.$val.AssignComputeBounds(mant, exp, neg, flt); }; - extFloat.Ptr.prototype.Normalize = function() { - var shift = 0, f, _tmp, _tmp$1, mant, exp, x, x$1, x$2, x$3, x$4, x$5, _tmp$2, _tmp$3; - f = this; - _tmp = f.mant; _tmp$1 = f.exp; mant = _tmp; exp = _tmp$1; - if ((mant.$high === 0 && mant.$low === 0)) { - shift = 0; - return shift; - } - if ((x = $shiftRightUint64(mant, 32), (x.$high === 0 && x.$low === 0))) { - mant = $shiftLeft64(mant, (32)); - exp = exp - (32) >> 0; - } - if ((x$1 = $shiftRightUint64(mant, 48), (x$1.$high === 0 && x$1.$low === 0))) { - mant = $shiftLeft64(mant, (16)); - exp = exp - (16) >> 0; - } - if ((x$2 = $shiftRightUint64(mant, 56), (x$2.$high === 0 && x$2.$low === 0))) { - mant = $shiftLeft64(mant, (8)); - exp = exp - (8) >> 0; - } - if ((x$3 = $shiftRightUint64(mant, 60), (x$3.$high === 0 && x$3.$low === 0))) { - mant = $shiftLeft64(mant, (4)); - exp = exp - (4) >> 0; - } - if ((x$4 = $shiftRightUint64(mant, 62), (x$4.$high === 0 && x$4.$low === 0))) { - mant = $shiftLeft64(mant, (2)); - exp = exp - (2) >> 0; - } - if ((x$5 = $shiftRightUint64(mant, 63), (x$5.$high === 0 && x$5.$low === 0))) { - mant = $shiftLeft64(mant, (1)); - exp = exp - (1) >> 0; - } - shift = ((f.exp - exp >> 0) >>> 0); - _tmp$2 = mant; _tmp$3 = exp; f.mant = _tmp$2; f.exp = _tmp$3; - return shift; + Time.prototype.After = function(u) { return this.$val.After(u); }; + Time.Ptr.prototype.Before = function(u) { + var t, x, x$1, x$2, x$3; + t = new Time.Ptr(); $copy(t, this, Time); + return (x = t.sec, x$1 = u.sec, (x.$high < x$1.$high || (x.$high === x$1.$high && x.$low < x$1.$low))) || (x$2 = t.sec, x$3 = u.sec, (x$2.$high === x$3.$high && x$2.$low === x$3.$low)) && t.nsec < u.nsec; }; - extFloat.prototype.Normalize = function() { return this.$val.Normalize(); }; - extFloat.Ptr.prototype.Multiply = function(g) { - var f, _tmp, _tmp$1, fhi, flo, _tmp$2, _tmp$3, ghi, glo, cross1, cross2, x, x$1, x$2, x$3, x$4, x$5, x$6, x$7, rem, x$8, x$9, x$10; - f = this; - _tmp = $shiftRightUint64(f.mant, 32); _tmp$1 = new $Uint64(0, (f.mant.$low >>> 0)); fhi = _tmp; flo = _tmp$1; - _tmp$2 = $shiftRightUint64(g.mant, 32); _tmp$3 = new $Uint64(0, (g.mant.$low >>> 0)); ghi = _tmp$2; glo = _tmp$3; - cross1 = $mul64(fhi, glo); - cross2 = $mul64(flo, ghi); - f.mant = (x = (x$1 = $mul64(fhi, ghi), x$2 = $shiftRightUint64(cross1, 32), new $Uint64(x$1.$high + x$2.$high, x$1.$low + x$2.$low)), x$3 = $shiftRightUint64(cross2, 32), new $Uint64(x.$high + x$3.$high, x.$low + x$3.$low)); - rem = (x$4 = (x$5 = new $Uint64(0, (cross1.$low >>> 0)), x$6 = new $Uint64(0, (cross2.$low >>> 0)), new $Uint64(x$5.$high + x$6.$high, x$5.$low + x$6.$low)), x$7 = $shiftRightUint64(($mul64(flo, glo)), 32), new $Uint64(x$4.$high + x$7.$high, x$4.$low + x$7.$low)); - rem = (x$8 = new $Uint64(0, 2147483648), new $Uint64(rem.$high + x$8.$high, rem.$low + x$8.$low)); - f.mant = (x$9 = f.mant, x$10 = ($shiftRightUint64(rem, 32)), new $Uint64(x$9.$high + x$10.$high, x$9.$low + x$10.$low)); - f.exp = (f.exp + g.exp >> 0) + 64 >> 0; + Time.prototype.Before = function(u) { return this.$val.Before(u); }; + Time.Ptr.prototype.Equal = function(u) { + var t, x, x$1; + t = new Time.Ptr(); $copy(t, this, Time); + return (x = t.sec, x$1 = u.sec, (x.$high === x$1.$high && x.$low === x$1.$low)) && (t.nsec === u.nsec); }; - extFloat.prototype.Multiply = function(g) { return this.$val.Multiply(g); }; - extFloat.Ptr.prototype.AssignDecimal = function(mantissa, exp10, neg, trunc, flt) { - var ok = false, f, errors$1, _q, i, _r, adjExp, x, x$1, shift, y, denormalExp, extrabits, halfway, x$2, x$3, x$4, mant_extra, x$5, x$6, x$7, x$8, x$9, x$10, x$11, x$12; - f = this; - errors$1 = 0; - if (trunc) { - errors$1 = errors$1 + (4) >> 0; - } - f.mant = mantissa; - f.exp = 0; - f.neg = neg; - i = (_q = ((exp10 - -348 >> 0)) / 8, (_q === _q && _q !== 1/0 && _q !== -1/0) ? _q >> 0 : $throwRuntimeError("integer divide by zero")); - if (exp10 < -348 || i >= 87) { - ok = false; - return ok; - } - adjExp = (_r = ((exp10 - -348 >> 0)) % 8, _r === _r ? _r : $throwRuntimeError("integer divide by zero")); - if (adjExp < 19 && (x = (x$1 = 19 - adjExp >> 0, ((x$1 < 0 || x$1 >= uint64pow10.length) ? $throwRuntimeError("index out of range") : uint64pow10[x$1])), (mantissa.$high < x.$high || (mantissa.$high === x.$high && mantissa.$low < x.$low)))) { - f.mant = $mul64(f.mant, (((adjExp < 0 || adjExp >= uint64pow10.length) ? $throwRuntimeError("index out of range") : uint64pow10[adjExp]))); - f.Normalize(); - } else { - f.Normalize(); - f.Multiply($clone(((adjExp < 0 || adjExp >= smallPowersOfTen.length) ? $throwRuntimeError("index out of range") : smallPowersOfTen[adjExp]), extFloat)); - errors$1 = errors$1 + (4) >> 0; - } - f.Multiply($clone(((i < 0 || i >= powersOfTen.length) ? $throwRuntimeError("index out of range") : powersOfTen[i]), extFloat)); - if (errors$1 > 0) { - errors$1 = errors$1 + (1) >> 0; - } - errors$1 = errors$1 + (4) >> 0; - shift = f.Normalize(); - errors$1 = (y = (shift), y < 32 ? (errors$1 << y) : 0) >> 0; - denormalExp = flt.bias - 63 >> 0; - extrabits = 0; - if (f.exp <= denormalExp) { - extrabits = (((63 - flt.mantbits >>> 0) + 1 >>> 0) + ((denormalExp - f.exp >> 0) >>> 0) >>> 0); - } else { - extrabits = (63 - flt.mantbits >>> 0); - } - halfway = $shiftLeft64(new $Uint64(0, 1), ((extrabits - 1 >>> 0))); - mant_extra = (x$2 = f.mant, x$3 = (x$4 = $shiftLeft64(new $Uint64(0, 1), extrabits), new $Uint64(x$4.$high - 0, x$4.$low - 1)), new $Uint64(x$2.$high & x$3.$high, (x$2.$low & x$3.$low) >>> 0)); - if ((x$5 = (x$6 = new $Int64(halfway.$high, halfway.$low), x$7 = new $Int64(0, errors$1), new $Int64(x$6.$high - x$7.$high, x$6.$low - x$7.$low)), x$8 = new $Int64(mant_extra.$high, mant_extra.$low), (x$5.$high < x$8.$high || (x$5.$high === x$8.$high && x$5.$low < x$8.$low))) && (x$9 = new $Int64(mant_extra.$high, mant_extra.$low), x$10 = (x$11 = new $Int64(halfway.$high, halfway.$low), x$12 = new $Int64(0, errors$1), new $Int64(x$11.$high + x$12.$high, x$11.$low + x$12.$low)), (x$9.$high < x$10.$high || (x$9.$high === x$10.$high && x$9.$low < x$10.$low)))) { - ok = false; - return ok; - } - ok = true; - return ok; + Time.prototype.Equal = function(u) { return this.$val.Equal(u); }; + Month.prototype.String = function() { + var m, x; + m = this.$val !== undefined ? this.$val : this; + return (x = m - 1 >> 0, ((x < 0 || x >= months.length) ? $throwRuntimeError("index out of range") : months[x])); }; - extFloat.prototype.AssignDecimal = function(mantissa, exp10, neg, trunc, flt) { return this.$val.AssignDecimal(mantissa, exp10, neg, trunc, flt); }; - extFloat.Ptr.prototype.frexp10 = function() { - var exp10 = 0, index = 0, f, _q, x, approxExp10, _q$1, i, exp, _tmp, _tmp$1; - f = this; - approxExp10 = (_q = (x = (-46 - f.exp >> 0), (((x >>> 16 << 16) * 28 >> 0) + (x << 16 >>> 16) * 28) >> 0) / 93, (_q === _q && _q !== 1/0 && _q !== -1/0) ? _q >> 0 : $throwRuntimeError("integer divide by zero")); - i = (_q$1 = ((approxExp10 - -348 >> 0)) / 8, (_q$1 === _q$1 && _q$1 !== 1/0 && _q$1 !== -1/0) ? _q$1 >> 0 : $throwRuntimeError("integer divide by zero")); - Loop: - while (true) { - exp = (f.exp + ((i < 0 || i >= powersOfTen.length) ? $throwRuntimeError("index out of range") : powersOfTen[i]).exp >> 0) + 64 >> 0; - if (exp < -60) { - i = i + (1) >> 0; - } else if (exp > -32) { - i = i - (1) >> 0; + $ptrType(Month).prototype.String = function() { return new Month(this.$get()).String(); }; + Weekday.prototype.String = function() { + var d; + d = this.$val !== undefined ? this.$val : this; + return ((d < 0 || d >= days.length) ? $throwRuntimeError("index out of range") : days[d]); + }; + $ptrType(Weekday).prototype.String = function() { return new Weekday(this.$get()).String(); }; + Time.Ptr.prototype.IsZero = function() { + var t, x; + t = new Time.Ptr(); $copy(t, this, Time); + return (x = t.sec, (x.$high === 0 && x.$low === 0)) && (t.nsec === 0); + }; + Time.prototype.IsZero = function() { return this.$val.IsZero(); }; + Time.Ptr.prototype.abs = function() { + var t, l, x, sec, x$1, x$2, x$3, _tuple$1, offset, x$4, x$5; + t = new Time.Ptr(); $copy(t, this, Time); + l = t.loc; + if (l === ($ptrType(Location)).nil || l === localLoc) { + l = l.get(); + } + sec = (x = t.sec, new $Int64(x.$high + -15, x.$low + 2288912640)); + if (!(l === utcLoc)) { + if (!(l.cacheZone === ($ptrType(zone)).nil) && (x$1 = l.cacheStart, (x$1.$high < sec.$high || (x$1.$high === sec.$high && x$1.$low <= sec.$low))) && (x$2 = l.cacheEnd, (sec.$high < x$2.$high || (sec.$high === x$2.$high && sec.$low < x$2.$low)))) { + sec = (x$3 = new $Int64(0, l.cacheZone.offset), new $Int64(sec.$high + x$3.$high, sec.$low + x$3.$low)); } else { - break Loop; + _tuple$1 = l.lookup(sec); offset = _tuple$1[1]; + sec = (x$4 = new $Int64(0, offset), new $Int64(sec.$high + x$4.$high, sec.$low + x$4.$low)); } } - f.Multiply($clone(((i < 0 || i >= powersOfTen.length) ? $throwRuntimeError("index out of range") : powersOfTen[i]), extFloat)); - _tmp = -((-348 + ((((i >>> 16 << 16) * 8 >> 0) + (i << 16 >>> 16) * 8) >> 0) >> 0)); _tmp$1 = i; exp10 = _tmp; index = _tmp$1; - return [exp10, index]; - }; - extFloat.prototype.frexp10 = function() { return this.$val.frexp10(); }; - frexp10Many = function(a, b, c) { - var exp10 = 0, _tuple, i; - _tuple = c.frexp10(); exp10 = _tuple[0]; i = _tuple[1]; - a.Multiply($clone(((i < 0 || i >= powersOfTen.length) ? $throwRuntimeError("index out of range") : powersOfTen[i]), extFloat)); - b.Multiply($clone(((i < 0 || i >= powersOfTen.length) ? $throwRuntimeError("index out of range") : powersOfTen[i]), extFloat)); - return exp10; + return (x$5 = new $Int64(sec.$high + 2147483646, sec.$low + 450480384), new $Uint64(x$5.$high, x$5.$low)); }; - extFloat.Ptr.prototype.FixedDecimal = function(d, n) { - var f, x, _tuple, exp10, shift, integer, x$1, x$2, fraction, nonAsciiName, needed, integerDigits, pow10, _tmp, _tmp$1, i, pow, x$3, rest, x$4, _q, x$5, buf, pos, v, _q$1, v1, i$1, x$6, x$7, nd, x$8, x$9, digit, x$10, x$11, x$12, ok, i$2, x$13; - f = this; - if ((x = f.mant, (x.$high === 0 && x.$low === 0))) { - d.nd = 0; - d.dp = 0; - d.neg = f.neg; - return true; - } - if (n === 0) { - $panic(new $String("strconv: internal error: extFloat.FixedDecimal called with n == 0")); + Time.prototype.abs = function() { return this.$val.abs(); }; + Time.Ptr.prototype.locabs = function() { + var name = "", offset = 0, abs = new $Uint64(0, 0), t, l, x, sec, x$1, x$2, _tuple$1, x$3, x$4; + t = new Time.Ptr(); $copy(t, this, Time); + l = t.loc; + if (l === ($ptrType(Location)).nil || l === localLoc) { + l = l.get(); } - f.Normalize(); - _tuple = f.frexp10(); exp10 = _tuple[0]; - shift = (-f.exp >>> 0); - integer = ($shiftRightUint64(f.mant, shift).$low >>> 0); - fraction = (x$1 = f.mant, x$2 = $shiftLeft64(new $Uint64(0, integer), shift), new $Uint64(x$1.$high - x$2.$high, x$1.$low - x$2.$low)); - nonAsciiName = new $Uint64(0, 1); - needed = n; - integerDigits = 0; - pow10 = new $Uint64(0, 1); - _tmp = 0; _tmp$1 = new $Uint64(0, 1); i = _tmp; pow = _tmp$1; - while (i < 20) { - if ((x$3 = new $Uint64(0, integer), (pow.$high > x$3.$high || (pow.$high === x$3.$high && pow.$low > x$3.$low)))) { - integerDigits = i; - break; + sec = (x = t.sec, new $Int64(x.$high + -15, x.$low + 2288912640)); + if (!(l === utcLoc)) { + if (!(l.cacheZone === ($ptrType(zone)).nil) && (x$1 = l.cacheStart, (x$1.$high < sec.$high || (x$1.$high === sec.$high && x$1.$low <= sec.$low))) && (x$2 = l.cacheEnd, (sec.$high < x$2.$high || (sec.$high === x$2.$high && sec.$low < x$2.$low)))) { + name = l.cacheZone.name; + offset = l.cacheZone.offset; + } else { + _tuple$1 = l.lookup(sec); name = _tuple$1[0]; offset = _tuple$1[1]; } - pow = $mul64(pow, (new $Uint64(0, 10))); - i = i + (1) >> 0; - } - rest = integer; - if (integerDigits > needed) { - pow10 = (x$4 = integerDigits - needed >> 0, ((x$4 < 0 || x$4 >= uint64pow10.length) ? $throwRuntimeError("index out of range") : uint64pow10[x$4])); - integer = (_q = integer / ((pow10.$low >>> 0)), (_q === _q && _q !== 1/0 && _q !== -1/0) ? _q >>> 0 : $throwRuntimeError("integer divide by zero")); - rest = rest - ((x$5 = (pow10.$low >>> 0), (((integer >>> 16 << 16) * x$5 >>> 0) + (integer << 16 >>> 16) * x$5) >>> 0)) >>> 0; + sec = (x$3 = new $Int64(0, offset), new $Int64(sec.$high + x$3.$high, sec.$low + x$3.$low)); } else { - rest = 0; + name = "UTC"; } - buf = ($arrayType($Uint8, 32)).zero(); $copy(buf, ($arrayType($Uint8, 32)).zero(), ($arrayType($Uint8, 32))); - pos = 32; - v = integer; - while (v > 0) { - v1 = (_q$1 = v / 10, (_q$1 === _q$1 && _q$1 !== 1/0 && _q$1 !== -1/0) ? _q$1 >>> 0 : $throwRuntimeError("integer divide by zero")); - v = v - (((((10 >>> 16 << 16) * v1 >>> 0) + (10 << 16 >>> 16) * v1) >>> 0)) >>> 0; - pos = pos - (1) >> 0; - (pos < 0 || pos >= buf.length) ? $throwRuntimeError("index out of range") : buf[pos] = ((v + 48 >>> 0) << 24 >>> 24); - v = v1; - } - i$1 = pos; - while (i$1 < 32) { - (x$6 = d.d, x$7 = i$1 - pos >> 0, (x$7 < 0 || x$7 >= x$6.$length) ? $throwRuntimeError("index out of range") : x$6.$array[x$6.$offset + x$7] = ((i$1 < 0 || i$1 >= buf.length) ? $throwRuntimeError("index out of range") : buf[i$1])); - i$1 = i$1 + (1) >> 0; + abs = (x$4 = new $Int64(sec.$high + 2147483646, sec.$low + 450480384), new $Uint64(x$4.$high, x$4.$low)); + return [name, offset, abs]; + }; + Time.prototype.locabs = function() { return this.$val.locabs(); }; + Time.Ptr.prototype.Date = function() { + var year = 0, month = 0, day = 0, t, _tuple$1; + t = new Time.Ptr(); $copy(t, this, Time); + _tuple$1 = t.date(true); year = _tuple$1[0]; month = _tuple$1[1]; day = _tuple$1[2]; + return [year, month, day]; + }; + Time.prototype.Date = function() { return this.$val.Date(); }; + Time.Ptr.prototype.Year = function() { + var t, _tuple$1, year; + t = new Time.Ptr(); $copy(t, this, Time); + _tuple$1 = t.date(false); year = _tuple$1[0]; + return year; + }; + Time.prototype.Year = function() { return this.$val.Year(); }; + Time.Ptr.prototype.Month = function() { + var t, _tuple$1, month; + t = new Time.Ptr(); $copy(t, this, Time); + _tuple$1 = t.date(true); month = _tuple$1[1]; + return month; + }; + Time.prototype.Month = function() { return this.$val.Month(); }; + Time.Ptr.prototype.Day = function() { + var t, _tuple$1, day; + t = new Time.Ptr(); $copy(t, this, Time); + _tuple$1 = t.date(true); day = _tuple$1[2]; + return day; + }; + Time.prototype.Day = function() { return this.$val.Day(); }; + Time.Ptr.prototype.Weekday = function() { + var t; + t = new Time.Ptr(); $copy(t, this, Time); + return absWeekday(t.abs()); + }; + Time.prototype.Weekday = function() { return this.$val.Weekday(); }; + absWeekday = function(abs) { + var sec, _q; + sec = $div64((new $Uint64(abs.$high + 0, abs.$low + 86400)), new $Uint64(0, 604800), true); + return ((_q = (sec.$low >> 0) / 86400, (_q === _q && _q !== 1/0 && _q !== -1/0) ? _q >> 0 : $throwRuntimeError("integer divide by zero")) >> 0); + }; + Time.Ptr.prototype.ISOWeek = function() { + var year = 0, week = 0, t, _tuple$1, month, day, yday, _r, wday, _q, _r$1, jan1wday, _r$2, dec31wday; + t = new Time.Ptr(); $copy(t, this, Time); + _tuple$1 = t.date(true); year = _tuple$1[0]; month = _tuple$1[1]; day = _tuple$1[2]; yday = _tuple$1[3]; + wday = (_r = ((t.Weekday() + 6 >> 0) >> 0) % 7, _r === _r ? _r : $throwRuntimeError("integer divide by zero")); + week = (_q = (((yday - wday >> 0) + 7 >> 0)) / 7, (_q === _q && _q !== 1/0 && _q !== -1/0) ? _q >> 0 : $throwRuntimeError("integer divide by zero")); + jan1wday = (_r$1 = (((wday - yday >> 0) + 371 >> 0)) % 7, _r$1 === _r$1 ? _r$1 : $throwRuntimeError("integer divide by zero")); + if (1 <= jan1wday && jan1wday <= 3) { + week = week + (1) >> 0; } - nd = 32 - pos >> 0; - d.nd = nd; - d.dp = integerDigits + exp10 >> 0; - needed = needed - (nd) >> 0; - if (needed > 0) { - if (!((rest === 0)) || !((pow10.$high === 0 && pow10.$low === 1))) { - $panic(new $String("strconv: internal error, rest != 0 but needed > 0")); - } - while (needed > 0) { - fraction = $mul64(fraction, (new $Uint64(0, 10))); - nonAsciiName = $mul64(nonAsciiName, (new $Uint64(0, 10))); - if ((x$8 = $mul64(new $Uint64(0, 2), nonAsciiName), x$9 = $shiftLeft64(new $Uint64(0, 1), shift), (x$8.$high > x$9.$high || (x$8.$high === x$9.$high && x$8.$low > x$9.$low)))) { - return false; - } - digit = $shiftRightUint64(fraction, shift); - (x$10 = d.d, (nd < 0 || nd >= x$10.$length) ? $throwRuntimeError("index out of range") : x$10.$array[x$10.$offset + nd] = (new $Uint64(digit.$high + 0, digit.$low + 48).$low << 24 >>> 24)); - fraction = (x$11 = $shiftLeft64(digit, shift), new $Uint64(fraction.$high - x$11.$high, fraction.$low - x$11.$low)); - nd = nd + (1) >> 0; - needed = needed - (1) >> 0; + if (week === 0) { + year = year - (1) >> 0; + week = 52; + if ((jan1wday === 4) || ((jan1wday === 5) && isLeap(year))) { + week = week + (1) >> 0; } - d.nd = nd; - } - ok = adjustLastDigitFixed(d, (x$12 = $shiftLeft64(new $Uint64(0, rest), shift), new $Uint64(x$12.$high | fraction.$high, (x$12.$low | fraction.$low) >>> 0)), pow10, shift, nonAsciiName); - if (!ok) { - return false; } - i$2 = d.nd - 1 >> 0; - while (i$2 >= 0) { - if (!(((x$13 = d.d, ((i$2 < 0 || i$2 >= x$13.$length) ? $throwRuntimeError("index out of range") : x$13.$array[x$13.$offset + i$2])) === 48))) { - d.nd = i$2 + 1 >> 0; - break; + if ((month === 12) && day >= 29 && wday < 3) { + dec31wday = (_r$2 = (((wday + 31 >> 0) - day >> 0)) % 7, _r$2 === _r$2 ? _r$2 : $throwRuntimeError("integer divide by zero")); + if (0 <= dec31wday && dec31wday <= 2) { + year = year + (1) >> 0; + week = 1; } - i$2 = i$2 - (1) >> 0; } - return true; + return [year, week]; }; - extFloat.prototype.FixedDecimal = function(d, n) { return this.$val.FixedDecimal(d, n); }; - adjustLastDigitFixed = function(d, num, den, shift, nonAsciiName) { - var x, x$1, x$2, x$3, x$4, x$5, x$6, i, x$7, x$8, _lhs, _index; - if ((x = $shiftLeft64(den, shift), (num.$high > x.$high || (num.$high === x.$high && num.$low > x.$low)))) { - $panic(new $String("strconv: num > den< x$2.$high || (x$1.$high === x$2.$high && x$1.$low > x$2.$low)))) { - $panic(new $String("strconv: \xCE\xB5 > (den< x$6.$high || (x$5.$high === x$6.$high && x$5.$low > x$6.$low)))) { - i = d.nd - 1 >> 0; - while (i >= 0) { - if ((x$7 = d.d, ((i < 0 || i >= x$7.$length) ? $throwRuntimeError("index out of range") : x$7.$array[x$7.$offset + i])) === 57) { - d.nd = d.nd - (1) >> 0; - } else { - break; - } - i = i - (1) >> 0; - } - if (i < 0) { - (x$8 = d.d, (0 < 0 || 0 >= x$8.$length) ? $throwRuntimeError("index out of range") : x$8.$array[x$8.$offset + 0] = 49); - d.nd = 1; - d.dp = d.dp + (1) >> 0; - } else { - _lhs = d.d; _index = i; (_index < 0 || _index >= _lhs.$length) ? $throwRuntimeError("index out of range") : _lhs.$array[_lhs.$offset + _index] = ((_index < 0 || _index >= _lhs.$length) ? $throwRuntimeError("index out of range") : _lhs.$array[_lhs.$offset + _index]) + (1) << 24 >>> 24; - } - return true; - } - return false; + Time.prototype.ISOWeek = function() { return this.$val.ISOWeek(); }; + Time.Ptr.prototype.Clock = function() { + var hour = 0, min = 0, sec = 0, t, _tuple$1; + t = new Time.Ptr(); $copy(t, this, Time); + _tuple$1 = absClock(t.abs()); hour = _tuple$1[0]; min = _tuple$1[1]; sec = _tuple$1[2]; + return [hour, min, sec]; }; - extFloat.Ptr.prototype.ShortestDecimal = function(d, lower, upper) { - var f, x, buf, n, v, v1, x$1, nd, i, x$2, x$3, _tmp, _tmp$1, x$4, x$5, exp10, x$6, x$7, x$8, x$9, shift, integer, x$10, x$11, fraction, x$12, x$13, allowance, x$14, x$15, targetDiff, integerDigits, _tmp$2, _tmp$3, i$1, pow, x$16, i$2, x$17, pow$1, _q, digit, x$18, x$19, x$20, currentDiff, digit$1, multiplier, x$21, x$22, x$23, x$24; - f = this; - if ((x = f.mant, (x.$high === 0 && x.$low === 0))) { - d.nd = 0; - d.dp = 0; - d.neg = f.neg; - return true; + Time.prototype.Clock = function() { return this.$val.Clock(); }; + absClock = function(abs) { + var hour = 0, min = 0, sec = 0, _q, _q$1; + sec = ($div64(abs, new $Uint64(0, 86400), true).$low >> 0); + hour = (_q = sec / 3600, (_q === _q && _q !== 1/0 && _q !== -1/0) ? _q >> 0 : $throwRuntimeError("integer divide by zero")); + sec = sec - (((((hour >>> 16 << 16) * 3600 >> 0) + (hour << 16 >>> 16) * 3600) >> 0)) >> 0; + min = (_q$1 = sec / 60, (_q$1 === _q$1 && _q$1 !== 1/0 && _q$1 !== -1/0) ? _q$1 >> 0 : $throwRuntimeError("integer divide by zero")); + sec = sec - (((((min >>> 16 << 16) * 60 >> 0) + (min << 16 >>> 16) * 60) >> 0)) >> 0; + return [hour, min, sec]; + }; + Time.Ptr.prototype.Hour = function() { + var t, _q; + t = new Time.Ptr(); $copy(t, this, Time); + return (_q = ($div64(t.abs(), new $Uint64(0, 86400), true).$low >> 0) / 3600, (_q === _q && _q !== 1/0 && _q !== -1/0) ? _q >> 0 : $throwRuntimeError("integer divide by zero")); + }; + Time.prototype.Hour = function() { return this.$val.Hour(); }; + Time.Ptr.prototype.Minute = function() { + var t, _q; + t = new Time.Ptr(); $copy(t, this, Time); + return (_q = ($div64(t.abs(), new $Uint64(0, 3600), true).$low >> 0) / 60, (_q === _q && _q !== 1/0 && _q !== -1/0) ? _q >> 0 : $throwRuntimeError("integer divide by zero")); + }; + Time.prototype.Minute = function() { return this.$val.Minute(); }; + Time.Ptr.prototype.Second = function() { + var t; + t = new Time.Ptr(); $copy(t, this, Time); + return ($div64(t.abs(), new $Uint64(0, 60), true).$low >> 0); + }; + Time.prototype.Second = function() { return this.$val.Second(); }; + Time.Ptr.prototype.Nanosecond = function() { + var t; + t = new Time.Ptr(); $copy(t, this, Time); + return (t.nsec >> 0); + }; + Time.prototype.Nanosecond = function() { return this.$val.Nanosecond(); }; + Time.Ptr.prototype.YearDay = function() { + var t, _tuple$1, yday; + t = new Time.Ptr(); $copy(t, this, Time); + _tuple$1 = t.date(false); yday = _tuple$1[3]; + return yday + 1 >> 0; + }; + Time.prototype.YearDay = function() { return this.$val.YearDay(); }; + Duration.prototype.String = function() { + var d, buf, w, u, neg, prec, unit, x, _tuple$1, _tuple$2; + d = this; + buf = ($arrayType($Uint8, 32)).zero(); $copy(buf, ($arrayType($Uint8, 32)).zero(), ($arrayType($Uint8, 32))); + w = 32; + u = new $Uint64(d.$high, d.$low); + neg = (d.$high < 0 || (d.$high === 0 && d.$low < 0)); + if (neg) { + u = new $Uint64(-u.$high, -u.$low); } - if ((f.exp === 0) && $equal(lower, f, extFloat) && $equal(lower, upper, extFloat)) { - buf = ($arrayType($Uint8, 24)).zero(); $copy(buf, ($arrayType($Uint8, 24)).zero(), ($arrayType($Uint8, 24))); - n = 23; - v = f.mant; - while ((v.$high > 0 || (v.$high === 0 && v.$low > 0))) { - v1 = $div64(v, new $Uint64(0, 10), false); - v = (x$1 = $mul64(new $Uint64(0, 10), v1), new $Uint64(v.$high - x$1.$high, v.$low - x$1.$low)); - (n < 0 || n >= buf.length) ? $throwRuntimeError("index out of range") : buf[n] = (new $Uint64(v.$high + 0, v.$low + 48).$low << 24 >>> 24); - n = n - (1) >> 0; - v = v1; - } - nd = (24 - n >> 0) - 1 >> 0; - i = 0; - while (i < nd) { - (x$3 = d.d, (i < 0 || i >= x$3.$length) ? $throwRuntimeError("index out of range") : x$3.$array[x$3.$offset + i] = (x$2 = (n + 1 >> 0) + i >> 0, ((x$2 < 0 || x$2 >= buf.length) ? $throwRuntimeError("index out of range") : buf[x$2]))); - i = i + (1) >> 0; - } - _tmp = nd; _tmp$1 = nd; d.nd = _tmp; d.dp = _tmp$1; - while (d.nd > 0 && ((x$4 = d.d, x$5 = d.nd - 1 >> 0, ((x$5 < 0 || x$5 >= x$4.$length) ? $throwRuntimeError("index out of range") : x$4.$array[x$4.$offset + x$5])) === 48)) { - d.nd = d.nd - (1) >> 0; + if ((u.$high < 0 || (u.$high === 0 && u.$low < 1000000000))) { + prec = 0; + unit = 0; + if ((u.$high === 0 && u.$low === 0)) { + return "0"; + } else if ((u.$high < 0 || (u.$high === 0 && u.$low < 1000))) { + prec = 0; + unit = 110; + } else if ((u.$high < 0 || (u.$high === 0 && u.$low < 1000000))) { + prec = 3; + unit = 117; + } else { + prec = 6; + unit = 109; } - if (d.nd === 0) { - d.dp = 0; + w = w - (2) >> 0; + (w < 0 || w >= buf.length) ? $throwRuntimeError("index out of range") : buf[w] = unit; + (x = w + 1 >> 0, (x < 0 || x >= buf.length) ? $throwRuntimeError("index out of range") : buf[x] = 115); + _tuple$1 = fmtFrac($subslice(new ($sliceType($Uint8))(buf), 0, w), u, prec); w = _tuple$1[0]; u = _tuple$1[1]; + w = fmtInt($subslice(new ($sliceType($Uint8))(buf), 0, w), u); + } else { + w = w - (1) >> 0; + (w < 0 || w >= buf.length) ? $throwRuntimeError("index out of range") : buf[w] = 115; + _tuple$2 = fmtFrac($subslice(new ($sliceType($Uint8))(buf), 0, w), u, 9); w = _tuple$2[0]; u = _tuple$2[1]; + w = fmtInt($subslice(new ($sliceType($Uint8))(buf), 0, w), $div64(u, new $Uint64(0, 60), true)); + u = $div64(u, (new $Uint64(0, 60)), false); + if ((u.$high > 0 || (u.$high === 0 && u.$low > 0))) { + w = w - (1) >> 0; + (w < 0 || w >= buf.length) ? $throwRuntimeError("index out of range") : buf[w] = 109; + w = fmtInt($subslice(new ($sliceType($Uint8))(buf), 0, w), $div64(u, new $Uint64(0, 60), true)); + u = $div64(u, (new $Uint64(0, 60)), false); + if ((u.$high > 0 || (u.$high === 0 && u.$low > 0))) { + w = w - (1) >> 0; + (w < 0 || w >= buf.length) ? $throwRuntimeError("index out of range") : buf[w] = 104; + w = fmtInt($subslice(new ($sliceType($Uint8))(buf), 0, w), u); + } } - d.neg = f.neg; - return true; - } - upper.Normalize(); - if (f.exp > upper.exp) { - f.mant = $shiftLeft64(f.mant, (((f.exp - upper.exp >> 0) >>> 0))); - f.exp = upper.exp; } - if (lower.exp > upper.exp) { - lower.mant = $shiftLeft64(lower.mant, (((lower.exp - upper.exp >> 0) >>> 0))); - lower.exp = upper.exp; + if (neg) { + w = w - (1) >> 0; + (w < 0 || w >= buf.length) ? $throwRuntimeError("index out of range") : buf[w] = 45; } - exp10 = frexp10Many(lower, f, upper); - upper.mant = (x$6 = upper.mant, x$7 = new $Uint64(0, 1), new $Uint64(x$6.$high + x$7.$high, x$6.$low + x$7.$low)); - lower.mant = (x$8 = lower.mant, x$9 = new $Uint64(0, 1), new $Uint64(x$8.$high - x$9.$high, x$8.$low - x$9.$low)); - shift = (-upper.exp >>> 0); - integer = ($shiftRightUint64(upper.mant, shift).$low >>> 0); - fraction = (x$10 = upper.mant, x$11 = $shiftLeft64(new $Uint64(0, integer), shift), new $Uint64(x$10.$high - x$11.$high, x$10.$low - x$11.$low)); - allowance = (x$12 = upper.mant, x$13 = lower.mant, new $Uint64(x$12.$high - x$13.$high, x$12.$low - x$13.$low)); - targetDiff = (x$14 = upper.mant, x$15 = f.mant, new $Uint64(x$14.$high - x$15.$high, x$14.$low - x$15.$low)); - integerDigits = 0; - _tmp$2 = 0; _tmp$3 = new $Uint64(0, 1); i$1 = _tmp$2; pow = _tmp$3; - while (i$1 < 20) { - if ((x$16 = new $Uint64(0, integer), (pow.$high > x$16.$high || (pow.$high === x$16.$high && pow.$low > x$16.$low)))) { - integerDigits = i$1; - break; + return $bytesToString($subslice(new ($sliceType($Uint8))(buf), w)); + }; + $ptrType(Duration).prototype.String = function() { return this.$get().String(); }; + fmtFrac = function(buf, v, prec) { + var nw = 0, nv = new $Uint64(0, 0), w, print, i, digit, _tmp, _tmp$1; + w = buf.$length; + print = false; + i = 0; + while (i < prec) { + digit = $div64(v, new $Uint64(0, 10), true); + print = print || !((digit.$high === 0 && digit.$low === 0)); + if (print) { + w = w - (1) >> 0; + (w < 0 || w >= buf.$length) ? $throwRuntimeError("index out of range") : buf.$array[buf.$offset + w] = (digit.$low << 24 >>> 24) + 48 << 24 >>> 24; } - pow = $mul64(pow, (new $Uint64(0, 10))); - i$1 = i$1 + (1) >> 0; + v = $div64(v, (new $Uint64(0, 10)), false); + i = i + (1) >> 0; } - i$2 = 0; - while (i$2 < integerDigits) { - pow$1 = (x$17 = (integerDigits - i$2 >> 0) - 1 >> 0, ((x$17 < 0 || x$17 >= uint64pow10.length) ? $throwRuntimeError("index out of range") : uint64pow10[x$17])); - digit = (_q = integer / (pow$1.$low >>> 0), (_q === _q && _q !== 1/0 && _q !== -1/0) ? _q >>> 0 : $throwRuntimeError("integer divide by zero")); - (x$18 = d.d, (i$2 < 0 || i$2 >= x$18.$length) ? $throwRuntimeError("index out of range") : x$18.$array[x$18.$offset + i$2] = ((digit + 48 >>> 0) << 24 >>> 24)); - integer = integer - ((x$19 = (pow$1.$low >>> 0), (((digit >>> 16 << 16) * x$19 >>> 0) + (digit << 16 >>> 16) * x$19) >>> 0)) >>> 0; - currentDiff = (x$20 = $shiftLeft64(new $Uint64(0, integer), shift), new $Uint64(x$20.$high + fraction.$high, x$20.$low + fraction.$low)); - if ((currentDiff.$high < allowance.$high || (currentDiff.$high === allowance.$high && currentDiff.$low < allowance.$low))) { - d.nd = i$2 + 1 >> 0; - d.dp = integerDigits + exp10 >> 0; - d.neg = f.neg; - return adjustLastDigit(d, currentDiff, targetDiff, allowance, $shiftLeft64(pow$1, shift), new $Uint64(0, 2)); - } - i$2 = i$2 + (1) >> 0; + if (print) { + w = w - (1) >> 0; + (w < 0 || w >= buf.$length) ? $throwRuntimeError("index out of range") : buf.$array[buf.$offset + w] = 46; } - d.nd = integerDigits; - d.dp = d.nd + exp10 >> 0; - d.neg = f.neg; - digit$1 = 0; - multiplier = new $Uint64(0, 1); - while (true) { - fraction = $mul64(fraction, (new $Uint64(0, 10))); - multiplier = $mul64(multiplier, (new $Uint64(0, 10))); - digit$1 = ($shiftRightUint64(fraction, shift).$low >> 0); - (x$21 = d.d, x$22 = d.nd, (x$22 < 0 || x$22 >= x$21.$length) ? $throwRuntimeError("index out of range") : x$21.$array[x$21.$offset + x$22] = ((digit$1 + 48 >> 0) << 24 >>> 24)); - d.nd = d.nd + (1) >> 0; - fraction = (x$23 = $shiftLeft64(new $Uint64(0, digit$1), shift), new $Uint64(fraction.$high - x$23.$high, fraction.$low - x$23.$low)); - if ((x$24 = $mul64(allowance, multiplier), (fraction.$high < x$24.$high || (fraction.$high === x$24.$high && fraction.$low < x$24.$low)))) { - return adjustLastDigit(d, fraction, $mul64(targetDiff, multiplier), $mul64(allowance, multiplier), $shiftLeft64(new $Uint64(0, 1), shift), $mul64(multiplier, new $Uint64(0, 2))); + _tmp = w; _tmp$1 = v; nw = _tmp; nv = _tmp$1; + return [nw, nv]; + }; + fmtInt = function(buf, v) { + var w; + w = buf.$length; + if ((v.$high === 0 && v.$low === 0)) { + w = w - (1) >> 0; + (w < 0 || w >= buf.$length) ? $throwRuntimeError("index out of range") : buf.$array[buf.$offset + w] = 48; + } else { + while ((v.$high > 0 || (v.$high === 0 && v.$low > 0))) { + w = w - (1) >> 0; + (w < 0 || w >= buf.$length) ? $throwRuntimeError("index out of range") : buf.$array[buf.$offset + w] = ($div64(v, new $Uint64(0, 10), true).$low << 24 >>> 24) + 48 << 24 >>> 24; + v = $div64(v, (new $Uint64(0, 10)), false); } } + return w; }; - extFloat.prototype.ShortestDecimal = function(d, lower, upper) { return this.$val.ShortestDecimal(d, lower, upper); }; - adjustLastDigit = function(d, currentDiff, targetDiff, maxDiff, ulpDecimal, ulpBinary) { - var x, x$1, x$2, x$3, _lhs, _index, x$4, x$5, x$6, x$7, x$8, x$9, x$10; - if ((x = $mul64(new $Uint64(0, 2), ulpBinary), (ulpDecimal.$high < x.$high || (ulpDecimal.$high === x.$high && ulpDecimal.$low < x.$low)))) { - return false; - } - while ((x$1 = (x$2 = (x$3 = $div64(ulpDecimal, new $Uint64(0, 2), false), new $Uint64(currentDiff.$high + x$3.$high, currentDiff.$low + x$3.$low)), new $Uint64(x$2.$high + ulpBinary.$high, x$2.$low + ulpBinary.$low)), (x$1.$high < targetDiff.$high || (x$1.$high === targetDiff.$high && x$1.$low < targetDiff.$low)))) { - _lhs = d.d; _index = d.nd - 1 >> 0; (_index < 0 || _index >= _lhs.$length) ? $throwRuntimeError("index out of range") : _lhs.$array[_lhs.$offset + _index] = ((_index < 0 || _index >= _lhs.$length) ? $throwRuntimeError("index out of range") : _lhs.$array[_lhs.$offset + _index]) - (1) << 24 >>> 24; - currentDiff = (x$4 = ulpDecimal, new $Uint64(currentDiff.$high + x$4.$high, currentDiff.$low + x$4.$low)); - } - if ((x$5 = new $Uint64(currentDiff.$high + ulpDecimal.$high, currentDiff.$low + ulpDecimal.$low), x$6 = (x$7 = (x$8 = $div64(ulpDecimal, new $Uint64(0, 2), false), new $Uint64(targetDiff.$high + x$8.$high, targetDiff.$low + x$8.$low)), new $Uint64(x$7.$high + ulpBinary.$high, x$7.$low + ulpBinary.$low)), (x$5.$high < x$6.$high || (x$5.$high === x$6.$high && x$5.$low <= x$6.$low)))) { - return false; - } - if ((currentDiff.$high < ulpBinary.$high || (currentDiff.$high === ulpBinary.$high && currentDiff.$low < ulpBinary.$low)) || (x$9 = new $Uint64(maxDiff.$high - ulpBinary.$high, maxDiff.$low - ulpBinary.$low), (currentDiff.$high > x$9.$high || (currentDiff.$high === x$9.$high && currentDiff.$low > x$9.$low)))) { - return false; + Duration.prototype.Nanoseconds = function() { + var d; + d = this; + return new $Int64(d.$high, d.$low); + }; + $ptrType(Duration).prototype.Nanoseconds = function() { return this.$get().Nanoseconds(); }; + Duration.prototype.Seconds = function() { + var d, sec, nsec; + d = this; + sec = $div64(d, new Duration(0, 1000000000), false); + nsec = $div64(d, new Duration(0, 1000000000), true); + return $flatten64(sec) + $flatten64(nsec) * 1e-09; + }; + $ptrType(Duration).prototype.Seconds = function() { return this.$get().Seconds(); }; + Duration.prototype.Minutes = function() { + var d, min, nsec; + d = this; + min = $div64(d, new Duration(13, 4165425152), false); + nsec = $div64(d, new Duration(13, 4165425152), true); + return $flatten64(min) + $flatten64(nsec) * 1.6666666666666667e-11; + }; + $ptrType(Duration).prototype.Minutes = function() { return this.$get().Minutes(); }; + Duration.prototype.Hours = function() { + var d, hour, nsec; + d = this; + hour = $div64(d, new Duration(838, 817405952), false); + nsec = $div64(d, new Duration(838, 817405952), true); + return $flatten64(hour) + $flatten64(nsec) * 2.777777777777778e-13; + }; + $ptrType(Duration).prototype.Hours = function() { return this.$get().Hours(); }; + Time.Ptr.prototype.Add = function(d) { + var t, x, x$1, x$2, x$3, nsec, x$4, x$5, x$6, x$7; + t = new Time.Ptr(); $copy(t, this, Time); + t.sec = (x = t.sec, x$1 = (x$2 = $div64(d, new Duration(0, 1000000000), false), new $Int64(x$2.$high, x$2.$low)), new $Int64(x.$high + x$1.$high, x.$low + x$1.$low)); + nsec = (t.nsec >> 0) + ((x$3 = $div64(d, new Duration(0, 1000000000), true), x$3.$low + ((x$3.$high >> 31) * 4294967296)) >> 0) >> 0; + if (nsec >= 1000000000) { + t.sec = (x$4 = t.sec, x$5 = new $Int64(0, 1), new $Int64(x$4.$high + x$5.$high, x$4.$low + x$5.$low)); + nsec = nsec - (1000000000) >> 0; + } else if (nsec < 0) { + t.sec = (x$6 = t.sec, x$7 = new $Int64(0, 1), new $Int64(x$6.$high - x$7.$high, x$6.$low - x$7.$low)); + nsec = nsec + (1000000000) >> 0; } - if ((d.nd === 1) && ((x$10 = d.d, ((0 < 0 || 0 >= x$10.$length) ? $throwRuntimeError("index out of range") : x$10.$array[x$10.$offset + 0])) === 48)) { - d.nd = 0; - d.dp = 0; + t.nsec = (nsec >>> 0); + return t; + }; + Time.prototype.Add = function(d) { return this.$val.Add(d); }; + Time.Ptr.prototype.Sub = function(u) { + var t, x, x$1, x$2, x$3, x$4, d; + t = new Time.Ptr(); $copy(t, this, Time); + d = (x = $mul64((x$1 = (x$2 = t.sec, x$3 = u.sec, new $Int64(x$2.$high - x$3.$high, x$2.$low - x$3.$low)), new Duration(x$1.$high, x$1.$low)), new Duration(0, 1000000000)), x$4 = new Duration(0, ((t.nsec >> 0) - (u.nsec >> 0) >> 0)), new Duration(x.$high + x$4.$high, x.$low + x$4.$low)); + if (u.Add(d).Equal($clone(t, Time))) { + return d; + } else if (t.Before($clone(u, Time))) { + return new Duration(-2147483648, 0); + } else { + return new Duration(2147483647, 4294967295); } - return true; }; - FormatFloat = $pkg.FormatFloat = function(f, fmt, prec, bitSize) { - return $bytesToString(genericFtoa(($sliceType($Uint8)).make(0, max(prec + 4 >> 0, 24)), f, fmt, prec, bitSize)); + Time.prototype.Sub = function(u) { return this.$val.Sub(u); }; + Time.Ptr.prototype.AddDate = function(years, months$1, days$1) { + var t, _tuple$1, year, month, day, _tuple$2, hour, min, sec; + t = new Time.Ptr(); $copy(t, this, Time); + _tuple$1 = t.Date(); year = _tuple$1[0]; month = _tuple$1[1]; day = _tuple$1[2]; + _tuple$2 = t.Clock(); hour = _tuple$2[0]; min = _tuple$2[1]; sec = _tuple$2[2]; + return Date(year + years >> 0, month + (months$1 >> 0) >> 0, day + days$1 >> 0, hour, min, sec, (t.nsec >> 0), t.loc); }; - AppendFloat = $pkg.AppendFloat = function(dst, f, fmt, prec, bitSize) { - return genericFtoa(dst, f, fmt, prec, bitSize); + Time.prototype.AddDate = function(years, months$1, days$1) { return this.$val.AddDate(years, months$1, days$1); }; + Time.Ptr.prototype.date = function(full) { + var year = 0, month = 0, day = 0, yday = 0, t, _tuple$1; + t = new Time.Ptr(); $copy(t, this, Time); + _tuple$1 = absDate(t.abs(), full); year = _tuple$1[0]; month = _tuple$1[1]; day = _tuple$1[2]; yday = _tuple$1[3]; + return [year, month, day, yday]; }; - genericFtoa = function(dst, val, fmt, prec, bitSize) { - var bits, flt, _ref, x, neg, y, exp, x$1, x$2, mant, _ref$1, y$1, s, x$3, digs, ok, shortest, f, _tuple, lower, upper, buf, _ref$2, digits, _ref$3, buf$1, f$1; - bits = new $Uint64(0, 0); - flt = ($ptrType(floatInfo)).nil; - _ref = bitSize; - if (_ref === 32) { - bits = new $Uint64(0, math.Float32bits(val)); - flt = float32info; - } else if (_ref === 64) { - bits = math.Float64bits(val); - flt = float64info; - } else { - $panic(new $String("strconv: illegal AppendFloat/FormatFloat bitSize")); + Time.prototype.date = function(full) { return this.$val.date(full); }; + absDate = function(abs, full) { + var year = 0, month = 0, day = 0, yday = 0, d, n, y, x, x$1, x$2, x$3, x$4, x$5, x$6, x$7, x$8, x$9, x$10, _q, x$11, end, begin; + d = $div64(abs, new $Uint64(0, 86400), false); + n = $div64(d, new $Uint64(0, 146097), false); + y = $mul64(new $Uint64(0, 400), n); + d = (x = $mul64(new $Uint64(0, 146097), n), new $Uint64(d.$high - x.$high, d.$low - x.$low)); + n = $div64(d, new $Uint64(0, 36524), false); + n = (x$1 = $shiftRightUint64(n, 2), new $Uint64(n.$high - x$1.$high, n.$low - x$1.$low)); + y = (x$2 = $mul64(new $Uint64(0, 100), n), new $Uint64(y.$high + x$2.$high, y.$low + x$2.$low)); + d = (x$3 = $mul64(new $Uint64(0, 36524), n), new $Uint64(d.$high - x$3.$high, d.$low - x$3.$low)); + n = $div64(d, new $Uint64(0, 1461), false); + y = (x$4 = $mul64(new $Uint64(0, 4), n), new $Uint64(y.$high + x$4.$high, y.$low + x$4.$low)); + d = (x$5 = $mul64(new $Uint64(0, 1461), n), new $Uint64(d.$high - x$5.$high, d.$low - x$5.$low)); + n = $div64(d, new $Uint64(0, 365), false); + n = (x$6 = $shiftRightUint64(n, 2), new $Uint64(n.$high - x$6.$high, n.$low - x$6.$low)); + y = (x$7 = n, new $Uint64(y.$high + x$7.$high, y.$low + x$7.$low)); + d = (x$8 = $mul64(new $Uint64(0, 365), n), new $Uint64(d.$high - x$8.$high, d.$low - x$8.$low)); + year = ((x$9 = (x$10 = new $Int64(y.$high, y.$low), new $Int64(x$10.$high + -69, x$10.$low + 4075721025)), x$9.$low + ((x$9.$high >> 31) * 4294967296)) >> 0); + yday = (d.$low >> 0); + if (!full) { + return [year, month, day, yday]; } - neg = !((x = $shiftRightUint64(bits, ((flt.expbits + flt.mantbits >>> 0))), (x.$high === 0 && x.$low === 0))); - exp = ($shiftRightUint64(bits, flt.mantbits).$low >> 0) & ((((y = flt.expbits, y < 32 ? (1 << y) : 0) >> 0) - 1 >> 0)); - mant = (x$1 = (x$2 = $shiftLeft64(new $Uint64(0, 1), flt.mantbits), new $Uint64(x$2.$high - 0, x$2.$low - 1)), new $Uint64(bits.$high & x$1.$high, (bits.$low & x$1.$low) >>> 0)); - _ref$1 = exp; - if (_ref$1 === (((y$1 = flt.expbits, y$1 < 32 ? (1 << y$1) : 0) >> 0) - 1 >> 0)) { - s = ""; - if (!((mant.$high === 0 && mant.$low === 0))) { - s = "NaN"; - } else if (neg) { - s = "-Inf"; - } else { - s = "+Inf"; + day = yday; + if (isLeap(year)) { + if (day > 59) { + day = day - (1) >> 0; + } else if (day === 59) { + month = 2; + day = 29; + return [year, month, day, yday]; } - return $appendSlice(dst, new ($sliceType($Uint8))($stringToBytes(s))); - } else if (_ref$1 === 0) { - exp = exp + (1) >> 0; - } else { - mant = (x$3 = $shiftLeft64(new $Uint64(0, 1), flt.mantbits), new $Uint64(mant.$high | x$3.$high, (mant.$low | x$3.$low) >>> 0)); - } - exp = exp + (flt.bias) >> 0; - if (fmt === 98) { - return fmtB(dst, neg, mant, exp, flt); } - if (!optimize) { - return bigFtoa(dst, prec, fmt, neg, mant, exp, flt); + month = ((_q = day / 31, (_q === _q && _q !== 1/0 && _q !== -1/0) ? _q >> 0 : $throwRuntimeError("integer divide by zero")) >> 0); + end = ((x$11 = month + 1 >> 0, ((x$11 < 0 || x$11 >= daysBefore.length) ? $throwRuntimeError("index out of range") : daysBefore[x$11])) >> 0); + begin = 0; + if (day >= end) { + month = month + (1) >> 0; + begin = end; + } else { + begin = (((month < 0 || month >= daysBefore.length) ? $throwRuntimeError("index out of range") : daysBefore[month]) >> 0); } - digs = new decimalSlice.Ptr(); $copy(digs, new decimalSlice.Ptr(), decimalSlice); - ok = false; - shortest = prec < 0; - if (shortest) { - f = new extFloat.Ptr(); - _tuple = f.AssignComputeBounds(mant, exp, neg, flt); lower = new extFloat.Ptr(); $copy(lower, _tuple[0], extFloat); upper = new extFloat.Ptr(); $copy(upper, _tuple[1], extFloat); - buf = ($arrayType($Uint8, 32)).zero(); $copy(buf, ($arrayType($Uint8, 32)).zero(), ($arrayType($Uint8, 32))); - digs.d = new ($sliceType($Uint8))(buf); - ok = f.ShortestDecimal(digs, lower, upper); - if (!ok) { - return bigFtoa(dst, prec, fmt, neg, mant, exp, flt); - } - _ref$2 = fmt; - if (_ref$2 === 101 || _ref$2 === 69) { - prec = digs.nd - 1 >> 0; - } else if (_ref$2 === 102) { - prec = max(digs.nd - digs.dp >> 0, 0); - } else if (_ref$2 === 103 || _ref$2 === 71) { - prec = digs.nd; - } - } else if (!((fmt === 102))) { - digits = prec; - _ref$3 = fmt; - if (_ref$3 === 101 || _ref$3 === 69) { - digits = digits + (1) >> 0; - } else if (_ref$3 === 103 || _ref$3 === 71) { - if (prec === 0) { - prec = 1; - } - digits = prec; - } - if (digits <= 15) { - buf$1 = ($arrayType($Uint8, 24)).zero(); $copy(buf$1, ($arrayType($Uint8, 24)).zero(), ($arrayType($Uint8, 24))); - digs.d = new ($sliceType($Uint8))(buf$1); - f$1 = new extFloat.Ptr(mant, exp - (flt.mantbits >> 0) >> 0, neg); - ok = f$1.FixedDecimal(digs, digits); - } - } - if (!ok) { - return bigFtoa(dst, prec, fmt, neg, mant, exp, flt); + month = month + (1) >> 0; + day = (day - begin >> 0) + 1 >> 0; + return [year, month, day, yday]; + }; + Now = $pkg.Now = function() { + var _tuple$1, sec, nsec; + _tuple$1 = now(); sec = _tuple$1[0]; nsec = _tuple$1[1]; + return new Time.Ptr(new $Int64(sec.$high + 14, sec.$low + 2006054656), (nsec >>> 0), $pkg.Local); + }; + Time.Ptr.prototype.UTC = function() { + var t; + t = new Time.Ptr(); $copy(t, this, Time); + t.loc = $pkg.UTC; + return t; + }; + Time.prototype.UTC = function() { return this.$val.UTC(); }; + Time.Ptr.prototype.Local = function() { + var t; + t = new Time.Ptr(); $copy(t, this, Time); + t.loc = $pkg.Local; + return t; + }; + Time.prototype.Local = function() { return this.$val.Local(); }; + Time.Ptr.prototype.In = function(loc) { + var t; + t = new Time.Ptr(); $copy(t, this, Time); + if (loc === ($ptrType(Location)).nil) { + $panic(new $String("time: missing Location in call to Time.In")); } - return formatDigits(dst, shortest, neg, $clone(digs, decimalSlice), prec, fmt); + t.loc = loc; + return t; }; - bigFtoa = function(dst, prec, fmt, neg, mant, exp, flt) { - var d, digs, shortest, _ref, _ref$1; - d = new decimal.Ptr(); - d.Assign(mant); - d.Shift(exp - (flt.mantbits >> 0) >> 0); - digs = new decimalSlice.Ptr(); $copy(digs, new decimalSlice.Ptr(), decimalSlice); - shortest = prec < 0; - if (shortest) { - roundShortest(d, mant, exp, flt); - $copy(digs, new decimalSlice.Ptr(new ($sliceType($Uint8))(d.d), d.nd, d.dp, false), decimalSlice); - _ref = fmt; - if (_ref === 101 || _ref === 69) { - prec = digs.nd - 1 >> 0; - } else if (_ref === 102) { - prec = max(digs.nd - digs.dp >> 0, 0); - } else if (_ref === 103 || _ref === 71) { - prec = digs.nd; - } - } else { - _ref$1 = fmt; - if (_ref$1 === 101 || _ref$1 === 69) { - d.Round(prec + 1 >> 0); - } else if (_ref$1 === 102) { - d.Round(d.dp + prec >> 0); - } else if (_ref$1 === 103 || _ref$1 === 71) { - if (prec === 0) { - prec = 1; - } - d.Round(prec); - } - $copy(digs, new decimalSlice.Ptr(new ($sliceType($Uint8))(d.d), d.nd, d.dp, false), decimalSlice); + Time.prototype.In = function(loc) { return this.$val.In(loc); }; + Time.Ptr.prototype.Location = function() { + var t, l; + t = new Time.Ptr(); $copy(t, this, Time); + l = t.loc; + if (l === ($ptrType(Location)).nil) { + l = $pkg.UTC; } - return formatDigits(dst, shortest, neg, $clone(digs, decimalSlice), prec, fmt); + return l; }; - formatDigits = function(dst, shortest, neg, digs, prec, fmt) { - var _ref, eprec, exp; - _ref = fmt; - if (_ref === 101 || _ref === 69) { - return fmtE(dst, neg, $clone(digs, decimalSlice), prec, fmt); - } else if (_ref === 102) { - return fmtF(dst, neg, $clone(digs, decimalSlice), prec); - } else if (_ref === 103 || _ref === 71) { - eprec = prec; - if (eprec > digs.nd && digs.nd >= digs.dp) { - eprec = digs.nd; - } - if (shortest) { - eprec = 6; - } - exp = digs.dp - 1 >> 0; - if (exp < -4 || exp >= eprec) { - if (prec > digs.nd) { - prec = digs.nd; - } - return fmtE(dst, neg, $clone(digs, decimalSlice), prec - 1 >> 0, (fmt + 101 << 24 >>> 24) - 103 << 24 >>> 24); + Time.prototype.Location = function() { return this.$val.Location(); }; + Time.Ptr.prototype.Zone = function() { + var name = "", offset = 0, t, _tuple$1, x; + t = new Time.Ptr(); $copy(t, this, Time); + _tuple$1 = t.loc.lookup((x = t.sec, new $Int64(x.$high + -15, x.$low + 2288912640))); name = _tuple$1[0]; offset = _tuple$1[1]; + return [name, offset]; + }; + Time.prototype.Zone = function() { return this.$val.Zone(); }; + Time.Ptr.prototype.Unix = function() { + var t, x; + t = new Time.Ptr(); $copy(t, this, Time); + return (x = t.sec, new $Int64(x.$high + -15, x.$low + 2288912640)); + }; + Time.prototype.Unix = function() { return this.$val.Unix(); }; + Time.Ptr.prototype.UnixNano = function() { + var t, x, x$1, x$2, x$3; + t = new Time.Ptr(); $copy(t, this, Time); + return (x = $mul64(((x$1 = t.sec, new $Int64(x$1.$high + -15, x$1.$low + 2288912640))), new $Int64(0, 1000000000)), x$2 = (x$3 = t.nsec, new $Int64(0, x$3.constructor === Number ? x$3 : 1)), new $Int64(x.$high + x$2.$high, x.$low + x$2.$low)); + }; + Time.prototype.UnixNano = function() { return this.$val.UnixNano(); }; + Time.Ptr.prototype.MarshalBinary = function() { + var t, offsetMin, _tuple$1, offset, _r, _q, enc; + t = new Time.Ptr(); $copy(t, this, Time); + offsetMin = 0; + if (t.Location() === utcLoc) { + offsetMin = -1; + } else { + _tuple$1 = t.Zone(); offset = _tuple$1[1]; + if (!(((_r = offset % 60, _r === _r ? _r : $throwRuntimeError("integer divide by zero")) === 0))) { + return [($sliceType($Uint8)).nil, errors.New("Time.MarshalBinary: zone offset has fractional minute")]; } - if (prec > digs.dp) { - prec = digs.nd; + offset = (_q = offset / (60), (_q === _q && _q !== 1/0 && _q !== -1/0) ? _q >> 0 : $throwRuntimeError("integer divide by zero")); + if (offset < -32768 || (offset === -1) || offset > 32767) { + return [($sliceType($Uint8)).nil, errors.New("Time.MarshalBinary: unexpected zone offset")]; } - return fmtF(dst, neg, $clone(digs, decimalSlice), max(prec - digs.dp >> 0, 0)); + offsetMin = (offset << 16 >> 16); } - return $append(dst, 37, fmt); + enc = new ($sliceType($Uint8))([1, ($shiftRightInt64(t.sec, 56).$low << 24 >>> 24), ($shiftRightInt64(t.sec, 48).$low << 24 >>> 24), ($shiftRightInt64(t.sec, 40).$low << 24 >>> 24), ($shiftRightInt64(t.sec, 32).$low << 24 >>> 24), ($shiftRightInt64(t.sec, 24).$low << 24 >>> 24), ($shiftRightInt64(t.sec, 16).$low << 24 >>> 24), ($shiftRightInt64(t.sec, 8).$low << 24 >>> 24), (t.sec.$low << 24 >>> 24), ((t.nsec >>> 24 >>> 0) << 24 >>> 24), ((t.nsec >>> 16 >>> 0) << 24 >>> 24), ((t.nsec >>> 8 >>> 0) << 24 >>> 24), (t.nsec << 24 >>> 24), ((offsetMin >> 8 << 16 >> 16) << 24 >>> 24), (offsetMin << 24 >>> 24)]); + return [enc, $ifaceNil]; }; - roundShortest = function(d, mant, exp, flt) { - var minexp, x, x$1, upper, x$2, mantlo, explo, x$3, x$4, lower, x$5, x$6, inclusive, i, _tmp, _tmp$1, _tmp$2, l, m, u, x$7, x$8, x$9, okdown, okup; - if ((mant.$high === 0 && mant.$low === 0)) { - d.nd = 0; - return; + Time.prototype.MarshalBinary = function() { return this.$val.MarshalBinary(); }; + Time.Ptr.prototype.UnmarshalBinary = function(data$1) { + var t, buf, x, x$1, x$2, x$3, x$4, x$5, x$6, x$7, x$8, x$9, x$10, x$11, x$12, x$13, x$14, offset, _tuple$1, x$15, localoff; + t = this; + buf = data$1; + if (buf.$length === 0) { + return errors.New("Time.UnmarshalBinary: no data"); } - minexp = flt.bias + 1 >> 0; - if (exp > minexp && (x = (d.dp - d.nd >> 0), (((332 >>> 16 << 16) * x >> 0) + (332 << 16 >>> 16) * x) >> 0) >= (x$1 = (exp - (flt.mantbits >> 0) >> 0), (((100 >>> 16 << 16) * x$1 >> 0) + (100 << 16 >>> 16) * x$1) >> 0)) { - return; + if (!((((0 < 0 || 0 >= buf.$length) ? $throwRuntimeError("index out of range") : buf.$array[buf.$offset + 0]) === 1))) { + return errors.New("Time.UnmarshalBinary: unsupported version"); } - upper = new decimal.Ptr(); - upper.Assign((x$2 = $mul64(mant, new $Uint64(0, 2)), new $Uint64(x$2.$high + 0, x$2.$low + 1))); - upper.Shift((exp - (flt.mantbits >> 0) >> 0) - 1 >> 0); - mantlo = new $Uint64(0, 0); - explo = 0; - if ((x$3 = $shiftLeft64(new $Uint64(0, 1), flt.mantbits), (mant.$high > x$3.$high || (mant.$high === x$3.$high && mant.$low > x$3.$low))) || (exp === minexp)) { - mantlo = new $Uint64(mant.$high - 0, mant.$low - 1); - explo = exp; - } else { - mantlo = (x$4 = $mul64(mant, new $Uint64(0, 2)), new $Uint64(x$4.$high - 0, x$4.$low - 1)); - explo = exp - 1 >> 0; + if (!((buf.$length === 15))) { + return errors.New("Time.UnmarshalBinary: invalid length"); } - lower = new decimal.Ptr(); - lower.Assign((x$5 = $mul64(mantlo, new $Uint64(0, 2)), new $Uint64(x$5.$high + 0, x$5.$low + 1))); - lower.Shift((explo - (flt.mantbits >> 0) >> 0) - 1 >> 0); - inclusive = (x$6 = $div64(mant, new $Uint64(0, 2), true), (x$6.$high === 0 && x$6.$low === 0)); - i = 0; - while (i < d.nd) { - _tmp = 0; _tmp$1 = 0; _tmp$2 = 0; l = _tmp; m = _tmp$1; u = _tmp$2; - if (i < lower.nd) { - l = (x$7 = lower.d, ((i < 0 || i >= x$7.length) ? $throwRuntimeError("index out of range") : x$7[i])); - } else { - l = 48; - } - m = (x$8 = d.d, ((i < 0 || i >= x$8.length) ? $throwRuntimeError("index out of range") : x$8[i])); - if (i < upper.nd) { - u = (x$9 = upper.d, ((i < 0 || i >= x$9.length) ? $throwRuntimeError("index out of range") : x$9[i])); + buf = $subslice(buf, 1); + t.sec = (x = (x$1 = (x$2 = (x$3 = (x$4 = (x$5 = (x$6 = new $Int64(0, ((7 < 0 || 7 >= buf.$length) ? $throwRuntimeError("index out of range") : buf.$array[buf.$offset + 7])), x$7 = $shiftLeft64(new $Int64(0, ((6 < 0 || 6 >= buf.$length) ? $throwRuntimeError("index out of range") : buf.$array[buf.$offset + 6])), 8), new $Int64(x$6.$high | x$7.$high, (x$6.$low | x$7.$low) >>> 0)), x$8 = $shiftLeft64(new $Int64(0, ((5 < 0 || 5 >= buf.$length) ? $throwRuntimeError("index out of range") : buf.$array[buf.$offset + 5])), 16), new $Int64(x$5.$high | x$8.$high, (x$5.$low | x$8.$low) >>> 0)), x$9 = $shiftLeft64(new $Int64(0, ((4 < 0 || 4 >= buf.$length) ? $throwRuntimeError("index out of range") : buf.$array[buf.$offset + 4])), 24), new $Int64(x$4.$high | x$9.$high, (x$4.$low | x$9.$low) >>> 0)), x$10 = $shiftLeft64(new $Int64(0, ((3 < 0 || 3 >= buf.$length) ? $throwRuntimeError("index out of range") : buf.$array[buf.$offset + 3])), 32), new $Int64(x$3.$high | x$10.$high, (x$3.$low | x$10.$low) >>> 0)), x$11 = $shiftLeft64(new $Int64(0, ((2 < 0 || 2 >= buf.$length) ? $throwRuntimeError("index out of range") : buf.$array[buf.$offset + 2])), 40), new $Int64(x$2.$high | x$11.$high, (x$2.$low | x$11.$low) >>> 0)), x$12 = $shiftLeft64(new $Int64(0, ((1 < 0 || 1 >= buf.$length) ? $throwRuntimeError("index out of range") : buf.$array[buf.$offset + 1])), 48), new $Int64(x$1.$high | x$12.$high, (x$1.$low | x$12.$low) >>> 0)), x$13 = $shiftLeft64(new $Int64(0, ((0 < 0 || 0 >= buf.$length) ? $throwRuntimeError("index out of range") : buf.$array[buf.$offset + 0])), 56), new $Int64(x.$high | x$13.$high, (x.$low | x$13.$low) >>> 0)); + buf = $subslice(buf, 8); + t.nsec = (((((((3 < 0 || 3 >= buf.$length) ? $throwRuntimeError("index out of range") : buf.$array[buf.$offset + 3]) >> 0) | ((((2 < 0 || 2 >= buf.$length) ? $throwRuntimeError("index out of range") : buf.$array[buf.$offset + 2]) >> 0) << 8 >> 0)) | ((((1 < 0 || 1 >= buf.$length) ? $throwRuntimeError("index out of range") : buf.$array[buf.$offset + 1]) >> 0) << 16 >> 0)) | ((((0 < 0 || 0 >= buf.$length) ? $throwRuntimeError("index out of range") : buf.$array[buf.$offset + 0]) >> 0) << 24 >> 0)) >>> 0); + buf = $subslice(buf, 4); + offset = (x$14 = (((((1 < 0 || 1 >= buf.$length) ? $throwRuntimeError("index out of range") : buf.$array[buf.$offset + 1]) << 16 >> 16) | ((((0 < 0 || 0 >= buf.$length) ? $throwRuntimeError("index out of range") : buf.$array[buf.$offset + 0]) << 16 >> 16) << 8 << 16 >> 16)) >> 0), (((x$14 >>> 16 << 16) * 60 >> 0) + (x$14 << 16 >>> 16) * 60) >> 0); + if (offset === -60) { + t.loc = utcLoc; + } else { + _tuple$1 = $pkg.Local.lookup((x$15 = t.sec, new $Int64(x$15.$high + -15, x$15.$low + 2288912640))); localoff = _tuple$1[1]; + if (offset === localoff) { + t.loc = $pkg.Local; } else { - u = 48; - } - okdown = !((l === m)) || (inclusive && (l === m) && ((i + 1 >> 0) === lower.nd)); - okup = !((m === u)) && (inclusive || (m + 1 << 24 >>> 24) < u || (i + 1 >> 0) < upper.nd); - if (okdown && okup) { - d.Round(i + 1 >> 0); - return; - } else if (okdown) { - d.RoundDown(i + 1 >> 0); - return; - } else if (okup) { - d.RoundUp(i + 1 >> 0); - return; + t.loc = FixedZone("", offset); } - i = i + (1) >> 0; } + return $ifaceNil; }; - fmtE = function(dst, neg, d, prec, fmt) { - var ch, x, i, m, x$1, exp, buf, i$1, _r, _q, _ref; - if (neg) { - dst = $append(dst, 45); + Time.prototype.UnmarshalBinary = function(data$1) { return this.$val.UnmarshalBinary(data$1); }; + Time.Ptr.prototype.GobEncode = function() { + var t; + t = new Time.Ptr(); $copy(t, this, Time); + return t.MarshalBinary(); + }; + Time.prototype.GobEncode = function() { return this.$val.GobEncode(); }; + Time.Ptr.prototype.GobDecode = function(data$1) { + var t; + t = this; + return t.UnmarshalBinary(data$1); + }; + Time.prototype.GobDecode = function(data$1) { return this.$val.GobDecode(data$1); }; + Time.Ptr.prototype.MarshalJSON = function() { + var t, y; + t = new Time.Ptr(); $copy(t, this, Time); + y = t.Year(); + if (y < 0 || y >= 10000) { + return [($sliceType($Uint8)).nil, errors.New("Time.MarshalJSON: year outside of range [0,9999]")]; } - ch = 48; - if (!((d.nd === 0))) { - ch = (x = d.d, ((0 < 0 || 0 >= x.$length) ? $throwRuntimeError("index out of range") : x.$array[x.$offset + 0])); + return [new ($sliceType($Uint8))($stringToBytes(t.Format("\"2006-01-02T15:04:05.999999999Z07:00\""))), $ifaceNil]; + }; + Time.prototype.MarshalJSON = function() { return this.$val.MarshalJSON(); }; + Time.Ptr.prototype.UnmarshalJSON = function(data$1) { + var err = $ifaceNil, t, _tuple$1; + t = this; + _tuple$1 = Parse("\"2006-01-02T15:04:05Z07:00\"", $bytesToString(data$1)); $copy(t, _tuple$1[0], Time); err = _tuple$1[1]; + return err; + }; + Time.prototype.UnmarshalJSON = function(data$1) { return this.$val.UnmarshalJSON(data$1); }; + Time.Ptr.prototype.MarshalText = function() { + var t, y; + t = new Time.Ptr(); $copy(t, this, Time); + y = t.Year(); + if (y < 0 || y >= 10000) { + return [($sliceType($Uint8)).nil, errors.New("Time.MarshalText: year outside of range [0,9999]")]; } - dst = $append(dst, ch); - if (prec > 0) { - dst = $append(dst, 46); - i = 1; - m = ((d.nd + prec >> 0) + 1 >> 0) - max(d.nd, prec + 1 >> 0) >> 0; - while (i < m) { - dst = $append(dst, (x$1 = d.d, ((i < 0 || i >= x$1.$length) ? $throwRuntimeError("index out of range") : x$1.$array[x$1.$offset + i]))); - i = i + (1) >> 0; - } - while (i <= prec) { - dst = $append(dst, 48); - i = i + (1) >> 0; + return [new ($sliceType($Uint8))($stringToBytes(t.Format("2006-01-02T15:04:05.999999999Z07:00"))), $ifaceNil]; + }; + Time.prototype.MarshalText = function() { return this.$val.MarshalText(); }; + Time.Ptr.prototype.UnmarshalText = function(data$1) { + var err = $ifaceNil, t, _tuple$1; + t = this; + _tuple$1 = Parse("2006-01-02T15:04:05Z07:00", $bytesToString(data$1)); $copy(t, _tuple$1[0], Time); err = _tuple$1[1]; + return err; + }; + Time.prototype.UnmarshalText = function(data$1) { return this.$val.UnmarshalText(data$1); }; + Unix = $pkg.Unix = function(sec, nsec) { + var n, x, x$1, x$2, x$3; + if ((nsec.$high < 0 || (nsec.$high === 0 && nsec.$low < 0)) || (nsec.$high > 0 || (nsec.$high === 0 && nsec.$low >= 1000000000))) { + n = $div64(nsec, new $Int64(0, 1000000000), false); + sec = (x = n, new $Int64(sec.$high + x.$high, sec.$low + x.$low)); + nsec = (x$1 = $mul64(n, new $Int64(0, 1000000000)), new $Int64(nsec.$high - x$1.$high, nsec.$low - x$1.$low)); + if ((nsec.$high < 0 || (nsec.$high === 0 && nsec.$low < 0))) { + nsec = (x$2 = new $Int64(0, 1000000000), new $Int64(nsec.$high + x$2.$high, nsec.$low + x$2.$low)); + sec = (x$3 = new $Int64(0, 1), new $Int64(sec.$high - x$3.$high, sec.$low - x$3.$low)); } } - dst = $append(dst, fmt); - exp = d.dp - 1 >> 0; - if (d.nd === 0) { - exp = 0; - } - if (exp < 0) { - ch = 45; - exp = -exp; - } else { - ch = 43; - } - dst = $append(dst, ch); - buf = ($arrayType($Uint8, 3)).zero(); $copy(buf, ($arrayType($Uint8, 3)).zero(), ($arrayType($Uint8, 3))); - i$1 = 3; - while (exp >= 10) { - i$1 = i$1 - (1) >> 0; - (i$1 < 0 || i$1 >= buf.length) ? $throwRuntimeError("index out of range") : buf[i$1] = (((_r = exp % 10, _r === _r ? _r : $throwRuntimeError("integer divide by zero")) + 48 >> 0) << 24 >>> 24); - exp = (_q = exp / (10), (_q === _q && _q !== 1/0 && _q !== -1/0) ? _q >> 0 : $throwRuntimeError("integer divide by zero")); + return new Time.Ptr(new $Int64(sec.$high + 14, sec.$low + 2006054656), (nsec.$low >>> 0), $pkg.Local); + }; + isLeap = function(year) { + var _r, _r$1, _r$2; + return ((_r = year % 4, _r === _r ? _r : $throwRuntimeError("integer divide by zero")) === 0) && (!(((_r$1 = year % 100, _r$1 === _r$1 ? _r$1 : $throwRuntimeError("integer divide by zero")) === 0)) || ((_r$2 = year % 400, _r$2 === _r$2 ? _r$2 : $throwRuntimeError("integer divide by zero")) === 0)); + }; + norm = function(hi, lo, base) { + var nhi = 0, nlo = 0, _q, n, _q$1, n$1, _tmp, _tmp$1; + if (lo < 0) { + n = (_q = ((-lo - 1 >> 0)) / base, (_q === _q && _q !== 1/0 && _q !== -1/0) ? _q >> 0 : $throwRuntimeError("integer divide by zero")) + 1 >> 0; + hi = hi - (n) >> 0; + lo = lo + (((((n >>> 16 << 16) * base >> 0) + (n << 16 >>> 16) * base) >> 0)) >> 0; } - i$1 = i$1 - (1) >> 0; - (i$1 < 0 || i$1 >= buf.length) ? $throwRuntimeError("index out of range") : buf[i$1] = ((exp + 48 >> 0) << 24 >>> 24); - _ref = i$1; - if (_ref === 0) { - dst = $append(dst, buf[0], buf[1], buf[2]); - } else if (_ref === 1) { - dst = $append(dst, buf[1], buf[2]); - } else if (_ref === 2) { - dst = $append(dst, 48, buf[2]); + if (lo >= base) { + n$1 = (_q$1 = lo / base, (_q$1 === _q$1 && _q$1 !== 1/0 && _q$1 !== -1/0) ? _q$1 >> 0 : $throwRuntimeError("integer divide by zero")); + hi = hi + (n$1) >> 0; + lo = lo - (((((n$1 >>> 16 << 16) * base >> 0) + (n$1 << 16 >>> 16) * base) >> 0)) >> 0; } - return dst; + _tmp = hi; _tmp$1 = lo; nhi = _tmp; nlo = _tmp$1; + return [nhi, nlo]; }; - fmtF = function(dst, neg, d, prec) { - var i, x, i$1, ch, j, x$1; - if (neg) { - dst = $append(dst, 45); + Date = $pkg.Date = function(year, month, day, hour, min, sec, nsec, loc) { + var m, _tuple$1, _tuple$2, _tuple$3, _tuple$4, _tuple$5, x, x$1, y, n, x$2, d, x$3, x$4, x$5, x$6, x$7, x$8, x$9, x$10, x$11, abs, x$12, x$13, unix, _tuple$6, offset, start, end, x$14, utc, _tuple$7, _tuple$8, x$15; + if (loc === ($ptrType(Location)).nil) { + $panic(new $String("time: missing Location in call to Date")); } - if (d.dp > 0) { - i = 0; - i = 0; - while (i < d.dp && i < d.nd) { - dst = $append(dst, (x = d.d, ((i < 0 || i >= x.$length) ? $throwRuntimeError("index out of range") : x.$array[x.$offset + i]))); - i = i + (1) >> 0; - } - while (i < d.dp) { - dst = $append(dst, 48); - i = i + (1) >> 0; - } - } else { - dst = $append(dst, 48); + m = (month >> 0) - 1 >> 0; + _tuple$1 = norm(year, m, 12); year = _tuple$1[0]; m = _tuple$1[1]; + month = (m >> 0) + 1 >> 0; + _tuple$2 = norm(sec, nsec, 1000000000); sec = _tuple$2[0]; nsec = _tuple$2[1]; + _tuple$3 = norm(min, sec, 60); min = _tuple$3[0]; sec = _tuple$3[1]; + _tuple$4 = norm(hour, min, 60); hour = _tuple$4[0]; min = _tuple$4[1]; + _tuple$5 = norm(day, hour, 24); day = _tuple$5[0]; hour = _tuple$5[1]; + y = (x = (x$1 = new $Int64(0, year), new $Int64(x$1.$high - -69, x$1.$low - 4075721025)), new $Uint64(x.$high, x.$low)); + n = $div64(y, new $Uint64(0, 400), false); + y = (x$2 = $mul64(new $Uint64(0, 400), n), new $Uint64(y.$high - x$2.$high, y.$low - x$2.$low)); + d = $mul64(new $Uint64(0, 146097), n); + n = $div64(y, new $Uint64(0, 100), false); + y = (x$3 = $mul64(new $Uint64(0, 100), n), new $Uint64(y.$high - x$3.$high, y.$low - x$3.$low)); + d = (x$4 = $mul64(new $Uint64(0, 36524), n), new $Uint64(d.$high + x$4.$high, d.$low + x$4.$low)); + n = $div64(y, new $Uint64(0, 4), false); + y = (x$5 = $mul64(new $Uint64(0, 4), n), new $Uint64(y.$high - x$5.$high, y.$low - x$5.$low)); + d = (x$6 = $mul64(new $Uint64(0, 1461), n), new $Uint64(d.$high + x$6.$high, d.$low + x$6.$low)); + n = y; + d = (x$7 = $mul64(new $Uint64(0, 365), n), new $Uint64(d.$high + x$7.$high, d.$low + x$7.$low)); + d = (x$8 = new $Uint64(0, (x$9 = month - 1 >> 0, ((x$9 < 0 || x$9 >= daysBefore.length) ? $throwRuntimeError("index out of range") : daysBefore[x$9]))), new $Uint64(d.$high + x$8.$high, d.$low + x$8.$low)); + if (isLeap(year) && month >= 3) { + d = (x$10 = new $Uint64(0, 1), new $Uint64(d.$high + x$10.$high, d.$low + x$10.$low)); } - if (prec > 0) { - dst = $append(dst, 46); - i$1 = 0; - while (i$1 < prec) { - ch = 48; - j = d.dp + i$1 >> 0; - if (0 <= j && j < d.nd) { - ch = (x$1 = d.d, ((j < 0 || j >= x$1.$length) ? $throwRuntimeError("index out of range") : x$1.$array[x$1.$offset + j])); - } - dst = $append(dst, ch); - i$1 = i$1 + (1) >> 0; + d = (x$11 = new $Uint64(0, (day - 1 >> 0)), new $Uint64(d.$high + x$11.$high, d.$low + x$11.$low)); + abs = $mul64(d, new $Uint64(0, 86400)); + abs = (x$12 = new $Uint64(0, ((((((hour >>> 16 << 16) * 3600 >> 0) + (hour << 16 >>> 16) * 3600) >> 0) + ((((min >>> 16 << 16) * 60 >> 0) + (min << 16 >>> 16) * 60) >> 0) >> 0) + sec >> 0)), new $Uint64(abs.$high + x$12.$high, abs.$low + x$12.$low)); + unix = (x$13 = new $Int64(abs.$high, abs.$low), new $Int64(x$13.$high + -2147483647, x$13.$low + 3844486912)); + _tuple$6 = loc.lookup(unix); offset = _tuple$6[1]; start = _tuple$6[3]; end = _tuple$6[4]; + if (!((offset === 0))) { + utc = (x$14 = new $Int64(0, offset), new $Int64(unix.$high - x$14.$high, unix.$low - x$14.$low)); + if ((utc.$high < start.$high || (utc.$high === start.$high && utc.$low < start.$low))) { + _tuple$7 = loc.lookup(new $Int64(start.$high - 0, start.$low - 1)); offset = _tuple$7[1]; + } else if ((utc.$high > end.$high || (utc.$high === end.$high && utc.$low >= end.$low))) { + _tuple$8 = loc.lookup(end); offset = _tuple$8[1]; } + unix = (x$15 = new $Int64(0, offset), new $Int64(unix.$high - x$15.$high, unix.$low - x$15.$low)); } - return dst; + return new Time.Ptr(new $Int64(unix.$high + 14, unix.$low + 2006054656), (nsec >>> 0), loc); }; - fmtB = function(dst, neg, mant, exp, flt) { - var buf, w, esign, n, _r, _q, x; - buf = ($arrayType($Uint8, 50)).zero(); $copy(buf, ($arrayType($Uint8, 50)).zero(), ($arrayType($Uint8, 50))); - w = 50; - exp = exp - ((flt.mantbits >> 0)) >> 0; - esign = 43; - if (exp < 0) { - esign = 45; - exp = -exp; - } - n = 0; - while (exp > 0 || n < 1) { - n = n + (1) >> 0; - w = w - (1) >> 0; - (w < 0 || w >= buf.length) ? $throwRuntimeError("index out of range") : buf[w] = (((_r = exp % 10, _r === _r ? _r : $throwRuntimeError("integer divide by zero")) + 48 >> 0) << 24 >>> 24); - exp = (_q = exp / (10), (_q === _q && _q !== 1/0 && _q !== -1/0) ? _q >> 0 : $throwRuntimeError("integer divide by zero")); + Time.Ptr.prototype.Truncate = function(d) { + var t, _tuple$1, r; + t = new Time.Ptr(); $copy(t, this, Time); + if ((d.$high < 0 || (d.$high === 0 && d.$low <= 0))) { + return t; } - w = w - (1) >> 0; - (w < 0 || w >= buf.length) ? $throwRuntimeError("index out of range") : buf[w] = esign; - w = w - (1) >> 0; - (w < 0 || w >= buf.length) ? $throwRuntimeError("index out of range") : buf[w] = 112; - n = 0; - while ((mant.$high > 0 || (mant.$high === 0 && mant.$low > 0)) || n < 1) { - n = n + (1) >> 0; - w = w - (1) >> 0; - (w < 0 || w >= buf.length) ? $throwRuntimeError("index out of range") : buf[w] = ((x = $div64(mant, new $Uint64(0, 10), true), new $Uint64(x.$high + 0, x.$low + 48)).$low << 24 >>> 24); - mant = $div64(mant, (new $Uint64(0, 10)), false); + _tuple$1 = div($clone(t, Time), d); r = _tuple$1[1]; + return t.Add(new Duration(-r.$high, -r.$low)); + }; + Time.prototype.Truncate = function(d) { return this.$val.Truncate(d); }; + Time.Ptr.prototype.Round = function(d) { + var t, _tuple$1, r, x; + t = new Time.Ptr(); $copy(t, this, Time); + if ((d.$high < 0 || (d.$high === 0 && d.$low <= 0))) { + return t; } - if (neg) { - w = w - (1) >> 0; - (w < 0 || w >= buf.length) ? $throwRuntimeError("index out of range") : buf[w] = 45; + _tuple$1 = div($clone(t, Time), d); r = _tuple$1[1]; + if ((x = new Duration(r.$high + r.$high, r.$low + r.$low), (x.$high < d.$high || (x.$high === d.$high && x.$low < d.$low)))) { + return t.Add(new Duration(-r.$high, -r.$low)); } - return $appendSlice(dst, $subslice(new ($sliceType($Uint8))(buf), w)); + return t.Add(new Duration(d.$high - r.$high, d.$low - r.$low)); }; - max = function(a, b) { - if (a > b) { - return a; + Time.prototype.Round = function(d) { return this.$val.Round(d); }; + div = function(t, d) { + var qmod2 = 0, r = new Duration(0, 0), neg, nsec, x, x$1, x$2, x$3, x$4, x$5, _q, _r, x$6, d1, x$7, x$8, x$9, x$10, x$11, sec, tmp, u1, u0, _tmp, _tmp$1, u0x, x$12, _tmp$2, _tmp$3, x$13, x$14, d1$1, x$15, d0, _tmp$4, _tmp$5, x$16, x$17, x$18, x$19; + neg = false; + nsec = (t.nsec >> 0); + if ((x = t.sec, (x.$high < 0 || (x.$high === 0 && x.$low < 0)))) { + neg = true; + t.sec = (x$1 = t.sec, new $Int64(-x$1.$high, -x$1.$low)); + nsec = -nsec; + if (nsec < 0) { + nsec = nsec + (1000000000) >> 0; + t.sec = (x$2 = t.sec, x$3 = new $Int64(0, 1), new $Int64(x$2.$high - x$3.$high, x$2.$low - x$3.$low)); + } } - return b; - }; - FormatUint = $pkg.FormatUint = function(i, base) { - var _tuple, s; - _tuple = formatBits(($sliceType($Uint8)).nil, i, base, false, false); s = _tuple[1]; - return s; - }; - FormatInt = $pkg.FormatInt = function(i, base) { - var _tuple, s; - _tuple = formatBits(($sliceType($Uint8)).nil, new $Uint64(i.$high, i.$low), base, (i.$high < 0 || (i.$high === 0 && i.$low < 0)), false); s = _tuple[1]; - return s; - }; - Itoa = $pkg.Itoa = function(i) { - return FormatInt(new $Int64(0, i), 10); - }; - AppendInt = $pkg.AppendInt = function(dst, i, base) { - var _tuple; - _tuple = formatBits(dst, new $Uint64(i.$high, i.$low), base, (i.$high < 0 || (i.$high === 0 && i.$low < 0)), true); dst = _tuple[0]; - return dst; - }; - AppendUint = $pkg.AppendUint = function(dst, i, base) { - var _tuple; - _tuple = formatBits(dst, i, base, false, true); dst = _tuple[0]; - return dst; - }; - formatBits = function(dst, u, base, neg, append_) { - var d = ($sliceType($Uint8)).nil, s = "", a, i, q, x, j, x$1, x$2, q$1, x$3, s$1, b, m, b$1; - if (base < 2 || base > 36) { - $panic(new $String("strconv: illegal AppendInt/FormatInt base")); - } - a = ($arrayType($Uint8, 65)).zero(); $copy(a, ($arrayType($Uint8, 65)).zero(), ($arrayType($Uint8, 65))); - i = 65; - if (neg) { - u = new $Uint64(-u.$high, -u.$low); - } - if (base === 10) { - while ((u.$high > 0 || (u.$high === 0 && u.$low >= 100))) { - i = i - (2) >> 0; - q = $div64(u, new $Uint64(0, 100), false); - j = ((x = $mul64(q, new $Uint64(0, 100)), new $Uint64(u.$high - x.$high, u.$low - x.$low)).$low >>> 0); - (x$1 = i + 1 >> 0, (x$1 < 0 || x$1 >= a.length) ? $throwRuntimeError("index out of range") : a[x$1] = "0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789".charCodeAt(j)); - (x$2 = i + 0 >> 0, (x$2 < 0 || x$2 >= a.length) ? $throwRuntimeError("index out of range") : a[x$2] = "0000000000111111111122222222223333333333444444444455555555556666666666777777777788888888889999999999".charCodeAt(j)); - u = q; - } - if ((u.$high > 0 || (u.$high === 0 && u.$low >= 10))) { - i = i - (1) >> 0; - q$1 = $div64(u, new $Uint64(0, 10), false); - (i < 0 || i >= a.length) ? $throwRuntimeError("index out of range") : a[i] = "0123456789abcdefghijklmnopqrstuvwxyz".charCodeAt(((x$3 = $mul64(q$1, new $Uint64(0, 10)), new $Uint64(u.$high - x$3.$high, u.$low - x$3.$low)).$low >>> 0)); - u = q$1; - } + if ((d.$high < 0 || (d.$high === 0 && d.$low < 1000000000)) && (x$4 = $div64(new Duration(0, 1000000000), (new Duration(d.$high + d.$high, d.$low + d.$low)), true), (x$4.$high === 0 && x$4.$low === 0))) { + qmod2 = ((_q = nsec / ((d.$low + ((d.$high >> 31) * 4294967296)) >> 0), (_q === _q && _q !== 1/0 && _q !== -1/0) ? _q >> 0 : $throwRuntimeError("integer divide by zero")) >> 0) & 1; + r = new Duration(0, (_r = nsec % ((d.$low + ((d.$high >> 31) * 4294967296)) >> 0), _r === _r ? _r : $throwRuntimeError("integer divide by zero"))); + } else if ((x$5 = $div64(d, new Duration(0, 1000000000), true), (x$5.$high === 0 && x$5.$low === 0))) { + d1 = (x$6 = $div64(d, new Duration(0, 1000000000), false), new $Int64(x$6.$high, x$6.$low)); + qmod2 = ((x$7 = $div64(t.sec, d1, false), x$7.$low + ((x$7.$high >> 31) * 4294967296)) >> 0) & 1; + r = (x$8 = $mul64((x$9 = $div64(t.sec, d1, true), new Duration(x$9.$high, x$9.$low)), new Duration(0, 1000000000)), x$10 = new Duration(0, nsec), new Duration(x$8.$high + x$10.$high, x$8.$low + x$10.$low)); } else { - s$1 = ((base < 0 || base >= shifts.length) ? $throwRuntimeError("index out of range") : shifts[base]); - if (s$1 > 0) { - b = new $Uint64(0, base); - m = (b.$low >>> 0) - 1 >>> 0; - while ((u.$high > b.$high || (u.$high === b.$high && u.$low >= b.$low))) { - i = i - (1) >> 0; - (i < 0 || i >= a.length) ? $throwRuntimeError("index out of range") : a[i] = "0123456789abcdefghijklmnopqrstuvwxyz".charCodeAt((((u.$low >>> 0) & m) >>> 0)); - u = $shiftRightUint64(u, (s$1)); - } - } else { - b$1 = new $Uint64(0, base); - while ((u.$high > b$1.$high || (u.$high === b$1.$high && u.$low >= b$1.$low))) { - i = i - (1) >> 0; - (i < 0 || i >= a.length) ? $throwRuntimeError("index out of range") : a[i] = "0123456789abcdefghijklmnopqrstuvwxyz".charCodeAt(($div64(u, b$1, true).$low >>> 0)); - u = $div64(u, (b$1), false); - } - } - } - i = i - (1) >> 0; - (i < 0 || i >= a.length) ? $throwRuntimeError("index out of range") : a[i] = "0123456789abcdefghijklmnopqrstuvwxyz".charCodeAt((u.$low >>> 0)); - if (neg) { - i = i - (1) >> 0; - (i < 0 || i >= a.length) ? $throwRuntimeError("index out of range") : a[i] = 45; - } - if (append_) { - d = $appendSlice(dst, $subslice(new ($sliceType($Uint8))(a), i)); - return [d, s]; - } - s = $bytesToString($subslice(new ($sliceType($Uint8))(a), i)); - return [d, s]; - }; - quoteWith = function(s, quote, ASCIIonly) { - var runeTmp, _q, x, buf, width, r, _tuple, n, _ref, s$1, s$2; - runeTmp = ($arrayType($Uint8, 4)).zero(); $copy(runeTmp, ($arrayType($Uint8, 4)).zero(), ($arrayType($Uint8, 4))); - buf = ($sliceType($Uint8)).make(0, (_q = (x = s.length, (((3 >>> 16 << 16) * x >> 0) + (3 << 16 >>> 16) * x) >> 0) / 2, (_q === _q && _q !== 1/0 && _q !== -1/0) ? _q >> 0 : $throwRuntimeError("integer divide by zero"))); - buf = $append(buf, quote); - width = 0; - while (s.length > 0) { - r = (s.charCodeAt(0) >> 0); - width = 1; - if (r >= 128) { - _tuple = utf8.DecodeRuneInString(s); r = _tuple[0]; width = _tuple[1]; - } - if ((width === 1) && (r === 65533)) { - buf = $appendSlice(buf, new ($sliceType($Uint8))($stringToBytes("\\x"))); - buf = $append(buf, "0123456789abcdef".charCodeAt((s.charCodeAt(0) >>> 4 << 24 >>> 24))); - buf = $append(buf, "0123456789abcdef".charCodeAt(((s.charCodeAt(0) & 15) >>> 0))); - s = s.substring(width); - continue; + sec = (x$11 = t.sec, new $Uint64(x$11.$high, x$11.$low)); + tmp = $mul64(($shiftRightUint64(sec, 32)), new $Uint64(0, 1000000000)); + u1 = $shiftRightUint64(tmp, 32); + u0 = $shiftLeft64(tmp, 32); + tmp = $mul64(new $Uint64(sec.$high & 0, (sec.$low & 4294967295) >>> 0), new $Uint64(0, 1000000000)); + _tmp = u0; _tmp$1 = new $Uint64(u0.$high + tmp.$high, u0.$low + tmp.$low); u0x = _tmp; u0 = _tmp$1; + if ((u0.$high < u0x.$high || (u0.$high === u0x.$high && u0.$low < u0x.$low))) { + u1 = (x$12 = new $Uint64(0, 1), new $Uint64(u1.$high + x$12.$high, u1.$low + x$12.$low)); } - if ((r === (quote >> 0)) || (r === 92)) { - buf = $append(buf, 92); - buf = $append(buf, (r << 24 >>> 24)); - s = s.substring(width); - continue; + _tmp$2 = u0; _tmp$3 = (x$13 = new $Uint64(0, nsec), new $Uint64(u0.$high + x$13.$high, u0.$low + x$13.$low)); u0x = _tmp$2; u0 = _tmp$3; + if ((u0.$high < u0x.$high || (u0.$high === u0x.$high && u0.$low < u0x.$low))) { + u1 = (x$14 = new $Uint64(0, 1), new $Uint64(u1.$high + x$14.$high, u1.$low + x$14.$low)); } - if (ASCIIonly) { - if (r < 128 && IsPrint(r)) { - buf = $append(buf, (r << 24 >>> 24)); - s = s.substring(width); - continue; - } - } else if (IsPrint(r)) { - n = utf8.EncodeRune(new ($sliceType($Uint8))(runeTmp), r); - buf = $appendSlice(buf, $subslice(new ($sliceType($Uint8))(runeTmp), 0, n)); - s = s.substring(width); - continue; + d1$1 = new $Uint64(d.$high, d.$low); + while (!((x$15 = $shiftRightUint64(d1$1, 63), (x$15.$high === 0 && x$15.$low === 1)))) { + d1$1 = $shiftLeft64(d1$1, (1)); } - _ref = r; - if (_ref === 7) { - buf = $appendSlice(buf, new ($sliceType($Uint8))($stringToBytes("\\a"))); - } else if (_ref === 8) { - buf = $appendSlice(buf, new ($sliceType($Uint8))($stringToBytes("\\b"))); - } else if (_ref === 12) { - buf = $appendSlice(buf, new ($sliceType($Uint8))($stringToBytes("\\f"))); - } else if (_ref === 10) { - buf = $appendSlice(buf, new ($sliceType($Uint8))($stringToBytes("\\n"))); - } else if (_ref === 13) { - buf = $appendSlice(buf, new ($sliceType($Uint8))($stringToBytes("\\r"))); - } else if (_ref === 9) { - buf = $appendSlice(buf, new ($sliceType($Uint8))($stringToBytes("\\t"))); - } else if (_ref === 11) { - buf = $appendSlice(buf, new ($sliceType($Uint8))($stringToBytes("\\v"))); - } else { - if (r < 32) { - buf = $appendSlice(buf, new ($sliceType($Uint8))($stringToBytes("\\x"))); - buf = $append(buf, "0123456789abcdef".charCodeAt((s.charCodeAt(0) >>> 4 << 24 >>> 24))); - buf = $append(buf, "0123456789abcdef".charCodeAt(((s.charCodeAt(0) & 15) >>> 0))); - } else if (r > 1114111) { - r = 65533; - buf = $appendSlice(buf, new ($sliceType($Uint8))($stringToBytes("\\u"))); - s$1 = 12; - while (s$1 >= 0) { - buf = $append(buf, "0123456789abcdef".charCodeAt((((r >> $min((s$1 >>> 0), 31)) >> 0) & 15))); - s$1 = s$1 - (4) >> 0; - } - } else if (r < 65536) { - buf = $appendSlice(buf, new ($sliceType($Uint8))($stringToBytes("\\u"))); - s$1 = 12; - while (s$1 >= 0) { - buf = $append(buf, "0123456789abcdef".charCodeAt((((r >> $min((s$1 >>> 0), 31)) >> 0) & 15))); - s$1 = s$1 - (4) >> 0; - } - } else { - buf = $appendSlice(buf, new ($sliceType($Uint8))($stringToBytes("\\U"))); - s$2 = 28; - while (s$2 >= 0) { - buf = $append(buf, "0123456789abcdef".charCodeAt((((r >> $min((s$2 >>> 0), 31)) >> 0) & 15))); - s$2 = s$2 - (4) >> 0; + d0 = new $Uint64(0, 0); + while (true) { + qmod2 = 0; + if ((u1.$high > d1$1.$high || (u1.$high === d1$1.$high && u1.$low > d1$1.$low)) || (u1.$high === d1$1.$high && u1.$low === d1$1.$low) && (u0.$high > d0.$high || (u0.$high === d0.$high && u0.$low >= d0.$low))) { + qmod2 = 1; + _tmp$4 = u0; _tmp$5 = new $Uint64(u0.$high - d0.$high, u0.$low - d0.$low); u0x = _tmp$4; u0 = _tmp$5; + if ((u0.$high > u0x.$high || (u0.$high === u0x.$high && u0.$low > u0x.$low))) { + u1 = (x$16 = new $Uint64(0, 1), new $Uint64(u1.$high - x$16.$high, u1.$low - x$16.$low)); } + u1 = (x$17 = d1$1, new $Uint64(u1.$high - x$17.$high, u1.$low - x$17.$low)); } + if ((d1$1.$high === 0 && d1$1.$low === 0) && (x$18 = new $Uint64(d.$high, d.$low), (d0.$high === x$18.$high && d0.$low === x$18.$low))) { + break; + } + d0 = $shiftRightUint64(d0, (1)); + d0 = (x$19 = $shiftLeft64((new $Uint64(d1$1.$high & 0, (d1$1.$low & 1) >>> 0)), 63), new $Uint64(d0.$high | x$19.$high, (d0.$low | x$19.$low) >>> 0)); + d1$1 = $shiftRightUint64(d1$1, (1)); } - s = s.substring(width); - } - buf = $append(buf, quote); - return $bytesToString(buf); - }; - Quote = $pkg.Quote = function(s) { - return quoteWith(s, 34, false); - }; - QuoteToASCII = $pkg.QuoteToASCII = function(s) { - return quoteWith(s, 34, true); - }; - QuoteRune = $pkg.QuoteRune = function(r) { - return quoteWith($encodeRune(r), 39, false); - }; - AppendQuoteRune = $pkg.AppendQuoteRune = function(dst, r) { - return $appendSlice(dst, new ($sliceType($Uint8))($stringToBytes(QuoteRune(r)))); - }; - QuoteRuneToASCII = $pkg.QuoteRuneToASCII = function(r) { - return quoteWith($encodeRune(r), 39, true); - }; - AppendQuoteRuneToASCII = $pkg.AppendQuoteRuneToASCII = function(dst, r) { - return $appendSlice(dst, new ($sliceType($Uint8))($stringToBytes(QuoteRuneToASCII(r)))); - }; - CanBackquote = $pkg.CanBackquote = function(s) { - var i, c; - i = 0; - while (i < s.length) { - c = s.charCodeAt(i); - if ((c < 32 && !((c === 9))) || (c === 96) || (c === 127)) { - return false; - } - i = i + (1) >> 0; + r = new Duration(u0.$high, u0.$low); } - return true; - }; - unhex = function(b) { - var v = 0, ok = false, c, _tmp, _tmp$1, _tmp$2, _tmp$3, _tmp$4, _tmp$5; - c = (b >> 0); - if (48 <= c && c <= 57) { - _tmp = c - 48 >> 0; _tmp$1 = true; v = _tmp; ok = _tmp$1; - return [v, ok]; - } else if (97 <= c && c <= 102) { - _tmp$2 = (c - 97 >> 0) + 10 >> 0; _tmp$3 = true; v = _tmp$2; ok = _tmp$3; - return [v, ok]; - } else if (65 <= c && c <= 70) { - _tmp$4 = (c - 65 >> 0) + 10 >> 0; _tmp$5 = true; v = _tmp$4; ok = _tmp$5; - return [v, ok]; + if (neg && !((r.$high === 0 && r.$low === 0))) { + qmod2 = (qmod2 ^ (1)) >> 0; + r = new Duration(d.$high - r.$high, d.$low - r.$low); } - return [v, ok]; + return [qmod2, r]; }; - UnquoteChar = $pkg.UnquoteChar = function(s, quote) { - var value = 0, multibyte = false, tail = "", err = $ifaceNil, c, _tuple, r, size, _tmp, _tmp$1, _tmp$2, _tmp$3, _tmp$4, _tmp$5, _tmp$6, _tmp$7, c$1, _ref, n, _ref$1, v, j, _tuple$1, x, ok, v$1, j$1, x$1; - c = s.charCodeAt(0); - if ((c === quote) && ((quote === 39) || (quote === 34))) { - err = $pkg.ErrSyntax; - return [value, multibyte, tail, err]; - } else if (c >= 128) { - _tuple = utf8.DecodeRuneInString(s); r = _tuple[0]; size = _tuple[1]; - _tmp = r; _tmp$1 = true; _tmp$2 = s.substring(size); _tmp$3 = $ifaceNil; value = _tmp; multibyte = _tmp$1; tail = _tmp$2; err = _tmp$3; - return [value, multibyte, tail, err]; - } else if (!((c === 92))) { - _tmp$4 = (s.charCodeAt(0) >> 0); _tmp$5 = false; _tmp$6 = s.substring(1); _tmp$7 = $ifaceNil; value = _tmp$4; multibyte = _tmp$5; tail = _tmp$6; err = _tmp$7; - return [value, multibyte, tail, err]; + Location.Ptr.prototype.get = function() { + var l; + l = this; + if (l === ($ptrType(Location)).nil) { + return utcLoc; } - if (s.length <= 1) { - err = $pkg.ErrSyntax; - return [value, multibyte, tail, err]; + if (l === localLoc) { + localOnce.Do(initLocal); } - c$1 = s.charCodeAt(1); - s = s.substring(2); - _ref = c$1; - switch (0) { default: if (_ref === 97) { - value = 7; - } else if (_ref === 98) { - value = 8; - } else if (_ref === 102) { - value = 12; - } else if (_ref === 110) { - value = 10; - } else if (_ref === 114) { - value = 13; - } else if (_ref === 116) { - value = 9; - } else if (_ref === 118) { - value = 11; - } else if (_ref === 120 || _ref === 117 || _ref === 85) { - n = 0; - _ref$1 = c$1; - if (_ref$1 === 120) { - n = 2; - } else if (_ref$1 === 117) { - n = 4; - } else if (_ref$1 === 85) { - n = 8; - } - v = 0; - if (s.length < n) { - err = $pkg.ErrSyntax; - return [value, multibyte, tail, err]; - } - j = 0; - while (j < n) { - _tuple$1 = unhex(s.charCodeAt(j)); x = _tuple$1[0]; ok = _tuple$1[1]; - if (!ok) { - err = $pkg.ErrSyntax; - return [value, multibyte, tail, err]; - } - v = (v << 4 >> 0) | x; - j = j + (1) >> 0; - } - s = s.substring(n); - if (c$1 === 120) { - value = v; - break; - } - if (v > 1114111) { - err = $pkg.ErrSyntax; - return [value, multibyte, tail, err]; - } - value = v; - multibyte = true; - } else if (_ref === 48 || _ref === 49 || _ref === 50 || _ref === 51 || _ref === 52 || _ref === 53 || _ref === 54 || _ref === 55) { - v$1 = (c$1 >> 0) - 48 >> 0; - if (s.length < 2) { - err = $pkg.ErrSyntax; - return [value, multibyte, tail, err]; - } - j$1 = 0; - while (j$1 < 2) { - x$1 = (s.charCodeAt(j$1) >> 0) - 48 >> 0; - if (x$1 < 0 || x$1 > 7) { - err = $pkg.ErrSyntax; - return [value, multibyte, tail, err]; - } - v$1 = ((v$1 << 3 >> 0)) | x$1; - j$1 = j$1 + (1) >> 0; - } - s = s.substring(2); - if (v$1 > 255) { - err = $pkg.ErrSyntax; - return [value, multibyte, tail, err]; - } - value = v$1; - } else if (_ref === 92) { - value = 92; - } else if (_ref === 39 || _ref === 34) { - if (!((c$1 === quote))) { - err = $pkg.ErrSyntax; - return [value, multibyte, tail, err]; - } - value = (c$1 >> 0); - } else { - err = $pkg.ErrSyntax; - return [value, multibyte, tail, err]; - } } - tail = s; - return [value, multibyte, tail, err]; + return l; }; - Unquote = $pkg.Unquote = function(s) { - var t = "", err = $ifaceNil, n, _tmp, _tmp$1, quote, _tmp$2, _tmp$3, _tmp$4, _tmp$5, _tmp$6, _tmp$7, _tmp$8, _tmp$9, _tmp$10, _tmp$11, _ref, _tmp$12, _tmp$13, _tuple, r, size, _tmp$14, _tmp$15, runeTmp, _q, x, buf, _tuple$1, c, multibyte, ss, err$1, _tmp$16, _tmp$17, n$1, _tmp$18, _tmp$19, _tmp$20, _tmp$21; - n = s.length; - if (n < 2) { - _tmp = ""; _tmp$1 = $pkg.ErrSyntax; t = _tmp; err = _tmp$1; - return [t, err]; + Location.prototype.get = function() { return this.$val.get(); }; + Location.Ptr.prototype.String = function() { + var l; + l = this; + return l.get().name; + }; + Location.prototype.String = function() { return this.$val.String(); }; + FixedZone = $pkg.FixedZone = function(name, offset) { + var l, x; + l = new Location.Ptr(name, new ($sliceType(zone))([new zone.Ptr(name, offset, false)]), new ($sliceType(zoneTrans))([new zoneTrans.Ptr(new $Int64(-2147483648, 0), 0, false, false)]), new $Int64(-2147483648, 0), new $Int64(2147483647, 4294967295), ($ptrType(zone)).nil); + l.cacheZone = (x = l.zone, ((0 < 0 || 0 >= x.$length) ? $throwRuntimeError("index out of range") : x.$array[x.$offset + 0])); + return l; + }; + Location.Ptr.prototype.lookup = function(sec) { + var name = "", offset = 0, isDST = false, start = new $Int64(0, 0), end = new $Int64(0, 0), l, zone$1, x, x$1, x$2, x$3, x$4, x$5, zone$2, x$6, tx, lo, hi, _q, m, lim, x$7, x$8, zone$3; + l = this; + l = l.get(); + if (l.zone.$length === 0) { + name = "UTC"; + offset = 0; + isDST = false; + start = new $Int64(-2147483648, 0); + end = new $Int64(2147483647, 4294967295); + return [name, offset, isDST, start, end]; } - quote = s.charCodeAt(0); - if (!((quote === s.charCodeAt((n - 1 >> 0))))) { - _tmp$2 = ""; _tmp$3 = $pkg.ErrSyntax; t = _tmp$2; err = _tmp$3; - return [t, err]; + zone$1 = l.cacheZone; + if (!(zone$1 === ($ptrType(zone)).nil) && (x = l.cacheStart, (x.$high < sec.$high || (x.$high === sec.$high && x.$low <= sec.$low))) && (x$1 = l.cacheEnd, (sec.$high < x$1.$high || (sec.$high === x$1.$high && sec.$low < x$1.$low)))) { + name = zone$1.name; + offset = zone$1.offset; + isDST = zone$1.isDST; + start = l.cacheStart; + end = l.cacheEnd; + return [name, offset, isDST, start, end]; } - s = s.substring(1, (n - 1 >> 0)); - if (quote === 96) { - if (contains(s, 96)) { - _tmp$4 = ""; _tmp$5 = $pkg.ErrSyntax; t = _tmp$4; err = _tmp$5; - return [t, err]; + if ((l.tx.$length === 0) || (x$2 = (x$3 = l.tx, ((0 < 0 || 0 >= x$3.$length) ? $throwRuntimeError("index out of range") : x$3.$array[x$3.$offset + 0])).when, (sec.$high < x$2.$high || (sec.$high === x$2.$high && sec.$low < x$2.$low)))) { + zone$2 = (x$4 = l.zone, x$5 = l.lookupFirstZone(), ((x$5 < 0 || x$5 >= x$4.$length) ? $throwRuntimeError("index out of range") : x$4.$array[x$4.$offset + x$5])); + name = zone$2.name; + offset = zone$2.offset; + isDST = zone$2.isDST; + start = new $Int64(-2147483648, 0); + if (l.tx.$length > 0) { + end = (x$6 = l.tx, ((0 < 0 || 0 >= x$6.$length) ? $throwRuntimeError("index out of range") : x$6.$array[x$6.$offset + 0])).when; + } else { + end = new $Int64(2147483647, 4294967295); } - _tmp$6 = s; _tmp$7 = $ifaceNil; t = _tmp$6; err = _tmp$7; - return [t, err]; + return [name, offset, isDST, start, end]; } - if (!((quote === 34)) && !((quote === 39))) { - _tmp$8 = ""; _tmp$9 = $pkg.ErrSyntax; t = _tmp$8; err = _tmp$9; - return [t, err]; + tx = l.tx; + end = new $Int64(2147483647, 4294967295); + lo = 0; + hi = tx.$length; + while ((hi - lo >> 0) > 1) { + m = lo + (_q = ((hi - lo >> 0)) / 2, (_q === _q && _q !== 1/0 && _q !== -1/0) ? _q >> 0 : $throwRuntimeError("integer divide by zero")) >> 0; + lim = ((m < 0 || m >= tx.$length) ? $throwRuntimeError("index out of range") : tx.$array[tx.$offset + m]).when; + if ((sec.$high < lim.$high || (sec.$high === lim.$high && sec.$low < lim.$low))) { + end = lim; + hi = m; + } else { + lo = m; + } } - if (contains(s, 10)) { - _tmp$10 = ""; _tmp$11 = $pkg.ErrSyntax; t = _tmp$10; err = _tmp$11; - return [t, err]; + zone$3 = (x$7 = l.zone, x$8 = ((lo < 0 || lo >= tx.$length) ? $throwRuntimeError("index out of range") : tx.$array[tx.$offset + lo]).index, ((x$8 < 0 || x$8 >= x$7.$length) ? $throwRuntimeError("index out of range") : x$7.$array[x$7.$offset + x$8])); + name = zone$3.name; + offset = zone$3.offset; + isDST = zone$3.isDST; + start = ((lo < 0 || lo >= tx.$length) ? $throwRuntimeError("index out of range") : tx.$array[tx.$offset + lo]).when; + return [name, offset, isDST, start, end]; + }; + Location.prototype.lookup = function(sec) { return this.$val.lookup(sec); }; + Location.Ptr.prototype.lookupFirstZone = function() { + var l, x, x$1, x$2, x$3, zi, x$4, _ref, _i, zi$1, x$5; + l = this; + if (!l.firstZoneUsed()) { + return 0; } - if (!contains(s, 92) && !contains(s, quote)) { - _ref = quote; - if (_ref === 34) { - _tmp$12 = s; _tmp$13 = $ifaceNil; t = _tmp$12; err = _tmp$13; - return [t, err]; - } else if (_ref === 39) { - _tuple = utf8.DecodeRuneInString(s); r = _tuple[0]; size = _tuple[1]; - if ((size === s.length) && (!((r === 65533)) || !((size === 1)))) { - _tmp$14 = s; _tmp$15 = $ifaceNil; t = _tmp$14; err = _tmp$15; - return [t, err]; + if (l.tx.$length > 0 && (x = l.zone, x$1 = (x$2 = l.tx, ((0 < 0 || 0 >= x$2.$length) ? $throwRuntimeError("index out of range") : x$2.$array[x$2.$offset + 0])).index, ((x$1 < 0 || x$1 >= x.$length) ? $throwRuntimeError("index out of range") : x.$array[x.$offset + x$1])).isDST) { + zi = ((x$3 = l.tx, ((0 < 0 || 0 >= x$3.$length) ? $throwRuntimeError("index out of range") : x$3.$array[x$3.$offset + 0])).index >> 0) - 1 >> 0; + while (zi >= 0) { + if (!(x$4 = l.zone, ((zi < 0 || zi >= x$4.$length) ? $throwRuntimeError("index out of range") : x$4.$array[x$4.$offset + zi])).isDST) { + return zi; } + zi = zi - (1) >> 0; } } - runeTmp = ($arrayType($Uint8, 4)).zero(); $copy(runeTmp, ($arrayType($Uint8, 4)).zero(), ($arrayType($Uint8, 4))); - buf = ($sliceType($Uint8)).make(0, (_q = (x = s.length, (((3 >>> 16 << 16) * x >> 0) + (3 << 16 >>> 16) * x) >> 0) / 2, (_q === _q && _q !== 1/0 && _q !== -1/0) ? _q >> 0 : $throwRuntimeError("integer divide by zero"))); - while (s.length > 0) { - _tuple$1 = UnquoteChar(s, quote); c = _tuple$1[0]; multibyte = _tuple$1[1]; ss = _tuple$1[2]; err$1 = _tuple$1[3]; - if (!($interfaceIsEqual(err$1, $ifaceNil))) { - _tmp$16 = ""; _tmp$17 = err$1; t = _tmp$16; err = _tmp$17; - return [t, err]; - } - s = ss; - if (c < 128 || !multibyte) { - buf = $append(buf, (c << 24 >>> 24)); - } else { - n$1 = utf8.EncodeRune(new ($sliceType($Uint8))(runeTmp), c); - buf = $appendSlice(buf, $subslice(new ($sliceType($Uint8))(runeTmp), 0, n$1)); - } - if ((quote === 39) && !((s.length === 0))) { - _tmp$18 = ""; _tmp$19 = $pkg.ErrSyntax; t = _tmp$18; err = _tmp$19; - return [t, err]; + _ref = l.zone; + _i = 0; + while (_i < _ref.$length) { + zi$1 = _i; + if (!(x$5 = l.zone, ((zi$1 < 0 || zi$1 >= x$5.$length) ? $throwRuntimeError("index out of range") : x$5.$array[x$5.$offset + zi$1])).isDST) { + return zi$1; } + _i++; } - _tmp$20 = $bytesToString(buf); _tmp$21 = $ifaceNil; t = _tmp$20; err = _tmp$21; - return [t, err]; + return 0; }; - contains = function(s, c) { - var i; - i = 0; - while (i < s.length) { - if (s.charCodeAt(i) === c) { + Location.prototype.lookupFirstZone = function() { return this.$val.lookupFirstZone(); }; + Location.Ptr.prototype.firstZoneUsed = function() { + var l, _ref, _i, tx; + l = this; + _ref = l.tx; + _i = 0; + while (_i < _ref.$length) { + tx = new zoneTrans.Ptr(); $copy(tx, ((_i < 0 || _i >= _ref.$length) ? $throwRuntimeError("index out of range") : _ref.$array[_ref.$offset + _i]), zoneTrans); + if (tx.index === 0) { return true; } - i = i + (1) >> 0; + _i++; } return false; }; - bsearch16 = function(a, x) { - var _tmp, _tmp$1, i, j, _q, h; - _tmp = 0; _tmp$1 = a.$length; i = _tmp; j = _tmp$1; - while (i < j) { - h = i + (_q = ((j - i >> 0)) / 2, (_q === _q && _q !== 1/0 && _q !== -1/0) ? _q >> 0 : $throwRuntimeError("integer divide by zero")) >> 0; - if (((h < 0 || h >= a.$length) ? $throwRuntimeError("index out of range") : a.$array[a.$offset + h]) < x) { - i = h + 1 >> 0; - } else { - j = h; - } - } - return i; - }; - bsearch32 = function(a, x) { - var _tmp, _tmp$1, i, j, _q, h; - _tmp = 0; _tmp$1 = a.$length; i = _tmp; j = _tmp$1; - while (i < j) { - h = i + (_q = ((j - i >> 0)) / 2, (_q === _q && _q !== 1/0 && _q !== -1/0) ? _q >> 0 : $throwRuntimeError("integer divide by zero")) >> 0; - if (((h < 0 || h >= a.$length) ? $throwRuntimeError("index out of range") : a.$array[a.$offset + h]) < x) { - i = h + 1 >> 0; - } else { - j = h; - } - } - return i; - }; - IsPrint = $pkg.IsPrint = function(r) { - var _tmp, _tmp$1, _tmp$2, rr, isPrint, isNotPrint, i, x, x$1, j, _tmp$3, _tmp$4, _tmp$5, rr$1, isPrint$1, isNotPrint$1, i$1, x$2, x$3, j$1; - if (r <= 255) { - if (32 <= r && r <= 126) { - return true; - } - if (161 <= r && r <= 255) { - return !((r === 173)); + Location.prototype.firstZoneUsed = function() { return this.$val.firstZoneUsed(); }; + Location.Ptr.prototype.lookupName = function(name, unix) { + var offset = 0, isDST = false, ok = false, l, _ref, _i, i, x, zone$1, _tuple$1, x$1, nam, offset$1, isDST$1, _tmp, _tmp$1, _tmp$2, _ref$1, _i$1, i$1, x$2, zone$2, _tmp$3, _tmp$4, _tmp$5; + l = this; + l = l.get(); + _ref = l.zone; + _i = 0; + while (_i < _ref.$length) { + i = _i; + zone$1 = (x = l.zone, ((i < 0 || i >= x.$length) ? $throwRuntimeError("index out of range") : x.$array[x.$offset + i])); + if (zone$1.name === name) { + _tuple$1 = l.lookup((x$1 = new $Int64(0, zone$1.offset), new $Int64(unix.$high - x$1.$high, unix.$low - x$1.$low))); nam = _tuple$1[0]; offset$1 = _tuple$1[1]; isDST$1 = _tuple$1[2]; + if (nam === zone$1.name) { + _tmp = offset$1; _tmp$1 = isDST$1; _tmp$2 = true; offset = _tmp; isDST = _tmp$1; ok = _tmp$2; + return [offset, isDST, ok]; + } } - return false; + _i++; } - if (0 <= r && r < 65536) { - _tmp = (r << 16 >>> 16); _tmp$1 = isPrint16; _tmp$2 = isNotPrint16; rr = _tmp; isPrint = _tmp$1; isNotPrint = _tmp$2; - i = bsearch16(isPrint, rr); - if (i >= isPrint.$length || rr < (x = i & ~1, ((x < 0 || x >= isPrint.$length) ? $throwRuntimeError("index out of range") : isPrint.$array[isPrint.$offset + x])) || (x$1 = i | 1, ((x$1 < 0 || x$1 >= isPrint.$length) ? $throwRuntimeError("index out of range") : isPrint.$array[isPrint.$offset + x$1])) < rr) { - return false; + _ref$1 = l.zone; + _i$1 = 0; + while (_i$1 < _ref$1.$length) { + i$1 = _i$1; + zone$2 = (x$2 = l.zone, ((i$1 < 0 || i$1 >= x$2.$length) ? $throwRuntimeError("index out of range") : x$2.$array[x$2.$offset + i$1])); + if (zone$2.name === name) { + _tmp$3 = zone$2.offset; _tmp$4 = zone$2.isDST; _tmp$5 = true; offset = _tmp$3; isDST = _tmp$4; ok = _tmp$5; + return [offset, isDST, ok]; } - j = bsearch16(isNotPrint, rr); - return j >= isNotPrint.$length || !((((j < 0 || j >= isNotPrint.$length) ? $throwRuntimeError("index out of range") : isNotPrint.$array[isNotPrint.$offset + j]) === rr)); - } - _tmp$3 = (r >>> 0); _tmp$4 = isPrint32; _tmp$5 = isNotPrint32; rr$1 = _tmp$3; isPrint$1 = _tmp$4; isNotPrint$1 = _tmp$5; - i$1 = bsearch32(isPrint$1, rr$1); - if (i$1 >= isPrint$1.$length || rr$1 < (x$2 = i$1 & ~1, ((x$2 < 0 || x$2 >= isPrint$1.$length) ? $throwRuntimeError("index out of range") : isPrint$1.$array[isPrint$1.$offset + x$2])) || (x$3 = i$1 | 1, ((x$3 < 0 || x$3 >= isPrint$1.$length) ? $throwRuntimeError("index out of range") : isPrint$1.$array[isPrint$1.$offset + x$3])) < rr$1) { - return false; - } - if (r >= 131072) { - return true; + _i$1++; } - r = r - (65536) >> 0; - j$1 = bsearch16(isNotPrint$1, (r << 16 >>> 16)); - return j$1 >= isNotPrint$1.$length || !((((j$1 < 0 || j$1 >= isNotPrint$1.$length) ? $throwRuntimeError("index out of range") : isNotPrint$1.$array[isNotPrint$1.$offset + j$1]) === (r << 16 >>> 16))); + return [offset, isDST, ok]; }; + Location.prototype.lookupName = function(name, unix) { return this.$val.lookupName(name, unix); }; $pkg.$init = function() { - ($ptrType(NumError)).methods = [["Error", "Error", "", $funcType([], [$String], false), -1]]; - NumError.init([["Func", "Func", "", $String, ""], ["Num", "Num", "", $String, ""], ["Err", "Err", "", $error, ""]]); - ($ptrType(decimal)).methods = [["Assign", "Assign", "", $funcType([$Uint64], [], false), -1], ["Round", "Round", "", $funcType([$Int], [], false), -1], ["RoundDown", "RoundDown", "", $funcType([$Int], [], false), -1], ["RoundUp", "RoundUp", "", $funcType([$Int], [], false), -1], ["RoundedInteger", "RoundedInteger", "", $funcType([], [$Uint64], false), -1], ["Shift", "Shift", "", $funcType([$Int], [], false), -1], ["String", "String", "", $funcType([], [$String], false), -1], ["floatBits", "floatBits", "strconv", $funcType([($ptrType(floatInfo))], [$Uint64, $Bool], false), -1], ["set", "set", "strconv", $funcType([$String], [$Bool], false), -1]]; - decimal.init([["d", "d", "strconv", ($arrayType($Uint8, 800)), ""], ["nd", "nd", "strconv", $Int, ""], ["dp", "dp", "strconv", $Int, ""], ["neg", "neg", "strconv", $Bool, ""], ["trunc", "trunc", "strconv", $Bool, ""]]); - leftCheat.init([["delta", "delta", "strconv", $Int, ""], ["cutoff", "cutoff", "strconv", $String, ""]]); - ($ptrType(extFloat)).methods = [["AssignComputeBounds", "AssignComputeBounds", "", $funcType([$Uint64, $Int, $Bool, ($ptrType(floatInfo))], [extFloat, extFloat], false), -1], ["AssignDecimal", "AssignDecimal", "", $funcType([$Uint64, $Int, $Bool, $Bool, ($ptrType(floatInfo))], [$Bool], false), -1], ["FixedDecimal", "FixedDecimal", "", $funcType([($ptrType(decimalSlice)), $Int], [$Bool], false), -1], ["Multiply", "Multiply", "", $funcType([extFloat], [], false), -1], ["Normalize", "Normalize", "", $funcType([], [$Uint], false), -1], ["ShortestDecimal", "ShortestDecimal", "", $funcType([($ptrType(decimalSlice)), ($ptrType(extFloat)), ($ptrType(extFloat))], [$Bool], false), -1], ["floatBits", "floatBits", "strconv", $funcType([($ptrType(floatInfo))], [$Uint64, $Bool], false), -1], ["frexp10", "frexp10", "strconv", $funcType([], [$Int, $Int], false), -1]]; - extFloat.init([["mant", "mant", "strconv", $Uint64, ""], ["exp", "exp", "strconv", $Int, ""], ["neg", "neg", "strconv", $Bool, ""]]); - floatInfo.init([["mantbits", "mantbits", "strconv", $Uint, ""], ["expbits", "expbits", "strconv", $Uint, ""], ["bias", "bias", "strconv", $Int, ""]]); - decimalSlice.init([["d", "d", "strconv", ($sliceType($Uint8)), ""], ["nd", "nd", "strconv", $Int, ""], ["dp", "dp", "strconv", $Int, ""], ["neg", "neg", "strconv", $Bool, ""]]); - optimize = true; - powtab = new ($sliceType($Int))([1, 3, 6, 9, 13, 16, 19, 23, 26]); - float64pow10 = new ($sliceType($Float64))([1, 10, 100, 1000, 10000, 100000, 1e+06, 1e+07, 1e+08, 1e+09, 1e+10, 1e+11, 1e+12, 1e+13, 1e+14, 1e+15, 1e+16, 1e+17, 1e+18, 1e+19, 1e+20, 1e+21, 1e+22]); - float32pow10 = new ($sliceType($Float32))([1, 10, 100, 1000, 10000, 100000, 1e+06, 1e+07, 1e+08, 1e+09, 1e+10]); - $pkg.ErrRange = errors.New("value out of range"); - $pkg.ErrSyntax = errors.New("invalid syntax"); - leftcheats = new ($sliceType(leftCheat))([new leftCheat.Ptr(0, ""), new leftCheat.Ptr(1, "5"), new leftCheat.Ptr(1, "25"), new leftCheat.Ptr(1, "125"), new leftCheat.Ptr(2, "625"), new leftCheat.Ptr(2, "3125"), new leftCheat.Ptr(2, "15625"), new leftCheat.Ptr(3, "78125"), new leftCheat.Ptr(3, "390625"), new leftCheat.Ptr(3, "1953125"), new leftCheat.Ptr(4, "9765625"), new leftCheat.Ptr(4, "48828125"), new leftCheat.Ptr(4, "244140625"), new leftCheat.Ptr(4, "1220703125"), new leftCheat.Ptr(5, "6103515625"), new leftCheat.Ptr(5, "30517578125"), new leftCheat.Ptr(5, "152587890625"), new leftCheat.Ptr(6, "762939453125"), new leftCheat.Ptr(6, "3814697265625"), new leftCheat.Ptr(6, "19073486328125"), new leftCheat.Ptr(7, "95367431640625"), new leftCheat.Ptr(7, "476837158203125"), new leftCheat.Ptr(7, "2384185791015625"), new leftCheat.Ptr(7, "11920928955078125"), new leftCheat.Ptr(8, "59604644775390625"), new leftCheat.Ptr(8, "298023223876953125"), new leftCheat.Ptr(8, "1490116119384765625"), new leftCheat.Ptr(9, "7450580596923828125")]); - smallPowersOfTen = $toNativeArray("Struct", [new extFloat.Ptr(new $Uint64(2147483648, 0), -63, false), new extFloat.Ptr(new $Uint64(2684354560, 0), -60, false), new extFloat.Ptr(new $Uint64(3355443200, 0), -57, false), new extFloat.Ptr(new $Uint64(4194304000, 0), -54, false), new extFloat.Ptr(new $Uint64(2621440000, 0), -50, false), new extFloat.Ptr(new $Uint64(3276800000, 0), -47, false), new extFloat.Ptr(new $Uint64(4096000000, 0), -44, false), new extFloat.Ptr(new $Uint64(2560000000, 0), -40, false)]); - powersOfTen = $toNativeArray("Struct", [new extFloat.Ptr(new $Uint64(4203730336, 136053384), -1220, false), new extFloat.Ptr(new $Uint64(3132023167, 2722021238), -1193, false), new extFloat.Ptr(new $Uint64(2333539104, 810921078), -1166, false), new extFloat.Ptr(new $Uint64(3477244234, 1573795306), -1140, false), new extFloat.Ptr(new $Uint64(2590748842, 1432697645), -1113, false), new extFloat.Ptr(new $Uint64(3860516611, 1025131999), -1087, false), new extFloat.Ptr(new $Uint64(2876309015, 3348809418), -1060, false), new extFloat.Ptr(new $Uint64(4286034428, 3200048207), -1034, false), new extFloat.Ptr(new $Uint64(3193344495, 1097586188), -1007, false), new extFloat.Ptr(new $Uint64(2379227053, 2424306748), -980, false), new extFloat.Ptr(new $Uint64(3545324584, 827693699), -954, false), new extFloat.Ptr(new $Uint64(2641472655, 2913388981), -927, false), new extFloat.Ptr(new $Uint64(3936100983, 602835915), -901, false), new extFloat.Ptr(new $Uint64(2932623761, 1081627501), -874, false), new extFloat.Ptr(new $Uint64(2184974969, 1572261463), -847, false), new extFloat.Ptr(new $Uint64(3255866422, 1308317239), -821, false), new extFloat.Ptr(new $Uint64(2425809519, 944281679), -794, false), new extFloat.Ptr(new $Uint64(3614737867, 629291719), -768, false), new extFloat.Ptr(new $Uint64(2693189581, 2545915892), -741, false), new extFloat.Ptr(new $Uint64(4013165208, 388672741), -715, false), new extFloat.Ptr(new $Uint64(2990041083, 708162190), -688, false), new extFloat.Ptr(new $Uint64(2227754207, 3536207675), -661, false), new extFloat.Ptr(new $Uint64(3319612455, 450088378), -635, false), new extFloat.Ptr(new $Uint64(2473304014, 3139815830), -608, false), new extFloat.Ptr(new $Uint64(3685510180, 2103616900), -582, false), new extFloat.Ptr(new $Uint64(2745919064, 224385782), -555, false), new extFloat.Ptr(new $Uint64(4091738259, 3737383206), -529, false), new extFloat.Ptr(new $Uint64(3048582568, 2868871352), -502, false), new extFloat.Ptr(new $Uint64(2271371013, 1820084875), -475, false), new extFloat.Ptr(new $Uint64(3384606560, 885076051), -449, false), new extFloat.Ptr(new $Uint64(2521728396, 2444895829), -422, false), new extFloat.Ptr(new $Uint64(3757668132, 1881767613), -396, false), new extFloat.Ptr(new $Uint64(2799680927, 3102062735), -369, false), new extFloat.Ptr(new $Uint64(4171849679, 2289335700), -343, false), new extFloat.Ptr(new $Uint64(3108270227, 2410191823), -316, false), new extFloat.Ptr(new $Uint64(2315841784, 3205436779), -289, false), new extFloat.Ptr(new $Uint64(3450873173, 1697722806), -263, false), new extFloat.Ptr(new $Uint64(2571100870, 3497754540), -236, false), new extFloat.Ptr(new $Uint64(3831238852, 707476230), -210, false), new extFloat.Ptr(new $Uint64(2854495385, 1769181907), -183, false), new extFloat.Ptr(new $Uint64(4253529586, 2197867022), -157, false), new extFloat.Ptr(new $Uint64(3169126500, 2450594539), -130, false), new extFloat.Ptr(new $Uint64(2361183241, 1867548876), -103, false), new extFloat.Ptr(new $Uint64(3518437208, 3793315116), -77, false), new extFloat.Ptr(new $Uint64(2621440000, 0), -50, false), new extFloat.Ptr(new $Uint64(3906250000, 0), -24, false), new extFloat.Ptr(new $Uint64(2910383045, 2892103680), 3, false), new extFloat.Ptr(new $Uint64(2168404344, 4170451332), 30, false), new extFloat.Ptr(new $Uint64(3231174267, 3372684723), 56, false), new extFloat.Ptr(new $Uint64(2407412430, 2078956656), 83, false), new extFloat.Ptr(new $Uint64(3587324068, 2884206696), 109, false), new extFloat.Ptr(new $Uint64(2672764710, 395977285), 136, false), new extFloat.Ptr(new $Uint64(3982729777, 3569679143), 162, false), new extFloat.Ptr(new $Uint64(2967364920, 2361961896), 189, false), new extFloat.Ptr(new $Uint64(2210859150, 447440347), 216, false), new extFloat.Ptr(new $Uint64(3294436857, 1114709402), 242, false), new extFloat.Ptr(new $Uint64(2454546732, 2786846552), 269, false), new extFloat.Ptr(new $Uint64(3657559652, 443583978), 295, false), new extFloat.Ptr(new $Uint64(2725094297, 2599384906), 322, false), new extFloat.Ptr(new $Uint64(4060706939, 3028118405), 348, false), new extFloat.Ptr(new $Uint64(3025462433, 2044532855), 375, false), new extFloat.Ptr(new $Uint64(2254145170, 1536935362), 402, false), new extFloat.Ptr(new $Uint64(3358938053, 3365297469), 428, false), new extFloat.Ptr(new $Uint64(2502603868, 4204241075), 455, false), new extFloat.Ptr(new $Uint64(3729170365, 2577424355), 481, false), new extFloat.Ptr(new $Uint64(2778448436, 3677981733), 508, false), new extFloat.Ptr(new $Uint64(4140210802, 2744688476), 534, false), new extFloat.Ptr(new $Uint64(3084697427, 1424604878), 561, false), new extFloat.Ptr(new $Uint64(2298278679, 4062331362), 588, false), new extFloat.Ptr(new $Uint64(3424702107, 3546052773), 614, false), new extFloat.Ptr(new $Uint64(2551601907, 2065781727), 641, false), new extFloat.Ptr(new $Uint64(3802183132, 2535403578), 667, false), new extFloat.Ptr(new $Uint64(2832847187, 1558426518), 694, false), new extFloat.Ptr(new $Uint64(4221271257, 2762425404), 720, false), new extFloat.Ptr(new $Uint64(3145092172, 2812560400), 747, false), new extFloat.Ptr(new $Uint64(2343276271, 3057687578), 774, false), new extFloat.Ptr(new $Uint64(3491753744, 2790753324), 800, false), new extFloat.Ptr(new $Uint64(2601559269, 3918606633), 827, false), new extFloat.Ptr(new $Uint64(3876625403, 2711358621), 853, false), new extFloat.Ptr(new $Uint64(2888311001, 1648096297), 880, false), new extFloat.Ptr(new $Uint64(2151959390, 2057817989), 907, false), new extFloat.Ptr(new $Uint64(3206669376, 61660461), 933, false), new extFloat.Ptr(new $Uint64(2389154863, 1581580175), 960, false), new extFloat.Ptr(new $Uint64(3560118173, 2626467905), 986, false), new extFloat.Ptr(new $Uint64(2652494738, 3034782633), 1013, false), new extFloat.Ptr(new $Uint64(3952525166, 3135207385), 1039, false), new extFloat.Ptr(new $Uint64(2944860731, 2616258155), 1066, false)]); - uint64pow10 = $toNativeArray("Uint64", [new $Uint64(0, 1), new $Uint64(0, 10), new $Uint64(0, 100), new $Uint64(0, 1000), new $Uint64(0, 10000), new $Uint64(0, 100000), new $Uint64(0, 1000000), new $Uint64(0, 10000000), new $Uint64(0, 100000000), new $Uint64(0, 1000000000), new $Uint64(2, 1410065408), new $Uint64(23, 1215752192), new $Uint64(232, 3567587328), new $Uint64(2328, 1316134912), new $Uint64(23283, 276447232), new $Uint64(232830, 2764472320), new $Uint64(2328306, 1874919424), new $Uint64(23283064, 1569325056), new $Uint64(232830643, 2808348672), new $Uint64(2328306436, 2313682944)]); - float32info = new floatInfo.Ptr(23, 8, -127); - float64info = new floatInfo.Ptr(52, 11, -1023); - isPrint16 = new ($sliceType($Uint16))([32, 126, 161, 887, 890, 894, 900, 1319, 1329, 1366, 1369, 1418, 1423, 1479, 1488, 1514, 1520, 1524, 1542, 1563, 1566, 1805, 1808, 1866, 1869, 1969, 1984, 2042, 2048, 2093, 2096, 2139, 2142, 2142, 2208, 2220, 2276, 2444, 2447, 2448, 2451, 2482, 2486, 2489, 2492, 2500, 2503, 2504, 2507, 2510, 2519, 2519, 2524, 2531, 2534, 2555, 2561, 2570, 2575, 2576, 2579, 2617, 2620, 2626, 2631, 2632, 2635, 2637, 2641, 2641, 2649, 2654, 2662, 2677, 2689, 2745, 2748, 2765, 2768, 2768, 2784, 2787, 2790, 2801, 2817, 2828, 2831, 2832, 2835, 2873, 2876, 2884, 2887, 2888, 2891, 2893, 2902, 2903, 2908, 2915, 2918, 2935, 2946, 2954, 2958, 2965, 2969, 2975, 2979, 2980, 2984, 2986, 2990, 3001, 3006, 3010, 3014, 3021, 3024, 3024, 3031, 3031, 3046, 3066, 3073, 3129, 3133, 3149, 3157, 3161, 3168, 3171, 3174, 3183, 3192, 3199, 3202, 3257, 3260, 3277, 3285, 3286, 3294, 3299, 3302, 3314, 3330, 3386, 3389, 3406, 3415, 3415, 3424, 3427, 3430, 3445, 3449, 3455, 3458, 3478, 3482, 3517, 3520, 3526, 3530, 3530, 3535, 3551, 3570, 3572, 3585, 3642, 3647, 3675, 3713, 3716, 3719, 3722, 3725, 3725, 3732, 3751, 3754, 3773, 3776, 3789, 3792, 3801, 3804, 3807, 3840, 3948, 3953, 4058, 4096, 4295, 4301, 4301, 4304, 4685, 4688, 4701, 4704, 4749, 4752, 4789, 4792, 4805, 4808, 4885, 4888, 4954, 4957, 4988, 4992, 5017, 5024, 5108, 5120, 5788, 5792, 5872, 5888, 5908, 5920, 5942, 5952, 5971, 5984, 6003, 6016, 6109, 6112, 6121, 6128, 6137, 6144, 6157, 6160, 6169, 6176, 6263, 6272, 6314, 6320, 6389, 6400, 6428, 6432, 6443, 6448, 6459, 6464, 6464, 6468, 6509, 6512, 6516, 6528, 6571, 6576, 6601, 6608, 6618, 6622, 6683, 6686, 6780, 6783, 6793, 6800, 6809, 6816, 6829, 6912, 6987, 6992, 7036, 7040, 7155, 7164, 7223, 7227, 7241, 7245, 7295, 7360, 7367, 7376, 7414, 7424, 7654, 7676, 7957, 7960, 7965, 7968, 8005, 8008, 8013, 8016, 8061, 8064, 8147, 8150, 8175, 8178, 8190, 8208, 8231, 8240, 8286, 8304, 8305, 8308, 8348, 8352, 8378, 8400, 8432, 8448, 8585, 8592, 9203, 9216, 9254, 9280, 9290, 9312, 11084, 11088, 11097, 11264, 11507, 11513, 11559, 11565, 11565, 11568, 11623, 11631, 11632, 11647, 11670, 11680, 11835, 11904, 12019, 12032, 12245, 12272, 12283, 12289, 12438, 12441, 12543, 12549, 12589, 12593, 12730, 12736, 12771, 12784, 19893, 19904, 40908, 40960, 42124, 42128, 42182, 42192, 42539, 42560, 42647, 42655, 42743, 42752, 42899, 42912, 42922, 43000, 43051, 43056, 43065, 43072, 43127, 43136, 43204, 43214, 43225, 43232, 43259, 43264, 43347, 43359, 43388, 43392, 43481, 43486, 43487, 43520, 43574, 43584, 43597, 43600, 43609, 43612, 43643, 43648, 43714, 43739, 43766, 43777, 43782, 43785, 43790, 43793, 43798, 43808, 43822, 43968, 44013, 44016, 44025, 44032, 55203, 55216, 55238, 55243, 55291, 63744, 64109, 64112, 64217, 64256, 64262, 64275, 64279, 64285, 64449, 64467, 64831, 64848, 64911, 64914, 64967, 65008, 65021, 65024, 65049, 65056, 65062, 65072, 65131, 65136, 65276, 65281, 65470, 65474, 65479, 65482, 65487, 65490, 65495, 65498, 65500, 65504, 65518, 65532, 65533]); - isNotPrint16 = new ($sliceType($Uint16))([173, 907, 909, 930, 1376, 1416, 1424, 1757, 2111, 2209, 2303, 2424, 2432, 2436, 2473, 2481, 2526, 2564, 2601, 2609, 2612, 2615, 2621, 2653, 2692, 2702, 2706, 2729, 2737, 2740, 2758, 2762, 2820, 2857, 2865, 2868, 2910, 2948, 2961, 2971, 2973, 3017, 3076, 3085, 3089, 3113, 3124, 3141, 3145, 3159, 3204, 3213, 3217, 3241, 3252, 3269, 3273, 3295, 3312, 3332, 3341, 3345, 3397, 3401, 3460, 3506, 3516, 3541, 3543, 3715, 3721, 3736, 3744, 3748, 3750, 3756, 3770, 3781, 3783, 3912, 3992, 4029, 4045, 4294, 4681, 4695, 4697, 4745, 4785, 4799, 4801, 4823, 4881, 5760, 5901, 5997, 6001, 6751, 8024, 8026, 8028, 8030, 8117, 8133, 8156, 8181, 8335, 9984, 11311, 11359, 11558, 11687, 11695, 11703, 11711, 11719, 11727, 11735, 11743, 11930, 12352, 12687, 12831, 13055, 42895, 43470, 43815, 64311, 64317, 64319, 64322, 64325, 65107, 65127, 65141, 65511]); - isPrint32 = new ($sliceType($Uint32))([65536, 65613, 65616, 65629, 65664, 65786, 65792, 65794, 65799, 65843, 65847, 65930, 65936, 65947, 66000, 66045, 66176, 66204, 66208, 66256, 66304, 66339, 66352, 66378, 66432, 66499, 66504, 66517, 66560, 66717, 66720, 66729, 67584, 67589, 67592, 67640, 67644, 67644, 67647, 67679, 67840, 67867, 67871, 67897, 67903, 67903, 67968, 68023, 68030, 68031, 68096, 68102, 68108, 68147, 68152, 68154, 68159, 68167, 68176, 68184, 68192, 68223, 68352, 68405, 68409, 68437, 68440, 68466, 68472, 68479, 68608, 68680, 69216, 69246, 69632, 69709, 69714, 69743, 69760, 69825, 69840, 69864, 69872, 69881, 69888, 69955, 70016, 70088, 70096, 70105, 71296, 71351, 71360, 71369, 73728, 74606, 74752, 74850, 74864, 74867, 77824, 78894, 92160, 92728, 93952, 94020, 94032, 94078, 94095, 94111, 110592, 110593, 118784, 119029, 119040, 119078, 119081, 119154, 119163, 119261, 119296, 119365, 119552, 119638, 119648, 119665, 119808, 119967, 119970, 119970, 119973, 119974, 119977, 120074, 120077, 120134, 120138, 120485, 120488, 120779, 120782, 120831, 126464, 126500, 126503, 126523, 126530, 126530, 126535, 126548, 126551, 126564, 126567, 126619, 126625, 126651, 126704, 126705, 126976, 127019, 127024, 127123, 127136, 127150, 127153, 127166, 127169, 127199, 127232, 127242, 127248, 127339, 127344, 127386, 127462, 127490, 127504, 127546, 127552, 127560, 127568, 127569, 127744, 127776, 127792, 127868, 127872, 127891, 127904, 127946, 127968, 127984, 128000, 128252, 128256, 128317, 128320, 128323, 128336, 128359, 128507, 128576, 128581, 128591, 128640, 128709, 128768, 128883, 131072, 173782, 173824, 177972, 177984, 178205, 194560, 195101, 917760, 917999]); - isNotPrint32 = new ($sliceType($Uint16))([12, 39, 59, 62, 799, 926, 2057, 2102, 2134, 2564, 2580, 2584, 4285, 4405, 54357, 54429, 54445, 54458, 54460, 54468, 54534, 54549, 54557, 54586, 54591, 54597, 54609, 60932, 60960, 60963, 60968, 60979, 60984, 60986, 61000, 61002, 61004, 61008, 61011, 61016, 61018, 61020, 61022, 61024, 61027, 61035, 61043, 61048, 61053, 61055, 61066, 61092, 61098, 61648, 61743, 62262, 62405, 62527, 62529, 62712]); - shifts = $toNativeArray("Uint", [0, 0, 1, 0, 2, 0, 0, 0, 3, 0, 0, 0, 0, 0, 0, 0, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 5, 0, 0, 0, 0]); + runtimeTimer.init([["i", "i", "time", $Int32, ""], ["when", "when", "time", $Int64, ""], ["period", "period", "time", $Int64, ""], ["f", "f", "time", ($funcType([$Int64, $emptyInterface], [], false)), ""], ["arg", "arg", "time", $emptyInterface, ""], ["timeout", "timeout", "time", js.Object, ""], ["active", "active", "time", $Bool, ""]]); + ($ptrType(ParseError)).methods = [["Error", "Error", "", $funcType([], [$String], false), -1]]; + ParseError.init([["Layout", "Layout", "", $String, ""], ["Value", "Value", "", $String, ""], ["LayoutElem", "LayoutElem", "", $String, ""], ["ValueElem", "ValueElem", "", $String, ""], ["Message", "Message", "", $String, ""]]); + ($ptrType(Timer)).methods = [["Reset", "Reset", "", $funcType([Duration], [$Bool], false), -1], ["Stop", "Stop", "", $funcType([], [$Bool], false), -1]]; + Timer.init([["C", "C", "", ($chanType(Time, false, true)), ""], ["r", "r", "time", runtimeTimer, ""]]); + Time.methods = [["Add", "Add", "", $funcType([Duration], [Time], false), -1], ["AddDate", "AddDate", "", $funcType([$Int, $Int, $Int], [Time], false), -1], ["After", "After", "", $funcType([Time], [$Bool], false), -1], ["Before", "Before", "", $funcType([Time], [$Bool], false), -1], ["Clock", "Clock", "", $funcType([], [$Int, $Int, $Int], false), -1], ["Date", "Date", "", $funcType([], [$Int, Month, $Int], false), -1], ["Day", "Day", "", $funcType([], [$Int], false), -1], ["Equal", "Equal", "", $funcType([Time], [$Bool], false), -1], ["Format", "Format", "", $funcType([$String], [$String], false), -1], ["GobEncode", "GobEncode", "", $funcType([], [($sliceType($Uint8)), $error], false), -1], ["Hour", "Hour", "", $funcType([], [$Int], false), -1], ["ISOWeek", "ISOWeek", "", $funcType([], [$Int, $Int], false), -1], ["In", "In", "", $funcType([($ptrType(Location))], [Time], false), -1], ["IsZero", "IsZero", "", $funcType([], [$Bool], false), -1], ["Local", "Local", "", $funcType([], [Time], false), -1], ["Location", "Location", "", $funcType([], [($ptrType(Location))], false), -1], ["MarshalBinary", "MarshalBinary", "", $funcType([], [($sliceType($Uint8)), $error], false), -1], ["MarshalJSON", "MarshalJSON", "", $funcType([], [($sliceType($Uint8)), $error], false), -1], ["MarshalText", "MarshalText", "", $funcType([], [($sliceType($Uint8)), $error], false), -1], ["Minute", "Minute", "", $funcType([], [$Int], false), -1], ["Month", "Month", "", $funcType([], [Month], false), -1], ["Nanosecond", "Nanosecond", "", $funcType([], [$Int], false), -1], ["Round", "Round", "", $funcType([Duration], [Time], false), -1], ["Second", "Second", "", $funcType([], [$Int], false), -1], ["String", "String", "", $funcType([], [$String], false), -1], ["Sub", "Sub", "", $funcType([Time], [Duration], false), -1], ["Truncate", "Truncate", "", $funcType([Duration], [Time], false), -1], ["UTC", "UTC", "", $funcType([], [Time], false), -1], ["Unix", "Unix", "", $funcType([], [$Int64], false), -1], ["UnixNano", "UnixNano", "", $funcType([], [$Int64], false), -1], ["Weekday", "Weekday", "", $funcType([], [Weekday], false), -1], ["Year", "Year", "", $funcType([], [$Int], false), -1], ["YearDay", "YearDay", "", $funcType([], [$Int], false), -1], ["Zone", "Zone", "", $funcType([], [$String, $Int], false), -1], ["abs", "abs", "time", $funcType([], [$Uint64], false), -1], ["date", "date", "time", $funcType([$Bool], [$Int, Month, $Int, $Int], false), -1], ["locabs", "locabs", "time", $funcType([], [$String, $Int, $Uint64], false), -1]]; + ($ptrType(Time)).methods = [["Add", "Add", "", $funcType([Duration], [Time], false), -1], ["AddDate", "AddDate", "", $funcType([$Int, $Int, $Int], [Time], false), -1], ["After", "After", "", $funcType([Time], [$Bool], false), -1], ["Before", "Before", "", $funcType([Time], [$Bool], false), -1], ["Clock", "Clock", "", $funcType([], [$Int, $Int, $Int], false), -1], ["Date", "Date", "", $funcType([], [$Int, Month, $Int], false), -1], ["Day", "Day", "", $funcType([], [$Int], false), -1], ["Equal", "Equal", "", $funcType([Time], [$Bool], false), -1], ["Format", "Format", "", $funcType([$String], [$String], false), -1], ["GobDecode", "GobDecode", "", $funcType([($sliceType($Uint8))], [$error], false), -1], ["GobEncode", "GobEncode", "", $funcType([], [($sliceType($Uint8)), $error], false), -1], ["Hour", "Hour", "", $funcType([], [$Int], false), -1], ["ISOWeek", "ISOWeek", "", $funcType([], [$Int, $Int], false), -1], ["In", "In", "", $funcType([($ptrType(Location))], [Time], false), -1], ["IsZero", "IsZero", "", $funcType([], [$Bool], false), -1], ["Local", "Local", "", $funcType([], [Time], false), -1], ["Location", "Location", "", $funcType([], [($ptrType(Location))], false), -1], ["MarshalBinary", "MarshalBinary", "", $funcType([], [($sliceType($Uint8)), $error], false), -1], ["MarshalJSON", "MarshalJSON", "", $funcType([], [($sliceType($Uint8)), $error], false), -1], ["MarshalText", "MarshalText", "", $funcType([], [($sliceType($Uint8)), $error], false), -1], ["Minute", "Minute", "", $funcType([], [$Int], false), -1], ["Month", "Month", "", $funcType([], [Month], false), -1], ["Nanosecond", "Nanosecond", "", $funcType([], [$Int], false), -1], ["Round", "Round", "", $funcType([Duration], [Time], false), -1], ["Second", "Second", "", $funcType([], [$Int], false), -1], ["String", "String", "", $funcType([], [$String], false), -1], ["Sub", "Sub", "", $funcType([Time], [Duration], false), -1], ["Truncate", "Truncate", "", $funcType([Duration], [Time], false), -1], ["UTC", "UTC", "", $funcType([], [Time], false), -1], ["Unix", "Unix", "", $funcType([], [$Int64], false), -1], ["UnixNano", "UnixNano", "", $funcType([], [$Int64], false), -1], ["UnmarshalBinary", "UnmarshalBinary", "", $funcType([($sliceType($Uint8))], [$error], false), -1], ["UnmarshalJSON", "UnmarshalJSON", "", $funcType([($sliceType($Uint8))], [$error], false), -1], ["UnmarshalText", "UnmarshalText", "", $funcType([($sliceType($Uint8))], [$error], false), -1], ["Weekday", "Weekday", "", $funcType([], [Weekday], false), -1], ["Year", "Year", "", $funcType([], [$Int], false), -1], ["YearDay", "YearDay", "", $funcType([], [$Int], false), -1], ["Zone", "Zone", "", $funcType([], [$String, $Int], false), -1], ["abs", "abs", "time", $funcType([], [$Uint64], false), -1], ["date", "date", "time", $funcType([$Bool], [$Int, Month, $Int, $Int], false), -1], ["locabs", "locabs", "time", $funcType([], [$String, $Int, $Uint64], false), -1]]; + Time.init([["sec", "sec", "time", $Int64, ""], ["nsec", "nsec", "time", $Uintptr, ""], ["loc", "loc", "time", ($ptrType(Location)), ""]]); + Month.methods = [["String", "String", "", $funcType([], [$String], false), -1]]; + ($ptrType(Month)).methods = [["String", "String", "", $funcType([], [$String], false), -1]]; + Weekday.methods = [["String", "String", "", $funcType([], [$String], false), -1]]; + ($ptrType(Weekday)).methods = [["String", "String", "", $funcType([], [$String], false), -1]]; + Duration.methods = [["Hours", "Hours", "", $funcType([], [$Float64], false), -1], ["Minutes", "Minutes", "", $funcType([], [$Float64], false), -1], ["Nanoseconds", "Nanoseconds", "", $funcType([], [$Int64], false), -1], ["Seconds", "Seconds", "", $funcType([], [$Float64], false), -1], ["String", "String", "", $funcType([], [$String], false), -1]]; + ($ptrType(Duration)).methods = [["Hours", "Hours", "", $funcType([], [$Float64], false), -1], ["Minutes", "Minutes", "", $funcType([], [$Float64], false), -1], ["Nanoseconds", "Nanoseconds", "", $funcType([], [$Int64], false), -1], ["Seconds", "Seconds", "", $funcType([], [$Float64], false), -1], ["String", "String", "", $funcType([], [$String], false), -1]]; + ($ptrType(Location)).methods = [["String", "String", "", $funcType([], [$String], false), -1], ["firstZoneUsed", "firstZoneUsed", "time", $funcType([], [$Bool], false), -1], ["get", "get", "time", $funcType([], [($ptrType(Location))], false), -1], ["lookup", "lookup", "time", $funcType([$Int64], [$String, $Int, $Bool, $Int64, $Int64], false), -1], ["lookupFirstZone", "lookupFirstZone", "time", $funcType([], [$Int], false), -1], ["lookupName", "lookupName", "time", $funcType([$String, $Int64], [$Int, $Bool, $Bool], false), -1]]; + Location.init([["name", "name", "time", $String, ""], ["zone", "zone", "time", ($sliceType(zone)), ""], ["tx", "tx", "time", ($sliceType(zoneTrans)), ""], ["cacheStart", "cacheStart", "time", $Int64, ""], ["cacheEnd", "cacheEnd", "time", $Int64, ""], ["cacheZone", "cacheZone", "time", ($ptrType(zone)), ""]]); + zone.init([["name", "name", "time", $String, ""], ["offset", "offset", "time", $Int, ""], ["isDST", "isDST", "time", $Bool, ""]]); + zoneTrans.init([["when", "when", "time", $Int64, ""], ["index", "index", "time", $Uint8, ""], ["isstd", "isstd", "time", $Bool, ""], ["isutc", "isutc", "time", $Bool, ""]]); + localLoc = new Location.Ptr(); + localOnce = new sync.Once.Ptr(); + std0x = $toNativeArray("Int", [260, 265, 524, 526, 528, 274]); + longDayNames = new ($sliceType($String))(["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"]); + shortDayNames = new ($sliceType($String))(["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"]); + shortMonthNames = new ($sliceType($String))(["---", "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"]); + longMonthNames = new ($sliceType($String))(["---", "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"]); + atoiError = errors.New("time: invalid number"); + errBad = errors.New("bad value for field"); + errLeadingInt = errors.New("time: bad [0-9]*"); + months = $toNativeArray("String", ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"]); + days = $toNativeArray("String", ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"]); + unitMap = (_map = new $Map(), _key = "ns", _map[_key] = { k: _key, v: 1 }, _key = "us", _map[_key] = { k: _key, v: 1000 }, _key = "\xC2\xB5s", _map[_key] = { k: _key, v: 1000 }, _key = "\xCE\xBCs", _map[_key] = { k: _key, v: 1000 }, _key = "ms", _map[_key] = { k: _key, v: 1e+06 }, _key = "s", _map[_key] = { k: _key, v: 1e+09 }, _key = "m", _map[_key] = { k: _key, v: 6e+10 }, _key = "h", _map[_key] = { k: _key, v: 3.6e+12 }, _map); + daysBefore = $toNativeArray("Int32", [0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334, 365]); + utcLoc = new Location.Ptr("UTC", ($sliceType(zone)).nil, ($sliceType(zoneTrans)).nil, new $Int64(0, 0), new $Int64(0, 0), ($ptrType(zone)).nil); + $pkg.UTC = utcLoc; + $pkg.Local = localLoc; + _tuple = syscall.Getenv("ZONEINFO"); zoneinfo = _tuple[0]; + badData = errors.New("malformed time zone information"); + zoneDirs = new ($sliceType($String))(["/usr/share/zoneinfo/", "/usr/share/lib/zoneinfo/", "/usr/lib/locale/TZ/", runtime.GOROOT() + "/lib/time/zoneinfo.zip"]); }; return $pkg; })(); -$packages["reflect"] = (function() { - var $pkg = {}, js = $packages["github.com/gopherjs/gopherjs/js"], runtime = $packages["runtime"], strconv = $packages["strconv"], sync = $packages["sync"], math = $packages["math"], mapIter, Type, Kind, rtype, method, uncommonType, ChanDir, arrayType, chanType, funcType, imethod, interfaceType, mapType, ptrType, sliceType, structField, structType, Method, StructField, StructTag, fieldScan, Value, flag, ValueError, iword, nonEmptyInterface, initialized, kindNames, uint8Type, init, jsType, reflectType, isWrapped, copyStruct, makeValue, MakeSlice, jsObject, TypeOf, ValueOf, SliceOf, Zero, unsafe_New, makeInt, memmove, loadScalar, makemap, mapaccess, mapassign, mapdelete, mapiterinit, mapiterkey, mapiternext, maplen, cvtDirect, Copy, methodReceiver, valueInterface, ifaceE2I, methodName, makeMethodValue, PtrTo, implements$1, directlyAssignable, haveIdenticalUnderlyingType, toType, overflowFloat32, typesMustMatch, MakeMap, Indirect, New, convertOp, makeFloat, makeComplex, makeString, makeBytes, makeRunes, cvtInt, cvtUint, cvtFloatInt, cvtFloatUint, cvtIntFloat, cvtUintFloat, cvtFloat, cvtComplex, cvtIntString, cvtUintString, cvtBytesString, cvtStringBytes, cvtRunesString, cvtStringRunes, cvtT2I, cvtI2I, call; - mapIter = $pkg.mapIter = $newType(0, "Struct", "reflect.mapIter", "mapIter", "reflect", function(t_, m_, keys_, i_) { - this.$val = this; - this.t = t_ !== undefined ? t_ : $ifaceNil; - this.m = m_ !== undefined ? m_ : $ifaceNil; - this.keys = keys_ !== undefined ? keys_ : $ifaceNil; - this.i = i_ !== undefined ? i_ : 0; - }); - Type = $pkg.Type = $newType(8, "Interface", "reflect.Type", "Type", "reflect", null); - Kind = $pkg.Kind = $newType(4, "Uint", "reflect.Kind", "Kind", "reflect", null); - rtype = $pkg.rtype = $newType(0, "Struct", "reflect.rtype", "rtype", "reflect", function(size_, hash_, _$2_, align_, fieldAlign_, kind_, alg_, gc_, string_, uncommonType_, ptrToThis_, zero_) { - this.$val = this; - this.size = size_ !== undefined ? size_ : 0; - this.hash = hash_ !== undefined ? hash_ : 0; - this._$2 = _$2_ !== undefined ? _$2_ : 0; - this.align = align_ !== undefined ? align_ : 0; - this.fieldAlign = fieldAlign_ !== undefined ? fieldAlign_ : 0; - this.kind = kind_ !== undefined ? kind_ : 0; - this.alg = alg_ !== undefined ? alg_ : ($ptrType($Uintptr)).nil; - this.gc = gc_ !== undefined ? gc_ : 0; - this.string = string_ !== undefined ? string_ : ($ptrType($String)).nil; - this.uncommonType = uncommonType_ !== undefined ? uncommonType_ : ($ptrType(uncommonType)).nil; - this.ptrToThis = ptrToThis_ !== undefined ? ptrToThis_ : ($ptrType(rtype)).nil; - this.zero = zero_ !== undefined ? zero_ : 0; - }); - method = $pkg.method = $newType(0, "Struct", "reflect.method", "method", "reflect", function(name_, pkgPath_, mtyp_, typ_, ifn_, tfn_) { - this.$val = this; - this.name = name_ !== undefined ? name_ : ($ptrType($String)).nil; - this.pkgPath = pkgPath_ !== undefined ? pkgPath_ : ($ptrType($String)).nil; - this.mtyp = mtyp_ !== undefined ? mtyp_ : ($ptrType(rtype)).nil; - this.typ = typ_ !== undefined ? typ_ : ($ptrType(rtype)).nil; - this.ifn = ifn_ !== undefined ? ifn_ : 0; - this.tfn = tfn_ !== undefined ? tfn_ : 0; - }); - uncommonType = $pkg.uncommonType = $newType(0, "Struct", "reflect.uncommonType", "uncommonType", "reflect", function(name_, pkgPath_, methods_) { - this.$val = this; - this.name = name_ !== undefined ? name_ : ($ptrType($String)).nil; - this.pkgPath = pkgPath_ !== undefined ? pkgPath_ : ($ptrType($String)).nil; - this.methods = methods_ !== undefined ? methods_ : ($sliceType(method)).nil; - }); - ChanDir = $pkg.ChanDir = $newType(4, "Int", "reflect.ChanDir", "ChanDir", "reflect", null); - arrayType = $pkg.arrayType = $newType(0, "Struct", "reflect.arrayType", "arrayType", "reflect", function(rtype_, elem_, slice_, len_) { - this.$val = this; - this.rtype = rtype_ !== undefined ? rtype_ : new rtype.Ptr(); - this.elem = elem_ !== undefined ? elem_ : ($ptrType(rtype)).nil; - this.slice = slice_ !== undefined ? slice_ : ($ptrType(rtype)).nil; - this.len = len_ !== undefined ? len_ : 0; - }); - chanType = $pkg.chanType = $newType(0, "Struct", "reflect.chanType", "chanType", "reflect", function(rtype_, elem_, dir_) { - this.$val = this; - this.rtype = rtype_ !== undefined ? rtype_ : new rtype.Ptr(); - this.elem = elem_ !== undefined ? elem_ : ($ptrType(rtype)).nil; - this.dir = dir_ !== undefined ? dir_ : 0; - }); - funcType = $pkg.funcType = $newType(0, "Struct", "reflect.funcType", "funcType", "reflect", function(rtype_, dotdotdot_, in$2_, out_) { - this.$val = this; - this.rtype = rtype_ !== undefined ? rtype_ : new rtype.Ptr(); - this.dotdotdot = dotdotdot_ !== undefined ? dotdotdot_ : false; - this.in$2 = in$2_ !== undefined ? in$2_ : ($sliceType(($ptrType(rtype)))).nil; - this.out = out_ !== undefined ? out_ : ($sliceType(($ptrType(rtype)))).nil; - }); - imethod = $pkg.imethod = $newType(0, "Struct", "reflect.imethod", "imethod", "reflect", function(name_, pkgPath_, typ_) { - this.$val = this; - this.name = name_ !== undefined ? name_ : ($ptrType($String)).nil; - this.pkgPath = pkgPath_ !== undefined ? pkgPath_ : ($ptrType($String)).nil; - this.typ = typ_ !== undefined ? typ_ : ($ptrType(rtype)).nil; - }); - interfaceType = $pkg.interfaceType = $newType(0, "Struct", "reflect.interfaceType", "interfaceType", "reflect", function(rtype_, methods_) { - this.$val = this; - this.rtype = rtype_ !== undefined ? rtype_ : new rtype.Ptr(); - this.methods = methods_ !== undefined ? methods_ : ($sliceType(imethod)).nil; - }); - mapType = $pkg.mapType = $newType(0, "Struct", "reflect.mapType", "mapType", "reflect", function(rtype_, key_, elem_, bucket_, hmap_) { - this.$val = this; - this.rtype = rtype_ !== undefined ? rtype_ : new rtype.Ptr(); - this.key = key_ !== undefined ? key_ : ($ptrType(rtype)).nil; - this.elem = elem_ !== undefined ? elem_ : ($ptrType(rtype)).nil; - this.bucket = bucket_ !== undefined ? bucket_ : ($ptrType(rtype)).nil; - this.hmap = hmap_ !== undefined ? hmap_ : ($ptrType(rtype)).nil; - }); - ptrType = $pkg.ptrType = $newType(0, "Struct", "reflect.ptrType", "ptrType", "reflect", function(rtype_, elem_) { - this.$val = this; - this.rtype = rtype_ !== undefined ? rtype_ : new rtype.Ptr(); - this.elem = elem_ !== undefined ? elem_ : ($ptrType(rtype)).nil; - }); - sliceType = $pkg.sliceType = $newType(0, "Struct", "reflect.sliceType", "sliceType", "reflect", function(rtype_, elem_) { - this.$val = this; - this.rtype = rtype_ !== undefined ? rtype_ : new rtype.Ptr(); - this.elem = elem_ !== undefined ? elem_ : ($ptrType(rtype)).nil; - }); - structField = $pkg.structField = $newType(0, "Struct", "reflect.structField", "structField", "reflect", function(name_, pkgPath_, typ_, tag_, offset_) { - this.$val = this; - this.name = name_ !== undefined ? name_ : ($ptrType($String)).nil; - this.pkgPath = pkgPath_ !== undefined ? pkgPath_ : ($ptrType($String)).nil; - this.typ = typ_ !== undefined ? typ_ : ($ptrType(rtype)).nil; - this.tag = tag_ !== undefined ? tag_ : ($ptrType($String)).nil; - this.offset = offset_ !== undefined ? offset_ : 0; - }); - structType = $pkg.structType = $newType(0, "Struct", "reflect.structType", "structType", "reflect", function(rtype_, fields_) { +$packages["os"] = (function() { + var $pkg = {}, js = $packages["github.com/gopherjs/gopherjs/js"], io = $packages["io"], syscall = $packages["syscall"], time = $packages["time"], errors = $packages["errors"], runtime = $packages["runtime"], atomic = $packages["sync/atomic"], sync = $packages["sync"], PathError, SyscallError, LinkError, File, file, dirInfo, FileInfo, FileMode, fileStat, lstat, getwdCache, useSyscallwd, init, Getenv, NewSyscallError, IsNotExist, isNotExist, Open, sigpipe, Readlink, syscallMode, NewFile, epipecheck, OpenFile, Stat, Lstat, basename, Getwd, IsPathSeparator, Exit, sameFile, fileInfoFromStat, timespecToTime, SameFile; + PathError = $pkg.PathError = $newType(0, "Struct", "os.PathError", "PathError", "os", function(Op_, Path_, Err_) { this.$val = this; - this.rtype = rtype_ !== undefined ? rtype_ : new rtype.Ptr(); - this.fields = fields_ !== undefined ? fields_ : ($sliceType(structField)).nil; + this.Op = Op_ !== undefined ? Op_ : ""; + this.Path = Path_ !== undefined ? Path_ : ""; + this.Err = Err_ !== undefined ? Err_ : $ifaceNil; }); - Method = $pkg.Method = $newType(0, "Struct", "reflect.Method", "Method", "reflect", function(Name_, PkgPath_, Type_, Func_, Index_) { + SyscallError = $pkg.SyscallError = $newType(0, "Struct", "os.SyscallError", "SyscallError", "os", function(Syscall_, Err_) { this.$val = this; - this.Name = Name_ !== undefined ? Name_ : ""; - this.PkgPath = PkgPath_ !== undefined ? PkgPath_ : ""; - this.Type = Type_ !== undefined ? Type_ : $ifaceNil; - this.Func = Func_ !== undefined ? Func_ : new Value.Ptr(); - this.Index = Index_ !== undefined ? Index_ : 0; + this.Syscall = Syscall_ !== undefined ? Syscall_ : ""; + this.Err = Err_ !== undefined ? Err_ : $ifaceNil; }); - StructField = $pkg.StructField = $newType(0, "Struct", "reflect.StructField", "StructField", "reflect", function(Name_, PkgPath_, Type_, Tag_, Offset_, Index_, Anonymous_) { + LinkError = $pkg.LinkError = $newType(0, "Struct", "os.LinkError", "LinkError", "os", function(Op_, Old_, New_, Err_) { this.$val = this; - this.Name = Name_ !== undefined ? Name_ : ""; - this.PkgPath = PkgPath_ !== undefined ? PkgPath_ : ""; - this.Type = Type_ !== undefined ? Type_ : $ifaceNil; - this.Tag = Tag_ !== undefined ? Tag_ : ""; - this.Offset = Offset_ !== undefined ? Offset_ : 0; - this.Index = Index_ !== undefined ? Index_ : ($sliceType($Int)).nil; - this.Anonymous = Anonymous_ !== undefined ? Anonymous_ : false; + this.Op = Op_ !== undefined ? Op_ : ""; + this.Old = Old_ !== undefined ? Old_ : ""; + this.New = New_ !== undefined ? New_ : ""; + this.Err = Err_ !== undefined ? Err_ : $ifaceNil; }); - StructTag = $pkg.StructTag = $newType(8, "String", "reflect.StructTag", "StructTag", "reflect", null); - fieldScan = $pkg.fieldScan = $newType(0, "Struct", "reflect.fieldScan", "fieldScan", "reflect", function(typ_, index_) { + File = $pkg.File = $newType(0, "Struct", "os.File", "File", "os", function(file_) { this.$val = this; - this.typ = typ_ !== undefined ? typ_ : ($ptrType(structType)).nil; - this.index = index_ !== undefined ? index_ : ($sliceType($Int)).nil; + this.file = file_ !== undefined ? file_ : ($ptrType(file)).nil; }); - Value = $pkg.Value = $newType(0, "Struct", "reflect.Value", "Value", "reflect", function(typ_, ptr_, scalar_, flag_) { + file = $pkg.file = $newType(0, "Struct", "os.file", "file", "os", function(fd_, name_, dirinfo_, nepipe_) { this.$val = this; - this.typ = typ_ !== undefined ? typ_ : ($ptrType(rtype)).nil; - this.ptr = ptr_ !== undefined ? ptr_ : 0; - this.scalar = scalar_ !== undefined ? scalar_ : 0; - this.flag = flag_ !== undefined ? flag_ : 0; + this.fd = fd_ !== undefined ? fd_ : 0; + this.name = name_ !== undefined ? name_ : ""; + this.dirinfo = dirinfo_ !== undefined ? dirinfo_ : ($ptrType(dirInfo)).nil; + this.nepipe = nepipe_ !== undefined ? nepipe_ : 0; }); - flag = $pkg.flag = $newType(4, "Uintptr", "reflect.flag", "flag", "reflect", null); - ValueError = $pkg.ValueError = $newType(0, "Struct", "reflect.ValueError", "ValueError", "reflect", function(Method_, Kind_) { + dirInfo = $pkg.dirInfo = $newType(0, "Struct", "os.dirInfo", "dirInfo", "os", function(buf_, nbuf_, bufp_) { this.$val = this; - this.Method = Method_ !== undefined ? Method_ : ""; - this.Kind = Kind_ !== undefined ? Kind_ : 0; + this.buf = buf_ !== undefined ? buf_ : ($sliceType($Uint8)).nil; + this.nbuf = nbuf_ !== undefined ? nbuf_ : 0; + this.bufp = bufp_ !== undefined ? bufp_ : 0; }); - iword = $pkg.iword = $newType(4, "UnsafePointer", "reflect.iword", "iword", "reflect", null); - nonEmptyInterface = $pkg.nonEmptyInterface = $newType(0, "Struct", "reflect.nonEmptyInterface", "nonEmptyInterface", "reflect", function(itab_, word_) { + FileInfo = $pkg.FileInfo = $newType(8, "Interface", "os.FileInfo", "FileInfo", "os", null); + FileMode = $pkg.FileMode = $newType(4, "Uint32", "os.FileMode", "FileMode", "os", null); + fileStat = $pkg.fileStat = $newType(0, "Struct", "os.fileStat", "fileStat", "os", function(name_, size_, mode_, modTime_, sys_) { this.$val = this; - this.itab = itab_ !== undefined ? itab_ : ($ptrType(($structType([["ityp", "ityp", "reflect", ($ptrType(rtype)), ""], ["typ", "typ", "reflect", ($ptrType(rtype)), ""], ["link", "link", "reflect", $UnsafePointer, ""], ["bad", "bad", "reflect", $Int32, ""], ["unused", "unused", "reflect", $Int32, ""], ["fun", "fun", "reflect", ($arrayType($UnsafePointer, 100000)), ""]])))).nil; - this.word = word_ !== undefined ? word_ : 0; + this.name = name_ !== undefined ? name_ : ""; + this.size = size_ !== undefined ? size_ : new $Int64(0, 0); + this.mode = mode_ !== undefined ? mode_ : 0; + this.modTime = modTime_ !== undefined ? modTime_ : new time.Time.Ptr(); + this.sys = sys_ !== undefined ? sys_ : $ifaceNil; }); init = function() { - var used, x, x$1, x$2, x$3, x$4, x$5, x$6, x$7, x$8, x$9, x$10, x$11, x$12, pkg, _map, _key; - used = (function(i) { - }); - used((x = new rtype.Ptr(0, 0, 0, 0, 0, 0, ($ptrType($Uintptr)).nil, 0, ($ptrType($String)).nil, ($ptrType(uncommonType)).nil, ($ptrType(rtype)).nil, 0), new x.constructor.Struct(x))); - used((x$1 = new uncommonType.Ptr(($ptrType($String)).nil, ($ptrType($String)).nil, ($sliceType(method)).nil), new x$1.constructor.Struct(x$1))); - used((x$2 = new method.Ptr(($ptrType($String)).nil, ($ptrType($String)).nil, ($ptrType(rtype)).nil, ($ptrType(rtype)).nil, 0, 0), new x$2.constructor.Struct(x$2))); - used((x$3 = new arrayType.Ptr(new rtype.Ptr(), ($ptrType(rtype)).nil, ($ptrType(rtype)).nil, 0), new x$3.constructor.Struct(x$3))); - used((x$4 = new chanType.Ptr(new rtype.Ptr(), ($ptrType(rtype)).nil, 0), new x$4.constructor.Struct(x$4))); - used((x$5 = new funcType.Ptr(new rtype.Ptr(), false, ($sliceType(($ptrType(rtype)))).nil, ($sliceType(($ptrType(rtype)))).nil), new x$5.constructor.Struct(x$5))); - used((x$6 = new interfaceType.Ptr(new rtype.Ptr(), ($sliceType(imethod)).nil), new x$6.constructor.Struct(x$6))); - used((x$7 = new mapType.Ptr(new rtype.Ptr(), ($ptrType(rtype)).nil, ($ptrType(rtype)).nil, ($ptrType(rtype)).nil, ($ptrType(rtype)).nil), new x$7.constructor.Struct(x$7))); - used((x$8 = new ptrType.Ptr(new rtype.Ptr(), ($ptrType(rtype)).nil), new x$8.constructor.Struct(x$8))); - used((x$9 = new sliceType.Ptr(new rtype.Ptr(), ($ptrType(rtype)).nil), new x$9.constructor.Struct(x$9))); - used((x$10 = new structType.Ptr(new rtype.Ptr(), ($sliceType(structField)).nil), new x$10.constructor.Struct(x$10))); - used((x$11 = new imethod.Ptr(($ptrType($String)).nil, ($ptrType($String)).nil, ($ptrType(rtype)).nil), new x$11.constructor.Struct(x$11))); - used((x$12 = new structField.Ptr(($ptrType($String)).nil, ($ptrType($String)).nil, ($ptrType(rtype)).nil, ($ptrType($String)).nil, 0), new x$12.constructor.Struct(x$12))); - pkg = $pkg; - pkg.kinds = $externalize((_map = new $Map(), _key = "Bool", _map[_key] = { k: _key, v: 1 }, _key = "Int", _map[_key] = { k: _key, v: 2 }, _key = "Int8", _map[_key] = { k: _key, v: 3 }, _key = "Int16", _map[_key] = { k: _key, v: 4 }, _key = "Int32", _map[_key] = { k: _key, v: 5 }, _key = "Int64", _map[_key] = { k: _key, v: 6 }, _key = "Uint", _map[_key] = { k: _key, v: 7 }, _key = "Uint8", _map[_key] = { k: _key, v: 8 }, _key = "Uint16", _map[_key] = { k: _key, v: 9 }, _key = "Uint32", _map[_key] = { k: _key, v: 10 }, _key = "Uint64", _map[_key] = { k: _key, v: 11 }, _key = "Uintptr", _map[_key] = { k: _key, v: 12 }, _key = "Float32", _map[_key] = { k: _key, v: 13 }, _key = "Float64", _map[_key] = { k: _key, v: 14 }, _key = "Complex64", _map[_key] = { k: _key, v: 15 }, _key = "Complex128", _map[_key] = { k: _key, v: 16 }, _key = "Array", _map[_key] = { k: _key, v: 17 }, _key = "Chan", _map[_key] = { k: _key, v: 18 }, _key = "Func", _map[_key] = { k: _key, v: 19 }, _key = "Interface", _map[_key] = { k: _key, v: 20 }, _key = "Map", _map[_key] = { k: _key, v: 21 }, _key = "Ptr", _map[_key] = { k: _key, v: 22 }, _key = "Slice", _map[_key] = { k: _key, v: 23 }, _key = "String", _map[_key] = { k: _key, v: 24 }, _key = "Struct", _map[_key] = { k: _key, v: 25 }, _key = "UnsafePointer", _map[_key] = { k: _key, v: 26 }, _map), ($mapType($String, Kind))); - pkg.RecvDir = 1; - pkg.SendDir = 2; - pkg.BothDir = 3; - $reflect = pkg; - initialized = true; - uint8Type = $assertType(TypeOf(new $Uint8(0)), ($ptrType(rtype))); - }; - jsType = function(typ) { - return typ.jsType; - }; - reflectType = function(typ) { - return typ.reflectType(); - }; - isWrapped = function(typ) { - var _ref; - _ref = typ.Kind(); - if (_ref === 1 || _ref === 2 || _ref === 3 || _ref === 4 || _ref === 5 || _ref === 7 || _ref === 8 || _ref === 9 || _ref === 10 || _ref === 12 || _ref === 13 || _ref === 14 || _ref === 17 || _ref === 21 || _ref === 19 || _ref === 24 || _ref === 25) { - return true; - } else if (_ref === 22) { - return typ.Elem().Kind() === 17; + var process, args, i; + process = $global.process; + if (process === undefined) { + $pkg.Args = new ($sliceType($String))(["browser"]); + return; } - return false; - }; - copyStruct = function(dst, src, typ) { - var fields, i, name; - fields = jsType(typ).fields; + args = process.argv; + $pkg.Args = ($sliceType($String)).make(($parseInt(args.length) - 1 >> 0)); i = 0; - while (i < $parseInt(fields.length)) { - name = $internalize(fields[i][0], $String); - dst[$externalize(name, $String)] = src[$externalize(name, $String)]; + while (i < ($parseInt(args.length) - 1 >> 0)) { + (i < 0 || i >= $pkg.Args.$length) ? $throwRuntimeError("index out of range") : $pkg.Args.$array[$pkg.Args.$offset + i] = $internalize(args[(i + 1 >> 0)], $String); i = i + (1) >> 0; } }; - makeValue = function(t, v, fl) { - var rt; - rt = t.common(); - if ((t.Kind() === 17) || (t.Kind() === 25) || rt.pointers()) { - return new Value.Ptr(rt, v, 0, (fl | ((t.Kind() >>> 0) << 4 >>> 0)) >>> 0); - } - if (t.Size() > 4 || (t.Kind() === 24)) { - return new Value.Ptr(rt, $newDataPointer(v, jsType(rt.ptrTo())), 0, (((fl | ((t.Kind() >>> 0) << 4 >>> 0)) >>> 0) | 2) >>> 0); - } - return new Value.Ptr(rt, 0, v, (fl | ((t.Kind() >>> 0) << 4 >>> 0)) >>> 0); - }; - MakeSlice = $pkg.MakeSlice = function(typ, len, cap) { - if (!((typ.Kind() === 23))) { - $panic(new $String("reflect.MakeSlice of non-slice type")); + File.Ptr.prototype.readdirnames = function(n) { + var names = ($sliceType($String)).nil, err = $ifaceNil, f, d, size, errno, _tuple, _tmp, _tmp$1, _tmp$2, _tmp$3, nb, nc, _tuple$1, _tmp$4, _tmp$5, _tmp$6, _tmp$7; + f = this; + if (f.file.dirinfo === ($ptrType(dirInfo)).nil) { + f.file.dirinfo = new dirInfo.Ptr(); + f.file.dirinfo.buf = ($sliceType($Uint8)).make(4096); } - if (len < 0) { - $panic(new $String("reflect.MakeSlice: negative len")); + d = f.file.dirinfo; + size = n; + if (size <= 0) { + size = 100; + n = -1; } - if (cap < 0) { - $panic(new $String("reflect.MakeSlice: negative cap")); + names = ($sliceType($String)).make(0, size); + while (!((n === 0))) { + if (d.bufp >= d.nbuf) { + d.bufp = 0; + errno = $ifaceNil; + _tuple = syscall.ReadDirent(f.file.fd, d.buf); d.nbuf = _tuple[0]; errno = _tuple[1]; + if (!($interfaceIsEqual(errno, $ifaceNil))) { + _tmp = names; _tmp$1 = NewSyscallError("readdirent", errno); names = _tmp; err = _tmp$1; + return [names, err]; + } + if (d.nbuf <= 0) { + break; + } + } + _tmp$2 = 0; _tmp$3 = 0; nb = _tmp$2; nc = _tmp$3; + _tuple$1 = syscall.ParseDirent($subslice(d.buf, d.bufp, d.nbuf), n, names); nb = _tuple$1[0]; nc = _tuple$1[1]; names = _tuple$1[2]; + d.bufp = d.bufp + (nb) >> 0; + n = n - (nc) >> 0; } - if (len > cap) { - $panic(new $String("reflect.MakeSlice: len > cap")); + if (n >= 0 && (names.$length === 0)) { + _tmp$4 = names; _tmp$5 = io.EOF; names = _tmp$4; err = _tmp$5; + return [names, err]; } - return makeValue(typ, jsType(typ).make(len, cap, $externalize((function() { - return jsType(typ.Elem()).zero(); - }), ($funcType([], [js.Object], false)))), 0); - }; - jsObject = function() { - return reflectType($packages[$externalize("github.com/gopherjs/gopherjs/js", $String)].Object); + _tmp$6 = names; _tmp$7 = $ifaceNil; names = _tmp$6; err = _tmp$7; + return [names, err]; }; - TypeOf = $pkg.TypeOf = function(i) { - var c; - if (!initialized) { - return new rtype.Ptr(0, 0, 0, 0, 0, 0, ($ptrType($Uintptr)).nil, 0, ($ptrType($String)).nil, ($ptrType(uncommonType)).nil, ($ptrType(rtype)).nil, 0); - } - if ($interfaceIsEqual(i, $ifaceNil)) { - return $ifaceNil; - } - c = i.constructor; - if (c.kind === undefined) { - return jsObject(); + File.prototype.readdirnames = function(n) { return this.$val.readdirnames(n); }; + File.Ptr.prototype.Readdir = function(n) { + var fi = ($sliceType(FileInfo)).nil, err = $ifaceNil, f, _tmp, _tmp$1, _tuple; + f = this; + if (f === ($ptrType(File)).nil) { + _tmp = ($sliceType(FileInfo)).nil; _tmp$1 = $pkg.ErrInvalid; fi = _tmp; err = _tmp$1; + return [fi, err]; } - return reflectType(c); + _tuple = f.readdir(n); fi = _tuple[0]; err = _tuple[1]; + return [fi, err]; }; - ValueOf = $pkg.ValueOf = function(i) { - var c; - if ($interfaceIsEqual(i, $ifaceNil)) { - return new Value.Ptr(($ptrType(rtype)).nil, 0, 0, 0); - } - c = i.constructor; - if (c.kind === undefined) { - return new Value.Ptr(jsObject(), 0, i, 320); + File.prototype.Readdir = function(n) { return this.$val.Readdir(n); }; + File.Ptr.prototype.Readdirnames = function(n) { + var names = ($sliceType($String)).nil, err = $ifaceNil, f, _tmp, _tmp$1, _tuple; + f = this; + if (f === ($ptrType(File)).nil) { + _tmp = ($sliceType($String)).nil; _tmp$1 = $pkg.ErrInvalid; names = _tmp; err = _tmp$1; + return [names, err]; } - return makeValue(reflectType(c), i.$val, 0); - }; - rtype.Ptr.prototype.ptrTo = function() { - var t; - t = this; - return reflectType($ptrType(jsType(t))); + _tuple = f.readdirnames(n); names = _tuple[0]; err = _tuple[1]; + return [names, err]; }; - rtype.prototype.ptrTo = function() { return this.$val.ptrTo(); }; - SliceOf = $pkg.SliceOf = function(t) { - return reflectType($sliceType(jsType(t))); + File.prototype.Readdirnames = function(n) { return this.$val.Readdirnames(n); }; + Getenv = $pkg.Getenv = function(key) { + var _tuple, v; + _tuple = syscall.Getenv(key); v = _tuple[0]; + return v; }; - Zero = $pkg.Zero = function(typ) { - return makeValue(typ, jsType(typ).zero(), 0); + PathError.Ptr.prototype.Error = function() { + var e; + e = this; + return e.Op + " " + e.Path + ": " + e.Err.Error(); }; - unsafe_New = function(typ) { - var _ref; - _ref = typ.Kind(); - if (_ref === 25) { - return new (jsType(typ).Ptr)(); - } else if (_ref === 17) { - return jsType(typ).zero(); - } else { - return $newDataPointer(jsType(typ).zero(), jsType(typ.ptrTo())); - } + PathError.prototype.Error = function() { return this.$val.Error(); }; + SyscallError.Ptr.prototype.Error = function() { + var e; + e = this; + return e.Syscall + ": " + e.Err.Error(); }; - makeInt = function(f, bits, t) { - var typ, ptr, s, _ref; - typ = t.common(); - if (typ.size > 4) { - ptr = unsafe_New(typ); - ptr.$set(bits); - return new Value.Ptr(typ, ptr, 0, (((f | 2) >>> 0) | ((typ.Kind() >>> 0) << 4 >>> 0)) >>> 0); - } - s = 0; - _ref = typ.Kind(); - if (_ref === 3) { - new ($ptrType($Uintptr))(function() { return s; }, function($v) { s = $v; }).$set((bits.$low << 24 >> 24)); - } else if (_ref === 4) { - new ($ptrType($Uintptr))(function() { return s; }, function($v) { s = $v; }).$set((bits.$low << 16 >> 16)); - } else if (_ref === 2 || _ref === 5) { - new ($ptrType($Uintptr))(function() { return s; }, function($v) { s = $v; }).$set((bits.$low >> 0)); - } else if (_ref === 8) { - new ($ptrType($Uintptr))(function() { return s; }, function($v) { s = $v; }).$set((bits.$low << 24 >>> 24)); - } else if (_ref === 9) { - new ($ptrType($Uintptr))(function() { return s; }, function($v) { s = $v; }).$set((bits.$low << 16 >>> 16)); - } else if (_ref === 7 || _ref === 10 || _ref === 12) { - new ($ptrType($Uintptr))(function() { return s; }, function($v) { s = $v; }).$set((bits.$low >>> 0)); + SyscallError.prototype.Error = function() { return this.$val.Error(); }; + NewSyscallError = $pkg.NewSyscallError = function(syscall$1, err) { + if ($interfaceIsEqual(err, $ifaceNil)) { + return $ifaceNil; } - return new Value.Ptr(typ, 0, s, (f | ((typ.Kind() >>> 0) << 4 >>> 0)) >>> 0); + return new SyscallError.Ptr(syscall$1, err); }; - memmove = function(adst, asrc, n) { - adst.$set(asrc.$get()); + IsNotExist = $pkg.IsNotExist = function(err) { + return isNotExist(err); }; - loadScalar = function(p, n) { - return p.$get(); + isNotExist = function(err) { + var pe, _ref; + _ref = err; + if (_ref === $ifaceNil) { + pe = _ref; + return false; + } else if ($assertType(_ref, ($ptrType(PathError)), true)[1]) { + pe = _ref.$val; + err = pe.Err; + } else if ($assertType(_ref, ($ptrType(LinkError)), true)[1]) { + pe = _ref.$val; + err = pe.Err; + } + return $interfaceIsEqual(err, new syscall.Errno(2)) || $interfaceIsEqual(err, $pkg.ErrNotExist); }; - makemap = function(t) { - var m = 0; - m = new ($Map)(); - return m; + File.Ptr.prototype.Name = function() { + var f; + f = this; + return f.file.name; }; - mapaccess = function(t, m, key) { - var k, entry; - k = key.$get(); - if (!(k.$key === undefined)) { - k = k.$key(); + File.prototype.Name = function() { return this.$val.Name(); }; + LinkError.Ptr.prototype.Error = function() { + var e; + e = this; + return e.Op + " " + e.Old + " " + e.New + ": " + e.Err.Error(); + }; + LinkError.prototype.Error = function() { return this.$val.Error(); }; + File.Ptr.prototype.Read = function(b) { + var n = 0, err = $ifaceNil, f, _tmp, _tmp$1, _tuple, e, _tmp$2, _tmp$3, _tmp$4, _tmp$5; + f = this; + if (f === ($ptrType(File)).nil) { + _tmp = 0; _tmp$1 = $pkg.ErrInvalid; n = _tmp; err = _tmp$1; + return [n, err]; } - entry = m[$externalize($internalize(k, $String), $String)]; - if (entry === undefined) { - return 0; + _tuple = f.read(b); n = _tuple[0]; e = _tuple[1]; + if (n < 0) { + n = 0; } - return $newDataPointer(entry.v, jsType(PtrTo(t.Elem()))); - }; - mapassign = function(t, m, key, val) { - var kv, k, jsVal, et, newVal, entry; - kv = key.$get(); - k = kv; - if (!(k.$key === undefined)) { - k = k.$key(); + if ((n === 0) && b.$length > 0 && $interfaceIsEqual(e, $ifaceNil)) { + _tmp$2 = 0; _tmp$3 = io.EOF; n = _tmp$2; err = _tmp$3; + return [n, err]; } - jsVal = val.$get(); - et = t.Elem(); - if (et.Kind() === 25) { - newVal = jsType(et).zero(); - copyStruct(newVal, jsVal, et); - jsVal = newVal; + if (!($interfaceIsEqual(e, $ifaceNil))) { + err = new PathError.Ptr("read", f.file.name, e); } - entry = new ($global.Object)(); - entry.k = kv; - entry.v = jsVal; - m[$externalize($internalize(k, $String), $String)] = entry; + _tmp$4 = n; _tmp$5 = err; n = _tmp$4; err = _tmp$5; + return [n, err]; }; - mapdelete = function(t, m, key) { - var k; - k = key.$get(); - if (!(k.$key === undefined)) { - k = k.$key(); + File.prototype.Read = function(b) { return this.$val.Read(b); }; + File.Ptr.prototype.ReadAt = function(b, off) { + var n = 0, err = $ifaceNil, f, _tmp, _tmp$1, _tuple, m, e, _tmp$2, _tmp$3, x; + f = this; + if (f === ($ptrType(File)).nil) { + _tmp = 0; _tmp$1 = $pkg.ErrInvalid; n = _tmp; err = _tmp$1; + return [n, err]; } - delete m[$externalize($internalize(k, $String), $String)]; - }; - mapiterinit = function(t, m) { - return new mapIter.Ptr(t, m, $keys(m), 0); - }; - mapiterkey = function(it) { - var iter, k; - iter = it; - k = iter.keys[iter.i]; - return $newDataPointer(iter.m[$externalize($internalize(k, $String), $String)].k, jsType(PtrTo(iter.t.Key()))); - }; - mapiternext = function(it) { - var iter; - iter = it; - iter.i = iter.i + (1) >> 0; + while (b.$length > 0) { + _tuple = f.pread(b, off); m = _tuple[0]; e = _tuple[1]; + if ((m === 0) && $interfaceIsEqual(e, $ifaceNil)) { + _tmp$2 = n; _tmp$3 = io.EOF; n = _tmp$2; err = _tmp$3; + return [n, err]; + } + if (!($interfaceIsEqual(e, $ifaceNil))) { + err = new PathError.Ptr("read", f.file.name, e); + break; + } + n = n + (m) >> 0; + b = $subslice(b, m); + off = (x = new $Int64(0, m), new $Int64(off.$high + x.$high, off.$low + x.$low)); + } + return [n, err]; }; - maplen = function(m) { - return $parseInt($keys(m).length); + File.prototype.ReadAt = function(b, off) { return this.$val.ReadAt(b, off); }; + File.Ptr.prototype.Write = function(b) { + var n = 0, err = $ifaceNil, f, _tmp, _tmp$1, _tuple, e, _tmp$2, _tmp$3; + f = this; + if (f === ($ptrType(File)).nil) { + _tmp = 0; _tmp$1 = $pkg.ErrInvalid; n = _tmp; err = _tmp$1; + return [n, err]; + } + _tuple = f.write(b); n = _tuple[0]; e = _tuple[1]; + if (n < 0) { + n = 0; + } + if (!((n === b.$length))) { + err = io.ErrShortWrite; + } + epipecheck(f, e); + if (!($interfaceIsEqual(e, $ifaceNil))) { + err = new PathError.Ptr("write", f.file.name, e); + } + _tmp$2 = n; _tmp$3 = err; n = _tmp$2; err = _tmp$3; + return [n, err]; }; - cvtDirect = function(v, typ) { - var srcVal, val, k, _ref, slice; - srcVal = v.iword(); - if (srcVal === jsType(v.typ).nil) { - return makeValue(typ, jsType(typ).nil, v.flag); + File.prototype.Write = function(b) { return this.$val.Write(b); }; + File.Ptr.prototype.WriteAt = function(b, off) { + var n = 0, err = $ifaceNil, f, _tmp, _tmp$1, _tuple, m, e, x; + f = this; + if (f === ($ptrType(File)).nil) { + _tmp = 0; _tmp$1 = $pkg.ErrInvalid; n = _tmp; err = _tmp$1; + return [n, err]; } - val = $ifaceNil; - k = typ.Kind(); - _ref = k; - switch (0) { default: if (_ref === 18) { - val = new (jsType(typ))(); - } else if (_ref === 23) { - slice = new (jsType(typ))(srcVal.$array); - slice.$offset = srcVal.$offset; - slice.$length = srcVal.$length; - slice.$capacity = srcVal.$capacity; - val = $newDataPointer(slice, jsType(PtrTo(typ))); - } else if (_ref === 22) { - if (typ.Elem().Kind() === 25) { - if ($interfaceIsEqual(typ.Elem(), v.typ.Elem())) { - val = srcVal; - break; - } - val = new (jsType(typ))(); - copyStruct(val, srcVal, typ.Elem()); + while (b.$length > 0) { + _tuple = f.pwrite(b, off); m = _tuple[0]; e = _tuple[1]; + if (!($interfaceIsEqual(e, $ifaceNil))) { + err = new PathError.Ptr("write", f.file.name, e); break; } - val = new (jsType(typ))(srcVal.$get, srcVal.$set); - } else if (_ref === 25) { - val = new (jsType(typ).Ptr)(); - copyStruct(val, srcVal, typ); - } else if (_ref === 17 || _ref === 19 || _ref === 20 || _ref === 21 || _ref === 24) { - val = v.ptr; - } else { - $panic(new ValueError.Ptr("reflect.Convert", k)); - } } - return new Value.Ptr(typ.common(), val, 0, (((v.flag & 3) >>> 0) | ((typ.Kind() >>> 0) << 4 >>> 0)) >>> 0); + n = n + (m) >> 0; + b = $subslice(b, m); + off = (x = new $Int64(0, m), new $Int64(off.$high + x.$high, off.$low + x.$low)); + } + return [n, err]; }; - Copy = $pkg.Copy = function(dst, src) { - var dk, sk, dstVal, srcVal; - dk = (new flag(dst.flag)).kind(); - if (!((dk === 17)) && !((dk === 23))) { - $panic(new ValueError.Ptr("reflect.Copy", dk)); + File.prototype.WriteAt = function(b, off) { return this.$val.WriteAt(b, off); }; + File.Ptr.prototype.Seek = function(offset, whence) { + var ret = new $Int64(0, 0), err = $ifaceNil, f, _tmp, _tmp$1, _tuple, r, e, _tmp$2, _tmp$3, _tmp$4, _tmp$5; + f = this; + if (f === ($ptrType(File)).nil) { + _tmp = new $Int64(0, 0); _tmp$1 = $pkg.ErrInvalid; ret = _tmp; err = _tmp$1; + return [ret, err]; } - if (dk === 17) { - (new flag(dst.flag)).mustBeAssignable(); + _tuple = f.seek(offset, whence); r = _tuple[0]; e = _tuple[1]; + if ($interfaceIsEqual(e, $ifaceNil) && !(f.file.dirinfo === ($ptrType(dirInfo)).nil) && !((r.$high === 0 && r.$low === 0))) { + e = new syscall.Errno(21); } - (new flag(dst.flag)).mustBeExported(); - sk = (new flag(src.flag)).kind(); - if (!((sk === 17)) && !((sk === 23))) { - $panic(new ValueError.Ptr("reflect.Copy", sk)); + if (!($interfaceIsEqual(e, $ifaceNil))) { + _tmp$2 = new $Int64(0, 0); _tmp$3 = new PathError.Ptr("seek", f.file.name, e); ret = _tmp$2; err = _tmp$3; + return [ret, err]; } - (new flag(src.flag)).mustBeExported(); - typesMustMatch("reflect.Copy", dst.typ.Elem(), src.typ.Elem()); - dstVal = dst.iword(); - if (dk === 17) { - dstVal = new (jsType(SliceOf(dst.typ.Elem())))(dstVal); + _tmp$4 = r; _tmp$5 = $ifaceNil; ret = _tmp$4; err = _tmp$5; + return [ret, err]; + }; + File.prototype.Seek = function(offset, whence) { return this.$val.Seek(offset, whence); }; + File.Ptr.prototype.WriteString = function(s) { + var ret = 0, err = $ifaceNil, f, _tmp, _tmp$1, _tuple; + f = this; + if (f === ($ptrType(File)).nil) { + _tmp = 0; _tmp$1 = $pkg.ErrInvalid; ret = _tmp; err = _tmp$1; + return [ret, err]; } - srcVal = src.iword(); - if (sk === 17) { - srcVal = new (jsType(SliceOf(src.typ.Elem())))(srcVal); + _tuple = f.Write(new ($sliceType($Uint8))($stringToBytes(s))); ret = _tuple[0]; err = _tuple[1]; + return [ret, err]; + }; + File.prototype.WriteString = function(s) { return this.$val.WriteString(s); }; + File.Ptr.prototype.Chdir = function() { + var f, e; + f = this; + if (f === ($ptrType(File)).nil) { + return $pkg.ErrInvalid; } - return $parseInt($copySlice(dstVal, srcVal)) >> 0; + e = syscall.Fchdir(f.file.fd); + if (!($interfaceIsEqual(e, $ifaceNil))) { + return new PathError.Ptr("chdir", f.file.name, e); + } + return $ifaceNil; }; - methodReceiver = function(op, v, i) { - var rcvrtype = ($ptrType(rtype)).nil, t = ($ptrType(rtype)).nil, fn = 0, name, tt, x, m, iface, ut, x$1, m$1, rcvr; - name = ""; - if (v.typ.Kind() === 20) { - tt = v.typ.interfaceType; - if (i < 0 || i >= tt.methods.$length) { - $panic(new $String("reflect: internal error: invalid method index")); - } - m = (x = tt.methods, ((i < 0 || i >= x.$length) ? $throwRuntimeError("index out of range") : x.$array[x.$offset + i])); - if (!($pointerIsEqual(m.pkgPath, ($ptrType($String)).nil))) { - $panic(new $String("reflect: " + op + " of unexported method")); - } - iface = $clone(v.ptr, nonEmptyInterface); - if (iface.itab === ($ptrType(($structType([["ityp", "ityp", "reflect", ($ptrType(rtype)), ""], ["typ", "typ", "reflect", ($ptrType(rtype)), ""], ["link", "link", "reflect", $UnsafePointer, ""], ["bad", "bad", "reflect", $Int32, ""], ["unused", "unused", "reflect", $Int32, ""], ["fun", "fun", "reflect", ($arrayType($UnsafePointer, 100000)), ""]])))).nil) { - $panic(new $String("reflect: " + op + " of method on nil interface value")); - } - t = m.typ; - name = m.name.$get(); - } else { - ut = v.typ.uncommonType.uncommon(); - if (ut === ($ptrType(uncommonType)).nil || i < 0 || i >= ut.methods.$length) { - $panic(new $String("reflect: internal error: invalid method index")); + File.prototype.Chdir = function() { return this.$val.Chdir(); }; + Open = $pkg.Open = function(name) { + var file$1 = ($ptrType(File)).nil, err = $ifaceNil, _tuple; + _tuple = OpenFile(name, 0, 0); file$1 = _tuple[0]; err = _tuple[1]; + return [file$1, err]; + }; + sigpipe = function() { + $panic("Native function not implemented: os.sigpipe"); + }; + Readlink = $pkg.Readlink = function(name) { + var len, b, _tuple, n, e, x; + len = 128; + while (true) { + b = ($sliceType($Uint8)).make(len); + _tuple = syscall.Readlink(name, b); n = _tuple[0]; e = _tuple[1]; + if (!($interfaceIsEqual(e, $ifaceNil))) { + return ["", new PathError.Ptr("readlink", name, e)]; } - m$1 = (x$1 = ut.methods, ((i < 0 || i >= x$1.$length) ? $throwRuntimeError("index out of range") : x$1.$array[x$1.$offset + i])); - if (!($pointerIsEqual(m$1.pkgPath, ($ptrType($String)).nil))) { - $panic(new $String("reflect: " + op + " of unexported method")); + if (n < len) { + return [$bytesToString($subslice(b, 0, n)), $ifaceNil]; } - t = m$1.mtyp; - name = $internalize(jsType(v.typ).methods[i][0], $String); - } - rcvr = v.iword(); - if (isWrapped(v.typ)) { - rcvr = new (jsType(v.typ))(rcvr); + len = (x = 2, (((len >>> 16 << 16) * x >> 0) + (len << 16 >>> 16) * x) >> 0); } - fn = rcvr[$externalize(name, $String)]; - return [rcvrtype, t, fn]; }; - valueInterface = function(v, safe) { - if (v.flag === 0) { - $panic(new ValueError.Ptr("reflect.Value.Interface", 0)); - } - if (safe && !((((v.flag & 1) >>> 0) === 0))) { - $panic(new $String("reflect.Value.Interface: cannot return value obtained from unexported field or method")); + syscallMode = function(i) { + var o = 0; + o = (o | (((new FileMode(i)).Perm() >>> 0))) >>> 0; + if (!((((i & 8388608) >>> 0) === 0))) { + o = (o | (2048)) >>> 0; } - if (!((((v.flag & 8) >>> 0) === 0))) { - $copy(v, makeMethodValue("Interface", $clone(v, Value)), Value); + if (!((((i & 4194304) >>> 0) === 0))) { + o = (o | (1024)) >>> 0; } - if (isWrapped(v.typ)) { - return new (jsType(v.typ))(v.iword()); + if (!((((i & 1048576) >>> 0) === 0))) { + o = (o | (512)) >>> 0; } - return v.iword(); - }; - ifaceE2I = function(t, src, dst) { - dst.$set(src); + return o; }; - methodName = function() { - return "?FIXME?"; + File.Ptr.prototype.Chmod = function(mode) { + var f, e; + f = this; + if (f === ($ptrType(File)).nil) { + return $pkg.ErrInvalid; + } + e = syscall.Fchmod(f.file.fd, syscallMode(mode)); + if (!($interfaceIsEqual(e, $ifaceNil))) { + return new PathError.Ptr("chmod", f.file.name, e); + } + return $ifaceNil; }; - makeMethodValue = function(op, v) { - var _tuple, fn, rcvr, fv; - if (((v.flag & 8) >>> 0) === 0) { - $panic(new $String("reflect: internal error: invalid use of makePartialFunc")); + File.prototype.Chmod = function(mode) { return this.$val.Chmod(mode); }; + File.Ptr.prototype.Chown = function(uid, gid) { + var f, e; + f = this; + if (f === ($ptrType(File)).nil) { + return $pkg.ErrInvalid; } - _tuple = methodReceiver(op, $clone(v, Value), (v.flag >> 0) >> 9 >> 0); fn = _tuple[2]; - rcvr = v.iword(); - if (isWrapped(v.typ)) { - rcvr = new (jsType(v.typ))(rcvr); + e = syscall.Fchown(f.file.fd, uid, gid); + if (!($interfaceIsEqual(e, $ifaceNil))) { + return new PathError.Ptr("chown", f.file.name, e); } - fv = (function() { - return fn.apply(rcvr, $externalize(new ($sliceType(js.Object))($global.Array.prototype.slice.call(arguments, [])), ($sliceType(js.Object)))); - }); - return new Value.Ptr(v.Type().common(), fv, 0, (((v.flag & 1) >>> 0) | 304) >>> 0); + return $ifaceNil; }; - rtype.Ptr.prototype.pointers = function() { - var t, _ref; - t = this; - _ref = t.Kind(); - if (_ref === 22 || _ref === 21 || _ref === 18 || _ref === 19 || _ref === 25 || _ref === 17) { - return true; - } else { - return false; + File.prototype.Chown = function(uid, gid) { return this.$val.Chown(uid, gid); }; + File.Ptr.prototype.Truncate = function(size) { + var f, e; + f = this; + if (f === ($ptrType(File)).nil) { + return $pkg.ErrInvalid; + } + e = syscall.Ftruncate(f.file.fd, size); + if (!($interfaceIsEqual(e, $ifaceNil))) { + return new PathError.Ptr("truncate", f.file.name, e); } + return $ifaceNil; }; - rtype.prototype.pointers = function() { return this.$val.pointers(); }; - uncommonType.Ptr.prototype.Method = function(i) { - var m = new Method.Ptr(), t, x, p, fl, mt, name, fn; - t = this; - if (t === ($ptrType(uncommonType)).nil || i < 0 || i >= t.methods.$length) { - $panic(new $String("reflect: Method index out of range")); + File.prototype.Truncate = function(size) { return this.$val.Truncate(size); }; + File.Ptr.prototype.Sync = function() { + var err = $ifaceNil, f, e; + f = this; + if (f === ($ptrType(File)).nil) { + err = $pkg.ErrInvalid; + return err; } - p = (x = t.methods, ((i < 0 || i >= x.$length) ? $throwRuntimeError("index out of range") : x.$array[x.$offset + i])); - if (!($pointerIsEqual(p.name, ($ptrType($String)).nil))) { - m.Name = p.name.$get(); + e = syscall.Fsync(f.file.fd); + if (!($interfaceIsEqual(e, $ifaceNil))) { + err = NewSyscallError("fsync", e); + return err; } - fl = 304; - if (!($pointerIsEqual(p.pkgPath, ($ptrType($String)).nil))) { - m.PkgPath = p.pkgPath.$get(); - fl = (fl | (1)) >>> 0; + err = $ifaceNil; + return err; + }; + File.prototype.Sync = function() { return this.$val.Sync(); }; + File.Ptr.prototype.Fd = function() { + var f; + f = this; + if (f === ($ptrType(File)).nil) { + return 4294967295; } - mt = p.typ; - m.Type = mt; - name = $internalize(t.jsType.methods[i][0], $String); - fn = (function(rcvr) { - return rcvr[$externalize(name, $String)].apply(rcvr, $externalize($subslice(new ($sliceType(js.Object))($global.Array.prototype.slice.call(arguments, [])), 1), ($sliceType(js.Object)))); - }); - $copy(m.Func, new Value.Ptr(mt, fn, 0, fl), Value); - m.Index = i; - return m; + return (f.file.fd >>> 0); }; - uncommonType.prototype.Method = function(i) { return this.$val.Method(i); }; - Value.Ptr.prototype.iword = function() { - var v, val, _ref, newVal; - v = new Value.Ptr(); $copy(v, this, Value); - if ((v.typ.Kind() === 17) || (v.typ.Kind() === 25)) { - return v.ptr; + File.prototype.Fd = function() { return this.$val.Fd(); }; + NewFile = $pkg.NewFile = function(fd, name) { + var fdi, f; + fdi = (fd >> 0); + if (fdi < 0) { + return ($ptrType(File)).nil; } - if (!((((v.flag & 2) >>> 0) === 0))) { - val = v.ptr.$get(); - if (!(val === $ifaceNil) && !(val.constructor === jsType(v.typ))) { - _ref = v.typ.Kind(); - switch (0) { default: if (_ref === 11 || _ref === 6) { - val = new (jsType(v.typ))(val.$high, val.$low); - } else if (_ref === 15 || _ref === 16) { - val = new (jsType(v.typ))(val.$real, val.$imag); - } else if (_ref === 23) { - if (val === val.constructor.nil) { - val = jsType(v.typ).nil; - break; - } - newVal = new (jsType(v.typ))(val.$array); - newVal.$offset = val.$offset; - newVal.$length = val.$length; - newVal.$capacity = val.$capacity; - val = newVal; - } } + f = new File.Ptr(new file.Ptr(fdi, name, ($ptrType(dirInfo)).nil, 0)); + runtime.SetFinalizer(f.file, new ($funcType([($ptrType(file))], [$error], false))($methodExpr(($ptrType(file)).prototype.close))); + return f; + }; + epipecheck = function(file$1, e) { + if ($interfaceIsEqual(e, new syscall.Errno(32))) { + if (atomic.AddInt32(new ($ptrType($Int32))(function() { return this.$target.file.nepipe; }, function($v) { this.$target.file.nepipe = $v; }, file$1), 1) >= 10) { + sigpipe(); } - return val; + } else { + atomic.StoreInt32(new ($ptrType($Int32))(function() { return this.$target.file.nepipe; }, function($v) { this.$target.file.nepipe = $v; }, file$1), 0); } - if (v.typ.pointers()) { - return v.ptr; + }; + OpenFile = $pkg.OpenFile = function(name, flag, perm) { + var file$1 = ($ptrType(File)).nil, err = $ifaceNil, _tuple, r, e, _tmp, _tmp$1, _tmp$2, _tmp$3; + _tuple = syscall.Open(name, flag | 524288, syscallMode(perm)); r = _tuple[0]; e = _tuple[1]; + if (!($interfaceIsEqual(e, $ifaceNil))) { + _tmp = ($ptrType(File)).nil; _tmp$1 = new PathError.Ptr("open", name, e); file$1 = _tmp; err = _tmp$1; + return [file$1, err]; } - return v.scalar; + _tmp$2 = NewFile((r >>> 0), name); _tmp$3 = $ifaceNil; file$1 = _tmp$2; err = _tmp$3; + return [file$1, err]; }; - Value.prototype.iword = function() { return this.$val.iword(); }; - Value.Ptr.prototype.call = function(op, in$1) { - var v, t, fn, rcvr, _tuple, isSlice, n, _ref, _i, x, i, _tmp, _tmp$1, xt, targ, m, slice, elem, i$1, x$1, x$2, xt$1, origIn, nin, nout, argsArray, _ref$1, _i$1, i$2, arg, results, _ref$2, ret, _ref$3, _i$2, i$3; - v = new Value.Ptr(); $copy(v, this, Value); - t = v.typ; - fn = 0; - rcvr = $ifaceNil; - if (!((((v.flag & 8) >>> 0) === 0))) { - _tuple = methodReceiver(op, $clone(v, Value), (v.flag >> 0) >> 9 >> 0); t = _tuple[1]; fn = _tuple[2]; - rcvr = v.iword(); - if (isWrapped(v.typ)) { - rcvr = new (jsType(v.typ))(rcvr); - } - } else { - fn = v.iword(); + File.Ptr.prototype.Close = function() { + var f; + f = this; + if (f === ($ptrType(File)).nil) { + return $pkg.ErrInvalid; } - if (fn === 0) { - $panic(new $String("reflect.Value.Call: call of nil function")); + return f.file.close(); + }; + File.prototype.Close = function() { return this.$val.Close(); }; + file.Ptr.prototype.close = function() { + var file$1, err, e; + file$1 = this; + if (file$1 === ($ptrType(file)).nil || file$1.fd < 0) { + return new syscall.Errno(22); } - isSlice = op === "CallSlice"; - n = t.NumIn(); - if (isSlice) { - if (!t.IsVariadic()) { - $panic(new $String("reflect: CallSlice of non-variadic function")); - } - if (in$1.$length < n) { - $panic(new $String("reflect: CallSlice with too few input arguments")); - } - if (in$1.$length > n) { - $panic(new $String("reflect: CallSlice with too many input arguments")); - } - } else { - if (t.IsVariadic()) { - n = n - (1) >> 0; - } - if (in$1.$length < n) { - $panic(new $String("reflect: Call with too few input arguments")); - } - if (!t.IsVariadic() && in$1.$length > n) { - $panic(new $String("reflect: Call with too many input arguments")); - } + err = $ifaceNil; + e = syscall.Close(file$1.fd); + if (!($interfaceIsEqual(e, $ifaceNil))) { + err = new PathError.Ptr("close", file$1.name, e); } - _ref = in$1; - _i = 0; - while (_i < _ref.$length) { - x = new Value.Ptr(); $copy(x, ((_i < 0 || _i >= _ref.$length) ? $throwRuntimeError("index out of range") : _ref.$array[_ref.$offset + _i]), Value); - if (x.Kind() === 0) { - $panic(new $String("reflect: " + op + " using zero Value argument")); - } - _i++; + file$1.fd = -1; + runtime.SetFinalizer(file$1, $ifaceNil); + return err; + }; + file.prototype.close = function() { return this.$val.close(); }; + File.Ptr.prototype.Stat = function() { + var fi = $ifaceNil, err = $ifaceNil, f, _tmp, _tmp$1, stat, _tmp$2, _tmp$3, _tmp$4, _tmp$5; + f = this; + if (f === ($ptrType(File)).nil) { + _tmp = $ifaceNil; _tmp$1 = $pkg.ErrInvalid; fi = _tmp; err = _tmp$1; + return [fi, err]; } - i = 0; - while (i < n) { - _tmp = ((i < 0 || i >= in$1.$length) ? $throwRuntimeError("index out of range") : in$1.$array[in$1.$offset + i]).Type(); _tmp$1 = t.In(i); xt = _tmp; targ = _tmp$1; - if (!xt.AssignableTo(targ)) { - $panic(new $String("reflect: " + op + " using " + xt.String() + " as type " + targ.String())); - } - i = i + (1) >> 0; + stat = new syscall.Stat_t.Ptr(); $copy(stat, new syscall.Stat_t.Ptr(), syscall.Stat_t); + err = syscall.Fstat(f.file.fd, stat); + if (!($interfaceIsEqual(err, $ifaceNil))) { + _tmp$2 = $ifaceNil; _tmp$3 = new PathError.Ptr("stat", f.file.name, err); fi = _tmp$2; err = _tmp$3; + return [fi, err]; } - if (!isSlice && t.IsVariadic()) { - m = in$1.$length - n >> 0; - slice = new Value.Ptr(); $copy(slice, MakeSlice(t.In(n), m, m), Value); - elem = t.In(n).Elem(); - i$1 = 0; - while (i$1 < m) { - x$2 = new Value.Ptr(); $copy(x$2, (x$1 = n + i$1 >> 0, ((x$1 < 0 || x$1 >= in$1.$length) ? $throwRuntimeError("index out of range") : in$1.$array[in$1.$offset + x$1])), Value); - xt$1 = x$2.Type(); - if (!xt$1.AssignableTo(elem)) { - $panic(new $String("reflect: cannot use " + xt$1.String() + " as type " + elem.String() + " in " + op)); - } - slice.Index(i$1).Set($clone(x$2, Value)); - i$1 = i$1 + (1) >> 0; - } - origIn = in$1; - in$1 = ($sliceType(Value)).make((n + 1 >> 0)); - $copySlice($subslice(in$1, 0, n), origIn); - $copy(((n < 0 || n >= in$1.$length) ? $throwRuntimeError("index out of range") : in$1.$array[in$1.$offset + n]), slice, Value); + _tmp$4 = fileInfoFromStat(stat, f.file.name); _tmp$5 = $ifaceNil; fi = _tmp$4; err = _tmp$5; + return [fi, err]; + }; + File.prototype.Stat = function() { return this.$val.Stat(); }; + Stat = $pkg.Stat = function(name) { + var fi = $ifaceNil, err = $ifaceNil, stat, _tmp, _tmp$1, _tmp$2, _tmp$3; + stat = new syscall.Stat_t.Ptr(); $copy(stat, new syscall.Stat_t.Ptr(), syscall.Stat_t); + err = syscall.Stat(name, stat); + if (!($interfaceIsEqual(err, $ifaceNil))) { + _tmp = $ifaceNil; _tmp$1 = new PathError.Ptr("stat", name, err); fi = _tmp; err = _tmp$1; + return [fi, err]; } - nin = in$1.$length; - if (!((nin === t.NumIn()))) { - $panic(new $String("reflect.Value.Call: wrong argument count")); + _tmp$2 = fileInfoFromStat(stat, name); _tmp$3 = $ifaceNil; fi = _tmp$2; err = _tmp$3; + return [fi, err]; + }; + Lstat = $pkg.Lstat = function(name) { + var fi = $ifaceNil, err = $ifaceNil, stat, _tmp, _tmp$1, _tmp$2, _tmp$3; + stat = new syscall.Stat_t.Ptr(); $copy(stat, new syscall.Stat_t.Ptr(), syscall.Stat_t); + err = syscall.Lstat(name, stat); + if (!($interfaceIsEqual(err, $ifaceNil))) { + _tmp = $ifaceNil; _tmp$1 = new PathError.Ptr("lstat", name, err); fi = _tmp; err = _tmp$1; + return [fi, err]; } - nout = t.NumOut(); - argsArray = new ($global.Array)(t.NumIn()); - _ref$1 = in$1; - _i$1 = 0; - while (_i$1 < _ref$1.$length) { - i$2 = _i$1; - arg = new Value.Ptr(); $copy(arg, ((_i$1 < 0 || _i$1 >= _ref$1.$length) ? $throwRuntimeError("index out of range") : _ref$1.$array[_ref$1.$offset + _i$1]), Value); - argsArray[i$2] = arg.assignTo("reflect.Value.Call", t.In(i$2).common(), ($ptrType($emptyInterface)).nil).iword(); - _i$1++; + _tmp$2 = fileInfoFromStat(stat, name); _tmp$3 = $ifaceNil; fi = _tmp$2; err = _tmp$3; + return [fi, err]; + }; + File.Ptr.prototype.readdir = function(n) { + var fi = ($sliceType(FileInfo)).nil, err = $ifaceNil, f, dirname, _tuple, names, _ref, _i, filename, _tuple$1, fip, lerr, _tmp, _tmp$1, _tmp$2, _tmp$3; + f = this; + dirname = f.file.name; + if (dirname === "") { + dirname = "."; } - results = fn.apply(rcvr, argsArray); - _ref$2 = nout; - if (_ref$2 === 0) { - return ($sliceType(Value)).nil; - } else if (_ref$2 === 1) { - return new ($sliceType(Value))([$clone(makeValue(t.Out(0), results, 0), Value)]); - } else { - ret = ($sliceType(Value)).make(nout); - _ref$3 = ret; - _i$2 = 0; - while (_i$2 < _ref$3.$length) { - i$3 = _i$2; - $copy(((i$3 < 0 || i$3 >= ret.$length) ? $throwRuntimeError("index out of range") : ret.$array[ret.$offset + i$3]), makeValue(t.Out(i$3), results[i$3], 0), Value); - _i$2++; + _tuple = f.Readdirnames(n); names = _tuple[0]; err = _tuple[1]; + fi = ($sliceType(FileInfo)).make(0, names.$length); + _ref = names; + _i = 0; + while (_i < _ref.$length) { + filename = ((_i < 0 || _i >= _ref.$length) ? $throwRuntimeError("index out of range") : _ref.$array[_ref.$offset + _i]); + _tuple$1 = lstat(dirname + "/" + filename); fip = _tuple$1[0]; lerr = _tuple$1[1]; + if (IsNotExist(lerr)) { + _i++; + continue; } - return ret; + if (!($interfaceIsEqual(lerr, $ifaceNil))) { + _tmp = fi; _tmp$1 = lerr; fi = _tmp; err = _tmp$1; + return [fi, err]; + } + fi = $append(fi, fip); + _i++; } + _tmp$2 = fi; _tmp$3 = err; fi = _tmp$2; err = _tmp$3; + return [fi, err]; }; - Value.prototype.call = function(op, in$1) { return this.$val.call(op, in$1); }; - Value.Ptr.prototype.Cap = function() { - var v, k, _ref; - v = new Value.Ptr(); $copy(v, this, Value); - k = (new flag(v.flag)).kind(); - _ref = k; - if (_ref === 17) { - return v.typ.Len(); - } else if (_ref === 18 || _ref === 23) { - return $parseInt(v.iword().$capacity) >> 0; - } - $panic(new ValueError.Ptr("reflect.Value.Cap", k)); + File.prototype.readdir = function(n) { return this.$val.readdir(n); }; + File.Ptr.prototype.read = function(b) { + var n = 0, err = $ifaceNil, f, _tuple; + f = this; + _tuple = syscall.Read(f.file.fd, b); n = _tuple[0]; err = _tuple[1]; + return [n, err]; }; - Value.prototype.Cap = function() { return this.$val.Cap(); }; - Value.Ptr.prototype.Elem = function() { - var v, k, _ref, val, typ, val$1, tt, fl; - v = new Value.Ptr(); $copy(v, this, Value); - k = (new flag(v.flag)).kind(); - _ref = k; - if (_ref === 20) { - val = v.iword(); - if (val === $ifaceNil) { - return new Value.Ptr(($ptrType(rtype)).nil, 0, 0, 0); + File.prototype.read = function(b) { return this.$val.read(b); }; + File.Ptr.prototype.pread = function(b, off) { + var n = 0, err = $ifaceNil, f, _tuple; + f = this; + _tuple = syscall.Pread(f.file.fd, b, off); n = _tuple[0]; err = _tuple[1]; + return [n, err]; + }; + File.prototype.pread = function(b, off) { return this.$val.pread(b, off); }; + File.Ptr.prototype.write = function(b) { + var n = 0, err = $ifaceNil, f, bcap, _tuple, m, err$1, _tmp, _tmp$1; + f = this; + while (true) { + bcap = b; + _tuple = syscall.Write(f.file.fd, bcap); m = _tuple[0]; err$1 = _tuple[1]; + n = n + (m) >> 0; + if (0 < m && m < bcap.$length || $interfaceIsEqual(err$1, new syscall.Errno(4))) { + b = $subslice(b, m); + continue; } - typ = reflectType(val.constructor); - return makeValue(typ, val.$val, (v.flag & 1) >>> 0); - } else if (_ref === 22) { - if (v.IsNil()) { - return new Value.Ptr(($ptrType(rtype)).nil, 0, 0, 0); + _tmp = n; _tmp$1 = err$1; n = _tmp; err = _tmp$1; + return [n, err]; + } + }; + File.prototype.write = function(b) { return this.$val.write(b); }; + File.Ptr.prototype.pwrite = function(b, off) { + var n = 0, err = $ifaceNil, f, _tuple; + f = this; + _tuple = syscall.Pwrite(f.file.fd, b, off); n = _tuple[0]; err = _tuple[1]; + return [n, err]; + }; + File.prototype.pwrite = function(b, off) { return this.$val.pwrite(b, off); }; + File.Ptr.prototype.seek = function(offset, whence) { + var ret = new $Int64(0, 0), err = $ifaceNil, f, _tuple; + f = this; + _tuple = syscall.Seek(f.file.fd, offset, whence); ret = _tuple[0]; err = _tuple[1]; + return [ret, err]; + }; + File.prototype.seek = function(offset, whence) { return this.$val.seek(offset, whence); }; + basename = function(name) { + var i; + i = name.length - 1 >> 0; + while (i > 0 && (name.charCodeAt(i) === 47)) { + name = name.substring(0, i); + i = i - (1) >> 0; + } + i = i - (1) >> 0; + while (i >= 0) { + if (name.charCodeAt(i) === 47) { + name = name.substring((i + 1 >> 0)); + break; } - val$1 = v.iword(); - tt = v.typ.ptrType; - fl = (((((v.flag & 1) >>> 0) | 2) >>> 0) | 4) >>> 0; - fl = (fl | (((tt.elem.Kind() >>> 0) << 4 >>> 0))) >>> 0; - return new Value.Ptr(tt.elem, val$1, 0, fl); - } else { - $panic(new ValueError.Ptr("reflect.Value.Elem", k)); + i = i - (1) >> 0; } + return name; }; - Value.prototype.Elem = function() { return this.$val.Elem(); }; - Value.Ptr.prototype.Field = function(i) { - var v, tt, x, field, name, typ, fl, s; - v = new Value.Ptr(); $copy(v, this, Value); - (new flag(v.flag)).mustBe(25); - tt = v.typ.structType; - if (i < 0 || i >= tt.fields.$length) { - $panic(new $String("reflect: Field index out of range")); + Getwd = $pkg.Getwd = function() { + var $this = this, $args = arguments, dir = "", err = $ifaceNil, $s = 0, _tuple, s, e, _tmp, _tmp$1, _tuple$1, dot, _tmp$2, _tmp$3, _tuple$2, d, err$1, _tmp$4, _tmp$5, _tuple$3, d$1, err$2, _tmp$6, _tmp$7, _tuple$4, root, _tmp$8, _tmp$9, _tmp$10, _tmp$11, parent, _tmp$12, _tmp$13, _tuple$5, fd, err$3, _tmp$14, _tmp$15, _tuple$6, names, err$4, _tmp$16, _tmp$17, _ref, _i, name, _tuple$7, d$2, _tuple$8, pd, _tmp$18, _tmp$19, _tmp$20, _tmp$21; + /* */ while (true) { switch ($s) { case 0: + _tuple = syscall.Getwd(); s = _tuple[0]; e = _tuple[1]; + if (useSyscallwd(e)) { + _tmp = s; _tmp$1 = NewSyscallError("getwd", e); dir = _tmp; err = _tmp$1; + return [dir, err]; } - field = (x = tt.fields, ((i < 0 || i >= x.$length) ? $throwRuntimeError("index out of range") : x.$array[x.$offset + i])); - name = $internalize(jsType(v.typ).fields[i][0], $String); - typ = field.typ; - fl = (v.flag & 7) >>> 0; - if (!($pointerIsEqual(field.pkgPath, ($ptrType($String)).nil))) { - fl = (fl | (1)) >>> 0; + _tuple$1 = Stat("."); dot = _tuple$1[0]; err = _tuple$1[1]; + if (!($interfaceIsEqual(err, $ifaceNil))) { + _tmp$2 = ""; _tmp$3 = err; dir = _tmp$2; err = _tmp$3; + return [dir, err]; } - fl = (fl | (((typ.Kind() >>> 0) << 4 >>> 0))) >>> 0; - s = v.ptr; - if (!((((fl & 2) >>> 0) === 0)) && !((typ.Kind() === 17)) && !((typ.Kind() === 25))) { - return new Value.Ptr(typ, new (jsType(PtrTo(typ)))($externalize((function() { - return s[$externalize(name, $String)]; - }), ($funcType([], [js.Object], false))), $externalize((function(v$1) { - s[$externalize(name, $String)] = v$1; - }), ($funcType([js.Object], [], false)))), 0, fl); + dir = Getenv("PWD"); + if (dir.length > 0 && (dir.charCodeAt(0) === 47)) { + _tuple$2 = Stat(dir); d = _tuple$2[0]; err$1 = _tuple$2[1]; + if ($interfaceIsEqual(err$1, $ifaceNil) && SameFile(dot, d)) { + _tmp$4 = dir; _tmp$5 = $ifaceNil; dir = _tmp$4; err = _tmp$5; + return [dir, err]; + } } - return makeValue(typ, s[$externalize(name, $String)], fl); - }; - Value.prototype.Field = function(i) { return this.$val.Field(i); }; - Value.Ptr.prototype.Index = function(i) { - var v, k, _ref, tt, typ, fl, a, s, tt$1, typ$1, fl$1, a$1, str, fl$2; - v = new Value.Ptr(); $copy(v, this, Value); - k = (new flag(v.flag)).kind(); - _ref = k; - if (_ref === 17) { - tt = v.typ.arrayType; - if (i < 0 || i > (tt.len >> 0)) { - $panic(new $String("reflect: array index out of range")); + getwdCache.Mutex.Lock(); + dir = getwdCache.dir; + getwdCache.Mutex.Unlock(); + if (dir.length > 0) { + _tuple$3 = Stat(dir); d$1 = _tuple$3[0]; err$2 = _tuple$3[1]; + if ($interfaceIsEqual(err$2, $ifaceNil) && SameFile(dot, d$1)) { + _tmp$6 = dir; _tmp$7 = $ifaceNil; dir = _tmp$6; err = _tmp$7; + return [dir, err]; } - typ = tt.elem; - fl = (v.flag & 7) >>> 0; - fl = (fl | (((typ.Kind() >>> 0) << 4 >>> 0))) >>> 0; - a = v.ptr; - if (!((((fl & 2) >>> 0) === 0)) && !((typ.Kind() === 17)) && !((typ.Kind() === 25))) { - return new Value.Ptr(typ, new (jsType(PtrTo(typ)))($externalize((function() { - return a[i]; - }), ($funcType([], [js.Object], false))), $externalize((function(v$1) { - a[i] = v$1; - }), ($funcType([js.Object], [], false)))), 0, fl); + } + _tuple$4 = Stat("/"); root = _tuple$4[0]; err = _tuple$4[1]; + if (!($interfaceIsEqual(err, $ifaceNil))) { + _tmp$8 = ""; _tmp$9 = err; dir = _tmp$8; err = _tmp$9; + return [dir, err]; + } + if (SameFile(root, dot)) { + _tmp$10 = "/"; _tmp$11 = $ifaceNil; dir = _tmp$10; err = _tmp$11; + return [dir, err]; + } + dir = ""; + parent = ".."; + /* while (true) { */ case 2: if(!(true)) { $s = 3; continue; } + if (parent.length >= 1024) { + _tmp$12 = ""; _tmp$13 = new syscall.Errno(36); dir = _tmp$12; err = _tmp$13; + return [dir, err]; } - return makeValue(typ, a[i], fl); - } else if (_ref === 23) { - s = v.iword(); - if (i < 0 || i >= ($parseInt(s.$length) >> 0)) { - $panic(new $String("reflect: slice index out of range")); + _tuple$5 = Open(parent); fd = _tuple$5[0]; err$3 = _tuple$5[1]; + if (!($interfaceIsEqual(err$3, $ifaceNil))) { + _tmp$14 = ""; _tmp$15 = err$3; dir = _tmp$14; err = _tmp$15; + return [dir, err]; } - tt$1 = v.typ.sliceType; - typ$1 = tt$1.elem; - fl$1 = (6 | ((v.flag & 1) >>> 0)) >>> 0; - fl$1 = (fl$1 | (((typ$1.Kind() >>> 0) << 4 >>> 0))) >>> 0; - i = i + (($parseInt(s.$offset) >> 0)) >> 0; - a$1 = s.$array; - if (!((((fl$1 & 2) >>> 0) === 0)) && !((typ$1.Kind() === 17)) && !((typ$1.Kind() === 25))) { - return new Value.Ptr(typ$1, new (jsType(PtrTo(typ$1)))($externalize((function() { - return a$1[i]; - }), ($funcType([], [js.Object], false))), $externalize((function(v$1) { - a$1[i] = v$1; - }), ($funcType([js.Object], [], false)))), 0, fl$1); + /* while (true) { */ case 4: if(!(true)) { $s = 5; continue; } + _tuple$6 = fd.Readdirnames(100); names = _tuple$6[0]; err$4 = _tuple$6[1]; + if (!($interfaceIsEqual(err$4, $ifaceNil))) { + fd.Close(); + _tmp$16 = ""; _tmp$17 = err$4; dir = _tmp$16; err = _tmp$17; + return [dir, err]; + } + _ref = names; + _i = 0; + /* while (_i < _ref.$length) { */ case 6: if(!(_i < _ref.$length)) { $s = 7; continue; } + name = ((_i < 0 || _i >= _ref.$length) ? $throwRuntimeError("index out of range") : _ref.$array[_ref.$offset + _i]); + _tuple$7 = Lstat(parent + "/" + name); d$2 = _tuple$7[0]; + /* if (SameFile(d$2, dot)) { */ if (SameFile(d$2, dot)) {} else { $s = 8; continue; } + dir = "/" + name + dir; + /* goto Found */ $s = 1; continue; + /* } */ case 8: + _i++; + /* } */ $s = 6; continue; case 7: + /* } */ $s = 4; continue; case 5: + /* Found: */ case 1: + _tuple$8 = fd.Stat(); pd = _tuple$8[0]; err$3 = _tuple$8[1]; + if (!($interfaceIsEqual(err$3, $ifaceNil))) { + _tmp$18 = ""; _tmp$19 = err$3; dir = _tmp$18; err = _tmp$19; + return [dir, err]; } - return makeValue(typ$1, a$1[i], fl$1); - } else if (_ref === 24) { - str = v.ptr.$get(); - if (i < 0 || i >= str.length) { - $panic(new $String("reflect: string index out of range")); + fd.Close(); + if (SameFile(pd, root)) { + /* break; */ $s = 3; continue; } - fl$2 = (((v.flag & 1) >>> 0) | 128) >>> 0; - return new Value.Ptr(uint8Type, 0, (str.charCodeAt(i) >>> 0), fl$2); - } else { - $panic(new ValueError.Ptr("reflect.Value.Index", k)); - } + dot = pd; + parent = "../" + parent; + /* } */ $s = 2; continue; case 3: + getwdCache.Mutex.Lock(); + getwdCache.dir = dir; + getwdCache.Mutex.Unlock(); + _tmp$20 = dir; _tmp$21 = $ifaceNil; dir = _tmp$20; err = _tmp$21; + return [dir, err]; + /* */ case -1: } return; } }; - Value.prototype.Index = function(i) { return this.$val.Index(i); }; - Value.Ptr.prototype.IsNil = function() { - var v, k, _ref; - v = new Value.Ptr(); $copy(v, this, Value); - k = (new flag(v.flag)).kind(); - _ref = k; - if (_ref === 18 || _ref === 22 || _ref === 23) { - return v.iword() === jsType(v.typ).nil; - } else if (_ref === 19) { - return v.iword() === $throwNilPointerError; - } else if (_ref === 21) { - return v.iword() === false; - } else if (_ref === 20) { - return v.iword() === $ifaceNil; - } else { - $panic(new ValueError.Ptr("reflect.Value.IsNil", k)); - } + IsPathSeparator = $pkg.IsPathSeparator = function(c) { + return 47 === c; }; - Value.prototype.IsNil = function() { return this.$val.IsNil(); }; - Value.Ptr.prototype.Len = function() { - var v, k, _ref; - v = new Value.Ptr(); $copy(v, this, Value); - k = (new flag(v.flag)).kind(); - _ref = k; - if (_ref === 17 || _ref === 24) { - return $parseInt(v.iword().length); - } else if (_ref === 23) { - return $parseInt(v.iword().$length) >> 0; - } else if (_ref === 18) { - return $parseInt(v.iword().$buffer.length) >> 0; - } else if (_ref === 21) { - return $parseInt($keys(v.iword()).length); - } else { - $panic(new ValueError.Ptr("reflect.Value.Len", k)); + Exit = $pkg.Exit = function(code) { + syscall.Exit(code); + }; + sameFile = function(fs1, fs2) { + var stat1, stat2, x, x$1, x$2, x$3; + stat1 = $assertType(fs1.sys, ($ptrType(syscall.Stat_t))); + stat2 = $assertType(fs2.sys, ($ptrType(syscall.Stat_t))); + return (x = stat1.Dev, x$1 = stat2.Dev, (x.$high === x$1.$high && x.$low === x$1.$low)) && (x$2 = stat1.Ino, x$3 = stat2.Ino, (x$2.$high === x$3.$high && x$2.$low === x$3.$low)); + }; + fileInfoFromStat = function(st, name) { + var fs, _ref; + fs = new fileStat.Ptr(basename(name), st.Size, 0, timespecToTime($clone(st.Mtim, syscall.Timespec)), st); + fs.mode = (((st.Mode & 511) >>> 0) >>> 0); + _ref = (st.Mode & 61440) >>> 0; + if (_ref === 24576) { + fs.mode = (fs.mode | (67108864)) >>> 0; + } else if (_ref === 8192) { + fs.mode = (fs.mode | (69206016)) >>> 0; + } else if (_ref === 16384) { + fs.mode = (fs.mode | (2147483648)) >>> 0; + } else if (_ref === 4096) { + fs.mode = (fs.mode | (33554432)) >>> 0; + } else if (_ref === 40960) { + fs.mode = (fs.mode | (134217728)) >>> 0; + } else if (_ref === 32768) { + } else if (_ref === 49152) { + fs.mode = (fs.mode | (16777216)) >>> 0; + } + if (!((((st.Mode & 1024) >>> 0) === 0))) { + fs.mode = (fs.mode | (4194304)) >>> 0; + } + if (!((((st.Mode & 2048) >>> 0) === 0))) { + fs.mode = (fs.mode | (8388608)) >>> 0; + } + if (!((((st.Mode & 512) >>> 0) === 0))) { + fs.mode = (fs.mode | (1048576)) >>> 0; } + return fs; }; - Value.prototype.Len = function() { return this.$val.Len(); }; - Value.Ptr.prototype.Pointer = function() { - var v, k, _ref; - v = new Value.Ptr(); $copy(v, this, Value); - k = (new flag(v.flag)).kind(); - _ref = k; - if (_ref === 18 || _ref === 21 || _ref === 22 || _ref === 23 || _ref === 26) { - if (v.IsNil()) { - return 0; + timespecToTime = function(ts) { + return time.Unix(ts.Sec, ts.Nsec); + }; + FileMode.prototype.String = function() { + var m, buf, w, _ref, _i, _rune, i, c, y, _ref$1, _i$1, _rune$1, i$1, c$1, y$1; + m = this.$val !== undefined ? this.$val : this; + buf = ($arrayType($Uint8, 32)).zero(); $copy(buf, ($arrayType($Uint8, 32)).zero(), ($arrayType($Uint8, 32))); + w = 0; + _ref = "dalTLDpSugct"; + _i = 0; + while (_i < _ref.length) { + _rune = $decodeRune(_ref, _i); + i = _i; + c = _rune[0]; + if (!((((m & (((y = ((31 - i >> 0) >>> 0), y < 32 ? (1 << y) : 0) >>> 0))) >>> 0) === 0))) { + (w < 0 || w >= buf.length) ? $throwRuntimeError("index out of range") : buf[w] = (c << 24 >>> 24); + w = w + (1) >> 0; } - return v.iword(); - } else if (_ref === 19) { - if (v.IsNil()) { - return 0; + _i += _rune[1]; + } + if (w === 0) { + (w < 0 || w >= buf.length) ? $throwRuntimeError("index out of range") : buf[w] = 45; + w = w + (1) >> 0; + } + _ref$1 = "rwxrwxrwx"; + _i$1 = 0; + while (_i$1 < _ref$1.length) { + _rune$1 = $decodeRune(_ref$1, _i$1); + i$1 = _i$1; + c$1 = _rune$1[0]; + if (!((((m & (((y$1 = ((8 - i$1 >> 0) >>> 0), y$1 < 32 ? (1 << y$1) : 0) >>> 0))) >>> 0) === 0))) { + (w < 0 || w >= buf.length) ? $throwRuntimeError("index out of range") : buf[w] = (c$1 << 24 >>> 24); + } else { + (w < 0 || w >= buf.length) ? $throwRuntimeError("index out of range") : buf[w] = 45; } - return 1; - } else { - $panic(new ValueError.Ptr("reflect.Value.Pointer", k)); + w = w + (1) >> 0; + _i$1 += _rune$1[1]; } + return $bytesToString($subslice(new ($sliceType($Uint8))(buf), 0, w)); }; - Value.prototype.Pointer = function() { return this.$val.Pointer(); }; - Value.Ptr.prototype.Set = function(x) { - var v, _ref; - v = new Value.Ptr(); $copy(v, this, Value); - (new flag(v.flag)).mustBeAssignable(); - (new flag(x.flag)).mustBeExported(); - $copy(x, x.assignTo("reflect.Set", v.typ, ($ptrType($emptyInterface)).nil), Value); - if (!((((v.flag & 2) >>> 0) === 0))) { - _ref = v.typ.Kind(); - if (_ref === 17) { - $copy(v.ptr, x.ptr, jsType(v.typ)); - } else if (_ref === 20) { - v.ptr.$set(valueInterface($clone(x, Value), false)); - } else if (_ref === 25) { - copyStruct(v.ptr, x.ptr, v.typ); - } else { - v.ptr.$set(x.iword()); - } - return; + $ptrType(FileMode).prototype.String = function() { return new FileMode(this.$get()).String(); }; + FileMode.prototype.IsDir = function() { + var m; + m = this.$val !== undefined ? this.$val : this; + return !((((m & 2147483648) >>> 0) === 0)); + }; + $ptrType(FileMode).prototype.IsDir = function() { return new FileMode(this.$get()).IsDir(); }; + FileMode.prototype.IsRegular = function() { + var m; + m = this.$val !== undefined ? this.$val : this; + return ((m & 2399141888) >>> 0) === 0; + }; + $ptrType(FileMode).prototype.IsRegular = function() { return new FileMode(this.$get()).IsRegular(); }; + FileMode.prototype.Perm = function() { + var m; + m = this.$val !== undefined ? this.$val : this; + return (m & 511) >>> 0; + }; + $ptrType(FileMode).prototype.Perm = function() { return new FileMode(this.$get()).Perm(); }; + fileStat.Ptr.prototype.Name = function() { + var fs; + fs = this; + return fs.name; + }; + fileStat.prototype.Name = function() { return this.$val.Name(); }; + fileStat.Ptr.prototype.IsDir = function() { + var fs; + fs = this; + return (new FileMode(fs.Mode())).IsDir(); + }; + fileStat.prototype.IsDir = function() { return this.$val.IsDir(); }; + SameFile = $pkg.SameFile = function(fi1, fi2) { + var _tuple, fs1, ok1, _tuple$1, fs2, ok2; + _tuple = $assertType(fi1, ($ptrType(fileStat)), true); fs1 = _tuple[0]; ok1 = _tuple[1]; + _tuple$1 = $assertType(fi2, ($ptrType(fileStat)), true); fs2 = _tuple$1[0]; ok2 = _tuple$1[1]; + if (!ok1 || !ok2) { + return false; } - v.ptr = x.ptr; + return sameFile(fs1, fs2); }; - Value.prototype.Set = function(x) { return this.$val.Set(x); }; - Value.Ptr.prototype.SetCap = function(n) { - var v, s, newSlice; - v = new Value.Ptr(); $copy(v, this, Value); - (new flag(v.flag)).mustBeAssignable(); - (new flag(v.flag)).mustBe(23); - s = v.ptr.$get(); - if (n < ($parseInt(s.$length) >> 0) || n > ($parseInt(s.$capacity) >> 0)) { - $panic(new $String("reflect: slice capacity out of range in SetCap")); + fileStat.Ptr.prototype.Size = function() { + var fs; + fs = this; + return fs.size; + }; + fileStat.prototype.Size = function() { return this.$val.Size(); }; + fileStat.Ptr.prototype.Mode = function() { + var fs; + fs = this; + return fs.mode; + }; + fileStat.prototype.Mode = function() { return this.$val.Mode(); }; + fileStat.Ptr.prototype.ModTime = function() { + var fs; + fs = this; + return fs.modTime; + }; + fileStat.prototype.ModTime = function() { return this.$val.ModTime(); }; + fileStat.Ptr.prototype.Sys = function() { + var fs; + fs = this; + return fs.sys; + }; + fileStat.prototype.Sys = function() { return this.$val.Sys(); }; + $pkg.$init = function() { + ($ptrType(PathError)).methods = [["Error", "Error", "", $funcType([], [$String], false), -1]]; + PathError.init([["Op", "Op", "", $String, ""], ["Path", "Path", "", $String, ""], ["Err", "Err", "", $error, ""]]); + ($ptrType(SyscallError)).methods = [["Error", "Error", "", $funcType([], [$String], false), -1]]; + SyscallError.init([["Syscall", "Syscall", "", $String, ""], ["Err", "Err", "", $error, ""]]); + ($ptrType(LinkError)).methods = [["Error", "Error", "", $funcType([], [$String], false), -1]]; + LinkError.init([["Op", "Op", "", $String, ""], ["Old", "Old", "", $String, ""], ["New", "New", "", $String, ""], ["Err", "Err", "", $error, ""]]); + File.methods = [["close", "close", "os", $funcType([], [$error], false), 0]]; + ($ptrType(File)).methods = [["Chdir", "Chdir", "", $funcType([], [$error], false), -1], ["Chmod", "Chmod", "", $funcType([FileMode], [$error], false), -1], ["Chown", "Chown", "", $funcType([$Int, $Int], [$error], false), -1], ["Close", "Close", "", $funcType([], [$error], false), -1], ["Fd", "Fd", "", $funcType([], [$Uintptr], false), -1], ["Name", "Name", "", $funcType([], [$String], false), -1], ["Read", "Read", "", $funcType([($sliceType($Uint8))], [$Int, $error], false), -1], ["ReadAt", "ReadAt", "", $funcType([($sliceType($Uint8)), $Int64], [$Int, $error], false), -1], ["Readdir", "Readdir", "", $funcType([$Int], [($sliceType(FileInfo)), $error], false), -1], ["Readdirnames", "Readdirnames", "", $funcType([$Int], [($sliceType($String)), $error], false), -1], ["Seek", "Seek", "", $funcType([$Int64, $Int], [$Int64, $error], false), -1], ["Stat", "Stat", "", $funcType([], [FileInfo, $error], false), -1], ["Sync", "Sync", "", $funcType([], [$error], false), -1], ["Truncate", "Truncate", "", $funcType([$Int64], [$error], false), -1], ["Write", "Write", "", $funcType([($sliceType($Uint8))], [$Int, $error], false), -1], ["WriteAt", "WriteAt", "", $funcType([($sliceType($Uint8)), $Int64], [$Int, $error], false), -1], ["WriteString", "WriteString", "", $funcType([$String], [$Int, $error], false), -1], ["close", "close", "os", $funcType([], [$error], false), 0], ["pread", "pread", "os", $funcType([($sliceType($Uint8)), $Int64], [$Int, $error], false), -1], ["pwrite", "pwrite", "os", $funcType([($sliceType($Uint8)), $Int64], [$Int, $error], false), -1], ["read", "read", "os", $funcType([($sliceType($Uint8))], [$Int, $error], false), -1], ["readdir", "readdir", "os", $funcType([$Int], [($sliceType(FileInfo)), $error], false), -1], ["readdirnames", "readdirnames", "os", $funcType([$Int], [($sliceType($String)), $error], false), -1], ["seek", "seek", "os", $funcType([$Int64, $Int], [$Int64, $error], false), -1], ["write", "write", "os", $funcType([($sliceType($Uint8))], [$Int, $error], false), -1]]; + File.init([["file", "", "os", ($ptrType(file)), ""]]); + ($ptrType(file)).methods = [["close", "close", "os", $funcType([], [$error], false), -1]]; + file.init([["fd", "fd", "os", $Int, ""], ["name", "name", "os", $String, ""], ["dirinfo", "dirinfo", "os", ($ptrType(dirInfo)), ""], ["nepipe", "nepipe", "os", $Int32, ""]]); + dirInfo.init([["buf", "buf", "os", ($sliceType($Uint8)), ""], ["nbuf", "nbuf", "os", $Int, ""], ["bufp", "bufp", "os", $Int, ""]]); + FileInfo.init([["IsDir", "IsDir", "", $funcType([], [$Bool], false)], ["ModTime", "ModTime", "", $funcType([], [time.Time], false)], ["Mode", "Mode", "", $funcType([], [FileMode], false)], ["Name", "Name", "", $funcType([], [$String], false)], ["Size", "Size", "", $funcType([], [$Int64], false)], ["Sys", "Sys", "", $funcType([], [$emptyInterface], false)]]); + FileMode.methods = [["IsDir", "IsDir", "", $funcType([], [$Bool], false), -1], ["IsRegular", "IsRegular", "", $funcType([], [$Bool], false), -1], ["Perm", "Perm", "", $funcType([], [FileMode], false), -1], ["String", "String", "", $funcType([], [$String], false), -1]]; + ($ptrType(FileMode)).methods = [["IsDir", "IsDir", "", $funcType([], [$Bool], false), -1], ["IsRegular", "IsRegular", "", $funcType([], [$Bool], false), -1], ["Perm", "Perm", "", $funcType([], [FileMode], false), -1], ["String", "String", "", $funcType([], [$String], false), -1]]; + ($ptrType(fileStat)).methods = [["IsDir", "IsDir", "", $funcType([], [$Bool], false), -1], ["ModTime", "ModTime", "", $funcType([], [time.Time], false), -1], ["Mode", "Mode", "", $funcType([], [FileMode], false), -1], ["Name", "Name", "", $funcType([], [$String], false), -1], ["Size", "Size", "", $funcType([], [$Int64], false), -1], ["Sys", "Sys", "", $funcType([], [$emptyInterface], false), -1]]; + fileStat.init([["name", "name", "os", $String, ""], ["size", "size", "os", $Int64, ""], ["mode", "mode", "os", FileMode, ""], ["modTime", "modTime", "os", time.Time, ""], ["sys", "sys", "os", $emptyInterface, ""]]); + getwdCache = new ($structType([["Mutex", "", "", sync.Mutex, ""], ["dir", "dir", "os", $String, ""]])).Ptr(); + $pkg.Args = ($sliceType($String)).nil; + $pkg.ErrInvalid = errors.New("invalid argument"); + $pkg.ErrPermission = errors.New("permission denied"); + $pkg.ErrExist = errors.New("file already exists"); + $pkg.ErrNotExist = errors.New("file does not exist"); + $pkg.Stdin = NewFile((syscall.Stdin >>> 0), "/dev/stdin"); + $pkg.Stdout = NewFile((syscall.Stdout >>> 0), "/dev/stdout"); + $pkg.Stderr = NewFile((syscall.Stderr >>> 0), "/dev/stderr"); + useSyscallwd = (function() { + return true; + }); + lstat = Lstat; + init(); + }; + return $pkg; +})(); +$packages["reflect"] = (function() { + var $pkg = {}, js = $packages["github.com/gopherjs/gopherjs/js"], runtime = $packages["runtime"], strconv = $packages["strconv"], sync = $packages["sync"], math = $packages["math"], mapIter, Type, Kind, rtype, method, uncommonType, ChanDir, arrayType, chanType, funcType, imethod, interfaceType, mapType, ptrType, sliceType, structField, structType, Method, StructField, StructTag, fieldScan, Value, flag, ValueError, iword, nonEmptyInterface, initialized, kindNames, uint8Type, init, jsType, reflectType, isWrapped, copyStruct, makeValue, MakeSlice, jsObject, TypeOf, ValueOf, SliceOf, Zero, unsafe_New, makeInt, memmove, loadScalar, makemap, mapaccess, mapassign, mapdelete, mapiterinit, mapiterkey, mapiternext, maplen, cvtDirect, Copy, methodReceiver, valueInterface, ifaceE2I, methodName, makeMethodValue, PtrTo, implements$1, directlyAssignable, haveIdenticalUnderlyingType, toType, overflowFloat32, typesMustMatch, MakeMap, Indirect, New, convertOp, makeFloat, makeComplex, makeString, makeBytes, makeRunes, cvtInt, cvtUint, cvtFloatInt, cvtFloatUint, cvtIntFloat, cvtUintFloat, cvtFloat, cvtComplex, cvtIntString, cvtUintString, cvtBytesString, cvtStringBytes, cvtRunesString, cvtStringRunes, cvtT2I, cvtI2I, call; + mapIter = $pkg.mapIter = $newType(0, "Struct", "reflect.mapIter", "mapIter", "reflect", function(t_, m_, keys_, i_) { + this.$val = this; + this.t = t_ !== undefined ? t_ : $ifaceNil; + this.m = m_ !== undefined ? m_ : $ifaceNil; + this.keys = keys_ !== undefined ? keys_ : $ifaceNil; + this.i = i_ !== undefined ? i_ : 0; + }); + Type = $pkg.Type = $newType(8, "Interface", "reflect.Type", "Type", "reflect", null); + Kind = $pkg.Kind = $newType(4, "Uint", "reflect.Kind", "Kind", "reflect", null); + rtype = $pkg.rtype = $newType(0, "Struct", "reflect.rtype", "rtype", "reflect", function(size_, hash_, _$2_, align_, fieldAlign_, kind_, alg_, gc_, string_, uncommonType_, ptrToThis_, zero_) { + this.$val = this; + this.size = size_ !== undefined ? size_ : 0; + this.hash = hash_ !== undefined ? hash_ : 0; + this._$2 = _$2_ !== undefined ? _$2_ : 0; + this.align = align_ !== undefined ? align_ : 0; + this.fieldAlign = fieldAlign_ !== undefined ? fieldAlign_ : 0; + this.kind = kind_ !== undefined ? kind_ : 0; + this.alg = alg_ !== undefined ? alg_ : ($ptrType($Uintptr)).nil; + this.gc = gc_ !== undefined ? gc_ : 0; + this.string = string_ !== undefined ? string_ : ($ptrType($String)).nil; + this.uncommonType = uncommonType_ !== undefined ? uncommonType_ : ($ptrType(uncommonType)).nil; + this.ptrToThis = ptrToThis_ !== undefined ? ptrToThis_ : ($ptrType(rtype)).nil; + this.zero = zero_ !== undefined ? zero_ : 0; + }); + method = $pkg.method = $newType(0, "Struct", "reflect.method", "method", "reflect", function(name_, pkgPath_, mtyp_, typ_, ifn_, tfn_) { + this.$val = this; + this.name = name_ !== undefined ? name_ : ($ptrType($String)).nil; + this.pkgPath = pkgPath_ !== undefined ? pkgPath_ : ($ptrType($String)).nil; + this.mtyp = mtyp_ !== undefined ? mtyp_ : ($ptrType(rtype)).nil; + this.typ = typ_ !== undefined ? typ_ : ($ptrType(rtype)).nil; + this.ifn = ifn_ !== undefined ? ifn_ : 0; + this.tfn = tfn_ !== undefined ? tfn_ : 0; + }); + uncommonType = $pkg.uncommonType = $newType(0, "Struct", "reflect.uncommonType", "uncommonType", "reflect", function(name_, pkgPath_, methods_) { + this.$val = this; + this.name = name_ !== undefined ? name_ : ($ptrType($String)).nil; + this.pkgPath = pkgPath_ !== undefined ? pkgPath_ : ($ptrType($String)).nil; + this.methods = methods_ !== undefined ? methods_ : ($sliceType(method)).nil; + }); + ChanDir = $pkg.ChanDir = $newType(4, "Int", "reflect.ChanDir", "ChanDir", "reflect", null); + arrayType = $pkg.arrayType = $newType(0, "Struct", "reflect.arrayType", "arrayType", "reflect", function(rtype_, elem_, slice_, len_) { + this.$val = this; + this.rtype = rtype_ !== undefined ? rtype_ : new rtype.Ptr(); + this.elem = elem_ !== undefined ? elem_ : ($ptrType(rtype)).nil; + this.slice = slice_ !== undefined ? slice_ : ($ptrType(rtype)).nil; + this.len = len_ !== undefined ? len_ : 0; + }); + chanType = $pkg.chanType = $newType(0, "Struct", "reflect.chanType", "chanType", "reflect", function(rtype_, elem_, dir_) { + this.$val = this; + this.rtype = rtype_ !== undefined ? rtype_ : new rtype.Ptr(); + this.elem = elem_ !== undefined ? elem_ : ($ptrType(rtype)).nil; + this.dir = dir_ !== undefined ? dir_ : 0; + }); + funcType = $pkg.funcType = $newType(0, "Struct", "reflect.funcType", "funcType", "reflect", function(rtype_, dotdotdot_, in$2_, out_) { + this.$val = this; + this.rtype = rtype_ !== undefined ? rtype_ : new rtype.Ptr(); + this.dotdotdot = dotdotdot_ !== undefined ? dotdotdot_ : false; + this.in$2 = in$2_ !== undefined ? in$2_ : ($sliceType(($ptrType(rtype)))).nil; + this.out = out_ !== undefined ? out_ : ($sliceType(($ptrType(rtype)))).nil; + }); + imethod = $pkg.imethod = $newType(0, "Struct", "reflect.imethod", "imethod", "reflect", function(name_, pkgPath_, typ_) { + this.$val = this; + this.name = name_ !== undefined ? name_ : ($ptrType($String)).nil; + this.pkgPath = pkgPath_ !== undefined ? pkgPath_ : ($ptrType($String)).nil; + this.typ = typ_ !== undefined ? typ_ : ($ptrType(rtype)).nil; + }); + interfaceType = $pkg.interfaceType = $newType(0, "Struct", "reflect.interfaceType", "interfaceType", "reflect", function(rtype_, methods_) { + this.$val = this; + this.rtype = rtype_ !== undefined ? rtype_ : new rtype.Ptr(); + this.methods = methods_ !== undefined ? methods_ : ($sliceType(imethod)).nil; + }); + mapType = $pkg.mapType = $newType(0, "Struct", "reflect.mapType", "mapType", "reflect", function(rtype_, key_, elem_, bucket_, hmap_) { + this.$val = this; + this.rtype = rtype_ !== undefined ? rtype_ : new rtype.Ptr(); + this.key = key_ !== undefined ? key_ : ($ptrType(rtype)).nil; + this.elem = elem_ !== undefined ? elem_ : ($ptrType(rtype)).nil; + this.bucket = bucket_ !== undefined ? bucket_ : ($ptrType(rtype)).nil; + this.hmap = hmap_ !== undefined ? hmap_ : ($ptrType(rtype)).nil; + }); + ptrType = $pkg.ptrType = $newType(0, "Struct", "reflect.ptrType", "ptrType", "reflect", function(rtype_, elem_) { + this.$val = this; + this.rtype = rtype_ !== undefined ? rtype_ : new rtype.Ptr(); + this.elem = elem_ !== undefined ? elem_ : ($ptrType(rtype)).nil; + }); + sliceType = $pkg.sliceType = $newType(0, "Struct", "reflect.sliceType", "sliceType", "reflect", function(rtype_, elem_) { + this.$val = this; + this.rtype = rtype_ !== undefined ? rtype_ : new rtype.Ptr(); + this.elem = elem_ !== undefined ? elem_ : ($ptrType(rtype)).nil; + }); + structField = $pkg.structField = $newType(0, "Struct", "reflect.structField", "structField", "reflect", function(name_, pkgPath_, typ_, tag_, offset_) { + this.$val = this; + this.name = name_ !== undefined ? name_ : ($ptrType($String)).nil; + this.pkgPath = pkgPath_ !== undefined ? pkgPath_ : ($ptrType($String)).nil; + this.typ = typ_ !== undefined ? typ_ : ($ptrType(rtype)).nil; + this.tag = tag_ !== undefined ? tag_ : ($ptrType($String)).nil; + this.offset = offset_ !== undefined ? offset_ : 0; + }); + structType = $pkg.structType = $newType(0, "Struct", "reflect.structType", "structType", "reflect", function(rtype_, fields_) { + this.$val = this; + this.rtype = rtype_ !== undefined ? rtype_ : new rtype.Ptr(); + this.fields = fields_ !== undefined ? fields_ : ($sliceType(structField)).nil; + }); + Method = $pkg.Method = $newType(0, "Struct", "reflect.Method", "Method", "reflect", function(Name_, PkgPath_, Type_, Func_, Index_) { + this.$val = this; + this.Name = Name_ !== undefined ? Name_ : ""; + this.PkgPath = PkgPath_ !== undefined ? PkgPath_ : ""; + this.Type = Type_ !== undefined ? Type_ : $ifaceNil; + this.Func = Func_ !== undefined ? Func_ : new Value.Ptr(); + this.Index = Index_ !== undefined ? Index_ : 0; + }); + StructField = $pkg.StructField = $newType(0, "Struct", "reflect.StructField", "StructField", "reflect", function(Name_, PkgPath_, Type_, Tag_, Offset_, Index_, Anonymous_) { + this.$val = this; + this.Name = Name_ !== undefined ? Name_ : ""; + this.PkgPath = PkgPath_ !== undefined ? PkgPath_ : ""; + this.Type = Type_ !== undefined ? Type_ : $ifaceNil; + this.Tag = Tag_ !== undefined ? Tag_ : ""; + this.Offset = Offset_ !== undefined ? Offset_ : 0; + this.Index = Index_ !== undefined ? Index_ : ($sliceType($Int)).nil; + this.Anonymous = Anonymous_ !== undefined ? Anonymous_ : false; + }); + StructTag = $pkg.StructTag = $newType(8, "String", "reflect.StructTag", "StructTag", "reflect", null); + fieldScan = $pkg.fieldScan = $newType(0, "Struct", "reflect.fieldScan", "fieldScan", "reflect", function(typ_, index_) { + this.$val = this; + this.typ = typ_ !== undefined ? typ_ : ($ptrType(structType)).nil; + this.index = index_ !== undefined ? index_ : ($sliceType($Int)).nil; + }); + Value = $pkg.Value = $newType(0, "Struct", "reflect.Value", "Value", "reflect", function(typ_, ptr_, scalar_, flag_) { + this.$val = this; + this.typ = typ_ !== undefined ? typ_ : ($ptrType(rtype)).nil; + this.ptr = ptr_ !== undefined ? ptr_ : 0; + this.scalar = scalar_ !== undefined ? scalar_ : 0; + this.flag = flag_ !== undefined ? flag_ : 0; + }); + flag = $pkg.flag = $newType(4, "Uintptr", "reflect.flag", "flag", "reflect", null); + ValueError = $pkg.ValueError = $newType(0, "Struct", "reflect.ValueError", "ValueError", "reflect", function(Method_, Kind_) { + this.$val = this; + this.Method = Method_ !== undefined ? Method_ : ""; + this.Kind = Kind_ !== undefined ? Kind_ : 0; + }); + iword = $pkg.iword = $newType(4, "UnsafePointer", "reflect.iword", "iword", "reflect", null); + nonEmptyInterface = $pkg.nonEmptyInterface = $newType(0, "Struct", "reflect.nonEmptyInterface", "nonEmptyInterface", "reflect", function(itab_, word_) { + this.$val = this; + this.itab = itab_ !== undefined ? itab_ : ($ptrType(($structType([["ityp", "ityp", "reflect", ($ptrType(rtype)), ""], ["typ", "typ", "reflect", ($ptrType(rtype)), ""], ["link", "link", "reflect", $UnsafePointer, ""], ["bad", "bad", "reflect", $Int32, ""], ["unused", "unused", "reflect", $Int32, ""], ["fun", "fun", "reflect", ($arrayType($UnsafePointer, 100000)), ""]])))).nil; + this.word = word_ !== undefined ? word_ : 0; + }); + init = function() { + var used, x, x$1, x$2, x$3, x$4, x$5, x$6, x$7, x$8, x$9, x$10, x$11, x$12, pkg, _map, _key; + used = (function(i) { + }); + used((x = new rtype.Ptr(0, 0, 0, 0, 0, 0, ($ptrType($Uintptr)).nil, 0, ($ptrType($String)).nil, ($ptrType(uncommonType)).nil, ($ptrType(rtype)).nil, 0), new x.constructor.Struct(x))); + used((x$1 = new uncommonType.Ptr(($ptrType($String)).nil, ($ptrType($String)).nil, ($sliceType(method)).nil), new x$1.constructor.Struct(x$1))); + used((x$2 = new method.Ptr(($ptrType($String)).nil, ($ptrType($String)).nil, ($ptrType(rtype)).nil, ($ptrType(rtype)).nil, 0, 0), new x$2.constructor.Struct(x$2))); + used((x$3 = new arrayType.Ptr(new rtype.Ptr(), ($ptrType(rtype)).nil, ($ptrType(rtype)).nil, 0), new x$3.constructor.Struct(x$3))); + used((x$4 = new chanType.Ptr(new rtype.Ptr(), ($ptrType(rtype)).nil, 0), new x$4.constructor.Struct(x$4))); + used((x$5 = new funcType.Ptr(new rtype.Ptr(), false, ($sliceType(($ptrType(rtype)))).nil, ($sliceType(($ptrType(rtype)))).nil), new x$5.constructor.Struct(x$5))); + used((x$6 = new interfaceType.Ptr(new rtype.Ptr(), ($sliceType(imethod)).nil), new x$6.constructor.Struct(x$6))); + used((x$7 = new mapType.Ptr(new rtype.Ptr(), ($ptrType(rtype)).nil, ($ptrType(rtype)).nil, ($ptrType(rtype)).nil, ($ptrType(rtype)).nil), new x$7.constructor.Struct(x$7))); + used((x$8 = new ptrType.Ptr(new rtype.Ptr(), ($ptrType(rtype)).nil), new x$8.constructor.Struct(x$8))); + used((x$9 = new sliceType.Ptr(new rtype.Ptr(), ($ptrType(rtype)).nil), new x$9.constructor.Struct(x$9))); + used((x$10 = new structType.Ptr(new rtype.Ptr(), ($sliceType(structField)).nil), new x$10.constructor.Struct(x$10))); + used((x$11 = new imethod.Ptr(($ptrType($String)).nil, ($ptrType($String)).nil, ($ptrType(rtype)).nil), new x$11.constructor.Struct(x$11))); + used((x$12 = new structField.Ptr(($ptrType($String)).nil, ($ptrType($String)).nil, ($ptrType(rtype)).nil, ($ptrType($String)).nil, 0), new x$12.constructor.Struct(x$12))); + pkg = $pkg; + pkg.kinds = $externalize((_map = new $Map(), _key = "Bool", _map[_key] = { k: _key, v: 1 }, _key = "Int", _map[_key] = { k: _key, v: 2 }, _key = "Int8", _map[_key] = { k: _key, v: 3 }, _key = "Int16", _map[_key] = { k: _key, v: 4 }, _key = "Int32", _map[_key] = { k: _key, v: 5 }, _key = "Int64", _map[_key] = { k: _key, v: 6 }, _key = "Uint", _map[_key] = { k: _key, v: 7 }, _key = "Uint8", _map[_key] = { k: _key, v: 8 }, _key = "Uint16", _map[_key] = { k: _key, v: 9 }, _key = "Uint32", _map[_key] = { k: _key, v: 10 }, _key = "Uint64", _map[_key] = { k: _key, v: 11 }, _key = "Uintptr", _map[_key] = { k: _key, v: 12 }, _key = "Float32", _map[_key] = { k: _key, v: 13 }, _key = "Float64", _map[_key] = { k: _key, v: 14 }, _key = "Complex64", _map[_key] = { k: _key, v: 15 }, _key = "Complex128", _map[_key] = { k: _key, v: 16 }, _key = "Array", _map[_key] = { k: _key, v: 17 }, _key = "Chan", _map[_key] = { k: _key, v: 18 }, _key = "Func", _map[_key] = { k: _key, v: 19 }, _key = "Interface", _map[_key] = { k: _key, v: 20 }, _key = "Map", _map[_key] = { k: _key, v: 21 }, _key = "Ptr", _map[_key] = { k: _key, v: 22 }, _key = "Slice", _map[_key] = { k: _key, v: 23 }, _key = "String", _map[_key] = { k: _key, v: 24 }, _key = "Struct", _map[_key] = { k: _key, v: 25 }, _key = "UnsafePointer", _map[_key] = { k: _key, v: 26 }, _map), ($mapType($String, Kind))); + pkg.RecvDir = 1; + pkg.SendDir = 2; + pkg.BothDir = 3; + $reflect = pkg; + initialized = true; + uint8Type = $assertType(TypeOf(new $Uint8(0)), ($ptrType(rtype))); + }; + jsType = function(typ) { + return typ.jsType; + }; + reflectType = function(typ) { + return typ.reflectType(); + }; + isWrapped = function(typ) { + var _ref; + _ref = typ.Kind(); + if (_ref === 1 || _ref === 2 || _ref === 3 || _ref === 4 || _ref === 5 || _ref === 7 || _ref === 8 || _ref === 9 || _ref === 10 || _ref === 12 || _ref === 13 || _ref === 14 || _ref === 17 || _ref === 21 || _ref === 19 || _ref === 24 || _ref === 25) { + return true; + } else if (_ref === 22) { + return typ.Elem().Kind() === 17; } - newSlice = new (jsType(v.typ))(s.$array); - newSlice.$offset = s.$offset; - newSlice.$length = s.$length; - newSlice.$capacity = n; - v.ptr.$set(newSlice); + return false; }; - Value.prototype.SetCap = function(n) { return this.$val.SetCap(n); }; - Value.Ptr.prototype.SetLen = function(n) { - var v, s, newSlice; - v = new Value.Ptr(); $copy(v, this, Value); - (new flag(v.flag)).mustBeAssignable(); - (new flag(v.flag)).mustBe(23); - s = v.ptr.$get(); - if (n < 0 || n > ($parseInt(s.$capacity) >> 0)) { - $panic(new $String("reflect: slice length out of range in SetLen")); + copyStruct = function(dst, src, typ) { + var fields, i, name; + fields = jsType(typ).fields; + i = 0; + while (i < $parseInt(fields.length)) { + name = $internalize(fields[i][0], $String); + dst[$externalize(name, $String)] = src[$externalize(name, $String)]; + i = i + (1) >> 0; } - newSlice = new (jsType(v.typ))(s.$array); - newSlice.$offset = s.$offset; - newSlice.$length = n; - newSlice.$capacity = s.$capacity; - v.ptr.$set(newSlice); }; - Value.prototype.SetLen = function(n) { return this.$val.SetLen(n); }; - Value.Ptr.prototype.Slice = function(i, j) { - var v, cap, typ, s, kind, _ref, tt, str; - v = new Value.Ptr(); $copy(v, this, Value); - cap = 0; - typ = $ifaceNil; - s = $ifaceNil; - kind = (new flag(v.flag)).kind(); - _ref = kind; - if (_ref === 17) { - if (((v.flag & 4) >>> 0) === 0) { - $panic(new $String("reflect.Value.Slice: slice of unaddressable array")); - } - tt = v.typ.arrayType; - cap = (tt.len >> 0); - typ = SliceOf(tt.elem); - s = new (jsType(typ))(v.iword()); - } else if (_ref === 23) { - typ = v.typ; - s = v.iword(); - cap = $parseInt(s.$capacity) >> 0; - } else if (_ref === 24) { - str = v.ptr.$get(); - if (i < 0 || j < i || j > str.length) { - $panic(new $String("reflect.Value.Slice: string slice index out of bounds")); - } - return ValueOf(new $String(str.substring(i, j))); - } else { - $panic(new ValueError.Ptr("reflect.Value.Slice", kind)); + makeValue = function(t, v, fl) { + var rt; + rt = t.common(); + if ((t.Kind() === 17) || (t.Kind() === 25) || rt.pointers()) { + return new Value.Ptr(rt, v, 0, (fl | ((t.Kind() >>> 0) << 4 >>> 0)) >>> 0); } - if (i < 0 || j < i || j > cap) { - $panic(new $String("reflect.Value.Slice: slice index out of bounds")); + if (t.Size() > 4 || (t.Kind() === 24)) { + return new Value.Ptr(rt, $newDataPointer(v, jsType(rt.ptrTo())), 0, (((fl | ((t.Kind() >>> 0) << 4 >>> 0)) >>> 0) | 2) >>> 0); } - return makeValue(typ, $subslice(s, i, j), (v.flag & 1) >>> 0); + return new Value.Ptr(rt, 0, v, (fl | ((t.Kind() >>> 0) << 4 >>> 0)) >>> 0); }; - Value.prototype.Slice = function(i, j) { return this.$val.Slice(i, j); }; - Value.Ptr.prototype.Slice3 = function(i, j, k) { - var v, cap, typ, s, kind, _ref, tt; - v = new Value.Ptr(); $copy(v, this, Value); - cap = 0; - typ = $ifaceNil; - s = $ifaceNil; - kind = (new flag(v.flag)).kind(); - _ref = kind; - if (_ref === 17) { - if (((v.flag & 4) >>> 0) === 0) { - $panic(new $String("reflect.Value.Slice: slice of unaddressable array")); - } - tt = v.typ.arrayType; - cap = (tt.len >> 0); - typ = SliceOf(tt.elem); - s = new (jsType(typ))(v.iword()); - } else if (_ref === 23) { - typ = v.typ; - s = v.iword(); - cap = $parseInt(s.$capacity) >> 0; - } else { - $panic(new ValueError.Ptr("reflect.Value.Slice3", kind)); + MakeSlice = $pkg.MakeSlice = function(typ, len, cap) { + if (!((typ.Kind() === 23))) { + $panic(new $String("reflect.MakeSlice of non-slice type")); } - if (i < 0 || j < i || k < j || k > cap) { - $panic(new $String("reflect.Value.Slice3: slice index out of bounds")); + if (len < 0) { + $panic(new $String("reflect.MakeSlice: negative len")); } - return makeValue(typ, $subslice(s, i, j, k), (v.flag & 1) >>> 0); - }; - Value.prototype.Slice3 = function(i, j, k) { return this.$val.Slice3(i, j, k); }; - Value.Ptr.prototype.Close = function() { - var v; - v = new Value.Ptr(); $copy(v, this, Value); - (new flag(v.flag)).mustBe(18); - (new flag(v.flag)).mustBeExported(); - $close(v.iword()); - }; - Value.prototype.Close = function() { return this.$val.Close(); }; - Value.Ptr.prototype.TrySend = function(x) { - var v, tt, c; - v = new Value.Ptr(); $copy(v, this, Value); - (new flag(v.flag)).mustBe(18); - (new flag(v.flag)).mustBeExported(); - tt = v.typ.chanType; - if (((tt.dir >> 0) & 2) === 0) { - $panic(new $String("reflect: send on recv-only channel")); + if (cap < 0) { + $panic(new $String("reflect.MakeSlice: negative cap")); } - (new flag(x.flag)).mustBeExported(); - c = v.iword(); - if (!!!(c.$closed) && ($parseInt(c.$recvQueue.length) === 0) && ($parseInt(c.$buffer.length) === ($parseInt(c.$capacity) >> 0))) { - return false; + if (len > cap) { + $panic(new $String("reflect.MakeSlice: len > cap")); } - $copy(x, x.assignTo("reflect.Value.Send", tt.elem, ($ptrType($emptyInterface)).nil), Value); - $send(c, x.iword()); - return true; + return makeValue(typ, jsType(typ).make(len, cap, $externalize((function() { + return jsType(typ.Elem()).zero(); + }), ($funcType([], [js.Object], false)))), 0); }; - Value.prototype.TrySend = function(x) { return this.$val.TrySend(x); }; - Value.Ptr.prototype.Send = function(x) { - var v; - v = new Value.Ptr(); $copy(v, this, Value); - $panic(new runtime.NotSupportedError.Ptr("reflect.Value.Send, use reflect.Value.TrySend is possible")); + jsObject = function() { + return reflectType($packages[$externalize("github.com/gopherjs/gopherjs/js", $String)].Object); }; - Value.prototype.Send = function(x) { return this.$val.Send(x); }; - Value.Ptr.prototype.TryRecv = function() { - var x = new Value.Ptr(), ok = false, v, tt, res, _tmp, _tmp$1, _tmp$2, _tmp$3; - v = new Value.Ptr(); $copy(v, this, Value); - (new flag(v.flag)).mustBe(18); - (new flag(v.flag)).mustBeExported(); - tt = v.typ.chanType; - if (((tt.dir >> 0) & 1) === 0) { - $panic(new $String("reflect: recv on send-only channel")); + TypeOf = $pkg.TypeOf = function(i) { + var c; + if (!initialized) { + return new rtype.Ptr(0, 0, 0, 0, 0, 0, ($ptrType($Uintptr)).nil, 0, ($ptrType($String)).nil, ($ptrType(uncommonType)).nil, ($ptrType(rtype)).nil, 0); } - res = $recv(v.iword()); - if (res.constructor === $global.Function) { - _tmp = new Value.Ptr(($ptrType(rtype)).nil, 0, 0, 0); _tmp$1 = false; $copy(x, _tmp, Value); ok = _tmp$1; - return [x, ok]; + if ($interfaceIsEqual(i, $ifaceNil)) { + return $ifaceNil; } - _tmp$2 = new Value.Ptr(); $copy(_tmp$2, makeValue(tt.elem, res[0], 0), Value); _tmp$3 = !!(res[1]); $copy(x, _tmp$2, Value); ok = _tmp$3; - return [x, ok]; - }; - Value.prototype.TryRecv = function() { return this.$val.TryRecv(); }; - Value.Ptr.prototype.Recv = function() { - var x = new Value.Ptr(), ok = false, v; - v = new Value.Ptr(); $copy(v, this, Value); - $panic(new runtime.NotSupportedError.Ptr("reflect.Value.Recv, use reflect.Value.TryRecv is possible")); - }; - Value.prototype.Recv = function() { return this.$val.Recv(); }; - Kind.prototype.String = function() { - var k; - k = this.$val !== undefined ? this.$val : this; - if ((k >> 0) < kindNames.$length) { - return ((k < 0 || k >= kindNames.$length) ? $throwRuntimeError("index out of range") : kindNames.$array[kindNames.$offset + k]); + c = i.constructor; + if (c.kind === undefined) { + return jsObject(); } - return "kind" + strconv.Itoa((k >> 0)); - }; - $ptrType(Kind).prototype.String = function() { return new Kind(this.$get()).String(); }; - uncommonType.Ptr.prototype.uncommon = function() { - var t; - t = this; - return t; + return reflectType(c); }; - uncommonType.prototype.uncommon = function() { return this.$val.uncommon(); }; - uncommonType.Ptr.prototype.PkgPath = function() { - var t; - t = this; - if (t === ($ptrType(uncommonType)).nil || $pointerIsEqual(t.pkgPath, ($ptrType($String)).nil)) { - return ""; + ValueOf = $pkg.ValueOf = function(i) { + var c; + if ($interfaceIsEqual(i, $ifaceNil)) { + return new Value.Ptr(($ptrType(rtype)).nil, 0, 0, 0); } - return t.pkgPath.$get(); - }; - uncommonType.prototype.PkgPath = function() { return this.$val.PkgPath(); }; - uncommonType.Ptr.prototype.Name = function() { - var t; - t = this; - if (t === ($ptrType(uncommonType)).nil || $pointerIsEqual(t.name, ($ptrType($String)).nil)) { - return ""; + c = i.constructor; + if (c.kind === undefined) { + return new Value.Ptr(jsObject(), 0, i, 320); } - return t.name.$get(); + return makeValue(reflectType(c), i.$val, 0); }; - uncommonType.prototype.Name = function() { return this.$val.Name(); }; - rtype.Ptr.prototype.String = function() { + rtype.Ptr.prototype.ptrTo = function() { var t; t = this; - return t.string.$get(); + return reflectType($ptrType(jsType(t))); }; - rtype.prototype.String = function() { return this.$val.String(); }; - rtype.Ptr.prototype.Size = function() { - var t; - t = this; - return t.size; + rtype.prototype.ptrTo = function() { return this.$val.ptrTo(); }; + SliceOf = $pkg.SliceOf = function(t) { + return reflectType($sliceType(jsType(t))); }; - rtype.prototype.Size = function() { return this.$val.Size(); }; - rtype.Ptr.prototype.Bits = function() { - var t, k, x; - t = this; - if (t === ($ptrType(rtype)).nil) { - $panic(new $String("reflect: Bits of nil Type")); - } - k = t.Kind(); - if (k < 2 || k > 16) { - $panic(new $String("reflect: Bits of non-arithmetic Type " + t.String())); + Zero = $pkg.Zero = function(typ) { + return makeValue(typ, jsType(typ).zero(), 0); + }; + unsafe_New = function(typ) { + var _ref; + _ref = typ.Kind(); + if (_ref === 25) { + return new (jsType(typ).Ptr)(); + } else if (_ref === 17) { + return jsType(typ).zero(); + } else { + return $newDataPointer(jsType(typ).zero(), jsType(typ.ptrTo())); } - return (x = (t.size >> 0), (((x >>> 16 << 16) * 8 >> 0) + (x << 16 >>> 16) * 8) >> 0); }; - rtype.prototype.Bits = function() { return this.$val.Bits(); }; - rtype.Ptr.prototype.Align = function() { - var t; - t = this; - return (t.align >> 0); + makeInt = function(f, bits, t) { + var typ, ptr, s, _ref; + typ = t.common(); + if (typ.size > 4) { + ptr = unsafe_New(typ); + ptr.$set(bits); + return new Value.Ptr(typ, ptr, 0, (((f | 2) >>> 0) | ((typ.Kind() >>> 0) << 4 >>> 0)) >>> 0); + } + s = 0; + _ref = typ.Kind(); + if (_ref === 3) { + new ($ptrType($Uintptr))(function() { return s; }, function($v) { s = $v; }).$set((bits.$low << 24 >> 24)); + } else if (_ref === 4) { + new ($ptrType($Uintptr))(function() { return s; }, function($v) { s = $v; }).$set((bits.$low << 16 >> 16)); + } else if (_ref === 2 || _ref === 5) { + new ($ptrType($Uintptr))(function() { return s; }, function($v) { s = $v; }).$set((bits.$low >> 0)); + } else if (_ref === 8) { + new ($ptrType($Uintptr))(function() { return s; }, function($v) { s = $v; }).$set((bits.$low << 24 >>> 24)); + } else if (_ref === 9) { + new ($ptrType($Uintptr))(function() { return s; }, function($v) { s = $v; }).$set((bits.$low << 16 >>> 16)); + } else if (_ref === 7 || _ref === 10 || _ref === 12) { + new ($ptrType($Uintptr))(function() { return s; }, function($v) { s = $v; }).$set((bits.$low >>> 0)); + } + return new Value.Ptr(typ, 0, s, (f | ((typ.Kind() >>> 0) << 4 >>> 0)) >>> 0); }; - rtype.prototype.Align = function() { return this.$val.Align(); }; - rtype.Ptr.prototype.FieldAlign = function() { - var t; - t = this; - return (t.fieldAlign >> 0); + memmove = function(adst, asrc, n) { + adst.$set(asrc.$get()); }; - rtype.prototype.FieldAlign = function() { return this.$val.FieldAlign(); }; - rtype.Ptr.prototype.Kind = function() { - var t; - t = this; - return (((t.kind & 127) >>> 0) >>> 0); + loadScalar = function(p, n) { + return p.$get(); }; - rtype.prototype.Kind = function() { return this.$val.Kind(); }; - rtype.Ptr.prototype.common = function() { - var t; - t = this; - return t; + makemap = function(t) { + var m = 0; + m = new ($Map)(); + return m; }; - rtype.prototype.common = function() { return this.$val.common(); }; - uncommonType.Ptr.prototype.NumMethod = function() { - var t; - t = this; - if (t === ($ptrType(uncommonType)).nil) { + mapaccess = function(t, m, key) { + var k, entry; + k = key.$get(); + if (!(k.$key === undefined)) { + k = k.$key(); + } + entry = m[$externalize($internalize(k, $String), $String)]; + if (entry === undefined) { return 0; } - return t.methods.$length; + return $newDataPointer(entry.v, jsType(PtrTo(t.Elem()))); }; - uncommonType.prototype.NumMethod = function() { return this.$val.NumMethod(); }; - uncommonType.Ptr.prototype.MethodByName = function(name) { - var m = new Method.Ptr(), ok = false, t, p, _ref, _i, i, x, _tmp, _tmp$1; - t = this; - if (t === ($ptrType(uncommonType)).nil) { - return [m, ok]; + mapassign = function(t, m, key, val) { + var kv, k, jsVal, et, newVal, entry; + kv = key.$get(); + k = kv; + if (!(k.$key === undefined)) { + k = k.$key(); } - p = ($ptrType(method)).nil; - _ref = t.methods; - _i = 0; - while (_i < _ref.$length) { - i = _i; - p = (x = t.methods, ((i < 0 || i >= x.$length) ? $throwRuntimeError("index out of range") : x.$array[x.$offset + i])); - if (!($pointerIsEqual(p.name, ($ptrType($String)).nil)) && p.name.$get() === name) { - _tmp = new Method.Ptr(); $copy(_tmp, t.Method(i), Method); _tmp$1 = true; $copy(m, _tmp, Method); ok = _tmp$1; - return [m, ok]; - } - _i++; + jsVal = val.$get(); + et = t.Elem(); + if (et.Kind() === 25) { + newVal = jsType(et).zero(); + copyStruct(newVal, jsVal, et); + jsVal = newVal; } - return [m, ok]; + entry = new ($global.Object)(); + entry.k = kv; + entry.v = jsVal; + m[$externalize($internalize(k, $String), $String)] = entry; }; - uncommonType.prototype.MethodByName = function(name) { return this.$val.MethodByName(name); }; - rtype.Ptr.prototype.NumMethod = function() { - var t, tt; - t = this; - if (t.Kind() === 20) { - tt = t.interfaceType; - return tt.NumMethod(); + mapdelete = function(t, m, key) { + var k; + k = key.$get(); + if (!(k.$key === undefined)) { + k = k.$key(); } - return t.uncommonType.NumMethod(); + delete m[$externalize($internalize(k, $String), $String)]; }; - rtype.prototype.NumMethod = function() { return this.$val.NumMethod(); }; - rtype.Ptr.prototype.Method = function(i) { - var m = new Method.Ptr(), t, tt; - t = this; - if (t.Kind() === 20) { - tt = t.interfaceType; - $copy(m, tt.Method(i), Method); - return m; - } - $copy(m, t.uncommonType.Method(i), Method); - return m; + mapiterinit = function(t, m) { + return new mapIter.Ptr(t, m, $keys(m), 0); }; - rtype.prototype.Method = function(i) { return this.$val.Method(i); }; - rtype.Ptr.prototype.MethodByName = function(name) { - var m = new Method.Ptr(), ok = false, t, tt, _tuple, _tuple$1; - t = this; - if (t.Kind() === 20) { - tt = t.interfaceType; - _tuple = tt.MethodByName(name); $copy(m, _tuple[0], Method); ok = _tuple[1]; - return [m, ok]; - } - _tuple$1 = t.uncommonType.MethodByName(name); $copy(m, _tuple$1[0], Method); ok = _tuple$1[1]; - return [m, ok]; + mapiterkey = function(it) { + var iter, k; + iter = it; + k = iter.keys[iter.i]; + return $newDataPointer(iter.m[$externalize($internalize(k, $String), $String)].k, jsType(PtrTo(iter.t.Key()))); }; - rtype.prototype.MethodByName = function(name) { return this.$val.MethodByName(name); }; - rtype.Ptr.prototype.PkgPath = function() { - var t; - t = this; - return t.uncommonType.PkgPath(); + mapiternext = function(it) { + var iter; + iter = it; + iter.i = iter.i + (1) >> 0; }; - rtype.prototype.PkgPath = function() { return this.$val.PkgPath(); }; - rtype.Ptr.prototype.Name = function() { - var t; - t = this; - return t.uncommonType.Name(); + maplen = function(m) { + return $parseInt($keys(m).length); }; - rtype.prototype.Name = function() { return this.$val.Name(); }; - rtype.Ptr.prototype.ChanDir = function() { - var t, tt; - t = this; - if (!((t.Kind() === 18))) { - $panic(new $String("reflect: ChanDir of non-chan type")); + cvtDirect = function(v, typ) { + var srcVal, val, k, _ref, slice; + srcVal = v.iword(); + if (srcVal === jsType(v.typ).nil) { + return makeValue(typ, jsType(typ).nil, v.flag); } - tt = t.chanType; - return (tt.dir >> 0); + val = $ifaceNil; + k = typ.Kind(); + _ref = k; + switch (0) { default: if (_ref === 18) { + val = new (jsType(typ))(); + } else if (_ref === 23) { + slice = new (jsType(typ))(srcVal.$array); + slice.$offset = srcVal.$offset; + slice.$length = srcVal.$length; + slice.$capacity = srcVal.$capacity; + val = $newDataPointer(slice, jsType(PtrTo(typ))); + } else if (_ref === 22) { + if (typ.Elem().Kind() === 25) { + if ($interfaceIsEqual(typ.Elem(), v.typ.Elem())) { + val = srcVal; + break; + } + val = new (jsType(typ))(); + copyStruct(val, srcVal, typ.Elem()); + break; + } + val = new (jsType(typ))(srcVal.$get, srcVal.$set); + } else if (_ref === 25) { + val = new (jsType(typ).Ptr)(); + copyStruct(val, srcVal, typ); + } else if (_ref === 17 || _ref === 19 || _ref === 20 || _ref === 21 || _ref === 24) { + val = v.ptr; + } else { + $panic(new ValueError.Ptr("reflect.Convert", k)); + } } + return new Value.Ptr(typ.common(), val, 0, (((v.flag & 3) >>> 0) | ((typ.Kind() >>> 0) << 4 >>> 0)) >>> 0); }; - rtype.prototype.ChanDir = function() { return this.$val.ChanDir(); }; - rtype.Ptr.prototype.IsVariadic = function() { - var t, tt; - t = this; - if (!((t.Kind() === 19))) { - $panic(new $String("reflect: IsVariadic of non-func type")); + Copy = $pkg.Copy = function(dst, src) { + var dk, sk, dstVal, srcVal; + dk = (new flag(dst.flag)).kind(); + if (!((dk === 17)) && !((dk === 23))) { + $panic(new ValueError.Ptr("reflect.Copy", dk)); } - tt = t.funcType; - return tt.dotdotdot; - }; - rtype.prototype.IsVariadic = function() { return this.$val.IsVariadic(); }; - rtype.Ptr.prototype.Elem = function() { - var t, _ref, tt, tt$1, tt$2, tt$3, tt$4; - t = this; - _ref = t.Kind(); - if (_ref === 17) { - tt = t.arrayType; - return toType(tt.elem); - } else if (_ref === 18) { - tt$1 = t.chanType; - return toType(tt$1.elem); - } else if (_ref === 21) { - tt$2 = t.mapType; - return toType(tt$2.elem); - } else if (_ref === 22) { - tt$3 = t.ptrType; - return toType(tt$3.elem); - } else if (_ref === 23) { - tt$4 = t.sliceType; - return toType(tt$4.elem); + if (dk === 17) { + (new flag(dst.flag)).mustBeAssignable(); } - $panic(new $String("reflect: Elem of invalid type")); - }; - rtype.prototype.Elem = function() { return this.$val.Elem(); }; - rtype.Ptr.prototype.Field = function(i) { - var t, tt; - t = this; - if (!((t.Kind() === 25))) { - $panic(new $String("reflect: Field of non-struct type")); + (new flag(dst.flag)).mustBeExported(); + sk = (new flag(src.flag)).kind(); + if (!((sk === 17)) && !((sk === 23))) { + $panic(new ValueError.Ptr("reflect.Copy", sk)); } - tt = t.structType; - return tt.Field(i); - }; - rtype.prototype.Field = function(i) { return this.$val.Field(i); }; - rtype.Ptr.prototype.FieldByIndex = function(index) { - var t, tt; - t = this; - if (!((t.Kind() === 25))) { - $panic(new $String("reflect: FieldByIndex of non-struct type")); + (new flag(src.flag)).mustBeExported(); + typesMustMatch("reflect.Copy", dst.typ.Elem(), src.typ.Elem()); + dstVal = dst.iword(); + if (dk === 17) { + dstVal = new (jsType(SliceOf(dst.typ.Elem())))(dstVal); } - tt = t.structType; - return tt.FieldByIndex(index); - }; - rtype.prototype.FieldByIndex = function(index) { return this.$val.FieldByIndex(index); }; - rtype.Ptr.prototype.FieldByName = function(name) { - var t, tt; - t = this; - if (!((t.Kind() === 25))) { - $panic(new $String("reflect: FieldByName of non-struct type")); + srcVal = src.iword(); + if (sk === 17) { + srcVal = new (jsType(SliceOf(src.typ.Elem())))(srcVal); } - tt = t.structType; - return tt.FieldByName(name); + return $parseInt($copySlice(dstVal, srcVal)) >> 0; }; - rtype.prototype.FieldByName = function(name) { return this.$val.FieldByName(name); }; - rtype.Ptr.prototype.FieldByNameFunc = function(match) { - var t, tt; - t = this; - if (!((t.Kind() === 25))) { - $panic(new $String("reflect: FieldByNameFunc of non-struct type")); + methodReceiver = function(op, v, i) { + var rcvrtype = ($ptrType(rtype)).nil, t = ($ptrType(rtype)).nil, fn = 0, name, tt, x, m, iface, ut, x$1, m$1, rcvr; + name = ""; + if (v.typ.Kind() === 20) { + tt = v.typ.interfaceType; + if (i < 0 || i >= tt.methods.$length) { + $panic(new $String("reflect: internal error: invalid method index")); + } + m = (x = tt.methods, ((i < 0 || i >= x.$length) ? $throwRuntimeError("index out of range") : x.$array[x.$offset + i])); + if (!($pointerIsEqual(m.pkgPath, ($ptrType($String)).nil))) { + $panic(new $String("reflect: " + op + " of unexported method")); + } + iface = $clone(v.ptr, nonEmptyInterface); + if (iface.itab === ($ptrType(($structType([["ityp", "ityp", "reflect", ($ptrType(rtype)), ""], ["typ", "typ", "reflect", ($ptrType(rtype)), ""], ["link", "link", "reflect", $UnsafePointer, ""], ["bad", "bad", "reflect", $Int32, ""], ["unused", "unused", "reflect", $Int32, ""], ["fun", "fun", "reflect", ($arrayType($UnsafePointer, 100000)), ""]])))).nil) { + $panic(new $String("reflect: " + op + " of method on nil interface value")); + } + t = m.typ; + name = m.name.$get(); + } else { + ut = v.typ.uncommonType.uncommon(); + if (ut === ($ptrType(uncommonType)).nil || i < 0 || i >= ut.methods.$length) { + $panic(new $String("reflect: internal error: invalid method index")); + } + m$1 = (x$1 = ut.methods, ((i < 0 || i >= x$1.$length) ? $throwRuntimeError("index out of range") : x$1.$array[x$1.$offset + i])); + if (!($pointerIsEqual(m$1.pkgPath, ($ptrType($String)).nil))) { + $panic(new $String("reflect: " + op + " of unexported method")); + } + t = m$1.mtyp; + name = $internalize(jsType(v.typ).methods[i][0], $String); } - tt = t.structType; - return tt.FieldByNameFunc(match); - }; - rtype.prototype.FieldByNameFunc = function(match) { return this.$val.FieldByNameFunc(match); }; - rtype.Ptr.prototype.In = function(i) { - var t, tt, x; - t = this; - if (!((t.Kind() === 19))) { - $panic(new $String("reflect: In of non-func type")); + rcvr = v.iword(); + if (isWrapped(v.typ)) { + rcvr = new (jsType(v.typ))(rcvr); } - tt = t.funcType; - return toType((x = tt.in$2, ((i < 0 || i >= x.$length) ? $throwRuntimeError("index out of range") : x.$array[x.$offset + i]))); + fn = rcvr[$externalize(name, $String)]; + return [rcvrtype, t, fn]; }; - rtype.prototype.In = function(i) { return this.$val.In(i); }; - rtype.Ptr.prototype.Key = function() { - var t, tt; - t = this; - if (!((t.Kind() === 21))) { - $panic(new $String("reflect: Key of non-map type")); + valueInterface = function(v, safe) { + if (v.flag === 0) { + $panic(new ValueError.Ptr("reflect.Value.Interface", 0)); } - tt = t.mapType; - return toType(tt.key); - }; - rtype.prototype.Key = function() { return this.$val.Key(); }; - rtype.Ptr.prototype.Len = function() { - var t, tt; - t = this; - if (!((t.Kind() === 17))) { - $panic(new $String("reflect: Len of non-array type")); + if (safe && !((((v.flag & 1) >>> 0) === 0))) { + $panic(new $String("reflect.Value.Interface: cannot return value obtained from unexported field or method")); } - tt = t.arrayType; - return (tt.len >> 0); - }; - rtype.prototype.Len = function() { return this.$val.Len(); }; - rtype.Ptr.prototype.NumField = function() { - var t, tt; - t = this; - if (!((t.Kind() === 25))) { - $panic(new $String("reflect: NumField of non-struct type")); + if (!((((v.flag & 8) >>> 0) === 0))) { + $copy(v, makeMethodValue("Interface", $clone(v, Value)), Value); } - tt = t.structType; - return tt.fields.$length; - }; - rtype.prototype.NumField = function() { return this.$val.NumField(); }; - rtype.Ptr.prototype.NumIn = function() { - var t, tt; - t = this; - if (!((t.Kind() === 19))) { - $panic(new $String("reflect: NumIn of non-func type")); + if (isWrapped(v.typ)) { + return new (jsType(v.typ))(v.iword()); } - tt = t.funcType; - return tt.in$2.$length; + return v.iword(); }; - rtype.prototype.NumIn = function() { return this.$val.NumIn(); }; - rtype.Ptr.prototype.NumOut = function() { - var t, tt; - t = this; - if (!((t.Kind() === 19))) { - $panic(new $String("reflect: NumOut of non-func type")); - } - tt = t.funcType; - return tt.out.$length; + ifaceE2I = function(t, src, dst) { + dst.$set(src); }; - rtype.prototype.NumOut = function() { return this.$val.NumOut(); }; - rtype.Ptr.prototype.Out = function(i) { - var t, tt, x; - t = this; - if (!((t.Kind() === 19))) { - $panic(new $String("reflect: Out of non-func type")); + methodName = function() { + return "?FIXME?"; + }; + makeMethodValue = function(op, v) { + var _tuple, fn, rcvr, fv; + if (((v.flag & 8) >>> 0) === 0) { + $panic(new $String("reflect: internal error: invalid use of makePartialFunc")); } - tt = t.funcType; - return toType((x = tt.out, ((i < 0 || i >= x.$length) ? $throwRuntimeError("index out of range") : x.$array[x.$offset + i]))); + _tuple = methodReceiver(op, $clone(v, Value), (v.flag >> 0) >> 9 >> 0); fn = _tuple[2]; + rcvr = v.iword(); + if (isWrapped(v.typ)) { + rcvr = new (jsType(v.typ))(rcvr); + } + fv = (function() { + return fn.apply(rcvr, $externalize(new ($sliceType(js.Object))($global.Array.prototype.slice.call(arguments, [])), ($sliceType(js.Object)))); + }); + return new Value.Ptr(v.Type().common(), fv, 0, (((v.flag & 1) >>> 0) | 304) >>> 0); }; - rtype.prototype.Out = function(i) { return this.$val.Out(i); }; - ChanDir.prototype.String = function() { - var d, _ref; - d = this.$val !== undefined ? this.$val : this; - _ref = d; - if (_ref === 2) { - return "chan<-"; - } else if (_ref === 1) { - return "<-chan"; - } else if (_ref === 3) { - return "chan"; + rtype.Ptr.prototype.pointers = function() { + var t, _ref; + t = this; + _ref = t.Kind(); + if (_ref === 22 || _ref === 21 || _ref === 18 || _ref === 19 || _ref === 25 || _ref === 17) { + return true; + } else { + return false; } - return "ChanDir" + strconv.Itoa((d >> 0)); }; - $ptrType(ChanDir).prototype.String = function() { return new ChanDir(this.$get()).String(); }; - interfaceType.Ptr.prototype.Method = function(i) { - var m = new Method.Ptr(), t, x, p; + rtype.prototype.pointers = function() { return this.$val.pointers(); }; + uncommonType.Ptr.prototype.Method = function(i) { + var m = new Method.Ptr(), t, x, p, fl, mt, name, fn; t = this; - if (i < 0 || i >= t.methods.$length) { - return m; + if (t === ($ptrType(uncommonType)).nil || i < 0 || i >= t.methods.$length) { + $panic(new $String("reflect: Method index out of range")); } p = (x = t.methods, ((i < 0 || i >= x.$length) ? $throwRuntimeError("index out of range") : x.$array[x.$offset + i])); - m.Name = p.name.$get(); + if (!($pointerIsEqual(p.name, ($ptrType($String)).nil))) { + m.Name = p.name.$get(); + } + fl = 304; if (!($pointerIsEqual(p.pkgPath, ($ptrType($String)).nil))) { m.PkgPath = p.pkgPath.$get(); + fl = (fl | (1)) >>> 0; } - m.Type = toType(p.typ); + mt = p.typ; + m.Type = mt; + name = $internalize(t.jsType.methods[i][0], $String); + fn = (function(rcvr) { + return rcvr[$externalize(name, $String)].apply(rcvr, $externalize($subslice(new ($sliceType(js.Object))($global.Array.prototype.slice.call(arguments, [])), 1), ($sliceType(js.Object)))); + }); + $copy(m.Func, new Value.Ptr(mt, fn, 0, fl), Value); m.Index = i; return m; }; - interfaceType.prototype.Method = function(i) { return this.$val.Method(i); }; - interfaceType.Ptr.prototype.NumMethod = function() { - var t; - t = this; - return t.methods.$length; - }; - interfaceType.prototype.NumMethod = function() { return this.$val.NumMethod(); }; - interfaceType.Ptr.prototype.MethodByName = function(name) { - var m = new Method.Ptr(), ok = false, t, p, _ref, _i, i, x, _tmp, _tmp$1; - t = this; - if (t === ($ptrType(interfaceType)).nil) { - return [m, ok]; + uncommonType.prototype.Method = function(i) { return this.$val.Method(i); }; + Value.Ptr.prototype.iword = function() { + var v, val, _ref, newVal; + v = new Value.Ptr(); $copy(v, this, Value); + if ((v.typ.Kind() === 17) || (v.typ.Kind() === 25)) { + return v.ptr; } - p = ($ptrType(imethod)).nil; - _ref = t.methods; - _i = 0; - while (_i < _ref.$length) { - i = _i; - p = (x = t.methods, ((i < 0 || i >= x.$length) ? $throwRuntimeError("index out of range") : x.$array[x.$offset + i])); - if (p.name.$get() === name) { - _tmp = new Method.Ptr(); $copy(_tmp, t.Method(i), Method); _tmp$1 = true; $copy(m, _tmp, Method); ok = _tmp$1; - return [m, ok]; + if (!((((v.flag & 2) >>> 0) === 0))) { + val = v.ptr.$get(); + if (!(val === $ifaceNil) && !(val.constructor === jsType(v.typ))) { + _ref = v.typ.Kind(); + switch (0) { default: if (_ref === 11 || _ref === 6) { + val = new (jsType(v.typ))(val.$high, val.$low); + } else if (_ref === 15 || _ref === 16) { + val = new (jsType(v.typ))(val.$real, val.$imag); + } else if (_ref === 23) { + if (val === val.constructor.nil) { + val = jsType(v.typ).nil; + break; + } + newVal = new (jsType(v.typ))(val.$array); + newVal.$offset = val.$offset; + newVal.$length = val.$length; + newVal.$capacity = val.$capacity; + val = newVal; + } } } - _i++; + return val; } - return [m, ok]; + if (v.typ.pointers()) { + return v.ptr; + } + return v.scalar; }; - interfaceType.prototype.MethodByName = function(name) { return this.$val.MethodByName(name); }; - StructTag.prototype.Get = function(key) { - var tag, i, name, qvalue, _tuple, value; - tag = this.$val !== undefined ? this.$val : this; - while (!(tag === "")) { - i = 0; - while (i < tag.length && (tag.charCodeAt(i) === 32)) { - i = i + (1) >> 0; - } - tag = tag.substring(i); - if (tag === "") { - break; + Value.prototype.iword = function() { return this.$val.iword(); }; + Value.Ptr.prototype.call = function(op, in$1) { + var v, t, fn, rcvr, _tuple, isSlice, n, _ref, _i, x, i, _tmp, _tmp$1, xt, targ, m, slice, elem, i$1, x$1, x$2, xt$1, origIn, nin, nout, argsArray, _ref$1, _i$1, i$2, arg, results, _ref$2, ret, _ref$3, _i$2, i$3; + v = new Value.Ptr(); $copy(v, this, Value); + t = v.typ; + fn = 0; + rcvr = $ifaceNil; + if (!((((v.flag & 8) >>> 0) === 0))) { + _tuple = methodReceiver(op, $clone(v, Value), (v.flag >> 0) >> 9 >> 0); t = _tuple[1]; fn = _tuple[2]; + rcvr = v.iword(); + if (isWrapped(v.typ)) { + rcvr = new (jsType(v.typ))(rcvr); } - i = 0; - while (i < tag.length && !((tag.charCodeAt(i) === 32)) && !((tag.charCodeAt(i) === 58)) && !((tag.charCodeAt(i) === 34))) { - i = i + (1) >> 0; + } else { + fn = v.iword(); + } + if (fn === 0) { + $panic(new $String("reflect.Value.Call: call of nil function")); + } + isSlice = op === "CallSlice"; + n = t.NumIn(); + if (isSlice) { + if (!t.IsVariadic()) { + $panic(new $String("reflect: CallSlice of non-variadic function")); } - if ((i + 1 >> 0) >= tag.length || !((tag.charCodeAt(i) === 58)) || !((tag.charCodeAt((i + 1 >> 0)) === 34))) { - break; + if (in$1.$length < n) { + $panic(new $String("reflect: CallSlice with too few input arguments")); } - name = tag.substring(0, i); - tag = tag.substring((i + 1 >> 0)); - i = 1; - while (i < tag.length && !((tag.charCodeAt(i) === 34))) { - if (tag.charCodeAt(i) === 92) { - i = i + (1) >> 0; - } - i = i + (1) >> 0; + if (in$1.$length > n) { + $panic(new $String("reflect: CallSlice with too many input arguments")); } - if (i >= tag.length) { - break; + } else { + if (t.IsVariadic()) { + n = n - (1) >> 0; } - qvalue = tag.substring(0, (i + 1 >> 0)); - tag = tag.substring((i + 1 >> 0)); - if (key === name) { - _tuple = strconv.Unquote(qvalue); value = _tuple[0]; - return value; + if (in$1.$length < n) { + $panic(new $String("reflect: Call with too few input arguments")); } - } - return ""; - }; - $ptrType(StructTag).prototype.Get = function(key) { return new StructTag(this.$get()).Get(key); }; - structType.Ptr.prototype.Field = function(i) { - var f = new StructField.Ptr(), t, x, p, t$1; - t = this; - if (i < 0 || i >= t.fields.$length) { - return f; - } - p = (x = t.fields, ((i < 0 || i >= x.$length) ? $throwRuntimeError("index out of range") : x.$array[x.$offset + i])); - f.Type = toType(p.typ); - if (!($pointerIsEqual(p.name, ($ptrType($String)).nil))) { - f.Name = p.name.$get(); - } else { - t$1 = f.Type; - if (t$1.Kind() === 22) { - t$1 = t$1.Elem(); + if (!t.IsVariadic() && in$1.$length > n) { + $panic(new $String("reflect: Call with too many input arguments")); } - f.Name = t$1.Name(); - f.Anonymous = true; - } - if (!($pointerIsEqual(p.pkgPath, ($ptrType($String)).nil))) { - f.PkgPath = p.pkgPath.$get(); - } - if (!($pointerIsEqual(p.tag, ($ptrType($String)).nil))) { - f.Tag = p.tag.$get(); } - f.Offset = p.offset; - f.Index = new ($sliceType($Int))([i]); - return f; - }; - structType.prototype.Field = function(i) { return this.$val.Field(i); }; - structType.Ptr.prototype.FieldByIndex = function(index) { - var f = new StructField.Ptr(), t, _ref, _i, i, x, ft; - t = this; - f.Type = toType(t.rtype); - _ref = index; + _ref = in$1; _i = 0; while (_i < _ref.$length) { - i = _i; - x = ((_i < 0 || _i >= _ref.$length) ? $throwRuntimeError("index out of range") : _ref.$array[_ref.$offset + _i]); - if (i > 0) { - ft = f.Type; - if ((ft.Kind() === 22) && (ft.Elem().Kind() === 25)) { - ft = ft.Elem(); - } - f.Type = ft; + x = new Value.Ptr(); $copy(x, ((_i < 0 || _i >= _ref.$length) ? $throwRuntimeError("index out of range") : _ref.$array[_ref.$offset + _i]), Value); + if (x.Kind() === 0) { + $panic(new $String("reflect: " + op + " using zero Value argument")); } - $copy(f, f.Type.Field(x), StructField); _i++; } - return f; - }; - structType.prototype.FieldByIndex = function(index) { return this.$val.FieldByIndex(index); }; - structType.Ptr.prototype.FieldByNameFunc = function(match) { - var result = new StructField.Ptr(), ok = false, t, current, next, nextCount, visited, _map, _key, _tmp, _tmp$1, count, _ref, _i, scan, t$1, _entry, _key$1, _ref$1, _i$1, i, x, f, fname, ntyp, _entry$1, _tmp$2, _tmp$3, styp, _entry$2, _key$2, _map$1, _key$3, _key$4, _entry$3, _key$5, index; - t = this; - current = new ($sliceType(fieldScan))([]); - next = new ($sliceType(fieldScan))([new fieldScan.Ptr(t, ($sliceType($Int)).nil)]); - nextCount = false; - visited = (_map = new $Map(), _map); - while (next.$length > 0) { - _tmp = next; _tmp$1 = $subslice(current, 0, 0); current = _tmp; next = _tmp$1; - count = nextCount; - nextCount = false; - _ref = current; - _i = 0; - while (_i < _ref.$length) { - scan = new fieldScan.Ptr(); $copy(scan, ((_i < 0 || _i >= _ref.$length) ? $throwRuntimeError("index out of range") : _ref.$array[_ref.$offset + _i]), fieldScan); - t$1 = scan.typ; - if ((_entry = visited[t$1.$key()], _entry !== undefined ? _entry.v : false)) { - _i++; - continue; - } - _key$1 = t$1; (visited || $throwRuntimeError("assignment to entry in nil map"))[_key$1.$key()] = { k: _key$1, v: true }; - _ref$1 = t$1.fields; - _i$1 = 0; - while (_i$1 < _ref$1.$length) { - i = _i$1; - f = (x = t$1.fields, ((i < 0 || i >= x.$length) ? $throwRuntimeError("index out of range") : x.$array[x.$offset + i])); - fname = ""; - ntyp = ($ptrType(rtype)).nil; - if (!($pointerIsEqual(f.name, ($ptrType($String)).nil))) { - fname = f.name.$get(); - } else { - ntyp = f.typ; - if (ntyp.Kind() === 22) { - ntyp = ntyp.Elem().common(); - } - fname = ntyp.Name(); - } - if (match(fname)) { - if ((_entry$1 = count[t$1.$key()], _entry$1 !== undefined ? _entry$1.v : 0) > 1 || ok) { - _tmp$2 = new StructField.Ptr("", "", $ifaceNil, "", 0, ($sliceType($Int)).nil, false); _tmp$3 = false; $copy(result, _tmp$2, StructField); ok = _tmp$3; - return [result, ok]; - } - $copy(result, t$1.Field(i), StructField); - result.Index = ($sliceType($Int)).nil; - result.Index = $appendSlice(result.Index, scan.index); - result.Index = $append(result.Index, i); - ok = true; - _i$1++; - continue; - } - if (ok || ntyp === ($ptrType(rtype)).nil || !((ntyp.Kind() === 25))) { - _i$1++; - continue; - } - styp = ntyp.structType; - if ((_entry$2 = nextCount[styp.$key()], _entry$2 !== undefined ? _entry$2.v : 0) > 0) { - _key$2 = styp; (nextCount || $throwRuntimeError("assignment to entry in nil map"))[_key$2.$key()] = { k: _key$2, v: 2 }; - _i$1++; - continue; - } - if (nextCount === false) { - nextCount = (_map$1 = new $Map(), _map$1); - } - _key$4 = styp; (nextCount || $throwRuntimeError("assignment to entry in nil map"))[_key$4.$key()] = { k: _key$4, v: 1 }; - if ((_entry$3 = count[t$1.$key()], _entry$3 !== undefined ? _entry$3.v : 0) > 1) { - _key$5 = styp; (nextCount || $throwRuntimeError("assignment to entry in nil map"))[_key$5.$key()] = { k: _key$5, v: 2 }; - } - index = ($sliceType($Int)).nil; - index = $appendSlice(index, scan.index); - index = $append(index, i); - next = $append(next, new fieldScan.Ptr(styp, index)); - _i$1++; - } - _i++; - } - if (ok) { - break; + i = 0; + while (i < n) { + _tmp = ((i < 0 || i >= in$1.$length) ? $throwRuntimeError("index out of range") : in$1.$array[in$1.$offset + i]).Type(); _tmp$1 = t.In(i); xt = _tmp; targ = _tmp$1; + if (!xt.AssignableTo(targ)) { + $panic(new $String("reflect: " + op + " using " + xt.String() + " as type " + targ.String())); } + i = i + (1) >> 0; } - return [result, ok]; - }; - structType.prototype.FieldByNameFunc = function(match) { return this.$val.FieldByNameFunc(match); }; - structType.Ptr.prototype.FieldByName = function(name) { - var f = new StructField.Ptr(), present = false, t, hasAnon, _ref, _i, i, x, tf, _tmp, _tmp$1, _tuple; - t = this; - hasAnon = false; - if (!(name === "")) { - _ref = t.fields; - _i = 0; - while (_i < _ref.$length) { - i = _i; - tf = (x = t.fields, ((i < 0 || i >= x.$length) ? $throwRuntimeError("index out of range") : x.$array[x.$offset + i])); - if ($pointerIsEqual(tf.name, ($ptrType($String)).nil)) { - hasAnon = true; - _i++; - continue; - } - if (tf.name.$get() === name) { - _tmp = new StructField.Ptr(); $copy(_tmp, t.Field(i), StructField); _tmp$1 = true; $copy(f, _tmp, StructField); present = _tmp$1; - return [f, present]; + if (!isSlice && t.IsVariadic()) { + m = in$1.$length - n >> 0; + slice = new Value.Ptr(); $copy(slice, MakeSlice(t.In(n), m, m), Value); + elem = t.In(n).Elem(); + i$1 = 0; + while (i$1 < m) { + x$2 = new Value.Ptr(); $copy(x$2, (x$1 = n + i$1 >> 0, ((x$1 < 0 || x$1 >= in$1.$length) ? $throwRuntimeError("index out of range") : in$1.$array[in$1.$offset + x$1])), Value); + xt$1 = x$2.Type(); + if (!xt$1.AssignableTo(elem)) { + $panic(new $String("reflect: cannot use " + xt$1.String() + " as type " + elem.String() + " in " + op)); } - _i++; + slice.Index(i$1).Set($clone(x$2, Value)); + i$1 = i$1 + (1) >> 0; } + origIn = in$1; + in$1 = ($sliceType(Value)).make((n + 1 >> 0)); + $copySlice($subslice(in$1, 0, n), origIn); + $copy(((n < 0 || n >= in$1.$length) ? $throwRuntimeError("index out of range") : in$1.$array[in$1.$offset + n]), slice, Value); } - if (!hasAnon) { - return [f, present]; - } - _tuple = t.FieldByNameFunc((function(s) { - return s === name; - })); $copy(f, _tuple[0], StructField); present = _tuple[1]; - return [f, present]; - }; - structType.prototype.FieldByName = function(name) { return this.$val.FieldByName(name); }; - PtrTo = $pkg.PtrTo = function(t) { - return $assertType(t, ($ptrType(rtype))).ptrTo(); - }; - rtype.Ptr.prototype.Implements = function(u) { - var t; - t = this; - if ($interfaceIsEqual(u, $ifaceNil)) { - $panic(new $String("reflect: nil type passed to Type.Implements")); + nin = in$1.$length; + if (!((nin === t.NumIn()))) { + $panic(new $String("reflect.Value.Call: wrong argument count")); } - if (!((u.Kind() === 20))) { - $panic(new $String("reflect: non-interface type passed to Type.Implements")); + nout = t.NumOut(); + argsArray = new ($global.Array)(t.NumIn()); + _ref$1 = in$1; + _i$1 = 0; + while (_i$1 < _ref$1.$length) { + i$2 = _i$1; + arg = new Value.Ptr(); $copy(arg, ((_i$1 < 0 || _i$1 >= _ref$1.$length) ? $throwRuntimeError("index out of range") : _ref$1.$array[_ref$1.$offset + _i$1]), Value); + argsArray[i$2] = arg.assignTo("reflect.Value.Call", t.In(i$2).common(), ($ptrType($emptyInterface)).nil).iword(); + _i$1++; } - return implements$1($assertType(u, ($ptrType(rtype))), t); - }; - rtype.prototype.Implements = function(u) { return this.$val.Implements(u); }; - rtype.Ptr.prototype.AssignableTo = function(u) { - var t, uu; - t = this; - if ($interfaceIsEqual(u, $ifaceNil)) { - $panic(new $String("reflect: nil type passed to Type.AssignableTo")); + results = fn.apply(rcvr, argsArray); + _ref$2 = nout; + if (_ref$2 === 0) { + return ($sliceType(Value)).nil; + } else if (_ref$2 === 1) { + return new ($sliceType(Value))([$clone(makeValue(t.Out(0), results, 0), Value)]); + } else { + ret = ($sliceType(Value)).make(nout); + _ref$3 = ret; + _i$2 = 0; + while (_i$2 < _ref$3.$length) { + i$3 = _i$2; + $copy(((i$3 < 0 || i$3 >= ret.$length) ? $throwRuntimeError("index out of range") : ret.$array[ret.$offset + i$3]), makeValue(t.Out(i$3), results[i$3], 0), Value); + _i$2++; + } + return ret; } - uu = $assertType(u, ($ptrType(rtype))); - return directlyAssignable(uu, t) || implements$1(uu, t); }; - rtype.prototype.AssignableTo = function(u) { return this.$val.AssignableTo(u); }; - rtype.Ptr.prototype.ConvertibleTo = function(u) { - var t, uu; - t = this; - if ($interfaceIsEqual(u, $ifaceNil)) { - $panic(new $String("reflect: nil type passed to Type.ConvertibleTo")); + Value.prototype.call = function(op, in$1) { return this.$val.call(op, in$1); }; + Value.Ptr.prototype.Cap = function() { + var v, k, _ref; + v = new Value.Ptr(); $copy(v, this, Value); + k = (new flag(v.flag)).kind(); + _ref = k; + if (_ref === 17) { + return v.typ.Len(); + } else if (_ref === 18 || _ref === 23) { + return $parseInt(v.iword().$capacity) >> 0; } - uu = $assertType(u, ($ptrType(rtype))); - return !(convertOp(uu, t) === $throwNilPointerError); + $panic(new ValueError.Ptr("reflect.Value.Cap", k)); }; - rtype.prototype.ConvertibleTo = function(u) { return this.$val.ConvertibleTo(u); }; - implements$1 = function(T, V) { - var t, v, i, j, x, tm, x$1, vm, v$1, i$1, j$1, x$2, tm$1, x$3, vm$1; - if (!((T.Kind() === 20))) { - return false; - } - t = T.interfaceType; - if (t.methods.$length === 0) { - return true; - } - if (V.Kind() === 20) { - v = V.interfaceType; - i = 0; - j = 0; - while (j < v.methods.$length) { - tm = (x = t.methods, ((i < 0 || i >= x.$length) ? $throwRuntimeError("index out of range") : x.$array[x.$offset + i])); - vm = (x$1 = v.methods, ((j < 0 || j >= x$1.$length) ? $throwRuntimeError("index out of range") : x$1.$array[x$1.$offset + j])); - if ($pointerIsEqual(vm.name, tm.name) && $pointerIsEqual(vm.pkgPath, tm.pkgPath) && vm.typ === tm.typ) { - i = i + (1) >> 0; - if (i >= t.methods.$length) { - return true; - } - } - j = j + (1) >> 0; + Value.prototype.Cap = function() { return this.$val.Cap(); }; + Value.Ptr.prototype.Elem = function() { + var v, k, _ref, val, typ, val$1, tt, fl; + v = new Value.Ptr(); $copy(v, this, Value); + k = (new flag(v.flag)).kind(); + _ref = k; + if (_ref === 20) { + val = v.iword(); + if (val === $ifaceNil) { + return new Value.Ptr(($ptrType(rtype)).nil, 0, 0, 0); } - return false; - } - v$1 = V.uncommonType.uncommon(); - if (v$1 === ($ptrType(uncommonType)).nil) { - return false; - } - i$1 = 0; - j$1 = 0; - while (j$1 < v$1.methods.$length) { - tm$1 = (x$2 = t.methods, ((i$1 < 0 || i$1 >= x$2.$length) ? $throwRuntimeError("index out of range") : x$2.$array[x$2.$offset + i$1])); - vm$1 = (x$3 = v$1.methods, ((j$1 < 0 || j$1 >= x$3.$length) ? $throwRuntimeError("index out of range") : x$3.$array[x$3.$offset + j$1])); - if ($pointerIsEqual(vm$1.name, tm$1.name) && $pointerIsEqual(vm$1.pkgPath, tm$1.pkgPath) && vm$1.mtyp === tm$1.typ) { - i$1 = i$1 + (1) >> 0; - if (i$1 >= t.methods.$length) { - return true; - } + typ = reflectType(val.constructor); + return makeValue(typ, val.$val, (v.flag & 1) >>> 0); + } else if (_ref === 22) { + if (v.IsNil()) { + return new Value.Ptr(($ptrType(rtype)).nil, 0, 0, 0); } - j$1 = j$1 + (1) >> 0; - } - return false; - }; - directlyAssignable = function(T, V) { - if (T === V) { - return true; - } - if (!(T.Name() === "") && !(V.Name() === "") || !((T.Kind() === V.Kind()))) { - return false; + val$1 = v.iword(); + tt = v.typ.ptrType; + fl = (((((v.flag & 1) >>> 0) | 2) >>> 0) | 4) >>> 0; + fl = (fl | (((tt.elem.Kind() >>> 0) << 4 >>> 0))) >>> 0; + return new Value.Ptr(tt.elem, val$1, 0, fl); + } else { + $panic(new ValueError.Ptr("reflect.Value.Elem", k)); } - return haveIdenticalUnderlyingType(T, V); }; - haveIdenticalUnderlyingType = function(T, V) { - var kind, _ref, t, v, _ref$1, _i, i, typ, x, _ref$2, _i$1, i$1, typ$1, x$1, t$1, v$1, t$2, v$2, _ref$3, _i$2, i$2, x$2, tf, x$3, vf; - if (T === V) { - return true; + Value.prototype.Elem = function() { return this.$val.Elem(); }; + Value.Ptr.prototype.Field = function(i) { + var v, tt, x, field, name, typ, fl, s; + v = new Value.Ptr(); $copy(v, this, Value); + (new flag(v.flag)).mustBe(25); + tt = v.typ.structType; + if (i < 0 || i >= tt.fields.$length) { + $panic(new $String("reflect: Field index out of range")); } - kind = T.Kind(); - if (!((kind === V.Kind()))) { - return false; + field = (x = tt.fields, ((i < 0 || i >= x.$length) ? $throwRuntimeError("index out of range") : x.$array[x.$offset + i])); + name = $internalize(jsType(v.typ).fields[i][0], $String); + typ = field.typ; + fl = (v.flag & 7) >>> 0; + if (!($pointerIsEqual(field.pkgPath, ($ptrType($String)).nil))) { + fl = (fl | (1)) >>> 0; } - if (1 <= kind && kind <= 16 || (kind === 24) || (kind === 26)) { - return true; + fl = (fl | (((typ.Kind() >>> 0) << 4 >>> 0))) >>> 0; + s = v.ptr; + if (!((((fl & 2) >>> 0) === 0)) && !((typ.Kind() === 17)) && !((typ.Kind() === 25))) { + return new Value.Ptr(typ, new (jsType(PtrTo(typ)))($externalize((function() { + return s[$externalize(name, $String)]; + }), ($funcType([], [js.Object], false))), $externalize((function(v$1) { + s[$externalize(name, $String)] = v$1; + }), ($funcType([js.Object], [], false)))), 0, fl); } - _ref = kind; + return makeValue(typ, s[$externalize(name, $String)], fl); + }; + Value.prototype.Field = function(i) { return this.$val.Field(i); }; + Value.Ptr.prototype.Index = function(i) { + var v, k, _ref, tt, typ, fl, a, s, tt$1, typ$1, fl$1, a$1, str, fl$2; + v = new Value.Ptr(); $copy(v, this, Value); + k = (new flag(v.flag)).kind(); + _ref = k; if (_ref === 17) { - return $interfaceIsEqual(T.Elem(), V.Elem()) && (T.Len() === V.Len()); - } else if (_ref === 18) { - if ((V.ChanDir() === 3) && $interfaceIsEqual(T.Elem(), V.Elem())) { - return true; - } - return (V.ChanDir() === T.ChanDir()) && $interfaceIsEqual(T.Elem(), V.Elem()); - } else if (_ref === 19) { - t = T.funcType; - v = V.funcType; - if (!(t.dotdotdot === v.dotdotdot) || !((t.in$2.$length === v.in$2.$length)) || !((t.out.$length === v.out.$length))) { - return false; - } - _ref$1 = t.in$2; - _i = 0; - while (_i < _ref$1.$length) { - i = _i; - typ = ((_i < 0 || _i >= _ref$1.$length) ? $throwRuntimeError("index out of range") : _ref$1.$array[_ref$1.$offset + _i]); - if (!(typ === (x = v.in$2, ((i < 0 || i >= x.$length) ? $throwRuntimeError("index out of range") : x.$array[x.$offset + i])))) { - return false; - } - _i++; + tt = v.typ.arrayType; + if (i < 0 || i > (tt.len >> 0)) { + $panic(new $String("reflect: array index out of range")); } - _ref$2 = t.out; - _i$1 = 0; - while (_i$1 < _ref$2.$length) { - i$1 = _i$1; - typ$1 = ((_i$1 < 0 || _i$1 >= _ref$2.$length) ? $throwRuntimeError("index out of range") : _ref$2.$array[_ref$2.$offset + _i$1]); - if (!(typ$1 === (x$1 = v.out, ((i$1 < 0 || i$1 >= x$1.$length) ? $throwRuntimeError("index out of range") : x$1.$array[x$1.$offset + i$1])))) { - return false; - } - _i$1++; + typ = tt.elem; + fl = (v.flag & 7) >>> 0; + fl = (fl | (((typ.Kind() >>> 0) << 4 >>> 0))) >>> 0; + a = v.ptr; + if (!((((fl & 2) >>> 0) === 0)) && !((typ.Kind() === 17)) && !((typ.Kind() === 25))) { + return new Value.Ptr(typ, new (jsType(PtrTo(typ)))($externalize((function() { + return a[i]; + }), ($funcType([], [js.Object], false))), $externalize((function(v$1) { + a[i] = v$1; + }), ($funcType([js.Object], [], false)))), 0, fl); } - return true; - } else if (_ref === 20) { - t$1 = T.interfaceType; - v$1 = V.interfaceType; - if ((t$1.methods.$length === 0) && (v$1.methods.$length === 0)) { - return true; + return makeValue(typ, a[i], fl); + } else if (_ref === 23) { + s = v.iword(); + if (i < 0 || i >= ($parseInt(s.$length) >> 0)) { + $panic(new $String("reflect: slice index out of range")); } - return false; - } else if (_ref === 21) { - return $interfaceIsEqual(T.Key(), V.Key()) && $interfaceIsEqual(T.Elem(), V.Elem()); - } else if (_ref === 22 || _ref === 23) { - return $interfaceIsEqual(T.Elem(), V.Elem()); - } else if (_ref === 25) { - t$2 = T.structType; - v$2 = V.structType; - if (!((t$2.fields.$length === v$2.fields.$length))) { - return false; + tt$1 = v.typ.sliceType; + typ$1 = tt$1.elem; + fl$1 = (6 | ((v.flag & 1) >>> 0)) >>> 0; + fl$1 = (fl$1 | (((typ$1.Kind() >>> 0) << 4 >>> 0))) >>> 0; + i = i + (($parseInt(s.$offset) >> 0)) >> 0; + a$1 = s.$array; + if (!((((fl$1 & 2) >>> 0) === 0)) && !((typ$1.Kind() === 17)) && !((typ$1.Kind() === 25))) { + return new Value.Ptr(typ$1, new (jsType(PtrTo(typ$1)))($externalize((function() { + return a$1[i]; + }), ($funcType([], [js.Object], false))), $externalize((function(v$1) { + a$1[i] = v$1; + }), ($funcType([js.Object], [], false)))), 0, fl$1); } - _ref$3 = t$2.fields; - _i$2 = 0; - while (_i$2 < _ref$3.$length) { - i$2 = _i$2; - tf = (x$2 = t$2.fields, ((i$2 < 0 || i$2 >= x$2.$length) ? $throwRuntimeError("index out of range") : x$2.$array[x$2.$offset + i$2])); - vf = (x$3 = v$2.fields, ((i$2 < 0 || i$2 >= x$3.$length) ? $throwRuntimeError("index out of range") : x$3.$array[x$3.$offset + i$2])); - if (!($pointerIsEqual(tf.name, vf.name)) && ($pointerIsEqual(tf.name, ($ptrType($String)).nil) || $pointerIsEqual(vf.name, ($ptrType($String)).nil) || !(tf.name.$get() === vf.name.$get()))) { - return false; - } - if (!($pointerIsEqual(tf.pkgPath, vf.pkgPath)) && ($pointerIsEqual(tf.pkgPath, ($ptrType($String)).nil) || $pointerIsEqual(vf.pkgPath, ($ptrType($String)).nil) || !(tf.pkgPath.$get() === vf.pkgPath.$get()))) { - return false; - } - if (!(tf.typ === vf.typ)) { - return false; - } - if (!($pointerIsEqual(tf.tag, vf.tag)) && ($pointerIsEqual(tf.tag, ($ptrType($String)).nil) || $pointerIsEqual(vf.tag, ($ptrType($String)).nil) || !(tf.tag.$get() === vf.tag.$get()))) { - return false; - } - if (!((tf.offset === vf.offset))) { - return false; - } - _i$2++; + return makeValue(typ$1, a$1[i], fl$1); + } else if (_ref === 24) { + str = v.ptr.$get(); + if (i < 0 || i >= str.length) { + $panic(new $String("reflect: string index out of range")); } - return true; - } - return false; - }; - toType = function(t) { - if (t === ($ptrType(rtype)).nil) { - return $ifaceNil; + fl$2 = (((v.flag & 1) >>> 0) | 128) >>> 0; + return new Value.Ptr(uint8Type, 0, (str.charCodeAt(i) >>> 0), fl$2); + } else { + $panic(new ValueError.Ptr("reflect.Value.Index", k)); } - return t; - }; - flag.prototype.kind = function() { - var f; - f = this.$val !== undefined ? this.$val : this; - return (((((f >>> 4 >>> 0)) & 31) >>> 0) >>> 0); }; - $ptrType(flag).prototype.kind = function() { return new flag(this.$get()).kind(); }; - Value.Ptr.prototype.pointer = function() { - var v; + Value.prototype.Index = function(i) { return this.$val.Index(i); }; + Value.Ptr.prototype.IsNil = function() { + var v, k, _ref; v = new Value.Ptr(); $copy(v, this, Value); - if (!((v.typ.size === 4)) || !v.typ.pointers()) { - $panic(new $String("can't call pointer on a non-pointer Value")); - } - if (!((((v.flag & 2) >>> 0) === 0))) { - return v.ptr.$get(); - } - return v.ptr; - }; - Value.prototype.pointer = function() { return this.$val.pointer(); }; - ValueError.Ptr.prototype.Error = function() { - var e; - e = this; - if (e.Kind === 0) { - return "reflect: call of " + e.Method + " on zero Value"; - } - return "reflect: call of " + e.Method + " on " + (new Kind(e.Kind)).String() + " Value"; - }; - ValueError.prototype.Error = function() { return this.$val.Error(); }; - flag.prototype.mustBe = function(expected) { - var f, k; - f = this.$val !== undefined ? this.$val : this; - k = (new flag(f)).kind(); - if (!((k === expected))) { - $panic(new ValueError.Ptr(methodName(), k)); - } - }; - $ptrType(flag).prototype.mustBe = function(expected) { return new flag(this.$get()).mustBe(expected); }; - flag.prototype.mustBeExported = function() { - var f; - f = this.$val !== undefined ? this.$val : this; - if (f === 0) { - $panic(new ValueError.Ptr(methodName(), 0)); - } - if (!((((f & 1) >>> 0) === 0))) { - $panic(new $String("reflect: " + methodName() + " using value obtained using unexported field")); + k = (new flag(v.flag)).kind(); + _ref = k; + if (_ref === 18 || _ref === 22 || _ref === 23) { + return v.iword() === jsType(v.typ).nil; + } else if (_ref === 19) { + return v.iword() === $throwNilPointerError; + } else if (_ref === 21) { + return v.iword() === false; + } else if (_ref === 20) { + return v.iword() === $ifaceNil; + } else { + $panic(new ValueError.Ptr("reflect.Value.IsNil", k)); } }; - $ptrType(flag).prototype.mustBeExported = function() { return new flag(this.$get()).mustBeExported(); }; - flag.prototype.mustBeAssignable = function() { - var f; - f = this.$val !== undefined ? this.$val : this; - if (f === 0) { - $panic(new ValueError.Ptr(methodName(), 0)); - } - if (!((((f & 1) >>> 0) === 0))) { - $panic(new $String("reflect: " + methodName() + " using value obtained using unexported field")); - } - if (((f & 4) >>> 0) === 0) { - $panic(new $String("reflect: " + methodName() + " using unaddressable value")); + Value.prototype.IsNil = function() { return this.$val.IsNil(); }; + Value.Ptr.prototype.Len = function() { + var v, k, _ref; + v = new Value.Ptr(); $copy(v, this, Value); + k = (new flag(v.flag)).kind(); + _ref = k; + if (_ref === 17 || _ref === 24) { + return $parseInt(v.iword().length); + } else if (_ref === 23) { + return $parseInt(v.iword().$length) >> 0; + } else if (_ref === 18) { + return $parseInt(v.iword().$buffer.length) >> 0; + } else if (_ref === 21) { + return $parseInt($keys(v.iword()).length); + } else { + $panic(new ValueError.Ptr("reflect.Value.Len", k)); } }; - $ptrType(flag).prototype.mustBeAssignable = function() { return new flag(this.$get()).mustBeAssignable(); }; - Value.Ptr.prototype.Addr = function() { - var v; + Value.prototype.Len = function() { return this.$val.Len(); }; + Value.Ptr.prototype.Pointer = function() { + var v, k, _ref; v = new Value.Ptr(); $copy(v, this, Value); - if (((v.flag & 4) >>> 0) === 0) { - $panic(new $String("reflect.Value.Addr of unaddressable value")); + k = (new flag(v.flag)).kind(); + _ref = k; + if (_ref === 18 || _ref === 21 || _ref === 22 || _ref === 23 || _ref === 26) { + if (v.IsNil()) { + return 0; + } + return v.iword(); + } else if (_ref === 19) { + if (v.IsNil()) { + return 0; + } + return 1; + } else { + $panic(new ValueError.Ptr("reflect.Value.Pointer", k)); } - return new Value.Ptr(v.typ.ptrTo(), v.ptr, 0, ((((v.flag & 1) >>> 0)) | 352) >>> 0); }; - Value.prototype.Addr = function() { return this.$val.Addr(); }; - Value.Ptr.prototype.Bool = function() { - var v; + Value.prototype.Pointer = function() { return this.$val.Pointer(); }; + Value.Ptr.prototype.Set = function(x) { + var v, _ref; v = new Value.Ptr(); $copy(v, this, Value); - (new flag(v.flag)).mustBe(1); + (new flag(v.flag)).mustBeAssignable(); + (new flag(x.flag)).mustBeExported(); + $copy(x, x.assignTo("reflect.Set", v.typ, ($ptrType($emptyInterface)).nil), Value); if (!((((v.flag & 2) >>> 0) === 0))) { - return v.ptr.$get(); + _ref = v.typ.Kind(); + if (_ref === 17) { + $copy(v.ptr, x.ptr, jsType(v.typ)); + } else if (_ref === 20) { + v.ptr.$set(valueInterface($clone(x, Value), false)); + } else if (_ref === 25) { + copyStruct(v.ptr, x.ptr, v.typ); + } else { + v.ptr.$set(x.iword()); + } + return; } - return v.scalar; + v.ptr = x.ptr; }; - Value.prototype.Bool = function() { return this.$val.Bool(); }; - Value.Ptr.prototype.Bytes = function() { - var v; + Value.prototype.Set = function(x) { return this.$val.Set(x); }; + Value.Ptr.prototype.SetCap = function(n) { + var v, s, newSlice; v = new Value.Ptr(); $copy(v, this, Value); + (new flag(v.flag)).mustBeAssignable(); (new flag(v.flag)).mustBe(23); - if (!((v.typ.Elem().Kind() === 8))) { - $panic(new $String("reflect.Value.Bytes of non-byte slice")); + s = v.ptr.$get(); + if (n < ($parseInt(s.$length) >> 0) || n > ($parseInt(s.$capacity) >> 0)) { + $panic(new $String("reflect: slice capacity out of range in SetCap")); } - return v.ptr.$get(); + newSlice = new (jsType(v.typ))(s.$array); + newSlice.$offset = s.$offset; + newSlice.$length = s.$length; + newSlice.$capacity = n; + v.ptr.$set(newSlice); }; - Value.prototype.Bytes = function() { return this.$val.Bytes(); }; - Value.Ptr.prototype.runes = function() { - var v; + Value.prototype.SetCap = function(n) { return this.$val.SetCap(n); }; + Value.Ptr.prototype.SetLen = function(n) { + var v, s, newSlice; v = new Value.Ptr(); $copy(v, this, Value); + (new flag(v.flag)).mustBeAssignable(); (new flag(v.flag)).mustBe(23); - if (!((v.typ.Elem().Kind() === 5))) { - $panic(new $String("reflect.Value.Bytes of non-rune slice")); + s = v.ptr.$get(); + if (n < 0 || n > ($parseInt(s.$capacity) >> 0)) { + $panic(new $String("reflect: slice length out of range in SetLen")); } - return v.ptr.$get(); + newSlice = new (jsType(v.typ))(s.$array); + newSlice.$offset = s.$offset; + newSlice.$length = n; + newSlice.$capacity = s.$capacity; + v.ptr.$set(newSlice); }; - Value.prototype.runes = function() { return this.$val.runes(); }; - Value.Ptr.prototype.CanAddr = function() { - var v; + Value.prototype.SetLen = function(n) { return this.$val.SetLen(n); }; + Value.Ptr.prototype.Slice = function(i, j) { + var v, cap, typ, s, kind, _ref, tt, str; v = new Value.Ptr(); $copy(v, this, Value); - return !((((v.flag & 4) >>> 0) === 0)); + cap = 0; + typ = $ifaceNil; + s = $ifaceNil; + kind = (new flag(v.flag)).kind(); + _ref = kind; + if (_ref === 17) { + if (((v.flag & 4) >>> 0) === 0) { + $panic(new $String("reflect.Value.Slice: slice of unaddressable array")); + } + tt = v.typ.arrayType; + cap = (tt.len >> 0); + typ = SliceOf(tt.elem); + s = new (jsType(typ))(v.iword()); + } else if (_ref === 23) { + typ = v.typ; + s = v.iword(); + cap = $parseInt(s.$capacity) >> 0; + } else if (_ref === 24) { + str = v.ptr.$get(); + if (i < 0 || j < i || j > str.length) { + $panic(new $String("reflect.Value.Slice: string slice index out of bounds")); + } + return ValueOf(new $String(str.substring(i, j))); + } else { + $panic(new ValueError.Ptr("reflect.Value.Slice", kind)); + } + if (i < 0 || j < i || j > cap) { + $panic(new $String("reflect.Value.Slice: slice index out of bounds")); + } + return makeValue(typ, $subslice(s, i, j), (v.flag & 1) >>> 0); }; - Value.prototype.CanAddr = function() { return this.$val.CanAddr(); }; - Value.Ptr.prototype.CanSet = function() { - var v; + Value.prototype.Slice = function(i, j) { return this.$val.Slice(i, j); }; + Value.Ptr.prototype.Slice3 = function(i, j, k) { + var v, cap, typ, s, kind, _ref, tt; v = new Value.Ptr(); $copy(v, this, Value); - return ((v.flag & 5) >>> 0) === 4; + cap = 0; + typ = $ifaceNil; + s = $ifaceNil; + kind = (new flag(v.flag)).kind(); + _ref = kind; + if (_ref === 17) { + if (((v.flag & 4) >>> 0) === 0) { + $panic(new $String("reflect.Value.Slice: slice of unaddressable array")); + } + tt = v.typ.arrayType; + cap = (tt.len >> 0); + typ = SliceOf(tt.elem); + s = new (jsType(typ))(v.iword()); + } else if (_ref === 23) { + typ = v.typ; + s = v.iword(); + cap = $parseInt(s.$capacity) >> 0; + } else { + $panic(new ValueError.Ptr("reflect.Value.Slice3", kind)); + } + if (i < 0 || j < i || k < j || k > cap) { + $panic(new $String("reflect.Value.Slice3: slice index out of bounds")); + } + return makeValue(typ, $subslice(s, i, j, k), (v.flag & 1) >>> 0); }; - Value.prototype.CanSet = function() { return this.$val.CanSet(); }; - Value.Ptr.prototype.Call = function(in$1) { + Value.prototype.Slice3 = function(i, j, k) { return this.$val.Slice3(i, j, k); }; + Value.Ptr.prototype.Close = function() { var v; v = new Value.Ptr(); $copy(v, this, Value); - (new flag(v.flag)).mustBe(19); + (new flag(v.flag)).mustBe(18); (new flag(v.flag)).mustBeExported(); - return v.call("Call", in$1); + $close(v.iword()); }; - Value.prototype.Call = function(in$1) { return this.$val.Call(in$1); }; - Value.Ptr.prototype.CallSlice = function(in$1) { - var v; + Value.prototype.Close = function() { return this.$val.Close(); }; + Value.Ptr.prototype.TrySend = function(x) { + var v, tt, c; v = new Value.Ptr(); $copy(v, this, Value); - (new flag(v.flag)).mustBe(19); + (new flag(v.flag)).mustBe(18); (new flag(v.flag)).mustBeExported(); - return v.call("CallSlice", in$1); - }; - Value.prototype.CallSlice = function(in$1) { return this.$val.CallSlice(in$1); }; - Value.Ptr.prototype.Complex = function() { - var v, k, _ref, x, x$1; - v = new Value.Ptr(); $copy(v, this, Value); - k = (new flag(v.flag)).kind(); - _ref = k; - if (_ref === 15) { - if (!((((v.flag & 2) >>> 0) === 0))) { - return (x = v.ptr.$get(), new $Complex128(x.$real, x.$imag)); - } - return (x$1 = v.scalar, new $Complex128(x$1.$real, x$1.$imag)); - } else if (_ref === 16) { - return v.ptr.$get(); + tt = v.typ.chanType; + if (((tt.dir >> 0) & 2) === 0) { + $panic(new $String("reflect: send on recv-only channel")); } - $panic(new ValueError.Ptr("reflect.Value.Complex", k)); - }; - Value.prototype.Complex = function() { return this.$val.Complex(); }; - Value.Ptr.prototype.FieldByIndex = function(index) { - var v, _ref, _i, i, x; - v = new Value.Ptr(); $copy(v, this, Value); - (new flag(v.flag)).mustBe(25); - _ref = index; - _i = 0; - while (_i < _ref.$length) { - i = _i; - x = ((_i < 0 || _i >= _ref.$length) ? $throwRuntimeError("index out of range") : _ref.$array[_ref.$offset + _i]); - if (i > 0) { - if ((v.Kind() === 22) && (v.typ.Elem().Kind() === 25)) { - if (v.IsNil()) { - $panic(new $String("reflect: indirection through nil pointer to embedded struct")); - } - $copy(v, v.Elem(), Value); - } - } - $copy(v, v.Field(x), Value); - _i++; + (new flag(x.flag)).mustBeExported(); + c = v.iword(); + if (!!!(c.$closed) && ($parseInt(c.$recvQueue.length) === 0) && ($parseInt(c.$buffer.length) === ($parseInt(c.$capacity) >> 0))) { + return false; } - return v; + $copy(x, x.assignTo("reflect.Value.Send", tt.elem, ($ptrType($emptyInterface)).nil), Value); + $send(c, x.iword()); + return true; }; - Value.prototype.FieldByIndex = function(index) { return this.$val.FieldByIndex(index); }; - Value.Ptr.prototype.FieldByName = function(name) { - var v, _tuple, f, ok; + Value.prototype.TrySend = function(x) { return this.$val.TrySend(x); }; + Value.Ptr.prototype.Send = function(x) { + var v; v = new Value.Ptr(); $copy(v, this, Value); - (new flag(v.flag)).mustBe(25); - _tuple = v.typ.FieldByName(name); f = new StructField.Ptr(); $copy(f, _tuple[0], StructField); ok = _tuple[1]; - if (ok) { - return v.FieldByIndex(f.Index); - } - return new Value.Ptr(($ptrType(rtype)).nil, 0, 0, 0); + $panic(new runtime.NotSupportedError.Ptr("reflect.Value.Send, use reflect.Value.TrySend is possible")); }; - Value.prototype.FieldByName = function(name) { return this.$val.FieldByName(name); }; - Value.Ptr.prototype.FieldByNameFunc = function(match) { - var v, _tuple, f, ok; + Value.prototype.Send = function(x) { return this.$val.Send(x); }; + Value.Ptr.prototype.TryRecv = function() { + var x = new Value.Ptr(), ok = false, v, tt, res, _tmp, _tmp$1, _tmp$2, _tmp$3; v = new Value.Ptr(); $copy(v, this, Value); - (new flag(v.flag)).mustBe(25); - _tuple = v.typ.FieldByNameFunc(match); f = new StructField.Ptr(); $copy(f, _tuple[0], StructField); ok = _tuple[1]; - if (ok) { - return v.FieldByIndex(f.Index); + (new flag(v.flag)).mustBe(18); + (new flag(v.flag)).mustBeExported(); + tt = v.typ.chanType; + if (((tt.dir >> 0) & 1) === 0) { + $panic(new $String("reflect: recv on send-only channel")); } - return new Value.Ptr(($ptrType(rtype)).nil, 0, 0, 0); - }; - Value.prototype.FieldByNameFunc = function(match) { return this.$val.FieldByNameFunc(match); }; - Value.Ptr.prototype.Float = function() { - var v, k, _ref; - v = new Value.Ptr(); $copy(v, this, Value); - k = (new flag(v.flag)).kind(); - _ref = k; - if (_ref === 13) { - if (!((((v.flag & 2) >>> 0) === 0))) { - return $coerceFloat32(v.ptr.$get()); - } - return $coerceFloat32(v.scalar); - } else if (_ref === 14) { - if (!((((v.flag & 2) >>> 0) === 0))) { - return v.ptr.$get(); - } - return v.scalar; + res = $recv(v.iword()); + if (res.constructor === $global.Function) { + _tmp = new Value.Ptr(($ptrType(rtype)).nil, 0, 0, 0); _tmp$1 = false; $copy(x, _tmp, Value); ok = _tmp$1; + return [x, ok]; } - $panic(new ValueError.Ptr("reflect.Value.Float", k)); + _tmp$2 = new Value.Ptr(); $copy(_tmp$2, makeValue(tt.elem, res[0], 0), Value); _tmp$3 = !!(res[1]); $copy(x, _tmp$2, Value); ok = _tmp$3; + return [x, ok]; }; - Value.prototype.Float = function() { return this.$val.Float(); }; - Value.Ptr.prototype.Int = function() { - var v, k, p, _ref; + Value.prototype.TryRecv = function() { return this.$val.TryRecv(); }; + Value.Ptr.prototype.Recv = function() { + var x = new Value.Ptr(), ok = false, v; v = new Value.Ptr(); $copy(v, this, Value); - k = (new flag(v.flag)).kind(); - p = 0; - if (!((((v.flag & 2) >>> 0) === 0))) { - p = v.ptr; - } else { - p = new ($ptrType($Uintptr))(function() { return this.$target.scalar; }, function($v) { this.$target.scalar = $v; }, v); - } - _ref = k; - if (_ref === 2) { - return new $Int64(0, p.$get()); - } else if (_ref === 3) { - return new $Int64(0, p.$get()); - } else if (_ref === 4) { - return new $Int64(0, p.$get()); - } else if (_ref === 5) { - return new $Int64(0, p.$get()); - } else if (_ref === 6) { - return p.$get(); - } - $panic(new ValueError.Ptr("reflect.Value.Int", k)); + $panic(new runtime.NotSupportedError.Ptr("reflect.Value.Recv, use reflect.Value.TryRecv is possible")); }; - Value.prototype.Int = function() { return this.$val.Int(); }; - Value.Ptr.prototype.CanInterface = function() { - var v; - v = new Value.Ptr(); $copy(v, this, Value); - if (v.flag === 0) { - $panic(new ValueError.Ptr("reflect.Value.CanInterface", 0)); + Value.prototype.Recv = function() { return this.$val.Recv(); }; + Kind.prototype.String = function() { + var k; + k = this.$val !== undefined ? this.$val : this; + if ((k >> 0) < kindNames.$length) { + return ((k < 0 || k >= kindNames.$length) ? $throwRuntimeError("index out of range") : kindNames.$array[kindNames.$offset + k]); } - return ((v.flag & 1) >>> 0) === 0; + return "kind" + strconv.Itoa((k >> 0)); }; - Value.prototype.CanInterface = function() { return this.$val.CanInterface(); }; - Value.Ptr.prototype.Interface = function() { - var i = $ifaceNil, v; - v = new Value.Ptr(); $copy(v, this, Value); - i = valueInterface($clone(v, Value), true); - return i; + $ptrType(Kind).prototype.String = function() { return new Kind(this.$get()).String(); }; + uncommonType.Ptr.prototype.uncommon = function() { + var t; + t = this; + return t; }; - Value.prototype.Interface = function() { return this.$val.Interface(); }; - Value.Ptr.prototype.InterfaceData = function() { - var v; - v = new Value.Ptr(); $copy(v, this, Value); - (new flag(v.flag)).mustBe(20); - return v.ptr; + uncommonType.prototype.uncommon = function() { return this.$val.uncommon(); }; + uncommonType.Ptr.prototype.PkgPath = function() { + var t; + t = this; + if (t === ($ptrType(uncommonType)).nil || $pointerIsEqual(t.pkgPath, ($ptrType($String)).nil)) { + return ""; + } + return t.pkgPath.$get(); }; - Value.prototype.InterfaceData = function() { return this.$val.InterfaceData(); }; - Value.Ptr.prototype.IsValid = function() { - var v; - v = new Value.Ptr(); $copy(v, this, Value); - return !((v.flag === 0)); + uncommonType.prototype.PkgPath = function() { return this.$val.PkgPath(); }; + uncommonType.Ptr.prototype.Name = function() { + var t; + t = this; + if (t === ($ptrType(uncommonType)).nil || $pointerIsEqual(t.name, ($ptrType($String)).nil)) { + return ""; + } + return t.name.$get(); }; - Value.prototype.IsValid = function() { return this.$val.IsValid(); }; - Value.Ptr.prototype.Kind = function() { - var v; - v = new Value.Ptr(); $copy(v, this, Value); - return (new flag(v.flag)).kind(); + uncommonType.prototype.Name = function() { return this.$val.Name(); }; + rtype.Ptr.prototype.String = function() { + var t; + t = this; + return t.string.$get(); }; - Value.prototype.Kind = function() { return this.$val.Kind(); }; - Value.Ptr.prototype.MapIndex = function(key) { - var v, tt, k, e, typ, fl, c; - v = new Value.Ptr(); $copy(v, this, Value); - (new flag(v.flag)).mustBe(21); - tt = v.typ.mapType; - $copy(key, key.assignTo("reflect.Value.MapIndex", tt.key, ($ptrType($emptyInterface)).nil), Value); - k = 0; - if (!((((key.flag & 2) >>> 0) === 0))) { - k = key.ptr; - } else if (key.typ.pointers()) { - k = new ($ptrType($UnsafePointer))(function() { return this.$target.ptr; }, function($v) { this.$target.ptr = $v; }, key); - } else { - k = new ($ptrType($Uintptr))(function() { return this.$target.scalar; }, function($v) { this.$target.scalar = $v; }, key); + rtype.prototype.String = function() { return this.$val.String(); }; + rtype.Ptr.prototype.Size = function() { + var t; + t = this; + return t.size; + }; + rtype.prototype.Size = function() { return this.$val.Size(); }; + rtype.Ptr.prototype.Bits = function() { + var t, k, x; + t = this; + if (t === ($ptrType(rtype)).nil) { + $panic(new $String("reflect: Bits of nil Type")); } - e = mapaccess(v.typ, v.pointer(), k); - if (e === 0) { - return new Value.Ptr(($ptrType(rtype)).nil, 0, 0, 0); + k = t.Kind(); + if (k < 2 || k > 16) { + $panic(new $String("reflect: Bits of non-arithmetic Type " + t.String())); } - typ = tt.elem; - fl = ((((v.flag | key.flag) >>> 0)) & 1) >>> 0; - fl = (fl | (((typ.Kind() >>> 0) << 4 >>> 0))) >>> 0; - if (typ.size > 4) { - c = unsafe_New(typ); - memmove(c, e, typ.size); - return new Value.Ptr(typ, c, 0, (fl | 2) >>> 0); - } else if (typ.pointers()) { - return new Value.Ptr(typ, e.$get(), 0, fl); - } else { - return new Value.Ptr(typ, 0, loadScalar(e, typ.size), fl); + return (x = (t.size >> 0), (((x >>> 16 << 16) * 8 >> 0) + (x << 16 >>> 16) * 8) >> 0); + }; + rtype.prototype.Bits = function() { return this.$val.Bits(); }; + rtype.Ptr.prototype.Align = function() { + var t; + t = this; + return (t.align >> 0); + }; + rtype.prototype.Align = function() { return this.$val.Align(); }; + rtype.Ptr.prototype.FieldAlign = function() { + var t; + t = this; + return (t.fieldAlign >> 0); + }; + rtype.prototype.FieldAlign = function() { return this.$val.FieldAlign(); }; + rtype.Ptr.prototype.Kind = function() { + var t; + t = this; + return (((t.kind & 127) >>> 0) >>> 0); + }; + rtype.prototype.Kind = function() { return this.$val.Kind(); }; + rtype.Ptr.prototype.common = function() { + var t; + t = this; + return t; + }; + rtype.prototype.common = function() { return this.$val.common(); }; + uncommonType.Ptr.prototype.NumMethod = function() { + var t; + t = this; + if (t === ($ptrType(uncommonType)).nil) { + return 0; } + return t.methods.$length; }; - Value.prototype.MapIndex = function(key) { return this.$val.MapIndex(key); }; - Value.Ptr.prototype.MapKeys = function() { - var v, tt, keyType, fl, m, mlen, it, a, i, key, c; - v = new Value.Ptr(); $copy(v, this, Value); - (new flag(v.flag)).mustBe(21); - tt = v.typ.mapType; - keyType = tt.key; - fl = (((v.flag & 1) >>> 0) | ((keyType.Kind() >>> 0) << 4 >>> 0)) >>> 0; - m = v.pointer(); - mlen = 0; - if (!(m === 0)) { - mlen = maplen(m); + uncommonType.prototype.NumMethod = function() { return this.$val.NumMethod(); }; + uncommonType.Ptr.prototype.MethodByName = function(name) { + var m = new Method.Ptr(), ok = false, t, p, _ref, _i, i, x, _tmp, _tmp$1; + t = this; + if (t === ($ptrType(uncommonType)).nil) { + return [m, ok]; } - it = mapiterinit(v.typ, m); - a = ($sliceType(Value)).make(mlen); - i = 0; - i = 0; - while (i < a.$length) { - key = mapiterkey(it); - if (key === 0) { - break; - } - if (keyType.size > 4) { - c = unsafe_New(keyType); - memmove(c, key, keyType.size); - $copy(((i < 0 || i >= a.$length) ? $throwRuntimeError("index out of range") : a.$array[a.$offset + i]), new Value.Ptr(keyType, c, 0, (fl | 2) >>> 0), Value); - } else if (keyType.pointers()) { - $copy(((i < 0 || i >= a.$length) ? $throwRuntimeError("index out of range") : a.$array[a.$offset + i]), new Value.Ptr(keyType, key.$get(), 0, fl), Value); - } else { - $copy(((i < 0 || i >= a.$length) ? $throwRuntimeError("index out of range") : a.$array[a.$offset + i]), new Value.Ptr(keyType, 0, loadScalar(key, keyType.size), fl), Value); + p = ($ptrType(method)).nil; + _ref = t.methods; + _i = 0; + while (_i < _ref.$length) { + i = _i; + p = (x = t.methods, ((i < 0 || i >= x.$length) ? $throwRuntimeError("index out of range") : x.$array[x.$offset + i])); + if (!($pointerIsEqual(p.name, ($ptrType($String)).nil)) && p.name.$get() === name) { + _tmp = new Method.Ptr(); $copy(_tmp, t.Method(i), Method); _tmp$1 = true; $copy(m, _tmp, Method); ok = _tmp$1; + return [m, ok]; } - mapiternext(it); - i = i + (1) >> 0; + _i++; } - return $subslice(a, 0, i); + return [m, ok]; }; - Value.prototype.MapKeys = function() { return this.$val.MapKeys(); }; - Value.Ptr.prototype.Method = function(i) { - var v, fl; - v = new Value.Ptr(); $copy(v, this, Value); - if (v.typ === ($ptrType(rtype)).nil) { - $panic(new ValueError.Ptr("reflect.Value.Method", 0)); - } - if (!((((v.flag & 8) >>> 0) === 0)) || i < 0 || i >= v.typ.NumMethod()) { - $panic(new $String("reflect: Method index out of range")); - } - if ((v.typ.Kind() === 20) && v.IsNil()) { - $panic(new $String("reflect: Method on nil interface value")); + uncommonType.prototype.MethodByName = function(name) { return this.$val.MethodByName(name); }; + rtype.Ptr.prototype.NumMethod = function() { + var t, tt; + t = this; + if (t.Kind() === 20) { + tt = t.interfaceType; + return tt.NumMethod(); } - fl = (v.flag & 3) >>> 0; - fl = (fl | (304)) >>> 0; - fl = (fl | (((((i >>> 0) << 9 >>> 0) | 8) >>> 0))) >>> 0; - return new Value.Ptr(v.typ, v.ptr, v.scalar, fl); + return t.uncommonType.NumMethod(); }; - Value.prototype.Method = function(i) { return this.$val.Method(i); }; - Value.Ptr.prototype.NumMethod = function() { - var v; - v = new Value.Ptr(); $copy(v, this, Value); - if (v.typ === ($ptrType(rtype)).nil) { - $panic(new ValueError.Ptr("reflect.Value.NumMethod", 0)); + rtype.prototype.NumMethod = function() { return this.$val.NumMethod(); }; + rtype.Ptr.prototype.Method = function(i) { + var m = new Method.Ptr(), t, tt; + t = this; + if (t.Kind() === 20) { + tt = t.interfaceType; + $copy(m, tt.Method(i), Method); + return m; } - if (!((((v.flag & 8) >>> 0) === 0))) { - return 0; + $copy(m, t.uncommonType.Method(i), Method); + return m; + }; + rtype.prototype.Method = function(i) { return this.$val.Method(i); }; + rtype.Ptr.prototype.MethodByName = function(name) { + var m = new Method.Ptr(), ok = false, t, tt, _tuple, _tuple$1; + t = this; + if (t.Kind() === 20) { + tt = t.interfaceType; + _tuple = tt.MethodByName(name); $copy(m, _tuple[0], Method); ok = _tuple[1]; + return [m, ok]; } - return v.typ.NumMethod(); + _tuple$1 = t.uncommonType.MethodByName(name); $copy(m, _tuple$1[0], Method); ok = _tuple$1[1]; + return [m, ok]; }; - Value.prototype.NumMethod = function() { return this.$val.NumMethod(); }; - Value.Ptr.prototype.MethodByName = function(name) { - var v, _tuple, m, ok; - v = new Value.Ptr(); $copy(v, this, Value); - if (v.typ === ($ptrType(rtype)).nil) { - $panic(new ValueError.Ptr("reflect.Value.MethodByName", 0)); + rtype.prototype.MethodByName = function(name) { return this.$val.MethodByName(name); }; + rtype.Ptr.prototype.PkgPath = function() { + var t; + t = this; + return t.uncommonType.PkgPath(); + }; + rtype.prototype.PkgPath = function() { return this.$val.PkgPath(); }; + rtype.Ptr.prototype.Name = function() { + var t; + t = this; + return t.uncommonType.Name(); + }; + rtype.prototype.Name = function() { return this.$val.Name(); }; + rtype.Ptr.prototype.ChanDir = function() { + var t, tt; + t = this; + if (!((t.Kind() === 18))) { + $panic(new $String("reflect: ChanDir of non-chan type")); } - if (!((((v.flag & 8) >>> 0) === 0))) { - return new Value.Ptr(($ptrType(rtype)).nil, 0, 0, 0); + tt = t.chanType; + return (tt.dir >> 0); + }; + rtype.prototype.ChanDir = function() { return this.$val.ChanDir(); }; + rtype.Ptr.prototype.IsVariadic = function() { + var t, tt; + t = this; + if (!((t.Kind() === 19))) { + $panic(new $String("reflect: IsVariadic of non-func type")); } - _tuple = v.typ.MethodByName(name); m = new Method.Ptr(); $copy(m, _tuple[0], Method); ok = _tuple[1]; - if (!ok) { - return new Value.Ptr(($ptrType(rtype)).nil, 0, 0, 0); + tt = t.funcType; + return tt.dotdotdot; + }; + rtype.prototype.IsVariadic = function() { return this.$val.IsVariadic(); }; + rtype.Ptr.prototype.Elem = function() { + var t, _ref, tt, tt$1, tt$2, tt$3, tt$4; + t = this; + _ref = t.Kind(); + if (_ref === 17) { + tt = t.arrayType; + return toType(tt.elem); + } else if (_ref === 18) { + tt$1 = t.chanType; + return toType(tt$1.elem); + } else if (_ref === 21) { + tt$2 = t.mapType; + return toType(tt$2.elem); + } else if (_ref === 22) { + tt$3 = t.ptrType; + return toType(tt$3.elem); + } else if (_ref === 23) { + tt$4 = t.sliceType; + return toType(tt$4.elem); } - return v.Method(m.Index); + $panic(new $String("reflect: Elem of invalid type")); }; - Value.prototype.MethodByName = function(name) { return this.$val.MethodByName(name); }; - Value.Ptr.prototype.NumField = function() { - var v, tt; - v = new Value.Ptr(); $copy(v, this, Value); - (new flag(v.flag)).mustBe(25); - tt = v.typ.structType; - return tt.fields.$length; + rtype.prototype.Elem = function() { return this.$val.Elem(); }; + rtype.Ptr.prototype.Field = function(i) { + var t, tt; + t = this; + if (!((t.Kind() === 25))) { + $panic(new $String("reflect: Field of non-struct type")); + } + tt = t.structType; + return tt.Field(i); }; - Value.prototype.NumField = function() { return this.$val.NumField(); }; - Value.Ptr.prototype.OverflowComplex = function(x) { - var v, k, _ref; - v = new Value.Ptr(); $copy(v, this, Value); - k = (new flag(v.flag)).kind(); - _ref = k; - if (_ref === 15) { - return overflowFloat32(x.$real) || overflowFloat32(x.$imag); - } else if (_ref === 16) { - return false; + rtype.prototype.Field = function(i) { return this.$val.Field(i); }; + rtype.Ptr.prototype.FieldByIndex = function(index) { + var t, tt; + t = this; + if (!((t.Kind() === 25))) { + $panic(new $String("reflect: FieldByIndex of non-struct type")); } - $panic(new ValueError.Ptr("reflect.Value.OverflowComplex", k)); + tt = t.structType; + return tt.FieldByIndex(index); }; - Value.prototype.OverflowComplex = function(x) { return this.$val.OverflowComplex(x); }; - Value.Ptr.prototype.OverflowFloat = function(x) { - var v, k, _ref; - v = new Value.Ptr(); $copy(v, this, Value); - k = (new flag(v.flag)).kind(); - _ref = k; - if (_ref === 13) { - return overflowFloat32(x); - } else if (_ref === 14) { - return false; + rtype.prototype.FieldByIndex = function(index) { return this.$val.FieldByIndex(index); }; + rtype.Ptr.prototype.FieldByName = function(name) { + var t, tt; + t = this; + if (!((t.Kind() === 25))) { + $panic(new $String("reflect: FieldByName of non-struct type")); } - $panic(new ValueError.Ptr("reflect.Value.OverflowFloat", k)); + tt = t.structType; + return tt.FieldByName(name); }; - Value.prototype.OverflowFloat = function(x) { return this.$val.OverflowFloat(x); }; - overflowFloat32 = function(x) { - if (x < 0) { - x = -x; + rtype.prototype.FieldByName = function(name) { return this.$val.FieldByName(name); }; + rtype.Ptr.prototype.FieldByNameFunc = function(match) { + var t, tt; + t = this; + if (!((t.Kind() === 25))) { + $panic(new $String("reflect: FieldByNameFunc of non-struct type")); } - return 3.4028234663852886e+38 < x && x <= 1.7976931348623157e+308; + tt = t.structType; + return tt.FieldByNameFunc(match); }; - Value.Ptr.prototype.OverflowInt = function(x) { - var v, k, _ref, x$1, bitSize, trunc; - v = new Value.Ptr(); $copy(v, this, Value); - k = (new flag(v.flag)).kind(); - _ref = k; - if (_ref === 2 || _ref === 3 || _ref === 4 || _ref === 5 || _ref === 6) { - bitSize = (x$1 = v.typ.size, (((x$1 >>> 16 << 16) * 8 >>> 0) + (x$1 << 16 >>> 16) * 8) >>> 0); - trunc = $shiftRightInt64(($shiftLeft64(x, ((64 - bitSize >>> 0)))), ((64 - bitSize >>> 0))); - return !((x.$high === trunc.$high && x.$low === trunc.$low)); + rtype.prototype.FieldByNameFunc = function(match) { return this.$val.FieldByNameFunc(match); }; + rtype.Ptr.prototype.In = function(i) { + var t, tt, x; + t = this; + if (!((t.Kind() === 19))) { + $panic(new $String("reflect: In of non-func type")); } - $panic(new ValueError.Ptr("reflect.Value.OverflowInt", k)); + tt = t.funcType; + return toType((x = tt.in$2, ((i < 0 || i >= x.$length) ? $throwRuntimeError("index out of range") : x.$array[x.$offset + i]))); }; - Value.prototype.OverflowInt = function(x) { return this.$val.OverflowInt(x); }; - Value.Ptr.prototype.OverflowUint = function(x) { - var v, k, _ref, x$1, bitSize, trunc; - v = new Value.Ptr(); $copy(v, this, Value); - k = (new flag(v.flag)).kind(); - _ref = k; - if (_ref === 7 || _ref === 12 || _ref === 8 || _ref === 9 || _ref === 10 || _ref === 11) { - bitSize = (x$1 = v.typ.size, (((x$1 >>> 16 << 16) * 8 >>> 0) + (x$1 << 16 >>> 16) * 8) >>> 0); - trunc = $shiftRightUint64(($shiftLeft64(x, ((64 - bitSize >>> 0)))), ((64 - bitSize >>> 0))); - return !((x.$high === trunc.$high && x.$low === trunc.$low)); + rtype.prototype.In = function(i) { return this.$val.In(i); }; + rtype.Ptr.prototype.Key = function() { + var t, tt; + t = this; + if (!((t.Kind() === 21))) { + $panic(new $String("reflect: Key of non-map type")); } - $panic(new ValueError.Ptr("reflect.Value.OverflowUint", k)); + tt = t.mapType; + return toType(tt.key); }; - Value.prototype.OverflowUint = function(x) { return this.$val.OverflowUint(x); }; - Value.Ptr.prototype.SetBool = function(x) { - var v; - v = new Value.Ptr(); $copy(v, this, Value); - (new flag(v.flag)).mustBeAssignable(); - (new flag(v.flag)).mustBe(1); - v.ptr.$set(x); + rtype.prototype.Key = function() { return this.$val.Key(); }; + rtype.Ptr.prototype.Len = function() { + var t, tt; + t = this; + if (!((t.Kind() === 17))) { + $panic(new $String("reflect: Len of non-array type")); + } + tt = t.arrayType; + return (tt.len >> 0); }; - Value.prototype.SetBool = function(x) { return this.$val.SetBool(x); }; - Value.Ptr.prototype.SetBytes = function(x) { - var v; - v = new Value.Ptr(); $copy(v, this, Value); - (new flag(v.flag)).mustBeAssignable(); - (new flag(v.flag)).mustBe(23); - if (!((v.typ.Elem().Kind() === 8))) { - $panic(new $String("reflect.Value.SetBytes of non-byte slice")); + rtype.prototype.Len = function() { return this.$val.Len(); }; + rtype.Ptr.prototype.NumField = function() { + var t, tt; + t = this; + if (!((t.Kind() === 25))) { + $panic(new $String("reflect: NumField of non-struct type")); } - v.ptr.$set(x); + tt = t.structType; + return tt.fields.$length; }; - Value.prototype.SetBytes = function(x) { return this.$val.SetBytes(x); }; - Value.Ptr.prototype.setRunes = function(x) { - var v; - v = new Value.Ptr(); $copy(v, this, Value); - (new flag(v.flag)).mustBeAssignable(); - (new flag(v.flag)).mustBe(23); - if (!((v.typ.Elem().Kind() === 5))) { - $panic(new $String("reflect.Value.setRunes of non-rune slice")); + rtype.prototype.NumField = function() { return this.$val.NumField(); }; + rtype.Ptr.prototype.NumIn = function() { + var t, tt; + t = this; + if (!((t.Kind() === 19))) { + $panic(new $String("reflect: NumIn of non-func type")); } - v.ptr.$set(x); + tt = t.funcType; + return tt.in$2.$length; }; - Value.prototype.setRunes = function(x) { return this.$val.setRunes(x); }; - Value.Ptr.prototype.SetComplex = function(x) { - var v, k, _ref; - v = new Value.Ptr(); $copy(v, this, Value); - (new flag(v.flag)).mustBeAssignable(); - k = (new flag(v.flag)).kind(); - _ref = k; - if (_ref === 15) { - v.ptr.$set(new $Complex64(x.$real, x.$imag)); - } else if (_ref === 16) { - v.ptr.$set(x); - } else { - $panic(new ValueError.Ptr("reflect.Value.SetComplex", k)); + rtype.prototype.NumIn = function() { return this.$val.NumIn(); }; + rtype.Ptr.prototype.NumOut = function() { + var t, tt; + t = this; + if (!((t.Kind() === 19))) { + $panic(new $String("reflect: NumOut of non-func type")); } + tt = t.funcType; + return tt.out.$length; }; - Value.prototype.SetComplex = function(x) { return this.$val.SetComplex(x); }; - Value.Ptr.prototype.SetFloat = function(x) { - var v, k, _ref; - v = new Value.Ptr(); $copy(v, this, Value); - (new flag(v.flag)).mustBeAssignable(); - k = (new flag(v.flag)).kind(); - _ref = k; - if (_ref === 13) { - v.ptr.$set(x); - } else if (_ref === 14) { - v.ptr.$set(x); - } else { - $panic(new ValueError.Ptr("reflect.Value.SetFloat", k)); + rtype.prototype.NumOut = function() { return this.$val.NumOut(); }; + rtype.Ptr.prototype.Out = function(i) { + var t, tt, x; + t = this; + if (!((t.Kind() === 19))) { + $panic(new $String("reflect: Out of non-func type")); } + tt = t.funcType; + return toType((x = tt.out, ((i < 0 || i >= x.$length) ? $throwRuntimeError("index out of range") : x.$array[x.$offset + i]))); }; - Value.prototype.SetFloat = function(x) { return this.$val.SetFloat(x); }; - Value.Ptr.prototype.SetInt = function(x) { - var v, k, _ref; - v = new Value.Ptr(); $copy(v, this, Value); - (new flag(v.flag)).mustBeAssignable(); - k = (new flag(v.flag)).kind(); - _ref = k; + rtype.prototype.Out = function(i) { return this.$val.Out(i); }; + ChanDir.prototype.String = function() { + var d, _ref; + d = this.$val !== undefined ? this.$val : this; + _ref = d; if (_ref === 2) { - v.ptr.$set(((x.$low + ((x.$high >> 31) * 4294967296)) >> 0)); + return "chan<-"; + } else if (_ref === 1) { + return "<-chan"; } else if (_ref === 3) { - v.ptr.$set(((x.$low + ((x.$high >> 31) * 4294967296)) << 24 >> 24)); - } else if (_ref === 4) { - v.ptr.$set(((x.$low + ((x.$high >> 31) * 4294967296)) << 16 >> 16)); - } else if (_ref === 5) { - v.ptr.$set(((x.$low + ((x.$high >> 31) * 4294967296)) >> 0)); - } else if (_ref === 6) { - v.ptr.$set(x); - } else { - $panic(new ValueError.Ptr("reflect.Value.SetInt", k)); + return "chan"; } + return "ChanDir" + strconv.Itoa((d >> 0)); }; - Value.prototype.SetInt = function(x) { return this.$val.SetInt(x); }; - Value.Ptr.prototype.SetMapIndex = function(key, val) { - var v, tt, k, e; - v = new Value.Ptr(); $copy(v, this, Value); - (new flag(v.flag)).mustBe(21); - (new flag(v.flag)).mustBeExported(); - (new flag(key.flag)).mustBeExported(); - tt = v.typ.mapType; - $copy(key, key.assignTo("reflect.Value.SetMapIndex", tt.key, ($ptrType($emptyInterface)).nil), Value); - k = 0; - if (!((((key.flag & 2) >>> 0) === 0))) { - k = key.ptr; - } else if (key.typ.pointers()) { - k = new ($ptrType($UnsafePointer))(function() { return this.$target.ptr; }, function($v) { this.$target.ptr = $v; }, key); - } else { - k = new ($ptrType($Uintptr))(function() { return this.$target.scalar; }, function($v) { this.$target.scalar = $v; }, key); - } - if (val.typ === ($ptrType(rtype)).nil) { - mapdelete(v.typ, v.pointer(), k); - return; + $ptrType(ChanDir).prototype.String = function() { return new ChanDir(this.$get()).String(); }; + interfaceType.Ptr.prototype.Method = function(i) { + var m = new Method.Ptr(), t, x, p; + t = this; + if (i < 0 || i >= t.methods.$length) { + return m; } - (new flag(val.flag)).mustBeExported(); - $copy(val, val.assignTo("reflect.Value.SetMapIndex", tt.elem, ($ptrType($emptyInterface)).nil), Value); - e = 0; - if (!((((val.flag & 2) >>> 0) === 0))) { - e = val.ptr; - } else if (val.typ.pointers()) { - e = new ($ptrType($UnsafePointer))(function() { return this.$target.ptr; }, function($v) { this.$target.ptr = $v; }, val); - } else { - e = new ($ptrType($Uintptr))(function() { return this.$target.scalar; }, function($v) { this.$target.scalar = $v; }, val); + p = (x = t.methods, ((i < 0 || i >= x.$length) ? $throwRuntimeError("index out of range") : x.$array[x.$offset + i])); + m.Name = p.name.$get(); + if (!($pointerIsEqual(p.pkgPath, ($ptrType($String)).nil))) { + m.PkgPath = p.pkgPath.$get(); } - mapassign(v.typ, v.pointer(), k, e); + m.Type = toType(p.typ); + m.Index = i; + return m; }; - Value.prototype.SetMapIndex = function(key, val) { return this.$val.SetMapIndex(key, val); }; - Value.Ptr.prototype.SetUint = function(x) { - var v, k, _ref; - v = new Value.Ptr(); $copy(v, this, Value); - (new flag(v.flag)).mustBeAssignable(); - k = (new flag(v.flag)).kind(); - _ref = k; - if (_ref === 7) { - v.ptr.$set((x.$low >>> 0)); - } else if (_ref === 8) { - v.ptr.$set((x.$low << 24 >>> 24)); - } else if (_ref === 9) { - v.ptr.$set((x.$low << 16 >>> 16)); - } else if (_ref === 10) { - v.ptr.$set((x.$low >>> 0)); - } else if (_ref === 11) { - v.ptr.$set(x); - } else if (_ref === 12) { - v.ptr.$set((x.$low >>> 0)); - } else { - $panic(new ValueError.Ptr("reflect.Value.SetUint", k)); - } - }; - Value.prototype.SetUint = function(x) { return this.$val.SetUint(x); }; - Value.Ptr.prototype.SetPointer = function(x) { - var v; - v = new Value.Ptr(); $copy(v, this, Value); - (new flag(v.flag)).mustBeAssignable(); - (new flag(v.flag)).mustBe(26); - v.ptr.$set(x); - }; - Value.prototype.SetPointer = function(x) { return this.$val.SetPointer(x); }; - Value.Ptr.prototype.SetString = function(x) { - var v; - v = new Value.Ptr(); $copy(v, this, Value); - (new flag(v.flag)).mustBeAssignable(); - (new flag(v.flag)).mustBe(24); - v.ptr.$set(x); + interfaceType.prototype.Method = function(i) { return this.$val.Method(i); }; + interfaceType.Ptr.prototype.NumMethod = function() { + var t; + t = this; + return t.methods.$length; }; - Value.prototype.SetString = function(x) { return this.$val.SetString(x); }; - Value.Ptr.prototype.String = function() { - var v, k, _ref; - v = new Value.Ptr(); $copy(v, this, Value); - k = (new flag(v.flag)).kind(); - _ref = k; - if (_ref === 0) { - return ""; - } else if (_ref === 24) { - return v.ptr.$get(); + interfaceType.prototype.NumMethod = function() { return this.$val.NumMethod(); }; + interfaceType.Ptr.prototype.MethodByName = function(name) { + var m = new Method.Ptr(), ok = false, t, p, _ref, _i, i, x, _tmp, _tmp$1; + t = this; + if (t === ($ptrType(interfaceType)).nil) { + return [m, ok]; } - return "<" + v.typ.String() + " Value>"; + p = ($ptrType(imethod)).nil; + _ref = t.methods; + _i = 0; + while (_i < _ref.$length) { + i = _i; + p = (x = t.methods, ((i < 0 || i >= x.$length) ? $throwRuntimeError("index out of range") : x.$array[x.$offset + i])); + if (p.name.$get() === name) { + _tmp = new Method.Ptr(); $copy(_tmp, t.Method(i), Method); _tmp$1 = true; $copy(m, _tmp, Method); ok = _tmp$1; + return [m, ok]; + } + _i++; + } + return [m, ok]; }; - Value.prototype.String = function() { return this.$val.String(); }; - Value.Ptr.prototype.Type = function() { - var v, f, i, tt, x, m, ut, x$1, m$1; - v = new Value.Ptr(); $copy(v, this, Value); - f = v.flag; - if (f === 0) { - $panic(new ValueError.Ptr("reflect.Value.Type", 0)); + interfaceType.prototype.MethodByName = function(name) { return this.$val.MethodByName(name); }; + StructTag.prototype.Get = function(key) { + var tag, i, name, qvalue, _tuple, value; + tag = this.$val !== undefined ? this.$val : this; + while (!(tag === "")) { + i = 0; + while (i < tag.length && (tag.charCodeAt(i) === 32)) { + i = i + (1) >> 0; + } + tag = tag.substring(i); + if (tag === "") { + break; + } + i = 0; + while (i < tag.length && !((tag.charCodeAt(i) === 32)) && !((tag.charCodeAt(i) === 58)) && !((tag.charCodeAt(i) === 34))) { + i = i + (1) >> 0; + } + if ((i + 1 >> 0) >= tag.length || !((tag.charCodeAt(i) === 58)) || !((tag.charCodeAt((i + 1 >> 0)) === 34))) { + break; + } + name = tag.substring(0, i); + tag = tag.substring((i + 1 >> 0)); + i = 1; + while (i < tag.length && !((tag.charCodeAt(i) === 34))) { + if (tag.charCodeAt(i) === 92) { + i = i + (1) >> 0; + } + i = i + (1) >> 0; + } + if (i >= tag.length) { + break; + } + qvalue = tag.substring(0, (i + 1 >> 0)); + tag = tag.substring((i + 1 >> 0)); + if (key === name) { + _tuple = strconv.Unquote(qvalue); value = _tuple[0]; + return value; + } } - if (((f & 8) >>> 0) === 0) { - return v.typ; + return ""; + }; + $ptrType(StructTag).prototype.Get = function(key) { return new StructTag(this.$get()).Get(key); }; + structType.Ptr.prototype.Field = function(i) { + var f = new StructField.Ptr(), t, x, p, t$1; + t = this; + if (i < 0 || i >= t.fields.$length) { + return f; } - i = (v.flag >> 0) >> 9 >> 0; - if (v.typ.Kind() === 20) { - tt = v.typ.interfaceType; - if (i < 0 || i >= tt.methods.$length) { - $panic(new $String("reflect: internal error: invalid method index")); + p = (x = t.fields, ((i < 0 || i >= x.$length) ? $throwRuntimeError("index out of range") : x.$array[x.$offset + i])); + f.Type = toType(p.typ); + if (!($pointerIsEqual(p.name, ($ptrType($String)).nil))) { + f.Name = p.name.$get(); + } else { + t$1 = f.Type; + if (t$1.Kind() === 22) { + t$1 = t$1.Elem(); } - m = (x = tt.methods, ((i < 0 || i >= x.$length) ? $throwRuntimeError("index out of range") : x.$array[x.$offset + i])); - return m.typ; + f.Name = t$1.Name(); + f.Anonymous = true; } - ut = v.typ.uncommonType.uncommon(); - if (ut === ($ptrType(uncommonType)).nil || i < 0 || i >= ut.methods.$length) { - $panic(new $String("reflect: internal error: invalid method index")); + if (!($pointerIsEqual(p.pkgPath, ($ptrType($String)).nil))) { + f.PkgPath = p.pkgPath.$get(); } - m$1 = (x$1 = ut.methods, ((i < 0 || i >= x$1.$length) ? $throwRuntimeError("index out of range") : x$1.$array[x$1.$offset + i])); - return m$1.mtyp; + if (!($pointerIsEqual(p.tag, ($ptrType($String)).nil))) { + f.Tag = p.tag.$get(); + } + f.Offset = p.offset; + f.Index = new ($sliceType($Int))([i]); + return f; }; - Value.prototype.Type = function() { return this.$val.Type(); }; - Value.Ptr.prototype.Uint = function() { - var v, k, p, _ref, x; - v = new Value.Ptr(); $copy(v, this, Value); - k = (new flag(v.flag)).kind(); - p = 0; - if (!((((v.flag & 2) >>> 0) === 0))) { - p = v.ptr; - } else { - p = new ($ptrType($Uintptr))(function() { return this.$target.scalar; }, function($v) { this.$target.scalar = $v; }, v); + structType.prototype.Field = function(i) { return this.$val.Field(i); }; + structType.Ptr.prototype.FieldByIndex = function(index) { + var f = new StructField.Ptr(), t, _ref, _i, i, x, ft; + t = this; + f.Type = toType(t.rtype); + _ref = index; + _i = 0; + while (_i < _ref.$length) { + i = _i; + x = ((_i < 0 || _i >= _ref.$length) ? $throwRuntimeError("index out of range") : _ref.$array[_ref.$offset + _i]); + if (i > 0) { + ft = f.Type; + if ((ft.Kind() === 22) && (ft.Elem().Kind() === 25)) { + ft = ft.Elem(); + } + f.Type = ft; + } + $copy(f, f.Type.Field(x), StructField); + _i++; } - _ref = k; - if (_ref === 7) { - return new $Uint64(0, p.$get()); - } else if (_ref === 8) { - return new $Uint64(0, p.$get()); - } else if (_ref === 9) { - return new $Uint64(0, p.$get()); - } else if (_ref === 10) { - return new $Uint64(0, p.$get()); - } else if (_ref === 11) { - return p.$get(); - } else if (_ref === 12) { - return (x = p.$get(), new $Uint64(0, x.constructor === Number ? x : 1)); + return f; + }; + structType.prototype.FieldByIndex = function(index) { return this.$val.FieldByIndex(index); }; + structType.Ptr.prototype.FieldByNameFunc = function(match) { + var result = new StructField.Ptr(), ok = false, t, current, next, nextCount, visited, _map, _key, _tmp, _tmp$1, count, _ref, _i, scan, t$1, _entry, _key$1, _ref$1, _i$1, i, x, f, fname, ntyp, _entry$1, _tmp$2, _tmp$3, styp, _entry$2, _key$2, _map$1, _key$3, _key$4, _entry$3, _key$5, index; + t = this; + current = new ($sliceType(fieldScan))([]); + next = new ($sliceType(fieldScan))([new fieldScan.Ptr(t, ($sliceType($Int)).nil)]); + nextCount = false; + visited = (_map = new $Map(), _map); + while (next.$length > 0) { + _tmp = next; _tmp$1 = $subslice(current, 0, 0); current = _tmp; next = _tmp$1; + count = nextCount; + nextCount = false; + _ref = current; + _i = 0; + while (_i < _ref.$length) { + scan = new fieldScan.Ptr(); $copy(scan, ((_i < 0 || _i >= _ref.$length) ? $throwRuntimeError("index out of range") : _ref.$array[_ref.$offset + _i]), fieldScan); + t$1 = scan.typ; + if ((_entry = visited[t$1.$key()], _entry !== undefined ? _entry.v : false)) { + _i++; + continue; + } + _key$1 = t$1; (visited || $throwRuntimeError("assignment to entry in nil map"))[_key$1.$key()] = { k: _key$1, v: true }; + _ref$1 = t$1.fields; + _i$1 = 0; + while (_i$1 < _ref$1.$length) { + i = _i$1; + f = (x = t$1.fields, ((i < 0 || i >= x.$length) ? $throwRuntimeError("index out of range") : x.$array[x.$offset + i])); + fname = ""; + ntyp = ($ptrType(rtype)).nil; + if (!($pointerIsEqual(f.name, ($ptrType($String)).nil))) { + fname = f.name.$get(); + } else { + ntyp = f.typ; + if (ntyp.Kind() === 22) { + ntyp = ntyp.Elem().common(); + } + fname = ntyp.Name(); + } + if (match(fname)) { + if ((_entry$1 = count[t$1.$key()], _entry$1 !== undefined ? _entry$1.v : 0) > 1 || ok) { + _tmp$2 = new StructField.Ptr("", "", $ifaceNil, "", 0, ($sliceType($Int)).nil, false); _tmp$3 = false; $copy(result, _tmp$2, StructField); ok = _tmp$3; + return [result, ok]; + } + $copy(result, t$1.Field(i), StructField); + result.Index = ($sliceType($Int)).nil; + result.Index = $appendSlice(result.Index, scan.index); + result.Index = $append(result.Index, i); + ok = true; + _i$1++; + continue; + } + if (ok || ntyp === ($ptrType(rtype)).nil || !((ntyp.Kind() === 25))) { + _i$1++; + continue; + } + styp = ntyp.structType; + if ((_entry$2 = nextCount[styp.$key()], _entry$2 !== undefined ? _entry$2.v : 0) > 0) { + _key$2 = styp; (nextCount || $throwRuntimeError("assignment to entry in nil map"))[_key$2.$key()] = { k: _key$2, v: 2 }; + _i$1++; + continue; + } + if (nextCount === false) { + nextCount = (_map$1 = new $Map(), _map$1); + } + _key$4 = styp; (nextCount || $throwRuntimeError("assignment to entry in nil map"))[_key$4.$key()] = { k: _key$4, v: 1 }; + if ((_entry$3 = count[t$1.$key()], _entry$3 !== undefined ? _entry$3.v : 0) > 1) { + _key$5 = styp; (nextCount || $throwRuntimeError("assignment to entry in nil map"))[_key$5.$key()] = { k: _key$5, v: 2 }; + } + index = ($sliceType($Int)).nil; + index = $appendSlice(index, scan.index); + index = $append(index, i); + next = $append(next, new fieldScan.Ptr(styp, index)); + _i$1++; + } + _i++; + } + if (ok) { + break; + } } - $panic(new ValueError.Ptr("reflect.Value.Uint", k)); + return [result, ok]; }; - Value.prototype.Uint = function() { return this.$val.Uint(); }; - Value.Ptr.prototype.UnsafeAddr = function() { - var v; - v = new Value.Ptr(); $copy(v, this, Value); - if (v.typ === ($ptrType(rtype)).nil) { - $panic(new ValueError.Ptr("reflect.Value.UnsafeAddr", 0)); + structType.prototype.FieldByNameFunc = function(match) { return this.$val.FieldByNameFunc(match); }; + structType.Ptr.prototype.FieldByName = function(name) { + var f = new StructField.Ptr(), present = false, t, hasAnon, _ref, _i, i, x, tf, _tmp, _tmp$1, _tuple; + t = this; + hasAnon = false; + if (!(name === "")) { + _ref = t.fields; + _i = 0; + while (_i < _ref.$length) { + i = _i; + tf = (x = t.fields, ((i < 0 || i >= x.$length) ? $throwRuntimeError("index out of range") : x.$array[x.$offset + i])); + if ($pointerIsEqual(tf.name, ($ptrType($String)).nil)) { + hasAnon = true; + _i++; + continue; + } + if (tf.name.$get() === name) { + _tmp = new StructField.Ptr(); $copy(_tmp, t.Field(i), StructField); _tmp$1 = true; $copy(f, _tmp, StructField); present = _tmp$1; + return [f, present]; + } + _i++; + } } - if (((v.flag & 4) >>> 0) === 0) { - $panic(new $String("reflect.Value.UnsafeAddr of unaddressable value")); + if (!hasAnon) { + return [f, present]; } - return v.ptr; + _tuple = t.FieldByNameFunc((function(s) { + return s === name; + })); $copy(f, _tuple[0], StructField); present = _tuple[1]; + return [f, present]; }; - Value.prototype.UnsafeAddr = function() { return this.$val.UnsafeAddr(); }; - typesMustMatch = function(what, t1, t2) { - if (!($interfaceIsEqual(t1, t2))) { - $panic(new $String(what + ": " + t1.String() + " != " + t2.String())); - } + structType.prototype.FieldByName = function(name) { return this.$val.FieldByName(name); }; + PtrTo = $pkg.PtrTo = function(t) { + return $assertType(t, ($ptrType(rtype))).ptrTo(); }; - MakeMap = $pkg.MakeMap = function(typ) { - var m; - if (!((typ.Kind() === 21))) { - $panic(new $String("reflect.MakeMap of non-map type")); + rtype.Ptr.prototype.Implements = function(u) { + var t; + t = this; + if ($interfaceIsEqual(u, $ifaceNil)) { + $panic(new $String("reflect: nil type passed to Type.Implements")); } - m = makemap($assertType(typ, ($ptrType(rtype)))); - return new Value.Ptr(typ.common(), m, 0, 336); - }; - Indirect = $pkg.Indirect = function(v) { - if (!((v.Kind() === 22))) { - return v; + if (!((u.Kind() === 20))) { + $panic(new $String("reflect: non-interface type passed to Type.Implements")); } - return v.Elem(); + return implements$1($assertType(u, ($ptrType(rtype))), t); }; - New = $pkg.New = function(typ) { - var ptr, fl; - if ($interfaceIsEqual(typ, $ifaceNil)) { - $panic(new $String("reflect: New(nil)")); + rtype.prototype.Implements = function(u) { return this.$val.Implements(u); }; + rtype.Ptr.prototype.AssignableTo = function(u) { + var t, uu; + t = this; + if ($interfaceIsEqual(u, $ifaceNil)) { + $panic(new $String("reflect: nil type passed to Type.AssignableTo")); } - ptr = unsafe_New($assertType(typ, ($ptrType(rtype)))); - fl = 352; - return new Value.Ptr(typ.common().ptrTo(), ptr, 0, fl); + uu = $assertType(u, ($ptrType(rtype))); + return directlyAssignable(uu, t) || implements$1(uu, t); }; - Value.Ptr.prototype.assignTo = function(context, dst, target) { - var v, fl, x; - v = new Value.Ptr(); $copy(v, this, Value); - if (!((((v.flag & 8) >>> 0) === 0))) { - $copy(v, makeMethodValue(context, $clone(v, Value)), Value); - } - if (directlyAssignable(dst, v.typ)) { - v.typ = dst; - fl = (v.flag & 7) >>> 0; - fl = (fl | (((dst.Kind() >>> 0) << 4 >>> 0))) >>> 0; - return new Value.Ptr(dst, v.ptr, v.scalar, fl); - } else if (implements$1(dst, v.typ)) { - if (target === ($ptrType($emptyInterface)).nil) { - target = $newDataPointer($ifaceNil, ($ptrType($emptyInterface))); - } - x = valueInterface($clone(v, Value), false); - if (dst.NumMethod() === 0) { - target.$set(x); - } else { - ifaceE2I(dst, x, target); - } - return new Value.Ptr(dst, target, 0, 322); + rtype.prototype.AssignableTo = function(u) { return this.$val.AssignableTo(u); }; + rtype.Ptr.prototype.ConvertibleTo = function(u) { + var t, uu; + t = this; + if ($interfaceIsEqual(u, $ifaceNil)) { + $panic(new $String("reflect: nil type passed to Type.ConvertibleTo")); } - $panic(new $String(context + ": value of type " + v.typ.String() + " is not assignable to type " + dst.String())); + uu = $assertType(u, ($ptrType(rtype))); + return !(convertOp(uu, t) === $throwNilPointerError); }; - Value.prototype.assignTo = function(context, dst, target) { return this.$val.assignTo(context, dst, target); }; - Value.Ptr.prototype.Convert = function(t) { - var v, op; - v = new Value.Ptr(); $copy(v, this, Value); - if (!((((v.flag & 8) >>> 0) === 0))) { - $copy(v, makeMethodValue("Convert", $clone(v, Value)), Value); + rtype.prototype.ConvertibleTo = function(u) { return this.$val.ConvertibleTo(u); }; + implements$1 = function(T, V) { + var t, v, i, j, x, tm, x$1, vm, v$1, i$1, j$1, x$2, tm$1, x$3, vm$1; + if (!((T.Kind() === 20))) { + return false; } - op = convertOp(t.common(), v.typ); - if (op === $throwNilPointerError) { - $panic(new $String("reflect.Value.Convert: value of type " + v.typ.String() + " cannot be converted to type " + t.String())); + t = T.interfaceType; + if (t.methods.$length === 0) { + return true; } - return op($clone(v, Value), t); - }; - Value.prototype.Convert = function(t) { return this.$val.Convert(t); }; - convertOp = function(dst, src) { - var _ref, _ref$1, _ref$2, _ref$3, _ref$4, _ref$5, _ref$6; - _ref = src.Kind(); - if (_ref === 2 || _ref === 3 || _ref === 4 || _ref === 5 || _ref === 6) { - _ref$1 = dst.Kind(); - if (_ref$1 === 2 || _ref$1 === 3 || _ref$1 === 4 || _ref$1 === 5 || _ref$1 === 6 || _ref$1 === 7 || _ref$1 === 8 || _ref$1 === 9 || _ref$1 === 10 || _ref$1 === 11 || _ref$1 === 12) { - return cvtInt; - } else if (_ref$1 === 13 || _ref$1 === 14) { - return cvtIntFloat; - } else if (_ref$1 === 24) { - return cvtIntString; - } - } else if (_ref === 7 || _ref === 8 || _ref === 9 || _ref === 10 || _ref === 11 || _ref === 12) { - _ref$2 = dst.Kind(); - if (_ref$2 === 2 || _ref$2 === 3 || _ref$2 === 4 || _ref$2 === 5 || _ref$2 === 6 || _ref$2 === 7 || _ref$2 === 8 || _ref$2 === 9 || _ref$2 === 10 || _ref$2 === 11 || _ref$2 === 12) { - return cvtUint; - } else if (_ref$2 === 13 || _ref$2 === 14) { - return cvtUintFloat; - } else if (_ref$2 === 24) { - return cvtUintString; - } - } else if (_ref === 13 || _ref === 14) { - _ref$3 = dst.Kind(); - if (_ref$3 === 2 || _ref$3 === 3 || _ref$3 === 4 || _ref$3 === 5 || _ref$3 === 6) { - return cvtFloatInt; - } else if (_ref$3 === 7 || _ref$3 === 8 || _ref$3 === 9 || _ref$3 === 10 || _ref$3 === 11 || _ref$3 === 12) { - return cvtFloatUint; - } else if (_ref$3 === 13 || _ref$3 === 14) { - return cvtFloat; - } - } else if (_ref === 15 || _ref === 16) { - _ref$4 = dst.Kind(); - if (_ref$4 === 15 || _ref$4 === 16) { - return cvtComplex; - } - } else if (_ref === 24) { - if ((dst.Kind() === 23) && dst.Elem().PkgPath() === "") { - _ref$5 = dst.Elem().Kind(); - if (_ref$5 === 8) { - return cvtStringBytes; - } else if (_ref$5 === 5) { - return cvtStringRunes; - } - } - } else if (_ref === 23) { - if ((dst.Kind() === 24) && src.Elem().PkgPath() === "") { - _ref$6 = src.Elem().Kind(); - if (_ref$6 === 8) { - return cvtBytesString; - } else if (_ref$6 === 5) { - return cvtRunesString; + if (V.Kind() === 20) { + v = V.interfaceType; + i = 0; + j = 0; + while (j < v.methods.$length) { + tm = (x = t.methods, ((i < 0 || i >= x.$length) ? $throwRuntimeError("index out of range") : x.$array[x.$offset + i])); + vm = (x$1 = v.methods, ((j < 0 || j >= x$1.$length) ? $throwRuntimeError("index out of range") : x$1.$array[x$1.$offset + j])); + if ($pointerIsEqual(vm.name, tm.name) && $pointerIsEqual(vm.pkgPath, tm.pkgPath) && vm.typ === tm.typ) { + i = i + (1) >> 0; + if (i >= t.methods.$length) { + return true; + } } + j = j + (1) >> 0; } + return false; } - if (haveIdenticalUnderlyingType(dst, src)) { - return cvtDirect; - } - if ((dst.Kind() === 22) && dst.Name() === "" && (src.Kind() === 22) && src.Name() === "" && haveIdenticalUnderlyingType(dst.Elem().common(), src.Elem().common())) { - return cvtDirect; + v$1 = V.uncommonType.uncommon(); + if (v$1 === ($ptrType(uncommonType)).nil) { + return false; } - if (implements$1(dst, src)) { - if (src.Kind() === 20) { - return cvtI2I; + i$1 = 0; + j$1 = 0; + while (j$1 < v$1.methods.$length) { + tm$1 = (x$2 = t.methods, ((i$1 < 0 || i$1 >= x$2.$length) ? $throwRuntimeError("index out of range") : x$2.$array[x$2.$offset + i$1])); + vm$1 = (x$3 = v$1.methods, ((j$1 < 0 || j$1 >= x$3.$length) ? $throwRuntimeError("index out of range") : x$3.$array[x$3.$offset + j$1])); + if ($pointerIsEqual(vm$1.name, tm$1.name) && $pointerIsEqual(vm$1.pkgPath, tm$1.pkgPath) && vm$1.mtyp === tm$1.typ) { + i$1 = i$1 + (1) >> 0; + if (i$1 >= t.methods.$length) { + return true; + } } - return cvtT2I; + j$1 = j$1 + (1) >> 0; } - return $throwNilPointerError; + return false; }; - makeFloat = function(f, v, t) { - var typ, ptr, s, _ref; - typ = t.common(); - if (typ.size > 4) { - ptr = unsafe_New(typ); - ptr.$set(v); - return new Value.Ptr(typ, ptr, 0, (((f | 2) >>> 0) | ((typ.Kind() >>> 0) << 4 >>> 0)) >>> 0); + directlyAssignable = function(T, V) { + if (T === V) { + return true; } - s = 0; - _ref = typ.size; - if (_ref === 4) { - new ($ptrType($Uintptr))(function() { return s; }, function($v) { s = $v; }).$set(v); - } else if (_ref === 8) { - new ($ptrType($Uintptr))(function() { return s; }, function($v) { s = $v; }).$set(v); + if (!(T.Name() === "") && !(V.Name() === "") || !((T.Kind() === V.Kind()))) { + return false; } - return new Value.Ptr(typ, 0, s, (f | ((typ.Kind() >>> 0) << 4 >>> 0)) >>> 0); + return haveIdenticalUnderlyingType(T, V); }; - makeComplex = function(f, v, t) { - var typ, ptr, _ref, s; - typ = t.common(); - if (typ.size > 4) { - ptr = unsafe_New(typ); - _ref = typ.size; - if (_ref === 8) { - ptr.$set(new $Complex64(v.$real, v.$imag)); - } else if (_ref === 16) { - ptr.$set(v); + haveIdenticalUnderlyingType = function(T, V) { + var kind, _ref, t, v, _ref$1, _i, i, typ, x, _ref$2, _i$1, i$1, typ$1, x$1, t$1, v$1, t$2, v$2, _ref$3, _i$2, i$2, x$2, tf, x$3, vf; + if (T === V) { + return true; + } + kind = T.Kind(); + if (!((kind === V.Kind()))) { + return false; + } + if (1 <= kind && kind <= 16 || (kind === 24) || (kind === 26)) { + return true; + } + _ref = kind; + if (_ref === 17) { + return $interfaceIsEqual(T.Elem(), V.Elem()) && (T.Len() === V.Len()); + } else if (_ref === 18) { + if ((V.ChanDir() === 3) && $interfaceIsEqual(T.Elem(), V.Elem())) { + return true; } - return new Value.Ptr(typ, ptr, 0, (((f | 2) >>> 0) | ((typ.Kind() >>> 0) << 4 >>> 0)) >>> 0); + return (V.ChanDir() === T.ChanDir()) && $interfaceIsEqual(T.Elem(), V.Elem()); + } else if (_ref === 19) { + t = T.funcType; + v = V.funcType; + if (!(t.dotdotdot === v.dotdotdot) || !((t.in$2.$length === v.in$2.$length)) || !((t.out.$length === v.out.$length))) { + return false; + } + _ref$1 = t.in$2; + _i = 0; + while (_i < _ref$1.$length) { + i = _i; + typ = ((_i < 0 || _i >= _ref$1.$length) ? $throwRuntimeError("index out of range") : _ref$1.$array[_ref$1.$offset + _i]); + if (!(typ === (x = v.in$2, ((i < 0 || i >= x.$length) ? $throwRuntimeError("index out of range") : x.$array[x.$offset + i])))) { + return false; + } + _i++; + } + _ref$2 = t.out; + _i$1 = 0; + while (_i$1 < _ref$2.$length) { + i$1 = _i$1; + typ$1 = ((_i$1 < 0 || _i$1 >= _ref$2.$length) ? $throwRuntimeError("index out of range") : _ref$2.$array[_ref$2.$offset + _i$1]); + if (!(typ$1 === (x$1 = v.out, ((i$1 < 0 || i$1 >= x$1.$length) ? $throwRuntimeError("index out of range") : x$1.$array[x$1.$offset + i$1])))) { + return false; + } + _i$1++; + } + return true; + } else if (_ref === 20) { + t$1 = T.interfaceType; + v$1 = V.interfaceType; + if ((t$1.methods.$length === 0) && (v$1.methods.$length === 0)) { + return true; + } + return false; + } else if (_ref === 21) { + return $interfaceIsEqual(T.Key(), V.Key()) && $interfaceIsEqual(T.Elem(), V.Elem()); + } else if (_ref === 22 || _ref === 23) { + return $interfaceIsEqual(T.Elem(), V.Elem()); + } else if (_ref === 25) { + t$2 = T.structType; + v$2 = V.structType; + if (!((t$2.fields.$length === v$2.fields.$length))) { + return false; + } + _ref$3 = t$2.fields; + _i$2 = 0; + while (_i$2 < _ref$3.$length) { + i$2 = _i$2; + tf = (x$2 = t$2.fields, ((i$2 < 0 || i$2 >= x$2.$length) ? $throwRuntimeError("index out of range") : x$2.$array[x$2.$offset + i$2])); + vf = (x$3 = v$2.fields, ((i$2 < 0 || i$2 >= x$3.$length) ? $throwRuntimeError("index out of range") : x$3.$array[x$3.$offset + i$2])); + if (!($pointerIsEqual(tf.name, vf.name)) && ($pointerIsEqual(tf.name, ($ptrType($String)).nil) || $pointerIsEqual(vf.name, ($ptrType($String)).nil) || !(tf.name.$get() === vf.name.$get()))) { + return false; + } + if (!($pointerIsEqual(tf.pkgPath, vf.pkgPath)) && ($pointerIsEqual(tf.pkgPath, ($ptrType($String)).nil) || $pointerIsEqual(vf.pkgPath, ($ptrType($String)).nil) || !(tf.pkgPath.$get() === vf.pkgPath.$get()))) { + return false; + } + if (!(tf.typ === vf.typ)) { + return false; + } + if (!($pointerIsEqual(tf.tag, vf.tag)) && ($pointerIsEqual(tf.tag, ($ptrType($String)).nil) || $pointerIsEqual(vf.tag, ($ptrType($String)).nil) || !(tf.tag.$get() === vf.tag.$get()))) { + return false; + } + if (!((tf.offset === vf.offset))) { + return false; + } + _i$2++; + } + return true; } - s = 0; - new ($ptrType($Uintptr))(function() { return s; }, function($v) { s = $v; }).$set(new $Complex64(v.$real, v.$imag)); - return new Value.Ptr(typ, 0, s, (f | ((typ.Kind() >>> 0) << 4 >>> 0)) >>> 0); - }; - makeString = function(f, v, t) { - var ret; - ret = new Value.Ptr(); $copy(ret, New(t).Elem(), Value); - ret.SetString(v); - ret.flag = ((ret.flag & ~4) | f) >>> 0; - return ret; + return false; }; - makeBytes = function(f, v, t) { - var ret; - ret = new Value.Ptr(); $copy(ret, New(t).Elem(), Value); - ret.SetBytes(v); - ret.flag = ((ret.flag & ~4) | f) >>> 0; - return ret; + toType = function(t) { + if (t === ($ptrType(rtype)).nil) { + return $ifaceNil; + } + return t; }; - makeRunes = function(f, v, t) { - var ret; - ret = new Value.Ptr(); $copy(ret, New(t).Elem(), Value); - ret.setRunes(v); - ret.flag = ((ret.flag & ~4) | f) >>> 0; - return ret; + flag.prototype.kind = function() { + var f; + f = this.$val !== undefined ? this.$val : this; + return (((((f >>> 4 >>> 0)) & 31) >>> 0) >>> 0); }; - cvtInt = function(v, t) { - var x; - return makeInt((v.flag & 1) >>> 0, (x = v.Int(), new $Uint64(x.$high, x.$low)), t); + $ptrType(flag).prototype.kind = function() { return new flag(this.$get()).kind(); }; + Value.Ptr.prototype.pointer = function() { + var v; + v = new Value.Ptr(); $copy(v, this, Value); + if (!((v.typ.size === 4)) || !v.typ.pointers()) { + $panic(new $String("can't call pointer on a non-pointer Value")); + } + if (!((((v.flag & 2) >>> 0) === 0))) { + return v.ptr.$get(); + } + return v.ptr; }; - cvtUint = function(v, t) { - return makeInt((v.flag & 1) >>> 0, v.Uint(), t); + Value.prototype.pointer = function() { return this.$val.pointer(); }; + ValueError.Ptr.prototype.Error = function() { + var e; + e = this; + if (e.Kind === 0) { + return "reflect: call of " + e.Method + " on zero Value"; + } + return "reflect: call of " + e.Method + " on " + (new Kind(e.Kind)).String() + " Value"; }; - cvtFloatInt = function(v, t) { - var x; - return makeInt((v.flag & 1) >>> 0, (x = new $Int64(0, v.Float()), new $Uint64(x.$high, x.$low)), t); + ValueError.prototype.Error = function() { return this.$val.Error(); }; + flag.prototype.mustBe = function(expected) { + var f, k; + f = this.$val !== undefined ? this.$val : this; + k = (new flag(f)).kind(); + if (!((k === expected))) { + $panic(new ValueError.Ptr(methodName(), k)); + } }; - cvtFloatUint = function(v, t) { - return makeInt((v.flag & 1) >>> 0, new $Uint64(0, v.Float()), t); + $ptrType(flag).prototype.mustBe = function(expected) { return new flag(this.$get()).mustBe(expected); }; + flag.prototype.mustBeExported = function() { + var f; + f = this.$val !== undefined ? this.$val : this; + if (f === 0) { + $panic(new ValueError.Ptr(methodName(), 0)); + } + if (!((((f & 1) >>> 0) === 0))) { + $panic(new $String("reflect: " + methodName() + " using value obtained using unexported field")); + } }; - cvtIntFloat = function(v, t) { - return makeFloat((v.flag & 1) >>> 0, $flatten64(v.Int()), t); + $ptrType(flag).prototype.mustBeExported = function() { return new flag(this.$get()).mustBeExported(); }; + flag.prototype.mustBeAssignable = function() { + var f; + f = this.$val !== undefined ? this.$val : this; + if (f === 0) { + $panic(new ValueError.Ptr(methodName(), 0)); + } + if (!((((f & 1) >>> 0) === 0))) { + $panic(new $String("reflect: " + methodName() + " using value obtained using unexported field")); + } + if (((f & 4) >>> 0) === 0) { + $panic(new $String("reflect: " + methodName() + " using unaddressable value")); + } }; - cvtUintFloat = function(v, t) { - return makeFloat((v.flag & 1) >>> 0, $flatten64(v.Uint()), t); + $ptrType(flag).prototype.mustBeAssignable = function() { return new flag(this.$get()).mustBeAssignable(); }; + Value.Ptr.prototype.Addr = function() { + var v; + v = new Value.Ptr(); $copy(v, this, Value); + if (((v.flag & 4) >>> 0) === 0) { + $panic(new $String("reflect.Value.Addr of unaddressable value")); + } + return new Value.Ptr(v.typ.ptrTo(), v.ptr, 0, ((((v.flag & 1) >>> 0)) | 352) >>> 0); }; - cvtFloat = function(v, t) { - return makeFloat((v.flag & 1) >>> 0, v.Float(), t); + Value.prototype.Addr = function() { return this.$val.Addr(); }; + Value.Ptr.prototype.Bool = function() { + var v; + v = new Value.Ptr(); $copy(v, this, Value); + (new flag(v.flag)).mustBe(1); + if (!((((v.flag & 2) >>> 0) === 0))) { + return v.ptr.$get(); + } + return v.scalar; }; - cvtComplex = function(v, t) { - return makeComplex((v.flag & 1) >>> 0, v.Complex(), t); + Value.prototype.Bool = function() { return this.$val.Bool(); }; + Value.Ptr.prototype.Bytes = function() { + var v; + v = new Value.Ptr(); $copy(v, this, Value); + (new flag(v.flag)).mustBe(23); + if (!((v.typ.Elem().Kind() === 8))) { + $panic(new $String("reflect.Value.Bytes of non-byte slice")); + } + return v.ptr.$get(); }; - cvtIntString = function(v, t) { - return makeString((v.flag & 1) >>> 0, $encodeRune(v.Int().$low), t); + Value.prototype.Bytes = function() { return this.$val.Bytes(); }; + Value.Ptr.prototype.runes = function() { + var v; + v = new Value.Ptr(); $copy(v, this, Value); + (new flag(v.flag)).mustBe(23); + if (!((v.typ.Elem().Kind() === 5))) { + $panic(new $String("reflect.Value.Bytes of non-rune slice")); + } + return v.ptr.$get(); }; - cvtUintString = function(v, t) { - return makeString((v.flag & 1) >>> 0, $encodeRune(v.Uint().$low), t); + Value.prototype.runes = function() { return this.$val.runes(); }; + Value.Ptr.prototype.CanAddr = function() { + var v; + v = new Value.Ptr(); $copy(v, this, Value); + return !((((v.flag & 4) >>> 0) === 0)); }; - cvtBytesString = function(v, t) { - return makeString((v.flag & 1) >>> 0, $bytesToString(v.Bytes()), t); + Value.prototype.CanAddr = function() { return this.$val.CanAddr(); }; + Value.Ptr.prototype.CanSet = function() { + var v; + v = new Value.Ptr(); $copy(v, this, Value); + return ((v.flag & 5) >>> 0) === 4; }; - cvtStringBytes = function(v, t) { - return makeBytes((v.flag & 1) >>> 0, new ($sliceType($Uint8))($stringToBytes(v.String())), t); + Value.prototype.CanSet = function() { return this.$val.CanSet(); }; + Value.Ptr.prototype.Call = function(in$1) { + var v; + v = new Value.Ptr(); $copy(v, this, Value); + (new flag(v.flag)).mustBe(19); + (new flag(v.flag)).mustBeExported(); + return v.call("Call", in$1); }; - cvtRunesString = function(v, t) { - return makeString((v.flag & 1) >>> 0, $runesToString(v.runes()), t); + Value.prototype.Call = function(in$1) { return this.$val.Call(in$1); }; + Value.Ptr.prototype.CallSlice = function(in$1) { + var v; + v = new Value.Ptr(); $copy(v, this, Value); + (new flag(v.flag)).mustBe(19); + (new flag(v.flag)).mustBeExported(); + return v.call("CallSlice", in$1); }; - cvtStringRunes = function(v, t) { - return makeRunes((v.flag & 1) >>> 0, new ($sliceType($Int32))($stringToRunes(v.String())), t); + Value.prototype.CallSlice = function(in$1) { return this.$val.CallSlice(in$1); }; + Value.Ptr.prototype.Complex = function() { + var v, k, _ref, x, x$1; + v = new Value.Ptr(); $copy(v, this, Value); + k = (new flag(v.flag)).kind(); + _ref = k; + if (_ref === 15) { + if (!((((v.flag & 2) >>> 0) === 0))) { + return (x = v.ptr.$get(), new $Complex128(x.$real, x.$imag)); + } + return (x$1 = v.scalar, new $Complex128(x$1.$real, x$1.$imag)); + } else if (_ref === 16) { + return v.ptr.$get(); + } + $panic(new ValueError.Ptr("reflect.Value.Complex", k)); }; - cvtT2I = function(v, typ) { - var target, x; - target = $newDataPointer($ifaceNil, ($ptrType($emptyInterface))); - x = valueInterface($clone(v, Value), false); - if (typ.NumMethod() === 0) { - target.$set(x); - } else { - ifaceE2I($assertType(typ, ($ptrType(rtype))), x, target); + Value.prototype.Complex = function() { return this.$val.Complex(); }; + Value.Ptr.prototype.FieldByIndex = function(index) { + var v, _ref, _i, i, x; + v = new Value.Ptr(); $copy(v, this, Value); + (new flag(v.flag)).mustBe(25); + _ref = index; + _i = 0; + while (_i < _ref.$length) { + i = _i; + x = ((_i < 0 || _i >= _ref.$length) ? $throwRuntimeError("index out of range") : _ref.$array[_ref.$offset + _i]); + if (i > 0) { + if ((v.Kind() === 22) && (v.typ.Elem().Kind() === 25)) { + if (v.IsNil()) { + $panic(new $String("reflect: indirection through nil pointer to embedded struct")); + } + $copy(v, v.Elem(), Value); + } + } + $copy(v, v.Field(x), Value); + _i++; } - return new Value.Ptr(typ.common(), target, 0, (((((v.flag & 1) >>> 0) | 2) >>> 0) | 320) >>> 0); + return v; }; - cvtI2I = function(v, typ) { - var ret; - if (v.IsNil()) { - ret = new Value.Ptr(); $copy(ret, Zero(typ), Value); - ret.flag = (ret.flag | (((v.flag & 1) >>> 0))) >>> 0; - return ret; + Value.prototype.FieldByIndex = function(index) { return this.$val.FieldByIndex(index); }; + Value.Ptr.prototype.FieldByName = function(name) { + var v, _tuple, f, ok; + v = new Value.Ptr(); $copy(v, this, Value); + (new flag(v.flag)).mustBe(25); + _tuple = v.typ.FieldByName(name); f = new StructField.Ptr(); $copy(f, _tuple[0], StructField); ok = _tuple[1]; + if (ok) { + return v.FieldByIndex(f.Index); } - return cvtT2I($clone(v.Elem(), Value), typ); + return new Value.Ptr(($ptrType(rtype)).nil, 0, 0, 0); }; - call = function() { - $panic("Native function not implemented: reflect.call"); + Value.prototype.FieldByName = function(name) { return this.$val.FieldByName(name); }; + Value.Ptr.prototype.FieldByNameFunc = function(match) { + var v, _tuple, f, ok; + v = new Value.Ptr(); $copy(v, this, Value); + (new flag(v.flag)).mustBe(25); + _tuple = v.typ.FieldByNameFunc(match); f = new StructField.Ptr(); $copy(f, _tuple[0], StructField); ok = _tuple[1]; + if (ok) { + return v.FieldByIndex(f.Index); + } + return new Value.Ptr(($ptrType(rtype)).nil, 0, 0, 0); }; - $pkg.$init = function() { - mapIter.init([["t", "t", "reflect", Type, ""], ["m", "m", "reflect", js.Object, ""], ["keys", "keys", "reflect", js.Object, ""], ["i", "i", "reflect", $Int, ""]]); - Type.init([["Align", "Align", "", $funcType([], [$Int], false)], ["AssignableTo", "AssignableTo", "", $funcType([Type], [$Bool], false)], ["Bits", "Bits", "", $funcType([], [$Int], false)], ["ChanDir", "ChanDir", "", $funcType([], [ChanDir], false)], ["ConvertibleTo", "ConvertibleTo", "", $funcType([Type], [$Bool], false)], ["Elem", "Elem", "", $funcType([], [Type], false)], ["Field", "Field", "", $funcType([$Int], [StructField], false)], ["FieldAlign", "FieldAlign", "", $funcType([], [$Int], false)], ["FieldByIndex", "FieldByIndex", "", $funcType([($sliceType($Int))], [StructField], false)], ["FieldByName", "FieldByName", "", $funcType([$String], [StructField, $Bool], false)], ["FieldByNameFunc", "FieldByNameFunc", "", $funcType([($funcType([$String], [$Bool], false))], [StructField, $Bool], false)], ["Implements", "Implements", "", $funcType([Type], [$Bool], false)], ["In", "In", "", $funcType([$Int], [Type], false)], ["IsVariadic", "IsVariadic", "", $funcType([], [$Bool], false)], ["Key", "Key", "", $funcType([], [Type], false)], ["Kind", "Kind", "", $funcType([], [Kind], false)], ["Len", "Len", "", $funcType([], [$Int], false)], ["Method", "Method", "", $funcType([$Int], [Method], false)], ["MethodByName", "MethodByName", "", $funcType([$String], [Method, $Bool], false)], ["Name", "Name", "", $funcType([], [$String], false)], ["NumField", "NumField", "", $funcType([], [$Int], false)], ["NumIn", "NumIn", "", $funcType([], [$Int], false)], ["NumMethod", "NumMethod", "", $funcType([], [$Int], false)], ["NumOut", "NumOut", "", $funcType([], [$Int], false)], ["Out", "Out", "", $funcType([$Int], [Type], false)], ["PkgPath", "PkgPath", "", $funcType([], [$String], false)], ["Size", "Size", "", $funcType([], [$Uintptr], false)], ["String", "String", "", $funcType([], [$String], false)], ["common", "common", "reflect", $funcType([], [($ptrType(rtype))], false)], ["uncommon", "uncommon", "reflect", $funcType([], [($ptrType(uncommonType))], false)]]); - Kind.methods = [["String", "String", "", $funcType([], [$String], false), -1]]; - ($ptrType(Kind)).methods = [["String", "String", "", $funcType([], [$String], false), -1]]; - rtype.methods = [["uncommon", "uncommon", "reflect", $funcType([], [($ptrType(uncommonType))], false), 9]]; - ($ptrType(rtype)).methods = [["Align", "Align", "", $funcType([], [$Int], false), -1], ["AssignableTo", "AssignableTo", "", $funcType([Type], [$Bool], false), -1], ["Bits", "Bits", "", $funcType([], [$Int], false), -1], ["ChanDir", "ChanDir", "", $funcType([], [ChanDir], false), -1], ["ConvertibleTo", "ConvertibleTo", "", $funcType([Type], [$Bool], false), -1], ["Elem", "Elem", "", $funcType([], [Type], false), -1], ["Field", "Field", "", $funcType([$Int], [StructField], false), -1], ["FieldAlign", "FieldAlign", "", $funcType([], [$Int], false), -1], ["FieldByIndex", "FieldByIndex", "", $funcType([($sliceType($Int))], [StructField], false), -1], ["FieldByName", "FieldByName", "", $funcType([$String], [StructField, $Bool], false), -1], ["FieldByNameFunc", "FieldByNameFunc", "", $funcType([($funcType([$String], [$Bool], false))], [StructField, $Bool], false), -1], ["Implements", "Implements", "", $funcType([Type], [$Bool], false), -1], ["In", "In", "", $funcType([$Int], [Type], false), -1], ["IsVariadic", "IsVariadic", "", $funcType([], [$Bool], false), -1], ["Key", "Key", "", $funcType([], [Type], false), -1], ["Kind", "Kind", "", $funcType([], [Kind], false), -1], ["Len", "Len", "", $funcType([], [$Int], false), -1], ["Method", "Method", "", $funcType([$Int], [Method], false), -1], ["MethodByName", "MethodByName", "", $funcType([$String], [Method, $Bool], false), -1], ["Name", "Name", "", $funcType([], [$String], false), -1], ["NumField", "NumField", "", $funcType([], [$Int], false), -1], ["NumIn", "NumIn", "", $funcType([], [$Int], false), -1], ["NumMethod", "NumMethod", "", $funcType([], [$Int], false), -1], ["NumOut", "NumOut", "", $funcType([], [$Int], false), -1], ["Out", "Out", "", $funcType([$Int], [Type], false), -1], ["PkgPath", "PkgPath", "", $funcType([], [$String], false), -1], ["Size", "Size", "", $funcType([], [$Uintptr], false), -1], ["String", "String", "", $funcType([], [$String], false), -1], ["common", "common", "reflect", $funcType([], [($ptrType(rtype))], false), -1], ["pointers", "pointers", "reflect", $funcType([], [$Bool], false), -1], ["ptrTo", "ptrTo", "reflect", $funcType([], [($ptrType(rtype))], false), -1], ["uncommon", "uncommon", "reflect", $funcType([], [($ptrType(uncommonType))], false), 9]]; - rtype.init([["size", "size", "reflect", $Uintptr, ""], ["hash", "hash", "reflect", $Uint32, ""], ["_$2", "_", "reflect", $Uint8, ""], ["align", "align", "reflect", $Uint8, ""], ["fieldAlign", "fieldAlign", "reflect", $Uint8, ""], ["kind", "kind", "reflect", $Uint8, ""], ["alg", "alg", "reflect", ($ptrType($Uintptr)), ""], ["gc", "gc", "reflect", $UnsafePointer, ""], ["string", "string", "reflect", ($ptrType($String)), ""], ["uncommonType", "", "reflect", ($ptrType(uncommonType)), ""], ["ptrToThis", "ptrToThis", "reflect", ($ptrType(rtype)), ""], ["zero", "zero", "reflect", $UnsafePointer, ""]]); - method.init([["name", "name", "reflect", ($ptrType($String)), ""], ["pkgPath", "pkgPath", "reflect", ($ptrType($String)), ""], ["mtyp", "mtyp", "reflect", ($ptrType(rtype)), ""], ["typ", "typ", "reflect", ($ptrType(rtype)), ""], ["ifn", "ifn", "reflect", $UnsafePointer, ""], ["tfn", "tfn", "reflect", $UnsafePointer, ""]]); - ($ptrType(uncommonType)).methods = [["Method", "Method", "", $funcType([$Int], [Method], false), -1], ["MethodByName", "MethodByName", "", $funcType([$String], [Method, $Bool], false), -1], ["Name", "Name", "", $funcType([], [$String], false), -1], ["NumMethod", "NumMethod", "", $funcType([], [$Int], false), -1], ["PkgPath", "PkgPath", "", $funcType([], [$String], false), -1], ["uncommon", "uncommon", "reflect", $funcType([], [($ptrType(uncommonType))], false), -1]]; - uncommonType.init([["name", "name", "reflect", ($ptrType($String)), ""], ["pkgPath", "pkgPath", "reflect", ($ptrType($String)), ""], ["methods", "methods", "reflect", ($sliceType(method)), ""]]); - ChanDir.methods = [["String", "String", "", $funcType([], [$String], false), -1]]; - ($ptrType(ChanDir)).methods = [["String", "String", "", $funcType([], [$String], false), -1]]; - arrayType.methods = [["uncommon", "uncommon", "reflect", $funcType([], [($ptrType(uncommonType))], false), 0]]; - ($ptrType(arrayType)).methods = [["Align", "Align", "", $funcType([], [$Int], false), 0], ["AssignableTo", "AssignableTo", "", $funcType([Type], [$Bool], false), 0], ["Bits", "Bits", "", $funcType([], [$Int], false), 0], ["ChanDir", "ChanDir", "", $funcType([], [ChanDir], false), 0], ["ConvertibleTo", "ConvertibleTo", "", $funcType([Type], [$Bool], false), 0], ["Elem", "Elem", "", $funcType([], [Type], false), 0], ["Field", "Field", "", $funcType([$Int], [StructField], false), 0], ["FieldAlign", "FieldAlign", "", $funcType([], [$Int], false), 0], ["FieldByIndex", "FieldByIndex", "", $funcType([($sliceType($Int))], [StructField], false), 0], ["FieldByName", "FieldByName", "", $funcType([$String], [StructField, $Bool], false), 0], ["FieldByNameFunc", "FieldByNameFunc", "", $funcType([($funcType([$String], [$Bool], false))], [StructField, $Bool], false), 0], ["Implements", "Implements", "", $funcType([Type], [$Bool], false), 0], ["In", "In", "", $funcType([$Int], [Type], false), 0], ["IsVariadic", "IsVariadic", "", $funcType([], [$Bool], false), 0], ["Key", "Key", "", $funcType([], [Type], false), 0], ["Kind", "Kind", "", $funcType([], [Kind], false), 0], ["Len", "Len", "", $funcType([], [$Int], false), 0], ["Method", "Method", "", $funcType([$Int], [Method], false), 0], ["MethodByName", "MethodByName", "", $funcType([$String], [Method, $Bool], false), 0], ["Name", "Name", "", $funcType([], [$String], false), 0], ["NumField", "NumField", "", $funcType([], [$Int], false), 0], ["NumIn", "NumIn", "", $funcType([], [$Int], false), 0], ["NumMethod", "NumMethod", "", $funcType([], [$Int], false), 0], ["NumOut", "NumOut", "", $funcType([], [$Int], false), 0], ["Out", "Out", "", $funcType([$Int], [Type], false), 0], ["PkgPath", "PkgPath", "", $funcType([], [$String], false), 0], ["Size", "Size", "", $funcType([], [$Uintptr], false), 0], ["String", "String", "", $funcType([], [$String], false), 0], ["common", "common", "reflect", $funcType([], [($ptrType(rtype))], false), 0], ["pointers", "pointers", "reflect", $funcType([], [$Bool], false), 0], ["ptrTo", "ptrTo", "reflect", $funcType([], [($ptrType(rtype))], false), 0], ["uncommon", "uncommon", "reflect", $funcType([], [($ptrType(uncommonType))], false), 0]]; - arrayType.init([["rtype", "", "reflect", rtype, "reflect:\"array\""], ["elem", "elem", "reflect", ($ptrType(rtype)), ""], ["slice", "slice", "reflect", ($ptrType(rtype)), ""], ["len", "len", "reflect", $Uintptr, ""]]); - chanType.methods = [["uncommon", "uncommon", "reflect", $funcType([], [($ptrType(uncommonType))], false), 0]]; - ($ptrType(chanType)).methods = [["Align", "Align", "", $funcType([], [$Int], false), 0], ["AssignableTo", "AssignableTo", "", $funcType([Type], [$Bool], false), 0], ["Bits", "Bits", "", $funcType([], [$Int], false), 0], ["ChanDir", "ChanDir", "", $funcType([], [ChanDir], false), 0], ["ConvertibleTo", "ConvertibleTo", "", $funcType([Type], [$Bool], false), 0], ["Elem", "Elem", "", $funcType([], [Type], false), 0], ["Field", "Field", "", $funcType([$Int], [StructField], false), 0], ["FieldAlign", "FieldAlign", "", $funcType([], [$Int], false), 0], ["FieldByIndex", "FieldByIndex", "", $funcType([($sliceType($Int))], [StructField], false), 0], ["FieldByName", "FieldByName", "", $funcType([$String], [StructField, $Bool], false), 0], ["FieldByNameFunc", "FieldByNameFunc", "", $funcType([($funcType([$String], [$Bool], false))], [StructField, $Bool], false), 0], ["Implements", "Implements", "", $funcType([Type], [$Bool], false), 0], ["In", "In", "", $funcType([$Int], [Type], false), 0], ["IsVariadic", "IsVariadic", "", $funcType([], [$Bool], false), 0], ["Key", "Key", "", $funcType([], [Type], false), 0], ["Kind", "Kind", "", $funcType([], [Kind], false), 0], ["Len", "Len", "", $funcType([], [$Int], false), 0], ["Method", "Method", "", $funcType([$Int], [Method], false), 0], ["MethodByName", "MethodByName", "", $funcType([$String], [Method, $Bool], false), 0], ["Name", "Name", "", $funcType([], [$String], false), 0], ["NumField", "NumField", "", $funcType([], [$Int], false), 0], ["NumIn", "NumIn", "", $funcType([], [$Int], false), 0], ["NumMethod", "NumMethod", "", $funcType([], [$Int], false), 0], ["NumOut", "NumOut", "", $funcType([], [$Int], false), 0], ["Out", "Out", "", $funcType([$Int], [Type], false), 0], ["PkgPath", "PkgPath", "", $funcType([], [$String], false), 0], ["Size", "Size", "", $funcType([], [$Uintptr], false), 0], ["String", "String", "", $funcType([], [$String], false), 0], ["common", "common", "reflect", $funcType([], [($ptrType(rtype))], false), 0], ["pointers", "pointers", "reflect", $funcType([], [$Bool], false), 0], ["ptrTo", "ptrTo", "reflect", $funcType([], [($ptrType(rtype))], false), 0], ["uncommon", "uncommon", "reflect", $funcType([], [($ptrType(uncommonType))], false), 0]]; - chanType.init([["rtype", "", "reflect", rtype, "reflect:\"chan\""], ["elem", "elem", "reflect", ($ptrType(rtype)), ""], ["dir", "dir", "reflect", $Uintptr, ""]]); - funcType.methods = [["uncommon", "uncommon", "reflect", $funcType([], [($ptrType(uncommonType))], false), 0]]; - ($ptrType(funcType)).methods = [["Align", "Align", "", $funcType([], [$Int], false), 0], ["AssignableTo", "AssignableTo", "", $funcType([Type], [$Bool], false), 0], ["Bits", "Bits", "", $funcType([], [$Int], false), 0], ["ChanDir", "ChanDir", "", $funcType([], [ChanDir], false), 0], ["ConvertibleTo", "ConvertibleTo", "", $funcType([Type], [$Bool], false), 0], ["Elem", "Elem", "", $funcType([], [Type], false), 0], ["Field", "Field", "", $funcType([$Int], [StructField], false), 0], ["FieldAlign", "FieldAlign", "", $funcType([], [$Int], false), 0], ["FieldByIndex", "FieldByIndex", "", $funcType([($sliceType($Int))], [StructField], false), 0], ["FieldByName", "FieldByName", "", $funcType([$String], [StructField, $Bool], false), 0], ["FieldByNameFunc", "FieldByNameFunc", "", $funcType([($funcType([$String], [$Bool], false))], [StructField, $Bool], false), 0], ["Implements", "Implements", "", $funcType([Type], [$Bool], false), 0], ["In", "In", "", $funcType([$Int], [Type], false), 0], ["IsVariadic", "IsVariadic", "", $funcType([], [$Bool], false), 0], ["Key", "Key", "", $funcType([], [Type], false), 0], ["Kind", "Kind", "", $funcType([], [Kind], false), 0], ["Len", "Len", "", $funcType([], [$Int], false), 0], ["Method", "Method", "", $funcType([$Int], [Method], false), 0], ["MethodByName", "MethodByName", "", $funcType([$String], [Method, $Bool], false), 0], ["Name", "Name", "", $funcType([], [$String], false), 0], ["NumField", "NumField", "", $funcType([], [$Int], false), 0], ["NumIn", "NumIn", "", $funcType([], [$Int], false), 0], ["NumMethod", "NumMethod", "", $funcType([], [$Int], false), 0], ["NumOut", "NumOut", "", $funcType([], [$Int], false), 0], ["Out", "Out", "", $funcType([$Int], [Type], false), 0], ["PkgPath", "PkgPath", "", $funcType([], [$String], false), 0], ["Size", "Size", "", $funcType([], [$Uintptr], false), 0], ["String", "String", "", $funcType([], [$String], false), 0], ["common", "common", "reflect", $funcType([], [($ptrType(rtype))], false), 0], ["pointers", "pointers", "reflect", $funcType([], [$Bool], false), 0], ["ptrTo", "ptrTo", "reflect", $funcType([], [($ptrType(rtype))], false), 0], ["uncommon", "uncommon", "reflect", $funcType([], [($ptrType(uncommonType))], false), 0]]; - funcType.init([["rtype", "", "reflect", rtype, "reflect:\"func\""], ["dotdotdot", "dotdotdot", "reflect", $Bool, ""], ["in$2", "in", "reflect", ($sliceType(($ptrType(rtype)))), ""], ["out", "out", "reflect", ($sliceType(($ptrType(rtype)))), ""]]); - imethod.init([["name", "name", "reflect", ($ptrType($String)), ""], ["pkgPath", "pkgPath", "reflect", ($ptrType($String)), ""], ["typ", "typ", "reflect", ($ptrType(rtype)), ""]]); - interfaceType.methods = [["uncommon", "uncommon", "reflect", $funcType([], [($ptrType(uncommonType))], false), 0]]; - ($ptrType(interfaceType)).methods = [["Align", "Align", "", $funcType([], [$Int], false), 0], ["AssignableTo", "AssignableTo", "", $funcType([Type], [$Bool], false), 0], ["Bits", "Bits", "", $funcType([], [$Int], false), 0], ["ChanDir", "ChanDir", "", $funcType([], [ChanDir], false), 0], ["ConvertibleTo", "ConvertibleTo", "", $funcType([Type], [$Bool], false), 0], ["Elem", "Elem", "", $funcType([], [Type], false), 0], ["Field", "Field", "", $funcType([$Int], [StructField], false), 0], ["FieldAlign", "FieldAlign", "", $funcType([], [$Int], false), 0], ["FieldByIndex", "FieldByIndex", "", $funcType([($sliceType($Int))], [StructField], false), 0], ["FieldByName", "FieldByName", "", $funcType([$String], [StructField, $Bool], false), 0], ["FieldByNameFunc", "FieldByNameFunc", "", $funcType([($funcType([$String], [$Bool], false))], [StructField, $Bool], false), 0], ["Implements", "Implements", "", $funcType([Type], [$Bool], false), 0], ["In", "In", "", $funcType([$Int], [Type], false), 0], ["IsVariadic", "IsVariadic", "", $funcType([], [$Bool], false), 0], ["Key", "Key", "", $funcType([], [Type], false), 0], ["Kind", "Kind", "", $funcType([], [Kind], false), 0], ["Len", "Len", "", $funcType([], [$Int], false), 0], ["Method", "Method", "", $funcType([$Int], [Method], false), -1], ["MethodByName", "MethodByName", "", $funcType([$String], [Method, $Bool], false), -1], ["Name", "Name", "", $funcType([], [$String], false), 0], ["NumField", "NumField", "", $funcType([], [$Int], false), 0], ["NumIn", "NumIn", "", $funcType([], [$Int], false), 0], ["NumMethod", "NumMethod", "", $funcType([], [$Int], false), -1], ["NumOut", "NumOut", "", $funcType([], [$Int], false), 0], ["Out", "Out", "", $funcType([$Int], [Type], false), 0], ["PkgPath", "PkgPath", "", $funcType([], [$String], false), 0], ["Size", "Size", "", $funcType([], [$Uintptr], false), 0], ["String", "String", "", $funcType([], [$String], false), 0], ["common", "common", "reflect", $funcType([], [($ptrType(rtype))], false), 0], ["pointers", "pointers", "reflect", $funcType([], [$Bool], false), 0], ["ptrTo", "ptrTo", "reflect", $funcType([], [($ptrType(rtype))], false), 0], ["uncommon", "uncommon", "reflect", $funcType([], [($ptrType(uncommonType))], false), 0]]; - interfaceType.init([["rtype", "", "reflect", rtype, "reflect:\"interface\""], ["methods", "methods", "reflect", ($sliceType(imethod)), ""]]); - mapType.methods = [["uncommon", "uncommon", "reflect", $funcType([], [($ptrType(uncommonType))], false), 0]]; - ($ptrType(mapType)).methods = [["Align", "Align", "", $funcType([], [$Int], false), 0], ["AssignableTo", "AssignableTo", "", $funcType([Type], [$Bool], false), 0], ["Bits", "Bits", "", $funcType([], [$Int], false), 0], ["ChanDir", "ChanDir", "", $funcType([], [ChanDir], false), 0], ["ConvertibleTo", "ConvertibleTo", "", $funcType([Type], [$Bool], false), 0], ["Elem", "Elem", "", $funcType([], [Type], false), 0], ["Field", "Field", "", $funcType([$Int], [StructField], false), 0], ["FieldAlign", "FieldAlign", "", $funcType([], [$Int], false), 0], ["FieldByIndex", "FieldByIndex", "", $funcType([($sliceType($Int))], [StructField], false), 0], ["FieldByName", "FieldByName", "", $funcType([$String], [StructField, $Bool], false), 0], ["FieldByNameFunc", "FieldByNameFunc", "", $funcType([($funcType([$String], [$Bool], false))], [StructField, $Bool], false), 0], ["Implements", "Implements", "", $funcType([Type], [$Bool], false), 0], ["In", "In", "", $funcType([$Int], [Type], false), 0], ["IsVariadic", "IsVariadic", "", $funcType([], [$Bool], false), 0], ["Key", "Key", "", $funcType([], [Type], false), 0], ["Kind", "Kind", "", $funcType([], [Kind], false), 0], ["Len", "Len", "", $funcType([], [$Int], false), 0], ["Method", "Method", "", $funcType([$Int], [Method], false), 0], ["MethodByName", "MethodByName", "", $funcType([$String], [Method, $Bool], false), 0], ["Name", "Name", "", $funcType([], [$String], false), 0], ["NumField", "NumField", "", $funcType([], [$Int], false), 0], ["NumIn", "NumIn", "", $funcType([], [$Int], false), 0], ["NumMethod", "NumMethod", "", $funcType([], [$Int], false), 0], ["NumOut", "NumOut", "", $funcType([], [$Int], false), 0], ["Out", "Out", "", $funcType([$Int], [Type], false), 0], ["PkgPath", "PkgPath", "", $funcType([], [$String], false), 0], ["Size", "Size", "", $funcType([], [$Uintptr], false), 0], ["String", "String", "", $funcType([], [$String], false), 0], ["common", "common", "reflect", $funcType([], [($ptrType(rtype))], false), 0], ["pointers", "pointers", "reflect", $funcType([], [$Bool], false), 0], ["ptrTo", "ptrTo", "reflect", $funcType([], [($ptrType(rtype))], false), 0], ["uncommon", "uncommon", "reflect", $funcType([], [($ptrType(uncommonType))], false), 0]]; - mapType.init([["rtype", "", "reflect", rtype, "reflect:\"map\""], ["key", "key", "reflect", ($ptrType(rtype)), ""], ["elem", "elem", "reflect", ($ptrType(rtype)), ""], ["bucket", "bucket", "reflect", ($ptrType(rtype)), ""], ["hmap", "hmap", "reflect", ($ptrType(rtype)), ""]]); - ptrType.methods = [["uncommon", "uncommon", "reflect", $funcType([], [($ptrType(uncommonType))], false), 0]]; - ($ptrType(ptrType)).methods = [["Align", "Align", "", $funcType([], [$Int], false), 0], ["AssignableTo", "AssignableTo", "", $funcType([Type], [$Bool], false), 0], ["Bits", "Bits", "", $funcType([], [$Int], false), 0], ["ChanDir", "ChanDir", "", $funcType([], [ChanDir], false), 0], ["ConvertibleTo", "ConvertibleTo", "", $funcType([Type], [$Bool], false), 0], ["Elem", "Elem", "", $funcType([], [Type], false), 0], ["Field", "Field", "", $funcType([$Int], [StructField], false), 0], ["FieldAlign", "FieldAlign", "", $funcType([], [$Int], false), 0], ["FieldByIndex", "FieldByIndex", "", $funcType([($sliceType($Int))], [StructField], false), 0], ["FieldByName", "FieldByName", "", $funcType([$String], [StructField, $Bool], false), 0], ["FieldByNameFunc", "FieldByNameFunc", "", $funcType([($funcType([$String], [$Bool], false))], [StructField, $Bool], false), 0], ["Implements", "Implements", "", $funcType([Type], [$Bool], false), 0], ["In", "In", "", $funcType([$Int], [Type], false), 0], ["IsVariadic", "IsVariadic", "", $funcType([], [$Bool], false), 0], ["Key", "Key", "", $funcType([], [Type], false), 0], ["Kind", "Kind", "", $funcType([], [Kind], false), 0], ["Len", "Len", "", $funcType([], [$Int], false), 0], ["Method", "Method", "", $funcType([$Int], [Method], false), 0], ["MethodByName", "MethodByName", "", $funcType([$String], [Method, $Bool], false), 0], ["Name", "Name", "", $funcType([], [$String], false), 0], ["NumField", "NumField", "", $funcType([], [$Int], false), 0], ["NumIn", "NumIn", "", $funcType([], [$Int], false), 0], ["NumMethod", "NumMethod", "", $funcType([], [$Int], false), 0], ["NumOut", "NumOut", "", $funcType([], [$Int], false), 0], ["Out", "Out", "", $funcType([$Int], [Type], false), 0], ["PkgPath", "PkgPath", "", $funcType([], [$String], false), 0], ["Size", "Size", "", $funcType([], [$Uintptr], false), 0], ["String", "String", "", $funcType([], [$String], false), 0], ["common", "common", "reflect", $funcType([], [($ptrType(rtype))], false), 0], ["pointers", "pointers", "reflect", $funcType([], [$Bool], false), 0], ["ptrTo", "ptrTo", "reflect", $funcType([], [($ptrType(rtype))], false), 0], ["uncommon", "uncommon", "reflect", $funcType([], [($ptrType(uncommonType))], false), 0]]; - ptrType.init([["rtype", "", "reflect", rtype, "reflect:\"ptr\""], ["elem", "elem", "reflect", ($ptrType(rtype)), ""]]); - sliceType.methods = [["uncommon", "uncommon", "reflect", $funcType([], [($ptrType(uncommonType))], false), 0]]; - ($ptrType(sliceType)).methods = [["Align", "Align", "", $funcType([], [$Int], false), 0], ["AssignableTo", "AssignableTo", "", $funcType([Type], [$Bool], false), 0], ["Bits", "Bits", "", $funcType([], [$Int], false), 0], ["ChanDir", "ChanDir", "", $funcType([], [ChanDir], false), 0], ["ConvertibleTo", "ConvertibleTo", "", $funcType([Type], [$Bool], false), 0], ["Elem", "Elem", "", $funcType([], [Type], false), 0], ["Field", "Field", "", $funcType([$Int], [StructField], false), 0], ["FieldAlign", "FieldAlign", "", $funcType([], [$Int], false), 0], ["FieldByIndex", "FieldByIndex", "", $funcType([($sliceType($Int))], [StructField], false), 0], ["FieldByName", "FieldByName", "", $funcType([$String], [StructField, $Bool], false), 0], ["FieldByNameFunc", "FieldByNameFunc", "", $funcType([($funcType([$String], [$Bool], false))], [StructField, $Bool], false), 0], ["Implements", "Implements", "", $funcType([Type], [$Bool], false), 0], ["In", "In", "", $funcType([$Int], [Type], false), 0], ["IsVariadic", "IsVariadic", "", $funcType([], [$Bool], false), 0], ["Key", "Key", "", $funcType([], [Type], false), 0], ["Kind", "Kind", "", $funcType([], [Kind], false), 0], ["Len", "Len", "", $funcType([], [$Int], false), 0], ["Method", "Method", "", $funcType([$Int], [Method], false), 0], ["MethodByName", "MethodByName", "", $funcType([$String], [Method, $Bool], false), 0], ["Name", "Name", "", $funcType([], [$String], false), 0], ["NumField", "NumField", "", $funcType([], [$Int], false), 0], ["NumIn", "NumIn", "", $funcType([], [$Int], false), 0], ["NumMethod", "NumMethod", "", $funcType([], [$Int], false), 0], ["NumOut", "NumOut", "", $funcType([], [$Int], false), 0], ["Out", "Out", "", $funcType([$Int], [Type], false), 0], ["PkgPath", "PkgPath", "", $funcType([], [$String], false), 0], ["Size", "Size", "", $funcType([], [$Uintptr], false), 0], ["String", "String", "", $funcType([], [$String], false), 0], ["common", "common", "reflect", $funcType([], [($ptrType(rtype))], false), 0], ["pointers", "pointers", "reflect", $funcType([], [$Bool], false), 0], ["ptrTo", "ptrTo", "reflect", $funcType([], [($ptrType(rtype))], false), 0], ["uncommon", "uncommon", "reflect", $funcType([], [($ptrType(uncommonType))], false), 0]]; - sliceType.init([["rtype", "", "reflect", rtype, "reflect:\"slice\""], ["elem", "elem", "reflect", ($ptrType(rtype)), ""]]); - structField.init([["name", "name", "reflect", ($ptrType($String)), ""], ["pkgPath", "pkgPath", "reflect", ($ptrType($String)), ""], ["typ", "typ", "reflect", ($ptrType(rtype)), ""], ["tag", "tag", "reflect", ($ptrType($String)), ""], ["offset", "offset", "reflect", $Uintptr, ""]]); - structType.methods = [["uncommon", "uncommon", "reflect", $funcType([], [($ptrType(uncommonType))], false), 0]]; - ($ptrType(structType)).methods = [["Align", "Align", "", $funcType([], [$Int], false), 0], ["AssignableTo", "AssignableTo", "", $funcType([Type], [$Bool], false), 0], ["Bits", "Bits", "", $funcType([], [$Int], false), 0], ["ChanDir", "ChanDir", "", $funcType([], [ChanDir], false), 0], ["ConvertibleTo", "ConvertibleTo", "", $funcType([Type], [$Bool], false), 0], ["Elem", "Elem", "", $funcType([], [Type], false), 0], ["Field", "Field", "", $funcType([$Int], [StructField], false), -1], ["FieldAlign", "FieldAlign", "", $funcType([], [$Int], false), 0], ["FieldByIndex", "FieldByIndex", "", $funcType([($sliceType($Int))], [StructField], false), -1], ["FieldByName", "FieldByName", "", $funcType([$String], [StructField, $Bool], false), -1], ["FieldByNameFunc", "FieldByNameFunc", "", $funcType([($funcType([$String], [$Bool], false))], [StructField, $Bool], false), -1], ["Implements", "Implements", "", $funcType([Type], [$Bool], false), 0], ["In", "In", "", $funcType([$Int], [Type], false), 0], ["IsVariadic", "IsVariadic", "", $funcType([], [$Bool], false), 0], ["Key", "Key", "", $funcType([], [Type], false), 0], ["Kind", "Kind", "", $funcType([], [Kind], false), 0], ["Len", "Len", "", $funcType([], [$Int], false), 0], ["Method", "Method", "", $funcType([$Int], [Method], false), 0], ["MethodByName", "MethodByName", "", $funcType([$String], [Method, $Bool], false), 0], ["Name", "Name", "", $funcType([], [$String], false), 0], ["NumField", "NumField", "", $funcType([], [$Int], false), 0], ["NumIn", "NumIn", "", $funcType([], [$Int], false), 0], ["NumMethod", "NumMethod", "", $funcType([], [$Int], false), 0], ["NumOut", "NumOut", "", $funcType([], [$Int], false), 0], ["Out", "Out", "", $funcType([$Int], [Type], false), 0], ["PkgPath", "PkgPath", "", $funcType([], [$String], false), 0], ["Size", "Size", "", $funcType([], [$Uintptr], false), 0], ["String", "String", "", $funcType([], [$String], false), 0], ["common", "common", "reflect", $funcType([], [($ptrType(rtype))], false), 0], ["pointers", "pointers", "reflect", $funcType([], [$Bool], false), 0], ["ptrTo", "ptrTo", "reflect", $funcType([], [($ptrType(rtype))], false), 0], ["uncommon", "uncommon", "reflect", $funcType([], [($ptrType(uncommonType))], false), 0]]; - structType.init([["rtype", "", "reflect", rtype, "reflect:\"struct\""], ["fields", "fields", "reflect", ($sliceType(structField)), ""]]); - Method.init([["Name", "Name", "", $String, ""], ["PkgPath", "PkgPath", "", $String, ""], ["Type", "Type", "", Type, ""], ["Func", "Func", "", Value, ""], ["Index", "Index", "", $Int, ""]]); - StructField.init([["Name", "Name", "", $String, ""], ["PkgPath", "PkgPath", "", $String, ""], ["Type", "Type", "", Type, ""], ["Tag", "Tag", "", StructTag, ""], ["Offset", "Offset", "", $Uintptr, ""], ["Index", "Index", "", ($sliceType($Int)), ""], ["Anonymous", "Anonymous", "", $Bool, ""]]); - StructTag.methods = [["Get", "Get", "", $funcType([$String], [$String], false), -1]]; - ($ptrType(StructTag)).methods = [["Get", "Get", "", $funcType([$String], [$String], false), -1]]; - fieldScan.init([["typ", "typ", "reflect", ($ptrType(structType)), ""], ["index", "index", "reflect", ($sliceType($Int)), ""]]); - Value.methods = [["Addr", "Addr", "", $funcType([], [Value], false), -1], ["Bool", "Bool", "", $funcType([], [$Bool], false), -1], ["Bytes", "Bytes", "", $funcType([], [($sliceType($Uint8))], false), -1], ["Call", "Call", "", $funcType([($sliceType(Value))], [($sliceType(Value))], false), -1], ["CallSlice", "CallSlice", "", $funcType([($sliceType(Value))], [($sliceType(Value))], false), -1], ["CanAddr", "CanAddr", "", $funcType([], [$Bool], false), -1], ["CanInterface", "CanInterface", "", $funcType([], [$Bool], false), -1], ["CanSet", "CanSet", "", $funcType([], [$Bool], false), -1], ["Cap", "Cap", "", $funcType([], [$Int], false), -1], ["Close", "Close", "", $funcType([], [], false), -1], ["Complex", "Complex", "", $funcType([], [$Complex128], false), -1], ["Convert", "Convert", "", $funcType([Type], [Value], false), -1], ["Elem", "Elem", "", $funcType([], [Value], false), -1], ["Field", "Field", "", $funcType([$Int], [Value], false), -1], ["FieldByIndex", "FieldByIndex", "", $funcType([($sliceType($Int))], [Value], false), -1], ["FieldByName", "FieldByName", "", $funcType([$String], [Value], false), -1], ["FieldByNameFunc", "FieldByNameFunc", "", $funcType([($funcType([$String], [$Bool], false))], [Value], false), -1], ["Float", "Float", "", $funcType([], [$Float64], false), -1], ["Index", "Index", "", $funcType([$Int], [Value], false), -1], ["Int", "Int", "", $funcType([], [$Int64], false), -1], ["Interface", "Interface", "", $funcType([], [$emptyInterface], false), -1], ["InterfaceData", "InterfaceData", "", $funcType([], [($arrayType($Uintptr, 2))], false), -1], ["IsNil", "IsNil", "", $funcType([], [$Bool], false), -1], ["IsValid", "IsValid", "", $funcType([], [$Bool], false), -1], ["Kind", "Kind", "", $funcType([], [Kind], false), -1], ["Len", "Len", "", $funcType([], [$Int], false), -1], ["MapIndex", "MapIndex", "", $funcType([Value], [Value], false), -1], ["MapKeys", "MapKeys", "", $funcType([], [($sliceType(Value))], false), -1], ["Method", "Method", "", $funcType([$Int], [Value], false), -1], ["MethodByName", "MethodByName", "", $funcType([$String], [Value], false), -1], ["NumField", "NumField", "", $funcType([], [$Int], false), -1], ["NumMethod", "NumMethod", "", $funcType([], [$Int], false), -1], ["OverflowComplex", "OverflowComplex", "", $funcType([$Complex128], [$Bool], false), -1], ["OverflowFloat", "OverflowFloat", "", $funcType([$Float64], [$Bool], false), -1], ["OverflowInt", "OverflowInt", "", $funcType([$Int64], [$Bool], false), -1], ["OverflowUint", "OverflowUint", "", $funcType([$Uint64], [$Bool], false), -1], ["Pointer", "Pointer", "", $funcType([], [$Uintptr], false), -1], ["Recv", "Recv", "", $funcType([], [Value, $Bool], false), -1], ["Send", "Send", "", $funcType([Value], [], false), -1], ["Set", "Set", "", $funcType([Value], [], false), -1], ["SetBool", "SetBool", "", $funcType([$Bool], [], false), -1], ["SetBytes", "SetBytes", "", $funcType([($sliceType($Uint8))], [], false), -1], ["SetCap", "SetCap", "", $funcType([$Int], [], false), -1], ["SetComplex", "SetComplex", "", $funcType([$Complex128], [], false), -1], ["SetFloat", "SetFloat", "", $funcType([$Float64], [], false), -1], ["SetInt", "SetInt", "", $funcType([$Int64], [], false), -1], ["SetLen", "SetLen", "", $funcType([$Int], [], false), -1], ["SetMapIndex", "SetMapIndex", "", $funcType([Value, Value], [], false), -1], ["SetPointer", "SetPointer", "", $funcType([$UnsafePointer], [], false), -1], ["SetString", "SetString", "", $funcType([$String], [], false), -1], ["SetUint", "SetUint", "", $funcType([$Uint64], [], false), -1], ["Slice", "Slice", "", $funcType([$Int, $Int], [Value], false), -1], ["Slice3", "Slice3", "", $funcType([$Int, $Int, $Int], [Value], false), -1], ["String", "String", "", $funcType([], [$String], false), -1], ["TryRecv", "TryRecv", "", $funcType([], [Value, $Bool], false), -1], ["TrySend", "TrySend", "", $funcType([Value], [$Bool], false), -1], ["Type", "Type", "", $funcType([], [Type], false), -1], ["Uint", "Uint", "", $funcType([], [$Uint64], false), -1], ["UnsafeAddr", "UnsafeAddr", "", $funcType([], [$Uintptr], false), -1], ["assignTo", "assignTo", "reflect", $funcType([$String, ($ptrType(rtype)), ($ptrType($emptyInterface))], [Value], false), -1], ["call", "call", "reflect", $funcType([$String, ($sliceType(Value))], [($sliceType(Value))], false), -1], ["iword", "iword", "reflect", $funcType([], [iword], false), -1], ["kind", "kind", "reflect", $funcType([], [Kind], false), 3], ["mustBe", "mustBe", "reflect", $funcType([Kind], [], false), 3], ["mustBeAssignable", "mustBeAssignable", "reflect", $funcType([], [], false), 3], ["mustBeExported", "mustBeExported", "reflect", $funcType([], [], false), 3], ["pointer", "pointer", "reflect", $funcType([], [$UnsafePointer], false), -1], ["recv", "recv", "reflect", $funcType([$Bool], [Value, $Bool], false), -1], ["runes", "runes", "reflect", $funcType([], [($sliceType($Int32))], false), -1], ["send", "send", "reflect", $funcType([Value, $Bool], [$Bool], false), -1], ["setRunes", "setRunes", "reflect", $funcType([($sliceType($Int32))], [], false), -1]]; - ($ptrType(Value)).methods = [["Addr", "Addr", "", $funcType([], [Value], false), -1], ["Bool", "Bool", "", $funcType([], [$Bool], false), -1], ["Bytes", "Bytes", "", $funcType([], [($sliceType($Uint8))], false), -1], ["Call", "Call", "", $funcType([($sliceType(Value))], [($sliceType(Value))], false), -1], ["CallSlice", "CallSlice", "", $funcType([($sliceType(Value))], [($sliceType(Value))], false), -1], ["CanAddr", "CanAddr", "", $funcType([], [$Bool], false), -1], ["CanInterface", "CanInterface", "", $funcType([], [$Bool], false), -1], ["CanSet", "CanSet", "", $funcType([], [$Bool], false), -1], ["Cap", "Cap", "", $funcType([], [$Int], false), -1], ["Close", "Close", "", $funcType([], [], false), -1], ["Complex", "Complex", "", $funcType([], [$Complex128], false), -1], ["Convert", "Convert", "", $funcType([Type], [Value], false), -1], ["Elem", "Elem", "", $funcType([], [Value], false), -1], ["Field", "Field", "", $funcType([$Int], [Value], false), -1], ["FieldByIndex", "FieldByIndex", "", $funcType([($sliceType($Int))], [Value], false), -1], ["FieldByName", "FieldByName", "", $funcType([$String], [Value], false), -1], ["FieldByNameFunc", "FieldByNameFunc", "", $funcType([($funcType([$String], [$Bool], false))], [Value], false), -1], ["Float", "Float", "", $funcType([], [$Float64], false), -1], ["Index", "Index", "", $funcType([$Int], [Value], false), -1], ["Int", "Int", "", $funcType([], [$Int64], false), -1], ["Interface", "Interface", "", $funcType([], [$emptyInterface], false), -1], ["InterfaceData", "InterfaceData", "", $funcType([], [($arrayType($Uintptr, 2))], false), -1], ["IsNil", "IsNil", "", $funcType([], [$Bool], false), -1], ["IsValid", "IsValid", "", $funcType([], [$Bool], false), -1], ["Kind", "Kind", "", $funcType([], [Kind], false), -1], ["Len", "Len", "", $funcType([], [$Int], false), -1], ["MapIndex", "MapIndex", "", $funcType([Value], [Value], false), -1], ["MapKeys", "MapKeys", "", $funcType([], [($sliceType(Value))], false), -1], ["Method", "Method", "", $funcType([$Int], [Value], false), -1], ["MethodByName", "MethodByName", "", $funcType([$String], [Value], false), -1], ["NumField", "NumField", "", $funcType([], [$Int], false), -1], ["NumMethod", "NumMethod", "", $funcType([], [$Int], false), -1], ["OverflowComplex", "OverflowComplex", "", $funcType([$Complex128], [$Bool], false), -1], ["OverflowFloat", "OverflowFloat", "", $funcType([$Float64], [$Bool], false), -1], ["OverflowInt", "OverflowInt", "", $funcType([$Int64], [$Bool], false), -1], ["OverflowUint", "OverflowUint", "", $funcType([$Uint64], [$Bool], false), -1], ["Pointer", "Pointer", "", $funcType([], [$Uintptr], false), -1], ["Recv", "Recv", "", $funcType([], [Value, $Bool], false), -1], ["Send", "Send", "", $funcType([Value], [], false), -1], ["Set", "Set", "", $funcType([Value], [], false), -1], ["SetBool", "SetBool", "", $funcType([$Bool], [], false), -1], ["SetBytes", "SetBytes", "", $funcType([($sliceType($Uint8))], [], false), -1], ["SetCap", "SetCap", "", $funcType([$Int], [], false), -1], ["SetComplex", "SetComplex", "", $funcType([$Complex128], [], false), -1], ["SetFloat", "SetFloat", "", $funcType([$Float64], [], false), -1], ["SetInt", "SetInt", "", $funcType([$Int64], [], false), -1], ["SetLen", "SetLen", "", $funcType([$Int], [], false), -1], ["SetMapIndex", "SetMapIndex", "", $funcType([Value, Value], [], false), -1], ["SetPointer", "SetPointer", "", $funcType([$UnsafePointer], [], false), -1], ["SetString", "SetString", "", $funcType([$String], [], false), -1], ["SetUint", "SetUint", "", $funcType([$Uint64], [], false), -1], ["Slice", "Slice", "", $funcType([$Int, $Int], [Value], false), -1], ["Slice3", "Slice3", "", $funcType([$Int, $Int, $Int], [Value], false), -1], ["String", "String", "", $funcType([], [$String], false), -1], ["TryRecv", "TryRecv", "", $funcType([], [Value, $Bool], false), -1], ["TrySend", "TrySend", "", $funcType([Value], [$Bool], false), -1], ["Type", "Type", "", $funcType([], [Type], false), -1], ["Uint", "Uint", "", $funcType([], [$Uint64], false), -1], ["UnsafeAddr", "UnsafeAddr", "", $funcType([], [$Uintptr], false), -1], ["assignTo", "assignTo", "reflect", $funcType([$String, ($ptrType(rtype)), ($ptrType($emptyInterface))], [Value], false), -1], ["call", "call", "reflect", $funcType([$String, ($sliceType(Value))], [($sliceType(Value))], false), -1], ["iword", "iword", "reflect", $funcType([], [iword], false), -1], ["kind", "kind", "reflect", $funcType([], [Kind], false), 3], ["mustBe", "mustBe", "reflect", $funcType([Kind], [], false), 3], ["mustBeAssignable", "mustBeAssignable", "reflect", $funcType([], [], false), 3], ["mustBeExported", "mustBeExported", "reflect", $funcType([], [], false), 3], ["pointer", "pointer", "reflect", $funcType([], [$UnsafePointer], false), -1], ["recv", "recv", "reflect", $funcType([$Bool], [Value, $Bool], false), -1], ["runes", "runes", "reflect", $funcType([], [($sliceType($Int32))], false), -1], ["send", "send", "reflect", $funcType([Value, $Bool], [$Bool], false), -1], ["setRunes", "setRunes", "reflect", $funcType([($sliceType($Int32))], [], false), -1]]; - Value.init([["typ", "typ", "reflect", ($ptrType(rtype)), ""], ["ptr", "ptr", "reflect", $UnsafePointer, ""], ["scalar", "scalar", "reflect", $Uintptr, ""], ["flag", "", "reflect", flag, ""]]); - flag.methods = [["kind", "kind", "reflect", $funcType([], [Kind], false), -1], ["mustBe", "mustBe", "reflect", $funcType([Kind], [], false), -1], ["mustBeAssignable", "mustBeAssignable", "reflect", $funcType([], [], false), -1], ["mustBeExported", "mustBeExported", "reflect", $funcType([], [], false), -1]]; - ($ptrType(flag)).methods = [["kind", "kind", "reflect", $funcType([], [Kind], false), -1], ["mustBe", "mustBe", "reflect", $funcType([Kind], [], false), -1], ["mustBeAssignable", "mustBeAssignable", "reflect", $funcType([], [], false), -1], ["mustBeExported", "mustBeExported", "reflect", $funcType([], [], false), -1]]; - ($ptrType(ValueError)).methods = [["Error", "Error", "", $funcType([], [$String], false), -1]]; - ValueError.init([["Method", "Method", "", $String, ""], ["Kind", "Kind", "", Kind, ""]]); - nonEmptyInterface.init([["itab", "itab", "reflect", ($ptrType(($structType([["ityp", "ityp", "reflect", ($ptrType(rtype)), ""], ["typ", "typ", "reflect", ($ptrType(rtype)), ""], ["link", "link", "reflect", $UnsafePointer, ""], ["bad", "bad", "reflect", $Int32, ""], ["unused", "unused", "reflect", $Int32, ""], ["fun", "fun", "reflect", ($arrayType($UnsafePointer, 100000)), ""]])))), ""], ["word", "word", "reflect", iword, ""]]); - initialized = false; - kindNames = new ($sliceType($String))(["invalid", "bool", "int", "int8", "int16", "int32", "int64", "uint", "uint8", "uint16", "uint32", "uint64", "uintptr", "float32", "float64", "complex64", "complex128", "array", "chan", "func", "interface", "map", "ptr", "slice", "string", "struct", "unsafe.Pointer"]); - uint8Type = $assertType(TypeOf(new $Uint8(0)), ($ptrType(rtype))); - init(); + Value.prototype.FieldByNameFunc = function(match) { return this.$val.FieldByNameFunc(match); }; + Value.Ptr.prototype.Float = function() { + var v, k, _ref; + v = new Value.Ptr(); $copy(v, this, Value); + k = (new flag(v.flag)).kind(); + _ref = k; + if (_ref === 13) { + if (!((((v.flag & 2) >>> 0) === 0))) { + return $coerceFloat32(v.ptr.$get()); + } + return $coerceFloat32(v.scalar); + } else if (_ref === 14) { + if (!((((v.flag & 2) >>> 0) === 0))) { + return v.ptr.$get(); + } + return v.scalar; + } + $panic(new ValueError.Ptr("reflect.Value.Float", k)); }; - return $pkg; -})(); -$packages["fmt"] = (function() { - var $pkg = {}, math = $packages["math"], strconv = $packages["strconv"], utf8 = $packages["unicode/utf8"], errors = $packages["errors"], io = $packages["io"], os = $packages["os"], reflect = $packages["reflect"], sync = $packages["sync"], fmt, State, Formatter, Stringer, GoStringer, buffer, pp, runeUnreader, ScanState, scanError, ss, ssave, padZeroBytes, padSpaceBytes, trueBytes, falseBytes, commaSpaceBytes, nilAngleBytes, nilParenBytes, nilBytes, mapBytes, percentBangBytes, missingBytes, badIndexBytes, panicBytes, extraBytes, irparenBytes, bytesBytes, badWidthBytes, badPrecBytes, noVerbBytes, ppFree, intBits, uintptrBits, space, ssFree, complexError, boolError, init, doPrec, newPrinter, Fprintf, Printf, Sprintf, Errorf, Fprint, Print, Sprint, Fprintln, Println, Sprintln, getField, parsenum, intFromArg, parseArgNumber, isSpace, notSpace, indexRune; - fmt = $pkg.fmt = $newType(0, "Struct", "fmt.fmt", "fmt", "fmt", function(intbuf_, buf_, wid_, prec_, widPresent_, precPresent_, minus_, plus_, sharp_, space_, unicode_, uniQuote_, zero_) { - this.$val = this; - this.intbuf = intbuf_ !== undefined ? intbuf_ : ($arrayType($Uint8, 65)).zero(); - this.buf = buf_ !== undefined ? buf_ : ($ptrType(buffer)).nil; - this.wid = wid_ !== undefined ? wid_ : 0; - this.prec = prec_ !== undefined ? prec_ : 0; - this.widPresent = widPresent_ !== undefined ? widPresent_ : false; - this.precPresent = precPresent_ !== undefined ? precPresent_ : false; - this.minus = minus_ !== undefined ? minus_ : false; - this.plus = plus_ !== undefined ? plus_ : false; - this.sharp = sharp_ !== undefined ? sharp_ : false; - this.space = space_ !== undefined ? space_ : false; - this.unicode = unicode_ !== undefined ? unicode_ : false; - this.uniQuote = uniQuote_ !== undefined ? uniQuote_ : false; - this.zero = zero_ !== undefined ? zero_ : false; - }); - State = $pkg.State = $newType(8, "Interface", "fmt.State", "State", "fmt", null); - Formatter = $pkg.Formatter = $newType(8, "Interface", "fmt.Formatter", "Formatter", "fmt", null); - Stringer = $pkg.Stringer = $newType(8, "Interface", "fmt.Stringer", "Stringer", "fmt", null); - GoStringer = $pkg.GoStringer = $newType(8, "Interface", "fmt.GoStringer", "GoStringer", "fmt", null); - buffer = $pkg.buffer = $newType(12, "Slice", "fmt.buffer", "buffer", "fmt", null); - pp = $pkg.pp = $newType(0, "Struct", "fmt.pp", "pp", "fmt", function(n_, panicking_, erroring_, buf_, arg_, value_, reordered_, goodArgNum_, runeBuf_, fmt_) { - this.$val = this; - this.n = n_ !== undefined ? n_ : 0; - this.panicking = panicking_ !== undefined ? panicking_ : false; - this.erroring = erroring_ !== undefined ? erroring_ : false; - this.buf = buf_ !== undefined ? buf_ : buffer.nil; - this.arg = arg_ !== undefined ? arg_ : $ifaceNil; - this.value = value_ !== undefined ? value_ : new reflect.Value.Ptr(); - this.reordered = reordered_ !== undefined ? reordered_ : false; - this.goodArgNum = goodArgNum_ !== undefined ? goodArgNum_ : false; - this.runeBuf = runeBuf_ !== undefined ? runeBuf_ : ($arrayType($Uint8, 4)).zero(); - this.fmt = fmt_ !== undefined ? fmt_ : new fmt.Ptr(); - }); - runeUnreader = $pkg.runeUnreader = $newType(8, "Interface", "fmt.runeUnreader", "runeUnreader", "fmt", null); - ScanState = $pkg.ScanState = $newType(8, "Interface", "fmt.ScanState", "ScanState", "fmt", null); - scanError = $pkg.scanError = $newType(0, "Struct", "fmt.scanError", "scanError", "fmt", function(err_) { - this.$val = this; - this.err = err_ !== undefined ? err_ : $ifaceNil; - }); - ss = $pkg.ss = $newType(0, "Struct", "fmt.ss", "ss", "fmt", function(rr_, buf_, peekRune_, prevRune_, count_, atEOF_, ssave_) { - this.$val = this; - this.rr = rr_ !== undefined ? rr_ : $ifaceNil; - this.buf = buf_ !== undefined ? buf_ : buffer.nil; - this.peekRune = peekRune_ !== undefined ? peekRune_ : 0; - this.prevRune = prevRune_ !== undefined ? prevRune_ : 0; - this.count = count_ !== undefined ? count_ : 0; - this.atEOF = atEOF_ !== undefined ? atEOF_ : false; - this.ssave = ssave_ !== undefined ? ssave_ : new ssave.Ptr(); - }); - ssave = $pkg.ssave = $newType(0, "Struct", "fmt.ssave", "ssave", "fmt", function(validSave_, nlIsEnd_, nlIsSpace_, argLimit_, limit_, maxWid_) { - this.$val = this; - this.validSave = validSave_ !== undefined ? validSave_ : false; - this.nlIsEnd = nlIsEnd_ !== undefined ? nlIsEnd_ : false; - this.nlIsSpace = nlIsSpace_ !== undefined ? nlIsSpace_ : false; - this.argLimit = argLimit_ !== undefined ? argLimit_ : 0; - this.limit = limit_ !== undefined ? limit_ : 0; - this.maxWid = maxWid_ !== undefined ? maxWid_ : 0; - }); - init = function() { - var i; - i = 0; - while (i < 65) { - (i < 0 || i >= padZeroBytes.$length) ? $throwRuntimeError("index out of range") : padZeroBytes.$array[padZeroBytes.$offset + i] = 48; - (i < 0 || i >= padSpaceBytes.$length) ? $throwRuntimeError("index out of range") : padSpaceBytes.$array[padSpaceBytes.$offset + i] = 32; - i = i + (1) >> 0; + Value.prototype.Float = function() { return this.$val.Float(); }; + Value.Ptr.prototype.Int = function() { + var v, k, p, _ref; + v = new Value.Ptr(); $copy(v, this, Value); + k = (new flag(v.flag)).kind(); + p = 0; + if (!((((v.flag & 2) >>> 0) === 0))) { + p = v.ptr; + } else { + p = new ($ptrType($Uintptr))(function() { return this.$target.scalar; }, function($v) { this.$target.scalar = $v; }, v); + } + _ref = k; + if (_ref === 2) { + return new $Int64(0, p.$get()); + } else if (_ref === 3) { + return new $Int64(0, p.$get()); + } else if (_ref === 4) { + return new $Int64(0, p.$get()); + } else if (_ref === 5) { + return new $Int64(0, p.$get()); + } else if (_ref === 6) { + return p.$get(); } + $panic(new ValueError.Ptr("reflect.Value.Int", k)); }; - fmt.Ptr.prototype.clearflags = function() { - var f; - f = this; - f.wid = 0; - f.widPresent = false; - f.prec = 0; - f.precPresent = false; - f.minus = false; - f.plus = false; - f.sharp = false; - f.space = false; - f.unicode = false; - f.uniQuote = false; - f.zero = false; + Value.prototype.Int = function() { return this.$val.Int(); }; + Value.Ptr.prototype.CanInterface = function() { + var v; + v = new Value.Ptr(); $copy(v, this, Value); + if (v.flag === 0) { + $panic(new ValueError.Ptr("reflect.Value.CanInterface", 0)); + } + return ((v.flag & 1) >>> 0) === 0; }; - fmt.prototype.clearflags = function() { return this.$val.clearflags(); }; - fmt.Ptr.prototype.init = function(buf) { - var f; - f = this; - f.buf = buf; - f.clearflags(); + Value.prototype.CanInterface = function() { return this.$val.CanInterface(); }; + Value.Ptr.prototype.Interface = function() { + var i = $ifaceNil, v; + v = new Value.Ptr(); $copy(v, this, Value); + i = valueInterface($clone(v, Value), true); + return i; }; - fmt.prototype.init = function(buf) { return this.$val.init(buf); }; - fmt.Ptr.prototype.computePadding = function(width) { - var padding = ($sliceType($Uint8)).nil, leftWidth = 0, rightWidth = 0, f, left, w, _tmp, _tmp$1, _tmp$2, _tmp$3, _tmp$4, _tmp$5, _tmp$6, _tmp$7, _tmp$8; - f = this; - left = !f.minus; - w = f.wid; - if (w < 0) { - left = false; - w = -w; - } - w = w - (width) >> 0; - if (w > 0) { - if (left && f.zero) { - _tmp = padZeroBytes; _tmp$1 = w; _tmp$2 = 0; padding = _tmp; leftWidth = _tmp$1; rightWidth = _tmp$2; - return [padding, leftWidth, rightWidth]; - } - if (left) { - _tmp$3 = padSpaceBytes; _tmp$4 = w; _tmp$5 = 0; padding = _tmp$3; leftWidth = _tmp$4; rightWidth = _tmp$5; - return [padding, leftWidth, rightWidth]; - } else { - _tmp$6 = padSpaceBytes; _tmp$7 = 0; _tmp$8 = w; padding = _tmp$6; leftWidth = _tmp$7; rightWidth = _tmp$8; - return [padding, leftWidth, rightWidth]; - } - } - return [padding, leftWidth, rightWidth]; + Value.prototype.Interface = function() { return this.$val.Interface(); }; + Value.Ptr.prototype.InterfaceData = function() { + var v; + v = new Value.Ptr(); $copy(v, this, Value); + (new flag(v.flag)).mustBe(20); + return v.ptr; }; - fmt.prototype.computePadding = function(width) { return this.$val.computePadding(width); }; - fmt.Ptr.prototype.writePadding = function(n, padding) { - var f, m; - f = this; - while (n > 0) { - m = n; - if (m > 65) { - m = 65; - } - f.buf.Write($subslice(padding, 0, m)); - n = n - (m) >> 0; - } + Value.prototype.InterfaceData = function() { return this.$val.InterfaceData(); }; + Value.Ptr.prototype.IsValid = function() { + var v; + v = new Value.Ptr(); $copy(v, this, Value); + return !((v.flag === 0)); }; - fmt.prototype.writePadding = function(n, padding) { return this.$val.writePadding(n, padding); }; - fmt.Ptr.prototype.pad = function(b) { - var f, _tuple, padding, left, right; - f = this; - if (!f.widPresent || (f.wid === 0)) { - f.buf.Write(b); - return; - } - _tuple = f.computePadding(b.$length); padding = _tuple[0]; left = _tuple[1]; right = _tuple[2]; - if (left > 0) { - f.writePadding(left, padding); - } - f.buf.Write(b); - if (right > 0) { - f.writePadding(right, padding); - } + Value.prototype.IsValid = function() { return this.$val.IsValid(); }; + Value.Ptr.prototype.Kind = function() { + var v; + v = new Value.Ptr(); $copy(v, this, Value); + return (new flag(v.flag)).kind(); }; - fmt.prototype.pad = function(b) { return this.$val.pad(b); }; - fmt.Ptr.prototype.padString = function(s) { - var f, _tuple, padding, left, right; - f = this; - if (!f.widPresent || (f.wid === 0)) { - f.buf.WriteString(s); - return; - } - _tuple = f.computePadding(utf8.RuneCountInString(s)); padding = _tuple[0]; left = _tuple[1]; right = _tuple[2]; - if (left > 0) { - f.writePadding(left, padding); + Value.prototype.Kind = function() { return this.$val.Kind(); }; + Value.Ptr.prototype.MapIndex = function(key) { + var v, tt, k, e, typ, fl, c; + v = new Value.Ptr(); $copy(v, this, Value); + (new flag(v.flag)).mustBe(21); + tt = v.typ.mapType; + $copy(key, key.assignTo("reflect.Value.MapIndex", tt.key, ($ptrType($emptyInterface)).nil), Value); + k = 0; + if (!((((key.flag & 2) >>> 0) === 0))) { + k = key.ptr; + } else if (key.typ.pointers()) { + k = new ($ptrType($UnsafePointer))(function() { return this.$target.ptr; }, function($v) { this.$target.ptr = $v; }, key); + } else { + k = new ($ptrType($Uintptr))(function() { return this.$target.scalar; }, function($v) { this.$target.scalar = $v; }, key); } - f.buf.WriteString(s); - if (right > 0) { - f.writePadding(right, padding); + e = mapaccess(v.typ, v.pointer(), k); + if (e === 0) { + return new Value.Ptr(($ptrType(rtype)).nil, 0, 0, 0); } - }; - fmt.prototype.padString = function(s) { return this.$val.padString(s); }; - fmt.Ptr.prototype.fmt_boolean = function(v) { - var f; - f = this; - if (v) { - f.pad(trueBytes); + typ = tt.elem; + fl = ((((v.flag | key.flag) >>> 0)) & 1) >>> 0; + fl = (fl | (((typ.Kind() >>> 0) << 4 >>> 0))) >>> 0; + if (typ.size > 4) { + c = unsafe_New(typ); + memmove(c, e, typ.size); + return new Value.Ptr(typ, c, 0, (fl | 2) >>> 0); + } else if (typ.pointers()) { + return new Value.Ptr(typ, e.$get(), 0, fl); } else { - f.pad(falseBytes); + return new Value.Ptr(typ, 0, loadScalar(e, typ.size), fl); } }; - fmt.prototype.fmt_boolean = function(v) { return this.$val.fmt_boolean(v); }; - fmt.Ptr.prototype.integer = function(a, base, signedness, digits) { - var f, buf, width, negative, prec, i, ua, _ref, runeWidth, width$1, j; - f = this; - if (f.precPresent && (f.prec === 0) && (a.$high === 0 && a.$low === 0)) { - return; + Value.prototype.MapIndex = function(key) { return this.$val.MapIndex(key); }; + Value.Ptr.prototype.MapKeys = function() { + var v, tt, keyType, fl, m, mlen, it, a, i, key, c; + v = new Value.Ptr(); $copy(v, this, Value); + (new flag(v.flag)).mustBe(21); + tt = v.typ.mapType; + keyType = tt.key; + fl = (((v.flag & 1) >>> 0) | ((keyType.Kind() >>> 0) << 4 >>> 0)) >>> 0; + m = v.pointer(); + mlen = 0; + if (!(m === 0)) { + mlen = maplen(m); } - buf = $subslice(new ($sliceType($Uint8))(f.intbuf), 0); - if (f.widPresent) { - width = f.wid; - if ((base.$high === 0 && base.$low === 16) && f.sharp) { - width = width + (2) >> 0; + it = mapiterinit(v.typ, m); + a = ($sliceType(Value)).make(mlen); + i = 0; + i = 0; + while (i < a.$length) { + key = mapiterkey(it); + if (key === 0) { + break; } - if (width > 65) { - buf = ($sliceType($Uint8)).make(width); + if (keyType.size > 4) { + c = unsafe_New(keyType); + memmove(c, key, keyType.size); + $copy(((i < 0 || i >= a.$length) ? $throwRuntimeError("index out of range") : a.$array[a.$offset + i]), new Value.Ptr(keyType, c, 0, (fl | 2) >>> 0), Value); + } else if (keyType.pointers()) { + $copy(((i < 0 || i >= a.$length) ? $throwRuntimeError("index out of range") : a.$array[a.$offset + i]), new Value.Ptr(keyType, key.$get(), 0, fl), Value); + } else { + $copy(((i < 0 || i >= a.$length) ? $throwRuntimeError("index out of range") : a.$array[a.$offset + i]), new Value.Ptr(keyType, 0, loadScalar(key, keyType.size), fl), Value); } + mapiternext(it); + i = i + (1) >> 0; } - negative = signedness === true && (a.$high < 0 || (a.$high === 0 && a.$low < 0)); - if (negative) { - a = new $Int64(-a.$high, -a.$low); + return $subslice(a, 0, i); + }; + Value.prototype.MapKeys = function() { return this.$val.MapKeys(); }; + Value.Ptr.prototype.Method = function(i) { + var v, fl; + v = new Value.Ptr(); $copy(v, this, Value); + if (v.typ === ($ptrType(rtype)).nil) { + $panic(new ValueError.Ptr("reflect.Value.Method", 0)); } - prec = 0; - if (f.precPresent) { - prec = f.prec; - f.zero = false; - } else if (f.zero && f.widPresent && !f.minus && f.wid > 0) { - prec = f.wid; - if (negative || f.plus || f.space) { - prec = prec - (1) >> 0; - } + if (!((((v.flag & 8) >>> 0) === 0)) || i < 0 || i >= v.typ.NumMethod()) { + $panic(new $String("reflect: Method index out of range")); } - i = buf.$length; - ua = new $Uint64(a.$high, a.$low); - while ((ua.$high > base.$high || (ua.$high === base.$high && ua.$low >= base.$low))) { - i = i - (1) >> 0; - (i < 0 || i >= buf.$length) ? $throwRuntimeError("index out of range") : buf.$array[buf.$offset + i] = digits.charCodeAt($flatten64($div64(ua, base, true))); - ua = $div64(ua, (base), false); + if ((v.typ.Kind() === 20) && v.IsNil()) { + $panic(new $String("reflect: Method on nil interface value")); } - i = i - (1) >> 0; - (i < 0 || i >= buf.$length) ? $throwRuntimeError("index out of range") : buf.$array[buf.$offset + i] = digits.charCodeAt($flatten64(ua)); - while (i > 0 && prec > (buf.$length - i >> 0)) { - i = i - (1) >> 0; - (i < 0 || i >= buf.$length) ? $throwRuntimeError("index out of range") : buf.$array[buf.$offset + i] = 48; + fl = (v.flag & 3) >>> 0; + fl = (fl | (304)) >>> 0; + fl = (fl | (((((i >>> 0) << 9 >>> 0) | 8) >>> 0))) >>> 0; + return new Value.Ptr(v.typ, v.ptr, v.scalar, fl); + }; + Value.prototype.Method = function(i) { return this.$val.Method(i); }; + Value.Ptr.prototype.NumMethod = function() { + var v; + v = new Value.Ptr(); $copy(v, this, Value); + if (v.typ === ($ptrType(rtype)).nil) { + $panic(new ValueError.Ptr("reflect.Value.NumMethod", 0)); } - if (f.sharp) { - _ref = base; - if ((_ref.$high === 0 && _ref.$low === 8)) { - if (!((((i < 0 || i >= buf.$length) ? $throwRuntimeError("index out of range") : buf.$array[buf.$offset + i]) === 48))) { - i = i - (1) >> 0; - (i < 0 || i >= buf.$length) ? $throwRuntimeError("index out of range") : buf.$array[buf.$offset + i] = 48; - } - } else if ((_ref.$high === 0 && _ref.$low === 16)) { - i = i - (1) >> 0; - (i < 0 || i >= buf.$length) ? $throwRuntimeError("index out of range") : buf.$array[buf.$offset + i] = (120 + digits.charCodeAt(10) << 24 >>> 24) - 97 << 24 >>> 24; - i = i - (1) >> 0; - (i < 0 || i >= buf.$length) ? $throwRuntimeError("index out of range") : buf.$array[buf.$offset + i] = 48; - } + if (!((((v.flag & 8) >>> 0) === 0))) { + return 0; } - if (f.unicode) { - i = i - (1) >> 0; - (i < 0 || i >= buf.$length) ? $throwRuntimeError("index out of range") : buf.$array[buf.$offset + i] = 43; - i = i - (1) >> 0; - (i < 0 || i >= buf.$length) ? $throwRuntimeError("index out of range") : buf.$array[buf.$offset + i] = 85; + return v.typ.NumMethod(); + }; + Value.prototype.NumMethod = function() { return this.$val.NumMethod(); }; + Value.Ptr.prototype.MethodByName = function(name) { + var v, _tuple, m, ok; + v = new Value.Ptr(); $copy(v, this, Value); + if (v.typ === ($ptrType(rtype)).nil) { + $panic(new ValueError.Ptr("reflect.Value.MethodByName", 0)); } - if (negative) { - i = i - (1) >> 0; - (i < 0 || i >= buf.$length) ? $throwRuntimeError("index out of range") : buf.$array[buf.$offset + i] = 45; - } else if (f.plus) { - i = i - (1) >> 0; - (i < 0 || i >= buf.$length) ? $throwRuntimeError("index out of range") : buf.$array[buf.$offset + i] = 43; - } else if (f.space) { - i = i - (1) >> 0; - (i < 0 || i >= buf.$length) ? $throwRuntimeError("index out of range") : buf.$array[buf.$offset + i] = 32; + if (!((((v.flag & 8) >>> 0) === 0))) { + return new Value.Ptr(($ptrType(rtype)).nil, 0, 0, 0); } - if (f.unicode && f.uniQuote && (a.$high > 0 || (a.$high === 0 && a.$low >= 0)) && (a.$high < 0 || (a.$high === 0 && a.$low <= 1114111)) && strconv.IsPrint(((a.$low + ((a.$high >> 31) * 4294967296)) >> 0))) { - runeWidth = utf8.RuneLen(((a.$low + ((a.$high >> 31) * 4294967296)) >> 0)); - width$1 = (2 + runeWidth >> 0) + 1 >> 0; - $copySlice($subslice(buf, (i - width$1 >> 0)), $subslice(buf, i)); - i = i - (width$1) >> 0; - j = buf.$length - width$1 >> 0; - (j < 0 || j >= buf.$length) ? $throwRuntimeError("index out of range") : buf.$array[buf.$offset + j] = 32; - j = j + (1) >> 0; - (j < 0 || j >= buf.$length) ? $throwRuntimeError("index out of range") : buf.$array[buf.$offset + j] = 39; - j = j + (1) >> 0; - utf8.EncodeRune($subslice(buf, j), ((a.$low + ((a.$high >> 31) * 4294967296)) >> 0)); - j = j + (runeWidth) >> 0; - (j < 0 || j >= buf.$length) ? $throwRuntimeError("index out of range") : buf.$array[buf.$offset + j] = 39; + _tuple = v.typ.MethodByName(name); m = new Method.Ptr(); $copy(m, _tuple[0], Method); ok = _tuple[1]; + if (!ok) { + return new Value.Ptr(($ptrType(rtype)).nil, 0, 0, 0); } - f.pad($subslice(buf, i)); + return v.Method(m.Index); }; - fmt.prototype.integer = function(a, base, signedness, digits) { return this.$val.integer(a, base, signedness, digits); }; - fmt.Ptr.prototype.truncate = function(s) { - var f, n, _ref, _i, _rune, i; - f = this; - if (f.precPresent && f.prec < utf8.RuneCountInString(s)) { - n = f.prec; - _ref = s; - _i = 0; - while (_i < _ref.length) { - _rune = $decodeRune(_ref, _i); - i = _i; - if (n === 0) { - s = s.substring(0, i); - break; - } - n = n - (1) >> 0; - _i += _rune[1]; - } + Value.prototype.MethodByName = function(name) { return this.$val.MethodByName(name); }; + Value.Ptr.prototype.NumField = function() { + var v, tt; + v = new Value.Ptr(); $copy(v, this, Value); + (new flag(v.flag)).mustBe(25); + tt = v.typ.structType; + return tt.fields.$length; + }; + Value.prototype.NumField = function() { return this.$val.NumField(); }; + Value.Ptr.prototype.OverflowComplex = function(x) { + var v, k, _ref; + v = new Value.Ptr(); $copy(v, this, Value); + k = (new flag(v.flag)).kind(); + _ref = k; + if (_ref === 15) { + return overflowFloat32(x.$real) || overflowFloat32(x.$imag); + } else if (_ref === 16) { + return false; } - return s; + $panic(new ValueError.Ptr("reflect.Value.OverflowComplex", k)); }; - fmt.prototype.truncate = function(s) { return this.$val.truncate(s); }; - fmt.Ptr.prototype.fmt_s = function(s) { - var f; - f = this; - s = f.truncate(s); - f.padString(s); + Value.prototype.OverflowComplex = function(x) { return this.$val.OverflowComplex(x); }; + Value.Ptr.prototype.OverflowFloat = function(x) { + var v, k, _ref; + v = new Value.Ptr(); $copy(v, this, Value); + k = (new flag(v.flag)).kind(); + _ref = k; + if (_ref === 13) { + return overflowFloat32(x); + } else if (_ref === 14) { + return false; + } + $panic(new ValueError.Ptr("reflect.Value.OverflowFloat", k)); }; - fmt.prototype.fmt_s = function(s) { return this.$val.fmt_s(s); }; - fmt.Ptr.prototype.fmt_sbx = function(s, b, digits) { - var f, n, x, buf, i, c; - f = this; - n = b.$length; - if (b === ($sliceType($Uint8)).nil) { - n = s.length; + Value.prototype.OverflowFloat = function(x) { return this.$val.OverflowFloat(x); }; + overflowFloat32 = function(x) { + if (x < 0) { + x = -x; } - x = (digits.charCodeAt(10) - 97 << 24 >>> 24) + 120 << 24 >>> 24; - buf = ($sliceType($Uint8)).nil; - i = 0; - while (i < n) { - if (i > 0 && f.space) { - buf = $append(buf, 32); - } - if (f.sharp) { - buf = $append(buf, 48, x); - } - c = 0; - if (b === ($sliceType($Uint8)).nil) { - c = s.charCodeAt(i); - } else { - c = ((i < 0 || i >= b.$length) ? $throwRuntimeError("index out of range") : b.$array[b.$offset + i]); - } - buf = $append(buf, digits.charCodeAt((c >>> 4 << 24 >>> 24)), digits.charCodeAt(((c & 15) >>> 0))); - i = i + (1) >> 0; + return 3.4028234663852886e+38 < x && x <= 1.7976931348623157e+308; + }; + Value.Ptr.prototype.OverflowInt = function(x) { + var v, k, _ref, x$1, bitSize, trunc; + v = new Value.Ptr(); $copy(v, this, Value); + k = (new flag(v.flag)).kind(); + _ref = k; + if (_ref === 2 || _ref === 3 || _ref === 4 || _ref === 5 || _ref === 6) { + bitSize = (x$1 = v.typ.size, (((x$1 >>> 16 << 16) * 8 >>> 0) + (x$1 << 16 >>> 16) * 8) >>> 0); + trunc = $shiftRightInt64(($shiftLeft64(x, ((64 - bitSize >>> 0)))), ((64 - bitSize >>> 0))); + return !((x.$high === trunc.$high && x.$low === trunc.$low)); } - f.pad(buf); + $panic(new ValueError.Ptr("reflect.Value.OverflowInt", k)); }; - fmt.prototype.fmt_sbx = function(s, b, digits) { return this.$val.fmt_sbx(s, b, digits); }; - fmt.Ptr.prototype.fmt_sx = function(s, digits) { - var f; - f = this; - f.fmt_sbx(s, ($sliceType($Uint8)).nil, digits); + Value.prototype.OverflowInt = function(x) { return this.$val.OverflowInt(x); }; + Value.Ptr.prototype.OverflowUint = function(x) { + var v, k, _ref, x$1, bitSize, trunc; + v = new Value.Ptr(); $copy(v, this, Value); + k = (new flag(v.flag)).kind(); + _ref = k; + if (_ref === 7 || _ref === 12 || _ref === 8 || _ref === 9 || _ref === 10 || _ref === 11) { + bitSize = (x$1 = v.typ.size, (((x$1 >>> 16 << 16) * 8 >>> 0) + (x$1 << 16 >>> 16) * 8) >>> 0); + trunc = $shiftRightUint64(($shiftLeft64(x, ((64 - bitSize >>> 0)))), ((64 - bitSize >>> 0))); + return !((x.$high === trunc.$high && x.$low === trunc.$low)); + } + $panic(new ValueError.Ptr("reflect.Value.OverflowUint", k)); }; - fmt.prototype.fmt_sx = function(s, digits) { return this.$val.fmt_sx(s, digits); }; - fmt.Ptr.prototype.fmt_bx = function(b, digits) { - var f; - f = this; - f.fmt_sbx("", b, digits); + Value.prototype.OverflowUint = function(x) { return this.$val.OverflowUint(x); }; + Value.Ptr.prototype.SetBool = function(x) { + var v; + v = new Value.Ptr(); $copy(v, this, Value); + (new flag(v.flag)).mustBeAssignable(); + (new flag(v.flag)).mustBe(1); + v.ptr.$set(x); }; - fmt.prototype.fmt_bx = function(b, digits) { return this.$val.fmt_bx(b, digits); }; - fmt.Ptr.prototype.fmt_q = function(s) { - var f, quoted; - f = this; - s = f.truncate(s); - quoted = ""; - if (f.sharp && strconv.CanBackquote(s)) { - quoted = "`" + s + "`"; - } else { - if (f.plus) { - quoted = strconv.QuoteToASCII(s); - } else { - quoted = strconv.Quote(s); - } + Value.prototype.SetBool = function(x) { return this.$val.SetBool(x); }; + Value.Ptr.prototype.SetBytes = function(x) { + var v; + v = new Value.Ptr(); $copy(v, this, Value); + (new flag(v.flag)).mustBeAssignable(); + (new flag(v.flag)).mustBe(23); + if (!((v.typ.Elem().Kind() === 8))) { + $panic(new $String("reflect.Value.SetBytes of non-byte slice")); } - f.padString(quoted); + v.ptr.$set(x); }; - fmt.prototype.fmt_q = function(s) { return this.$val.fmt_q(s); }; - fmt.Ptr.prototype.fmt_qc = function(c) { - var f, quoted; - f = this; - quoted = ($sliceType($Uint8)).nil; - if (f.plus) { - quoted = strconv.AppendQuoteRuneToASCII($subslice(new ($sliceType($Uint8))(f.intbuf), 0, 0), ((c.$low + ((c.$high >> 31) * 4294967296)) >> 0)); - } else { - quoted = strconv.AppendQuoteRune($subslice(new ($sliceType($Uint8))(f.intbuf), 0, 0), ((c.$low + ((c.$high >> 31) * 4294967296)) >> 0)); + Value.prototype.SetBytes = function(x) { return this.$val.SetBytes(x); }; + Value.Ptr.prototype.setRunes = function(x) { + var v; + v = new Value.Ptr(); $copy(v, this, Value); + (new flag(v.flag)).mustBeAssignable(); + (new flag(v.flag)).mustBe(23); + if (!((v.typ.Elem().Kind() === 5))) { + $panic(new $String("reflect.Value.setRunes of non-rune slice")); } - f.pad(quoted); + v.ptr.$set(x); }; - fmt.prototype.fmt_qc = function(c) { return this.$val.fmt_qc(c); }; - doPrec = function(f, def) { - if (f.precPresent) { - return f.prec; + Value.prototype.setRunes = function(x) { return this.$val.setRunes(x); }; + Value.Ptr.prototype.SetComplex = function(x) { + var v, k, _ref; + v = new Value.Ptr(); $copy(v, this, Value); + (new flag(v.flag)).mustBeAssignable(); + k = (new flag(v.flag)).kind(); + _ref = k; + if (_ref === 15) { + v.ptr.$set(new $Complex64(x.$real, x.$imag)); + } else if (_ref === 16) { + v.ptr.$set(x); + } else { + $panic(new ValueError.Ptr("reflect.Value.SetComplex", k)); } - return def; }; - fmt.Ptr.prototype.formatFloat = function(v, verb, prec, n) { - var $deferred = [], $err = null, f, num; - /* */ try { $deferFrames.push($deferred); - f = this; - num = strconv.AppendFloat($subslice(new ($sliceType($Uint8))(f.intbuf), 0, 1), v, verb, prec, n); - if ((((1 < 0 || 1 >= num.$length) ? $throwRuntimeError("index out of range") : num.$array[num.$offset + 1]) === 45) || (((1 < 0 || 1 >= num.$length) ? $throwRuntimeError("index out of range") : num.$array[num.$offset + 1]) === 43)) { - num = $subslice(num, 1); + Value.prototype.SetComplex = function(x) { return this.$val.SetComplex(x); }; + Value.Ptr.prototype.SetFloat = function(x) { + var v, k, _ref; + v = new Value.Ptr(); $copy(v, this, Value); + (new flag(v.flag)).mustBeAssignable(); + k = (new flag(v.flag)).kind(); + _ref = k; + if (_ref === 13) { + v.ptr.$set(x); + } else if (_ref === 14) { + v.ptr.$set(x); } else { - (0 < 0 || 0 >= num.$length) ? $throwRuntimeError("index out of range") : num.$array[num.$offset + 0] = 43; - } - if (math.IsInf(v, 0)) { - if (f.zero) { - $deferred.push([(function() { - f.zero = true; - }), []]); - f.zero = false; - } + $panic(new ValueError.Ptr("reflect.Value.SetFloat", k)); } - if (f.zero && f.widPresent && f.wid > num.$length) { - if (f.space && v >= 0) { - f.buf.WriteByte(32); - f.wid = f.wid - (1) >> 0; - } else if (f.plus || v < 0) { - f.buf.WriteByte(((0 < 0 || 0 >= num.$length) ? $throwRuntimeError("index out of range") : num.$array[num.$offset + 0])); - f.wid = f.wid - (1) >> 0; - } - f.pad($subslice(num, 1)); - return; + }; + Value.prototype.SetFloat = function(x) { return this.$val.SetFloat(x); }; + Value.Ptr.prototype.SetInt = function(x) { + var v, k, _ref; + v = new Value.Ptr(); $copy(v, this, Value); + (new flag(v.flag)).mustBeAssignable(); + k = (new flag(v.flag)).kind(); + _ref = k; + if (_ref === 2) { + v.ptr.$set(((x.$low + ((x.$high >> 31) * 4294967296)) >> 0)); + } else if (_ref === 3) { + v.ptr.$set(((x.$low + ((x.$high >> 31) * 4294967296)) << 24 >> 24)); + } else if (_ref === 4) { + v.ptr.$set(((x.$low + ((x.$high >> 31) * 4294967296)) << 16 >> 16)); + } else if (_ref === 5) { + v.ptr.$set(((x.$low + ((x.$high >> 31) * 4294967296)) >> 0)); + } else if (_ref === 6) { + v.ptr.$set(x); + } else { + $panic(new ValueError.Ptr("reflect.Value.SetInt", k)); } - if (f.space && (((0 < 0 || 0 >= num.$length) ? $throwRuntimeError("index out of range") : num.$array[num.$offset + 0]) === 43)) { - (0 < 0 || 0 >= num.$length) ? $throwRuntimeError("index out of range") : num.$array[num.$offset + 0] = 32; - f.pad(num); - return; + }; + Value.prototype.SetInt = function(x) { return this.$val.SetInt(x); }; + Value.Ptr.prototype.SetMapIndex = function(key, val) { + var v, tt, k, e; + v = new Value.Ptr(); $copy(v, this, Value); + (new flag(v.flag)).mustBe(21); + (new flag(v.flag)).mustBeExported(); + (new flag(key.flag)).mustBeExported(); + tt = v.typ.mapType; + $copy(key, key.assignTo("reflect.Value.SetMapIndex", tt.key, ($ptrType($emptyInterface)).nil), Value); + k = 0; + if (!((((key.flag & 2) >>> 0) === 0))) { + k = key.ptr; + } else if (key.typ.pointers()) { + k = new ($ptrType($UnsafePointer))(function() { return this.$target.ptr; }, function($v) { this.$target.ptr = $v; }, key); + } else { + k = new ($ptrType($Uintptr))(function() { return this.$target.scalar; }, function($v) { this.$target.scalar = $v; }, key); } - if (f.plus || (((0 < 0 || 0 >= num.$length) ? $throwRuntimeError("index out of range") : num.$array[num.$offset + 0]) === 45) || math.IsInf(v, 0)) { - f.pad(num); + if (val.typ === ($ptrType(rtype)).nil) { + mapdelete(v.typ, v.pointer(), k); return; } - f.pad($subslice(num, 1)); - /* */ } catch(err) { $err = err; } finally { $deferFrames.pop(); $callDeferred($deferred, $err); } - }; - fmt.prototype.formatFloat = function(v, verb, prec, n) { return this.$val.formatFloat(v, verb, prec, n); }; - fmt.Ptr.prototype.fmt_e64 = function(v) { - var f; - f = this; - f.formatFloat(v, 101, doPrec(f, 6), 64); - }; - fmt.prototype.fmt_e64 = function(v) { return this.$val.fmt_e64(v); }; - fmt.Ptr.prototype.fmt_E64 = function(v) { - var f; - f = this; - f.formatFloat(v, 69, doPrec(f, 6), 64); - }; - fmt.prototype.fmt_E64 = function(v) { return this.$val.fmt_E64(v); }; - fmt.Ptr.prototype.fmt_f64 = function(v) { - var f; - f = this; - f.formatFloat(v, 102, doPrec(f, 6), 64); + (new flag(val.flag)).mustBeExported(); + $copy(val, val.assignTo("reflect.Value.SetMapIndex", tt.elem, ($ptrType($emptyInterface)).nil), Value); + e = 0; + if (!((((val.flag & 2) >>> 0) === 0))) { + e = val.ptr; + } else if (val.typ.pointers()) { + e = new ($ptrType($UnsafePointer))(function() { return this.$target.ptr; }, function($v) { this.$target.ptr = $v; }, val); + } else { + e = new ($ptrType($Uintptr))(function() { return this.$target.scalar; }, function($v) { this.$target.scalar = $v; }, val); + } + mapassign(v.typ, v.pointer(), k, e); }; - fmt.prototype.fmt_f64 = function(v) { return this.$val.fmt_f64(v); }; - fmt.Ptr.prototype.fmt_g64 = function(v) { - var f; - f = this; - f.formatFloat(v, 103, doPrec(f, -1), 64); + Value.prototype.SetMapIndex = function(key, val) { return this.$val.SetMapIndex(key, val); }; + Value.Ptr.prototype.SetUint = function(x) { + var v, k, _ref; + v = new Value.Ptr(); $copy(v, this, Value); + (new flag(v.flag)).mustBeAssignable(); + k = (new flag(v.flag)).kind(); + _ref = k; + if (_ref === 7) { + v.ptr.$set((x.$low >>> 0)); + } else if (_ref === 8) { + v.ptr.$set((x.$low << 24 >>> 24)); + } else if (_ref === 9) { + v.ptr.$set((x.$low << 16 >>> 16)); + } else if (_ref === 10) { + v.ptr.$set((x.$low >>> 0)); + } else if (_ref === 11) { + v.ptr.$set(x); + } else if (_ref === 12) { + v.ptr.$set((x.$low >>> 0)); + } else { + $panic(new ValueError.Ptr("reflect.Value.SetUint", k)); + } }; - fmt.prototype.fmt_g64 = function(v) { return this.$val.fmt_g64(v); }; - fmt.Ptr.prototype.fmt_G64 = function(v) { - var f; - f = this; - f.formatFloat(v, 71, doPrec(f, -1), 64); + Value.prototype.SetUint = function(x) { return this.$val.SetUint(x); }; + Value.Ptr.prototype.SetPointer = function(x) { + var v; + v = new Value.Ptr(); $copy(v, this, Value); + (new flag(v.flag)).mustBeAssignable(); + (new flag(v.flag)).mustBe(26); + v.ptr.$set(x); }; - fmt.prototype.fmt_G64 = function(v) { return this.$val.fmt_G64(v); }; - fmt.Ptr.prototype.fmt_fb64 = function(v) { - var f; - f = this; - f.formatFloat(v, 98, 0, 64); + Value.prototype.SetPointer = function(x) { return this.$val.SetPointer(x); }; + Value.Ptr.prototype.SetString = function(x) { + var v; + v = new Value.Ptr(); $copy(v, this, Value); + (new flag(v.flag)).mustBeAssignable(); + (new flag(v.flag)).mustBe(24); + v.ptr.$set(x); }; - fmt.prototype.fmt_fb64 = function(v) { return this.$val.fmt_fb64(v); }; - fmt.Ptr.prototype.fmt_e32 = function(v) { - var f; - f = this; - f.formatFloat($coerceFloat32(v), 101, doPrec(f, 6), 32); + Value.prototype.SetString = function(x) { return this.$val.SetString(x); }; + Value.Ptr.prototype.String = function() { + var v, k, _ref; + v = new Value.Ptr(); $copy(v, this, Value); + k = (new flag(v.flag)).kind(); + _ref = k; + if (_ref === 0) { + return ""; + } else if (_ref === 24) { + return v.ptr.$get(); + } + return "<" + v.typ.String() + " Value>"; }; - fmt.prototype.fmt_e32 = function(v) { return this.$val.fmt_e32(v); }; - fmt.Ptr.prototype.fmt_E32 = function(v) { - var f; - f = this; - f.formatFloat($coerceFloat32(v), 69, doPrec(f, 6), 32); + Value.prototype.String = function() { return this.$val.String(); }; + Value.Ptr.prototype.Type = function() { + var v, f, i, tt, x, m, ut, x$1, m$1; + v = new Value.Ptr(); $copy(v, this, Value); + f = v.flag; + if (f === 0) { + $panic(new ValueError.Ptr("reflect.Value.Type", 0)); + } + if (((f & 8) >>> 0) === 0) { + return v.typ; + } + i = (v.flag >> 0) >> 9 >> 0; + if (v.typ.Kind() === 20) { + tt = v.typ.interfaceType; + if (i < 0 || i >= tt.methods.$length) { + $panic(new $String("reflect: internal error: invalid method index")); + } + m = (x = tt.methods, ((i < 0 || i >= x.$length) ? $throwRuntimeError("index out of range") : x.$array[x.$offset + i])); + return m.typ; + } + ut = v.typ.uncommonType.uncommon(); + if (ut === ($ptrType(uncommonType)).nil || i < 0 || i >= ut.methods.$length) { + $panic(new $String("reflect: internal error: invalid method index")); + } + m$1 = (x$1 = ut.methods, ((i < 0 || i >= x$1.$length) ? $throwRuntimeError("index out of range") : x$1.$array[x$1.$offset + i])); + return m$1.mtyp; }; - fmt.prototype.fmt_E32 = function(v) { return this.$val.fmt_E32(v); }; - fmt.Ptr.prototype.fmt_f32 = function(v) { - var f; - f = this; - f.formatFloat($coerceFloat32(v), 102, doPrec(f, 6), 32); + Value.prototype.Type = function() { return this.$val.Type(); }; + Value.Ptr.prototype.Uint = function() { + var v, k, p, _ref, x; + v = new Value.Ptr(); $copy(v, this, Value); + k = (new flag(v.flag)).kind(); + p = 0; + if (!((((v.flag & 2) >>> 0) === 0))) { + p = v.ptr; + } else { + p = new ($ptrType($Uintptr))(function() { return this.$target.scalar; }, function($v) { this.$target.scalar = $v; }, v); + } + _ref = k; + if (_ref === 7) { + return new $Uint64(0, p.$get()); + } else if (_ref === 8) { + return new $Uint64(0, p.$get()); + } else if (_ref === 9) { + return new $Uint64(0, p.$get()); + } else if (_ref === 10) { + return new $Uint64(0, p.$get()); + } else if (_ref === 11) { + return p.$get(); + } else if (_ref === 12) { + return (x = p.$get(), new $Uint64(0, x.constructor === Number ? x : 1)); + } + $panic(new ValueError.Ptr("reflect.Value.Uint", k)); }; - fmt.prototype.fmt_f32 = function(v) { return this.$val.fmt_f32(v); }; - fmt.Ptr.prototype.fmt_g32 = function(v) { - var f; - f = this; - f.formatFloat($coerceFloat32(v), 103, doPrec(f, -1), 32); + Value.prototype.Uint = function() { return this.$val.Uint(); }; + Value.Ptr.prototype.UnsafeAddr = function() { + var v; + v = new Value.Ptr(); $copy(v, this, Value); + if (v.typ === ($ptrType(rtype)).nil) { + $panic(new ValueError.Ptr("reflect.Value.UnsafeAddr", 0)); + } + if (((v.flag & 4) >>> 0) === 0) { + $panic(new $String("reflect.Value.UnsafeAddr of unaddressable value")); + } + return v.ptr; }; - fmt.prototype.fmt_g32 = function(v) { return this.$val.fmt_g32(v); }; - fmt.Ptr.prototype.fmt_G32 = function(v) { - var f; - f = this; - f.formatFloat($coerceFloat32(v), 71, doPrec(f, -1), 32); + Value.prototype.UnsafeAddr = function() { return this.$val.UnsafeAddr(); }; + typesMustMatch = function(what, t1, t2) { + if (!($interfaceIsEqual(t1, t2))) { + $panic(new $String(what + ": " + t1.String() + " != " + t2.String())); + } }; - fmt.prototype.fmt_G32 = function(v) { return this.$val.fmt_G32(v); }; - fmt.Ptr.prototype.fmt_fb32 = function(v) { - var f; - f = this; - f.formatFloat($coerceFloat32(v), 98, 0, 32); + MakeMap = $pkg.MakeMap = function(typ) { + var m; + if (!((typ.Kind() === 21))) { + $panic(new $String("reflect.MakeMap of non-map type")); + } + m = makemap($assertType(typ, ($ptrType(rtype)))); + return new Value.Ptr(typ.common(), m, 0, 336); }; - fmt.prototype.fmt_fb32 = function(v) { return this.$val.fmt_fb32(v); }; - fmt.Ptr.prototype.fmt_c64 = function(v, verb) { - var f; - f = this; - f.fmt_complex($coerceFloat32(v.$real), $coerceFloat32(v.$imag), 32, verb); + Indirect = $pkg.Indirect = function(v) { + if (!((v.Kind() === 22))) { + return v; + } + return v.Elem(); }; - fmt.prototype.fmt_c64 = function(v, verb) { return this.$val.fmt_c64(v, verb); }; - fmt.Ptr.prototype.fmt_c128 = function(v, verb) { - var f; - f = this; - f.fmt_complex(v.$real, v.$imag, 64, verb); + New = $pkg.New = function(typ) { + var ptr, fl; + if ($interfaceIsEqual(typ, $ifaceNil)) { + $panic(new $String("reflect: New(nil)")); + } + ptr = unsafe_New($assertType(typ, ($ptrType(rtype)))); + fl = 352; + return new Value.Ptr(typ.common().ptrTo(), ptr, 0, fl); }; - fmt.prototype.fmt_c128 = function(v, verb) { return this.$val.fmt_c128(v, verb); }; - fmt.Ptr.prototype.fmt_complex = function(r, j, size, verb) { - var f, oldPlus, oldSpace, oldWid, i, _ref; - f = this; - f.buf.WriteByte(40); - oldPlus = f.plus; - oldSpace = f.space; - oldWid = f.wid; - i = 0; - while (true) { - _ref = verb; - if (_ref === 98) { - f.formatFloat(r, 98, 0, size); - } else if (_ref === 101) { - f.formatFloat(r, 101, doPrec(f, 6), size); - } else if (_ref === 69) { - f.formatFloat(r, 69, doPrec(f, 6), size); - } else if (_ref === 102 || _ref === 70) { - f.formatFloat(r, 102, doPrec(f, 6), size); - } else if (_ref === 103) { - f.formatFloat(r, 103, doPrec(f, -1), size); - } else if (_ref === 71) { - f.formatFloat(r, 71, doPrec(f, -1), size); + Value.Ptr.prototype.assignTo = function(context, dst, target) { + var v, fl, x; + v = new Value.Ptr(); $copy(v, this, Value); + if (!((((v.flag & 8) >>> 0) === 0))) { + $copy(v, makeMethodValue(context, $clone(v, Value)), Value); + } + if (directlyAssignable(dst, v.typ)) { + v.typ = dst; + fl = (v.flag & 7) >>> 0; + fl = (fl | (((dst.Kind() >>> 0) << 4 >>> 0))) >>> 0; + return new Value.Ptr(dst, v.ptr, v.scalar, fl); + } else if (implements$1(dst, v.typ)) { + if (target === ($ptrType($emptyInterface)).nil) { + target = $newDataPointer($ifaceNil, ($ptrType($emptyInterface))); } - if (!((i === 0))) { - break; + x = valueInterface($clone(v, Value), false); + if (dst.NumMethod() === 0) { + target.$set(x); + } else { + ifaceE2I(dst, x, target); } - f.plus = true; - f.space = false; - f.wid = oldWid; - r = j; - i = i + (1) >> 0; + return new Value.Ptr(dst, target, 0, 322); } - f.space = oldSpace; - f.plus = oldPlus; - f.wid = oldWid; - f.buf.Write(irparenBytes); - }; - fmt.prototype.fmt_complex = function(r, j, size, verb) { return this.$val.fmt_complex(r, j, size, verb); }; - $ptrType(buffer).prototype.Write = function(p) { - var n = 0, err = $ifaceNil, b, _tmp, _tmp$1; - b = this; - b.$set($appendSlice(b.$get(), p)); - _tmp = p.$length; _tmp$1 = $ifaceNil; n = _tmp; err = _tmp$1; - return [n, err]; - }; - $ptrType(buffer).prototype.WriteString = function(s) { - var n = 0, err = $ifaceNil, b, _tmp, _tmp$1; - b = this; - b.$set($appendSlice(b.$get(), new buffer($stringToBytes(s)))); - _tmp = s.length; _tmp$1 = $ifaceNil; n = _tmp; err = _tmp$1; - return [n, err]; + $panic(new $String(context + ": value of type " + v.typ.String() + " is not assignable to type " + dst.String())); }; - $ptrType(buffer).prototype.WriteByte = function(c) { - var b; - b = this; - b.$set($append(b.$get(), c)); - return $ifaceNil; + Value.prototype.assignTo = function(context, dst, target) { return this.$val.assignTo(context, dst, target); }; + Value.Ptr.prototype.Convert = function(t) { + var v, op; + v = new Value.Ptr(); $copy(v, this, Value); + if (!((((v.flag & 8) >>> 0) === 0))) { + $copy(v, makeMethodValue("Convert", $clone(v, Value)), Value); + } + op = convertOp(t.common(), v.typ); + if (op === $throwNilPointerError) { + $panic(new $String("reflect.Value.Convert: value of type " + v.typ.String() + " cannot be converted to type " + t.String())); + } + return op($clone(v, Value), t); }; - $ptrType(buffer).prototype.WriteRune = function(r) { - var bp, b, n, x, w; - bp = this; - if (r < 128) { - bp.$set($append(bp.$get(), (r << 24 >>> 24))); - return $ifaceNil; + Value.prototype.Convert = function(t) { return this.$val.Convert(t); }; + convertOp = function(dst, src) { + var _ref, _ref$1, _ref$2, _ref$3, _ref$4, _ref$5, _ref$6; + _ref = src.Kind(); + if (_ref === 2 || _ref === 3 || _ref === 4 || _ref === 5 || _ref === 6) { + _ref$1 = dst.Kind(); + if (_ref$1 === 2 || _ref$1 === 3 || _ref$1 === 4 || _ref$1 === 5 || _ref$1 === 6 || _ref$1 === 7 || _ref$1 === 8 || _ref$1 === 9 || _ref$1 === 10 || _ref$1 === 11 || _ref$1 === 12) { + return cvtInt; + } else if (_ref$1 === 13 || _ref$1 === 14) { + return cvtIntFloat; + } else if (_ref$1 === 24) { + return cvtIntString; + } + } else if (_ref === 7 || _ref === 8 || _ref === 9 || _ref === 10 || _ref === 11 || _ref === 12) { + _ref$2 = dst.Kind(); + if (_ref$2 === 2 || _ref$2 === 3 || _ref$2 === 4 || _ref$2 === 5 || _ref$2 === 6 || _ref$2 === 7 || _ref$2 === 8 || _ref$2 === 9 || _ref$2 === 10 || _ref$2 === 11 || _ref$2 === 12) { + return cvtUint; + } else if (_ref$2 === 13 || _ref$2 === 14) { + return cvtUintFloat; + } else if (_ref$2 === 24) { + return cvtUintString; + } + } else if (_ref === 13 || _ref === 14) { + _ref$3 = dst.Kind(); + if (_ref$3 === 2 || _ref$3 === 3 || _ref$3 === 4 || _ref$3 === 5 || _ref$3 === 6) { + return cvtFloatInt; + } else if (_ref$3 === 7 || _ref$3 === 8 || _ref$3 === 9 || _ref$3 === 10 || _ref$3 === 11 || _ref$3 === 12) { + return cvtFloatUint; + } else if (_ref$3 === 13 || _ref$3 === 14) { + return cvtFloat; + } + } else if (_ref === 15 || _ref === 16) { + _ref$4 = dst.Kind(); + if (_ref$4 === 15 || _ref$4 === 16) { + return cvtComplex; + } + } else if (_ref === 24) { + if ((dst.Kind() === 23) && dst.Elem().PkgPath() === "") { + _ref$5 = dst.Elem().Kind(); + if (_ref$5 === 8) { + return cvtStringBytes; + } else if (_ref$5 === 5) { + return cvtStringRunes; + } + } + } else if (_ref === 23) { + if ((dst.Kind() === 24) && src.Elem().PkgPath() === "") { + _ref$6 = src.Elem().Kind(); + if (_ref$6 === 8) { + return cvtBytesString; + } else if (_ref$6 === 5) { + return cvtRunesString; + } + } } - b = bp.$get(); - n = b.$length; - while ((n + 4 >> 0) > b.$capacity) { - b = $append(b, 0); + if (haveIdenticalUnderlyingType(dst, src)) { + return cvtDirect; } - w = utf8.EncodeRune((x = $subslice(b, n, (n + 4 >> 0)), $subslice(new ($sliceType($Uint8))(x.$array), x.$offset, x.$offset + x.$length)), r); - bp.$set($subslice(b, 0, (n + w >> 0))); - return $ifaceNil; + if ((dst.Kind() === 22) && dst.Name() === "" && (src.Kind() === 22) && src.Name() === "" && haveIdenticalUnderlyingType(dst.Elem().common(), src.Elem().common())) { + return cvtDirect; + } + if (implements$1(dst, src)) { + if (src.Kind() === 20) { + return cvtI2I; + } + return cvtT2I; + } + return $throwNilPointerError; }; - newPrinter = function() { - var p; - p = $assertType(ppFree.Get(), ($ptrType(pp))); - p.panicking = false; - p.erroring = false; - p.fmt.init(new ($ptrType(buffer))(function() { return this.$target.buf; }, function($v) { this.$target.buf = $v; }, p)); - return p; + makeFloat = function(f, v, t) { + var typ, ptr, s, _ref; + typ = t.common(); + if (typ.size > 4) { + ptr = unsafe_New(typ); + ptr.$set(v); + return new Value.Ptr(typ, ptr, 0, (((f | 2) >>> 0) | ((typ.Kind() >>> 0) << 4 >>> 0)) >>> 0); + } + s = 0; + _ref = typ.size; + if (_ref === 4) { + new ($ptrType($Uintptr))(function() { return s; }, function($v) { s = $v; }).$set(v); + } else if (_ref === 8) { + new ($ptrType($Uintptr))(function() { return s; }, function($v) { s = $v; }).$set(v); + } + return new Value.Ptr(typ, 0, s, (f | ((typ.Kind() >>> 0) << 4 >>> 0)) >>> 0); }; - pp.Ptr.prototype.free = function() { - var p; - p = this; - if (p.buf.$capacity > 1024) { - return; + makeComplex = function(f, v, t) { + var typ, ptr, _ref, s; + typ = t.common(); + if (typ.size > 4) { + ptr = unsafe_New(typ); + _ref = typ.size; + if (_ref === 8) { + ptr.$set(new $Complex64(v.$real, v.$imag)); + } else if (_ref === 16) { + ptr.$set(v); + } + return new Value.Ptr(typ, ptr, 0, (((f | 2) >>> 0) | ((typ.Kind() >>> 0) << 4 >>> 0)) >>> 0); } - p.buf = $subslice(p.buf, 0, 0); - p.arg = $ifaceNil; - $copy(p.value, new reflect.Value.Ptr(($ptrType(reflect.rtype)).nil, 0, 0, 0), reflect.Value); - ppFree.Put(p); + s = 0; + new ($ptrType($Uintptr))(function() { return s; }, function($v) { s = $v; }).$set(new $Complex64(v.$real, v.$imag)); + return new Value.Ptr(typ, 0, s, (f | ((typ.Kind() >>> 0) << 4 >>> 0)) >>> 0); }; - pp.prototype.free = function() { return this.$val.free(); }; - pp.Ptr.prototype.Width = function() { - var wid = 0, ok = false, p, _tmp, _tmp$1; - p = this; - _tmp = p.fmt.wid; _tmp$1 = p.fmt.widPresent; wid = _tmp; ok = _tmp$1; - return [wid, ok]; + makeString = function(f, v, t) { + var ret; + ret = new Value.Ptr(); $copy(ret, New(t).Elem(), Value); + ret.SetString(v); + ret.flag = ((ret.flag & ~4) | f) >>> 0; + return ret; }; - pp.prototype.Width = function() { return this.$val.Width(); }; - pp.Ptr.prototype.Precision = function() { - var prec = 0, ok = false, p, _tmp, _tmp$1; - p = this; - _tmp = p.fmt.prec; _tmp$1 = p.fmt.precPresent; prec = _tmp; ok = _tmp$1; - return [prec, ok]; + makeBytes = function(f, v, t) { + var ret; + ret = new Value.Ptr(); $copy(ret, New(t).Elem(), Value); + ret.SetBytes(v); + ret.flag = ((ret.flag & ~4) | f) >>> 0; + return ret; }; - pp.prototype.Precision = function() { return this.$val.Precision(); }; - pp.Ptr.prototype.Flag = function(b) { - var p, _ref; - p = this; - _ref = b; - if (_ref === 45) { - return p.fmt.minus; - } else if (_ref === 43) { - return p.fmt.plus; - } else if (_ref === 35) { - return p.fmt.sharp; - } else if (_ref === 32) { - return p.fmt.space; - } else if (_ref === 48) { - return p.fmt.zero; - } - return false; - }; - pp.prototype.Flag = function(b) { return this.$val.Flag(b); }; - pp.Ptr.prototype.add = function(c) { - var p; - p = this; - new ($ptrType(buffer))(function() { return this.$target.buf; }, function($v) { this.$target.buf = $v; }, p).WriteRune(c); + makeRunes = function(f, v, t) { + var ret; + ret = new Value.Ptr(); $copy(ret, New(t).Elem(), Value); + ret.setRunes(v); + ret.flag = ((ret.flag & ~4) | f) >>> 0; + return ret; }; - pp.prototype.add = function(c) { return this.$val.add(c); }; - pp.Ptr.prototype.Write = function(b) { - var ret = 0, err = $ifaceNil, p, _tuple; - p = this; - _tuple = new ($ptrType(buffer))(function() { return this.$target.buf; }, function($v) { this.$target.buf = $v; }, p).Write(b); ret = _tuple[0]; err = _tuple[1]; - return [ret, err]; + cvtInt = function(v, t) { + var x; + return makeInt((v.flag & 1) >>> 0, (x = v.Int(), new $Uint64(x.$high, x.$low)), t); }; - pp.prototype.Write = function(b) { return this.$val.Write(b); }; - Fprintf = $pkg.Fprintf = function(w, format, a) { - var n = 0, err = $ifaceNil, p, _tuple, x; - p = newPrinter(); - p.doPrintf(format, a); - _tuple = w.Write((x = p.buf, $subslice(new ($sliceType($Uint8))(x.$array), x.$offset, x.$offset + x.$length))); n = _tuple[0]; err = _tuple[1]; - p.free(); - return [n, err]; + cvtUint = function(v, t) { + return makeInt((v.flag & 1) >>> 0, v.Uint(), t); }; - Printf = $pkg.Printf = function(format, a) { - var n = 0, err = $ifaceNil, _tuple; - _tuple = Fprintf(os.Stdout, format, a); n = _tuple[0]; err = _tuple[1]; - return [n, err]; + cvtFloatInt = function(v, t) { + var x; + return makeInt((v.flag & 1) >>> 0, (x = new $Int64(0, v.Float()), new $Uint64(x.$high, x.$low)), t); }; - Sprintf = $pkg.Sprintf = function(format, a) { - var p, s; - p = newPrinter(); - p.doPrintf(format, a); - s = $bytesToString(p.buf); - p.free(); - return s; + cvtFloatUint = function(v, t) { + return makeInt((v.flag & 1) >>> 0, new $Uint64(0, v.Float()), t); }; - Errorf = $pkg.Errorf = function(format, a) { - return errors.New(Sprintf(format, a)); + cvtIntFloat = function(v, t) { + return makeFloat((v.flag & 1) >>> 0, $flatten64(v.Int()), t); }; - Fprint = $pkg.Fprint = function(w, a) { - var n = 0, err = $ifaceNil, p, _tuple, x; - p = newPrinter(); - p.doPrint(a, false, false); - _tuple = w.Write((x = p.buf, $subslice(new ($sliceType($Uint8))(x.$array), x.$offset, x.$offset + x.$length))); n = _tuple[0]; err = _tuple[1]; - p.free(); - return [n, err]; + cvtUintFloat = function(v, t) { + return makeFloat((v.flag & 1) >>> 0, $flatten64(v.Uint()), t); }; - Print = $pkg.Print = function(a) { - var n = 0, err = $ifaceNil, _tuple; - _tuple = Fprint(os.Stdout, a); n = _tuple[0]; err = _tuple[1]; - return [n, err]; + cvtFloat = function(v, t) { + return makeFloat((v.flag & 1) >>> 0, v.Float(), t); }; - Sprint = $pkg.Sprint = function(a) { - var p, s; - p = newPrinter(); - p.doPrint(a, false, false); - s = $bytesToString(p.buf); - p.free(); - return s; + cvtComplex = function(v, t) { + return makeComplex((v.flag & 1) >>> 0, v.Complex(), t); }; - Fprintln = $pkg.Fprintln = function(w, a) { - var n = 0, err = $ifaceNil, p, _tuple, x; - p = newPrinter(); - p.doPrint(a, true, true); - _tuple = w.Write((x = p.buf, $subslice(new ($sliceType($Uint8))(x.$array), x.$offset, x.$offset + x.$length))); n = _tuple[0]; err = _tuple[1]; - p.free(); - return [n, err]; + cvtIntString = function(v, t) { + return makeString((v.flag & 1) >>> 0, $encodeRune(v.Int().$low), t); }; - Println = $pkg.Println = function(a) { - var n = 0, err = $ifaceNil, _tuple; - _tuple = Fprintln(os.Stdout, a); n = _tuple[0]; err = _tuple[1]; - return [n, err]; + cvtUintString = function(v, t) { + return makeString((v.flag & 1) >>> 0, $encodeRune(v.Uint().$low), t); }; - Sprintln = $pkg.Sprintln = function(a) { - var p, s; - p = newPrinter(); - p.doPrint(a, true, true); - s = $bytesToString(p.buf); - p.free(); - return s; + cvtBytesString = function(v, t) { + return makeString((v.flag & 1) >>> 0, $bytesToString(v.Bytes()), t); }; - getField = function(v, i) { - var val; - val = new reflect.Value.Ptr(); $copy(val, v.Field(i), reflect.Value); - if ((val.Kind() === 20) && !val.IsNil()) { - $copy(val, val.Elem(), reflect.Value); - } - return val; + cvtStringBytes = function(v, t) { + return makeBytes((v.flag & 1) >>> 0, new ($sliceType($Uint8))($stringToBytes(v.String())), t); }; - parsenum = function(s, start, end) { - var num = 0, isnum = false, newi = 0, _tmp, _tmp$1, _tmp$2; - if (start >= end) { - _tmp = 0; _tmp$1 = false; _tmp$2 = end; num = _tmp; isnum = _tmp$1; newi = _tmp$2; - return [num, isnum, newi]; - } - newi = start; - while (newi < end && 48 <= s.charCodeAt(newi) && s.charCodeAt(newi) <= 57) { - num = ((((num >>> 16 << 16) * 10 >> 0) + (num << 16 >>> 16) * 10) >> 0) + ((s.charCodeAt(newi) - 48 << 24 >>> 24) >> 0) >> 0; - isnum = true; - newi = newi + (1) >> 0; - } - return [num, isnum, newi]; + cvtRunesString = function(v, t) { + return makeString((v.flag & 1) >>> 0, $runesToString(v.runes()), t); }; - pp.Ptr.prototype.unknownType = function(v) { - var p; - p = this; - if ($interfaceIsEqual(v, $ifaceNil)) { - new ($ptrType(buffer))(function() { return this.$target.buf; }, function($v) { this.$target.buf = $v; }, p).Write(nilAngleBytes); - return; - } - new ($ptrType(buffer))(function() { return this.$target.buf; }, function($v) { this.$target.buf = $v; }, p).WriteByte(63); - new ($ptrType(buffer))(function() { return this.$target.buf; }, function($v) { this.$target.buf = $v; }, p).WriteString(reflect.TypeOf(v).String()); - new ($ptrType(buffer))(function() { return this.$target.buf; }, function($v) { this.$target.buf = $v; }, p).WriteByte(63); + cvtStringRunes = function(v, t) { + return makeRunes((v.flag & 1) >>> 0, new ($sliceType($Int32))($stringToRunes(v.String())), t); }; - pp.prototype.unknownType = function(v) { return this.$val.unknownType(v); }; - pp.Ptr.prototype.badVerb = function(verb) { - var p; - p = this; - p.erroring = true; - p.add(37); - p.add(33); - p.add(verb); - p.add(40); - if (!($interfaceIsEqual(p.arg, $ifaceNil))) { - new ($ptrType(buffer))(function() { return this.$target.buf; }, function($v) { this.$target.buf = $v; }, p).WriteString(reflect.TypeOf(p.arg).String()); - p.add(61); - p.printArg(p.arg, 118, false, false, 0); - } else if (p.value.IsValid()) { - new ($ptrType(buffer))(function() { return this.$target.buf; }, function($v) { this.$target.buf = $v; }, p).WriteString(p.value.Type().String()); - p.add(61); - p.printValue($clone(p.value, reflect.Value), 118, false, false, 0); + cvtT2I = function(v, typ) { + var target, x; + target = $newDataPointer($ifaceNil, ($ptrType($emptyInterface))); + x = valueInterface($clone(v, Value), false); + if (typ.NumMethod() === 0) { + target.$set(x); } else { - new ($ptrType(buffer))(function() { return this.$target.buf; }, function($v) { this.$target.buf = $v; }, p).Write(nilAngleBytes); + ifaceE2I($assertType(typ, ($ptrType(rtype))), x, target); } - p.add(41); - p.erroring = false; + return new Value.Ptr(typ.common(), target, 0, (((((v.flag & 1) >>> 0) | 2) >>> 0) | 320) >>> 0); }; - pp.prototype.badVerb = function(verb) { return this.$val.badVerb(verb); }; - pp.Ptr.prototype.fmtBool = function(v, verb) { - var p, _ref; - p = this; - _ref = verb; - if (_ref === 116 || _ref === 118) { - p.fmt.fmt_boolean(v); - } else { - p.badVerb(verb); + cvtI2I = function(v, typ) { + var ret; + if (v.IsNil()) { + ret = new Value.Ptr(); $copy(ret, Zero(typ), Value); + ret.flag = (ret.flag | (((v.flag & 1) >>> 0))) >>> 0; + return ret; } + return cvtT2I($clone(v.Elem(), Value), typ); }; - pp.prototype.fmtBool = function(v, verb) { return this.$val.fmtBool(v, verb); }; - pp.Ptr.prototype.fmtC = function(c) { - var p, r, x, w; - p = this; - r = ((c.$low + ((c.$high >> 31) * 4294967296)) >> 0); - if (!((x = new $Int64(0, r), (x.$high === c.$high && x.$low === c.$low)))) { - r = 65533; - } - w = utf8.EncodeRune($subslice(new ($sliceType($Uint8))(p.runeBuf), 0, 4), r); - p.fmt.pad($subslice(new ($sliceType($Uint8))(p.runeBuf), 0, w)); + call = function() { + $panic("Native function not implemented: reflect.call"); }; - pp.prototype.fmtC = function(c) { return this.$val.fmtC(c); }; - pp.Ptr.prototype.fmtInt64 = function(v, verb) { - var p, _ref; - p = this; - _ref = verb; - if (_ref === 98) { - p.fmt.integer(v, new $Uint64(0, 2), true, "0123456789abcdef"); - } else if (_ref === 99) { - p.fmtC(v); - } else if (_ref === 100 || _ref === 118) { - p.fmt.integer(v, new $Uint64(0, 10), true, "0123456789abcdef"); - } else if (_ref === 111) { - p.fmt.integer(v, new $Uint64(0, 8), true, "0123456789abcdef"); - } else if (_ref === 113) { - if ((0 < v.$high || (0 === v.$high && 0 <= v.$low)) && (v.$high < 0 || (v.$high === 0 && v.$low <= 1114111))) { - p.fmt.fmt_qc(v); - } else { - p.badVerb(verb); - } - } else if (_ref === 120) { - p.fmt.integer(v, new $Uint64(0, 16), true, "0123456789abcdef"); - } else if (_ref === 85) { - p.fmtUnicode(v); - } else if (_ref === 88) { - p.fmt.integer(v, new $Uint64(0, 16), true, "0123456789ABCDEF"); - } else { - p.badVerb(verb); + $pkg.$init = function() { + mapIter.init([["t", "t", "reflect", Type, ""], ["m", "m", "reflect", js.Object, ""], ["keys", "keys", "reflect", js.Object, ""], ["i", "i", "reflect", $Int, ""]]); + Type.init([["Align", "Align", "", $funcType([], [$Int], false)], ["AssignableTo", "AssignableTo", "", $funcType([Type], [$Bool], false)], ["Bits", "Bits", "", $funcType([], [$Int], false)], ["ChanDir", "ChanDir", "", $funcType([], [ChanDir], false)], ["ConvertibleTo", "ConvertibleTo", "", $funcType([Type], [$Bool], false)], ["Elem", "Elem", "", $funcType([], [Type], false)], ["Field", "Field", "", $funcType([$Int], [StructField], false)], ["FieldAlign", "FieldAlign", "", $funcType([], [$Int], false)], ["FieldByIndex", "FieldByIndex", "", $funcType([($sliceType($Int))], [StructField], false)], ["FieldByName", "FieldByName", "", $funcType([$String], [StructField, $Bool], false)], ["FieldByNameFunc", "FieldByNameFunc", "", $funcType([($funcType([$String], [$Bool], false))], [StructField, $Bool], false)], ["Implements", "Implements", "", $funcType([Type], [$Bool], false)], ["In", "In", "", $funcType([$Int], [Type], false)], ["IsVariadic", "IsVariadic", "", $funcType([], [$Bool], false)], ["Key", "Key", "", $funcType([], [Type], false)], ["Kind", "Kind", "", $funcType([], [Kind], false)], ["Len", "Len", "", $funcType([], [$Int], false)], ["Method", "Method", "", $funcType([$Int], [Method], false)], ["MethodByName", "MethodByName", "", $funcType([$String], [Method, $Bool], false)], ["Name", "Name", "", $funcType([], [$String], false)], ["NumField", "NumField", "", $funcType([], [$Int], false)], ["NumIn", "NumIn", "", $funcType([], [$Int], false)], ["NumMethod", "NumMethod", "", $funcType([], [$Int], false)], ["NumOut", "NumOut", "", $funcType([], [$Int], false)], ["Out", "Out", "", $funcType([$Int], [Type], false)], ["PkgPath", "PkgPath", "", $funcType([], [$String], false)], ["Size", "Size", "", $funcType([], [$Uintptr], false)], ["String", "String", "", $funcType([], [$String], false)], ["common", "common", "reflect", $funcType([], [($ptrType(rtype))], false)], ["uncommon", "uncommon", "reflect", $funcType([], [($ptrType(uncommonType))], false)]]); + Kind.methods = [["String", "String", "", $funcType([], [$String], false), -1]]; + ($ptrType(Kind)).methods = [["String", "String", "", $funcType([], [$String], false), -1]]; + rtype.methods = [["uncommon", "uncommon", "reflect", $funcType([], [($ptrType(uncommonType))], false), 9]]; + ($ptrType(rtype)).methods = [["Align", "Align", "", $funcType([], [$Int], false), -1], ["AssignableTo", "AssignableTo", "", $funcType([Type], [$Bool], false), -1], ["Bits", "Bits", "", $funcType([], [$Int], false), -1], ["ChanDir", "ChanDir", "", $funcType([], [ChanDir], false), -1], ["ConvertibleTo", "ConvertibleTo", "", $funcType([Type], [$Bool], false), -1], ["Elem", "Elem", "", $funcType([], [Type], false), -1], ["Field", "Field", "", $funcType([$Int], [StructField], false), -1], ["FieldAlign", "FieldAlign", "", $funcType([], [$Int], false), -1], ["FieldByIndex", "FieldByIndex", "", $funcType([($sliceType($Int))], [StructField], false), -1], ["FieldByName", "FieldByName", "", $funcType([$String], [StructField, $Bool], false), -1], ["FieldByNameFunc", "FieldByNameFunc", "", $funcType([($funcType([$String], [$Bool], false))], [StructField, $Bool], false), -1], ["Implements", "Implements", "", $funcType([Type], [$Bool], false), -1], ["In", "In", "", $funcType([$Int], [Type], false), -1], ["IsVariadic", "IsVariadic", "", $funcType([], [$Bool], false), -1], ["Key", "Key", "", $funcType([], [Type], false), -1], ["Kind", "Kind", "", $funcType([], [Kind], false), -1], ["Len", "Len", "", $funcType([], [$Int], false), -1], ["Method", "Method", "", $funcType([$Int], [Method], false), -1], ["MethodByName", "MethodByName", "", $funcType([$String], [Method, $Bool], false), -1], ["Name", "Name", "", $funcType([], [$String], false), -1], ["NumField", "NumField", "", $funcType([], [$Int], false), -1], ["NumIn", "NumIn", "", $funcType([], [$Int], false), -1], ["NumMethod", "NumMethod", "", $funcType([], [$Int], false), -1], ["NumOut", "NumOut", "", $funcType([], [$Int], false), -1], ["Out", "Out", "", $funcType([$Int], [Type], false), -1], ["PkgPath", "PkgPath", "", $funcType([], [$String], false), -1], ["Size", "Size", "", $funcType([], [$Uintptr], false), -1], ["String", "String", "", $funcType([], [$String], false), -1], ["common", "common", "reflect", $funcType([], [($ptrType(rtype))], false), -1], ["pointers", "pointers", "reflect", $funcType([], [$Bool], false), -1], ["ptrTo", "ptrTo", "reflect", $funcType([], [($ptrType(rtype))], false), -1], ["uncommon", "uncommon", "reflect", $funcType([], [($ptrType(uncommonType))], false), 9]]; + rtype.init([["size", "size", "reflect", $Uintptr, ""], ["hash", "hash", "reflect", $Uint32, ""], ["_$2", "_", "reflect", $Uint8, ""], ["align", "align", "reflect", $Uint8, ""], ["fieldAlign", "fieldAlign", "reflect", $Uint8, ""], ["kind", "kind", "reflect", $Uint8, ""], ["alg", "alg", "reflect", ($ptrType($Uintptr)), ""], ["gc", "gc", "reflect", $UnsafePointer, ""], ["string", "string", "reflect", ($ptrType($String)), ""], ["uncommonType", "", "reflect", ($ptrType(uncommonType)), ""], ["ptrToThis", "ptrToThis", "reflect", ($ptrType(rtype)), ""], ["zero", "zero", "reflect", $UnsafePointer, ""]]); + method.init([["name", "name", "reflect", ($ptrType($String)), ""], ["pkgPath", "pkgPath", "reflect", ($ptrType($String)), ""], ["mtyp", "mtyp", "reflect", ($ptrType(rtype)), ""], ["typ", "typ", "reflect", ($ptrType(rtype)), ""], ["ifn", "ifn", "reflect", $UnsafePointer, ""], ["tfn", "tfn", "reflect", $UnsafePointer, ""]]); + ($ptrType(uncommonType)).methods = [["Method", "Method", "", $funcType([$Int], [Method], false), -1], ["MethodByName", "MethodByName", "", $funcType([$String], [Method, $Bool], false), -1], ["Name", "Name", "", $funcType([], [$String], false), -1], ["NumMethod", "NumMethod", "", $funcType([], [$Int], false), -1], ["PkgPath", "PkgPath", "", $funcType([], [$String], false), -1], ["uncommon", "uncommon", "reflect", $funcType([], [($ptrType(uncommonType))], false), -1]]; + uncommonType.init([["name", "name", "reflect", ($ptrType($String)), ""], ["pkgPath", "pkgPath", "reflect", ($ptrType($String)), ""], ["methods", "methods", "reflect", ($sliceType(method)), ""]]); + ChanDir.methods = [["String", "String", "", $funcType([], [$String], false), -1]]; + ($ptrType(ChanDir)).methods = [["String", "String", "", $funcType([], [$String], false), -1]]; + arrayType.methods = [["uncommon", "uncommon", "reflect", $funcType([], [($ptrType(uncommonType))], false), 0]]; + ($ptrType(arrayType)).methods = [["Align", "Align", "", $funcType([], [$Int], false), 0], ["AssignableTo", "AssignableTo", "", $funcType([Type], [$Bool], false), 0], ["Bits", "Bits", "", $funcType([], [$Int], false), 0], ["ChanDir", "ChanDir", "", $funcType([], [ChanDir], false), 0], ["ConvertibleTo", "ConvertibleTo", "", $funcType([Type], [$Bool], false), 0], ["Elem", "Elem", "", $funcType([], [Type], false), 0], ["Field", "Field", "", $funcType([$Int], [StructField], false), 0], ["FieldAlign", "FieldAlign", "", $funcType([], [$Int], false), 0], ["FieldByIndex", "FieldByIndex", "", $funcType([($sliceType($Int))], [StructField], false), 0], ["FieldByName", "FieldByName", "", $funcType([$String], [StructField, $Bool], false), 0], ["FieldByNameFunc", "FieldByNameFunc", "", $funcType([($funcType([$String], [$Bool], false))], [StructField, $Bool], false), 0], ["Implements", "Implements", "", $funcType([Type], [$Bool], false), 0], ["In", "In", "", $funcType([$Int], [Type], false), 0], ["IsVariadic", "IsVariadic", "", $funcType([], [$Bool], false), 0], ["Key", "Key", "", $funcType([], [Type], false), 0], ["Kind", "Kind", "", $funcType([], [Kind], false), 0], ["Len", "Len", "", $funcType([], [$Int], false), 0], ["Method", "Method", "", $funcType([$Int], [Method], false), 0], ["MethodByName", "MethodByName", "", $funcType([$String], [Method, $Bool], false), 0], ["Name", "Name", "", $funcType([], [$String], false), 0], ["NumField", "NumField", "", $funcType([], [$Int], false), 0], ["NumIn", "NumIn", "", $funcType([], [$Int], false), 0], ["NumMethod", "NumMethod", "", $funcType([], [$Int], false), 0], ["NumOut", "NumOut", "", $funcType([], [$Int], false), 0], ["Out", "Out", "", $funcType([$Int], [Type], false), 0], ["PkgPath", "PkgPath", "", $funcType([], [$String], false), 0], ["Size", "Size", "", $funcType([], [$Uintptr], false), 0], ["String", "String", "", $funcType([], [$String], false), 0], ["common", "common", "reflect", $funcType([], [($ptrType(rtype))], false), 0], ["pointers", "pointers", "reflect", $funcType([], [$Bool], false), 0], ["ptrTo", "ptrTo", "reflect", $funcType([], [($ptrType(rtype))], false), 0], ["uncommon", "uncommon", "reflect", $funcType([], [($ptrType(uncommonType))], false), 0]]; + arrayType.init([["rtype", "", "reflect", rtype, "reflect:\"array\""], ["elem", "elem", "reflect", ($ptrType(rtype)), ""], ["slice", "slice", "reflect", ($ptrType(rtype)), ""], ["len", "len", "reflect", $Uintptr, ""]]); + chanType.methods = [["uncommon", "uncommon", "reflect", $funcType([], [($ptrType(uncommonType))], false), 0]]; + ($ptrType(chanType)).methods = [["Align", "Align", "", $funcType([], [$Int], false), 0], ["AssignableTo", "AssignableTo", "", $funcType([Type], [$Bool], false), 0], ["Bits", "Bits", "", $funcType([], [$Int], false), 0], ["ChanDir", "ChanDir", "", $funcType([], [ChanDir], false), 0], ["ConvertibleTo", "ConvertibleTo", "", $funcType([Type], [$Bool], false), 0], ["Elem", "Elem", "", $funcType([], [Type], false), 0], ["Field", "Field", "", $funcType([$Int], [StructField], false), 0], ["FieldAlign", "FieldAlign", "", $funcType([], [$Int], false), 0], ["FieldByIndex", "FieldByIndex", "", $funcType([($sliceType($Int))], [StructField], false), 0], ["FieldByName", "FieldByName", "", $funcType([$String], [StructField, $Bool], false), 0], ["FieldByNameFunc", "FieldByNameFunc", "", $funcType([($funcType([$String], [$Bool], false))], [StructField, $Bool], false), 0], ["Implements", "Implements", "", $funcType([Type], [$Bool], false), 0], ["In", "In", "", $funcType([$Int], [Type], false), 0], ["IsVariadic", "IsVariadic", "", $funcType([], [$Bool], false), 0], ["Key", "Key", "", $funcType([], [Type], false), 0], ["Kind", "Kind", "", $funcType([], [Kind], false), 0], ["Len", "Len", "", $funcType([], [$Int], false), 0], ["Method", "Method", "", $funcType([$Int], [Method], false), 0], ["MethodByName", "MethodByName", "", $funcType([$String], [Method, $Bool], false), 0], ["Name", "Name", "", $funcType([], [$String], false), 0], ["NumField", "NumField", "", $funcType([], [$Int], false), 0], ["NumIn", "NumIn", "", $funcType([], [$Int], false), 0], ["NumMethod", "NumMethod", "", $funcType([], [$Int], false), 0], ["NumOut", "NumOut", "", $funcType([], [$Int], false), 0], ["Out", "Out", "", $funcType([$Int], [Type], false), 0], ["PkgPath", "PkgPath", "", $funcType([], [$String], false), 0], ["Size", "Size", "", $funcType([], [$Uintptr], false), 0], ["String", "String", "", $funcType([], [$String], false), 0], ["common", "common", "reflect", $funcType([], [($ptrType(rtype))], false), 0], ["pointers", "pointers", "reflect", $funcType([], [$Bool], false), 0], ["ptrTo", "ptrTo", "reflect", $funcType([], [($ptrType(rtype))], false), 0], ["uncommon", "uncommon", "reflect", $funcType([], [($ptrType(uncommonType))], false), 0]]; + chanType.init([["rtype", "", "reflect", rtype, "reflect:\"chan\""], ["elem", "elem", "reflect", ($ptrType(rtype)), ""], ["dir", "dir", "reflect", $Uintptr, ""]]); + funcType.methods = [["uncommon", "uncommon", "reflect", $funcType([], [($ptrType(uncommonType))], false), 0]]; + ($ptrType(funcType)).methods = [["Align", "Align", "", $funcType([], [$Int], false), 0], ["AssignableTo", "AssignableTo", "", $funcType([Type], [$Bool], false), 0], ["Bits", "Bits", "", $funcType([], [$Int], false), 0], ["ChanDir", "ChanDir", "", $funcType([], [ChanDir], false), 0], ["ConvertibleTo", "ConvertibleTo", "", $funcType([Type], [$Bool], false), 0], ["Elem", "Elem", "", $funcType([], [Type], false), 0], ["Field", "Field", "", $funcType([$Int], [StructField], false), 0], ["FieldAlign", "FieldAlign", "", $funcType([], [$Int], false), 0], ["FieldByIndex", "FieldByIndex", "", $funcType([($sliceType($Int))], [StructField], false), 0], ["FieldByName", "FieldByName", "", $funcType([$String], [StructField, $Bool], false), 0], ["FieldByNameFunc", "FieldByNameFunc", "", $funcType([($funcType([$String], [$Bool], false))], [StructField, $Bool], false), 0], ["Implements", "Implements", "", $funcType([Type], [$Bool], false), 0], ["In", "In", "", $funcType([$Int], [Type], false), 0], ["IsVariadic", "IsVariadic", "", $funcType([], [$Bool], false), 0], ["Key", "Key", "", $funcType([], [Type], false), 0], ["Kind", "Kind", "", $funcType([], [Kind], false), 0], ["Len", "Len", "", $funcType([], [$Int], false), 0], ["Method", "Method", "", $funcType([$Int], [Method], false), 0], ["MethodByName", "MethodByName", "", $funcType([$String], [Method, $Bool], false), 0], ["Name", "Name", "", $funcType([], [$String], false), 0], ["NumField", "NumField", "", $funcType([], [$Int], false), 0], ["NumIn", "NumIn", "", $funcType([], [$Int], false), 0], ["NumMethod", "NumMethod", "", $funcType([], [$Int], false), 0], ["NumOut", "NumOut", "", $funcType([], [$Int], false), 0], ["Out", "Out", "", $funcType([$Int], [Type], false), 0], ["PkgPath", "PkgPath", "", $funcType([], [$String], false), 0], ["Size", "Size", "", $funcType([], [$Uintptr], false), 0], ["String", "String", "", $funcType([], [$String], false), 0], ["common", "common", "reflect", $funcType([], [($ptrType(rtype))], false), 0], ["pointers", "pointers", "reflect", $funcType([], [$Bool], false), 0], ["ptrTo", "ptrTo", "reflect", $funcType([], [($ptrType(rtype))], false), 0], ["uncommon", "uncommon", "reflect", $funcType([], [($ptrType(uncommonType))], false), 0]]; + funcType.init([["rtype", "", "reflect", rtype, "reflect:\"func\""], ["dotdotdot", "dotdotdot", "reflect", $Bool, ""], ["in$2", "in", "reflect", ($sliceType(($ptrType(rtype)))), ""], ["out", "out", "reflect", ($sliceType(($ptrType(rtype)))), ""]]); + imethod.init([["name", "name", "reflect", ($ptrType($String)), ""], ["pkgPath", "pkgPath", "reflect", ($ptrType($String)), ""], ["typ", "typ", "reflect", ($ptrType(rtype)), ""]]); + interfaceType.methods = [["uncommon", "uncommon", "reflect", $funcType([], [($ptrType(uncommonType))], false), 0]]; + ($ptrType(interfaceType)).methods = [["Align", "Align", "", $funcType([], [$Int], false), 0], ["AssignableTo", "AssignableTo", "", $funcType([Type], [$Bool], false), 0], ["Bits", "Bits", "", $funcType([], [$Int], false), 0], ["ChanDir", "ChanDir", "", $funcType([], [ChanDir], false), 0], ["ConvertibleTo", "ConvertibleTo", "", $funcType([Type], [$Bool], false), 0], ["Elem", "Elem", "", $funcType([], [Type], false), 0], ["Field", "Field", "", $funcType([$Int], [StructField], false), 0], ["FieldAlign", "FieldAlign", "", $funcType([], [$Int], false), 0], ["FieldByIndex", "FieldByIndex", "", $funcType([($sliceType($Int))], [StructField], false), 0], ["FieldByName", "FieldByName", "", $funcType([$String], [StructField, $Bool], false), 0], ["FieldByNameFunc", "FieldByNameFunc", "", $funcType([($funcType([$String], [$Bool], false))], [StructField, $Bool], false), 0], ["Implements", "Implements", "", $funcType([Type], [$Bool], false), 0], ["In", "In", "", $funcType([$Int], [Type], false), 0], ["IsVariadic", "IsVariadic", "", $funcType([], [$Bool], false), 0], ["Key", "Key", "", $funcType([], [Type], false), 0], ["Kind", "Kind", "", $funcType([], [Kind], false), 0], ["Len", "Len", "", $funcType([], [$Int], false), 0], ["Method", "Method", "", $funcType([$Int], [Method], false), -1], ["MethodByName", "MethodByName", "", $funcType([$String], [Method, $Bool], false), -1], ["Name", "Name", "", $funcType([], [$String], false), 0], ["NumField", "NumField", "", $funcType([], [$Int], false), 0], ["NumIn", "NumIn", "", $funcType([], [$Int], false), 0], ["NumMethod", "NumMethod", "", $funcType([], [$Int], false), -1], ["NumOut", "NumOut", "", $funcType([], [$Int], false), 0], ["Out", "Out", "", $funcType([$Int], [Type], false), 0], ["PkgPath", "PkgPath", "", $funcType([], [$String], false), 0], ["Size", "Size", "", $funcType([], [$Uintptr], false), 0], ["String", "String", "", $funcType([], [$String], false), 0], ["common", "common", "reflect", $funcType([], [($ptrType(rtype))], false), 0], ["pointers", "pointers", "reflect", $funcType([], [$Bool], false), 0], ["ptrTo", "ptrTo", "reflect", $funcType([], [($ptrType(rtype))], false), 0], ["uncommon", "uncommon", "reflect", $funcType([], [($ptrType(uncommonType))], false), 0]]; + interfaceType.init([["rtype", "", "reflect", rtype, "reflect:\"interface\""], ["methods", "methods", "reflect", ($sliceType(imethod)), ""]]); + mapType.methods = [["uncommon", "uncommon", "reflect", $funcType([], [($ptrType(uncommonType))], false), 0]]; + ($ptrType(mapType)).methods = [["Align", "Align", "", $funcType([], [$Int], false), 0], ["AssignableTo", "AssignableTo", "", $funcType([Type], [$Bool], false), 0], ["Bits", "Bits", "", $funcType([], [$Int], false), 0], ["ChanDir", "ChanDir", "", $funcType([], [ChanDir], false), 0], ["ConvertibleTo", "ConvertibleTo", "", $funcType([Type], [$Bool], false), 0], ["Elem", "Elem", "", $funcType([], [Type], false), 0], ["Field", "Field", "", $funcType([$Int], [StructField], false), 0], ["FieldAlign", "FieldAlign", "", $funcType([], [$Int], false), 0], ["FieldByIndex", "FieldByIndex", "", $funcType([($sliceType($Int))], [StructField], false), 0], ["FieldByName", "FieldByName", "", $funcType([$String], [StructField, $Bool], false), 0], ["FieldByNameFunc", "FieldByNameFunc", "", $funcType([($funcType([$String], [$Bool], false))], [StructField, $Bool], false), 0], ["Implements", "Implements", "", $funcType([Type], [$Bool], false), 0], ["In", "In", "", $funcType([$Int], [Type], false), 0], ["IsVariadic", "IsVariadic", "", $funcType([], [$Bool], false), 0], ["Key", "Key", "", $funcType([], [Type], false), 0], ["Kind", "Kind", "", $funcType([], [Kind], false), 0], ["Len", "Len", "", $funcType([], [$Int], false), 0], ["Method", "Method", "", $funcType([$Int], [Method], false), 0], ["MethodByName", "MethodByName", "", $funcType([$String], [Method, $Bool], false), 0], ["Name", "Name", "", $funcType([], [$String], false), 0], ["NumField", "NumField", "", $funcType([], [$Int], false), 0], ["NumIn", "NumIn", "", $funcType([], [$Int], false), 0], ["NumMethod", "NumMethod", "", $funcType([], [$Int], false), 0], ["NumOut", "NumOut", "", $funcType([], [$Int], false), 0], ["Out", "Out", "", $funcType([$Int], [Type], false), 0], ["PkgPath", "PkgPath", "", $funcType([], [$String], false), 0], ["Size", "Size", "", $funcType([], [$Uintptr], false), 0], ["String", "String", "", $funcType([], [$String], false), 0], ["common", "common", "reflect", $funcType([], [($ptrType(rtype))], false), 0], ["pointers", "pointers", "reflect", $funcType([], [$Bool], false), 0], ["ptrTo", "ptrTo", "reflect", $funcType([], [($ptrType(rtype))], false), 0], ["uncommon", "uncommon", "reflect", $funcType([], [($ptrType(uncommonType))], false), 0]]; + mapType.init([["rtype", "", "reflect", rtype, "reflect:\"map\""], ["key", "key", "reflect", ($ptrType(rtype)), ""], ["elem", "elem", "reflect", ($ptrType(rtype)), ""], ["bucket", "bucket", "reflect", ($ptrType(rtype)), ""], ["hmap", "hmap", "reflect", ($ptrType(rtype)), ""]]); + ptrType.methods = [["uncommon", "uncommon", "reflect", $funcType([], [($ptrType(uncommonType))], false), 0]]; + ($ptrType(ptrType)).methods = [["Align", "Align", "", $funcType([], [$Int], false), 0], ["AssignableTo", "AssignableTo", "", $funcType([Type], [$Bool], false), 0], ["Bits", "Bits", "", $funcType([], [$Int], false), 0], ["ChanDir", "ChanDir", "", $funcType([], [ChanDir], false), 0], ["ConvertibleTo", "ConvertibleTo", "", $funcType([Type], [$Bool], false), 0], ["Elem", "Elem", "", $funcType([], [Type], false), 0], ["Field", "Field", "", $funcType([$Int], [StructField], false), 0], ["FieldAlign", "FieldAlign", "", $funcType([], [$Int], false), 0], ["FieldByIndex", "FieldByIndex", "", $funcType([($sliceType($Int))], [StructField], false), 0], ["FieldByName", "FieldByName", "", $funcType([$String], [StructField, $Bool], false), 0], ["FieldByNameFunc", "FieldByNameFunc", "", $funcType([($funcType([$String], [$Bool], false))], [StructField, $Bool], false), 0], ["Implements", "Implements", "", $funcType([Type], [$Bool], false), 0], ["In", "In", "", $funcType([$Int], [Type], false), 0], ["IsVariadic", "IsVariadic", "", $funcType([], [$Bool], false), 0], ["Key", "Key", "", $funcType([], [Type], false), 0], ["Kind", "Kind", "", $funcType([], [Kind], false), 0], ["Len", "Len", "", $funcType([], [$Int], false), 0], ["Method", "Method", "", $funcType([$Int], [Method], false), 0], ["MethodByName", "MethodByName", "", $funcType([$String], [Method, $Bool], false), 0], ["Name", "Name", "", $funcType([], [$String], false), 0], ["NumField", "NumField", "", $funcType([], [$Int], false), 0], ["NumIn", "NumIn", "", $funcType([], [$Int], false), 0], ["NumMethod", "NumMethod", "", $funcType([], [$Int], false), 0], ["NumOut", "NumOut", "", $funcType([], [$Int], false), 0], ["Out", "Out", "", $funcType([$Int], [Type], false), 0], ["PkgPath", "PkgPath", "", $funcType([], [$String], false), 0], ["Size", "Size", "", $funcType([], [$Uintptr], false), 0], ["String", "String", "", $funcType([], [$String], false), 0], ["common", "common", "reflect", $funcType([], [($ptrType(rtype))], false), 0], ["pointers", "pointers", "reflect", $funcType([], [$Bool], false), 0], ["ptrTo", "ptrTo", "reflect", $funcType([], [($ptrType(rtype))], false), 0], ["uncommon", "uncommon", "reflect", $funcType([], [($ptrType(uncommonType))], false), 0]]; + ptrType.init([["rtype", "", "reflect", rtype, "reflect:\"ptr\""], ["elem", "elem", "reflect", ($ptrType(rtype)), ""]]); + sliceType.methods = [["uncommon", "uncommon", "reflect", $funcType([], [($ptrType(uncommonType))], false), 0]]; + ($ptrType(sliceType)).methods = [["Align", "Align", "", $funcType([], [$Int], false), 0], ["AssignableTo", "AssignableTo", "", $funcType([Type], [$Bool], false), 0], ["Bits", "Bits", "", $funcType([], [$Int], false), 0], ["ChanDir", "ChanDir", "", $funcType([], [ChanDir], false), 0], ["ConvertibleTo", "ConvertibleTo", "", $funcType([Type], [$Bool], false), 0], ["Elem", "Elem", "", $funcType([], [Type], false), 0], ["Field", "Field", "", $funcType([$Int], [StructField], false), 0], ["FieldAlign", "FieldAlign", "", $funcType([], [$Int], false), 0], ["FieldByIndex", "FieldByIndex", "", $funcType([($sliceType($Int))], [StructField], false), 0], ["FieldByName", "FieldByName", "", $funcType([$String], [StructField, $Bool], false), 0], ["FieldByNameFunc", "FieldByNameFunc", "", $funcType([($funcType([$String], [$Bool], false))], [StructField, $Bool], false), 0], ["Implements", "Implements", "", $funcType([Type], [$Bool], false), 0], ["In", "In", "", $funcType([$Int], [Type], false), 0], ["IsVariadic", "IsVariadic", "", $funcType([], [$Bool], false), 0], ["Key", "Key", "", $funcType([], [Type], false), 0], ["Kind", "Kind", "", $funcType([], [Kind], false), 0], ["Len", "Len", "", $funcType([], [$Int], false), 0], ["Method", "Method", "", $funcType([$Int], [Method], false), 0], ["MethodByName", "MethodByName", "", $funcType([$String], [Method, $Bool], false), 0], ["Name", "Name", "", $funcType([], [$String], false), 0], ["NumField", "NumField", "", $funcType([], [$Int], false), 0], ["NumIn", "NumIn", "", $funcType([], [$Int], false), 0], ["NumMethod", "NumMethod", "", $funcType([], [$Int], false), 0], ["NumOut", "NumOut", "", $funcType([], [$Int], false), 0], ["Out", "Out", "", $funcType([$Int], [Type], false), 0], ["PkgPath", "PkgPath", "", $funcType([], [$String], false), 0], ["Size", "Size", "", $funcType([], [$Uintptr], false), 0], ["String", "String", "", $funcType([], [$String], false), 0], ["common", "common", "reflect", $funcType([], [($ptrType(rtype))], false), 0], ["pointers", "pointers", "reflect", $funcType([], [$Bool], false), 0], ["ptrTo", "ptrTo", "reflect", $funcType([], [($ptrType(rtype))], false), 0], ["uncommon", "uncommon", "reflect", $funcType([], [($ptrType(uncommonType))], false), 0]]; + sliceType.init([["rtype", "", "reflect", rtype, "reflect:\"slice\""], ["elem", "elem", "reflect", ($ptrType(rtype)), ""]]); + structField.init([["name", "name", "reflect", ($ptrType($String)), ""], ["pkgPath", "pkgPath", "reflect", ($ptrType($String)), ""], ["typ", "typ", "reflect", ($ptrType(rtype)), ""], ["tag", "tag", "reflect", ($ptrType($String)), ""], ["offset", "offset", "reflect", $Uintptr, ""]]); + structType.methods = [["uncommon", "uncommon", "reflect", $funcType([], [($ptrType(uncommonType))], false), 0]]; + ($ptrType(structType)).methods = [["Align", "Align", "", $funcType([], [$Int], false), 0], ["AssignableTo", "AssignableTo", "", $funcType([Type], [$Bool], false), 0], ["Bits", "Bits", "", $funcType([], [$Int], false), 0], ["ChanDir", "ChanDir", "", $funcType([], [ChanDir], false), 0], ["ConvertibleTo", "ConvertibleTo", "", $funcType([Type], [$Bool], false), 0], ["Elem", "Elem", "", $funcType([], [Type], false), 0], ["Field", "Field", "", $funcType([$Int], [StructField], false), -1], ["FieldAlign", "FieldAlign", "", $funcType([], [$Int], false), 0], ["FieldByIndex", "FieldByIndex", "", $funcType([($sliceType($Int))], [StructField], false), -1], ["FieldByName", "FieldByName", "", $funcType([$String], [StructField, $Bool], false), -1], ["FieldByNameFunc", "FieldByNameFunc", "", $funcType([($funcType([$String], [$Bool], false))], [StructField, $Bool], false), -1], ["Implements", "Implements", "", $funcType([Type], [$Bool], false), 0], ["In", "In", "", $funcType([$Int], [Type], false), 0], ["IsVariadic", "IsVariadic", "", $funcType([], [$Bool], false), 0], ["Key", "Key", "", $funcType([], [Type], false), 0], ["Kind", "Kind", "", $funcType([], [Kind], false), 0], ["Len", "Len", "", $funcType([], [$Int], false), 0], ["Method", "Method", "", $funcType([$Int], [Method], false), 0], ["MethodByName", "MethodByName", "", $funcType([$String], [Method, $Bool], false), 0], ["Name", "Name", "", $funcType([], [$String], false), 0], ["NumField", "NumField", "", $funcType([], [$Int], false), 0], ["NumIn", "NumIn", "", $funcType([], [$Int], false), 0], ["NumMethod", "NumMethod", "", $funcType([], [$Int], false), 0], ["NumOut", "NumOut", "", $funcType([], [$Int], false), 0], ["Out", "Out", "", $funcType([$Int], [Type], false), 0], ["PkgPath", "PkgPath", "", $funcType([], [$String], false), 0], ["Size", "Size", "", $funcType([], [$Uintptr], false), 0], ["String", "String", "", $funcType([], [$String], false), 0], ["common", "common", "reflect", $funcType([], [($ptrType(rtype))], false), 0], ["pointers", "pointers", "reflect", $funcType([], [$Bool], false), 0], ["ptrTo", "ptrTo", "reflect", $funcType([], [($ptrType(rtype))], false), 0], ["uncommon", "uncommon", "reflect", $funcType([], [($ptrType(uncommonType))], false), 0]]; + structType.init([["rtype", "", "reflect", rtype, "reflect:\"struct\""], ["fields", "fields", "reflect", ($sliceType(structField)), ""]]); + Method.init([["Name", "Name", "", $String, ""], ["PkgPath", "PkgPath", "", $String, ""], ["Type", "Type", "", Type, ""], ["Func", "Func", "", Value, ""], ["Index", "Index", "", $Int, ""]]); + StructField.init([["Name", "Name", "", $String, ""], ["PkgPath", "PkgPath", "", $String, ""], ["Type", "Type", "", Type, ""], ["Tag", "Tag", "", StructTag, ""], ["Offset", "Offset", "", $Uintptr, ""], ["Index", "Index", "", ($sliceType($Int)), ""], ["Anonymous", "Anonymous", "", $Bool, ""]]); + StructTag.methods = [["Get", "Get", "", $funcType([$String], [$String], false), -1]]; + ($ptrType(StructTag)).methods = [["Get", "Get", "", $funcType([$String], [$String], false), -1]]; + fieldScan.init([["typ", "typ", "reflect", ($ptrType(structType)), ""], ["index", "index", "reflect", ($sliceType($Int)), ""]]); + Value.methods = [["Addr", "Addr", "", $funcType([], [Value], false), -1], ["Bool", "Bool", "", $funcType([], [$Bool], false), -1], ["Bytes", "Bytes", "", $funcType([], [($sliceType($Uint8))], false), -1], ["Call", "Call", "", $funcType([($sliceType(Value))], [($sliceType(Value))], false), -1], ["CallSlice", "CallSlice", "", $funcType([($sliceType(Value))], [($sliceType(Value))], false), -1], ["CanAddr", "CanAddr", "", $funcType([], [$Bool], false), -1], ["CanInterface", "CanInterface", "", $funcType([], [$Bool], false), -1], ["CanSet", "CanSet", "", $funcType([], [$Bool], false), -1], ["Cap", "Cap", "", $funcType([], [$Int], false), -1], ["Close", "Close", "", $funcType([], [], false), -1], ["Complex", "Complex", "", $funcType([], [$Complex128], false), -1], ["Convert", "Convert", "", $funcType([Type], [Value], false), -1], ["Elem", "Elem", "", $funcType([], [Value], false), -1], ["Field", "Field", "", $funcType([$Int], [Value], false), -1], ["FieldByIndex", "FieldByIndex", "", $funcType([($sliceType($Int))], [Value], false), -1], ["FieldByName", "FieldByName", "", $funcType([$String], [Value], false), -1], ["FieldByNameFunc", "FieldByNameFunc", "", $funcType([($funcType([$String], [$Bool], false))], [Value], false), -1], ["Float", "Float", "", $funcType([], [$Float64], false), -1], ["Index", "Index", "", $funcType([$Int], [Value], false), -1], ["Int", "Int", "", $funcType([], [$Int64], false), -1], ["Interface", "Interface", "", $funcType([], [$emptyInterface], false), -1], ["InterfaceData", "InterfaceData", "", $funcType([], [($arrayType($Uintptr, 2))], false), -1], ["IsNil", "IsNil", "", $funcType([], [$Bool], false), -1], ["IsValid", "IsValid", "", $funcType([], [$Bool], false), -1], ["Kind", "Kind", "", $funcType([], [Kind], false), -1], ["Len", "Len", "", $funcType([], [$Int], false), -1], ["MapIndex", "MapIndex", "", $funcType([Value], [Value], false), -1], ["MapKeys", "MapKeys", "", $funcType([], [($sliceType(Value))], false), -1], ["Method", "Method", "", $funcType([$Int], [Value], false), -1], ["MethodByName", "MethodByName", "", $funcType([$String], [Value], false), -1], ["NumField", "NumField", "", $funcType([], [$Int], false), -1], ["NumMethod", "NumMethod", "", $funcType([], [$Int], false), -1], ["OverflowComplex", "OverflowComplex", "", $funcType([$Complex128], [$Bool], false), -1], ["OverflowFloat", "OverflowFloat", "", $funcType([$Float64], [$Bool], false), -1], ["OverflowInt", "OverflowInt", "", $funcType([$Int64], [$Bool], false), -1], ["OverflowUint", "OverflowUint", "", $funcType([$Uint64], [$Bool], false), -1], ["Pointer", "Pointer", "", $funcType([], [$Uintptr], false), -1], ["Recv", "Recv", "", $funcType([], [Value, $Bool], false), -1], ["Send", "Send", "", $funcType([Value], [], false), -1], ["Set", "Set", "", $funcType([Value], [], false), -1], ["SetBool", "SetBool", "", $funcType([$Bool], [], false), -1], ["SetBytes", "SetBytes", "", $funcType([($sliceType($Uint8))], [], false), -1], ["SetCap", "SetCap", "", $funcType([$Int], [], false), -1], ["SetComplex", "SetComplex", "", $funcType([$Complex128], [], false), -1], ["SetFloat", "SetFloat", "", $funcType([$Float64], [], false), -1], ["SetInt", "SetInt", "", $funcType([$Int64], [], false), -1], ["SetLen", "SetLen", "", $funcType([$Int], [], false), -1], ["SetMapIndex", "SetMapIndex", "", $funcType([Value, Value], [], false), -1], ["SetPointer", "SetPointer", "", $funcType([$UnsafePointer], [], false), -1], ["SetString", "SetString", "", $funcType([$String], [], false), -1], ["SetUint", "SetUint", "", $funcType([$Uint64], [], false), -1], ["Slice", "Slice", "", $funcType([$Int, $Int], [Value], false), -1], ["Slice3", "Slice3", "", $funcType([$Int, $Int, $Int], [Value], false), -1], ["String", "String", "", $funcType([], [$String], false), -1], ["TryRecv", "TryRecv", "", $funcType([], [Value, $Bool], false), -1], ["TrySend", "TrySend", "", $funcType([Value], [$Bool], false), -1], ["Type", "Type", "", $funcType([], [Type], false), -1], ["Uint", "Uint", "", $funcType([], [$Uint64], false), -1], ["UnsafeAddr", "UnsafeAddr", "", $funcType([], [$Uintptr], false), -1], ["assignTo", "assignTo", "reflect", $funcType([$String, ($ptrType(rtype)), ($ptrType($emptyInterface))], [Value], false), -1], ["call", "call", "reflect", $funcType([$String, ($sliceType(Value))], [($sliceType(Value))], false), -1], ["iword", "iword", "reflect", $funcType([], [iword], false), -1], ["kind", "kind", "reflect", $funcType([], [Kind], false), 3], ["mustBe", "mustBe", "reflect", $funcType([Kind], [], false), 3], ["mustBeAssignable", "mustBeAssignable", "reflect", $funcType([], [], false), 3], ["mustBeExported", "mustBeExported", "reflect", $funcType([], [], false), 3], ["pointer", "pointer", "reflect", $funcType([], [$UnsafePointer], false), -1], ["recv", "recv", "reflect", $funcType([$Bool], [Value, $Bool], false), -1], ["runes", "runes", "reflect", $funcType([], [($sliceType($Int32))], false), -1], ["send", "send", "reflect", $funcType([Value, $Bool], [$Bool], false), -1], ["setRunes", "setRunes", "reflect", $funcType([($sliceType($Int32))], [], false), -1]]; + ($ptrType(Value)).methods = [["Addr", "Addr", "", $funcType([], [Value], false), -1], ["Bool", "Bool", "", $funcType([], [$Bool], false), -1], ["Bytes", "Bytes", "", $funcType([], [($sliceType($Uint8))], false), -1], ["Call", "Call", "", $funcType([($sliceType(Value))], [($sliceType(Value))], false), -1], ["CallSlice", "CallSlice", "", $funcType([($sliceType(Value))], [($sliceType(Value))], false), -1], ["CanAddr", "CanAddr", "", $funcType([], [$Bool], false), -1], ["CanInterface", "CanInterface", "", $funcType([], [$Bool], false), -1], ["CanSet", "CanSet", "", $funcType([], [$Bool], false), -1], ["Cap", "Cap", "", $funcType([], [$Int], false), -1], ["Close", "Close", "", $funcType([], [], false), -1], ["Complex", "Complex", "", $funcType([], [$Complex128], false), -1], ["Convert", "Convert", "", $funcType([Type], [Value], false), -1], ["Elem", "Elem", "", $funcType([], [Value], false), -1], ["Field", "Field", "", $funcType([$Int], [Value], false), -1], ["FieldByIndex", "FieldByIndex", "", $funcType([($sliceType($Int))], [Value], false), -1], ["FieldByName", "FieldByName", "", $funcType([$String], [Value], false), -1], ["FieldByNameFunc", "FieldByNameFunc", "", $funcType([($funcType([$String], [$Bool], false))], [Value], false), -1], ["Float", "Float", "", $funcType([], [$Float64], false), -1], ["Index", "Index", "", $funcType([$Int], [Value], false), -1], ["Int", "Int", "", $funcType([], [$Int64], false), -1], ["Interface", "Interface", "", $funcType([], [$emptyInterface], false), -1], ["InterfaceData", "InterfaceData", "", $funcType([], [($arrayType($Uintptr, 2))], false), -1], ["IsNil", "IsNil", "", $funcType([], [$Bool], false), -1], ["IsValid", "IsValid", "", $funcType([], [$Bool], false), -1], ["Kind", "Kind", "", $funcType([], [Kind], false), -1], ["Len", "Len", "", $funcType([], [$Int], false), -1], ["MapIndex", "MapIndex", "", $funcType([Value], [Value], false), -1], ["MapKeys", "MapKeys", "", $funcType([], [($sliceType(Value))], false), -1], ["Method", "Method", "", $funcType([$Int], [Value], false), -1], ["MethodByName", "MethodByName", "", $funcType([$String], [Value], false), -1], ["NumField", "NumField", "", $funcType([], [$Int], false), -1], ["NumMethod", "NumMethod", "", $funcType([], [$Int], false), -1], ["OverflowComplex", "OverflowComplex", "", $funcType([$Complex128], [$Bool], false), -1], ["OverflowFloat", "OverflowFloat", "", $funcType([$Float64], [$Bool], false), -1], ["OverflowInt", "OverflowInt", "", $funcType([$Int64], [$Bool], false), -1], ["OverflowUint", "OverflowUint", "", $funcType([$Uint64], [$Bool], false), -1], ["Pointer", "Pointer", "", $funcType([], [$Uintptr], false), -1], ["Recv", "Recv", "", $funcType([], [Value, $Bool], false), -1], ["Send", "Send", "", $funcType([Value], [], false), -1], ["Set", "Set", "", $funcType([Value], [], false), -1], ["SetBool", "SetBool", "", $funcType([$Bool], [], false), -1], ["SetBytes", "SetBytes", "", $funcType([($sliceType($Uint8))], [], false), -1], ["SetCap", "SetCap", "", $funcType([$Int], [], false), -1], ["SetComplex", "SetComplex", "", $funcType([$Complex128], [], false), -1], ["SetFloat", "SetFloat", "", $funcType([$Float64], [], false), -1], ["SetInt", "SetInt", "", $funcType([$Int64], [], false), -1], ["SetLen", "SetLen", "", $funcType([$Int], [], false), -1], ["SetMapIndex", "SetMapIndex", "", $funcType([Value, Value], [], false), -1], ["SetPointer", "SetPointer", "", $funcType([$UnsafePointer], [], false), -1], ["SetString", "SetString", "", $funcType([$String], [], false), -1], ["SetUint", "SetUint", "", $funcType([$Uint64], [], false), -1], ["Slice", "Slice", "", $funcType([$Int, $Int], [Value], false), -1], ["Slice3", "Slice3", "", $funcType([$Int, $Int, $Int], [Value], false), -1], ["String", "String", "", $funcType([], [$String], false), -1], ["TryRecv", "TryRecv", "", $funcType([], [Value, $Bool], false), -1], ["TrySend", "TrySend", "", $funcType([Value], [$Bool], false), -1], ["Type", "Type", "", $funcType([], [Type], false), -1], ["Uint", "Uint", "", $funcType([], [$Uint64], false), -1], ["UnsafeAddr", "UnsafeAddr", "", $funcType([], [$Uintptr], false), -1], ["assignTo", "assignTo", "reflect", $funcType([$String, ($ptrType(rtype)), ($ptrType($emptyInterface))], [Value], false), -1], ["call", "call", "reflect", $funcType([$String, ($sliceType(Value))], [($sliceType(Value))], false), -1], ["iword", "iword", "reflect", $funcType([], [iword], false), -1], ["kind", "kind", "reflect", $funcType([], [Kind], false), 3], ["mustBe", "mustBe", "reflect", $funcType([Kind], [], false), 3], ["mustBeAssignable", "mustBeAssignable", "reflect", $funcType([], [], false), 3], ["mustBeExported", "mustBeExported", "reflect", $funcType([], [], false), 3], ["pointer", "pointer", "reflect", $funcType([], [$UnsafePointer], false), -1], ["recv", "recv", "reflect", $funcType([$Bool], [Value, $Bool], false), -1], ["runes", "runes", "reflect", $funcType([], [($sliceType($Int32))], false), -1], ["send", "send", "reflect", $funcType([Value, $Bool], [$Bool], false), -1], ["setRunes", "setRunes", "reflect", $funcType([($sliceType($Int32))], [], false), -1]]; + Value.init([["typ", "typ", "reflect", ($ptrType(rtype)), ""], ["ptr", "ptr", "reflect", $UnsafePointer, ""], ["scalar", "scalar", "reflect", $Uintptr, ""], ["flag", "", "reflect", flag, ""]]); + flag.methods = [["kind", "kind", "reflect", $funcType([], [Kind], false), -1], ["mustBe", "mustBe", "reflect", $funcType([Kind], [], false), -1], ["mustBeAssignable", "mustBeAssignable", "reflect", $funcType([], [], false), -1], ["mustBeExported", "mustBeExported", "reflect", $funcType([], [], false), -1]]; + ($ptrType(flag)).methods = [["kind", "kind", "reflect", $funcType([], [Kind], false), -1], ["mustBe", "mustBe", "reflect", $funcType([Kind], [], false), -1], ["mustBeAssignable", "mustBeAssignable", "reflect", $funcType([], [], false), -1], ["mustBeExported", "mustBeExported", "reflect", $funcType([], [], false), -1]]; + ($ptrType(ValueError)).methods = [["Error", "Error", "", $funcType([], [$String], false), -1]]; + ValueError.init([["Method", "Method", "", $String, ""], ["Kind", "Kind", "", Kind, ""]]); + nonEmptyInterface.init([["itab", "itab", "reflect", ($ptrType(($structType([["ityp", "ityp", "reflect", ($ptrType(rtype)), ""], ["typ", "typ", "reflect", ($ptrType(rtype)), ""], ["link", "link", "reflect", $UnsafePointer, ""], ["bad", "bad", "reflect", $Int32, ""], ["unused", "unused", "reflect", $Int32, ""], ["fun", "fun", "reflect", ($arrayType($UnsafePointer, 100000)), ""]])))), ""], ["word", "word", "reflect", iword, ""]]); + initialized = false; + kindNames = new ($sliceType($String))(["invalid", "bool", "int", "int8", "int16", "int32", "int64", "uint", "uint8", "uint16", "uint32", "uint64", "uintptr", "float32", "float64", "complex64", "complex128", "array", "chan", "func", "interface", "map", "ptr", "slice", "string", "struct", "unsafe.Pointer"]); + uint8Type = $assertType(TypeOf(new $Uint8(0)), ($ptrType(rtype))); + init(); + }; + return $pkg; +})(); +$packages["fmt"] = (function() { + var $pkg = {}, math = $packages["math"], strconv = $packages["strconv"], utf8 = $packages["unicode/utf8"], errors = $packages["errors"], io = $packages["io"], os = $packages["os"], reflect = $packages["reflect"], sync = $packages["sync"], fmt, State, Formatter, Stringer, GoStringer, buffer, pp, runeUnreader, ScanState, scanError, ss, ssave, padZeroBytes, padSpaceBytes, trueBytes, falseBytes, commaSpaceBytes, nilAngleBytes, nilParenBytes, nilBytes, mapBytes, percentBangBytes, missingBytes, badIndexBytes, panicBytes, extraBytes, irparenBytes, bytesBytes, badWidthBytes, badPrecBytes, noVerbBytes, ppFree, intBits, uintptrBits, space, ssFree, complexError, boolError, init, doPrec, newPrinter, Fprintf, Printf, Sprintf, Errorf, Fprint, Print, Sprint, Fprintln, Println, Sprintln, getField, parsenum, intFromArg, parseArgNumber, isSpace, notSpace, indexRune; + fmt = $pkg.fmt = $newType(0, "Struct", "fmt.fmt", "fmt", "fmt", function(intbuf_, buf_, wid_, prec_, widPresent_, precPresent_, minus_, plus_, sharp_, space_, unicode_, uniQuote_, zero_) { + this.$val = this; + this.intbuf = intbuf_ !== undefined ? intbuf_ : ($arrayType($Uint8, 65)).zero(); + this.buf = buf_ !== undefined ? buf_ : ($ptrType(buffer)).nil; + this.wid = wid_ !== undefined ? wid_ : 0; + this.prec = prec_ !== undefined ? prec_ : 0; + this.widPresent = widPresent_ !== undefined ? widPresent_ : false; + this.precPresent = precPresent_ !== undefined ? precPresent_ : false; + this.minus = minus_ !== undefined ? minus_ : false; + this.plus = plus_ !== undefined ? plus_ : false; + this.sharp = sharp_ !== undefined ? sharp_ : false; + this.space = space_ !== undefined ? space_ : false; + this.unicode = unicode_ !== undefined ? unicode_ : false; + this.uniQuote = uniQuote_ !== undefined ? uniQuote_ : false; + this.zero = zero_ !== undefined ? zero_ : false; + }); + State = $pkg.State = $newType(8, "Interface", "fmt.State", "State", "fmt", null); + Formatter = $pkg.Formatter = $newType(8, "Interface", "fmt.Formatter", "Formatter", "fmt", null); + Stringer = $pkg.Stringer = $newType(8, "Interface", "fmt.Stringer", "Stringer", "fmt", null); + GoStringer = $pkg.GoStringer = $newType(8, "Interface", "fmt.GoStringer", "GoStringer", "fmt", null); + buffer = $pkg.buffer = $newType(12, "Slice", "fmt.buffer", "buffer", "fmt", null); + pp = $pkg.pp = $newType(0, "Struct", "fmt.pp", "pp", "fmt", function(n_, panicking_, erroring_, buf_, arg_, value_, reordered_, goodArgNum_, runeBuf_, fmt_) { + this.$val = this; + this.n = n_ !== undefined ? n_ : 0; + this.panicking = panicking_ !== undefined ? panicking_ : false; + this.erroring = erroring_ !== undefined ? erroring_ : false; + this.buf = buf_ !== undefined ? buf_ : buffer.nil; + this.arg = arg_ !== undefined ? arg_ : $ifaceNil; + this.value = value_ !== undefined ? value_ : new reflect.Value.Ptr(); + this.reordered = reordered_ !== undefined ? reordered_ : false; + this.goodArgNum = goodArgNum_ !== undefined ? goodArgNum_ : false; + this.runeBuf = runeBuf_ !== undefined ? runeBuf_ : ($arrayType($Uint8, 4)).zero(); + this.fmt = fmt_ !== undefined ? fmt_ : new fmt.Ptr(); + }); + runeUnreader = $pkg.runeUnreader = $newType(8, "Interface", "fmt.runeUnreader", "runeUnreader", "fmt", null); + ScanState = $pkg.ScanState = $newType(8, "Interface", "fmt.ScanState", "ScanState", "fmt", null); + scanError = $pkg.scanError = $newType(0, "Struct", "fmt.scanError", "scanError", "fmt", function(err_) { + this.$val = this; + this.err = err_ !== undefined ? err_ : $ifaceNil; + }); + ss = $pkg.ss = $newType(0, "Struct", "fmt.ss", "ss", "fmt", function(rr_, buf_, peekRune_, prevRune_, count_, atEOF_, ssave_) { + this.$val = this; + this.rr = rr_ !== undefined ? rr_ : $ifaceNil; + this.buf = buf_ !== undefined ? buf_ : buffer.nil; + this.peekRune = peekRune_ !== undefined ? peekRune_ : 0; + this.prevRune = prevRune_ !== undefined ? prevRune_ : 0; + this.count = count_ !== undefined ? count_ : 0; + this.atEOF = atEOF_ !== undefined ? atEOF_ : false; + this.ssave = ssave_ !== undefined ? ssave_ : new ssave.Ptr(); + }); + ssave = $pkg.ssave = $newType(0, "Struct", "fmt.ssave", "ssave", "fmt", function(validSave_, nlIsEnd_, nlIsSpace_, argLimit_, limit_, maxWid_) { + this.$val = this; + this.validSave = validSave_ !== undefined ? validSave_ : false; + this.nlIsEnd = nlIsEnd_ !== undefined ? nlIsEnd_ : false; + this.nlIsSpace = nlIsSpace_ !== undefined ? nlIsSpace_ : false; + this.argLimit = argLimit_ !== undefined ? argLimit_ : 0; + this.limit = limit_ !== undefined ? limit_ : 0; + this.maxWid = maxWid_ !== undefined ? maxWid_ : 0; + }); + init = function() { + var i; + i = 0; + while (i < 65) { + (i < 0 || i >= padZeroBytes.$length) ? $throwRuntimeError("index out of range") : padZeroBytes.$array[padZeroBytes.$offset + i] = 48; + (i < 0 || i >= padSpaceBytes.$length) ? $throwRuntimeError("index out of range") : padSpaceBytes.$array[padSpaceBytes.$offset + i] = 32; + i = i + (1) >> 0; } }; - pp.prototype.fmtInt64 = function(v, verb) { return this.$val.fmtInt64(v, verb); }; - pp.Ptr.prototype.fmt0x64 = function(v, leading0x) { - var p, sharp; - p = this; - sharp = p.fmt.sharp; - p.fmt.sharp = leading0x; - p.fmt.integer(new $Int64(v.$high, v.$low), new $Uint64(0, 16), false, "0123456789abcdef"); - p.fmt.sharp = sharp; + fmt.Ptr.prototype.clearflags = function() { + var f; + f = this; + f.wid = 0; + f.widPresent = false; + f.prec = 0; + f.precPresent = false; + f.minus = false; + f.plus = false; + f.sharp = false; + f.space = false; + f.unicode = false; + f.uniQuote = false; + f.zero = false; }; - pp.prototype.fmt0x64 = function(v, leading0x) { return this.$val.fmt0x64(v, leading0x); }; - pp.Ptr.prototype.fmtUnicode = function(v) { - var p, precPresent, sharp, prec; - p = this; - precPresent = p.fmt.precPresent; - sharp = p.fmt.sharp; - p.fmt.sharp = false; - prec = p.fmt.prec; - if (!precPresent) { - p.fmt.prec = 4; - p.fmt.precPresent = true; - } - p.fmt.unicode = true; - p.fmt.uniQuote = sharp; - p.fmt.integer(v, new $Uint64(0, 16), false, "0123456789ABCDEF"); - p.fmt.unicode = false; - p.fmt.uniQuote = false; - p.fmt.prec = prec; - p.fmt.precPresent = precPresent; - p.fmt.sharp = sharp; + fmt.prototype.clearflags = function() { return this.$val.clearflags(); }; + fmt.Ptr.prototype.init = function(buf) { + var f; + f = this; + f.buf = buf; + f.clearflags(); }; - pp.prototype.fmtUnicode = function(v) { return this.$val.fmtUnicode(v); }; - pp.Ptr.prototype.fmtUint64 = function(v, verb, goSyntax) { - var p, _ref; - p = this; - _ref = verb; - if (_ref === 98) { - p.fmt.integer(new $Int64(v.$high, v.$low), new $Uint64(0, 2), false, "0123456789abcdef"); - } else if (_ref === 99) { - p.fmtC(new $Int64(v.$high, v.$low)); - } else if (_ref === 100) { - p.fmt.integer(new $Int64(v.$high, v.$low), new $Uint64(0, 10), false, "0123456789abcdef"); - } else if (_ref === 118) { - if (goSyntax) { - p.fmt0x64(v, true); - } else { - p.fmt.integer(new $Int64(v.$high, v.$low), new $Uint64(0, 10), false, "0123456789abcdef"); + fmt.prototype.init = function(buf) { return this.$val.init(buf); }; + fmt.Ptr.prototype.computePadding = function(width) { + var padding = ($sliceType($Uint8)).nil, leftWidth = 0, rightWidth = 0, f, left, w, _tmp, _tmp$1, _tmp$2, _tmp$3, _tmp$4, _tmp$5, _tmp$6, _tmp$7, _tmp$8; + f = this; + left = !f.minus; + w = f.wid; + if (w < 0) { + left = false; + w = -w; + } + w = w - (width) >> 0; + if (w > 0) { + if (left && f.zero) { + _tmp = padZeroBytes; _tmp$1 = w; _tmp$2 = 0; padding = _tmp; leftWidth = _tmp$1; rightWidth = _tmp$2; + return [padding, leftWidth, rightWidth]; } - } else if (_ref === 111) { - p.fmt.integer(new $Int64(v.$high, v.$low), new $Uint64(0, 8), false, "0123456789abcdef"); - } else if (_ref === 113) { - if ((0 < v.$high || (0 === v.$high && 0 <= v.$low)) && (v.$high < 0 || (v.$high === 0 && v.$low <= 1114111))) { - p.fmt.fmt_qc(new $Int64(v.$high, v.$low)); + if (left) { + _tmp$3 = padSpaceBytes; _tmp$4 = w; _tmp$5 = 0; padding = _tmp$3; leftWidth = _tmp$4; rightWidth = _tmp$5; + return [padding, leftWidth, rightWidth]; } else { - p.badVerb(verb); + _tmp$6 = padSpaceBytes; _tmp$7 = 0; _tmp$8 = w; padding = _tmp$6; leftWidth = _tmp$7; rightWidth = _tmp$8; + return [padding, leftWidth, rightWidth]; } - } else if (_ref === 120) { - p.fmt.integer(new $Int64(v.$high, v.$low), new $Uint64(0, 16), false, "0123456789abcdef"); - } else if (_ref === 88) { - p.fmt.integer(new $Int64(v.$high, v.$low), new $Uint64(0, 16), false, "0123456789ABCDEF"); - } else if (_ref === 85) { - p.fmtUnicode(new $Int64(v.$high, v.$low)); - } else { - p.badVerb(verb); - } - }; - pp.prototype.fmtUint64 = function(v, verb, goSyntax) { return this.$val.fmtUint64(v, verb, goSyntax); }; - pp.Ptr.prototype.fmtFloat32 = function(v, verb) { - var p, _ref; - p = this; - _ref = verb; - if (_ref === 98) { - p.fmt.fmt_fb32(v); - } else if (_ref === 101) { - p.fmt.fmt_e32(v); - } else if (_ref === 69) { - p.fmt.fmt_E32(v); - } else if (_ref === 102 || _ref === 70) { - p.fmt.fmt_f32(v); - } else if (_ref === 103 || _ref === 118) { - p.fmt.fmt_g32(v); - } else if (_ref === 71) { - p.fmt.fmt_G32(v); - } else { - p.badVerb(verb); } + return [padding, leftWidth, rightWidth]; }; - pp.prototype.fmtFloat32 = function(v, verb) { return this.$val.fmtFloat32(v, verb); }; - pp.Ptr.prototype.fmtFloat64 = function(v, verb) { - var p, _ref; - p = this; - _ref = verb; - if (_ref === 98) { - p.fmt.fmt_fb64(v); - } else if (_ref === 101) { - p.fmt.fmt_e64(v); - } else if (_ref === 69) { - p.fmt.fmt_E64(v); - } else if (_ref === 102 || _ref === 70) { - p.fmt.fmt_f64(v); - } else if (_ref === 103 || _ref === 118) { - p.fmt.fmt_g64(v); - } else if (_ref === 71) { - p.fmt.fmt_G64(v); - } else { - p.badVerb(verb); + fmt.prototype.computePadding = function(width) { return this.$val.computePadding(width); }; + fmt.Ptr.prototype.writePadding = function(n, padding) { + var f, m; + f = this; + while (n > 0) { + m = n; + if (m > 65) { + m = 65; + } + f.buf.Write($subslice(padding, 0, m)); + n = n - (m) >> 0; } }; - pp.prototype.fmtFloat64 = function(v, verb) { return this.$val.fmtFloat64(v, verb); }; - pp.Ptr.prototype.fmtComplex64 = function(v, verb) { - var p, _ref; - p = this; - _ref = verb; - if (_ref === 98 || _ref === 101 || _ref === 69 || _ref === 102 || _ref === 70 || _ref === 103 || _ref === 71) { - p.fmt.fmt_c64(v, verb); - } else if (_ref === 118) { - p.fmt.fmt_c64(v, 103); - } else { - p.badVerb(verb); + fmt.prototype.writePadding = function(n, padding) { return this.$val.writePadding(n, padding); }; + fmt.Ptr.prototype.pad = function(b) { + var f, _tuple, padding, left, right; + f = this; + if (!f.widPresent || (f.wid === 0)) { + f.buf.Write(b); + return; } - }; - pp.prototype.fmtComplex64 = function(v, verb) { return this.$val.fmtComplex64(v, verb); }; - pp.Ptr.prototype.fmtComplex128 = function(v, verb) { - var p, _ref; - p = this; - _ref = verb; - if (_ref === 98 || _ref === 101 || _ref === 69 || _ref === 102 || _ref === 70 || _ref === 103 || _ref === 71) { - p.fmt.fmt_c128(v, verb); - } else if (_ref === 118) { - p.fmt.fmt_c128(v, 103); - } else { - p.badVerb(verb); + _tuple = f.computePadding(b.$length); padding = _tuple[0]; left = _tuple[1]; right = _tuple[2]; + if (left > 0) { + f.writePadding(left, padding); } - }; - pp.prototype.fmtComplex128 = function(v, verb) { return this.$val.fmtComplex128(v, verb); }; - pp.Ptr.prototype.fmtString = function(v, verb, goSyntax) { - var p, _ref; - p = this; - _ref = verb; - if (_ref === 118) { - if (goSyntax) { - p.fmt.fmt_q(v); - } else { - p.fmt.fmt_s(v); - } - } else if (_ref === 115) { - p.fmt.fmt_s(v); - } else if (_ref === 120) { - p.fmt.fmt_sx(v, "0123456789abcdef"); - } else if (_ref === 88) { - p.fmt.fmt_sx(v, "0123456789ABCDEF"); - } else if (_ref === 113) { - p.fmt.fmt_q(v); - } else { - p.badVerb(verb); + f.buf.Write(b); + if (right > 0) { + f.writePadding(right, padding); } }; - pp.prototype.fmtString = function(v, verb, goSyntax) { return this.$val.fmtString(v, verb, goSyntax); }; - pp.Ptr.prototype.fmtBytes = function(v, verb, goSyntax, typ, depth) { - var p, _ref, _i, i, c, _ref$1; - p = this; - if ((verb === 118) || (verb === 100)) { - if (goSyntax) { - if (v === ($sliceType($Uint8)).nil) { - if ($interfaceIsEqual(typ, $ifaceNil)) { - new ($ptrType(buffer))(function() { return this.$target.buf; }, function($v) { this.$target.buf = $v; }, p).WriteString("[]byte(nil)"); - } else { - new ($ptrType(buffer))(function() { return this.$target.buf; }, function($v) { this.$target.buf = $v; }, p).WriteString(typ.String()); - new ($ptrType(buffer))(function() { return this.$target.buf; }, function($v) { this.$target.buf = $v; }, p).Write(nilParenBytes); - } - return; - } - if ($interfaceIsEqual(typ, $ifaceNil)) { - new ($ptrType(buffer))(function() { return this.$target.buf; }, function($v) { this.$target.buf = $v; }, p).Write(bytesBytes); - } else { - new ($ptrType(buffer))(function() { return this.$target.buf; }, function($v) { this.$target.buf = $v; }, p).WriteString(typ.String()); - new ($ptrType(buffer))(function() { return this.$target.buf; }, function($v) { this.$target.buf = $v; }, p).WriteByte(123); - } - } else { - new ($ptrType(buffer))(function() { return this.$target.buf; }, function($v) { this.$target.buf = $v; }, p).WriteByte(91); - } - _ref = v; - _i = 0; - while (_i < _ref.$length) { - i = _i; - c = ((_i < 0 || _i >= _ref.$length) ? $throwRuntimeError("index out of range") : _ref.$array[_ref.$offset + _i]); - if (i > 0) { - if (goSyntax) { - new ($ptrType(buffer))(function() { return this.$target.buf; }, function($v) { this.$target.buf = $v; }, p).Write(commaSpaceBytes); - } else { - new ($ptrType(buffer))(function() { return this.$target.buf; }, function($v) { this.$target.buf = $v; }, p).WriteByte(32); - } - } - p.printArg(new $Uint8(c), 118, p.fmt.plus, goSyntax, depth + 1 >> 0); - _i++; - } - if (goSyntax) { - new ($ptrType(buffer))(function() { return this.$target.buf; }, function($v) { this.$target.buf = $v; }, p).WriteByte(125); - } else { - new ($ptrType(buffer))(function() { return this.$target.buf; }, function($v) { this.$target.buf = $v; }, p).WriteByte(93); - } + fmt.prototype.pad = function(b) { return this.$val.pad(b); }; + fmt.Ptr.prototype.padString = function(s) { + var f, _tuple, padding, left, right; + f = this; + if (!f.widPresent || (f.wid === 0)) { + f.buf.WriteString(s); return; } - _ref$1 = verb; - if (_ref$1 === 115) { - p.fmt.fmt_s($bytesToString(v)); - } else if (_ref$1 === 120) { - p.fmt.fmt_bx(v, "0123456789abcdef"); - } else if (_ref$1 === 88) { - p.fmt.fmt_bx(v, "0123456789ABCDEF"); - } else if (_ref$1 === 113) { - p.fmt.fmt_q($bytesToString(v)); - } else { - p.badVerb(verb); + _tuple = f.computePadding(utf8.RuneCountInString(s)); padding = _tuple[0]; left = _tuple[1]; right = _tuple[2]; + if (left > 0) { + f.writePadding(left, padding); + } + f.buf.WriteString(s); + if (right > 0) { + f.writePadding(right, padding); } }; - pp.prototype.fmtBytes = function(v, verb, goSyntax, typ, depth) { return this.$val.fmtBytes(v, verb, goSyntax, typ, depth); }; - pp.Ptr.prototype.fmtPointer = function(value, verb, goSyntax) { - var p, use0x64, _ref, u, _ref$1; - p = this; - use0x64 = true; - _ref = verb; - if (_ref === 112 || _ref === 118) { - } else if (_ref === 98 || _ref === 100 || _ref === 111 || _ref === 120 || _ref === 88) { - use0x64 = false; + fmt.prototype.padString = function(s) { return this.$val.padString(s); }; + fmt.Ptr.prototype.fmt_boolean = function(v) { + var f; + f = this; + if (v) { + f.pad(trueBytes); } else { - p.badVerb(verb); - return; + f.pad(falseBytes); } - u = 0; - _ref$1 = value.Kind(); - if (_ref$1 === 18 || _ref$1 === 19 || _ref$1 === 21 || _ref$1 === 22 || _ref$1 === 23 || _ref$1 === 26) { - u = value.Pointer(); - } else { - p.badVerb(verb); + }; + fmt.prototype.fmt_boolean = function(v) { return this.$val.fmt_boolean(v); }; + fmt.Ptr.prototype.integer = function(a, base, signedness, digits) { + var f, buf, width, negative, prec, i, ua, _ref, runeWidth, width$1, j; + f = this; + if (f.precPresent && (f.prec === 0) && (a.$high === 0 && a.$low === 0)) { return; } - if (goSyntax) { - p.add(40); - new ($ptrType(buffer))(function() { return this.$target.buf; }, function($v) { this.$target.buf = $v; }, p).WriteString(value.Type().String()); - p.add(41); - p.add(40); - if (u === 0) { - new ($ptrType(buffer))(function() { return this.$target.buf; }, function($v) { this.$target.buf = $v; }, p).Write(nilBytes); - } else { - p.fmt0x64(new $Uint64(0, u.constructor === Number ? u : 1), true); + buf = $subslice(new ($sliceType($Uint8))(f.intbuf), 0); + if (f.widPresent) { + width = f.wid; + if ((base.$high === 0 && base.$low === 16) && f.sharp) { + width = width + (2) >> 0; } - p.add(41); - } else if ((verb === 118) && (u === 0)) { - new ($ptrType(buffer))(function() { return this.$target.buf; }, function($v) { this.$target.buf = $v; }, p).Write(nilAngleBytes); - } else { - if (use0x64) { - p.fmt0x64(new $Uint64(0, u.constructor === Number ? u : 1), !p.fmt.sharp); - } else { - p.fmtUint64(new $Uint64(0, u.constructor === Number ? u : 1), verb, false); + if (width > 65) { + buf = ($sliceType($Uint8)).make(width); } } - }; - pp.prototype.fmtPointer = function(value, verb, goSyntax) { return this.$val.fmtPointer(value, verb, goSyntax); }; - pp.Ptr.prototype.catchPanic = function(arg, verb) { - var p, err, v; - p = this; - err = $recover(); - if (!($interfaceIsEqual(err, $ifaceNil))) { - v = new reflect.Value.Ptr(); $copy(v, reflect.ValueOf(arg), reflect.Value); - if ((v.Kind() === 22) && v.IsNil()) { - new ($ptrType(buffer))(function() { return this.$target.buf; }, function($v) { this.$target.buf = $v; }, p).Write(nilAngleBytes); - return; + negative = signedness === true && (a.$high < 0 || (a.$high === 0 && a.$low < 0)); + if (negative) { + a = new $Int64(-a.$high, -a.$low); + } + prec = 0; + if (f.precPresent) { + prec = f.prec; + f.zero = false; + } else if (f.zero && f.widPresent && !f.minus && f.wid > 0) { + prec = f.wid; + if (negative || f.plus || f.space) { + prec = prec - (1) >> 0; } - if (p.panicking) { - $panic(err); + } + i = buf.$length; + ua = new $Uint64(a.$high, a.$low); + while ((ua.$high > base.$high || (ua.$high === base.$high && ua.$low >= base.$low))) { + i = i - (1) >> 0; + (i < 0 || i >= buf.$length) ? $throwRuntimeError("index out of range") : buf.$array[buf.$offset + i] = digits.charCodeAt($flatten64($div64(ua, base, true))); + ua = $div64(ua, (base), false); + } + i = i - (1) >> 0; + (i < 0 || i >= buf.$length) ? $throwRuntimeError("index out of range") : buf.$array[buf.$offset + i] = digits.charCodeAt($flatten64(ua)); + while (i > 0 && prec > (buf.$length - i >> 0)) { + i = i - (1) >> 0; + (i < 0 || i >= buf.$length) ? $throwRuntimeError("index out of range") : buf.$array[buf.$offset + i] = 48; + } + if (f.sharp) { + _ref = base; + if ((_ref.$high === 0 && _ref.$low === 8)) { + if (!((((i < 0 || i >= buf.$length) ? $throwRuntimeError("index out of range") : buf.$array[buf.$offset + i]) === 48))) { + i = i - (1) >> 0; + (i < 0 || i >= buf.$length) ? $throwRuntimeError("index out of range") : buf.$array[buf.$offset + i] = 48; + } + } else if ((_ref.$high === 0 && _ref.$low === 16)) { + i = i - (1) >> 0; + (i < 0 || i >= buf.$length) ? $throwRuntimeError("index out of range") : buf.$array[buf.$offset + i] = (120 + digits.charCodeAt(10) << 24 >>> 24) - 97 << 24 >>> 24; + i = i - (1) >> 0; + (i < 0 || i >= buf.$length) ? $throwRuntimeError("index out of range") : buf.$array[buf.$offset + i] = 48; } - new ($ptrType(buffer))(function() { return this.$target.buf; }, function($v) { this.$target.buf = $v; }, p).Write(percentBangBytes); - p.add(verb); - new ($ptrType(buffer))(function() { return this.$target.buf; }, function($v) { this.$target.buf = $v; }, p).Write(panicBytes); - p.panicking = true; - p.printArg(err, 118, false, false, 0); - p.panicking = false; - new ($ptrType(buffer))(function() { return this.$target.buf; }, function($v) { this.$target.buf = $v; }, p).WriteByte(41); } - }; - pp.prototype.catchPanic = function(arg, verb) { return this.$val.catchPanic(arg, verb); }; - pp.Ptr.prototype.handleMethods = function(verb, plus, goSyntax, depth) { - var wasString = false, handled = false, $deferred = [], $err = null, p, _tuple, formatter, ok, _tuple$1, stringer, ok$1, _ref, v, _ref$1; - /* */ try { $deferFrames.push($deferred); - p = this; - if (p.erroring) { - return [wasString, handled]; + if (f.unicode) { + i = i - (1) >> 0; + (i < 0 || i >= buf.$length) ? $throwRuntimeError("index out of range") : buf.$array[buf.$offset + i] = 43; + i = i - (1) >> 0; + (i < 0 || i >= buf.$length) ? $throwRuntimeError("index out of range") : buf.$array[buf.$offset + i] = 85; } - _tuple = $assertType(p.arg, Formatter, true); formatter = _tuple[0]; ok = _tuple[1]; - if (ok) { - handled = true; - wasString = false; - $deferred.push([$methodVal(p, "catchPanic"), [p.arg, verb]]); - formatter.Format(p, verb); - return [wasString, handled]; + if (negative) { + i = i - (1) >> 0; + (i < 0 || i >= buf.$length) ? $throwRuntimeError("index out of range") : buf.$array[buf.$offset + i] = 45; + } else if (f.plus) { + i = i - (1) >> 0; + (i < 0 || i >= buf.$length) ? $throwRuntimeError("index out of range") : buf.$array[buf.$offset + i] = 43; + } else if (f.space) { + i = i - (1) >> 0; + (i < 0 || i >= buf.$length) ? $throwRuntimeError("index out of range") : buf.$array[buf.$offset + i] = 32; } - if (plus) { - p.fmt.plus = false; + if (f.unicode && f.uniQuote && (a.$high > 0 || (a.$high === 0 && a.$low >= 0)) && (a.$high < 0 || (a.$high === 0 && a.$low <= 1114111)) && strconv.IsPrint(((a.$low + ((a.$high >> 31) * 4294967296)) >> 0))) { + runeWidth = utf8.RuneLen(((a.$low + ((a.$high >> 31) * 4294967296)) >> 0)); + width$1 = (2 + runeWidth >> 0) + 1 >> 0; + $copySlice($subslice(buf, (i - width$1 >> 0)), $subslice(buf, i)); + i = i - (width$1) >> 0; + j = buf.$length - width$1 >> 0; + (j < 0 || j >= buf.$length) ? $throwRuntimeError("index out of range") : buf.$array[buf.$offset + j] = 32; + j = j + (1) >> 0; + (j < 0 || j >= buf.$length) ? $throwRuntimeError("index out of range") : buf.$array[buf.$offset + j] = 39; + j = j + (1) >> 0; + utf8.EncodeRune($subslice(buf, j), ((a.$low + ((a.$high >> 31) * 4294967296)) >> 0)); + j = j + (runeWidth) >> 0; + (j < 0 || j >= buf.$length) ? $throwRuntimeError("index out of range") : buf.$array[buf.$offset + j] = 39; } - if (goSyntax) { - p.fmt.sharp = false; - _tuple$1 = $assertType(p.arg, GoStringer, true); stringer = _tuple$1[0]; ok$1 = _tuple$1[1]; - if (ok$1) { - wasString = false; - handled = true; - $deferred.push([$methodVal(p, "catchPanic"), [p.arg, verb]]); - p.fmtString(stringer.GoString(), 115, false); - return [wasString, handled]; - } - } else { - _ref = verb; - if (_ref === 118 || _ref === 115 || _ref === 120 || _ref === 88 || _ref === 113) { - _ref$1 = p.arg; - if ($assertType(_ref$1, $error, true)[1]) { - v = _ref$1; - wasString = false; - handled = true; - $deferred.push([$methodVal(p, "catchPanic"), [p.arg, verb]]); - p.printArg(new $String(v.Error()), verb, plus, false, depth); - return [wasString, handled]; - } else if ($assertType(_ref$1, Stringer, true)[1]) { - v = _ref$1; - wasString = false; - handled = true; - $deferred.push([$methodVal(p, "catchPanic"), [p.arg, verb]]); - p.printArg(new $String(v.String()), verb, plus, false, depth); - return [wasString, handled]; + f.pad($subslice(buf, i)); + }; + fmt.prototype.integer = function(a, base, signedness, digits) { return this.$val.integer(a, base, signedness, digits); }; + fmt.Ptr.prototype.truncate = function(s) { + var f, n, _ref, _i, _rune, i; + f = this; + if (f.precPresent && f.prec < utf8.RuneCountInString(s)) { + n = f.prec; + _ref = s; + _i = 0; + while (_i < _ref.length) { + _rune = $decodeRune(_ref, _i); + i = _i; + if (n === 0) { + s = s.substring(0, i); + break; } + n = n - (1) >> 0; + _i += _rune[1]; } } - handled = false; - return [wasString, handled]; - /* */ } catch(err) { $err = err; } finally { $deferFrames.pop(); $callDeferred($deferred, $err); return [wasString, handled]; } + return s; }; - pp.prototype.handleMethods = function(verb, plus, goSyntax, depth) { return this.$val.handleMethods(verb, plus, goSyntax, depth); }; - pp.Ptr.prototype.printArg = function(arg, verb, plus, goSyntax, depth) { - var wasString = false, p, _ref, oldPlus, oldSharp, f, _ref$1, _tuple, isString, handled; - p = this; - p.arg = arg; - $copy(p.value, new reflect.Value.Ptr(($ptrType(reflect.rtype)).nil, 0, 0, 0), reflect.Value); - if ($interfaceIsEqual(arg, $ifaceNil)) { - if ((verb === 84) || (verb === 118)) { - p.fmt.pad(nilAngleBytes); + fmt.prototype.truncate = function(s) { return this.$val.truncate(s); }; + fmt.Ptr.prototype.fmt_s = function(s) { + var f; + f = this; + s = f.truncate(s); + f.padString(s); + }; + fmt.prototype.fmt_s = function(s) { return this.$val.fmt_s(s); }; + fmt.Ptr.prototype.fmt_sbx = function(s, b, digits) { + var f, n, x, buf, i, c; + f = this; + n = b.$length; + if (b === ($sliceType($Uint8)).nil) { + n = s.length; + } + x = (digits.charCodeAt(10) - 97 << 24 >>> 24) + 120 << 24 >>> 24; + buf = ($sliceType($Uint8)).nil; + i = 0; + while (i < n) { + if (i > 0 && f.space) { + buf = $append(buf, 32); + } + if (f.sharp) { + buf = $append(buf, 48, x); + } + c = 0; + if (b === ($sliceType($Uint8)).nil) { + c = s.charCodeAt(i); } else { - p.badVerb(verb); + c = ((i < 0 || i >= b.$length) ? $throwRuntimeError("index out of range") : b.$array[b.$offset + i]); } - wasString = false; - return wasString; - } - _ref = verb; - if (_ref === 84) { - p.printArg(new $String(reflect.TypeOf(arg).String()), 115, false, false, 0); - wasString = false; - return wasString; - } else if (_ref === 112) { - p.fmtPointer($clone(reflect.ValueOf(arg), reflect.Value), verb, goSyntax); - wasString = false; - return wasString; - } - oldPlus = p.fmt.plus; - oldSharp = p.fmt.sharp; - if (plus) { - p.fmt.plus = false; - } - if (goSyntax) { - p.fmt.sharp = false; + buf = $append(buf, digits.charCodeAt((c >>> 4 << 24 >>> 24)), digits.charCodeAt(((c & 15) >>> 0))); + i = i + (1) >> 0; } - _ref$1 = arg; - if ($assertType(_ref$1, $Bool, true)[1]) { - f = _ref$1.$val; - p.fmtBool(f, verb); - } else if ($assertType(_ref$1, $Float32, true)[1]) { - f = _ref$1.$val; - p.fmtFloat32(f, verb); - } else if ($assertType(_ref$1, $Float64, true)[1]) { - f = _ref$1.$val; - p.fmtFloat64(f, verb); - } else if ($assertType(_ref$1, $Complex64, true)[1]) { - f = _ref$1.$val; - p.fmtComplex64(f, verb); - } else if ($assertType(_ref$1, $Complex128, true)[1]) { - f = _ref$1.$val; - p.fmtComplex128(f, verb); - } else if ($assertType(_ref$1, $Int, true)[1]) { - f = _ref$1.$val; - p.fmtInt64(new $Int64(0, f), verb); - } else if ($assertType(_ref$1, $Int8, true)[1]) { - f = _ref$1.$val; - p.fmtInt64(new $Int64(0, f), verb); - } else if ($assertType(_ref$1, $Int16, true)[1]) { - f = _ref$1.$val; - p.fmtInt64(new $Int64(0, f), verb); - } else if ($assertType(_ref$1, $Int32, true)[1]) { - f = _ref$1.$val; - p.fmtInt64(new $Int64(0, f), verb); - } else if ($assertType(_ref$1, $Int64, true)[1]) { - f = _ref$1.$val; - p.fmtInt64(f, verb); - } else if ($assertType(_ref$1, $Uint, true)[1]) { - f = _ref$1.$val; - p.fmtUint64(new $Uint64(0, f), verb, goSyntax); - } else if ($assertType(_ref$1, $Uint8, true)[1]) { - f = _ref$1.$val; - p.fmtUint64(new $Uint64(0, f), verb, goSyntax); - } else if ($assertType(_ref$1, $Uint16, true)[1]) { - f = _ref$1.$val; - p.fmtUint64(new $Uint64(0, f), verb, goSyntax); - } else if ($assertType(_ref$1, $Uint32, true)[1]) { - f = _ref$1.$val; - p.fmtUint64(new $Uint64(0, f), verb, goSyntax); - } else if ($assertType(_ref$1, $Uint64, true)[1]) { - f = _ref$1.$val; - p.fmtUint64(f, verb, goSyntax); - } else if ($assertType(_ref$1, $Uintptr, true)[1]) { - f = _ref$1.$val; - p.fmtUint64(new $Uint64(0, f.constructor === Number ? f : 1), verb, goSyntax); - } else if ($assertType(_ref$1, $String, true)[1]) { - f = _ref$1.$val; - p.fmtString(f, verb, goSyntax); - wasString = (verb === 115) || (verb === 118); - } else if ($assertType(_ref$1, ($sliceType($Uint8)), true)[1]) { - f = _ref$1.$val; - p.fmtBytes(f, verb, goSyntax, $ifaceNil, depth); - wasString = verb === 115; + f.pad(buf); + }; + fmt.prototype.fmt_sbx = function(s, b, digits) { return this.$val.fmt_sbx(s, b, digits); }; + fmt.Ptr.prototype.fmt_sx = function(s, digits) { + var f; + f = this; + f.fmt_sbx(s, ($sliceType($Uint8)).nil, digits); + }; + fmt.prototype.fmt_sx = function(s, digits) { return this.$val.fmt_sx(s, digits); }; + fmt.Ptr.prototype.fmt_bx = function(b, digits) { + var f; + f = this; + f.fmt_sbx("", b, digits); + }; + fmt.prototype.fmt_bx = function(b, digits) { return this.$val.fmt_bx(b, digits); }; + fmt.Ptr.prototype.fmt_q = function(s) { + var f, quoted; + f = this; + s = f.truncate(s); + quoted = ""; + if (f.sharp && strconv.CanBackquote(s)) { + quoted = "`" + s + "`"; } else { - f = _ref$1; - p.fmt.plus = oldPlus; - p.fmt.sharp = oldSharp; - _tuple = p.handleMethods(verb, plus, goSyntax, depth); isString = _tuple[0]; handled = _tuple[1]; - if (handled) { - wasString = isString; - return wasString; + if (f.plus) { + quoted = strconv.QuoteToASCII(s); + } else { + quoted = strconv.Quote(s); } - wasString = p.printReflectValue($clone(reflect.ValueOf(arg), reflect.Value), verb, plus, goSyntax, depth); - return wasString; } - p.arg = $ifaceNil; - return wasString; + f.padString(quoted); }; - pp.prototype.printArg = function(arg, verb, plus, goSyntax, depth) { return this.$val.printArg(arg, verb, plus, goSyntax, depth); }; - pp.Ptr.prototype.printValue = function(value, verb, plus, goSyntax, depth) { - var wasString = false, p, _ref, _tuple, isString, handled; - p = this; - if (!value.IsValid()) { - if ((verb === 84) || (verb === 118)) { - new ($ptrType(buffer))(function() { return this.$target.buf; }, function($v) { this.$target.buf = $v; }, p).Write(nilAngleBytes); - } else { - p.badVerb(verb); - } - wasString = false; - return wasString; + fmt.prototype.fmt_q = function(s) { return this.$val.fmt_q(s); }; + fmt.Ptr.prototype.fmt_qc = function(c) { + var f, quoted; + f = this; + quoted = ($sliceType($Uint8)).nil; + if (f.plus) { + quoted = strconv.AppendQuoteRuneToASCII($subslice(new ($sliceType($Uint8))(f.intbuf), 0, 0), ((c.$low + ((c.$high >> 31) * 4294967296)) >> 0)); + } else { + quoted = strconv.AppendQuoteRune($subslice(new ($sliceType($Uint8))(f.intbuf), 0, 0), ((c.$low + ((c.$high >> 31) * 4294967296)) >> 0)); } - _ref = verb; - if (_ref === 84) { - p.printArg(new $String(value.Type().String()), 115, false, false, 0); - wasString = false; - return wasString; - } else if (_ref === 112) { - p.fmtPointer($clone(value, reflect.Value), verb, goSyntax); - wasString = false; - return wasString; - } - p.arg = $ifaceNil; - if (value.CanInterface()) { - p.arg = value.Interface(); - } - _tuple = p.handleMethods(verb, plus, goSyntax, depth); isString = _tuple[0]; handled = _tuple[1]; - if (handled) { - wasString = isString; - return wasString; - } - wasString = p.printReflectValue($clone(value, reflect.Value), verb, plus, goSyntax, depth); - return wasString; - }; - pp.prototype.printValue = function(value, verb, plus, goSyntax, depth) { return this.$val.printValue(value, verb, plus, goSyntax, depth); }; - pp.Ptr.prototype.printReflectValue = function(value, verb, plus, goSyntax, depth) { - var wasString = false, p, oldValue, f, _ref, x, keys, _ref$1, _i, i, key, v, t, i$1, f$1, value$1, typ, bytes, _ref$2, _i$1, i$2, i$3, v$1, a, _ref$3; - p = this; - oldValue = new reflect.Value.Ptr(); $copy(oldValue, p.value, reflect.Value); - $copy(p.value, value, reflect.Value); - f = new reflect.Value.Ptr(); $copy(f, value, reflect.Value); - _ref = f.Kind(); - BigSwitch: - switch (0) { default: if (_ref === 1) { - p.fmtBool(f.Bool(), verb); - } else if (_ref === 2 || _ref === 3 || _ref === 4 || _ref === 5 || _ref === 6) { - p.fmtInt64(f.Int(), verb); - } else if (_ref === 7 || _ref === 8 || _ref === 9 || _ref === 10 || _ref === 11 || _ref === 12) { - p.fmtUint64(f.Uint(), verb, goSyntax); - } else if (_ref === 13 || _ref === 14) { - if (f.Type().Size() === 4) { - p.fmtFloat32(f.Float(), verb); - } else { - p.fmtFloat64(f.Float(), verb); - } - } else if (_ref === 15 || _ref === 16) { - if (f.Type().Size() === 8) { - p.fmtComplex64((x = f.Complex(), new $Complex64(x.$real, x.$imag)), verb); - } else { - p.fmtComplex128(f.Complex(), verb); - } - } else if (_ref === 24) { - p.fmtString(f.String(), verb, goSyntax); - } else if (_ref === 21) { - if (goSyntax) { - new ($ptrType(buffer))(function() { return this.$target.buf; }, function($v) { this.$target.buf = $v; }, p).WriteString(f.Type().String()); - if (f.IsNil()) { - new ($ptrType(buffer))(function() { return this.$target.buf; }, function($v) { this.$target.buf = $v; }, p).WriteString("(nil)"); - break; - } - new ($ptrType(buffer))(function() { return this.$target.buf; }, function($v) { this.$target.buf = $v; }, p).WriteByte(123); - } else { - new ($ptrType(buffer))(function() { return this.$target.buf; }, function($v) { this.$target.buf = $v; }, p).Write(mapBytes); - } - keys = f.MapKeys(); - _ref$1 = keys; - _i = 0; - while (_i < _ref$1.$length) { - i = _i; - key = new reflect.Value.Ptr(); $copy(key, ((_i < 0 || _i >= _ref$1.$length) ? $throwRuntimeError("index out of range") : _ref$1.$array[_ref$1.$offset + _i]), reflect.Value); - if (i > 0) { - if (goSyntax) { - new ($ptrType(buffer))(function() { return this.$target.buf; }, function($v) { this.$target.buf = $v; }, p).Write(commaSpaceBytes); - } else { - new ($ptrType(buffer))(function() { return this.$target.buf; }, function($v) { this.$target.buf = $v; }, p).WriteByte(32); - } - } - p.printValue($clone(key, reflect.Value), verb, plus, goSyntax, depth + 1 >> 0); - new ($ptrType(buffer))(function() { return this.$target.buf; }, function($v) { this.$target.buf = $v; }, p).WriteByte(58); - p.printValue($clone(f.MapIndex($clone(key, reflect.Value)), reflect.Value), verb, plus, goSyntax, depth + 1 >> 0); - _i++; - } - if (goSyntax) { - new ($ptrType(buffer))(function() { return this.$target.buf; }, function($v) { this.$target.buf = $v; }, p).WriteByte(125); - } else { - new ($ptrType(buffer))(function() { return this.$target.buf; }, function($v) { this.$target.buf = $v; }, p).WriteByte(93); - } - } else if (_ref === 25) { - if (goSyntax) { - new ($ptrType(buffer))(function() { return this.$target.buf; }, function($v) { this.$target.buf = $v; }, p).WriteString(value.Type().String()); - } - p.add(123); - v = new reflect.Value.Ptr(); $copy(v, f, reflect.Value); - t = v.Type(); - i$1 = 0; - while (i$1 < v.NumField()) { - if (i$1 > 0) { - if (goSyntax) { - new ($ptrType(buffer))(function() { return this.$target.buf; }, function($v) { this.$target.buf = $v; }, p).Write(commaSpaceBytes); - } else { - new ($ptrType(buffer))(function() { return this.$target.buf; }, function($v) { this.$target.buf = $v; }, p).WriteByte(32); - } - } - if (plus || goSyntax) { - f$1 = new reflect.StructField.Ptr(); $copy(f$1, t.Field(i$1), reflect.StructField); - if (!(f$1.Name === "")) { - new ($ptrType(buffer))(function() { return this.$target.buf; }, function($v) { this.$target.buf = $v; }, p).WriteString(f$1.Name); - new ($ptrType(buffer))(function() { return this.$target.buf; }, function($v) { this.$target.buf = $v; }, p).WriteByte(58); - } - } - p.printValue($clone(getField($clone(v, reflect.Value), i$1), reflect.Value), verb, plus, goSyntax, depth + 1 >> 0); - i$1 = i$1 + (1) >> 0; - } - new ($ptrType(buffer))(function() { return this.$target.buf; }, function($v) { this.$target.buf = $v; }, p).WriteByte(125); - } else if (_ref === 20) { - value$1 = new reflect.Value.Ptr(); $copy(value$1, f.Elem(), reflect.Value); - if (!value$1.IsValid()) { - if (goSyntax) { - new ($ptrType(buffer))(function() { return this.$target.buf; }, function($v) { this.$target.buf = $v; }, p).WriteString(f.Type().String()); - new ($ptrType(buffer))(function() { return this.$target.buf; }, function($v) { this.$target.buf = $v; }, p).Write(nilParenBytes); - } else { - new ($ptrType(buffer))(function() { return this.$target.buf; }, function($v) { this.$target.buf = $v; }, p).Write(nilAngleBytes); - } - } else { - wasString = p.printValue($clone(value$1, reflect.Value), verb, plus, goSyntax, depth + 1 >> 0); - } - } else if (_ref === 17 || _ref === 23) { - typ = f.Type(); - if (typ.Elem().Kind() === 8) { - bytes = ($sliceType($Uint8)).nil; - if (f.Kind() === 23) { - bytes = f.Bytes(); - } else if (f.CanAddr()) { - bytes = f.Slice(0, f.Len()).Bytes(); - } else { - bytes = ($sliceType($Uint8)).make(f.Len()); - _ref$2 = bytes; - _i$1 = 0; - while (_i$1 < _ref$2.$length) { - i$2 = _i$1; - (i$2 < 0 || i$2 >= bytes.$length) ? $throwRuntimeError("index out of range") : bytes.$array[bytes.$offset + i$2] = (f.Index(i$2).Uint().$low << 24 >>> 24); - _i$1++; - } - } - p.fmtBytes(bytes, verb, goSyntax, typ, depth); - wasString = verb === 115; - break; - } - if (goSyntax) { - new ($ptrType(buffer))(function() { return this.$target.buf; }, function($v) { this.$target.buf = $v; }, p).WriteString(value.Type().String()); - if ((f.Kind() === 23) && f.IsNil()) { - new ($ptrType(buffer))(function() { return this.$target.buf; }, function($v) { this.$target.buf = $v; }, p).WriteString("(nil)"); - break; - } - new ($ptrType(buffer))(function() { return this.$target.buf; }, function($v) { this.$target.buf = $v; }, p).WriteByte(123); - } else { - new ($ptrType(buffer))(function() { return this.$target.buf; }, function($v) { this.$target.buf = $v; }, p).WriteByte(91); - } - i$3 = 0; - while (i$3 < f.Len()) { - if (i$3 > 0) { - if (goSyntax) { - new ($ptrType(buffer))(function() { return this.$target.buf; }, function($v) { this.$target.buf = $v; }, p).Write(commaSpaceBytes); - } else { - new ($ptrType(buffer))(function() { return this.$target.buf; }, function($v) { this.$target.buf = $v; }, p).WriteByte(32); - } - } - p.printValue($clone(f.Index(i$3), reflect.Value), verb, plus, goSyntax, depth + 1 >> 0); - i$3 = i$3 + (1) >> 0; - } - if (goSyntax) { - new ($ptrType(buffer))(function() { return this.$target.buf; }, function($v) { this.$target.buf = $v; }, p).WriteByte(125); - } else { - new ($ptrType(buffer))(function() { return this.$target.buf; }, function($v) { this.$target.buf = $v; }, p).WriteByte(93); - } - } else if (_ref === 22) { - v$1 = f.Pointer(); - if (!((v$1 === 0)) && (depth === 0)) { - a = new reflect.Value.Ptr(); $copy(a, f.Elem(), reflect.Value); - _ref$3 = a.Kind(); - if (_ref$3 === 17 || _ref$3 === 23) { - new ($ptrType(buffer))(function() { return this.$target.buf; }, function($v) { this.$target.buf = $v; }, p).WriteByte(38); - p.printValue($clone(a, reflect.Value), verb, plus, goSyntax, depth + 1 >> 0); - break BigSwitch; - } else if (_ref$3 === 25) { - new ($ptrType(buffer))(function() { return this.$target.buf; }, function($v) { this.$target.buf = $v; }, p).WriteByte(38); - p.printValue($clone(a, reflect.Value), verb, plus, goSyntax, depth + 1 >> 0); - break BigSwitch; - } - } - p.fmtPointer($clone(value, reflect.Value), verb, goSyntax); - } else if (_ref === 18 || _ref === 19 || _ref === 26) { - p.fmtPointer($clone(value, reflect.Value), verb, goSyntax); - } else { - p.unknownType(new f.constructor.Struct(f)); - } } - $copy(p.value, oldValue, reflect.Value); - wasString = wasString; - return wasString; - }; - pp.prototype.printReflectValue = function(value, verb, plus, goSyntax, depth) { return this.$val.printReflectValue(value, verb, plus, goSyntax, depth); }; - intFromArg = function(a, argNum) { - var num = 0, isInt = false, newArgNum = 0, _tuple; - newArgNum = argNum; - if (argNum < a.$length) { - _tuple = $assertType(((argNum < 0 || argNum >= a.$length) ? $throwRuntimeError("index out of range") : a.$array[a.$offset + argNum]), $Int, true); num = _tuple[0]; isInt = _tuple[1]; - newArgNum = argNum + 1 >> 0; - } - return [num, isInt, newArgNum]; + f.pad(quoted); }; - parseArgNumber = function(format) { - var index = 0, wid = 0, ok = false, i, _tuple, width, ok$1, newi, _tmp, _tmp$1, _tmp$2, _tmp$3, _tmp$4, _tmp$5, _tmp$6, _tmp$7, _tmp$8; - i = 1; - while (i < format.length) { - if (format.charCodeAt(i) === 93) { - _tuple = parsenum(format, 1, i); width = _tuple[0]; ok$1 = _tuple[1]; newi = _tuple[2]; - if (!ok$1 || !((newi === i))) { - _tmp = 0; _tmp$1 = i + 1 >> 0; _tmp$2 = false; index = _tmp; wid = _tmp$1; ok = _tmp$2; - return [index, wid, ok]; - } - _tmp$3 = width - 1 >> 0; _tmp$4 = i + 1 >> 0; _tmp$5 = true; index = _tmp$3; wid = _tmp$4; ok = _tmp$5; - return [index, wid, ok]; - } - i = i + (1) >> 0; + fmt.prototype.fmt_qc = function(c) { return this.$val.fmt_qc(c); }; + doPrec = function(f, def) { + if (f.precPresent) { + return f.prec; } - _tmp$6 = 0; _tmp$7 = 1; _tmp$8 = false; index = _tmp$6; wid = _tmp$7; ok = _tmp$8; - return [index, wid, ok]; + return def; }; - pp.Ptr.prototype.argNumber = function(argNum, format, i, numArgs) { - var newArgNum = 0, newi = 0, found = false, p, _tmp, _tmp$1, _tmp$2, _tuple, index, wid, ok, _tmp$3, _tmp$4, _tmp$5, _tmp$6, _tmp$7, _tmp$8; - p = this; - if (format.length <= i || !((format.charCodeAt(i) === 91))) { - _tmp = argNum; _tmp$1 = i; _tmp$2 = false; newArgNum = _tmp; newi = _tmp$1; found = _tmp$2; - return [newArgNum, newi, found]; - } - p.reordered = true; - _tuple = parseArgNumber(format.substring(i)); index = _tuple[0]; wid = _tuple[1]; ok = _tuple[2]; - if (ok && 0 <= index && index < numArgs) { - _tmp$3 = index; _tmp$4 = i + wid >> 0; _tmp$5 = true; newArgNum = _tmp$3; newi = _tmp$4; found = _tmp$5; - return [newArgNum, newi, found]; + fmt.Ptr.prototype.formatFloat = function(v, verb, prec, n) { + var $deferred = [], $err = null, f, num; + /* */ try { $deferFrames.push($deferred); + f = this; + num = strconv.AppendFloat($subslice(new ($sliceType($Uint8))(f.intbuf), 0, 1), v, verb, prec, n); + if ((((1 < 0 || 1 >= num.$length) ? $throwRuntimeError("index out of range") : num.$array[num.$offset + 1]) === 45) || (((1 < 0 || 1 >= num.$length) ? $throwRuntimeError("index out of range") : num.$array[num.$offset + 1]) === 43)) { + num = $subslice(num, 1); + } else { + (0 < 0 || 0 >= num.$length) ? $throwRuntimeError("index out of range") : num.$array[num.$offset + 0] = 43; } - p.goodArgNum = false; - _tmp$6 = argNum; _tmp$7 = i + wid >> 0; _tmp$8 = true; newArgNum = _tmp$6; newi = _tmp$7; found = _tmp$8; - return [newArgNum, newi, found]; - }; - pp.prototype.argNumber = function(argNum, format, i, numArgs) { return this.$val.argNumber(argNum, format, i, numArgs); }; - pp.Ptr.prototype.doPrintf = function(format, a) { - var p, end, argNum, afterIndex, i, lasti, _ref, _tuple, _tuple$1, _tuple$2, _tuple$3, _tuple$4, _tuple$5, _tuple$6, _tuple$7, c, w, arg, goSyntax, plus, arg$1; - p = this; - end = format.length; - argNum = 0; - afterIndex = false; - p.reordered = false; - i = 0; - while (i < end) { - p.goodArgNum = true; - lasti = i; - while (i < end && !((format.charCodeAt(i) === 37))) { - i = i + (1) >> 0; - } - if (i > lasti) { - new ($ptrType(buffer))(function() { return this.$target.buf; }, function($v) { this.$target.buf = $v; }, p).WriteString(format.substring(lasti, i)); - } - if (i >= end) { - break; - } - i = i + (1) >> 0; - p.fmt.clearflags(); - F: - while (i < end) { - _ref = format.charCodeAt(i); - if (_ref === 35) { - p.fmt.sharp = true; - } else if (_ref === 48) { - p.fmt.zero = true; - } else if (_ref === 43) { - p.fmt.plus = true; - } else if (_ref === 45) { - p.fmt.minus = true; - } else if (_ref === 32) { - p.fmt.space = true; - } else { - break F; - } - i = i + (1) >> 0; - } - _tuple = p.argNumber(argNum, format, i, a.$length); argNum = _tuple[0]; i = _tuple[1]; afterIndex = _tuple[2]; - if (i < end && (format.charCodeAt(i) === 42)) { - i = i + (1) >> 0; - _tuple$1 = intFromArg(a, argNum); p.fmt.wid = _tuple$1[0]; p.fmt.widPresent = _tuple$1[1]; argNum = _tuple$1[2]; - if (!p.fmt.widPresent) { - new ($ptrType(buffer))(function() { return this.$target.buf; }, function($v) { this.$target.buf = $v; }, p).Write(badWidthBytes); - } - afterIndex = false; - } else { - _tuple$2 = parsenum(format, i, end); p.fmt.wid = _tuple$2[0]; p.fmt.widPresent = _tuple$2[1]; i = _tuple$2[2]; - if (afterIndex && p.fmt.widPresent) { - p.goodArgNum = false; - } - } - if ((i + 1 >> 0) < end && (format.charCodeAt(i) === 46)) { - i = i + (1) >> 0; - if (afterIndex) { - p.goodArgNum = false; - } - _tuple$3 = p.argNumber(argNum, format, i, a.$length); argNum = _tuple$3[0]; i = _tuple$3[1]; afterIndex = _tuple$3[2]; - if (format.charCodeAt(i) === 42) { - i = i + (1) >> 0; - _tuple$4 = intFromArg(a, argNum); p.fmt.prec = _tuple$4[0]; p.fmt.precPresent = _tuple$4[1]; argNum = _tuple$4[2]; - if (!p.fmt.precPresent) { - new ($ptrType(buffer))(function() { return this.$target.buf; }, function($v) { this.$target.buf = $v; }, p).Write(badPrecBytes); - } - afterIndex = false; - } else { - _tuple$5 = parsenum(format, i, end); p.fmt.prec = _tuple$5[0]; p.fmt.precPresent = _tuple$5[1]; i = _tuple$5[2]; - if (!p.fmt.precPresent) { - p.fmt.prec = 0; - p.fmt.precPresent = true; - } - } - } - if (!afterIndex) { - _tuple$6 = p.argNumber(argNum, format, i, a.$length); argNum = _tuple$6[0]; i = _tuple$6[1]; afterIndex = _tuple$6[2]; - } - if (i >= end) { - new ($ptrType(buffer))(function() { return this.$target.buf; }, function($v) { this.$target.buf = $v; }, p).Write(noVerbBytes); - continue; - } - _tuple$7 = utf8.DecodeRuneInString(format.substring(i)); c = _tuple$7[0]; w = _tuple$7[1]; - i = i + (w) >> 0; - if (c === 37) { - new ($ptrType(buffer))(function() { return this.$target.buf; }, function($v) { this.$target.buf = $v; }, p).WriteByte(37); - continue; - } - if (!p.goodArgNum) { - new ($ptrType(buffer))(function() { return this.$target.buf; }, function($v) { this.$target.buf = $v; }, p).Write(percentBangBytes); - p.add(c); - new ($ptrType(buffer))(function() { return this.$target.buf; }, function($v) { this.$target.buf = $v; }, p).Write(badIndexBytes); - continue; - } else if (argNum >= a.$length) { - new ($ptrType(buffer))(function() { return this.$target.buf; }, function($v) { this.$target.buf = $v; }, p).Write(percentBangBytes); - p.add(c); - new ($ptrType(buffer))(function() { return this.$target.buf; }, function($v) { this.$target.buf = $v; }, p).Write(missingBytes); - continue; + if (math.IsInf(v, 0)) { + if (f.zero) { + $deferred.push([(function() { + f.zero = true; + }), []]); + f.zero = false; } - arg = ((argNum < 0 || argNum >= a.$length) ? $throwRuntimeError("index out of range") : a.$array[a.$offset + argNum]); - argNum = argNum + (1) >> 0; - goSyntax = (c === 118) && p.fmt.sharp; - plus = (c === 118) && p.fmt.plus; - p.printArg(arg, c, plus, goSyntax, 0); } - if (!p.reordered && argNum < a.$length) { - new ($ptrType(buffer))(function() { return this.$target.buf; }, function($v) { this.$target.buf = $v; }, p).Write(extraBytes); - while (argNum < a.$length) { - arg$1 = ((argNum < 0 || argNum >= a.$length) ? $throwRuntimeError("index out of range") : a.$array[a.$offset + argNum]); - if (!($interfaceIsEqual(arg$1, $ifaceNil))) { - new ($ptrType(buffer))(function() { return this.$target.buf; }, function($v) { this.$target.buf = $v; }, p).WriteString(reflect.TypeOf(arg$1).String()); - new ($ptrType(buffer))(function() { return this.$target.buf; }, function($v) { this.$target.buf = $v; }, p).WriteByte(61); - } - p.printArg(arg$1, 118, false, false, 0); - if ((argNum + 1 >> 0) < a.$length) { - new ($ptrType(buffer))(function() { return this.$target.buf; }, function($v) { this.$target.buf = $v; }, p).Write(commaSpaceBytes); - } - argNum = argNum + (1) >> 0; + if (f.zero && f.widPresent && f.wid > num.$length) { + if (f.space && v >= 0) { + f.buf.WriteByte(32); + f.wid = f.wid - (1) >> 0; + } else if (f.plus || v < 0) { + f.buf.WriteByte(((0 < 0 || 0 >= num.$length) ? $throwRuntimeError("index out of range") : num.$array[num.$offset + 0])); + f.wid = f.wid - (1) >> 0; } - new ($ptrType(buffer))(function() { return this.$target.buf; }, function($v) { this.$target.buf = $v; }, p).WriteByte(41); + f.pad($subslice(num, 1)); + return; } - }; - pp.prototype.doPrintf = function(format, a) { return this.$val.doPrintf(format, a); }; - pp.Ptr.prototype.doPrint = function(a, addspace, addnewline) { - var p, prevString, argNum, arg, isString; - p = this; - prevString = false; - argNum = 0; - while (argNum < a.$length) { - p.fmt.clearflags(); - arg = ((argNum < 0 || argNum >= a.$length) ? $throwRuntimeError("index out of range") : a.$array[a.$offset + argNum]); - if (argNum > 0) { - isString = !($interfaceIsEqual(arg, $ifaceNil)) && (reflect.TypeOf(arg).Kind() === 24); - if (addspace || !isString && !prevString) { - new ($ptrType(buffer))(function() { return this.$target.buf; }, function($v) { this.$target.buf = $v; }, p).WriteByte(32); - } - } - prevString = p.printArg(arg, 118, false, false, 0); - argNum = argNum + (1) >> 0; + if (f.space && (((0 < 0 || 0 >= num.$length) ? $throwRuntimeError("index out of range") : num.$array[num.$offset + 0]) === 43)) { + (0 < 0 || 0 >= num.$length) ? $throwRuntimeError("index out of range") : num.$array[num.$offset + 0] = 32; + f.pad(num); + return; } - if (addnewline) { - new ($ptrType(buffer))(function() { return this.$target.buf; }, function($v) { this.$target.buf = $v; }, p).WriteByte(10); + if (f.plus || (((0 < 0 || 0 >= num.$length) ? $throwRuntimeError("index out of range") : num.$array[num.$offset + 0]) === 45) || math.IsInf(v, 0)) { + f.pad(num); + return; } + f.pad($subslice(num, 1)); + /* */ } catch(err) { $err = err; } finally { $deferFrames.pop(); $callDeferred($deferred, $err); } }; - pp.prototype.doPrint = function(a, addspace, addnewline) { return this.$val.doPrint(a, addspace, addnewline); }; - ss.Ptr.prototype.Read = function(buf) { - var n = 0, err = $ifaceNil, s, _tmp, _tmp$1; - s = this; - _tmp = 0; _tmp$1 = errors.New("ScanState's Read should not be called. Use ReadRune"); n = _tmp; err = _tmp$1; - return [n, err]; - }; - ss.prototype.Read = function(buf) { return this.$val.Read(buf); }; - ss.Ptr.prototype.ReadRune = function() { - var r = 0, size = 0, err = $ifaceNil, s, _tuple; - s = this; - if (s.peekRune >= 0) { - s.count = s.count + (1) >> 0; - r = s.peekRune; - size = utf8.RuneLen(r); - s.prevRune = r; - s.peekRune = -1; - return [r, size, err]; - } - if (s.atEOF || s.ssave.nlIsEnd && (s.prevRune === 10) || s.count >= s.ssave.argLimit) { - err = io.EOF; - return [r, size, err]; - } - _tuple = s.rr.ReadRune(); r = _tuple[0]; size = _tuple[1]; err = _tuple[2]; - if ($interfaceIsEqual(err, $ifaceNil)) { - s.count = s.count + (1) >> 0; - s.prevRune = r; - } else if ($interfaceIsEqual(err, io.EOF)) { - s.atEOF = true; - } - return [r, size, err]; + fmt.prototype.formatFloat = function(v, verb, prec, n) { return this.$val.formatFloat(v, verb, prec, n); }; + fmt.Ptr.prototype.fmt_e64 = function(v) { + var f; + f = this; + f.formatFloat(v, 101, doPrec(f, 6), 64); }; - ss.prototype.ReadRune = function() { return this.$val.ReadRune(); }; - ss.Ptr.prototype.Width = function() { - var wid = 0, ok = false, s, _tmp, _tmp$1, _tmp$2, _tmp$3; - s = this; - if (s.ssave.maxWid === 1073741824) { - _tmp = 0; _tmp$1 = false; wid = _tmp; ok = _tmp$1; - return [wid, ok]; - } - _tmp$2 = s.ssave.maxWid; _tmp$3 = true; wid = _tmp$2; ok = _tmp$3; - return [wid, ok]; + fmt.prototype.fmt_e64 = function(v) { return this.$val.fmt_e64(v); }; + fmt.Ptr.prototype.fmt_E64 = function(v) { + var f; + f = this; + f.formatFloat(v, 69, doPrec(f, 6), 64); }; - ss.prototype.Width = function() { return this.$val.Width(); }; - ss.Ptr.prototype.getRune = function() { - var r = 0, s, _tuple, err; - s = this; - _tuple = s.ReadRune(); r = _tuple[0]; err = _tuple[2]; - if (!($interfaceIsEqual(err, $ifaceNil))) { - if ($interfaceIsEqual(err, io.EOF)) { - r = -1; - return r; - } - s.error(err); - } - return r; + fmt.prototype.fmt_E64 = function(v) { return this.$val.fmt_E64(v); }; + fmt.Ptr.prototype.fmt_f64 = function(v) { + var f; + f = this; + f.formatFloat(v, 102, doPrec(f, 6), 64); }; - ss.prototype.getRune = function() { return this.$val.getRune(); }; - ss.Ptr.prototype.UnreadRune = function() { - var s, _tuple, u, ok; - s = this; - _tuple = $assertType(s.rr, runeUnreader, true); u = _tuple[0]; ok = _tuple[1]; - if (ok) { - u.UnreadRune(); - } else { - s.peekRune = s.prevRune; - } - s.prevRune = -1; - s.count = s.count - (1) >> 0; - return $ifaceNil; + fmt.prototype.fmt_f64 = function(v) { return this.$val.fmt_f64(v); }; + fmt.Ptr.prototype.fmt_g64 = function(v) { + var f; + f = this; + f.formatFloat(v, 103, doPrec(f, -1), 64); }; - ss.prototype.UnreadRune = function() { return this.$val.UnreadRune(); }; - ss.Ptr.prototype.error = function(err) { - var s, x; - s = this; - $panic((x = new scanError.Ptr(err), new x.constructor.Struct(x))); + fmt.prototype.fmt_g64 = function(v) { return this.$val.fmt_g64(v); }; + fmt.Ptr.prototype.fmt_G64 = function(v) { + var f; + f = this; + f.formatFloat(v, 71, doPrec(f, -1), 64); }; - ss.prototype.error = function(err) { return this.$val.error(err); }; - ss.Ptr.prototype.errorString = function(err) { - var s, x; - s = this; - $panic((x = new scanError.Ptr(errors.New(err)), new x.constructor.Struct(x))); + fmt.prototype.fmt_G64 = function(v) { return this.$val.fmt_G64(v); }; + fmt.Ptr.prototype.fmt_fb64 = function(v) { + var f; + f = this; + f.formatFloat(v, 98, 0, 64); }; - ss.prototype.errorString = function(err) { return this.$val.errorString(err); }; - ss.Ptr.prototype.Token = function(skipSpace, f) { - var tok = ($sliceType($Uint8)).nil, err = $ifaceNil, $deferred = [], $err = null, s; - /* */ try { $deferFrames.push($deferred); - s = this; - $deferred.push([(function() { - var e, _tuple, se, ok; - e = $recover(); - if (!($interfaceIsEqual(e, $ifaceNil))) { - _tuple = $assertType(e, scanError, true); se = new scanError.Ptr(); $copy(se, _tuple[0], scanError); ok = _tuple[1]; - if (ok) { - err = se.err; - } else { - $panic(e); - } - } - }), []]); - if (f === $throwNilPointerError) { - f = notSpace; - } - s.buf = $subslice(s.buf, 0, 0); - tok = s.token(skipSpace, f); - return [tok, err]; - /* */ } catch(err) { $err = err; } finally { $deferFrames.pop(); $callDeferred($deferred, $err); return [tok, err]; } + fmt.prototype.fmt_fb64 = function(v) { return this.$val.fmt_fb64(v); }; + fmt.Ptr.prototype.fmt_e32 = function(v) { + var f; + f = this; + f.formatFloat($coerceFloat32(v), 101, doPrec(f, 6), 32); }; - ss.prototype.Token = function(skipSpace, f) { return this.$val.Token(skipSpace, f); }; - isSpace = function(r) { - var rx, _ref, _i, rng; - if (r >= 65536) { - return false; - } - rx = (r << 16 >>> 16); - _ref = space; - _i = 0; - while (_i < _ref.$length) { - rng = ($arrayType($Uint16, 2)).zero(); $copy(rng, ((_i < 0 || _i >= _ref.$length) ? $throwRuntimeError("index out of range") : _ref.$array[_ref.$offset + _i]), ($arrayType($Uint16, 2))); - if (rx < rng[0]) { - return false; - } - if (rx <= rng[1]) { - return true; - } - _i++; - } - return false; + fmt.prototype.fmt_e32 = function(v) { return this.$val.fmt_e32(v); }; + fmt.Ptr.prototype.fmt_E32 = function(v) { + var f; + f = this; + f.formatFloat($coerceFloat32(v), 69, doPrec(f, 6), 32); }; - notSpace = function(r) { - return !isSpace(r); + fmt.prototype.fmt_E32 = function(v) { return this.$val.fmt_E32(v); }; + fmt.Ptr.prototype.fmt_f32 = function(v) { + var f; + f = this; + f.formatFloat($coerceFloat32(v), 102, doPrec(f, 6), 32); }; - ss.Ptr.prototype.SkipSpace = function() { - var s; - s = this; - s.skipSpace(false); + fmt.prototype.fmt_f32 = function(v) { return this.$val.fmt_f32(v); }; + fmt.Ptr.prototype.fmt_g32 = function(v) { + var f; + f = this; + f.formatFloat($coerceFloat32(v), 103, doPrec(f, -1), 32); }; - ss.prototype.SkipSpace = function() { return this.$val.SkipSpace(); }; - ss.Ptr.prototype.free = function(old) { - var s; - s = this; - if (old.validSave) { - $copy(s.ssave, old, ssave); - return; - } - if (s.buf.$capacity > 1024) { - return; - } - s.buf = $subslice(s.buf, 0, 0); - s.rr = $ifaceNil; - ssFree.Put(s); + fmt.prototype.fmt_g32 = function(v) { return this.$val.fmt_g32(v); }; + fmt.Ptr.prototype.fmt_G32 = function(v) { + var f; + f = this; + f.formatFloat($coerceFloat32(v), 71, doPrec(f, -1), 32); }; - ss.prototype.free = function(old) { return this.$val.free(old); }; - ss.Ptr.prototype.skipSpace = function(stopAtNewline) { - var s, r; - s = this; + fmt.prototype.fmt_G32 = function(v) { return this.$val.fmt_G32(v); }; + fmt.Ptr.prototype.fmt_fb32 = function(v) { + var f; + f = this; + f.formatFloat($coerceFloat32(v), 98, 0, 32); + }; + fmt.prototype.fmt_fb32 = function(v) { return this.$val.fmt_fb32(v); }; + fmt.Ptr.prototype.fmt_c64 = function(v, verb) { + var f; + f = this; + f.fmt_complex($coerceFloat32(v.$real), $coerceFloat32(v.$imag), 32, verb); + }; + fmt.prototype.fmt_c64 = function(v, verb) { return this.$val.fmt_c64(v, verb); }; + fmt.Ptr.prototype.fmt_c128 = function(v, verb) { + var f; + f = this; + f.fmt_complex(v.$real, v.$imag, 64, verb); + }; + fmt.prototype.fmt_c128 = function(v, verb) { return this.$val.fmt_c128(v, verb); }; + fmt.Ptr.prototype.fmt_complex = function(r, j, size, verb) { + var f, oldPlus, oldSpace, oldWid, i, _ref; + f = this; + f.buf.WriteByte(40); + oldPlus = f.plus; + oldSpace = f.space; + oldWid = f.wid; + i = 0; while (true) { - r = s.getRune(); - if (r === -1) { - return; - } - if ((r === 13) && s.peek("\n")) { - continue; - } - if (r === 10) { - if (stopAtNewline) { - break; - } - if (s.ssave.nlIsSpace) { - continue; - } - s.errorString("unexpected newline"); - return; + _ref = verb; + if (_ref === 98) { + f.formatFloat(r, 98, 0, size); + } else if (_ref === 101) { + f.formatFloat(r, 101, doPrec(f, 6), size); + } else if (_ref === 69) { + f.formatFloat(r, 69, doPrec(f, 6), size); + } else if (_ref === 102 || _ref === 70) { + f.formatFloat(r, 102, doPrec(f, 6), size); + } else if (_ref === 103) { + f.formatFloat(r, 103, doPrec(f, -1), size); + } else if (_ref === 71) { + f.formatFloat(r, 71, doPrec(f, -1), size); } - if (!isSpace(r)) { - s.UnreadRune(); + if (!((i === 0))) { break; } + f.plus = true; + f.space = false; + f.wid = oldWid; + r = j; + i = i + (1) >> 0; } + f.space = oldSpace; + f.plus = oldPlus; + f.wid = oldWid; + f.buf.Write(irparenBytes); }; - ss.prototype.skipSpace = function(stopAtNewline) { return this.$val.skipSpace(stopAtNewline); }; - ss.Ptr.prototype.token = function(skipSpace, f) { - var s, r, x; - s = this; - if (skipSpace) { - s.skipSpace(false); + fmt.prototype.fmt_complex = function(r, j, size, verb) { return this.$val.fmt_complex(r, j, size, verb); }; + $ptrType(buffer).prototype.Write = function(p) { + var n = 0, err = $ifaceNil, b, _tmp, _tmp$1; + b = this; + b.$set($appendSlice(b.$get(), p)); + _tmp = p.$length; _tmp$1 = $ifaceNil; n = _tmp; err = _tmp$1; + return [n, err]; + }; + $ptrType(buffer).prototype.WriteString = function(s) { + var n = 0, err = $ifaceNil, b, _tmp, _tmp$1; + b = this; + b.$set($appendSlice(b.$get(), new buffer($stringToBytes(s)))); + _tmp = s.length; _tmp$1 = $ifaceNil; n = _tmp; err = _tmp$1; + return [n, err]; + }; + $ptrType(buffer).prototype.WriteByte = function(c) { + var b; + b = this; + b.$set($append(b.$get(), c)); + return $ifaceNil; + }; + $ptrType(buffer).prototype.WriteRune = function(r) { + var bp, b, n, x, w; + bp = this; + if (r < 128) { + bp.$set($append(bp.$get(), (r << 24 >>> 24))); + return $ifaceNil; } - while (true) { - r = s.getRune(); - if (r === -1) { - break; - } - if (!f(r)) { - s.UnreadRune(); - break; - } - new ($ptrType(buffer))(function() { return this.$target.buf; }, function($v) { this.$target.buf = $v; }, s).WriteRune(r); + b = bp.$get(); + n = b.$length; + while ((n + 4 >> 0) > b.$capacity) { + b = $append(b, 0); } - return (x = s.buf, $subslice(new ($sliceType($Uint8))(x.$array), x.$offset, x.$offset + x.$length)); + w = utf8.EncodeRune((x = $subslice(b, n, (n + 4 >> 0)), $subslice(new ($sliceType($Uint8))(x.$array), x.$offset, x.$offset + x.$length)), r); + bp.$set($subslice(b, 0, (n + w >> 0))); + return $ifaceNil; }; - ss.prototype.token = function(skipSpace, f) { return this.$val.token(skipSpace, f); }; - indexRune = function(s, r) { - var _ref, _i, _rune, i, c; - _ref = s; - _i = 0; - while (_i < _ref.length) { - _rune = $decodeRune(_ref, _i); - i = _i; - c = _rune[0]; - if (c === r) { - return i; - } - _i += _rune[1]; - } - return -1; + newPrinter = function() { + var p; + p = $assertType(ppFree.Get(), ($ptrType(pp))); + p.panicking = false; + p.erroring = false; + p.fmt.init(new ($ptrType(buffer))(function() { return this.$target.buf; }, function($v) { this.$target.buf = $v; }, p)); + return p; }; - ss.Ptr.prototype.peek = function(ok) { - var s, r; - s = this; - r = s.getRune(); - if (!((r === -1))) { - s.UnreadRune(); + pp.Ptr.prototype.free = function() { + var p; + p = this; + if (p.buf.$capacity > 1024) { + return; } - return indexRune(ok, r) >= 0; + p.buf = $subslice(p.buf, 0, 0); + p.arg = $ifaceNil; + $copy(p.value, new reflect.Value.Ptr(($ptrType(reflect.rtype)).nil, 0, 0, 0), reflect.Value); + ppFree.Put(p); }; - ss.prototype.peek = function(ok) { return this.$val.peek(ok); }; - $pkg.$init = function() { - ($ptrType(fmt)).methods = [["clearflags", "clearflags", "fmt", $funcType([], [], false), -1], ["computePadding", "computePadding", "fmt", $funcType([$Int], [($sliceType($Uint8)), $Int, $Int], false), -1], ["fmt_E32", "fmt_E32", "fmt", $funcType([$Float32], [], false), -1], ["fmt_E64", "fmt_E64", "fmt", $funcType([$Float64], [], false), -1], ["fmt_G32", "fmt_G32", "fmt", $funcType([$Float32], [], false), -1], ["fmt_G64", "fmt_G64", "fmt", $funcType([$Float64], [], false), -1], ["fmt_boolean", "fmt_boolean", "fmt", $funcType([$Bool], [], false), -1], ["fmt_bx", "fmt_bx", "fmt", $funcType([($sliceType($Uint8)), $String], [], false), -1], ["fmt_c128", "fmt_c128", "fmt", $funcType([$Complex128, $Int32], [], false), -1], ["fmt_c64", "fmt_c64", "fmt", $funcType([$Complex64, $Int32], [], false), -1], ["fmt_complex", "fmt_complex", "fmt", $funcType([$Float64, $Float64, $Int, $Int32], [], false), -1], ["fmt_e32", "fmt_e32", "fmt", $funcType([$Float32], [], false), -1], ["fmt_e64", "fmt_e64", "fmt", $funcType([$Float64], [], false), -1], ["fmt_f32", "fmt_f32", "fmt", $funcType([$Float32], [], false), -1], ["fmt_f64", "fmt_f64", "fmt", $funcType([$Float64], [], false), -1], ["fmt_fb32", "fmt_fb32", "fmt", $funcType([$Float32], [], false), -1], ["fmt_fb64", "fmt_fb64", "fmt", $funcType([$Float64], [], false), -1], ["fmt_g32", "fmt_g32", "fmt", $funcType([$Float32], [], false), -1], ["fmt_g64", "fmt_g64", "fmt", $funcType([$Float64], [], false), -1], ["fmt_q", "fmt_q", "fmt", $funcType([$String], [], false), -1], ["fmt_qc", "fmt_qc", "fmt", $funcType([$Int64], [], false), -1], ["fmt_s", "fmt_s", "fmt", $funcType([$String], [], false), -1], ["fmt_sbx", "fmt_sbx", "fmt", $funcType([$String, ($sliceType($Uint8)), $String], [], false), -1], ["fmt_sx", "fmt_sx", "fmt", $funcType([$String, $String], [], false), -1], ["formatFloat", "formatFloat", "fmt", $funcType([$Float64, $Uint8, $Int, $Int], [], false), -1], ["init", "init", "fmt", $funcType([($ptrType(buffer))], [], false), -1], ["integer", "integer", "fmt", $funcType([$Int64, $Uint64, $Bool, $String], [], false), -1], ["pad", "pad", "fmt", $funcType([($sliceType($Uint8))], [], false), -1], ["padString", "padString", "fmt", $funcType([$String], [], false), -1], ["truncate", "truncate", "fmt", $funcType([$String], [$String], false), -1], ["writePadding", "writePadding", "fmt", $funcType([$Int, ($sliceType($Uint8))], [], false), -1]]; - fmt.init([["intbuf", "intbuf", "fmt", ($arrayType($Uint8, 65)), ""], ["buf", "buf", "fmt", ($ptrType(buffer)), ""], ["wid", "wid", "fmt", $Int, ""], ["prec", "prec", "fmt", $Int, ""], ["widPresent", "widPresent", "fmt", $Bool, ""], ["precPresent", "precPresent", "fmt", $Bool, ""], ["minus", "minus", "fmt", $Bool, ""], ["plus", "plus", "fmt", $Bool, ""], ["sharp", "sharp", "fmt", $Bool, ""], ["space", "space", "fmt", $Bool, ""], ["unicode", "unicode", "fmt", $Bool, ""], ["uniQuote", "uniQuote", "fmt", $Bool, ""], ["zero", "zero", "fmt", $Bool, ""]]); - State.init([["Flag", "Flag", "", $funcType([$Int], [$Bool], false)], ["Precision", "Precision", "", $funcType([], [$Int, $Bool], false)], ["Width", "Width", "", $funcType([], [$Int, $Bool], false)], ["Write", "Write", "", $funcType([($sliceType($Uint8))], [$Int, $error], false)]]); - Formatter.init([["Format", "Format", "", $funcType([State, $Int32], [], false)]]); - Stringer.init([["String", "String", "", $funcType([], [$String], false)]]); - GoStringer.init([["GoString", "GoString", "", $funcType([], [$String], false)]]); - ($ptrType(buffer)).methods = [["Write", "Write", "", $funcType([($sliceType($Uint8))], [$Int, $error], false), -1], ["WriteByte", "WriteByte", "", $funcType([$Uint8], [$error], false), -1], ["WriteRune", "WriteRune", "", $funcType([$Int32], [$error], false), -1], ["WriteString", "WriteString", "", $funcType([$String], [$Int, $error], false), -1]]; - buffer.init($Uint8); - ($ptrType(pp)).methods = [["Flag", "Flag", "", $funcType([$Int], [$Bool], false), -1], ["Precision", "Precision", "", $funcType([], [$Int, $Bool], false), -1], ["Width", "Width", "", $funcType([], [$Int, $Bool], false), -1], ["Write", "Write", "", $funcType([($sliceType($Uint8))], [$Int, $error], false), -1], ["add", "add", "fmt", $funcType([$Int32], [], false), -1], ["argNumber", "argNumber", "fmt", $funcType([$Int, $String, $Int, $Int], [$Int, $Int, $Bool], false), -1], ["badVerb", "badVerb", "fmt", $funcType([$Int32], [], false), -1], ["catchPanic", "catchPanic", "fmt", $funcType([$emptyInterface, $Int32], [], false), -1], ["doPrint", "doPrint", "fmt", $funcType([($sliceType($emptyInterface)), $Bool, $Bool], [], false), -1], ["doPrintf", "doPrintf", "fmt", $funcType([$String, ($sliceType($emptyInterface))], [], false), -1], ["fmt0x64", "fmt0x64", "fmt", $funcType([$Uint64, $Bool], [], false), -1], ["fmtBool", "fmtBool", "fmt", $funcType([$Bool, $Int32], [], false), -1], ["fmtBytes", "fmtBytes", "fmt", $funcType([($sliceType($Uint8)), $Int32, $Bool, reflect.Type, $Int], [], false), -1], ["fmtC", "fmtC", "fmt", $funcType([$Int64], [], false), -1], ["fmtComplex128", "fmtComplex128", "fmt", $funcType([$Complex128, $Int32], [], false), -1], ["fmtComplex64", "fmtComplex64", "fmt", $funcType([$Complex64, $Int32], [], false), -1], ["fmtFloat32", "fmtFloat32", "fmt", $funcType([$Float32, $Int32], [], false), -1], ["fmtFloat64", "fmtFloat64", "fmt", $funcType([$Float64, $Int32], [], false), -1], ["fmtInt64", "fmtInt64", "fmt", $funcType([$Int64, $Int32], [], false), -1], ["fmtPointer", "fmtPointer", "fmt", $funcType([reflect.Value, $Int32, $Bool], [], false), -1], ["fmtString", "fmtString", "fmt", $funcType([$String, $Int32, $Bool], [], false), -1], ["fmtUint64", "fmtUint64", "fmt", $funcType([$Uint64, $Int32, $Bool], [], false), -1], ["fmtUnicode", "fmtUnicode", "fmt", $funcType([$Int64], [], false), -1], ["free", "free", "fmt", $funcType([], [], false), -1], ["handleMethods", "handleMethods", "fmt", $funcType([$Int32, $Bool, $Bool, $Int], [$Bool, $Bool], false), -1], ["printArg", "printArg", "fmt", $funcType([$emptyInterface, $Int32, $Bool, $Bool, $Int], [$Bool], false), -1], ["printReflectValue", "printReflectValue", "fmt", $funcType([reflect.Value, $Int32, $Bool, $Bool, $Int], [$Bool], false), -1], ["printValue", "printValue", "fmt", $funcType([reflect.Value, $Int32, $Bool, $Bool, $Int], [$Bool], false), -1], ["unknownType", "unknownType", "fmt", $funcType([$emptyInterface], [], false), -1]]; - pp.init([["n", "n", "fmt", $Int, ""], ["panicking", "panicking", "fmt", $Bool, ""], ["erroring", "erroring", "fmt", $Bool, ""], ["buf", "buf", "fmt", buffer, ""], ["arg", "arg", "fmt", $emptyInterface, ""], ["value", "value", "fmt", reflect.Value, ""], ["reordered", "reordered", "fmt", $Bool, ""], ["goodArgNum", "goodArgNum", "fmt", $Bool, ""], ["runeBuf", "runeBuf", "fmt", ($arrayType($Uint8, 4)), ""], ["fmt", "fmt", "fmt", fmt, ""]]); - runeUnreader.init([["UnreadRune", "UnreadRune", "", $funcType([], [$error], false)]]); - ScanState.init([["Read", "Read", "", $funcType([($sliceType($Uint8))], [$Int, $error], false)], ["ReadRune", "ReadRune", "", $funcType([], [$Int32, $Int, $error], false)], ["SkipSpace", "SkipSpace", "", $funcType([], [], false)], ["Token", "Token", "", $funcType([$Bool, ($funcType([$Int32], [$Bool], false))], [($sliceType($Uint8)), $error], false)], ["UnreadRune", "UnreadRune", "", $funcType([], [$error], false)], ["Width", "Width", "", $funcType([], [$Int, $Bool], false)]]); - scanError.init([["err", "err", "fmt", $error, ""]]); - ($ptrType(ss)).methods = [["Read", "Read", "", $funcType([($sliceType($Uint8))], [$Int, $error], false), -1], ["ReadRune", "ReadRune", "", $funcType([], [$Int32, $Int, $error], false), -1], ["SkipSpace", "SkipSpace", "", $funcType([], [], false), -1], ["Token", "Token", "", $funcType([$Bool, ($funcType([$Int32], [$Bool], false))], [($sliceType($Uint8)), $error], false), -1], ["UnreadRune", "UnreadRune", "", $funcType([], [$error], false), -1], ["Width", "Width", "", $funcType([], [$Int, $Bool], false), -1], ["accept", "accept", "fmt", $funcType([$String], [$Bool], false), -1], ["advance", "advance", "fmt", $funcType([$String], [$Int], false), -1], ["complexTokens", "complexTokens", "fmt", $funcType([], [$String, $String], false), -1], ["consume", "consume", "fmt", $funcType([$String, $Bool], [$Bool], false), -1], ["convertFloat", "convertFloat", "fmt", $funcType([$String, $Int], [$Float64], false), -1], ["convertString", "convertString", "fmt", $funcType([$Int32], [$String], false), -1], ["doScan", "doScan", "fmt", $funcType([($sliceType($emptyInterface))], [$Int, $error], false), -1], ["doScanf", "doScanf", "fmt", $funcType([$String, ($sliceType($emptyInterface))], [$Int, $error], false), -1], ["error", "error", "fmt", $funcType([$error], [], false), -1], ["errorString", "errorString", "fmt", $funcType([$String], [], false), -1], ["floatToken", "floatToken", "fmt", $funcType([], [$String], false), -1], ["free", "free", "fmt", $funcType([ssave], [], false), -1], ["getBase", "getBase", "fmt", $funcType([$Int32], [$Int, $String], false), -1], ["getRune", "getRune", "fmt", $funcType([], [$Int32], false), -1], ["hexByte", "hexByte", "fmt", $funcType([], [$Uint8, $Bool], false), -1], ["hexDigit", "hexDigit", "fmt", $funcType([$Int32], [$Int], false), -1], ["hexString", "hexString", "fmt", $funcType([], [$String], false), -1], ["mustReadRune", "mustReadRune", "fmt", $funcType([], [$Int32], false), -1], ["notEOF", "notEOF", "fmt", $funcType([], [], false), -1], ["okVerb", "okVerb", "fmt", $funcType([$Int32, $String, $String], [$Bool], false), -1], ["peek", "peek", "fmt", $funcType([$String], [$Bool], false), -1], ["quotedString", "quotedString", "fmt", $funcType([], [$String], false), -1], ["scanBasePrefix", "scanBasePrefix", "fmt", $funcType([], [$Int, $String, $Bool], false), -1], ["scanBool", "scanBool", "fmt", $funcType([$Int32], [$Bool], false), -1], ["scanComplex", "scanComplex", "fmt", $funcType([$Int32, $Int], [$Complex128], false), -1], ["scanInt", "scanInt", "fmt", $funcType([$Int32, $Int], [$Int64], false), -1], ["scanNumber", "scanNumber", "fmt", $funcType([$String, $Bool], [$String], false), -1], ["scanOne", "scanOne", "fmt", $funcType([$Int32, $emptyInterface], [], false), -1], ["scanRune", "scanRune", "fmt", $funcType([$Int], [$Int64], false), -1], ["scanUint", "scanUint", "fmt", $funcType([$Int32, $Int], [$Uint64], false), -1], ["skipSpace", "skipSpace", "fmt", $funcType([$Bool], [], false), -1], ["token", "token", "fmt", $funcType([$Bool, ($funcType([$Int32], [$Bool], false))], [($sliceType($Uint8))], false), -1]]; - ss.init([["rr", "rr", "fmt", io.RuneReader, ""], ["buf", "buf", "fmt", buffer, ""], ["peekRune", "peekRune", "fmt", $Int32, ""], ["prevRune", "prevRune", "fmt", $Int32, ""], ["count", "count", "fmt", $Int, ""], ["atEOF", "atEOF", "fmt", $Bool, ""], ["ssave", "", "fmt", ssave, ""]]); - ssave.init([["validSave", "validSave", "fmt", $Bool, ""], ["nlIsEnd", "nlIsEnd", "fmt", $Bool, ""], ["nlIsSpace", "nlIsSpace", "fmt", $Bool, ""], ["argLimit", "argLimit", "fmt", $Int, ""], ["limit", "limit", "fmt", $Int, ""], ["maxWid", "maxWid", "fmt", $Int, ""]]); - padZeroBytes = ($sliceType($Uint8)).make(65); - padSpaceBytes = ($sliceType($Uint8)).make(65); - trueBytes = new ($sliceType($Uint8))($stringToBytes("true")); - falseBytes = new ($sliceType($Uint8))($stringToBytes("false")); - commaSpaceBytes = new ($sliceType($Uint8))($stringToBytes(", ")); - nilAngleBytes = new ($sliceType($Uint8))($stringToBytes("")); - nilParenBytes = new ($sliceType($Uint8))($stringToBytes("(nil)")); - nilBytes = new ($sliceType($Uint8))($stringToBytes("nil")); - mapBytes = new ($sliceType($Uint8))($stringToBytes("map[")); - percentBangBytes = new ($sliceType($Uint8))($stringToBytes("%!")); - missingBytes = new ($sliceType($Uint8))($stringToBytes("(MISSING)")); - badIndexBytes = new ($sliceType($Uint8))($stringToBytes("(BADINDEX)")); - panicBytes = new ($sliceType($Uint8))($stringToBytes("(PANIC=")); - extraBytes = new ($sliceType($Uint8))($stringToBytes("%!(EXTRA ")); - irparenBytes = new ($sliceType($Uint8))($stringToBytes("i)")); - bytesBytes = new ($sliceType($Uint8))($stringToBytes("[]byte{")); - badWidthBytes = new ($sliceType($Uint8))($stringToBytes("%!(BADWIDTH)")); - badPrecBytes = new ($sliceType($Uint8))($stringToBytes("%!(BADPREC)")); - noVerbBytes = new ($sliceType($Uint8))($stringToBytes("%!(NOVERB)")); - ppFree = new sync.Pool.Ptr(0, 0, ($sliceType($emptyInterface)).nil, (function() { - return new pp.Ptr(); - })); - intBits = reflect.TypeOf(new $Int(0)).Bits(); - uintptrBits = reflect.TypeOf(new $Uintptr(0)).Bits(); - space = new ($sliceType(($arrayType($Uint16, 2))))([$toNativeArray("Uint16", [9, 13]), $toNativeArray("Uint16", [32, 32]), $toNativeArray("Uint16", [133, 133]), $toNativeArray("Uint16", [160, 160]), $toNativeArray("Uint16", [5760, 5760]), $toNativeArray("Uint16", [8192, 8202]), $toNativeArray("Uint16", [8232, 8233]), $toNativeArray("Uint16", [8239, 8239]), $toNativeArray("Uint16", [8287, 8287]), $toNativeArray("Uint16", [12288, 12288])]); - ssFree = new sync.Pool.Ptr(0, 0, ($sliceType($emptyInterface)).nil, (function() { - return new ss.Ptr(); - })); - complexError = errors.New("syntax error scanning complex number"); - boolError = errors.New("syntax error scanning boolean"); - init(); + pp.prototype.free = function() { return this.$val.free(); }; + pp.Ptr.prototype.Width = function() { + var wid = 0, ok = false, p, _tmp, _tmp$1; + p = this; + _tmp = p.fmt.wid; _tmp$1 = p.fmt.widPresent; wid = _tmp; ok = _tmp$1; + return [wid, ok]; }; - return $pkg; -})(); -$packages["sort"] = (function() { - var $pkg = {}, StringSlice, Search, SearchStrings, min, insertionSort, siftDown, heapSort, medianOfThree, swapRange, doPivot, quickSort, Sort, IsSorted, Strings; - StringSlice = $pkg.StringSlice = $newType(12, "Slice", "sort.StringSlice", "StringSlice", "sort", null); - Search = $pkg.Search = function(n, f) { - var _tmp, _tmp$1, i, j, _q, h; - _tmp = 0; _tmp$1 = n; i = _tmp; j = _tmp$1; - while (i < j) { - h = i + (_q = ((j - i >> 0)) / 2, (_q === _q && _q !== 1/0 && _q !== -1/0) ? _q >> 0 : $throwRuntimeError("integer divide by zero")) >> 0; - if (!f(h)) { - i = h + 1 >> 0; - } else { - j = h; - } - } - return i; + pp.prototype.Width = function() { return this.$val.Width(); }; + pp.Ptr.prototype.Precision = function() { + var prec = 0, ok = false, p, _tmp, _tmp$1; + p = this; + _tmp = p.fmt.prec; _tmp$1 = p.fmt.precPresent; prec = _tmp; ok = _tmp$1; + return [prec, ok]; }; - SearchStrings = $pkg.SearchStrings = function(a, x) { - return Search(a.$length, (function(i) { - return ((i < 0 || i >= a.$length) ? $throwRuntimeError("index out of range") : a.$array[a.$offset + i]) >= x; - })); + pp.prototype.Precision = function() { return this.$val.Precision(); }; + pp.Ptr.prototype.Flag = function(b) { + var p, _ref; + p = this; + _ref = b; + if (_ref === 45) { + return p.fmt.minus; + } else if (_ref === 43) { + return p.fmt.plus; + } else if (_ref === 35) { + return p.fmt.sharp; + } else if (_ref === 32) { + return p.fmt.space; + } else if (_ref === 48) { + return p.fmt.zero; + } + return false; }; - StringSlice.prototype.Search = function(x) { + pp.prototype.Flag = function(b) { return this.$val.Flag(b); }; + pp.Ptr.prototype.add = function(c) { var p; p = this; - return SearchStrings($subslice(new ($sliceType($String))(p.$array), p.$offset, p.$offset + p.$length), x); + new ($ptrType(buffer))(function() { return this.$target.buf; }, function($v) { this.$target.buf = $v; }, p).WriteRune(c); }; - $ptrType(StringSlice).prototype.Search = function(x) { return this.$get().Search(x); }; - min = function(a, b) { - if (a < b) { - return a; - } - return b; + pp.prototype.add = function(c) { return this.$val.add(c); }; + pp.Ptr.prototype.Write = function(b) { + var ret = 0, err = $ifaceNil, p, _tuple; + p = this; + _tuple = new ($ptrType(buffer))(function() { return this.$target.buf; }, function($v) { this.$target.buf = $v; }, p).Write(b); ret = _tuple[0]; err = _tuple[1]; + return [ret, err]; }; - insertionSort = function(data, a, b) { - var i, j; - i = a + 1 >> 0; - while (i < b) { - j = i; - while (j > a && data.Less(j, j - 1 >> 0)) { - data.Swap(j, j - 1 >> 0); - j = j - (1) >> 0; - } - i = i + (1) >> 0; - } + pp.prototype.Write = function(b) { return this.$val.Write(b); }; + Fprintf = $pkg.Fprintf = function(w, format, a) { + var n = 0, err = $ifaceNil, p, _tuple, x; + p = newPrinter(); + p.doPrintf(format, a); + _tuple = w.Write((x = p.buf, $subslice(new ($sliceType($Uint8))(x.$array), x.$offset, x.$offset + x.$length))); n = _tuple[0]; err = _tuple[1]; + p.free(); + return [n, err]; }; - siftDown = function(data, lo, hi, first) { - var root, child; - root = lo; - while (true) { - child = ((((2 >>> 16 << 16) * root >> 0) + (2 << 16 >>> 16) * root) >> 0) + 1 >> 0; - if (child >= hi) { - break; - } - if ((child + 1 >> 0) < hi && data.Less(first + child >> 0, (first + child >> 0) + 1 >> 0)) { - child = child + (1) >> 0; - } - if (!data.Less(first + root >> 0, first + child >> 0)) { - return; - } - data.Swap(first + root >> 0, first + child >> 0); - root = child; - } + Printf = $pkg.Printf = function(format, a) { + var n = 0, err = $ifaceNil, _tuple; + _tuple = Fprintf(os.Stdout, format, a); n = _tuple[0]; err = _tuple[1]; + return [n, err]; }; - heapSort = function(data, a, b) { - var first, lo, hi, _q, i, i$1; - first = a; - lo = 0; - hi = b - a >> 0; - i = (_q = ((hi - 1 >> 0)) / 2, (_q === _q && _q !== 1/0 && _q !== -1/0) ? _q >> 0 : $throwRuntimeError("integer divide by zero")); - while (i >= 0) { - siftDown(data, i, hi, first); - i = i - (1) >> 0; - } - i$1 = hi - 1 >> 0; - while (i$1 >= 0) { - data.Swap(first, first + i$1 >> 0); - siftDown(data, lo, i$1, first); - i$1 = i$1 - (1) >> 0; - } + Sprintf = $pkg.Sprintf = function(format, a) { + var p, s; + p = newPrinter(); + p.doPrintf(format, a); + s = $bytesToString(p.buf); + p.free(); + return s; }; - medianOfThree = function(data, a, b, c) { - var m0, m1, m2; - m0 = b; - m1 = a; - m2 = c; - if (data.Less(m1, m0)) { - data.Swap(m1, m0); + Errorf = $pkg.Errorf = function(format, a) { + return errors.New(Sprintf(format, a)); + }; + Fprint = $pkg.Fprint = function(w, a) { + var n = 0, err = $ifaceNil, p, _tuple, x; + p = newPrinter(); + p.doPrint(a, false, false); + _tuple = w.Write((x = p.buf, $subslice(new ($sliceType($Uint8))(x.$array), x.$offset, x.$offset + x.$length))); n = _tuple[0]; err = _tuple[1]; + p.free(); + return [n, err]; + }; + Print = $pkg.Print = function(a) { + var n = 0, err = $ifaceNil, _tuple; + _tuple = Fprint(os.Stdout, a); n = _tuple[0]; err = _tuple[1]; + return [n, err]; + }; + Sprint = $pkg.Sprint = function(a) { + var p, s; + p = newPrinter(); + p.doPrint(a, false, false); + s = $bytesToString(p.buf); + p.free(); + return s; + }; + Fprintln = $pkg.Fprintln = function(w, a) { + var n = 0, err = $ifaceNil, p, _tuple, x; + p = newPrinter(); + p.doPrint(a, true, true); + _tuple = w.Write((x = p.buf, $subslice(new ($sliceType($Uint8))(x.$array), x.$offset, x.$offset + x.$length))); n = _tuple[0]; err = _tuple[1]; + p.free(); + return [n, err]; + }; + Println = $pkg.Println = function(a) { + var n = 0, err = $ifaceNil, _tuple; + _tuple = Fprintln(os.Stdout, a); n = _tuple[0]; err = _tuple[1]; + return [n, err]; + }; + Sprintln = $pkg.Sprintln = function(a) { + var p, s; + p = newPrinter(); + p.doPrint(a, true, true); + s = $bytesToString(p.buf); + p.free(); + return s; + }; + getField = function(v, i) { + var val; + val = new reflect.Value.Ptr(); $copy(val, v.Field(i), reflect.Value); + if ((val.Kind() === 20) && !val.IsNil()) { + $copy(val, val.Elem(), reflect.Value); } - if (data.Less(m2, m1)) { - data.Swap(m2, m1); + return val; + }; + parsenum = function(s, start, end) { + var num = 0, isnum = false, newi = 0, _tmp, _tmp$1, _tmp$2; + if (start >= end) { + _tmp = 0; _tmp$1 = false; _tmp$2 = end; num = _tmp; isnum = _tmp$1; newi = _tmp$2; + return [num, isnum, newi]; } - if (data.Less(m1, m0)) { - data.Swap(m1, m0); + newi = start; + while (newi < end && 48 <= s.charCodeAt(newi) && s.charCodeAt(newi) <= 57) { + num = ((((num >>> 16 << 16) * 10 >> 0) + (num << 16 >>> 16) * 10) >> 0) + ((s.charCodeAt(newi) - 48 << 24 >>> 24) >> 0) >> 0; + isnum = true; + newi = newi + (1) >> 0; } + return [num, isnum, newi]; }; - swapRange = function(data, a, b, n) { - var i; - i = 0; - while (i < n) { - data.Swap(a + i >> 0, b + i >> 0); - i = i + (1) >> 0; + pp.Ptr.prototype.unknownType = function(v) { + var p; + p = this; + if ($interfaceIsEqual(v, $ifaceNil)) { + new ($ptrType(buffer))(function() { return this.$target.buf; }, function($v) { this.$target.buf = $v; }, p).Write(nilAngleBytes); + return; } + new ($ptrType(buffer))(function() { return this.$target.buf; }, function($v) { this.$target.buf = $v; }, p).WriteByte(63); + new ($ptrType(buffer))(function() { return this.$target.buf; }, function($v) { this.$target.buf = $v; }, p).WriteString(reflect.TypeOf(v).String()); + new ($ptrType(buffer))(function() { return this.$target.buf; }, function($v) { this.$target.buf = $v; }, p).WriteByte(63); }; - doPivot = function(data, lo, hi) { - var midlo = 0, midhi = 0, _q, m, _q$1, s, pivot, _tmp, _tmp$1, _tmp$2, _tmp$3, a, b, c, d, n, _tmp$4, _tmp$5; - m = lo + (_q = ((hi - lo >> 0)) / 2, (_q === _q && _q !== 1/0 && _q !== -1/0) ? _q >> 0 : $throwRuntimeError("integer divide by zero")) >> 0; - if ((hi - lo >> 0) > 40) { - s = (_q$1 = ((hi - lo >> 0)) / 8, (_q$1 === _q$1 && _q$1 !== 1/0 && _q$1 !== -1/0) ? _q$1 >> 0 : $throwRuntimeError("integer divide by zero")); - medianOfThree(data, lo, lo + s >> 0, lo + ((((2 >>> 16 << 16) * s >> 0) + (2 << 16 >>> 16) * s) >> 0) >> 0); - medianOfThree(data, m, m - s >> 0, m + s >> 0); - medianOfThree(data, hi - 1 >> 0, (hi - 1 >> 0) - s >> 0, (hi - 1 >> 0) - ((((2 >>> 16 << 16) * s >> 0) + (2 << 16 >>> 16) * s) >> 0) >> 0); - } - medianOfThree(data, lo, m, hi - 1 >> 0); - pivot = lo; - _tmp = lo + 1 >> 0; _tmp$1 = lo + 1 >> 0; _tmp$2 = hi; _tmp$3 = hi; a = _tmp; b = _tmp$1; c = _tmp$2; d = _tmp$3; - while (true) { - while (b < c) { - if (data.Less(b, pivot)) { - b = b + (1) >> 0; - } else if (!data.Less(pivot, b)) { - data.Swap(a, b); - a = a + (1) >> 0; - b = b + (1) >> 0; - } else { - break; - } - } - while (b < c) { - if (data.Less(pivot, c - 1 >> 0)) { - c = c - (1) >> 0; - } else if (!data.Less(c - 1 >> 0, pivot)) { - data.Swap(c - 1 >> 0, d - 1 >> 0); - c = c - (1) >> 0; - d = d - (1) >> 0; - } else { - break; - } - } - if (b >= c) { - break; - } - data.Swap(b, c - 1 >> 0); - b = b + (1) >> 0; - c = c - (1) >> 0; + pp.prototype.unknownType = function(v) { return this.$val.unknownType(v); }; + pp.Ptr.prototype.badVerb = function(verb) { + var p; + p = this; + p.erroring = true; + p.add(37); + p.add(33); + p.add(verb); + p.add(40); + if (!($interfaceIsEqual(p.arg, $ifaceNil))) { + new ($ptrType(buffer))(function() { return this.$target.buf; }, function($v) { this.$target.buf = $v; }, p).WriteString(reflect.TypeOf(p.arg).String()); + p.add(61); + p.printArg(p.arg, 118, false, false, 0); + } else if (p.value.IsValid()) { + new ($ptrType(buffer))(function() { return this.$target.buf; }, function($v) { this.$target.buf = $v; }, p).WriteString(p.value.Type().String()); + p.add(61); + p.printValue($clone(p.value, reflect.Value), 118, false, false, 0); + } else { + new ($ptrType(buffer))(function() { return this.$target.buf; }, function($v) { this.$target.buf = $v; }, p).Write(nilAngleBytes); } - n = min(b - a >> 0, a - lo >> 0); - swapRange(data, lo, b - n >> 0, n); - n = min(hi - d >> 0, d - c >> 0); - swapRange(data, c, hi - n >> 0, n); - _tmp$4 = (lo + b >> 0) - a >> 0; _tmp$5 = hi - ((d - c >> 0)) >> 0; midlo = _tmp$4; midhi = _tmp$5; - return [midlo, midhi]; + p.add(41); + p.erroring = false; }; - quickSort = function(data, a, b, maxDepth) { - var _tuple, mlo, mhi; - while ((b - a >> 0) > 7) { - if (maxDepth === 0) { - heapSort(data, a, b); - return; - } - maxDepth = maxDepth - (1) >> 0; - _tuple = doPivot(data, a, b); mlo = _tuple[0]; mhi = _tuple[1]; - if ((mlo - a >> 0) < (b - mhi >> 0)) { - quickSort(data, a, mlo, maxDepth); - a = mhi; - } else { - quickSort(data, mhi, b, maxDepth); - b = mlo; - } - } - if ((b - a >> 0) > 1) { - insertionSort(data, a, b); + pp.prototype.badVerb = function(verb) { return this.$val.badVerb(verb); }; + pp.Ptr.prototype.fmtBool = function(v, verb) { + var p, _ref; + p = this; + _ref = verb; + if (_ref === 116 || _ref === 118) { + p.fmt.fmt_boolean(v); + } else { + p.badVerb(verb); } }; - Sort = $pkg.Sort = function(data) { - var n, maxDepth, i, x; - n = data.Len(); - maxDepth = 0; - i = n; - while (i > 0) { - maxDepth = maxDepth + (1) >> 0; - i = (i >> $min((1), 31)) >> 0; + pp.prototype.fmtBool = function(v, verb) { return this.$val.fmtBool(v, verb); }; + pp.Ptr.prototype.fmtC = function(c) { + var p, r, x, w; + p = this; + r = ((c.$low + ((c.$high >> 31) * 4294967296)) >> 0); + if (!((x = new $Int64(0, r), (x.$high === c.$high && x.$low === c.$low)))) { + r = 65533; } - maxDepth = (x = 2, (((maxDepth >>> 16 << 16) * x >> 0) + (maxDepth << 16 >>> 16) * x) >> 0); - quickSort(data, 0, n, maxDepth); + w = utf8.EncodeRune($subslice(new ($sliceType($Uint8))(p.runeBuf), 0, 4), r); + p.fmt.pad($subslice(new ($sliceType($Uint8))(p.runeBuf), 0, w)); }; - IsSorted = $pkg.IsSorted = function(data) { - var n, i; - n = data.Len(); - i = n - 1 >> 0; - while (i > 0) { - if (data.Less(i, i - 1 >> 0)) { - return false; + pp.prototype.fmtC = function(c) { return this.$val.fmtC(c); }; + pp.Ptr.prototype.fmtInt64 = function(v, verb) { + var p, _ref; + p = this; + _ref = verb; + if (_ref === 98) { + p.fmt.integer(v, new $Uint64(0, 2), true, "0123456789abcdef"); + } else if (_ref === 99) { + p.fmtC(v); + } else if (_ref === 100 || _ref === 118) { + p.fmt.integer(v, new $Uint64(0, 10), true, "0123456789abcdef"); + } else if (_ref === 111) { + p.fmt.integer(v, new $Uint64(0, 8), true, "0123456789abcdef"); + } else if (_ref === 113) { + if ((0 < v.$high || (0 === v.$high && 0 <= v.$low)) && (v.$high < 0 || (v.$high === 0 && v.$low <= 1114111))) { + p.fmt.fmt_qc(v); + } else { + p.badVerb(verb); } - i = i - (1) >> 0; + } else if (_ref === 120) { + p.fmt.integer(v, new $Uint64(0, 16), true, "0123456789abcdef"); + } else if (_ref === 85) { + p.fmtUnicode(v); + } else if (_ref === 88) { + p.fmt.integer(v, new $Uint64(0, 16), true, "0123456789ABCDEF"); + } else { + p.badVerb(verb); } - return true; }; - StringSlice.prototype.Len = function() { - var p; + pp.prototype.fmtInt64 = function(v, verb) { return this.$val.fmtInt64(v, verb); }; + pp.Ptr.prototype.fmt0x64 = function(v, leading0x) { + var p, sharp; p = this; - return p.$length; + sharp = p.fmt.sharp; + p.fmt.sharp = leading0x; + p.fmt.integer(new $Int64(v.$high, v.$low), new $Uint64(0, 16), false, "0123456789abcdef"); + p.fmt.sharp = sharp; }; - $ptrType(StringSlice).prototype.Len = function() { return this.$get().Len(); }; - StringSlice.prototype.Less = function(i, j) { - var p; + pp.prototype.fmt0x64 = function(v, leading0x) { return this.$val.fmt0x64(v, leading0x); }; + pp.Ptr.prototype.fmtUnicode = function(v) { + var p, precPresent, sharp, prec; p = this; - return ((i < 0 || i >= p.$length) ? $throwRuntimeError("index out of range") : p.$array[p.$offset + i]) < ((j < 0 || j >= p.$length) ? $throwRuntimeError("index out of range") : p.$array[p.$offset + j]); + precPresent = p.fmt.precPresent; + sharp = p.fmt.sharp; + p.fmt.sharp = false; + prec = p.fmt.prec; + if (!precPresent) { + p.fmt.prec = 4; + p.fmt.precPresent = true; + } + p.fmt.unicode = true; + p.fmt.uniQuote = sharp; + p.fmt.integer(v, new $Uint64(0, 16), false, "0123456789ABCDEF"); + p.fmt.unicode = false; + p.fmt.uniQuote = false; + p.fmt.prec = prec; + p.fmt.precPresent = precPresent; + p.fmt.sharp = sharp; }; - $ptrType(StringSlice).prototype.Less = function(i, j) { return this.$get().Less(i, j); }; - StringSlice.prototype.Swap = function(i, j) { - var p, _tmp, _tmp$1; + pp.prototype.fmtUnicode = function(v) { return this.$val.fmtUnicode(v); }; + pp.Ptr.prototype.fmtUint64 = function(v, verb, goSyntax) { + var p, _ref; p = this; - _tmp = ((j < 0 || j >= p.$length) ? $throwRuntimeError("index out of range") : p.$array[p.$offset + j]); _tmp$1 = ((i < 0 || i >= p.$length) ? $throwRuntimeError("index out of range") : p.$array[p.$offset + i]); (i < 0 || i >= p.$length) ? $throwRuntimeError("index out of range") : p.$array[p.$offset + i] = _tmp; (j < 0 || j >= p.$length) ? $throwRuntimeError("index out of range") : p.$array[p.$offset + j] = _tmp$1; + _ref = verb; + if (_ref === 98) { + p.fmt.integer(new $Int64(v.$high, v.$low), new $Uint64(0, 2), false, "0123456789abcdef"); + } else if (_ref === 99) { + p.fmtC(new $Int64(v.$high, v.$low)); + } else if (_ref === 100) { + p.fmt.integer(new $Int64(v.$high, v.$low), new $Uint64(0, 10), false, "0123456789abcdef"); + } else if (_ref === 118) { + if (goSyntax) { + p.fmt0x64(v, true); + } else { + p.fmt.integer(new $Int64(v.$high, v.$low), new $Uint64(0, 10), false, "0123456789abcdef"); + } + } else if (_ref === 111) { + p.fmt.integer(new $Int64(v.$high, v.$low), new $Uint64(0, 8), false, "0123456789abcdef"); + } else if (_ref === 113) { + if ((0 < v.$high || (0 === v.$high && 0 <= v.$low)) && (v.$high < 0 || (v.$high === 0 && v.$low <= 1114111))) { + p.fmt.fmt_qc(new $Int64(v.$high, v.$low)); + } else { + p.badVerb(verb); + } + } else if (_ref === 120) { + p.fmt.integer(new $Int64(v.$high, v.$low), new $Uint64(0, 16), false, "0123456789abcdef"); + } else if (_ref === 88) { + p.fmt.integer(new $Int64(v.$high, v.$low), new $Uint64(0, 16), false, "0123456789ABCDEF"); + } else if (_ref === 85) { + p.fmtUnicode(new $Int64(v.$high, v.$low)); + } else { + p.badVerb(verb); + } }; - $ptrType(StringSlice).prototype.Swap = function(i, j) { return this.$get().Swap(i, j); }; - StringSlice.prototype.Sort = function() { - var p; + pp.prototype.fmtUint64 = function(v, verb, goSyntax) { return this.$val.fmtUint64(v, verb, goSyntax); }; + pp.Ptr.prototype.fmtFloat32 = function(v, verb) { + var p, _ref; p = this; - Sort(p); - }; - $ptrType(StringSlice).prototype.Sort = function() { return this.$get().Sort(); }; - Strings = $pkg.Strings = function(a) { - Sort($subslice(new StringSlice(a.$array), a.$offset, a.$offset + a.$length)); + _ref = verb; + if (_ref === 98) { + p.fmt.fmt_fb32(v); + } else if (_ref === 101) { + p.fmt.fmt_e32(v); + } else if (_ref === 69) { + p.fmt.fmt_E32(v); + } else if (_ref === 102 || _ref === 70) { + p.fmt.fmt_f32(v); + } else if (_ref === 103 || _ref === 118) { + p.fmt.fmt_g32(v); + } else if (_ref === 71) { + p.fmt.fmt_G32(v); + } else { + p.badVerb(verb); + } }; - $pkg.$init = function() { - StringSlice.methods = [["Len", "Len", "", $funcType([], [$Int], false), -1], ["Less", "Less", "", $funcType([$Int, $Int], [$Bool], false), -1], ["Search", "Search", "", $funcType([$String], [$Int], false), -1], ["Sort", "Sort", "", $funcType([], [], false), -1], ["Swap", "Swap", "", $funcType([$Int, $Int], [], false), -1]]; - ($ptrType(StringSlice)).methods = [["Len", "Len", "", $funcType([], [$Int], false), -1], ["Less", "Less", "", $funcType([$Int, $Int], [$Bool], false), -1], ["Search", "Search", "", $funcType([$String], [$Int], false), -1], ["Sort", "Sort", "", $funcType([], [], false), -1], ["Swap", "Swap", "", $funcType([$Int, $Int], [], false), -1]]; - StringSlice.init($String); + pp.prototype.fmtFloat32 = function(v, verb) { return this.$val.fmtFloat32(v, verb); }; + pp.Ptr.prototype.fmtFloat64 = function(v, verb) { + var p, _ref; + p = this; + _ref = verb; + if (_ref === 98) { + p.fmt.fmt_fb64(v); + } else if (_ref === 101) { + p.fmt.fmt_e64(v); + } else if (_ref === 69) { + p.fmt.fmt_E64(v); + } else if (_ref === 102 || _ref === 70) { + p.fmt.fmt_f64(v); + } else if (_ref === 103 || _ref === 118) { + p.fmt.fmt_g64(v); + } else if (_ref === 71) { + p.fmt.fmt_G64(v); + } else { + p.badVerb(verb); + } }; - return $pkg; -})(); -$packages["flag"] = (function() { - var $pkg = {}, errors = $packages["errors"], fmt = $packages["fmt"], io = $packages["io"], os = $packages["os"], sort = $packages["sort"], strconv = $packages["strconv"], time = $packages["time"], boolValue, boolFlag, intValue, int64Value, uintValue, uint64Value, stringValue, float64Value, durationValue, Value, ErrorHandling, FlagSet, Flag, x, newBoolValue, newIntValue, newInt64Value, newUintValue, newUint64Value, newStringValue, newFloat64Value, newDurationValue, sortFlags, PrintDefaults, defaultUsage, Bool, Int, String, Duration, Parse, NewFlagSet; - boolValue = $pkg.boolValue = $newType(1, "Bool", "flag.boolValue", "boolValue", "flag", null); - boolFlag = $pkg.boolFlag = $newType(8, "Interface", "flag.boolFlag", "boolFlag", "flag", null); - intValue = $pkg.intValue = $newType(4, "Int", "flag.intValue", "intValue", "flag", null); - int64Value = $pkg.int64Value = $newType(8, "Int64", "flag.int64Value", "int64Value", "flag", null); - uintValue = $pkg.uintValue = $newType(4, "Uint", "flag.uintValue", "uintValue", "flag", null); - uint64Value = $pkg.uint64Value = $newType(8, "Uint64", "flag.uint64Value", "uint64Value", "flag", null); - stringValue = $pkg.stringValue = $newType(8, "String", "flag.stringValue", "stringValue", "flag", null); - float64Value = $pkg.float64Value = $newType(8, "Float64", "flag.float64Value", "float64Value", "flag", null); - durationValue = $pkg.durationValue = $newType(8, "Int64", "flag.durationValue", "durationValue", "flag", null); - Value = $pkg.Value = $newType(8, "Interface", "flag.Value", "Value", "flag", null); - ErrorHandling = $pkg.ErrorHandling = $newType(4, "Int", "flag.ErrorHandling", "ErrorHandling", "flag", null); - FlagSet = $pkg.FlagSet = $newType(0, "Struct", "flag.FlagSet", "FlagSet", "flag", function(Usage_, name_, parsed_, actual_, formal_, args_, errorHandling_, output_) { - this.$val = this; - this.Usage = Usage_ !== undefined ? Usage_ : $throwNilPointerError; - this.name = name_ !== undefined ? name_ : ""; - this.parsed = parsed_ !== undefined ? parsed_ : false; - this.actual = actual_ !== undefined ? actual_ : false; - this.formal = formal_ !== undefined ? formal_ : false; - this.args = args_ !== undefined ? args_ : ($sliceType($String)).nil; - this.errorHandling = errorHandling_ !== undefined ? errorHandling_ : 0; - this.output = output_ !== undefined ? output_ : $ifaceNil; - }); - Flag = $pkg.Flag = $newType(0, "Struct", "flag.Flag", "Flag", "flag", function(Name_, Usage_, Value_, DefValue_) { - this.$val = this; - this.Name = Name_ !== undefined ? Name_ : ""; - this.Usage = Usage_ !== undefined ? Usage_ : ""; - this.Value = Value_ !== undefined ? Value_ : $ifaceNil; - this.DefValue = DefValue_ !== undefined ? DefValue_ : ""; - }); - newBoolValue = function(val, p) { - p.$set(val); - return new ($ptrType(boolValue))(p.$get, p.$set); + pp.prototype.fmtFloat64 = function(v, verb) { return this.$val.fmtFloat64(v, verb); }; + pp.Ptr.prototype.fmtComplex64 = function(v, verb) { + var p, _ref; + p = this; + _ref = verb; + if (_ref === 98 || _ref === 101 || _ref === 69 || _ref === 102 || _ref === 70 || _ref === 103 || _ref === 71) { + p.fmt.fmt_c64(v, verb); + } else if (_ref === 118) { + p.fmt.fmt_c64(v, 103); + } else { + p.badVerb(verb); + } }; - $ptrType(boolValue).prototype.Set = function(s) { - var b, _tuple, v, err; - b = this; - _tuple = strconv.ParseBool(s); v = _tuple[0]; err = _tuple[1]; - b.$set(v); - return err; + pp.prototype.fmtComplex64 = function(v, verb) { return this.$val.fmtComplex64(v, verb); }; + pp.Ptr.prototype.fmtComplex128 = function(v, verb) { + var p, _ref; + p = this; + _ref = verb; + if (_ref === 98 || _ref === 101 || _ref === 69 || _ref === 102 || _ref === 70 || _ref === 103 || _ref === 71) { + p.fmt.fmt_c128(v, verb); + } else if (_ref === 118) { + p.fmt.fmt_c128(v, 103); + } else { + p.badVerb(verb); + } }; - $ptrType(boolValue).prototype.Get = function() { - var b; - b = this; - return new $Bool(b.$get()); + pp.prototype.fmtComplex128 = function(v, verb) { return this.$val.fmtComplex128(v, verb); }; + pp.Ptr.prototype.fmtString = function(v, verb, goSyntax) { + var p, _ref; + p = this; + _ref = verb; + if (_ref === 118) { + if (goSyntax) { + p.fmt.fmt_q(v); + } else { + p.fmt.fmt_s(v); + } + } else if (_ref === 115) { + p.fmt.fmt_s(v); + } else if (_ref === 120) { + p.fmt.fmt_sx(v, "0123456789abcdef"); + } else if (_ref === 88) { + p.fmt.fmt_sx(v, "0123456789ABCDEF"); + } else if (_ref === 113) { + p.fmt.fmt_q(v); + } else { + p.badVerb(verb); + } }; - $ptrType(boolValue).prototype.String = function() { - var b; - b = this; - return fmt.Sprintf("%v", new ($sliceType($emptyInterface))([new boolValue(b.$get())])); + pp.prototype.fmtString = function(v, verb, goSyntax) { return this.$val.fmtString(v, verb, goSyntax); }; + pp.Ptr.prototype.fmtBytes = function(v, verb, goSyntax, typ, depth) { + var p, _ref, _i, i, c, _ref$1; + p = this; + if ((verb === 118) || (verb === 100)) { + if (goSyntax) { + if (v === ($sliceType($Uint8)).nil) { + if ($interfaceIsEqual(typ, $ifaceNil)) { + new ($ptrType(buffer))(function() { return this.$target.buf; }, function($v) { this.$target.buf = $v; }, p).WriteString("[]byte(nil)"); + } else { + new ($ptrType(buffer))(function() { return this.$target.buf; }, function($v) { this.$target.buf = $v; }, p).WriteString(typ.String()); + new ($ptrType(buffer))(function() { return this.$target.buf; }, function($v) { this.$target.buf = $v; }, p).Write(nilParenBytes); + } + return; + } + if ($interfaceIsEqual(typ, $ifaceNil)) { + new ($ptrType(buffer))(function() { return this.$target.buf; }, function($v) { this.$target.buf = $v; }, p).Write(bytesBytes); + } else { + new ($ptrType(buffer))(function() { return this.$target.buf; }, function($v) { this.$target.buf = $v; }, p).WriteString(typ.String()); + new ($ptrType(buffer))(function() { return this.$target.buf; }, function($v) { this.$target.buf = $v; }, p).WriteByte(123); + } + } else { + new ($ptrType(buffer))(function() { return this.$target.buf; }, function($v) { this.$target.buf = $v; }, p).WriteByte(91); + } + _ref = v; + _i = 0; + while (_i < _ref.$length) { + i = _i; + c = ((_i < 0 || _i >= _ref.$length) ? $throwRuntimeError("index out of range") : _ref.$array[_ref.$offset + _i]); + if (i > 0) { + if (goSyntax) { + new ($ptrType(buffer))(function() { return this.$target.buf; }, function($v) { this.$target.buf = $v; }, p).Write(commaSpaceBytes); + } else { + new ($ptrType(buffer))(function() { return this.$target.buf; }, function($v) { this.$target.buf = $v; }, p).WriteByte(32); + } + } + p.printArg(new $Uint8(c), 118, p.fmt.plus, goSyntax, depth + 1 >> 0); + _i++; + } + if (goSyntax) { + new ($ptrType(buffer))(function() { return this.$target.buf; }, function($v) { this.$target.buf = $v; }, p).WriteByte(125); + } else { + new ($ptrType(buffer))(function() { return this.$target.buf; }, function($v) { this.$target.buf = $v; }, p).WriteByte(93); + } + return; + } + _ref$1 = verb; + if (_ref$1 === 115) { + p.fmt.fmt_s($bytesToString(v)); + } else if (_ref$1 === 120) { + p.fmt.fmt_bx(v, "0123456789abcdef"); + } else if (_ref$1 === 88) { + p.fmt.fmt_bx(v, "0123456789ABCDEF"); + } else if (_ref$1 === 113) { + p.fmt.fmt_q($bytesToString(v)); + } else { + p.badVerb(verb); + } }; - $ptrType(boolValue).prototype.IsBoolFlag = function() { - var b; - b = this; - return true; + pp.prototype.fmtBytes = function(v, verb, goSyntax, typ, depth) { return this.$val.fmtBytes(v, verb, goSyntax, typ, depth); }; + pp.Ptr.prototype.fmtPointer = function(value, verb, goSyntax) { + var p, use0x64, _ref, u, _ref$1; + p = this; + use0x64 = true; + _ref = verb; + if (_ref === 112 || _ref === 118) { + } else if (_ref === 98 || _ref === 100 || _ref === 111 || _ref === 120 || _ref === 88) { + use0x64 = false; + } else { + p.badVerb(verb); + return; + } + u = 0; + _ref$1 = value.Kind(); + if (_ref$1 === 18 || _ref$1 === 19 || _ref$1 === 21 || _ref$1 === 22 || _ref$1 === 23 || _ref$1 === 26) { + u = value.Pointer(); + } else { + p.badVerb(verb); + return; + } + if (goSyntax) { + p.add(40); + new ($ptrType(buffer))(function() { return this.$target.buf; }, function($v) { this.$target.buf = $v; }, p).WriteString(value.Type().String()); + p.add(41); + p.add(40); + if (u === 0) { + new ($ptrType(buffer))(function() { return this.$target.buf; }, function($v) { this.$target.buf = $v; }, p).Write(nilBytes); + } else { + p.fmt0x64(new $Uint64(0, u.constructor === Number ? u : 1), true); + } + p.add(41); + } else if ((verb === 118) && (u === 0)) { + new ($ptrType(buffer))(function() { return this.$target.buf; }, function($v) { this.$target.buf = $v; }, p).Write(nilAngleBytes); + } else { + if (use0x64) { + p.fmt0x64(new $Uint64(0, u.constructor === Number ? u : 1), !p.fmt.sharp); + } else { + p.fmtUint64(new $Uint64(0, u.constructor === Number ? u : 1), verb, false); + } + } }; - newIntValue = function(val, p) { - p.$set(val); - return new ($ptrType(intValue))(p.$get, p.$set); + pp.prototype.fmtPointer = function(value, verb, goSyntax) { return this.$val.fmtPointer(value, verb, goSyntax); }; + pp.Ptr.prototype.catchPanic = function(arg, verb) { + var p, err, v; + p = this; + err = $recover(); + if (!($interfaceIsEqual(err, $ifaceNil))) { + v = new reflect.Value.Ptr(); $copy(v, reflect.ValueOf(arg), reflect.Value); + if ((v.Kind() === 22) && v.IsNil()) { + new ($ptrType(buffer))(function() { return this.$target.buf; }, function($v) { this.$target.buf = $v; }, p).Write(nilAngleBytes); + return; + } + if (p.panicking) { + $panic(err); + } + new ($ptrType(buffer))(function() { return this.$target.buf; }, function($v) { this.$target.buf = $v; }, p).Write(percentBangBytes); + p.add(verb); + new ($ptrType(buffer))(function() { return this.$target.buf; }, function($v) { this.$target.buf = $v; }, p).Write(panicBytes); + p.panicking = true; + p.printArg(err, 118, false, false, 0); + p.panicking = false; + new ($ptrType(buffer))(function() { return this.$target.buf; }, function($v) { this.$target.buf = $v; }, p).WriteByte(41); + } }; - $ptrType(intValue).prototype.Set = function(s) { - var i, _tuple, v, err; - i = this; - _tuple = strconv.ParseInt(s, 0, 64); v = _tuple[0]; err = _tuple[1]; - i.$set(((v.$low + ((v.$high >> 31) * 4294967296)) >> 0)); - return err; - }; - $ptrType(intValue).prototype.Get = function() { - var i; - i = this; - return new $Int((i.$get() >> 0)); - }; - $ptrType(intValue).prototype.String = function() { - var i; - i = this; - return fmt.Sprintf("%v", new ($sliceType($emptyInterface))([new intValue(i.$get())])); - }; - newInt64Value = function(val, p) { - p.$set(val); - return new ($ptrType(int64Value))(p.$get, p.$set); - }; - $ptrType(int64Value).prototype.Set = function(s) { - var i, _tuple, v, err; - i = this; - _tuple = strconv.ParseInt(s, 0, 64); v = _tuple[0]; err = _tuple[1]; - i.$set(new int64Value(v.$high, v.$low)); - return err; - }; - $ptrType(int64Value).prototype.Get = function() { - var i, x$1; - i = this; - return (x$1 = i.$get(), new $Int64(x$1.$high, x$1.$low)); - }; - $ptrType(int64Value).prototype.String = function() { - var i; - i = this; - return fmt.Sprintf("%v", new ($sliceType($emptyInterface))([i.$get()])); - }; - newUintValue = function(val, p) { - p.$set(val); - return new ($ptrType(uintValue))(p.$get, p.$set); - }; - $ptrType(uintValue).prototype.Set = function(s) { - var i, _tuple, v, err; - i = this; - _tuple = strconv.ParseUint(s, 0, 64); v = _tuple[0]; err = _tuple[1]; - i.$set((v.$low >>> 0)); - return err; - }; - $ptrType(uintValue).prototype.Get = function() { - var i; - i = this; - return new $Uint((i.$get() >>> 0)); - }; - $ptrType(uintValue).prototype.String = function() { - var i; - i = this; - return fmt.Sprintf("%v", new ($sliceType($emptyInterface))([new uintValue(i.$get())])); - }; - newUint64Value = function(val, p) { - p.$set(val); - return new ($ptrType(uint64Value))(p.$get, p.$set); - }; - $ptrType(uint64Value).prototype.Set = function(s) { - var i, _tuple, v, err; - i = this; - _tuple = strconv.ParseUint(s, 0, 64); v = _tuple[0]; err = _tuple[1]; - i.$set(new uint64Value(v.$high, v.$low)); - return err; - }; - $ptrType(uint64Value).prototype.Get = function() { - var i, x$1; - i = this; - return (x$1 = i.$get(), new $Uint64(x$1.$high, x$1.$low)); - }; - $ptrType(uint64Value).prototype.String = function() { - var i; - i = this; - return fmt.Sprintf("%v", new ($sliceType($emptyInterface))([i.$get()])); - }; - newStringValue = function(val, p) { - p.$set(val); - return new ($ptrType(stringValue))(p.$get, p.$set); - }; - $ptrType(stringValue).prototype.Set = function(val) { - var s; - s = this; - s.$set(val); - return $ifaceNil; - }; - $ptrType(stringValue).prototype.Get = function() { - var s; - s = this; - return new $String(s.$get()); - }; - $ptrType(stringValue).prototype.String = function() { - var s; - s = this; - return fmt.Sprintf("%s", new ($sliceType($emptyInterface))([new stringValue(s.$get())])); - }; - newFloat64Value = function(val, p) { - p.$set(val); - return new ($ptrType(float64Value))(p.$get, p.$set); - }; - $ptrType(float64Value).prototype.Set = function(s) { - var f, _tuple, v, err; - f = this; - _tuple = strconv.ParseFloat(s, 64); v = _tuple[0]; err = _tuple[1]; - f.$set(v); - return err; - }; - $ptrType(float64Value).prototype.Get = function() { - var f; - f = this; - return new $Float64(f.$get()); - }; - $ptrType(float64Value).prototype.String = function() { - var f; - f = this; - return fmt.Sprintf("%v", new ($sliceType($emptyInterface))([new float64Value(f.$get())])); - }; - newDurationValue = function(val, p) { - p.$set(val); - return new ($ptrType(durationValue))(p.$get, p.$set); - }; - $ptrType(durationValue).prototype.Set = function(s) { - var d, _tuple, v, err; - d = this; - _tuple = time.ParseDuration(s); v = _tuple[0]; err = _tuple[1]; - d.$set(new durationValue(v.$high, v.$low)); - return err; - }; - $ptrType(durationValue).prototype.Get = function() { - var d, x$1; - d = this; - return (x$1 = d.$get(), new time.Duration(x$1.$high, x$1.$low)); - }; - $ptrType(durationValue).prototype.String = function() { - var d; - d = this; - return new ($ptrType(time.Duration))(d.$get, d.$set).String(); - }; - sortFlags = function(flags) { - var list, i, _ref, _i, _keys, _entry, f, result, _ref$1, _i$1, i$1, name, _entry$1; - list = sort.StringSlice.make($keys(flags).length); - i = 0; - _ref = flags; - _i = 0; - _keys = $keys(_ref); - while (_i < _keys.length) { - _entry = _ref[_keys[_i]]; - if (_entry === undefined) { - _i++; - continue; - } - f = _entry.v; - (i < 0 || i >= list.$length) ? $throwRuntimeError("index out of range") : list.$array[list.$offset + i] = f.Name; - i = i + (1) >> 0; - _i++; + pp.prototype.catchPanic = function(arg, verb) { return this.$val.catchPanic(arg, verb); }; + pp.Ptr.prototype.handleMethods = function(verb, plus, goSyntax, depth) { + var wasString = false, handled = false, $deferred = [], $err = null, p, _tuple, formatter, ok, _tuple$1, stringer, ok$1, _ref, v, _ref$1; + /* */ try { $deferFrames.push($deferred); + p = this; + if (p.erroring) { + return [wasString, handled]; } - list.Sort(); - result = ($sliceType(($ptrType(Flag)))).make(list.$length); - _ref$1 = list; - _i$1 = 0; - while (_i$1 < _ref$1.$length) { - i$1 = _i$1; - name = ((_i$1 < 0 || _i$1 >= _ref$1.$length) ? $throwRuntimeError("index out of range") : _ref$1.$array[_ref$1.$offset + _i$1]); - (i$1 < 0 || i$1 >= result.$length) ? $throwRuntimeError("index out of range") : result.$array[result.$offset + i$1] = (_entry$1 = flags[name], _entry$1 !== undefined ? _entry$1.v : ($ptrType(Flag)).nil); - _i$1++; + _tuple = $assertType(p.arg, Formatter, true); formatter = _tuple[0]; ok = _tuple[1]; + if (ok) { + handled = true; + wasString = false; + $deferred.push([$methodVal(p, "catchPanic"), [p.arg, verb]]); + formatter.Format(p, verb); + return [wasString, handled]; } - return result; - }; - FlagSet.Ptr.prototype.out = function() { - var f; - f = this; - if ($interfaceIsEqual(f.output, $ifaceNil)) { - return os.Stderr; + if (plus) { + p.fmt.plus = false; } - return f.output; - }; - FlagSet.prototype.out = function() { return this.$val.out(); }; - FlagSet.Ptr.prototype.SetOutput = function(output) { - var f; - f = this; - f.output = output; - }; - FlagSet.prototype.SetOutput = function(output) { return this.$val.SetOutput(output); }; - FlagSet.Ptr.prototype.VisitAll = function(fn) { - var f, _ref, _i, flag; - f = this; - _ref = sortFlags(f.formal); - _i = 0; - while (_i < _ref.$length) { - flag = ((_i < 0 || _i >= _ref.$length) ? $throwRuntimeError("index out of range") : _ref.$array[_ref.$offset + _i]); - fn(flag); - _i++; + if (goSyntax) { + p.fmt.sharp = false; + _tuple$1 = $assertType(p.arg, GoStringer, true); stringer = _tuple$1[0]; ok$1 = _tuple$1[1]; + if (ok$1) { + wasString = false; + handled = true; + $deferred.push([$methodVal(p, "catchPanic"), [p.arg, verb]]); + p.fmtString(stringer.GoString(), 115, false); + return [wasString, handled]; + } + } else { + _ref = verb; + if (_ref === 118 || _ref === 115 || _ref === 120 || _ref === 88 || _ref === 113) { + _ref$1 = p.arg; + if ($assertType(_ref$1, $error, true)[1]) { + v = _ref$1; + wasString = false; + handled = true; + $deferred.push([$methodVal(p, "catchPanic"), [p.arg, verb]]); + p.printArg(new $String(v.Error()), verb, plus, false, depth); + return [wasString, handled]; + } else if ($assertType(_ref$1, Stringer, true)[1]) { + v = _ref$1; + wasString = false; + handled = true; + $deferred.push([$methodVal(p, "catchPanic"), [p.arg, verb]]); + p.printArg(new $String(v.String()), verb, plus, false, depth); + return [wasString, handled]; + } + } } + handled = false; + return [wasString, handled]; + /* */ } catch(err) { $err = err; } finally { $deferFrames.pop(); $callDeferred($deferred, $err); return [wasString, handled]; } }; - FlagSet.prototype.VisitAll = function(fn) { return this.$val.VisitAll(fn); }; - FlagSet.Ptr.prototype.Visit = function(fn) { - var f, _ref, _i, flag; - f = this; - _ref = sortFlags(f.actual); - _i = 0; - while (_i < _ref.$length) { - flag = ((_i < 0 || _i >= _ref.$length) ? $throwRuntimeError("index out of range") : _ref.$array[_ref.$offset + _i]); - fn(flag); - _i++; + pp.prototype.handleMethods = function(verb, plus, goSyntax, depth) { return this.$val.handleMethods(verb, plus, goSyntax, depth); }; + pp.Ptr.prototype.printArg = function(arg, verb, plus, goSyntax, depth) { + var wasString = false, p, _ref, oldPlus, oldSharp, f, _ref$1, _tuple, isString, handled; + p = this; + p.arg = arg; + $copy(p.value, new reflect.Value.Ptr(($ptrType(reflect.rtype)).nil, 0, 0, 0), reflect.Value); + if ($interfaceIsEqual(arg, $ifaceNil)) { + if ((verb === 84) || (verb === 118)) { + p.fmt.pad(nilAngleBytes); + } else { + p.badVerb(verb); + } + wasString = false; + return wasString; } - }; - FlagSet.prototype.Visit = function(fn) { return this.$val.Visit(fn); }; - FlagSet.Ptr.prototype.Lookup = function(name) { - var f, _entry; - f = this; - return (_entry = f.formal[name], _entry !== undefined ? _entry.v : ($ptrType(Flag)).nil); - }; - FlagSet.prototype.Lookup = function(name) { return this.$val.Lookup(name); }; - FlagSet.Ptr.prototype.Set = function(name, value) { - var f, _tuple, _entry, flag, ok, err, _key; - f = this; - _tuple = (_entry = f.formal[name], _entry !== undefined ? [_entry.v, true] : [($ptrType(Flag)).nil, false]); flag = _tuple[0]; ok = _tuple[1]; - if (!ok) { - return fmt.Errorf("no such flag -%v", new ($sliceType($emptyInterface))([new $String(name)])); + _ref = verb; + if (_ref === 84) { + p.printArg(new $String(reflect.TypeOf(arg).String()), 115, false, false, 0); + wasString = false; + return wasString; + } else if (_ref === 112) { + p.fmtPointer($clone(reflect.ValueOf(arg), reflect.Value), verb, goSyntax); + wasString = false; + return wasString; } - err = flag.Value.Set(value); - if (!($interfaceIsEqual(err, $ifaceNil))) { - return err; + oldPlus = p.fmt.plus; + oldSharp = p.fmt.sharp; + if (plus) { + p.fmt.plus = false; } - if (f.actual === false) { - f.actual = new $Map(); + if (goSyntax) { + p.fmt.sharp = false; } - _key = name; (f.actual || $throwRuntimeError("assignment to entry in nil map"))[_key] = { k: _key, v: flag }; - return $ifaceNil; - }; - FlagSet.prototype.Set = function(name, value) { return this.$val.Set(name, value); }; - FlagSet.Ptr.prototype.PrintDefaults = function() { - var f; - f = this; - f.VisitAll((function(flag) { - var format, _tuple, ok; - format = " -%s=%s: %s\n"; - _tuple = $assertType(flag.Value, ($ptrType(stringValue)), true); ok = _tuple[1]; - if (ok) { - format = " -%s=%q: %s\n"; - } - fmt.Fprintf(f.out(), format, new ($sliceType($emptyInterface))([new $String(flag.Name), new $String(flag.DefValue), new $String(flag.Usage)])); - })); - }; - FlagSet.prototype.PrintDefaults = function() { return this.$val.PrintDefaults(); }; - PrintDefaults = $pkg.PrintDefaults = function() { - $pkg.CommandLine.PrintDefaults(); - }; - defaultUsage = function(f) { - if (f.name === "") { - fmt.Fprintf(f.out(), "Usage:\n", new ($sliceType($emptyInterface))([])); + _ref$1 = arg; + if ($assertType(_ref$1, $Bool, true)[1]) { + f = _ref$1.$val; + p.fmtBool(f, verb); + } else if ($assertType(_ref$1, $Float32, true)[1]) { + f = _ref$1.$val; + p.fmtFloat32(f, verb); + } else if ($assertType(_ref$1, $Float64, true)[1]) { + f = _ref$1.$val; + p.fmtFloat64(f, verb); + } else if ($assertType(_ref$1, $Complex64, true)[1]) { + f = _ref$1.$val; + p.fmtComplex64(f, verb); + } else if ($assertType(_ref$1, $Complex128, true)[1]) { + f = _ref$1.$val; + p.fmtComplex128(f, verb); + } else if ($assertType(_ref$1, $Int, true)[1]) { + f = _ref$1.$val; + p.fmtInt64(new $Int64(0, f), verb); + } else if ($assertType(_ref$1, $Int8, true)[1]) { + f = _ref$1.$val; + p.fmtInt64(new $Int64(0, f), verb); + } else if ($assertType(_ref$1, $Int16, true)[1]) { + f = _ref$1.$val; + p.fmtInt64(new $Int64(0, f), verb); + } else if ($assertType(_ref$1, $Int32, true)[1]) { + f = _ref$1.$val; + p.fmtInt64(new $Int64(0, f), verb); + } else if ($assertType(_ref$1, $Int64, true)[1]) { + f = _ref$1.$val; + p.fmtInt64(f, verb); + } else if ($assertType(_ref$1, $Uint, true)[1]) { + f = _ref$1.$val; + p.fmtUint64(new $Uint64(0, f), verb, goSyntax); + } else if ($assertType(_ref$1, $Uint8, true)[1]) { + f = _ref$1.$val; + p.fmtUint64(new $Uint64(0, f), verb, goSyntax); + } else if ($assertType(_ref$1, $Uint16, true)[1]) { + f = _ref$1.$val; + p.fmtUint64(new $Uint64(0, f), verb, goSyntax); + } else if ($assertType(_ref$1, $Uint32, true)[1]) { + f = _ref$1.$val; + p.fmtUint64(new $Uint64(0, f), verb, goSyntax); + } else if ($assertType(_ref$1, $Uint64, true)[1]) { + f = _ref$1.$val; + p.fmtUint64(f, verb, goSyntax); + } else if ($assertType(_ref$1, $Uintptr, true)[1]) { + f = _ref$1.$val; + p.fmtUint64(new $Uint64(0, f.constructor === Number ? f : 1), verb, goSyntax); + } else if ($assertType(_ref$1, $String, true)[1]) { + f = _ref$1.$val; + p.fmtString(f, verb, goSyntax); + wasString = (verb === 115) || (verb === 118); + } else if ($assertType(_ref$1, ($sliceType($Uint8)), true)[1]) { + f = _ref$1.$val; + p.fmtBytes(f, verb, goSyntax, $ifaceNil, depth); + wasString = verb === 115; } else { - fmt.Fprintf(f.out(), "Usage of %s:\n", new ($sliceType($emptyInterface))([new $String(f.name)])); + f = _ref$1; + p.fmt.plus = oldPlus; + p.fmt.sharp = oldSharp; + _tuple = p.handleMethods(verb, plus, goSyntax, depth); isString = _tuple[0]; handled = _tuple[1]; + if (handled) { + wasString = isString; + return wasString; + } + wasString = p.printReflectValue($clone(reflect.ValueOf(arg), reflect.Value), verb, plus, goSyntax, depth); + return wasString; } - f.PrintDefaults(); - }; - FlagSet.Ptr.prototype.NFlag = function() { - var f; - f = this; - return $keys(f.actual).length; + p.arg = $ifaceNil; + return wasString; }; - FlagSet.prototype.NFlag = function() { return this.$val.NFlag(); }; - FlagSet.Ptr.prototype.Arg = function(i) { - var f, x$1; - f = this; - if (i < 0 || i >= f.args.$length) { - return ""; + pp.prototype.printArg = function(arg, verb, plus, goSyntax, depth) { return this.$val.printArg(arg, verb, plus, goSyntax, depth); }; + pp.Ptr.prototype.printValue = function(value, verb, plus, goSyntax, depth) { + var wasString = false, p, _ref, _tuple, isString, handled; + p = this; + if (!value.IsValid()) { + if ((verb === 84) || (verb === 118)) { + new ($ptrType(buffer))(function() { return this.$target.buf; }, function($v) { this.$target.buf = $v; }, p).Write(nilAngleBytes); + } else { + p.badVerb(verb); + } + wasString = false; + return wasString; } - return (x$1 = f.args, ((i < 0 || i >= x$1.$length) ? $throwRuntimeError("index out of range") : x$1.$array[x$1.$offset + i])); - }; - FlagSet.prototype.Arg = function(i) { return this.$val.Arg(i); }; - FlagSet.Ptr.prototype.NArg = function() { - var f; - f = this; - return f.args.$length; - }; - FlagSet.prototype.NArg = function() { return this.$val.NArg(); }; - FlagSet.Ptr.prototype.Args = function() { - var f; - f = this; - return f.args; - }; - FlagSet.prototype.Args = function() { return this.$val.Args(); }; - FlagSet.Ptr.prototype.BoolVar = function(p, name, value, usage) { - var f; - f = this; - f.Var(newBoolValue(value, p), name, usage); - }; - FlagSet.prototype.BoolVar = function(p, name, value, usage) { return this.$val.BoolVar(p, name, value, usage); }; - FlagSet.Ptr.prototype.Bool = function(name, value, usage) { - var f, p; - f = this; - p = $newDataPointer(false, ($ptrType($Bool))); - f.BoolVar(p, name, value, usage); - return p; - }; - FlagSet.prototype.Bool = function(name, value, usage) { return this.$val.Bool(name, value, usage); }; - Bool = $pkg.Bool = function(name, value, usage) { - return $pkg.CommandLine.Bool(name, value, usage); - }; - FlagSet.Ptr.prototype.IntVar = function(p, name, value, usage) { - var f; - f = this; - f.Var(newIntValue(value, p), name, usage); - }; - FlagSet.prototype.IntVar = function(p, name, value, usage) { return this.$val.IntVar(p, name, value, usage); }; - FlagSet.Ptr.prototype.Int = function(name, value, usage) { - var f, p; - f = this; - p = $newDataPointer(0, ($ptrType($Int))); - f.IntVar(p, name, value, usage); - return p; - }; - FlagSet.prototype.Int = function(name, value, usage) { return this.$val.Int(name, value, usage); }; - Int = $pkg.Int = function(name, value, usage) { - return $pkg.CommandLine.Int(name, value, usage); - }; - FlagSet.Ptr.prototype.Int64Var = function(p, name, value, usage) { - var f; - f = this; - f.Var(newInt64Value(value, p), name, usage); - }; - FlagSet.prototype.Int64Var = function(p, name, value, usage) { return this.$val.Int64Var(p, name, value, usage); }; - FlagSet.Ptr.prototype.Int64 = function(name, value, usage) { - var f, p; - f = this; - p = $newDataPointer(new $Int64(0, 0), ($ptrType($Int64))); - f.Int64Var(p, name, value, usage); - return p; - }; - FlagSet.prototype.Int64 = function(name, value, usage) { return this.$val.Int64(name, value, usage); }; - FlagSet.Ptr.prototype.UintVar = function(p, name, value, usage) { - var f; - f = this; - f.Var(newUintValue(value, p), name, usage); - }; - FlagSet.prototype.UintVar = function(p, name, value, usage) { return this.$val.UintVar(p, name, value, usage); }; - FlagSet.Ptr.prototype.Uint = function(name, value, usage) { - var f, p; - f = this; - p = $newDataPointer(0, ($ptrType($Uint))); - f.UintVar(p, name, value, usage); - return p; + _ref = verb; + if (_ref === 84) { + p.printArg(new $String(value.Type().String()), 115, false, false, 0); + wasString = false; + return wasString; + } else if (_ref === 112) { + p.fmtPointer($clone(value, reflect.Value), verb, goSyntax); + wasString = false; + return wasString; + } + p.arg = $ifaceNil; + if (value.CanInterface()) { + p.arg = value.Interface(); + } + _tuple = p.handleMethods(verb, plus, goSyntax, depth); isString = _tuple[0]; handled = _tuple[1]; + if (handled) { + wasString = isString; + return wasString; + } + wasString = p.printReflectValue($clone(value, reflect.Value), verb, plus, goSyntax, depth); + return wasString; }; - FlagSet.prototype.Uint = function(name, value, usage) { return this.$val.Uint(name, value, usage); }; - FlagSet.Ptr.prototype.Uint64Var = function(p, name, value, usage) { - var f; - f = this; - f.Var(newUint64Value(value, p), name, usage); - }; - FlagSet.prototype.Uint64Var = function(p, name, value, usage) { return this.$val.Uint64Var(p, name, value, usage); }; - FlagSet.Ptr.prototype.Uint64 = function(name, value, usage) { - var f, p; - f = this; - p = $newDataPointer(new $Uint64(0, 0), ($ptrType($Uint64))); - f.Uint64Var(p, name, value, usage); - return p; - }; - FlagSet.prototype.Uint64 = function(name, value, usage) { return this.$val.Uint64(name, value, usage); }; - FlagSet.Ptr.prototype.StringVar = function(p, name, value, usage) { - var f; - f = this; - f.Var(newStringValue(value, p), name, usage); - }; - FlagSet.prototype.StringVar = function(p, name, value, usage) { return this.$val.StringVar(p, name, value, usage); }; - FlagSet.Ptr.prototype.String = function(name, value, usage) { - var f, p; - f = this; - p = $newDataPointer("", ($ptrType($String))); - f.StringVar(p, name, value, usage); - return p; - }; - FlagSet.prototype.String = function(name, value, usage) { return this.$val.String(name, value, usage); }; - String = $pkg.String = function(name, value, usage) { - return $pkg.CommandLine.String(name, value, usage); - }; - FlagSet.Ptr.prototype.Float64Var = function(p, name, value, usage) { - var f; - f = this; - f.Var(newFloat64Value(value, p), name, usage); - }; - FlagSet.prototype.Float64Var = function(p, name, value, usage) { return this.$val.Float64Var(p, name, value, usage); }; - FlagSet.Ptr.prototype.Float64 = function(name, value, usage) { - var f, p; - f = this; - p = $newDataPointer(0, ($ptrType($Float64))); - f.Float64Var(p, name, value, usage); - return p; - }; - FlagSet.prototype.Float64 = function(name, value, usage) { return this.$val.Float64(name, value, usage); }; - FlagSet.Ptr.prototype.DurationVar = function(p, name, value, usage) { - var f; - f = this; - f.Var(newDurationValue(value, p), name, usage); - }; - FlagSet.prototype.DurationVar = function(p, name, value, usage) { return this.$val.DurationVar(p, name, value, usage); }; - FlagSet.Ptr.prototype.Duration = function(name, value, usage) { - var f, p; - f = this; - p = $newDataPointer(new time.Duration(0, 0), ($ptrType(time.Duration))); - f.DurationVar(p, name, value, usage); - return p; - }; - FlagSet.prototype.Duration = function(name, value, usage) { return this.$val.Duration(name, value, usage); }; - Duration = $pkg.Duration = function(name, value, usage) { - return $pkg.CommandLine.Duration(name, value, usage); - }; - FlagSet.Ptr.prototype.Var = function(value, name, usage) { - var f, flag, _tuple, _entry, alreadythere, msg, _key; - f = this; - flag = new Flag.Ptr(name, usage, value, value.String()); - _tuple = (_entry = f.formal[name], _entry !== undefined ? [_entry.v, true] : [($ptrType(Flag)).nil, false]); alreadythere = _tuple[1]; - if (alreadythere) { - msg = ""; - if (f.name === "") { - msg = fmt.Sprintf("flag redefined: %s", new ($sliceType($emptyInterface))([new $String(name)])); + pp.prototype.printValue = function(value, verb, plus, goSyntax, depth) { return this.$val.printValue(value, verb, plus, goSyntax, depth); }; + pp.Ptr.prototype.printReflectValue = function(value, verb, plus, goSyntax, depth) { + var wasString = false, p, oldValue, f, _ref, x, keys, _ref$1, _i, i, key, v, t, i$1, f$1, value$1, typ, bytes, _ref$2, _i$1, i$2, i$3, v$1, a, _ref$3; + p = this; + oldValue = new reflect.Value.Ptr(); $copy(oldValue, p.value, reflect.Value); + $copy(p.value, value, reflect.Value); + f = new reflect.Value.Ptr(); $copy(f, value, reflect.Value); + _ref = f.Kind(); + BigSwitch: + switch (0) { default: if (_ref === 1) { + p.fmtBool(f.Bool(), verb); + } else if (_ref === 2 || _ref === 3 || _ref === 4 || _ref === 5 || _ref === 6) { + p.fmtInt64(f.Int(), verb); + } else if (_ref === 7 || _ref === 8 || _ref === 9 || _ref === 10 || _ref === 11 || _ref === 12) { + p.fmtUint64(f.Uint(), verb, goSyntax); + } else if (_ref === 13 || _ref === 14) { + if (f.Type().Size() === 4) { + p.fmtFloat32(f.Float(), verb); } else { - msg = fmt.Sprintf("%s flag redefined: %s", new ($sliceType($emptyInterface))([new $String(f.name), new $String(name)])); + p.fmtFloat64(f.Float(), verb); } - fmt.Fprintln(f.out(), new ($sliceType($emptyInterface))([new $String(msg)])); - $panic(new $String(msg)); - } - if (f.formal === false) { - f.formal = new $Map(); - } - _key = name; (f.formal || $throwRuntimeError("assignment to entry in nil map"))[_key] = { k: _key, v: flag }; + } else if (_ref === 15 || _ref === 16) { + if (f.Type().Size() === 8) { + p.fmtComplex64((x = f.Complex(), new $Complex64(x.$real, x.$imag)), verb); + } else { + p.fmtComplex128(f.Complex(), verb); + } + } else if (_ref === 24) { + p.fmtString(f.String(), verb, goSyntax); + } else if (_ref === 21) { + if (goSyntax) { + new ($ptrType(buffer))(function() { return this.$target.buf; }, function($v) { this.$target.buf = $v; }, p).WriteString(f.Type().String()); + if (f.IsNil()) { + new ($ptrType(buffer))(function() { return this.$target.buf; }, function($v) { this.$target.buf = $v; }, p).WriteString("(nil)"); + break; + } + new ($ptrType(buffer))(function() { return this.$target.buf; }, function($v) { this.$target.buf = $v; }, p).WriteByte(123); + } else { + new ($ptrType(buffer))(function() { return this.$target.buf; }, function($v) { this.$target.buf = $v; }, p).Write(mapBytes); + } + keys = f.MapKeys(); + _ref$1 = keys; + _i = 0; + while (_i < _ref$1.$length) { + i = _i; + key = new reflect.Value.Ptr(); $copy(key, ((_i < 0 || _i >= _ref$1.$length) ? $throwRuntimeError("index out of range") : _ref$1.$array[_ref$1.$offset + _i]), reflect.Value); + if (i > 0) { + if (goSyntax) { + new ($ptrType(buffer))(function() { return this.$target.buf; }, function($v) { this.$target.buf = $v; }, p).Write(commaSpaceBytes); + } else { + new ($ptrType(buffer))(function() { return this.$target.buf; }, function($v) { this.$target.buf = $v; }, p).WriteByte(32); + } + } + p.printValue($clone(key, reflect.Value), verb, plus, goSyntax, depth + 1 >> 0); + new ($ptrType(buffer))(function() { return this.$target.buf; }, function($v) { this.$target.buf = $v; }, p).WriteByte(58); + p.printValue($clone(f.MapIndex($clone(key, reflect.Value)), reflect.Value), verb, plus, goSyntax, depth + 1 >> 0); + _i++; + } + if (goSyntax) { + new ($ptrType(buffer))(function() { return this.$target.buf; }, function($v) { this.$target.buf = $v; }, p).WriteByte(125); + } else { + new ($ptrType(buffer))(function() { return this.$target.buf; }, function($v) { this.$target.buf = $v; }, p).WriteByte(93); + } + } else if (_ref === 25) { + if (goSyntax) { + new ($ptrType(buffer))(function() { return this.$target.buf; }, function($v) { this.$target.buf = $v; }, p).WriteString(value.Type().String()); + } + p.add(123); + v = new reflect.Value.Ptr(); $copy(v, f, reflect.Value); + t = v.Type(); + i$1 = 0; + while (i$1 < v.NumField()) { + if (i$1 > 0) { + if (goSyntax) { + new ($ptrType(buffer))(function() { return this.$target.buf; }, function($v) { this.$target.buf = $v; }, p).Write(commaSpaceBytes); + } else { + new ($ptrType(buffer))(function() { return this.$target.buf; }, function($v) { this.$target.buf = $v; }, p).WriteByte(32); + } + } + if (plus || goSyntax) { + f$1 = new reflect.StructField.Ptr(); $copy(f$1, t.Field(i$1), reflect.StructField); + if (!(f$1.Name === "")) { + new ($ptrType(buffer))(function() { return this.$target.buf; }, function($v) { this.$target.buf = $v; }, p).WriteString(f$1.Name); + new ($ptrType(buffer))(function() { return this.$target.buf; }, function($v) { this.$target.buf = $v; }, p).WriteByte(58); + } + } + p.printValue($clone(getField($clone(v, reflect.Value), i$1), reflect.Value), verb, plus, goSyntax, depth + 1 >> 0); + i$1 = i$1 + (1) >> 0; + } + new ($ptrType(buffer))(function() { return this.$target.buf; }, function($v) { this.$target.buf = $v; }, p).WriteByte(125); + } else if (_ref === 20) { + value$1 = new reflect.Value.Ptr(); $copy(value$1, f.Elem(), reflect.Value); + if (!value$1.IsValid()) { + if (goSyntax) { + new ($ptrType(buffer))(function() { return this.$target.buf; }, function($v) { this.$target.buf = $v; }, p).WriteString(f.Type().String()); + new ($ptrType(buffer))(function() { return this.$target.buf; }, function($v) { this.$target.buf = $v; }, p).Write(nilParenBytes); + } else { + new ($ptrType(buffer))(function() { return this.$target.buf; }, function($v) { this.$target.buf = $v; }, p).Write(nilAngleBytes); + } + } else { + wasString = p.printValue($clone(value$1, reflect.Value), verb, plus, goSyntax, depth + 1 >> 0); + } + } else if (_ref === 17 || _ref === 23) { + typ = f.Type(); + if (typ.Elem().Kind() === 8) { + bytes = ($sliceType($Uint8)).nil; + if (f.Kind() === 23) { + bytes = f.Bytes(); + } else if (f.CanAddr()) { + bytes = f.Slice(0, f.Len()).Bytes(); + } else { + bytes = ($sliceType($Uint8)).make(f.Len()); + _ref$2 = bytes; + _i$1 = 0; + while (_i$1 < _ref$2.$length) { + i$2 = _i$1; + (i$2 < 0 || i$2 >= bytes.$length) ? $throwRuntimeError("index out of range") : bytes.$array[bytes.$offset + i$2] = (f.Index(i$2).Uint().$low << 24 >>> 24); + _i$1++; + } + } + p.fmtBytes(bytes, verb, goSyntax, typ, depth); + wasString = verb === 115; + break; + } + if (goSyntax) { + new ($ptrType(buffer))(function() { return this.$target.buf; }, function($v) { this.$target.buf = $v; }, p).WriteString(value.Type().String()); + if ((f.Kind() === 23) && f.IsNil()) { + new ($ptrType(buffer))(function() { return this.$target.buf; }, function($v) { this.$target.buf = $v; }, p).WriteString("(nil)"); + break; + } + new ($ptrType(buffer))(function() { return this.$target.buf; }, function($v) { this.$target.buf = $v; }, p).WriteByte(123); + } else { + new ($ptrType(buffer))(function() { return this.$target.buf; }, function($v) { this.$target.buf = $v; }, p).WriteByte(91); + } + i$3 = 0; + while (i$3 < f.Len()) { + if (i$3 > 0) { + if (goSyntax) { + new ($ptrType(buffer))(function() { return this.$target.buf; }, function($v) { this.$target.buf = $v; }, p).Write(commaSpaceBytes); + } else { + new ($ptrType(buffer))(function() { return this.$target.buf; }, function($v) { this.$target.buf = $v; }, p).WriteByte(32); + } + } + p.printValue($clone(f.Index(i$3), reflect.Value), verb, plus, goSyntax, depth + 1 >> 0); + i$3 = i$3 + (1) >> 0; + } + if (goSyntax) { + new ($ptrType(buffer))(function() { return this.$target.buf; }, function($v) { this.$target.buf = $v; }, p).WriteByte(125); + } else { + new ($ptrType(buffer))(function() { return this.$target.buf; }, function($v) { this.$target.buf = $v; }, p).WriteByte(93); + } + } else if (_ref === 22) { + v$1 = f.Pointer(); + if (!((v$1 === 0)) && (depth === 0)) { + a = new reflect.Value.Ptr(); $copy(a, f.Elem(), reflect.Value); + _ref$3 = a.Kind(); + if (_ref$3 === 17 || _ref$3 === 23) { + new ($ptrType(buffer))(function() { return this.$target.buf; }, function($v) { this.$target.buf = $v; }, p).WriteByte(38); + p.printValue($clone(a, reflect.Value), verb, plus, goSyntax, depth + 1 >> 0); + break BigSwitch; + } else if (_ref$3 === 25) { + new ($ptrType(buffer))(function() { return this.$target.buf; }, function($v) { this.$target.buf = $v; }, p).WriteByte(38); + p.printValue($clone(a, reflect.Value), verb, plus, goSyntax, depth + 1 >> 0); + break BigSwitch; + } + } + p.fmtPointer($clone(value, reflect.Value), verb, goSyntax); + } else if (_ref === 18 || _ref === 19 || _ref === 26) { + p.fmtPointer($clone(value, reflect.Value), verb, goSyntax); + } else { + p.unknownType(new f.constructor.Struct(f)); + } } + $copy(p.value, oldValue, reflect.Value); + wasString = wasString; + return wasString; }; - FlagSet.prototype.Var = function(value, name, usage) { return this.$val.Var(value, name, usage); }; - FlagSet.Ptr.prototype.failf = function(format, a) { - var f, err; - f = this; - err = fmt.Errorf(format, a); - fmt.Fprintln(f.out(), new ($sliceType($emptyInterface))([err])); - f.usage(); - return err; + pp.prototype.printReflectValue = function(value, verb, plus, goSyntax, depth) { return this.$val.printReflectValue(value, verb, plus, goSyntax, depth); }; + intFromArg = function(a, argNum) { + var num = 0, isInt = false, newArgNum = 0, _tuple; + newArgNum = argNum; + if (argNum < a.$length) { + _tuple = $assertType(((argNum < 0 || argNum >= a.$length) ? $throwRuntimeError("index out of range") : a.$array[a.$offset + argNum]), $Int, true); num = _tuple[0]; isInt = _tuple[1]; + newArgNum = argNum + 1 >> 0; + } + return [num, isInt, newArgNum]; }; - FlagSet.prototype.failf = function(format, a) { return this.$val.failf(format, a); }; - FlagSet.Ptr.prototype.usage = function() { - var f; - f = this; - if (f === $pkg.CommandLine) { - $pkg.Usage(); - } else if (f.Usage === $throwNilPointerError) { - defaultUsage(f); - } else { - f.Usage(); + parseArgNumber = function(format) { + var index = 0, wid = 0, ok = false, i, _tuple, width, ok$1, newi, _tmp, _tmp$1, _tmp$2, _tmp$3, _tmp$4, _tmp$5, _tmp$6, _tmp$7, _tmp$8; + i = 1; + while (i < format.length) { + if (format.charCodeAt(i) === 93) { + _tuple = parsenum(format, 1, i); width = _tuple[0]; ok$1 = _tuple[1]; newi = _tuple[2]; + if (!ok$1 || !((newi === i))) { + _tmp = 0; _tmp$1 = i + 1 >> 0; _tmp$2 = false; index = _tmp; wid = _tmp$1; ok = _tmp$2; + return [index, wid, ok]; + } + _tmp$3 = width - 1 >> 0; _tmp$4 = i + 1 >> 0; _tmp$5 = true; index = _tmp$3; wid = _tmp$4; ok = _tmp$5; + return [index, wid, ok]; + } + i = i + (1) >> 0; } + _tmp$6 = 0; _tmp$7 = 1; _tmp$8 = false; index = _tmp$6; wid = _tmp$7; ok = _tmp$8; + return [index, wid, ok]; }; - FlagSet.prototype.usage = function() { return this.$val.usage(); }; - FlagSet.Ptr.prototype.parseOne = function() { - var f, x$1, s, num_minuses, name, has_value, value, i, m, _tuple, _entry, flag, alreadythere, _tuple$1, fv, ok, err, _tmp, x$2, _tmp$1, err$1, _key; - f = this; - if (f.args.$length === 0) { - return [false, $ifaceNil]; + pp.Ptr.prototype.argNumber = function(argNum, format, i, numArgs) { + var newArgNum = 0, newi = 0, found = false, p, _tmp, _tmp$1, _tmp$2, _tuple, index, wid, ok, _tmp$3, _tmp$4, _tmp$5, _tmp$6, _tmp$7, _tmp$8; + p = this; + if (format.length <= i || !((format.charCodeAt(i) === 91))) { + _tmp = argNum; _tmp$1 = i; _tmp$2 = false; newArgNum = _tmp; newi = _tmp$1; found = _tmp$2; + return [newArgNum, newi, found]; } - s = (x$1 = f.args, ((0 < 0 || 0 >= x$1.$length) ? $throwRuntimeError("index out of range") : x$1.$array[x$1.$offset + 0])); - if ((s.length === 0) || !((s.charCodeAt(0) === 45)) || (s.length === 1)) { - return [false, $ifaceNil]; + p.reordered = true; + _tuple = parseArgNumber(format.substring(i)); index = _tuple[0]; wid = _tuple[1]; ok = _tuple[2]; + if (ok && 0 <= index && index < numArgs) { + _tmp$3 = index; _tmp$4 = i + wid >> 0; _tmp$5 = true; newArgNum = _tmp$3; newi = _tmp$4; found = _tmp$5; + return [newArgNum, newi, found]; } - num_minuses = 1; - if (s.charCodeAt(1) === 45) { - num_minuses = num_minuses + (1) >> 0; - if (s.length === 2) { - f.args = $subslice(f.args, 1); - return [false, $ifaceNil]; + p.goodArgNum = false; + _tmp$6 = argNum; _tmp$7 = i + wid >> 0; _tmp$8 = true; newArgNum = _tmp$6; newi = _tmp$7; found = _tmp$8; + return [newArgNum, newi, found]; + }; + pp.prototype.argNumber = function(argNum, format, i, numArgs) { return this.$val.argNumber(argNum, format, i, numArgs); }; + pp.Ptr.prototype.doPrintf = function(format, a) { + var p, end, argNum, afterIndex, i, lasti, _ref, _tuple, _tuple$1, _tuple$2, _tuple$3, _tuple$4, _tuple$5, _tuple$6, _tuple$7, c, w, arg, goSyntax, plus, arg$1; + p = this; + end = format.length; + argNum = 0; + afterIndex = false; + p.reordered = false; + i = 0; + while (i < end) { + p.goodArgNum = true; + lasti = i; + while (i < end && !((format.charCodeAt(i) === 37))) { + i = i + (1) >> 0; } - } - name = s.substring(num_minuses); - if ((name.length === 0) || (name.charCodeAt(0) === 45) || (name.charCodeAt(0) === 61)) { - return [false, f.failf("bad flag syntax: %s", new ($sliceType($emptyInterface))([new $String(s)]))]; - } - f.args = $subslice(f.args, 1); - has_value = false; - value = ""; - i = 1; - while (i < name.length) { - if (name.charCodeAt(i) === 61) { - value = name.substring((i + 1 >> 0)); - has_value = true; - name = name.substring(0, i); + if (i > lasti) { + new ($ptrType(buffer))(function() { return this.$target.buf; }, function($v) { this.$target.buf = $v; }, p).WriteString(format.substring(lasti, i)); + } + if (i >= end) { break; } i = i + (1) >> 0; - } - m = f.formal; - _tuple = (_entry = m[name], _entry !== undefined ? [_entry.v, true] : [($ptrType(Flag)).nil, false]); flag = _tuple[0]; alreadythere = _tuple[1]; - if (!alreadythere) { - if (name === "help" || name === "h") { - f.usage(); - return [false, $pkg.ErrHelp]; + p.fmt.clearflags(); + F: + while (i < end) { + _ref = format.charCodeAt(i); + if (_ref === 35) { + p.fmt.sharp = true; + } else if (_ref === 48) { + p.fmt.zero = true; + } else if (_ref === 43) { + p.fmt.plus = true; + } else if (_ref === 45) { + p.fmt.minus = true; + } else if (_ref === 32) { + p.fmt.space = true; + } else { + break F; + } + i = i + (1) >> 0; } - return [false, f.failf("flag provided but not defined: -%s", new ($sliceType($emptyInterface))([new $String(name)]))]; - } - _tuple$1 = $assertType(flag.Value, boolFlag, true); fv = _tuple$1[0]; ok = _tuple$1[1]; - if (ok && fv.IsBoolFlag()) { - if (has_value) { - err = fv.Set(value); - if (!($interfaceIsEqual(err, $ifaceNil))) { - return [false, f.failf("invalid boolean value %q for -%s: %v", new ($sliceType($emptyInterface))([new $String(value), new $String(name), err]))]; + _tuple = p.argNumber(argNum, format, i, a.$length); argNum = _tuple[0]; i = _tuple[1]; afterIndex = _tuple[2]; + if (i < end && (format.charCodeAt(i) === 42)) { + i = i + (1) >> 0; + _tuple$1 = intFromArg(a, argNum); p.fmt.wid = _tuple$1[0]; p.fmt.widPresent = _tuple$1[1]; argNum = _tuple$1[2]; + if (!p.fmt.widPresent) { + new ($ptrType(buffer))(function() { return this.$target.buf; }, function($v) { this.$target.buf = $v; }, p).Write(badWidthBytes); } + afterIndex = false; } else { - fv.Set("true"); + _tuple$2 = parsenum(format, i, end); p.fmt.wid = _tuple$2[0]; p.fmt.widPresent = _tuple$2[1]; i = _tuple$2[2]; + if (afterIndex && p.fmt.widPresent) { + p.goodArgNum = false; + } } - } else { - if (!has_value && f.args.$length > 0) { - has_value = true; - _tmp = (x$2 = f.args, ((0 < 0 || 0 >= x$2.$length) ? $throwRuntimeError("index out of range") : x$2.$array[x$2.$offset + 0])); _tmp$1 = $subslice(f.args, 1); value = _tmp; f.args = _tmp$1; + if ((i + 1 >> 0) < end && (format.charCodeAt(i) === 46)) { + i = i + (1) >> 0; + if (afterIndex) { + p.goodArgNum = false; + } + _tuple$3 = p.argNumber(argNum, format, i, a.$length); argNum = _tuple$3[0]; i = _tuple$3[1]; afterIndex = _tuple$3[2]; + if (format.charCodeAt(i) === 42) { + i = i + (1) >> 0; + _tuple$4 = intFromArg(a, argNum); p.fmt.prec = _tuple$4[0]; p.fmt.precPresent = _tuple$4[1]; argNum = _tuple$4[2]; + if (!p.fmt.precPresent) { + new ($ptrType(buffer))(function() { return this.$target.buf; }, function($v) { this.$target.buf = $v; }, p).Write(badPrecBytes); + } + afterIndex = false; + } else { + _tuple$5 = parsenum(format, i, end); p.fmt.prec = _tuple$5[0]; p.fmt.precPresent = _tuple$5[1]; i = _tuple$5[2]; + if (!p.fmt.precPresent) { + p.fmt.prec = 0; + p.fmt.precPresent = true; + } + } } - if (!has_value) { - return [false, f.failf("flag needs an argument: -%s", new ($sliceType($emptyInterface))([new $String(name)]))]; + if (!afterIndex) { + _tuple$6 = p.argNumber(argNum, format, i, a.$length); argNum = _tuple$6[0]; i = _tuple$6[1]; afterIndex = _tuple$6[2]; } - err$1 = flag.Value.Set(value); - if (!($interfaceIsEqual(err$1, $ifaceNil))) { - return [false, f.failf("invalid value %q for flag -%s: %v", new ($sliceType($emptyInterface))([new $String(value), new $String(name), err$1]))]; + if (i >= end) { + new ($ptrType(buffer))(function() { return this.$target.buf; }, function($v) { this.$target.buf = $v; }, p).Write(noVerbBytes); + continue; } - } - if (f.actual === false) { - f.actual = new $Map(); - } - _key = name; (f.actual || $throwRuntimeError("assignment to entry in nil map"))[_key] = { k: _key, v: flag }; - return [true, $ifaceNil]; - }; - FlagSet.prototype.parseOne = function() { return this.$val.parseOne(); }; - FlagSet.Ptr.prototype.Parse = function(arguments$1) { - var f, _tuple, seen, err, _ref; - f = this; - f.parsed = true; - f.args = arguments$1; - while (true) { - _tuple = f.parseOne(); seen = _tuple[0]; err = _tuple[1]; - if (seen) { + _tuple$7 = utf8.DecodeRuneInString(format.substring(i)); c = _tuple$7[0]; w = _tuple$7[1]; + i = i + (w) >> 0; + if (c === 37) { + new ($ptrType(buffer))(function() { return this.$target.buf; }, function($v) { this.$target.buf = $v; }, p).WriteByte(37); continue; } - if ($interfaceIsEqual(err, $ifaceNil)) { - break; + if (!p.goodArgNum) { + new ($ptrType(buffer))(function() { return this.$target.buf; }, function($v) { this.$target.buf = $v; }, p).Write(percentBangBytes); + p.add(c); + new ($ptrType(buffer))(function() { return this.$target.buf; }, function($v) { this.$target.buf = $v; }, p).Write(badIndexBytes); + continue; + } else if (argNum >= a.$length) { + new ($ptrType(buffer))(function() { return this.$target.buf; }, function($v) { this.$target.buf = $v; }, p).Write(percentBangBytes); + p.add(c); + new ($ptrType(buffer))(function() { return this.$target.buf; }, function($v) { this.$target.buf = $v; }, p).Write(missingBytes); + continue; } - _ref = f.errorHandling; - if (_ref === 0) { - return err; - } else if (_ref === 1) { - os.Exit(2); - } else if (_ref === 2) { - $panic(err); + arg = ((argNum < 0 || argNum >= a.$length) ? $throwRuntimeError("index out of range") : a.$array[a.$offset + argNum]); + argNum = argNum + (1) >> 0; + goSyntax = (c === 118) && p.fmt.sharp; + plus = (c === 118) && p.fmt.plus; + p.printArg(arg, c, plus, goSyntax, 0); + } + if (!p.reordered && argNum < a.$length) { + new ($ptrType(buffer))(function() { return this.$target.buf; }, function($v) { this.$target.buf = $v; }, p).Write(extraBytes); + while (argNum < a.$length) { + arg$1 = ((argNum < 0 || argNum >= a.$length) ? $throwRuntimeError("index out of range") : a.$array[a.$offset + argNum]); + if (!($interfaceIsEqual(arg$1, $ifaceNil))) { + new ($ptrType(buffer))(function() { return this.$target.buf; }, function($v) { this.$target.buf = $v; }, p).WriteString(reflect.TypeOf(arg$1).String()); + new ($ptrType(buffer))(function() { return this.$target.buf; }, function($v) { this.$target.buf = $v; }, p).WriteByte(61); + } + p.printArg(arg$1, 118, false, false, 0); + if ((argNum + 1 >> 0) < a.$length) { + new ($ptrType(buffer))(function() { return this.$target.buf; }, function($v) { this.$target.buf = $v; }, p).Write(commaSpaceBytes); + } + argNum = argNum + (1) >> 0; } + new ($ptrType(buffer))(function() { return this.$target.buf; }, function($v) { this.$target.buf = $v; }, p).WriteByte(41); } - return $ifaceNil; - }; - FlagSet.prototype.Parse = function(arguments$1) { return this.$val.Parse(arguments$1); }; - FlagSet.Ptr.prototype.Parsed = function() { - var f; - f = this; - return f.parsed; - }; - FlagSet.prototype.Parsed = function() { return this.$val.Parsed(); }; - Parse = $pkg.Parse = function() { - $pkg.CommandLine.Parse($subslice(os.Args, 1)); - }; - NewFlagSet = $pkg.NewFlagSet = function(name, errorHandling) { - var f; - f = new FlagSet.Ptr($throwNilPointerError, name, false, false, false, ($sliceType($String)).nil, errorHandling, $ifaceNil); - return f; }; - FlagSet.Ptr.prototype.Init = function(name, errorHandling) { - var f; - f = this; - f.name = name; - f.errorHandling = errorHandling; - }; - FlagSet.prototype.Init = function(name, errorHandling) { return this.$val.Init(name, errorHandling); }; - $pkg.$init = function() { - ($ptrType(boolValue)).methods = [["Get", "Get", "", $funcType([], [$emptyInterface], false), -1], ["IsBoolFlag", "IsBoolFlag", "", $funcType([], [$Bool], false), -1], ["Set", "Set", "", $funcType([$String], [$error], false), -1], ["String", "String", "", $funcType([], [$String], false), -1]]; - boolFlag.init([["IsBoolFlag", "IsBoolFlag", "", $funcType([], [$Bool], false)], ["Set", "Set", "", $funcType([$String], [$error], false)], ["String", "String", "", $funcType([], [$String], false)]]); - ($ptrType(intValue)).methods = [["Get", "Get", "", $funcType([], [$emptyInterface], false), -1], ["Set", "Set", "", $funcType([$String], [$error], false), -1], ["String", "String", "", $funcType([], [$String], false), -1]]; - ($ptrType(int64Value)).methods = [["Get", "Get", "", $funcType([], [$emptyInterface], false), -1], ["Set", "Set", "", $funcType([$String], [$error], false), -1], ["String", "String", "", $funcType([], [$String], false), -1]]; - ($ptrType(uintValue)).methods = [["Get", "Get", "", $funcType([], [$emptyInterface], false), -1], ["Set", "Set", "", $funcType([$String], [$error], false), -1], ["String", "String", "", $funcType([], [$String], false), -1]]; - ($ptrType(uint64Value)).methods = [["Get", "Get", "", $funcType([], [$emptyInterface], false), -1], ["Set", "Set", "", $funcType([$String], [$error], false), -1], ["String", "String", "", $funcType([], [$String], false), -1]]; - ($ptrType(stringValue)).methods = [["Get", "Get", "", $funcType([], [$emptyInterface], false), -1], ["Set", "Set", "", $funcType([$String], [$error], false), -1], ["String", "String", "", $funcType([], [$String], false), -1]]; - ($ptrType(float64Value)).methods = [["Get", "Get", "", $funcType([], [$emptyInterface], false), -1], ["Set", "Set", "", $funcType([$String], [$error], false), -1], ["String", "String", "", $funcType([], [$String], false), -1]]; - ($ptrType(durationValue)).methods = [["Get", "Get", "", $funcType([], [$emptyInterface], false), -1], ["Set", "Set", "", $funcType([$String], [$error], false), -1], ["String", "String", "", $funcType([], [$String], false), -1]]; - Value.init([["Set", "Set", "", $funcType([$String], [$error], false)], ["String", "String", "", $funcType([], [$String], false)]]); - ($ptrType(FlagSet)).methods = [["Arg", "Arg", "", $funcType([$Int], [$String], false), -1], ["Args", "Args", "", $funcType([], [($sliceType($String))], false), -1], ["Bool", "Bool", "", $funcType([$String, $Bool, $String], [($ptrType($Bool))], false), -1], ["BoolVar", "BoolVar", "", $funcType([($ptrType($Bool)), $String, $Bool, $String], [], false), -1], ["Duration", "Duration", "", $funcType([$String, time.Duration, $String], [($ptrType(time.Duration))], false), -1], ["DurationVar", "DurationVar", "", $funcType([($ptrType(time.Duration)), $String, time.Duration, $String], [], false), -1], ["Float64", "Float64", "", $funcType([$String, $Float64, $String], [($ptrType($Float64))], false), -1], ["Float64Var", "Float64Var", "", $funcType([($ptrType($Float64)), $String, $Float64, $String], [], false), -1], ["Init", "Init", "", $funcType([$String, ErrorHandling], [], false), -1], ["Int", "Int", "", $funcType([$String, $Int, $String], [($ptrType($Int))], false), -1], ["Int64", "Int64", "", $funcType([$String, $Int64, $String], [($ptrType($Int64))], false), -1], ["Int64Var", "Int64Var", "", $funcType([($ptrType($Int64)), $String, $Int64, $String], [], false), -1], ["IntVar", "IntVar", "", $funcType([($ptrType($Int)), $String, $Int, $String], [], false), -1], ["Lookup", "Lookup", "", $funcType([$String], [($ptrType(Flag))], false), -1], ["NArg", "NArg", "", $funcType([], [$Int], false), -1], ["NFlag", "NFlag", "", $funcType([], [$Int], false), -1], ["Parse", "Parse", "", $funcType([($sliceType($String))], [$error], false), -1], ["Parsed", "Parsed", "", $funcType([], [$Bool], false), -1], ["PrintDefaults", "PrintDefaults", "", $funcType([], [], false), -1], ["Set", "Set", "", $funcType([$String, $String], [$error], false), -1], ["SetOutput", "SetOutput", "", $funcType([io.Writer], [], false), -1], ["String", "String", "", $funcType([$String, $String, $String], [($ptrType($String))], false), -1], ["StringVar", "StringVar", "", $funcType([($ptrType($String)), $String, $String, $String], [], false), -1], ["Uint", "Uint", "", $funcType([$String, $Uint, $String], [($ptrType($Uint))], false), -1], ["Uint64", "Uint64", "", $funcType([$String, $Uint64, $String], [($ptrType($Uint64))], false), -1], ["Uint64Var", "Uint64Var", "", $funcType([($ptrType($Uint64)), $String, $Uint64, $String], [], false), -1], ["UintVar", "UintVar", "", $funcType([($ptrType($Uint)), $String, $Uint, $String], [], false), -1], ["Var", "Var", "", $funcType([Value, $String, $String], [], false), -1], ["Visit", "Visit", "", $funcType([($funcType([($ptrType(Flag))], [], false))], [], false), -1], ["VisitAll", "VisitAll", "", $funcType([($funcType([($ptrType(Flag))], [], false))], [], false), -1], ["failf", "failf", "flag", $funcType([$String, ($sliceType($emptyInterface))], [$error], true), -1], ["out", "out", "flag", $funcType([], [io.Writer], false), -1], ["parseOne", "parseOne", "flag", $funcType([], [$Bool, $error], false), -1], ["usage", "usage", "flag", $funcType([], [], false), -1]]; - FlagSet.init([["Usage", "Usage", "", ($funcType([], [], false)), ""], ["name", "name", "flag", $String, ""], ["parsed", "parsed", "flag", $Bool, ""], ["actual", "actual", "flag", ($mapType($String, ($ptrType(Flag)))), ""], ["formal", "formal", "flag", ($mapType($String, ($ptrType(Flag)))), ""], ["args", "args", "flag", ($sliceType($String)), ""], ["errorHandling", "errorHandling", "flag", ErrorHandling, ""], ["output", "output", "flag", io.Writer, ""]]); - Flag.init([["Name", "Name", "", $String, ""], ["Usage", "Usage", "", $String, ""], ["Value", "Value", "", Value, ""], ["DefValue", "DefValue", "", $String, ""]]); - $pkg.ErrHelp = errors.New("flag: help requested"); - $pkg.CommandLine = NewFlagSet((x = os.Args, ((0 < 0 || 0 >= x.$length) ? $throwRuntimeError("index out of range") : x.$array[x.$offset + 0])), 1); - $pkg.Usage = (function() { - var x$1; - fmt.Fprintf(os.Stderr, "Usage of %s:\n", new ($sliceType($emptyInterface))([new $String((x$1 = os.Args, ((0 < 0 || 0 >= x$1.$length) ? $throwRuntimeError("index out of range") : x$1.$array[x$1.$offset + 0])))])); - PrintDefaults(); - }); - }; - return $pkg; -})(); -$packages["bufio"] = (function() { - var $pkg = {}, bytes = $packages["bytes"], errors = $packages["errors"], io = $packages["io"], utf8 = $packages["unicode/utf8"], Reader, errNegativeRead, NewReaderSize, NewReader; - Reader = $pkg.Reader = $newType(0, "Struct", "bufio.Reader", "Reader", "bufio", function(buf_, rd_, r_, w_, err_, lastByte_, lastRuneSize_) { - this.$val = this; - this.buf = buf_ !== undefined ? buf_ : ($sliceType($Uint8)).nil; - this.rd = rd_ !== undefined ? rd_ : $ifaceNil; - this.r = r_ !== undefined ? r_ : 0; - this.w = w_ !== undefined ? w_ : 0; - this.err = err_ !== undefined ? err_ : $ifaceNil; - this.lastByte = lastByte_ !== undefined ? lastByte_ : 0; - this.lastRuneSize = lastRuneSize_ !== undefined ? lastRuneSize_ : 0; - }); - NewReaderSize = $pkg.NewReaderSize = function(rd, size) { - var _tuple, b, ok, r; - _tuple = $assertType(rd, ($ptrType(Reader)), true); b = _tuple[0]; ok = _tuple[1]; - if (ok && b.buf.$length >= size) { - return b; + pp.prototype.doPrintf = function(format, a) { return this.$val.doPrintf(format, a); }; + pp.Ptr.prototype.doPrint = function(a, addspace, addnewline) { + var p, prevString, argNum, arg, isString; + p = this; + prevString = false; + argNum = 0; + while (argNum < a.$length) { + p.fmt.clearflags(); + arg = ((argNum < 0 || argNum >= a.$length) ? $throwRuntimeError("index out of range") : a.$array[a.$offset + argNum]); + if (argNum > 0) { + isString = !($interfaceIsEqual(arg, $ifaceNil)) && (reflect.TypeOf(arg).Kind() === 24); + if (addspace || !isString && !prevString) { + new ($ptrType(buffer))(function() { return this.$target.buf; }, function($v) { this.$target.buf = $v; }, p).WriteByte(32); + } + } + prevString = p.printArg(arg, 118, false, false, 0); + argNum = argNum + (1) >> 0; } - if (size < 16) { - size = 16; + if (addnewline) { + new ($ptrType(buffer))(function() { return this.$target.buf; }, function($v) { this.$target.buf = $v; }, p).WriteByte(10); } - r = new Reader.Ptr(); - r.reset(($sliceType($Uint8)).make(size), rd); - return r; - }; - NewReader = $pkg.NewReader = function(rd) { - return NewReaderSize(rd, 4096); - }; - Reader.Ptr.prototype.Reset = function(r) { - var b; - b = this; - b.reset(b.buf, r); }; - Reader.prototype.Reset = function(r) { return this.$val.Reset(r); }; - Reader.Ptr.prototype.reset = function(buf, r) { - var b; - b = this; - $copy(b, new Reader.Ptr(buf, r, 0, 0, $ifaceNil, -1, -1), Reader); + pp.prototype.doPrint = function(a, addspace, addnewline) { return this.$val.doPrint(a, addspace, addnewline); }; + ss.Ptr.prototype.Read = function(buf) { + var n = 0, err = $ifaceNil, s, _tmp, _tmp$1; + s = this; + _tmp = 0; _tmp$1 = errors.New("ScanState's Read should not be called. Use ReadRune"); n = _tmp; err = _tmp$1; + return [n, err]; }; - Reader.prototype.reset = function(buf, r) { return this.$val.reset(buf, r); }; - Reader.Ptr.prototype.fill = function() { - var b, i, _tuple, n, err; - b = this; - if (b.r > 0) { - $copySlice(b.buf, $subslice(b.buf, b.r, b.w)); - b.w = b.w - (b.r) >> 0; - b.r = 0; + ss.prototype.Read = function(buf) { return this.$val.Read(buf); }; + ss.Ptr.prototype.ReadRune = function() { + var r = 0, size = 0, err = $ifaceNil, s, _tuple; + s = this; + if (s.peekRune >= 0) { + s.count = s.count + (1) >> 0; + r = s.peekRune; + size = utf8.RuneLen(r); + s.prevRune = r; + s.peekRune = -1; + return [r, size, err]; } - if (b.w >= b.buf.$length) { - $panic(new $String("bufio: tried to fill full buffer")); + if (s.atEOF || s.ssave.nlIsEnd && (s.prevRune === 10) || s.count >= s.ssave.argLimit) { + err = io.EOF; + return [r, size, err]; } - i = 100; - while (i > 0) { - _tuple = b.rd.Read($subslice(b.buf, b.w)); n = _tuple[0]; err = _tuple[1]; - if (n < 0) { - $panic(errNegativeRead); - } - b.w = b.w + (n) >> 0; - if (!($interfaceIsEqual(err, $ifaceNil))) { - b.err = err; - return; - } - if (n > 0) { - return; - } - i = i - (1) >> 0; + _tuple = s.rr.ReadRune(); r = _tuple[0]; size = _tuple[1]; err = _tuple[2]; + if ($interfaceIsEqual(err, $ifaceNil)) { + s.count = s.count + (1) >> 0; + s.prevRune = r; + } else if ($interfaceIsEqual(err, io.EOF)) { + s.atEOF = true; } - b.err = io.ErrNoProgress; - }; - Reader.prototype.fill = function() { return this.$val.fill(); }; - Reader.Ptr.prototype.readErr = function() { - var b, err; - b = this; - err = b.err; - b.err = $ifaceNil; - return err; + return [r, size, err]; }; - Reader.prototype.readErr = function() { return this.$val.readErr(); }; - Reader.Ptr.prototype.Peek = function(n) { - var b, m, err; - b = this; - if (n < 0) { - return [($sliceType($Uint8)).nil, $pkg.ErrNegativeCount]; - } - if (n > b.buf.$length) { - return [($sliceType($Uint8)).nil, $pkg.ErrBufferFull]; - } - while ((b.w - b.r >> 0) < n && $interfaceIsEqual(b.err, $ifaceNil)) { - b.fill(); - } - m = b.w - b.r >> 0; - if (m > n) { - m = n; + ss.prototype.ReadRune = function() { return this.$val.ReadRune(); }; + ss.Ptr.prototype.Width = function() { + var wid = 0, ok = false, s, _tmp, _tmp$1, _tmp$2, _tmp$3; + s = this; + if (s.ssave.maxWid === 1073741824) { + _tmp = 0; _tmp$1 = false; wid = _tmp; ok = _tmp$1; + return [wid, ok]; } - err = $ifaceNil; - if (m < n) { - err = b.readErr(); - if ($interfaceIsEqual(err, $ifaceNil)) { - err = $pkg.ErrBufferFull; + _tmp$2 = s.ssave.maxWid; _tmp$3 = true; wid = _tmp$2; ok = _tmp$3; + return [wid, ok]; + }; + ss.prototype.Width = function() { return this.$val.Width(); }; + ss.Ptr.prototype.getRune = function() { + var r = 0, s, _tuple, err; + s = this; + _tuple = s.ReadRune(); r = _tuple[0]; err = _tuple[2]; + if (!($interfaceIsEqual(err, $ifaceNil))) { + if ($interfaceIsEqual(err, io.EOF)) { + r = -1; + return r; } + s.error(err); } - return [$subslice(b.buf, b.r, (b.r + m >> 0)), err]; + return r; }; - Reader.prototype.Peek = function(n) { return this.$val.Peek(n); }; - Reader.Ptr.prototype.Read = function(p) { - var n = 0, err = $ifaceNil, b, _tmp, _tmp$1, _tmp$2, _tmp$3, _tuple, x, _tmp$4, _tmp$5, _tmp$6, _tmp$7, x$1, x$2, _tmp$8, _tmp$9; - b = this; - n = p.$length; - if (n === 0) { - _tmp = 0; _tmp$1 = b.readErr(); n = _tmp; err = _tmp$1; - return [n, err]; + ss.prototype.getRune = function() { return this.$val.getRune(); }; + ss.Ptr.prototype.UnreadRune = function() { + var s, _tuple, u, ok; + s = this; + _tuple = $assertType(s.rr, runeUnreader, true); u = _tuple[0]; ok = _tuple[1]; + if (ok) { + u.UnreadRune(); + } else { + s.peekRune = s.prevRune; } - if (b.r === b.w) { - if (!($interfaceIsEqual(b.err, $ifaceNil))) { - _tmp$2 = 0; _tmp$3 = b.readErr(); n = _tmp$2; err = _tmp$3; - return [n, err]; - } - if (p.$length >= b.buf.$length) { - _tuple = b.rd.Read(p); n = _tuple[0]; b.err = _tuple[1]; - if (n < 0) { - $panic(errNegativeRead); - } - if (n > 0) { - b.lastByte = ((x = n - 1 >> 0, ((x < 0 || x >= p.$length) ? $throwRuntimeError("index out of range") : p.$array[p.$offset + x])) >> 0); - b.lastRuneSize = -1; + s.prevRune = -1; + s.count = s.count - (1) >> 0; + return $ifaceNil; + }; + ss.prototype.UnreadRune = function() { return this.$val.UnreadRune(); }; + ss.Ptr.prototype.error = function(err) { + var s, x; + s = this; + $panic((x = new scanError.Ptr(err), new x.constructor.Struct(x))); + }; + ss.prototype.error = function(err) { return this.$val.error(err); }; + ss.Ptr.prototype.errorString = function(err) { + var s, x; + s = this; + $panic((x = new scanError.Ptr(errors.New(err)), new x.constructor.Struct(x))); + }; + ss.prototype.errorString = function(err) { return this.$val.errorString(err); }; + ss.Ptr.prototype.Token = function(skipSpace, f) { + var tok = ($sliceType($Uint8)).nil, err = $ifaceNil, $deferred = [], $err = null, s; + /* */ try { $deferFrames.push($deferred); + s = this; + $deferred.push([(function() { + var e, _tuple, se, ok; + e = $recover(); + if (!($interfaceIsEqual(e, $ifaceNil))) { + _tuple = $assertType(e, scanError, true); se = new scanError.Ptr(); $copy(se, _tuple[0], scanError); ok = _tuple[1]; + if (ok) { + err = se.err; + } else { + $panic(e); } - _tmp$4 = n; _tmp$5 = b.readErr(); n = _tmp$4; err = _tmp$5; - return [n, err]; - } - b.fill(); - if (b.w === b.r) { - _tmp$6 = 0; _tmp$7 = b.readErr(); n = _tmp$6; err = _tmp$7; - return [n, err]; } + }), []]); + if (f === $throwNilPointerError) { + f = notSpace; } - if (n > (b.w - b.r >> 0)) { - n = b.w - b.r >> 0; - } - $copySlice($subslice(p, 0, n), $subslice(b.buf, b.r)); - b.r = b.r + (n) >> 0; - b.lastByte = ((x$1 = b.buf, x$2 = b.r - 1 >> 0, ((x$2 < 0 || x$2 >= x$1.$length) ? $throwRuntimeError("index out of range") : x$1.$array[x$1.$offset + x$2])) >> 0); - b.lastRuneSize = -1; - _tmp$8 = n; _tmp$9 = $ifaceNil; n = _tmp$8; err = _tmp$9; - return [n, err]; + s.buf = $subslice(s.buf, 0, 0); + tok = s.token(skipSpace, f); + return [tok, err]; + /* */ } catch(err) { $err = err; } finally { $deferFrames.pop(); $callDeferred($deferred, $err); return [tok, err]; } }; - Reader.prototype.Read = function(p) { return this.$val.Read(p); }; - Reader.Ptr.prototype.ReadByte = function() { - var c = 0, err = $ifaceNil, b, _tmp, _tmp$1, x, x$1, _tmp$2, _tmp$3; - b = this; - b.lastRuneSize = -1; - while (b.r === b.w) { - if (!($interfaceIsEqual(b.err, $ifaceNil))) { - _tmp = 0; _tmp$1 = b.readErr(); c = _tmp; err = _tmp$1; - return [c, err]; + ss.prototype.Token = function(skipSpace, f) { return this.$val.Token(skipSpace, f); }; + isSpace = function(r) { + var rx, _ref, _i, rng; + if (r >= 65536) { + return false; + } + rx = (r << 16 >>> 16); + _ref = space; + _i = 0; + while (_i < _ref.$length) { + rng = ($arrayType($Uint16, 2)).zero(); $copy(rng, ((_i < 0 || _i >= _ref.$length) ? $throwRuntimeError("index out of range") : _ref.$array[_ref.$offset + _i]), ($arrayType($Uint16, 2))); + if (rx < rng[0]) { + return false; } - b.fill(); + if (rx <= rng[1]) { + return true; + } + _i++; } - c = (x = b.buf, x$1 = b.r, ((x$1 < 0 || x$1 >= x.$length) ? $throwRuntimeError("index out of range") : x.$array[x.$offset + x$1])); - b.r = b.r + (1) >> 0; - b.lastByte = (c >> 0); - _tmp$2 = c; _tmp$3 = $ifaceNil; c = _tmp$2; err = _tmp$3; - return [c, err]; + return false; }; - Reader.prototype.ReadByte = function() { return this.$val.ReadByte(); }; - Reader.Ptr.prototype.UnreadByte = function() { - var b, x, x$1; - b = this; - if (b.lastByte < 0 || (b.r === 0) && b.w > 0) { - return $pkg.ErrInvalidUnreadByte; - } - if (b.r > 0) { - b.r = b.r - (1) >> 0; - } else { - b.w = 1; - } - (x = b.buf, x$1 = b.r, (x$1 < 0 || x$1 >= x.$length) ? $throwRuntimeError("index out of range") : x.$array[x.$offset + x$1] = (b.lastByte << 24 >>> 24)); - b.lastByte = -1; - b.lastRuneSize = -1; - return $ifaceNil; + notSpace = function(r) { + return !isSpace(r); }; - Reader.prototype.UnreadByte = function() { return this.$val.UnreadByte(); }; - Reader.Ptr.prototype.ReadRune = function() { - var r = 0, size = 0, err = $ifaceNil, b, _tmp, _tmp$1, _tmp$2, _tmp$3, x, x$1, _tmp$4, _tuple, x$2, x$3, _tmp$5, _tmp$6, _tmp$7; - b = this; - while ((b.r + 4 >> 0) > b.w && !utf8.FullRune($subslice(b.buf, b.r, b.w)) && $interfaceIsEqual(b.err, $ifaceNil) && (b.w - b.r >> 0) < b.buf.$length) { - b.fill(); - } - b.lastRuneSize = -1; - if (b.r === b.w) { - _tmp = 0; _tmp$1 = 0; _tmp$2 = b.readErr(); r = _tmp; size = _tmp$1; err = _tmp$2; - return [r, size, err]; - } - _tmp$3 = ((x = b.buf, x$1 = b.r, ((x$1 < 0 || x$1 >= x.$length) ? $throwRuntimeError("index out of range") : x.$array[x.$offset + x$1])) >> 0); _tmp$4 = 1; r = _tmp$3; size = _tmp$4; - if (r >= 128) { - _tuple = utf8.DecodeRune($subslice(b.buf, b.r, b.w)); r = _tuple[0]; size = _tuple[1]; - } - b.r = b.r + (size) >> 0; - b.lastByte = ((x$2 = b.buf, x$3 = b.r - 1 >> 0, ((x$3 < 0 || x$3 >= x$2.$length) ? $throwRuntimeError("index out of range") : x$2.$array[x$2.$offset + x$3])) >> 0); - b.lastRuneSize = size; - _tmp$5 = r; _tmp$6 = size; _tmp$7 = $ifaceNil; r = _tmp$5; size = _tmp$6; err = _tmp$7; - return [r, size, err]; + ss.Ptr.prototype.SkipSpace = function() { + var s; + s = this; + s.skipSpace(false); }; - Reader.prototype.ReadRune = function() { return this.$val.ReadRune(); }; - Reader.Ptr.prototype.UnreadRune = function() { - var b; - b = this; - if (b.lastRuneSize < 0 || b.r < b.lastRuneSize) { - return $pkg.ErrInvalidUnreadRune; + ss.prototype.SkipSpace = function() { return this.$val.SkipSpace(); }; + ss.Ptr.prototype.free = function(old) { + var s; + s = this; + if (old.validSave) { + $copy(s.ssave, old, ssave); + return; } - b.r = b.r - (b.lastRuneSize) >> 0; - b.lastByte = -1; - b.lastRuneSize = -1; - return $ifaceNil; - }; - Reader.prototype.UnreadRune = function() { return this.$val.UnreadRune(); }; - Reader.Ptr.prototype.Buffered = function() { - var b; - b = this; - return b.w - b.r >> 0; + if (s.buf.$capacity > 1024) { + return; + } + s.buf = $subslice(s.buf, 0, 0); + s.rr = $ifaceNil; + ssFree.Put(s); }; - Reader.prototype.Buffered = function() { return this.$val.Buffered(); }; - Reader.Ptr.prototype.ReadSlice = function(delim) { - var line = ($sliceType($Uint8)).nil, err = $ifaceNil, b, i, n, i$1; - b = this; + ss.prototype.free = function(old) { return this.$val.free(old); }; + ss.Ptr.prototype.skipSpace = function(stopAtNewline) { + var s, r; + s = this; while (true) { - i = bytes.IndexByte($subslice(b.buf, b.r, b.w), delim); - if (i >= 0) { - line = $subslice(b.buf, b.r, ((b.r + i >> 0) + 1 >> 0)); - b.r = b.r + ((i + 1 >> 0)) >> 0; - break; - } - if (!($interfaceIsEqual(b.err, $ifaceNil))) { - line = $subslice(b.buf, b.r, b.w); - b.r = b.w; - err = b.readErr(); - break; + r = s.getRune(); + if (r === -1) { + return; } - n = b.Buffered(); - if (n >= b.buf.$length) { - b.r = b.w; - line = b.buf; - err = $pkg.ErrBufferFull; - break; + if ((r === 13) && s.peek("\n")) { + continue; } - b.fill(); - } - i$1 = line.$length - 1 >> 0; - if (i$1 >= 0) { - b.lastByte = (((i$1 < 0 || i$1 >= line.$length) ? $throwRuntimeError("index out of range") : line.$array[line.$offset + i$1]) >> 0); - } - return [line, err]; - }; - Reader.prototype.ReadSlice = function(delim) { return this.$val.ReadSlice(delim); }; - Reader.Ptr.prototype.ReadLine = function() { - var line = ($sliceType($Uint8)).nil, isPrefix = false, err = $ifaceNil, b, _tuple, x, _tmp, _tmp$1, _tmp$2, x$1, drop, x$2; - b = this; - _tuple = b.ReadSlice(10); line = _tuple[0]; err = _tuple[1]; - if ($interfaceIsEqual(err, $pkg.ErrBufferFull)) { - if (line.$length > 0 && ((x = line.$length - 1 >> 0, ((x < 0 || x >= line.$length) ? $throwRuntimeError("index out of range") : line.$array[line.$offset + x])) === 13)) { - if (b.r === 0) { - $panic(new $String("bufio: tried to rewind past start of buffer")); + if (r === 10) { + if (stopAtNewline) { + break; } - b.r = b.r - (1) >> 0; - line = $subslice(line, 0, (line.$length - 1 >> 0)); - } - _tmp = line; _tmp$1 = true; _tmp$2 = $ifaceNil; line = _tmp; isPrefix = _tmp$1; err = _tmp$2; - return [line, isPrefix, err]; - } - if (line.$length === 0) { - if (!($interfaceIsEqual(err, $ifaceNil))) { - line = ($sliceType($Uint8)).nil; + if (s.ssave.nlIsSpace) { + continue; + } + s.errorString("unexpected newline"); + return; } - return [line, isPrefix, err]; - } - err = $ifaceNil; - if ((x$1 = line.$length - 1 >> 0, ((x$1 < 0 || x$1 >= line.$length) ? $throwRuntimeError("index out of range") : line.$array[line.$offset + x$1])) === 10) { - drop = 1; - if (line.$length > 1 && ((x$2 = line.$length - 2 >> 0, ((x$2 < 0 || x$2 >= line.$length) ? $throwRuntimeError("index out of range") : line.$array[line.$offset + x$2])) === 13)) { - drop = 2; + if (!isSpace(r)) { + s.UnreadRune(); + break; } - line = $subslice(line, 0, (line.$length - drop >> 0)); } - return [line, isPrefix, err]; }; - Reader.prototype.ReadLine = function() { return this.$val.ReadLine(); }; - Reader.Ptr.prototype.ReadBytes = function(delim) { - var line = ($sliceType($Uint8)).nil, err = $ifaceNil, b, frag, full, e, _tuple, buf, n, _ref, _i, i, buf$1, _ref$1, _i$1, i$1, _tmp, _tmp$1; - b = this; - frag = ($sliceType($Uint8)).nil; - full = ($sliceType(($sliceType($Uint8)))).nil; - err = $ifaceNil; + ss.prototype.skipSpace = function(stopAtNewline) { return this.$val.skipSpace(stopAtNewline); }; + ss.Ptr.prototype.token = function(skipSpace, f) { + var s, r, x; + s = this; + if (skipSpace) { + s.skipSpace(false); + } while (true) { - e = $ifaceNil; - _tuple = b.ReadSlice(delim); frag = _tuple[0]; e = _tuple[1]; - if ($interfaceIsEqual(e, $ifaceNil)) { + r = s.getRune(); + if (r === -1) { break; } - if (!($interfaceIsEqual(e, $pkg.ErrBufferFull))) { - err = e; + if (!f(r)) { + s.UnreadRune(); break; } - buf = ($sliceType($Uint8)).make(frag.$length); - $copySlice(buf, frag); - full = $append(full, buf); + new ($ptrType(buffer))(function() { return this.$target.buf; }, function($v) { this.$target.buf = $v; }, s).WriteRune(r); } - n = 0; - _ref = full; + return (x = s.buf, $subslice(new ($sliceType($Uint8))(x.$array), x.$offset, x.$offset + x.$length)); + }; + ss.prototype.token = function(skipSpace, f) { return this.$val.token(skipSpace, f); }; + indexRune = function(s, r) { + var _ref, _i, _rune, i, c; + _ref = s; _i = 0; - while (_i < _ref.$length) { + while (_i < _ref.length) { + _rune = $decodeRune(_ref, _i); i = _i; - n = n + (((i < 0 || i >= full.$length) ? $throwRuntimeError("index out of range") : full.$array[full.$offset + i]).$length) >> 0; - _i++; - } - n = n + (frag.$length) >> 0; - buf$1 = ($sliceType($Uint8)).make(n); - n = 0; - _ref$1 = full; - _i$1 = 0; - while (_i$1 < _ref$1.$length) { - i$1 = _i$1; - n = n + ($copySlice($subslice(buf$1, n), ((i$1 < 0 || i$1 >= full.$length) ? $throwRuntimeError("index out of range") : full.$array[full.$offset + i$1]))) >> 0; - _i$1++; + c = _rune[0]; + if (c === r) { + return i; + } + _i += _rune[1]; } - $copySlice($subslice(buf$1, n), frag); - _tmp = buf$1; _tmp$1 = err; line = _tmp; err = _tmp$1; - return [line, err]; + return -1; }; - Reader.prototype.ReadBytes = function(delim) { return this.$val.ReadBytes(delim); }; - Reader.Ptr.prototype.ReadString = function(delim) { - var line = "", err = $ifaceNil, b, _tuple, bytes$1, _tmp, _tmp$1; - b = this; - _tuple = b.ReadBytes(delim); bytes$1 = _tuple[0]; err = _tuple[1]; - line = $bytesToString(bytes$1); - _tmp = line; _tmp$1 = err; line = _tmp; err = _tmp$1; - return [line, err]; - }; - Reader.prototype.ReadString = function(delim) { return this.$val.ReadString(delim); }; - Reader.Ptr.prototype.WriteTo = function(w) { - var n = new $Int64(0, 0), err = $ifaceNil, b, _tuple, _tuple$1, r, ok, _tuple$2, m, err$1, x, _tmp, _tmp$1, _tuple$3, w$1, ok$1, _tuple$4, m$1, err$2, x$1, _tmp$2, _tmp$3, _tuple$5, m$2, err$3, x$2, _tmp$4, _tmp$5, _tmp$6, _tmp$7; - b = this; - _tuple = b.writeBuf(w); n = _tuple[0]; err = _tuple[1]; - if (!($interfaceIsEqual(err, $ifaceNil))) { - return [n, err]; - } - _tuple$1 = $assertType(b.rd, io.WriterTo, true); r = _tuple$1[0]; ok = _tuple$1[1]; - if (ok) { - _tuple$2 = r.WriteTo(w); m = _tuple$2[0]; err$1 = _tuple$2[1]; - n = (x = m, new $Int64(n.$high + x.$high, n.$low + x.$low)); - _tmp = n; _tmp$1 = err$1; n = _tmp; err = _tmp$1; - return [n, err]; - } - _tuple$3 = $assertType(w, io.ReaderFrom, true); w$1 = _tuple$3[0]; ok$1 = _tuple$3[1]; - if (ok$1) { - _tuple$4 = w$1.ReadFrom(b.rd); m$1 = _tuple$4[0]; err$2 = _tuple$4[1]; - n = (x$1 = m$1, new $Int64(n.$high + x$1.$high, n.$low + x$1.$low)); - _tmp$2 = n; _tmp$3 = err$2; n = _tmp$2; err = _tmp$3; - return [n, err]; - } - if ((b.w - b.r >> 0) < b.buf.$length) { - b.fill(); - } - while (b.r < b.w) { - _tuple$5 = b.writeBuf(w); m$2 = _tuple$5[0]; err$3 = _tuple$5[1]; - n = (x$2 = m$2, new $Int64(n.$high + x$2.$high, n.$low + x$2.$low)); - if (!($interfaceIsEqual(err$3, $ifaceNil))) { - _tmp$4 = n; _tmp$5 = err$3; n = _tmp$4; err = _tmp$5; - return [n, err]; - } - b.fill(); - } - if ($interfaceIsEqual(b.err, io.EOF)) { - b.err = $ifaceNil; - } - _tmp$6 = n; _tmp$7 = b.readErr(); n = _tmp$6; err = _tmp$7; - return [n, err]; - }; - Reader.prototype.WriteTo = function(w) { return this.$val.WriteTo(w); }; - Reader.Ptr.prototype.writeBuf = function(w) { - var b, _tuple, n, err; - b = this; - _tuple = w.Write($subslice(b.buf, b.r, b.w)); n = _tuple[0]; err = _tuple[1]; - if (n < (b.r - b.w >> 0)) { - $panic(errors.New("bufio: writer did not write all data")); + ss.Ptr.prototype.peek = function(ok) { + var s, r; + s = this; + r = s.getRune(); + if (!((r === -1))) { + s.UnreadRune(); } - b.r = b.r + (n) >> 0; - return [new $Int64(0, n), err]; + return indexRune(ok, r) >= 0; }; - Reader.prototype.writeBuf = function(w) { return this.$val.writeBuf(w); }; + ss.prototype.peek = function(ok) { return this.$val.peek(ok); }; $pkg.$init = function() { - ($ptrType(Reader)).methods = [["Buffered", "Buffered", "", $funcType([], [$Int], false), -1], ["Peek", "Peek", "", $funcType([$Int], [($sliceType($Uint8)), $error], false), -1], ["Read", "Read", "", $funcType([($sliceType($Uint8))], [$Int, $error], false), -1], ["ReadByte", "ReadByte", "", $funcType([], [$Uint8, $error], false), -1], ["ReadBytes", "ReadBytes", "", $funcType([$Uint8], [($sliceType($Uint8)), $error], false), -1], ["ReadLine", "ReadLine", "", $funcType([], [($sliceType($Uint8)), $Bool, $error], false), -1], ["ReadRune", "ReadRune", "", $funcType([], [$Int32, $Int, $error], false), -1], ["ReadSlice", "ReadSlice", "", $funcType([$Uint8], [($sliceType($Uint8)), $error], false), -1], ["ReadString", "ReadString", "", $funcType([$Uint8], [$String, $error], false), -1], ["Reset", "Reset", "", $funcType([io.Reader], [], false), -1], ["UnreadByte", "UnreadByte", "", $funcType([], [$error], false), -1], ["UnreadRune", "UnreadRune", "", $funcType([], [$error], false), -1], ["WriteTo", "WriteTo", "", $funcType([io.Writer], [$Int64, $error], false), -1], ["fill", "fill", "bufio", $funcType([], [], false), -1], ["readErr", "readErr", "bufio", $funcType([], [$error], false), -1], ["reset", "reset", "bufio", $funcType([($sliceType($Uint8)), io.Reader], [], false), -1], ["writeBuf", "writeBuf", "bufio", $funcType([io.Writer], [$Int64, $error], false), -1]]; - Reader.init([["buf", "buf", "bufio", ($sliceType($Uint8)), ""], ["rd", "rd", "bufio", io.Reader, ""], ["r", "r", "bufio", $Int, ""], ["w", "w", "bufio", $Int, ""], ["err", "err", "bufio", $error, ""], ["lastByte", "lastByte", "bufio", $Int, ""], ["lastRuneSize", "lastRuneSize", "bufio", $Int, ""]]); - $pkg.ErrInvalidUnreadByte = errors.New("bufio: invalid use of UnreadByte"); - $pkg.ErrInvalidUnreadRune = errors.New("bufio: invalid use of UnreadRune"); - $pkg.ErrBufferFull = errors.New("bufio: buffer full"); - $pkg.ErrNegativeCount = errors.New("bufio: negative count"); - errNegativeRead = errors.New("bufio: reader returned negative count from Read"); - $pkg.ErrTooLong = errors.New("bufio.Scanner: token too long"); - $pkg.ErrNegativeAdvance = errors.New("bufio.Scanner: SplitFunc returns negative advance count"); - $pkg.ErrAdvanceTooFar = errors.New("bufio.Scanner: SplitFunc returns advance count beyond input"); + ($ptrType(fmt)).methods = [["clearflags", "clearflags", "fmt", $funcType([], [], false), -1], ["computePadding", "computePadding", "fmt", $funcType([$Int], [($sliceType($Uint8)), $Int, $Int], false), -1], ["fmt_E32", "fmt_E32", "fmt", $funcType([$Float32], [], false), -1], ["fmt_E64", "fmt_E64", "fmt", $funcType([$Float64], [], false), -1], ["fmt_G32", "fmt_G32", "fmt", $funcType([$Float32], [], false), -1], ["fmt_G64", "fmt_G64", "fmt", $funcType([$Float64], [], false), -1], ["fmt_boolean", "fmt_boolean", "fmt", $funcType([$Bool], [], false), -1], ["fmt_bx", "fmt_bx", "fmt", $funcType([($sliceType($Uint8)), $String], [], false), -1], ["fmt_c128", "fmt_c128", "fmt", $funcType([$Complex128, $Int32], [], false), -1], ["fmt_c64", "fmt_c64", "fmt", $funcType([$Complex64, $Int32], [], false), -1], ["fmt_complex", "fmt_complex", "fmt", $funcType([$Float64, $Float64, $Int, $Int32], [], false), -1], ["fmt_e32", "fmt_e32", "fmt", $funcType([$Float32], [], false), -1], ["fmt_e64", "fmt_e64", "fmt", $funcType([$Float64], [], false), -1], ["fmt_f32", "fmt_f32", "fmt", $funcType([$Float32], [], false), -1], ["fmt_f64", "fmt_f64", "fmt", $funcType([$Float64], [], false), -1], ["fmt_fb32", "fmt_fb32", "fmt", $funcType([$Float32], [], false), -1], ["fmt_fb64", "fmt_fb64", "fmt", $funcType([$Float64], [], false), -1], ["fmt_g32", "fmt_g32", "fmt", $funcType([$Float32], [], false), -1], ["fmt_g64", "fmt_g64", "fmt", $funcType([$Float64], [], false), -1], ["fmt_q", "fmt_q", "fmt", $funcType([$String], [], false), -1], ["fmt_qc", "fmt_qc", "fmt", $funcType([$Int64], [], false), -1], ["fmt_s", "fmt_s", "fmt", $funcType([$String], [], false), -1], ["fmt_sbx", "fmt_sbx", "fmt", $funcType([$String, ($sliceType($Uint8)), $String], [], false), -1], ["fmt_sx", "fmt_sx", "fmt", $funcType([$String, $String], [], false), -1], ["formatFloat", "formatFloat", "fmt", $funcType([$Float64, $Uint8, $Int, $Int], [], false), -1], ["init", "init", "fmt", $funcType([($ptrType(buffer))], [], false), -1], ["integer", "integer", "fmt", $funcType([$Int64, $Uint64, $Bool, $String], [], false), -1], ["pad", "pad", "fmt", $funcType([($sliceType($Uint8))], [], false), -1], ["padString", "padString", "fmt", $funcType([$String], [], false), -1], ["truncate", "truncate", "fmt", $funcType([$String], [$String], false), -1], ["writePadding", "writePadding", "fmt", $funcType([$Int, ($sliceType($Uint8))], [], false), -1]]; + fmt.init([["intbuf", "intbuf", "fmt", ($arrayType($Uint8, 65)), ""], ["buf", "buf", "fmt", ($ptrType(buffer)), ""], ["wid", "wid", "fmt", $Int, ""], ["prec", "prec", "fmt", $Int, ""], ["widPresent", "widPresent", "fmt", $Bool, ""], ["precPresent", "precPresent", "fmt", $Bool, ""], ["minus", "minus", "fmt", $Bool, ""], ["plus", "plus", "fmt", $Bool, ""], ["sharp", "sharp", "fmt", $Bool, ""], ["space", "space", "fmt", $Bool, ""], ["unicode", "unicode", "fmt", $Bool, ""], ["uniQuote", "uniQuote", "fmt", $Bool, ""], ["zero", "zero", "fmt", $Bool, ""]]); + State.init([["Flag", "Flag", "", $funcType([$Int], [$Bool], false)], ["Precision", "Precision", "", $funcType([], [$Int, $Bool], false)], ["Width", "Width", "", $funcType([], [$Int, $Bool], false)], ["Write", "Write", "", $funcType([($sliceType($Uint8))], [$Int, $error], false)]]); + Formatter.init([["Format", "Format", "", $funcType([State, $Int32], [], false)]]); + Stringer.init([["String", "String", "", $funcType([], [$String], false)]]); + GoStringer.init([["GoString", "GoString", "", $funcType([], [$String], false)]]); + ($ptrType(buffer)).methods = [["Write", "Write", "", $funcType([($sliceType($Uint8))], [$Int, $error], false), -1], ["WriteByte", "WriteByte", "", $funcType([$Uint8], [$error], false), -1], ["WriteRune", "WriteRune", "", $funcType([$Int32], [$error], false), -1], ["WriteString", "WriteString", "", $funcType([$String], [$Int, $error], false), -1]]; + buffer.init($Uint8); + ($ptrType(pp)).methods = [["Flag", "Flag", "", $funcType([$Int], [$Bool], false), -1], ["Precision", "Precision", "", $funcType([], [$Int, $Bool], false), -1], ["Width", "Width", "", $funcType([], [$Int, $Bool], false), -1], ["Write", "Write", "", $funcType([($sliceType($Uint8))], [$Int, $error], false), -1], ["add", "add", "fmt", $funcType([$Int32], [], false), -1], ["argNumber", "argNumber", "fmt", $funcType([$Int, $String, $Int, $Int], [$Int, $Int, $Bool], false), -1], ["badVerb", "badVerb", "fmt", $funcType([$Int32], [], false), -1], ["catchPanic", "catchPanic", "fmt", $funcType([$emptyInterface, $Int32], [], false), -1], ["doPrint", "doPrint", "fmt", $funcType([($sliceType($emptyInterface)), $Bool, $Bool], [], false), -1], ["doPrintf", "doPrintf", "fmt", $funcType([$String, ($sliceType($emptyInterface))], [], false), -1], ["fmt0x64", "fmt0x64", "fmt", $funcType([$Uint64, $Bool], [], false), -1], ["fmtBool", "fmtBool", "fmt", $funcType([$Bool, $Int32], [], false), -1], ["fmtBytes", "fmtBytes", "fmt", $funcType([($sliceType($Uint8)), $Int32, $Bool, reflect.Type, $Int], [], false), -1], ["fmtC", "fmtC", "fmt", $funcType([$Int64], [], false), -1], ["fmtComplex128", "fmtComplex128", "fmt", $funcType([$Complex128, $Int32], [], false), -1], ["fmtComplex64", "fmtComplex64", "fmt", $funcType([$Complex64, $Int32], [], false), -1], ["fmtFloat32", "fmtFloat32", "fmt", $funcType([$Float32, $Int32], [], false), -1], ["fmtFloat64", "fmtFloat64", "fmt", $funcType([$Float64, $Int32], [], false), -1], ["fmtInt64", "fmtInt64", "fmt", $funcType([$Int64, $Int32], [], false), -1], ["fmtPointer", "fmtPointer", "fmt", $funcType([reflect.Value, $Int32, $Bool], [], false), -1], ["fmtString", "fmtString", "fmt", $funcType([$String, $Int32, $Bool], [], false), -1], ["fmtUint64", "fmtUint64", "fmt", $funcType([$Uint64, $Int32, $Bool], [], false), -1], ["fmtUnicode", "fmtUnicode", "fmt", $funcType([$Int64], [], false), -1], ["free", "free", "fmt", $funcType([], [], false), -1], ["handleMethods", "handleMethods", "fmt", $funcType([$Int32, $Bool, $Bool, $Int], [$Bool, $Bool], false), -1], ["printArg", "printArg", "fmt", $funcType([$emptyInterface, $Int32, $Bool, $Bool, $Int], [$Bool], false), -1], ["printReflectValue", "printReflectValue", "fmt", $funcType([reflect.Value, $Int32, $Bool, $Bool, $Int], [$Bool], false), -1], ["printValue", "printValue", "fmt", $funcType([reflect.Value, $Int32, $Bool, $Bool, $Int], [$Bool], false), -1], ["unknownType", "unknownType", "fmt", $funcType([$emptyInterface], [], false), -1]]; + pp.init([["n", "n", "fmt", $Int, ""], ["panicking", "panicking", "fmt", $Bool, ""], ["erroring", "erroring", "fmt", $Bool, ""], ["buf", "buf", "fmt", buffer, ""], ["arg", "arg", "fmt", $emptyInterface, ""], ["value", "value", "fmt", reflect.Value, ""], ["reordered", "reordered", "fmt", $Bool, ""], ["goodArgNum", "goodArgNum", "fmt", $Bool, ""], ["runeBuf", "runeBuf", "fmt", ($arrayType($Uint8, 4)), ""], ["fmt", "fmt", "fmt", fmt, ""]]); + runeUnreader.init([["UnreadRune", "UnreadRune", "", $funcType([], [$error], false)]]); + ScanState.init([["Read", "Read", "", $funcType([($sliceType($Uint8))], [$Int, $error], false)], ["ReadRune", "ReadRune", "", $funcType([], [$Int32, $Int, $error], false)], ["SkipSpace", "SkipSpace", "", $funcType([], [], false)], ["Token", "Token", "", $funcType([$Bool, ($funcType([$Int32], [$Bool], false))], [($sliceType($Uint8)), $error], false)], ["UnreadRune", "UnreadRune", "", $funcType([], [$error], false)], ["Width", "Width", "", $funcType([], [$Int, $Bool], false)]]); + scanError.init([["err", "err", "fmt", $error, ""]]); + ($ptrType(ss)).methods = [["Read", "Read", "", $funcType([($sliceType($Uint8))], [$Int, $error], false), -1], ["ReadRune", "ReadRune", "", $funcType([], [$Int32, $Int, $error], false), -1], ["SkipSpace", "SkipSpace", "", $funcType([], [], false), -1], ["Token", "Token", "", $funcType([$Bool, ($funcType([$Int32], [$Bool], false))], [($sliceType($Uint8)), $error], false), -1], ["UnreadRune", "UnreadRune", "", $funcType([], [$error], false), -1], ["Width", "Width", "", $funcType([], [$Int, $Bool], false), -1], ["accept", "accept", "fmt", $funcType([$String], [$Bool], false), -1], ["advance", "advance", "fmt", $funcType([$String], [$Int], false), -1], ["complexTokens", "complexTokens", "fmt", $funcType([], [$String, $String], false), -1], ["consume", "consume", "fmt", $funcType([$String, $Bool], [$Bool], false), -1], ["convertFloat", "convertFloat", "fmt", $funcType([$String, $Int], [$Float64], false), -1], ["convertString", "convertString", "fmt", $funcType([$Int32], [$String], false), -1], ["doScan", "doScan", "fmt", $funcType([($sliceType($emptyInterface))], [$Int, $error], false), -1], ["doScanf", "doScanf", "fmt", $funcType([$String, ($sliceType($emptyInterface))], [$Int, $error], false), -1], ["error", "error", "fmt", $funcType([$error], [], false), -1], ["errorString", "errorString", "fmt", $funcType([$String], [], false), -1], ["floatToken", "floatToken", "fmt", $funcType([], [$String], false), -1], ["free", "free", "fmt", $funcType([ssave], [], false), -1], ["getBase", "getBase", "fmt", $funcType([$Int32], [$Int, $String], false), -1], ["getRune", "getRune", "fmt", $funcType([], [$Int32], false), -1], ["hexByte", "hexByte", "fmt", $funcType([], [$Uint8, $Bool], false), -1], ["hexDigit", "hexDigit", "fmt", $funcType([$Int32], [$Int], false), -1], ["hexString", "hexString", "fmt", $funcType([], [$String], false), -1], ["mustReadRune", "mustReadRune", "fmt", $funcType([], [$Int32], false), -1], ["notEOF", "notEOF", "fmt", $funcType([], [], false), -1], ["okVerb", "okVerb", "fmt", $funcType([$Int32, $String, $String], [$Bool], false), -1], ["peek", "peek", "fmt", $funcType([$String], [$Bool], false), -1], ["quotedString", "quotedString", "fmt", $funcType([], [$String], false), -1], ["scanBasePrefix", "scanBasePrefix", "fmt", $funcType([], [$Int, $String, $Bool], false), -1], ["scanBool", "scanBool", "fmt", $funcType([$Int32], [$Bool], false), -1], ["scanComplex", "scanComplex", "fmt", $funcType([$Int32, $Int], [$Complex128], false), -1], ["scanInt", "scanInt", "fmt", $funcType([$Int32, $Int], [$Int64], false), -1], ["scanNumber", "scanNumber", "fmt", $funcType([$String, $Bool], [$String], false), -1], ["scanOne", "scanOne", "fmt", $funcType([$Int32, $emptyInterface], [], false), -1], ["scanRune", "scanRune", "fmt", $funcType([$Int], [$Int64], false), -1], ["scanUint", "scanUint", "fmt", $funcType([$Int32, $Int], [$Uint64], false), -1], ["skipSpace", "skipSpace", "fmt", $funcType([$Bool], [], false), -1], ["token", "token", "fmt", $funcType([$Bool, ($funcType([$Int32], [$Bool], false))], [($sliceType($Uint8))], false), -1]]; + ss.init([["rr", "rr", "fmt", io.RuneReader, ""], ["buf", "buf", "fmt", buffer, ""], ["peekRune", "peekRune", "fmt", $Int32, ""], ["prevRune", "prevRune", "fmt", $Int32, ""], ["count", "count", "fmt", $Int, ""], ["atEOF", "atEOF", "fmt", $Bool, ""], ["ssave", "", "fmt", ssave, ""]]); + ssave.init([["validSave", "validSave", "fmt", $Bool, ""], ["nlIsEnd", "nlIsEnd", "fmt", $Bool, ""], ["nlIsSpace", "nlIsSpace", "fmt", $Bool, ""], ["argLimit", "argLimit", "fmt", $Int, ""], ["limit", "limit", "fmt", $Int, ""], ["maxWid", "maxWid", "fmt", $Int, ""]]); + padZeroBytes = ($sliceType($Uint8)).make(65); + padSpaceBytes = ($sliceType($Uint8)).make(65); + trueBytes = new ($sliceType($Uint8))($stringToBytes("true")); + falseBytes = new ($sliceType($Uint8))($stringToBytes("false")); + commaSpaceBytes = new ($sliceType($Uint8))($stringToBytes(", ")); + nilAngleBytes = new ($sliceType($Uint8))($stringToBytes("")); + nilParenBytes = new ($sliceType($Uint8))($stringToBytes("(nil)")); + nilBytes = new ($sliceType($Uint8))($stringToBytes("nil")); + mapBytes = new ($sliceType($Uint8))($stringToBytes("map[")); + percentBangBytes = new ($sliceType($Uint8))($stringToBytes("%!")); + missingBytes = new ($sliceType($Uint8))($stringToBytes("(MISSING)")); + badIndexBytes = new ($sliceType($Uint8))($stringToBytes("(BADINDEX)")); + panicBytes = new ($sliceType($Uint8))($stringToBytes("(PANIC=")); + extraBytes = new ($sliceType($Uint8))($stringToBytes("%!(EXTRA ")); + irparenBytes = new ($sliceType($Uint8))($stringToBytes("i)")); + bytesBytes = new ($sliceType($Uint8))($stringToBytes("[]byte{")); + badWidthBytes = new ($sliceType($Uint8))($stringToBytes("%!(BADWIDTH)")); + badPrecBytes = new ($sliceType($Uint8))($stringToBytes("%!(BADPREC)")); + noVerbBytes = new ($sliceType($Uint8))($stringToBytes("%!(NOVERB)")); + ppFree = new sync.Pool.Ptr(0, 0, ($sliceType($emptyInterface)).nil, (function() { + return new pp.Ptr(); + })); + intBits = reflect.TypeOf(new $Int(0)).Bits(); + uintptrBits = reflect.TypeOf(new $Uintptr(0)).Bits(); + space = new ($sliceType(($arrayType($Uint16, 2))))([$toNativeArray("Uint16", [9, 13]), $toNativeArray("Uint16", [32, 32]), $toNativeArray("Uint16", [133, 133]), $toNativeArray("Uint16", [160, 160]), $toNativeArray("Uint16", [5760, 5760]), $toNativeArray("Uint16", [8192, 8202]), $toNativeArray("Uint16", [8232, 8233]), $toNativeArray("Uint16", [8239, 8239]), $toNativeArray("Uint16", [8287, 8287]), $toNativeArray("Uint16", [12288, 12288])]); + ssFree = new sync.Pool.Ptr(0, 0, ($sliceType($emptyInterface)).nil, (function() { + return new ss.Ptr(); + })); + complexError = errors.New("syntax error scanning complex number"); + boolError = errors.New("syntax error scanning boolean"); + init(); }; return $pkg; })(); -$packages["text/tabwriter"] = (function() { - var $pkg = {}, bytes = $packages["bytes"], io = $packages["io"], utf8 = $packages["unicode/utf8"], cell, Writer, osError, newline, tabs, vbar, hbar, handlePanic, NewWriter; - cell = $pkg.cell = $newType(0, "Struct", "tabwriter.cell", "cell", "text/tabwriter", function(size_, width_, htab_) { - this.$val = this; - this.size = size_ !== undefined ? size_ : 0; - this.width = width_ !== undefined ? width_ : 0; - this.htab = htab_ !== undefined ? htab_ : false; - }); - Writer = $pkg.Writer = $newType(0, "Struct", "tabwriter.Writer", "Writer", "text/tabwriter", function(output_, minwidth_, tabwidth_, padding_, padbytes_, flags_, buf_, pos_, cell_, endChar_, lines_, widths_) { - this.$val = this; - this.output = output_ !== undefined ? output_ : $ifaceNil; - this.minwidth = minwidth_ !== undefined ? minwidth_ : 0; - this.tabwidth = tabwidth_ !== undefined ? tabwidth_ : 0; - this.padding = padding_ !== undefined ? padding_ : 0; - this.padbytes = padbytes_ !== undefined ? padbytes_ : ($arrayType($Uint8, 8)).zero(); - this.flags = flags_ !== undefined ? flags_ : 0; - this.buf = buf_ !== undefined ? buf_ : new bytes.Buffer.Ptr(); - this.pos = pos_ !== undefined ? pos_ : 0; - this.cell = cell_ !== undefined ? cell_ : new cell.Ptr(); - this.endChar = endChar_ !== undefined ? endChar_ : 0; - this.lines = lines_ !== undefined ? lines_ : ($sliceType(($sliceType(cell)))).nil; - this.widths = widths_ !== undefined ? widths_ : ($sliceType($Int)).nil; - }); - osError = $pkg.osError = $newType(0, "Struct", "tabwriter.osError", "osError", "text/tabwriter", function(err_) { - this.$val = this; - this.err = err_ !== undefined ? err_ : $ifaceNil; - }); - Writer.Ptr.prototype.addLine = function() { - var b; - b = this; - b.lines = $append(b.lines, new ($sliceType(cell))([])); +$packages["sort"] = (function() { + var $pkg = {}, StringSlice, Search, SearchStrings, min, insertionSort, siftDown, heapSort, medianOfThree, swapRange, doPivot, quickSort, Sort, IsSorted, Strings; + StringSlice = $pkg.StringSlice = $newType(12, "Slice", "sort.StringSlice", "StringSlice", "sort", null); + Search = $pkg.Search = function(n, f) { + var _tmp, _tmp$1, i, j, _q, h; + _tmp = 0; _tmp$1 = n; i = _tmp; j = _tmp$1; + while (i < j) { + h = i + (_q = ((j - i >> 0)) / 2, (_q === _q && _q !== 1/0 && _q !== -1/0) ? _q >> 0 : $throwRuntimeError("integer divide by zero")) >> 0; + if (!f(h)) { + i = h + 1 >> 0; + } else { + j = h; + } + } + return i; }; - Writer.prototype.addLine = function() { return this.$val.addLine(); }; - Writer.Ptr.prototype.reset = function() { - var b; - b = this; - b.buf.Reset(); - b.pos = 0; - $copy(b.cell, new cell.Ptr(0, 0, false), cell); - b.endChar = 0; - b.lines = $subslice(b.lines, 0, 0); - b.widths = $subslice(b.widths, 0, 0); - b.addLine(); + SearchStrings = $pkg.SearchStrings = function(a, x) { + return Search(a.$length, (function(i) { + return ((i < 0 || i >= a.$length) ? $throwRuntimeError("index out of range") : a.$array[a.$offset + i]) >= x; + })); }; - Writer.prototype.reset = function() { return this.$val.reset(); }; - Writer.Ptr.prototype.Init = function(output, minwidth, tabwidth, padding, padchar, flags) { - var b, _ref, _i, i, x; - b = this; - if (minwidth < 0 || tabwidth < 0 || padding < 0) { - $panic(new $String("negative minwidth, tabwidth, or padding")); + StringSlice.prototype.Search = function(x) { + var p; + p = this; + return SearchStrings($subslice(new ($sliceType($String))(p.$array), p.$offset, p.$offset + p.$length), x); + }; + $ptrType(StringSlice).prototype.Search = function(x) { return this.$get().Search(x); }; + min = function(a, b) { + if (a < b) { + return a; } - b.output = output; - b.minwidth = minwidth; - b.tabwidth = tabwidth; - b.padding = padding; - _ref = b.padbytes; - _i = 0; - while (_i < 8) { - i = _i; - (x = b.padbytes, (i < 0 || i >= x.length) ? $throwRuntimeError("index out of range") : x[i] = padchar); - _i++; + return b; + }; + insertionSort = function(data, a, b) { + var i, j; + i = a + 1 >> 0; + while (i < b) { + j = i; + while (j > a && data.Less(j, j - 1 >> 0)) { + data.Swap(j, j - 1 >> 0); + j = j - (1) >> 0; + } + i = i + (1) >> 0; } - if (padchar === 9) { - flags = flags & ~(4); + }; + siftDown = function(data, lo, hi, first) { + var root, child; + root = lo; + while (true) { + child = ((((2 >>> 16 << 16) * root >> 0) + (2 << 16 >>> 16) * root) >> 0) + 1 >> 0; + if (child >= hi) { + break; + } + if ((child + 1 >> 0) < hi && data.Less(first + child >> 0, (first + child >> 0) + 1 >> 0)) { + child = child + (1) >> 0; + } + if (!data.Less(first + root >> 0, first + child >> 0)) { + return; + } + data.Swap(first + root >> 0, first + child >> 0); + root = child; } - b.flags = flags; - b.reset(); - return b; }; - Writer.prototype.Init = function(output, minwidth, tabwidth, padding, padchar, flags) { return this.$val.Init(output, minwidth, tabwidth, padding, padchar, flags); }; - Writer.Ptr.prototype.write0 = function(buf) { - var b, _tuple, n, err, x; - b = this; - _tuple = b.output.Write(buf); n = _tuple[0]; err = _tuple[1]; - if (!((n === buf.$length)) && $interfaceIsEqual(err, $ifaceNil)) { - err = io.ErrShortWrite; + heapSort = function(data, a, b) { + var first, lo, hi, _q, i, i$1; + first = a; + lo = 0; + hi = b - a >> 0; + i = (_q = ((hi - 1 >> 0)) / 2, (_q === _q && _q !== 1/0 && _q !== -1/0) ? _q >> 0 : $throwRuntimeError("integer divide by zero")); + while (i >= 0) { + siftDown(data, i, hi, first); + i = i - (1) >> 0; } - if (!($interfaceIsEqual(err, $ifaceNil))) { - $panic((x = new osError.Ptr(err), new x.constructor.Struct(x))); + i$1 = hi - 1 >> 0; + while (i$1 >= 0) { + data.Swap(first, first + i$1 >> 0); + siftDown(data, lo, i$1, first); + i$1 = i$1 - (1) >> 0; } }; - Writer.prototype.write0 = function(buf) { return this.$val.write0(buf); }; - Writer.Ptr.prototype.writeN = function(src, n) { - var b; - b = this; - while (n > src.$length) { - b.write0(src); - n = n - (src.$length) >> 0; + medianOfThree = function(data, a, b, c) { + var m0, m1, m2; + m0 = b; + m1 = a; + m2 = c; + if (data.Less(m1, m0)) { + data.Swap(m1, m0); + } + if (data.Less(m2, m1)) { + data.Swap(m2, m1); + } + if (data.Less(m1, m0)) { + data.Swap(m1, m0); } - b.write0($subslice(src, 0, n)); }; - Writer.prototype.writeN = function(src, n) { return this.$val.writeN(src, n); }; - Writer.Ptr.prototype.writePadding = function(textw, cellw, useTabs) { - var b, x, _q, x$1, n, _q$1; - b = this; - if ((b.padbytes[0] === 9) || useTabs) { - if (b.tabwidth === 0) { - return; - } - cellw = (x = (_q = (((cellw + b.tabwidth >> 0) - 1 >> 0)) / b.tabwidth, (_q === _q && _q !== 1/0 && _q !== -1/0) ? _q >> 0 : $throwRuntimeError("integer divide by zero")), x$1 = b.tabwidth, (((x >>> 16 << 16) * x$1 >> 0) + (x << 16 >>> 16) * x$1) >> 0); - n = cellw - textw >> 0; - if (n < 0) { - $panic(new $String("internal error")); - } - b.writeN(tabs, (_q$1 = (((n + b.tabwidth >> 0) - 1 >> 0)) / b.tabwidth, (_q$1 === _q$1 && _q$1 !== 1/0 && _q$1 !== -1/0) ? _q$1 >> 0 : $throwRuntimeError("integer divide by zero"))); - return; + swapRange = function(data, a, b, n) { + var i; + i = 0; + while (i < n) { + data.Swap(a + i >> 0, b + i >> 0); + i = i + (1) >> 0; } - b.writeN($subslice(new ($sliceType($Uint8))(b.padbytes), 0), cellw - textw >> 0); }; - Writer.prototype.writePadding = function(textw, cellw, useTabs) { return this.$val.writePadding(textw, cellw, useTabs); }; - Writer.Ptr.prototype.writeLines = function(pos0, line0, line1) { - var pos = 0, b, i, x, line, useTabs, _ref, _i, j, c, x$1, x$2, x$3; - b = this; - pos = pos0; - i = line0; - while (i < line1) { - line = (x = b.lines, ((i < 0 || i >= x.$length) ? $throwRuntimeError("index out of range") : x.$array[x.$offset + i])); - useTabs = !((((b.flags & 16) >>> 0) === 0)); - _ref = line; - _i = 0; - while (_i < _ref.$length) { - j = _i; - c = new cell.Ptr(); $copy(c, ((_i < 0 || _i >= _ref.$length) ? $throwRuntimeError("index out of range") : _ref.$array[_ref.$offset + _i]), cell); - if (j > 0 && !((((b.flags & 32) >>> 0) === 0))) { - b.write0(vbar); + doPivot = function(data, lo, hi) { + var midlo = 0, midhi = 0, _q, m, _q$1, s, pivot, _tmp, _tmp$1, _tmp$2, _tmp$3, a, b, c, d, n, _tmp$4, _tmp$5; + m = lo + (_q = ((hi - lo >> 0)) / 2, (_q === _q && _q !== 1/0 && _q !== -1/0) ? _q >> 0 : $throwRuntimeError("integer divide by zero")) >> 0; + if ((hi - lo >> 0) > 40) { + s = (_q$1 = ((hi - lo >> 0)) / 8, (_q$1 === _q$1 && _q$1 !== 1/0 && _q$1 !== -1/0) ? _q$1 >> 0 : $throwRuntimeError("integer divide by zero")); + medianOfThree(data, lo, lo + s >> 0, lo + ((((2 >>> 16 << 16) * s >> 0) + (2 << 16 >>> 16) * s) >> 0) >> 0); + medianOfThree(data, m, m - s >> 0, m + s >> 0); + medianOfThree(data, hi - 1 >> 0, (hi - 1 >> 0) - s >> 0, (hi - 1 >> 0) - ((((2 >>> 16 << 16) * s >> 0) + (2 << 16 >>> 16) * s) >> 0) >> 0); + } + medianOfThree(data, lo, m, hi - 1 >> 0); + pivot = lo; + _tmp = lo + 1 >> 0; _tmp$1 = lo + 1 >> 0; _tmp$2 = hi; _tmp$3 = hi; a = _tmp; b = _tmp$1; c = _tmp$2; d = _tmp$3; + while (true) { + while (b < c) { + if (data.Less(b, pivot)) { + b = b + (1) >> 0; + } else if (!data.Less(pivot, b)) { + data.Swap(a, b); + a = a + (1) >> 0; + b = b + (1) >> 0; + } else { + break; } - if (c.size === 0) { - if (j < b.widths.$length) { - b.writePadding(c.width, (x$1 = b.widths, ((j < 0 || j >= x$1.$length) ? $throwRuntimeError("index out of range") : x$1.$array[x$1.$offset + j])), useTabs); - } + } + while (b < c) { + if (data.Less(pivot, c - 1 >> 0)) { + c = c - (1) >> 0; + } else if (!data.Less(c - 1 >> 0, pivot)) { + data.Swap(c - 1 >> 0, d - 1 >> 0); + c = c - (1) >> 0; + d = d - (1) >> 0; } else { - useTabs = false; - if (((b.flags & 4) >>> 0) === 0) { - b.write0($subslice(b.buf.Bytes(), pos, (pos + c.size >> 0))); - pos = pos + (c.size) >> 0; - if (j < b.widths.$length) { - b.writePadding(c.width, (x$2 = b.widths, ((j < 0 || j >= x$2.$length) ? $throwRuntimeError("index out of range") : x$2.$array[x$2.$offset + j])), false); - } - } else { - if (j < b.widths.$length) { - b.writePadding(c.width, (x$3 = b.widths, ((j < 0 || j >= x$3.$length) ? $throwRuntimeError("index out of range") : x$3.$array[x$3.$offset + j])), false); - } - b.write0($subslice(b.buf.Bytes(), pos, (pos + c.size >> 0))); - pos = pos + (c.size) >> 0; - } + break; } - _i++; } - if ((i + 1 >> 0) === b.lines.$length) { - b.write0($subslice(b.buf.Bytes(), pos, (pos + b.cell.size >> 0))); - pos = pos + (b.cell.size) >> 0; - } else { - b.write0(newline); + if (b >= c) { + break; } - i = i + (1) >> 0; + data.Swap(b, c - 1 >> 0); + b = b + (1) >> 0; + c = c - (1) >> 0; } - return pos; + n = min(b - a >> 0, a - lo >> 0); + swapRange(data, lo, b - n >> 0, n); + n = min(hi - d >> 0, d - c >> 0); + swapRange(data, c, hi - n >> 0, n); + _tmp$4 = (lo + b >> 0) - a >> 0; _tmp$5 = hi - ((d - c >> 0)) >> 0; midlo = _tmp$4; midhi = _tmp$5; + return [midlo, midhi]; }; - Writer.prototype.writeLines = function(pos0, line0, line1) { return this.$val.writeLines(pos0, line0, line1); }; - Writer.Ptr.prototype.format = function(pos0, line0, line1) { - var pos = 0, b, column, this$1, x, line, width, discardable, x$1, c, w; - b = this; - pos = pos0; - column = b.widths.$length; - this$1 = line0; - while (this$1 < line1) { - line = (x = b.lines, ((this$1 < 0 || this$1 >= x.$length) ? $throwRuntimeError("index out of range") : x.$array[x.$offset + this$1])); - if (column < (line.$length - 1 >> 0)) { - pos = b.writeLines(pos, line0, this$1); - line0 = this$1; - width = b.minwidth; - discardable = true; - while (this$1 < line1) { - line = (x$1 = b.lines, ((this$1 < 0 || this$1 >= x$1.$length) ? $throwRuntimeError("index out of range") : x$1.$array[x$1.$offset + this$1])); - if (column < (line.$length - 1 >> 0)) { - c = new cell.Ptr(); $copy(c, ((column < 0 || column >= line.$length) ? $throwRuntimeError("index out of range") : line.$array[line.$offset + column]), cell); - w = c.width + b.padding >> 0; - if (w > width) { - width = w; - } - if (c.width > 0 || c.htab) { - discardable = false; - } - } else { - break; - } - this$1 = this$1 + (1) >> 0; - } - if (discardable && !((((b.flags & 8) >>> 0) === 0))) { - width = 0; - } - b.widths = $append(b.widths, width); - pos = b.format(pos, line0, this$1); - b.widths = $subslice(b.widths, 0, (b.widths.$length - 1 >> 0)); - line0 = this$1; + quickSort = function(data, a, b, maxDepth) { + var _tuple, mlo, mhi; + while ((b - a >> 0) > 7) { + if (maxDepth === 0) { + heapSort(data, a, b); + return; + } + maxDepth = maxDepth - (1) >> 0; + _tuple = doPivot(data, a, b); mlo = _tuple[0]; mhi = _tuple[1]; + if ((mlo - a >> 0) < (b - mhi >> 0)) { + quickSort(data, a, mlo, maxDepth); + a = mhi; + } else { + quickSort(data, mhi, b, maxDepth); + b = mlo; } - this$1 = this$1 + (1) >> 0; } - pos = b.writeLines(pos, line0, line1); - return pos; - }; - Writer.prototype.format = function(pos0, line0, line1) { return this.$val.format(pos0, line0, line1); }; - Writer.Ptr.prototype.append = function(text) { - var b; - b = this; - b.buf.Write(text); - b.cell.size = b.cell.size + (text.$length) >> 0; - }; - Writer.prototype.append = function(text) { return this.$val.append(text); }; - Writer.Ptr.prototype.updateWidth = function() { - var b; - b = this; - b.cell.width = b.cell.width + (utf8.RuneCount($subslice(b.buf.Bytes(), b.pos, b.buf.Len()))) >> 0; - b.pos = b.buf.Len(); + if ((b - a >> 0) > 1) { + insertionSort(data, a, b); + } }; - Writer.prototype.updateWidth = function() { return this.$val.updateWidth(); }; - Writer.Ptr.prototype.startEscape = function(ch) { - var b, _ref; - b = this; - _ref = ch; - if (_ref === 255) { - b.endChar = 255; - } else if (_ref === 60) { - b.endChar = 62; - } else if (_ref === 38) { - b.endChar = 59; + Sort = $pkg.Sort = function(data) { + var n, maxDepth, i, x; + n = data.Len(); + maxDepth = 0; + i = n; + while (i > 0) { + maxDepth = maxDepth + (1) >> 0; + i = (i >> $min((1), 31)) >> 0; } + maxDepth = (x = 2, (((maxDepth >>> 16 << 16) * x >> 0) + (maxDepth << 16 >>> 16) * x) >> 0); + quickSort(data, 0, n, maxDepth); }; - Writer.prototype.startEscape = function(ch) { return this.$val.startEscape(ch); }; - Writer.Ptr.prototype.endEscape = function() { - var b, _ref; - b = this; - _ref = b.endChar; - if (_ref === 255) { - b.updateWidth(); - if (((b.flags & 2) >>> 0) === 0) { - b.cell.width = b.cell.width - (2) >> 0; + IsSorted = $pkg.IsSorted = function(data) { + var n, i; + n = data.Len(); + i = n - 1 >> 0; + while (i > 0) { + if (data.Less(i, i - 1 >> 0)) { + return false; } - } else if (_ref === 62) { - } else if (_ref === 59) { - b.cell.width = b.cell.width + (1) >> 0; + i = i - (1) >> 0; } - b.pos = b.buf.Len(); - b.endChar = 0; + return true; }; - Writer.prototype.endEscape = function() { return this.$val.endEscape(); }; - Writer.Ptr.prototype.terminateCell = function(htab) { - var b, x, x$1, line; - b = this; - b.cell.htab = htab; - line = new ($ptrType(($sliceType(cell))))(function() { return (x$1 = b.lines.$length - 1 >> 0, ((x$1 < 0 || x$1 >= this.$target.$length) ? $throwRuntimeError("index out of range") : this.$target.$array[this.$target.$offset + x$1])); }, function($v) { (x = b.lines.$length - 1 >> 0, (x < 0 || x >= this.$target.$length) ? $throwRuntimeError("index out of range") : this.$target.$array[this.$target.$offset + x] = $v); }, b.lines); - line.$set($append(line.$get(), b.cell)); - $copy(b.cell, new cell.Ptr(0, 0, false), cell); - return line.$get().$length; - }; - Writer.prototype.terminateCell = function(htab) { return this.$val.terminateCell(htab); }; - handlePanic = function(err, op) { - var e, _tuple, nerr, ok; - e = $recover(); - if (!($interfaceIsEqual(e, $ifaceNil))) { - _tuple = $assertType(e, osError, true); nerr = new osError.Ptr(); $copy(nerr, _tuple[0], osError); ok = _tuple[1]; - if (ok) { - err.$set(nerr.err); - return; - } - $panic(new $String("tabwriter: panic during " + op)); - } + StringSlice.prototype.Len = function() { + var p; + p = this; + return p.$length; }; - Writer.Ptr.prototype.Flush = function() { - var err = $ifaceNil, $deferred = [], $err = null, b; - /* */ try { $deferFrames.push($deferred); - b = this; - $deferred.push([$methodVal(b, "reset"), []]); - $deferred.push([handlePanic, [new ($ptrType($error))(function() { return err; }, function($v) { err = $v; }), "Flush"]]); - if (b.cell.size > 0) { - if (!((b.endChar === 0))) { - b.endEscape(); - } - b.terminateCell(false); - } - b.format(0, 0, b.lines.$length); - return err; - /* */ } catch(err) { $err = err; } finally { $deferFrames.pop(); $callDeferred($deferred, $err); return err; } + $ptrType(StringSlice).prototype.Len = function() { return this.$get().Len(); }; + StringSlice.prototype.Less = function(i, j) { + var p; + p = this; + return ((i < 0 || i >= p.$length) ? $throwRuntimeError("index out of range") : p.$array[p.$offset + i]) < ((j < 0 || j >= p.$length) ? $throwRuntimeError("index out of range") : p.$array[p.$offset + j]); }; - Writer.prototype.Flush = function() { return this.$val.Flush(); }; - Writer.Ptr.prototype.Write = function(buf) { - var n = 0, err = $ifaceNil, $deferred = [], $err = null, b, _ref, _i, i, ch, _ref$1, ncells, j; - /* */ try { $deferFrames.push($deferred); - b = this; - $deferred.push([handlePanic, [new ($ptrType($error))(function() { return err; }, function($v) { err = $v; }), "Write"]]); - n = 0; - _ref = buf; - _i = 0; - while (_i < _ref.$length) { - i = _i; - ch = ((_i < 0 || _i >= _ref.$length) ? $throwRuntimeError("index out of range") : _ref.$array[_ref.$offset + _i]); - if (b.endChar === 0) { - _ref$1 = ch; - if (_ref$1 === 9 || _ref$1 === 11 || _ref$1 === 10 || _ref$1 === 12) { - b.append($subslice(buf, n, i)); - b.updateWidth(); - n = i + 1 >> 0; - ncells = b.terminateCell(ch === 9); - if ((ch === 10) || (ch === 12)) { - b.addLine(); - if ((ch === 12) || (ncells === 1)) { - err = b.Flush(); - if (!($interfaceIsEqual(err, $ifaceNil))) { - return [n, err]; - } - if ((ch === 12) && !((((b.flags & 32) >>> 0) === 0))) { - b.write0(hbar); - } - } - } - } else if (_ref$1 === 255) { - b.append($subslice(buf, n, i)); - b.updateWidth(); - n = i; - if (!((((b.flags & 2) >>> 0) === 0))) { - n = n + (1) >> 0; - } - b.startEscape(255); - } else if (_ref$1 === 60 || _ref$1 === 38) { - if (!((((b.flags & 1) >>> 0) === 0))) { - b.append($subslice(buf, n, i)); - b.updateWidth(); - n = i; - b.startEscape(ch); - } - } - } else { - if (ch === b.endChar) { - j = i + 1 >> 0; - if ((ch === 255) && !((((b.flags & 2) >>> 0) === 0))) { - j = i; - } - b.append($subslice(buf, n, j)); - n = i + 1 >> 0; - b.endEscape(); - } - } - _i++; - } - b.append($subslice(buf, n)); - n = buf.$length; - return [n, err]; - /* */ } catch(err) { $err = err; } finally { $deferFrames.pop(); $callDeferred($deferred, $err); return [n, err]; } + $ptrType(StringSlice).prototype.Less = function(i, j) { return this.$get().Less(i, j); }; + StringSlice.prototype.Swap = function(i, j) { + var p, _tmp, _tmp$1; + p = this; + _tmp = ((j < 0 || j >= p.$length) ? $throwRuntimeError("index out of range") : p.$array[p.$offset + j]); _tmp$1 = ((i < 0 || i >= p.$length) ? $throwRuntimeError("index out of range") : p.$array[p.$offset + i]); (i < 0 || i >= p.$length) ? $throwRuntimeError("index out of range") : p.$array[p.$offset + i] = _tmp; (j < 0 || j >= p.$length) ? $throwRuntimeError("index out of range") : p.$array[p.$offset + j] = _tmp$1; }; - Writer.prototype.Write = function(buf) { return this.$val.Write(buf); }; - NewWriter = $pkg.NewWriter = function(output, minwidth, tabwidth, padding, padchar, flags) { - return new Writer.Ptr().Init(output, minwidth, tabwidth, padding, padchar, flags); + $ptrType(StringSlice).prototype.Swap = function(i, j) { return this.$get().Swap(i, j); }; + StringSlice.prototype.Sort = function() { + var p; + p = this; + Sort(p); }; - $pkg.$init = function() { - cell.init([["size", "size", "text/tabwriter", $Int, ""], ["width", "width", "text/tabwriter", $Int, ""], ["htab", "htab", "text/tabwriter", $Bool, ""]]); - ($ptrType(Writer)).methods = [["Flush", "Flush", "", $funcType([], [$error], false), -1], ["Init", "Init", "", $funcType([io.Writer, $Int, $Int, $Int, $Uint8, $Uint], [($ptrType(Writer))], false), -1], ["Write", "Write", "", $funcType([($sliceType($Uint8))], [$Int, $error], false), -1], ["addLine", "addLine", "text/tabwriter", $funcType([], [], false), -1], ["append", "append", "text/tabwriter", $funcType([($sliceType($Uint8))], [], false), -1], ["dump", "dump", "text/tabwriter", $funcType([], [], false), -1], ["endEscape", "endEscape", "text/tabwriter", $funcType([], [], false), -1], ["format", "format", "text/tabwriter", $funcType([$Int, $Int, $Int], [$Int], false), -1], ["reset", "reset", "text/tabwriter", $funcType([], [], false), -1], ["startEscape", "startEscape", "text/tabwriter", $funcType([$Uint8], [], false), -1], ["terminateCell", "terminateCell", "text/tabwriter", $funcType([$Bool], [$Int], false), -1], ["updateWidth", "updateWidth", "text/tabwriter", $funcType([], [], false), -1], ["write0", "write0", "text/tabwriter", $funcType([($sliceType($Uint8))], [], false), -1], ["writeLines", "writeLines", "text/tabwriter", $funcType([$Int, $Int, $Int], [$Int], false), -1], ["writeN", "writeN", "text/tabwriter", $funcType([($sliceType($Uint8)), $Int], [], false), -1], ["writePadding", "writePadding", "text/tabwriter", $funcType([$Int, $Int, $Bool], [], false), -1]]; - Writer.init([["output", "output", "text/tabwriter", io.Writer, ""], ["minwidth", "minwidth", "text/tabwriter", $Int, ""], ["tabwidth", "tabwidth", "text/tabwriter", $Int, ""], ["padding", "padding", "text/tabwriter", $Int, ""], ["padbytes", "padbytes", "text/tabwriter", ($arrayType($Uint8, 8)), ""], ["flags", "flags", "text/tabwriter", $Uint, ""], ["buf", "buf", "text/tabwriter", bytes.Buffer, ""], ["pos", "pos", "text/tabwriter", $Int, ""], ["cell", "cell", "text/tabwriter", cell, ""], ["endChar", "endChar", "text/tabwriter", $Uint8, ""], ["lines", "lines", "text/tabwriter", ($sliceType(($sliceType(cell)))), ""], ["widths", "widths", "text/tabwriter", ($sliceType($Int)), ""]]); - osError.init([["err", "err", "text/tabwriter", $error, ""]]); - newline = new ($sliceType($Uint8))([10]); - tabs = new ($sliceType($Uint8))($stringToBytes("\t\t\t\t\t\t\t\t")); - vbar = new ($sliceType($Uint8))([124]); - hbar = new ($sliceType($Uint8))($stringToBytes("---\n")); + $ptrType(StringSlice).prototype.Sort = function() { return this.$get().Sort(); }; + Strings = $pkg.Strings = function(a) { + Sort($subslice(new StringSlice(a.$array), a.$offset, a.$offset + a.$length)); }; - return $pkg; -})(); -$packages["runtime/pprof"] = (function() { - var $pkg = {}, bufio = $packages["bufio"], bytes = $packages["bytes"], fmt = $packages["fmt"], io = $packages["io"], runtime = $packages["runtime"], sort = $packages["sort"], strings = $packages["strings"], sync = $packages["sync"], tabwriter = $packages["text/tabwriter"]; $pkg.$init = function() { + StringSlice.methods = [["Len", "Len", "", $funcType([], [$Int], false), -1], ["Less", "Less", "", $funcType([$Int, $Int], [$Bool], false), -1], ["Search", "Search", "", $funcType([$String], [$Int], false), -1], ["Sort", "Sort", "", $funcType([], [], false), -1], ["Swap", "Swap", "", $funcType([$Int, $Int], [], false), -1]]; + ($ptrType(StringSlice)).methods = [["Len", "Len", "", $funcType([], [$Int], false), -1], ["Less", "Less", "", $funcType([$Int, $Int], [$Bool], false), -1], ["Search", "Search", "", $funcType([$String], [$Int], false), -1], ["Sort", "Sort", "", $funcType([], [], false), -1], ["Swap", "Swap", "", $funcType([$Int, $Int], [], false), -1]]; + StringSlice.init($String); }; return $pkg; })(); -$packages["testing"] = (function() { - var $pkg = {}, flag = $packages["flag"], fmt = $packages["fmt"], os = $packages["os"], runtime = $packages["runtime"], time = $packages["time"], sync = $packages["sync"], atomic = $packages["sync/atomic"], bytes = $packages["bytes"], io = $packages["io"], strings = $packages["strings"], pprof = $packages["runtime/pprof"], strconv = $packages["strconv"], InternalBenchmark, B, BenchmarkResult, PB, InternalExample, common, T, InternalTest, matchBenchmarks, benchTime, benchmarkMemory, memStats, short$1, outputDir, chatty, coverProfile, match, memProfile, memProfileRate, cpuProfile, blockProfile, blockProfileRate, timeout, cpuListStr, parallel, init, Main, decorate; - InternalBenchmark = $pkg.InternalBenchmark = $newType(0, "Struct", "testing.InternalBenchmark", "InternalBenchmark", "testing", function(Name_, F_) { - this.$val = this; - this.Name = Name_ !== undefined ? Name_ : ""; - this.F = F_ !== undefined ? F_ : $throwNilPointerError; - }); - B = $pkg.B = $newType(0, "Struct", "testing.B", "B", "testing", function(common_, N_, previousN_, previousDuration_, benchmark_, bytes_, timerOn_, showAllocResult_, result_, parallelism_, startAllocs_, startBytes_, netAllocs_, netBytes_) { - this.$val = this; - this.common = common_ !== undefined ? common_ : new common.Ptr(); - this.N = N_ !== undefined ? N_ : 0; - this.previousN = previousN_ !== undefined ? previousN_ : 0; - this.previousDuration = previousDuration_ !== undefined ? previousDuration_ : new time.Duration(0, 0); - this.benchmark = benchmark_ !== undefined ? benchmark_ : new InternalBenchmark.Ptr(); - this.bytes = bytes_ !== undefined ? bytes_ : new $Int64(0, 0); - this.timerOn = timerOn_ !== undefined ? timerOn_ : false; - this.showAllocResult = showAllocResult_ !== undefined ? showAllocResult_ : false; - this.result = result_ !== undefined ? result_ : new BenchmarkResult.Ptr(); - this.parallelism = parallelism_ !== undefined ? parallelism_ : 0; - this.startAllocs = startAllocs_ !== undefined ? startAllocs_ : new $Uint64(0, 0); - this.startBytes = startBytes_ !== undefined ? startBytes_ : new $Uint64(0, 0); - this.netAllocs = netAllocs_ !== undefined ? netAllocs_ : new $Uint64(0, 0); - this.netBytes = netBytes_ !== undefined ? netBytes_ : new $Uint64(0, 0); - }); - BenchmarkResult = $pkg.BenchmarkResult = $newType(0, "Struct", "testing.BenchmarkResult", "BenchmarkResult", "testing", function(N_, T_, Bytes_, MemAllocs_, MemBytes_) { - this.$val = this; - this.N = N_ !== undefined ? N_ : 0; - this.T = T_ !== undefined ? T_ : new time.Duration(0, 0); - this.Bytes = Bytes_ !== undefined ? Bytes_ : new $Int64(0, 0); - this.MemAllocs = MemAllocs_ !== undefined ? MemAllocs_ : new $Uint64(0, 0); - this.MemBytes = MemBytes_ !== undefined ? MemBytes_ : new $Uint64(0, 0); - }); - PB = $pkg.PB = $newType(0, "Struct", "testing.PB", "PB", "testing", function(globalN_, grain_, cache_, bN_) { - this.$val = this; - this.globalN = globalN_ !== undefined ? globalN_ : ($ptrType($Uint64)).nil; - this.grain = grain_ !== undefined ? grain_ : new $Uint64(0, 0); - this.cache = cache_ !== undefined ? cache_ : new $Uint64(0, 0); - this.bN = bN_ !== undefined ? bN_ : new $Uint64(0, 0); - }); - InternalExample = $pkg.InternalExample = $newType(0, "Struct", "testing.InternalExample", "InternalExample", "testing", function(Name_, F_, Output_) { - this.$val = this; - this.Name = Name_ !== undefined ? Name_ : ""; - this.F = F_ !== undefined ? F_ : $throwNilPointerError; - this.Output = Output_ !== undefined ? Output_ : ""; - }); - common = $pkg.common = $newType(0, "Struct", "testing.common", "common", "testing", function(mu_, output_, failed_, skipped_, finished_, start_, duration_, self_, signal_) { - this.$val = this; - this.mu = mu_ !== undefined ? mu_ : new sync.RWMutex.Ptr(); - this.output = output_ !== undefined ? output_ : ($sliceType($Uint8)).nil; - this.failed = failed_ !== undefined ? failed_ : false; - this.skipped = skipped_ !== undefined ? skipped_ : false; - this.finished = finished_ !== undefined ? finished_ : false; - this.start = start_ !== undefined ? start_ : new time.Time.Ptr(); - this.duration = duration_ !== undefined ? duration_ : new time.Duration(0, 0); - this.self = self_ !== undefined ? self_ : $ifaceNil; - this.signal = signal_ !== undefined ? signal_ : ($chanType($emptyInterface, false, false)).nil; - }); - T = $pkg.T = $newType(0, "Struct", "testing.T", "T", "testing", function(common_, name_, startParallel_) { +$packages["flag"] = (function() { + var $pkg = {}, errors = $packages["errors"], fmt = $packages["fmt"], io = $packages["io"], os = $packages["os"], sort = $packages["sort"], strconv = $packages["strconv"], time = $packages["time"], boolValue, boolFlag, intValue, int64Value, uintValue, uint64Value, stringValue, float64Value, durationValue, Value, ErrorHandling, FlagSet, Flag, x, newBoolValue, newIntValue, newInt64Value, newUintValue, newUint64Value, newStringValue, newFloat64Value, newDurationValue, sortFlags, PrintDefaults, defaultUsage, Bool, Int, String, Duration, Parse, NewFlagSet; + boolValue = $pkg.boolValue = $newType(1, "Bool", "flag.boolValue", "boolValue", "flag", null); + boolFlag = $pkg.boolFlag = $newType(8, "Interface", "flag.boolFlag", "boolFlag", "flag", null); + intValue = $pkg.intValue = $newType(4, "Int", "flag.intValue", "intValue", "flag", null); + int64Value = $pkg.int64Value = $newType(8, "Int64", "flag.int64Value", "int64Value", "flag", null); + uintValue = $pkg.uintValue = $newType(4, "Uint", "flag.uintValue", "uintValue", "flag", null); + uint64Value = $pkg.uint64Value = $newType(8, "Uint64", "flag.uint64Value", "uint64Value", "flag", null); + stringValue = $pkg.stringValue = $newType(8, "String", "flag.stringValue", "stringValue", "flag", null); + float64Value = $pkg.float64Value = $newType(8, "Float64", "flag.float64Value", "float64Value", "flag", null); + durationValue = $pkg.durationValue = $newType(8, "Int64", "flag.durationValue", "durationValue", "flag", null); + Value = $pkg.Value = $newType(8, "Interface", "flag.Value", "Value", "flag", null); + ErrorHandling = $pkg.ErrorHandling = $newType(4, "Int", "flag.ErrorHandling", "ErrorHandling", "flag", null); + FlagSet = $pkg.FlagSet = $newType(0, "Struct", "flag.FlagSet", "FlagSet", "flag", function(Usage_, name_, parsed_, actual_, formal_, args_, errorHandling_, output_) { this.$val = this; - this.common = common_ !== undefined ? common_ : new common.Ptr(); + this.Usage = Usage_ !== undefined ? Usage_ : $throwNilPointerError; this.name = name_ !== undefined ? name_ : ""; - this.startParallel = startParallel_ !== undefined ? startParallel_ : ($chanType($Bool, false, false)).nil; + this.parsed = parsed_ !== undefined ? parsed_ : false; + this.actual = actual_ !== undefined ? actual_ : false; + this.formal = formal_ !== undefined ? formal_ : false; + this.args = args_ !== undefined ? args_ : ($sliceType($String)).nil; + this.errorHandling = errorHandling_ !== undefined ? errorHandling_ : 0; + this.output = output_ !== undefined ? output_ : $ifaceNil; }); - InternalTest = $pkg.InternalTest = $newType(0, "Struct", "testing.InternalTest", "InternalTest", "testing", function(Name_, F_) { + Flag = $pkg.Flag = $newType(0, "Struct", "flag.Flag", "Flag", "flag", function(Name_, Usage_, Value_, DefValue_) { this.$val = this; this.Name = Name_ !== undefined ? Name_ : ""; - this.F = F_ !== undefined ? F_ : $throwNilPointerError; + this.Usage = Usage_ !== undefined ? Usage_ : ""; + this.Value = Value_ !== undefined ? Value_ : $ifaceNil; + this.DefValue = DefValue_ !== undefined ? DefValue_ : ""; }); - init = function($b) { - var $this = this, $args = arguments, $r, $s = 0, x; - /* */ if(!$b) { $nonblockingCall(); }; var $f = function() { while (true) { switch ($s) { case 0: - x = false; - /* if (x) { */ if (x) {} else { $s = 1; continue; } - $r = Main($throwNilPointerError, ($sliceType(InternalTest)).nil, ($sliceType(InternalBenchmark)).nil, ($sliceType(InternalExample)).nil, true); /* */ $s = 2; case 2: if ($r && $r.$blocking) { $r = $r(); } - /* } */ case 1: - /* */ case -1: } return; } }; $f.$blocking = true; return $f; - }; - Main = $pkg.Main = function(matchString, tests, benchmarks, examples, $b) { - var $this = this, $args = arguments, $r, $s = 0, failed, _ref, _i, err, done, t, test, _r, _tuple, e, ok; - /* */ if(!$b) { $nonblockingCall(); }; var $f = function() { while (true) { switch ($s) { case 0: - flag.Parse(); - if (tests.$length === 0) { - fmt.Println(new ($sliceType($emptyInterface))([new $String("testing: warning: no tests to run")])); - } - failed = false; - _ref = tests; - _i = 0; - /* while (_i < _ref.$length) { */ case 1: if(!(_i < _ref.$length)) { $s = 2; continue; } - err = [undefined]; - done = [undefined]; - t = [undefined]; - test = new InternalTest.Ptr(); $copy(test, ((_i < 0 || _i >= _ref.$length) ? $throwRuntimeError("index out of range") : _ref.$array[_ref.$offset + _i]), InternalTest); - t[0] = new T.Ptr(new common.Ptr(new sync.RWMutex.Ptr(), ($sliceType($Uint8)).nil, false, false, false, time.Now(), new time.Duration(0, 0), $ifaceNil, ($chanType($emptyInterface, false, false)).nil), test.Name, ($chanType($Bool, false, false)).nil); - t[0].common.self = t[0]; - if (chatty.$get()) { - fmt.Printf("=== RUN %s\n", new ($sliceType($emptyInterface))([new $String(t[0].name)])); - } - done[0] = new ($chanType(($structType([])), false, false))(0); - err[0] = $ifaceNil; - $go((function(done, err, t) { return function($b) { - var $this = this, $args = arguments, $r, $deferred = [], $err = null, $s = 0; - /* */ if(!$b) { $nonblockingCall(); }; var $f = function() { try { $deferFrames.push($deferred); while (true) { switch ($s) { case 0: - $deferred.push([(function(done, err, t) { return function() { - err[0] = $recover(); - $close(done[0]); - }; })(done, err, t), [true]]); - $r = test.F(t[0], true); /* */ $s = 1; case 1: if ($r && $r.$blocking) { $r = $r(); } - /* */ case -1: } return; } } catch(err) { $err = err; } finally { $deferFrames.pop(); if ($curGoroutine.asleep && !$jumpToDefer) { throw null; } $s = -1; $callDeferred($deferred, $err); } }; $f.$blocking = true; return $f; - }; })(done, err, t), []); - _r = $recv(done[0], true); /* */ $s = 3; case 3: if (_r && _r.$blocking) { _r = _r(); } - _r[0]; - t[0].common.duration = time.Now().Sub($clone(t[0].common.start, time.Time)); - _tuple = $assertType(err[0], ($ptrType(runtime.NotSupportedError)), true); e = _tuple[0]; ok = _tuple[1]; - if (ok) { - t[0].common.log(e.Error()); - t[0].common.skip(); - err[0] = $ifaceNil; - } - if (!($interfaceIsEqual(err[0], $ifaceNil))) { - t[0].common.Fail(); - } - t[0].report(); - if (!($interfaceIsEqual(err[0], $ifaceNil))) { - $panic(err[0]); - } - failed = failed || t[0].common.failed; - _i++; - /* } */ $s = 1; continue; case 2: - if (failed) { - os.Exit(1); - } - os.Exit(0); - /* */ case -1: } return; } }; $f.$blocking = true; return $f; - }; - B.Ptr.prototype.StartTimer = function() { - var b; - b = this; - if (!b.timerOn) { - runtime.ReadMemStats(memStats); - b.startAllocs = memStats.Mallocs; - b.startBytes = memStats.TotalAlloc; - $copy(b.common.start, time.Now(), time.Time); - b.timerOn = true; - } + newBoolValue = function(val, p) { + p.$set(val); + return new ($ptrType(boolValue))(p.$get, p.$set); }; - B.prototype.StartTimer = function() { return this.$val.StartTimer(); }; - B.Ptr.prototype.StopTimer = function() { - var b, x, x$1, x$2, x$3, x$4, x$5, x$6, x$7, x$8, x$9; + $ptrType(boolValue).prototype.Set = function(s) { + var b, _tuple, v, err; b = this; - if (b.timerOn) { - b.common.duration = (x = b.common.duration, x$1 = time.Now().Sub($clone(b.common.start, time.Time)), new time.Duration(x.$high + x$1.$high, x.$low + x$1.$low)); - runtime.ReadMemStats(memStats); - b.netAllocs = (x$2 = b.netAllocs, x$3 = (x$4 = memStats.Mallocs, x$5 = b.startAllocs, new $Uint64(x$4.$high - x$5.$high, x$4.$low - x$5.$low)), new $Uint64(x$2.$high + x$3.$high, x$2.$low + x$3.$low)); - b.netBytes = (x$6 = b.netBytes, x$7 = (x$8 = memStats.TotalAlloc, x$9 = b.startBytes, new $Uint64(x$8.$high - x$9.$high, x$8.$low - x$9.$low)), new $Uint64(x$6.$high + x$7.$high, x$6.$low + x$7.$low)); - b.timerOn = false; - } + _tuple = strconv.ParseBool(s); v = _tuple[0]; err = _tuple[1]; + b.$set(v); + return err; }; - B.prototype.StopTimer = function() { return this.$val.StopTimer(); }; - B.Ptr.prototype.ResetTimer = function() { + $ptrType(boolValue).prototype.Get = function() { var b; b = this; - if (b.timerOn) { - runtime.ReadMemStats(memStats); - b.startAllocs = memStats.Mallocs; - b.startBytes = memStats.TotalAlloc; - $copy(b.common.start, time.Now(), time.Time); - } - b.common.duration = new time.Duration(0, 0); - b.netAllocs = new $Uint64(0, 0); - b.netBytes = new $Uint64(0, 0); + return new $Bool(b.$get()); }; - B.prototype.ResetTimer = function() { return this.$val.ResetTimer(); }; - B.Ptr.prototype.SetBytes = function(n) { + $ptrType(boolValue).prototype.String = function() { var b; b = this; - b.bytes = n; + return fmt.Sprintf("%v", new ($sliceType($emptyInterface))([new boolValue(b.$get())])); }; - B.prototype.SetBytes = function(n) { return this.$val.SetBytes(n); }; - B.Ptr.prototype.ReportAllocs = function() { + $ptrType(boolValue).prototype.IsBoolFlag = function() { var b; b = this; - b.showAllocResult = true; + return true; }; - B.prototype.ReportAllocs = function() { return this.$val.ReportAllocs(); }; - BenchmarkResult.Ptr.prototype.NsPerOp = function() { - var r; - r = new BenchmarkResult.Ptr(); $copy(r, this, BenchmarkResult); - if (r.N <= 0) { - return new $Int64(0, 0); - } - return $div64(r.T.Nanoseconds(), new $Int64(0, r.N), false); + newIntValue = function(val, p) { + p.$set(val); + return new ($ptrType(intValue))(p.$get, p.$set); }; - BenchmarkResult.prototype.NsPerOp = function() { return this.$val.NsPerOp(); }; - BenchmarkResult.Ptr.prototype.mbPerSec = function() { - var r, x, x$1; - r = new BenchmarkResult.Ptr(); $copy(r, this, BenchmarkResult); - if ((x = r.Bytes, (x.$high < 0 || (x.$high === 0 && x.$low <= 0))) || (x$1 = r.T, (x$1.$high < 0 || (x$1.$high === 0 && x$1.$low <= 0))) || r.N <= 0) { - return 0; - } - return ($flatten64(r.Bytes) * r.N / 1e+06) / r.T.Seconds(); + $ptrType(intValue).prototype.Set = function(s) { + var i, _tuple, v, err; + i = this; + _tuple = strconv.ParseInt(s, 0, 64); v = _tuple[0]; err = _tuple[1]; + i.$set(((v.$low + ((v.$high >> 31) * 4294967296)) >> 0)); + return err; }; - BenchmarkResult.prototype.mbPerSec = function() { return this.$val.mbPerSec(); }; - BenchmarkResult.Ptr.prototype.AllocsPerOp = function() { - var r, x; - r = new BenchmarkResult.Ptr(); $copy(r, this, BenchmarkResult); - if (r.N <= 0) { - return new $Int64(0, 0); - } - return $div64((x = r.MemAllocs, new $Int64(x.$high, x.$low)), new $Int64(0, r.N), false); + $ptrType(intValue).prototype.Get = function() { + var i; + i = this; + return new $Int((i.$get() >> 0)); }; - BenchmarkResult.prototype.AllocsPerOp = function() { return this.$val.AllocsPerOp(); }; - BenchmarkResult.Ptr.prototype.AllocedBytesPerOp = function() { - var r, x; - r = new BenchmarkResult.Ptr(); $copy(r, this, BenchmarkResult); - if (r.N <= 0) { - return new $Int64(0, 0); - } - return $div64((x = r.MemBytes, new $Int64(x.$high, x.$low)), new $Int64(0, r.N), false); + $ptrType(intValue).prototype.String = function() { + var i; + i = this; + return fmt.Sprintf("%v", new ($sliceType($emptyInterface))([new intValue(i.$get())])); }; - BenchmarkResult.prototype.AllocedBytesPerOp = function() { return this.$val.AllocedBytesPerOp(); }; - BenchmarkResult.Ptr.prototype.String = function() { - var r, mbs, mb, nsop, ns; - r = new BenchmarkResult.Ptr(); $copy(r, this, BenchmarkResult); - mbs = r.mbPerSec(); - mb = ""; - if (!((mbs === 0))) { - mb = fmt.Sprintf("\t%7.2f MB/s", new ($sliceType($emptyInterface))([new $Float64(mbs)])); - } - nsop = r.NsPerOp(); - ns = fmt.Sprintf("%10d ns/op", new ($sliceType($emptyInterface))([nsop])); - if (r.N > 0 && (nsop.$high < 0 || (nsop.$high === 0 && nsop.$low < 100))) { - if ((nsop.$high < 0 || (nsop.$high === 0 && nsop.$low < 10))) { - ns = fmt.Sprintf("%13.2f ns/op", new ($sliceType($emptyInterface))([new $Float64($flatten64(r.T.Nanoseconds()) / r.N)])); - } else { - ns = fmt.Sprintf("%12.1f ns/op", new ($sliceType($emptyInterface))([new $Float64($flatten64(r.T.Nanoseconds()) / r.N)])); - } - } - return fmt.Sprintf("%8d\t%s%s", new ($sliceType($emptyInterface))([new $Int(r.N), new $String(ns), new $String(mb)])); + newInt64Value = function(val, p) { + p.$set(val); + return new ($ptrType(int64Value))(p.$get, p.$set); }; - BenchmarkResult.prototype.String = function() { return this.$val.String(); }; - BenchmarkResult.Ptr.prototype.MemString = function() { - var r; - r = new BenchmarkResult.Ptr(); $copy(r, this, BenchmarkResult); - return fmt.Sprintf("%8d B/op\t%8d allocs/op", new ($sliceType($emptyInterface))([r.AllocedBytesPerOp(), r.AllocsPerOp()])); + $ptrType(int64Value).prototype.Set = function(s) { + var i, _tuple, v, err; + i = this; + _tuple = strconv.ParseInt(s, 0, 64); v = _tuple[0]; err = _tuple[1]; + i.$set(new int64Value(v.$high, v.$low)); + return err; }; - BenchmarkResult.prototype.MemString = function() { return this.$val.MemString(); }; - PB.Ptr.prototype.Next = function() { - var pb, x, n, x$1, x$2, x$3, x$4, x$5, x$6, x$7, x$8, x$9; - pb = this; - if ((x = pb.cache, (x.$high === 0 && x.$low === 0))) { - n = atomic.AddUint64(pb.globalN, pb.grain); - if ((x$1 = pb.bN, (n.$high < x$1.$high || (n.$high === x$1.$high && n.$low <= x$1.$low)))) { - pb.cache = pb.grain; - } else if ((x$2 = (x$3 = pb.bN, x$4 = pb.grain, new $Uint64(x$3.$high + x$4.$high, x$3.$low + x$4.$low)), (n.$high < x$2.$high || (n.$high === x$2.$high && n.$low < x$2.$low)))) { - pb.cache = (x$5 = (x$6 = pb.bN, x$7 = pb.grain, new $Uint64(x$6.$high + x$7.$high, x$6.$low + x$7.$low)), new $Uint64(x$5.$high - n.$high, x$5.$low - n.$low)); - } else { - return false; - } - } - pb.cache = (x$8 = pb.cache, x$9 = new $Uint64(0, 1), new $Uint64(x$8.$high - x$9.$high, x$8.$low - x$9.$low)); - return true; + $ptrType(int64Value).prototype.Get = function() { + var i, x$1; + i = this; + return (x$1 = i.$get(), new $Int64(x$1.$high, x$1.$low)); }; - PB.prototype.Next = function() { return this.$val.Next(); }; - B.Ptr.prototype.RunParallel = function(body) { - var b, grain, x, x$1, n, x$2, x$3, numProcs, wg, p, x$4; - b = this; - grain = new $Uint64(0, 0); - if (b.previousN > 0 && (x = b.previousDuration, (x.$high > 0 || (x.$high === 0 && x.$low > 0)))) { - grain = $div64($mul64(new $Uint64(0, 100000), new $Uint64(0, b.previousN)), (x$1 = b.previousDuration, new $Uint64(x$1.$high, x$1.$low)), false); - } - if ((grain.$high < 0 || (grain.$high === 0 && grain.$low < 1))) { - grain = new $Uint64(0, 1); - } - if ((grain.$high > 0 || (grain.$high === 0 && grain.$low > 10000))) { - grain = new $Uint64(0, 10000); - } - n = new $Uint64(0, 0); - numProcs = (x$2 = b.parallelism, x$3 = runtime.GOMAXPROCS(0), (((x$2 >>> 16 << 16) * x$3 >> 0) + (x$2 << 16 >>> 16) * x$3) >> 0); - wg = new sync.WaitGroup.Ptr(); $copy(wg, new sync.WaitGroup.Ptr(), sync.WaitGroup); - wg.Add(numProcs); - p = 0; - while (p < numProcs) { - $go((function() { - var $deferred = [], $err = null, pb; - /* */ try { $deferFrames.push($deferred); - $deferred.push([$methodVal(wg, "Done"), []]); - pb = new PB.Ptr(new ($ptrType($Uint64))(function() { return n; }, function($v) { n = $v; }), grain, new $Uint64(0, 0), new $Uint64(0, b.N)); - body(pb); - /* */ } catch(err) { $err = err; } finally { $deferFrames.pop(); $callDeferred($deferred, $err); } - }), []); - p = p + (1) >> 0; - } - wg.Wait(); - if ((x$4 = new $Uint64(0, b.N), (n.$high < x$4.$high || (n.$high === x$4.$high && n.$low <= x$4.$low))) && !b.common.Failed()) { - b.common.Fatal(new ($sliceType($emptyInterface))([new $String("RunParallel: body exited without pb.Next() == false")])); - } + $ptrType(int64Value).prototype.String = function() { + var i; + i = this; + return fmt.Sprintf("%v", new ($sliceType($emptyInterface))([i.$get()])); }; - B.prototype.RunParallel = function(body) { return this.$val.RunParallel(body); }; - B.Ptr.prototype.SetParallelism = function(p) { - var b; - b = this; - if (p >= 1) { - b.parallelism = p; - } + newUintValue = function(val, p) { + p.$set(val); + return new ($ptrType(uintValue))(p.$get, p.$set); }; - B.prototype.SetParallelism = function(p) { return this.$val.SetParallelism(p); }; - decorate = function(s) { - var _tuple, file, line, ok, index, buf, lines, l, x, _ref, _i, i, line$1; - _tuple = runtime.Caller(3); file = _tuple[1]; line = _tuple[2]; ok = _tuple[3]; - if (ok) { - index = strings.LastIndex(file, "/"); - if (index >= 0) { - file = file.substring((index + 1 >> 0)); - } else { - index = strings.LastIndex(file, "\\"); - if (index >= 0) { - file = file.substring((index + 1 >> 0)); - } - } - } else { - file = "???"; - line = 1; - } - buf = new bytes.Buffer.Ptr(); - buf.WriteByte(9); - fmt.Fprintf(buf, "%s:%d: ", new ($sliceType($emptyInterface))([new $String(file), new $Int(line)])); - lines = strings.Split(s, "\n"); - l = lines.$length; - if (l > 1 && (x = l - 1 >> 0, ((x < 0 || x >= lines.$length) ? $throwRuntimeError("index out of range") : lines.$array[lines.$offset + x])) === "") { - lines = $subslice(lines, 0, (l - 1 >> 0)); - } - _ref = lines; - _i = 0; - while (_i < _ref.$length) { - i = _i; - line$1 = ((_i < 0 || _i >= _ref.$length) ? $throwRuntimeError("index out of range") : _ref.$array[_ref.$offset + _i]); - if (i > 0) { - buf.WriteString("\n\t\t"); - } - buf.WriteString(line$1); - _i++; - } - buf.WriteByte(10); - return buf.String(); - }; - common.Ptr.prototype.Fail = function() { - var $deferred = [], $err = null, c; - /* */ try { $deferFrames.push($deferred); - c = this; - c.mu.Lock(); - $deferred.push([$methodVal(c.mu, "Unlock"), []]); - c.failed = true; - /* */ } catch(err) { $err = err; } finally { $deferFrames.pop(); $callDeferred($deferred, $err); } + $ptrType(uintValue).prototype.Set = function(s) { + var i, _tuple, v, err; + i = this; + _tuple = strconv.ParseUint(s, 0, 64); v = _tuple[0]; err = _tuple[1]; + i.$set((v.$low >>> 0)); + return err; }; - common.prototype.Fail = function() { return this.$val.Fail(); }; - common.Ptr.prototype.Failed = function() { - var $deferred = [], $err = null, c; - /* */ try { $deferFrames.push($deferred); - c = this; - c.mu.RLock(); - $deferred.push([$methodVal(c.mu, "RUnlock"), []]); - return c.failed; - /* */ } catch(err) { $err = err; return false; } finally { $deferFrames.pop(); $callDeferred($deferred, $err); } + $ptrType(uintValue).prototype.Get = function() { + var i; + i = this; + return new $Uint((i.$get() >>> 0)); }; - common.prototype.Failed = function() { return this.$val.Failed(); }; - common.Ptr.prototype.FailNow = function() { - var c; - c = this; - c.Fail(); - c.finished = true; - runtime.Goexit(); + $ptrType(uintValue).prototype.String = function() { + var i; + i = this; + return fmt.Sprintf("%v", new ($sliceType($emptyInterface))([new uintValue(i.$get())])); }; - common.prototype.FailNow = function() { return this.$val.FailNow(); }; - common.Ptr.prototype.log = function(s) { - var $deferred = [], $err = null, c; - /* */ try { $deferFrames.push($deferred); - c = this; - c.mu.Lock(); - $deferred.push([$methodVal(c.mu, "Unlock"), []]); - c.output = $appendSlice(c.output, new ($sliceType($Uint8))($stringToBytes(decorate(s)))); - /* */ } catch(err) { $err = err; } finally { $deferFrames.pop(); $callDeferred($deferred, $err); } + newUint64Value = function(val, p) { + p.$set(val); + return new ($ptrType(uint64Value))(p.$get, p.$set); }; - common.prototype.log = function(s) { return this.$val.log(s); }; - common.Ptr.prototype.Log = function(args) { - var c; - c = this; - c.log(fmt.Sprintln(args)); + $ptrType(uint64Value).prototype.Set = function(s) { + var i, _tuple, v, err; + i = this; + _tuple = strconv.ParseUint(s, 0, 64); v = _tuple[0]; err = _tuple[1]; + i.$set(new uint64Value(v.$high, v.$low)); + return err; }; - common.prototype.Log = function(args) { return this.$val.Log(args); }; - common.Ptr.prototype.Logf = function(format, args) { - var c; - c = this; - c.log(fmt.Sprintf(format, args)); + $ptrType(uint64Value).prototype.Get = function() { + var i, x$1; + i = this; + return (x$1 = i.$get(), new $Uint64(x$1.$high, x$1.$low)); }; - common.prototype.Logf = function(format, args) { return this.$val.Logf(format, args); }; - common.Ptr.prototype.Error = function(args) { - var c; - c = this; - c.log(fmt.Sprintln(args)); - c.Fail(); + $ptrType(uint64Value).prototype.String = function() { + var i; + i = this; + return fmt.Sprintf("%v", new ($sliceType($emptyInterface))([i.$get()])); }; - common.prototype.Error = function(args) { return this.$val.Error(args); }; - common.Ptr.prototype.Errorf = function(format, args) { - var c; - c = this; - c.log(fmt.Sprintf(format, args)); - c.Fail(); + newStringValue = function(val, p) { + p.$set(val); + return new ($ptrType(stringValue))(p.$get, p.$set); }; - common.prototype.Errorf = function(format, args) { return this.$val.Errorf(format, args); }; - common.Ptr.prototype.Fatal = function(args) { - var c; - c = this; - c.log(fmt.Sprintln(args)); - c.FailNow(); + $ptrType(stringValue).prototype.Set = function(val) { + var s; + s = this; + s.$set(val); + return $ifaceNil; }; - common.prototype.Fatal = function(args) { return this.$val.Fatal(args); }; - common.Ptr.prototype.Fatalf = function(format, args) { - var c; - c = this; - c.log(fmt.Sprintf(format, args)); - c.FailNow(); + $ptrType(stringValue).prototype.Get = function() { + var s; + s = this; + return new $String(s.$get()); }; - common.prototype.Fatalf = function(format, args) { return this.$val.Fatalf(format, args); }; - common.Ptr.prototype.Skip = function(args) { - var c; - c = this; - c.log(fmt.Sprintln(args)); - c.SkipNow(); + $ptrType(stringValue).prototype.String = function() { + var s; + s = this; + return fmt.Sprintf("%s", new ($sliceType($emptyInterface))([new stringValue(s.$get())])); }; - common.prototype.Skip = function(args) { return this.$val.Skip(args); }; - common.Ptr.prototype.Skipf = function(format, args) { - var c; - c = this; - c.log(fmt.Sprintf(format, args)); - c.SkipNow(); + newFloat64Value = function(val, p) { + p.$set(val); + return new ($ptrType(float64Value))(p.$get, p.$set); }; - common.prototype.Skipf = function(format, args) { return this.$val.Skipf(format, args); }; - common.Ptr.prototype.SkipNow = function() { - var c; - c = this; - c.skip(); - c.finished = true; - runtime.Goexit(); + $ptrType(float64Value).prototype.Set = function(s) { + var f, _tuple, v, err; + f = this; + _tuple = strconv.ParseFloat(s, 64); v = _tuple[0]; err = _tuple[1]; + f.$set(v); + return err; }; - common.prototype.SkipNow = function() { return this.$val.SkipNow(); }; - common.Ptr.prototype.skip = function() { - var $deferred = [], $err = null, c; - /* */ try { $deferFrames.push($deferred); - c = this; - c.mu.Lock(); - $deferred.push([$methodVal(c.mu, "Unlock"), []]); - c.skipped = true; - /* */ } catch(err) { $err = err; } finally { $deferFrames.pop(); $callDeferred($deferred, $err); } + $ptrType(float64Value).prototype.Get = function() { + var f; + f = this; + return new $Float64(f.$get()); }; - common.prototype.skip = function() { return this.$val.skip(); }; - common.Ptr.prototype.Skipped = function() { - var $deferred = [], $err = null, c; - /* */ try { $deferFrames.push($deferred); - c = this; - c.mu.RLock(); - $deferred.push([$methodVal(c.mu, "RUnlock"), []]); - return c.skipped; - /* */ } catch(err) { $err = err; return false; } finally { $deferFrames.pop(); $callDeferred($deferred, $err); } + $ptrType(float64Value).prototype.String = function() { + var f; + f = this; + return fmt.Sprintf("%v", new ($sliceType($emptyInterface))([new float64Value(f.$get())])); }; - common.prototype.Skipped = function() { return this.$val.Skipped(); }; - T.Ptr.prototype.Parallel = function($b) { - var $this = this, $args = arguments, $r, $s = 0, t, _r; - /* */ if(!$b) { $nonblockingCall(); }; var $f = function() { while (true) { switch ($s) { case 0: - t = $this; - $r = $send(t.common.signal, ($ptrType(T)).nil, true); /* */ $s = 1; case 1: if ($r && $r.$blocking) { $r = $r(); } - _r = $recv(t.startParallel, true); /* */ $s = 2; case 2: if (_r && _r.$blocking) { _r = _r(); } - _r[0]; - $copy(t.common.start, time.Now(), time.Time); - /* */ case -1: } return; } }; $f.$blocking = true; return $f; + newDurationValue = function(val, p) { + p.$set(val); + return new ($ptrType(durationValue))(p.$get, p.$set); }; - T.prototype.Parallel = function($b) { return this.$val.Parallel($b); }; - T.Ptr.prototype.report = function() { - var t, tstr, format; - t = this; - tstr = fmt.Sprintf("(%.2f seconds)", new ($sliceType($emptyInterface))([new $Float64(t.common.duration.Seconds())])); - format = "--- %s: %s %s\n%s"; - if (t.common.Failed()) { - fmt.Printf(format, new ($sliceType($emptyInterface))([new $String("FAIL"), new $String(t.name), new $String(tstr), t.common.output])); - } else if (chatty.$get()) { - if (t.common.Skipped()) { - fmt.Printf(format, new ($sliceType($emptyInterface))([new $String("SKIP"), new $String(t.name), new $String(tstr), t.common.output])); - } else { - fmt.Printf(format, new ($sliceType($emptyInterface))([new $String("PASS"), new $String(t.name), new $String(tstr), t.common.output])); - } - } + $ptrType(durationValue).prototype.Set = function(s) { + var d, _tuple, v, err; + d = this; + _tuple = time.ParseDuration(s); v = _tuple[0]; err = _tuple[1]; + d.$set(new durationValue(v.$high, v.$low)); + return err; }; - T.prototype.report = function() { return this.$val.report(); }; - $pkg.$init = function() { - /* */ var $r, $s = 0; var $f = function() { while (true) { switch ($s) { case 0: - InternalBenchmark.init([["Name", "Name", "", $String, ""], ["F", "F", "", ($funcType([($ptrType(B))], [], false)), ""]]); - ($ptrType(B)).methods = [["Error", "Error", "", $funcType([($sliceType($emptyInterface))], [], true), 0], ["Errorf", "Errorf", "", $funcType([$String, ($sliceType($emptyInterface))], [], true), 0], ["Fail", "Fail", "", $funcType([], [], false), 0], ["FailNow", "FailNow", "", $funcType([], [], false), 0], ["Failed", "Failed", "", $funcType([], [$Bool], false), 0], ["Fatal", "Fatal", "", $funcType([($sliceType($emptyInterface))], [], true), 0], ["Fatalf", "Fatalf", "", $funcType([$String, ($sliceType($emptyInterface))], [], true), 0], ["Log", "Log", "", $funcType([($sliceType($emptyInterface))], [], true), 0], ["Logf", "Logf", "", $funcType([$String, ($sliceType($emptyInterface))], [], true), 0], ["ReportAllocs", "ReportAllocs", "", $funcType([], [], false), -1], ["ResetTimer", "ResetTimer", "", $funcType([], [], false), -1], ["RunParallel", "RunParallel", "", $funcType([($funcType([($ptrType(PB))], [], false))], [], false), -1], ["SetBytes", "SetBytes", "", $funcType([$Int64], [], false), -1], ["SetParallelism", "SetParallelism", "", $funcType([$Int], [], false), -1], ["Skip", "Skip", "", $funcType([($sliceType($emptyInterface))], [], true), 0], ["SkipNow", "SkipNow", "", $funcType([], [], false), 0], ["Skipf", "Skipf", "", $funcType([$String, ($sliceType($emptyInterface))], [], true), 0], ["Skipped", "Skipped", "", $funcType([], [$Bool], false), 0], ["StartTimer", "StartTimer", "", $funcType([], [], false), -1], ["StopTimer", "StopTimer", "", $funcType([], [], false), -1], ["launch", "launch", "testing", $funcType([], [], false), -1], ["log", "log", "testing", $funcType([$String], [], false), 0], ["nsPerOp", "nsPerOp", "testing", $funcType([], [$Int64], false), -1], ["private$", "private", "testing", $funcType([], [], false), 0], ["run", "run", "testing", $funcType([], [BenchmarkResult], false), -1], ["runN", "runN", "testing", $funcType([$Int], [], false), -1], ["skip", "skip", "testing", $funcType([], [], false), 0], ["trimOutput", "trimOutput", "testing", $funcType([], [], false), -1]]; - B.init([["common", "", "testing", common, ""], ["N", "N", "", $Int, ""], ["previousN", "previousN", "testing", $Int, ""], ["previousDuration", "previousDuration", "testing", time.Duration, ""], ["benchmark", "benchmark", "testing", InternalBenchmark, ""], ["bytes", "bytes", "testing", $Int64, ""], ["timerOn", "timerOn", "testing", $Bool, ""], ["showAllocResult", "showAllocResult", "testing", $Bool, ""], ["result", "result", "testing", BenchmarkResult, ""], ["parallelism", "parallelism", "testing", $Int, ""], ["startAllocs", "startAllocs", "testing", $Uint64, ""], ["startBytes", "startBytes", "testing", $Uint64, ""], ["netAllocs", "netAllocs", "testing", $Uint64, ""], ["netBytes", "netBytes", "testing", $Uint64, ""]]); - BenchmarkResult.methods = [["AllocedBytesPerOp", "AllocedBytesPerOp", "", $funcType([], [$Int64], false), -1], ["AllocsPerOp", "AllocsPerOp", "", $funcType([], [$Int64], false), -1], ["MemString", "MemString", "", $funcType([], [$String], false), -1], ["NsPerOp", "NsPerOp", "", $funcType([], [$Int64], false), -1], ["String", "String", "", $funcType([], [$String], false), -1], ["mbPerSec", "mbPerSec", "testing", $funcType([], [$Float64], false), -1]]; - ($ptrType(BenchmarkResult)).methods = [["AllocedBytesPerOp", "AllocedBytesPerOp", "", $funcType([], [$Int64], false), -1], ["AllocsPerOp", "AllocsPerOp", "", $funcType([], [$Int64], false), -1], ["MemString", "MemString", "", $funcType([], [$String], false), -1], ["NsPerOp", "NsPerOp", "", $funcType([], [$Int64], false), -1], ["String", "String", "", $funcType([], [$String], false), -1], ["mbPerSec", "mbPerSec", "testing", $funcType([], [$Float64], false), -1]]; - BenchmarkResult.init([["N", "N", "", $Int, ""], ["T", "T", "", time.Duration, ""], ["Bytes", "Bytes", "", $Int64, ""], ["MemAllocs", "MemAllocs", "", $Uint64, ""], ["MemBytes", "MemBytes", "", $Uint64, ""]]); - ($ptrType(PB)).methods = [["Next", "Next", "", $funcType([], [$Bool], false), -1]]; - PB.init([["globalN", "globalN", "testing", ($ptrType($Uint64)), ""], ["grain", "grain", "testing", $Uint64, ""], ["cache", "cache", "testing", $Uint64, ""], ["bN", "bN", "testing", $Uint64, ""]]); - InternalExample.init([["Name", "Name", "", $String, ""], ["F", "F", "", ($funcType([], [], false)), ""], ["Output", "Output", "", $String, ""]]); - ($ptrType(common)).methods = [["Error", "Error", "", $funcType([($sliceType($emptyInterface))], [], true), -1], ["Errorf", "Errorf", "", $funcType([$String, ($sliceType($emptyInterface))], [], true), -1], ["Fail", "Fail", "", $funcType([], [], false), -1], ["FailNow", "FailNow", "", $funcType([], [], false), -1], ["Failed", "Failed", "", $funcType([], [$Bool], false), -1], ["Fatal", "Fatal", "", $funcType([($sliceType($emptyInterface))], [], true), -1], ["Fatalf", "Fatalf", "", $funcType([$String, ($sliceType($emptyInterface))], [], true), -1], ["Log", "Log", "", $funcType([($sliceType($emptyInterface))], [], true), -1], ["Logf", "Logf", "", $funcType([$String, ($sliceType($emptyInterface))], [], true), -1], ["Skip", "Skip", "", $funcType([($sliceType($emptyInterface))], [], true), -1], ["SkipNow", "SkipNow", "", $funcType([], [], false), -1], ["Skipf", "Skipf", "", $funcType([$String, ($sliceType($emptyInterface))], [], true), -1], ["Skipped", "Skipped", "", $funcType([], [$Bool], false), -1], ["log", "log", "testing", $funcType([$String], [], false), -1], ["private$", "private", "testing", $funcType([], [], false), -1], ["skip", "skip", "testing", $funcType([], [], false), -1]]; - common.init([["mu", "mu", "testing", sync.RWMutex, ""], ["output", "output", "testing", ($sliceType($Uint8)), ""], ["failed", "failed", "testing", $Bool, ""], ["skipped", "skipped", "testing", $Bool, ""], ["finished", "finished", "testing", $Bool, ""], ["start", "start", "testing", time.Time, ""], ["duration", "duration", "testing", time.Duration, ""], ["self", "self", "testing", $emptyInterface, ""], ["signal", "signal", "testing", ($chanType($emptyInterface, false, false)), ""]]); - ($ptrType(T)).methods = [["Error", "Error", "", $funcType([($sliceType($emptyInterface))], [], true), 0], ["Errorf", "Errorf", "", $funcType([$String, ($sliceType($emptyInterface))], [], true), 0], ["Fail", "Fail", "", $funcType([], [], false), 0], ["FailNow", "FailNow", "", $funcType([], [], false), 0], ["Failed", "Failed", "", $funcType([], [$Bool], false), 0], ["Fatal", "Fatal", "", $funcType([($sliceType($emptyInterface))], [], true), 0], ["Fatalf", "Fatalf", "", $funcType([$String, ($sliceType($emptyInterface))], [], true), 0], ["Log", "Log", "", $funcType([($sliceType($emptyInterface))], [], true), 0], ["Logf", "Logf", "", $funcType([$String, ($sliceType($emptyInterface))], [], true), 0], ["Parallel", "Parallel", "", $funcType([], [], false), -1], ["Skip", "Skip", "", $funcType([($sliceType($emptyInterface))], [], true), 0], ["SkipNow", "SkipNow", "", $funcType([], [], false), 0], ["Skipf", "Skipf", "", $funcType([$String, ($sliceType($emptyInterface))], [], true), 0], ["Skipped", "Skipped", "", $funcType([], [$Bool], false), 0], ["log", "log", "testing", $funcType([$String], [], false), 0], ["private$", "private", "testing", $funcType([], [], false), 0], ["report", "report", "testing", $funcType([], [], false), -1], ["skip", "skip", "testing", $funcType([], [], false), 0]]; - T.init([["common", "", "testing", common, ""], ["name", "name", "testing", $String, ""], ["startParallel", "startParallel", "testing", ($chanType($Bool, false, false)), ""]]); - InternalTest.init([["Name", "Name", "", $String, ""], ["F", "F", "", ($funcType([($ptrType(T))], [], false)), ""]]); - memStats = new runtime.MemStats.Ptr(); - matchBenchmarks = flag.String("test.bench", "", "regular expression to select benchmarks to run"); - benchTime = flag.Duration("test.benchtime", new time.Duration(0, 1000000000), "approximate run time for each benchmark"); - benchmarkMemory = flag.Bool("test.benchmem", false, "print memory allocations for benchmarks"); - short$1 = flag.Bool("test.short", false, "run smaller test suite to save time"); - outputDir = flag.String("test.outputdir", "", "directory in which to write profiles"); - chatty = flag.Bool("test.v", false, "verbose: print additional output"); - coverProfile = flag.String("test.coverprofile", "", "write a coverage profile to the named file after execution"); - match = flag.String("test.run", "", "regular expression to select tests and examples to run"); - memProfile = flag.String("test.memprofile", "", "write a memory profile to the named file after execution"); - memProfileRate = flag.Int("test.memprofilerate", 0, "if >=0, sets runtime.MemProfileRate"); - cpuProfile = flag.String("test.cpuprofile", "", "write a cpu profile to the named file during execution"); - blockProfile = flag.String("test.blockprofile", "", "write a goroutine blocking profile to the named file after execution"); - blockProfileRate = flag.Int("test.blockprofilerate", 1, "if >= 0, calls runtime.SetBlockProfileRate()"); - timeout = flag.Duration("test.timeout", new time.Duration(0, 0), "if positive, sets an aggregate time limit for all tests"); - cpuListStr = flag.String("test.cpu", "", "comma-separated list of number of CPUs to use for each test"); - parallel = flag.Int("test.parallel", runtime.GOMAXPROCS(0), "maximum test parallelism"); - $r = init(true); /* */ $s = 1; case 1: if ($r && $r.$blocking) { $r = $r(); } - /* */ } return; } }; $f.$blocking = true; return $f; + $ptrType(durationValue).prototype.Get = function() { + var d, x$1; + d = this; + return (x$1 = d.$get(), new time.Duration(x$1.$high, x$1.$low)); }; - return $pkg; -})(); -$packages["go/token"] = (function() { - var $pkg = {}, testing = $packages["testing"], fmt = $packages["fmt"], sort = $packages["sort"], sync = $packages["sync"], strconv = $packages["strconv"], Position, Pos, File, lineInfo, FileSet, serializedFile, serializedFileSet, Token, tokens, keywords, searchLineInfos, NewFileSet, searchFiles, searchInts, init, Lookup; - Position = $pkg.Position = $newType(0, "Struct", "token.Position", "Position", "go/token", function(Filename_, Offset_, Line_, Column_) { - this.$val = this; - this.Filename = Filename_ !== undefined ? Filename_ : ""; - this.Offset = Offset_ !== undefined ? Offset_ : 0; - this.Line = Line_ !== undefined ? Line_ : 0; - this.Column = Column_ !== undefined ? Column_ : 0; - }); - Pos = $pkg.Pos = $newType(4, "Int", "token.Pos", "Pos", "go/token", null); - File = $pkg.File = $newType(0, "Struct", "token.File", "File", "go/token", function(set_, name_, base_, size_, lines_, infos_) { - this.$val = this; - this.set = set_ !== undefined ? set_ : ($ptrType(FileSet)).nil; - this.name = name_ !== undefined ? name_ : ""; - this.base = base_ !== undefined ? base_ : 0; - this.size = size_ !== undefined ? size_ : 0; - this.lines = lines_ !== undefined ? lines_ : ($sliceType($Int)).nil; - this.infos = infos_ !== undefined ? infos_ : ($sliceType(lineInfo)).nil; - }); - lineInfo = $pkg.lineInfo = $newType(0, "Struct", "token.lineInfo", "lineInfo", "go/token", function(Offset_, Filename_, Line_) { - this.$val = this; - this.Offset = Offset_ !== undefined ? Offset_ : 0; - this.Filename = Filename_ !== undefined ? Filename_ : ""; - this.Line = Line_ !== undefined ? Line_ : 0; - }); - FileSet = $pkg.FileSet = $newType(0, "Struct", "token.FileSet", "FileSet", "go/token", function(mutex_, base_, files_, last_) { - this.$val = this; - this.mutex = mutex_ !== undefined ? mutex_ : new sync.RWMutex.Ptr(); - this.base = base_ !== undefined ? base_ : 0; - this.files = files_ !== undefined ? files_ : ($sliceType(($ptrType(File)))).nil; - this.last = last_ !== undefined ? last_ : ($ptrType(File)).nil; - }); - serializedFile = $pkg.serializedFile = $newType(0, "Struct", "token.serializedFile", "serializedFile", "go/token", function(Name_, Base_, Size_, Lines_, Infos_) { - this.$val = this; - this.Name = Name_ !== undefined ? Name_ : ""; - this.Base = Base_ !== undefined ? Base_ : 0; - this.Size = Size_ !== undefined ? Size_ : 0; - this.Lines = Lines_ !== undefined ? Lines_ : ($sliceType($Int)).nil; - this.Infos = Infos_ !== undefined ? Infos_ : ($sliceType(lineInfo)).nil; - }); - serializedFileSet = $pkg.serializedFileSet = $newType(0, "Struct", "token.serializedFileSet", "serializedFileSet", "go/token", function(Base_, Files_) { - this.$val = this; - this.Base = Base_ !== undefined ? Base_ : 0; - this.Files = Files_ !== undefined ? Files_ : ($sliceType(serializedFile)).nil; - }); - Token = $pkg.Token = $newType(4, "Int", "token.Token", "Token", "go/token", null); - Position.Ptr.prototype.IsValid = function() { - var pos; - pos = this; - return pos.Line > 0; + $ptrType(durationValue).prototype.String = function() { + var d; + d = this; + return new ($ptrType(time.Duration))(d.$get, d.$set).String(); }; - Position.prototype.IsValid = function() { return this.$val.IsValid(); }; - Position.Ptr.prototype.String = function() { - var pos, s; - pos = new Position.Ptr(); $copy(pos, this, Position); - s = pos.Filename; - if (pos.IsValid()) { - if (!(s === "")) { - s = s + (":"); + sortFlags = function(flags) { + var list, i, _ref, _i, _keys, _entry, f, result, _ref$1, _i$1, i$1, name, _entry$1; + list = sort.StringSlice.make($keys(flags).length); + i = 0; + _ref = flags; + _i = 0; + _keys = $keys(_ref); + while (_i < _keys.length) { + _entry = _ref[_keys[_i]]; + if (_entry === undefined) { + _i++; + continue; } - s = s + (fmt.Sprintf("%d:%d", new ($sliceType($emptyInterface))([new $Int(pos.Line), new $Int(pos.Column)]))); + f = _entry.v; + (i < 0 || i >= list.$length) ? $throwRuntimeError("index out of range") : list.$array[list.$offset + i] = f.Name; + i = i + (1) >> 0; + _i++; } - if (s === "") { - s = "-"; + list.Sort(); + result = ($sliceType(($ptrType(Flag)))).make(list.$length); + _ref$1 = list; + _i$1 = 0; + while (_i$1 < _ref$1.$length) { + i$1 = _i$1; + name = ((_i$1 < 0 || _i$1 >= _ref$1.$length) ? $throwRuntimeError("index out of range") : _ref$1.$array[_ref$1.$offset + _i$1]); + (i$1 < 0 || i$1 >= result.$length) ? $throwRuntimeError("index out of range") : result.$array[result.$offset + i$1] = (_entry$1 = flags[name], _entry$1 !== undefined ? _entry$1.v : ($ptrType(Flag)).nil); + _i$1++; } - return s; - }; - Position.prototype.String = function() { return this.$val.String(); }; - Pos.prototype.IsValid = function() { - var p; - p = this.$val !== undefined ? this.$val : this; - return !((p === 0)); - }; - $ptrType(Pos).prototype.IsValid = function() { return new Pos(this.$get()).IsValid(); }; - File.Ptr.prototype.Name = function() { - var f; - f = this; - return f.name; - }; - File.prototype.Name = function() { return this.$val.Name(); }; - File.Ptr.prototype.Base = function() { - var f; - f = this; - return f.base; + return result; }; - File.prototype.Base = function() { return this.$val.Base(); }; - File.Ptr.prototype.Size = function() { + FlagSet.Ptr.prototype.out = function() { var f; f = this; - return f.size; - }; - File.prototype.Size = function() { return this.$val.Size(); }; - File.Ptr.prototype.LineCount = function() { - var f, n; - f = this; - f.set.mutex.RLock(); - n = f.lines.$length; - f.set.mutex.RUnlock(); - return n; - }; - File.prototype.LineCount = function() { return this.$val.LineCount(); }; - File.Ptr.prototype.AddLine = function(offset) { - var f, i, x, x$1; - f = this; - f.set.mutex.Lock(); - i = f.lines.$length; - if (((i === 0) || (x = f.lines, x$1 = i - 1 >> 0, ((x$1 < 0 || x$1 >= x.$length) ? $throwRuntimeError("index out of range") : x.$array[x.$offset + x$1])) < offset) && offset < f.size) { - f.lines = $append(f.lines, offset); + if ($interfaceIsEqual(f.output, $ifaceNil)) { + return os.Stderr; } - f.set.mutex.Unlock(); + return f.output; }; - File.prototype.AddLine = function(offset) { return this.$val.AddLine(offset); }; - File.Ptr.prototype.MergeLine = function(line) { - var $deferred = [], $err = null, f; - /* */ try { $deferFrames.push($deferred); + FlagSet.prototype.out = function() { return this.$val.out(); }; + FlagSet.Ptr.prototype.SetOutput = function(output) { + var f; f = this; - if (line <= 0) { - $panic(new $String("illegal line number (line numbering starts at 1)")); - } - f.set.mutex.Lock(); - $deferred.push([$methodVal(f.set.mutex, "Unlock"), []]); - if (line >= f.lines.$length) { - $panic(new $String("illegal line number")); - } - $copySlice($subslice(f.lines, line), $subslice(f.lines, (line + 1 >> 0))); - f.lines = $subslice(f.lines, 0, (f.lines.$length - 1 >> 0)); - /* */ } catch(err) { $err = err; } finally { $deferFrames.pop(); $callDeferred($deferred, $err); } + f.output = output; }; - File.prototype.MergeLine = function(line) { return this.$val.MergeLine(line); }; - File.Ptr.prototype.SetLines = function(lines) { - var f, size, _ref, _i, i, offset, x; + FlagSet.prototype.SetOutput = function(output) { return this.$val.SetOutput(output); }; + FlagSet.Ptr.prototype.VisitAll = function(fn) { + var f, _ref, _i, flag; f = this; - size = f.size; - _ref = lines; + _ref = sortFlags(f.formal); _i = 0; while (_i < _ref.$length) { - i = _i; - offset = ((_i < 0 || _i >= _ref.$length) ? $throwRuntimeError("index out of range") : _ref.$array[_ref.$offset + _i]); - if (i > 0 && offset <= (x = i - 1 >> 0, ((x < 0 || x >= lines.$length) ? $throwRuntimeError("index out of range") : lines.$array[lines.$offset + x])) || size <= offset) { - return false; - } + flag = ((_i < 0 || _i >= _ref.$length) ? $throwRuntimeError("index out of range") : _ref.$array[_ref.$offset + _i]); + fn(flag); _i++; } - f.set.mutex.Lock(); - f.lines = lines; - f.set.mutex.Unlock(); - return true; }; - File.prototype.SetLines = function(lines) { return this.$val.SetLines(lines); }; - File.Ptr.prototype.SetLinesForContent = function(content) { - var f, lines, line, _ref, _i, offset, b; + FlagSet.prototype.VisitAll = function(fn) { return this.$val.VisitAll(fn); }; + FlagSet.Ptr.prototype.Visit = function(fn) { + var f, _ref, _i, flag; f = this; - lines = ($sliceType($Int)).nil; - line = 0; - _ref = content; + _ref = sortFlags(f.actual); _i = 0; while (_i < _ref.$length) { - offset = _i; - b = ((_i < 0 || _i >= _ref.$length) ? $throwRuntimeError("index out of range") : _ref.$array[_ref.$offset + _i]); - if (line >= 0) { - lines = $append(lines, line); - } - line = -1; - if (b === 10) { - line = offset + 1 >> 0; - } + flag = ((_i < 0 || _i >= _ref.$length) ? $throwRuntimeError("index out of range") : _ref.$array[_ref.$offset + _i]); + fn(flag); _i++; } - f.set.mutex.Lock(); - f.lines = lines; - f.set.mutex.Unlock(); }; - File.prototype.SetLinesForContent = function(content) { return this.$val.SetLinesForContent(content); }; - File.Ptr.prototype.AddLineInfo = function(offset, filename, line) { - var f, i, x, x$1; + FlagSet.prototype.Visit = function(fn) { return this.$val.Visit(fn); }; + FlagSet.Ptr.prototype.Lookup = function(name) { + var f, _entry; f = this; - f.set.mutex.Lock(); - i = f.infos.$length; - if ((i === 0) || (x = f.infos, x$1 = i - 1 >> 0, ((x$1 < 0 || x$1 >= x.$length) ? $throwRuntimeError("index out of range") : x.$array[x.$offset + x$1])).Offset < offset && offset < f.size) { - f.infos = $append(f.infos, new lineInfo.Ptr(offset, filename, line)); - } - f.set.mutex.Unlock(); + return (_entry = f.formal[name], _entry !== undefined ? _entry.v : ($ptrType(Flag)).nil); }; - File.prototype.AddLineInfo = function(offset, filename, line) { return this.$val.AddLineInfo(offset, filename, line); }; - File.Ptr.prototype.Pos = function(offset) { - var f; + FlagSet.prototype.Lookup = function(name) { return this.$val.Lookup(name); }; + FlagSet.Ptr.prototype.Set = function(name, value) { + var f, _tuple, _entry, flag, ok, err, _key; f = this; - if (offset > f.size) { - $panic(new $String("illegal file offset")); + _tuple = (_entry = f.formal[name], _entry !== undefined ? [_entry.v, true] : [($ptrType(Flag)).nil, false]); flag = _tuple[0]; ok = _tuple[1]; + if (!ok) { + return fmt.Errorf("no such flag -%v", new ($sliceType($emptyInterface))([new $String(name)])); } - return ((f.base + offset >> 0) >> 0); - }; - File.prototype.Pos = function(offset) { return this.$val.Pos(offset); }; - File.Ptr.prototype.Offset = function(p) { - var f; - f = this; - if ((p >> 0) < f.base || (p >> 0) > (f.base + f.size >> 0)) { - $panic(new $String("illegal Pos value")); + err = flag.Value.Set(value); + if (!($interfaceIsEqual(err, $ifaceNil))) { + return err; } - return (p >> 0) - f.base >> 0; + if (f.actual === false) { + f.actual = new $Map(); + } + _key = name; (f.actual || $throwRuntimeError("assignment to entry in nil map"))[_key] = { k: _key, v: flag }; + return $ifaceNil; }; - File.prototype.Offset = function(p) { return this.$val.Offset(p); }; - File.Ptr.prototype.Line = function(p) { + FlagSet.prototype.Set = function(name, value) { return this.$val.Set(name, value); }; + FlagSet.Ptr.prototype.PrintDefaults = function() { var f; f = this; - return f.Position(p).Line; - }; - File.prototype.Line = function(p) { return this.$val.Line(p); }; - searchLineInfos = function(a, x) { - return sort.Search(a.$length, (function(i) { - return ((i < 0 || i >= a.$length) ? $throwRuntimeError("index out of range") : a.$array[a.$offset + i]).Offset > x; - })) - 1 >> 0; - }; - File.Ptr.prototype.info = function(offset) { - var filename = "", line = 0, column = 0, f, i, _tmp, _tmp$1, x, i$1, x$1, alt, i$2; - f = this; - filename = f.name; - i = searchInts(f.lines, offset); - if (i >= 0) { - _tmp = i + 1 >> 0; _tmp$1 = (offset - (x = f.lines, ((i < 0 || i >= x.$length) ? $throwRuntimeError("index out of range") : x.$array[x.$offset + i])) >> 0) + 1 >> 0; line = _tmp; column = _tmp$1; - } - if (f.infos.$length > 0) { - i$1 = searchLineInfos(f.infos, offset); - if (i$1 >= 0) { - alt = (x$1 = f.infos, ((i$1 < 0 || i$1 >= x$1.$length) ? $throwRuntimeError("index out of range") : x$1.$array[x$1.$offset + i$1])); - filename = alt.Filename; - i$2 = searchInts(f.lines, alt.Offset); - if (i$2 >= 0) { - line = line + (((alt.Line - i$2 >> 0) - 1 >> 0)) >> 0; - } + f.VisitAll((function(flag) { + var format, _tuple, ok; + format = " -%s=%s: %s\n"; + _tuple = $assertType(flag.Value, ($ptrType(stringValue)), true); ok = _tuple[1]; + if (ok) { + format = " -%s=%q: %s\n"; } + fmt.Fprintf(f.out(), format, new ($sliceType($emptyInterface))([new $String(flag.Name), new $String(flag.DefValue), new $String(flag.Usage)])); + })); + }; + FlagSet.prototype.PrintDefaults = function() { return this.$val.PrintDefaults(); }; + PrintDefaults = $pkg.PrintDefaults = function() { + $pkg.CommandLine.PrintDefaults(); + }; + defaultUsage = function(f) { + if (f.name === "") { + fmt.Fprintf(f.out(), "Usage:\n", new ($sliceType($emptyInterface))([])); + } else { + fmt.Fprintf(f.out(), "Usage of %s:\n", new ($sliceType($emptyInterface))([new $String(f.name)])); } - return [filename, line, column]; + f.PrintDefaults(); }; - File.prototype.info = function(offset) { return this.$val.info(offset); }; - File.Ptr.prototype.position = function(p) { - var pos = new Position.Ptr(), f, offset, _tuple; + FlagSet.Ptr.prototype.NFlag = function() { + var f; f = this; - offset = (p >> 0) - f.base >> 0; - pos.Offset = offset; - _tuple = f.info(offset); pos.Filename = _tuple[0]; pos.Line = _tuple[1]; pos.Column = _tuple[2]; - return pos; + return $keys(f.actual).length; }; - File.prototype.position = function(p) { return this.$val.position(p); }; - File.Ptr.prototype.Position = function(p) { - var pos = new Position.Ptr(), f; + FlagSet.prototype.NFlag = function() { return this.$val.NFlag(); }; + FlagSet.Ptr.prototype.Arg = function(i) { + var f, x$1; f = this; - if (!((p === 0))) { - if ((p >> 0) < f.base || (p >> 0) > (f.base + f.size >> 0)) { - $panic(new $String("illegal Pos value")); - } - $copy(pos, f.position(p), Position); + if (i < 0 || i >= f.args.$length) { + return ""; } - return pos; - }; - File.prototype.Position = function(p) { return this.$val.Position(p); }; - NewFileSet = $pkg.NewFileSet = function() { - return new FileSet.Ptr(new sync.RWMutex.Ptr(), 1, ($sliceType(($ptrType(File)))).nil, ($ptrType(File)).nil); - }; - FileSet.Ptr.prototype.Base = function() { - var s, b; - s = this; - s.mutex.RLock(); - b = s.base; - s.mutex.RUnlock(); - return b; + return (x$1 = f.args, ((i < 0 || i >= x$1.$length) ? $throwRuntimeError("index out of range") : x$1.$array[x$1.$offset + i])); }; - FileSet.prototype.Base = function() { return this.$val.Base(); }; - FileSet.Ptr.prototype.AddFile = function(filename, base, size) { - var $deferred = [], $err = null, s, f; - /* */ try { $deferFrames.push($deferred); - s = this; - s.mutex.Lock(); - $deferred.push([$methodVal(s.mutex, "Unlock"), []]); - if (base < 0) { - base = s.base; - } - if (base < s.base || size < 0) { - $panic(new $String("illegal base or size")); - } - f = new File.Ptr(s, filename, base, size, new ($sliceType($Int))([0]), ($sliceType(lineInfo)).nil); - base = base + ((size + 1 >> 0)) >> 0; - if (base < 0) { - $panic(new $String("token.Pos offset overflow (> 2G of source code in file set)")); - } - s.base = base; - s.files = $append(s.files, f); - s.last = f; - return f; - /* */ } catch(err) { $err = err; return ($ptrType(File)).nil; } finally { $deferFrames.pop(); $callDeferred($deferred, $err); } + FlagSet.prototype.Arg = function(i) { return this.$val.Arg(i); }; + FlagSet.Ptr.prototype.NArg = function() { + var f; + f = this; + return f.args.$length; }; - FileSet.prototype.AddFile = function(filename, base, size) { return this.$val.AddFile(filename, base, size); }; - FileSet.Ptr.prototype.Iterate = function(f) { - var s, i, file, x; - s = this; - i = 0; - while (true) { - file = ($ptrType(File)).nil; - s.mutex.RLock(); - if (i < s.files.$length) { - file = (x = s.files, ((i < 0 || i >= x.$length) ? $throwRuntimeError("index out of range") : x.$array[x.$offset + i])); - } - s.mutex.RUnlock(); - if (file === ($ptrType(File)).nil || !f(file)) { - break; - } - i = i + (1) >> 0; - } + FlagSet.prototype.NArg = function() { return this.$val.NArg(); }; + FlagSet.Ptr.prototype.Args = function() { + var f; + f = this; + return f.args; }; - FileSet.prototype.Iterate = function(f) { return this.$val.Iterate(f); }; - searchFiles = function(a, x) { - return sort.Search(a.$length, (function(i) { - return ((i < 0 || i >= a.$length) ? $throwRuntimeError("index out of range") : a.$array[a.$offset + i]).base > x; - })) - 1 >> 0; + FlagSet.prototype.Args = function() { return this.$val.Args(); }; + FlagSet.Ptr.prototype.BoolVar = function(p, name, value, usage) { + var f; + f = this; + f.Var(newBoolValue(value, p), name, usage); }; - FileSet.Ptr.prototype.file = function(p) { - var s, f, i, x, f$1; - s = this; - s.mutex.RLock(); - f = s.last; - if (!(f === ($ptrType(File)).nil) && f.base <= (p >> 0) && (p >> 0) <= (f.base + f.size >> 0)) { - s.mutex.RUnlock(); - return f; - } - i = searchFiles(s.files, (p >> 0)); - if (i >= 0) { - f$1 = (x = s.files, ((i < 0 || i >= x.$length) ? $throwRuntimeError("index out of range") : x.$array[x.$offset + i])); - if ((p >> 0) <= (f$1.base + f$1.size >> 0)) { - s.mutex.RUnlock(); - s.mutex.Lock(); - s.last = f$1; - s.mutex.Unlock(); - return f$1; - } - } - s.mutex.RUnlock(); - return ($ptrType(File)).nil; + FlagSet.prototype.BoolVar = function(p, name, value, usage) { return this.$val.BoolVar(p, name, value, usage); }; + FlagSet.Ptr.prototype.Bool = function(name, value, usage) { + var f, p; + f = this; + p = $newDataPointer(false, ($ptrType($Bool))); + f.BoolVar(p, name, value, usage); + return p; }; - FileSet.prototype.file = function(p) { return this.$val.file(p); }; - FileSet.Ptr.prototype.File = function(p) { - var f = ($ptrType(File)).nil, s; - s = this; - if (!((p === 0))) { - f = s.file(p); - } - return f; + FlagSet.prototype.Bool = function(name, value, usage) { return this.$val.Bool(name, value, usage); }; + Bool = $pkg.Bool = function(name, value, usage) { + return $pkg.CommandLine.Bool(name, value, usage); }; - FileSet.prototype.File = function(p) { return this.$val.File(p); }; - FileSet.Ptr.prototype.Position = function(p) { - var pos = new Position.Ptr(), s, f; - s = this; - if (!((p === 0))) { - f = s.file(p); - if (!(f === ($ptrType(File)).nil)) { - $copy(pos, f.position(p), Position); - } - } - return pos; + FlagSet.Ptr.prototype.IntVar = function(p, name, value, usage) { + var f; + f = this; + f.Var(newIntValue(value, p), name, usage); }; - FileSet.prototype.Position = function(p) { return this.$val.Position(p); }; - searchInts = function(a, x) { - var _tmp, _tmp$1, i, j, _q, h; - _tmp = 0; _tmp$1 = a.$length; i = _tmp; j = _tmp$1; - while (i < j) { - h = i + (_q = ((j - i >> 0)) / 2, (_q === _q && _q !== 1/0 && _q !== -1/0) ? _q >> 0 : $throwRuntimeError("integer divide by zero")) >> 0; - if (((h < 0 || h >= a.$length) ? $throwRuntimeError("index out of range") : a.$array[a.$offset + h]) <= x) { - i = h + 1 >> 0; - } else { - j = h; - } - } - return i - 1 >> 0; + FlagSet.prototype.IntVar = function(p, name, value, usage) { return this.$val.IntVar(p, name, value, usage); }; + FlagSet.Ptr.prototype.Int = function(name, value, usage) { + var f, p; + f = this; + p = $newDataPointer(0, ($ptrType($Int))); + f.IntVar(p, name, value, usage); + return p; }; - FileSet.Ptr.prototype.Read = function(decode) { - var s, ss, err, files, i, x, f; - s = this; - ss = new serializedFileSet.Ptr(); $copy(ss, new serializedFileSet.Ptr(), serializedFileSet); - err = decode(ss); - if (!($interfaceIsEqual(err, $ifaceNil))) { - return err; - } - s.mutex.Lock(); - s.base = ss.Base; - files = ($sliceType(($ptrType(File)))).make(ss.Files.$length); - i = 0; - while (i < ss.Files.$length) { - f = (x = ss.Files, ((i < 0 || i >= x.$length) ? $throwRuntimeError("index out of range") : x.$array[x.$offset + i])); - (i < 0 || i >= files.$length) ? $throwRuntimeError("index out of range") : files.$array[files.$offset + i] = new File.Ptr(s, f.Name, f.Base, f.Size, f.Lines, f.Infos); - i = i + (1) >> 0; - } - s.files = files; - s.last = ($ptrType(File)).nil; - s.mutex.Unlock(); - return $ifaceNil; + FlagSet.prototype.Int = function(name, value, usage) { return this.$val.Int(name, value, usage); }; + Int = $pkg.Int = function(name, value, usage) { + return $pkg.CommandLine.Int(name, value, usage); }; - FileSet.prototype.Read = function(decode) { return this.$val.Read(decode); }; - FileSet.Ptr.prototype.Write = function(encode) { - var s, ss, files, _ref, _i, i, f; - s = this; - ss = new serializedFileSet.Ptr(); $copy(ss, new serializedFileSet.Ptr(), serializedFileSet); - s.mutex.Lock(); - ss.Base = s.base; - files = ($sliceType(serializedFile)).make(s.files.$length); - _ref = s.files; - _i = 0; - while (_i < _ref.$length) { - i = _i; - f = ((_i < 0 || _i >= _ref.$length) ? $throwRuntimeError("index out of range") : _ref.$array[_ref.$offset + _i]); - $copy(((i < 0 || i >= files.$length) ? $throwRuntimeError("index out of range") : files.$array[files.$offset + i]), new serializedFile.Ptr(f.name, f.base, f.size, f.lines, f.infos), serializedFile); - _i++; - } - ss.Files = files; - s.mutex.Unlock(); - return encode(new ss.constructor.Struct(ss)); + FlagSet.Ptr.prototype.Int64Var = function(p, name, value, usage) { + var f; + f = this; + f.Var(newInt64Value(value, p), name, usage); }; - FileSet.prototype.Write = function(encode) { return this.$val.Write(encode); }; - Token.prototype.String = function() { - var tok, s; - tok = this.$val !== undefined ? this.$val : this; - s = ""; - if (0 <= tok && tok < 86) { - s = ((tok < 0 || tok >= tokens.length) ? $throwRuntimeError("index out of range") : tokens[tok]); - } - if (s === "") { - s = "token(" + strconv.Itoa((tok >> 0)) + ")"; - } - return s; + FlagSet.prototype.Int64Var = function(p, name, value, usage) { return this.$val.Int64Var(p, name, value, usage); }; + FlagSet.Ptr.prototype.Int64 = function(name, value, usage) { + var f, p; + f = this; + p = $newDataPointer(new $Int64(0, 0), ($ptrType($Int64))); + f.Int64Var(p, name, value, usage); + return p; }; - $ptrType(Token).prototype.String = function() { return new Token(this.$get()).String(); }; - Token.prototype.Precedence = function() { - var op, _ref; - op = this.$val !== undefined ? this.$val : this; - _ref = op; - if (_ref === 35) { - return 1; - } else if (_ref === 34) { - return 2; - } else if (_ref === 39 || _ref === 44 || _ref === 40 || _ref === 45 || _ref === 41 || _ref === 46) { - return 3; - } else if (_ref === 12 || _ref === 13 || _ref === 18 || _ref === 19) { - return 4; - } else if (_ref === 14 || _ref === 15 || _ref === 16 || _ref === 20 || _ref === 21 || _ref === 17 || _ref === 22) { - return 5; - } - return 0; + FlagSet.prototype.Int64 = function(name, value, usage) { return this.$val.Int64(name, value, usage); }; + FlagSet.Ptr.prototype.UintVar = function(p, name, value, usage) { + var f; + f = this; + f.Var(newUintValue(value, p), name, usage); }; - $ptrType(Token).prototype.Precedence = function() { return new Token(this.$get()).Precedence(); }; - init = function() { - var i, _key; - keywords = new $Map(); - i = 61; - while (i < 86) { - _key = ((i < 0 || i >= tokens.length) ? $throwRuntimeError("index out of range") : tokens[i]); (keywords || $throwRuntimeError("assignment to entry in nil map"))[_key] = { k: _key, v: i }; - i = i + (1) >> 0; - } + FlagSet.prototype.UintVar = function(p, name, value, usage) { return this.$val.UintVar(p, name, value, usage); }; + FlagSet.Ptr.prototype.Uint = function(name, value, usage) { + var f, p; + f = this; + p = $newDataPointer(0, ($ptrType($Uint))); + f.UintVar(p, name, value, usage); + return p; }; - Lookup = $pkg.Lookup = function(ident) { - var _tuple, _entry, tok, is_keyword; - _tuple = (_entry = keywords[ident], _entry !== undefined ? [_entry.v, true] : [0, false]); tok = _tuple[0]; is_keyword = _tuple[1]; - if (is_keyword) { - return tok; - } - return 4; + FlagSet.prototype.Uint = function(name, value, usage) { return this.$val.Uint(name, value, usage); }; + FlagSet.Ptr.prototype.Uint64Var = function(p, name, value, usage) { + var f; + f = this; + f.Var(newUint64Value(value, p), name, usage); }; - Token.prototype.IsLiteral = function() { - var tok; - tok = this.$val !== undefined ? this.$val : this; - return 3 < tok && tok < 10; + FlagSet.prototype.Uint64Var = function(p, name, value, usage) { return this.$val.Uint64Var(p, name, value, usage); }; + FlagSet.Ptr.prototype.Uint64 = function(name, value, usage) { + var f, p; + f = this; + p = $newDataPointer(new $Uint64(0, 0), ($ptrType($Uint64))); + f.Uint64Var(p, name, value, usage); + return p; }; - $ptrType(Token).prototype.IsLiteral = function() { return new Token(this.$get()).IsLiteral(); }; - Token.prototype.IsOperator = function() { - var tok; - tok = this.$val !== undefined ? this.$val : this; - return 11 < tok && tok < 59; + FlagSet.prototype.Uint64 = function(name, value, usage) { return this.$val.Uint64(name, value, usage); }; + FlagSet.Ptr.prototype.StringVar = function(p, name, value, usage) { + var f; + f = this; + f.Var(newStringValue(value, p), name, usage); }; - $ptrType(Token).prototype.IsOperator = function() { return new Token(this.$get()).IsOperator(); }; - Token.prototype.IsKeyword = function() { - var tok; - tok = this.$val !== undefined ? this.$val : this; - return 60 < tok && tok < 86; + FlagSet.prototype.StringVar = function(p, name, value, usage) { return this.$val.StringVar(p, name, value, usage); }; + FlagSet.Ptr.prototype.String = function(name, value, usage) { + var f, p; + f = this; + p = $newDataPointer("", ($ptrType($String))); + f.StringVar(p, name, value, usage); + return p; }; - $ptrType(Token).prototype.IsKeyword = function() { return new Token(this.$get()).IsKeyword(); }; - $pkg.$init = function() { - Position.methods = [["String", "String", "", $funcType([], [$String], false), -1]]; - ($ptrType(Position)).methods = [["IsValid", "IsValid", "", $funcType([], [$Bool], false), -1], ["String", "String", "", $funcType([], [$String], false), -1]]; - Position.init([["Filename", "Filename", "", $String, ""], ["Offset", "Offset", "", $Int, ""], ["Line", "Line", "", $Int, ""], ["Column", "Column", "", $Int, ""]]); - Pos.methods = [["IsValid", "IsValid", "", $funcType([], [$Bool], false), -1]]; - ($ptrType(Pos)).methods = [["IsValid", "IsValid", "", $funcType([], [$Bool], false), -1]]; - ($ptrType(File)).methods = [["AddLine", "AddLine", "", $funcType([$Int], [], false), -1], ["AddLineInfo", "AddLineInfo", "", $funcType([$Int, $String, $Int], [], false), -1], ["Base", "Base", "", $funcType([], [$Int], false), -1], ["Line", "Line", "", $funcType([Pos], [$Int], false), -1], ["LineCount", "LineCount", "", $funcType([], [$Int], false), -1], ["MergeLine", "MergeLine", "", $funcType([$Int], [], false), -1], ["Name", "Name", "", $funcType([], [$String], false), -1], ["Offset", "Offset", "", $funcType([Pos], [$Int], false), -1], ["Pos", "Pos", "", $funcType([$Int], [Pos], false), -1], ["Position", "Position", "", $funcType([Pos], [Position], false), -1], ["SetLines", "SetLines", "", $funcType([($sliceType($Int))], [$Bool], false), -1], ["SetLinesForContent", "SetLinesForContent", "", $funcType([($sliceType($Uint8))], [], false), -1], ["Size", "Size", "", $funcType([], [$Int], false), -1], ["info", "info", "go/token", $funcType([$Int], [$String, $Int, $Int], false), -1], ["position", "position", "go/token", $funcType([Pos], [Position], false), -1]]; - File.init([["set", "set", "go/token", ($ptrType(FileSet)), ""], ["name", "name", "go/token", $String, ""], ["base", "base", "go/token", $Int, ""], ["size", "size", "go/token", $Int, ""], ["lines", "lines", "go/token", ($sliceType($Int)), ""], ["infos", "infos", "go/token", ($sliceType(lineInfo)), ""]]); - lineInfo.init([["Offset", "Offset", "", $Int, ""], ["Filename", "Filename", "", $String, ""], ["Line", "Line", "", $Int, ""]]); - ($ptrType(FileSet)).methods = [["AddFile", "AddFile", "", $funcType([$String, $Int, $Int], [($ptrType(File))], false), -1], ["Base", "Base", "", $funcType([], [$Int], false), -1], ["File", "File", "", $funcType([Pos], [($ptrType(File))], false), -1], ["Iterate", "Iterate", "", $funcType([($funcType([($ptrType(File))], [$Bool], false))], [], false), -1], ["Position", "Position", "", $funcType([Pos], [Position], false), -1], ["Read", "Read", "", $funcType([($funcType([$emptyInterface], [$error], false))], [$error], false), -1], ["Write", "Write", "", $funcType([($funcType([$emptyInterface], [$error], false))], [$error], false), -1], ["file", "file", "go/token", $funcType([Pos], [($ptrType(File))], false), -1]]; - FileSet.init([["mutex", "mutex", "go/token", sync.RWMutex, ""], ["base", "base", "go/token", $Int, ""], ["files", "files", "go/token", ($sliceType(($ptrType(File)))), ""], ["last", "last", "go/token", ($ptrType(File)), ""]]); - serializedFile.init([["Name", "Name", "", $String, ""], ["Base", "Base", "", $Int, ""], ["Size", "Size", "", $Int, ""], ["Lines", "Lines", "", ($sliceType($Int)), ""], ["Infos", "Infos", "", ($sliceType(lineInfo)), ""]]); - serializedFileSet.init([["Base", "Base", "", $Int, ""], ["Files", "Files", "", ($sliceType(serializedFile)), ""]]); - Token.methods = [["IsKeyword", "IsKeyword", "", $funcType([], [$Bool], false), -1], ["IsLiteral", "IsLiteral", "", $funcType([], [$Bool], false), -1], ["IsOperator", "IsOperator", "", $funcType([], [$Bool], false), -1], ["Precedence", "Precedence", "", $funcType([], [$Int], false), -1], ["String", "String", "", $funcType([], [$String], false), -1]]; - ($ptrType(Token)).methods = [["IsKeyword", "IsKeyword", "", $funcType([], [$Bool], false), -1], ["IsLiteral", "IsLiteral", "", $funcType([], [$Bool], false), -1], ["IsOperator", "IsOperator", "", $funcType([], [$Bool], false), -1], ["Precedence", "Precedence", "", $funcType([], [$Int], false), -1], ["String", "String", "", $funcType([], [$String], false), -1]]; - keywords = false; - tokens = $toNativeArray("String", ["ILLEGAL", "EOF", "COMMENT", "", "IDENT", "INT", "FLOAT", "IMAG", "CHAR", "STRING", "", "", "+", "-", "*", "/", "%", "&", "|", "^", "<<", ">>", "&^", "+=", "-=", "*=", "/=", "%=", "&=", "|=", "^=", "<<=", ">>=", "&^=", "&&", "||", "<-", "++", "--", "==", "<", ">", "=", "!", "!=", "<=", ">=", ":=", "...", "(", "[", "{", ",", ".", ")", "]", "}", ";", ":", "", "", "break", "case", "chan", "const", "continue", "default", "defer", "else", "fallthrough", "for", "func", "go", "goto", "if", "import", "interface", "map", "package", "range", "return", "select", "struct", "switch", "type", "var"]); - init(); + FlagSet.prototype.String = function(name, value, usage) { return this.$val.String(name, value, usage); }; + String = $pkg.String = function(name, value, usage) { + return $pkg.CommandLine.String(name, value, usage); }; - return $pkg; -})(); -$packages["encoding/binary"] = (function() { - var $pkg = {}, errors = $packages["errors"], io = $packages["io"], math = $packages["math"], reflect = $packages["reflect"], ByteOrder, bigEndian, encoder, overflow, Write, dataSize, sizeof, intDataSize; - ByteOrder = $pkg.ByteOrder = $newType(8, "Interface", "binary.ByteOrder", "ByteOrder", "encoding/binary", null); - bigEndian = $pkg.bigEndian = $newType(0, "Struct", "binary.bigEndian", "bigEndian", "encoding/binary", function() { - this.$val = this; - }); - encoder = $pkg.encoder = $newType(0, "Struct", "binary.encoder", "encoder", "encoding/binary", function(order_, buf_) { - this.$val = this; - this.order = order_ !== undefined ? order_ : $ifaceNil; - this.buf = buf_ !== undefined ? buf_ : ($sliceType($Uint8)).nil; - }); - bigEndian.Ptr.prototype.Uint16 = function(b) { - return ((((1 < 0 || 1 >= b.$length) ? $throwRuntimeError("index out of range") : b.$array[b.$offset + 1]) << 16 >>> 16) | ((((0 < 0 || 0 >= b.$length) ? $throwRuntimeError("index out of range") : b.$array[b.$offset + 0]) << 16 >>> 16) << 8 << 16 >>> 16)) >>> 0; + FlagSet.Ptr.prototype.Float64Var = function(p, name, value, usage) { + var f; + f = this; + f.Var(newFloat64Value(value, p), name, usage); }; - bigEndian.prototype.Uint16 = function(b) { return this.$val.Uint16(b); }; - bigEndian.Ptr.prototype.PutUint16 = function(b, v) { - (0 < 0 || 0 >= b.$length) ? $throwRuntimeError("index out of range") : b.$array[b.$offset + 0] = ((v >>> 8 << 16 >>> 16) << 24 >>> 24); - (1 < 0 || 1 >= b.$length) ? $throwRuntimeError("index out of range") : b.$array[b.$offset + 1] = (v << 24 >>> 24); + FlagSet.prototype.Float64Var = function(p, name, value, usage) { return this.$val.Float64Var(p, name, value, usage); }; + FlagSet.Ptr.prototype.Float64 = function(name, value, usage) { + var f, p; + f = this; + p = $newDataPointer(0, ($ptrType($Float64))); + f.Float64Var(p, name, value, usage); + return p; }; - bigEndian.prototype.PutUint16 = function(b, v) { return this.$val.PutUint16(b, v); }; - bigEndian.Ptr.prototype.Uint32 = function(b) { - return ((((((((3 < 0 || 3 >= b.$length) ? $throwRuntimeError("index out of range") : b.$array[b.$offset + 3]) >>> 0) | ((((2 < 0 || 2 >= b.$length) ? $throwRuntimeError("index out of range") : b.$array[b.$offset + 2]) >>> 0) << 8 >>> 0)) >>> 0) | ((((1 < 0 || 1 >= b.$length) ? $throwRuntimeError("index out of range") : b.$array[b.$offset + 1]) >>> 0) << 16 >>> 0)) >>> 0) | ((((0 < 0 || 0 >= b.$length) ? $throwRuntimeError("index out of range") : b.$array[b.$offset + 0]) >>> 0) << 24 >>> 0)) >>> 0; + FlagSet.prototype.Float64 = function(name, value, usage) { return this.$val.Float64(name, value, usage); }; + FlagSet.Ptr.prototype.DurationVar = function(p, name, value, usage) { + var f; + f = this; + f.Var(newDurationValue(value, p), name, usage); }; - bigEndian.prototype.Uint32 = function(b) { return this.$val.Uint32(b); }; - bigEndian.Ptr.prototype.PutUint32 = function(b, v) { - (0 < 0 || 0 >= b.$length) ? $throwRuntimeError("index out of range") : b.$array[b.$offset + 0] = ((v >>> 24 >>> 0) << 24 >>> 24); - (1 < 0 || 1 >= b.$length) ? $throwRuntimeError("index out of range") : b.$array[b.$offset + 1] = ((v >>> 16 >>> 0) << 24 >>> 24); - (2 < 0 || 2 >= b.$length) ? $throwRuntimeError("index out of range") : b.$array[b.$offset + 2] = ((v >>> 8 >>> 0) << 24 >>> 24); - (3 < 0 || 3 >= b.$length) ? $throwRuntimeError("index out of range") : b.$array[b.$offset + 3] = (v << 24 >>> 24); + FlagSet.prototype.DurationVar = function(p, name, value, usage) { return this.$val.DurationVar(p, name, value, usage); }; + FlagSet.Ptr.prototype.Duration = function(name, value, usage) { + var f, p; + f = this; + p = $newDataPointer(new time.Duration(0, 0), ($ptrType(time.Duration))); + f.DurationVar(p, name, value, usage); + return p; }; - bigEndian.prototype.PutUint32 = function(b, v) { return this.$val.PutUint32(b, v); }; - bigEndian.Ptr.prototype.Uint64 = function(b) { - var x, x$1, x$2, x$3, x$4, x$5, x$6, x$7, x$8, x$9, x$10, x$11, x$12, x$13; - return (x = (x$1 = (x$2 = (x$3 = (x$4 = (x$5 = (x$6 = new $Uint64(0, ((7 < 0 || 7 >= b.$length) ? $throwRuntimeError("index out of range") : b.$array[b.$offset + 7])), x$7 = $shiftLeft64(new $Uint64(0, ((6 < 0 || 6 >= b.$length) ? $throwRuntimeError("index out of range") : b.$array[b.$offset + 6])), 8), new $Uint64(x$6.$high | x$7.$high, (x$6.$low | x$7.$low) >>> 0)), x$8 = $shiftLeft64(new $Uint64(0, ((5 < 0 || 5 >= b.$length) ? $throwRuntimeError("index out of range") : b.$array[b.$offset + 5])), 16), new $Uint64(x$5.$high | x$8.$high, (x$5.$low | x$8.$low) >>> 0)), x$9 = $shiftLeft64(new $Uint64(0, ((4 < 0 || 4 >= b.$length) ? $throwRuntimeError("index out of range") : b.$array[b.$offset + 4])), 24), new $Uint64(x$4.$high | x$9.$high, (x$4.$low | x$9.$low) >>> 0)), x$10 = $shiftLeft64(new $Uint64(0, ((3 < 0 || 3 >= b.$length) ? $throwRuntimeError("index out of range") : b.$array[b.$offset + 3])), 32), new $Uint64(x$3.$high | x$10.$high, (x$3.$low | x$10.$low) >>> 0)), x$11 = $shiftLeft64(new $Uint64(0, ((2 < 0 || 2 >= b.$length) ? $throwRuntimeError("index out of range") : b.$array[b.$offset + 2])), 40), new $Uint64(x$2.$high | x$11.$high, (x$2.$low | x$11.$low) >>> 0)), x$12 = $shiftLeft64(new $Uint64(0, ((1 < 0 || 1 >= b.$length) ? $throwRuntimeError("index out of range") : b.$array[b.$offset + 1])), 48), new $Uint64(x$1.$high | x$12.$high, (x$1.$low | x$12.$low) >>> 0)), x$13 = $shiftLeft64(new $Uint64(0, ((0 < 0 || 0 >= b.$length) ? $throwRuntimeError("index out of range") : b.$array[b.$offset + 0])), 56), new $Uint64(x.$high | x$13.$high, (x.$low | x$13.$low) >>> 0)); + FlagSet.prototype.Duration = function(name, value, usage) { return this.$val.Duration(name, value, usage); }; + Duration = $pkg.Duration = function(name, value, usage) { + return $pkg.CommandLine.Duration(name, value, usage); }; - bigEndian.prototype.Uint64 = function(b) { return this.$val.Uint64(b); }; - bigEndian.Ptr.prototype.PutUint64 = function(b, v) { - (0 < 0 || 0 >= b.$length) ? $throwRuntimeError("index out of range") : b.$array[b.$offset + 0] = ($shiftRightUint64(v, 56).$low << 24 >>> 24); - (1 < 0 || 1 >= b.$length) ? $throwRuntimeError("index out of range") : b.$array[b.$offset + 1] = ($shiftRightUint64(v, 48).$low << 24 >>> 24); - (2 < 0 || 2 >= b.$length) ? $throwRuntimeError("index out of range") : b.$array[b.$offset + 2] = ($shiftRightUint64(v, 40).$low << 24 >>> 24); - (3 < 0 || 3 >= b.$length) ? $throwRuntimeError("index out of range") : b.$array[b.$offset + 3] = ($shiftRightUint64(v, 32).$low << 24 >>> 24); - (4 < 0 || 4 >= b.$length) ? $throwRuntimeError("index out of range") : b.$array[b.$offset + 4] = ($shiftRightUint64(v, 24).$low << 24 >>> 24); - (5 < 0 || 5 >= b.$length) ? $throwRuntimeError("index out of range") : b.$array[b.$offset + 5] = ($shiftRightUint64(v, 16).$low << 24 >>> 24); - (6 < 0 || 6 >= b.$length) ? $throwRuntimeError("index out of range") : b.$array[b.$offset + 6] = ($shiftRightUint64(v, 8).$low << 24 >>> 24); - (7 < 0 || 7 >= b.$length) ? $throwRuntimeError("index out of range") : b.$array[b.$offset + 7] = (v.$low << 24 >>> 24); + FlagSet.Ptr.prototype.Var = function(value, name, usage) { + var f, flag, _tuple, _entry, alreadythere, msg, _key; + f = this; + flag = new Flag.Ptr(name, usage, value, value.String()); + _tuple = (_entry = f.formal[name], _entry !== undefined ? [_entry.v, true] : [($ptrType(Flag)).nil, false]); alreadythere = _tuple[1]; + if (alreadythere) { + msg = ""; + if (f.name === "") { + msg = fmt.Sprintf("flag redefined: %s", new ($sliceType($emptyInterface))([new $String(name)])); + } else { + msg = fmt.Sprintf("%s flag redefined: %s", new ($sliceType($emptyInterface))([new $String(f.name), new $String(name)])); + } + fmt.Fprintln(f.out(), new ($sliceType($emptyInterface))([new $String(msg)])); + $panic(new $String(msg)); + } + if (f.formal === false) { + f.formal = new $Map(); + } + _key = name; (f.formal || $throwRuntimeError("assignment to entry in nil map"))[_key] = { k: _key, v: flag }; }; - bigEndian.prototype.PutUint64 = function(b, v) { return this.$val.PutUint64(b, v); }; - bigEndian.Ptr.prototype.String = function() { - return "BigEndian"; + FlagSet.prototype.Var = function(value, name, usage) { return this.$val.Var(value, name, usage); }; + FlagSet.Ptr.prototype.failf = function(format, a) { + var f, err; + f = this; + err = fmt.Errorf(format, a); + fmt.Fprintln(f.out(), new ($sliceType($emptyInterface))([err])); + f.usage(); + return err; }; - bigEndian.prototype.String = function() { return this.$val.String(); }; - bigEndian.Ptr.prototype.GoString = function() { - return "binary.BigEndian"; + FlagSet.prototype.failf = function(format, a) { return this.$val.failf(format, a); }; + FlagSet.Ptr.prototype.usage = function() { + var f; + f = this; + if (f === $pkg.CommandLine) { + $pkg.Usage(); + } else if (f.Usage === $throwNilPointerError) { + defaultUsage(f); + } else { + f.Usage(); + } }; - bigEndian.prototype.GoString = function() { return this.$val.GoString(); }; - Write = $pkg.Write = function(w, order, data) { - var n, b, bs, v, _ref, _ref$1, _i, i, x, _ref$2, _i$1, i$1, x$1, _ref$3, _i$2, i$2, x$2, _ref$4, _i$3, i$3, x$3, _ref$5, _i$4, i$4, x$4, x$5, _ref$6, _i$5, i$5, x$6, _ref$7, _i$6, i$6, x$7, _tuple, err, v$1, _tuple$1, size, err$1, buf, e, _tuple$2; - n = intDataSize(data); - if (!((n === 0))) { - b = ($arrayType($Uint8, 8)).zero(); $copy(b, ($arrayType($Uint8, 8)).zero(), ($arrayType($Uint8, 8))); - bs = ($sliceType($Uint8)).nil; - if (n > 8) { - bs = ($sliceType($Uint8)).make(n); - } else { - bs = $subslice(new ($sliceType($Uint8))(b), 0, n); - } - _ref = data; - if ($assertType(_ref, ($ptrType($Int8)), true)[1]) { - v = _ref.$val; - bs = $subslice(new ($sliceType($Uint8))(b), 0, 1); - b[0] = (v.$get() << 24 >>> 24); - } else if ($assertType(_ref, $Int8, true)[1]) { - v = _ref.$val; - bs = $subslice(new ($sliceType($Uint8))(b), 0, 1); - b[0] = (v << 24 >>> 24); - } else if ($assertType(_ref, ($sliceType($Int8)), true)[1]) { - v = _ref.$val; - _ref$1 = v; - _i = 0; - while (_i < _ref$1.$length) { - i = _i; - x = ((_i < 0 || _i >= _ref$1.$length) ? $throwRuntimeError("index out of range") : _ref$1.$array[_ref$1.$offset + _i]); - (i < 0 || i >= bs.$length) ? $throwRuntimeError("index out of range") : bs.$array[bs.$offset + i] = (x << 24 >>> 24); - _i++; - } - } else if ($assertType(_ref, ($ptrType($Uint8)), true)[1]) { - v = _ref.$val; - bs = $subslice(new ($sliceType($Uint8))(b), 0, 1); - b[0] = v.$get(); - } else if ($assertType(_ref, $Uint8, true)[1]) { - v = _ref.$val; - bs = $subslice(new ($sliceType($Uint8))(b), 0, 1); - b[0] = v; - } else if ($assertType(_ref, ($sliceType($Uint8)), true)[1]) { - v = _ref.$val; - bs = v; - } else if ($assertType(_ref, ($ptrType($Int16)), true)[1]) { - v = _ref.$val; - bs = $subslice(new ($sliceType($Uint8))(b), 0, 2); - order.PutUint16(bs, (v.$get() << 16 >>> 16)); - } else if ($assertType(_ref, $Int16, true)[1]) { - v = _ref.$val; - bs = $subslice(new ($sliceType($Uint8))(b), 0, 2); - order.PutUint16(bs, (v << 16 >>> 16)); - } else if ($assertType(_ref, ($sliceType($Int16)), true)[1]) { - v = _ref.$val; - _ref$2 = v; - _i$1 = 0; - while (_i$1 < _ref$2.$length) { - i$1 = _i$1; - x$1 = ((_i$1 < 0 || _i$1 >= _ref$2.$length) ? $throwRuntimeError("index out of range") : _ref$2.$array[_ref$2.$offset + _i$1]); - order.PutUint16($subslice(bs, ((((2 >>> 16 << 16) * i$1 >> 0) + (2 << 16 >>> 16) * i$1) >> 0)), (x$1 << 16 >>> 16)); - _i$1++; - } - } else if ($assertType(_ref, ($ptrType($Uint16)), true)[1]) { - v = _ref.$val; - bs = $subslice(new ($sliceType($Uint8))(b), 0, 2); - order.PutUint16(bs, v.$get()); - } else if ($assertType(_ref, $Uint16, true)[1]) { - v = _ref.$val; - bs = $subslice(new ($sliceType($Uint8))(b), 0, 2); - order.PutUint16(bs, v); - } else if ($assertType(_ref, ($sliceType($Uint16)), true)[1]) { - v = _ref.$val; - _ref$3 = v; - _i$2 = 0; - while (_i$2 < _ref$3.$length) { - i$2 = _i$2; - x$2 = ((_i$2 < 0 || _i$2 >= _ref$3.$length) ? $throwRuntimeError("index out of range") : _ref$3.$array[_ref$3.$offset + _i$2]); - order.PutUint16($subslice(bs, ((((2 >>> 16 << 16) * i$2 >> 0) + (2 << 16 >>> 16) * i$2) >> 0)), x$2); - _i$2++; - } - } else if ($assertType(_ref, ($ptrType($Int32)), true)[1]) { - v = _ref.$val; - bs = $subslice(new ($sliceType($Uint8))(b), 0, 4); - order.PutUint32(bs, (v.$get() >>> 0)); - } else if ($assertType(_ref, $Int32, true)[1]) { - v = _ref.$val; - bs = $subslice(new ($sliceType($Uint8))(b), 0, 4); - order.PutUint32(bs, (v >>> 0)); - } else if ($assertType(_ref, ($sliceType($Int32)), true)[1]) { - v = _ref.$val; - _ref$4 = v; - _i$3 = 0; - while (_i$3 < _ref$4.$length) { - i$3 = _i$3; - x$3 = ((_i$3 < 0 || _i$3 >= _ref$4.$length) ? $throwRuntimeError("index out of range") : _ref$4.$array[_ref$4.$offset + _i$3]); - order.PutUint32($subslice(bs, ((((4 >>> 16 << 16) * i$3 >> 0) + (4 << 16 >>> 16) * i$3) >> 0)), (x$3 >>> 0)); - _i$3++; - } - } else if ($assertType(_ref, ($ptrType($Uint32)), true)[1]) { - v = _ref.$val; - bs = $subslice(new ($sliceType($Uint8))(b), 0, 4); - order.PutUint32(bs, v.$get()); - } else if ($assertType(_ref, $Uint32, true)[1]) { - v = _ref.$val; - bs = $subslice(new ($sliceType($Uint8))(b), 0, 4); - order.PutUint32(bs, v); - } else if ($assertType(_ref, ($sliceType($Uint32)), true)[1]) { - v = _ref.$val; - _ref$5 = v; - _i$4 = 0; - while (_i$4 < _ref$5.$length) { - i$4 = _i$4; - x$4 = ((_i$4 < 0 || _i$4 >= _ref$5.$length) ? $throwRuntimeError("index out of range") : _ref$5.$array[_ref$5.$offset + _i$4]); - order.PutUint32($subslice(bs, ((((4 >>> 16 << 16) * i$4 >> 0) + (4 << 16 >>> 16) * i$4) >> 0)), x$4); - _i$4++; - } - } else if ($assertType(_ref, ($ptrType($Int64)), true)[1]) { - v = _ref.$val; - bs = $subslice(new ($sliceType($Uint8))(b), 0, 8); - order.PutUint64(bs, (x$5 = v.$get(), new $Uint64(x$5.$high, x$5.$low))); - } else if ($assertType(_ref, $Int64, true)[1]) { - v = _ref.$val; - bs = $subslice(new ($sliceType($Uint8))(b), 0, 8); - order.PutUint64(bs, new $Uint64(v.$high, v.$low)); - } else if ($assertType(_ref, ($sliceType($Int64)), true)[1]) { - v = _ref.$val; - _ref$6 = v; - _i$5 = 0; - while (_i$5 < _ref$6.$length) { - i$5 = _i$5; - x$6 = ((_i$5 < 0 || _i$5 >= _ref$6.$length) ? $throwRuntimeError("index out of range") : _ref$6.$array[_ref$6.$offset + _i$5]); - order.PutUint64($subslice(bs, ((((8 >>> 16 << 16) * i$5 >> 0) + (8 << 16 >>> 16) * i$5) >> 0)), new $Uint64(x$6.$high, x$6.$low)); - _i$5++; - } - } else if ($assertType(_ref, ($ptrType($Uint64)), true)[1]) { - v = _ref.$val; - bs = $subslice(new ($sliceType($Uint8))(b), 0, 8); - order.PutUint64(bs, v.$get()); - } else if ($assertType(_ref, $Uint64, true)[1]) { - v = _ref.$val; - bs = $subslice(new ($sliceType($Uint8))(b), 0, 8); - order.PutUint64(bs, v); - } else if ($assertType(_ref, ($sliceType($Uint64)), true)[1]) { - v = _ref.$val; - _ref$7 = v; - _i$6 = 0; - while (_i$6 < _ref$7.$length) { - i$6 = _i$6; - x$7 = ((_i$6 < 0 || _i$6 >= _ref$7.$length) ? $throwRuntimeError("index out of range") : _ref$7.$array[_ref$7.$offset + _i$6]); - order.PutUint64($subslice(bs, ((((8 >>> 16 << 16) * i$6 >> 0) + (8 << 16 >>> 16) * i$6) >> 0)), x$7); - _i$6++; - } - } - _tuple = w.Write(bs); err = _tuple[1]; - return err; + FlagSet.prototype.usage = function() { return this.$val.usage(); }; + FlagSet.Ptr.prototype.parseOne = function() { + var f, x$1, s, num_minuses, name, has_value, value, i, m, _tuple, _entry, flag, alreadythere, _tuple$1, fv, ok, err, _tmp, x$2, _tmp$1, err$1, _key; + f = this; + if (f.args.$length === 0) { + return [false, $ifaceNil]; } - v$1 = new reflect.Value.Ptr(); $copy(v$1, reflect.Indirect($clone(reflect.ValueOf(data), reflect.Value)), reflect.Value); - _tuple$1 = dataSize($clone(v$1, reflect.Value)); size = _tuple$1[0]; err$1 = _tuple$1[1]; - if (!($interfaceIsEqual(err$1, $ifaceNil))) { - return errors.New("binary.Write: " + err$1.Error()); + s = (x$1 = f.args, ((0 < 0 || 0 >= x$1.$length) ? $throwRuntimeError("index out of range") : x$1.$array[x$1.$offset + 0])); + if ((s.length === 0) || !((s.charCodeAt(0) === 45)) || (s.length === 1)) { + return [false, $ifaceNil]; } - buf = ($sliceType($Uint8)).make(size); - e = new encoder.Ptr(order, buf); - e.value($clone(v$1, reflect.Value)); - _tuple$2 = w.Write(buf); err$1 = _tuple$2[1]; - return err$1; - }; - dataSize = function(v) { - var _tuple, elem, err, x; - if (v.Kind() === 23) { - _tuple = sizeof(v.Type().Elem()); elem = _tuple[0]; err = _tuple[1]; - if (!($interfaceIsEqual(err, $ifaceNil))) { - return [0, err]; + num_minuses = 1; + if (s.charCodeAt(1) === 45) { + num_minuses = num_minuses + (1) >> 0; + if (s.length === 2) { + f.args = $subslice(f.args, 1); + return [false, $ifaceNil]; } - return [(x = v.Len(), (((x >>> 16 << 16) * elem >> 0) + (x << 16 >>> 16) * elem) >> 0), $ifaceNil]; } - return sizeof(v.Type()); - }; - sizeof = function(t) { - var _ref, _tuple, n, err, x, sum, _tmp, _tmp$1, i, n$1, _tuple$1, s, err$1; - _ref = t.Kind(); - if (_ref === 17) { - _tuple = sizeof(t.Elem()); n = _tuple[0]; err = _tuple[1]; - if (!($interfaceIsEqual(err, $ifaceNil))) { - return [0, err]; - } - return [(x = t.Len(), (((x >>> 16 << 16) * n >> 0) + (x << 16 >>> 16) * n) >> 0), $ifaceNil]; - } else if (_ref === 25) { - sum = 0; - _tmp = 0; _tmp$1 = t.NumField(); i = _tmp; n$1 = _tmp$1; - while (i < n$1) { - _tuple$1 = sizeof(t.Field(i).Type); s = _tuple$1[0]; err$1 = _tuple$1[1]; - if (!($interfaceIsEqual(err$1, $ifaceNil))) { - return [0, err$1]; - } - sum = sum + (s) >> 0; - i = i + (1) >> 0; + name = s.substring(num_minuses); + if ((name.length === 0) || (name.charCodeAt(0) === 45) || (name.charCodeAt(0) === 61)) { + return [false, f.failf("bad flag syntax: %s", new ($sliceType($emptyInterface))([new $String(s)]))]; + } + f.args = $subslice(f.args, 1); + has_value = false; + value = ""; + i = 1; + while (i < name.length) { + if (name.charCodeAt(i) === 61) { + value = name.substring((i + 1 >> 0)); + has_value = true; + name = name.substring(0, i); + break; } - return [sum, $ifaceNil]; - } else if (_ref === 8 || _ref === 9 || _ref === 10 || _ref === 11 || _ref === 3 || _ref === 4 || _ref === 5 || _ref === 6 || _ref === 13 || _ref === 14 || _ref === 15 || _ref === 16) { - return [(t.Size() >> 0), $ifaceNil]; + i = i + (1) >> 0; } - return [0, errors.New("invalid type " + t.String())]; - }; - encoder.Ptr.prototype.uint8 = function(x) { - var e, x$1; - e = this; - (x$1 = e.buf, (0 < 0 || 0 >= x$1.$length) ? $throwRuntimeError("index out of range") : x$1.$array[x$1.$offset + 0] = x); - e.buf = $subslice(e.buf, 1); - }; - encoder.prototype.uint8 = function(x) { return this.$val.uint8(x); }; - encoder.Ptr.prototype.uint16 = function(x) { - var e; - e = this; - e.order.PutUint16($subslice(e.buf, 0, 2), x); - e.buf = $subslice(e.buf, 2); - }; - encoder.prototype.uint16 = function(x) { return this.$val.uint16(x); }; - encoder.Ptr.prototype.uint32 = function(x) { - var e; - e = this; - e.order.PutUint32($subslice(e.buf, 0, 4), x); - e.buf = $subslice(e.buf, 4); - }; - encoder.prototype.uint32 = function(x) { return this.$val.uint32(x); }; - encoder.Ptr.prototype.uint64 = function(x) { - var e; - e = this; - e.order.PutUint64($subslice(e.buf, 0, 8), x); - e.buf = $subslice(e.buf, 8); - }; - encoder.prototype.uint64 = function(x) { return this.$val.uint64(x); }; - encoder.Ptr.prototype.int8 = function(x) { - var e; - e = this; - e.uint8((x << 24 >>> 24)); - }; - encoder.prototype.int8 = function(x) { return this.$val.int8(x); }; - encoder.Ptr.prototype.int16 = function(x) { - var e; - e = this; - e.uint16((x << 16 >>> 16)); - }; - encoder.prototype.int16 = function(x) { return this.$val.int16(x); }; - encoder.Ptr.prototype.int32 = function(x) { - var e; - e = this; - e.uint32((x >>> 0)); - }; - encoder.prototype.int32 = function(x) { return this.$val.int32(x); }; - encoder.Ptr.prototype.int64 = function(x) { - var e; - e = this; - e.uint64(new $Uint64(x.$high, x.$low)); - }; - encoder.prototype.int64 = function(x) { return this.$val.int64(x); }; - encoder.Ptr.prototype.value = function(v) { - var e, _ref, l, i, t, l$1, i$1, v$1, l$2, i$2, _ref$1, x, x$1, x$2, _ref$2, _ref$3, _ref$4, x$3, x$4; - e = this; - _ref = v.Kind(); - if (_ref === 17) { - l = v.Len(); - i = 0; - while (i < l) { - e.value($clone(v.Index(i), reflect.Value)); - i = i + (1) >> 0; + m = f.formal; + _tuple = (_entry = m[name], _entry !== undefined ? [_entry.v, true] : [($ptrType(Flag)).nil, false]); flag = _tuple[0]; alreadythere = _tuple[1]; + if (!alreadythere) { + if (name === "help" || name === "h") { + f.usage(); + return [false, $pkg.ErrHelp]; } - } else if (_ref === 25) { - t = v.Type(); - l$1 = v.NumField(); - i$1 = 0; - while (i$1 < l$1) { - v$1 = new reflect.Value.Ptr(); $copy(v$1, v.Field(i$1), reflect.Value); - if (v$1.CanSet() || !(t.Field(i$1).Name === "_")) { - e.value($clone(v$1, reflect.Value)); - } else { - e.skip($clone(v$1, reflect.Value)); + return [false, f.failf("flag provided but not defined: -%s", new ($sliceType($emptyInterface))([new $String(name)]))]; + } + _tuple$1 = $assertType(flag.Value, boolFlag, true); fv = _tuple$1[0]; ok = _tuple$1[1]; + if (ok && fv.IsBoolFlag()) { + if (has_value) { + err = fv.Set(value); + if (!($interfaceIsEqual(err, $ifaceNil))) { + return [false, f.failf("invalid boolean value %q for -%s: %v", new ($sliceType($emptyInterface))([new $String(value), new $String(name), err]))]; } - i$1 = i$1 + (1) >> 0; + } else { + fv.Set("true"); } - } else if (_ref === 23) { - l$2 = v.Len(); - i$2 = 0; - while (i$2 < l$2) { - e.value($clone(v.Index(i$2), reflect.Value)); - i$2 = i$2 + (1) >> 0; + } else { + if (!has_value && f.args.$length > 0) { + has_value = true; + _tmp = (x$2 = f.args, ((0 < 0 || 0 >= x$2.$length) ? $throwRuntimeError("index out of range") : x$2.$array[x$2.$offset + 0])); _tmp$1 = $subslice(f.args, 1); value = _tmp; f.args = _tmp$1; } - } else if (_ref === 2 || _ref === 3 || _ref === 4 || _ref === 5 || _ref === 6) { - _ref$1 = v.Type().Kind(); - if (_ref$1 === 3) { - e.int8(((x = v.Int(), x.$low + ((x.$high >> 31) * 4294967296)) << 24 >> 24)); - } else if (_ref$1 === 4) { - e.int16(((x$1 = v.Int(), x$1.$low + ((x$1.$high >> 31) * 4294967296)) << 16 >> 16)); - } else if (_ref$1 === 5) { - e.int32(((x$2 = v.Int(), x$2.$low + ((x$2.$high >> 31) * 4294967296)) >> 0)); - } else if (_ref$1 === 6) { - e.int64(v.Int()); + if (!has_value) { + return [false, f.failf("flag needs an argument: -%s", new ($sliceType($emptyInterface))([new $String(name)]))]; } - } else if (_ref === 7 || _ref === 8 || _ref === 9 || _ref === 10 || _ref === 11 || _ref === 12) { - _ref$2 = v.Type().Kind(); - if (_ref$2 === 8) { - e.uint8((v.Uint().$low << 24 >>> 24)); - } else if (_ref$2 === 9) { - e.uint16((v.Uint().$low << 16 >>> 16)); - } else if (_ref$2 === 10) { - e.uint32((v.Uint().$low >>> 0)); - } else if (_ref$2 === 11) { - e.uint64(v.Uint()); + err$1 = flag.Value.Set(value); + if (!($interfaceIsEqual(err$1, $ifaceNil))) { + return [false, f.failf("invalid value %q for flag -%s: %v", new ($sliceType($emptyInterface))([new $String(value), new $String(name), err$1]))]; } - } else if (_ref === 13 || _ref === 14) { - _ref$3 = v.Type().Kind(); - if (_ref$3 === 13) { - e.uint32(math.Float32bits(v.Float())); - } else if (_ref$3 === 14) { - e.uint64(math.Float64bits(v.Float())); + } + if (f.actual === false) { + f.actual = new $Map(); + } + _key = name; (f.actual || $throwRuntimeError("assignment to entry in nil map"))[_key] = { k: _key, v: flag }; + return [true, $ifaceNil]; + }; + FlagSet.prototype.parseOne = function() { return this.$val.parseOne(); }; + FlagSet.Ptr.prototype.Parse = function(arguments$1) { + var f, _tuple, seen, err, _ref; + f = this; + f.parsed = true; + f.args = arguments$1; + while (true) { + _tuple = f.parseOne(); seen = _tuple[0]; err = _tuple[1]; + if (seen) { + continue; } - } else if (_ref === 15 || _ref === 16) { - _ref$4 = v.Type().Kind(); - if (_ref$4 === 15) { - x$3 = v.Complex(); - e.uint32(math.Float32bits(x$3.$real)); - e.uint32(math.Float32bits(x$3.$imag)); - } else if (_ref$4 === 16) { - x$4 = v.Complex(); - e.uint64(math.Float64bits(x$4.$real)); - e.uint64(math.Float64bits(x$4.$imag)); + if ($interfaceIsEqual(err, $ifaceNil)) { + break; + } + _ref = f.errorHandling; + if (_ref === 0) { + return err; + } else if (_ref === 1) { + os.Exit(2); + } else if (_ref === 2) { + $panic(err); } } + return $ifaceNil; }; - encoder.prototype.value = function(v) { return this.$val.value(v); }; - encoder.Ptr.prototype.skip = function(v) { - var e, _tuple, n, _ref, _i, i, x; - e = this; - _tuple = dataSize($clone(v, reflect.Value)); n = _tuple[0]; - _ref = $subslice(e.buf, 0, n); - _i = 0; - while (_i < _ref.$length) { - i = _i; - (x = e.buf, (i < 0 || i >= x.$length) ? $throwRuntimeError("index out of range") : x.$array[x.$offset + i] = 0); - _i++; - } - e.buf = $subslice(e.buf, n); + FlagSet.prototype.Parse = function(arguments$1) { return this.$val.Parse(arguments$1); }; + FlagSet.Ptr.prototype.Parsed = function() { + var f; + f = this; + return f.parsed; }; - encoder.prototype.skip = function(v) { return this.$val.skip(v); }; - intDataSize = function(data) { - var data$1, _ref, x, x$1, x$2, x$3, x$4, x$5; - _ref = data; - if ($assertType(_ref, $Int8, true)[1] || $assertType(_ref, ($ptrType($Int8)), true)[1] || $assertType(_ref, ($ptrType($Uint8)), true)[1]) { - data$1 = _ref; - return 1; - } else if ($assertType(_ref, ($sliceType($Int8)), true)[1]) { - data$1 = _ref.$val; - return data$1.$length; - } else if ($assertType(_ref, ($sliceType($Uint8)), true)[1]) { - data$1 = _ref.$val; - return data$1.$length; - } else if ($assertType(_ref, $Int16, true)[1] || $assertType(_ref, ($ptrType($Int16)), true)[1] || $assertType(_ref, ($ptrType($Uint16)), true)[1]) { - data$1 = _ref; - return 2; - } else if ($assertType(_ref, ($sliceType($Int16)), true)[1]) { - data$1 = _ref.$val; - return (x = data$1.$length, (((2 >>> 16 << 16) * x >> 0) + (2 << 16 >>> 16) * x) >> 0); - } else if ($assertType(_ref, ($sliceType($Uint16)), true)[1]) { - data$1 = _ref.$val; - return (x$1 = data$1.$length, (((2 >>> 16 << 16) * x$1 >> 0) + (2 << 16 >>> 16) * x$1) >> 0); - } else if ($assertType(_ref, $Int32, true)[1] || $assertType(_ref, ($ptrType($Int32)), true)[1] || $assertType(_ref, ($ptrType($Uint32)), true)[1]) { - data$1 = _ref; - return 4; - } else if ($assertType(_ref, ($sliceType($Int32)), true)[1]) { - data$1 = _ref.$val; - return (x$2 = data$1.$length, (((4 >>> 16 << 16) * x$2 >> 0) + (4 << 16 >>> 16) * x$2) >> 0); - } else if ($assertType(_ref, ($sliceType($Uint32)), true)[1]) { - data$1 = _ref.$val; - return (x$3 = data$1.$length, (((4 >>> 16 << 16) * x$3 >> 0) + (4 << 16 >>> 16) * x$3) >> 0); - } else if ($assertType(_ref, $Int64, true)[1] || $assertType(_ref, ($ptrType($Int64)), true)[1] || $assertType(_ref, ($ptrType($Uint64)), true)[1]) { - data$1 = _ref; - return 8; - } else if ($assertType(_ref, ($sliceType($Int64)), true)[1]) { - data$1 = _ref.$val; - return (x$4 = data$1.$length, (((8 >>> 16 << 16) * x$4 >> 0) + (8 << 16 >>> 16) * x$4) >> 0); - } else if ($assertType(_ref, ($sliceType($Uint64)), true)[1]) { - data$1 = _ref.$val; - return (x$5 = data$1.$length, (((8 >>> 16 << 16) * x$5 >> 0) + (8 << 16 >>> 16) * x$5) >> 0); - } - return 0; + FlagSet.prototype.Parsed = function() { return this.$val.Parsed(); }; + Parse = $pkg.Parse = function() { + $pkg.CommandLine.Parse($subslice(os.Args, 1)); + }; + NewFlagSet = $pkg.NewFlagSet = function(name, errorHandling) { + var f; + f = new FlagSet.Ptr($throwNilPointerError, name, false, false, false, ($sliceType($String)).nil, errorHandling, $ifaceNil); + return f; + }; + FlagSet.Ptr.prototype.Init = function(name, errorHandling) { + var f; + f = this; + f.name = name; + f.errorHandling = errorHandling; }; + FlagSet.prototype.Init = function(name, errorHandling) { return this.$val.Init(name, errorHandling); }; $pkg.$init = function() { - ByteOrder.init([["PutUint16", "PutUint16", "", $funcType([($sliceType($Uint8)), $Uint16], [], false)], ["PutUint32", "PutUint32", "", $funcType([($sliceType($Uint8)), $Uint32], [], false)], ["PutUint64", "PutUint64", "", $funcType([($sliceType($Uint8)), $Uint64], [], false)], ["String", "String", "", $funcType([], [$String], false)], ["Uint16", "Uint16", "", $funcType([($sliceType($Uint8))], [$Uint16], false)], ["Uint32", "Uint32", "", $funcType([($sliceType($Uint8))], [$Uint32], false)], ["Uint64", "Uint64", "", $funcType([($sliceType($Uint8))], [$Uint64], false)]]); - bigEndian.methods = [["GoString", "GoString", "", $funcType([], [$String], false), -1], ["PutUint16", "PutUint16", "", $funcType([($sliceType($Uint8)), $Uint16], [], false), -1], ["PutUint32", "PutUint32", "", $funcType([($sliceType($Uint8)), $Uint32], [], false), -1], ["PutUint64", "PutUint64", "", $funcType([($sliceType($Uint8)), $Uint64], [], false), -1], ["String", "String", "", $funcType([], [$String], false), -1], ["Uint16", "Uint16", "", $funcType([($sliceType($Uint8))], [$Uint16], false), -1], ["Uint32", "Uint32", "", $funcType([($sliceType($Uint8))], [$Uint32], false), -1], ["Uint64", "Uint64", "", $funcType([($sliceType($Uint8))], [$Uint64], false), -1]]; - ($ptrType(bigEndian)).methods = [["GoString", "GoString", "", $funcType([], [$String], false), -1], ["PutUint16", "PutUint16", "", $funcType([($sliceType($Uint8)), $Uint16], [], false), -1], ["PutUint32", "PutUint32", "", $funcType([($sliceType($Uint8)), $Uint32], [], false), -1], ["PutUint64", "PutUint64", "", $funcType([($sliceType($Uint8)), $Uint64], [], false), -1], ["String", "String", "", $funcType([], [$String], false), -1], ["Uint16", "Uint16", "", $funcType([($sliceType($Uint8))], [$Uint16], false), -1], ["Uint32", "Uint32", "", $funcType([($sliceType($Uint8))], [$Uint32], false), -1], ["Uint64", "Uint64", "", $funcType([($sliceType($Uint8))], [$Uint64], false), -1]]; - bigEndian.init([]); - ($ptrType(encoder)).methods = [["int16", "int16", "encoding/binary", $funcType([$Int16], [], false), -1], ["int32", "int32", "encoding/binary", $funcType([$Int32], [], false), -1], ["int64", "int64", "encoding/binary", $funcType([$Int64], [], false), -1], ["int8", "int8", "encoding/binary", $funcType([$Int8], [], false), -1], ["skip", "skip", "encoding/binary", $funcType([reflect.Value], [], false), -1], ["uint16", "uint16", "encoding/binary", $funcType([$Uint16], [], false), -1], ["uint32", "uint32", "encoding/binary", $funcType([$Uint32], [], false), -1], ["uint64", "uint64", "encoding/binary", $funcType([$Uint64], [], false), -1], ["uint8", "uint8", "encoding/binary", $funcType([$Uint8], [], false), -1], ["value", "value", "encoding/binary", $funcType([reflect.Value], [], false), -1]]; - encoder.init([["order", "order", "encoding/binary", ByteOrder, ""], ["buf", "buf", "encoding/binary", ($sliceType($Uint8)), ""]]); - $pkg.BigEndian = new bigEndian.Ptr(); - overflow = errors.New("binary: varint overflows a 64-bit integer"); + ($ptrType(boolValue)).methods = [["Get", "Get", "", $funcType([], [$emptyInterface], false), -1], ["IsBoolFlag", "IsBoolFlag", "", $funcType([], [$Bool], false), -1], ["Set", "Set", "", $funcType([$String], [$error], false), -1], ["String", "String", "", $funcType([], [$String], false), -1]]; + boolFlag.init([["IsBoolFlag", "IsBoolFlag", "", $funcType([], [$Bool], false)], ["Set", "Set", "", $funcType([$String], [$error], false)], ["String", "String", "", $funcType([], [$String], false)]]); + ($ptrType(intValue)).methods = [["Get", "Get", "", $funcType([], [$emptyInterface], false), -1], ["Set", "Set", "", $funcType([$String], [$error], false), -1], ["String", "String", "", $funcType([], [$String], false), -1]]; + ($ptrType(int64Value)).methods = [["Get", "Get", "", $funcType([], [$emptyInterface], false), -1], ["Set", "Set", "", $funcType([$String], [$error], false), -1], ["String", "String", "", $funcType([], [$String], false), -1]]; + ($ptrType(uintValue)).methods = [["Get", "Get", "", $funcType([], [$emptyInterface], false), -1], ["Set", "Set", "", $funcType([$String], [$error], false), -1], ["String", "String", "", $funcType([], [$String], false), -1]]; + ($ptrType(uint64Value)).methods = [["Get", "Get", "", $funcType([], [$emptyInterface], false), -1], ["Set", "Set", "", $funcType([$String], [$error], false), -1], ["String", "String", "", $funcType([], [$String], false), -1]]; + ($ptrType(stringValue)).methods = [["Get", "Get", "", $funcType([], [$emptyInterface], false), -1], ["Set", "Set", "", $funcType([$String], [$error], false), -1], ["String", "String", "", $funcType([], [$String], false), -1]]; + ($ptrType(float64Value)).methods = [["Get", "Get", "", $funcType([], [$emptyInterface], false), -1], ["Set", "Set", "", $funcType([$String], [$error], false), -1], ["String", "String", "", $funcType([], [$String], false), -1]]; + ($ptrType(durationValue)).methods = [["Get", "Get", "", $funcType([], [$emptyInterface], false), -1], ["Set", "Set", "", $funcType([$String], [$error], false), -1], ["String", "String", "", $funcType([], [$String], false), -1]]; + Value.init([["Set", "Set", "", $funcType([$String], [$error], false)], ["String", "String", "", $funcType([], [$String], false)]]); + ($ptrType(FlagSet)).methods = [["Arg", "Arg", "", $funcType([$Int], [$String], false), -1], ["Args", "Args", "", $funcType([], [($sliceType($String))], false), -1], ["Bool", "Bool", "", $funcType([$String, $Bool, $String], [($ptrType($Bool))], false), -1], ["BoolVar", "BoolVar", "", $funcType([($ptrType($Bool)), $String, $Bool, $String], [], false), -1], ["Duration", "Duration", "", $funcType([$String, time.Duration, $String], [($ptrType(time.Duration))], false), -1], ["DurationVar", "DurationVar", "", $funcType([($ptrType(time.Duration)), $String, time.Duration, $String], [], false), -1], ["Float64", "Float64", "", $funcType([$String, $Float64, $String], [($ptrType($Float64))], false), -1], ["Float64Var", "Float64Var", "", $funcType([($ptrType($Float64)), $String, $Float64, $String], [], false), -1], ["Init", "Init", "", $funcType([$String, ErrorHandling], [], false), -1], ["Int", "Int", "", $funcType([$String, $Int, $String], [($ptrType($Int))], false), -1], ["Int64", "Int64", "", $funcType([$String, $Int64, $String], [($ptrType($Int64))], false), -1], ["Int64Var", "Int64Var", "", $funcType([($ptrType($Int64)), $String, $Int64, $String], [], false), -1], ["IntVar", "IntVar", "", $funcType([($ptrType($Int)), $String, $Int, $String], [], false), -1], ["Lookup", "Lookup", "", $funcType([$String], [($ptrType(Flag))], false), -1], ["NArg", "NArg", "", $funcType([], [$Int], false), -1], ["NFlag", "NFlag", "", $funcType([], [$Int], false), -1], ["Parse", "Parse", "", $funcType([($sliceType($String))], [$error], false), -1], ["Parsed", "Parsed", "", $funcType([], [$Bool], false), -1], ["PrintDefaults", "PrintDefaults", "", $funcType([], [], false), -1], ["Set", "Set", "", $funcType([$String, $String], [$error], false), -1], ["SetOutput", "SetOutput", "", $funcType([io.Writer], [], false), -1], ["String", "String", "", $funcType([$String, $String, $String], [($ptrType($String))], false), -1], ["StringVar", "StringVar", "", $funcType([($ptrType($String)), $String, $String, $String], [], false), -1], ["Uint", "Uint", "", $funcType([$String, $Uint, $String], [($ptrType($Uint))], false), -1], ["Uint64", "Uint64", "", $funcType([$String, $Uint64, $String], [($ptrType($Uint64))], false), -1], ["Uint64Var", "Uint64Var", "", $funcType([($ptrType($Uint64)), $String, $Uint64, $String], [], false), -1], ["UintVar", "UintVar", "", $funcType([($ptrType($Uint)), $String, $Uint, $String], [], false), -1], ["Var", "Var", "", $funcType([Value, $String, $String], [], false), -1], ["Visit", "Visit", "", $funcType([($funcType([($ptrType(Flag))], [], false))], [], false), -1], ["VisitAll", "VisitAll", "", $funcType([($funcType([($ptrType(Flag))], [], false))], [], false), -1], ["failf", "failf", "flag", $funcType([$String, ($sliceType($emptyInterface))], [$error], true), -1], ["out", "out", "flag", $funcType([], [io.Writer], false), -1], ["parseOne", "parseOne", "flag", $funcType([], [$Bool, $error], false), -1], ["usage", "usage", "flag", $funcType([], [], false), -1]]; + FlagSet.init([["Usage", "Usage", "", ($funcType([], [], false)), ""], ["name", "name", "flag", $String, ""], ["parsed", "parsed", "flag", $Bool, ""], ["actual", "actual", "flag", ($mapType($String, ($ptrType(Flag)))), ""], ["formal", "formal", "flag", ($mapType($String, ($ptrType(Flag)))), ""], ["args", "args", "flag", ($sliceType($String)), ""], ["errorHandling", "errorHandling", "flag", ErrorHandling, ""], ["output", "output", "flag", io.Writer, ""]]); + Flag.init([["Name", "Name", "", $String, ""], ["Usage", "Usage", "", $String, ""], ["Value", "Value", "", Value, ""], ["DefValue", "DefValue", "", $String, ""]]); + $pkg.ErrHelp = errors.New("flag: help requested"); + $pkg.CommandLine = NewFlagSet((x = os.Args, ((0 < 0 || 0 >= x.$length) ? $throwRuntimeError("index out of range") : x.$array[x.$offset + 0])), 1); + $pkg.Usage = (function() { + var x$1; + fmt.Fprintf(os.Stderr, "Usage of %s:\n", new ($sliceType($emptyInterface))([new $String((x$1 = os.Args, ((0 < 0 || 0 >= x$1.$length) ? $throwRuntimeError("index out of range") : x$1.$array[x$1.$offset + 0])))])); + PrintDefaults(); + }); }; return $pkg; })(); -$packages["math/rand"] = (function() { - var $pkg = {}, math = $packages["math"], sync = $packages["sync"], Source, Rand, lockedSource, rngSource, ke, we, fe, kn, wn, fn, globalRand, rng_cooked, absInt32, NewSource, New, seedrand; - Source = $pkg.Source = $newType(8, "Interface", "rand.Source", "Source", "math/rand", null); - Rand = $pkg.Rand = $newType(0, "Struct", "rand.Rand", "Rand", "math/rand", function(src_) { - this.$val = this; - this.src = src_ !== undefined ? src_ : $ifaceNil; - }); - lockedSource = $pkg.lockedSource = $newType(0, "Struct", "rand.lockedSource", "lockedSource", "math/rand", function(lk_, src_) { - this.$val = this; - this.lk = lk_ !== undefined ? lk_ : new sync.Mutex.Ptr(); - this.src = src_ !== undefined ? src_ : $ifaceNil; - }); - rngSource = $pkg.rngSource = $newType(0, "Struct", "rand.rngSource", "rngSource", "math/rand", function(tap_, feed_, vec_) { +$packages["bufio"] = (function() { + var $pkg = {}, bytes = $packages["bytes"], errors = $packages["errors"], io = $packages["io"], utf8 = $packages["unicode/utf8"], Reader, errNegativeRead, NewReaderSize, NewReader; + Reader = $pkg.Reader = $newType(0, "Struct", "bufio.Reader", "Reader", "bufio", function(buf_, rd_, r_, w_, err_, lastByte_, lastRuneSize_) { this.$val = this; - this.tap = tap_ !== undefined ? tap_ : 0; - this.feed = feed_ !== undefined ? feed_ : 0; - this.vec = vec_ !== undefined ? vec_ : ($arrayType($Int64, 607)).zero(); + this.buf = buf_ !== undefined ? buf_ : ($sliceType($Uint8)).nil; + this.rd = rd_ !== undefined ? rd_ : $ifaceNil; + this.r = r_ !== undefined ? r_ : 0; + this.w = w_ !== undefined ? w_ : 0; + this.err = err_ !== undefined ? err_ : $ifaceNil; + this.lastByte = lastByte_ !== undefined ? lastByte_ : 0; + this.lastRuneSize = lastRuneSize_ !== undefined ? lastRuneSize_ : 0; }); - Rand.Ptr.prototype.ExpFloat64 = function() { - var r, j, i, x, x$1; - r = this; - while (true) { - j = r.Uint32(); - i = (j & 255) >>> 0; - x = j * $coerceFloat32(((i < 0 || i >= we.length) ? $throwRuntimeError("index out of range") : we[i])); - if (j < ((i < 0 || i >= ke.length) ? $throwRuntimeError("index out of range") : ke[i])) { - return x; + NewReaderSize = $pkg.NewReaderSize = function(rd, size) { + var _tuple, b, ok, r; + _tuple = $assertType(rd, ($ptrType(Reader)), true); b = _tuple[0]; ok = _tuple[1]; + if (ok && b.buf.$length >= size) { + return b; + } + if (size < 16) { + size = 16; + } + r = new Reader.Ptr(); + r.reset(($sliceType($Uint8)).make(size), rd); + return r; + }; + NewReader = $pkg.NewReader = function(rd) { + return NewReaderSize(rd, 4096); + }; + Reader.Ptr.prototype.Reset = function(r) { + var b; + b = this; + b.reset(b.buf, r); + }; + Reader.prototype.Reset = function(r) { return this.$val.Reset(r); }; + Reader.Ptr.prototype.reset = function(buf, r) { + var b; + b = this; + $copy(b, new Reader.Ptr(buf, r, 0, 0, $ifaceNil, -1, -1), Reader); + }; + Reader.prototype.reset = function(buf, r) { return this.$val.reset(buf, r); }; + Reader.Ptr.prototype.fill = function() { + var b, i, _tuple, n, err; + b = this; + if (b.r > 0) { + $copySlice(b.buf, $subslice(b.buf, b.r, b.w)); + b.w = b.w - (b.r) >> 0; + b.r = 0; + } + if (b.w >= b.buf.$length) { + $panic(new $String("bufio: tried to fill full buffer")); + } + i = 100; + while (i > 0) { + _tuple = b.rd.Read($subslice(b.buf, b.w)); n = _tuple[0]; err = _tuple[1]; + if (n < 0) { + $panic(errNegativeRead); } - if (i === 0) { - return 7.69711747013105 - math.Log(r.Float64()); + b.w = b.w + (n) >> 0; + if (!($interfaceIsEqual(err, $ifaceNil))) { + b.err = err; + return; } - if (((i < 0 || i >= fe.length) ? $throwRuntimeError("index out of range") : fe[i]) + r.Float64() * ((x$1 = i - 1 >>> 0, ((x$1 < 0 || x$1 >= fe.length) ? $throwRuntimeError("index out of range") : fe[x$1])) - ((i < 0 || i >= fe.length) ? $throwRuntimeError("index out of range") : fe[i])) < math.Exp(-x)) { - return x; + if (n > 0) { + return; } + i = i - (1) >> 0; } + b.err = io.ErrNoProgress; }; - Rand.prototype.ExpFloat64 = function() { return this.$val.ExpFloat64(); }; - absInt32 = function(i) { - if (i < 0) { - return (-i >>> 0); + Reader.prototype.fill = function() { return this.$val.fill(); }; + Reader.Ptr.prototype.readErr = function() { + var b, err; + b = this; + err = b.err; + b.err = $ifaceNil; + return err; + }; + Reader.prototype.readErr = function() { return this.$val.readErr(); }; + Reader.Ptr.prototype.Peek = function(n) { + var b, m, err; + b = this; + if (n < 0) { + return [($sliceType($Uint8)).nil, $pkg.ErrNegativeCount]; } - return (i >>> 0); + if (n > b.buf.$length) { + return [($sliceType($Uint8)).nil, $pkg.ErrBufferFull]; + } + while ((b.w - b.r >> 0) < n && $interfaceIsEqual(b.err, $ifaceNil)) { + b.fill(); + } + m = b.w - b.r >> 0; + if (m > n) { + m = n; + } + err = $ifaceNil; + if (m < n) { + err = b.readErr(); + if ($interfaceIsEqual(err, $ifaceNil)) { + err = $pkg.ErrBufferFull; + } + } + return [$subslice(b.buf, b.r, (b.r + m >> 0)), err]; }; - Rand.Ptr.prototype.NormFloat64 = function() { - var r, j, i, x, y, x$1; - r = this; - while (true) { - j = (r.Uint32() >> 0); - i = j & 127; - x = j * $coerceFloat32(((i < 0 || i >= wn.length) ? $throwRuntimeError("index out of range") : wn[i])); - if (absInt32(j) < ((i < 0 || i >= kn.length) ? $throwRuntimeError("index out of range") : kn[i])) { - return x; + Reader.prototype.Peek = function(n) { return this.$val.Peek(n); }; + Reader.Ptr.prototype.Read = function(p) { + var n = 0, err = $ifaceNil, b, _tmp, _tmp$1, _tmp$2, _tmp$3, _tuple, x, _tmp$4, _tmp$5, _tmp$6, _tmp$7, x$1, x$2, _tmp$8, _tmp$9; + b = this; + n = p.$length; + if (n === 0) { + _tmp = 0; _tmp$1 = b.readErr(); n = _tmp; err = _tmp$1; + return [n, err]; + } + if (b.r === b.w) { + if (!($interfaceIsEqual(b.err, $ifaceNil))) { + _tmp$2 = 0; _tmp$3 = b.readErr(); n = _tmp$2; err = _tmp$3; + return [n, err]; } - if (i === 0) { - while (true) { - x = -math.Log(r.Float64()) * 0.29047645161474317; - y = -math.Log(r.Float64()); - if (y + y >= x * x) { - break; - } + if (p.$length >= b.buf.$length) { + _tuple = b.rd.Read(p); n = _tuple[0]; b.err = _tuple[1]; + if (n < 0) { + $panic(errNegativeRead); } - if (j > 0) { - return 3.442619855899 + x; + if (n > 0) { + b.lastByte = ((x = n - 1 >> 0, ((x < 0 || x >= p.$length) ? $throwRuntimeError("index out of range") : p.$array[p.$offset + x])) >> 0); + b.lastRuneSize = -1; } - return -3.442619855899 - x; + _tmp$4 = n; _tmp$5 = b.readErr(); n = _tmp$4; err = _tmp$5; + return [n, err]; } - if (((i < 0 || i >= fn.length) ? $throwRuntimeError("index out of range") : fn[i]) + r.Float64() * ((x$1 = i - 1 >> 0, ((x$1 < 0 || x$1 >= fn.length) ? $throwRuntimeError("index out of range") : fn[x$1])) - ((i < 0 || i >= fn.length) ? $throwRuntimeError("index out of range") : fn[i])) < math.Exp(-0.5 * x * x)) { - return x; + b.fill(); + if (b.w === b.r) { + _tmp$6 = 0; _tmp$7 = b.readErr(); n = _tmp$6; err = _tmp$7; + return [n, err]; } } + if (n > (b.w - b.r >> 0)) { + n = b.w - b.r >> 0; + } + $copySlice($subslice(p, 0, n), $subslice(b.buf, b.r)); + b.r = b.r + (n) >> 0; + b.lastByte = ((x$1 = b.buf, x$2 = b.r - 1 >> 0, ((x$2 < 0 || x$2 >= x$1.$length) ? $throwRuntimeError("index out of range") : x$1.$array[x$1.$offset + x$2])) >> 0); + b.lastRuneSize = -1; + _tmp$8 = n; _tmp$9 = $ifaceNil; n = _tmp$8; err = _tmp$9; + return [n, err]; }; - Rand.prototype.NormFloat64 = function() { return this.$val.NormFloat64(); }; - NewSource = $pkg.NewSource = function(seed) { - var rng; - rng = new rngSource.Ptr(); $copy(rng, new rngSource.Ptr(), rngSource); - rng.Seed(seed); - return rng; - }; - New = $pkg.New = function(src) { - return new Rand.Ptr(src); - }; - Rand.Ptr.prototype.Seed = function(seed) { - var r; - r = this; - r.src.Seed(seed); - }; - Rand.prototype.Seed = function(seed) { return this.$val.Seed(seed); }; - Rand.Ptr.prototype.Int63 = function() { - var r; - r = this; - return r.src.Int63(); - }; - Rand.prototype.Int63 = function() { return this.$val.Int63(); }; - Rand.Ptr.prototype.Uint32 = function() { - var r; - r = this; - return ($shiftRightInt64(r.Int63(), 31).$low >>> 0); - }; - Rand.prototype.Uint32 = function() { return this.$val.Uint32(); }; - Rand.Ptr.prototype.Int31 = function() { - var r, x; - r = this; - return ((x = $shiftRightInt64(r.Int63(), 32), x.$low + ((x.$high >> 31) * 4294967296)) >> 0); + Reader.prototype.Read = function(p) { return this.$val.Read(p); }; + Reader.Ptr.prototype.ReadByte = function() { + var c = 0, err = $ifaceNil, b, _tmp, _tmp$1, x, x$1, _tmp$2, _tmp$3; + b = this; + b.lastRuneSize = -1; + while (b.r === b.w) { + if (!($interfaceIsEqual(b.err, $ifaceNil))) { + _tmp = 0; _tmp$1 = b.readErr(); c = _tmp; err = _tmp$1; + return [c, err]; + } + b.fill(); + } + c = (x = b.buf, x$1 = b.r, ((x$1 < 0 || x$1 >= x.$length) ? $throwRuntimeError("index out of range") : x.$array[x.$offset + x$1])); + b.r = b.r + (1) >> 0; + b.lastByte = (c >> 0); + _tmp$2 = c; _tmp$3 = $ifaceNil; c = _tmp$2; err = _tmp$3; + return [c, err]; }; - Rand.prototype.Int31 = function() { return this.$val.Int31(); }; - Rand.Ptr.prototype.Int = function() { - var r, u; - r = this; - u = (r.Int63().$low >>> 0); - return (((u << 1 >>> 0) >>> 1 >>> 0) >> 0); + Reader.prototype.ReadByte = function() { return this.$val.ReadByte(); }; + Reader.Ptr.prototype.UnreadByte = function() { + var b, x, x$1; + b = this; + if (b.lastByte < 0 || (b.r === 0) && b.w > 0) { + return $pkg.ErrInvalidUnreadByte; + } + if (b.r > 0) { + b.r = b.r - (1) >> 0; + } else { + b.w = 1; + } + (x = b.buf, x$1 = b.r, (x$1 < 0 || x$1 >= x.$length) ? $throwRuntimeError("index out of range") : x.$array[x.$offset + x$1] = (b.lastByte << 24 >>> 24)); + b.lastByte = -1; + b.lastRuneSize = -1; + return $ifaceNil; }; - Rand.prototype.Int = function() { return this.$val.Int(); }; - Rand.Ptr.prototype.Int63n = function(n) { - var r, x, x$1, x$2, x$3, x$4, x$5, max, v; - r = this; - if ((n.$high < 0 || (n.$high === 0 && n.$low <= 0))) { - $panic(new $String("invalid argument to Int63n")); + Reader.prototype.UnreadByte = function() { return this.$val.UnreadByte(); }; + Reader.Ptr.prototype.ReadRune = function() { + var r = 0, size = 0, err = $ifaceNil, b, _tmp, _tmp$1, _tmp$2, _tmp$3, x, x$1, _tmp$4, _tuple, x$2, x$3, _tmp$5, _tmp$6, _tmp$7; + b = this; + while ((b.r + 4 >> 0) > b.w && !utf8.FullRune($subslice(b.buf, b.r, b.w)) && $interfaceIsEqual(b.err, $ifaceNil) && (b.w - b.r >> 0) < b.buf.$length) { + b.fill(); } - if ((x = (x$1 = new $Int64(n.$high - 0, n.$low - 1), new $Int64(n.$high & x$1.$high, (n.$low & x$1.$low) >>> 0)), (x.$high === 0 && x.$low === 0))) { - return (x$2 = r.Int63(), x$3 = new $Int64(n.$high - 0, n.$low - 1), new $Int64(x$2.$high & x$3.$high, (x$2.$low & x$3.$low) >>> 0)); + b.lastRuneSize = -1; + if (b.r === b.w) { + _tmp = 0; _tmp$1 = 0; _tmp$2 = b.readErr(); r = _tmp; size = _tmp$1; err = _tmp$2; + return [r, size, err]; } - max = (x$4 = (x$5 = $div64(new $Uint64(2147483648, 0), new $Uint64(n.$high, n.$low), true), new $Uint64(2147483647 - x$5.$high, 4294967295 - x$5.$low)), new $Int64(x$4.$high, x$4.$low)); - v = r.Int63(); - while ((v.$high > max.$high || (v.$high === max.$high && v.$low > max.$low))) { - v = r.Int63(); + _tmp$3 = ((x = b.buf, x$1 = b.r, ((x$1 < 0 || x$1 >= x.$length) ? $throwRuntimeError("index out of range") : x.$array[x.$offset + x$1])) >> 0); _tmp$4 = 1; r = _tmp$3; size = _tmp$4; + if (r >= 128) { + _tuple = utf8.DecodeRune($subslice(b.buf, b.r, b.w)); r = _tuple[0]; size = _tuple[1]; } - return $div64(v, n, true); + b.r = b.r + (size) >> 0; + b.lastByte = ((x$2 = b.buf, x$3 = b.r - 1 >> 0, ((x$3 < 0 || x$3 >= x$2.$length) ? $throwRuntimeError("index out of range") : x$2.$array[x$2.$offset + x$3])) >> 0); + b.lastRuneSize = size; + _tmp$5 = r; _tmp$6 = size; _tmp$7 = $ifaceNil; r = _tmp$5; size = _tmp$6; err = _tmp$7; + return [r, size, err]; }; - Rand.prototype.Int63n = function(n) { return this.$val.Int63n(n); }; - Rand.Ptr.prototype.Int31n = function(n) { - var r, _r, max, v, _r$1; - r = this; - if (n <= 0) { - $panic(new $String("invalid argument to Int31n")); + Reader.prototype.ReadRune = function() { return this.$val.ReadRune(); }; + Reader.Ptr.prototype.UnreadRune = function() { + var b; + b = this; + if (b.lastRuneSize < 0 || b.r < b.lastRuneSize) { + return $pkg.ErrInvalidUnreadRune; } - if ((n & ((n - 1 >> 0))) === 0) { - return r.Int31() & ((n - 1 >> 0)); + b.r = b.r - (b.lastRuneSize) >> 0; + b.lastByte = -1; + b.lastRuneSize = -1; + return $ifaceNil; + }; + Reader.prototype.UnreadRune = function() { return this.$val.UnreadRune(); }; + Reader.Ptr.prototype.Buffered = function() { + var b; + b = this; + return b.w - b.r >> 0; + }; + Reader.prototype.Buffered = function() { return this.$val.Buffered(); }; + Reader.Ptr.prototype.ReadSlice = function(delim) { + var line = ($sliceType($Uint8)).nil, err = $ifaceNil, b, i, n, i$1; + b = this; + while (true) { + i = bytes.IndexByte($subslice(b.buf, b.r, b.w), delim); + if (i >= 0) { + line = $subslice(b.buf, b.r, ((b.r + i >> 0) + 1 >> 0)); + b.r = b.r + ((i + 1 >> 0)) >> 0; + break; + } + if (!($interfaceIsEqual(b.err, $ifaceNil))) { + line = $subslice(b.buf, b.r, b.w); + b.r = b.w; + err = b.readErr(); + break; + } + n = b.Buffered(); + if (n >= b.buf.$length) { + b.r = b.w; + line = b.buf; + err = $pkg.ErrBufferFull; + break; + } + b.fill(); } - max = ((2147483647 - (_r = 2147483648 % (n >>> 0), _r === _r ? _r : $throwRuntimeError("integer divide by zero")) >>> 0) >> 0); - v = r.Int31(); - while (v > max) { - v = r.Int31(); + i$1 = line.$length - 1 >> 0; + if (i$1 >= 0) { + b.lastByte = (((i$1 < 0 || i$1 >= line.$length) ? $throwRuntimeError("index out of range") : line.$array[line.$offset + i$1]) >> 0); } - return (_r$1 = v % n, _r$1 === _r$1 ? _r$1 : $throwRuntimeError("integer divide by zero")); + return [line, err]; }; - Rand.prototype.Int31n = function(n) { return this.$val.Int31n(n); }; - Rand.Ptr.prototype.Intn = function(n) { - var r, x; - r = this; - if (n <= 0) { - $panic(new $String("invalid argument to Intn")); + Reader.prototype.ReadSlice = function(delim) { return this.$val.ReadSlice(delim); }; + Reader.Ptr.prototype.ReadLine = function() { + var line = ($sliceType($Uint8)).nil, isPrefix = false, err = $ifaceNil, b, _tuple, x, _tmp, _tmp$1, _tmp$2, x$1, drop, x$2; + b = this; + _tuple = b.ReadSlice(10); line = _tuple[0]; err = _tuple[1]; + if ($interfaceIsEqual(err, $pkg.ErrBufferFull)) { + if (line.$length > 0 && ((x = line.$length - 1 >> 0, ((x < 0 || x >= line.$length) ? $throwRuntimeError("index out of range") : line.$array[line.$offset + x])) === 13)) { + if (b.r === 0) { + $panic(new $String("bufio: tried to rewind past start of buffer")); + } + b.r = b.r - (1) >> 0; + line = $subslice(line, 0, (line.$length - 1 >> 0)); + } + _tmp = line; _tmp$1 = true; _tmp$2 = $ifaceNil; line = _tmp; isPrefix = _tmp$1; err = _tmp$2; + return [line, isPrefix, err]; } - if (n <= 2147483647) { - return (r.Int31n((n >> 0)) >> 0); + if (line.$length === 0) { + if (!($interfaceIsEqual(err, $ifaceNil))) { + line = ($sliceType($Uint8)).nil; + } + return [line, isPrefix, err]; } - return ((x = r.Int63n(new $Int64(0, n)), x.$low + ((x.$high >> 31) * 4294967296)) >> 0); - }; - Rand.prototype.Intn = function(n) { return this.$val.Intn(n); }; - Rand.Ptr.prototype.Float64 = function() { - var r, f; - r = this; - f = $flatten64(r.Int63()) / 9.223372036854776e+18; - if (f === 1) { - f = 0; + err = $ifaceNil; + if ((x$1 = line.$length - 1 >> 0, ((x$1 < 0 || x$1 >= line.$length) ? $throwRuntimeError("index out of range") : line.$array[line.$offset + x$1])) === 10) { + drop = 1; + if (line.$length > 1 && ((x$2 = line.$length - 2 >> 0, ((x$2 < 0 || x$2 >= line.$length) ? $throwRuntimeError("index out of range") : line.$array[line.$offset + x$2])) === 13)) { + drop = 2; + } + line = $subslice(line, 0, (line.$length - drop >> 0)); } - return f; + return [line, isPrefix, err]; }; - Rand.prototype.Float64 = function() { return this.$val.Float64(); }; - Rand.Ptr.prototype.Float32 = function() { - var r, f; - r = this; - f = r.Float64(); - if ($float32IsEqual(f, 1)) { - f = 0; + Reader.prototype.ReadLine = function() { return this.$val.ReadLine(); }; + Reader.Ptr.prototype.ReadBytes = function(delim) { + var line = ($sliceType($Uint8)).nil, err = $ifaceNil, b, frag, full, e, _tuple, buf, n, _ref, _i, i, buf$1, _ref$1, _i$1, i$1, _tmp, _tmp$1; + b = this; + frag = ($sliceType($Uint8)).nil; + full = ($sliceType(($sliceType($Uint8)))).nil; + err = $ifaceNil; + while (true) { + e = $ifaceNil; + _tuple = b.ReadSlice(delim); frag = _tuple[0]; e = _tuple[1]; + if ($interfaceIsEqual(e, $ifaceNil)) { + break; + } + if (!($interfaceIsEqual(e, $pkg.ErrBufferFull))) { + err = e; + break; + } + buf = ($sliceType($Uint8)).make(frag.$length); + $copySlice(buf, frag); + full = $append(full, buf); } - return f; - }; - Rand.prototype.Float32 = function() { return this.$val.Float32(); }; - Rand.Ptr.prototype.Perm = function(n) { - var r, m, i, j; - r = this; - m = ($sliceType($Int)).make(n); - i = 0; - while (i < n) { - j = r.Intn(i + 1 >> 0); - (i < 0 || i >= m.$length) ? $throwRuntimeError("index out of range") : m.$array[m.$offset + i] = ((j < 0 || j >= m.$length) ? $throwRuntimeError("index out of range") : m.$array[m.$offset + j]); - (j < 0 || j >= m.$length) ? $throwRuntimeError("index out of range") : m.$array[m.$offset + j] = i; - i = i + (1) >> 0; + n = 0; + _ref = full; + _i = 0; + while (_i < _ref.$length) { + i = _i; + n = n + (((i < 0 || i >= full.$length) ? $throwRuntimeError("index out of range") : full.$array[full.$offset + i]).$length) >> 0; + _i++; } - return m; - }; - Rand.prototype.Perm = function(n) { return this.$val.Perm(n); }; - lockedSource.Ptr.prototype.Int63 = function() { - var n = new $Int64(0, 0), r; - r = this; - r.lk.Lock(); - n = r.src.Int63(); - r.lk.Unlock(); - return n; + n = n + (frag.$length) >> 0; + buf$1 = ($sliceType($Uint8)).make(n); + n = 0; + _ref$1 = full; + _i$1 = 0; + while (_i$1 < _ref$1.$length) { + i$1 = _i$1; + n = n + ($copySlice($subslice(buf$1, n), ((i$1 < 0 || i$1 >= full.$length) ? $throwRuntimeError("index out of range") : full.$array[full.$offset + i$1]))) >> 0; + _i$1++; + } + $copySlice($subslice(buf$1, n), frag); + _tmp = buf$1; _tmp$1 = err; line = _tmp; err = _tmp$1; + return [line, err]; }; - lockedSource.prototype.Int63 = function() { return this.$val.Int63(); }; - lockedSource.Ptr.prototype.Seed = function(seed) { - var r; - r = this; - r.lk.Lock(); - r.src.Seed(seed); - r.lk.Unlock(); + Reader.prototype.ReadBytes = function(delim) { return this.$val.ReadBytes(delim); }; + Reader.Ptr.prototype.ReadString = function(delim) { + var line = "", err = $ifaceNil, b, _tuple, bytes$1, _tmp, _tmp$1; + b = this; + _tuple = b.ReadBytes(delim); bytes$1 = _tuple[0]; err = _tuple[1]; + line = $bytesToString(bytes$1); + _tmp = line; _tmp$1 = err; line = _tmp; err = _tmp$1; + return [line, err]; }; - lockedSource.prototype.Seed = function(seed) { return this.$val.Seed(seed); }; - seedrand = function(x) { - var _q, hi, _r, lo; - hi = (_q = x / 44488, (_q === _q && _q !== 1/0 && _q !== -1/0) ? _q >> 0 : $throwRuntimeError("integer divide by zero")); - lo = (_r = x % 44488, _r === _r ? _r : $throwRuntimeError("integer divide by zero")); - x = ((((48271 >>> 16 << 16) * lo >> 0) + (48271 << 16 >>> 16) * lo) >> 0) - ((((3399 >>> 16 << 16) * hi >> 0) + (3399 << 16 >>> 16) * hi) >> 0) >> 0; - if (x < 0) { - x = x + (2147483647) >> 0; + Reader.prototype.ReadString = function(delim) { return this.$val.ReadString(delim); }; + Reader.Ptr.prototype.WriteTo = function(w) { + var n = new $Int64(0, 0), err = $ifaceNil, b, _tuple, _tuple$1, r, ok, _tuple$2, m, err$1, x, _tmp, _tmp$1, _tuple$3, w$1, ok$1, _tuple$4, m$1, err$2, x$1, _tmp$2, _tmp$3, _tuple$5, m$2, err$3, x$2, _tmp$4, _tmp$5, _tmp$6, _tmp$7; + b = this; + _tuple = b.writeBuf(w); n = _tuple[0]; err = _tuple[1]; + if (!($interfaceIsEqual(err, $ifaceNil))) { + return [n, err]; } - return x; - }; - rngSource.Ptr.prototype.Seed = function(seed) { - var rng, x, x$1, i, u, x$2, x$3, x$4, x$5; - rng = this; - rng.tap = 0; - rng.feed = 334; - seed = $div64(seed, new $Int64(0, 2147483647), true); - if ((seed.$high < 0 || (seed.$high === 0 && seed.$low < 0))) { - seed = (x = new $Int64(0, 2147483647), new $Int64(seed.$high + x.$high, seed.$low + x.$low)); + _tuple$1 = $assertType(b.rd, io.WriterTo, true); r = _tuple$1[0]; ok = _tuple$1[1]; + if (ok) { + _tuple$2 = r.WriteTo(w); m = _tuple$2[0]; err$1 = _tuple$2[1]; + n = (x = m, new $Int64(n.$high + x.$high, n.$low + x.$low)); + _tmp = n; _tmp$1 = err$1; n = _tmp; err = _tmp$1; + return [n, err]; } - if ((seed.$high === 0 && seed.$low === 0)) { - seed = new $Int64(0, 89482311); + _tuple$3 = $assertType(w, io.ReaderFrom, true); w$1 = _tuple$3[0]; ok$1 = _tuple$3[1]; + if (ok$1) { + _tuple$4 = w$1.ReadFrom(b.rd); m$1 = _tuple$4[0]; err$2 = _tuple$4[1]; + n = (x$1 = m$1, new $Int64(n.$high + x$1.$high, n.$low + x$1.$low)); + _tmp$2 = n; _tmp$3 = err$2; n = _tmp$2; err = _tmp$3; + return [n, err]; } - x$1 = ((seed.$low + ((seed.$high >> 31) * 4294967296)) >> 0); - i = -20; - while (i < 607) { - x$1 = seedrand(x$1); - if (i >= 0) { - u = new $Int64(0, 0); - u = $shiftLeft64(new $Int64(0, x$1), 40); - x$1 = seedrand(x$1); - u = (x$2 = $shiftLeft64(new $Int64(0, x$1), 20), new $Int64(u.$high ^ x$2.$high, (u.$low ^ x$2.$low) >>> 0)); - x$1 = seedrand(x$1); - u = (x$3 = new $Int64(0, x$1), new $Int64(u.$high ^ x$3.$high, (u.$low ^ x$3.$low) >>> 0)); - u = (x$4 = ((i < 0 || i >= rng_cooked.length) ? $throwRuntimeError("index out of range") : rng_cooked[i]), new $Int64(u.$high ^ x$4.$high, (u.$low ^ x$4.$low) >>> 0)); - (x$5 = rng.vec, (i < 0 || i >= x$5.length) ? $throwRuntimeError("index out of range") : x$5[i] = new $Int64(u.$high & 2147483647, (u.$low & 4294967295) >>> 0)); + if ((b.w - b.r >> 0) < b.buf.$length) { + b.fill(); + } + while (b.r < b.w) { + _tuple$5 = b.writeBuf(w); m$2 = _tuple$5[0]; err$3 = _tuple$5[1]; + n = (x$2 = m$2, new $Int64(n.$high + x$2.$high, n.$low + x$2.$low)); + if (!($interfaceIsEqual(err$3, $ifaceNil))) { + _tmp$4 = n; _tmp$5 = err$3; n = _tmp$4; err = _tmp$5; + return [n, err]; } - i = i + (1) >> 0; + b.fill(); + } + if ($interfaceIsEqual(b.err, io.EOF)) { + b.err = $ifaceNil; } + _tmp$6 = n; _tmp$7 = b.readErr(); n = _tmp$6; err = _tmp$7; + return [n, err]; }; - rngSource.prototype.Seed = function(seed) { return this.$val.Seed(seed); }; - rngSource.Ptr.prototype.Int63 = function() { - var rng, x, x$1, x$2, x$3, x$4, x$5, x$6, x$7, x$8, x$9; - rng = this; - rng.tap = rng.tap - (1) >> 0; - if (rng.tap < 0) { - rng.tap = rng.tap + (607) >> 0; - } - rng.feed = rng.feed - (1) >> 0; - if (rng.feed < 0) { - rng.feed = rng.feed + (607) >> 0; + Reader.prototype.WriteTo = function(w) { return this.$val.WriteTo(w); }; + Reader.Ptr.prototype.writeBuf = function(w) { + var b, _tuple, n, err; + b = this; + _tuple = w.Write($subslice(b.buf, b.r, b.w)); n = _tuple[0]; err = _tuple[1]; + if (n < (b.r - b.w >> 0)) { + $panic(errors.New("bufio: writer did not write all data")); } - x$7 = (x = (x$1 = (x$2 = rng.vec, x$3 = rng.feed, ((x$3 < 0 || x$3 >= x$2.length) ? $throwRuntimeError("index out of range") : x$2[x$3])), x$4 = (x$5 = rng.vec, x$6 = rng.tap, ((x$6 < 0 || x$6 >= x$5.length) ? $throwRuntimeError("index out of range") : x$5[x$6])), new $Int64(x$1.$high + x$4.$high, x$1.$low + x$4.$low)), new $Int64(x.$high & 2147483647, (x.$low & 4294967295) >>> 0)); - (x$8 = rng.vec, x$9 = rng.feed, (x$9 < 0 || x$9 >= x$8.length) ? $throwRuntimeError("index out of range") : x$8[x$9] = x$7); - return x$7; + b.r = b.r + (n) >> 0; + return [new $Int64(0, n), err]; }; - rngSource.prototype.Int63 = function() { return this.$val.Int63(); }; + Reader.prototype.writeBuf = function(w) { return this.$val.writeBuf(w); }; $pkg.$init = function() { - Source.init([["Int63", "Int63", "", $funcType([], [$Int64], false)], ["Seed", "Seed", "", $funcType([$Int64], [], false)]]); - ($ptrType(Rand)).methods = [["ExpFloat64", "ExpFloat64", "", $funcType([], [$Float64], false), -1], ["Float32", "Float32", "", $funcType([], [$Float32], false), -1], ["Float64", "Float64", "", $funcType([], [$Float64], false), -1], ["Int", "Int", "", $funcType([], [$Int], false), -1], ["Int31", "Int31", "", $funcType([], [$Int32], false), -1], ["Int31n", "Int31n", "", $funcType([$Int32], [$Int32], false), -1], ["Int63", "Int63", "", $funcType([], [$Int64], false), -1], ["Int63n", "Int63n", "", $funcType([$Int64], [$Int64], false), -1], ["Intn", "Intn", "", $funcType([$Int], [$Int], false), -1], ["NormFloat64", "NormFloat64", "", $funcType([], [$Float64], false), -1], ["Perm", "Perm", "", $funcType([$Int], [($sliceType($Int))], false), -1], ["Seed", "Seed", "", $funcType([$Int64], [], false), -1], ["Uint32", "Uint32", "", $funcType([], [$Uint32], false), -1]]; - Rand.init([["src", "src", "math/rand", Source, ""]]); - ($ptrType(lockedSource)).methods = [["Int63", "Int63", "", $funcType([], [$Int64], false), -1], ["Seed", "Seed", "", $funcType([$Int64], [], false), -1]]; - lockedSource.init([["lk", "lk", "math/rand", sync.Mutex, ""], ["src", "src", "math/rand", Source, ""]]); - ($ptrType(rngSource)).methods = [["Int63", "Int63", "", $funcType([], [$Int64], false), -1], ["Seed", "Seed", "", $funcType([$Int64], [], false), -1]]; - rngSource.init([["tap", "tap", "math/rand", $Int, ""], ["feed", "feed", "math/rand", $Int, ""], ["vec", "vec", "math/rand", ($arrayType($Int64, 607)), ""]]); - ke = $toNativeArray("Uint32", [3801129273, 0, 2615860924, 3279400049, 3571300752, 3733536696, 3836274812, 3906990442, 3958562475, 3997804264, 4028649213, 4053523342, 4074002619, 4091154507, 4105727352, 4118261130, 4129155133, 4138710916, 4147160435, 4154685009, 4161428406, 4167506077, 4173011791, 4178022498, 4182601930, 4186803325, 4190671498, 4194244443, 4197554582, 4200629752, 4203493986, 4206168142, 4208670408, 4211016720, 4213221098, 4215295924, 4217252177, 4219099625, 4220846988, 4222502074, 4224071896, 4225562770, 4226980400, 4228329951, 4229616109, 4230843138, 4232014925, 4233135020, 4234206673, 4235232866, 4236216336, 4237159604, 4238064994, 4238934652, 4239770563, 4240574564, 4241348362, 4242093539, 4242811568, 4243503822, 4244171579, 4244816032, 4245438297, 4246039419, 4246620374, 4247182079, 4247725394, 4248251127, 4248760037, 4249252839, 4249730206, 4250192773, 4250641138, 4251075867, 4251497493, 4251906522, 4252303431, 4252688672, 4253062674, 4253425844, 4253778565, 4254121205, 4254454110, 4254777611, 4255092022, 4255397640, 4255694750, 4255983622, 4256264513, 4256537670, 4256803325, 4257061702, 4257313014, 4257557464, 4257795244, 4258026541, 4258251531, 4258470383, 4258683258, 4258890309, 4259091685, 4259287526, 4259477966, 4259663135, 4259843154, 4260018142, 4260188212, 4260353470, 4260514019, 4260669958, 4260821380, 4260968374, 4261111028, 4261249421, 4261383632, 4261513736, 4261639802, 4261761900, 4261880092, 4261994441, 4262105003, 4262211835, 4262314988, 4262414513, 4262510454, 4262602857, 4262691764, 4262777212, 4262859239, 4262937878, 4263013162, 4263085118, 4263153776, 4263219158, 4263281289, 4263340187, 4263395872, 4263448358, 4263497660, 4263543789, 4263586755, 4263626565, 4263663224, 4263696735, 4263727099, 4263754314, 4263778377, 4263799282, 4263817020, 4263831582, 4263842955, 4263851124, 4263856071, 4263857776, 4263856218, 4263851370, 4263843206, 4263831695, 4263816804, 4263798497, 4263776735, 4263751476, 4263722676, 4263690284, 4263654251, 4263614520, 4263571032, 4263523724, 4263472530, 4263417377, 4263358192, 4263294892, 4263227394, 4263155608, 4263079437, 4262998781, 4262913534, 4262823581, 4262728804, 4262629075, 4262524261, 4262414220, 4262298801, 4262177846, 4262051187, 4261918645, 4261780032, 4261635148, 4261483780, 4261325704, 4261160681, 4260988457, 4260808763, 4260621313, 4260425802, 4260221905, 4260009277, 4259787550, 4259556329, 4259315195, 4259063697, 4258801357, 4258527656, 4258242044, 4257943926, 4257632664, 4257307571, 4256967906, 4256612870, 4256241598, 4255853155, 4255446525, 4255020608, 4254574202, 4254106002, 4253614578, 4253098370, 4252555662, 4251984571, 4251383021, 4250748722, 4250079132, 4249371435, 4248622490, 4247828790, 4246986404, 4246090910, 4245137315, 4244119963, 4243032411, 4241867296, 4240616155, 4239269214, 4237815118, 4236240596, 4234530035, 4232664930, 4230623176, 4228378137, 4225897409, 4223141146, 4220059768, 4216590757, 4212654085, 4208145538, 4202926710, 4196809522, 4189531420, 4180713890, 4169789475, 4155865042, 4137444620, 4111806704, 4073393724, 4008685917, 3873074895]); - we = $toNativeArray("Float32", [2.0249555365836613e-09, 1.4866739783681027e-11, 2.4409616689036184e-11, 3.1968806074589295e-11, 3.844677007314168e-11, 4.42282044321729e-11, 4.951644302919611e-11, 5.443358958023836e-11, 5.905943789574764e-11, 6.34494193296753e-11, 6.764381416113352e-11, 7.167294535648239e-11, 7.556032188826833e-11, 7.932458162551725e-11, 8.298078890689453e-11, 8.654132271912474e-11, 9.001651507523079e-11, 9.341507428706208e-11, 9.674443190998971e-11, 1.0001099254308699e-10, 1.0322031424037093e-10, 1.0637725422757427e-10, 1.0948611461891744e-10, 1.1255067711157807e-10, 1.1557434870246297e-10, 1.1856014781042035e-10, 1.2151082917633005e-10, 1.2442885610752796e-10, 1.2731647680563896e-10, 1.3017574518325858e-10, 1.330085347417409e-10, 1.3581656632677408e-10, 1.386014220061682e-10, 1.413645728254309e-10, 1.4410737880776736e-10, 1.4683107507629245e-10, 1.4953686899854546e-10, 1.522258291641876e-10, 1.5489899640730442e-10, 1.575573282952547e-10, 1.6020171300645814e-10, 1.628330109637588e-10, 1.6545202707884954e-10, 1.68059510752272e-10, 1.7065616975120435e-10, 1.73242697965037e-10, 1.758197337720091e-10, 1.783878739169964e-10, 1.8094774290045024e-10, 1.834998542005195e-10, 1.8604476292871652e-10, 1.8858298256319017e-10, 1.9111498494872592e-10, 1.9364125580789704e-10, 1.9616222535212557e-10, 1.9867835154840918e-10, 2.011900368525943e-10, 2.0369768372052732e-10, 2.062016807302669e-10, 2.0870240258208383e-10, 2.1120022397624894e-10, 2.136955057352452e-10, 2.1618855317040442e-10, 2.1867974098199738e-10, 2.2116936060356807e-10, 2.2365774510202385e-10, 2.2614519978869652e-10, 2.2863201609713002e-10, 2.3111849933865614e-10, 2.3360494094681883e-10, 2.3609159072179864e-10, 2.3857874009713953e-10, 2.4106666662859766e-10, 2.4355562011635357e-10, 2.460458781161634e-10, 2.485376904282077e-10, 2.5103127909709144e-10, 2.5352694943414633e-10, 2.560248957284017e-10, 2.585253955356137e-10, 2.610286709003873e-10, 2.6353494386732734e-10, 2.6604446423661443e-10, 2.6855745405285347e-10, 2.71074163116225e-10, 2.7359478571575835e-10, 2.7611959940720965e-10, 2.786487707240326e-10, 2.8118254946640775e-10, 2.8372118543451563e-10, 2.8626484516180994e-10, 2.8881380620404684e-10, 2.9136826285025563e-10, 2.9392840938946563e-10, 2.96494523377433e-10, 2.990667713476114e-10, 3.016454031001814e-10, 3.042306406797479e-10, 3.068226783753403e-10, 3.09421765987139e-10, 3.12028125559749e-10, 3.1464195138219964e-10, 3.17263521010247e-10, 3.1989300097734485e-10, 3.225306410836737e-10, 3.2517669112941405e-10, 3.2783134540359526e-10, 3.3049485370639786e-10, 3.3316743808242677e-10, 3.3584937608743815e-10, 3.385408342548857e-10, 3.4124211789610115e-10, 3.4395342130011386e-10, 3.4667499426710435e-10, 3.494071143528288e-10, 3.521500313574677e-10, 3.54903967325626e-10, 3.576691720574843e-10, 3.6044595086437425e-10, 3.632345535464765e-10, 3.660352021483959e-10, 3.688482297370399e-10, 3.716738583570134e-10, 3.7451239331964814e-10, 3.773641121807003e-10, 3.802292924959261e-10, 3.831082673322328e-10, 3.8600128648980103e-10, 3.8890865527996255e-10, 3.9183070676962473e-10, 3.9476774627011935e-10, 3.977200790927782e-10, 4.006880383045086e-10, 4.0367195697221803e-10, 4.066721681628138e-10, 4.0968900494320337e-10, 4.127228558914453e-10, 4.15774054074447e-10, 4.188429603146915e-10, 4.2192993543466173e-10, 4.25035395767992e-10, 4.2815970213716525e-10, 4.313032986313914e-10, 4.3446651831757777e-10, 4.376498607960855e-10, 4.408536868893975e-10, 4.4407846844229937e-10, 4.4732464954400086e-10, 4.5059267428371186e-10, 4.538830145062178e-10, 4.5719619756745544e-10, 4.605326675566346e-10, 4.638929240741163e-10, 4.672775499869886e-10, 4.706869893844612e-10, 4.74121908400349e-10, 4.775827511238617e-10, 4.810701836888143e-10, 4.845848167178701e-10, 4.881271498113904e-10, 4.916979601254923e-10, 4.952977472605369e-10, 4.989272883726414e-10, 5.025872495956207e-10, 5.062783525744408e-10, 5.100013189540675e-10, 5.13756870379467e-10, 5.175458395179078e-10, 5.21369003525507e-10, 5.252272505806843e-10, 5.29121357839557e-10, 5.330522134805449e-10, 5.3702081670437e-10, 5.41028055689452e-10, 5.450749851476644e-10, 5.491624932574268e-10, 5.532918012640664e-10, 5.574638528571541e-10, 5.616799247931681e-10, 5.659410717839819e-10, 5.702485705860738e-10, 5.746036979559221e-10, 5.790077306500052e-10, 5.83462111958255e-10, 5.879682296594524e-10, 5.925275825546805e-10, 5.971417249561739e-10, 6.01812211176167e-10, 6.065408175714992e-10, 6.113292094767075e-10, 6.16179329782085e-10, 6.21092954844471e-10, 6.260721940876124e-10, 6.311191569352559e-10, 6.362359528111483e-10, 6.414249686947926e-10, 6.466885360545405e-10, 6.520292639144998e-10, 6.574497612987784e-10, 6.629528592760892e-10, 6.685415554485985e-10, 6.742187919073217e-10, 6.799880103436351e-10, 6.858525969377638e-10, 6.918161599145378e-10, 6.978825850545434e-10, 7.040559801829716e-10, 7.103406751696184e-10, 7.167412219288849e-10, 7.232625609532306e-10, 7.2990985477972e-10, 7.366885990123251e-10, 7.436047333442275e-10, 7.506645305355164e-10, 7.57874762946642e-10, 7.652426470272644e-10, 7.727759543385559e-10, 7.804830115532013e-10, 7.883728114777e-10, 7.964550685635174e-10, 8.047402189070851e-10, 8.132396422944055e-10, 8.219657177122031e-10, 8.309318788590758e-10, 8.401527806789488e-10, 8.496445214056791e-10, 8.594246980742071e-10, 8.695127395874636e-10, 8.799300732498239e-10, 8.90700457834015e-10, 9.01850316648023e-10, 9.134091816243028e-10, 9.254100818978372e-10, 9.37890431984556e-10, 9.508922538259412e-10, 9.64463842123564e-10, 9.78660263939446e-10, 9.935448019859905e-10, 1.0091912860943353e-09, 1.0256859805934937e-09, 1.0431305819125214e-09, 1.0616465484503124e-09, 1.0813799855569073e-09, 1.1025096391392708e-09, 1.1252564435793033e-09, 1.149898620766976e-09, 1.176793218427008e-09, 1.2064089727203964e-09, 1.2393785997488749e-09, 1.2765849488616254e-09, 1.319313880365769e-09, 1.36954347862428e-09, 1.4305497897382224e-09, 1.5083649884672923e-09, 1.6160853766322703e-09, 1.7921247819074893e-09]); - fe = $toNativeArray("Float32", [1, 0.9381436705589294, 0.900469958782196, 0.8717043399810791, 0.847785472869873, 0.8269932866096497, 0.8084216713905334, 0.7915276288986206, 0.7759568691253662, 0.7614634037017822, 0.7478685975074768, 0.7350381016731262, 0.7228676676750183, 0.7112747430801392, 0.7001926302909851, 0.6895664930343628, 0.6793505549430847, 0.669506311416626, 0.6600008606910706, 0.6508058309555054, 0.6418967247009277, 0.633251965045929, 0.62485271692276, 0.6166821718215942, 0.608725368976593, 0.6009689569473267, 0.5934008955955505, 0.5860103368759155, 0.5787873864173889, 0.5717230439186096, 0.5648092031478882, 0.5580382943153381, 0.5514034032821655, 0.5448982119560242, 0.5385168790817261, 0.5322538614273071, 0.526104211807251, 0.5200631618499756, 0.5141264200210571, 0.5082897543907166, 0.5025495290756226, 0.4969019889831543, 0.4913438558578491, 0.4858720004558563, 0.48048335313796997, 0.4751752018928528, 0.4699448347091675, 0.4647897481918335, 0.4597076177597046, 0.4546961486339569, 0.4497532546520233, 0.44487687945365906, 0.4400651156902313, 0.4353161156177521, 0.4306281507015228, 0.42599955201148987, 0.42142874002456665, 0.4169141948223114, 0.4124544560909271, 0.40804818272590637, 0.4036940038204193, 0.39939069747924805, 0.3951369822025299, 0.39093172550201416, 0.38677382469177246, 0.38266217708587646, 0.378595769405365, 0.37457355856895447, 0.37059465050697327, 0.366658091545105, 0.362762987613678, 0.358908474445343, 0.35509374737739563, 0.35131800174713135, 0.3475804924964905, 0.34388044476509094, 0.34021714329719543, 0.33658990263938904, 0.3329980671405792, 0.3294409513473511, 0.32591795921325684, 0.32242849469184875, 0.3189719021320343, 0.3155476748943329, 0.31215524673461914, 0.3087940812110901, 0.30546361207962036, 0.30216339230537415, 0.29889291524887085, 0.29565170407295227, 0.2924392819404602, 0.2892552316188812, 0.28609907627105713, 0.2829704284667969, 0.27986884117126465, 0.2767939269542694, 0.2737452983856201, 0.2707225978374481, 0.26772540807724, 0.26475343108177185, 0.2618062496185303, 0.258883535861969, 0.2559850215911865, 0.25311028957366943, 0.25025907158851624, 0.24743106961250305, 0.2446259707212448, 0.24184346199035645, 0.23908329010009766, 0.23634515702724457, 0.2336287796497345, 0.23093391954898834, 0.22826029360294342, 0.22560766339302063, 0.22297576069831848, 0.22036437690258026, 0.21777324378490448, 0.21520215272903442, 0.212650865316391, 0.21011915802955627, 0.20760682225227356, 0.20511364936828613, 0.20263944566249847, 0.20018397271633148, 0.19774706661701202, 0.1953285187482834, 0.19292815029621124, 0.19054576754570007, 0.18818120658397675, 0.18583425879478455, 0.18350479006767273, 0.18119260668754578, 0.17889754474163055, 0.17661945521831512, 0.17435817420482635, 0.1721135377883911, 0.16988539695739746, 0.16767361760139465, 0.16547803580760956, 0.16329853236675262, 0.16113494336605072, 0.1589871346950531, 0.15685498714447021, 0.15473836660385132, 0.15263713896274567, 0.1505511850118637, 0.1484803706407547, 0.14642459154129028, 0.1443837285041809, 0.14235764741897583, 0.1403462439775467, 0.13834942877292633, 0.136367067694664, 0.13439907133579254, 0.1324453204870224, 0.1305057406425476, 0.12858019769191742, 0.12666863203048706, 0.12477091699838638, 0.12288697808980942, 0.1210167184472084, 0.11916005611419678, 0.11731690168380737, 0.11548716574907303, 0.11367076635360718, 0.11186762899160385, 0.11007767915725708, 0.1083008274435997, 0.10653700679540634, 0.10478614270687103, 0.1030481606721878, 0.10132300108671188, 0.0996105819940567, 0.09791085124015808, 0.09622374176979065, 0.09454918652772903, 0.09288713335990906, 0.09123751521110535, 0.08960027992725372, 0.08797537535429001, 0.08636274188756943, 0.0847623273730278, 0.08317409455776215, 0.08159798383712769, 0.08003395050764084, 0.07848194986581802, 0.07694194465875626, 0.07541389018297195, 0.07389774918556213, 0.07239348441362381, 0.070901058614254, 0.06942043453454971, 0.06795158982276917, 0.06649449467658997, 0.06504911929368973, 0.06361543387174606, 0.06219341605901718, 0.06078304722905159, 0.0593843050301075, 0.05799717456102371, 0.05662164092063904, 0.05525768920779228, 0.05390531197190285, 0.05256449431180954, 0.05123523622751236, 0.04991753399372101, 0.04861138388514519, 0.047316793352365494, 0.04603376239538193, 0.044762298464775085, 0.04350241273641586, 0.04225412383675575, 0.04101744294166565, 0.039792392402887344, 0.03857899457216263, 0.03737728297710419, 0.03618728369474411, 0.03500903770327568, 0.03384258225560188, 0.0326879620552063, 0.031545232981443405, 0.030414443463087082, 0.0292956605553627, 0.028188949450850487, 0.027094384655356407, 0.02601204626262188, 0.024942025542259216, 0.023884421214461327, 0.022839335724711418, 0.021806888282299042, 0.020787203684449196, 0.019780423492193222, 0.018786700442433357, 0.017806200310587883, 0.016839107498526573, 0.015885621309280396, 0.014945968054234982, 0.01402039173990488, 0.013109165243804455, 0.012212592177093029, 0.011331013403832912, 0.010464809834957123, 0.009614413604140282, 0.008780314587056637, 0.007963077165186405, 0.007163353264331818, 0.0063819061033427715, 0.005619642324745655, 0.004877655766904354, 0.004157294984906912, 0.003460264764726162, 0.0027887988835573196, 0.0021459676790982485, 0.001536299823783338, 0.0009672692976891994, 0.0004541343660093844]); - kn = $toNativeArray("Uint32", [1991057938, 0, 1611602771, 1826899878, 1918584482, 1969227037, 2001281515, 2023368125, 2039498179, 2051788381, 2061460127, 2069267110, 2075699398, 2081089314, 2085670119, 2089610331, 2093034710, 2096037586, 2098691595, 2101053571, 2103168620, 2105072996, 2106796166, 2108362327, 2109791536, 2111100552, 2112303493, 2113412330, 2114437283, 2115387130, 2116269447, 2117090813, 2117856962, 2118572919, 2119243101, 2119871411, 2120461303, 2121015852, 2121537798, 2122029592, 2122493434, 2122931299, 2123344971, 2123736059, 2124106020, 2124456175, 2124787725, 2125101763, 2125399283, 2125681194, 2125948325, 2126201433, 2126441213, 2126668298, 2126883268, 2127086657, 2127278949, 2127460589, 2127631985, 2127793506, 2127945490, 2128088244, 2128222044, 2128347141, 2128463758, 2128572095, 2128672327, 2128764606, 2128849065, 2128925811, 2128994934, 2129056501, 2129110560, 2129157136, 2129196237, 2129227847, 2129251929, 2129268426, 2129277255, 2129278312, 2129271467, 2129256561, 2129233410, 2129201800, 2129161480, 2129112170, 2129053545, 2128985244, 2128906855, 2128817916, 2128717911, 2128606255, 2128482298, 2128345305, 2128194452, 2128028813, 2127847342, 2127648860, 2127432031, 2127195339, 2126937058, 2126655214, 2126347546, 2126011445, 2125643893, 2125241376, 2124799783, 2124314271, 2123779094, 2123187386, 2122530867, 2121799464, 2120980787, 2120059418, 2119015917, 2117825402, 2116455471, 2114863093, 2112989789, 2110753906, 2108037662, 2104664315, 2100355223, 2094642347, 2086670106, 2074676188, 2054300022, 2010539237]); - wn = $toNativeArray("Float32", [1.7290404663583558e-09, 1.2680928529462676e-10, 1.689751810696194e-10, 1.9862687883343e-10, 2.223243117382978e-10, 2.4244936613904144e-10, 2.601613091623989e-10, 2.761198769629658e-10, 2.9073962681813725e-10, 3.042996965518796e-10, 3.169979556627567e-10, 3.289802041894774e-10, 3.4035738116777736e-10, 3.5121602848242617e-10, 3.61625090983253e-10, 3.7164057942185025e-10, 3.813085680537398e-10, 3.906675816178762e-10, 3.997501218933053e-10, 4.0858399996679395e-10, 4.1719308563337165e-10, 4.255982233303257e-10, 4.3381759295968436e-10, 4.4186720948857783e-10, 4.497613115272969e-10, 4.57512583373898e-10, 4.6513240481438345e-10, 4.726310454117311e-10, 4.800177477726209e-10, 4.873009773476156e-10, 4.944885056978876e-10, 5.015873272284921e-10, 5.086040477664255e-10, 5.155446070048697e-10, 5.224146670812502e-10, 5.292193350214802e-10, 5.359634958068682e-10, 5.426517013518151e-10, 5.492881705038144e-10, 5.558769555769061e-10, 5.624218868405251e-10, 5.689264614971989e-10, 5.75394121238304e-10, 5.818281967329142e-10, 5.882316855831959e-10, 5.946076964136182e-10, 6.009590047817426e-10, 6.072883862451306e-10, 6.135985053390414e-10, 6.19892026598734e-10, 6.261713370037114e-10, 6.324390455780815e-10, 6.386973727678935e-10, 6.449488165749528e-10, 6.511955974453087e-10, 6.574400468473129e-10, 6.636843297158634e-10, 6.699307220081607e-10, 6.761814441702541e-10, 6.824387166481927e-10, 6.887046488657234e-10, 6.949815167800466e-10, 7.012714853260604e-10, 7.075767749498141e-10, 7.13899661608508e-10, 7.202424212593428e-10, 7.266072743483676e-10, 7.329966078550854e-10, 7.394128087589991e-10, 7.458582640396116e-10, 7.523354716987285e-10, 7.588469852493063e-10, 7.653954137154528e-10, 7.719834771435785e-10, 7.786139510912449e-10, 7.852897221383159e-10, 7.920137878869582e-10, 7.987892014504894e-10, 8.056192379868321e-10, 8.125072836762115e-10, 8.194568912323064e-10, 8.264716688799467e-10, 8.3355555791087e-10, 8.407127216614185e-10, 8.479473234679347e-10, 8.552640262671218e-10, 8.626675485068347e-10, 8.701631637464402e-10, 8.777562010564566e-10, 8.854524335966119e-10, 8.932581896381464e-10, 9.011799639857543e-10, 9.092249730890956e-10, 9.174008219758889e-10, 9.25715837318819e-10, 9.341788453909317e-10, 9.42799727177146e-10, 9.515889187738935e-10, 9.605578554783278e-10, 9.697193048552322e-10, 9.790869226478094e-10, 9.886760299337993e-10, 9.985036131254788e-10, 1.008588212947359e-09, 1.0189509236369076e-09, 1.0296150598776421e-09, 1.040606933955246e-09, 1.0519566329136865e-09, 1.0636980185552147e-09, 1.0758701707302976e-09, 1.0885182755160372e-09, 1.101694735439196e-09, 1.115461056855338e-09, 1.1298901814171813e-09, 1.1450695946990663e-09, 1.1611052119775422e-09, 1.178127595480305e-09, 1.1962995039027646e-09, 1.2158286599728285e-09, 1.2369856250415978e-09, 1.2601323318151003e-09, 1.2857697129220469e-09, 1.3146201904845611e-09, 1.3477839955200466e-09, 1.3870635751089821e-09, 1.43574030442295e-09, 1.5008658760251592e-09, 1.6030947680434338e-09]); - fn = $toNativeArray("Float32", [1, 0.963599681854248, 0.9362826943397522, 0.9130436182022095, 0.8922816514968872, 0.8732430338859558, 0.8555005788803101, 0.8387836217880249, 0.8229072093963623, 0.8077383041381836, 0.7931770086288452, 0.7791460752487183, 0.7655841708183289, 0.7524415850639343, 0.7396772503852844, 0.7272568941116333, 0.7151514887809753, 0.7033361196517944, 0.6917891502380371, 0.6804918646812439, 0.6694276928901672, 0.6585819721221924, 0.6479418277740479, 0.6374954581260681, 0.6272324919700623, 0.6171433925628662, 0.6072195172309875, 0.5974531769752502, 0.5878370404243469, 0.5783646702766418, 0.5690299868583679, 0.5598273873329163, 0.550751805305481, 0.5417983531951904, 0.5329626798629761, 0.5242405533790588, 0.5156282186508179, 0.5071220397949219, 0.49871864914894104, 0.4904148280620575, 0.48220765590667725, 0.47409430146217346, 0.466072142124176, 0.45813870429992676, 0.45029163360595703, 0.44252872467041016, 0.4348478317260742, 0.42724698781967163, 0.41972434520721436, 0.41227802634239197, 0.40490642189979553, 0.39760786294937134, 0.3903807997703552, 0.3832238018512726, 0.3761354684829712, 0.3691144585609436, 0.36215949058532715, 0.3552693724632263, 0.3484429717063904, 0.3416791558265686, 0.33497685194015503, 0.32833510637283325, 0.3217529058456421, 0.3152293860912323, 0.30876362323760986, 0.3023548424243927, 0.2960021495819092, 0.2897048592567444, 0.28346219658851624, 0.2772735059261322, 0.271138072013855, 0.2650552988052368, 0.25902456045150757, 0.25304529070854187, 0.24711695313453674, 0.24123899638652802, 0.23541094362735748, 0.22963231801986694, 0.22390270233154297, 0.21822164952754974, 0.21258877217769623, 0.20700371265411377, 0.20146611332893372, 0.1959756463766098, 0.19053204357624054, 0.18513499200344086, 0.17978426814079285, 0.1744796335697174, 0.16922089457511902, 0.16400785744190216, 0.1588403731584549, 0.15371830761432648, 0.14864157140254974, 0.14361007511615753, 0.13862377405166626, 0.13368265330791473, 0.12878671288490295, 0.12393598258495331, 0.11913054436445236, 0.11437050998210907, 0.10965602099895477, 0.1049872562289238, 0.10036443918943405, 0.09578784555196762, 0.09125780314207077, 0.08677466958761215, 0.08233889937400818, 0.07795098423957825, 0.07361150532960892, 0.06932111829519272, 0.06508058309555054, 0.06089077144861221, 0.05675266310572624, 0.05266740173101425, 0.048636294901371, 0.044660862535238266, 0.040742866694927216, 0.03688438981771469, 0.03308788686990738, 0.029356317594647408, 0.025693291798233986, 0.02210330404341221, 0.018592102453112602, 0.015167297795414925, 0.011839478276669979, 0.0086244847625494, 0.005548994988203049, 0.0026696291752159595]); - rng_cooked = $toNativeArray("Int64", [new $Int64(1173834291, 3952672746), new $Int64(1081821761, 3130416987), new $Int64(324977939, 3414273807), new $Int64(1241840476, 2806224363), new $Int64(669549340, 1997590414), new $Int64(2103305448, 2402795971), new $Int64(1663160183, 1140819369), new $Int64(1120601685, 1788868961), new $Int64(1848035537, 1089001426), new $Int64(1235702047, 873593504), new $Int64(1911387977, 581324885), new $Int64(492609478, 1609182556), new $Int64(1069394745, 1241596776), new $Int64(1895445337, 1771189259), new $Int64(772864846, 3467012610), new $Int64(2006957225, 2344407434), new $Int64(402115761, 782467244), new $Int64(26335124, 3404933915), new $Int64(1063924276, 618867887), new $Int64(1178782866, 520164395), new $Int64(555910815, 1341358184), new $Int64(632398609, 665794848), new $Int64(1527227641, 3183648150), new $Int64(1781176124, 696329606), new $Int64(1789146075, 4151988961), new $Int64(60039534, 998951326), new $Int64(1535158725, 1364957564), new $Int64(63173359, 4090230633), new $Int64(649454641, 4009697548), new $Int64(248009524, 2569622517), new $Int64(778703922, 3742421481), new $Int64(1038377625, 1506914633), new $Int64(1738099768, 1983412561), new $Int64(236311649, 1436266083), new $Int64(1035966148, 3922894967), new $Int64(810508934, 1792680179), new $Int64(563141142, 1188796351), new $Int64(1349617468, 405968250), new $Int64(1044074554, 433754187), new $Int64(870549669, 4073162024), new $Int64(1053232044, 433121399), new $Int64(2451824, 4162580594), new $Int64(2010221076, 4132415622), new $Int64(611252600, 3033822028), new $Int64(2016407895, 824682382), new $Int64(2366218, 3583765414), new $Int64(1522878809, 535386927), new $Int64(1637219058, 2286693689), new $Int64(1453075389, 2968466525), new $Int64(193683513, 1351410206), new $Int64(1863677552, 1412813499), new $Int64(492736522, 4126267639), new $Int64(512765208, 2105529399), new $Int64(2132966268, 2413882233), new $Int64(947457634, 32226200), new $Int64(1149341356, 2032329073), new $Int64(106485445, 1356518208), new $Int64(79673492, 3430061722), new $Int64(663048513, 3820169661), new $Int64(481498454, 2981816134), new $Int64(1017155588, 4184371017), new $Int64(206574701, 2119206761), new $Int64(1295374591, 2472200560), new $Int64(1587026100, 2853524696), new $Int64(1307803389, 1681119904), new $Int64(1972496813, 95608918), new $Int64(392686347, 3690479145), new $Int64(941912722, 1397922290), new $Int64(988169623, 1516129515), new $Int64(1827305493, 1547420459), new $Int64(1311333971, 1470949486), new $Int64(194013850, 1336785672), new $Int64(2102397034, 4131677129), new $Int64(755205548, 4246329084), new $Int64(1004983461, 3788585631), new $Int64(2081005363, 3080389532), new $Int64(1501045284, 2215402037), new $Int64(391002300, 1171593935), new $Int64(1408774047, 1423855166), new $Int64(1628305930, 2276716302), new $Int64(1779030508, 2068027241), new $Int64(1369359303, 3427553297), new $Int64(189241615, 3289637845), new $Int64(1057480830, 3486407650), new $Int64(634572984, 3071877822), new $Int64(1159653919, 3363620705), new $Int64(1213226718, 4159821533), new $Int64(2070861710, 1894661), new $Int64(1472989750, 1156868282), new $Int64(348271067, 776219088), new $Int64(1646054810, 2425634259), new $Int64(1716021749, 680510161), new $Int64(1573220192, 1310101429), new $Int64(1095885995, 2964454134), new $Int64(1821788136, 3467098407), new $Int64(1990672920, 2109628894), new $Int64(7834944, 1232604732), new $Int64(309412934, 3261916179), new $Int64(1699175360, 434597899), new $Int64(235436061, 1624796439), new $Int64(521080809, 3589632480), new $Int64(1198416575, 864579159), new $Int64(208735487, 1380889830), new $Int64(619206309, 2654509477), new $Int64(1419738251, 1468209306), new $Int64(403198876, 100794388), new $Int64(956062190, 2991674471), new $Int64(1938816907, 2224662036), new $Int64(1973824487, 977097250), new $Int64(1351320195, 726419512), new $Int64(1964023751, 1747974366), new $Int64(1394388465, 1556430604), new $Int64(1097991433, 1080776742), new $Int64(1761636690, 280794874), new $Int64(117767733, 919835643), new $Int64(1180474222, 3434019658), new $Int64(196069168, 2461941785), new $Int64(133215641, 3615001066), new $Int64(417204809, 3103414427), new $Int64(790056561, 3380809712), new $Int64(879802240, 2724693469), new $Int64(547796833, 598827710), new $Int64(300924196, 3452273442), new $Int64(2071705424, 649274915), new $Int64(1346182319, 2585724112), new $Int64(636549385, 3165579553), new $Int64(1185578221, 2635894283), new $Int64(2094573470, 2053289721), new $Int64(985976581, 3169337108), new $Int64(1170569632, 144717764), new $Int64(1079216270, 1383666384), new $Int64(2022678706, 681540375), new $Int64(1375448925, 537050586), new $Int64(182715304, 315246468), new $Int64(226402871, 849323088), new $Int64(1262421183, 45543944), new $Int64(1201038398, 2319052083), new $Int64(2106775454, 3613090841), new $Int64(560472520, 2992171180), new $Int64(1765620479, 2068244785), new $Int64(917538188, 4239862634), new $Int64(777927839, 3892253031), new $Int64(720683925, 958186149), new $Int64(1724185863, 1877702262), new $Int64(1357886971, 837674867), new $Int64(1837048883, 1507589294), new $Int64(1905518400, 873336795), new $Int64(267722611, 2764496274), new $Int64(341003118, 4196182374), new $Int64(1080717893, 550964545), new $Int64(818747069, 420611474), new $Int64(222653272, 204265180), new $Int64(1549974541, 1787046383), new $Int64(1215581865, 3102292318), new $Int64(418321538, 1552199393), new $Int64(1243493047, 980542004), new $Int64(267284263, 3293718720), new $Int64(1179528763, 3771917473), new $Int64(599484404, 2195808264), new $Int64(252818753, 3894702887), new $Int64(780007692, 2099949527), new $Int64(1424094358, 338442522), new $Int64(490737398, 637158004), new $Int64(419862118, 281976339), new $Int64(574970164, 3619802330), new $Int64(1715552825, 3084554784), new $Int64(882872465, 4129772886), new $Int64(43084605, 1680378557), new $Int64(525521057, 3339087776), new $Int64(1680500332, 4220317857), new $Int64(211654685, 2959322499), new $Int64(1675600481, 1488354890), new $Int64(1312620086, 3958162143), new $Int64(920972075, 2773705983), new $Int64(1876039582, 225908689), new $Int64(963748535, 908216283), new $Int64(1541787429, 3574646075), new $Int64(319760557, 1936937569), new $Int64(1519770881, 75492235), new $Int64(816689472, 1935193178), new $Int64(2142521206, 2018250883), new $Int64(455141620, 3943126022), new $Int64(1546084160, 3066544345), new $Int64(1932392669, 2793082663), new $Int64(908474287, 3297036421), new $Int64(1640597065, 2206987825), new $Int64(1594236910, 807894872), new $Int64(366158341, 766252117), new $Int64(2060649606, 3833114345), new $Int64(845619743, 1255067973), new $Int64(1201145605, 741697208), new $Int64(671241040, 2810093753), new $Int64(1109032642, 4229340371), new $Int64(1462188720, 1361684224), new $Int64(988084219, 1906263026), new $Int64(475781207, 3904421704), new $Int64(1523946520, 1769075545), new $Int64(1062308525, 2621599764), new $Int64(1279509432, 3431891480), new $Int64(404732502, 1871896503), new $Int64(128756421, 1412808876), new $Int64(1605404688, 952876175), new $Int64(1917039957, 1824438899), new $Int64(1662295856, 1005035476), new $Int64(1990909507, 527508597), new $Int64(1288873303, 3066806859), new $Int64(565995893, 3244940914), new $Int64(1257737460, 209092916), new $Int64(1899814242, 1242699167), new $Int64(1433653252, 456723774), new $Int64(1776978905, 1001252870), new $Int64(1468772157, 2026725874), new $Int64(857254202, 2137562569), new $Int64(765939740, 3183366709), new $Int64(1533887628, 2612072960), new $Int64(56977098, 1727148468), new $Int64(949899753, 3803658212), new $Int64(1883670356, 479946959), new $Int64(685713571, 1562982345), new $Int64(201241205, 1766109365), new $Int64(700596547, 3257093788), new $Int64(1962768719, 2365720207), new $Int64(93384808, 3742754173), new $Int64(1689098413, 2878193673), new $Int64(1096135042, 2174002182), new $Int64(1313222695, 3573511231), new $Int64(1392911121, 1760299077), new $Int64(771856457, 2260779833), new $Int64(1281464374, 1452805722), new $Int64(917811730, 2940011802), new $Int64(1890251082, 1886183802), new $Int64(893897673, 2514369088), new $Int64(1644345561, 3924317791), new $Int64(172616216, 500935732), new $Int64(1403501753, 676580929), new $Int64(581571365, 1184984890), new $Int64(1455515235, 1271474274), new $Int64(318728910, 3163791473), new $Int64(2051027584, 2842487377), new $Int64(1511537551, 2170968612), new $Int64(573262976, 3535856740), new $Int64(94256461, 1488599718), new $Int64(966951817, 3408913763), new $Int64(60951736, 2501050084), new $Int64(1272353200, 1639124157), new $Int64(138001144, 4088176393), new $Int64(1574896563, 3989947576), new $Int64(1982239940, 3414355209), new $Int64(1355154361, 2275136352), new $Int64(89709303, 2151835223), new $Int64(1216338715, 1654534827), new $Int64(1467562197, 377892833), new $Int64(1664767638, 660204544), new $Int64(85706799, 390828249), new $Int64(725310955, 3402783878), new $Int64(678849488, 3717936603), new $Int64(1113532086, 2211058823), new $Int64(1564224320, 2692150867), new $Int64(1952770442, 1928910388), new $Int64(788716862, 3931011137), new $Int64(1083670504, 1112701047), new $Int64(2079333076, 2452299106), new $Int64(1251318826, 2337204777), new $Int64(1774877857, 273889282), new $Int64(1798719843, 1462008793), new $Int64(2138834788, 1554494002), new $Int64(952516517, 182675323), new $Int64(548928884, 1882802136), new $Int64(589279648, 3700220025), new $Int64(381039426, 3083431543), new $Int64(1295624457, 3622207527), new $Int64(338126939, 432729309), new $Int64(480013522, 2391914317), new $Int64(297925497, 235747924), new $Int64(2120733629, 3088823825), new $Int64(1402403853, 2314658321), new $Int64(1165929723, 2957634338), new $Int64(501323675, 4117056981), new $Int64(1564699815, 1482500298), new $Int64(1406657158, 840489337), new $Int64(799522364, 3483178565), new $Int64(532129761, 2074004656), new $Int64(724246478, 3643392642), new $Int64(1482330167, 1583624461), new $Int64(1261660694, 287473085), new $Int64(1667835381, 3136843981), new $Int64(1138806821, 1266970974), new $Int64(135185781, 1998688839), new $Int64(392094735, 1492900209), new $Int64(1031326774, 1538112737), new $Int64(76914806, 2207265429), new $Int64(260686035, 963263315), new $Int64(1671145500, 2295892134), new $Int64(1068469660, 2002560897), new $Int64(1791233343, 1369254035), new $Int64(33436120, 3353312708), new $Int64(57507843, 947771099), new $Int64(201728503, 1747061399), new $Int64(1507240140, 2047354631), new $Int64(720000810, 4165367136), new $Int64(479265078, 3388864963), new $Int64(1195302398, 286492130), new $Int64(2045622690, 2795735007), new $Int64(1431753082, 3703961339), new $Int64(1999047161, 1797825479), new $Int64(1429039600, 1116589674), new $Int64(482063550, 2593309206), new $Int64(1329049334, 3404995677), new $Int64(1396904208, 3453462936), new $Int64(1014767077, 3016498634), new $Int64(75698599, 1650371545), new $Int64(1592007860, 212344364), new $Int64(1127766888, 3843932156), new $Int64(1399463792, 3573129983), new $Int64(1256901817, 665897820), new $Int64(1071492673, 1675628772), new $Int64(243225682, 2831752928), new $Int64(2120298836, 1486294219), new $Int64(193076235, 268782709), new $Int64(1145360145, 4186179080), new $Int64(624342951, 1613720397), new $Int64(857179861, 2703686015), new $Int64(1235864944, 2205342611), new $Int64(1474779655, 1411666394), new $Int64(619028749, 677744900), new $Int64(270855115, 4172867247), new $Int64(135494707, 2163418403), new $Int64(849547544, 2841526879), new $Int64(1029966689, 1082141470), new $Int64(377371856, 4046134367), new $Int64(51415528, 2142943655), new $Int64(1897659315, 3124627521), new $Int64(998228909, 219992939), new $Int64(1068692697, 1756846531), new $Int64(1283749206, 1225118210), new $Int64(1621625642, 1647770243), new $Int64(111523943, 444807907), new $Int64(2036369448, 3952076173), new $Int64(53201823, 1461839639), new $Int64(315761893, 3699250910), new $Int64(702974850, 1373688981), new $Int64(734022261, 147523747), new $Int64(100152742, 1211276581), new $Int64(1294440951, 2548832680), new $Int64(1144696256, 1995631888), new $Int64(154500578, 2011457303), new $Int64(796460974, 3057425772), new $Int64(667839456, 81484597), new $Int64(465502760, 3646681560), new $Int64(775020923, 635548515), new $Int64(602489502, 2508044581), new $Int64(353263531, 1014917157), new $Int64(719992433, 3214891315), new $Int64(852684611, 959582252), new $Int64(226415134, 3347040449), new $Int64(1784615552, 4102971975), new $Int64(397887437, 4078022210), new $Int64(1610679822, 2851767182), new $Int64(749162636, 1540160644), new $Int64(598384772, 1057290595), new $Int64(2034890660, 3907769253), new $Int64(579300318, 4248952684), new $Int64(1092907599, 132554364), new $Int64(1061621234, 1029351092), new $Int64(697840928, 2583007416), new $Int64(298619124, 1486185789), new $Int64(55905697, 2871589073), new $Int64(2017643612, 723203291), new $Int64(146250550, 2494333952), new $Int64(1064490251, 2230939180), new $Int64(342915576, 3943232912), new $Int64(1768732449, 2181367922), new $Int64(1418222537, 2889274791), new $Int64(1824032949, 2046728161), new $Int64(1653899792, 1376052477), new $Int64(1022327048, 381236993), new $Int64(1034385958, 3188942166), new $Int64(2073003539, 350070824), new $Int64(144881592, 61758415), new $Int64(1405659422, 3492950336), new $Int64(117440928, 3093818430), new $Int64(1693893113, 2962480613), new $Int64(235432940, 3154871160), new $Int64(511005079, 3228564679), new $Int64(610731502, 888276216), new $Int64(1200780674, 3574998604), new $Int64(870415268, 1967526716), new $Int64(591335707, 1554691298), new $Int64(574459414, 339944798), new $Int64(1223764147, 1154515356), new $Int64(1825645307, 967516237), new $Int64(1546195135, 596588202), new $Int64(279882768, 3764362170), new $Int64(492091056, 266611402), new $Int64(1754227768, 2047856075), new $Int64(1146757215, 21444105), new $Int64(1198058894, 3065563181), new $Int64(1915064845, 1140663212), new $Int64(633187674, 2323741028), new $Int64(2126290159, 3103873707), new $Int64(1008658319, 2766828349), new $Int64(1661896145, 1970872996), new $Int64(1628585413, 3766615585), new $Int64(1552335120, 2036813414), new $Int64(152606527, 3105536507), new $Int64(13954645, 3396176938), new $Int64(1426081645, 1377154485), new $Int64(2085644467, 3807014186), new $Int64(543009040, 3710110597), new $Int64(396058129, 916420443), new $Int64(734556788, 2103831255), new $Int64(381322154, 717331943), new $Int64(572884752, 3550505941), new $Int64(45939673, 378749927), new $Int64(149867929, 611017331), new $Int64(592130075, 758907650), new $Int64(1012992349, 154266815), new $Int64(1107028706, 1407468696), new $Int64(469292398, 970098704), new $Int64(1862426162, 1971660656), new $Int64(998365243, 3332747885), new $Int64(1947089649, 1935189867), new $Int64(1510248801, 203520055), new $Int64(842317902, 3916463034), new $Int64(1758884993, 3474113316), new $Int64(1036101639, 316544223), new $Int64(373738757, 1650844677), new $Int64(1240292229, 4267565603), new $Int64(1077208624, 2501167616), new $Int64(626831785, 3929401789), new $Int64(56122796, 337170252), new $Int64(1186981558, 2061966842), new $Int64(1843292800, 2508461464), new $Int64(206012532, 2791377107), new $Int64(1240791848, 1227227588), new $Int64(1813978778, 1709681848), new $Int64(1153692192, 3768820575), new $Int64(1145186199, 2887126398), new $Int64(700372314, 296561685), new $Int64(700300844, 3729960077), new $Int64(575172304, 372833036), new $Int64(2078875613, 2409779288), new $Int64(1829161290, 555274064), new $Int64(1041887929, 4239804901), new $Int64(1839403216, 3723486978), new $Int64(498390553, 2145871984), new $Int64(564717933, 3565480803), new $Int64(578829821, 2197313814), new $Int64(974785092, 3613674566), new $Int64(438638731, 3042093666), new $Int64(2050927384, 3324034321), new $Int64(869420878, 3708873369), new $Int64(946682149, 1698090092), new $Int64(1618900382, 4213940712), new $Int64(304003901, 2087477361), new $Int64(381315848, 2407950639), new $Int64(851258090, 3942568569), new $Int64(923583198, 4088074412), new $Int64(723260036, 2964773675), new $Int64(1473561819, 1539178386), new $Int64(1062961552, 2694849566), new $Int64(460977733, 2120273838), new $Int64(542912908, 2484608657), new $Int64(880846449, 2956190677), new $Int64(1970902366, 4223313749), new $Int64(662161910, 3502682327), new $Int64(705634754, 4133891139), new $Int64(1116124348, 1166449596), new $Int64(1038247601, 3362705993), new $Int64(93734798, 3892921029), new $Int64(1876124043, 786869787), new $Int64(1057490746, 1046342263), new $Int64(242763728, 493777327), new $Int64(1293910447, 3304827646), new $Int64(616460742, 125356352), new $Int64(499300063, 74094113), new $Int64(1351896723, 2500816079), new $Int64(1657235204, 514015239), new $Int64(1377565129, 543520454), new $Int64(107706923, 3614531153), new $Int64(2056746300, 2356753985), new $Int64(1390062617, 2018141668), new $Int64(131272971, 2087974891), new $Int64(644556607, 3166972343), new $Int64(372256200, 1517638666), new $Int64(1212207984, 173466846), new $Int64(1451709187, 4241513471), new $Int64(733932806, 2783126920), new $Int64(1972004134, 4167264826), new $Int64(29260506, 3907395640), new $Int64(1236582087, 1539634186), new $Int64(1551526350, 178241987), new $Int64(2034206012, 182168164), new $Int64(1044953189, 2386154934), new $Int64(1379126408, 4077374341), new $Int64(32803926, 1732699140), new $Int64(1726425903, 1041306002), new $Int64(1860414813, 2068001749), new $Int64(1005320202, 3208962910), new $Int64(844054010, 697710380), new $Int64(638124245, 2228431183), new $Int64(1337169671, 3554678728), new $Int64(1396494601, 173470263), new $Int64(2061597383, 3848297795), new $Int64(1220546671, 246236185), new $Int64(163293187, 2066374846), new $Int64(1771673660, 312890749), new $Int64(703378057, 3573310289), new $Int64(1548631747, 143166754), new $Int64(613554316, 2081511079), new $Int64(1197802104, 486038032), new $Int64(240999859, 2982218564), new $Int64(364901986, 1000939191), new $Int64(1902782651, 2750454885), new $Int64(1475638791, 3375313137), new $Int64(503615608, 881302957), new $Int64(638698903, 2514186393), new $Int64(443860803, 360024739), new $Int64(1399671872, 292500025), new $Int64(1381210821, 2276300752), new $Int64(521803381, 4069087683), new $Int64(208500981, 1637778212), new $Int64(720490469, 1676670893), new $Int64(1067262482, 3855174429), new $Int64(2114075974, 2067248671), new $Int64(2058057389, 2884561259), new $Int64(1341742553, 2456511185), new $Int64(983726246, 561175414), new $Int64(427994085, 432588903), new $Int64(885133709, 4059399550), new $Int64(2054387382, 1075014784), new $Int64(413651020, 2728058415), new $Int64(1839142064, 1299703678), new $Int64(1262333188, 2347583393), new $Int64(1285481956, 2468164145), new $Int64(989129637, 1140014346), new $Int64(2033889184, 1936972070), new $Int64(409904655, 3870530098), new $Int64(1662989391, 1717789158), new $Int64(1914486492, 1153452491), new $Int64(1157059232, 3948827651), new $Int64(790338018, 2101413152), new $Int64(1495744672, 3854091229), new $Int64(83644069, 4215565463), new $Int64(762206335, 1202710438), new $Int64(1582574611, 2072216740), new $Int64(705690639, 2066751068), new $Int64(33900336, 173902580), new $Int64(1405499842, 142459001), new $Int64(172391592, 1889151926), new $Int64(1648540523, 3034199774), new $Int64(1618587731, 516490102), new $Int64(93114264, 3692577783), new $Int64(68662295, 2953948865), new $Int64(1826544975, 4041040923), new $Int64(204965672, 592046130), new $Int64(1441840008, 384297211), new $Int64(95834184, 265863924), new $Int64(2101717619, 1333136237), new $Int64(1499611781, 1406273556), new $Int64(1074670496, 426305476), new $Int64(125704633, 2750898176), new $Int64(488068495, 1633944332), new $Int64(2037723464, 3236349343), new $Int64(444060402, 4013676611), new $Int64(1718532237, 2265047407), new $Int64(1433593806, 875071080), new $Int64(1804436145, 1418843655), new $Int64(2009228711, 451657300), new $Int64(1229446621, 1866374663), new $Int64(1653472867, 1551455622), new $Int64(577191481, 3560962459), new $Int64(1669204077, 3347903778), new $Int64(1849156454, 2675874918), new $Int64(316128071, 2762991672), new $Int64(530492383, 3689068477), new $Int64(844089962, 4071997905), new $Int64(1508155730, 1381702441), new $Int64(2089931018, 2373284878), new $Int64(1283216186, 2143983064), new $Int64(308739063, 1938207195), new $Int64(1754949306, 1188152253), new $Int64(1272345009, 615870490), new $Int64(742653194, 2662252621), new $Int64(1477718295, 3839976789), new $Int64(56149435, 306752547), new $Int64(720795581, 2162363077), new $Int64(2090431015, 2767224719), new $Int64(675859549, 2628837712), new $Int64(1678405918, 2967771969), new $Int64(1694285728, 499792248), new $Int64(403352367, 4285253508), new $Int64(962357072, 2856511070), new $Int64(679471692, 2526409716), new $Int64(353777175, 1240875658), new $Int64(1232590226, 2577342868), new $Int64(1146185433, 4136853496), new $Int64(670368674, 2403540137), new $Int64(1372824515, 1371410668), new $Int64(1970921600, 371758825), new $Int64(1706420536, 1528834084), new $Int64(2075795018, 1504757260), new $Int64(685663576, 699052551), new $Int64(1641940109, 3347789870), new $Int64(1951619734, 3430604759), new $Int64(2119672219, 1935601723), new $Int64(966789690, 834676166)]); - globalRand = New(new lockedSource.Ptr(new sync.Mutex.Ptr(), NewSource(new $Int64(0, 1)))); + ($ptrType(Reader)).methods = [["Buffered", "Buffered", "", $funcType([], [$Int], false), -1], ["Peek", "Peek", "", $funcType([$Int], [($sliceType($Uint8)), $error], false), -1], ["Read", "Read", "", $funcType([($sliceType($Uint8))], [$Int, $error], false), -1], ["ReadByte", "ReadByte", "", $funcType([], [$Uint8, $error], false), -1], ["ReadBytes", "ReadBytes", "", $funcType([$Uint8], [($sliceType($Uint8)), $error], false), -1], ["ReadLine", "ReadLine", "", $funcType([], [($sliceType($Uint8)), $Bool, $error], false), -1], ["ReadRune", "ReadRune", "", $funcType([], [$Int32, $Int, $error], false), -1], ["ReadSlice", "ReadSlice", "", $funcType([$Uint8], [($sliceType($Uint8)), $error], false), -1], ["ReadString", "ReadString", "", $funcType([$Uint8], [$String, $error], false), -1], ["Reset", "Reset", "", $funcType([io.Reader], [], false), -1], ["UnreadByte", "UnreadByte", "", $funcType([], [$error], false), -1], ["UnreadRune", "UnreadRune", "", $funcType([], [$error], false), -1], ["WriteTo", "WriteTo", "", $funcType([io.Writer], [$Int64, $error], false), -1], ["fill", "fill", "bufio", $funcType([], [], false), -1], ["readErr", "readErr", "bufio", $funcType([], [$error], false), -1], ["reset", "reset", "bufio", $funcType([($sliceType($Uint8)), io.Reader], [], false), -1], ["writeBuf", "writeBuf", "bufio", $funcType([io.Writer], [$Int64, $error], false), -1]]; + Reader.init([["buf", "buf", "bufio", ($sliceType($Uint8)), ""], ["rd", "rd", "bufio", io.Reader, ""], ["r", "r", "bufio", $Int, ""], ["w", "w", "bufio", $Int, ""], ["err", "err", "bufio", $error, ""], ["lastByte", "lastByte", "bufio", $Int, ""], ["lastRuneSize", "lastRuneSize", "bufio", $Int, ""]]); + $pkg.ErrInvalidUnreadByte = errors.New("bufio: invalid use of UnreadByte"); + $pkg.ErrInvalidUnreadRune = errors.New("bufio: invalid use of UnreadRune"); + $pkg.ErrBufferFull = errors.New("bufio: buffer full"); + $pkg.ErrNegativeCount = errors.New("bufio: negative count"); + errNegativeRead = errors.New("bufio: reader returned negative count from Read"); + $pkg.ErrTooLong = errors.New("bufio.Scanner: token too long"); + $pkg.ErrNegativeAdvance = errors.New("bufio.Scanner: SplitFunc returns negative advance count"); + $pkg.ErrAdvanceTooFar = errors.New("bufio.Scanner: SplitFunc returns advance count beyond input"); }; return $pkg; })(); -$packages["math/big"] = (function() { - var $pkg = {}, errors = $packages["errors"], fmt = $packages["fmt"], io = $packages["io"], rand = $packages["math/rand"], strings = $packages["strings"], math = $packages["math"], sync = $packages["sync"], binary = $packages["encoding/binary"], Word, Int, nat, divisor, Rat, intOne, natOne, natTwo, natTen, karatsubaThreshold, leafSize, cacheBase10, deBruijn32Lookup, deBruijn64Lookup, mulWW, divWW, addVV, subVV, addVW, subVW, shlVU, shrVU, mulAddVWW, addMulVVW, divWVW, bitLen, addWW_g, subWW_g, mulWW_g, mulAddWWW_g, bitLen_g, leadingZeros, divWW_g, addVV_g, subVV_g, addVW_g, subVW_g, shlVU_g, shrVU_g, mulAddVWW_g, addMulVVW_g, divWVW_g, NewInt, charset, writeMultiple, basicMul, karatsubaAdd, karatsubaSub, karatsuba, alias, addAt, max, karatsubaLen, hexValue, divisors, trailingZeroBits, greaterThan, NewRat, low64, quotToFloat, mulDenom, scaleDenom, ratTok; - Word = $pkg.Word = $newType(4, "Uintptr", "big.Word", "Word", "math/big", null); - Int = $pkg.Int = $newType(0, "Struct", "big.Int", "Int", "math/big", function(neg_, abs_) { +$packages["text/tabwriter"] = (function() { + var $pkg = {}, bytes = $packages["bytes"], io = $packages["io"], utf8 = $packages["unicode/utf8"], cell, Writer, osError, newline, tabs, vbar, hbar, handlePanic, NewWriter; + cell = $pkg.cell = $newType(0, "Struct", "tabwriter.cell", "cell", "text/tabwriter", function(size_, width_, htab_) { this.$val = this; - this.neg = neg_ !== undefined ? neg_ : false; - this.abs = abs_ !== undefined ? abs_ : nat.nil; + this.size = size_ !== undefined ? size_ : 0; + this.width = width_ !== undefined ? width_ : 0; + this.htab = htab_ !== undefined ? htab_ : false; }); - nat = $pkg.nat = $newType(12, "Slice", "big.nat", "nat", "math/big", null); - divisor = $pkg.divisor = $newType(0, "Struct", "big.divisor", "divisor", "math/big", function(bbb_, nbits_, ndigits_) { + Writer = $pkg.Writer = $newType(0, "Struct", "tabwriter.Writer", "Writer", "text/tabwriter", function(output_, minwidth_, tabwidth_, padding_, padbytes_, flags_, buf_, pos_, cell_, endChar_, lines_, widths_) { this.$val = this; - this.bbb = bbb_ !== undefined ? bbb_ : nat.nil; - this.nbits = nbits_ !== undefined ? nbits_ : 0; - this.ndigits = ndigits_ !== undefined ? ndigits_ : 0; + this.output = output_ !== undefined ? output_ : $ifaceNil; + this.minwidth = minwidth_ !== undefined ? minwidth_ : 0; + this.tabwidth = tabwidth_ !== undefined ? tabwidth_ : 0; + this.padding = padding_ !== undefined ? padding_ : 0; + this.padbytes = padbytes_ !== undefined ? padbytes_ : ($arrayType($Uint8, 8)).zero(); + this.flags = flags_ !== undefined ? flags_ : 0; + this.buf = buf_ !== undefined ? buf_ : new bytes.Buffer.Ptr(); + this.pos = pos_ !== undefined ? pos_ : 0; + this.cell = cell_ !== undefined ? cell_ : new cell.Ptr(); + this.endChar = endChar_ !== undefined ? endChar_ : 0; + this.lines = lines_ !== undefined ? lines_ : ($sliceType(($sliceType(cell)))).nil; + this.widths = widths_ !== undefined ? widths_ : ($sliceType($Int)).nil; }); - Rat = $pkg.Rat = $newType(0, "Struct", "big.Rat", "Rat", "math/big", function(a_, b_) { + osError = $pkg.osError = $newType(0, "Struct", "tabwriter.osError", "osError", "text/tabwriter", function(err_) { this.$val = this; - this.a = a_ !== undefined ? a_ : new Int.Ptr(); - this.b = b_ !== undefined ? b_ : new Int.Ptr(); + this.err = err_ !== undefined ? err_ : $ifaceNil; }); - mulWW = function(x, y) { - var z1 = 0, z0 = 0, _tuple; - _tuple = mulWW_g(x, y); z1 = _tuple[0]; z0 = _tuple[1]; - return [z1, z0]; - }; - divWW = function(x1, x0, y) { - var q = 0, r = 0, _tuple; - _tuple = divWW_g(x1, x0, y); q = _tuple[0]; r = _tuple[1]; - return [q, r]; - }; - addVV = function(z, x, y) { - var c = 0; - c = addVV_g(z, x, y); - return c; - }; - subVV = function(z, x, y) { - var c = 0; - c = subVV_g(z, x, y); - return c; - }; - addVW = function(z, x, y) { - var c = 0; - c = addVW_g(z, x, y); - return c; - }; - subVW = function(z, x, y) { - var c = 0; - c = subVW_g(z, x, y); - return c; - }; - shlVU = function(z, x, s) { - var c = 0; - c = shlVU_g(z, x, s); - return c; - }; - shrVU = function(z, x, s) { - var c = 0; - c = shrVU_g(z, x, s); - return c; - }; - mulAddVWW = function(z, x, y, r) { - var c = 0; - c = mulAddVWW_g(z, x, y, r); - return c; - }; - addMulVVW = function(z, x, y) { - var c = 0; - c = addMulVVW_g(z, x, y); - return c; - }; - divWVW = function(z, xn, x, y) { - var r = 0; - r = divWVW_g(z, xn, x, y); - return r; + Writer.Ptr.prototype.addLine = function() { + var b; + b = this; + b.lines = $append(b.lines, new ($sliceType(cell))([])); }; - bitLen = function(x) { - var n = 0; - n = bitLen_g(x); - return n; + Writer.prototype.addLine = function() { return this.$val.addLine(); }; + Writer.Ptr.prototype.reset = function() { + var b; + b = this; + b.buf.Reset(); + b.pos = 0; + $copy(b.cell, new cell.Ptr(0, 0, false), cell); + b.endChar = 0; + b.lines = $subslice(b.lines, 0, 0); + b.widths = $subslice(b.widths, 0, 0); + b.addLine(); }; - addWW_g = function(x, y, c) { - var z1 = 0, z0 = 0, yc; - yc = y + c >>> 0; - z0 = x + yc >>> 0; - if (z0 < x || yc < y) { - z1 = 1; + Writer.prototype.reset = function() { return this.$val.reset(); }; + Writer.Ptr.prototype.Init = function(output, minwidth, tabwidth, padding, padchar, flags) { + var b, _ref, _i, i, x; + b = this; + if (minwidth < 0 || tabwidth < 0 || padding < 0) { + $panic(new $String("negative minwidth, tabwidth, or padding")); } - return [z1, z0]; - }; - subWW_g = function(x, y, c) { - var z1 = 0, z0 = 0, yc; - yc = y + c >>> 0; - z0 = x - yc >>> 0; - if (z0 > x || yc < y) { - z1 = 1; + b.output = output; + b.minwidth = minwidth; + b.tabwidth = tabwidth; + b.padding = padding; + _ref = b.padbytes; + _i = 0; + while (_i < 8) { + i = _i; + (x = b.padbytes, (i < 0 || i >= x.length) ? $throwRuntimeError("index out of range") : x[i] = padchar); + _i++; } - return [z1, z0]; - }; - mulWW_g = function(x, y) { - var z1 = 0, z0 = 0, x0, x1, y0, y1, w0, t, w1, w2; - x0 = (x & 65535) >>> 0; - x1 = x >>> 16 >>> 0; - y0 = (y & 65535) >>> 0; - y1 = y >>> 16 >>> 0; - w0 = (((x0 >>> 16 << 16) * y0 >>> 0) + (x0 << 16 >>> 16) * y0) >>> 0; - t = ((((x1 >>> 16 << 16) * y0 >>> 0) + (x1 << 16 >>> 16) * y0) >>> 0) + (w0 >>> 16 >>> 0) >>> 0; - w1 = (t & 65535) >>> 0; - w2 = t >>> 16 >>> 0; - w1 = w1 + (((((x0 >>> 16 << 16) * y1 >>> 0) + (x0 << 16 >>> 16) * y1) >>> 0)) >>> 0; - z1 = (((((x1 >>> 16 << 16) * y1 >>> 0) + (x1 << 16 >>> 16) * y1) >>> 0) + w2 >>> 0) + (w1 >>> 16 >>> 0) >>> 0; - z0 = (((x >>> 16 << 16) * y >>> 0) + (x << 16 >>> 16) * y) >>> 0; - return [z1, z0]; - }; - mulAddWWW_g = function(x, y, c) { - var z1 = 0, z0 = 0, _tuple, zz0; - _tuple = mulWW(x, y); z1 = _tuple[0]; zz0 = _tuple[1]; - z0 = zz0 + c >>> 0; - if (z0 < zz0) { - z1 = z1 + (1) >>> 0; + if (padchar === 9) { + flags = flags & ~(4); } - return [z1, z0]; + b.flags = flags; + b.reset(); + return b; }; - bitLen_g = function(x) { - var n = 0, y, y$1, y$2, y$3; - while (x >= 32768) { - n = n + (16) >> 0; - x = (y = (16), y < 32 ? (x >>> y) : 0) >>> 0; - } - if (x >= 128) { - x = (y$1 = (8), y$1 < 32 ? (x >>> y$1) : 0) >>> 0; - n = n + (8) >> 0; - } - if (x >= 8) { - x = (y$2 = (4), y$2 < 32 ? (x >>> y$2) : 0) >>> 0; - n = n + (4) >> 0; - } - if (x >= 2) { - x = (y$3 = (2), y$3 < 32 ? (x >>> y$3) : 0) >>> 0; - n = n + (2) >> 0; + Writer.prototype.Init = function(output, minwidth, tabwidth, padding, padchar, flags) { return this.$val.Init(output, minwidth, tabwidth, padding, padchar, flags); }; + Writer.Ptr.prototype.write0 = function(buf) { + var b, _tuple, n, err, x; + b = this; + _tuple = b.output.Write(buf); n = _tuple[0]; err = _tuple[1]; + if (!((n === buf.$length)) && $interfaceIsEqual(err, $ifaceNil)) { + err = io.ErrShortWrite; } - if (x >= 1) { - n = n + (1) >> 0; + if (!($interfaceIsEqual(err, $ifaceNil))) { + $panic((x = new osError.Ptr(err), new x.constructor.Struct(x))); } - return n; - }; - leadingZeros = function(x) { - return ((32 - bitLen(x) >> 0) >>> 0); }; - divWW_g = function(u1, u0, v) { - var q = 0, r = 0, _tmp, _tmp$1, s, y, vn1, vn0, y$1, y$2, un32, y$3, un10, un1, un0, _q, q1, rhat, un21, _q$1, q0, _tmp$2, _tmp$3, y$4; - if (u1 >= v) { - _tmp = 4294967295; _tmp$1 = 4294967295; q = _tmp; r = _tmp$1; - return [q, r]; + Writer.prototype.write0 = function(buf) { return this.$val.write0(buf); }; + Writer.Ptr.prototype.writeN = function(src, n) { + var b; + b = this; + while (n > src.$length) { + b.write0(src); + n = n - (src.$length) >> 0; } - s = leadingZeros(v); - v = (y = (s), y < 32 ? (v << y) : 0) >>> 0; - vn1 = v >>> 16 >>> 0; - vn0 = (v & 65535) >>> 0; - un32 = (((y$1 = s, y$1 < 32 ? (u1 << y$1) : 0) >>> 0) | ((y$2 = ((32 - s >>> 0)), y$2 < 32 ? (u0 >>> y$2) : 0) >>> 0)) >>> 0; - un10 = (y$3 = s, y$3 < 32 ? (u0 << y$3) : 0) >>> 0; - un1 = un10 >>> 16 >>> 0; - un0 = (un10 & 65535) >>> 0; - q1 = (_q = un32 / vn1, (_q === _q && _q !== 1/0 && _q !== -1/0) ? _q >>> 0 : $throwRuntimeError("integer divide by zero")); - rhat = un32 - ((((q1 >>> 16 << 16) * vn1 >>> 0) + (q1 << 16 >>> 16) * vn1) >>> 0) >>> 0; - while (q1 >= 65536 || ((((q1 >>> 16 << 16) * vn0 >>> 0) + (q1 << 16 >>> 16) * vn0) >>> 0) > (((((65536 >>> 16 << 16) * rhat >>> 0) + (65536 << 16 >>> 16) * rhat) >>> 0) + un1 >>> 0)) { - q1 = q1 - (1) >>> 0; - rhat = rhat + (vn1) >>> 0; - if (rhat >= 65536) { - break; + b.write0($subslice(src, 0, n)); + }; + Writer.prototype.writeN = function(src, n) { return this.$val.writeN(src, n); }; + Writer.Ptr.prototype.writePadding = function(textw, cellw, useTabs) { + var b, x, _q, x$1, n, _q$1; + b = this; + if ((b.padbytes[0] === 9) || useTabs) { + if (b.tabwidth === 0) { + return; } - } - un21 = (((((un32 >>> 16 << 16) * 65536 >>> 0) + (un32 << 16 >>> 16) * 65536) >>> 0) + un1 >>> 0) - ((((q1 >>> 16 << 16) * v >>> 0) + (q1 << 16 >>> 16) * v) >>> 0) >>> 0; - q0 = (_q$1 = un21 / vn1, (_q$1 === _q$1 && _q$1 !== 1/0 && _q$1 !== -1/0) ? _q$1 >>> 0 : $throwRuntimeError("integer divide by zero")); - rhat = un21 - ((((q0 >>> 16 << 16) * vn1 >>> 0) + (q0 << 16 >>> 16) * vn1) >>> 0) >>> 0; - while (q0 >= 65536 || ((((q0 >>> 16 << 16) * vn0 >>> 0) + (q0 << 16 >>> 16) * vn0) >>> 0) > (((((65536 >>> 16 << 16) * rhat >>> 0) + (65536 << 16 >>> 16) * rhat) >>> 0) + un0 >>> 0)) { - q0 = q0 - (1) >>> 0; - rhat = rhat + (vn1) >>> 0; - if (rhat >= 65536) { - break; + cellw = (x = (_q = (((cellw + b.tabwidth >> 0) - 1 >> 0)) / b.tabwidth, (_q === _q && _q !== 1/0 && _q !== -1/0) ? _q >> 0 : $throwRuntimeError("integer divide by zero")), x$1 = b.tabwidth, (((x >>> 16 << 16) * x$1 >> 0) + (x << 16 >>> 16) * x$1) >> 0); + n = cellw - textw >> 0; + if (n < 0) { + $panic(new $String("internal error")); } + b.writeN(tabs, (_q$1 = (((n + b.tabwidth >> 0) - 1 >> 0)) / b.tabwidth, (_q$1 === _q$1 && _q$1 !== 1/0 && _q$1 !== -1/0) ? _q$1 >> 0 : $throwRuntimeError("integer divide by zero"))); + return; } - _tmp$2 = ((((q1 >>> 16 << 16) * 65536 >>> 0) + (q1 << 16 >>> 16) * 65536) >>> 0) + q0 >>> 0; _tmp$3 = (y$4 = s, y$4 < 32 ? ((((((((un21 >>> 16 << 16) * 65536 >>> 0) + (un21 << 16 >>> 16) * 65536) >>> 0) + un0 >>> 0) - ((((q0 >>> 16 << 16) * v >>> 0) + (q0 << 16 >>> 16) * v) >>> 0) >>> 0)) >>> y$4) : 0) >>> 0; q = _tmp$2; r = _tmp$3; - return [q, r]; + b.writeN($subslice(new ($sliceType($Uint8))(b.padbytes), 0), cellw - textw >> 0); }; - addVV_g = function(z, x, y) { - var c = 0, _ref, _i, i, _tuple; - _ref = z; - _i = 0; - while (_i < _ref.$length) { - i = _i; - _tuple = addWW_g(((i < 0 || i >= x.$length) ? $throwRuntimeError("index out of range") : x.$array[x.$offset + i]), ((i < 0 || i >= y.$length) ? $throwRuntimeError("index out of range") : y.$array[y.$offset + i]), c); c = _tuple[0]; (i < 0 || i >= z.$length) ? $throwRuntimeError("index out of range") : z.$array[z.$offset + i] = _tuple[1]; - _i++; + Writer.prototype.writePadding = function(textw, cellw, useTabs) { return this.$val.writePadding(textw, cellw, useTabs); }; + Writer.Ptr.prototype.writeLines = function(pos0, line0, line1) { + var pos = 0, b, i, x, line, useTabs, _ref, _i, j, c, x$1, x$2, x$3; + b = this; + pos = pos0; + i = line0; + while (i < line1) { + line = (x = b.lines, ((i < 0 || i >= x.$length) ? $throwRuntimeError("index out of range") : x.$array[x.$offset + i])); + useTabs = !((((b.flags & 16) >>> 0) === 0)); + _ref = line; + _i = 0; + while (_i < _ref.$length) { + j = _i; + c = new cell.Ptr(); $copy(c, ((_i < 0 || _i >= _ref.$length) ? $throwRuntimeError("index out of range") : _ref.$array[_ref.$offset + _i]), cell); + if (j > 0 && !((((b.flags & 32) >>> 0) === 0))) { + b.write0(vbar); + } + if (c.size === 0) { + if (j < b.widths.$length) { + b.writePadding(c.width, (x$1 = b.widths, ((j < 0 || j >= x$1.$length) ? $throwRuntimeError("index out of range") : x$1.$array[x$1.$offset + j])), useTabs); + } + } else { + useTabs = false; + if (((b.flags & 4) >>> 0) === 0) { + b.write0($subslice(b.buf.Bytes(), pos, (pos + c.size >> 0))); + pos = pos + (c.size) >> 0; + if (j < b.widths.$length) { + b.writePadding(c.width, (x$2 = b.widths, ((j < 0 || j >= x$2.$length) ? $throwRuntimeError("index out of range") : x$2.$array[x$2.$offset + j])), false); + } + } else { + if (j < b.widths.$length) { + b.writePadding(c.width, (x$3 = b.widths, ((j < 0 || j >= x$3.$length) ? $throwRuntimeError("index out of range") : x$3.$array[x$3.$offset + j])), false); + } + b.write0($subslice(b.buf.Bytes(), pos, (pos + c.size >> 0))); + pos = pos + (c.size) >> 0; + } + } + _i++; + } + if ((i + 1 >> 0) === b.lines.$length) { + b.write0($subslice(b.buf.Bytes(), pos, (pos + b.cell.size >> 0))); + pos = pos + (b.cell.size) >> 0; + } else { + b.write0(newline); + } + i = i + (1) >> 0; } - return c; + return pos; }; - subVV_g = function(z, x, y) { - var c = 0, _ref, _i, i, _tuple; - _ref = z; - _i = 0; - while (_i < _ref.$length) { - i = _i; - _tuple = subWW_g(((i < 0 || i >= x.$length) ? $throwRuntimeError("index out of range") : x.$array[x.$offset + i]), ((i < 0 || i >= y.$length) ? $throwRuntimeError("index out of range") : y.$array[y.$offset + i]), c); c = _tuple[0]; (i < 0 || i >= z.$length) ? $throwRuntimeError("index out of range") : z.$array[z.$offset + i] = _tuple[1]; - _i++; + Writer.prototype.writeLines = function(pos0, line0, line1) { return this.$val.writeLines(pos0, line0, line1); }; + Writer.Ptr.prototype.format = function(pos0, line0, line1) { + var pos = 0, b, column, this$1, x, line, width, discardable, x$1, c, w; + b = this; + pos = pos0; + column = b.widths.$length; + this$1 = line0; + while (this$1 < line1) { + line = (x = b.lines, ((this$1 < 0 || this$1 >= x.$length) ? $throwRuntimeError("index out of range") : x.$array[x.$offset + this$1])); + if (column < (line.$length - 1 >> 0)) { + pos = b.writeLines(pos, line0, this$1); + line0 = this$1; + width = b.minwidth; + discardable = true; + while (this$1 < line1) { + line = (x$1 = b.lines, ((this$1 < 0 || this$1 >= x$1.$length) ? $throwRuntimeError("index out of range") : x$1.$array[x$1.$offset + this$1])); + if (column < (line.$length - 1 >> 0)) { + c = new cell.Ptr(); $copy(c, ((column < 0 || column >= line.$length) ? $throwRuntimeError("index out of range") : line.$array[line.$offset + column]), cell); + w = c.width + b.padding >> 0; + if (w > width) { + width = w; + } + if (c.width > 0 || c.htab) { + discardable = false; + } + } else { + break; + } + this$1 = this$1 + (1) >> 0; + } + if (discardable && !((((b.flags & 8) >>> 0) === 0))) { + width = 0; + } + b.widths = $append(b.widths, width); + pos = b.format(pos, line0, this$1); + b.widths = $subslice(b.widths, 0, (b.widths.$length - 1 >> 0)); + line0 = this$1; + } + this$1 = this$1 + (1) >> 0; } - return c; + pos = b.writeLines(pos, line0, line1); + return pos; }; - addVW_g = function(z, x, y) { - var c = 0, _ref, _i, i, _tuple; - c = y; - _ref = z; - _i = 0; - while (_i < _ref.$length) { - i = _i; - _tuple = addWW_g(((i < 0 || i >= x.$length) ? $throwRuntimeError("index out of range") : x.$array[x.$offset + i]), c, 0); c = _tuple[0]; (i < 0 || i >= z.$length) ? $throwRuntimeError("index out of range") : z.$array[z.$offset + i] = _tuple[1]; - _i++; - } - return c; + Writer.prototype.format = function(pos0, line0, line1) { return this.$val.format(pos0, line0, line1); }; + Writer.Ptr.prototype.append = function(text) { + var b; + b = this; + b.buf.Write(text); + b.cell.size = b.cell.size + (text.$length) >> 0; }; - subVW_g = function(z, x, y) { - var c = 0, _ref, _i, i, _tuple; - c = y; - _ref = z; - _i = 0; - while (_i < _ref.$length) { - i = _i; - _tuple = subWW_g(((i < 0 || i >= x.$length) ? $throwRuntimeError("index out of range") : x.$array[x.$offset + i]), c, 0); c = _tuple[0]; (i < 0 || i >= z.$length) ? $throwRuntimeError("index out of range") : z.$array[z.$offset + i] = _tuple[1]; - _i++; - } - return c; + Writer.prototype.append = function(text) { return this.$val.append(text); }; + Writer.Ptr.prototype.updateWidth = function() { + var b; + b = this; + b.cell.width = b.cell.width + (utf8.RuneCount($subslice(b.buf.Bytes(), b.pos, b.buf.Len()))) >> 0; + b.pos = b.buf.Len(); }; - shlVU_g = function(z, x, s) { - var c = 0, n, nonAsciiName, x$1, w1, y, i, w, x$2, y$1, y$2, y$3; - n = z.$length; - if (n > 0) { - nonAsciiName = 32 - s >>> 0; - w1 = (x$1 = n - 1 >> 0, ((x$1 < 0 || x$1 >= x.$length) ? $throwRuntimeError("index out of range") : x.$array[x.$offset + x$1])); - c = (y = nonAsciiName, y < 32 ? (w1 >>> y) : 0) >>> 0; - i = n - 1 >> 0; - while (i > 0) { - w = w1; - w1 = (x$2 = i - 1 >> 0, ((x$2 < 0 || x$2 >= x.$length) ? $throwRuntimeError("index out of range") : x.$array[x.$offset + x$2])); - (i < 0 || i >= z.$length) ? $throwRuntimeError("index out of range") : z.$array[z.$offset + i] = (((y$1 = s, y$1 < 32 ? (w << y$1) : 0) >>> 0) | ((y$2 = nonAsciiName, y$2 < 32 ? (w1 >>> y$2) : 0) >>> 0)) >>> 0; - i = i - (1) >> 0; - } - (0 < 0 || 0 >= z.$length) ? $throwRuntimeError("index out of range") : z.$array[z.$offset + 0] = (y$3 = s, y$3 < 32 ? (w1 << y$3) : 0) >>> 0; + Writer.prototype.updateWidth = function() { return this.$val.updateWidth(); }; + Writer.Ptr.prototype.startEscape = function(ch) { + var b, _ref; + b = this; + _ref = ch; + if (_ref === 255) { + b.endChar = 255; + } else if (_ref === 60) { + b.endChar = 62; + } else if (_ref === 38) { + b.endChar = 59; } - return c; }; - shrVU_g = function(z, x, s) { - var c = 0, n, nonAsciiName, w1, y, i, w, x$1, y$1, y$2, y$3, x$2; - n = z.$length; - if (n > 0) { - nonAsciiName = 32 - s >>> 0; - w1 = ((0 < 0 || 0 >= x.$length) ? $throwRuntimeError("index out of range") : x.$array[x.$offset + 0]); - c = (y = nonAsciiName, y < 32 ? (w1 << y) : 0) >>> 0; - i = 0; - while (i < (n - 1 >> 0)) { - w = w1; - w1 = (x$1 = i + 1 >> 0, ((x$1 < 0 || x$1 >= x.$length) ? $throwRuntimeError("index out of range") : x.$array[x.$offset + x$1])); - (i < 0 || i >= z.$length) ? $throwRuntimeError("index out of range") : z.$array[z.$offset + i] = (((y$1 = s, y$1 < 32 ? (w >>> y$1) : 0) >>> 0) | ((y$2 = nonAsciiName, y$2 < 32 ? (w1 << y$2) : 0) >>> 0)) >>> 0; - i = i + (1) >> 0; + Writer.prototype.startEscape = function(ch) { return this.$val.startEscape(ch); }; + Writer.Ptr.prototype.endEscape = function() { + var b, _ref; + b = this; + _ref = b.endChar; + if (_ref === 255) { + b.updateWidth(); + if (((b.flags & 2) >>> 0) === 0) { + b.cell.width = b.cell.width - (2) >> 0; } - (x$2 = n - 1 >> 0, (x$2 < 0 || x$2 >= z.$length) ? $throwRuntimeError("index out of range") : z.$array[z.$offset + x$2] = (y$3 = s, y$3 < 32 ? (w1 >>> y$3) : 0) >>> 0); - } - return c; - }; - mulAddVWW_g = function(z, x, y, r) { - var c = 0, _ref, _i, i, _tuple; - c = r; - _ref = z; - _i = 0; - while (_i < _ref.$length) { - i = _i; - _tuple = mulAddWWW_g(((i < 0 || i >= x.$length) ? $throwRuntimeError("index out of range") : x.$array[x.$offset + i]), y, c); c = _tuple[0]; (i < 0 || i >= z.$length) ? $throwRuntimeError("index out of range") : z.$array[z.$offset + i] = _tuple[1]; - _i++; + } else if (_ref === 62) { + } else if (_ref === 59) { + b.cell.width = b.cell.width + (1) >> 0; } - return c; + b.pos = b.buf.Len(); + b.endChar = 0; }; - addMulVVW_g = function(z, x, y) { - var c = 0, _ref, _i, i, _tuple, z1, z0, _tuple$1; - _ref = z; + Writer.prototype.endEscape = function() { return this.$val.endEscape(); }; + Writer.Ptr.prototype.terminateCell = function(htab) { + var b, x, x$1, line; + b = this; + b.cell.htab = htab; + line = new ($ptrType(($sliceType(cell))))(function() { return (x$1 = b.lines.$length - 1 >> 0, ((x$1 < 0 || x$1 >= this.$target.$length) ? $throwRuntimeError("index out of range") : this.$target.$array[this.$target.$offset + x$1])); }, function($v) { (x = b.lines.$length - 1 >> 0, (x < 0 || x >= this.$target.$length) ? $throwRuntimeError("index out of range") : this.$target.$array[this.$target.$offset + x] = $v); }, b.lines); + line.$set($append(line.$get(), b.cell)); + $copy(b.cell, new cell.Ptr(0, 0, false), cell); + return line.$get().$length; + }; + Writer.prototype.terminateCell = function(htab) { return this.$val.terminateCell(htab); }; + handlePanic = function(err, op) { + var e, _tuple, nerr, ok; + e = $recover(); + if (!($interfaceIsEqual(e, $ifaceNil))) { + _tuple = $assertType(e, osError, true); nerr = new osError.Ptr(); $copy(nerr, _tuple[0], osError); ok = _tuple[1]; + if (ok) { + err.$set(nerr.err); + return; + } + $panic(new $String("tabwriter: panic during " + op)); + } + }; + Writer.Ptr.prototype.Flush = function() { + var err = $ifaceNil, $deferred = [], $err = null, b; + /* */ try { $deferFrames.push($deferred); + b = this; + $deferred.push([$methodVal(b, "reset"), []]); + $deferred.push([handlePanic, [new ($ptrType($error))(function() { return err; }, function($v) { err = $v; }), "Flush"]]); + if (b.cell.size > 0) { + if (!((b.endChar === 0))) { + b.endEscape(); + } + b.terminateCell(false); + } + b.format(0, 0, b.lines.$length); + return err; + /* */ } catch(err) { $err = err; } finally { $deferFrames.pop(); $callDeferred($deferred, $err); return err; } + }; + Writer.prototype.Flush = function() { return this.$val.Flush(); }; + Writer.Ptr.prototype.Write = function(buf) { + var n = 0, err = $ifaceNil, $deferred = [], $err = null, b, _ref, _i, i, ch, _ref$1, ncells, j; + /* */ try { $deferFrames.push($deferred); + b = this; + $deferred.push([handlePanic, [new ($ptrType($error))(function() { return err; }, function($v) { err = $v; }), "Write"]]); + n = 0; + _ref = buf; _i = 0; while (_i < _ref.$length) { i = _i; - _tuple = mulAddWWW_g(((i < 0 || i >= x.$length) ? $throwRuntimeError("index out of range") : x.$array[x.$offset + i]), y, ((i < 0 || i >= z.$length) ? $throwRuntimeError("index out of range") : z.$array[z.$offset + i])); z1 = _tuple[0]; z0 = _tuple[1]; - _tuple$1 = addWW_g(z0, c, 0); c = _tuple$1[0]; (i < 0 || i >= z.$length) ? $throwRuntimeError("index out of range") : z.$array[z.$offset + i] = _tuple$1[1]; - c = c + (z1) >>> 0; + ch = ((_i < 0 || _i >= _ref.$length) ? $throwRuntimeError("index out of range") : _ref.$array[_ref.$offset + _i]); + if (b.endChar === 0) { + _ref$1 = ch; + if (_ref$1 === 9 || _ref$1 === 11 || _ref$1 === 10 || _ref$1 === 12) { + b.append($subslice(buf, n, i)); + b.updateWidth(); + n = i + 1 >> 0; + ncells = b.terminateCell(ch === 9); + if ((ch === 10) || (ch === 12)) { + b.addLine(); + if ((ch === 12) || (ncells === 1)) { + err = b.Flush(); + if (!($interfaceIsEqual(err, $ifaceNil))) { + return [n, err]; + } + if ((ch === 12) && !((((b.flags & 32) >>> 0) === 0))) { + b.write0(hbar); + } + } + } + } else if (_ref$1 === 255) { + b.append($subslice(buf, n, i)); + b.updateWidth(); + n = i; + if (!((((b.flags & 2) >>> 0) === 0))) { + n = n + (1) >> 0; + } + b.startEscape(255); + } else if (_ref$1 === 60 || _ref$1 === 38) { + if (!((((b.flags & 1) >>> 0) === 0))) { + b.append($subslice(buf, n, i)); + b.updateWidth(); + n = i; + b.startEscape(ch); + } + } + } else { + if (ch === b.endChar) { + j = i + 1 >> 0; + if ((ch === 255) && !((((b.flags & 2) >>> 0) === 0))) { + j = i; + } + b.append($subslice(buf, n, j)); + n = i + 1 >> 0; + b.endEscape(); + } + } _i++; } - return c; + b.append($subslice(buf, n)); + n = buf.$length; + return [n, err]; + /* */ } catch(err) { $err = err; } finally { $deferFrames.pop(); $callDeferred($deferred, $err); return [n, err]; } }; - divWVW_g = function(z, xn, x, y) { - var r = 0, i, _tuple; - r = xn; - i = z.$length - 1 >> 0; - while (i >= 0) { - _tuple = divWW_g(r, ((i < 0 || i >= x.$length) ? $throwRuntimeError("index out of range") : x.$array[x.$offset + i]), y); (i < 0 || i >= z.$length) ? $throwRuntimeError("index out of range") : z.$array[z.$offset + i] = _tuple[0]; r = _tuple[1]; - i = i - (1) >> 0; + Writer.prototype.Write = function(buf) { return this.$val.Write(buf); }; + NewWriter = $pkg.NewWriter = function(output, minwidth, tabwidth, padding, padchar, flags) { + return new Writer.Ptr().Init(output, minwidth, tabwidth, padding, padchar, flags); + }; + $pkg.$init = function() { + cell.init([["size", "size", "text/tabwriter", $Int, ""], ["width", "width", "text/tabwriter", $Int, ""], ["htab", "htab", "text/tabwriter", $Bool, ""]]); + ($ptrType(Writer)).methods = [["Flush", "Flush", "", $funcType([], [$error], false), -1], ["Init", "Init", "", $funcType([io.Writer, $Int, $Int, $Int, $Uint8, $Uint], [($ptrType(Writer))], false), -1], ["Write", "Write", "", $funcType([($sliceType($Uint8))], [$Int, $error], false), -1], ["addLine", "addLine", "text/tabwriter", $funcType([], [], false), -1], ["append", "append", "text/tabwriter", $funcType([($sliceType($Uint8))], [], false), -1], ["dump", "dump", "text/tabwriter", $funcType([], [], false), -1], ["endEscape", "endEscape", "text/tabwriter", $funcType([], [], false), -1], ["format", "format", "text/tabwriter", $funcType([$Int, $Int, $Int], [$Int], false), -1], ["reset", "reset", "text/tabwriter", $funcType([], [], false), -1], ["startEscape", "startEscape", "text/tabwriter", $funcType([$Uint8], [], false), -1], ["terminateCell", "terminateCell", "text/tabwriter", $funcType([$Bool], [$Int], false), -1], ["updateWidth", "updateWidth", "text/tabwriter", $funcType([], [], false), -1], ["write0", "write0", "text/tabwriter", $funcType([($sliceType($Uint8))], [], false), -1], ["writeLines", "writeLines", "text/tabwriter", $funcType([$Int, $Int, $Int], [$Int], false), -1], ["writeN", "writeN", "text/tabwriter", $funcType([($sliceType($Uint8)), $Int], [], false), -1], ["writePadding", "writePadding", "text/tabwriter", $funcType([$Int, $Int, $Bool], [], false), -1]]; + Writer.init([["output", "output", "text/tabwriter", io.Writer, ""], ["minwidth", "minwidth", "text/tabwriter", $Int, ""], ["tabwidth", "tabwidth", "text/tabwriter", $Int, ""], ["padding", "padding", "text/tabwriter", $Int, ""], ["padbytes", "padbytes", "text/tabwriter", ($arrayType($Uint8, 8)), ""], ["flags", "flags", "text/tabwriter", $Uint, ""], ["buf", "buf", "text/tabwriter", bytes.Buffer, ""], ["pos", "pos", "text/tabwriter", $Int, ""], ["cell", "cell", "text/tabwriter", cell, ""], ["endChar", "endChar", "text/tabwriter", $Uint8, ""], ["lines", "lines", "text/tabwriter", ($sliceType(($sliceType(cell)))), ""], ["widths", "widths", "text/tabwriter", ($sliceType($Int)), ""]]); + osError.init([["err", "err", "text/tabwriter", $error, ""]]); + newline = new ($sliceType($Uint8))([10]); + tabs = new ($sliceType($Uint8))($stringToBytes("\t\t\t\t\t\t\t\t")); + vbar = new ($sliceType($Uint8))([124]); + hbar = new ($sliceType($Uint8))($stringToBytes("---\n")); + }; + return $pkg; +})(); +$packages["runtime/pprof"] = (function() { + var $pkg = {}, bufio = $packages["bufio"], bytes = $packages["bytes"], fmt = $packages["fmt"], io = $packages["io"], runtime = $packages["runtime"], sort = $packages["sort"], strings = $packages["strings"], sync = $packages["sync"], tabwriter = $packages["text/tabwriter"]; + $pkg.$init = function() { + }; + return $pkg; +})(); +$packages["testing"] = (function() { + var $pkg = {}, flag = $packages["flag"], fmt = $packages["fmt"], os = $packages["os"], runtime = $packages["runtime"], time = $packages["time"], sync = $packages["sync"], atomic = $packages["sync/atomic"], bytes = $packages["bytes"], io = $packages["io"], strings = $packages["strings"], pprof = $packages["runtime/pprof"], strconv = $packages["strconv"], InternalBenchmark, B, BenchmarkResult, PB, InternalExample, common, T, InternalTest, matchBenchmarks, benchTime, benchmarkMemory, memStats, short$1, outputDir, chatty, coverProfile, match, memProfile, memProfileRate, cpuProfile, blockProfile, blockProfileRate, timeout, cpuListStr, parallel, init, Main, decorate; + InternalBenchmark = $pkg.InternalBenchmark = $newType(0, "Struct", "testing.InternalBenchmark", "InternalBenchmark", "testing", function(Name_, F_) { + this.$val = this; + this.Name = Name_ !== undefined ? Name_ : ""; + this.F = F_ !== undefined ? F_ : $throwNilPointerError; + }); + B = $pkg.B = $newType(0, "Struct", "testing.B", "B", "testing", function(common_, N_, previousN_, previousDuration_, benchmark_, bytes_, timerOn_, showAllocResult_, result_, parallelism_, startAllocs_, startBytes_, netAllocs_, netBytes_) { + this.$val = this; + this.common = common_ !== undefined ? common_ : new common.Ptr(); + this.N = N_ !== undefined ? N_ : 0; + this.previousN = previousN_ !== undefined ? previousN_ : 0; + this.previousDuration = previousDuration_ !== undefined ? previousDuration_ : new time.Duration(0, 0); + this.benchmark = benchmark_ !== undefined ? benchmark_ : new InternalBenchmark.Ptr(); + this.bytes = bytes_ !== undefined ? bytes_ : new $Int64(0, 0); + this.timerOn = timerOn_ !== undefined ? timerOn_ : false; + this.showAllocResult = showAllocResult_ !== undefined ? showAllocResult_ : false; + this.result = result_ !== undefined ? result_ : new BenchmarkResult.Ptr(); + this.parallelism = parallelism_ !== undefined ? parallelism_ : 0; + this.startAllocs = startAllocs_ !== undefined ? startAllocs_ : new $Uint64(0, 0); + this.startBytes = startBytes_ !== undefined ? startBytes_ : new $Uint64(0, 0); + this.netAllocs = netAllocs_ !== undefined ? netAllocs_ : new $Uint64(0, 0); + this.netBytes = netBytes_ !== undefined ? netBytes_ : new $Uint64(0, 0); + }); + BenchmarkResult = $pkg.BenchmarkResult = $newType(0, "Struct", "testing.BenchmarkResult", "BenchmarkResult", "testing", function(N_, T_, Bytes_, MemAllocs_, MemBytes_) { + this.$val = this; + this.N = N_ !== undefined ? N_ : 0; + this.T = T_ !== undefined ? T_ : new time.Duration(0, 0); + this.Bytes = Bytes_ !== undefined ? Bytes_ : new $Int64(0, 0); + this.MemAllocs = MemAllocs_ !== undefined ? MemAllocs_ : new $Uint64(0, 0); + this.MemBytes = MemBytes_ !== undefined ? MemBytes_ : new $Uint64(0, 0); + }); + PB = $pkg.PB = $newType(0, "Struct", "testing.PB", "PB", "testing", function(globalN_, grain_, cache_, bN_) { + this.$val = this; + this.globalN = globalN_ !== undefined ? globalN_ : ($ptrType($Uint64)).nil; + this.grain = grain_ !== undefined ? grain_ : new $Uint64(0, 0); + this.cache = cache_ !== undefined ? cache_ : new $Uint64(0, 0); + this.bN = bN_ !== undefined ? bN_ : new $Uint64(0, 0); + }); + InternalExample = $pkg.InternalExample = $newType(0, "Struct", "testing.InternalExample", "InternalExample", "testing", function(Name_, F_, Output_) { + this.$val = this; + this.Name = Name_ !== undefined ? Name_ : ""; + this.F = F_ !== undefined ? F_ : $throwNilPointerError; + this.Output = Output_ !== undefined ? Output_ : ""; + }); + common = $pkg.common = $newType(0, "Struct", "testing.common", "common", "testing", function(mu_, output_, failed_, skipped_, finished_, start_, duration_, self_, signal_) { + this.$val = this; + this.mu = mu_ !== undefined ? mu_ : new sync.RWMutex.Ptr(); + this.output = output_ !== undefined ? output_ : ($sliceType($Uint8)).nil; + this.failed = failed_ !== undefined ? failed_ : false; + this.skipped = skipped_ !== undefined ? skipped_ : false; + this.finished = finished_ !== undefined ? finished_ : false; + this.start = start_ !== undefined ? start_ : new time.Time.Ptr(); + this.duration = duration_ !== undefined ? duration_ : new time.Duration(0, 0); + this.self = self_ !== undefined ? self_ : $ifaceNil; + this.signal = signal_ !== undefined ? signal_ : ($chanType($emptyInterface, false, false)).nil; + }); + T = $pkg.T = $newType(0, "Struct", "testing.T", "T", "testing", function(common_, name_, startParallel_) { + this.$val = this; + this.common = common_ !== undefined ? common_ : new common.Ptr(); + this.name = name_ !== undefined ? name_ : ""; + this.startParallel = startParallel_ !== undefined ? startParallel_ : ($chanType($Bool, false, false)).nil; + }); + InternalTest = $pkg.InternalTest = $newType(0, "Struct", "testing.InternalTest", "InternalTest", "testing", function(Name_, F_) { + this.$val = this; + this.Name = Name_ !== undefined ? Name_ : ""; + this.F = F_ !== undefined ? F_ : $throwNilPointerError; + }); + init = function($b) { + var $this = this, $args = arguments, $r, $s = 0, x; + /* */ if(!$b) { $nonblockingCall(); }; var $f = function() { while (true) { switch ($s) { case 0: + x = false; + /* if (x) { */ if (x) {} else { $s = 1; continue; } + $r = Main($throwNilPointerError, ($sliceType(InternalTest)).nil, ($sliceType(InternalBenchmark)).nil, ($sliceType(InternalExample)).nil, true); /* */ $s = 2; case 2: if ($r && $r.$blocking) { $r = $r(); } + /* } */ case 1: + /* */ case -1: } return; } }; $f.$blocking = true; return $f; + }; + Main = $pkg.Main = function(matchString, tests, benchmarks, examples, $b) { + var $this = this, $args = arguments, $r, $s = 0, failed, _ref, _i, done, t, err, test, _r, _tuple, e, ok; + /* */ if(!$b) { $nonblockingCall(); }; var $f = function() { while (true) { switch ($s) { case 0: + flag.Parse(); + if (tests.$length === 0) { + fmt.Println(new ($sliceType($emptyInterface))([new $String("testing: warning: no tests to run")])); } - return r; + failed = false; + _ref = tests; + _i = 0; + /* while (_i < _ref.$length) { */ case 1: if(!(_i < _ref.$length)) { $s = 2; continue; } + done = [undefined]; + t = [undefined]; + err = [undefined]; + test = new InternalTest.Ptr(); $copy(test, ((_i < 0 || _i >= _ref.$length) ? $throwRuntimeError("index out of range") : _ref.$array[_ref.$offset + _i]), InternalTest); + t[0] = new T.Ptr(new common.Ptr(new sync.RWMutex.Ptr(), ($sliceType($Uint8)).nil, false, false, false, time.Now(), new time.Duration(0, 0), $ifaceNil, ($chanType($emptyInterface, false, false)).nil), test.Name, ($chanType($Bool, false, false)).nil); + t[0].common.self = t[0]; + if (chatty.$get()) { + fmt.Printf("=== RUN %s\n", new ($sliceType($emptyInterface))([new $String(t[0].name)])); + } + done[0] = new ($chanType(($structType([])), false, false))(0); + err[0] = $ifaceNil; + $go((function(done, err, t) { return function($b) { + var $this = this, $args = arguments, $r, $deferred = [], $err = null, $s = 0; + /* */ if(!$b) { $nonblockingCall(); }; var $f = function() { try { $deferFrames.push($deferred); while (true) { switch ($s) { case 0: + $deferred.push([(function(done, err, t) { return function() { + err[0] = $recover(); + $close(done[0]); + }; })(done, err, t), [true]]); + $r = test.F(t[0], true); /* */ $s = 1; case 1: if ($r && $r.$blocking) { $r = $r(); } + /* */ case -1: } return; } } catch(err) { $err = err; } finally { $deferFrames.pop(); if ($curGoroutine.asleep && !$jumpToDefer) { throw null; } $s = -1; $callDeferred($deferred, $err); } }; $f.$blocking = true; return $f; + }; })(done, err, t), []); + _r = $recv(done[0], true); /* */ $s = 3; case 3: if (_r && _r.$blocking) { _r = _r(); } + _r[0]; + t[0].common.duration = time.Now().Sub($clone(t[0].common.start, time.Time)); + _tuple = $assertType(err[0], ($ptrType(runtime.NotSupportedError)), true); e = _tuple[0]; ok = _tuple[1]; + if (ok) { + t[0].common.log(e.Error()); + t[0].common.skip(); + err[0] = $ifaceNil; + } + if (!($interfaceIsEqual(err[0], $ifaceNil))) { + t[0].common.Fail(); + } + t[0].report(); + if (!($interfaceIsEqual(err[0], $ifaceNil))) { + $panic(err[0]); + } + failed = failed || t[0].common.failed; + _i++; + /* } */ $s = 1; continue; case 2: + if (failed) { + os.Exit(1); + } + os.Exit(0); + /* */ case -1: } return; } }; $f.$blocking = true; return $f; }; - Int.Ptr.prototype.Sign = function() { - var x; - x = this; - if (x.abs.$length === 0) { - return 0; + B.Ptr.prototype.StartTimer = function() { + var b; + b = this; + if (!b.timerOn) { + runtime.ReadMemStats(memStats); + b.startAllocs = memStats.Mallocs; + b.startBytes = memStats.TotalAlloc; + $copy(b.common.start, time.Now(), time.Time); + b.timerOn = true; } - if (x.neg) { - return -1; + }; + B.prototype.StartTimer = function() { return this.$val.StartTimer(); }; + B.Ptr.prototype.StopTimer = function() { + var b, x, x$1, x$2, x$3, x$4, x$5, x$6, x$7, x$8, x$9; + b = this; + if (b.timerOn) { + b.common.duration = (x = b.common.duration, x$1 = time.Now().Sub($clone(b.common.start, time.Time)), new time.Duration(x.$high + x$1.$high, x.$low + x$1.$low)); + runtime.ReadMemStats(memStats); + b.netAllocs = (x$2 = b.netAllocs, x$3 = (x$4 = memStats.Mallocs, x$5 = b.startAllocs, new $Uint64(x$4.$high - x$5.$high, x$4.$low - x$5.$low)), new $Uint64(x$2.$high + x$3.$high, x$2.$low + x$3.$low)); + b.netBytes = (x$6 = b.netBytes, x$7 = (x$8 = memStats.TotalAlloc, x$9 = b.startBytes, new $Uint64(x$8.$high - x$9.$high, x$8.$low - x$9.$low)), new $Uint64(x$6.$high + x$7.$high, x$6.$low + x$7.$low)); + b.timerOn = false; } - return 1; }; - Int.prototype.Sign = function() { return this.$val.Sign(); }; - Int.Ptr.prototype.SetInt64 = function(x) { - var z, neg; - z = this; - neg = false; - if ((x.$high < 0 || (x.$high === 0 && x.$low < 0))) { - neg = true; - x = new $Int64(-x.$high, -x.$low); + B.prototype.StopTimer = function() { return this.$val.StopTimer(); }; + B.Ptr.prototype.ResetTimer = function() { + var b; + b = this; + if (b.timerOn) { + runtime.ReadMemStats(memStats); + b.startAllocs = memStats.Mallocs; + b.startBytes = memStats.TotalAlloc; + $copy(b.common.start, time.Now(), time.Time); } - z.abs = z.abs.setUint64(new $Uint64(x.$high, x.$low)); - z.neg = neg; - return z; + b.common.duration = new time.Duration(0, 0); + b.netAllocs = new $Uint64(0, 0); + b.netBytes = new $Uint64(0, 0); }; - Int.prototype.SetInt64 = function(x) { return this.$val.SetInt64(x); }; - Int.Ptr.prototype.SetUint64 = function(x) { - var z; - z = this; - z.abs = z.abs.setUint64(x); - z.neg = false; - return z; + B.prototype.ResetTimer = function() { return this.$val.ResetTimer(); }; + B.Ptr.prototype.SetBytes = function(n) { + var b; + b = this; + b.bytes = n; }; - Int.prototype.SetUint64 = function(x) { return this.$val.SetUint64(x); }; - NewInt = $pkg.NewInt = function(x) { - return new Int.Ptr().SetInt64(x); + B.prototype.SetBytes = function(n) { return this.$val.SetBytes(n); }; + B.Ptr.prototype.ReportAllocs = function() { + var b; + b = this; + b.showAllocResult = true; }; - Int.Ptr.prototype.Set = function(x) { - var z; - z = this; - if (!(z === x)) { - z.abs = z.abs.set(x.abs); - z.neg = x.neg; + B.prototype.ReportAllocs = function() { return this.$val.ReportAllocs(); }; + BenchmarkResult.Ptr.prototype.NsPerOp = function() { + var r; + r = new BenchmarkResult.Ptr(); $copy(r, this, BenchmarkResult); + if (r.N <= 0) { + return new $Int64(0, 0); } - return z; - }; - Int.prototype.Set = function(x) { return this.$val.Set(x); }; - Int.Ptr.prototype.Bits = function() { - var x, x$1; - x = this; - return (x$1 = x.abs, $subslice(new ($sliceType(Word))(x$1.$array), x$1.$offset, x$1.$offset + x$1.$length)); + return $div64(r.T.Nanoseconds(), new $Int64(0, r.N), false); }; - Int.prototype.Bits = function() { return this.$val.Bits(); }; - Int.Ptr.prototype.SetBits = function(abs) { - var z; - z = this; - z.abs = $subslice(new nat(abs.$array), abs.$offset, abs.$offset + abs.$length).norm(); - z.neg = false; - return z; + BenchmarkResult.prototype.NsPerOp = function() { return this.$val.NsPerOp(); }; + BenchmarkResult.Ptr.prototype.mbPerSec = function() { + var r, x, x$1; + r = new BenchmarkResult.Ptr(); $copy(r, this, BenchmarkResult); + if ((x = r.Bytes, (x.$high < 0 || (x.$high === 0 && x.$low <= 0))) || (x$1 = r.T, (x$1.$high < 0 || (x$1.$high === 0 && x$1.$low <= 0))) || r.N <= 0) { + return 0; + } + return ($flatten64(r.Bytes) * r.N / 1e+06) / r.T.Seconds(); }; - Int.prototype.SetBits = function(abs) { return this.$val.SetBits(abs); }; - Int.Ptr.prototype.Abs = function(x) { - var z; - z = this; - z.Set(x); - z.neg = false; - return z; + BenchmarkResult.prototype.mbPerSec = function() { return this.$val.mbPerSec(); }; + BenchmarkResult.Ptr.prototype.AllocsPerOp = function() { + var r, x; + r = new BenchmarkResult.Ptr(); $copy(r, this, BenchmarkResult); + if (r.N <= 0) { + return new $Int64(0, 0); + } + return $div64((x = r.MemAllocs, new $Int64(x.$high, x.$low)), new $Int64(0, r.N), false); }; - Int.prototype.Abs = function(x) { return this.$val.Abs(x); }; - Int.Ptr.prototype.Neg = function(x) { - var z; - z = this; - z.Set(x); - z.neg = z.abs.$length > 0 && !z.neg; - return z; + BenchmarkResult.prototype.AllocsPerOp = function() { return this.$val.AllocsPerOp(); }; + BenchmarkResult.Ptr.prototype.AllocedBytesPerOp = function() { + var r, x; + r = new BenchmarkResult.Ptr(); $copy(r, this, BenchmarkResult); + if (r.N <= 0) { + return new $Int64(0, 0); + } + return $div64((x = r.MemBytes, new $Int64(x.$high, x.$low)), new $Int64(0, r.N), false); }; - Int.prototype.Neg = function(x) { return this.$val.Neg(x); }; - Int.Ptr.prototype.Add = function(x, y) { - var z, neg; - z = this; - neg = x.neg; - if (x.neg === y.neg) { - z.abs = z.abs.add(x.abs, y.abs); - } else { - if (x.abs.cmp(y.abs) >= 0) { - z.abs = z.abs.sub(x.abs, y.abs); + BenchmarkResult.prototype.AllocedBytesPerOp = function() { return this.$val.AllocedBytesPerOp(); }; + BenchmarkResult.Ptr.prototype.String = function() { + var r, mbs, mb, nsop, ns; + r = new BenchmarkResult.Ptr(); $copy(r, this, BenchmarkResult); + mbs = r.mbPerSec(); + mb = ""; + if (!((mbs === 0))) { + mb = fmt.Sprintf("\t%7.2f MB/s", new ($sliceType($emptyInterface))([new $Float64(mbs)])); + } + nsop = r.NsPerOp(); + ns = fmt.Sprintf("%10d ns/op", new ($sliceType($emptyInterface))([nsop])); + if (r.N > 0 && (nsop.$high < 0 || (nsop.$high === 0 && nsop.$low < 100))) { + if ((nsop.$high < 0 || (nsop.$high === 0 && nsop.$low < 10))) { + ns = fmt.Sprintf("%13.2f ns/op", new ($sliceType($emptyInterface))([new $Float64($flatten64(r.T.Nanoseconds()) / r.N)])); } else { - neg = !neg; - z.abs = z.abs.sub(y.abs, x.abs); + ns = fmt.Sprintf("%12.1f ns/op", new ($sliceType($emptyInterface))([new $Float64($flatten64(r.T.Nanoseconds()) / r.N)])); } } - z.neg = z.abs.$length > 0 && neg; - return z; + return fmt.Sprintf("%8d\t%s%s", new ($sliceType($emptyInterface))([new $Int(r.N), new $String(ns), new $String(mb)])); }; - Int.prototype.Add = function(x, y) { return this.$val.Add(x, y); }; - Int.Ptr.prototype.Sub = function(x, y) { - var z, neg; - z = this; - neg = x.neg; - if (!(x.neg === y.neg)) { - z.abs = z.abs.add(x.abs, y.abs); - } else { - if (x.abs.cmp(y.abs) >= 0) { - z.abs = z.abs.sub(x.abs, y.abs); + BenchmarkResult.prototype.String = function() { return this.$val.String(); }; + BenchmarkResult.Ptr.prototype.MemString = function() { + var r; + r = new BenchmarkResult.Ptr(); $copy(r, this, BenchmarkResult); + return fmt.Sprintf("%8d B/op\t%8d allocs/op", new ($sliceType($emptyInterface))([r.AllocedBytesPerOp(), r.AllocsPerOp()])); + }; + BenchmarkResult.prototype.MemString = function() { return this.$val.MemString(); }; + PB.Ptr.prototype.Next = function() { + var pb, x, n, x$1, x$2, x$3, x$4, x$5, x$6, x$7, x$8, x$9; + pb = this; + if ((x = pb.cache, (x.$high === 0 && x.$low === 0))) { + n = atomic.AddUint64(pb.globalN, pb.grain); + if ((x$1 = pb.bN, (n.$high < x$1.$high || (n.$high === x$1.$high && n.$low <= x$1.$low)))) { + pb.cache = pb.grain; + } else if ((x$2 = (x$3 = pb.bN, x$4 = pb.grain, new $Uint64(x$3.$high + x$4.$high, x$3.$low + x$4.$low)), (n.$high < x$2.$high || (n.$high === x$2.$high && n.$low < x$2.$low)))) { + pb.cache = (x$5 = (x$6 = pb.bN, x$7 = pb.grain, new $Uint64(x$6.$high + x$7.$high, x$6.$low + x$7.$low)), new $Uint64(x$5.$high - n.$high, x$5.$low - n.$low)); } else { - neg = !neg; - z.abs = z.abs.sub(y.abs, x.abs); + return false; } } - z.neg = z.abs.$length > 0 && neg; - return z; - }; - Int.prototype.Sub = function(x, y) { return this.$val.Sub(x, y); }; - Int.Ptr.prototype.Mul = function(x, y) { - var z; - z = this; - z.abs = z.abs.mul(x.abs, y.abs); - z.neg = z.abs.$length > 0 && !(x.neg === y.neg); - return z; + pb.cache = (x$8 = pb.cache, x$9 = new $Uint64(0, 1), new $Uint64(x$8.$high - x$9.$high, x$8.$low - x$9.$low)); + return true; }; - Int.prototype.Mul = function(x, y) { return this.$val.Mul(x, y); }; - Int.Ptr.prototype.MulRange = function(a, b) { - var z, neg, x, x$1, _tmp, _tmp$1; - z = this; - if ((a.$high > b.$high || (a.$high === b.$high && a.$low > b.$low))) { - return z.SetInt64(new $Int64(0, 1)); - } else if ((a.$high < 0 || (a.$high === 0 && a.$low <= 0)) && (b.$high > 0 || (b.$high === 0 && b.$low >= 0))) { - return z.SetInt64(new $Int64(0, 0)); + PB.prototype.Next = function() { return this.$val.Next(); }; + B.Ptr.prototype.RunParallel = function(body) { + var b, grain, x, x$1, n, x$2, x$3, numProcs, wg, p, x$4; + b = this; + grain = new $Uint64(0, 0); + if (b.previousN > 0 && (x = b.previousDuration, (x.$high > 0 || (x.$high === 0 && x.$low > 0)))) { + grain = $div64($mul64(new $Uint64(0, 100000), new $Uint64(0, b.previousN)), (x$1 = b.previousDuration, new $Uint64(x$1.$high, x$1.$low)), false); } - neg = false; - if ((a.$high < 0 || (a.$high === 0 && a.$low < 0))) { - neg = (x = (x$1 = new $Int64(b.$high - a.$high, b.$low - a.$low), new $Int64(x$1.$high & 0, (x$1.$low & 1) >>> 0)), (x.$high === 0 && x.$low === 0)); - _tmp = new $Int64(-b.$high, -b.$low); _tmp$1 = new $Int64(-a.$high, -a.$low); a = _tmp; b = _tmp$1; + if ((grain.$high < 0 || (grain.$high === 0 && grain.$low < 1))) { + grain = new $Uint64(0, 1); } - z.abs = z.abs.mulRange(new $Uint64(a.$high, a.$low), new $Uint64(b.$high, b.$low)); - z.neg = neg; - return z; - }; - Int.prototype.MulRange = function(a, b) { return this.$val.MulRange(a, b); }; - Int.Ptr.prototype.Binomial = function(n, k) { - var z, _tmp, _tmp$1, a, b, x; - z = this; - _tmp = new Int.Ptr(); $copy(_tmp, new Int.Ptr(), Int); _tmp$1 = new Int.Ptr(); $copy(_tmp$1, new Int.Ptr(), Int); a = new Int.Ptr(); $copy(a, _tmp, Int); b = new Int.Ptr(); $copy(b, _tmp$1, Int); - a.MulRange((x = new $Int64(n.$high - k.$high, n.$low - k.$low), new $Int64(x.$high + 0, x.$low + 1)), n); - b.MulRange(new $Int64(0, 1), k); - return z.Quo(a, b); - }; - Int.prototype.Binomial = function(n, k) { return this.$val.Binomial(n, k); }; - Int.Ptr.prototype.Quo = function(x, y) { - var z, _tuple; - z = this; - _tuple = z.abs.div(nat.nil, x.abs, y.abs); z.abs = _tuple[0]; - z.neg = z.abs.$length > 0 && !(x.neg === y.neg); - return z; - }; - Int.prototype.Quo = function(x, y) { return this.$val.Quo(x, y); }; - Int.Ptr.prototype.Rem = function(x, y) { - var z, _tuple; - z = this; - _tuple = nat.nil.div(z.abs, x.abs, y.abs); z.abs = _tuple[1]; - z.neg = z.abs.$length > 0 && x.neg; - return z; - }; - Int.prototype.Rem = function(x, y) { return this.$val.Rem(x, y); }; - Int.Ptr.prototype.QuoRem = function(x, y, r) { - var z, _tuple, _tmp, _tmp$1; - z = this; - _tuple = z.abs.div(r.abs, x.abs, y.abs); z.abs = _tuple[0]; r.abs = _tuple[1]; - _tmp = z.abs.$length > 0 && !(x.neg === y.neg); _tmp$1 = r.abs.$length > 0 && x.neg; z.neg = _tmp; r.neg = _tmp$1; - return [z, r]; - }; - Int.prototype.QuoRem = function(x, y, r) { return this.$val.QuoRem(x, y, r); }; - Int.Ptr.prototype.Div = function(x, y) { - var z, y_neg, r; - z = this; - y_neg = y.neg; - r = new Int.Ptr(); $copy(r, new Int.Ptr(), Int); - z.QuoRem(x, y, r); - if (r.neg) { - if (y_neg) { - z.Add(z, intOne); - } else { - z.Sub(z, intOne); - } + if ((grain.$high > 0 || (grain.$high === 0 && grain.$low > 10000))) { + grain = new $Uint64(0, 10000); } - return z; - }; - Int.prototype.Div = function(x, y) { return this.$val.Div(x, y); }; - Int.Ptr.prototype.Mod = function(x, y) { - var z, y0, q; - z = this; - y0 = y; - if (z === y || alias(z.abs, y.abs)) { - y0 = new Int.Ptr().Set(y); + n = new $Uint64(0, 0); + numProcs = (x$2 = b.parallelism, x$3 = runtime.GOMAXPROCS(0), (((x$2 >>> 16 << 16) * x$3 >> 0) + (x$2 << 16 >>> 16) * x$3) >> 0); + wg = new sync.WaitGroup.Ptr(); $copy(wg, new sync.WaitGroup.Ptr(), sync.WaitGroup); + wg.Add(numProcs); + p = 0; + while (p < numProcs) { + $go((function() { + var $deferred = [], $err = null, pb; + /* */ try { $deferFrames.push($deferred); + $deferred.push([$methodVal(wg, "Done"), []]); + pb = new PB.Ptr(new ($ptrType($Uint64))(function() { return n; }, function($v) { n = $v; }), grain, new $Uint64(0, 0), new $Uint64(0, b.N)); + body(pb); + /* */ } catch(err) { $err = err; } finally { $deferFrames.pop(); $callDeferred($deferred, $err); } + }), []); + p = p + (1) >> 0; } - q = new Int.Ptr(); $copy(q, new Int.Ptr(), Int); - q.QuoRem(x, y, z); - if (z.neg) { - if (y0.neg) { - z.Sub(z, y0); - } else { - z.Add(z, y0); - } + wg.Wait(); + if ((x$4 = new $Uint64(0, b.N), (n.$high < x$4.$high || (n.$high === x$4.$high && n.$low <= x$4.$low))) && !b.common.Failed()) { + b.common.Fatal(new ($sliceType($emptyInterface))([new $String("RunParallel: body exited without pb.Next() == false")])); } - return z; }; - Int.prototype.Mod = function(x, y) { return this.$val.Mod(x, y); }; - Int.Ptr.prototype.DivMod = function(x, y, m) { - var z, y0; - z = this; - y0 = y; - if (z === y || alias(z.abs, y.abs)) { - y0 = new Int.Ptr().Set(y); + B.prototype.RunParallel = function(body) { return this.$val.RunParallel(body); }; + B.Ptr.prototype.SetParallelism = function(p) { + var b; + b = this; + if (p >= 1) { + b.parallelism = p; } - z.QuoRem(x, y, m); - if (m.neg) { - if (y0.neg) { - z.Add(z, intOne); - m.Sub(m, y0); + }; + B.prototype.SetParallelism = function(p) { return this.$val.SetParallelism(p); }; + decorate = function(s) { + var _tuple, file, line, ok, index, buf, lines, l, x, _ref, _i, i, line$1; + _tuple = runtime.Caller(3); file = _tuple[1]; line = _tuple[2]; ok = _tuple[3]; + if (ok) { + index = strings.LastIndex(file, "/"); + if (index >= 0) { + file = file.substring((index + 1 >> 0)); } else { - z.Sub(z, intOne); - m.Add(m, y0); + index = strings.LastIndex(file, "\\"); + if (index >= 0) { + file = file.substring((index + 1 >> 0)); + } } + } else { + file = "???"; + line = 1; } - return [z, m]; - }; - Int.prototype.DivMod = function(x, y, m) { return this.$val.DivMod(x, y, m); }; - Int.Ptr.prototype.Cmp = function(y) { - var r = 0, x; - x = this; - if (x.neg === y.neg) { - r = x.abs.cmp(y.abs); - if (x.neg) { - r = -r; + buf = new bytes.Buffer.Ptr(); + buf.WriteByte(9); + fmt.Fprintf(buf, "%s:%d: ", new ($sliceType($emptyInterface))([new $String(file), new $Int(line)])); + lines = strings.Split(s, "\n"); + l = lines.$length; + if (l > 1 && (x = l - 1 >> 0, ((x < 0 || x >= lines.$length) ? $throwRuntimeError("index out of range") : lines.$array[lines.$offset + x])) === "") { + lines = $subslice(lines, 0, (l - 1 >> 0)); + } + _ref = lines; + _i = 0; + while (_i < _ref.$length) { + i = _i; + line$1 = ((_i < 0 || _i >= _ref.$length) ? $throwRuntimeError("index out of range") : _ref.$array[_ref.$offset + _i]); + if (i > 0) { + buf.WriteString("\n\t\t"); } - } else if (x.neg) { - r = -1; - } else { - r = 1; + buf.WriteString(line$1); + _i++; } - return r; + buf.WriteByte(10); + return buf.String(); }; - Int.prototype.Cmp = function(y) { return this.$val.Cmp(y); }; - Int.Ptr.prototype.String = function() { - var x; - x = this; - if (x === ($ptrType(Int)).nil) { - return ""; - } else if (x.neg) { - return "-" + x.abs.decimalString(); - } - return x.abs.decimalString(); + common.Ptr.prototype.Fail = function() { + var $deferred = [], $err = null, c; + /* */ try { $deferFrames.push($deferred); + c = this; + c.mu.Lock(); + $deferred.push([$methodVal(c.mu, "Unlock"), []]); + c.failed = true; + /* */ } catch(err) { $err = err; } finally { $deferFrames.pop(); $callDeferred($deferred, $err); } }; - Int.prototype.String = function() { return this.$val.String(); }; - charset = function(ch) { - var _ref; - _ref = ch; - if (_ref === 98) { - return "0123456789abcdefghijklmnopqrstuvwxyz".substring(0, 2); - } else if (_ref === 111) { - return "0123456789abcdefghijklmnopqrstuvwxyz".substring(0, 8); - } else if (_ref === 100 || _ref === 115 || _ref === 118) { - return "0123456789abcdefghijklmnopqrstuvwxyz".substring(0, 10); - } else if (_ref === 120) { - return "0123456789abcdefghijklmnopqrstuvwxyz".substring(0, 16); - } else if (_ref === 88) { - return "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ".substring(0, 16); - } - return ""; + common.prototype.Fail = function() { return this.$val.Fail(); }; + common.Ptr.prototype.Failed = function() { + var $deferred = [], $err = null, c; + /* */ try { $deferFrames.push($deferred); + c = this; + c.mu.RLock(); + $deferred.push([$methodVal(c.mu, "RUnlock"), []]); + return c.failed; + /* */ } catch(err) { $err = err; return false; } finally { $deferFrames.pop(); $callDeferred($deferred, $err); } }; - writeMultiple = function(s, text, count) { - var b; - if (text.length > 0) { - b = new ($sliceType($Uint8))($stringToBytes(text)); - while (count > 0) { - s.Write(b); - count = count - (1) >> 0; - } - } + common.prototype.Failed = function() { return this.$val.Failed(); }; + common.Ptr.prototype.FailNow = function() { + var c; + c = this; + c.Fail(); + c.finished = true; + runtime.Goexit(); }; - Int.Ptr.prototype.Format = function(s, ch) { - var x, cs, sign, prefix, _ref, digits, left, zeroes, right, _tuple, precision, precisionSet, length, _tuple$1, width, widthSet, d; - x = this; - cs = charset(ch); - if (cs === "") { - fmt.Fprintf(s, "%%!%c(big.Int=%s)", new ($sliceType($emptyInterface))([new $Int32(ch), new $String(x.String())])); - return; - } else if (x === ($ptrType(Int)).nil) { - fmt.Fprint(s, new ($sliceType($emptyInterface))([new $String("")])); - return; - } - sign = ""; - if (x.neg) { - sign = "-"; - } else if (s.Flag(43)) { - sign = "+"; - } else if (s.Flag(32)) { - sign = " "; - } - prefix = ""; - if (s.Flag(35)) { - _ref = ch; - if (_ref === 111) { - prefix = "0"; - } else if (_ref === 120) { - prefix = "0x"; - } else if (_ref === 88) { - prefix = "0X"; - } - } - digits = x.abs.string(cs); - left = 0; - zeroes = 0; - right = 0; - _tuple = s.Precision(); precision = _tuple[0]; precisionSet = _tuple[1]; - if (precisionSet) { - if (digits.length < precision) { - zeroes = precision - digits.length >> 0; - } else if (digits === "0" && (precision === 0)) { - return; - } - } - length = ((sign.length + prefix.length >> 0) + zeroes >> 0) + digits.length >> 0; - _tuple$1 = s.Width(); width = _tuple$1[0]; widthSet = _tuple$1[1]; - if (widthSet && length < width) { - d = width - length >> 0; - if (s.Flag(45)) { - right = d; - } else if (s.Flag(48) && !precisionSet) { - zeroes = d; - } else { - left = d; - } - } - writeMultiple(s, " ", left); - writeMultiple(s, sign, 1); - writeMultiple(s, prefix, 1); - writeMultiple(s, "0", zeroes); - writeMultiple(s, digits, 1); - writeMultiple(s, " ", right); + common.prototype.FailNow = function() { return this.$val.FailNow(); }; + common.Ptr.prototype.log = function(s) { + var $deferred = [], $err = null, c; + /* */ try { $deferFrames.push($deferred); + c = this; + c.mu.Lock(); + $deferred.push([$methodVal(c.mu, "Unlock"), []]); + c.output = $appendSlice(c.output, new ($sliceType($Uint8))($stringToBytes(decorate(s)))); + /* */ } catch(err) { $err = err; } finally { $deferFrames.pop(); $callDeferred($deferred, $err); } }; - Int.prototype.Format = function(s, ch) { return this.$val.Format(s, ch); }; - Int.Ptr.prototype.scan = function(r, base) { - var z, _tuple, ch, err, neg, _ref, _tuple$1; - z = this; - _tuple = r.ReadRune(); ch = _tuple[0]; err = _tuple[2]; - if (!($interfaceIsEqual(err, $ifaceNil))) { - return [($ptrType(Int)).nil, 0, err]; - } - neg = false; - _ref = ch; - if (_ref === 45) { - neg = true; - } else if (_ref === 43) { - } else { - r.UnreadRune(); - } - _tuple$1 = z.abs.scan(r, base); z.abs = _tuple$1[0]; base = _tuple$1[1]; err = _tuple$1[2]; - if (!($interfaceIsEqual(err, $ifaceNil))) { - return [($ptrType(Int)).nil, base, err]; - } - z.neg = z.abs.$length > 0 && neg; - return [z, base, $ifaceNil]; + common.prototype.log = function(s) { return this.$val.log(s); }; + common.Ptr.prototype.Log = function(args) { + var c; + c = this; + c.log(fmt.Sprintln(args)); }; - Int.prototype.scan = function(r, base) { return this.$val.scan(r, base); }; - Int.Ptr.prototype.Scan = function(s, ch) { - var z, base, _ref, _tuple, err; - z = this; - s.SkipSpace(); - base = 0; - _ref = ch; - if (_ref === 98) { - base = 2; - } else if (_ref === 111) { - base = 8; - } else if (_ref === 100) { - base = 10; - } else if (_ref === 120 || _ref === 88) { - base = 16; - } else if (_ref === 115 || _ref === 118) { - } else { - return errors.New("Int.Scan: invalid verb"); - } - _tuple = z.scan(s, base); err = _tuple[2]; - return err; + common.prototype.Log = function(args) { return this.$val.Log(args); }; + common.Ptr.prototype.Logf = function(format, args) { + var c; + c = this; + c.log(fmt.Sprintf(format, args)); }; - Int.prototype.Scan = function(s, ch) { return this.$val.Scan(s, ch); }; - Int.Ptr.prototype.Int64 = function() { - var x, x$1, v; - x = this; - v = (x$1 = x.Uint64(), new $Int64(x$1.$high, x$1.$low)); - if (x.neg) { - v = new $Int64(-v.$high, -v.$low); - } - return v; + common.prototype.Logf = function(format, args) { return this.$val.Logf(format, args); }; + common.Ptr.prototype.Error = function(args) { + var c; + c = this; + c.log(fmt.Sprintln(args)); + c.Fail(); }; - Int.prototype.Int64 = function() { return this.$val.Int64(); }; - Int.Ptr.prototype.Uint64 = function() { - var x, x$1, x$2, v, x$3, x$4, x$5; - x = this; - if (x.abs.$length === 0) { - return new $Uint64(0, 0); - } - v = (x$1 = (x$2 = x.abs, ((0 < 0 || 0 >= x$2.$length) ? $throwRuntimeError("index out of range") : x$2.$array[x$2.$offset + 0])), new $Uint64(0, x$1.constructor === Number ? x$1 : 1)); - if (true && x.abs.$length > 1) { - v = (x$3 = $shiftLeft64((x$4 = (x$5 = x.abs, ((1 < 0 || 1 >= x$5.$length) ? $throwRuntimeError("index out of range") : x$5.$array[x$5.$offset + 1])), new $Uint64(0, x$4.constructor === Number ? x$4 : 1)), 32), new $Uint64(v.$high | x$3.$high, (v.$low | x$3.$low) >>> 0)); - } - return v; + common.prototype.Error = function(args) { return this.$val.Error(args); }; + common.Ptr.prototype.Errorf = function(format, args) { + var c; + c = this; + c.log(fmt.Sprintf(format, args)); + c.Fail(); }; - Int.prototype.Uint64 = function() { return this.$val.Uint64(); }; - Int.Ptr.prototype.SetString = function(s, base) { - var z, r, _tuple, err, _tuple$1; - z = this; - r = strings.NewReader(s); - _tuple = z.scan(r, base); err = _tuple[2]; - if (!($interfaceIsEqual(err, $ifaceNil))) { - return [($ptrType(Int)).nil, false]; - } - _tuple$1 = r.ReadRune(); err = _tuple$1[2]; - if (!($interfaceIsEqual(err, io.EOF))) { - return [($ptrType(Int)).nil, false]; - } - return [z, true]; + common.prototype.Errorf = function(format, args) { return this.$val.Errorf(format, args); }; + common.Ptr.prototype.Fatal = function(args) { + var c; + c = this; + c.log(fmt.Sprintln(args)); + c.FailNow(); }; - Int.prototype.SetString = function(s, base) { return this.$val.SetString(s, base); }; - Int.Ptr.prototype.SetBytes = function(buf) { - var z; - z = this; - z.abs = z.abs.setBytes(buf); - z.neg = false; - return z; + common.prototype.Fatal = function(args) { return this.$val.Fatal(args); }; + common.Ptr.prototype.Fatalf = function(format, args) { + var c; + c = this; + c.log(fmt.Sprintf(format, args)); + c.FailNow(); }; - Int.prototype.SetBytes = function(buf) { return this.$val.SetBytes(buf); }; - Int.Ptr.prototype.Bytes = function() { - var x, x$1, buf; - x = this; - buf = ($sliceType($Uint8)).make((x$1 = x.abs.$length, (((x$1 >>> 16 << 16) * 4 >> 0) + (x$1 << 16 >>> 16) * 4) >> 0)); - return $subslice(buf, x.abs.bytes(buf)); + common.prototype.Fatalf = function(format, args) { return this.$val.Fatalf(format, args); }; + common.Ptr.prototype.Skip = function(args) { + var c; + c = this; + c.log(fmt.Sprintln(args)); + c.SkipNow(); }; - Int.prototype.Bytes = function() { return this.$val.Bytes(); }; - Int.Ptr.prototype.BitLen = function() { - var x; - x = this; - return x.abs.bitLen(); + common.prototype.Skip = function(args) { return this.$val.Skip(args); }; + common.Ptr.prototype.Skipf = function(format, args) { + var c; + c = this; + c.log(fmt.Sprintf(format, args)); + c.SkipNow(); }; - Int.prototype.BitLen = function() { return this.$val.BitLen(); }; - Int.Ptr.prototype.Exp = function(x, y, m) { - var z, yWords, mWords; - z = this; - yWords = nat.nil; - if (!y.neg) { - yWords = y.abs; - } - mWords = nat.nil; - if (!(m === ($ptrType(Int)).nil)) { - mWords = m.abs; - } - z.abs = z.abs.expNN(x.abs, yWords, mWords); - z.neg = z.abs.$length > 0 && x.neg && yWords.$length > 0 && (((((0 < 0 || 0 >= yWords.$length) ? $throwRuntimeError("index out of range") : yWords.$array[yWords.$offset + 0]) & 1) >>> 0) === 1); - return z; + common.prototype.Skipf = function(format, args) { return this.$val.Skipf(format, args); }; + common.Ptr.prototype.SkipNow = function() { + var c; + c = this; + c.skip(); + c.finished = true; + runtime.Goexit(); }; - Int.prototype.Exp = function(x, y, m) { return this.$val.Exp(x, y, m); }; - Int.Ptr.prototype.GCD = function(x, y, a, b) { - var z, A, B, X, Y, lastX, lastY, q, temp, r, _tuple, _tmp, _tmp$1; - z = this; - if (a.Sign() <= 0 || b.Sign() <= 0) { - z.SetInt64(new $Int64(0, 0)); - if (!(x === ($ptrType(Int)).nil)) { - x.SetInt64(new $Int64(0, 0)); - } - if (!(y === ($ptrType(Int)).nil)) { - y.SetInt64(new $Int64(0, 0)); + common.prototype.SkipNow = function() { return this.$val.SkipNow(); }; + common.Ptr.prototype.skip = function() { + var $deferred = [], $err = null, c; + /* */ try { $deferFrames.push($deferred); + c = this; + c.mu.Lock(); + $deferred.push([$methodVal(c.mu, "Unlock"), []]); + c.skipped = true; + /* */ } catch(err) { $err = err; } finally { $deferFrames.pop(); $callDeferred($deferred, $err); } + }; + common.prototype.skip = function() { return this.$val.skip(); }; + common.Ptr.prototype.Skipped = function() { + var $deferred = [], $err = null, c; + /* */ try { $deferFrames.push($deferred); + c = this; + c.mu.RLock(); + $deferred.push([$methodVal(c.mu, "RUnlock"), []]); + return c.skipped; + /* */ } catch(err) { $err = err; return false; } finally { $deferFrames.pop(); $callDeferred($deferred, $err); } + }; + common.prototype.Skipped = function() { return this.$val.Skipped(); }; + T.Ptr.prototype.Parallel = function($b) { + var $this = this, $args = arguments, $r, $s = 0, t, _r; + /* */ if(!$b) { $nonblockingCall(); }; var $f = function() { while (true) { switch ($s) { case 0: + t = $this; + $r = $send(t.common.signal, ($ptrType(T)).nil, true); /* */ $s = 1; case 1: if ($r && $r.$blocking) { $r = $r(); } + _r = $recv(t.startParallel, true); /* */ $s = 2; case 2: if (_r && _r.$blocking) { _r = _r(); } + _r[0]; + $copy(t.common.start, time.Now(), time.Time); + /* */ case -1: } return; } }; $f.$blocking = true; return $f; + }; + T.prototype.Parallel = function($b) { return this.$val.Parallel($b); }; + T.Ptr.prototype.report = function() { + var t, tstr, format; + t = this; + tstr = fmt.Sprintf("(%.2f seconds)", new ($sliceType($emptyInterface))([new $Float64(t.common.duration.Seconds())])); + format = "--- %s: %s %s\n%s"; + if (t.common.Failed()) { + fmt.Printf(format, new ($sliceType($emptyInterface))([new $String("FAIL"), new $String(t.name), new $String(tstr), t.common.output])); + } else if (chatty.$get()) { + if (t.common.Skipped()) { + fmt.Printf(format, new ($sliceType($emptyInterface))([new $String("SKIP"), new $String(t.name), new $String(tstr), t.common.output])); + } else { + fmt.Printf(format, new ($sliceType($emptyInterface))([new $String("PASS"), new $String(t.name), new $String(tstr), t.common.output])); } - return z; - } - if (x === ($ptrType(Int)).nil && y === ($ptrType(Int)).nil) { - return z.binaryGCD(a, b); } - A = new Int.Ptr().Set(a); - B = new Int.Ptr().Set(b); - X = new Int.Ptr(); - Y = new Int.Ptr().SetInt64(new $Int64(0, 1)); - lastX = new Int.Ptr().SetInt64(new $Int64(0, 1)); - lastY = new Int.Ptr(); - q = new Int.Ptr(); - temp = new Int.Ptr(); - while (B.abs.$length > 0) { - r = new Int.Ptr(); - _tuple = q.QuoRem(A, B, r); q = _tuple[0]; r = _tuple[1]; - _tmp = B; _tmp$1 = r; A = _tmp; B = _tmp$1; - temp.Set(X); - X.Mul(X, q); - X.neg = !X.neg; - X.Add(X, lastX); - lastX.Set(temp); - temp.Set(Y); - Y.Mul(Y, q); - Y.neg = !Y.neg; - Y.Add(Y, lastY); - lastY.Set(temp); - } - if (!(x === ($ptrType(Int)).nil)) { - $copy(x, lastX, Int); - } - if (!(y === ($ptrType(Int)).nil)) { - $copy(y, lastY, Int); - } - $copy(z, A, Int); - return z; }; - Int.prototype.GCD = function(x, y, a, b) { return this.$val.GCD(x, y, a, b); }; - Int.Ptr.prototype.binaryGCD = function(a, b) { - var z, u, v, k, vk, t, x, _tmp, _tmp$1, _tmp$2, _tmp$3; - z = this; - u = z; - v = new Int.Ptr(); - if (a.abs.$length > b.abs.$length) { - u.Set(b); - v.Rem(a, b); - } else if (a.abs.$length < b.abs.$length) { - u.Set(a); - v.Rem(b, a); - } else { - u.Set(a); - v.Set(b); - } - if (v.abs.$length === 0) { - return u; + T.prototype.report = function() { return this.$val.report(); }; + $pkg.$init = function() { + /* */ var $r, $s = 0; var $f = function() { while (true) { switch ($s) { case 0: + InternalBenchmark.init([["Name", "Name", "", $String, ""], ["F", "F", "", ($funcType([($ptrType(B))], [], false)), ""]]); + ($ptrType(B)).methods = [["Error", "Error", "", $funcType([($sliceType($emptyInterface))], [], true), 0], ["Errorf", "Errorf", "", $funcType([$String, ($sliceType($emptyInterface))], [], true), 0], ["Fail", "Fail", "", $funcType([], [], false), 0], ["FailNow", "FailNow", "", $funcType([], [], false), 0], ["Failed", "Failed", "", $funcType([], [$Bool], false), 0], ["Fatal", "Fatal", "", $funcType([($sliceType($emptyInterface))], [], true), 0], ["Fatalf", "Fatalf", "", $funcType([$String, ($sliceType($emptyInterface))], [], true), 0], ["Log", "Log", "", $funcType([($sliceType($emptyInterface))], [], true), 0], ["Logf", "Logf", "", $funcType([$String, ($sliceType($emptyInterface))], [], true), 0], ["ReportAllocs", "ReportAllocs", "", $funcType([], [], false), -1], ["ResetTimer", "ResetTimer", "", $funcType([], [], false), -1], ["RunParallel", "RunParallel", "", $funcType([($funcType([($ptrType(PB))], [], false))], [], false), -1], ["SetBytes", "SetBytes", "", $funcType([$Int64], [], false), -1], ["SetParallelism", "SetParallelism", "", $funcType([$Int], [], false), -1], ["Skip", "Skip", "", $funcType([($sliceType($emptyInterface))], [], true), 0], ["SkipNow", "SkipNow", "", $funcType([], [], false), 0], ["Skipf", "Skipf", "", $funcType([$String, ($sliceType($emptyInterface))], [], true), 0], ["Skipped", "Skipped", "", $funcType([], [$Bool], false), 0], ["StartTimer", "StartTimer", "", $funcType([], [], false), -1], ["StopTimer", "StopTimer", "", $funcType([], [], false), -1], ["launch", "launch", "testing", $funcType([], [], false), -1], ["log", "log", "testing", $funcType([$String], [], false), 0], ["nsPerOp", "nsPerOp", "testing", $funcType([], [$Int64], false), -1], ["private$", "private", "testing", $funcType([], [], false), 0], ["run", "run", "testing", $funcType([], [BenchmarkResult], false), -1], ["runN", "runN", "testing", $funcType([$Int], [], false), -1], ["skip", "skip", "testing", $funcType([], [], false), 0], ["trimOutput", "trimOutput", "testing", $funcType([], [], false), -1]]; + B.init([["common", "", "testing", common, ""], ["N", "N", "", $Int, ""], ["previousN", "previousN", "testing", $Int, ""], ["previousDuration", "previousDuration", "testing", time.Duration, ""], ["benchmark", "benchmark", "testing", InternalBenchmark, ""], ["bytes", "bytes", "testing", $Int64, ""], ["timerOn", "timerOn", "testing", $Bool, ""], ["showAllocResult", "showAllocResult", "testing", $Bool, ""], ["result", "result", "testing", BenchmarkResult, ""], ["parallelism", "parallelism", "testing", $Int, ""], ["startAllocs", "startAllocs", "testing", $Uint64, ""], ["startBytes", "startBytes", "testing", $Uint64, ""], ["netAllocs", "netAllocs", "testing", $Uint64, ""], ["netBytes", "netBytes", "testing", $Uint64, ""]]); + BenchmarkResult.methods = [["AllocedBytesPerOp", "AllocedBytesPerOp", "", $funcType([], [$Int64], false), -1], ["AllocsPerOp", "AllocsPerOp", "", $funcType([], [$Int64], false), -1], ["MemString", "MemString", "", $funcType([], [$String], false), -1], ["NsPerOp", "NsPerOp", "", $funcType([], [$Int64], false), -1], ["String", "String", "", $funcType([], [$String], false), -1], ["mbPerSec", "mbPerSec", "testing", $funcType([], [$Float64], false), -1]]; + ($ptrType(BenchmarkResult)).methods = [["AllocedBytesPerOp", "AllocedBytesPerOp", "", $funcType([], [$Int64], false), -1], ["AllocsPerOp", "AllocsPerOp", "", $funcType([], [$Int64], false), -1], ["MemString", "MemString", "", $funcType([], [$String], false), -1], ["NsPerOp", "NsPerOp", "", $funcType([], [$Int64], false), -1], ["String", "String", "", $funcType([], [$String], false), -1], ["mbPerSec", "mbPerSec", "testing", $funcType([], [$Float64], false), -1]]; + BenchmarkResult.init([["N", "N", "", $Int, ""], ["T", "T", "", time.Duration, ""], ["Bytes", "Bytes", "", $Int64, ""], ["MemAllocs", "MemAllocs", "", $Uint64, ""], ["MemBytes", "MemBytes", "", $Uint64, ""]]); + ($ptrType(PB)).methods = [["Next", "Next", "", $funcType([], [$Bool], false), -1]]; + PB.init([["globalN", "globalN", "testing", ($ptrType($Uint64)), ""], ["grain", "grain", "testing", $Uint64, ""], ["cache", "cache", "testing", $Uint64, ""], ["bN", "bN", "testing", $Uint64, ""]]); + InternalExample.init([["Name", "Name", "", $String, ""], ["F", "F", "", ($funcType([], [], false)), ""], ["Output", "Output", "", $String, ""]]); + ($ptrType(common)).methods = [["Error", "Error", "", $funcType([($sliceType($emptyInterface))], [], true), -1], ["Errorf", "Errorf", "", $funcType([$String, ($sliceType($emptyInterface))], [], true), -1], ["Fail", "Fail", "", $funcType([], [], false), -1], ["FailNow", "FailNow", "", $funcType([], [], false), -1], ["Failed", "Failed", "", $funcType([], [$Bool], false), -1], ["Fatal", "Fatal", "", $funcType([($sliceType($emptyInterface))], [], true), -1], ["Fatalf", "Fatalf", "", $funcType([$String, ($sliceType($emptyInterface))], [], true), -1], ["Log", "Log", "", $funcType([($sliceType($emptyInterface))], [], true), -1], ["Logf", "Logf", "", $funcType([$String, ($sliceType($emptyInterface))], [], true), -1], ["Skip", "Skip", "", $funcType([($sliceType($emptyInterface))], [], true), -1], ["SkipNow", "SkipNow", "", $funcType([], [], false), -1], ["Skipf", "Skipf", "", $funcType([$String, ($sliceType($emptyInterface))], [], true), -1], ["Skipped", "Skipped", "", $funcType([], [$Bool], false), -1], ["log", "log", "testing", $funcType([$String], [], false), -1], ["private$", "private", "testing", $funcType([], [], false), -1], ["skip", "skip", "testing", $funcType([], [], false), -1]]; + common.init([["mu", "mu", "testing", sync.RWMutex, ""], ["output", "output", "testing", ($sliceType($Uint8)), ""], ["failed", "failed", "testing", $Bool, ""], ["skipped", "skipped", "testing", $Bool, ""], ["finished", "finished", "testing", $Bool, ""], ["start", "start", "testing", time.Time, ""], ["duration", "duration", "testing", time.Duration, ""], ["self", "self", "testing", $emptyInterface, ""], ["signal", "signal", "testing", ($chanType($emptyInterface, false, false)), ""]]); + ($ptrType(T)).methods = [["Error", "Error", "", $funcType([($sliceType($emptyInterface))], [], true), 0], ["Errorf", "Errorf", "", $funcType([$String, ($sliceType($emptyInterface))], [], true), 0], ["Fail", "Fail", "", $funcType([], [], false), 0], ["FailNow", "FailNow", "", $funcType([], [], false), 0], ["Failed", "Failed", "", $funcType([], [$Bool], false), 0], ["Fatal", "Fatal", "", $funcType([($sliceType($emptyInterface))], [], true), 0], ["Fatalf", "Fatalf", "", $funcType([$String, ($sliceType($emptyInterface))], [], true), 0], ["Log", "Log", "", $funcType([($sliceType($emptyInterface))], [], true), 0], ["Logf", "Logf", "", $funcType([$String, ($sliceType($emptyInterface))], [], true), 0], ["Parallel", "Parallel", "", $funcType([], [], false), -1], ["Skip", "Skip", "", $funcType([($sliceType($emptyInterface))], [], true), 0], ["SkipNow", "SkipNow", "", $funcType([], [], false), 0], ["Skipf", "Skipf", "", $funcType([$String, ($sliceType($emptyInterface))], [], true), 0], ["Skipped", "Skipped", "", $funcType([], [$Bool], false), 0], ["log", "log", "testing", $funcType([$String], [], false), 0], ["private$", "private", "testing", $funcType([], [], false), 0], ["report", "report", "testing", $funcType([], [], false), -1], ["skip", "skip", "testing", $funcType([], [], false), 0]]; + T.init([["common", "", "testing", common, ""], ["name", "name", "testing", $String, ""], ["startParallel", "startParallel", "testing", ($chanType($Bool, false, false)), ""]]); + InternalTest.init([["Name", "Name", "", $String, ""], ["F", "F", "", ($funcType([($ptrType(T))], [], false)), ""]]); + memStats = new runtime.MemStats.Ptr(); + matchBenchmarks = flag.String("test.bench", "", "regular expression to select benchmarks to run"); + benchTime = flag.Duration("test.benchtime", new time.Duration(0, 1000000000), "approximate run time for each benchmark"); + benchmarkMemory = flag.Bool("test.benchmem", false, "print memory allocations for benchmarks"); + short$1 = flag.Bool("test.short", false, "run smaller test suite to save time"); + outputDir = flag.String("test.outputdir", "", "directory in which to write profiles"); + chatty = flag.Bool("test.v", false, "verbose: print additional output"); + coverProfile = flag.String("test.coverprofile", "", "write a coverage profile to the named file after execution"); + match = flag.String("test.run", "", "regular expression to select tests and examples to run"); + memProfile = flag.String("test.memprofile", "", "write a memory profile to the named file after execution"); + memProfileRate = flag.Int("test.memprofilerate", 0, "if >=0, sets runtime.MemProfileRate"); + cpuProfile = flag.String("test.cpuprofile", "", "write a cpu profile to the named file during execution"); + blockProfile = flag.String("test.blockprofile", "", "write a goroutine blocking profile to the named file after execution"); + blockProfileRate = flag.Int("test.blockprofilerate", 1, "if >= 0, calls runtime.SetBlockProfileRate()"); + timeout = flag.Duration("test.timeout", new time.Duration(0, 0), "if positive, sets an aggregate time limit for all tests"); + cpuListStr = flag.String("test.cpu", "", "comma-separated list of number of CPUs to use for each test"); + parallel = flag.Int("test.parallel", runtime.GOMAXPROCS(0), "maximum test parallelism"); + $r = init(true); /* */ $s = 1; case 1: if ($r && $r.$blocking) { $r = $r(); } + /* */ } return; } }; $f.$blocking = true; return $f; + }; + return $pkg; +})(); +$packages["encoding/base64"] = (function() { + var $pkg = {}, testing = $packages["testing"], bytes = $packages["bytes"], io = $packages["io"], strconv = $packages["strconv"], strings = $packages["strings"], Encoding, encoder, CorruptInputError, removeNewlinesMapper, NewEncoding, NewEncoder; + Encoding = $pkg.Encoding = $newType(0, "Struct", "base64.Encoding", "Encoding", "encoding/base64", function(encode_, decodeMap_) { + this.$val = this; + this.encode = encode_ !== undefined ? encode_ : ""; + this.decodeMap = decodeMap_ !== undefined ? decodeMap_ : ($arrayType($Uint8, 256)).zero(); + }); + encoder = $pkg.encoder = $newType(0, "Struct", "base64.encoder", "encoder", "encoding/base64", function(err_, enc_, w_, buf_, nbuf_, out_) { + this.$val = this; + this.err = err_ !== undefined ? err_ : $ifaceNil; + this.enc = enc_ !== undefined ? enc_ : ($ptrType(Encoding)).nil; + this.w = w_ !== undefined ? w_ : $ifaceNil; + this.buf = buf_ !== undefined ? buf_ : ($arrayType($Uint8, 3)).zero(); + this.nbuf = nbuf_ !== undefined ? nbuf_ : 0; + this.out = out_ !== undefined ? out_ : ($arrayType($Uint8, 1024)).zero(); + }); + CorruptInputError = $pkg.CorruptInputError = $newType(8, "Int64", "base64.CorruptInputError", "CorruptInputError", "encoding/base64", null); + NewEncoding = $pkg.NewEncoding = function(encoder$1) { + var e, i, x, i$1, x$1, x$2; + e = new Encoding.Ptr(); + e.encode = encoder$1; + i = 0; + while (i < 256) { + (x = e.decodeMap, (i < 0 || i >= x.length) ? $throwRuntimeError("index out of range") : x[i] = 255); + i = i + (1) >> 0; } - k = u.abs.trailingZeroBits(); - vk = v.abs.trailingZeroBits(); - if (vk < k) { - k = vk; + i$1 = 0; + while (i$1 < encoder$1.length) { + (x$1 = e.decodeMap, x$2 = encoder$1.charCodeAt(i$1), (x$2 < 0 || x$2 >= x$1.length) ? $throwRuntimeError("index out of range") : x$1[x$2] = (i$1 << 24 >>> 24)); + i$1 = i$1 + (1) >> 0; } - u.Rsh(u, k); - v.Rsh(v, k); - t = new Int.Ptr(); - if (!(((((x = u.abs, ((0 < 0 || 0 >= x.$length) ? $throwRuntimeError("index out of range") : x.$array[x.$offset + 0])) & 1) >>> 0) === 0))) { - t.Neg(v); - } else { - t.Set(u); + return e; + }; + Encoding.Ptr.prototype.Encode = function(dst, src) { + var enc, _ref, _lhs, _index, _lhs$1, _index$1, _lhs$2, _index$2, _lhs$3, _index$3, _lhs$4, _index$4, _lhs$5, _index$5, _lhs$6, _index$6, _lhs$7, _index$7, _lhs$8, _index$8, _lhs$9, _index$9, _lhs$10, _index$10, _lhs$11, _index$11, j; + enc = this; + if (src.$length === 0) { + return; } - while (t.abs.$length > 0) { - t.Rsh(t, t.abs.trailingZeroBits()); - if (t.neg) { - _tmp = t; _tmp$1 = v; v = _tmp; t = _tmp$1; - v.neg = v.abs.$length > 0 && !v.neg; + while (src.$length > 0) { + (0 < 0 || 0 >= dst.$length) ? $throwRuntimeError("index out of range") : dst.$array[dst.$offset + 0] = 0; + (1 < 0 || 1 >= dst.$length) ? $throwRuntimeError("index out of range") : dst.$array[dst.$offset + 1] = 0; + (2 < 0 || 2 >= dst.$length) ? $throwRuntimeError("index out of range") : dst.$array[dst.$offset + 2] = 0; + (3 < 0 || 3 >= dst.$length) ? $throwRuntimeError("index out of range") : dst.$array[dst.$offset + 3] = 0; + _ref = src.$length; + if (_ref === 2) { + _lhs = dst; _index = 2; (_index < 0 || _index >= _lhs.$length) ? $throwRuntimeError("index out of range") : _lhs.$array[_lhs.$offset + _index] = (((_index < 0 || _index >= _lhs.$length) ? $throwRuntimeError("index out of range") : _lhs.$array[_lhs.$offset + _index]) | (((((((1 < 0 || 1 >= src.$length) ? $throwRuntimeError("index out of range") : src.$array[src.$offset + 1]) << 2 << 24 >>> 24)) & 63) >>> 0))) >>> 0; + _lhs$1 = dst; _index$1 = 1; (_index$1 < 0 || _index$1 >= _lhs$1.$length) ? $throwRuntimeError("index out of range") : _lhs$1.$array[_lhs$1.$offset + _index$1] = (((_index$1 < 0 || _index$1 >= _lhs$1.$length) ? $throwRuntimeError("index out of range") : _lhs$1.$array[_lhs$1.$offset + _index$1]) | ((((1 < 0 || 1 >= src.$length) ? $throwRuntimeError("index out of range") : src.$array[src.$offset + 1]) >>> 4 << 24 >>> 24))) >>> 0; + _lhs$2 = dst; _index$2 = 1; (_index$2 < 0 || _index$2 >= _lhs$2.$length) ? $throwRuntimeError("index out of range") : _lhs$2.$array[_lhs$2.$offset + _index$2] = (((_index$2 < 0 || _index$2 >= _lhs$2.$length) ? $throwRuntimeError("index out of range") : _lhs$2.$array[_lhs$2.$offset + _index$2]) | (((((((0 < 0 || 0 >= src.$length) ? $throwRuntimeError("index out of range") : src.$array[src.$offset + 0]) << 4 << 24 >>> 24)) & 63) >>> 0))) >>> 0; + _lhs$3 = dst; _index$3 = 0; (_index$3 < 0 || _index$3 >= _lhs$3.$length) ? $throwRuntimeError("index out of range") : _lhs$3.$array[_lhs$3.$offset + _index$3] = (((_index$3 < 0 || _index$3 >= _lhs$3.$length) ? $throwRuntimeError("index out of range") : _lhs$3.$array[_lhs$3.$offset + _index$3]) | ((((0 < 0 || 0 >= src.$length) ? $throwRuntimeError("index out of range") : src.$array[src.$offset + 0]) >>> 2 << 24 >>> 24))) >>> 0; + } else if (_ref === 1) { + _lhs$4 = dst; _index$4 = 1; (_index$4 < 0 || _index$4 >= _lhs$4.$length) ? $throwRuntimeError("index out of range") : _lhs$4.$array[_lhs$4.$offset + _index$4] = (((_index$4 < 0 || _index$4 >= _lhs$4.$length) ? $throwRuntimeError("index out of range") : _lhs$4.$array[_lhs$4.$offset + _index$4]) | (((((((0 < 0 || 0 >= src.$length) ? $throwRuntimeError("index out of range") : src.$array[src.$offset + 0]) << 4 << 24 >>> 24)) & 63) >>> 0))) >>> 0; + _lhs$5 = dst; _index$5 = 0; (_index$5 < 0 || _index$5 >= _lhs$5.$length) ? $throwRuntimeError("index out of range") : _lhs$5.$array[_lhs$5.$offset + _index$5] = (((_index$5 < 0 || _index$5 >= _lhs$5.$length) ? $throwRuntimeError("index out of range") : _lhs$5.$array[_lhs$5.$offset + _index$5]) | ((((0 < 0 || 0 >= src.$length) ? $throwRuntimeError("index out of range") : src.$array[src.$offset + 0]) >>> 2 << 24 >>> 24))) >>> 0; } else { - _tmp$2 = t; _tmp$3 = u; u = _tmp$2; t = _tmp$3; + _lhs$6 = dst; _index$6 = 3; (_index$6 < 0 || _index$6 >= _lhs$6.$length) ? $throwRuntimeError("index out of range") : _lhs$6.$array[_lhs$6.$offset + _index$6] = (((_index$6 < 0 || _index$6 >= _lhs$6.$length) ? $throwRuntimeError("index out of range") : _lhs$6.$array[_lhs$6.$offset + _index$6]) | (((((2 < 0 || 2 >= src.$length) ? $throwRuntimeError("index out of range") : src.$array[src.$offset + 2]) & 63) >>> 0))) >>> 0; + _lhs$7 = dst; _index$7 = 2; (_index$7 < 0 || _index$7 >= _lhs$7.$length) ? $throwRuntimeError("index out of range") : _lhs$7.$array[_lhs$7.$offset + _index$7] = (((_index$7 < 0 || _index$7 >= _lhs$7.$length) ? $throwRuntimeError("index out of range") : _lhs$7.$array[_lhs$7.$offset + _index$7]) | ((((2 < 0 || 2 >= src.$length) ? $throwRuntimeError("index out of range") : src.$array[src.$offset + 2]) >>> 6 << 24 >>> 24))) >>> 0; + _lhs$8 = dst; _index$8 = 2; (_index$8 < 0 || _index$8 >= _lhs$8.$length) ? $throwRuntimeError("index out of range") : _lhs$8.$array[_lhs$8.$offset + _index$8] = (((_index$8 < 0 || _index$8 >= _lhs$8.$length) ? $throwRuntimeError("index out of range") : _lhs$8.$array[_lhs$8.$offset + _index$8]) | (((((((1 < 0 || 1 >= src.$length) ? $throwRuntimeError("index out of range") : src.$array[src.$offset + 1]) << 2 << 24 >>> 24)) & 63) >>> 0))) >>> 0; + _lhs$9 = dst; _index$9 = 1; (_index$9 < 0 || _index$9 >= _lhs$9.$length) ? $throwRuntimeError("index out of range") : _lhs$9.$array[_lhs$9.$offset + _index$9] = (((_index$9 < 0 || _index$9 >= _lhs$9.$length) ? $throwRuntimeError("index out of range") : _lhs$9.$array[_lhs$9.$offset + _index$9]) | ((((1 < 0 || 1 >= src.$length) ? $throwRuntimeError("index out of range") : src.$array[src.$offset + 1]) >>> 4 << 24 >>> 24))) >>> 0; + _lhs$10 = dst; _index$10 = 1; (_index$10 < 0 || _index$10 >= _lhs$10.$length) ? $throwRuntimeError("index out of range") : _lhs$10.$array[_lhs$10.$offset + _index$10] = (((_index$10 < 0 || _index$10 >= _lhs$10.$length) ? $throwRuntimeError("index out of range") : _lhs$10.$array[_lhs$10.$offset + _index$10]) | (((((((0 < 0 || 0 >= src.$length) ? $throwRuntimeError("index out of range") : src.$array[src.$offset + 0]) << 4 << 24 >>> 24)) & 63) >>> 0))) >>> 0; + _lhs$11 = dst; _index$11 = 0; (_index$11 < 0 || _index$11 >= _lhs$11.$length) ? $throwRuntimeError("index out of range") : _lhs$11.$array[_lhs$11.$offset + _index$11] = (((_index$11 < 0 || _index$11 >= _lhs$11.$length) ? $throwRuntimeError("index out of range") : _lhs$11.$array[_lhs$11.$offset + _index$11]) | ((((0 < 0 || 0 >= src.$length) ? $throwRuntimeError("index out of range") : src.$array[src.$offset + 0]) >>> 2 << 24 >>> 24))) >>> 0; } - t.Sub(u, v); - } - return z.Lsh(u, k); - }; - Int.prototype.binaryGCD = function(a, b) { return this.$val.binaryGCD(a, b); }; - Int.Ptr.prototype.ProbablyPrime = function(n) { - var x; - x = this; - return !x.neg && x.abs.probablyPrime(n); - }; - Int.prototype.ProbablyPrime = function(n) { return this.$val.ProbablyPrime(n); }; - Int.Ptr.prototype.Rand = function(rnd, n) { - var z; - z = this; - z.neg = false; - if (n.neg === true || (n.abs.$length === 0)) { - z.abs = nat.nil; - return z; - } - z.abs = z.abs.random(rnd, n.abs, n.abs.bitLen()); - return z; - }; - Int.prototype.Rand = function(rnd, n) { return this.$val.Rand(rnd, n); }; - Int.Ptr.prototype.ModInverse = function(g, p) { - var z, d; - z = this; - d = new Int.Ptr(); $copy(d, new Int.Ptr(), Int); - d.GCD(z, ($ptrType(Int)).nil, g, p); - if (z.neg) { - z.Add(z, p); + j = 0; + while (j < 4) { + (j < 0 || j >= dst.$length) ? $throwRuntimeError("index out of range") : dst.$array[dst.$offset + j] = enc.encode.charCodeAt(((j < 0 || j >= dst.$length) ? $throwRuntimeError("index out of range") : dst.$array[dst.$offset + j])); + j = j + (1) >> 0; + } + if (src.$length < 3) { + (3 < 0 || 3 >= dst.$length) ? $throwRuntimeError("index out of range") : dst.$array[dst.$offset + 3] = 61; + if (src.$length < 2) { + (2 < 0 || 2 >= dst.$length) ? $throwRuntimeError("index out of range") : dst.$array[dst.$offset + 2] = 61; + } + break; + } + src = $subslice(src, 3); + dst = $subslice(dst, 4); } - return z; }; - Int.prototype.ModInverse = function(g, p) { return this.$val.ModInverse(g, p); }; - Int.Ptr.prototype.Lsh = function(x, n) { - var z; - z = this; - z.abs = z.abs.shl(x.abs, n); - z.neg = x.neg; - return z; + Encoding.prototype.Encode = function(dst, src) { return this.$val.Encode(dst, src); }; + Encoding.Ptr.prototype.EncodeToString = function(src) { + var enc, buf; + enc = this; + buf = ($sliceType($Uint8)).make(enc.EncodedLen(src.$length)); + enc.Encode(buf, src); + return $bytesToString(buf); }; - Int.prototype.Lsh = function(x, n) { return this.$val.Lsh(x, n); }; - Int.Ptr.prototype.Rsh = function(x, n) { - var z, t; - z = this; - if (x.neg) { - t = z.abs.sub(x.abs, natOne); - t = t.shr(t, n); - z.abs = t.add(t, natOne); - z.neg = true; - return z; + Encoding.prototype.EncodeToString = function(src) { return this.$val.EncodeToString(src); }; + encoder.Ptr.prototype.Write = function(p) { + var n = 0, err = $ifaceNil, e, _tmp, _tmp$1, i, x, x$1, _tuple, _tmp$2, _tmp$3, nn, _r, _tuple$1, x$2, _q, _tmp$4, _tmp$5, i$1, x$3; + e = this; + if (!($interfaceIsEqual(e.err, $ifaceNil))) { + _tmp = 0; _tmp$1 = e.err; n = _tmp; err = _tmp$1; + return [n, err]; } - z.abs = z.abs.shr(x.abs, n); - z.neg = false; - return z; - }; - Int.prototype.Rsh = function(x, n) { return this.$val.Rsh(x, n); }; - Int.Ptr.prototype.Bit = function(i) { - var x, x$1, t; - x = this; - if (i === 0) { - if (x.abs.$length > 0) { - return ((((x$1 = x.abs, ((0 < 0 || 0 >= x$1.$length) ? $throwRuntimeError("index out of range") : x$1.$array[x$1.$offset + 0])) & 1) >>> 0) >>> 0); + if (e.nbuf > 0) { + i = 0; + i = 0; + while (i < p.$length && e.nbuf < 3) { + (x = e.buf, x$1 = e.nbuf, (x$1 < 0 || x$1 >= x.length) ? $throwRuntimeError("index out of range") : x[x$1] = ((i < 0 || i >= p.$length) ? $throwRuntimeError("index out of range") : p.$array[p.$offset + i])); + e.nbuf = e.nbuf + (1) >> 0; + i = i + (1) >> 0; } - return 0; + n = n + (i) >> 0; + p = $subslice(p, i); + if (e.nbuf < 3) { + return [n, err]; + } + e.enc.Encode($subslice(new ($sliceType($Uint8))(e.out), 0), $subslice(new ($sliceType($Uint8))(e.buf), 0)); + _tuple = e.w.Write($subslice(new ($sliceType($Uint8))(e.out), 0, 4)); e.err = _tuple[1]; + if (!($interfaceIsEqual(e.err, $ifaceNil))) { + _tmp$2 = n; _tmp$3 = e.err; n = _tmp$2; err = _tmp$3; + return [n, err]; + } + e.nbuf = 0; } - if (i < 0) { - $panic(new $String("negative bit index")); + while (p.$length >= 3) { + nn = 768; + if (nn > p.$length) { + nn = p.$length; + nn = nn - ((_r = nn % 3, _r === _r ? _r : $throwRuntimeError("integer divide by zero"))) >> 0; + } + e.enc.Encode($subslice(new ($sliceType($Uint8))(e.out), 0), $subslice(p, 0, nn)); + _tuple$1 = e.w.Write($subslice(new ($sliceType($Uint8))(e.out), 0, (x$2 = (_q = nn / 3, (_q === _q && _q !== 1/0 && _q !== -1/0) ? _q >> 0 : $throwRuntimeError("integer divide by zero")), (((x$2 >>> 16 << 16) * 4 >> 0) + (x$2 << 16 >>> 16) * 4) >> 0))); e.err = _tuple$1[1]; + if (!($interfaceIsEqual(e.err, $ifaceNil))) { + _tmp$4 = n; _tmp$5 = e.err; n = _tmp$4; err = _tmp$5; + return [n, err]; + } + n = n + (nn) >> 0; + p = $subslice(p, nn); } - if (x.neg) { - t = nat.nil.sub(x.abs, natOne); - return (t.bit((i >>> 0)) ^ 1) >>> 0; + i$1 = 0; + while (i$1 < p.$length) { + (x$3 = e.buf, (i$1 < 0 || i$1 >= x$3.length) ? $throwRuntimeError("index out of range") : x$3[i$1] = ((i$1 < 0 || i$1 >= p.$length) ? $throwRuntimeError("index out of range") : p.$array[p.$offset + i$1])); + i$1 = i$1 + (1) >> 0; } - return x.abs.bit((i >>> 0)); + e.nbuf = p.$length; + n = n + (p.$length) >> 0; + return [n, err]; }; - Int.prototype.Bit = function(i) { return this.$val.Bit(i); }; - Int.Ptr.prototype.SetBit = function(x, i, b) { - var z, t; - z = this; - if (i < 0) { - $panic(new $String("negative bit index")); - } - if (x.neg) { - t = z.abs.sub(x.abs, natOne); - t = t.setBit(t, (i >>> 0), (b ^ 1) >>> 0); - z.abs = t.add(t, natOne); - z.neg = z.abs.$length > 0; - return z; + encoder.prototype.Write = function(p) { return this.$val.Write(p); }; + encoder.Ptr.prototype.Close = function() { + var e, _tuple; + e = this; + if ($interfaceIsEqual(e.err, $ifaceNil) && e.nbuf > 0) { + e.enc.Encode($subslice(new ($sliceType($Uint8))(e.out), 0), $subslice(new ($sliceType($Uint8))(e.buf), 0, e.nbuf)); + e.nbuf = 0; + _tuple = e.w.Write($subslice(new ($sliceType($Uint8))(e.out), 0, 4)); e.err = _tuple[1]; } - z.abs = z.abs.setBit(x.abs, (i >>> 0), b); - z.neg = false; - return z; + return e.err; }; - Int.prototype.SetBit = function(x, i, b) { return this.$val.SetBit(x, i, b); }; - Int.Ptr.prototype.And = function(x, y) { - var z, x1, y1, _tmp, _tmp$1, y1$1; - z = this; - if (x.neg === y.neg) { - if (x.neg) { - x1 = nat.nil.sub(x.abs, natOne); - y1 = nat.nil.sub(y.abs, natOne); - z.abs = z.abs.add(z.abs.or(x1, y1), natOne); - z.neg = true; - return z; - } - z.abs = z.abs.and(x.abs, y.abs); - z.neg = false; - return z; - } - if (x.neg) { - _tmp = y; _tmp$1 = x; x = _tmp; y = _tmp$1; - } - y1$1 = nat.nil.sub(y.abs, natOne); - z.abs = z.abs.andNot(x.abs, y1$1); - z.neg = false; - return z; + encoder.prototype.Close = function() { return this.$val.Close(); }; + NewEncoder = $pkg.NewEncoder = function(enc, w) { + return new encoder.Ptr($ifaceNil, enc, w, ($arrayType($Uint8, 3)).zero(), 0, ($arrayType($Uint8, 1024)).zero()); }; - Int.prototype.And = function(x, y) { return this.$val.And(x, y); }; - Int.Ptr.prototype.AndNot = function(x, y) { - var z, x1, y1, x1$1, y1$1; - z = this; - if (x.neg === y.neg) { - if (x.neg) { - x1 = nat.nil.sub(x.abs, natOne); - y1 = nat.nil.sub(y.abs, natOne); - z.abs = z.abs.andNot(y1, x1); - z.neg = false; - return z; - } - z.abs = z.abs.andNot(x.abs, y.abs); - z.neg = false; - return z; - } - if (x.neg) { - x1$1 = nat.nil.sub(x.abs, natOne); - z.abs = z.abs.add(z.abs.or(x1$1, y.abs), natOne); - z.neg = true; - return z; - } - y1$1 = nat.nil.add(y.abs, natOne); - z.abs = z.abs.and(x.abs, y1$1); - z.neg = false; - return z; + Encoding.Ptr.prototype.EncodedLen = function(n) { + var enc, x, _q; + enc = this; + return (x = (_q = ((n + 2 >> 0)) / 3, (_q === _q && _q !== 1/0 && _q !== -1/0) ? _q >> 0 : $throwRuntimeError("integer divide by zero")), (((x >>> 16 << 16) * 4 >> 0) + (x << 16 >>> 16) * 4) >> 0); }; - Int.prototype.AndNot = function(x, y) { return this.$val.AndNot(x, y); }; - Int.Ptr.prototype.Or = function(x, y) { - var z, x1, y1, _tmp, _tmp$1, y1$1; - z = this; - if (x.neg === y.neg) { - if (x.neg) { - x1 = nat.nil.sub(x.abs, natOne); - y1 = nat.nil.sub(y.abs, natOne); - z.abs = z.abs.add(z.abs.and(x1, y1), natOne); - z.neg = true; - return z; - } - z.abs = z.abs.or(x.abs, y.abs); - z.neg = false; - return z; - } - if (x.neg) { - _tmp = y; _tmp$1 = x; x = _tmp; y = _tmp$1; - } - y1$1 = nat.nil.sub(y.abs, natOne); - z.abs = z.abs.add(z.abs.andNot(y1$1, x.abs), natOne); - z.neg = true; - return z; + Encoding.prototype.EncodedLen = function(n) { return this.$val.EncodedLen(n); }; + CorruptInputError.prototype.Error = function() { + var e; + e = this; + return "illegal base64 data at input byte " + strconv.FormatInt(new $Int64(e.$high, e.$low), 10); }; - Int.prototype.Or = function(x, y) { return this.$val.Or(x, y); }; - Int.Ptr.prototype.Xor = function(x, y) { - var z, x1, y1, _tmp, _tmp$1, y1$1; - z = this; - if (x.neg === y.neg) { - if (x.neg) { - x1 = nat.nil.sub(x.abs, natOne); - y1 = nat.nil.sub(y.abs, natOne); - z.abs = z.abs.xor(x1, y1); - z.neg = false; - return z; + $ptrType(CorruptInputError).prototype.Error = function() { return this.$get().Error(); }; + Encoding.Ptr.prototype.decode = function(dst, src) { + var n = 0, end = false, err = $ifaceNil, enc, olen, dbuf, dlen, _ref, _i, j, _tmp, _tmp$1, _tmp$2, in$1, _ref$1, _tmp$3, _tmp$4, _tmp$5, _tmp$6, _tmp$7, _tmp$8, _tmp$9, _tmp$10, _tmp$11, _tmp$12, _tmp$13, x, _tmp$14, _tmp$15, _tmp$16, _ref$2, _tmp$17, _tmp$18, _tmp$19; + enc = this; + olen = src.$length; + while (src.$length > 0 && !end) { + dbuf = ($arrayType($Uint8, 4)).zero(); $copy(dbuf, ($arrayType($Uint8, 4)).zero(), ($arrayType($Uint8, 4))); + dlen = 4; + _ref = dbuf; + _i = 0; + while (_i < 4) { + j = _i; + if (src.$length === 0) { + _tmp = n; _tmp$1 = false; _tmp$2 = new CorruptInputError(0, ((olen - src.$length >> 0) - j >> 0)); n = _tmp; end = _tmp$1; err = _tmp$2; + return [n, end, err]; + } + in$1 = ((0 < 0 || 0 >= src.$length) ? $throwRuntimeError("index out of range") : src.$array[src.$offset + 0]); + src = $subslice(src, 1); + if (in$1 === 61) { + _ref$1 = j; + if (_ref$1 === 0 || _ref$1 === 1) { + _tmp$3 = n; _tmp$4 = false; _tmp$5 = new CorruptInputError(0, ((olen - src.$length >> 0) - 1 >> 0)); n = _tmp$3; end = _tmp$4; err = _tmp$5; + return [n, end, err]; + } else if (_ref$1 === 2) { + if (src.$length === 0) { + _tmp$6 = n; _tmp$7 = false; _tmp$8 = new CorruptInputError(0, olen); n = _tmp$6; end = _tmp$7; err = _tmp$8; + return [n, end, err]; + } + if (!((((0 < 0 || 0 >= src.$length) ? $throwRuntimeError("index out of range") : src.$array[src.$offset + 0]) === 61))) { + _tmp$9 = n; _tmp$10 = false; _tmp$11 = new CorruptInputError(0, ((olen - src.$length >> 0) - 1 >> 0)); n = _tmp$9; end = _tmp$10; err = _tmp$11; + return [n, end, err]; + } + src = $subslice(src, 1); + } + if (src.$length > 0) { + err = new CorruptInputError(0, (olen - src.$length >> 0)); + } + _tmp$12 = j; _tmp$13 = true; dlen = _tmp$12; end = _tmp$13; + break; + } + (j < 0 || j >= dbuf.length) ? $throwRuntimeError("index out of range") : dbuf[j] = (x = enc.decodeMap, ((in$1 < 0 || in$1 >= x.length) ? $throwRuntimeError("index out of range") : x[in$1])); + if (((j < 0 || j >= dbuf.length) ? $throwRuntimeError("index out of range") : dbuf[j]) === 255) { + _tmp$14 = n; _tmp$15 = false; _tmp$16 = new CorruptInputError(0, ((olen - src.$length >> 0) - 1 >> 0)); n = _tmp$14; end = _tmp$15; err = _tmp$16; + return [n, end, err]; + } + _i++; } - z.abs = z.abs.xor(x.abs, y.abs); - z.neg = false; - return z; - } - if (x.neg) { - _tmp = y; _tmp$1 = x; x = _tmp; y = _tmp$1; + _ref$2 = dlen; + if (_ref$2 === 4) { + (2 < 0 || 2 >= dst.$length) ? $throwRuntimeError("index out of range") : dst.$array[dst.$offset + 2] = ((dbuf[2] << 6 << 24 >>> 24) | dbuf[3]) >>> 0; + (1 < 0 || 1 >= dst.$length) ? $throwRuntimeError("index out of range") : dst.$array[dst.$offset + 1] = ((dbuf[1] << 4 << 24 >>> 24) | (dbuf[2] >>> 2 << 24 >>> 24)) >>> 0; + (0 < 0 || 0 >= dst.$length) ? $throwRuntimeError("index out of range") : dst.$array[dst.$offset + 0] = ((dbuf[0] << 2 << 24 >>> 24) | (dbuf[1] >>> 4 << 24 >>> 24)) >>> 0; + } else if (_ref$2 === 3) { + (1 < 0 || 1 >= dst.$length) ? $throwRuntimeError("index out of range") : dst.$array[dst.$offset + 1] = ((dbuf[1] << 4 << 24 >>> 24) | (dbuf[2] >>> 2 << 24 >>> 24)) >>> 0; + (0 < 0 || 0 >= dst.$length) ? $throwRuntimeError("index out of range") : dst.$array[dst.$offset + 0] = ((dbuf[0] << 2 << 24 >>> 24) | (dbuf[1] >>> 4 << 24 >>> 24)) >>> 0; + } else if (_ref$2 === 2) { + (0 < 0 || 0 >= dst.$length) ? $throwRuntimeError("index out of range") : dst.$array[dst.$offset + 0] = ((dbuf[0] << 2 << 24 >>> 24) | (dbuf[1] >>> 4 << 24 >>> 24)) >>> 0; + } + dst = $subslice(dst, 3); + n = n + ((dlen - 1 >> 0)) >> 0; } - y1$1 = nat.nil.sub(y.abs, natOne); - z.abs = z.abs.add(z.abs.xor(x.abs, y1$1), natOne); - z.neg = true; - return z; + _tmp$17 = n; _tmp$18 = end; _tmp$19 = err; n = _tmp$17; end = _tmp$18; err = _tmp$19; + return [n, end, err]; }; - Int.prototype.Xor = function(x, y) { return this.$val.Xor(x, y); }; - Int.Ptr.prototype.Not = function(x) { - var z; - z = this; - if (x.neg) { - z.abs = z.abs.sub(x.abs, natOne); - z.neg = false; - return z; - } - z.abs = z.abs.add(x.abs, natOne); - z.neg = true; - return z; + Encoding.prototype.decode = function(dst, src) { return this.$val.decode(dst, src); }; + Encoding.Ptr.prototype.Decode = function(dst, src) { + var n = 0, err = $ifaceNil, enc, _tuple; + enc = this; + src = bytes.Map(removeNewlinesMapper, src); + _tuple = enc.decode(dst, src); n = _tuple[0]; err = _tuple[2]; + return [n, err]; }; - Int.prototype.Not = function(x) { return this.$val.Not(x); }; - Int.Ptr.prototype.GobEncode = function() { - var x, x$1, buf, i, b; - x = this; - if (x === ($ptrType(Int)).nil) { - return [($sliceType($Uint8)).nil, $ifaceNil]; - } - buf = ($sliceType($Uint8)).make((1 + (x$1 = x.abs.$length, (((x$1 >>> 16 << 16) * 4 >> 0) + (x$1 << 16 >>> 16) * 4) >> 0) >> 0)); - i = x.abs.bytes(buf) - 1 >> 0; - b = 2; - if (x.neg) { - b = (b | (1)) >>> 0; - } - (i < 0 || i >= buf.$length) ? $throwRuntimeError("index out of range") : buf.$array[buf.$offset + i] = b; - return [$subslice(buf, i), $ifaceNil]; + Encoding.prototype.Decode = function(dst, src) { return this.$val.Decode(dst, src); }; + Encoding.Ptr.prototype.DecodeString = function(s) { + var enc, dbuf, _tuple, n, err; + enc = this; + s = strings.Map(removeNewlinesMapper, s); + dbuf = ($sliceType($Uint8)).make(enc.DecodedLen(s.length)); + _tuple = enc.Decode(dbuf, new ($sliceType($Uint8))($stringToBytes(s))); n = _tuple[0]; err = _tuple[1]; + return [$subslice(dbuf, 0, n), err]; }; - Int.prototype.GobEncode = function() { return this.$val.GobEncode(); }; - Int.Ptr.prototype.GobDecode = function(buf) { - var z, b; - z = this; - if (buf.$length === 0) { - $copy(z, new Int.Ptr(false, nat.nil), Int); - return $ifaceNil; - } - b = ((0 < 0 || 0 >= buf.$length) ? $throwRuntimeError("index out of range") : buf.$array[buf.$offset + 0]); - if (!(((b >>> 1 << 24 >>> 24) === 1))) { - return errors.New(fmt.Sprintf("Int.GobDecode: encoding version %d not supported", new ($sliceType($emptyInterface))([new $Uint8((b >>> 1 << 24 >>> 24))]))); - } - z.neg = !((((b & 1) >>> 0) === 0)); - z.abs = z.abs.setBytes($subslice(buf, 1)); - return $ifaceNil; + Encoding.prototype.DecodeString = function(s) { return this.$val.DecodeString(s); }; + Encoding.Ptr.prototype.DecodedLen = function(n) { + var enc, x, _q; + enc = this; + return (x = (_q = n / 4, (_q === _q && _q !== 1/0 && _q !== -1/0) ? _q >> 0 : $throwRuntimeError("integer divide by zero")), (((x >>> 16 << 16) * 3 >> 0) + (x << 16 >>> 16) * 3) >> 0); }; - Int.prototype.GobDecode = function(buf) { return this.$val.GobDecode(buf); }; - Int.Ptr.prototype.MarshalJSON = function() { - var z; - z = this; - return [new ($sliceType($Uint8))($stringToBytes(z.String())), $ifaceNil]; + Encoding.prototype.DecodedLen = function(n) { return this.$val.DecodedLen(n); }; + $pkg.$init = function() { + ($ptrType(Encoding)).methods = [["Decode", "Decode", "", $funcType([($sliceType($Uint8)), ($sliceType($Uint8))], [$Int, $error], false), -1], ["DecodeString", "DecodeString", "", $funcType([$String], [($sliceType($Uint8)), $error], false), -1], ["DecodedLen", "DecodedLen", "", $funcType([$Int], [$Int], false), -1], ["Encode", "Encode", "", $funcType([($sliceType($Uint8)), ($sliceType($Uint8))], [], false), -1], ["EncodeToString", "EncodeToString", "", $funcType([($sliceType($Uint8))], [$String], false), -1], ["EncodedLen", "EncodedLen", "", $funcType([$Int], [$Int], false), -1], ["decode", "decode", "encoding/base64", $funcType([($sliceType($Uint8)), ($sliceType($Uint8))], [$Int, $Bool, $error], false), -1]]; + Encoding.init([["encode", "encode", "encoding/base64", $String, ""], ["decodeMap", "decodeMap", "encoding/base64", ($arrayType($Uint8, 256)), ""]]); + ($ptrType(encoder)).methods = [["Close", "Close", "", $funcType([], [$error], false), -1], ["Write", "Write", "", $funcType([($sliceType($Uint8))], [$Int, $error], false), -1]]; + encoder.init([["err", "err", "encoding/base64", $error, ""], ["enc", "enc", "encoding/base64", ($ptrType(Encoding)), ""], ["w", "w", "encoding/base64", io.Writer, ""], ["buf", "buf", "encoding/base64", ($arrayType($Uint8, 3)), ""], ["nbuf", "nbuf", "encoding/base64", $Int, ""], ["out", "out", "encoding/base64", ($arrayType($Uint8, 1024)), ""]]); + CorruptInputError.methods = [["Error", "Error", "", $funcType([], [$String], false), -1]]; + ($ptrType(CorruptInputError)).methods = [["Error", "Error", "", $funcType([], [$String], false), -1]]; + $pkg.StdEncoding = NewEncoding("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"); + $pkg.URLEncoding = NewEncoding("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_"); + removeNewlinesMapper = (function(r) { + if ((r === 13) || (r === 10)) { + return -1; + } + return r; + }); }; - Int.prototype.MarshalJSON = function() { return this.$val.MarshalJSON(); }; - Int.Ptr.prototype.UnmarshalJSON = function(text) { - var z, _tuple, ok; - z = this; - _tuple = z.SetString($bytesToString(text), 0); ok = _tuple[1]; - if (!ok) { - return fmt.Errorf("math/big: cannot unmarshal %q into a *big.Int", new ($sliceType($emptyInterface))([text])); + return $pkg; +})(); +$packages["unicode/utf16"] = (function() { + var $pkg = {}, IsSurrogate, DecodeRune; + IsSurrogate = $pkg.IsSurrogate = function(r) { + return 55296 <= r && r < 57344; + }; + DecodeRune = $pkg.DecodeRune = function(r1, r2) { + if (55296 <= r1 && r1 < 56320 && 56320 <= r2 && r2 < 57344) { + return ((((r1 - 55296 >> 0)) << 10 >> 0) | ((r2 - 56320 >> 0))) + 65536 >> 0; } - return $ifaceNil; + return 65533; }; - Int.prototype.UnmarshalJSON = function(text) { return this.$val.UnmarshalJSON(text); }; - Int.Ptr.prototype.MarshalText = function() { - var text = ($sliceType($Uint8)).nil, err = $ifaceNil, z, _tmp, _tmp$1; - z = this; - _tmp = new ($sliceType($Uint8))($stringToBytes(z.String())); _tmp$1 = $ifaceNil; text = _tmp; err = _tmp$1; - return [text, err]; + $pkg.$init = function() { }; - Int.prototype.MarshalText = function() { return this.$val.MarshalText(); }; - Int.Ptr.prototype.UnmarshalText = function(text) { - var z, _tuple, ok; - z = this; - _tuple = z.SetString($bytesToString(text), 0); ok = _tuple[1]; - if (!ok) { - return fmt.Errorf("math/big: cannot unmarshal %q into a *big.Int", new ($sliceType($emptyInterface))([text])); + return $pkg; +})(); +$packages["encoding/json"] = (function() { + var $pkg = {}, bytes = $packages["bytes"], encoding = $packages["encoding"], base64 = $packages["encoding/base64"], errors = $packages["errors"], fmt = $packages["fmt"], reflect = $packages["reflect"], runtime = $packages["runtime"], strconv = $packages["strconv"], unicode = $packages["unicode"], utf16 = $packages["unicode/utf16"], utf8 = $packages["unicode/utf8"], math = $packages["math"], sort = $packages["sort"], strings = $packages["strings"], sync = $packages["sync"], io = $packages["io"], Unmarshaler, UnmarshalTypeError, InvalidUnmarshalError, Number, decodeState, Marshaler, UnsupportedTypeError, UnsupportedValueError, MarshalerError, encodeState, encoderFunc, floatEncoder, structEncoder, mapEncoder, sliceEncoder, arrayEncoder, ptrEncoder, condAddrEncoder, stringValues, field, byName, byIndex, SyntaxError, scanner, Decoder, Encoder, tagOptions, errPhase, numberType, hex, encodeStatePool, byteSliceType, encoderCache, marshalerType, textMarshalerType, float32Encoder, float64Encoder, fieldCache, Unmarshal, getu4, unquote, unquoteBytes, Marshal, newEncodeState, isEmptyValue, valueEncoder, typeEncoder, newTypeEncoder, invalidValueEncoder, marshalerEncoder, addrMarshalerEncoder, textMarshalerEncoder, addrTextMarshalerEncoder, boolEncoder, intEncoder, uintEncoder, stringEncoder, interfaceEncoder, unsupportedTypeEncoder, newStructEncoder, newMapEncoder, encodeByteSlice, newSliceEncoder, newArrayEncoder, newPtrEncoder, newCondAddrEncoder, isValidTag, fieldByIndex, typeByIndex, fillField, typeFields, dominantField, cachedTypeFields, foldFunc, equalFoldRight, asciiEqualFold, simpleLetterEqualFold, compact, checkValid, nextValue, isSpace, stateBeginValueOrEmpty, stateBeginValue, stateBeginStringOrEmpty, stateBeginString, stateEndValue, stateEndTop, stateInString, stateInStringEsc, stateInStringEscU, stateInStringEscU1, stateInStringEscU12, stateInStringEscU123, stateNeg, state1, state0, stateDot, stateDot0, stateE, stateESign, stateE0, stateT, stateTr, stateTru, stateF, stateFa, stateFal, stateFals, stateN, stateNu, stateNul, stateError, quoteChar, stateRedo, NewDecoder, nonSpace, NewEncoder, parseTag; + Unmarshaler = $pkg.Unmarshaler = $newType(8, "Interface", "json.Unmarshaler", "Unmarshaler", "encoding/json", null); + UnmarshalTypeError = $pkg.UnmarshalTypeError = $newType(0, "Struct", "json.UnmarshalTypeError", "UnmarshalTypeError", "encoding/json", function(Value_, Type_) { + this.$val = this; + this.Value = Value_ !== undefined ? Value_ : ""; + this.Type = Type_ !== undefined ? Type_ : $ifaceNil; + }); + InvalidUnmarshalError = $pkg.InvalidUnmarshalError = $newType(0, "Struct", "json.InvalidUnmarshalError", "InvalidUnmarshalError", "encoding/json", function(Type_) { + this.$val = this; + this.Type = Type_ !== undefined ? Type_ : $ifaceNil; + }); + Number = $pkg.Number = $newType(8, "String", "json.Number", "Number", "encoding/json", null); + decodeState = $pkg.decodeState = $newType(0, "Struct", "json.decodeState", "decodeState", "encoding/json", function(data_, off_, scan_, nextscan_, savedError_, tempstr_, useNumber_) { + this.$val = this; + this.data = data_ !== undefined ? data_ : ($sliceType($Uint8)).nil; + this.off = off_ !== undefined ? off_ : 0; + this.scan = scan_ !== undefined ? scan_ : new scanner.Ptr(); + this.nextscan = nextscan_ !== undefined ? nextscan_ : new scanner.Ptr(); + this.savedError = savedError_ !== undefined ? savedError_ : $ifaceNil; + this.tempstr = tempstr_ !== undefined ? tempstr_ : ""; + this.useNumber = useNumber_ !== undefined ? useNumber_ : false; + }); + Marshaler = $pkg.Marshaler = $newType(8, "Interface", "json.Marshaler", "Marshaler", "encoding/json", null); + UnsupportedTypeError = $pkg.UnsupportedTypeError = $newType(0, "Struct", "json.UnsupportedTypeError", "UnsupportedTypeError", "encoding/json", function(Type_) { + this.$val = this; + this.Type = Type_ !== undefined ? Type_ : $ifaceNil; + }); + UnsupportedValueError = $pkg.UnsupportedValueError = $newType(0, "Struct", "json.UnsupportedValueError", "UnsupportedValueError", "encoding/json", function(Value_, Str_) { + this.$val = this; + this.Value = Value_ !== undefined ? Value_ : new reflect.Value.Ptr(); + this.Str = Str_ !== undefined ? Str_ : ""; + }); + MarshalerError = $pkg.MarshalerError = $newType(0, "Struct", "json.MarshalerError", "MarshalerError", "encoding/json", function(Type_, Err_) { + this.$val = this; + this.Type = Type_ !== undefined ? Type_ : $ifaceNil; + this.Err = Err_ !== undefined ? Err_ : $ifaceNil; + }); + encodeState = $pkg.encodeState = $newType(0, "Struct", "json.encodeState", "encodeState", "encoding/json", function(Buffer_, scratch_) { + this.$val = this; + this.Buffer = Buffer_ !== undefined ? Buffer_ : new bytes.Buffer.Ptr(); + this.scratch = scratch_ !== undefined ? scratch_ : ($arrayType($Uint8, 64)).zero(); + }); + encoderFunc = $pkg.encoderFunc = $newType(4, "Func", "json.encoderFunc", "encoderFunc", "encoding/json", null); + floatEncoder = $pkg.floatEncoder = $newType(4, "Int", "json.floatEncoder", "floatEncoder", "encoding/json", null); + structEncoder = $pkg.structEncoder = $newType(0, "Struct", "json.structEncoder", "structEncoder", "encoding/json", function(fields_, fieldEncs_) { + this.$val = this; + this.fields = fields_ !== undefined ? fields_ : ($sliceType(field)).nil; + this.fieldEncs = fieldEncs_ !== undefined ? fieldEncs_ : ($sliceType(encoderFunc)).nil; + }); + mapEncoder = $pkg.mapEncoder = $newType(0, "Struct", "json.mapEncoder", "mapEncoder", "encoding/json", function(elemEnc_) { + this.$val = this; + this.elemEnc = elemEnc_ !== undefined ? elemEnc_ : $throwNilPointerError; + }); + sliceEncoder = $pkg.sliceEncoder = $newType(0, "Struct", "json.sliceEncoder", "sliceEncoder", "encoding/json", function(arrayEnc_) { + this.$val = this; + this.arrayEnc = arrayEnc_ !== undefined ? arrayEnc_ : $throwNilPointerError; + }); + arrayEncoder = $pkg.arrayEncoder = $newType(0, "Struct", "json.arrayEncoder", "arrayEncoder", "encoding/json", function(elemEnc_) { + this.$val = this; + this.elemEnc = elemEnc_ !== undefined ? elemEnc_ : $throwNilPointerError; + }); + ptrEncoder = $pkg.ptrEncoder = $newType(0, "Struct", "json.ptrEncoder", "ptrEncoder", "encoding/json", function(elemEnc_) { + this.$val = this; + this.elemEnc = elemEnc_ !== undefined ? elemEnc_ : $throwNilPointerError; + }); + condAddrEncoder = $pkg.condAddrEncoder = $newType(0, "Struct", "json.condAddrEncoder", "condAddrEncoder", "encoding/json", function(canAddrEnc_, elseEnc_) { + this.$val = this; + this.canAddrEnc = canAddrEnc_ !== undefined ? canAddrEnc_ : $throwNilPointerError; + this.elseEnc = elseEnc_ !== undefined ? elseEnc_ : $throwNilPointerError; + }); + stringValues = $pkg.stringValues = $newType(12, "Slice", "json.stringValues", "stringValues", "encoding/json", null); + field = $pkg.field = $newType(0, "Struct", "json.field", "field", "encoding/json", function(name_, nameBytes_, equalFold_, tag_, index_, typ_, omitEmpty_, quoted_) { + this.$val = this; + this.name = name_ !== undefined ? name_ : ""; + this.nameBytes = nameBytes_ !== undefined ? nameBytes_ : ($sliceType($Uint8)).nil; + this.equalFold = equalFold_ !== undefined ? equalFold_ : $throwNilPointerError; + this.tag = tag_ !== undefined ? tag_ : false; + this.index = index_ !== undefined ? index_ : ($sliceType($Int)).nil; + this.typ = typ_ !== undefined ? typ_ : $ifaceNil; + this.omitEmpty = omitEmpty_ !== undefined ? omitEmpty_ : false; + this.quoted = quoted_ !== undefined ? quoted_ : false; + }); + byName = $pkg.byName = $newType(12, "Slice", "json.byName", "byName", "encoding/json", null); + byIndex = $pkg.byIndex = $newType(12, "Slice", "json.byIndex", "byIndex", "encoding/json", null); + SyntaxError = $pkg.SyntaxError = $newType(0, "Struct", "json.SyntaxError", "SyntaxError", "encoding/json", function(msg_, Offset_) { + this.$val = this; + this.msg = msg_ !== undefined ? msg_ : ""; + this.Offset = Offset_ !== undefined ? Offset_ : new $Int64(0, 0); + }); + scanner = $pkg.scanner = $newType(0, "Struct", "json.scanner", "scanner", "encoding/json", function(step_, endTop_, parseState_, err_, redo_, redoCode_, redoState_, bytes_) { + this.$val = this; + this.step = step_ !== undefined ? step_ : $throwNilPointerError; + this.endTop = endTop_ !== undefined ? endTop_ : false; + this.parseState = parseState_ !== undefined ? parseState_ : ($sliceType($Int)).nil; + this.err = err_ !== undefined ? err_ : $ifaceNil; + this.redo = redo_ !== undefined ? redo_ : false; + this.redoCode = redoCode_ !== undefined ? redoCode_ : 0; + this.redoState = redoState_ !== undefined ? redoState_ : $throwNilPointerError; + this.bytes = bytes_ !== undefined ? bytes_ : new $Int64(0, 0); + }); + Decoder = $pkg.Decoder = $newType(0, "Struct", "json.Decoder", "Decoder", "encoding/json", function(r_, buf_, d_, scan_, err_) { + this.$val = this; + this.r = r_ !== undefined ? r_ : $ifaceNil; + this.buf = buf_ !== undefined ? buf_ : ($sliceType($Uint8)).nil; + this.d = d_ !== undefined ? d_ : new decodeState.Ptr(); + this.scan = scan_ !== undefined ? scan_ : new scanner.Ptr(); + this.err = err_ !== undefined ? err_ : $ifaceNil; + }); + Encoder = $pkg.Encoder = $newType(0, "Struct", "json.Encoder", "Encoder", "encoding/json", function(w_, e_, err_) { + this.$val = this; + this.w = w_ !== undefined ? w_ : $ifaceNil; + this.e = e_ !== undefined ? e_ : new encodeState.Ptr(); + this.err = err_ !== undefined ? err_ : $ifaceNil; + }); + tagOptions = $pkg.tagOptions = $newType(8, "String", "json.tagOptions", "tagOptions", "encoding/json", null); + Unmarshal = $pkg.Unmarshal = function(data, v) { + var d, err; + d = new decodeState.Ptr(); $copy(d, new decodeState.Ptr(), decodeState); + err = checkValid(data, d.scan); + if (!($interfaceIsEqual(err, $ifaceNil))) { + return err; } - return $ifaceNil; + d.init(data); + return d.unmarshal(v); }; - Int.prototype.UnmarshalText = function(text) { return this.$val.UnmarshalText(text); }; - nat.prototype.clear = function() { - var z, _ref, _i, i; - z = this; - _ref = z; - _i = 0; - while (_i < _ref.$length) { - i = _i; - (i < 0 || i >= z.$length) ? $throwRuntimeError("index out of range") : z.$array[z.$offset + i] = 0; - _i++; - } + UnmarshalTypeError.Ptr.prototype.Error = function() { + var e; + e = this; + return "json: cannot unmarshal " + e.Value + " into Go value of type " + e.Type.String(); }; - $ptrType(nat).prototype.clear = function() { return this.$get().clear(); }; - nat.prototype.norm = function() { - var z, i, x; - z = this; - i = z.$length; - while (i > 0 && ((x = i - 1 >> 0, ((x < 0 || x >= z.$length) ? $throwRuntimeError("index out of range") : z.$array[z.$offset + x])) === 0)) { - i = i - (1) >> 0; + UnmarshalTypeError.prototype.Error = function() { return this.$val.Error(); }; + InvalidUnmarshalError.Ptr.prototype.Error = function() { + var e; + e = this; + if ($interfaceIsEqual(e.Type, $ifaceNil)) { + return "json: Unmarshal(nil)"; } - return $subslice(z, 0, i); - }; - $ptrType(nat).prototype.norm = function() { return this.$get().norm(); }; - nat.prototype.make = function(n) { - var z; - z = this; - if (n <= z.$capacity) { - return $subslice(z, 0, n); + if (!((e.Type.Kind() === 22))) { + return "json: Unmarshal(non-pointer " + e.Type.String() + ")"; } - return nat.make(n, (n + 4 >> 0)); + return "json: Unmarshal(nil " + e.Type.String() + ")"; }; - $ptrType(nat).prototype.make = function(n) { return this.$get().make(n); }; - nat.prototype.setWord = function(x) { - var z; - z = this; - if (x === 0) { - return z.make(0); + InvalidUnmarshalError.prototype.Error = function() { return this.$val.Error(); }; + decodeState.Ptr.prototype.unmarshal = function(v) { + var err = $ifaceNil, $deferred = [], $err = null, d, rv; + /* */ try { $deferFrames.push($deferred); + d = this; + $deferred.push([(function() { + var r, _tuple, ok; + r = $recover(); + if (!($interfaceIsEqual(r, $ifaceNil))) { + _tuple = $assertType(r, runtime.Error, true); ok = _tuple[1]; + if (ok) { + $panic(r); + } + err = $assertType(r, $error); + } + }), []]); + rv = new reflect.Value.Ptr(); $copy(rv, reflect.ValueOf(v), reflect.Value); + if (!((rv.Kind() === 22)) || rv.IsNil()) { + err = new InvalidUnmarshalError.Ptr(reflect.TypeOf(v)); + return err; } - z = z.make(1); - (0 < 0 || 0 >= z.$length) ? $throwRuntimeError("index out of range") : z.$array[z.$offset + 0] = x; - return z; + d.scan.reset(); + d.value($clone(rv, reflect.Value)); + err = d.savedError; + return err; + /* */ } catch(err) { $err = err; } finally { $deferFrames.pop(); $callDeferred($deferred, $err); return err; } }; - $ptrType(nat).prototype.setWord = function(x) { return this.$get().setWord(x); }; - nat.prototype.setUint64 = function(x) { - var z, w, x$1, n, t, _ref, _i, i; - z = this; - w = (x.$low >>> 0); - if ((x$1 = new $Uint64(0, w.constructor === Number ? w : 1), (x$1.$high === x.$high && x$1.$low === x.$low))) { - return z.setWord(w); - } - n = 0; - t = x; - while ((t.$high > 0 || (t.$high === 0 && t.$low > 0))) { - n = n + (1) >> 0; - t = $shiftRightUint64(t, (32)); - } - z = z.make(n); - _ref = z; - _i = 0; - while (_i < _ref.$length) { - i = _i; - (i < 0 || i >= z.$length) ? $throwRuntimeError("index out of range") : z.$array[z.$offset + i] = (new $Uint64(x.$high & 0, (x.$low & 4294967295) >>> 0).$low >>> 0); - x = $shiftRightUint64(x, (32)); - _i++; - } - return z; + decodeState.prototype.unmarshal = function(v) { return this.$val.unmarshal(v); }; + Number.prototype.String = function() { + var n; + n = this.$val !== undefined ? this.$val : this; + return n; }; - $ptrType(nat).prototype.setUint64 = function(x) { return this.$get().setUint64(x); }; - nat.prototype.set = function(x) { - var z; - z = this; - z = z.make(x.$length); - $copySlice(z, x); - return z; + $ptrType(Number).prototype.String = function() { return new Number(this.$get()).String(); }; + Number.prototype.Float64 = function() { + var n; + n = this.$val !== undefined ? this.$val : this; + return strconv.ParseFloat(n, 64); }; - $ptrType(nat).prototype.set = function(x) { return this.$get().set(x); }; - nat.prototype.add = function(x, y) { - var z, m, n, x$1, c, x$2, x$3; - z = this; - m = x.$length; - n = y.$length; - if (m < n) { - return z.add(y, x); - } else if (m === 0) { - return z.make(0); - } else if (n === 0) { - return z.set(x); - } - z = z.make(m + 1 >> 0); - c = addVV((x$1 = $subslice(z, 0, n), $subslice(new ($sliceType(Word))(x$1.$array), x$1.$offset, x$1.$offset + x$1.$length)), $subslice(new ($sliceType(Word))(x.$array), x.$offset, x.$offset + x.$length), $subslice(new ($sliceType(Word))(y.$array), y.$offset, y.$offset + y.$length)); - if (m > n) { - c = addVW((x$2 = $subslice(z, n, m), $subslice(new ($sliceType(Word))(x$2.$array), x$2.$offset, x$2.$offset + x$2.$length)), (x$3 = $subslice(x, n), $subslice(new ($sliceType(Word))(x$3.$array), x$3.$offset, x$3.$offset + x$3.$length)), c); - } - (m < 0 || m >= z.$length) ? $throwRuntimeError("index out of range") : z.$array[z.$offset + m] = c; - return z.norm(); + $ptrType(Number).prototype.Float64 = function() { return new Number(this.$get()).Float64(); }; + Number.prototype.Int64 = function() { + var n; + n = this.$val !== undefined ? this.$val : this; + return strconv.ParseInt(n, 10, 64); }; - $ptrType(nat).prototype.add = function(x, y) { return this.$get().add(x, y); }; - nat.prototype.sub = function(x, y) { - var z, m, n, x$1, c, x$2, x$3; - z = this; - m = x.$length; - n = y.$length; - if (m < n) { - $panic(new $String("underflow")); - } else if (m === 0) { - return z.make(0); - } else if (n === 0) { - return z.set(x); + $ptrType(Number).prototype.Int64 = function() { return new Number(this.$get()).Int64(); }; + decodeState.Ptr.prototype.init = function(data) { + var d; + d = this; + d.data = data; + d.off = 0; + d.savedError = $ifaceNil; + return d; + }; + decodeState.prototype.init = function(data) { return this.$val.init(data); }; + decodeState.Ptr.prototype.error = function(err) { + var d; + d = this; + $panic(err); + }; + decodeState.prototype.error = function(err) { return this.$val.error(err); }; + decodeState.Ptr.prototype.saveError = function(err) { + var d; + d = this; + if ($interfaceIsEqual(d.savedError, $ifaceNil)) { + d.savedError = err; } - z = z.make(m); - c = subVV((x$1 = $subslice(z, 0, n), $subslice(new ($sliceType(Word))(x$1.$array), x$1.$offset, x$1.$offset + x$1.$length)), $subslice(new ($sliceType(Word))(x.$array), x.$offset, x.$offset + x.$length), $subslice(new ($sliceType(Word))(y.$array), y.$offset, y.$offset + y.$length)); - if (m > n) { - c = subVW((x$2 = $subslice(z, n), $subslice(new ($sliceType(Word))(x$2.$array), x$2.$offset, x$2.$offset + x$2.$length)), (x$3 = $subslice(x, n), $subslice(new ($sliceType(Word))(x$3.$array), x$3.$offset, x$3.$offset + x$3.$length)), c); + }; + decodeState.prototype.saveError = function(err) { return this.$val.saveError(err); }; + decodeState.Ptr.prototype.next = function() { + var d, x, x$1, c, _tuple, item, rest, err; + d = this; + c = (x = d.data, x$1 = d.off, ((x$1 < 0 || x$1 >= x.$length) ? $throwRuntimeError("index out of range") : x.$array[x.$offset + x$1])); + _tuple = nextValue($subslice(d.data, d.off), d.nextscan); item = _tuple[0]; rest = _tuple[1]; err = _tuple[2]; + if (!($interfaceIsEqual(err, $ifaceNil))) { + d.error(err); } - if (!((c === 0))) { - $panic(new $String("underflow")); + d.off = d.data.$length - rest.$length >> 0; + if (c === 123) { + d.scan.step(d.scan, 125); + } else { + d.scan.step(d.scan, 93); } - return z.norm(); + return item; }; - $ptrType(nat).prototype.sub = function(x, y) { return this.$get().sub(x, y); }; - nat.prototype.cmp = function(y) { - var r = 0, x, m, n, i; - x = this; - m = x.$length; - n = y.$length; - if (!((m === n)) || (m === 0)) { - if (m < n) { - r = -1; - } else if (m > n) { - r = 1; + decodeState.prototype.next = function() { return this.$val.next(); }; + decodeState.Ptr.prototype.scanWhile = function(op) { + var d, newOp, x, x$1, c; + d = this; + newOp = 0; + while (true) { + if (d.off >= d.data.$length) { + newOp = d.scan.eof(); + d.off = d.data.$length + 1 >> 0; + } else { + c = ((x = d.data, x$1 = d.off, ((x$1 < 0 || x$1 >= x.$length) ? $throwRuntimeError("index out of range") : x.$array[x.$offset + x$1])) >> 0); + d.off = d.off + (1) >> 0; + newOp = d.scan.step(d.scan, c); + } + if (!((newOp === op))) { + break; } - return r; } - i = m - 1 >> 0; - while (i > 0 && (((i < 0 || i >= x.$length) ? $throwRuntimeError("index out of range") : x.$array[x.$offset + i]) === ((i < 0 || i >= y.$length) ? $throwRuntimeError("index out of range") : y.$array[y.$offset + i]))) { - i = i - (1) >> 0; + return newOp; + }; + decodeState.prototype.scanWhile = function(op) { return this.$val.scanWhile(op); }; + decodeState.Ptr.prototype.value = function(v) { + var d, _tuple, rest, err, n, x, x$1, op, _ref; + d = this; + if (!v.IsValid()) { + _tuple = nextValue($subslice(d.data, d.off), d.nextscan); rest = _tuple[1]; err = _tuple[2]; + if (!($interfaceIsEqual(err, $ifaceNil))) { + d.error(err); + } + d.off = d.data.$length - rest.$length >> 0; + if (d.scan.redo) { + d.scan.redo = false; + d.scan.step = stateBeginValue; + } + d.scan.step(d.scan, 34); + d.scan.step(d.scan, 34); + n = d.scan.parseState.$length; + if (n > 0 && ((x = d.scan.parseState, x$1 = n - 1 >> 0, ((x$1 < 0 || x$1 >= x.$length) ? $throwRuntimeError("index out of range") : x.$array[x.$offset + x$1])) === 0)) { + d.scan.step(d.scan, 58); + d.scan.step(d.scan, 34); + d.scan.step(d.scan, 34); + d.scan.step(d.scan, 125); + } + return; } - if (((i < 0 || i >= x.$length) ? $throwRuntimeError("index out of range") : x.$array[x.$offset + i]) < ((i < 0 || i >= y.$length) ? $throwRuntimeError("index out of range") : y.$array[y.$offset + i])) { - r = -1; - } else if (((i < 0 || i >= x.$length) ? $throwRuntimeError("index out of range") : x.$array[x.$offset + i]) > ((i < 0 || i >= y.$length) ? $throwRuntimeError("index out of range") : y.$array[y.$offset + i])) { - r = 1; + op = d.scanWhile(9); + _ref = op; + if (_ref === 6) { + d.array($clone(v, reflect.Value)); + } else if (_ref === 2) { + d.object($clone(v, reflect.Value)); + } else if (_ref === 1) { + d.literal($clone(v, reflect.Value)); + } else { + d.error(errPhase); } - return r; }; - $ptrType(nat).prototype.cmp = function(y) { return this.$get().cmp(y); }; - nat.prototype.mulAddWW = function(x, y, r) { - var z, m, x$1; - z = this; - m = x.$length; - if ((m === 0) || (y === 0)) { - return z.setWord(r); + decodeState.prototype.value = function(v) { return this.$val.value(v); }; + decodeState.Ptr.prototype.indirect = function(v, decodingNull) { + var d, e, _tuple, u, ok, _tuple$1, u$1, ok$1; + d = this; + if (!((v.Kind() === 22)) && !(v.Type().Name() === "") && v.CanAddr()) { + $copy(v, v.Addr(), reflect.Value); } - z = z.make(m + 1 >> 0); - (m < 0 || m >= z.$length) ? $throwRuntimeError("index out of range") : z.$array[z.$offset + m] = mulAddVWW((x$1 = $subslice(z, 0, m), $subslice(new ($sliceType(Word))(x$1.$array), x$1.$offset, x$1.$offset + x$1.$length)), $subslice(new ($sliceType(Word))(x.$array), x.$offset, x.$offset + x.$length), y, r); - return z.norm(); - }; - $ptrType(nat).prototype.mulAddWW = function(x, y, r) { return this.$get().mulAddWW(x, y, r); }; - basicMul = function(z, x, y) { - var _ref, _i, i, d, x$1, x$2; - $subslice(z, 0, (x.$length + y.$length >> 0)).clear(); - _ref = y; - _i = 0; - while (_i < _ref.$length) { - i = _i; - d = ((_i < 0 || _i >= _ref.$length) ? $throwRuntimeError("index out of range") : _ref.$array[_ref.$offset + _i]); - if (!((d === 0))) { - (x$2 = x.$length + i >> 0, (x$2 < 0 || x$2 >= z.$length) ? $throwRuntimeError("index out of range") : z.$array[z.$offset + x$2] = addMulVVW((x$1 = $subslice(z, i, (i + x.$length >> 0)), $subslice(new ($sliceType(Word))(x$1.$array), x$1.$offset, x$1.$offset + x$1.$length)), $subslice(new ($sliceType(Word))(x.$array), x.$offset, x.$offset + x.$length), d)); + while (true) { + if ((v.Kind() === 20) && !v.IsNil()) { + e = new reflect.Value.Ptr(); $copy(e, v.Elem(), reflect.Value); + if ((e.Kind() === 22) && !e.IsNil() && (!decodingNull || (e.Elem().Kind() === 22))) { + $copy(v, e, reflect.Value); + continue; + } } - _i++; + if (!((v.Kind() === 22))) { + break; + } + if (!((v.Elem().Kind() === 22)) && decodingNull && v.CanSet()) { + break; + } + if (v.IsNil()) { + v.Set($clone(reflect.New(v.Type().Elem()), reflect.Value)); + } + if (v.Type().NumMethod() > 0) { + _tuple = $assertType(v.Interface(), Unmarshaler, true); u = _tuple[0]; ok = _tuple[1]; + if (ok) { + return [u, $ifaceNil, new reflect.Value.Ptr(($ptrType(reflect.rtype)).nil, 0, 0, 0)]; + } + _tuple$1 = $assertType(v.Interface(), encoding.TextUnmarshaler, true); u$1 = _tuple$1[0]; ok$1 = _tuple$1[1]; + if (ok$1) { + return [$ifaceNil, u$1, new reflect.Value.Ptr(($ptrType(reflect.rtype)).nil, 0, 0, 0)]; + } + } + $copy(v, v.Elem(), reflect.Value); } + return [$ifaceNil, $ifaceNil, v]; }; - karatsubaAdd = function(z, x, n) { - var x$1, c, x$2, x$3; - c = addVV((x$1 = $subslice(z, 0, n), $subslice(new ($sliceType(Word))(x$1.$array), x$1.$offset, x$1.$offset + x$1.$length)), $subslice(new ($sliceType(Word))(z.$array), z.$offset, z.$offset + z.$length), $subslice(new ($sliceType(Word))(x.$array), x.$offset, x.$offset + x.$length)); - if (!((c === 0))) { - addVW((x$2 = $subslice(z, n, (n + (n >> 1 >> 0) >> 0)), $subslice(new ($sliceType(Word))(x$2.$array), x$2.$offset, x$2.$offset + x$2.$length)), (x$3 = $subslice(z, n), $subslice(new ($sliceType(Word))(x$3.$array), x$3.$offset, x$3.$offset + x$3.$length)), c); - } - }; - karatsubaSub = function(z, x, n) { - var x$1, c, x$2, x$3; - c = subVV((x$1 = $subslice(z, 0, n), $subslice(new ($sliceType(Word))(x$1.$array), x$1.$offset, x$1.$offset + x$1.$length)), $subslice(new ($sliceType(Word))(z.$array), z.$offset, z.$offset + z.$length), $subslice(new ($sliceType(Word))(x.$array), x.$offset, x.$offset + x.$length)); - if (!((c === 0))) { - subVW((x$2 = $subslice(z, n, (n + (n >> 1 >> 0) >> 0)), $subslice(new ($sliceType(Word))(x$2.$array), x$2.$offset, x$2.$offset + x$2.$length)), (x$3 = $subslice(z, n), $subslice(new ($sliceType(Word))(x$3.$array), x$3.$offset, x$3.$offset + x$3.$length)), c); - } - }; - karatsuba = function(z, x, y) { - var n, n2, _tmp, _tmp$1, x1, x0, _tmp$2, _tmp$3, y1, y0, s, xd, yd, p, r; - n = y.$length; - if (!(((n & 1) === 0)) || n < karatsubaThreshold || n < 2) { - basicMul(z, x, y); + decodeState.prototype.indirect = function(v, decodingNull) { return this.$val.indirect(v, decodingNull); }; + decodeState.Ptr.prototype.array = function(v) { + var d, _tuple, u, ut, pv, err, _ref, i, op, _q, newcap, newv, z; + d = this; + _tuple = d.indirect($clone(v, reflect.Value), false); u = _tuple[0]; ut = _tuple[1]; pv = new reflect.Value.Ptr(); $copy(pv, _tuple[2], reflect.Value); + if (!($interfaceIsEqual(u, $ifaceNil))) { + d.off = d.off - (1) >> 0; + err = u.UnmarshalJSON(d.next()); + if (!($interfaceIsEqual(err, $ifaceNil))) { + d.error(err); + } return; } - n2 = n >> 1 >> 0; - _tmp = $subslice(x, n2); _tmp$1 = $subslice(x, 0, n2); x1 = _tmp; x0 = _tmp$1; - _tmp$2 = $subslice(y, n2); _tmp$3 = $subslice(y, 0, n2); y1 = _tmp$2; y0 = _tmp$3; - karatsuba(z, x0, y0); - karatsuba($subslice(z, n), x1, y1); - s = 1; - xd = $subslice(z, ((((2 >>> 16 << 16) * n >> 0) + (2 << 16 >>> 16) * n) >> 0), (((((2 >>> 16 << 16) * n >> 0) + (2 << 16 >>> 16) * n) >> 0) + n2 >> 0)); - if (!((subVV($subslice(new ($sliceType(Word))(xd.$array), xd.$offset, xd.$offset + xd.$length), $subslice(new ($sliceType(Word))(x1.$array), x1.$offset, x1.$offset + x1.$length), $subslice(new ($sliceType(Word))(x0.$array), x0.$offset, x0.$offset + x0.$length)) === 0))) { - s = -s; - subVV($subslice(new ($sliceType(Word))(xd.$array), xd.$offset, xd.$offset + xd.$length), $subslice(new ($sliceType(Word))(x0.$array), x0.$offset, x0.$offset + x0.$length), $subslice(new ($sliceType(Word))(x1.$array), x1.$offset, x1.$offset + x1.$length)); - } - yd = $subslice(z, (((((2 >>> 16 << 16) * n >> 0) + (2 << 16 >>> 16) * n) >> 0) + n2 >> 0), ((((3 >>> 16 << 16) * n >> 0) + (3 << 16 >>> 16) * n) >> 0)); - if (!((subVV($subslice(new ($sliceType(Word))(yd.$array), yd.$offset, yd.$offset + yd.$length), $subslice(new ($sliceType(Word))(y0.$array), y0.$offset, y0.$offset + y0.$length), $subslice(new ($sliceType(Word))(y1.$array), y1.$offset, y1.$offset + y1.$length)) === 0))) { - s = -s; - subVV($subslice(new ($sliceType(Word))(yd.$array), yd.$offset, yd.$offset + yd.$length), $subslice(new ($sliceType(Word))(y1.$array), y1.$offset, y1.$offset + y1.$length), $subslice(new ($sliceType(Word))(y0.$array), y0.$offset, y0.$offset + y0.$length)); + if (!($interfaceIsEqual(ut, $ifaceNil))) { + d.saveError(new UnmarshalTypeError.Ptr("array", v.Type())); + d.off = d.off - (1) >> 0; + d.next(); + return; } - p = $subslice(z, ((((n >>> 16 << 16) * 3 >> 0) + (n << 16 >>> 16) * 3) >> 0)); - karatsuba(p, xd, yd); - r = $subslice(z, ((((n >>> 16 << 16) * 4 >> 0) + (n << 16 >>> 16) * 4) >> 0)); - $copySlice(r, $subslice(z, 0, ((((n >>> 16 << 16) * 2 >> 0) + (n << 16 >>> 16) * 2) >> 0))); - karatsubaAdd($subslice(z, n2), r, n); - karatsubaAdd($subslice(z, n2), $subslice(r, n), n); - if (s > 0) { - karatsubaAdd($subslice(z, n2), p, n); + $copy(v, pv, reflect.Value); + _ref = v.Kind(); + switch (0) { default: if (_ref === 20) { + if (v.NumMethod() === 0) { + v.Set($clone(reflect.ValueOf(d.arrayInterface()), reflect.Value)); + return; + } + d.saveError(new UnmarshalTypeError.Ptr("array", v.Type())); + d.off = d.off - (1) >> 0; + d.next(); + return; + } else if (_ref === 17) { + } else if (_ref === 23) { + break; } else { - karatsubaSub($subslice(z, n2), p, n); - } - }; - alias = function(x, y) { - return x.$capacity > 0 && y.$capacity > 0 && $sliceIsEqual($subslice(x, 0, x.$capacity), (x.$capacity - 1 >> 0), $subslice(y, 0, y.$capacity), (y.$capacity - 1 >> 0)); - }; - addAt = function(z, x, i) { - var n, x$1, x$2, c, j, x$3, x$4; - n = x.$length; - if (n > 0) { - c = addVV((x$1 = $subslice(z, i, (i + n >> 0)), $subslice(new ($sliceType(Word))(x$1.$array), x$1.$offset, x$1.$offset + x$1.$length)), (x$2 = $subslice(z, i), $subslice(new ($sliceType(Word))(x$2.$array), x$2.$offset, x$2.$offset + x$2.$length)), $subslice(new ($sliceType(Word))(x.$array), x.$offset, x.$offset + x.$length)); - if (!((c === 0))) { - j = i + n >> 0; - if (j < z.$length) { - addVW((x$3 = $subslice(z, j), $subslice(new ($sliceType(Word))(x$3.$array), x$3.$offset, x$3.$offset + x$3.$length)), (x$4 = $subslice(z, j), $subslice(new ($sliceType(Word))(x$4.$array), x$4.$offset, x$4.$offset + x$4.$length)), c); + d.saveError(new UnmarshalTypeError.Ptr("array", v.Type())); + d.off = d.off - (1) >> 0; + d.next(); + return; + } } + i = 0; + while (true) { + op = d.scanWhile(9); + if (op === 8) { + break; + } + d.off = d.off - (1) >> 0; + d.scan.undo(op); + if (v.Kind() === 23) { + if (i >= v.Cap()) { + newcap = v.Cap() + (_q = v.Cap() / 2, (_q === _q && _q !== 1/0 && _q !== -1/0) ? _q >> 0 : $throwRuntimeError("integer divide by zero")) >> 0; + if (newcap < 4) { + newcap = 4; + } + newv = new reflect.Value.Ptr(); $copy(newv, reflect.MakeSlice(v.Type(), v.Len(), newcap), reflect.Value); + reflect.Copy($clone(newv, reflect.Value), $clone(v, reflect.Value)); + v.Set($clone(newv, reflect.Value)); + } + if (i >= v.Len()) { + v.SetLen(i + 1 >> 0); } } + if (i < v.Len()) { + d.value($clone(v.Index(i), reflect.Value)); + } else { + d.value(new reflect.Value.Ptr(($ptrType(reflect.rtype)).nil, 0, 0, 0)); + } + i = i + (1) >> 0; + op = d.scanWhile(9); + if (op === 8) { + break; + } + if (!((op === 7))) { + d.error(errPhase); + } } - }; - max = function(x, y) { - if (x > y) { - return x; - } - return y; - }; - karatsubaLen = function(n) { - var i, y; - i = 0; - while (n > karatsubaThreshold) { - n = (n >> $min((1), 31)) >> 0; - i = i + (1) >>> 0; - } - return (y = i, y < 32 ? (n << y) : 0) >> 0; - }; - nat.prototype.mul = function(x, y) { - var z, m, n, k, x0, y0, t, x0$1, y1, y0$1, i, xi; - z = this; - m = x.$length; - n = y.$length; - if (m < n) { - return z.mul(y, x); - } else if ((m === 0) || (n === 0)) { - return z.make(0); - } else if (n === 1) { - return z.mulAddWW(x, ((0 < 0 || 0 >= y.$length) ? $throwRuntimeError("index out of range") : y.$array[y.$offset + 0]), 0); - } - if (alias(z, x) || alias(z, y)) { - z = nat.nil; - } - if (n < karatsubaThreshold) { - z = z.make(m + n >> 0); - basicMul(z, x, y); - return z.norm(); - } - k = karatsubaLen(n); - x0 = $subslice(x, 0, k); - y0 = $subslice(y, 0, k); - z = z.make(max((((6 >>> 16 << 16) * k >> 0) + (6 << 16 >>> 16) * k) >> 0, m + n >> 0)); - karatsuba(z, x0, y0); - z = $subslice(z, 0, (m + n >> 0)); - $subslice(z, ((((2 >>> 16 << 16) * k >> 0) + (2 << 16 >>> 16) * k) >> 0)).clear(); - if (k < n || !((m === n))) { - t = nat.nil; - x0$1 = x0.norm(); - y1 = $subslice(y, k); - t = t.mul(x0$1, y1); - addAt(z, t, k); - y0$1 = y0.norm(); - i = k; - while (i < x.$length) { - xi = $subslice(x, i); - if (xi.$length > k) { - xi = $subslice(xi, 0, k); + if (i < v.Len()) { + if (v.Kind() === 17) { + z = new reflect.Value.Ptr(); $copy(z, reflect.Zero(v.Type().Elem()), reflect.Value); + while (i < v.Len()) { + v.Index(i).Set($clone(z, reflect.Value)); + i = i + (1) >> 0; } - xi = xi.norm(); - t = t.mul(xi, y0$1); - addAt(z, t, i); - t = t.mul(xi, y1); - addAt(z, t, i + k >> 0); - i = i + (k) >> 0; + } else { + v.SetLen(i); } } - return z.norm(); - }; - $ptrType(nat).prototype.mul = function(x, y) { return this.$get().mul(x, y); }; - nat.prototype.mulRange = function(a, b) { - var z, x, m; - z = this; - if ((a.$high === 0 && a.$low === 0)) { - return z.setUint64(new $Uint64(0, 0)); - } else if ((a.$high > b.$high || (a.$high === b.$high && a.$low > b.$low))) { - return z.setUint64(new $Uint64(0, 1)); - } else if ((a.$high === b.$high && a.$low === b.$low)) { - return z.setUint64(a); - } else if ((x = new $Uint64(a.$high + 0, a.$low + 1), (x.$high === b.$high && x.$low === b.$low))) { - return z.mul(nat.nil.setUint64(a), nat.nil.setUint64(b)); - } - m = $div64((new $Uint64(a.$high + b.$high, a.$low + b.$low)), new $Uint64(0, 2), false); - return z.mul(nat.nil.mulRange(a, m), nat.nil.mulRange(new $Uint64(m.$high + 0, m.$low + 1), b)); - }; - $ptrType(nat).prototype.mulRange = function(a, b) { return this.$get().mulRange(a, b); }; - nat.prototype.divW = function(x, y) { - var q = nat.nil, r = 0, z, m; - z = this; - m = x.$length; - if (y === 0) { - $panic(new $String("division by zero")); - } else if (y === 1) { - q = z.set(x); - return [q, r]; - } else if (m === 0) { - q = z.make(0); - return [q, r]; - } - z = z.make(m); - r = divWVW($subslice(new ($sliceType(Word))(z.$array), z.$offset, z.$offset + z.$length), 0, $subslice(new ($sliceType(Word))(x.$array), x.$offset, x.$offset + x.$length), y); - q = z.norm(); - return [q, r]; - }; - $ptrType(nat).prototype.divW = function(x, y) { return this.$get().divW(x, y); }; - nat.prototype.div = function(z2, u, v) { - var q = nat.nil, r = nat.nil, z, r2, _tuple, _tuple$1; - z = this; - if (v.$length === 0) { - $panic(new $String("division by zero")); - } - if (u.cmp(v) < 0) { - q = z.make(0); - r = z2.set(u); - return [q, r]; - } - if (v.$length === 1) { - r2 = 0; - _tuple = z.divW(u, ((0 < 0 || 0 >= v.$length) ? $throwRuntimeError("index out of range") : v.$array[v.$offset + 0])); q = _tuple[0]; r2 = _tuple[1]; - r = z2.setWord(r2); - return [q, r]; + if ((i === 0) && (v.Kind() === 23)) { + v.Set($clone(reflect.MakeSlice(v.Type(), 0, 0), reflect.Value)); } - _tuple$1 = z.divLarge(z2, u, v); q = _tuple$1[0]; r = _tuple$1[1]; - return [q, r]; }; - $ptrType(nat).prototype.div = function(z2, u, v) { return this.$get().div(z2, u, v); }; - nat.prototype.divLarge = function(u, uIn, v) { - var q = nat.nil, r = nat.nil, z, n, m, qhatv, x, shift, v1, x$1, x$2, j, qhat, x$3, x$4, rhat, _tuple, x$5, x$6, x$7, _tuple$1, x$8, x1, x2, x$9, prevRhat, x$10, _tuple$2, x$11, x$12, x$13, x$14, c, x$15, x$16, c$1, _lhs, _index, _tmp, _tmp$1; - z = this; - n = v.$length; - m = uIn.$length - n >> 0; - if (alias(z, uIn) || alias(z, v)) { - z = nat.nil; + decodeState.prototype.array = function(v) { return this.$val.array(v); }; + decodeState.Ptr.prototype.object = function(v) { + var d, _tuple, u, ut, pv, err, _ref, t, mapElem, op, start, item, _tuple$1, key, ok, subv, destring, elemType, f, fields, _ref$1, _i, i, ff, _ref$2, _i$1, i$1, kv; + d = this; + _tuple = d.indirect($clone(v, reflect.Value), false); u = _tuple[0]; ut = _tuple[1]; pv = new reflect.Value.Ptr(); $copy(pv, _tuple[2], reflect.Value); + if (!($interfaceIsEqual(u, $ifaceNil))) { + d.off = d.off - (1) >> 0; + err = u.UnmarshalJSON(d.next()); + if (!($interfaceIsEqual(err, $ifaceNil))) { + d.error(err); + } + return; } - q = z.make(m + 1 >> 0); - qhatv = nat.make((n + 1 >> 0)); - if (alias(u, uIn) || alias(u, v)) { - u = nat.nil; + if (!($interfaceIsEqual(ut, $ifaceNil))) { + d.saveError(new UnmarshalTypeError.Ptr("object", v.Type())); + d.off = d.off - (1) >> 0; + d.next(); + return; } - u = u.make(uIn.$length + 1 >> 0); - u.clear(); - shift = leadingZeros((x = n - 1 >> 0, ((x < 0 || x >= v.$length) ? $throwRuntimeError("index out of range") : v.$array[v.$offset + x]))); - if (shift > 0) { - v1 = nat.make(n); - shlVU($subslice(new ($sliceType(Word))(v1.$array), v1.$offset, v1.$offset + v1.$length), $subslice(new ($sliceType(Word))(v.$array), v.$offset, v.$offset + v.$length), shift); - v = v1; + $copy(v, pv, reflect.Value); + if ((v.Kind() === 20) && (v.NumMethod() === 0)) { + v.Set($clone(reflect.ValueOf(new ($mapType($String, $emptyInterface))(d.objectInterface())), reflect.Value)); + return; } - (x$2 = uIn.$length, (x$2 < 0 || x$2 >= u.$length) ? $throwRuntimeError("index out of range") : u.$array[u.$offset + x$2] = shlVU((x$1 = $subslice(u, 0, uIn.$length), $subslice(new ($sliceType(Word))(x$1.$array), x$1.$offset, x$1.$offset + x$1.$length)), $subslice(new ($sliceType(Word))(uIn.$array), uIn.$offset, uIn.$offset + uIn.$length), shift)); - j = m; - while (j >= 0) { - qhat = 4294967295; - if (!(((x$3 = j + n >> 0, ((x$3 < 0 || x$3 >= u.$length) ? $throwRuntimeError("index out of range") : u.$array[u.$offset + x$3])) === (x$4 = n - 1 >> 0, ((x$4 < 0 || x$4 >= v.$length) ? $throwRuntimeError("index out of range") : v.$array[v.$offset + x$4]))))) { - rhat = 0; - _tuple = divWW((x$5 = j + n >> 0, ((x$5 < 0 || x$5 >= u.$length) ? $throwRuntimeError("index out of range") : u.$array[u.$offset + x$5])), (x$6 = (j + n >> 0) - 1 >> 0, ((x$6 < 0 || x$6 >= u.$length) ? $throwRuntimeError("index out of range") : u.$array[u.$offset + x$6])), (x$7 = n - 1 >> 0, ((x$7 < 0 || x$7 >= v.$length) ? $throwRuntimeError("index out of range") : v.$array[v.$offset + x$7]))); qhat = _tuple[0]; rhat = _tuple[1]; - _tuple$1 = mulWW(qhat, (x$8 = n - 2 >> 0, ((x$8 < 0 || x$8 >= v.$length) ? $throwRuntimeError("index out of range") : v.$array[v.$offset + x$8]))); x1 = _tuple$1[0]; x2 = _tuple$1[1]; - while (greaterThan(x1, x2, rhat, (x$9 = (j + n >> 0) - 2 >> 0, ((x$9 < 0 || x$9 >= u.$length) ? $throwRuntimeError("index out of range") : u.$array[u.$offset + x$9])))) { - qhat = qhat - (1) >>> 0; - prevRhat = rhat; - rhat = rhat + ((x$10 = n - 1 >> 0, ((x$10 < 0 || x$10 >= v.$length) ? $throwRuntimeError("index out of range") : v.$array[v.$offset + x$10]))) >>> 0; - if (rhat < prevRhat) { - break; - } - _tuple$2 = mulWW(qhat, (x$11 = n - 2 >> 0, ((x$11 < 0 || x$11 >= v.$length) ? $throwRuntimeError("index out of range") : v.$array[v.$offset + x$11]))); x1 = _tuple$2[0]; x2 = _tuple$2[1]; - } + _ref = v.Kind(); + switch (0) { default: if (_ref === 21) { + t = v.Type(); + if (!((t.Key().Kind() === 24))) { + d.saveError(new UnmarshalTypeError.Ptr("object", v.Type())); + break; } - (n < 0 || n >= qhatv.$length) ? $throwRuntimeError("index out of range") : qhatv.$array[qhatv.$offset + n] = mulAddVWW((x$12 = $subslice(qhatv, 0, n), $subslice(new ($sliceType(Word))(x$12.$array), x$12.$offset, x$12.$offset + x$12.$length)), $subslice(new ($sliceType(Word))(v.$array), v.$offset, v.$offset + v.$length), qhat, 0); - c = subVV((x$13 = $subslice(u, j, (j + qhatv.$length >> 0)), $subslice(new ($sliceType(Word))(x$13.$array), x$13.$offset, x$13.$offset + x$13.$length)), (x$14 = $subslice(u, j), $subslice(new ($sliceType(Word))(x$14.$array), x$14.$offset, x$14.$offset + x$14.$length)), $subslice(new ($sliceType(Word))(qhatv.$array), qhatv.$offset, qhatv.$offset + qhatv.$length)); - if (!((c === 0))) { - c$1 = addVV((x$15 = $subslice(u, j, (j + n >> 0)), $subslice(new ($sliceType(Word))(x$15.$array), x$15.$offset, x$15.$offset + x$15.$length)), (x$16 = $subslice(u, j), $subslice(new ($sliceType(Word))(x$16.$array), x$16.$offset, x$16.$offset + x$16.$length)), $subslice(new ($sliceType(Word))(v.$array), v.$offset, v.$offset + v.$length)); - _lhs = u; _index = j + n >> 0; (_index < 0 || _index >= _lhs.$length) ? $throwRuntimeError("index out of range") : _lhs.$array[_lhs.$offset + _index] = ((_index < 0 || _index >= _lhs.$length) ? $throwRuntimeError("index out of range") : _lhs.$array[_lhs.$offset + _index]) + (c$1) >>> 0; - qhat = qhat - (1) >>> 0; + if (v.IsNil()) { + v.Set($clone(reflect.MakeMap(t), reflect.Value)); } - (j < 0 || j >= q.$length) ? $throwRuntimeError("index out of range") : q.$array[q.$offset + j] = qhat; - j = j - (1) >> 0; - } - q = q.norm(); - shrVU($subslice(new ($sliceType(Word))(u.$array), u.$offset, u.$offset + u.$length), $subslice(new ($sliceType(Word))(u.$array), u.$offset, u.$offset + u.$length), shift); - r = u.norm(); - _tmp = q; _tmp$1 = r; q = _tmp; r = _tmp$1; - return [q, r]; - }; - $ptrType(nat).prototype.divLarge = function(u, uIn, v) { return this.$get().divLarge(u, uIn, v); }; - nat.prototype.bitLen = function() { - var x, i; - x = this; - i = x.$length - 1 >> 0; - if (i >= 0) { - return ((((i >>> 16 << 16) * 32 >> 0) + (i << 16 >>> 16) * 32) >> 0) + bitLen(((i < 0 || i >= x.$length) ? $throwRuntimeError("index out of range") : x.$array[x.$offset + i])) >> 0; - } - return 0; - }; - $ptrType(nat).prototype.bitLen = function() { return this.$get().bitLen(); }; - hexValue = function(ch) { - var d; - d = 37; - if (48 <= ch && ch <= 57) { - d = ((ch - 48 >> 0) >> 0); - } else if (97 <= ch && ch <= 122) { - d = (((ch - 97 >> 0) + 10 >> 0) >> 0); - } else if (65 <= ch && ch <= 90) { - d = (((ch - 65 >> 0) + 10 >> 0) >> 0); - } - return (d >>> 0); - }; - nat.prototype.scan = function(r, base) { - var z, _tuple, ch, err, b, _tuple$1, _ref, _ref$1, _tuple$2, bb, dd, _q, max$1, d, x, _tuple$3; - z = this; - if (base < 0 || (base === 1) || 36 < base) { - return [z, 0, errors.New("illegal number base")]; - } - _tuple = r.ReadRune(); ch = _tuple[0]; err = _tuple[2]; - if (!($interfaceIsEqual(err, $ifaceNil))) { - return [z, 0, err]; - } - b = (base >>> 0); - if (base === 0) { - b = 10; - if (ch === 48) { - _tuple$1 = r.ReadRune(); ch = _tuple$1[0]; err = _tuple$1[2]; - _ref = err; - if ($interfaceIsEqual(_ref, $ifaceNil)) { - b = 8; - _ref$1 = ch; - if (_ref$1 === 120 || _ref$1 === 88) { - b = 16; - } else if (_ref$1 === 98 || _ref$1 === 66) { - b = 2; + } else if (_ref === 25) { + } else { + d.saveError(new UnmarshalTypeError.Ptr("object", v.Type())); + d.off = d.off - (1) >> 0; + d.next(); + return; + } } + mapElem = new reflect.Value.Ptr(); $copy(mapElem, new reflect.Value.Ptr(), reflect.Value); + while (true) { + op = d.scanWhile(9); + if (op === 5) { + break; + } + if (!((op === 1))) { + d.error(errPhase); + } + start = d.off - 1 >> 0; + op = d.scanWhile(0); + item = $subslice(d.data, start, (d.off - 1 >> 0)); + _tuple$1 = unquoteBytes(item); key = _tuple$1[0]; ok = _tuple$1[1]; + if (!ok) { + d.error(errPhase); + } + subv = new reflect.Value.Ptr(); $copy(subv, new reflect.Value.Ptr(), reflect.Value); + destring = false; + if (v.Kind() === 21) { + elemType = v.Type().Elem(); + if (!mapElem.IsValid()) { + $copy(mapElem, reflect.New(elemType).Elem(), reflect.Value); + } else { + mapElem.Set($clone(reflect.Zero(elemType), reflect.Value)); + } + $copy(subv, mapElem, reflect.Value); + } else { + f = ($ptrType(field)).nil; + fields = cachedTypeFields(v.Type()); + _ref$1 = fields; + _i = 0; + while (_i < _ref$1.$length) { + i = _i; + ff = ((i < 0 || i >= fields.$length) ? $throwRuntimeError("index out of range") : fields.$array[fields.$offset + i]); + if (bytes.Equal(ff.nameBytes, key)) { + f = ff; + break; } - if ((b === 2) || (b === 16)) { - _tuple$2 = r.ReadRune(); ch = _tuple$2[0]; err = _tuple$2[2]; - if (!($interfaceIsEqual(err, $ifaceNil))) { - return [z, 0, err]; + if (f === ($ptrType(field)).nil && ff.equalFold(ff.nameBytes, key)) { + f = ff; + } + _i++; + } + if (!(f === ($ptrType(field)).nil)) { + $copy(subv, v, reflect.Value); + destring = f.quoted; + _ref$2 = f.index; + _i$1 = 0; + while (_i$1 < _ref$2.$length) { + i$1 = ((_i$1 < 0 || _i$1 >= _ref$2.$length) ? $throwRuntimeError("index out of range") : _ref$2.$array[_ref$2.$offset + _i$1]); + if (subv.Kind() === 22) { + if (subv.IsNil()) { + subv.Set($clone(reflect.New(subv.Type().Elem()), reflect.Value)); + } + $copy(subv, subv.Elem(), reflect.Value); } + $copy(subv, subv.Field(i$1), reflect.Value); + _i$1++; } - } else if ($interfaceIsEqual(_ref, io.EOF)) { - return [z.make(0), 10, $ifaceNil]; - } else { - return [z, 10, err]; } } - } - z = z.make(0); - bb = 1; - dd = 0; - max$1 = (_q = 4294967295 / b, (_q === _q && _q !== 1/0 && _q !== -1/0) ? _q >>> 0 : $throwRuntimeError("integer divide by zero")); - while (true) { - d = hexValue(ch); - if (d >= b) { - r.UnreadRune(); - break; + if (op === 9) { + op = d.scanWhile(9); } - if (bb <= max$1) { - bb = (x = b, (((bb >>> 16 << 16) * x >>> 0) + (bb << 16 >>> 16) * x) >>> 0); - dd = ((((dd >>> 16 << 16) * b >>> 0) + (dd << 16 >>> 16) * b) >>> 0) + d >>> 0; + if (!((op === 3))) { + d.error(errPhase); + } + if (destring) { + d.value($clone(reflect.ValueOf(new ($ptrType($String))(function() { return this.$target.tempstr; }, function($v) { this.$target.tempstr = $v; }, d)), reflect.Value)); + d.literalStore(new ($sliceType($Uint8))($stringToBytes(d.tempstr)), $clone(subv, reflect.Value), true); + d.tempstr = ""; } else { - z = z.mulAddWW(z, bb, dd); - bb = b; - dd = d; + d.value($clone(subv, reflect.Value)); } - _tuple$3 = r.ReadRune(); ch = _tuple$3[0]; err = _tuple$3[2]; - if (!($interfaceIsEqual(err, $ifaceNil))) { - if (!($interfaceIsEqual(err, io.EOF))) { - return [z, (b >> 0), err]; - } + if (v.Kind() === 21) { + kv = new reflect.Value.Ptr(); $copy(kv, reflect.ValueOf(key).Convert(v.Type().Key()), reflect.Value); + v.SetMapIndex($clone(kv, reflect.Value), $clone(subv, reflect.Value)); + } + op = d.scanWhile(9); + if (op === 5) { break; } + if (!((op === 4))) { + d.error(errPhase); + } } - if (bb > 1) { - z = z.mulAddWW(z, bb, dd); - } else if ((base === 0) && (b === 8)) { - return [z, 10, $ifaceNil]; - } else if (!((base === 0)) || !((b === 8))) { - return [z, (b >> 0), errors.New("syntax error scanning number")]; - } - return [z.norm(), (b >> 0), $ifaceNil]; }; - $ptrType(nat).prototype.scan = function(r, base) { return this.$get().scan(r, base); }; - nat.prototype.decimalString = function() { - var x; - x = this; - return x.string("0123456789abcdefghijklmnopqrstuvwxyz".substring(0, 10)); + decodeState.prototype.object = function(v) { return this.$val.object(v); }; + decodeState.Ptr.prototype.literal = function(v) { + var d, start, op; + d = this; + start = d.off - 1 >> 0; + op = d.scanWhile(0); + d.off = d.off - (1) >> 0; + d.scan.undo(op); + d.literalStore($subslice(d.data, start, d.off), $clone(v, reflect.Value), false); }; - $ptrType(nat).prototype.decimalString = function() { return this.$get().decimalString(); }; - nat.prototype.string = function(charset$1) { - var x, b, i, s, shift, y, mask, w, nbits, k, y$1, y$2, y$3, y$4, bb, ndigits, _q, max$1, x$1, table, q, zero; - x = this; - b = (charset$1.length >>> 0); - if (b < 2 || false) { - $panic(new $String("illegal base")); - } else if (x.$length === 0) { - return $encodeRune(charset$1.charCodeAt(0)); + decodeState.prototype.literal = function(v) { return this.$val.literal(v); }; + decodeState.Ptr.prototype.convertNumber = function(s) { + var d, _tuple, f, err; + d = this; + if (d.useNumber) { + return [new Number(s), $ifaceNil]; } - i = (x.bitLen() / math.Log2(b) >> 0) + 1 >> 0; - s = ($sliceType($Uint8)).make(i); - if (b === ((b & (-b >>> 0)) >>> 0)) { - shift = trailingZeroBits(b); - mask = ((y = shift, y < 32 ? (1 << y) : 0) >>> 0) - 1 >>> 0; - w = ((0 < 0 || 0 >= x.$length) ? $throwRuntimeError("index out of range") : x.$array[x.$offset + 0]); - nbits = 32; - k = 1; - while (k < x.$length) { - while (nbits >= shift) { - i = i - (1) >> 0; - (i < 0 || i >= s.$length) ? $throwRuntimeError("index out of range") : s.$array[s.$offset + i] = charset$1.charCodeAt(((w & mask) >>> 0)); - w = (y$1 = (shift), y$1 < 32 ? (w >>> y$1) : 0) >>> 0; - nbits = nbits - (shift) >>> 0; - } - if (nbits === 0) { - w = ((k < 0 || k >= x.$length) ? $throwRuntimeError("index out of range") : x.$array[x.$offset + k]); - nbits = 32; + _tuple = strconv.ParseFloat(s, 64); f = _tuple[0]; err = _tuple[1]; + if (!($interfaceIsEqual(err, $ifaceNil))) { + return [$ifaceNil, new UnmarshalTypeError.Ptr("number " + s, reflect.TypeOf(new $Float64(0)))]; + } + return [new $Float64(f), $ifaceNil]; + }; + decodeState.prototype.convertNumber = function(s) { return this.$val.convertNumber(s); }; + decodeState.Ptr.prototype.literalStore = function(item, v, fromQuoted) { + var d, wantptr, _tuple, u, ut, pv, err, _tuple$1, s, ok, err$1, c, _ref, _ref$1, value, _ref$2, _tuple$2, s$1, ok$1, _ref$3, b, _tuple$3, n, err$2, s$2, _ref$4, _tuple$4, n$1, err$3, _tuple$5, n$2, err$4, _tuple$6, n$3, err$5, _tuple$7, n$4, err$6; + d = this; + if (item.$length === 0) { + d.saveError(fmt.Errorf("json: invalid use of ,string struct tag, trying to unmarshal %q into %v", new ($sliceType($emptyInterface))([item, v.Type()]))); + return; + } + wantptr = ((0 < 0 || 0 >= item.$length) ? $throwRuntimeError("index out of range") : item.$array[item.$offset + 0]) === 110; + _tuple = d.indirect($clone(v, reflect.Value), wantptr); u = _tuple[0]; ut = _tuple[1]; pv = new reflect.Value.Ptr(); $copy(pv, _tuple[2], reflect.Value); + if (!($interfaceIsEqual(u, $ifaceNil))) { + err = u.UnmarshalJSON(item); + if (!($interfaceIsEqual(err, $ifaceNil))) { + d.error(err); + } + return; + } + if (!($interfaceIsEqual(ut, $ifaceNil))) { + if (!((((0 < 0 || 0 >= item.$length) ? $throwRuntimeError("index out of range") : item.$array[item.$offset + 0]) === 34))) { + if (fromQuoted) { + d.saveError(fmt.Errorf("json: invalid use of ,string struct tag, trying to unmarshal %q into %v", new ($sliceType($emptyInterface))([item, v.Type()]))); } else { - w = (w | (((y$2 = nbits, y$2 < 32 ? (((k < 0 || k >= x.$length) ? $throwRuntimeError("index out of range") : x.$array[x.$offset + k]) << y$2) : 0) >>> 0))) >>> 0; - i = i - (1) >> 0; - (i < 0 || i >= s.$length) ? $throwRuntimeError("index out of range") : s.$array[s.$offset + i] = charset$1.charCodeAt(((w & mask) >>> 0)); - w = (y$3 = ((shift - nbits >>> 0)), y$3 < 32 ? (((k < 0 || k >= x.$length) ? $throwRuntimeError("index out of range") : x.$array[x.$offset + k]) >>> y$3) : 0) >>> 0; - nbits = 32 - ((shift - nbits >>> 0)) >>> 0; + d.saveError(new UnmarshalTypeError.Ptr("string", v.Type())); } - k = k + (1) >> 0; - } - while (nbits >= 0 && !((w === 0))) { - i = i - (1) >> 0; - (i < 0 || i >= s.$length) ? $throwRuntimeError("index out of range") : s.$array[s.$offset + i] = charset$1.charCodeAt(((w & mask) >>> 0)); - w = (y$4 = (shift), y$4 < 32 ? (w >>> y$4) : 0) >>> 0; - nbits = nbits - (shift) >>> 0; } - } else { - bb = b; - ndigits = 1; - max$1 = (_q = 4294967295 / b, (_q === _q && _q !== 1/0 && _q !== -1/0) ? _q >>> 0 : $throwRuntimeError("integer divide by zero")); - while (bb <= max$1) { - ndigits = ndigits + (1) >> 0; - bb = (x$1 = b, (((bb >>> 16 << 16) * x$1 >>> 0) + (bb << 16 >>> 16) * x$1) >>> 0); + _tuple$1 = unquoteBytes(item); s = _tuple$1[0]; ok = _tuple$1[1]; + if (!ok) { + if (fromQuoted) { + d.error(fmt.Errorf("json: invalid use of ,string struct tag, trying to unmarshal %q into %v", new ($sliceType($emptyInterface))([item, v.Type()]))); + } else { + d.error(errPhase); + } } - table = divisors(x.$length, b, ndigits, bb); - q = nat.nil.set(x); - q.convertWords(s, charset$1, b, ndigits, bb, table); - i = 0; - zero = charset$1.charCodeAt(0); - while (((i < 0 || i >= s.$length) ? $throwRuntimeError("index out of range") : s.$array[s.$offset + i]) === zero) { - i = i + (1) >> 0; + err$1 = ut.UnmarshalText(s); + if (!($interfaceIsEqual(err$1, $ifaceNil))) { + d.error(err$1); } + return; } - return $bytesToString($subslice(s, i)); - }; - $ptrType(nat).prototype.string = function(charset$1) { return this.$get().string(charset$1); }; - nat.prototype.convertWords = function(s, charset$1, b, ndigits, bb, table) { - var q, r, index, maxLength, minLength, x, _tuple, h, i, r$1, _tuple$1, j, _q, t, _tuple$2, j$1, _r, _q$1, zero; - q = this; - if (!(table === ($sliceType(divisor)).nil)) { - r = nat.nil; - index = table.$length - 1 >> 0; - while (q.$length > leafSize) { - maxLength = q.bitLen(); - minLength = maxLength >> 1 >> 0; - while (index > 0 && (x = index - 1 >> 0, ((x < 0 || x >= table.$length) ? $throwRuntimeError("index out of range") : table.$array[table.$offset + x])).nbits > minLength) { - index = index - (1) >> 0; + $copy(v, pv, reflect.Value); + c = ((0 < 0 || 0 >= item.$length) ? $throwRuntimeError("index out of range") : item.$array[item.$offset + 0]); + _ref = c; + if (_ref === 110) { + _ref$1 = v.Kind(); + if (_ref$1 === 20 || _ref$1 === 22 || _ref$1 === 21 || _ref$1 === 23) { + v.Set($clone(reflect.Zero(v.Type()), reflect.Value)); + } + } else if (_ref === 116 || _ref === 102) { + value = c === 116; + _ref$2 = v.Kind(); + if (_ref$2 === 1) { + v.SetBool(value); + } else if (_ref$2 === 20) { + if (v.NumMethod() === 0) { + v.Set($clone(reflect.ValueOf(new $Bool(value)), reflect.Value)); + } else { + d.saveError(new UnmarshalTypeError.Ptr("bool", v.Type())); } - if (((index < 0 || index >= table.$length) ? $throwRuntimeError("index out of range") : table.$array[table.$offset + index]).nbits >= maxLength && ((index < 0 || index >= table.$length) ? $throwRuntimeError("index out of range") : table.$array[table.$offset + index]).bbb.cmp(q) >= 0) { - index = index - (1) >> 0; - if (index < 0) { - $panic(new $String("internal inconsistency")); - } + } else { + if (fromQuoted) { + d.saveError(fmt.Errorf("json: invalid use of ,string struct tag, trying to unmarshal %q into %v", new ($sliceType($emptyInterface))([item, v.Type()]))); + } else { + d.saveError(new UnmarshalTypeError.Ptr("bool", v.Type())); } - _tuple = q.div(r, q, ((index < 0 || index >= table.$length) ? $throwRuntimeError("index out of range") : table.$array[table.$offset + index]).bbb); q = _tuple[0]; r = _tuple[1]; - h = s.$length - ((index < 0 || index >= table.$length) ? $throwRuntimeError("index out of range") : table.$array[table.$offset + index]).ndigits >> 0; - r.convertWords($subslice(s, h), charset$1, b, ndigits, bb, $subslice(table, 0, index)); - s = $subslice(s, 0, h); } - } - i = s.$length; - r$1 = 0; - if (b === 10) { - while (q.$length > 0) { - _tuple$1 = q.divW(q, bb); q = _tuple$1[0]; r$1 = _tuple$1[1]; - j = 0; - while (j < ndigits && i > 0) { - i = i - (1) >> 0; - t = (_q = r$1 / 10, (_q === _q && _q !== 1/0 && _q !== -1/0) ? _q >>> 0 : $throwRuntimeError("integer divide by zero")); - (i < 0 || i >= s.$length) ? $throwRuntimeError("index out of range") : s.$array[s.$offset + i] = charset$1.charCodeAt((((r$1 - (t << 3 >>> 0) >>> 0) - t >>> 0) - t >>> 0)); - r$1 = t; - j = j + (1) >> 0; + } else if (_ref === 34) { + _tuple$2 = unquoteBytes(item); s$1 = _tuple$2[0]; ok$1 = _tuple$2[1]; + if (!ok$1) { + if (fromQuoted) { + d.error(fmt.Errorf("json: invalid use of ,string struct tag, trying to unmarshal %q into %v", new ($sliceType($emptyInterface))([item, v.Type()]))); + } else { + d.error(errPhase); } } + _ref$3 = v.Kind(); + switch (0) { default: if (_ref$3 === 23) { + if (!($interfaceIsEqual(v.Type(), byteSliceType))) { + d.saveError(new UnmarshalTypeError.Ptr("string", v.Type())); + break; + } + b = ($sliceType($Uint8)).make(base64.StdEncoding.DecodedLen(s$1.$length)); + _tuple$3 = base64.StdEncoding.Decode(b, s$1); n = _tuple$3[0]; err$2 = _tuple$3[1]; + if (!($interfaceIsEqual(err$2, $ifaceNil))) { + d.saveError(err$2); + break; + } + v.Set($clone(reflect.ValueOf($subslice(b, 0, n)), reflect.Value)); + } else if (_ref$3 === 24) { + v.SetString($bytesToString(s$1)); + } else if (_ref$3 === 20) { + if (v.NumMethod() === 0) { + v.Set($clone(reflect.ValueOf(new $String($bytesToString(s$1))), reflect.Value)); + } else { + d.saveError(new UnmarshalTypeError.Ptr("string", v.Type())); + } + } else { + d.saveError(new UnmarshalTypeError.Ptr("string", v.Type())); + } } } else { - while (q.$length > 0) { - _tuple$2 = q.divW(q, bb); q = _tuple$2[0]; r$1 = _tuple$2[1]; - j$1 = 0; - while (j$1 < ndigits && i > 0) { - i = i - (1) >> 0; - (i < 0 || i >= s.$length) ? $throwRuntimeError("index out of range") : s.$array[s.$offset + i] = charset$1.charCodeAt((_r = r$1 % b, _r === _r ? _r : $throwRuntimeError("integer divide by zero"))); - r$1 = (_q$1 = r$1 / (b), (_q$1 === _q$1 && _q$1 !== 1/0 && _q$1 !== -1/0) ? _q$1 >>> 0 : $throwRuntimeError("integer divide by zero")); - j$1 = j$1 + (1) >> 0; + if (!((c === 45)) && (c < 48 || c > 57)) { + if (fromQuoted) { + d.error(fmt.Errorf("json: invalid use of ,string struct tag, trying to unmarshal %q into %v", new ($sliceType($emptyInterface))([item, v.Type()]))); + } else { + d.error(errPhase); } } + s$2 = $bytesToString(item); + _ref$4 = v.Kind(); + switch (0) { default: if (_ref$4 === 20) { + _tuple$4 = d.convertNumber(s$2); n$1 = _tuple$4[0]; err$3 = _tuple$4[1]; + if (!($interfaceIsEqual(err$3, $ifaceNil))) { + d.saveError(err$3); + break; + } + if (!((v.NumMethod() === 0))) { + d.saveError(new UnmarshalTypeError.Ptr("number", v.Type())); + break; + } + v.Set($clone(reflect.ValueOf(n$1), reflect.Value)); + } else if (_ref$4 === 2 || _ref$4 === 3 || _ref$4 === 4 || _ref$4 === 5 || _ref$4 === 6) { + _tuple$5 = strconv.ParseInt(s$2, 10, 64); n$2 = _tuple$5[0]; err$4 = _tuple$5[1]; + if (!($interfaceIsEqual(err$4, $ifaceNil)) || v.OverflowInt(n$2)) { + d.saveError(new UnmarshalTypeError.Ptr("number " + s$2, v.Type())); + break; + } + v.SetInt(n$2); + } else if (_ref$4 === 7 || _ref$4 === 8 || _ref$4 === 9 || _ref$4 === 10 || _ref$4 === 11 || _ref$4 === 12) { + _tuple$6 = strconv.ParseUint(s$2, 10, 64); n$3 = _tuple$6[0]; err$5 = _tuple$6[1]; + if (!($interfaceIsEqual(err$5, $ifaceNil)) || v.OverflowUint(n$3)) { + d.saveError(new UnmarshalTypeError.Ptr("number " + s$2, v.Type())); + break; + } + v.SetUint(n$3); + } else if (_ref$4 === 13 || _ref$4 === 14) { + _tuple$7 = strconv.ParseFloat(s$2, v.Type().Bits()); n$4 = _tuple$7[0]; err$6 = _tuple$7[1]; + if (!($interfaceIsEqual(err$6, $ifaceNil)) || v.OverflowFloat(n$4)) { + d.saveError(new UnmarshalTypeError.Ptr("number " + s$2, v.Type())); + break; + } + v.SetFloat(n$4); + } else { + if ((v.Kind() === 24) && $interfaceIsEqual(v.Type(), numberType)) { + v.SetString(s$2); + break; + } + if (fromQuoted) { + d.error(fmt.Errorf("json: invalid use of ,string struct tag, trying to unmarshal %q into %v", new ($sliceType($emptyInterface))([item, v.Type()]))); + } else { + d.error(new UnmarshalTypeError.Ptr("number", v.Type())); + } + } } } - zero = charset$1.charCodeAt(0); - while (i > 0) { - i = i - (1) >> 0; - (i < 0 || i >= s.$length) ? $throwRuntimeError("index out of range") : s.$array[s.$offset + i] = zero; - } - }; - $ptrType(nat).prototype.convertWords = function(s, charset$1, b, ndigits, bb, table) { return this.$get().convertWords(s, charset$1, b, ndigits, bb, table); }; - nat.prototype.expWW = function(x, y) { - var z; - z = this; - return z.expNN(nat.nil.setWord(x), nat.nil.setWord(y), nat.nil); }; - $ptrType(nat).prototype.expWW = function(x, y) { return this.$get().expWW(x, y); }; - divisors = function(m, b, ndigits, bb) { - var k, words, y, table, x, larger, i, x$1, x$2, x$3, x$4; - if ((leafSize === 0) || m <= leafSize) { - return ($sliceType(divisor)).nil; - } - k = 1; - words = leafSize; - while (words < (m >> 1 >> 0) && k < 64) { - k = k + (1) >> 0; - words = (y = (1), y < 32 ? (words << y) : 0) >> 0; - } - table = ($sliceType(divisor)).nil; - if (b === 10) { - cacheBase10.Mutex.Lock(); - table = $subslice(new ($sliceType(divisor))(cacheBase10.table), 0, k); + decodeState.prototype.literalStore = function(item, v, fromQuoted) { return this.$val.literalStore(item, v, fromQuoted); }; + decodeState.Ptr.prototype.valueInterface = function() { + var d, _ref; + d = this; + _ref = d.scanWhile(9); + if (_ref === 6) { + return d.arrayInterface(); + } else if (_ref === 2) { + return new ($mapType($String, $emptyInterface))(d.objectInterface()); + } else if (_ref === 1) { + return d.literalInterface(); } else { - table = ($sliceType(divisor)).make(k); + d.error(errPhase); + $panic(new $String("unreachable")); } - if ((x = k - 1 >> 0, ((x < 0 || x >= table.$length) ? $throwRuntimeError("index out of range") : table.$array[table.$offset + x])).ndigits === 0) { - larger = nat.nil; - i = 0; - while (i < k) { - if (((i < 0 || i >= table.$length) ? $throwRuntimeError("index out of range") : table.$array[table.$offset + i]).ndigits === 0) { - if (i === 0) { - ((0 < 0 || 0 >= table.$length) ? $throwRuntimeError("index out of range") : table.$array[table.$offset + 0]).bbb = nat.nil.expWW(bb, (leafSize >>> 0)); - ((0 < 0 || 0 >= table.$length) ? $throwRuntimeError("index out of range") : table.$array[table.$offset + 0]).ndigits = (((ndigits >>> 16 << 16) * leafSize >> 0) + (ndigits << 16 >>> 16) * leafSize) >> 0; - } else { - ((i < 0 || i >= table.$length) ? $throwRuntimeError("index out of range") : table.$array[table.$offset + i]).bbb = nat.nil.mul((x$1 = i - 1 >> 0, ((x$1 < 0 || x$1 >= table.$length) ? $throwRuntimeError("index out of range") : table.$array[table.$offset + x$1])).bbb, (x$2 = i - 1 >> 0, ((x$2 < 0 || x$2 >= table.$length) ? $throwRuntimeError("index out of range") : table.$array[table.$offset + x$2])).bbb); - ((i < 0 || i >= table.$length) ? $throwRuntimeError("index out of range") : table.$array[table.$offset + i]).ndigits = (x$3 = (x$4 = i - 1 >> 0, ((x$4 < 0 || x$4 >= table.$length) ? $throwRuntimeError("index out of range") : table.$array[table.$offset + x$4])).ndigits, (((2 >>> 16 << 16) * x$3 >> 0) + (2 << 16 >>> 16) * x$3) >> 0); - } - larger = nat.nil.set(((i < 0 || i >= table.$length) ? $throwRuntimeError("index out of range") : table.$array[table.$offset + i]).bbb); - while (mulAddVWW($subslice(new ($sliceType(Word))(larger.$array), larger.$offset, larger.$offset + larger.$length), $subslice(new ($sliceType(Word))(larger.$array), larger.$offset, larger.$offset + larger.$length), b, 0) === 0) { - ((i < 0 || i >= table.$length) ? $throwRuntimeError("index out of range") : table.$array[table.$offset + i]).bbb = ((i < 0 || i >= table.$length) ? $throwRuntimeError("index out of range") : table.$array[table.$offset + i]).bbb.set(larger); - ((i < 0 || i >= table.$length) ? $throwRuntimeError("index out of range") : table.$array[table.$offset + i]).ndigits = ((i < 0 || i >= table.$length) ? $throwRuntimeError("index out of range") : table.$array[table.$offset + i]).ndigits + (1) >> 0; - } - ((i < 0 || i >= table.$length) ? $throwRuntimeError("index out of range") : table.$array[table.$offset + i]).nbits = ((i < 0 || i >= table.$length) ? $throwRuntimeError("index out of range") : table.$array[table.$offset + i]).bbb.bitLen(); - } - i = i + (1) >> 0; + }; + decodeState.prototype.valueInterface = function() { return this.$val.valueInterface(); }; + decodeState.Ptr.prototype.arrayInterface = function() { + var d, v, op; + d = this; + v = ($sliceType($emptyInterface)).make(0); + while (true) { + op = d.scanWhile(9); + if (op === 8) { + break; + } + d.off = d.off - (1) >> 0; + d.scan.undo(op); + v = $append(v, d.valueInterface()); + op = d.scanWhile(9); + if (op === 8) { + break; + } + if (!((op === 7))) { + d.error(errPhase); } } - if (b === 10) { - cacheBase10.Mutex.Unlock(); + return v; + }; + decodeState.prototype.arrayInterface = function() { return this.$val.arrayInterface(); }; + decodeState.Ptr.prototype.objectInterface = function() { + var d, m, op, start, item, _tuple, key, ok, _key; + d = this; + m = new $Map(); + while (true) { + op = d.scanWhile(9); + if (op === 5) { + break; + } + if (!((op === 1))) { + d.error(errPhase); + } + start = d.off - 1 >> 0; + op = d.scanWhile(0); + item = $subslice(d.data, start, (d.off - 1 >> 0)); + _tuple = unquote(item); key = _tuple[0]; ok = _tuple[1]; + if (!ok) { + d.error(errPhase); + } + if (op === 9) { + op = d.scanWhile(9); + } + if (!((op === 3))) { + d.error(errPhase); + } + _key = key; (m || $throwRuntimeError("assignment to entry in nil map"))[_key] = { k: _key, v: d.valueInterface() }; + op = d.scanWhile(9); + if (op === 5) { + break; + } + if (!((op === 4))) { + d.error(errPhase); + } } - return table; + return m; }; - trailingZeroBits = function(x) { - var _ref, x$1, x$2, x$3, x$4; - _ref = 32; - if (_ref === 32) { - return ((x$1 = ((x$2 = ((x & (-x >>> 0)) >>> 0), (((x$2 >>> 16 << 16) * 125613361 >>> 0) + (x$2 << 16 >>> 16) * 125613361) >>> 0)) >>> 27 >>> 0, ((x$1 < 0 || x$1 >= deBruijn32Lookup.$length) ? $throwRuntimeError("index out of range") : deBruijn32Lookup.$array[deBruijn32Lookup.$offset + x$1])) >>> 0); - } else if (_ref === 64) { - return ((x$3 = ((x$4 = ((x & (-x >>> 0)) >>> 0), (((x$4 >>> 16 << 16) * 3033172745 >>> 0) + (x$4 << 16 >>> 16) * 3033172745) >>> 0)) >>> 58 >>> 0, ((x$3 < 0 || x$3 >= deBruijn64Lookup.$length) ? $throwRuntimeError("index out of range") : deBruijn64Lookup.$array[deBruijn64Lookup.$offset + x$3])) >>> 0); + decodeState.prototype.objectInterface = function() { return this.$val.objectInterface(); }; + decodeState.Ptr.prototype.literalInterface = function() { + var d, start, op, item, c, _ref, _tuple, s, ok, _tuple$1, n, err; + d = this; + start = d.off - 1 >> 0; + op = d.scanWhile(0); + d.off = d.off - (1) >> 0; + d.scan.undo(op); + item = $subslice(d.data, start, d.off); + c = ((0 < 0 || 0 >= item.$length) ? $throwRuntimeError("index out of range") : item.$array[item.$offset + 0]); + _ref = c; + if (_ref === 110) { + return $ifaceNil; + } else if (_ref === 116 || _ref === 102) { + return new $Bool((c === 116)); + } else if (_ref === 34) { + _tuple = unquote(item); s = _tuple[0]; ok = _tuple[1]; + if (!ok) { + d.error(errPhase); + } + return new $String(s); } else { - $panic(new $String("unknown word size")); + if (!((c === 45)) && (c < 48 || c > 57)) { + d.error(errPhase); + } + _tuple$1 = d.convertNumber($bytesToString(item)); n = _tuple$1[0]; err = _tuple$1[1]; + if (!($interfaceIsEqual(err, $ifaceNil))) { + d.saveError(err); + } + return n; } }; - nat.prototype.trailingZeroBits = function() { - var x, i; - x = this; - if (x.$length === 0) { - return 0; + decodeState.prototype.literalInterface = function() { return this.$val.literalInterface(); }; + getu4 = function(s) { + var _tuple, r, err; + if (s.$length < 6 || !((((0 < 0 || 0 >= s.$length) ? $throwRuntimeError("index out of range") : s.$array[s.$offset + 0]) === 92)) || !((((1 < 0 || 1 >= s.$length) ? $throwRuntimeError("index out of range") : s.$array[s.$offset + 1]) === 117))) { + return -1; } - i = 0; - while (((i < 0 || i >= x.$length) ? $throwRuntimeError("index out of range") : x.$array[x.$offset + i]) === 0) { - i = i + (1) >>> 0; + _tuple = strconv.ParseUint($bytesToString($subslice(s, 2, 6)), 16, 64); r = _tuple[0]; err = _tuple[1]; + if (!($interfaceIsEqual(err, $ifaceNil))) { + return -1; } - return ((((i >>> 16 << 16) * 32 >>> 0) + (i << 16 >>> 16) * 32) >>> 0) + trailingZeroBits(((i < 0 || i >= x.$length) ? $throwRuntimeError("index out of range") : x.$array[x.$offset + i])) >>> 0; + return (r.$low >> 0); }; - $ptrType(nat).prototype.trailingZeroBits = function() { return this.$get().trailingZeroBits(); }; - nat.prototype.shl = function(x, s) { - var z, m, _q, n, x$1, _r; - z = this; - m = x.$length; - if (m === 0) { - return z.make(0); - } - n = m + ((_q = s / 32, (_q === _q && _q !== 1/0 && _q !== -1/0) ? _q >>> 0 : $throwRuntimeError("integer divide by zero")) >> 0) >> 0; - z = z.make(n + 1 >> 0); - (n < 0 || n >= z.$length) ? $throwRuntimeError("index out of range") : z.$array[z.$offset + n] = shlVU((x$1 = $subslice(z, (n - m >> 0), n), $subslice(new ($sliceType(Word))(x$1.$array), x$1.$offset, x$1.$offset + x$1.$length)), $subslice(new ($sliceType(Word))(x.$array), x.$offset, x.$offset + x.$length), (_r = s % 32, _r === _r ? _r : $throwRuntimeError("integer divide by zero"))); - $subslice(z, 0, (n - m >> 0)).clear(); - return z.norm(); + unquote = function(s) { + var t = "", ok = false, _tuple; + _tuple = unquoteBytes(s); s = _tuple[0]; ok = _tuple[1]; + t = $bytesToString(s); + return [t, ok]; }; - $ptrType(nat).prototype.shl = function(x, s) { return this.$get().shl(x, s); }; - nat.prototype.shr = function(x, s) { - var z, m, _q, n, x$1, _r; - z = this; - m = x.$length; - n = m - ((_q = s / 32, (_q === _q && _q !== 1/0 && _q !== -1/0) ? _q >>> 0 : $throwRuntimeError("integer divide by zero")) >> 0) >> 0; - if (n <= 0) { - return z.make(0); + unquoteBytes = function(s) { + var t = ($sliceType($Uint8)).nil, ok = false, x, r, c, _tuple, rr, size, _tmp, _tmp$1, b, w, x$1, nb, c$1, _ref, rr$1, rr1, dec, _tuple$1, rr$2, size$1, _tmp$2, _tmp$3; + if (s.$length < 2 || !((((0 < 0 || 0 >= s.$length) ? $throwRuntimeError("index out of range") : s.$array[s.$offset + 0]) === 34)) || !(((x = s.$length - 1 >> 0, ((x < 0 || x >= s.$length) ? $throwRuntimeError("index out of range") : s.$array[s.$offset + x])) === 34))) { + return [t, ok]; } - z = z.make(n); - shrVU($subslice(new ($sliceType(Word))(z.$array), z.$offset, z.$offset + z.$length), (x$1 = $subslice(x, (m - n >> 0)), $subslice(new ($sliceType(Word))(x$1.$array), x$1.$offset, x$1.$offset + x$1.$length)), (_r = s % 32, _r === _r ? _r : $throwRuntimeError("integer divide by zero"))); - return z.norm(); - }; - $ptrType(nat).prototype.shr = function(x, s) { return this.$get().shr(x, s); }; - nat.prototype.setBit = function(x, i, b) { - var z, _q, j, y, _r, m, n, _ref, _lhs, _index, _lhs$1, _index$1; - z = this; - j = ((_q = i / 32, (_q === _q && _q !== 1/0 && _q !== -1/0) ? _q >>> 0 : $throwRuntimeError("integer divide by zero")) >> 0); - m = (y = ((_r = i % 32, _r === _r ? _r : $throwRuntimeError("integer divide by zero"))), y < 32 ? (1 << y) : 0) >>> 0; - n = x.$length; - _ref = b; - if (_ref === 0) { - z = z.make(n); - $copySlice(z, x); - if (j >= n) { - return z; + s = $subslice(s, 1, (s.$length - 1 >> 0)); + r = 0; + while (r < s.$length) { + c = ((r < 0 || r >= s.$length) ? $throwRuntimeError("index out of range") : s.$array[s.$offset + r]); + if ((c === 92) || (c === 34) || c < 32) { + break; } - _lhs = z; _index = j; (_index < 0 || _index >= _lhs.$length) ? $throwRuntimeError("index out of range") : _lhs.$array[_lhs.$offset + _index] = ((_index < 0 || _index >= _lhs.$length) ? $throwRuntimeError("index out of range") : _lhs.$array[_lhs.$offset + _index]) & ~(m); - return z.norm(); - } else if (_ref === 1) { - if (j >= n) { - z = z.make(j + 1 >> 0); - $subslice(z, n).clear(); - } else { - z = z.make(n); + if (c < 128) { + r = r + (1) >> 0; + continue; } - $copySlice(z, x); - _lhs$1 = z; _index$1 = j; (_index$1 < 0 || _index$1 >= _lhs$1.$length) ? $throwRuntimeError("index out of range") : _lhs$1.$array[_lhs$1.$offset + _index$1] = (((_index$1 < 0 || _index$1 >= _lhs$1.$length) ? $throwRuntimeError("index out of range") : _lhs$1.$array[_lhs$1.$offset + _index$1]) | (m)) >>> 0; - return z; + _tuple = utf8.DecodeRune($subslice(s, r)); rr = _tuple[0]; size = _tuple[1]; + if ((rr === 65533) && (size === 1)) { + break; + } + r = r + (size) >> 0; } - $panic(new $String("set bit is not 0 or 1")); - }; - $ptrType(nat).prototype.setBit = function(x, i, b) { return this.$get().setBit(x, i, b); }; - nat.prototype.bit = function(i) { - var z, _q, j, y, _r; - z = this; - j = ((_q = i / 32, (_q === _q && _q !== 1/0 && _q !== -1/0) ? _q >>> 0 : $throwRuntimeError("integer divide by zero")) >> 0); - if (j >= z.$length) { - return 0; + if (r === s.$length) { + _tmp = s; _tmp$1 = true; t = _tmp; ok = _tmp$1; + return [t, ok]; } - return (((((y = ((_r = i % 32, _r === _r ? _r : $throwRuntimeError("integer divide by zero"))), y < 32 ? (((j < 0 || j >= z.$length) ? $throwRuntimeError("index out of range") : z.$array[z.$offset + j]) >>> y) : 0) >>> 0) & 1) >>> 0) >>> 0); - }; - $ptrType(nat).prototype.bit = function(i) { return this.$get().bit(i); }; - nat.prototype.and = function(x, y) { - var z, m, n, i; - z = this; - m = x.$length; - n = y.$length; - if (m > n) { - m = n; - } - z = z.make(m); - i = 0; - while (i < m) { - (i < 0 || i >= z.$length) ? $throwRuntimeError("index out of range") : z.$array[z.$offset + i] = (((i < 0 || i >= x.$length) ? $throwRuntimeError("index out of range") : x.$array[x.$offset + i]) & ((i < 0 || i >= y.$length) ? $throwRuntimeError("index out of range") : y.$array[y.$offset + i])) >>> 0; - i = i + (1) >> 0; - } - return z.norm(); - }; - $ptrType(nat).prototype.and = function(x, y) { return this.$get().and(x, y); }; - nat.prototype.andNot = function(x, y) { - var z, m, n, i; - z = this; - m = x.$length; - n = y.$length; - if (n > m) { - n = m; - } - z = z.make(m); - i = 0; - while (i < n) { - (i < 0 || i >= z.$length) ? $throwRuntimeError("index out of range") : z.$array[z.$offset + i] = ((i < 0 || i >= x.$length) ? $throwRuntimeError("index out of range") : x.$array[x.$offset + i]) & ~((i < 0 || i >= y.$length) ? $throwRuntimeError("index out of range") : y.$array[y.$offset + i]); - i = i + (1) >> 0; + b = ($sliceType($Uint8)).make((s.$length + 8 >> 0)); + w = $copySlice(b, $subslice(s, 0, r)); + while (r < s.$length) { + if (w >= (b.$length - 8 >> 0)) { + nb = ($sliceType($Uint8)).make((x$1 = (b.$length + 4 >> 0), (((x$1 >>> 16 << 16) * 2 >> 0) + (x$1 << 16 >>> 16) * 2) >> 0)); + $copySlice(nb, $subslice(b, 0, w)); + b = nb; + } + c$1 = ((r < 0 || r >= s.$length) ? $throwRuntimeError("index out of range") : s.$array[s.$offset + r]); + if (c$1 === 92) { + r = r + (1) >> 0; + if (r >= s.$length) { + return [t, ok]; + } + _ref = ((r < 0 || r >= s.$length) ? $throwRuntimeError("index out of range") : s.$array[s.$offset + r]); + switch (0) { default: if (_ref === 34 || _ref === 92 || _ref === 47 || _ref === 39) { + (w < 0 || w >= b.$length) ? $throwRuntimeError("index out of range") : b.$array[b.$offset + w] = ((r < 0 || r >= s.$length) ? $throwRuntimeError("index out of range") : s.$array[s.$offset + r]); + r = r + (1) >> 0; + w = w + (1) >> 0; + } else if (_ref === 98) { + (w < 0 || w >= b.$length) ? $throwRuntimeError("index out of range") : b.$array[b.$offset + w] = 8; + r = r + (1) >> 0; + w = w + (1) >> 0; + } else if (_ref === 102) { + (w < 0 || w >= b.$length) ? $throwRuntimeError("index out of range") : b.$array[b.$offset + w] = 12; + r = r + (1) >> 0; + w = w + (1) >> 0; + } else if (_ref === 110) { + (w < 0 || w >= b.$length) ? $throwRuntimeError("index out of range") : b.$array[b.$offset + w] = 10; + r = r + (1) >> 0; + w = w + (1) >> 0; + } else if (_ref === 114) { + (w < 0 || w >= b.$length) ? $throwRuntimeError("index out of range") : b.$array[b.$offset + w] = 13; + r = r + (1) >> 0; + w = w + (1) >> 0; + } else if (_ref === 116) { + (w < 0 || w >= b.$length) ? $throwRuntimeError("index out of range") : b.$array[b.$offset + w] = 9; + r = r + (1) >> 0; + w = w + (1) >> 0; + } else if (_ref === 117) { + r = r - (1) >> 0; + rr$1 = getu4($subslice(s, r)); + if (rr$1 < 0) { + return [t, ok]; + } + r = r + (6) >> 0; + if (utf16.IsSurrogate(rr$1)) { + rr1 = getu4($subslice(s, r)); + dec = utf16.DecodeRune(rr$1, rr1); + if (!((dec === 65533))) { + r = r + (6) >> 0; + w = w + (utf8.EncodeRune($subslice(b, w), dec)) >> 0; + break; + } + rr$1 = 65533; + } + w = w + (utf8.EncodeRune($subslice(b, w), rr$1)) >> 0; + } else { + return [t, ok]; + } } + } else if (c$1 === 34 || c$1 < 32) { + return [t, ok]; + } else if (c$1 < 128) { + (w < 0 || w >= b.$length) ? $throwRuntimeError("index out of range") : b.$array[b.$offset + w] = c$1; + r = r + (1) >> 0; + w = w + (1) >> 0; + } else { + _tuple$1 = utf8.DecodeRune($subslice(s, r)); rr$2 = _tuple$1[0]; size$1 = _tuple$1[1]; + r = r + (size$1) >> 0; + w = w + (utf8.EncodeRune($subslice(b, w), rr$2)) >> 0; + } } - $copySlice($subslice(z, n, m), $subslice(x, n, m)); - return z.norm(); + _tmp$2 = $subslice(b, 0, w); _tmp$3 = true; t = _tmp$2; ok = _tmp$3; + return [t, ok]; }; - $ptrType(nat).prototype.andNot = function(x, y) { return this.$get().andNot(x, y); }; - nat.prototype.or = function(x, y) { - var z, m, n, s, _tmp, _tmp$1, i; - z = this; - m = x.$length; - n = y.$length; - s = x; - if (m < n) { - _tmp = m; _tmp$1 = n; n = _tmp; m = _tmp$1; - s = y; - } - z = z.make(m); - i = 0; - while (i < n) { - (i < 0 || i >= z.$length) ? $throwRuntimeError("index out of range") : z.$array[z.$offset + i] = (((i < 0 || i >= x.$length) ? $throwRuntimeError("index out of range") : x.$array[x.$offset + i]) | ((i < 0 || i >= y.$length) ? $throwRuntimeError("index out of range") : y.$array[y.$offset + i])) >>> 0; - i = i + (1) >> 0; + Marshal = $pkg.Marshal = function(v) { + var e, err; + e = new encodeState.Ptr(new bytes.Buffer.Ptr(), ($arrayType($Uint8, 64)).zero()); + err = e.marshal(v); + if (!($interfaceIsEqual(err, $ifaceNil))) { + return [($sliceType($Uint8)).nil, err]; } - $copySlice($subslice(z, n, m), $subslice(s, n, m)); - return z.norm(); + return [e.Buffer.Bytes(), $ifaceNil]; }; - $ptrType(nat).prototype.or = function(x, y) { return this.$get().or(x, y); }; - nat.prototype.xor = function(x, y) { - var z, m, n, s, _tmp, _tmp$1, i; - z = this; - m = x.$length; - n = y.$length; - s = x; - if (m < n) { - _tmp = m; _tmp$1 = n; n = _tmp; m = _tmp$1; - s = y; - } - z = z.make(m); - i = 0; - while (i < n) { - (i < 0 || i >= z.$length) ? $throwRuntimeError("index out of range") : z.$array[z.$offset + i] = (((i < 0 || i >= x.$length) ? $throwRuntimeError("index out of range") : x.$array[x.$offset + i]) ^ ((i < 0 || i >= y.$length) ? $throwRuntimeError("index out of range") : y.$array[y.$offset + i])) >>> 0; - i = i + (1) >> 0; - } - $copySlice($subslice(z, n, m), $subslice(s, n, m)); - return z.norm(); + UnsupportedTypeError.Ptr.prototype.Error = function() { + var e; + e = this; + return "json: unsupported type: " + e.Type.String(); }; - $ptrType(nat).prototype.xor = function(x, y) { return this.$get().xor(x, y); }; - greaterThan = function(x1, x2, y1, y2) { - return x1 > y1 || (x1 === y1) && x2 > y2; + UnsupportedTypeError.prototype.Error = function() { return this.$val.Error(); }; + UnsupportedValueError.Ptr.prototype.Error = function() { + var e; + e = this; + return "json: unsupported value: " + e.Str; }; - nat.prototype.modW = function(d) { - var r = 0, x, q; - x = this; - q = nat.nil; - q = q.make(x.$length); - r = divWVW($subslice(new ($sliceType(Word))(q.$array), q.$offset, q.$offset + q.$length), 0, $subslice(new ($sliceType(Word))(x.$array), x.$offset, x.$offset + x.$length), d); - return r; + UnsupportedValueError.prototype.Error = function() { return this.$val.Error(); }; + MarshalerError.Ptr.prototype.Error = function() { + var e; + e = this; + return "json: error calling MarshalJSON for type " + e.Type.String() + ": " + e.Err.Error(); }; - $ptrType(nat).prototype.modW = function(d) { return this.$get().modW(d); }; - nat.prototype.random = function(rand$1, limit, n) { - var z, _r, bitLengthOfMSW, y, mask, _ref, _ref$1, _i, i, _ref$2, _i$1, i$1, _lhs, _index; - z = this; - if (alias(z, limit)) { - z = nat.nil; - } - z = z.make(limit.$length); - bitLengthOfMSW = ((_r = n % 32, _r === _r ? _r : $throwRuntimeError("integer divide by zero")) >>> 0); - if (bitLengthOfMSW === 0) { - bitLengthOfMSW = 32; + MarshalerError.prototype.Error = function() { return this.$val.Error(); }; + newEncodeState = function() { + var v, e; + v = encodeStatePool.Get(); + if (!($interfaceIsEqual(v, $ifaceNil))) { + e = $assertType(v, ($ptrType(encodeState))); + e.Buffer.Reset(); + return e; } - mask = ((((y = bitLengthOfMSW, y < 32 ? (1 << y) : 0) >>> 0)) - 1 >>> 0); - while (true) { - _ref = 32; - if (_ref === 32) { - _ref$1 = z; - _i = 0; - while (_i < _ref$1.$length) { - i = _i; - (i < 0 || i >= z.$length) ? $throwRuntimeError("index out of range") : z.$array[z.$offset + i] = (rand$1.Uint32() >>> 0); - _i++; + return new encodeState.Ptr(); + }; + encodeState.Ptr.prototype.marshal = function(v) { + var err = $ifaceNil, $deferred = [], $err = null, e; + /* */ try { $deferFrames.push($deferred); + e = this; + $deferred.push([(function() { + var r, _tuple, ok, _tuple$1, s, ok$1; + r = $recover(); + if (!($interfaceIsEqual(r, $ifaceNil))) { + _tuple = $assertType(r, runtime.Error, true); ok = _tuple[1]; + if (ok) { + $panic(r); } - } else if (_ref === 64) { - _ref$2 = z; - _i$1 = 0; - while (_i$1 < _ref$2.$length) { - i$1 = _i$1; - (i$1 < 0 || i$1 >= z.$length) ? $throwRuntimeError("index out of range") : z.$array[z.$offset + i$1] = ((rand$1.Uint32() >>> 0) | ((rand$1.Uint32() >>> 0) << 32 >>> 0)) >>> 0; - _i$1++; + _tuple$1 = $assertType(r, $String, true); s = _tuple$1[0]; ok$1 = _tuple$1[1]; + if (ok$1) { + $panic(new $String(s)); } - } else { - $panic(new $String("unknown word size")); - } - _lhs = z; _index = limit.$length - 1 >> 0; (_index < 0 || _index >= _lhs.$length) ? $throwRuntimeError("index out of range") : _lhs.$array[_lhs.$offset + _index] = (((_index < 0 || _index >= _lhs.$length) ? $throwRuntimeError("index out of range") : _lhs.$array[_lhs.$offset + _index]) & (mask)) >>> 0; - if (z.cmp(limit) < 0) { - break; + err = $assertType(r, $error); } - } - return z.norm(); + }), []]); + e.reflectValue($clone(reflect.ValueOf(v), reflect.Value)); + err = $ifaceNil; + return err; + /* */ } catch(err) { $err = err; } finally { $deferFrames.pop(); $callDeferred($deferred, $err); return err; } }; - $ptrType(nat).prototype.random = function(rand$1, limit, n) { return this.$get().random(rand$1, limit, n); }; - nat.prototype.expNN = function(x, y, m) { - var z, x$1, v, shift, y$1, q, w, _tmp, _tmp$1, zz, r, j, _tmp$2, _tmp$3, _tmp$4, _tmp$5, _tuple, _tmp$6, _tmp$7, _tmp$8, _tmp$9, y$2, i, j$1, _tmp$10, _tmp$11, _tmp$12, _tmp$13, _tuple$1, _tmp$14, _tmp$15, _tmp$16, _tmp$17, y$3; - z = this; - if (alias(z, x) || alias(z, y)) { - z = nat.nil; + encodeState.prototype.marshal = function(v) { return this.$val.marshal(v); }; + encodeState.Ptr.prototype.error = function(err) { + var e; + e = this; + $panic(err); + }; + encodeState.prototype.error = function(err) { return this.$val.error(err); }; + isEmptyValue = function(v) { + var _ref, x, x$1; + _ref = v.Kind(); + if (_ref === 17 || _ref === 21 || _ref === 23 || _ref === 24) { + return v.Len() === 0; + } else if (_ref === 1) { + return !v.Bool(); + } else if (_ref === 2 || _ref === 3 || _ref === 4 || _ref === 5 || _ref === 6) { + return (x = v.Int(), (x.$high === 0 && x.$low === 0)); + } else if (_ref === 7 || _ref === 8 || _ref === 9 || _ref === 10 || _ref === 11 || _ref === 12) { + return (x$1 = v.Uint(), (x$1.$high === 0 && x$1.$low === 0)); + } else if (_ref === 13 || _ref === 14) { + return v.Float() === 0; + } else if (_ref === 20 || _ref === 22) { + return v.IsNil(); } - if ((m.$length === 1) && (((0 < 0 || 0 >= m.$length) ? $throwRuntimeError("index out of range") : m.$array[m.$offset + 0]) === 1)) { - return z.setWord(0); + return false; + }; + encodeState.Ptr.prototype.reflectValue = function(v) { + var e; + e = this; + valueEncoder($clone(v, reflect.Value))(e, $clone(v, reflect.Value), false); + }; + encodeState.prototype.reflectValue = function(v) { return this.$val.reflectValue(v); }; + valueEncoder = function(v) { + if (!v.IsValid()) { + return invalidValueEncoder; } - if (y.$length === 0) { - return z.setWord(1); + return typeEncoder(v.Type()); + }; + typeEncoder = function(t) { + var _entry, f, wg, _key, _key$1; + encoderCache.RWMutex.RLock(); + f = (_entry = encoderCache.m[t.$key()], _entry !== undefined ? _entry.v : $throwNilPointerError); + encoderCache.RWMutex.RUnlock(); + if (!(f === $throwNilPointerError)) { + return f; } - if (!((m.$length === 0))) { - z = z.make(m.$length); + encoderCache.RWMutex.Lock(); + if (encoderCache.m === false) { + encoderCache.m = new $Map(); } - z = z.set(x); - if (x.$length > 1 && y.$length > 1 && m.$length > 0) { - return z.expNNWindowed(x, y, m); + wg = new sync.WaitGroup.Ptr(); $copy(wg, new sync.WaitGroup.Ptr(), sync.WaitGroup); + wg.Add(1); + _key = t; (encoderCache.m || $throwRuntimeError("assignment to entry in nil map"))[_key.$key()] = { k: _key, v: (function(e, v, quoted) { + wg.Wait(); + f(e, $clone(v, reflect.Value), quoted); + }) }; + encoderCache.RWMutex.Unlock(); + f = newTypeEncoder(t, true); + wg.Done(); + encoderCache.RWMutex.Lock(); + _key$1 = t; (encoderCache.m || $throwRuntimeError("assignment to entry in nil map"))[_key$1.$key()] = { k: _key$1, v: f }; + encoderCache.RWMutex.Unlock(); + return f; + }; + newTypeEncoder = function(t, allowAddr) { + var _ref; + if (t.Implements(marshalerType)) { + return marshalerEncoder; } - v = (x$1 = y.$length - 1 >> 0, ((x$1 < 0 || x$1 >= y.$length) ? $throwRuntimeError("index out of range") : y.$array[y.$offset + x$1])); - shift = leadingZeros(v) + 1 >>> 0; - v = (y$1 = (shift), y$1 < 32 ? (v << y$1) : 0) >>> 0; - q = nat.nil; - w = 32 - (shift >> 0) >> 0; - _tmp = nat.nil; _tmp$1 = nat.nil; zz = _tmp; r = _tmp$1; - j = 0; - while (j < w) { - zz = zz.mul(z, z); - _tmp$2 = z; _tmp$3 = zz; zz = _tmp$2; z = _tmp$3; - if (!((((v & 2147483648) >>> 0) === 0))) { - zz = zz.mul(z, x); - _tmp$4 = z; _tmp$5 = zz; zz = _tmp$4; z = _tmp$5; - } - if (!((m.$length === 0))) { - _tuple = zz.div(r, z, m); zz = _tuple[0]; r = _tuple[1]; - _tmp$6 = q; _tmp$7 = z; _tmp$8 = zz; _tmp$9 = r; zz = _tmp$6; r = _tmp$7; q = _tmp$8; z = _tmp$9; + if (!((t.Kind() === 22)) && allowAddr) { + if (reflect.PtrTo(t).Implements(marshalerType)) { + return newCondAddrEncoder(addrMarshalerEncoder, newTypeEncoder(t, false)); } - v = (y$2 = (1), y$2 < 32 ? (v << y$2) : 0) >>> 0; - j = j + (1) >> 0; } - i = y.$length - 2 >> 0; - while (i >= 0) { - v = ((i < 0 || i >= y.$length) ? $throwRuntimeError("index out of range") : y.$array[y.$offset + i]); - j$1 = 0; - while (j$1 < 32) { - zz = zz.mul(z, z); - _tmp$10 = z; _tmp$11 = zz; zz = _tmp$10; z = _tmp$11; - if (!((((v & 2147483648) >>> 0) === 0))) { - zz = zz.mul(z, x); - _tmp$12 = z; _tmp$13 = zz; zz = _tmp$12; z = _tmp$13; - } - if (!((m.$length === 0))) { - _tuple$1 = zz.div(r, z, m); zz = _tuple$1[0]; r = _tuple$1[1]; - _tmp$14 = q; _tmp$15 = z; _tmp$16 = zz; _tmp$17 = r; zz = _tmp$14; r = _tmp$15; q = _tmp$16; z = _tmp$17; - } - v = (y$3 = (1), y$3 < 32 ? (v << y$3) : 0) >>> 0; - j$1 = j$1 + (1) >> 0; + if (t.Implements(textMarshalerType)) { + return textMarshalerEncoder; + } + if (!((t.Kind() === 22)) && allowAddr) { + if (reflect.PtrTo(t).Implements(textMarshalerType)) { + return newCondAddrEncoder(addrTextMarshalerEncoder, newTypeEncoder(t, false)); } - i = i - (1) >> 0; } - return z.norm(); + _ref = t.Kind(); + if (_ref === 1) { + return boolEncoder; + } else if (_ref === 2 || _ref === 3 || _ref === 4 || _ref === 5 || _ref === 6) { + return intEncoder; + } else if (_ref === 7 || _ref === 8 || _ref === 9 || _ref === 10 || _ref === 11 || _ref === 12) { + return uintEncoder; + } else if (_ref === 13) { + return float32Encoder; + } else if (_ref === 14) { + return float64Encoder; + } else if (_ref === 24) { + return stringEncoder; + } else if (_ref === 20) { + return interfaceEncoder; + } else if (_ref === 25) { + return newStructEncoder(t); + } else if (_ref === 21) { + return newMapEncoder(t); + } else if (_ref === 23) { + return newSliceEncoder(t); + } else if (_ref === 17) { + return newArrayEncoder(t); + } else if (_ref === 22) { + return newPtrEncoder(t); + } else { + return unsupportedTypeEncoder; + } }; - $ptrType(nat).prototype.expNN = function(x, y, m) { return this.$get().expNN(x, y, m); }; - nat.prototype.expNNWindowed = function(x, y, m) { - var z, _tmp, _tmp$1, zz, r, powers, i, _tmp$2, x$1, _q, x$2, _q$1, _tmp$3, _tmp$4, x$3, x$4, p2, p, p1, _tuple, _tmp$5, _tmp$6, _tuple$1, _tmp$7, _tmp$8, i$1, yi, j, _tmp$9, _tmp$10, _tuple$2, _tmp$11, _tmp$12, _tmp$13, _tmp$14, _tuple$3, _tmp$15, _tmp$16, _tmp$17, _tmp$18, _tuple$4, _tmp$19, _tmp$20, _tmp$21, _tmp$22, _tuple$5, _tmp$23, _tmp$24, x$5, _tmp$25, _tmp$26, _tuple$6, _tmp$27, _tmp$28, y$1; - z = this; - _tmp = nat.nil; _tmp$1 = nat.nil; zz = _tmp; r = _tmp$1; - powers = ($arrayType(nat, 16)).zero(); $copy(powers, ($arrayType(nat, 16)).zero(), ($arrayType(nat, 16))); - powers[0] = natOne; - powers[1] = x; - i = 2; - while (i < 16) { - _tmp$2 = new ($ptrType(nat))(function() { return (x$2 = (_q$1 = i / 2, (_q$1 === _q$1 && _q$1 !== 1/0 && _q$1 !== -1/0) ? _q$1 >> 0 : $throwRuntimeError("integer divide by zero")), ((x$2 < 0 || x$2 >= this.$target.length) ? $throwRuntimeError("index out of range") : this.$target[x$2])); }, function($v) { (x$1 = (_q = i / 2, (_q === _q && _q !== 1/0 && _q !== -1/0) ? _q >> 0 : $throwRuntimeError("integer divide by zero")), (x$1 < 0 || x$1 >= this.$target.length) ? $throwRuntimeError("index out of range") : this.$target[x$1] = $v); }, powers); _tmp$3 = new ($ptrType(nat))(function() { return ((i < 0 || i >= this.$target.length) ? $throwRuntimeError("index out of range") : this.$target[i]); }, function($v) { (i < 0 || i >= this.$target.length) ? $throwRuntimeError("index out of range") : this.$target[i] = $v; }, powers); _tmp$4 = new ($ptrType(nat))(function() { return (x$4 = i + 1 >> 0, ((x$4 < 0 || x$4 >= this.$target.length) ? $throwRuntimeError("index out of range") : this.$target[x$4])); }, function($v) { (x$3 = i + 1 >> 0, (x$3 < 0 || x$3 >= this.$target.length) ? $throwRuntimeError("index out of range") : this.$target[x$3] = $v); }, powers); p2 = _tmp$2; p = _tmp$3; p1 = _tmp$4; - p.$set(p.mul(p2.$get(), p2.$get())); - _tuple = zz.div(r, p.$get(), m); zz = _tuple[0]; r = _tuple[1]; - _tmp$5 = r; _tmp$6 = p.$get(); p.$set(_tmp$5); r = _tmp$6; - p1.$set(p1.mul(p.$get(), x)); - _tuple$1 = zz.div(r, p1.$get(), m); zz = _tuple$1[0]; r = _tuple$1[1]; - _tmp$7 = r; _tmp$8 = p1.$get(); p1.$set(_tmp$7); r = _tmp$8; - i = i + (2) >> 0; + invalidValueEncoder = function(e, v, quoted) { + e.Buffer.WriteString("null"); + }; + marshalerEncoder = function(e, v, quoted) { + var m, _tuple, b, err; + if ((v.Kind() === 22) && v.IsNil()) { + e.Buffer.WriteString("null"); + return; } - z = z.setWord(1); - i$1 = y.$length - 1 >> 0; - while (i$1 >= 0) { - yi = ((i$1 < 0 || i$1 >= y.$length) ? $throwRuntimeError("index out of range") : y.$array[y.$offset + i$1]); - j = 0; - while (j < 32) { - if (!((i$1 === (y.$length - 1 >> 0))) || !((j === 0))) { - zz = zz.mul(z, z); - _tmp$9 = z; _tmp$10 = zz; zz = _tmp$9; z = _tmp$10; - _tuple$2 = zz.div(r, z, m); zz = _tuple$2[0]; r = _tuple$2[1]; - _tmp$11 = r; _tmp$12 = z; z = _tmp$11; r = _tmp$12; - zz = zz.mul(z, z); - _tmp$13 = z; _tmp$14 = zz; zz = _tmp$13; z = _tmp$14; - _tuple$3 = zz.div(r, z, m); zz = _tuple$3[0]; r = _tuple$3[1]; - _tmp$15 = r; _tmp$16 = z; z = _tmp$15; r = _tmp$16; - zz = zz.mul(z, z); - _tmp$17 = z; _tmp$18 = zz; zz = _tmp$17; z = _tmp$18; - _tuple$4 = zz.div(r, z, m); zz = _tuple$4[0]; r = _tuple$4[1]; - _tmp$19 = r; _tmp$20 = z; z = _tmp$19; r = _tmp$20; - zz = zz.mul(z, z); - _tmp$21 = z; _tmp$22 = zz; zz = _tmp$21; z = _tmp$22; - _tuple$5 = zz.div(r, z, m); zz = _tuple$5[0]; r = _tuple$5[1]; - _tmp$23 = r; _tmp$24 = z; z = _tmp$23; r = _tmp$24; - } - zz = zz.mul(z, (x$5 = yi >>> 28 >>> 0, ((x$5 < 0 || x$5 >= powers.length) ? $throwRuntimeError("index out of range") : powers[x$5]))); - _tmp$25 = z; _tmp$26 = zz; zz = _tmp$25; z = _tmp$26; - _tuple$6 = zz.div(r, z, m); zz = _tuple$6[0]; r = _tuple$6[1]; - _tmp$27 = r; _tmp$28 = z; z = _tmp$27; r = _tmp$28; - yi = (y$1 = (4), y$1 < 32 ? (yi << y$1) : 0) >>> 0; - j = j + (4) >> 0; - } - i$1 = i$1 - (1) >> 0; + m = $assertType(v.Interface(), Marshaler); + _tuple = m.MarshalJSON(); b = _tuple[0]; err = _tuple[1]; + if ($interfaceIsEqual(err, $ifaceNil)) { + err = compact(e.Buffer, b, true); + } + if (!($interfaceIsEqual(err, $ifaceNil))) { + e.error(new MarshalerError.Ptr(v.Type(), err)); } - return z.norm(); }; - $ptrType(nat).prototype.expNNWindowed = function(x, y, m) { return this.$get().expNNWindowed(x, y, m); }; - nat.prototype.probablyPrime = function(reps) { - var n, _r, _ref, r, _ref$1, _r$1, _r$2, _r$3, _r$4, _r$5, _r$6, _r$7, _r$8, _r$9, _r$10, _r$11, _r$12, _r$13, _r$14, _r$15, nm1, k, q, nm3, x, rand$1, _tmp, _tmp$1, _tmp$2, x$1, y, quotient, nm3Len, i, j, _tuple; - n = this; - if (n.$length === 0) { - return false; + addrMarshalerEncoder = function(e, v, quoted) { + var va, m, _tuple, b, err; + va = new reflect.Value.Ptr(); $copy(va, v.Addr(), reflect.Value); + if (va.IsNil()) { + e.Buffer.WriteString("null"); + return; } - if (n.$length === 1) { - if (((0 < 0 || 0 >= n.$length) ? $throwRuntimeError("index out of range") : n.$array[n.$offset + 0]) < 2) { - return false; - } - if ((_r = ((0 < 0 || 0 >= n.$length) ? $throwRuntimeError("index out of range") : n.$array[n.$offset + 0]) % 2, _r === _r ? _r : $throwRuntimeError("integer divide by zero")) === 0) { - return ((0 < 0 || 0 >= n.$length) ? $throwRuntimeError("index out of range") : n.$array[n.$offset + 0]) === 2; - } - _ref = ((0 < 0 || 0 >= n.$length) ? $throwRuntimeError("index out of range") : n.$array[n.$offset + 0]); - if (_ref === 3 || _ref === 5 || _ref === 7 || _ref === 11 || _ref === 13 || _ref === 17 || _ref === 19 || _ref === 23 || _ref === 29 || _ref === 31 || _ref === 37 || _ref === 41 || _ref === 43 || _ref === 47 || _ref === 53) { - return true; - } + m = $assertType(va.Interface(), Marshaler); + _tuple = m.MarshalJSON(); b = _tuple[0]; err = _tuple[1]; + if ($interfaceIsEqual(err, $ifaceNil)) { + err = compact(e.Buffer, b, true); } - r = 0; - _ref$1 = 32; - if (_ref$1 === 32) { - r = n.modW(3234846615); - } else if (_ref$1 === 64) { - r = n.modW(820596253); - } else { - $panic(new $String("Unknown word size")); + if (!($interfaceIsEqual(err, $ifaceNil))) { + e.error(new MarshalerError.Ptr(v.Type(), err)); } - if (((_r$1 = r % 3, _r$1 === _r$1 ? _r$1 : $throwRuntimeError("integer divide by zero")) === 0) || ((_r$2 = r % 5, _r$2 === _r$2 ? _r$2 : $throwRuntimeError("integer divide by zero")) === 0) || ((_r$3 = r % 7, _r$3 === _r$3 ? _r$3 : $throwRuntimeError("integer divide by zero")) === 0) || ((_r$4 = r % 11, _r$4 === _r$4 ? _r$4 : $throwRuntimeError("integer divide by zero")) === 0) || ((_r$5 = r % 13, _r$5 === _r$5 ? _r$5 : $throwRuntimeError("integer divide by zero")) === 0) || ((_r$6 = r % 17, _r$6 === _r$6 ? _r$6 : $throwRuntimeError("integer divide by zero")) === 0) || ((_r$7 = r % 19, _r$7 === _r$7 ? _r$7 : $throwRuntimeError("integer divide by zero")) === 0) || ((_r$8 = r % 23, _r$8 === _r$8 ? _r$8 : $throwRuntimeError("integer divide by zero")) === 0) || ((_r$9 = r % 29, _r$9 === _r$9 ? _r$9 : $throwRuntimeError("integer divide by zero")) === 0)) { - return false; + }; + textMarshalerEncoder = function(e, v, quoted) { + var m, _tuple, b, err, _tuple$1; + if ((v.Kind() === 22) && v.IsNil()) { + e.Buffer.WriteString("null"); + return; } - nm1 = nat.nil.sub(n, natOne); - k = nm1.trailingZeroBits(); - q = nat.nil.shr(nm1, k); - nm3 = nat.nil.sub(nm1, natTwo); - rand$1 = rand.New(rand.NewSource((x = ((0 < 0 || 0 >= n.$length) ? $throwRuntimeError("index out of range") : n.$array[n.$offset + 0]), new $Int64(0, x.constructor === Number ? x : 1)))); - _tmp = nat.nil; _tmp$1 = nat.nil; _tmp$2 = nat.nil; x$1 = _tmp; y = _tmp$1; quotient = _tmp$2; - nm3Len = nm3.bitLen(); - i = 0; - NextRandom: - while (i < reps) { - x$1 = x$1.random(rand$1, nm3, nm3Len); - x$1 = x$1.add(x$1, natTwo); - y = y.expNN(x$1, q, n); - if ((y.cmp(natOne) === 0) || (y.cmp(nm1) === 0)) { - i = i + (1) >> 0; - continue; - } - j = 1; - while (j < k) { - y = y.mul(y, y); - _tuple = quotient.div(y, y, n); quotient = _tuple[0]; y = _tuple[1]; - if (y.cmp(nm1) === 0) { - i = i + (1) >> 0; - continue NextRandom; - } - if (y.cmp(natOne) === 0) { - return false; - } - j = j + (1) >>> 0; - } - return false; - } - return true; - }; - $ptrType(nat).prototype.probablyPrime = function(reps) { return this.$get().probablyPrime(reps); }; - nat.prototype.bytes = function(buf) { - var i = 0, z, _ref, _i, d, j, y; - z = this; - i = buf.$length; - _ref = z; - _i = 0; - while (_i < _ref.$length) { - d = ((_i < 0 || _i >= _ref.$length) ? $throwRuntimeError("index out of range") : _ref.$array[_ref.$offset + _i]); - j = 0; - while (j < 4) { - i = i - (1) >> 0; - (i < 0 || i >= buf.$length) ? $throwRuntimeError("index out of range") : buf.$array[buf.$offset + i] = (d << 24 >>> 24); - d = (y = (8), y < 32 ? (d >>> y) : 0) >>> 0; - j = j + (1) >> 0; - } - _i++; + m = $assertType(v.Interface(), encoding.TextMarshaler); + _tuple = m.MarshalText(); b = _tuple[0]; err = _tuple[1]; + if ($interfaceIsEqual(err, $ifaceNil)) { + _tuple$1 = e.stringBytes(b); err = _tuple$1[1]; } - while (i < buf.$length && (((i < 0 || i >= buf.$length) ? $throwRuntimeError("index out of range") : buf.$array[buf.$offset + i]) === 0)) { - i = i + (1) >> 0; + if (!($interfaceIsEqual(err, $ifaceNil))) { + e.error(new MarshalerError.Ptr(v.Type(), err)); } - return i; }; - $ptrType(nat).prototype.bytes = function(buf) { return this.$get().bytes(buf); }; - nat.prototype.setBytes = function(buf) { - var z, _q, k, s, d, i, y, x; - z = this; - z = z.make((_q = (((buf.$length + 4 >> 0) - 1 >> 0)) / 4, (_q === _q && _q !== 1/0 && _q !== -1/0) ? _q >> 0 : $throwRuntimeError("integer divide by zero"))); - k = 0; - s = 0; - d = 0; - i = buf.$length; - while (i > 0) { - d = (d | (((y = s, y < 32 ? (((x = i - 1 >> 0, ((x < 0 || x >= buf.$length) ? $throwRuntimeError("index out of range") : buf.$array[buf.$offset + x])) >>> 0) << y) : 0) >>> 0))) >>> 0; - s = s + (8) >>> 0; - if (s === 32) { - (k < 0 || k >= z.$length) ? $throwRuntimeError("index out of range") : z.$array[z.$offset + k] = d; - k = k + (1) >> 0; - s = 0; - d = 0; - } - i = i - (1) >> 0; + addrTextMarshalerEncoder = function(e, v, quoted) { + var va, m, _tuple, b, err, _tuple$1; + va = new reflect.Value.Ptr(); $copy(va, v.Addr(), reflect.Value); + if (va.IsNil()) { + e.Buffer.WriteString("null"); + return; } - if (k < z.$length) { - (k < 0 || k >= z.$length) ? $throwRuntimeError("index out of range") : z.$array[z.$offset + k] = d; + m = $assertType(va.Interface(), encoding.TextMarshaler); + _tuple = m.MarshalText(); b = _tuple[0]; err = _tuple[1]; + if ($interfaceIsEqual(err, $ifaceNil)) { + _tuple$1 = e.stringBytes(b); err = _tuple$1[1]; + } + if (!($interfaceIsEqual(err, $ifaceNil))) { + e.error(new MarshalerError.Ptr(v.Type(), err)); } - return z.norm(); - }; - $ptrType(nat).prototype.setBytes = function(buf) { return this.$get().setBytes(buf); }; - NewRat = $pkg.NewRat = function(a, b) { - return new Rat.Ptr().SetFrac64(a, b); }; - Rat.Ptr.prototype.SetFloat64 = function(f) { - var z, bits, mantissa, x, exp, _ref, x$1, shift, x$2; - z = this; - bits = math.Float64bits(f); - mantissa = new $Uint64(bits.$high & 1048575, (bits.$low & 4294967295) >>> 0); - exp = ((x = $shiftRightUint64(bits, 52), new $Uint64(x.$high & 0, (x.$low & 2047) >>> 0)).$low >> 0); - _ref = exp; - if (_ref === 2047) { - return ($ptrType(Rat)).nil; - } else if (_ref === 0) { - exp = exp - (1022) >> 0; + boolEncoder = function(e, v, quoted) { + if (quoted) { + e.Buffer.WriteByte(34); + } + if (v.Bool()) { + e.Buffer.WriteString("true"); } else { - mantissa = (x$1 = new $Uint64(1048576, 0), new $Uint64(mantissa.$high | x$1.$high, (mantissa.$low | x$1.$low) >>> 0)); - exp = exp - (1023) >> 0; + e.Buffer.WriteString("false"); } - shift = 52 - exp >> 0; - while ((x$2 = new $Uint64(mantissa.$high & 0, (mantissa.$low & 1) >>> 0), (x$2.$high === 0 && x$2.$low === 0)) && shift > 0) { - mantissa = $shiftRightUint64(mantissa, (1)); - shift = shift - (1) >> 0; + if (quoted) { + e.Buffer.WriteByte(34); } - z.a.SetUint64(mantissa); - z.a.neg = f < 0; - z.b.Set(intOne); - if (shift > 0) { - z.b.Lsh(z.b, (shift >>> 0)); - } else { - z.a.Lsh(z.a, (-shift >>> 0)); + }; + intEncoder = function(e, v, quoted) { + var b; + b = strconv.AppendInt($subslice(new ($sliceType($Uint8))(e.scratch), 0, 0), v.Int(), 10); + if (quoted) { + e.Buffer.WriteByte(34); + } + e.Buffer.Write(b); + if (quoted) { + e.Buffer.WriteByte(34); } - return z.norm(); }; - Rat.prototype.SetFloat64 = function(f) { return this.$val.SetFloat64(f); }; - low64 = function(z) { - var x, x$1, x$2, x$3, x$4; - if (z.$length === 0) { - return new $Uint64(0, 0); + uintEncoder = function(e, v, quoted) { + var b; + b = strconv.AppendUint($subslice(new ($sliceType($Uint8))(e.scratch), 0, 0), v.Uint(), 10); + if (quoted) { + e.Buffer.WriteByte(34); } - if (true && z.$length > 1) { - return (x = $shiftLeft64((x$1 = ((1 < 0 || 1 >= z.$length) ? $throwRuntimeError("index out of range") : z.$array[z.$offset + 1]), new $Uint64(0, x$1.constructor === Number ? x$1 : 1)), 32), x$2 = (x$3 = ((0 < 0 || 0 >= z.$length) ? $throwRuntimeError("index out of range") : z.$array[z.$offset + 0]), new $Uint64(0, x$3.constructor === Number ? x$3 : 1)), new $Uint64(x.$high | x$2.$high, (x.$low | x$2.$low) >>> 0)); + e.Buffer.Write(b); + if (quoted) { + e.Buffer.WriteByte(34); } - return (x$4 = ((0 < 0 || 0 >= z.$length) ? $throwRuntimeError("index out of range") : z.$array[z.$offset + 0]), new $Uint64(0, x$4.constructor === Number ? x$4 : 1)); }; - quotToFloat = function(a, b) { - var f = 0, exact = false, alen, _tmp, _tmp$1, blen, exp, _tmp$2, _tmp$3, a2, b2, shift, q, _tuple, r, mantissa, haveRem, x, x$1, x$2, shift$1, x$3, x$4, lostbits, x$5, x$6, x$7; - alen = a.bitLen(); - if (alen === 0) { - _tmp = 0; _tmp$1 = true; f = _tmp; exact = _tmp$1; - return [f, exact]; + floatEncoder.prototype.encode = function(e, v, quoted) { + var bits, f, b; + bits = this.$val !== undefined ? this.$val : this; + f = v.Float(); + if (math.IsInf(f, 0) || math.IsNaN(f)) { + e.error(new UnsupportedValueError.Ptr(v, strconv.FormatFloat(f, 103, -1, (bits >> 0)))); } - blen = b.bitLen(); - if (blen === 0) { - $panic(new $String("division by zero")); + b = strconv.AppendFloat($subslice(new ($sliceType($Uint8))(e.scratch), 0, 0), f, 103, -1, (bits >> 0)); + if (quoted) { + e.Buffer.WriteByte(34); } - exp = alen - blen >> 0; - _tmp$2 = nat.nil; _tmp$3 = nat.nil; a2 = _tmp$2; b2 = _tmp$3; - a2 = a2.set(a); - b2 = b2.set(b); - shift = 54 - exp >> 0; - if (shift > 0) { - a2 = a2.shl(a2, (shift >>> 0)); - } else if (shift < 0) { - b2 = b2.shl(b2, (-shift >>> 0)); + e.Buffer.Write(b); + if (quoted) { + e.Buffer.WriteByte(34); } - q = nat.nil; - _tuple = q.div(a2, a2, b2); q = _tuple[0]; r = _tuple[1]; - mantissa = low64(q); - haveRem = r.$length > 0; - if ((x = $shiftRightUint64(mantissa, 54), (x.$high === 0 && x.$low === 1))) { - if ((x$1 = new $Uint64(mantissa.$high & 0, (mantissa.$low & 1) >>> 0), (x$1.$high === 0 && x$1.$low === 1))) { - haveRem = true; + }; + $ptrType(floatEncoder).prototype.encode = function(e, v, quoted) { return new floatEncoder(this.$get()).encode(e, v, quoted); }; + stringEncoder = function(e, v, quoted) { + var numStr, _tuple, sb, err; + if ($interfaceIsEqual(v.Type(), numberType)) { + numStr = v.String(); + if (numStr === "") { + numStr = "0"; } - mantissa = $shiftRightUint64(mantissa, (1)); - exp = exp + (1) >> 0; + e.Buffer.WriteString(numStr); + return; } - if (!((x$2 = $shiftRightUint64(mantissa, 53), (x$2.$high === 0 && x$2.$low === 1)))) { - $panic(new $String("expected exactly 54 bits of result")); + if (quoted) { + _tuple = Marshal(new $String(v.String())); sb = _tuple[0]; err = _tuple[1]; + if (!($interfaceIsEqual(err, $ifaceNil))) { + e.error(err); + } + e.string($bytesToString(sb)); + } else { + e.string(v.String()); } - if (-1074 <= exp && exp <= -1022) { - shift$1 = new $Uint64(0, (-1022 - ((exp - 1 >> 0)) >> 0)); - lostbits = (x$3 = (x$4 = $shiftLeft64(new $Uint64(0, 1), $flatten64(shift$1)), new $Uint64(x$4.$high - 0, x$4.$low - 1)), new $Uint64(mantissa.$high & x$3.$high, (mantissa.$low & x$3.$low) >>> 0)); - haveRem = haveRem || !((lostbits.$high === 0 && lostbits.$low === 0)); - mantissa = $shiftRightUint64(mantissa, $flatten64((shift$1))); - exp = -1021; + }; + interfaceEncoder = function(e, v, quoted) { + if (v.IsNil()) { + e.Buffer.WriteString("null"); + return; } - exact = !haveRem; - if (!((x$5 = new $Uint64(mantissa.$high & 0, (mantissa.$low & 1) >>> 0), (x$5.$high === 0 && x$5.$low === 0)))) { - exact = false; - if (haveRem || !((x$6 = new $Uint64(mantissa.$high & 0, (mantissa.$low & 2) >>> 0), (x$6.$high === 0 && x$6.$low === 0)))) { - mantissa = (x$7 = new $Uint64(0, 1), new $Uint64(mantissa.$high + x$7.$high, mantissa.$low + x$7.$low)); - if ((mantissa.$high > 4194304 || (mantissa.$high === 4194304 && mantissa.$low >= 0))) { - mantissa = $shiftRightUint64(mantissa, (1)); - exp = exp + (1) >> 0; - } + e.reflectValue($clone(v.Elem(), reflect.Value)); + }; + unsupportedTypeEncoder = function(e, v, quoted) { + e.error(new UnsupportedTypeError.Ptr(v.Type())); + }; + structEncoder.Ptr.prototype.encode = function(e, v, quoted) { + var se, first, _ref, _i, i, f, fv, x; + se = this; + e.Buffer.WriteByte(123); + first = true; + _ref = se.fields; + _i = 0; + while (_i < _ref.$length) { + i = _i; + f = new field.Ptr(); $copy(f, ((_i < 0 || _i >= _ref.$length) ? $throwRuntimeError("index out of range") : _ref.$array[_ref.$offset + _i]), field); + fv = new reflect.Value.Ptr(); $copy(fv, fieldByIndex($clone(v, reflect.Value), f.index), reflect.Value); + if (!fv.IsValid() || f.omitEmpty && isEmptyValue($clone(fv, reflect.Value))) { + _i++; + continue; + } + if (first) { + first = false; + } else { + e.Buffer.WriteByte(44); } + e.string(f.name); + e.Buffer.WriteByte(58); + (x = se.fieldEncs, ((i < 0 || i >= x.$length) ? $throwRuntimeError("index out of range") : x.$array[x.$offset + i]))(e, $clone(fv, reflect.Value), f.quoted); + _i++; } - mantissa = $shiftRightUint64(mantissa, (1)); - f = math.Ldexp($flatten64(mantissa), exp - 53 >> 0); - if (math.IsInf(f, 0)) { - exact = false; + e.Buffer.WriteByte(125); + }; + structEncoder.prototype.encode = function(e, v, quoted) { return this.$val.encode(e, v, quoted); }; + newStructEncoder = function(t) { + var fields, se, _ref, _i, i, f, x; + fields = cachedTypeFields(t); + se = new structEncoder.Ptr(fields, ($sliceType(encoderFunc)).make(fields.$length)); + _ref = fields; + _i = 0; + while (_i < _ref.$length) { + i = _i; + f = new field.Ptr(); $copy(f, ((_i < 0 || _i >= _ref.$length) ? $throwRuntimeError("index out of range") : _ref.$array[_ref.$offset + _i]), field); + (x = se.fieldEncs, (i < 0 || i >= x.$length) ? $throwRuntimeError("index out of range") : x.$array[x.$offset + i] = typeEncoder(typeByIndex(t, f.index))); + _i++; } - return [f, exact]; + return $methodVal(se, "encode"); }; - Rat.Ptr.prototype.Float64 = function() { - var f = 0, exact = false, x, b, _tuple; - x = this; - b = x.b.abs; - if (b.$length === 0) { - b = b.set(natOne); + mapEncoder.Ptr.prototype.encode = function(e, v, param) { + var me, x, sv, _ref, _i, i, k; + me = this; + if (v.IsNil()) { + e.Buffer.WriteString("null"); + return; } - _tuple = quotToFloat(x.a.abs, b); f = _tuple[0]; exact = _tuple[1]; - if (x.a.neg) { - f = -f; + e.Buffer.WriteByte(123); + sv = (x = v.MapKeys(), $subslice(new stringValues(x.$array), x.$offset, x.$offset + x.$length)); + sort.Sort(sv); + _ref = sv; + _i = 0; + while (_i < _ref.$length) { + i = _i; + k = new reflect.Value.Ptr(); $copy(k, ((_i < 0 || _i >= _ref.$length) ? $throwRuntimeError("index out of range") : _ref.$array[_ref.$offset + _i]), reflect.Value); + if (i > 0) { + e.Buffer.WriteByte(44); + } + e.string(k.String()); + e.Buffer.WriteByte(58); + me.elemEnc(e, $clone(v.MapIndex($clone(k, reflect.Value)), reflect.Value), false); + _i++; } - return [f, exact]; + e.Buffer.WriteByte(125); }; - Rat.prototype.Float64 = function() { return this.$val.Float64(); }; - Rat.Ptr.prototype.SetFrac = function(a, b) { - var z, babs; - z = this; - z.a.neg = !(a.neg === b.neg); - babs = b.abs; - if (babs.$length === 0) { - $panic(new $String("division by zero")); - } - if (z.a === b || alias(z.a.abs, babs)) { - babs = nat.nil.set(babs); + mapEncoder.prototype.encode = function(e, v, param) { return this.$val.encode(e, v, param); }; + newMapEncoder = function(t) { + var me; + if (!((t.Key().Kind() === 24))) { + return unsupportedTypeEncoder; } - z.a.abs = z.a.abs.set(a.abs); - z.b.abs = z.b.abs.set(babs); - return z.norm(); + me = new mapEncoder.Ptr(typeEncoder(t.Elem())); + return $methodVal(me, "encode"); }; - Rat.prototype.SetFrac = function(a, b) { return this.$val.SetFrac(a, b); }; - Rat.Ptr.prototype.SetFrac64 = function(a, b) { - var z; - z = this; - z.a.SetInt64(a); - if ((b.$high === 0 && b.$low === 0)) { - $panic(new $String("division by zero")); + encodeByteSlice = function(e, v, param) { + var s, dst, enc; + if (v.IsNil()) { + e.Buffer.WriteString("null"); + return; } - if ((b.$high < 0 || (b.$high === 0 && b.$low < 0))) { - b = new $Int64(-b.$high, -b.$low); - z.a.neg = !z.a.neg; + s = v.Bytes(); + e.Buffer.WriteByte(34); + if (s.$length < 1024) { + dst = ($sliceType($Uint8)).make(base64.StdEncoding.EncodedLen(s.$length)); + base64.StdEncoding.Encode(dst, s); + e.Buffer.Write(dst); + } else { + enc = base64.NewEncoder(base64.StdEncoding, e); + enc.Write(s); + enc.Close(); } - z.b.abs = z.b.abs.setUint64(new $Uint64(b.$high, b.$low)); - return z.norm(); - }; - Rat.prototype.SetFrac64 = function(a, b) { return this.$val.SetFrac64(a, b); }; - Rat.Ptr.prototype.SetInt = function(x) { - var z; - z = this; - z.a.Set(x); - z.b.abs = z.b.abs.make(0); - return z; + e.Buffer.WriteByte(34); }; - Rat.prototype.SetInt = function(x) { return this.$val.SetInt(x); }; - Rat.Ptr.prototype.SetInt64 = function(x) { - var z; - z = this; - z.a.SetInt64(x); - z.b.abs = z.b.abs.make(0); - return z; + sliceEncoder.Ptr.prototype.encode = function(e, v, param) { + var se; + se = this; + if (v.IsNil()) { + e.Buffer.WriteString("null"); + return; + } + se.arrayEnc(e, $clone(v, reflect.Value), false); }; - Rat.prototype.SetInt64 = function(x) { return this.$val.SetInt64(x); }; - Rat.Ptr.prototype.Set = function(x) { - var z; - z = this; - if (!(z === x)) { - z.a.Set(x.a); - z.b.Set(x.b); + sliceEncoder.prototype.encode = function(e, v, param) { return this.$val.encode(e, v, param); }; + newSliceEncoder = function(t) { + var enc; + if (t.Elem().Kind() === 8) { + return encodeByteSlice; } - return z; + enc = new sliceEncoder.Ptr(newArrayEncoder(t)); + return $methodVal(enc, "encode"); }; - Rat.prototype.Set = function(x) { return this.$val.Set(x); }; - Rat.Ptr.prototype.Abs = function(x) { - var z; - z = this; - z.Set(x); - z.a.neg = false; - return z; + arrayEncoder.Ptr.prototype.encode = function(e, v, param) { + var ae, n, i; + ae = this; + e.Buffer.WriteByte(91); + n = v.Len(); + i = 0; + while (i < n) { + if (i > 0) { + e.Buffer.WriteByte(44); + } + ae.elemEnc(e, $clone(v.Index(i), reflect.Value), false); + i = i + (1) >> 0; + } + e.Buffer.WriteByte(93); }; - Rat.prototype.Abs = function(x) { return this.$val.Abs(x); }; - Rat.Ptr.prototype.Neg = function(x) { - var z; - z = this; - z.Set(x); - z.a.neg = z.a.abs.$length > 0 && !z.a.neg; - return z; + arrayEncoder.prototype.encode = function(e, v, param) { return this.$val.encode(e, v, param); }; + newArrayEncoder = function(t) { + var enc; + enc = new arrayEncoder.Ptr(typeEncoder(t.Elem())); + return $methodVal(enc, "encode"); }; - Rat.prototype.Neg = function(x) { return this.$val.Neg(x); }; - Rat.Ptr.prototype.Inv = function(x) { - var z, a, b, _tmp, _tmp$1; - z = this; - if (x.a.abs.$length === 0) { - $panic(new $String("division by zero")); - } - z.Set(x); - a = z.b.abs; - if (a.$length === 0) { - a = a.set(natOne); - } - b = z.a.abs; - if (b.cmp(natOne) === 0) { - b = b.make(0); + ptrEncoder.Ptr.prototype.encode = function(e, v, param) { + var pe; + pe = this; + if (v.IsNil()) { + e.Buffer.WriteString("null"); + return; } - _tmp = a; _tmp$1 = b; z.a.abs = _tmp; z.b.abs = _tmp$1; - return z; + pe.elemEnc(e, $clone(v.Elem(), reflect.Value), false); }; - Rat.prototype.Inv = function(x) { return this.$val.Inv(x); }; - Rat.Ptr.prototype.Sign = function() { - var x; - x = this; - return x.a.Sign(); + ptrEncoder.prototype.encode = function(e, v, param) { return this.$val.encode(e, v, param); }; + newPtrEncoder = function(t) { + var enc; + enc = new ptrEncoder.Ptr(typeEncoder(t.Elem())); + return $methodVal(enc, "encode"); }; - Rat.prototype.Sign = function() { return this.$val.Sign(); }; - Rat.Ptr.prototype.IsInt = function() { - var x; - x = this; - return (x.b.abs.$length === 0) || (x.b.abs.cmp(natOne) === 0); + condAddrEncoder.Ptr.prototype.encode = function(e, v, quoted) { + var ce; + ce = this; + if (v.CanAddr()) { + ce.canAddrEnc(e, $clone(v, reflect.Value), quoted); + } else { + ce.elseEnc(e, $clone(v, reflect.Value), quoted); + } }; - Rat.prototype.IsInt = function() { return this.$val.IsInt(); }; - Rat.Ptr.prototype.Num = function() { - var x; - x = this; - return x.a; + condAddrEncoder.prototype.encode = function(e, v, quoted) { return this.$val.encode(e, v, quoted); }; + newCondAddrEncoder = function(canAddrEnc, elseEnc) { + var enc; + enc = new condAddrEncoder.Ptr(canAddrEnc, elseEnc); + return $methodVal(enc, "encode"); }; - Rat.prototype.Num = function() { return this.$val.Num(); }; - Rat.Ptr.prototype.Denom = function() { - var x; - x = this; - x.b.neg = false; - if (x.b.abs.$length === 0) { - x.b.abs = x.b.abs.set(natOne); + isValidTag = function(s) { + var _ref, _i, _rune, c; + if (s === "") { + return false; } - return x.b; + _ref = s; + _i = 0; + while (_i < _ref.length) { + _rune = $decodeRune(_ref, _i); + c = _rune[0]; + if (strings.ContainsRune("!#$%&()*+-./:<=>?@[]^_{|}~ ", c)) { + } else { + if (!unicode.IsLetter(c) && !unicode.IsDigit(c)) { + return false; + } + } + _i += _rune[1]; + } + return true; }; - Rat.prototype.Denom = function() { return this.$val.Denom(); }; - Rat.Ptr.prototype.norm = function() { - var z, neg, f, _tuple, _tuple$1; - z = this; - if (z.a.abs.$length === 0) { - z.a.neg = false; - z.b.abs = z.b.abs.make(0); - } else if (z.b.abs.$length === 0) { - } else if (z.b.abs.cmp(natOne) === 0) { - z.b.abs = z.b.abs.make(0); - } else { - neg = z.a.neg; - z.a.neg = false; - z.b.neg = false; - f = NewInt(new $Int64(0, 0)).binaryGCD(z.a, z.b); - if (!((f.Cmp(intOne) === 0))) { - _tuple = z.a.abs.div(nat.nil, z.a.abs, f.abs); z.a.abs = _tuple[0]; - _tuple$1 = z.b.abs.div(nat.nil, z.b.abs, f.abs); z.b.abs = _tuple$1[0]; - if (z.b.abs.cmp(natOne) === 0) { - z.b.abs = z.b.abs.make(0); + fieldByIndex = function(v, index) { + var _ref, _i, i; + _ref = index; + _i = 0; + while (_i < _ref.$length) { + i = ((_i < 0 || _i >= _ref.$length) ? $throwRuntimeError("index out of range") : _ref.$array[_ref.$offset + _i]); + if (v.Kind() === 22) { + if (v.IsNil()) { + return new reflect.Value.Ptr(($ptrType(reflect.rtype)).nil, 0, 0, 0); } + $copy(v, v.Elem(), reflect.Value); } - z.a.neg = neg; - } - return z; - }; - Rat.prototype.norm = function() { return this.$val.norm(); }; - mulDenom = function(z, x, y) { - if (x.$length === 0) { - return z.set(y); - } else if (y.$length === 0) { - return z.set(x); + $copy(v, v.Field(i), reflect.Value); + _i++; } - return z.mul(x, y); + return v; }; - scaleDenom = function(x, f) { - var z; - z = new Int.Ptr(); $copy(z, new Int.Ptr(), Int); - if (f.$length === 0) { - return z.Set(x); + typeByIndex = function(t, index) { + var _ref, _i, i; + _ref = index; + _i = 0; + while (_i < _ref.$length) { + i = ((_i < 0 || _i >= _ref.$length) ? $throwRuntimeError("index out of range") : _ref.$array[_ref.$offset + _i]); + if (t.Kind() === 22) { + t = t.Elem(); + } + t = t.Field(i).Type; + _i++; } - z.abs = z.abs.mul(x.abs, f); - z.neg = x.neg; - return z; - }; - Rat.Ptr.prototype.Cmp = function(y) { - var x; - x = this; - return scaleDenom(x.a, y.b.abs).Cmp(scaleDenom(y.a, x.b.abs)); - }; - Rat.prototype.Cmp = function(y) { return this.$val.Cmp(y); }; - Rat.Ptr.prototype.Add = function(x, y) { - var z, a1, a2; - z = this; - a1 = scaleDenom(x.a, y.b.abs); - a2 = scaleDenom(y.a, x.b.abs); - z.a.Add(a1, a2); - z.b.abs = mulDenom(z.b.abs, x.b.abs, y.b.abs); - return z.norm(); + return t; }; - Rat.prototype.Add = function(x, y) { return this.$val.Add(x, y); }; - Rat.Ptr.prototype.Sub = function(x, y) { - var z, a1, a2; - z = this; - a1 = scaleDenom(x.a, y.b.abs); - a2 = scaleDenom(y.a, x.b.abs); - z.a.Sub(a1, a2); - z.b.abs = mulDenom(z.b.abs, x.b.abs, y.b.abs); - return z.norm(); + stringValues.prototype.Len = function() { + var sv; + sv = this; + return sv.$length; }; - Rat.prototype.Sub = function(x, y) { return this.$val.Sub(x, y); }; - Rat.Ptr.prototype.Mul = function(x, y) { - var z; - z = this; - z.a.Mul(x.a, y.a); - z.b.abs = mulDenom(z.b.abs, x.b.abs, y.b.abs); - return z.norm(); + $ptrType(stringValues).prototype.Len = function() { return this.$get().Len(); }; + stringValues.prototype.Swap = function(i, j) { + var sv, _tmp, _tmp$1; + sv = this; + _tmp = new reflect.Value.Ptr(); $copy(_tmp, ((j < 0 || j >= sv.$length) ? $throwRuntimeError("index out of range") : sv.$array[sv.$offset + j]), reflect.Value); _tmp$1 = new reflect.Value.Ptr(); $copy(_tmp$1, ((i < 0 || i >= sv.$length) ? $throwRuntimeError("index out of range") : sv.$array[sv.$offset + i]), reflect.Value); $copy(((i < 0 || i >= sv.$length) ? $throwRuntimeError("index out of range") : sv.$array[sv.$offset + i]), _tmp, reflect.Value); $copy(((j < 0 || j >= sv.$length) ? $throwRuntimeError("index out of range") : sv.$array[sv.$offset + j]), _tmp$1, reflect.Value); }; - Rat.prototype.Mul = function(x, y) { return this.$val.Mul(x, y); }; - Rat.Ptr.prototype.Quo = function(x, y) { - var z, a, b; - z = this; - if (y.a.abs.$length === 0) { - $panic(new $String("division by zero")); - } - a = scaleDenom(x.a, y.b.abs); - b = scaleDenom(y.a, x.b.abs); - z.a.abs = a.abs; - z.b.abs = b.abs; - z.a.neg = !(a.neg === b.neg); - return z.norm(); + $ptrType(stringValues).prototype.Swap = function(i, j) { return this.$get().Swap(i, j); }; + stringValues.prototype.Less = function(i, j) { + var sv; + sv = this; + return sv.get(i) < sv.get(j); }; - Rat.prototype.Quo = function(x, y) { return this.$val.Quo(x, y); }; - ratTok = function(ch) { - return strings.IndexRune("+-/0123456789.eE", ch) >= 0; + $ptrType(stringValues).prototype.Less = function(i, j) { return this.$get().Less(i, j); }; + stringValues.prototype.get = function(i) { + var sv; + sv = this; + return ((i < 0 || i >= sv.$length) ? $throwRuntimeError("index out of range") : sv.$array[sv.$offset + i]).String(); }; - Rat.Ptr.prototype.Scan = function(s, ch) { - var z, _tuple, tok, err, _tuple$1, ok; - z = this; - _tuple = s.Token(true, ratTok); tok = _tuple[0]; err = _tuple[1]; - if (!($interfaceIsEqual(err, $ifaceNil))) { - return err; - } - if (strings.IndexRune("efgEFGv", ch) < 0) { - return errors.New("Rat.Scan: invalid verb"); + $ptrType(stringValues).prototype.get = function(i) { return this.$get().get(i); }; + encodeState.Ptr.prototype.string = function(s) { + var e, len0, start, i, b, _ref, _tuple, c, size; + e = this; + len0 = e.Buffer.Len(); + e.Buffer.WriteByte(34); + start = 0; + i = 0; + while (i < s.length) { + b = s.charCodeAt(i); + if (b < 128) { + if (32 <= b && !((b === 92)) && !((b === 34)) && !((b === 60)) && !((b === 62)) && !((b === 38))) { + i = i + (1) >> 0; + continue; + } + if (start < i) { + e.Buffer.WriteString(s.substring(start, i)); + } + _ref = b; + if (_ref === 92 || _ref === 34) { + e.Buffer.WriteByte(92); + e.Buffer.WriteByte(b); + } else if (_ref === 10) { + e.Buffer.WriteByte(92); + e.Buffer.WriteByte(110); + } else if (_ref === 13) { + e.Buffer.WriteByte(92); + e.Buffer.WriteByte(114); + } else { + e.Buffer.WriteString("\\u00"); + e.Buffer.WriteByte(hex.charCodeAt((b >>> 4 << 24 >>> 24))); + e.Buffer.WriteByte(hex.charCodeAt(((b & 15) >>> 0))); + } + i = i + (1) >> 0; + start = i; + continue; + } + _tuple = utf8.DecodeRuneInString(s.substring(i)); c = _tuple[0]; size = _tuple[1]; + if ((c === 65533) && (size === 1)) { + if (start < i) { + e.Buffer.WriteString(s.substring(start, i)); + } + e.Buffer.WriteString("\\ufffd"); + i = i + (size) >> 0; + start = i; + continue; + } + if ((c === 8232) || (c === 8233)) { + if (start < i) { + e.Buffer.WriteString(s.substring(start, i)); + } + e.Buffer.WriteString("\\u202"); + e.Buffer.WriteByte(hex.charCodeAt((c & 15))); + i = i + (size) >> 0; + start = i; + continue; + } + i = i + (size) >> 0; } - _tuple$1 = z.SetString($bytesToString(tok)); ok = _tuple$1[1]; - if (!ok) { - return errors.New("Rat.Scan: invalid syntax"); + if (start < s.length) { + e.Buffer.WriteString(s.substring(start)); } - return $ifaceNil; + e.Buffer.WriteByte(34); + return [e.Buffer.Len() - len0 >> 0, $ifaceNil]; }; - Rat.prototype.Scan = function(s, ch) { return this.$val.Scan(s, ch); }; - Rat.Ptr.prototype.SetString = function(s) { - var z, sep, _tuple, ok, err, _tuple$1, e, exp, _tuple$2, ok$1, _tuple$3, ok$2, powTen; - z = this; - if (s.length === 0) { - return [($ptrType(Rat)).nil, false]; - } - sep = strings.Index(s, "/"); - if (sep >= 0) { - _tuple = z.a.SetString(s.substring(0, sep), 10); ok = _tuple[1]; - if (!ok) { - return [($ptrType(Rat)).nil, false]; - } - s = s.substring((sep + 1 >> 0)); - err = $ifaceNil; - _tuple$1 = z.b.abs.scan(strings.NewReader(s), 10); z.b.abs = _tuple$1[0]; err = _tuple$1[2]; - if (!($interfaceIsEqual(err, $ifaceNil))) { - return [($ptrType(Rat)).nil, false]; + encodeState.prototype.string = function(s) { return this.$val.string(s); }; + encodeState.Ptr.prototype.stringBytes = function(s) { + var e, len0, start, i, b, _ref, _tuple, c, size; + e = this; + len0 = e.Buffer.Len(); + e.Buffer.WriteByte(34); + start = 0; + i = 0; + while (i < s.$length) { + b = ((i < 0 || i >= s.$length) ? $throwRuntimeError("index out of range") : s.$array[s.$offset + i]); + if (b < 128) { + if (32 <= b && !((b === 92)) && !((b === 34)) && !((b === 60)) && !((b === 62)) && !((b === 38))) { + i = i + (1) >> 0; + continue; + } + if (start < i) { + e.Buffer.Write($subslice(s, start, i)); + } + _ref = b; + if (_ref === 92 || _ref === 34) { + e.Buffer.WriteByte(92); + e.Buffer.WriteByte(b); + } else if (_ref === 10) { + e.Buffer.WriteByte(92); + e.Buffer.WriteByte(110); + } else if (_ref === 13) { + e.Buffer.WriteByte(92); + e.Buffer.WriteByte(114); + } else { + e.Buffer.WriteString("\\u00"); + e.Buffer.WriteByte(hex.charCodeAt((b >>> 4 << 24 >>> 24))); + e.Buffer.WriteByte(hex.charCodeAt(((b & 15) >>> 0))); + } + i = i + (1) >> 0; + start = i; + continue; } - return [z.norm(), true]; - } - sep = strings.Index(s, "."); - e = strings.IndexAny(s, "eE"); - exp = new Int.Ptr(); $copy(exp, new Int.Ptr(), Int); - if (e >= 0) { - if (e < sep) { - return [($ptrType(Rat)).nil, false]; + _tuple = utf8.DecodeRune($subslice(s, i)); c = _tuple[0]; size = _tuple[1]; + if ((c === 65533) && (size === 1)) { + if (start < i) { + e.Buffer.Write($subslice(s, start, i)); + } + e.Buffer.WriteString("\\ufffd"); + i = i + (size) >> 0; + start = i; + continue; } - _tuple$2 = exp.SetString(s.substring((e + 1 >> 0)), 10); ok$1 = _tuple$2[1]; - if (!ok$1) { - return [($ptrType(Rat)).nil, false]; + if ((c === 8232) || (c === 8233)) { + if (start < i) { + e.Buffer.Write($subslice(s, start, i)); + } + e.Buffer.WriteString("\\u202"); + e.Buffer.WriteByte(hex.charCodeAt((c & 15))); + i = i + (size) >> 0; + start = i; + continue; } - s = s.substring(0, e); - } - if (sep >= 0) { - s = s.substring(0, sep) + s.substring((sep + 1 >> 0)); - exp.Sub(exp, NewInt(new $Int64(0, (s.length - sep >> 0)))); - } - _tuple$3 = z.a.SetString(s, 10); ok$2 = _tuple$3[1]; - if (!ok$2) { - return [($ptrType(Rat)).nil, false]; + i = i + (size) >> 0; } - powTen = nat.nil.expNN(natTen, exp.abs, nat.nil); - if (exp.neg) { - z.b.abs = powTen; - z.norm(); - } else { - z.a.abs = z.a.abs.mul(z.a.abs, powTen); - z.b.abs = z.b.abs.make(0); + if (start < s.$length) { + e.Buffer.Write($subslice(s, start)); } - return [z, true]; + e.Buffer.WriteByte(34); + return [e.Buffer.Len() - len0 >> 0, $ifaceNil]; }; - Rat.prototype.SetString = function(s) { return this.$val.SetString(s); }; - Rat.Ptr.prototype.String = function() { - var x, s; - x = this; - s = "/1"; - if (!((x.b.abs.$length === 0))) { - s = "/" + x.b.abs.decimalString(); - } - return x.a.String() + s; + encodeState.prototype.stringBytes = function(s) { return this.$val.stringBytes(s); }; + fillField = function(f) { + f.nameBytes = new ($sliceType($Uint8))($stringToBytes(f.name)); + f.equalFold = foldFunc(f.nameBytes); + return f; }; - Rat.prototype.String = function() { return this.$val.String(); }; - Rat.Ptr.prototype.RatString = function() { + byName.prototype.Len = function() { var x; x = this; - if (x.IsInt()) { - return x.a.String(); - } - return x.String(); + return x.$length; }; - Rat.prototype.RatString = function() { return this.$val.RatString(); }; - Rat.Ptr.prototype.FloatString = function(prec) { - var x, s, _tuple, q, r, p, _tuple$1, r2, s$1, rs, leadingZeros$1; + $ptrType(byName).prototype.Len = function() { return this.$get().Len(); }; + byName.prototype.Swap = function(i, j) { + var x, _tmp, _tmp$1; x = this; - if (x.IsInt()) { - s = x.a.String(); - if (prec > 0) { - s = s + ("." + strings.Repeat("0", prec)); - } - return s; - } - _tuple = nat.nil.div(nat.nil, x.a.abs, x.b.abs); q = _tuple[0]; r = _tuple[1]; - p = natOne; - if (prec > 0) { - p = nat.nil.expNN(natTen, nat.nil.setUint64(new $Uint64(0, prec)), nat.nil); - } - r = r.mul(r, p); - _tuple$1 = r.div(nat.nil, r, x.b.abs); r = _tuple$1[0]; r2 = _tuple$1[1]; - r2 = r2.add(r2, r2); - if (x.b.abs.cmp(r2) <= 0) { - r = r.add(r, natOne); - if (r.cmp(p) >= 0) { - q = nat.nil.add(q, natOne); - r = nat.nil.sub(r, p); - } - } - s$1 = q.decimalString(); - if (x.a.neg) { - s$1 = "-" + s$1; - } - if (prec > 0) { - rs = r.decimalString(); - leadingZeros$1 = prec - rs.length >> 0; - s$1 = s$1 + ("." + strings.Repeat("0", leadingZeros$1) + rs); - } - return s$1; + _tmp = new field.Ptr(); $copy(_tmp, ((j < 0 || j >= x.$length) ? $throwRuntimeError("index out of range") : x.$array[x.$offset + j]), field); _tmp$1 = new field.Ptr(); $copy(_tmp$1, ((i < 0 || i >= x.$length) ? $throwRuntimeError("index out of range") : x.$array[x.$offset + i]), field); $copy(((i < 0 || i >= x.$length) ? $throwRuntimeError("index out of range") : x.$array[x.$offset + i]), _tmp, field); $copy(((j < 0 || j >= x.$length) ? $throwRuntimeError("index out of range") : x.$array[x.$offset + j]), _tmp$1, field); }; - Rat.prototype.FloatString = function(prec) { return this.$val.FloatString(prec); }; - Rat.Ptr.prototype.GobEncode = function() { - var x, x$1, buf, i, j, n, b; + $ptrType(byName).prototype.Swap = function(i, j) { return this.$get().Swap(i, j); }; + byName.prototype.Less = function(i, j) { + var x; x = this; - if (x === ($ptrType(Rat)).nil) { - return [($sliceType($Uint8)).nil, $ifaceNil]; + if (!(((i < 0 || i >= x.$length) ? $throwRuntimeError("index out of range") : x.$array[x.$offset + i]).name === ((j < 0 || j >= x.$length) ? $throwRuntimeError("index out of range") : x.$array[x.$offset + j]).name)) { + return ((i < 0 || i >= x.$length) ? $throwRuntimeError("index out of range") : x.$array[x.$offset + i]).name < ((j < 0 || j >= x.$length) ? $throwRuntimeError("index out of range") : x.$array[x.$offset + j]).name; } - buf = ($sliceType($Uint8)).make((5 + (x$1 = (x.a.abs.$length + x.b.abs.$length >> 0), (((x$1 >>> 16 << 16) * 4 >> 0) + (x$1 << 16 >>> 16) * 4) >> 0) >> 0)); - i = x.b.abs.bytes(buf); - j = x.a.abs.bytes($subslice(buf, 0, i)); - n = i - j >> 0; - if (!((((n >>> 0) >> 0) === n))) { - return [($sliceType($Uint8)).nil, errors.New("Rat.GobEncode: numerator too large")]; + if (!((((i < 0 || i >= x.$length) ? $throwRuntimeError("index out of range") : x.$array[x.$offset + i]).index.$length === ((j < 0 || j >= x.$length) ? $throwRuntimeError("index out of range") : x.$array[x.$offset + j]).index.$length))) { + return ((i < 0 || i >= x.$length) ? $throwRuntimeError("index out of range") : x.$array[x.$offset + i]).index.$length < ((j < 0 || j >= x.$length) ? $throwRuntimeError("index out of range") : x.$array[x.$offset + j]).index.$length; } - binary.BigEndian.PutUint32($subslice(buf, (j - 4 >> 0), j), (n >>> 0)); - j = j - (5) >> 0; - b = 2; - if (x.a.neg) { - b = (b | (1)) >>> 0; + if (!(((i < 0 || i >= x.$length) ? $throwRuntimeError("index out of range") : x.$array[x.$offset + i]).tag === ((j < 0 || j >= x.$length) ? $throwRuntimeError("index out of range") : x.$array[x.$offset + j]).tag)) { + return ((i < 0 || i >= x.$length) ? $throwRuntimeError("index out of range") : x.$array[x.$offset + i]).tag; } - (j < 0 || j >= buf.$length) ? $throwRuntimeError("index out of range") : buf.$array[buf.$offset + j] = b; - return [$subslice(buf, j), $ifaceNil]; + return $subslice(new byIndex(x.$array), x.$offset, x.$offset + x.$length).Less(i, j); }; - Rat.prototype.GobEncode = function() { return this.$val.GobEncode(); }; - Rat.Ptr.prototype.GobDecode = function(buf) { - var z, b, i; - z = this; - if (buf.$length === 0) { - $copy(z, new Rat.Ptr(new Int.Ptr(), new Int.Ptr()), Rat); - return $ifaceNil; - } - b = ((0 < 0 || 0 >= buf.$length) ? $throwRuntimeError("index out of range") : buf.$array[buf.$offset + 0]); - if (!(((b >>> 1 << 24 >>> 24) === 1))) { - return errors.New(fmt.Sprintf("Rat.GobDecode: encoding version %d not supported", new ($sliceType($emptyInterface))([new $Uint8((b >>> 1 << 24 >>> 24))]))); - } - i = 5 + binary.BigEndian.Uint32($subslice(buf, 1, 5)) >>> 0; - z.a.neg = !((((b & 1) >>> 0) === 0)); - z.a.abs = z.a.abs.setBytes($subslice(buf, 5, i)); - z.b.abs = z.b.abs.setBytes($subslice(buf, i)); - return $ifaceNil; + $ptrType(byName).prototype.Less = function(i, j) { return this.$get().Less(i, j); }; + byIndex.prototype.Len = function() { + var x; + x = this; + return x.$length; }; - Rat.prototype.GobDecode = function(buf) { return this.$val.GobDecode(buf); }; - Rat.Ptr.prototype.MarshalText = function() { - var text = ($sliceType($Uint8)).nil, err = $ifaceNil, r, _tmp, _tmp$1; - r = this; - _tmp = new ($sliceType($Uint8))($stringToBytes(r.RatString())); _tmp$1 = $ifaceNil; text = _tmp; err = _tmp$1; - return [text, err]; + $ptrType(byIndex).prototype.Len = function() { return this.$get().Len(); }; + byIndex.prototype.Swap = function(i, j) { + var x, _tmp, _tmp$1; + x = this; + _tmp = new field.Ptr(); $copy(_tmp, ((j < 0 || j >= x.$length) ? $throwRuntimeError("index out of range") : x.$array[x.$offset + j]), field); _tmp$1 = new field.Ptr(); $copy(_tmp$1, ((i < 0 || i >= x.$length) ? $throwRuntimeError("index out of range") : x.$array[x.$offset + i]), field); $copy(((i < 0 || i >= x.$length) ? $throwRuntimeError("index out of range") : x.$array[x.$offset + i]), _tmp, field); $copy(((j < 0 || j >= x.$length) ? $throwRuntimeError("index out of range") : x.$array[x.$offset + j]), _tmp$1, field); }; - Rat.prototype.MarshalText = function() { return this.$val.MarshalText(); }; - Rat.Ptr.prototype.UnmarshalText = function(text) { - var r, _tuple, ok; - r = this; - _tuple = r.SetString($bytesToString(text)); ok = _tuple[1]; - if (!ok) { - return fmt.Errorf("math/big: cannot unmarshal %q into a *big.Rat", new ($sliceType($emptyInterface))([text])); + $ptrType(byIndex).prototype.Swap = function(i, j) { return this.$get().Swap(i, j); }; + byIndex.prototype.Less = function(i, j) { + var x, _ref, _i, k, xik, x$1, x$2; + x = this; + _ref = ((i < 0 || i >= x.$length) ? $throwRuntimeError("index out of range") : x.$array[x.$offset + i]).index; + _i = 0; + while (_i < _ref.$length) { + k = _i; + xik = ((_i < 0 || _i >= _ref.$length) ? $throwRuntimeError("index out of range") : _ref.$array[_ref.$offset + _i]); + if (k >= ((j < 0 || j >= x.$length) ? $throwRuntimeError("index out of range") : x.$array[x.$offset + j]).index.$length) { + return false; + } + if (!((xik === (x$1 = ((j < 0 || j >= x.$length) ? $throwRuntimeError("index out of range") : x.$array[x.$offset + j]).index, ((k < 0 || k >= x$1.$length) ? $throwRuntimeError("index out of range") : x$1.$array[x$1.$offset + k]))))) { + return xik < (x$2 = ((j < 0 || j >= x.$length) ? $throwRuntimeError("index out of range") : x.$array[x.$offset + j]).index, ((k < 0 || k >= x$2.$length) ? $throwRuntimeError("index out of range") : x$2.$array[x$2.$offset + k])); + } + _i++; } - return $ifaceNil; - }; - Rat.prototype.UnmarshalText = function(text) { return this.$val.UnmarshalText(text); }; - $pkg.$init = function() { - ($ptrType(Int)).methods = [["Abs", "Abs", "", $funcType([($ptrType(Int))], [($ptrType(Int))], false), -1], ["Add", "Add", "", $funcType([($ptrType(Int)), ($ptrType(Int))], [($ptrType(Int))], false), -1], ["And", "And", "", $funcType([($ptrType(Int)), ($ptrType(Int))], [($ptrType(Int))], false), -1], ["AndNot", "AndNot", "", $funcType([($ptrType(Int)), ($ptrType(Int))], [($ptrType(Int))], false), -1], ["Binomial", "Binomial", "", $funcType([$Int64, $Int64], [($ptrType(Int))], false), -1], ["Bit", "Bit", "", $funcType([$Int], [$Uint], false), -1], ["BitLen", "BitLen", "", $funcType([], [$Int], false), -1], ["Bits", "Bits", "", $funcType([], [($sliceType(Word))], false), -1], ["Bytes", "Bytes", "", $funcType([], [($sliceType($Uint8))], false), -1], ["Cmp", "Cmp", "", $funcType([($ptrType(Int))], [$Int], false), -1], ["Div", "Div", "", $funcType([($ptrType(Int)), ($ptrType(Int))], [($ptrType(Int))], false), -1], ["DivMod", "DivMod", "", $funcType([($ptrType(Int)), ($ptrType(Int)), ($ptrType(Int))], [($ptrType(Int)), ($ptrType(Int))], false), -1], ["Exp", "Exp", "", $funcType([($ptrType(Int)), ($ptrType(Int)), ($ptrType(Int))], [($ptrType(Int))], false), -1], ["Format", "Format", "", $funcType([fmt.State, $Int32], [], false), -1], ["GCD", "GCD", "", $funcType([($ptrType(Int)), ($ptrType(Int)), ($ptrType(Int)), ($ptrType(Int))], [($ptrType(Int))], false), -1], ["GobDecode", "GobDecode", "", $funcType([($sliceType($Uint8))], [$error], false), -1], ["GobEncode", "GobEncode", "", $funcType([], [($sliceType($Uint8)), $error], false), -1], ["Int64", "Int64", "", $funcType([], [$Int64], false), -1], ["Lsh", "Lsh", "", $funcType([($ptrType(Int)), $Uint], [($ptrType(Int))], false), -1], ["MarshalJSON", "MarshalJSON", "", $funcType([], [($sliceType($Uint8)), $error], false), -1], ["MarshalText", "MarshalText", "", $funcType([], [($sliceType($Uint8)), $error], false), -1], ["Mod", "Mod", "", $funcType([($ptrType(Int)), ($ptrType(Int))], [($ptrType(Int))], false), -1], ["ModInverse", "ModInverse", "", $funcType([($ptrType(Int)), ($ptrType(Int))], [($ptrType(Int))], false), -1], ["Mul", "Mul", "", $funcType([($ptrType(Int)), ($ptrType(Int))], [($ptrType(Int))], false), -1], ["MulRange", "MulRange", "", $funcType([$Int64, $Int64], [($ptrType(Int))], false), -1], ["Neg", "Neg", "", $funcType([($ptrType(Int))], [($ptrType(Int))], false), -1], ["Not", "Not", "", $funcType([($ptrType(Int))], [($ptrType(Int))], false), -1], ["Or", "Or", "", $funcType([($ptrType(Int)), ($ptrType(Int))], [($ptrType(Int))], false), -1], ["ProbablyPrime", "ProbablyPrime", "", $funcType([$Int], [$Bool], false), -1], ["Quo", "Quo", "", $funcType([($ptrType(Int)), ($ptrType(Int))], [($ptrType(Int))], false), -1], ["QuoRem", "QuoRem", "", $funcType([($ptrType(Int)), ($ptrType(Int)), ($ptrType(Int))], [($ptrType(Int)), ($ptrType(Int))], false), -1], ["Rand", "Rand", "", $funcType([($ptrType(rand.Rand)), ($ptrType(Int))], [($ptrType(Int))], false), -1], ["Rem", "Rem", "", $funcType([($ptrType(Int)), ($ptrType(Int))], [($ptrType(Int))], false), -1], ["Rsh", "Rsh", "", $funcType([($ptrType(Int)), $Uint], [($ptrType(Int))], false), -1], ["Scan", "Scan", "", $funcType([fmt.ScanState, $Int32], [$error], false), -1], ["Set", "Set", "", $funcType([($ptrType(Int))], [($ptrType(Int))], false), -1], ["SetBit", "SetBit", "", $funcType([($ptrType(Int)), $Int, $Uint], [($ptrType(Int))], false), -1], ["SetBits", "SetBits", "", $funcType([($sliceType(Word))], [($ptrType(Int))], false), -1], ["SetBytes", "SetBytes", "", $funcType([($sliceType($Uint8))], [($ptrType(Int))], false), -1], ["SetInt64", "SetInt64", "", $funcType([$Int64], [($ptrType(Int))], false), -1], ["SetString", "SetString", "", $funcType([$String, $Int], [($ptrType(Int)), $Bool], false), -1], ["SetUint64", "SetUint64", "", $funcType([$Uint64], [($ptrType(Int))], false), -1], ["Sign", "Sign", "", $funcType([], [$Int], false), -1], ["String", "String", "", $funcType([], [$String], false), -1], ["Sub", "Sub", "", $funcType([($ptrType(Int)), ($ptrType(Int))], [($ptrType(Int))], false), -1], ["Uint64", "Uint64", "", $funcType([], [$Uint64], false), -1], ["UnmarshalJSON", "UnmarshalJSON", "", $funcType([($sliceType($Uint8))], [$error], false), -1], ["UnmarshalText", "UnmarshalText", "", $funcType([($sliceType($Uint8))], [$error], false), -1], ["Xor", "Xor", "", $funcType([($ptrType(Int)), ($ptrType(Int))], [($ptrType(Int))], false), -1], ["binaryGCD", "binaryGCD", "math/big", $funcType([($ptrType(Int)), ($ptrType(Int))], [($ptrType(Int))], false), -1], ["scan", "scan", "math/big", $funcType([io.RuneScanner, $Int], [($ptrType(Int)), $Int, $error], false), -1]]; - Int.init([["neg", "neg", "math/big", $Bool, ""], ["abs", "abs", "math/big", nat, ""]]); - nat.methods = [["add", "add", "math/big", $funcType([nat, nat], [nat], false), -1], ["and", "and", "math/big", $funcType([nat, nat], [nat], false), -1], ["andNot", "andNot", "math/big", $funcType([nat, nat], [nat], false), -1], ["bit", "bit", "math/big", $funcType([$Uint], [$Uint], false), -1], ["bitLen", "bitLen", "math/big", $funcType([], [$Int], false), -1], ["bytes", "bytes", "math/big", $funcType([($sliceType($Uint8))], [$Int], false), -1], ["clear", "clear", "math/big", $funcType([], [], false), -1], ["cmp", "cmp", "math/big", $funcType([nat], [$Int], false), -1], ["convertWords", "convertWords", "math/big", $funcType([($sliceType($Uint8)), $String, Word, $Int, Word, ($sliceType(divisor))], [], false), -1], ["decimalString", "decimalString", "math/big", $funcType([], [$String], false), -1], ["div", "div", "math/big", $funcType([nat, nat, nat], [nat, nat], false), -1], ["divLarge", "divLarge", "math/big", $funcType([nat, nat, nat], [nat, nat], false), -1], ["divW", "divW", "math/big", $funcType([nat, Word], [nat, Word], false), -1], ["expNN", "expNN", "math/big", $funcType([nat, nat, nat], [nat], false), -1], ["expNNWindowed", "expNNWindowed", "math/big", $funcType([nat, nat, nat], [nat], false), -1], ["expWW", "expWW", "math/big", $funcType([Word, Word], [nat], false), -1], ["make", "make", "math/big", $funcType([$Int], [nat], false), -1], ["modW", "modW", "math/big", $funcType([Word], [Word], false), -1], ["mul", "mul", "math/big", $funcType([nat, nat], [nat], false), -1], ["mulAddWW", "mulAddWW", "math/big", $funcType([nat, Word, Word], [nat], false), -1], ["mulRange", "mulRange", "math/big", $funcType([$Uint64, $Uint64], [nat], false), -1], ["norm", "norm", "math/big", $funcType([], [nat], false), -1], ["or", "or", "math/big", $funcType([nat, nat], [nat], false), -1], ["probablyPrime", "probablyPrime", "math/big", $funcType([$Int], [$Bool], false), -1], ["random", "random", "math/big", $funcType([($ptrType(rand.Rand)), nat, $Int], [nat], false), -1], ["scan", "scan", "math/big", $funcType([io.RuneScanner, $Int], [nat, $Int, $error], false), -1], ["set", "set", "math/big", $funcType([nat], [nat], false), -1], ["setBit", "setBit", "math/big", $funcType([nat, $Uint, $Uint], [nat], false), -1], ["setBytes", "setBytes", "math/big", $funcType([($sliceType($Uint8))], [nat], false), -1], ["setUint64", "setUint64", "math/big", $funcType([$Uint64], [nat], false), -1], ["setWord", "setWord", "math/big", $funcType([Word], [nat], false), -1], ["shl", "shl", "math/big", $funcType([nat, $Uint], [nat], false), -1], ["shr", "shr", "math/big", $funcType([nat, $Uint], [nat], false), -1], ["string", "string", "math/big", $funcType([$String], [$String], false), -1], ["sub", "sub", "math/big", $funcType([nat, nat], [nat], false), -1], ["trailingZeroBits", "trailingZeroBits", "math/big", $funcType([], [$Uint], false), -1], ["xor", "xor", "math/big", $funcType([nat, nat], [nat], false), -1]]; - ($ptrType(nat)).methods = [["add", "add", "math/big", $funcType([nat, nat], [nat], false), -1], ["and", "and", "math/big", $funcType([nat, nat], [nat], false), -1], ["andNot", "andNot", "math/big", $funcType([nat, nat], [nat], false), -1], ["bit", "bit", "math/big", $funcType([$Uint], [$Uint], false), -1], ["bitLen", "bitLen", "math/big", $funcType([], [$Int], false), -1], ["bytes", "bytes", "math/big", $funcType([($sliceType($Uint8))], [$Int], false), -1], ["clear", "clear", "math/big", $funcType([], [], false), -1], ["cmp", "cmp", "math/big", $funcType([nat], [$Int], false), -1], ["convertWords", "convertWords", "math/big", $funcType([($sliceType($Uint8)), $String, Word, $Int, Word, ($sliceType(divisor))], [], false), -1], ["decimalString", "decimalString", "math/big", $funcType([], [$String], false), -1], ["div", "div", "math/big", $funcType([nat, nat, nat], [nat, nat], false), -1], ["divLarge", "divLarge", "math/big", $funcType([nat, nat, nat], [nat, nat], false), -1], ["divW", "divW", "math/big", $funcType([nat, Word], [nat, Word], false), -1], ["expNN", "expNN", "math/big", $funcType([nat, nat, nat], [nat], false), -1], ["expNNWindowed", "expNNWindowed", "math/big", $funcType([nat, nat, nat], [nat], false), -1], ["expWW", "expWW", "math/big", $funcType([Word, Word], [nat], false), -1], ["make", "make", "math/big", $funcType([$Int], [nat], false), -1], ["modW", "modW", "math/big", $funcType([Word], [Word], false), -1], ["mul", "mul", "math/big", $funcType([nat, nat], [nat], false), -1], ["mulAddWW", "mulAddWW", "math/big", $funcType([nat, Word, Word], [nat], false), -1], ["mulRange", "mulRange", "math/big", $funcType([$Uint64, $Uint64], [nat], false), -1], ["norm", "norm", "math/big", $funcType([], [nat], false), -1], ["or", "or", "math/big", $funcType([nat, nat], [nat], false), -1], ["probablyPrime", "probablyPrime", "math/big", $funcType([$Int], [$Bool], false), -1], ["random", "random", "math/big", $funcType([($ptrType(rand.Rand)), nat, $Int], [nat], false), -1], ["scan", "scan", "math/big", $funcType([io.RuneScanner, $Int], [nat, $Int, $error], false), -1], ["set", "set", "math/big", $funcType([nat], [nat], false), -1], ["setBit", "setBit", "math/big", $funcType([nat, $Uint, $Uint], [nat], false), -1], ["setBytes", "setBytes", "math/big", $funcType([($sliceType($Uint8))], [nat], false), -1], ["setUint64", "setUint64", "math/big", $funcType([$Uint64], [nat], false), -1], ["setWord", "setWord", "math/big", $funcType([Word], [nat], false), -1], ["shl", "shl", "math/big", $funcType([nat, $Uint], [nat], false), -1], ["shr", "shr", "math/big", $funcType([nat, $Uint], [nat], false), -1], ["string", "string", "math/big", $funcType([$String], [$String], false), -1], ["sub", "sub", "math/big", $funcType([nat, nat], [nat], false), -1], ["trailingZeroBits", "trailingZeroBits", "math/big", $funcType([], [$Uint], false), -1], ["xor", "xor", "math/big", $funcType([nat, nat], [nat], false), -1]]; - nat.init(Word); - divisor.init([["bbb", "bbb", "math/big", nat, ""], ["nbits", "nbits", "math/big", $Int, ""], ["ndigits", "ndigits", "math/big", $Int, ""]]); - ($ptrType(Rat)).methods = [["Abs", "Abs", "", $funcType([($ptrType(Rat))], [($ptrType(Rat))], false), -1], ["Add", "Add", "", $funcType([($ptrType(Rat)), ($ptrType(Rat))], [($ptrType(Rat))], false), -1], ["Cmp", "Cmp", "", $funcType([($ptrType(Rat))], [$Int], false), -1], ["Denom", "Denom", "", $funcType([], [($ptrType(Int))], false), -1], ["Float64", "Float64", "", $funcType([], [$Float64, $Bool], false), -1], ["FloatString", "FloatString", "", $funcType([$Int], [$String], false), -1], ["GobDecode", "GobDecode", "", $funcType([($sliceType($Uint8))], [$error], false), -1], ["GobEncode", "GobEncode", "", $funcType([], [($sliceType($Uint8)), $error], false), -1], ["Inv", "Inv", "", $funcType([($ptrType(Rat))], [($ptrType(Rat))], false), -1], ["IsInt", "IsInt", "", $funcType([], [$Bool], false), -1], ["MarshalText", "MarshalText", "", $funcType([], [($sliceType($Uint8)), $error], false), -1], ["Mul", "Mul", "", $funcType([($ptrType(Rat)), ($ptrType(Rat))], [($ptrType(Rat))], false), -1], ["Neg", "Neg", "", $funcType([($ptrType(Rat))], [($ptrType(Rat))], false), -1], ["Num", "Num", "", $funcType([], [($ptrType(Int))], false), -1], ["Quo", "Quo", "", $funcType([($ptrType(Rat)), ($ptrType(Rat))], [($ptrType(Rat))], false), -1], ["RatString", "RatString", "", $funcType([], [$String], false), -1], ["Scan", "Scan", "", $funcType([fmt.ScanState, $Int32], [$error], false), -1], ["Set", "Set", "", $funcType([($ptrType(Rat))], [($ptrType(Rat))], false), -1], ["SetFloat64", "SetFloat64", "", $funcType([$Float64], [($ptrType(Rat))], false), -1], ["SetFrac", "SetFrac", "", $funcType([($ptrType(Int)), ($ptrType(Int))], [($ptrType(Rat))], false), -1], ["SetFrac64", "SetFrac64", "", $funcType([$Int64, $Int64], [($ptrType(Rat))], false), -1], ["SetInt", "SetInt", "", $funcType([($ptrType(Int))], [($ptrType(Rat))], false), -1], ["SetInt64", "SetInt64", "", $funcType([$Int64], [($ptrType(Rat))], false), -1], ["SetString", "SetString", "", $funcType([$String], [($ptrType(Rat)), $Bool], false), -1], ["Sign", "Sign", "", $funcType([], [$Int], false), -1], ["String", "String", "", $funcType([], [$String], false), -1], ["Sub", "Sub", "", $funcType([($ptrType(Rat)), ($ptrType(Rat))], [($ptrType(Rat))], false), -1], ["UnmarshalText", "UnmarshalText", "", $funcType([($sliceType($Uint8))], [$error], false), -1], ["norm", "norm", "math/big", $funcType([], [($ptrType(Rat))], false), -1]]; - Rat.init([["a", "a", "math/big", Int, ""], ["b", "b", "math/big", Int, ""]]); - cacheBase10 = new ($structType([["Mutex", "", "", sync.Mutex, ""], ["table", "table", "math/big", ($arrayType(divisor, 64)), ""]])).Ptr(); - natOne = new nat([1]); - intOne = new Int.Ptr(false, natOne); - natTwo = new nat([2]); - natTen = new nat([10]); - karatsubaThreshold = 40; - leafSize = 8; - deBruijn32Lookup = new ($sliceType($Uint8))([0, 1, 28, 2, 29, 14, 24, 3, 30, 22, 20, 15, 25, 17, 4, 8, 31, 27, 13, 23, 21, 19, 16, 7, 26, 12, 18, 6, 11, 5, 10, 9]); - deBruijn64Lookup = new ($sliceType($Uint8))([0, 1, 56, 2, 57, 49, 28, 3, 61, 58, 42, 50, 38, 29, 17, 4, 62, 47, 59, 36, 45, 43, 51, 22, 53, 39, 33, 30, 24, 18, 12, 5, 63, 55, 48, 27, 60, 41, 37, 16, 46, 35, 44, 21, 52, 32, 23, 11, 54, 26, 40, 15, 34, 20, 31, 10, 25, 14, 19, 9, 13, 8, 7, 6]); - }; - return $pkg; -})(); -$packages["code.google.com/p/go.tools/go/exact"] = (function() { - var $pkg = {}, fmt = $packages["fmt"], token = $packages["go/token"], big = $packages["math/big"], strconv = $packages["strconv"], math = $packages["math"], Kind, Value, unknownVal, boolVal, stringVal, int64Val, intVal, floatVal, complexVal, minInt64, maxInt64, int1, rat0, normInt, normFloat, normComplex, MakeUnknown, MakeBool, MakeString, MakeInt64, MakeFloat64, MakeFromLiteral, BoolVal, StringVal, Int64Val, Uint64Val, Float32Val, Float64Val, BitLen, Sign, MakeImag, Real, Imag, is32bit, is63bit, UnaryOp, ord, match, BinaryOp, Shift, cmpZero, Compare, ratToFloat32; - Kind = $pkg.Kind = $newType(4, "Int", "exact.Kind", "Kind", "code.google.com/p/go.tools/go/exact", null); - Value = $pkg.Value = $newType(8, "Interface", "exact.Value", "Value", "code.google.com/p/go.tools/go/exact", null); - unknownVal = $pkg.unknownVal = $newType(0, "Struct", "exact.unknownVal", "unknownVal", "code.google.com/p/go.tools/go/exact", function() { - this.$val = this; - }); - boolVal = $pkg.boolVal = $newType(1, "Bool", "exact.boolVal", "boolVal", "code.google.com/p/go.tools/go/exact", null); - stringVal = $pkg.stringVal = $newType(8, "String", "exact.stringVal", "stringVal", "code.google.com/p/go.tools/go/exact", null); - int64Val = $pkg.int64Val = $newType(8, "Int64", "exact.int64Val", "int64Val", "code.google.com/p/go.tools/go/exact", null); - intVal = $pkg.intVal = $newType(0, "Struct", "exact.intVal", "intVal", "code.google.com/p/go.tools/go/exact", function(val_) { - this.$val = this; - this.val = val_ !== undefined ? val_ : ($ptrType(big.Int)).nil; - }); - floatVal = $pkg.floatVal = $newType(0, "Struct", "exact.floatVal", "floatVal", "code.google.com/p/go.tools/go/exact", function(val_) { - this.$val = this; - this.val = val_ !== undefined ? val_ : ($ptrType(big.Rat)).nil; - }); - complexVal = $pkg.complexVal = $newType(0, "Struct", "exact.complexVal", "complexVal", "code.google.com/p/go.tools/go/exact", function(re_, im_) { - this.$val = this; - this.re = re_ !== undefined ? re_ : ($ptrType(big.Rat)).nil; - this.im = im_ !== undefined ? im_ : ($ptrType(big.Rat)).nil; - }); - unknownVal.Ptr.prototype.Kind = function() { - return 0; - }; - unknownVal.prototype.Kind = function() { return this.$val.Kind(); }; - boolVal.prototype.Kind = function() { - return 1; - }; - $ptrType(boolVal).prototype.Kind = function() { return new boolVal(this.$get()).Kind(); }; - stringVal.prototype.Kind = function() { - return 2; + return ((i < 0 || i >= x.$length) ? $throwRuntimeError("index out of range") : x.$array[x.$offset + i]).index.$length < ((j < 0 || j >= x.$length) ? $throwRuntimeError("index out of range") : x.$array[x.$offset + j]).index.$length; }; - $ptrType(stringVal).prototype.Kind = function() { return new stringVal(this.$get()).Kind(); }; - int64Val.prototype.Kind = function() { - return 3; - }; - $ptrType(int64Val).prototype.Kind = function() { return this.$get().Kind(); }; - intVal.Ptr.prototype.Kind = function() { - return 3; - }; - intVal.prototype.Kind = function() { return this.$val.Kind(); }; - floatVal.Ptr.prototype.Kind = function() { - return 4; - }; - floatVal.prototype.Kind = function() { return this.$val.Kind(); }; - complexVal.Ptr.prototype.Kind = function() { - return 5; - }; - complexVal.prototype.Kind = function() { return this.$val.Kind(); }; - unknownVal.Ptr.prototype.String = function() { - return "unknown"; - }; - unknownVal.prototype.String = function() { return this.$val.String(); }; - boolVal.prototype.String = function() { - var x; - x = this.$val !== undefined ? this.$val : this; - return fmt.Sprintf("%v", new ($sliceType($emptyInterface))([new $Bool(x)])); - }; - $ptrType(boolVal).prototype.String = function() { return new boolVal(this.$get()).String(); }; - stringVal.prototype.String = function() { - var x; - x = this.$val !== undefined ? this.$val : this; - return strconv.Quote(x); - }; - $ptrType(stringVal).prototype.String = function() { return new stringVal(this.$get()).String(); }; - int64Val.prototype.String = function() { - var x; - x = this; - return strconv.FormatInt(new $Int64(x.$high, x.$low), 10); - }; - $ptrType(int64Val).prototype.String = function() { return this.$get().String(); }; - intVal.Ptr.prototype.String = function() { - var x; - x = new intVal.Ptr(); $copy(x, this, intVal); - return x.val.String(); - }; - intVal.prototype.String = function() { return this.$val.String(); }; - floatVal.Ptr.prototype.String = function() { - var x; - x = new floatVal.Ptr(); $copy(x, this, floatVal); - return x.val.String(); - }; - floatVal.prototype.String = function() { return this.$val.String(); }; - complexVal.Ptr.prototype.String = function() { - var x; - x = new complexVal.Ptr(); $copy(x, this, complexVal); - return fmt.Sprintf("(%s + %si)", new ($sliceType($emptyInterface))([x.re, x.im])); - }; - complexVal.prototype.String = function() { return this.$val.String(); }; - normInt = function(x) { - var x$1, x$2; - if (minInt64.Cmp(x) <= 0 && x.Cmp(maxInt64) <= 0) { - return (x$1 = x.Int64(), new int64Val(x$1.$high, x$1.$low)); + $ptrType(byIndex).prototype.Less = function(i, j) { return this.$get().Less(i, j); }; + typeFields = function(t) { + var current, next, count, _map, _key, nextCount, _map$1, _key$1, visited, _map$2, _key$2, fields, _tmp, _tmp$1, _tmp$2, _tmp$3, _map$3, _key$3, _ref, _i, f, _entry, _key$4, i, sf, tag, _tuple, name, opts, index, x, ft, tagged, _entry$1, x$1, _lhs, _index, _entry$2, _key$5, _entry$3, out, _tmp$4, _tmp$5, advance, i$1, fi, name$1, x$2, fj, _tuple$1, dominant, ok; + current = new ($sliceType(field))([]); + next = new ($sliceType(field))([new field.Ptr("", ($sliceType($Uint8)).nil, $throwNilPointerError, false, ($sliceType($Int)).nil, t, false, false)]); + count = (_map = new $Map(), _map); + nextCount = (_map$1 = new $Map(), _map$1); + visited = (_map$2 = new $Map(), _map$2); + fields = ($sliceType(field)).nil; + while (next.$length > 0) { + _tmp = next; _tmp$1 = $subslice(current, 0, 0); current = _tmp; next = _tmp$1; + _tmp$2 = nextCount; _tmp$3 = (_map$3 = new $Map(), _map$3); count = _tmp$2; nextCount = _tmp$3; + _ref = current; + _i = 0; + while (_i < _ref.$length) { + f = new field.Ptr(); $copy(f, ((_i < 0 || _i >= _ref.$length) ? $throwRuntimeError("index out of range") : _ref.$array[_ref.$offset + _i]), field); + if ((_entry = visited[f.typ.$key()], _entry !== undefined ? _entry.v : false)) { + _i++; + continue; + } + _key$4 = f.typ; (visited || $throwRuntimeError("assignment to entry in nil map"))[_key$4.$key()] = { k: _key$4, v: true }; + i = 0; + while (i < f.typ.NumField()) { + sf = new reflect.StructField.Ptr(); $copy(sf, f.typ.Field(i), reflect.StructField); + if (!(sf.PkgPath === "")) { + i = i + (1) >> 0; + continue; + } + tag = (new reflect.StructTag(sf.Tag)).Get("json"); + if (tag === "-") { + i = i + (1) >> 0; + continue; + } + _tuple = parseTag(tag); name = _tuple[0]; opts = _tuple[1]; + if (!isValidTag(name)) { + name = ""; + } + index = ($sliceType($Int)).make((f.index.$length + 1 >> 0)); + $copySlice(index, f.index); + (x = f.index.$length, (x < 0 || x >= index.$length) ? $throwRuntimeError("index out of range") : index.$array[index.$offset + x] = i); + ft = sf.Type; + if (ft.Name() === "" && (ft.Kind() === 22)) { + ft = ft.Elem(); + } + if (!(name === "") || !sf.Anonymous || !((ft.Kind() === 25))) { + tagged = !(name === ""); + if (name === "") { + name = sf.Name; + } + fields = $append(fields, fillField(new field.Ptr(name, ($sliceType($Uint8)).nil, $throwNilPointerError, tagged, index, ft, (new tagOptions(opts)).Contains("omitempty"), (new tagOptions(opts)).Contains("string")))); + if ((_entry$1 = count[f.typ.$key()], _entry$1 !== undefined ? _entry$1.v : 0) > 1) { + fields = $append(fields, (x$1 = fields.$length - 1 >> 0, ((x$1 < 0 || x$1 >= fields.$length) ? $throwRuntimeError("index out of range") : fields.$array[fields.$offset + x$1]))); + } + i = i + (1) >> 0; + continue; + } + _lhs = nextCount; _index = ft; _key$5 = _index; (_lhs || $throwRuntimeError("assignment to entry in nil map"))[_key$5.$key()] = { k: _key$5, v: (_entry$2 = _lhs[_index.$key()], _entry$2 !== undefined ? _entry$2.v : 0) + (1) >> 0 }; + if ((_entry$3 = nextCount[ft.$key()], _entry$3 !== undefined ? _entry$3.v : 0) === 1) { + next = $append(next, fillField(new field.Ptr(ft.Name(), ($sliceType($Uint8)).nil, $throwNilPointerError, false, index, ft, false, false))); + } + i = i + (1) >> 0; + } + _i++; + } } - return (x$2 = new intVal.Ptr(x), new x$2.constructor.Struct(x$2)); - }; - normFloat = function(x) { - var x$1; - if (x.IsInt()) { - return normInt(x.Num()); + sort.Sort($subslice(new byName(fields.$array), fields.$offset, fields.$offset + fields.$length)); + out = $subslice(fields, 0, 0); + _tmp$4 = 0; _tmp$5 = 0; advance = _tmp$4; i$1 = _tmp$5; + while (i$1 < fields.$length) { + fi = new field.Ptr(); $copy(fi, ((i$1 < 0 || i$1 >= fields.$length) ? $throwRuntimeError("index out of range") : fields.$array[fields.$offset + i$1]), field); + name$1 = fi.name; + advance = 1; + while ((i$1 + advance >> 0) < fields.$length) { + fj = new field.Ptr(); $copy(fj, (x$2 = i$1 + advance >> 0, ((x$2 < 0 || x$2 >= fields.$length) ? $throwRuntimeError("index out of range") : fields.$array[fields.$offset + x$2])), field); + if (!(fj.name === name$1)) { + break; + } + advance = advance + (1) >> 0; + } + if (advance === 1) { + out = $append(out, fi); + i$1 = i$1 + (advance) >> 0; + continue; + } + _tuple$1 = dominantField($subslice(fields, i$1, (i$1 + advance >> 0))); dominant = new field.Ptr(); $copy(dominant, _tuple$1[0], field); ok = _tuple$1[1]; + if (ok) { + out = $append(out, dominant); + } + i$1 = i$1 + (advance) >> 0; } - return (x$1 = new floatVal.Ptr(x), new x$1.constructor.Struct(x$1)); + fields = out; + sort.Sort($subslice(new byIndex(fields.$array), fields.$offset, fields.$offset + fields.$length)); + return fields; }; - normComplex = function(re, im) { - var x; - if (im.Sign() === 0) { - return normFloat(re); + dominantField = function(fields) { + var length, tagged, _ref, _i, i, f; + length = ((0 < 0 || 0 >= fields.$length) ? $throwRuntimeError("index out of range") : fields.$array[fields.$offset + 0]).index.$length; + tagged = -1; + _ref = fields; + _i = 0; + while (_i < _ref.$length) { + i = _i; + f = new field.Ptr(); $copy(f, ((_i < 0 || _i >= _ref.$length) ? $throwRuntimeError("index out of range") : _ref.$array[_ref.$offset + _i]), field); + if (f.index.$length > length) { + fields = $subslice(fields, 0, i); + break; + } + if (f.tag) { + if (tagged >= 0) { + return [new field.Ptr("", ($sliceType($Uint8)).nil, $throwNilPointerError, false, ($sliceType($Int)).nil, $ifaceNil, false, false), false]; + } + tagged = i; + } + _i++; } - return (x = new complexVal.Ptr(re, im), new x.constructor.Struct(x)); - }; - MakeUnknown = $pkg.MakeUnknown = function() { - var x; - return (x = new unknownVal.Ptr(), new x.constructor.Struct(x)); - }; - MakeBool = $pkg.MakeBool = function(b) { - return new boolVal(b); - }; - MakeString = $pkg.MakeString = function(s) { - return new stringVal(s); - }; - MakeInt64 = $pkg.MakeInt64 = function(x) { - return new int64Val(x.$high, x.$low); + if (tagged >= 0) { + return [((tagged < 0 || tagged >= fields.$length) ? $throwRuntimeError("index out of range") : fields.$array[fields.$offset + tagged]), true]; + } + if (fields.$length > 1) { + return [new field.Ptr("", ($sliceType($Uint8)).nil, $throwNilPointerError, false, ($sliceType($Int)).nil, $ifaceNil, false, false), false]; + } + return [((0 < 0 || 0 >= fields.$length) ? $throwRuntimeError("index out of range") : fields.$array[fields.$offset + 0]), true]; }; - MakeFloat64 = $pkg.MakeFloat64 = function(x) { - var f, x$1; - f = new big.Rat.Ptr().SetFloat64(x); - if (!(f === ($ptrType(big.Rat)).nil)) { - return normFloat(f); + cachedTypeFields = function(t) { + var _entry, f, _map, _key, _key$1; + fieldCache.RWMutex.RLock(); + f = (_entry = fieldCache.m[t.$key()], _entry !== undefined ? _entry.v : ($sliceType(field)).nil); + fieldCache.RWMutex.RUnlock(); + if (!(f === ($sliceType(field)).nil)) { + return f; } - return (x$1 = new unknownVal.Ptr(), new x$1.constructor.Struct(x$1)); + f = typeFields(t); + if (f === ($sliceType(field)).nil) { + f = new ($sliceType(field))([]); + } + fieldCache.RWMutex.Lock(); + if (fieldCache.m === false) { + fieldCache.m = (_map = new $Map(), _map); + } + _key$1 = t; (fieldCache.m || $throwRuntimeError("assignment to entry in nil map"))[_key$1.$key()] = { k: _key$1, v: f }; + fieldCache.RWMutex.Unlock(); + return f; }; - MakeFromLiteral = $pkg.MakeFromLiteral = function(lit, tok) { - var _ref, _tuple, x, err, _tuple$1, x$1, ok, x$2, _tuple$2, x$3, ok$1, n, _tuple$3, im, ok$2, n$1, _tuple$4, code, err$1, _tuple$5, s, err$2; - _ref = tok; - if (_ref === 5) { - _tuple = strconv.ParseInt(lit, 0, 64); x = _tuple[0]; err = _tuple[1]; - if ($interfaceIsEqual(err, $ifaceNil)) { - return new int64Val(x.$high, x.$low); + foldFunc = function(s) { + var nonLetter, special, _ref, _i, b, upper; + nonLetter = false; + special = false; + _ref = s; + _i = 0; + while (_i < _ref.$length) { + b = ((_i < 0 || _i >= _ref.$length) ? $throwRuntimeError("index out of range") : _ref.$array[_ref.$offset + _i]); + if (b >= 128) { + return bytes.EqualFold; } - _tuple$1 = new big.Int.Ptr().SetString(lit, 0); x$1 = _tuple$1[0]; ok = _tuple$1[1]; - if (ok) { - return (x$2 = new intVal.Ptr(x$1), new x$2.constructor.Struct(x$2)); + upper = (b & 223) >>> 0; + if (upper < 65 || upper > 90) { + nonLetter = true; + } else if ((upper === 75) || (upper === 83)) { + special = true; } - } else if (_ref === 6) { - _tuple$2 = new big.Rat.Ptr().SetString(lit); x$3 = _tuple$2[0]; ok$1 = _tuple$2[1]; - if (ok$1) { - return normFloat(x$3); + _i++; + } + if (special) { + return equalFoldRight; + } + if (nonLetter) { + return asciiEqualFold; + } + return simpleLetterEqualFold; + }; + equalFoldRight = function(s, t) { + var _ref, _i, sb, tb, sbUpper, _tuple, tr, size, _ref$1; + _ref = s; + _i = 0; + while (_i < _ref.$length) { + sb = ((_i < 0 || _i >= _ref.$length) ? $throwRuntimeError("index out of range") : _ref.$array[_ref.$offset + _i]); + if (t.$length === 0) { + return false; } - } else if (_ref === 7) { - n = lit.length; - if (n > 0 && (lit.charCodeAt((n - 1 >> 0)) === 105)) { - _tuple$3 = new big.Rat.Ptr().SetString(lit.substring(0, (n - 1 >> 0))); im = _tuple$3[0]; ok$2 = _tuple$3[1]; - if (ok$2) { - return normComplex(big.NewRat(new $Int64(0, 0), new $Int64(0, 1)), im); + tb = ((0 < 0 || 0 >= t.$length) ? $throwRuntimeError("index out of range") : t.$array[t.$offset + 0]); + if (tb < 128) { + if (!((sb === tb))) { + sbUpper = (sb & 223) >>> 0; + if (65 <= sbUpper && sbUpper <= 90) { + if (!((sbUpper === ((tb & 223) >>> 0)))) { + return false; + } + } else { + return false; + } } + t = $subslice(t, 1); + _i++; + continue; } - } else if (_ref === 8) { - n$1 = lit.length; - if (n$1 >= 2) { - _tuple$4 = strconv.UnquoteChar(lit.substring(1, (n$1 - 1 >> 0)), 39); code = _tuple$4[0]; err$1 = _tuple$4[3]; - if ($interfaceIsEqual(err$1, $ifaceNil)) { - return new int64Val(0, code); + _tuple = utf8.DecodeRune(t); tr = _tuple[0]; size = _tuple[1]; + _ref$1 = sb; + if (_ref$1 === 115 || _ref$1 === 83) { + if (!((tr === 383))) { + return false; } + } else if (_ref$1 === 107 || _ref$1 === 75) { + if (!((tr === 8490))) { + return false; + } + } else { + return false; } - } else if (_ref === 9) { - _tuple$5 = strconv.Unquote(lit); s = _tuple$5[0]; err$2 = _tuple$5[1]; - if ($interfaceIsEqual(err$2, $ifaceNil)) { - return new stringVal(s); - } + t = $subslice(t, size); + _i++; } - return $ifaceNil; - }; - BoolVal = $pkg.BoolVal = function(x) { - var x$1, _ref; - _ref = x; - if ($assertType(_ref, boolVal, true)[1]) { - x$1 = _ref.$val; - return x$1; - } else if ($assertType(_ref, unknownVal, true)[1]) { - x$1 = _ref.$val; + if (t.$length > 0) { return false; } - $panic(new $String(fmt.Sprintf("%v not a Bool", new ($sliceType($emptyInterface))([x])))); + return true; }; - StringVal = $pkg.StringVal = function(x) { - var x$1, _ref; - _ref = x; - if ($assertType(_ref, stringVal, true)[1]) { - x$1 = _ref.$val; - return x$1; - } else if ($assertType(_ref, unknownVal, true)[1]) { - x$1 = _ref.$val; - return ""; + asciiEqualFold = function(s, t) { + var _ref, _i, i, sb, tb; + if (!((s.$length === t.$length))) { + return false; } - $panic(new $String(fmt.Sprintf("%v not a String", new ($sliceType($emptyInterface))([x])))); - }; - Int64Val = $pkg.Int64Val = function(x) { - var x$1, _ref; - _ref = x; - if ($assertType(_ref, int64Val, true)[1]) { - x$1 = _ref.$val; - return [new $Int64(x$1.$high, x$1.$low), true]; - } else if ($assertType(_ref, intVal, true)[1]) { - x$1 = _ref.$val; - return [x$1.val.Int64(), x$1.val.BitLen() <= 63]; - } else if ($assertType(_ref, unknownVal, true)[1]) { - x$1 = _ref.$val; - return [new $Int64(0, 0), false]; + _ref = s; + _i = 0; + while (_i < _ref.$length) { + i = _i; + sb = ((_i < 0 || _i >= _ref.$length) ? $throwRuntimeError("index out of range") : _ref.$array[_ref.$offset + _i]); + tb = ((i < 0 || i >= t.$length) ? $throwRuntimeError("index out of range") : t.$array[t.$offset + i]); + if (sb === tb) { + _i++; + continue; + } + if ((97 <= sb && sb <= 122) || (65 <= sb && sb <= 90)) { + if (!((((sb & 223) >>> 0) === ((tb & 223) >>> 0)))) { + return false; + } + } else { + return false; + } + _i++; } - $panic(new $String(fmt.Sprintf("%v not an Int", new ($sliceType($emptyInterface))([x])))); + return true; }; - Uint64Val = $pkg.Uint64Val = function(x) { - var x$1, _ref; - _ref = x; - if ($assertType(_ref, int64Val, true)[1]) { - x$1 = _ref.$val; - return [new $Uint64(x$1.$high, x$1.$low), (x$1.$high > 0 || (x$1.$high === 0 && x$1.$low >= 0))]; - } else if ($assertType(_ref, intVal, true)[1]) { - x$1 = _ref.$val; - return [x$1.val.Uint64(), x$1.val.Sign() >= 0 && x$1.val.BitLen() <= 64]; - } else if ($assertType(_ref, unknownVal, true)[1]) { - x$1 = _ref.$val; - return [new $Uint64(0, 0), false]; + simpleLetterEqualFold = function(s, t) { + var _ref, _i, i, b; + if (!((s.$length === t.$length))) { + return false; } - $panic(new $String(fmt.Sprintf("%v not an Int", new ($sliceType($emptyInterface))([x])))); - }; - Float32Val = $pkg.Float32Val = function(x) { - var x$1, _ref, f, x$2; - _ref = x; - if ($assertType(_ref, int64Val, true)[1]) { - x$1 = _ref.$val; - f = $flatten64(x$1); - return [f, (x$2 = new int64Val(0, f), (x$2.$high === x$1.$high && x$2.$low === x$1.$low))]; - } else if ($assertType(_ref, intVal, true)[1]) { - x$1 = _ref.$val; - return ratToFloat32(new big.Rat.Ptr().SetFrac(x$1.val, int1)); - } else if ($assertType(_ref, floatVal, true)[1]) { - x$1 = _ref.$val; - return ratToFloat32(x$1.val); - } else if ($assertType(_ref, unknownVal, true)[1]) { - x$1 = _ref.$val; - return [0, false]; + _ref = s; + _i = 0; + while (_i < _ref.$length) { + i = _i; + b = ((_i < 0 || _i >= _ref.$length) ? $throwRuntimeError("index out of range") : _ref.$array[_ref.$offset + _i]); + if (!((((b & 223) >>> 0) === ((((i < 0 || i >= t.$length) ? $throwRuntimeError("index out of range") : t.$array[t.$offset + i]) & 223) >>> 0)))) { + return false; + } + _i++; } - $panic(new $String(fmt.Sprintf("%v not a Float", new ($sliceType($emptyInterface))([x])))); + return true; }; - Float64Val = $pkg.Float64Val = function(x) { - var x$1, _ref, f, x$2; - _ref = x; - if ($assertType(_ref, int64Val, true)[1]) { - x$1 = _ref.$val; - f = $flatten64(new $Int64(x$1.$high, x$1.$low)); - return [f, (x$2 = new int64Val(0, f), (x$2.$high === x$1.$high && x$2.$low === x$1.$low))]; - } else if ($assertType(_ref, intVal, true)[1]) { - x$1 = _ref.$val; - return new big.Rat.Ptr().SetFrac(x$1.val, int1).Float64(); - } else if ($assertType(_ref, floatVal, true)[1]) { - x$1 = _ref.$val; - return x$1.val.Float64(); - } else if ($assertType(_ref, unknownVal, true)[1]) { - x$1 = _ref.$val; - return [0, false]; + compact = function(dst, src, escape) { + var origLen, scan, start, _ref, _i, i, c, x, x$1, x$2, v; + origLen = dst.Len(); + scan = new scanner.Ptr(); $copy(scan, new scanner.Ptr(), scanner); + scan.reset(); + start = 0; + _ref = src; + _i = 0; + while (_i < _ref.$length) { + i = _i; + c = ((_i < 0 || _i >= _ref.$length) ? $throwRuntimeError("index out of range") : _ref.$array[_ref.$offset + _i]); + if (escape && ((c === 60) || (c === 62) || (c === 38))) { + if (start < i) { + dst.Write($subslice(src, start, i)); + } + dst.WriteString("\\u00"); + dst.WriteByte(hex.charCodeAt((c >>> 4 << 24 >>> 24))); + dst.WriteByte(hex.charCodeAt(((c & 15) >>> 0))); + start = i + 1 >> 0; + } + if ((c === 226) && (i + 2 >> 0) < src.$length && ((x = i + 1 >> 0, ((x < 0 || x >= src.$length) ? $throwRuntimeError("index out of range") : src.$array[src.$offset + x])) === 128) && (((x$1 = i + 2 >> 0, ((x$1 < 0 || x$1 >= src.$length) ? $throwRuntimeError("index out of range") : src.$array[src.$offset + x$1])) & ~1) === 168)) { + if (start < i) { + dst.Write($subslice(src, start, i)); + } + dst.WriteString("\\u202"); + dst.WriteByte(hex.charCodeAt((((x$2 = i + 2 >> 0, ((x$2 < 0 || x$2 >= src.$length) ? $throwRuntimeError("index out of range") : src.$array[src.$offset + x$2])) & 15) >>> 0))); + start = i + 3 >> 0; + } + v = scan.step(scan, (c >> 0)); + if (v >= 9) { + if (v === 11) { + break; + } + if (start < i) { + dst.Write($subslice(src, start, i)); + } + start = i + 1 >> 0; + } + _i++; } - $panic(new $String(fmt.Sprintf("%v not a Float", new ($sliceType($emptyInterface))([x])))); - }; - BitLen = $pkg.BitLen = function(x) { - var x$1, _ref; - _ref = x; - if ($assertType(_ref, int64Val, true)[1]) { - x$1 = _ref.$val; - return new big.Int.Ptr().SetInt64(new $Int64(x$1.$high, x$1.$low)).BitLen(); - } else if ($assertType(_ref, intVal, true)[1]) { - x$1 = _ref.$val; - return x$1.val.BitLen(); - } else if ($assertType(_ref, unknownVal, true)[1]) { - x$1 = _ref.$val; - return 0; + if (scan.eof() === 11) { + dst.Truncate(origLen); + return scan.err; } - $panic(new $String(fmt.Sprintf("%v not an Int", new ($sliceType($emptyInterface))([x])))); + if (start < src.$length) { + dst.Write($subslice(src, start)); + } + return $ifaceNil; }; - Sign = $pkg.Sign = function(x) { - var x$1, _ref; - _ref = x; - if ($assertType(_ref, int64Val, true)[1]) { - x$1 = _ref.$val; - if ((x$1.$high < 0 || (x$1.$high === 0 && x$1.$low < 0))) { - return -1; - } else if ((x$1.$high > 0 || (x$1.$high === 0 && x$1.$low > 0))) { - return 1; + checkValid = function(data, scan) { + var _ref, _i, c, x, x$1; + scan.reset(); + _ref = data; + _i = 0; + while (_i < _ref.$length) { + c = ((_i < 0 || _i >= _ref.$length) ? $throwRuntimeError("index out of range") : _ref.$array[_ref.$offset + _i]); + scan.bytes = (x = scan.bytes, x$1 = new $Int64(0, 1), new $Int64(x.$high + x$1.$high, x.$low + x$1.$low)); + if (scan.step(scan, (c >> 0)) === 11) { + return scan.err; } - return 0; - } else if ($assertType(_ref, intVal, true)[1]) { - x$1 = _ref.$val; - return x$1.val.Sign(); - } else if ($assertType(_ref, floatVal, true)[1]) { - x$1 = _ref.$val; - return x$1.val.Sign(); - } else if ($assertType(_ref, complexVal, true)[1]) { - x$1 = _ref.$val; - return x$1.re.Sign() | x$1.im.Sign(); - } else if ($assertType(_ref, unknownVal, true)[1]) { - x$1 = _ref.$val; - return 1; + _i++; } - $panic(new $String(fmt.Sprintf("%v not numeric", new ($sliceType($emptyInterface))([x])))); + if (scan.eof() === 11) { + return scan.err; + } + return $ifaceNil; }; - MakeImag = $pkg.MakeImag = function(x) { - var im, x$1, _ref; - im = ($ptrType(big.Rat)).nil; - _ref = x; - if ($assertType(_ref, unknownVal, true)[1]) { - x$1 = _ref.$val; - return new x$1.constructor.Struct(x$1); - } else if ($assertType(_ref, int64Val, true)[1]) { - x$1 = _ref.$val; - im = big.NewRat(new $Int64(x$1.$high, x$1.$low), new $Int64(0, 1)); - } else if ($assertType(_ref, intVal, true)[1]) { - x$1 = _ref.$val; - im = new big.Rat.Ptr().SetFrac(x$1.val, int1); - } else if ($assertType(_ref, floatVal, true)[1]) { - x$1 = _ref.$val; - im = x$1.val; + nextValue = function(data, scan) { + var value = ($sliceType($Uint8)).nil, rest = ($sliceType($Uint8)).nil, err = $ifaceNil, _ref, _i, i, c, v, _ref$1, _tmp, _tmp$1, _tmp$2, _tmp$3, _tmp$4, _tmp$5, _tmp$6, _tmp$7, _tmp$8, _tmp$9, _tmp$10, _tmp$11; + scan.reset(); + _ref = data; + _i = 0; + while (_i < _ref.$length) { + i = _i; + c = ((_i < 0 || _i >= _ref.$length) ? $throwRuntimeError("index out of range") : _ref.$array[_ref.$offset + _i]); + v = scan.step(scan, (c >> 0)); + if (v >= 10) { + _ref$1 = v; + if (_ref$1 === 11) { + _tmp = ($sliceType($Uint8)).nil; _tmp$1 = ($sliceType($Uint8)).nil; _tmp$2 = scan.err; value = _tmp; rest = _tmp$1; err = _tmp$2; + return [value, rest, err]; + } else if (_ref$1 === 10) { + _tmp$3 = $subslice(data, 0, i); _tmp$4 = $subslice(data, i); _tmp$5 = $ifaceNil; value = _tmp$3; rest = _tmp$4; err = _tmp$5; + return [value, rest, err]; + } + } + _i++; + } + if (scan.eof() === 11) { + _tmp$6 = ($sliceType($Uint8)).nil; _tmp$7 = ($sliceType($Uint8)).nil; _tmp$8 = scan.err; value = _tmp$6; rest = _tmp$7; err = _tmp$8; + return [value, rest, err]; + } + _tmp$9 = data; _tmp$10 = ($sliceType($Uint8)).nil; _tmp$11 = $ifaceNil; value = _tmp$9; rest = _tmp$10; err = _tmp$11; + return [value, rest, err]; + }; + SyntaxError.Ptr.prototype.Error = function() { + var e; + e = this; + return e.msg; + }; + SyntaxError.prototype.Error = function() { return this.$val.Error(); }; + scanner.Ptr.prototype.reset = function() { + var s; + s = this; + s.step = stateBeginValue; + s.parseState = $subslice(s.parseState, 0, 0); + s.err = $ifaceNil; + s.redo = false; + s.endTop = false; + }; + scanner.prototype.reset = function() { return this.$val.reset(); }; + scanner.Ptr.prototype.eof = function() { + var s; + s = this; + if (!($interfaceIsEqual(s.err, $ifaceNil))) { + return 11; + } + if (s.endTop) { + return 10; + } + s.step(s, 32); + if (s.endTop) { + return 10; + } + if ($interfaceIsEqual(s.err, $ifaceNil)) { + s.err = new SyntaxError.Ptr("unexpected end of JSON input", s.bytes); + } + return 11; + }; + scanner.prototype.eof = function() { return this.$val.eof(); }; + scanner.Ptr.prototype.pushParseState = function(p) { + var s; + s = this; + s.parseState = $append(s.parseState, p); + }; + scanner.prototype.pushParseState = function(p) { return this.$val.pushParseState(p); }; + scanner.Ptr.prototype.popParseState = function() { + var s, n; + s = this; + n = s.parseState.$length - 1 >> 0; + s.parseState = $subslice(s.parseState, 0, n); + s.redo = false; + if (n === 0) { + s.step = stateEndTop; + s.endTop = true; } else { - x$1 = _ref; - $panic(new $String(fmt.Sprintf("%v not Int or Float", new ($sliceType($emptyInterface))([x$1])))); + s.step = stateEndValue; } - return normComplex(rat0, im); }; - Real = $pkg.Real = function(x) { - var x$1, _ref; - _ref = x; - if ($assertType(_ref, unknownVal, true)[1] || $assertType(_ref, int64Val, true)[1] || $assertType(_ref, intVal, true)[1] || $assertType(_ref, floatVal, true)[1]) { - x$1 = _ref; - return x$1; - } else if ($assertType(_ref, complexVal, true)[1]) { - x$1 = _ref.$val; - return normFloat(x$1.re); + scanner.prototype.popParseState = function() { return this.$val.popParseState(); }; + isSpace = function(c) { + return (c === 32) || (c === 9) || (c === 13) || (c === 10); + }; + stateBeginValueOrEmpty = function(s, c) { + if (c <= 32 && isSpace((c >> 0))) { + return 9; } - $panic(new $String(fmt.Sprintf("%v not numeric", new ($sliceType($emptyInterface))([x])))); + if (c === 93) { + return stateEndValue(s, c); + } + return stateBeginValue(s, c); }; - Imag = $pkg.Imag = function(x) { - var x$1, _ref; - _ref = x; - if ($assertType(_ref, unknownVal, true)[1]) { - x$1 = _ref.$val; - return new x$1.constructor.Struct(x$1); - } else if ($assertType(_ref, int64Val, true)[1] || $assertType(_ref, intVal, true)[1] || $assertType(_ref, floatVal, true)[1]) { - x$1 = _ref; - return new int64Val(0, 0); - } else if ($assertType(_ref, complexVal, true)[1]) { - x$1 = _ref.$val; - return normFloat(x$1.im); + stateBeginValue = function(s, c) { + var _ref; + if (c <= 32 && isSpace((c >> 0))) { + return 9; } - $panic(new $String(fmt.Sprintf("%v not numeric", new ($sliceType($emptyInterface))([x])))); + _ref = c; + if (_ref === 123) { + s.step = stateBeginStringOrEmpty; + s.pushParseState(0); + return 2; + } else if (_ref === 91) { + s.step = stateBeginValueOrEmpty; + s.pushParseState(2); + return 6; + } else if (_ref === 34) { + s.step = stateInString; + return 1; + } else if (_ref === 45) { + s.step = stateNeg; + return 1; + } else if (_ref === 48) { + s.step = state0; + return 1; + } else if (_ref === 116) { + s.step = stateT; + return 1; + } else if (_ref === 102) { + s.step = stateF; + return 1; + } else if (_ref === 110) { + s.step = stateN; + return 1; + } + if (49 <= c && c <= 57) { + s.step = state1; + return 1; + } + return s.error(c, "looking for beginning of value"); }; - is32bit = function(x) { - return (-1 < x.$high || (-1 === x.$high && 2147483648 <= x.$low)) && (x.$high < 0 || (x.$high === 0 && x.$low <= 2147483647)); + stateBeginStringOrEmpty = function(s, c) { + var n, x, x$1; + if (c <= 32 && isSpace((c >> 0))) { + return 9; + } + if (c === 125) { + n = s.parseState.$length; + (x = s.parseState, x$1 = n - 1 >> 0, (x$1 < 0 || x$1 >= x.$length) ? $throwRuntimeError("index out of range") : x.$array[x.$offset + x$1] = 1); + return stateEndValue(s, c); + } + return stateBeginString(s, c); }; - is63bit = function(x) { - return (-1073741824 < x.$high || (-1073741824 === x.$high && 0 <= x.$low)) && (x.$high < 1073741823 || (x.$high === 1073741823 && x.$low <= 4294967295)); + stateBeginString = function(s, c) { + if (c <= 32 && isSpace((c >> 0))) { + return 9; + } + if (c === 34) { + s.step = stateInString; + return 1; + } + return s.error(c, "looking for beginning of object key string"); }; - UnaryOp = $pkg.UnaryOp = function(op, y, size) { - var $this = this, $args = arguments, $s = 0, _ref, _ref$1, y$1, _ref$2, z, z$1, y$2, _ref$3, x, s, y$3, _ref$4; - /* */ while (true) { switch ($s) { case 0: - _ref = op; - /* if (_ref === 12) { */ if (_ref === 12) {} else if (_ref === 13) { $s = 2; continue; } else if (_ref === 19) { $s = 3; continue; } else if (_ref === 43) { $s = 4; continue; } else { $s = 5; continue; } - _ref$1 = y; - if ($assertType(_ref$1, unknownVal, true)[1] || $assertType(_ref$1, int64Val, true)[1] || $assertType(_ref$1, intVal, true)[1] || $assertType(_ref$1, floatVal, true)[1] || $assertType(_ref$1, complexVal, true)[1]) { - return y; + stateEndValue = function(s, c) { + var n, x, x$1, ps, _ref, x$2, x$3, x$4, x$5; + n = s.parseState.$length; + if (n === 0) { + s.step = stateEndTop; + s.endTop = true; + return stateEndTop(s, c); + } + if (c <= 32 && isSpace((c >> 0))) { + s.step = stateEndValue; + return 9; + } + ps = (x = s.parseState, x$1 = n - 1 >> 0, ((x$1 < 0 || x$1 >= x.$length) ? $throwRuntimeError("index out of range") : x.$array[x.$offset + x$1])); + _ref = ps; + if (_ref === 0) { + if (c === 58) { + (x$2 = s.parseState, x$3 = n - 1 >> 0, (x$3 < 0 || x$3 >= x$2.$length) ? $throwRuntimeError("index out of range") : x$2.$array[x$2.$offset + x$3] = 1); + s.step = stateBeginValue; + return 3; } - /* } else if (_ref === 13) { */ $s = 5; continue; case 2: - _ref$2 = y; - if ($assertType(_ref$2, unknownVal, true)[1]) { - y$1 = _ref$2.$val; - return new y$1.constructor.Struct(y$1); - } else if ($assertType(_ref$2, int64Val, true)[1]) { - y$1 = _ref$2.$val; - z = new int64Val(-y$1.$high, -y$1.$low); - if (!((z.$high === y$1.$high && z.$low === y$1.$low))) { - return z; - } - return normInt(new big.Int.Ptr().Neg(big.NewInt(new $Int64(y$1.$high, y$1.$low)))); - } else if ($assertType(_ref$2, intVal, true)[1]) { - y$1 = _ref$2.$val; - return normInt(new big.Int.Ptr().Neg(y$1.val)); - } else if ($assertType(_ref$2, floatVal, true)[1]) { - y$1 = _ref$2.$val; - return normFloat(new big.Rat.Ptr().Neg(y$1.val)); - } else if ($assertType(_ref$2, complexVal, true)[1]) { - y$1 = _ref$2.$val; - return normComplex(new big.Rat.Ptr().Neg(y$1.re), new big.Rat.Ptr().Neg(y$1.im)); + return s.error(c, "after object key"); + } else if (_ref === 1) { + if (c === 44) { + (x$4 = s.parseState, x$5 = n - 1 >> 0, (x$5 < 0 || x$5 >= x$4.$length) ? $throwRuntimeError("index out of range") : x$4.$array[x$4.$offset + x$5] = 0); + s.step = stateBeginString; + return 4; } - /* } else if (_ref === 19) { */ $s = 5; continue; case 3: - z$1 = new big.Int.Ptr(); $copy(z$1, new big.Int.Ptr(), big.Int); - _ref$3 = y; - /* if ($assertType(_ref$3, unknownVal, true)[1]) { */ if ($assertType(_ref$3, unknownVal, true)[1]) {} else if ($assertType(_ref$3, int64Val, true)[1]) { $s = 6; continue; } else if ($assertType(_ref$3, intVal, true)[1]) { $s = 7; continue; } else { $s = 8; continue; } - y$2 = _ref$3.$val; - return new y$2.constructor.Struct(y$2); - /* } else if ($assertType(_ref$3, int64Val, true)[1]) { */ $s = 9; continue; case 6: - y$2 = _ref$3.$val; - z$1.Not(big.NewInt(new $Int64(y$2.$high, y$2.$low))); - /* } else if ($assertType(_ref$3, intVal, true)[1]) { */ $s = 9; continue; case 7: - y$2 = _ref$3.$val; - z$1.Not(y$2.val); - /* } else { */ $s = 9; continue; case 8: - y$2 = _ref$3; - /* goto Error */ $s = 1; continue; - /* } */ case 9: - if (size >= 0) { - s = (x = (size >>> 0), (((x >>> 16 << 16) * 8 >>> 0) + (x << 16 >>> 16) * 8) >>> 0); - z$1.AndNot(z$1, new big.Int.Ptr().Lsh(big.NewInt(new $Int64(-1, 4294967295)), s)); + if (c === 125) { + s.popParseState(); + return 5; } - return normInt(z$1); - /* } else if (_ref === 43) { */ $s = 5; continue; case 4: - _ref$4 = y; - if ($assertType(_ref$4, unknownVal, true)[1]) { - y$3 = _ref$4.$val; - return new y$3.constructor.Struct(y$3); - } else if ($assertType(_ref$4, boolVal, true)[1]) { - y$3 = _ref$4.$val; - return new boolVal(!y$3); + return s.error(c, "after object key:value pair"); + } else if (_ref === 2) { + if (c === 44) { + s.step = stateBeginValue; + return 7; } - /* } */ case 5: - /* Error: */ case 1: - $panic(new $String(fmt.Sprintf("invalid unary operation %s%v", new ($sliceType($emptyInterface))([new token.Token(op), y])))); - /* */ case -1: } return; } + if (c === 93) { + s.popParseState(); + return 8; + } + return s.error(c, "after array element"); + } + return s.error(c, ""); }; - ord = function(x) { + stateEndTop = function(s, c) { + if (!((c === 32)) && !((c === 9)) && !((c === 13)) && !((c === 10))) { + s.error(c, "after top-level value"); + } + return 10; + }; + stateInString = function(s, c) { + if (c === 34) { + s.step = stateEndValue; + return 0; + } + if (c === 92) { + s.step = stateInStringEsc; + return 0; + } + if (c < 32) { + return s.error(c, "in string literal"); + } + return 0; + }; + stateInStringEsc = function(s, c) { var _ref; - _ref = x; - if ($assertType(_ref, int64Val, true)[1]) { - return 1; - } else if ($assertType(_ref, intVal, true)[1]) { - return 2; - } else if ($assertType(_ref, floatVal, true)[1]) { - return 3; - } else if ($assertType(_ref, complexVal, true)[1]) { - return 4; - } else { + _ref = c; + if (_ref === 98 || _ref === 102 || _ref === 110 || _ref === 114 || _ref === 116 || _ref === 92 || _ref === 47 || _ref === 34) { + s.step = stateInString; + return 0; + } + if (c === 117) { + s.step = stateInStringEscU; return 0; } + return s.error(c, "in string escape code"); }; - match = function(x, y) { - var result = $ifaceNil, result$1 = $ifaceNil, _tuple, _tmp, _tmp$1, x$1, _ref, _tmp$2, _tmp$3, _tmp$4, _tmp$5, y$1, _ref$1, _tmp$6, _tmp$7, _tmp$8, x$2, _tmp$9, _tmp$10, x$3, _tmp$11, _tmp$12, x$4, _tmp$13, y$2, _ref$2, _tmp$14, _tmp$15, _tmp$16, x$5, _tmp$17, _tmp$18, x$6, _tmp$19, y$3, _ref$3, _tmp$20, _tmp$21, _tmp$22, x$7, _tmp$23; - if (ord(x) > ord(y)) { - _tuple = match(y, x); y = _tuple[0]; x = _tuple[1]; - _tmp = x; _tmp$1 = y; result = _tmp; result$1 = _tmp$1; - return [result, result$1]; + stateInStringEscU = function(s, c) { + if (48 <= c && c <= 57 || 97 <= c && c <= 102 || 65 <= c && c <= 70) { + s.step = stateInStringEscU1; + return 0; } - _ref = x; - if ($assertType(_ref, unknownVal, true)[1]) { - x$1 = _ref.$val; - _tmp$2 = new x$1.constructor.Struct(x$1); _tmp$3 = new x$1.constructor.Struct(x$1); result = _tmp$2; result$1 = _tmp$3; - return [result, result$1]; - } else if ($assertType(_ref, boolVal, true)[1] || $assertType(_ref, stringVal, true)[1] || $assertType(_ref, complexVal, true)[1]) { - x$1 = _ref; - _tmp$4 = x$1; _tmp$5 = y; result = _tmp$4; result$1 = _tmp$5; - return [result, result$1]; - } else if ($assertType(_ref, int64Val, true)[1]) { - x$1 = _ref.$val; - _ref$1 = y; - if ($assertType(_ref$1, int64Val, true)[1]) { - y$1 = _ref$1.$val; - _tmp$6 = x$1; _tmp$7 = y$1; result = _tmp$6; result$1 = _tmp$7; - return [result, result$1]; - } else if ($assertType(_ref$1, intVal, true)[1]) { - y$1 = _ref$1.$val; - _tmp$8 = (x$2 = new intVal.Ptr(big.NewInt(new $Int64(x$1.$high, x$1.$low))), new x$2.constructor.Struct(x$2)); _tmp$9 = new y$1.constructor.Struct(y$1); result = _tmp$8; result$1 = _tmp$9; - return [result, result$1]; - } else if ($assertType(_ref$1, floatVal, true)[1]) { - y$1 = _ref$1.$val; - _tmp$10 = (x$3 = new floatVal.Ptr(big.NewRat(new $Int64(x$1.$high, x$1.$low), new $Int64(0, 1))), new x$3.constructor.Struct(x$3)); _tmp$11 = new y$1.constructor.Struct(y$1); result = _tmp$10; result$1 = _tmp$11; - return [result, result$1]; - } else if ($assertType(_ref$1, complexVal, true)[1]) { - y$1 = _ref$1.$val; - _tmp$12 = (x$4 = new complexVal.Ptr(big.NewRat(new $Int64(x$1.$high, x$1.$low), new $Int64(0, 1)), rat0), new x$4.constructor.Struct(x$4)); _tmp$13 = new y$1.constructor.Struct(y$1); result = _tmp$12; result$1 = _tmp$13; - return [result, result$1]; - } - } else if ($assertType(_ref, intVal, true)[1]) { - x$1 = _ref.$val; - _ref$2 = y; - if ($assertType(_ref$2, intVal, true)[1]) { - y$2 = _ref$2.$val; - _tmp$14 = new x$1.constructor.Struct(x$1); _tmp$15 = new y$2.constructor.Struct(y$2); result = _tmp$14; result$1 = _tmp$15; - return [result, result$1]; - } else if ($assertType(_ref$2, floatVal, true)[1]) { - y$2 = _ref$2.$val; - _tmp$16 = (x$5 = new floatVal.Ptr(new big.Rat.Ptr().SetFrac(x$1.val, int1)), new x$5.constructor.Struct(x$5)); _tmp$17 = new y$2.constructor.Struct(y$2); result = _tmp$16; result$1 = _tmp$17; - return [result, result$1]; - } else if ($assertType(_ref$2, complexVal, true)[1]) { - y$2 = _ref$2.$val; - _tmp$18 = (x$6 = new complexVal.Ptr(new big.Rat.Ptr().SetFrac(x$1.val, int1), rat0), new x$6.constructor.Struct(x$6)); _tmp$19 = new y$2.constructor.Struct(y$2); result = _tmp$18; result$1 = _tmp$19; - return [result, result$1]; - } - } else if ($assertType(_ref, floatVal, true)[1]) { - x$1 = _ref.$val; - _ref$3 = y; - if ($assertType(_ref$3, floatVal, true)[1]) { - y$3 = _ref$3.$val; - _tmp$20 = new x$1.constructor.Struct(x$1); _tmp$21 = new y$3.constructor.Struct(y$3); result = _tmp$20; result$1 = _tmp$21; - return [result, result$1]; - } else if ($assertType(_ref$3, complexVal, true)[1]) { - y$3 = _ref$3.$val; - _tmp$22 = (x$7 = new complexVal.Ptr(x$1.val, rat0), new x$7.constructor.Struct(x$7)); _tmp$23 = new y$3.constructor.Struct(y$3); result = _tmp$22; result$1 = _tmp$23; - return [result, result$1]; - } + return s.error(c, "in \\u hexadecimal character escape"); + }; + stateInStringEscU1 = function(s, c) { + if (48 <= c && c <= 57 || 97 <= c && c <= 102 || 65 <= c && c <= 70) { + s.step = stateInStringEscU12; + return 0; } - $panic(new $String("unreachable")); + return s.error(c, "in \\u hexadecimal character escape"); }; - BinaryOp = $pkg.BinaryOp = function(x, op, y) { - var $this = this, $args = arguments, $s = 0, _tuple, x$1, _ref, y$1, _ref$1, a, x$2, b, c, _ref$2, a$1, b$1, c$1, _ref$3, a$2, b$2, c$2, _ref$4, y$2, _tmp, _tmp$1, a$3, b$3, _tmp$2, _tmp$3, c$3, d, _tmp$4, _tmp$5, re, im, _ref$5, _tmp$6, _tmp$7, _tmp$8, _tmp$9, ac, bd, bc, ad, _tmp$10, _tmp$11, _tmp$12, _tmp$13, _tmp$14, _tmp$15, _tmp$16, ac$1, bd$1, bc$1, ad$1, s, cc, dd; - /* */ while (true) { switch ($s) { case 0: - _tuple = match(x, y); x = _tuple[0]; y = _tuple[1]; - _ref = x; - /* if ($assertType(_ref, unknownVal, true)[1]) { */ if ($assertType(_ref, unknownVal, true)[1]) {} else if ($assertType(_ref, boolVal, true)[1]) { $s = 2; continue; } else if ($assertType(_ref, int64Val, true)[1]) { $s = 3; continue; } else if ($assertType(_ref, intVal, true)[1]) { $s = 4; continue; } else if ($assertType(_ref, floatVal, true)[1]) { $s = 5; continue; } else if ($assertType(_ref, complexVal, true)[1]) { $s = 6; continue; } else if ($assertType(_ref, stringVal, true)[1]) { $s = 7; continue; } else { $s = 8; continue; } - x$1 = _ref.$val; - return new x$1.constructor.Struct(x$1); - /* } else if ($assertType(_ref, boolVal, true)[1]) { */ $s = 8; continue; case 2: - x$1 = _ref.$val; - y$1 = $assertType(y, boolVal); - _ref$1 = op; - if (_ref$1 === 34) { - return new boolVal(x$1 && y$1); - } else if (_ref$1 === 35) { - return new boolVal(x$1 || y$1); - } - /* } else if ($assertType(_ref, int64Val, true)[1]) { */ $s = 8; continue; case 3: - x$1 = _ref.$val; - a = new $Int64(x$1.$high, x$1.$low); - b = (x$2 = $assertType(y, int64Val), new $Int64(x$2.$high, x$2.$low)); - c = new $Int64(0, 0); - _ref$2 = op; - /* if (_ref$2 === 12) { */ if (_ref$2 === 12) {} else if (_ref$2 === 13) { $s = 9; continue; } else if (_ref$2 === 14) { $s = 10; continue; } else if (_ref$2 === 15) { $s = 11; continue; } else if (_ref$2 === 26) { $s = 12; continue; } else if (_ref$2 === 16) { $s = 13; continue; } else if (_ref$2 === 17) { $s = 14; continue; } else if (_ref$2 === 18) { $s = 15; continue; } else if (_ref$2 === 19) { $s = 16; continue; } else if (_ref$2 === 22) { $s = 17; continue; } else { $s = 18; continue; } - if (!is63bit(a) || !is63bit(b)) { - return normInt(new big.Int.Ptr().Add(big.NewInt(a), big.NewInt(b))); - } - c = new $Int64(a.$high + b.$high, a.$low + b.$low); - /* } else if (_ref$2 === 13) { */ $s = 19; continue; case 9: - if (!is63bit(a) || !is63bit(b)) { - return normInt(new big.Int.Ptr().Sub(big.NewInt(a), big.NewInt(b))); - } - c = new $Int64(a.$high - b.$high, a.$low - b.$low); - /* } else if (_ref$2 === 14) { */ $s = 19; continue; case 10: - if (!is32bit(a) || !is32bit(b)) { - return normInt(new big.Int.Ptr().Mul(big.NewInt(a), big.NewInt(b))); - } - c = $mul64(a, b); - /* } else if (_ref$2 === 15) { */ $s = 19; continue; case 11: - return normFloat(new big.Rat.Ptr().SetFrac(big.NewInt(a), big.NewInt(b))); - /* } else if (_ref$2 === 26) { */ $s = 19; continue; case 12: - c = $div64(a, b, false); - /* } else if (_ref$2 === 16) { */ $s = 19; continue; case 13: - c = $div64(a, b, true); - /* } else if (_ref$2 === 17) { */ $s = 19; continue; case 14: - c = new $Int64(a.$high & b.$high, (a.$low & b.$low) >>> 0); - /* } else if (_ref$2 === 18) { */ $s = 19; continue; case 15: - c = new $Int64(a.$high | b.$high, (a.$low | b.$low) >>> 0); - /* } else if (_ref$2 === 19) { */ $s = 19; continue; case 16: - c = new $Int64(a.$high ^ b.$high, (a.$low ^ b.$low) >>> 0); - /* } else if (_ref$2 === 22) { */ $s = 19; continue; case 17: - c = new $Int64(a.$high &~ b.$high, (a.$low &~ b.$low) >>> 0); - /* } else { */ $s = 19; continue; case 18: - /* goto Error */ $s = 1; continue; - /* } */ case 19: - return new int64Val(c.$high, c.$low); - /* } else if ($assertType(_ref, intVal, true)[1]) { */ $s = 8; continue; case 4: - x$1 = _ref.$val; - a$1 = x$1.val; - b$1 = $assertType(y, intVal).val; - c$1 = new big.Int.Ptr(); $copy(c$1, new big.Int.Ptr(), big.Int); - _ref$3 = op; - /* if (_ref$3 === 12) { */ if (_ref$3 === 12) {} else if (_ref$3 === 13) { $s = 20; continue; } else if (_ref$3 === 14) { $s = 21; continue; } else if (_ref$3 === 15) { $s = 22; continue; } else if (_ref$3 === 26) { $s = 23; continue; } else if (_ref$3 === 16) { $s = 24; continue; } else if (_ref$3 === 17) { $s = 25; continue; } else if (_ref$3 === 18) { $s = 26; continue; } else if (_ref$3 === 19) { $s = 27; continue; } else if (_ref$3 === 22) { $s = 28; continue; } else { $s = 29; continue; } - c$1.Add(a$1, b$1); - /* } else if (_ref$3 === 13) { */ $s = 30; continue; case 20: - c$1.Sub(a$1, b$1); - /* } else if (_ref$3 === 14) { */ $s = 30; continue; case 21: - c$1.Mul(a$1, b$1); - /* } else if (_ref$3 === 15) { */ $s = 30; continue; case 22: - return normFloat(new big.Rat.Ptr().SetFrac(a$1, b$1)); - /* } else if (_ref$3 === 26) { */ $s = 30; continue; case 23: - c$1.Quo(a$1, b$1); - /* } else if (_ref$3 === 16) { */ $s = 30; continue; case 24: - c$1.Rem(a$1, b$1); - /* } else if (_ref$3 === 17) { */ $s = 30; continue; case 25: - c$1.And(a$1, b$1); - /* } else if (_ref$3 === 18) { */ $s = 30; continue; case 26: - c$1.Or(a$1, b$1); - /* } else if (_ref$3 === 19) { */ $s = 30; continue; case 27: - c$1.Xor(a$1, b$1); - /* } else if (_ref$3 === 22) { */ $s = 30; continue; case 28: - c$1.AndNot(a$1, b$1); - /* } else { */ $s = 30; continue; case 29: - /* goto Error */ $s = 1; continue; - /* } */ case 30: - return normInt(c$1); - /* } else if ($assertType(_ref, floatVal, true)[1]) { */ $s = 8; continue; case 5: - x$1 = _ref.$val; - a$2 = x$1.val; - b$2 = $assertType(y, floatVal).val; - c$2 = new big.Rat.Ptr(); $copy(c$2, new big.Rat.Ptr(), big.Rat); - _ref$4 = op; - /* if (_ref$4 === 12) { */ if (_ref$4 === 12) {} else if (_ref$4 === 13) { $s = 31; continue; } else if (_ref$4 === 14) { $s = 32; continue; } else if (_ref$4 === 15) { $s = 33; continue; } else { $s = 34; continue; } - c$2.Add(a$2, b$2); - /* } else if (_ref$4 === 13) { */ $s = 35; continue; case 31: - c$2.Sub(a$2, b$2); - /* } else if (_ref$4 === 14) { */ $s = 35; continue; case 32: - c$2.Mul(a$2, b$2); - /* } else if (_ref$4 === 15) { */ $s = 35; continue; case 33: - c$2.Quo(a$2, b$2); - /* } else { */ $s = 35; continue; case 34: - /* goto Error */ $s = 1; continue; - /* } */ case 35: - return normFloat(c$2); - /* } else if ($assertType(_ref, complexVal, true)[1]) { */ $s = 8; continue; case 6: - x$1 = _ref.$val; - y$2 = new complexVal.Ptr(); $copy(y$2, $assertType(y, complexVal), complexVal); - _tmp = x$1.re; _tmp$1 = x$1.im; a$3 = _tmp; b$3 = _tmp$1; - _tmp$2 = y$2.re; _tmp$3 = y$2.im; c$3 = _tmp$2; d = _tmp$3; - _tmp$4 = new big.Rat.Ptr(); $copy(_tmp$4, new big.Rat.Ptr(), big.Rat); _tmp$5 = new big.Rat.Ptr(); $copy(_tmp$5, new big.Rat.Ptr(), big.Rat); re = new big.Rat.Ptr(); $copy(re, _tmp$4, big.Rat); im = new big.Rat.Ptr(); $copy(im, _tmp$5, big.Rat); - _ref$5 = op; - /* if (_ref$5 === 12) { */ if (_ref$5 === 12) {} else if (_ref$5 === 13) { $s = 36; continue; } else if (_ref$5 === 14) { $s = 37; continue; } else if (_ref$5 === 15) { $s = 38; continue; } else { $s = 39; continue; } - re.Add(a$3, c$3); - im.Add(b$3, d); - /* } else if (_ref$5 === 13) { */ $s = 40; continue; case 36: - re.Sub(a$3, c$3); - im.Sub(b$3, d); - /* } else if (_ref$5 === 14) { */ $s = 40; continue; case 37: - _tmp$6 = new big.Rat.Ptr(); $copy(_tmp$6, new big.Rat.Ptr(), big.Rat); _tmp$7 = new big.Rat.Ptr(); $copy(_tmp$7, new big.Rat.Ptr(), big.Rat); _tmp$8 = new big.Rat.Ptr(); $copy(_tmp$8, new big.Rat.Ptr(), big.Rat); _tmp$9 = new big.Rat.Ptr(); $copy(_tmp$9, new big.Rat.Ptr(), big.Rat); ac = new big.Rat.Ptr(); $copy(ac, _tmp$6, big.Rat); bd = new big.Rat.Ptr(); $copy(bd, _tmp$7, big.Rat); bc = new big.Rat.Ptr(); $copy(bc, _tmp$8, big.Rat); ad = new big.Rat.Ptr(); $copy(ad, _tmp$9, big.Rat); - ac.Mul(a$3, c$3); - bd.Mul(b$3, d); - bc.Mul(b$3, c$3); - ad.Mul(a$3, d); - re.Sub(ac, bd); - im.Add(bc, ad); - /* } else if (_ref$5 === 15) { */ $s = 40; continue; case 38: - _tmp$10 = new big.Rat.Ptr(); $copy(_tmp$10, new big.Rat.Ptr(), big.Rat); _tmp$11 = new big.Rat.Ptr(); $copy(_tmp$11, new big.Rat.Ptr(), big.Rat); _tmp$12 = new big.Rat.Ptr(); $copy(_tmp$12, new big.Rat.Ptr(), big.Rat); _tmp$13 = new big.Rat.Ptr(); $copy(_tmp$13, new big.Rat.Ptr(), big.Rat); _tmp$14 = new big.Rat.Ptr(); $copy(_tmp$14, new big.Rat.Ptr(), big.Rat); _tmp$15 = new big.Rat.Ptr(); $copy(_tmp$15, new big.Rat.Ptr(), big.Rat); _tmp$16 = new big.Rat.Ptr(); $copy(_tmp$16, new big.Rat.Ptr(), big.Rat); ac$1 = new big.Rat.Ptr(); $copy(ac$1, _tmp$10, big.Rat); bd$1 = new big.Rat.Ptr(); $copy(bd$1, _tmp$11, big.Rat); bc$1 = new big.Rat.Ptr(); $copy(bc$1, _tmp$12, big.Rat); ad$1 = new big.Rat.Ptr(); $copy(ad$1, _tmp$13, big.Rat); s = new big.Rat.Ptr(); $copy(s, _tmp$14, big.Rat); cc = new big.Rat.Ptr(); $copy(cc, _tmp$15, big.Rat); dd = new big.Rat.Ptr(); $copy(dd, _tmp$16, big.Rat); - ac$1.Mul(a$3, c$3); - bd$1.Mul(b$3, d); - bc$1.Mul(b$3, c$3); - ad$1.Mul(a$3, d); - cc.Mul(c$3, c$3); - dd.Mul(d, d); - s.Add(cc, dd); - re.Add(ac$1, bd$1); - re.Quo(re, s); - im.Sub(bc$1, ad$1); - im.Quo(im, s); - /* } else { */ $s = 40; continue; case 39: - /* goto Error */ $s = 1; continue; - /* } */ case 40: - return normComplex(re, im); - /* } else if ($assertType(_ref, stringVal, true)[1]) { */ $s = 8; continue; case 7: - x$1 = _ref.$val; - if (op === 12) { - return new stringVal(x$1 + $assertType(y, stringVal)); - } - /* } */ case 8: - /* Error: */ case 1: - $panic(new $String(fmt.Sprintf("invalid binary operation %v %s %v", new ($sliceType($emptyInterface))([x, new token.Token(op), y])))); - /* */ case -1: } return; } + stateInStringEscU12 = function(s, c) { + if (48 <= c && c <= 57 || 97 <= c && c <= 102 || 65 <= c && c <= 70) { + s.step = stateInStringEscU123; + return 0; + } + return s.error(c, "in \\u hexadecimal character escape"); }; - Shift = $pkg.Shift = function(x, op, s) { - var x$1, _ref, _ref$1, z, z$1, _ref$2; - _ref = x; - if ($assertType(_ref, unknownVal, true)[1]) { - x$1 = _ref.$val; - return new x$1.constructor.Struct(x$1); - } else if ($assertType(_ref, int64Val, true)[1]) { - x$1 = _ref.$val; - if (s === 0) { - return x$1; - } - _ref$1 = op; - if (_ref$1 === 20) { - z = big.NewInt(new $Int64(x$1.$high, x$1.$low)); - return normInt(z.Lsh(z, s)); - } else if (_ref$1 === 21) { - return $shiftRightInt64(x$1, s); - } - } else if ($assertType(_ref, intVal, true)[1]) { - x$1 = _ref.$val; - if (s === 0) { - return new x$1.constructor.Struct(x$1); - } - z$1 = new big.Int.Ptr(); $copy(z$1, new big.Int.Ptr(), big.Int); - _ref$2 = op; - if (_ref$2 === 20) { - return normInt(z$1.Lsh(x$1.val, s)); - } else if (_ref$2 === 21) { - return normInt(z$1.Rsh(x$1.val, s)); - } + stateInStringEscU123 = function(s, c) { + if (48 <= c && c <= 57 || 97 <= c && c <= 102 || 65 <= c && c <= 70) { + s.step = stateInString; + return 0; } - $panic(new $String(fmt.Sprintf("invalid shift %v %s %d", new ($sliceType($emptyInterface))([x, new token.Token(op), new $Uint(s)])))); + return s.error(c, "in \\u hexadecimal character escape"); }; - cmpZero = function(x, op) { - var _ref; - _ref = op; - if (_ref === 39) { - return x === 0; - } else if (_ref === 44) { - return !((x === 0)); - } else if (_ref === 40) { - return x < 0; - } else if (_ref === 45) { - return x <= 0; - } else if (_ref === 41) { - return x > 0; - } else if (_ref === 46) { - return x >= 0; + stateNeg = function(s, c) { + if (c === 48) { + s.step = state0; + return 0; } - $panic(new $String("unreachable")); + if (49 <= c && c <= 57) { + s.step = state1; + return 0; + } + return s.error(c, "in numeric literal"); }; - Compare = $pkg.Compare = function(x, op, y) { - var _tuple, x$1, _ref, y$1, _ref$1, y$2, _ref$2, y$3, re, im, _ref$3, y$4, _ref$4; - _tuple = match(x, y); x = _tuple[0]; y = _tuple[1]; - _ref = x; - if ($assertType(_ref, unknownVal, true)[1]) { - x$1 = _ref.$val; - return false; - } else if ($assertType(_ref, boolVal, true)[1]) { - x$1 = _ref.$val; - y$1 = $assertType(y, boolVal); - _ref$1 = op; - if (_ref$1 === 39) { - return x$1 === y$1; - } else if (_ref$1 === 44) { - return !(x$1 === y$1); - } - } else if ($assertType(_ref, int64Val, true)[1]) { - x$1 = _ref.$val; - y$2 = $assertType(y, int64Val); - _ref$2 = op; - if (_ref$2 === 39) { - return (x$1.$high === y$2.$high && x$1.$low === y$2.$low); - } else if (_ref$2 === 44) { - return !((x$1.$high === y$2.$high && x$1.$low === y$2.$low)); - } else if (_ref$2 === 40) { - return (x$1.$high < y$2.$high || (x$1.$high === y$2.$high && x$1.$low < y$2.$low)); - } else if (_ref$2 === 45) { - return (x$1.$high < y$2.$high || (x$1.$high === y$2.$high && x$1.$low <= y$2.$low)); - } else if (_ref$2 === 41) { - return (x$1.$high > y$2.$high || (x$1.$high === y$2.$high && x$1.$low > y$2.$low)); - } else if (_ref$2 === 46) { - return (x$1.$high > y$2.$high || (x$1.$high === y$2.$high && x$1.$low >= y$2.$low)); - } - } else if ($assertType(_ref, intVal, true)[1]) { - x$1 = _ref.$val; - return cmpZero(x$1.val.Cmp($assertType(y, intVal).val), op); - } else if ($assertType(_ref, floatVal, true)[1]) { - x$1 = _ref.$val; - return cmpZero(x$1.val.Cmp($assertType(y, floatVal).val), op); - } else if ($assertType(_ref, complexVal, true)[1]) { - x$1 = _ref.$val; - y$3 = new complexVal.Ptr(); $copy(y$3, $assertType(y, complexVal), complexVal); - re = x$1.re.Cmp(y$3.re); - im = x$1.im.Cmp(y$3.im); - _ref$3 = op; - if (_ref$3 === 39) { - return (re === 0) && (im === 0); - } else if (_ref$3 === 44) { - return !((re === 0)) || !((im === 0)); - } - } else if ($assertType(_ref, stringVal, true)[1]) { - x$1 = _ref.$val; - y$4 = $assertType(y, stringVal); - _ref$4 = op; - if (_ref$4 === 39) { - return x$1 === y$4; - } else if (_ref$4 === 44) { - return !(x$1 === y$4); - } else if (_ref$4 === 40) { - return x$1 < y$4; - } else if (_ref$4 === 45) { - return x$1 <= y$4; - } else if (_ref$4 === 41) { - return x$1 > y$4; - } else if (_ref$4 === 46) { - return x$1 >= y$4; - } + state1 = function(s, c) { + if (48 <= c && c <= 57) { + s.step = state1; + return 0; } - $panic(new $String(fmt.Sprintf("invalid comparison %v %s %v", new ($sliceType($emptyInterface))([x, new token.Token(op), y])))); + return state0(s, c); }; - ratToFloat32 = function(x) { - var _tuple, x64, exact, x32; - _tuple = x.Float64(); x64 = _tuple[0]; exact = _tuple[1]; - x32 = x64; - if (math.IsInf($coerceFloat32(x32), 0)) { - exact = false; + state0 = function(s, c) { + if (c === 46) { + s.step = stateDot; + return 0; } - return [x32, exact]; + if ((c === 101) || (c === 69)) { + s.step = stateE; + return 0; + } + return stateEndValue(s, c); }; - $pkg.$init = function() { - Value.init([["Kind", "Kind", "", $funcType([], [Kind], false)], ["String", "String", "", $funcType([], [$String], false)], ["implementsValue", "implementsValue", "code.google.com/p/go.tools/go/exact", $funcType([], [], false)]]); - unknownVal.methods = [["Kind", "Kind", "", $funcType([], [Kind], false), -1], ["String", "String", "", $funcType([], [$String], false), -1], ["implementsValue", "implementsValue", "code.google.com/p/go.tools/go/exact", $funcType([], [], false), -1]]; - ($ptrType(unknownVal)).methods = [["Kind", "Kind", "", $funcType([], [Kind], false), -1], ["String", "String", "", $funcType([], [$String], false), -1], ["implementsValue", "implementsValue", "code.google.com/p/go.tools/go/exact", $funcType([], [], false), -1]]; - unknownVal.init([]); - boolVal.methods = [["Kind", "Kind", "", $funcType([], [Kind], false), -1], ["String", "String", "", $funcType([], [$String], false), -1], ["implementsValue", "implementsValue", "code.google.com/p/go.tools/go/exact", $funcType([], [], false), -1]]; - ($ptrType(boolVal)).methods = [["Kind", "Kind", "", $funcType([], [Kind], false), -1], ["String", "String", "", $funcType([], [$String], false), -1], ["implementsValue", "implementsValue", "code.google.com/p/go.tools/go/exact", $funcType([], [], false), -1]]; - stringVal.methods = [["Kind", "Kind", "", $funcType([], [Kind], false), -1], ["String", "String", "", $funcType([], [$String], false), -1], ["implementsValue", "implementsValue", "code.google.com/p/go.tools/go/exact", $funcType([], [], false), -1]]; - ($ptrType(stringVal)).methods = [["Kind", "Kind", "", $funcType([], [Kind], false), -1], ["String", "String", "", $funcType([], [$String], false), -1], ["implementsValue", "implementsValue", "code.google.com/p/go.tools/go/exact", $funcType([], [], false), -1]]; - int64Val.methods = [["Kind", "Kind", "", $funcType([], [Kind], false), -1], ["String", "String", "", $funcType([], [$String], false), -1], ["implementsValue", "implementsValue", "code.google.com/p/go.tools/go/exact", $funcType([], [], false), -1]]; - ($ptrType(int64Val)).methods = [["Kind", "Kind", "", $funcType([], [Kind], false), -1], ["String", "String", "", $funcType([], [$String], false), -1], ["implementsValue", "implementsValue", "code.google.com/p/go.tools/go/exact", $funcType([], [], false), -1]]; - intVal.methods = [["Kind", "Kind", "", $funcType([], [Kind], false), -1], ["String", "String", "", $funcType([], [$String], false), -1], ["implementsValue", "implementsValue", "code.google.com/p/go.tools/go/exact", $funcType([], [], false), -1]]; - ($ptrType(intVal)).methods = [["Kind", "Kind", "", $funcType([], [Kind], false), -1], ["String", "String", "", $funcType([], [$String], false), -1], ["implementsValue", "implementsValue", "code.google.com/p/go.tools/go/exact", $funcType([], [], false), -1]]; - intVal.init([["val", "val", "code.google.com/p/go.tools/go/exact", ($ptrType(big.Int)), ""]]); - floatVal.methods = [["Kind", "Kind", "", $funcType([], [Kind], false), -1], ["String", "String", "", $funcType([], [$String], false), -1], ["implementsValue", "implementsValue", "code.google.com/p/go.tools/go/exact", $funcType([], [], false), -1]]; - ($ptrType(floatVal)).methods = [["Kind", "Kind", "", $funcType([], [Kind], false), -1], ["String", "String", "", $funcType([], [$String], false), -1], ["implementsValue", "implementsValue", "code.google.com/p/go.tools/go/exact", $funcType([], [], false), -1]]; - floatVal.init([["val", "val", "code.google.com/p/go.tools/go/exact", ($ptrType(big.Rat)), ""]]); - complexVal.methods = [["Kind", "Kind", "", $funcType([], [Kind], false), -1], ["String", "String", "", $funcType([], [$String], false), -1], ["implementsValue", "implementsValue", "code.google.com/p/go.tools/go/exact", $funcType([], [], false), -1]]; - ($ptrType(complexVal)).methods = [["Kind", "Kind", "", $funcType([], [Kind], false), -1], ["String", "String", "", $funcType([], [$String], false), -1], ["implementsValue", "implementsValue", "code.google.com/p/go.tools/go/exact", $funcType([], [], false), -1]]; - complexVal.init([["re", "re", "code.google.com/p/go.tools/go/exact", ($ptrType(big.Rat)), ""], ["im", "im", "code.google.com/p/go.tools/go/exact", ($ptrType(big.Rat)), ""]]); - minInt64 = big.NewInt(new $Int64(-2147483648, 0)); - maxInt64 = big.NewInt(new $Int64(2147483647, 4294967295)); - int1 = big.NewInt(new $Int64(0, 1)); - rat0 = big.NewRat(new $Int64(0, 0), new $Int64(0, 1)); + stateDot = function(s, c) { + if (48 <= c && c <= 57) { + s.step = stateDot0; + return 0; + } + return s.error(c, "after decimal point in numeric literal"); }; - return $pkg; -})(); -$packages["container/heap"] = (function() { - var $pkg = {}, sort = $packages["sort"], Init, Pop, Fix, up, down; - Init = $pkg.Init = function(h) { - var n, _q, i; - n = h.Len(); - i = (_q = n / 2, (_q === _q && _q !== 1/0 && _q !== -1/0) ? _q >> 0 : $throwRuntimeError("integer divide by zero")) - 1 >> 0; - while (i >= 0) { - down(h, i, n); - i = i - (1) >> 0; + stateDot0 = function(s, c) { + if (48 <= c && c <= 57) { + s.step = stateDot0; + return 0; + } + if ((c === 101) || (c === 69)) { + s.step = stateE; + return 0; } + return stateEndValue(s, c); }; - Pop = $pkg.Pop = function(h) { - var n; - n = h.Len() - 1 >> 0; - h.Swap(0, n); - down(h, 0, n); - return h.Pop(); + stateE = function(s, c) { + if (c === 43) { + s.step = stateESign; + return 0; + } + if (c === 45) { + s.step = stateESign; + return 0; + } + return stateESign(s, c); }; - Fix = $pkg.Fix = function(h, i) { - down(h, i, h.Len()); - up(h, i); + stateESign = function(s, c) { + if (48 <= c && c <= 57) { + s.step = stateE0; + return 0; + } + return s.error(c, "in exponent of numeric literal"); }; - up = function(h, j) { - var _q, i; - while (true) { - i = (_q = ((j - 1 >> 0)) / 2, (_q === _q && _q !== 1/0 && _q !== -1/0) ? _q >> 0 : $throwRuntimeError("integer divide by zero")); - if ((i === j) || !h.Less(j, i)) { - break; - } - h.Swap(i, j); - j = i; + stateE0 = function(s, c) { + if (48 <= c && c <= 57) { + s.step = stateE0; + return 0; } + return stateEndValue(s, c); }; - down = function(h, i, n) { - var j1, j, j2; - while (true) { - j1 = ((((2 >>> 16 << 16) * i >> 0) + (2 << 16 >>> 16) * i) >> 0) + 1 >> 0; - if (j1 >= n || j1 < 0) { - break; - } - j = j1; - j2 = j1 + 1 >> 0; - if (j2 < n && !h.Less(j1, j2)) { - j = j2; - } - if (!h.Less(j, i)) { - break; - } - h.Swap(i, j); - i = j; + stateT = function(s, c) { + if (c === 114) { + s.step = stateTr; + return 0; } + return s.error(c, "in literal true (expecting 'r')"); }; - $pkg.$init = function() { + stateTr = function(s, c) { + if (c === 117) { + s.step = stateTru; + return 0; + } + return s.error(c, "in literal true (expecting 'u')"); }; - return $pkg; -})(); -$packages["path/filepath"] = (function() { - var $pkg = {}, errors = $packages["errors"], os = $packages["os"], runtime = $packages["runtime"], sort = $packages["sort"], strings = $packages["strings"], utf8 = $packages["unicode/utf8"], bytes = $packages["bytes"], lazybuf, Clean, ToSlash, FromSlash, SplitList, Split, Join, EvalSymlinks, VolumeName, IsAbs, volumeNameLen, splitList, evalSymlinks; - lazybuf = $pkg.lazybuf = $newType(0, "Struct", "filepath.lazybuf", "lazybuf", "path/filepath", function(path_, buf_, w_, volAndPath_, volLen_) { - this.$val = this; - this.path = path_ !== undefined ? path_ : ""; - this.buf = buf_ !== undefined ? buf_ : ($sliceType($Uint8)).nil; - this.w = w_ !== undefined ? w_ : 0; - this.volAndPath = volAndPath_ !== undefined ? volAndPath_ : ""; - this.volLen = volLen_ !== undefined ? volLen_ : 0; - }); - lazybuf.Ptr.prototype.index = function(i) { - var b, x; - b = this; - if (!(b.buf === ($sliceType($Uint8)).nil)) { - return (x = b.buf, ((i < 0 || i >= x.$length) ? $throwRuntimeError("index out of range") : x.$array[x.$offset + i])); + stateTru = function(s, c) { + if (c === 101) { + s.step = stateEndValue; + return 0; } - return b.path.charCodeAt(i); + return s.error(c, "in literal true (expecting 'e')"); }; - lazybuf.prototype.index = function(i) { return this.$val.index(i); }; - lazybuf.Ptr.prototype.append = function(c) { - var b, x, x$1; - b = this; - if (b.buf === ($sliceType($Uint8)).nil) { - if (b.w < b.path.length && (b.path.charCodeAt(b.w) === c)) { - b.w = b.w + (1) >> 0; - return; - } - b.buf = ($sliceType($Uint8)).make(b.path.length); - $copyString(b.buf, b.path.substring(0, b.w)); + stateF = function(s, c) { + if (c === 97) { + s.step = stateFa; + return 0; } - (x = b.buf, x$1 = b.w, (x$1 < 0 || x$1 >= x.$length) ? $throwRuntimeError("index out of range") : x.$array[x.$offset + x$1] = c); - b.w = b.w + (1) >> 0; + return s.error(c, "in literal false (expecting 'a')"); }; - lazybuf.prototype.append = function(c) { return this.$val.append(c); }; - lazybuf.Ptr.prototype.string = function() { - var b; - b = this; - if (b.buf === ($sliceType($Uint8)).nil) { - return b.volAndPath.substring(0, (b.volLen + b.w >> 0)); + stateFa = function(s, c) { + if (c === 108) { + s.step = stateFal; + return 0; } - return b.volAndPath.substring(0, b.volLen) + $bytesToString($subslice(b.buf, 0, b.w)); + return s.error(c, "in literal false (expecting 'l')"); }; - lazybuf.prototype.string = function() { return this.$val.string(); }; - Clean = $pkg.Clean = function(path) { - var originalPath, volLen, rooted, n, out, _tmp, _tmp$1, r, dotdot, _tmp$2, _tmp$3; - originalPath = path; - volLen = volumeNameLen(path); - path = path.substring(volLen); - if (path === "") { - if (volLen > 1 && !((originalPath.charCodeAt(1) === 58))) { - return FromSlash(originalPath); - } - return originalPath + "."; + stateFal = function(s, c) { + if (c === 115) { + s.step = stateFals; + return 0; } - rooted = os.IsPathSeparator(path.charCodeAt(0)); - n = path.length; - out = new lazybuf.Ptr(path, ($sliceType($Uint8)).nil, 0, originalPath, volLen); - _tmp = 0; _tmp$1 = 0; r = _tmp; dotdot = _tmp$1; - if (rooted) { - out.append(47); - _tmp$2 = 1; _tmp$3 = 1; r = _tmp$2; dotdot = _tmp$3; + return s.error(c, "in literal false (expecting 's')"); + }; + stateFals = function(s, c) { + if (c === 101) { + s.step = stateEndValue; + return 0; } - while (r < n) { - if (os.IsPathSeparator(path.charCodeAt(r))) { - r = r + (1) >> 0; - } else if ((path.charCodeAt(r) === 46) && (((r + 1 >> 0) === n) || os.IsPathSeparator(path.charCodeAt((r + 1 >> 0))))) { - r = r + (1) >> 0; - } else if ((path.charCodeAt(r) === 46) && (path.charCodeAt((r + 1 >> 0)) === 46) && (((r + 2 >> 0) === n) || os.IsPathSeparator(path.charCodeAt((r + 2 >> 0))))) { - r = r + (2) >> 0; - if (out.w > dotdot) { - out.w = out.w - (1) >> 0; - while (out.w > dotdot && !os.IsPathSeparator(out.index(out.w))) { - out.w = out.w - (1) >> 0; - } - } else if (!rooted) { - if (out.w > 0) { - out.append(47); - } - out.append(46); - out.append(46); - dotdot = out.w; - } - } else { - if (rooted && !((out.w === 1)) || !rooted && !((out.w === 0))) { - out.append(47); - } - while (r < n && !os.IsPathSeparator(path.charCodeAt(r))) { - out.append(path.charCodeAt(r)); - r = r + (1) >> 0; - } - } + return s.error(c, "in literal false (expecting 'e')"); + }; + stateN = function(s, c) { + if (c === 117) { + s.step = stateNu; + return 0; } - if (out.w === 0) { - out.append(46); + return s.error(c, "in literal null (expecting 'u')"); + }; + stateNu = function(s, c) { + if (c === 108) { + s.step = stateNul; + return 0; } - return FromSlash(out.string()); + return s.error(c, "in literal null (expecting 'l')"); }; - ToSlash = $pkg.ToSlash = function(path) { - return path; - return strings.Replace(path, "/", "/", -1); + stateNul = function(s, c) { + if (c === 108) { + s.step = stateEndValue; + return 0; + } + return s.error(c, "in literal null (expecting 'l')"); }; - FromSlash = $pkg.FromSlash = function(path) { - return path; - return strings.Replace(path, "/", "/", -1); + stateError = function(s, c) { + return 11; }; - SplitList = $pkg.SplitList = function(path) { - return splitList(path); + scanner.Ptr.prototype.error = function(c, context) { + var s; + s = this; + s.step = stateError; + s.err = new SyntaxError.Ptr("invalid character " + quoteChar(c) + " " + context, s.bytes); + return 11; }; - Split = $pkg.Split = function(path) { - var dir = "", file = "", vol, i, _tmp, _tmp$1; - vol = VolumeName(path); - i = path.length - 1 >> 0; - while (i >= vol.length && !os.IsPathSeparator(path.charCodeAt(i))) { - i = i - (1) >> 0; + scanner.prototype.error = function(c, context) { return this.$val.error(c, context); }; + quoteChar = function(c) { + var s; + if (c === 39) { + return "'\\''"; } - _tmp = path.substring(0, (i + 1 >> 0)); _tmp$1 = path.substring((i + 1 >> 0)); dir = _tmp; file = _tmp$1; - return [dir, file]; + if (c === 34) { + return "'\"'"; + } + s = strconv.Quote($encodeRune(c)); + return "'" + s.substring(1, (s.length - 1 >> 0)) + "'"; }; - Join = $pkg.Join = function(elem) { - var _ref, _i, i, e; - _ref = elem; - _i = 0; - while (_i < _ref.$length) { - i = _i; - e = ((_i < 0 || _i >= _ref.$length) ? $throwRuntimeError("index out of range") : _ref.$array[_ref.$offset + _i]); - if (!(e === "")) { - return Clean(strings.Join($subslice(elem, i), "/")); - } - _i++; + scanner.Ptr.prototype.undo = function(scanCode) { + var s; + s = this; + if (s.redo) { + $panic(new $String("json: invalid use of scanner")); } - return ""; - }; - EvalSymlinks = $pkg.EvalSymlinks = function(path) { - return evalSymlinks(path); + s.redoCode = scanCode; + s.redoState = s.step; + s.step = stateRedo; + s.redo = true; }; - VolumeName = $pkg.VolumeName = function(path) { - var v = ""; - v = path.substring(0, volumeNameLen(path)); - return v; + scanner.prototype.undo = function(scanCode) { return this.$val.undo(scanCode); }; + stateRedo = function(s, c) { + s.redo = false; + s.step = s.redoState; + return s.redoCode; }; - IsAbs = $pkg.IsAbs = function(path) { - return strings.HasPrefix(path, "/"); + NewDecoder = $pkg.NewDecoder = function(r) { + return new Decoder.Ptr(r, ($sliceType($Uint8)).nil, new decodeState.Ptr(), new scanner.Ptr(), $ifaceNil); }; - volumeNameLen = function(path) { - return 0; + Decoder.Ptr.prototype.UseNumber = function() { + var dec; + dec = this; + dec.d.useNumber = true; }; - splitList = function(path) { - if (path === "") { - return new ($sliceType($String))([]); + Decoder.prototype.UseNumber = function() { return this.$val.UseNumber(); }; + Decoder.Ptr.prototype.Decode = function(v) { + var dec, _tuple, n, err, rest; + dec = this; + if (!($interfaceIsEqual(dec.err, $ifaceNil))) { + return dec.err; } - return strings.Split(path, ":"); + _tuple = dec.readValue(); n = _tuple[0]; err = _tuple[1]; + if (!($interfaceIsEqual(err, $ifaceNil))) { + return err; + } + dec.d.init($subslice(dec.buf, 0, n)); + err = dec.d.unmarshal(v); + rest = $copySlice(dec.buf, $subslice(dec.buf, n)); + dec.buf = $subslice(dec.buf, 0, rest); + return err; }; - evalSymlinks = function(path) { - var originalPath, b, n, i, p, _tmp, _tmp$1, _tmp$2, _tmp$3, _tuple, fi, err, _tuple$1, dest; - originalPath = path; - b = new bytes.Buffer.Ptr(); $copy(b, new bytes.Buffer.Ptr(), bytes.Buffer); - n = 0; - while (!(path === "")) { - if (n > 255) { - return ["", errors.New("EvalSymlinks: too many links in " + originalPath)]; - } - i = strings.IndexRune(path, 47); - p = ""; - if (i === -1) { - _tmp = path; _tmp$1 = ""; p = _tmp; path = _tmp$1; - } else { - _tmp$2 = path.substring(0, i); _tmp$3 = path.substring((i + 1 >> 0)); p = _tmp$2; path = _tmp$3; - } - if (p === "") { - if (b.Len() === 0) { - b.WriteRune(47); + Decoder.prototype.Decode = function(v) { return this.$val.Decode(v); }; + Decoder.Ptr.prototype.Buffered = function() { + var dec; + dec = this; + return bytes.NewReader(dec.buf); + }; + Decoder.prototype.Buffered = function() { return this.$val.Buffered(); }; + Decoder.Ptr.prototype.readValue = function() { + var dec, scanp, err, _ref, _i, i, c, x, x$1, v, x$2, newBuf, n, _tuple; + dec = this; + dec.scan.reset(); + scanp = 0; + err = $ifaceNil; + Input: + while (true) { + _ref = $subslice(dec.buf, scanp); + _i = 0; + while (_i < _ref.$length) { + i = _i; + c = ((_i < 0 || _i >= _ref.$length) ? $throwRuntimeError("index out of range") : _ref.$array[_ref.$offset + _i]); + dec.scan.bytes = (x = dec.scan.bytes, x$1 = new $Int64(0, 1), new $Int64(x.$high + x$1.$high, x.$low + x$1.$low)); + v = dec.scan.step(dec.scan, (c >> 0)); + if (v === 10) { + scanp = scanp + (i) >> 0; + break Input; } - n = n + (1) >> 0; - continue; + if (((v === 5) || (v === 8)) && (dec.scan.step(dec.scan, 32) === 10)) { + scanp = scanp + ((i + 1 >> 0)) >> 0; + break Input; + } + if (v === 11) { + dec.err = dec.scan.err; + return [0, dec.scan.err]; + } + _i++; } - _tuple = os.Lstat(b.String() + p); fi = _tuple[0]; err = _tuple[1]; + scanp = dec.buf.$length; if (!($interfaceIsEqual(err, $ifaceNil))) { - return ["", err]; - } - if (((fi.Mode() & 134217728) >>> 0) === 0) { - b.WriteString(p); - if (!(path === "")) { - b.WriteRune(47); + if ($interfaceIsEqual(err, io.EOF)) { + if (dec.scan.step(dec.scan, 32) === 10) { + break Input; + } + if (nonSpace(dec.buf)) { + err = io.ErrUnexpectedEOF; + } } - n = n + (1) >> 0; - continue; + dec.err = err; + return [0, err]; } - _tuple$1 = os.Readlink(b.String() + p); dest = _tuple$1[0]; err = _tuple$1[1]; - if (!($interfaceIsEqual(err, $ifaceNil))) { - return ["", err]; + if ((dec.buf.$capacity - dec.buf.$length >> 0) < 512) { + newBuf = ($sliceType($Uint8)).make(dec.buf.$length, ((x$2 = dec.buf.$capacity, (((2 >>> 16 << 16) * x$2 >> 0) + (2 << 16 >>> 16) * x$2) >> 0) + 512 >> 0)); + $copySlice(newBuf, dec.buf); + dec.buf = newBuf; } - if (IsAbs(dest)) { - b.Reset(); + n = 0; + _tuple = dec.r.Read($subslice(dec.buf, dec.buf.$length, dec.buf.$capacity)); n = _tuple[0]; err = _tuple[1]; + dec.buf = $subslice(dec.buf, 0, (dec.buf.$length + n >> 0)); + } + return [scanp, $ifaceNil]; + }; + Decoder.prototype.readValue = function() { return this.$val.readValue(); }; + nonSpace = function(b) { + var _ref, _i, c; + _ref = b; + _i = 0; + while (_i < _ref.$length) { + c = ((_i < 0 || _i >= _ref.$length) ? $throwRuntimeError("index out of range") : _ref.$array[_ref.$offset + _i]); + if (!isSpace((c >> 0))) { + return true; } - path = dest + "/" + path; - n = n + (1) >> 0; + _i++; } - return [Clean(b.String()), $ifaceNil]; + return false; + }; + NewEncoder = $pkg.NewEncoder = function(w) { + return new Encoder.Ptr(w, new encodeState.Ptr(), $ifaceNil); + }; + Encoder.Ptr.prototype.Encode = function(v) { + var enc, e, err, _tuple; + enc = this; + if (!($interfaceIsEqual(enc.err, $ifaceNil))) { + return enc.err; + } + e = newEncodeState(); + err = e.marshal(v); + if (!($interfaceIsEqual(err, $ifaceNil))) { + return err; + } + e.Buffer.WriteByte(10); + _tuple = enc.w.Write(e.Buffer.Bytes()); err = _tuple[1]; + if (!($interfaceIsEqual(err, $ifaceNil))) { + enc.err = err; + } + encodeStatePool.Put(e); + return err; + }; + Encoder.prototype.Encode = function(v) { return this.$val.Encode(v); }; + parseTag = function(tag) { + var idx; + idx = strings.Index(tag, ","); + if (!((idx === -1))) { + return [tag.substring(0, idx), tag.substring((idx + 1 >> 0))]; + } + return [tag, ""]; + }; + tagOptions.prototype.Contains = function(optionName) { + var o, s, next, i, _tmp, _tmp$1; + o = this.$val !== undefined ? this.$val : this; + if (o.length === 0) { + return false; + } + s = o; + while (!(s === "")) { + next = ""; + i = strings.Index(s, ","); + if (i >= 0) { + _tmp = s.substring(0, i); _tmp$1 = s.substring((i + 1 >> 0)); s = _tmp; next = _tmp$1; + } + if (s === optionName) { + return true; + } + s = next; + } + return false; }; + $ptrType(tagOptions).prototype.Contains = function(optionName) { return new tagOptions(this.$get()).Contains(optionName); }; $pkg.$init = function() { - ($ptrType(lazybuf)).methods = [["append", "append", "path/filepath", $funcType([$Uint8], [], false), -1], ["index", "index", "path/filepath", $funcType([$Int], [$Uint8], false), -1], ["string", "string", "path/filepath", $funcType([], [$String], false), -1]]; - lazybuf.init([["path", "path", "path/filepath", $String, ""], ["buf", "buf", "path/filepath", ($sliceType($Uint8)), ""], ["w", "w", "path/filepath", $Int, ""], ["volAndPath", "volAndPath", "path/filepath", $String, ""], ["volLen", "volLen", "path/filepath", $Int, ""]]); - $pkg.ErrBadPattern = errors.New("syntax error in pattern"); - $pkg.SkipDir = errors.New("skip this directory"); + Unmarshaler.init([["UnmarshalJSON", "UnmarshalJSON", "", $funcType([($sliceType($Uint8))], [$error], false)]]); + ($ptrType(UnmarshalTypeError)).methods = [["Error", "Error", "", $funcType([], [$String], false), -1]]; + UnmarshalTypeError.init([["Value", "Value", "", $String, ""], ["Type", "Type", "", reflect.Type, ""]]); + ($ptrType(InvalidUnmarshalError)).methods = [["Error", "Error", "", $funcType([], [$String], false), -1]]; + InvalidUnmarshalError.init([["Type", "Type", "", reflect.Type, ""]]); + Number.methods = [["Float64", "Float64", "", $funcType([], [$Float64, $error], false), -1], ["Int64", "Int64", "", $funcType([], [$Int64, $error], false), -1], ["String", "String", "", $funcType([], [$String], false), -1]]; + ($ptrType(Number)).methods = [["Float64", "Float64", "", $funcType([], [$Float64, $error], false), -1], ["Int64", "Int64", "", $funcType([], [$Int64, $error], false), -1], ["String", "String", "", $funcType([], [$String], false), -1]]; + ($ptrType(decodeState)).methods = [["array", "array", "encoding/json", $funcType([reflect.Value], [], false), -1], ["arrayInterface", "arrayInterface", "encoding/json", $funcType([], [($sliceType($emptyInterface))], false), -1], ["convertNumber", "convertNumber", "encoding/json", $funcType([$String], [$emptyInterface, $error], false), -1], ["error", "error", "encoding/json", $funcType([$error], [], false), -1], ["indirect", "indirect", "encoding/json", $funcType([reflect.Value, $Bool], [Unmarshaler, encoding.TextUnmarshaler, reflect.Value], false), -1], ["init", "init", "encoding/json", $funcType([($sliceType($Uint8))], [($ptrType(decodeState))], false), -1], ["literal", "literal", "encoding/json", $funcType([reflect.Value], [], false), -1], ["literalInterface", "literalInterface", "encoding/json", $funcType([], [$emptyInterface], false), -1], ["literalStore", "literalStore", "encoding/json", $funcType([($sliceType($Uint8)), reflect.Value, $Bool], [], false), -1], ["next", "next", "encoding/json", $funcType([], [($sliceType($Uint8))], false), -1], ["object", "object", "encoding/json", $funcType([reflect.Value], [], false), -1], ["objectInterface", "objectInterface", "encoding/json", $funcType([], [($mapType($String, $emptyInterface))], false), -1], ["saveError", "saveError", "encoding/json", $funcType([$error], [], false), -1], ["scanWhile", "scanWhile", "encoding/json", $funcType([$Int], [$Int], false), -1], ["unmarshal", "unmarshal", "encoding/json", $funcType([$emptyInterface], [$error], false), -1], ["value", "value", "encoding/json", $funcType([reflect.Value], [], false), -1], ["valueInterface", "valueInterface", "encoding/json", $funcType([], [$emptyInterface], false), -1]]; + decodeState.init([["data", "data", "encoding/json", ($sliceType($Uint8)), ""], ["off", "off", "encoding/json", $Int, ""], ["scan", "scan", "encoding/json", scanner, ""], ["nextscan", "nextscan", "encoding/json", scanner, ""], ["savedError", "savedError", "encoding/json", $error, ""], ["tempstr", "tempstr", "encoding/json", $String, ""], ["useNumber", "useNumber", "encoding/json", $Bool, ""]]); + Marshaler.init([["MarshalJSON", "MarshalJSON", "", $funcType([], [($sliceType($Uint8)), $error], false)]]); + ($ptrType(UnsupportedTypeError)).methods = [["Error", "Error", "", $funcType([], [$String], false), -1]]; + UnsupportedTypeError.init([["Type", "Type", "", reflect.Type, ""]]); + ($ptrType(UnsupportedValueError)).methods = [["Error", "Error", "", $funcType([], [$String], false), -1]]; + UnsupportedValueError.init([["Value", "Value", "", reflect.Value, ""], ["Str", "Str", "", $String, ""]]); + ($ptrType(MarshalerError)).methods = [["Error", "Error", "", $funcType([], [$String], false), -1]]; + MarshalerError.init([["Type", "Type", "", reflect.Type, ""], ["Err", "Err", "", $error, ""]]); + ($ptrType(encodeState)).methods = [["Bytes", "Bytes", "", $funcType([], [($sliceType($Uint8))], false), 0], ["Grow", "Grow", "", $funcType([$Int], [], false), 0], ["Len", "Len", "", $funcType([], [$Int], false), 0], ["Next", "Next", "", $funcType([$Int], [($sliceType($Uint8))], false), 0], ["Read", "Read", "", $funcType([($sliceType($Uint8))], [$Int, $error], false), 0], ["ReadByte", "ReadByte", "", $funcType([], [$Uint8, $error], false), 0], ["ReadBytes", "ReadBytes", "", $funcType([$Uint8], [($sliceType($Uint8)), $error], false), 0], ["ReadFrom", "ReadFrom", "", $funcType([io.Reader], [$Int64, $error], false), 0], ["ReadRune", "ReadRune", "", $funcType([], [$Int32, $Int, $error], false), 0], ["ReadString", "ReadString", "", $funcType([$Uint8], [$String, $error], false), 0], ["Reset", "Reset", "", $funcType([], [], false), 0], ["String", "String", "", $funcType([], [$String], false), 0], ["Truncate", "Truncate", "", $funcType([$Int], [], false), 0], ["UnreadByte", "UnreadByte", "", $funcType([], [$error], false), 0], ["UnreadRune", "UnreadRune", "", $funcType([], [$error], false), 0], ["Write", "Write", "", $funcType([($sliceType($Uint8))], [$Int, $error], false), 0], ["WriteByte", "WriteByte", "", $funcType([$Uint8], [$error], false), 0], ["WriteRune", "WriteRune", "", $funcType([$Int32], [$Int, $error], false), 0], ["WriteString", "WriteString", "", $funcType([$String], [$Int, $error], false), 0], ["WriteTo", "WriteTo", "", $funcType([io.Writer], [$Int64, $error], false), 0], ["grow", "grow", "bytes", $funcType([$Int], [$Int], false), 0], ["readSlice", "readSlice", "bytes", $funcType([$Uint8], [($sliceType($Uint8)), $error], false), 0], ["error", "error", "encoding/json", $funcType([$error], [], false), -1], ["marshal", "marshal", "encoding/json", $funcType([$emptyInterface], [$error], false), -1], ["reflectValue", "reflectValue", "encoding/json", $funcType([reflect.Value], [], false), -1], ["string", "string", "encoding/json", $funcType([$String], [$Int, $error], false), -1], ["stringBytes", "stringBytes", "encoding/json", $funcType([($sliceType($Uint8))], [$Int, $error], false), -1]]; + encodeState.init([["Buffer", "", "", bytes.Buffer, ""], ["scratch", "scratch", "encoding/json", ($arrayType($Uint8, 64)), ""]]); + encoderFunc.init([($ptrType(encodeState)), reflect.Value, $Bool], [], false); + floatEncoder.methods = [["encode", "encode", "encoding/json", $funcType([($ptrType(encodeState)), reflect.Value, $Bool], [], false), -1]]; + ($ptrType(floatEncoder)).methods = [["encode", "encode", "encoding/json", $funcType([($ptrType(encodeState)), reflect.Value, $Bool], [], false), -1]]; + ($ptrType(structEncoder)).methods = [["encode", "encode", "encoding/json", $funcType([($ptrType(encodeState)), reflect.Value, $Bool], [], false), -1]]; + structEncoder.init([["fields", "fields", "encoding/json", ($sliceType(field)), ""], ["fieldEncs", "fieldEncs", "encoding/json", ($sliceType(encoderFunc)), ""]]); + ($ptrType(mapEncoder)).methods = [["encode", "encode", "encoding/json", $funcType([($ptrType(encodeState)), reflect.Value, $Bool], [], false), -1]]; + mapEncoder.init([["elemEnc", "elemEnc", "encoding/json", encoderFunc, ""]]); + ($ptrType(sliceEncoder)).methods = [["encode", "encode", "encoding/json", $funcType([($ptrType(encodeState)), reflect.Value, $Bool], [], false), -1]]; + sliceEncoder.init([["arrayEnc", "arrayEnc", "encoding/json", encoderFunc, ""]]); + ($ptrType(arrayEncoder)).methods = [["encode", "encode", "encoding/json", $funcType([($ptrType(encodeState)), reflect.Value, $Bool], [], false), -1]]; + arrayEncoder.init([["elemEnc", "elemEnc", "encoding/json", encoderFunc, ""]]); + ($ptrType(ptrEncoder)).methods = [["encode", "encode", "encoding/json", $funcType([($ptrType(encodeState)), reflect.Value, $Bool], [], false), -1]]; + ptrEncoder.init([["elemEnc", "elemEnc", "encoding/json", encoderFunc, ""]]); + ($ptrType(condAddrEncoder)).methods = [["encode", "encode", "encoding/json", $funcType([($ptrType(encodeState)), reflect.Value, $Bool], [], false), -1]]; + condAddrEncoder.init([["canAddrEnc", "canAddrEnc", "encoding/json", encoderFunc, ""], ["elseEnc", "elseEnc", "encoding/json", encoderFunc, ""]]); + stringValues.methods = [["Len", "Len", "", $funcType([], [$Int], false), -1], ["Less", "Less", "", $funcType([$Int, $Int], [$Bool], false), -1], ["Swap", "Swap", "", $funcType([$Int, $Int], [], false), -1], ["get", "get", "encoding/json", $funcType([$Int], [$String], false), -1]]; + ($ptrType(stringValues)).methods = [["Len", "Len", "", $funcType([], [$Int], false), -1], ["Less", "Less", "", $funcType([$Int, $Int], [$Bool], false), -1], ["Swap", "Swap", "", $funcType([$Int, $Int], [], false), -1], ["get", "get", "encoding/json", $funcType([$Int], [$String], false), -1]]; + stringValues.init(reflect.Value); + field.init([["name", "name", "encoding/json", $String, ""], ["nameBytes", "nameBytes", "encoding/json", ($sliceType($Uint8)), ""], ["equalFold", "equalFold", "encoding/json", ($funcType([($sliceType($Uint8)), ($sliceType($Uint8))], [$Bool], false)), ""], ["tag", "tag", "encoding/json", $Bool, ""], ["index", "index", "encoding/json", ($sliceType($Int)), ""], ["typ", "typ", "encoding/json", reflect.Type, ""], ["omitEmpty", "omitEmpty", "encoding/json", $Bool, ""], ["quoted", "quoted", "encoding/json", $Bool, ""]]); + byName.methods = [["Len", "Len", "", $funcType([], [$Int], false), -1], ["Less", "Less", "", $funcType([$Int, $Int], [$Bool], false), -1], ["Swap", "Swap", "", $funcType([$Int, $Int], [], false), -1]]; + ($ptrType(byName)).methods = [["Len", "Len", "", $funcType([], [$Int], false), -1], ["Less", "Less", "", $funcType([$Int, $Int], [$Bool], false), -1], ["Swap", "Swap", "", $funcType([$Int, $Int], [], false), -1]]; + byName.init(field); + byIndex.methods = [["Len", "Len", "", $funcType([], [$Int], false), -1], ["Less", "Less", "", $funcType([$Int, $Int], [$Bool], false), -1], ["Swap", "Swap", "", $funcType([$Int, $Int], [], false), -1]]; + ($ptrType(byIndex)).methods = [["Len", "Len", "", $funcType([], [$Int], false), -1], ["Less", "Less", "", $funcType([$Int, $Int], [$Bool], false), -1], ["Swap", "Swap", "", $funcType([$Int, $Int], [], false), -1]]; + byIndex.init(field); + ($ptrType(SyntaxError)).methods = [["Error", "Error", "", $funcType([], [$String], false), -1]]; + SyntaxError.init([["msg", "msg", "encoding/json", $String, ""], ["Offset", "Offset", "", $Int64, ""]]); + ($ptrType(scanner)).methods = [["eof", "eof", "encoding/json", $funcType([], [$Int], false), -1], ["error", "error", "encoding/json", $funcType([$Int, $String], [$Int], false), -1], ["popParseState", "popParseState", "encoding/json", $funcType([], [], false), -1], ["pushParseState", "pushParseState", "encoding/json", $funcType([$Int], [], false), -1], ["reset", "reset", "encoding/json", $funcType([], [], false), -1], ["undo", "undo", "encoding/json", $funcType([$Int], [], false), -1]]; + scanner.init([["step", "step", "encoding/json", ($funcType([($ptrType(scanner)), $Int], [$Int], false)), ""], ["endTop", "endTop", "encoding/json", $Bool, ""], ["parseState", "parseState", "encoding/json", ($sliceType($Int)), ""], ["err", "err", "encoding/json", $error, ""], ["redo", "redo", "encoding/json", $Bool, ""], ["redoCode", "redoCode", "encoding/json", $Int, ""], ["redoState", "redoState", "encoding/json", ($funcType([($ptrType(scanner)), $Int], [$Int], false)), ""], ["bytes", "bytes", "encoding/json", $Int64, ""]]); + ($ptrType(Decoder)).methods = [["Buffered", "Buffered", "", $funcType([], [io.Reader], false), -1], ["Decode", "Decode", "", $funcType([$emptyInterface], [$error], false), -1], ["UseNumber", "UseNumber", "", $funcType([], [], false), -1], ["readValue", "readValue", "encoding/json", $funcType([], [$Int, $error], false), -1]]; + Decoder.init([["r", "r", "encoding/json", io.Reader, ""], ["buf", "buf", "encoding/json", ($sliceType($Uint8)), ""], ["d", "d", "encoding/json", decodeState, ""], ["scan", "scan", "encoding/json", scanner, ""], ["err", "err", "encoding/json", $error, ""]]); + ($ptrType(Encoder)).methods = [["Encode", "Encode", "", $funcType([$emptyInterface], [$error], false), -1]]; + Encoder.init([["w", "w", "encoding/json", io.Writer, ""], ["e", "e", "encoding/json", encodeState, ""], ["err", "err", "encoding/json", $error, ""]]); + tagOptions.methods = [["Contains", "Contains", "", $funcType([$String], [$Bool], false), -1]]; + ($ptrType(tagOptions)).methods = [["Contains", "Contains", "", $funcType([$String], [$Bool], false), -1]]; + encodeStatePool = new sync.Pool.Ptr(); + encoderCache = new ($structType([["RWMutex", "", "", sync.RWMutex, ""], ["m", "m", "encoding/json", ($mapType(reflect.Type, encoderFunc)), ""]])).Ptr(); + fieldCache = new ($structType([["RWMutex", "", "", sync.RWMutex, ""], ["m", "m", "encoding/json", ($mapType(reflect.Type, ($sliceType(field)))), ""]])).Ptr(); + errPhase = errors.New("JSON decoder out of sync - data changing underfoot?"); + numberType = reflect.TypeOf(new Number("")); + hex = "0123456789abcdef"; + byteSliceType = reflect.TypeOf(($sliceType($Uint8)).nil); + marshalerType = reflect.TypeOf($newDataPointer($ifaceNil, ($ptrType(Marshaler)))).Elem(); + textMarshalerType = reflect.TypeOf($newDataPointer($ifaceNil, ($ptrType(encoding.TextMarshaler)))).Elem(); + float32Encoder = $methodVal((new floatEncoder(32)), "encode"); + float64Encoder = $methodVal((new floatEncoder(64)), "encode"); }; return $pkg; })(); -$packages["go/scanner"] = (function() { - var $pkg = {}, fmt = $packages["fmt"], token = $packages["go/token"], io = $packages["io"], sort = $packages["sort"], bytes = $packages["bytes"], filepath = $packages["path/filepath"], strconv = $packages["strconv"], unicode = $packages["unicode"], utf8 = $packages["unicode/utf8"], Error, ErrorList, ErrorHandler, Scanner, Mode, prefix, isLetter, isDigit, digitVal, stripCR; - Error = $pkg.Error = $newType(0, "Struct", "scanner.Error", "Error", "go/scanner", function(Pos_, Msg_) { - this.$val = this; - this.Pos = Pos_ !== undefined ? Pos_ : new token.Position.Ptr(); - this.Msg = Msg_ !== undefined ? Msg_ : ""; - }); - ErrorList = $pkg.ErrorList = $newType(12, "Slice", "scanner.ErrorList", "ErrorList", "go/scanner", null); - ErrorHandler = $pkg.ErrorHandler = $newType(4, "Func", "scanner.ErrorHandler", "ErrorHandler", "go/scanner", null); - Scanner = $pkg.Scanner = $newType(0, "Struct", "scanner.Scanner", "Scanner", "go/scanner", function(file_, dir_, src_, err_, mode_, ch_, offset_, rdOffset_, lineOffset_, insertSemi_, ErrorCount_) { +$packages["github.com/codegangsta/inject"] = (function() { + var $pkg = {}, fmt = $packages["fmt"], reflect = $packages["reflect"], Injector, TypeMapper, injector, InterfaceOf, New; + Injector = $pkg.Injector = $newType(8, "Interface", "inject.Injector", "Injector", "github.com/codegangsta/inject", null); + TypeMapper = $pkg.TypeMapper = $newType(8, "Interface", "inject.TypeMapper", "TypeMapper", "github.com/codegangsta/inject", null); + injector = $pkg.injector = $newType(0, "Struct", "inject.injector", "injector", "github.com/codegangsta/inject", function(values_, parent_) { this.$val = this; - this.file = file_ !== undefined ? file_ : ($ptrType(token.File)).nil; - this.dir = dir_ !== undefined ? dir_ : ""; - this.src = src_ !== undefined ? src_ : ($sliceType($Uint8)).nil; - this.err = err_ !== undefined ? err_ : $throwNilPointerError; - this.mode = mode_ !== undefined ? mode_ : 0; - this.ch = ch_ !== undefined ? ch_ : 0; - this.offset = offset_ !== undefined ? offset_ : 0; - this.rdOffset = rdOffset_ !== undefined ? rdOffset_ : 0; - this.lineOffset = lineOffset_ !== undefined ? lineOffset_ : 0; - this.insertSemi = insertSemi_ !== undefined ? insertSemi_ : false; - this.ErrorCount = ErrorCount_ !== undefined ? ErrorCount_ : 0; + this.values = values_ !== undefined ? values_ : false; + this.parent = parent_ !== undefined ? parent_ : $ifaceNil; }); - Mode = $pkg.Mode = $newType(4, "Uint", "scanner.Mode", "Mode", "go/scanner", null); - Error.Ptr.prototype.Error = function() { - var e; - e = new Error.Ptr(); $copy(e, this, Error); - if (!(e.Pos.Filename === "") || e.Pos.IsValid()) { - return e.Pos.String() + ": " + e.Msg; + InterfaceOf = $pkg.InterfaceOf = function(value) { + var t; + t = reflect.TypeOf(value); + while (t.Kind() === 22) { + t = t.Elem(); } - return e.Msg; + if (!((t.Kind() === 20))) { + $panic(new $String("Called inject.InterfaceOf with a value that is not a pointer to an interface. (*MyInterface)(nil)")); + } + return t; }; - Error.prototype.Error = function() { return this.$val.Error(); }; - $ptrType(ErrorList).prototype.Add = function(pos, msg) { - var p; - p = this; - p.$set($append(p.$get(), new Error.Ptr(pos, msg))); + New = $pkg.New = function() { + return new injector.Ptr(new $Map(), $ifaceNil); }; - $ptrType(ErrorList).prototype.Reset = function() { - var p; - p = this; - p.$set($subslice((p.$get()), 0, 0)); + injector.Ptr.prototype.Invoke = function(f) { + var inj, t, in$1, i, argType, val; + inj = this; + t = reflect.TypeOf(f); + in$1 = ($sliceType(reflect.Value)).make(t.NumIn()); + i = 0; + while (i < t.NumIn()) { + argType = t.In(i); + val = new reflect.Value.Ptr(); $copy(val, inj.Get(argType), reflect.Value); + if (!val.IsValid()) { + return [($sliceType(reflect.Value)).nil, fmt.Errorf("Value not found for type %v", new ($sliceType($emptyInterface))([argType]))]; + } + $copy(((i < 0 || i >= in$1.$length) ? $throwRuntimeError("index out of range") : in$1.$array[in$1.$offset + i]), val, reflect.Value); + i = i + (1) >> 0; + } + return [reflect.ValueOf(f).Call(in$1), $ifaceNil]; }; - ErrorList.prototype.Len = function() { - var p; - p = this; - return p.$length; + injector.prototype.Invoke = function(f) { return this.$val.Invoke(f); }; + injector.Ptr.prototype.Apply = function(val) { + var inj, v, t, i, f, structField, ft, v$1; + inj = this; + v = new reflect.Value.Ptr(); $copy(v, reflect.ValueOf(val), reflect.Value); + while (v.Kind() === 22) { + $copy(v, v.Elem(), reflect.Value); + } + if (!((v.Kind() === 25))) { + return $ifaceNil; + } + t = v.Type(); + i = 0; + while (i < v.NumField()) { + f = new reflect.Value.Ptr(); $copy(f, v.Field(i), reflect.Value); + structField = new reflect.StructField.Ptr(); $copy(structField, t.Field(i), reflect.StructField); + if (f.CanSet() && (structField.Tag === "inject" || !((new reflect.StructTag(structField.Tag)).Get("inject") === ""))) { + ft = f.Type(); + v$1 = new reflect.Value.Ptr(); $copy(v$1, inj.Get(ft), reflect.Value); + if (!v$1.IsValid()) { + return fmt.Errorf("Value not found for type %v", new ($sliceType($emptyInterface))([ft])); + } + f.Set($clone(v$1, reflect.Value)); + } + i = i + (1) >> 0; + } + return $ifaceNil; }; - $ptrType(ErrorList).prototype.Len = function() { return this.$get().Len(); }; - ErrorList.prototype.Swap = function(i, j) { - var p, _tmp, _tmp$1; - p = this; - _tmp = ((j < 0 || j >= p.$length) ? $throwRuntimeError("index out of range") : p.$array[p.$offset + j]); _tmp$1 = ((i < 0 || i >= p.$length) ? $throwRuntimeError("index out of range") : p.$array[p.$offset + i]); (i < 0 || i >= p.$length) ? $throwRuntimeError("index out of range") : p.$array[p.$offset + i] = _tmp; (j < 0 || j >= p.$length) ? $throwRuntimeError("index out of range") : p.$array[p.$offset + j] = _tmp$1; + injector.prototype.Apply = function(val) { return this.$val.Apply(val); }; + injector.Ptr.prototype.Map = function(val) { + var i, _key; + i = this; + _key = reflect.TypeOf(val); (i.values || $throwRuntimeError("assignment to entry in nil map"))[_key.$key()] = { k: _key, v: reflect.ValueOf(val) }; + return i; }; - $ptrType(ErrorList).prototype.Swap = function(i, j) { return this.$get().Swap(i, j); }; - ErrorList.prototype.Less = function(i, j) { - var p, e, f; - p = this; - e = ((i < 0 || i >= p.$length) ? $throwRuntimeError("index out of range") : p.$array[p.$offset + i]).Pos; - f = ((j < 0 || j >= p.$length) ? $throwRuntimeError("index out of range") : p.$array[p.$offset + j]).Pos; - if (e.Filename < f.Filename) { - return true; + injector.prototype.Map = function(val) { return this.$val.Map(val); }; + injector.Ptr.prototype.MapTo = function(val, ifacePtr) { + var i, _key; + i = this; + _key = InterfaceOf(ifacePtr); (i.values || $throwRuntimeError("assignment to entry in nil map"))[_key.$key()] = { k: _key, v: reflect.ValueOf(val) }; + return i; + }; + injector.prototype.MapTo = function(val, ifacePtr) { return this.$val.MapTo(val, ifacePtr); }; + injector.Ptr.prototype.Set = function(typ, val) { + var i, _key; + i = this; + _key = typ; (i.values || $throwRuntimeError("assignment to entry in nil map"))[_key.$key()] = { k: _key, v: val }; + return i; + }; + injector.prototype.Set = function(typ, val) { return this.$val.Set(typ, val); }; + injector.Ptr.prototype.Get = function(t) { + var i, _entry, val, _ref, _i, _keys, _entry$1, k, v; + i = this; + val = new reflect.Value.Ptr(); $copy(val, (_entry = i.values[t.$key()], _entry !== undefined ? _entry.v : new reflect.Value.Ptr()), reflect.Value); + if (val.IsValid()) { + return val; } - if (e.Filename === f.Filename) { - if (e.Line < f.Line) { - return true; - } - if (e.Line === f.Line) { - return e.Column < f.Column; + if (t.Kind() === 20) { + _ref = i.values; + _i = 0; + _keys = $keys(_ref); + while (_i < _keys.length) { + _entry$1 = _ref[_keys[_i]]; + if (_entry$1 === undefined) { + _i++; + continue; + } + k = _entry$1.k; + v = new reflect.Value.Ptr(); $copy(v, _entry$1.v, reflect.Value); + if (k.Implements(t)) { + $copy(val, v, reflect.Value); + break; + } + _i++; } } - return false; + if (!val.IsValid() && !($interfaceIsEqual(i.parent, $ifaceNil))) { + $copy(val, i.parent.Get(t), reflect.Value); + } + return val; }; - $ptrType(ErrorList).prototype.Less = function(i, j) { return this.$get().Less(i, j); }; - ErrorList.prototype.Sort = function() { - var p; - p = this; - sort.Sort(p); + injector.prototype.Get = function(t) { return this.$val.Get(t); }; + injector.Ptr.prototype.SetParent = function(parent) { + var i; + i = this; + i.parent = parent; }; - $ptrType(ErrorList).prototype.Sort = function() { return this.$get().Sort(); }; - $ptrType(ErrorList).prototype.RemoveMultiples = function() { - var p, last, i, _ref, _i, e, x; - p = this; - sort.Sort(p); - last = new token.Position.Ptr(); $copy(last, new token.Position.Ptr(), token.Position); + injector.prototype.SetParent = function(parent) { return this.$val.SetParent(parent); }; + $pkg.$init = function() { + Injector.init([["Apply", "Apply", "", $funcType([$emptyInterface], [$error], false)], ["Get", "Get", "", $funcType([reflect.Type], [reflect.Value], false)], ["Invoke", "Invoke", "", $funcType([$emptyInterface], [($sliceType(reflect.Value)), $error], false)], ["Map", "Map", "", $funcType([$emptyInterface], [TypeMapper], false)], ["MapTo", "MapTo", "", $funcType([$emptyInterface, $emptyInterface], [TypeMapper], false)], ["Set", "Set", "", $funcType([reflect.Type, reflect.Value], [TypeMapper], false)], ["SetParent", "SetParent", "", $funcType([Injector], [], false)]]); + TypeMapper.init([["Get", "Get", "", $funcType([reflect.Type], [reflect.Value], false)], ["Map", "Map", "", $funcType([$emptyInterface], [TypeMapper], false)], ["MapTo", "MapTo", "", $funcType([$emptyInterface, $emptyInterface], [TypeMapper], false)], ["Set", "Set", "", $funcType([reflect.Type, reflect.Value], [TypeMapper], false)]]); + ($ptrType(injector)).methods = [["Apply", "Apply", "", $funcType([$emptyInterface], [$error], false), -1], ["Get", "Get", "", $funcType([reflect.Type], [reflect.Value], false), -1], ["Invoke", "Invoke", "", $funcType([$emptyInterface], [($sliceType(reflect.Value)), $error], false), -1], ["Map", "Map", "", $funcType([$emptyInterface], [TypeMapper], false), -1], ["MapTo", "MapTo", "", $funcType([$emptyInterface, $emptyInterface], [TypeMapper], false), -1], ["Set", "Set", "", $funcType([reflect.Type, reflect.Value], [TypeMapper], false), -1], ["SetParent", "SetParent", "", $funcType([Injector], [], false), -1]]; + injector.init([["values", "values", "github.com/codegangsta/inject", ($mapType(reflect.Type, reflect.Value)), ""], ["parent", "parent", "github.com/codegangsta/inject", Injector, ""]]); + }; + return $pkg; +})(); +$packages["github.com/phaikawl/options"] = (function() { + var $pkg = {}, fmt = $packages["fmt"], reflect = $packages["reflect"], Spec, Option, OptionsProvider, NewOptions; + Spec = $pkg.Spec = $newType(8, "Interface", "options.Spec", "Spec", "github.com/phaikawl/options", null); + Option = $pkg.Option = $newType(8, "Interface", "options.Option", "Option", "github.com/phaikawl/options", null); + OptionsProvider = $pkg.OptionsProvider = $newType(0, "Struct", "options.OptionsProvider", "OptionsProvider", "github.com/phaikawl/options", function(spec_, m_, set_) { + this.$val = this; + this.spec = spec_ !== undefined ? spec_ : $ifaceNil; + this.m = m_ !== undefined ? m_ : false; + this.set = set_ !== undefined ? set_ : false; + }); + NewOptions = $pkg.NewOptions = function(spec) { + var o, v, specType, i, field, _key; + o = new OptionsProvider.Ptr(spec, new $Map(), new $Map()); + v = new reflect.Value.Ptr(); $copy(v, reflect.ValueOf(spec), reflect.Value); + if (v.CanSet()) { + $panic(new $String(fmt.Sprintf("The spec passed in must be a pointer, got type %v", new ($sliceType($emptyInterface))([new $String(v.Type().Name())])))); + } + $copy(v, v.Elem(), reflect.Value); + specType = v.Type(); i = 0; - _ref = p.$get(); + while (i < specType.NumField()) { + field = new reflect.StructField.Ptr(); $copy(field, specType.Field(i), reflect.StructField); + _key = field.Type.Name(); (o.m || $throwRuntimeError("assignment to entry in nil map"))[_key] = { k: _key, v: field.Name }; + i = i + (1) >> 0; + } + return o; + }; + OptionsProvider.Ptr.prototype.Options = function(opts) { + var o, _ref, _i, opt, optType, _tuple, ok, _entry, fieldName, field, _key; + o = this; + _ref = opts; _i = 0; while (_i < _ref.$length) { - e = ((_i < 0 || _i >= _ref.$length) ? $throwRuntimeError("index out of range") : _ref.$array[_ref.$offset + _i]); - if (!(e.Pos.Filename === last.Filename) || !((e.Pos.Line === last.Line))) { - $copy(last, e.Pos, token.Position); - (x = p.$get(), (i < 0 || i >= x.$length) ? $throwRuntimeError("index out of range") : x.$array[x.$offset + i] = e); - i = i + (1) >> 0; + opt = ((_i < 0 || _i >= _ref.$length) ? $throwRuntimeError("index out of range") : _ref.$array[_ref.$offset + _i]); + optType = reflect.TypeOf(opt); + _tuple = optType.FieldByName("Value"); ok = _tuple[1]; + if (!ok) { + $panic(new $String(fmt.Sprintf("Option %v doesn't have a Value field.", new ($sliceType($emptyInterface))([new $String(optType.Name())])))); + } + fieldName = (_entry = o.m[optType.Name()], _entry !== undefined ? _entry.v : ""); + field = new reflect.Value.Ptr(); $copy(field, reflect.ValueOf(o.spec).Elem().FieldByName(fieldName), reflect.Value); + if (!field.CanSet() || !field.IsValid()) { + $panic(new $String(fmt.Sprintf("There is no option %v.", new ($sliceType($emptyInterface))([new $String(optType.Name())])))); } + field.Set($clone(reflect.ValueOf(opt), reflect.Value)); + _key = fieldName; (o.set || $throwRuntimeError("assignment to entry in nil map"))[_key] = { k: _key, v: true }; _i++; } - p.$set($subslice((p.$get()), 0, i)); + return o; }; - ErrorList.prototype.Error = function() { - var p, _ref; - p = this; - _ref = p.$length; - if (_ref === 0) { - return "no errors"; - } else if (_ref === 1) { - return ((0 < 0 || 0 >= p.$length) ? $throwRuntimeError("index out of range") : p.$array[p.$offset + 0]).Error(); - } - return fmt.Sprintf("%s (and %d more errors)", new ($sliceType($emptyInterface))([((0 < 0 || 0 >= p.$length) ? $throwRuntimeError("index out of range") : p.$array[p.$offset + 0]), new $Int((p.$length - 1 >> 0))])); + OptionsProvider.prototype.Options = function(opts) { return this.$val.Options(opts); }; + OptionsProvider.Ptr.prototype.Get = function() { + var o; + o = this; + return o.spec; }; - $ptrType(ErrorList).prototype.Error = function() { return this.$get().Error(); }; - ErrorList.prototype.Err = function() { - var p; - p = this; - if (p.$length === 0) { - return $ifaceNil; - } - return p; + OptionsProvider.prototype.Get = function() { return this.$val.Get(); }; + OptionsProvider.Ptr.prototype.IsSet = function(field) { + var o, _entry; + o = this; + return (_entry = o.set[field], _entry !== undefined ? _entry.v : false); }; - $ptrType(ErrorList).prototype.Err = function() { return this.$get().Err(); }; - Scanner.Ptr.prototype.next = function() { - var s, _tmp, x, x$1, _tmp$1, r, w, _tuple; - s = this; - if (s.rdOffset < s.src.$length) { - s.offset = s.rdOffset; - if (s.ch === 10) { - s.lineOffset = s.offset; - s.file.AddLine(s.offset); + OptionsProvider.prototype.IsSet = function(field) { return this.$val.IsSet(field); }; + OptionsProvider.Ptr.prototype.ExportToMap = function() { + var o; + o = this; + return o.ExportToMapWithTag(""); + }; + OptionsProvider.prototype.ExportToMap = function() { return this.$val.ExportToMap(); }; + OptionsProvider.Ptr.prototype.ExportToMapWithTag = function(tag) { + var o, spec, specType, m, i, exportedName, taggedName, _key; + o = this; + spec = new reflect.Value.Ptr(); $copy(spec, reflect.ValueOf(o.spec).Elem(), reflect.Value); + specType = spec.Type(); + m = new $Map(); + i = 0; + while (i < specType.NumField()) { + exportedName = specType.Field(i).Name; + if (!o.IsSet(exportedName)) { + i = i + (1) >> 0; + continue; } - _tmp = ((x = s.src, x$1 = s.rdOffset, ((x$1 < 0 || x$1 >= x.$length) ? $throwRuntimeError("index out of range") : x.$array[x.$offset + x$1])) >> 0); _tmp$1 = 1; r = _tmp; w = _tmp$1; - if (r === 0) { - s.error(s.offset, "illegal character NUL"); - } else if (r >= 128) { - _tuple = utf8.DecodeRune($subslice(s.src, s.rdOffset)); r = _tuple[0]; w = _tuple[1]; - if ((r === 65533) && (w === 1)) { - s.error(s.offset, "illegal UTF-8 encoding"); - } else if ((r === 65279) && s.offset > 0) { - s.error(s.offset, "illegal byte order mark"); + if (!(tag === "")) { + taggedName = (new reflect.StructTag(specType.Field(i).Tag)).Get(tag); + if (!(taggedName === "")) { + exportedName = taggedName; } } - s.rdOffset = s.rdOffset + (w) >> 0; - s.ch = r; - } else { - s.offset = s.src.$length; - if (s.ch === 10) { - s.lineOffset = s.offset; - s.file.AddLine(s.offset); - } - s.ch = -1; - } - }; - Scanner.prototype.next = function() { return this.$val.next(); }; - Scanner.Ptr.prototype.Init = function(file, src, err, mode) { - var s, _tuple; - s = this; - if (!((file.Size() === src.$length))) { - $panic(new $String(fmt.Sprintf("file size (%d) does not match src len (%d)", new ($sliceType($emptyInterface))([new $Int(file.Size()), new $Int(src.$length)])))); - } - s.file = file; - _tuple = filepath.Split(file.Name()); s.dir = _tuple[0]; - s.src = src; - s.err = err; - s.mode = mode; - s.ch = 32; - s.offset = 0; - s.rdOffset = 0; - s.lineOffset = 0; - s.insertSemi = false; - s.ErrorCount = 0; - s.next(); - if (s.ch === 65279) { - s.next(); + _key = exportedName; (m || $throwRuntimeError("assignment to entry in nil map"))[_key] = { k: _key, v: spec.Field(i).FieldByName("Value").Interface() }; + i = i + (1) >> 0; } + return m; }; - Scanner.prototype.Init = function(file, src, err, mode) { return this.$val.Init(file, src, err, mode); }; - Scanner.Ptr.prototype.error = function(offs, msg) { - var s; - s = this; - if (!(s.err === $throwNilPointerError)) { - s.err($clone(s.file.Position(s.file.Pos(offs)), token.Position), msg); - } - s.ErrorCount = s.ErrorCount + (1) >> 0; + OptionsProvider.prototype.ExportToMapWithTag = function(tag) { return this.$val.ExportToMapWithTag(tag); }; + $pkg.$init = function() { + Spec.init([]); + Option.init([]); + ($ptrType(OptionsProvider)).methods = [["ExportToMap", "ExportToMap", "", $funcType([], [($mapType($String, $emptyInterface))], false), -1], ["ExportToMapWithTag", "ExportToMapWithTag", "", $funcType([$String], [($mapType($String, $emptyInterface))], false), -1], ["Get", "Get", "", $funcType([], [$emptyInterface], false), -1], ["IsSet", "IsSet", "", $funcType([$String], [$Bool], false), -1], ["Options", "Options", "", $funcType([($sliceType(Option))], [($ptrType(OptionsProvider))], true), -1]]; + OptionsProvider.init([["spec", "spec", "github.com/phaikawl/options", Spec, ""], ["m", "m", "github.com/phaikawl/options", ($mapType($String, $String)), ""], ["set", "set", "github.com/phaikawl/options", ($mapType($String, $Bool)), ""]]); }; - Scanner.prototype.error = function(offs, msg) { return this.$val.error(offs, msg); }; - Scanner.Ptr.prototype.interpretLineComment = function(text) { - var s, i, _tuple, line, err, filename; - s = this; - if (bytes.HasPrefix(text, prefix)) { - i = bytes.LastIndex(text, new ($sliceType($Uint8))([58])); - if (i > 0) { - _tuple = strconv.Atoi($bytesToString($subslice(text, (i + 1 >> 0)))); line = _tuple[0]; err = _tuple[1]; - if ($interfaceIsEqual(err, $ifaceNil) && line > 0) { - filename = $bytesToString(bytes.TrimSpace($subslice(text, prefix.$length, i))); - if (!(filename === "")) { - filename = filepath.Clean(filename); - if (!filepath.IsAbs(filename)) { - filename = filepath.Join(new ($sliceType($String))([s.dir, filename])); - } - } - s.file.AddLineInfo((s.lineOffset + text.$length >> 0) + 1 >> 0, filename, line); - } - } - } + return $pkg; +})(); +$packages["github.com/gopherjs/go-angularjs"] = (function() { + var $pkg = {}, fmt = $packages["fmt"], reflect = $packages["reflect"], inject = $packages["github.com/codegangsta/inject"], js = $packages["github.com/gopherjs/gopherjs/js"], options = $packages["github.com/phaikawl/options"], json = $packages["encoding/json"], AngularOpts, DummyJsObj, Injector, Angular, Module, provider, Provider, Interval, Scope, JQueryElement, Event, headersGetter, HttpTransformFunc, ReqMethod, ReqUrl, ReqParams, ReqData, ReqHeaders, ReqTransformReqFunc, ReqTransformRespFunc, ReqTimeout, ReqSpec, ReqOpts, HttpService, HttpProvider, httpMethod, Future, RequestCallback, RootScope, QProvider, RouteOpts, RouteProvider, RouteParams, _map, _key, x, x$1, x$2, x$3, x$4, x$5, x$6, x$7, AngularJs, NewInjector, InitAngular, NewProvider, NewModule, ElementById, HttpConfig; + AngularOpts = $pkg.AngularOpts = $newType(0, "Struct", "angularjs.AngularOpts", "AngularOpts", "github.com/gopherjs/go-angularjs", function(OptionsProvider_) { + this.$val = this; + this.OptionsProvider = OptionsProvider_ !== undefined ? OptionsProvider_ : ($ptrType(options.OptionsProvider)).nil; + }); + DummyJsObj = $pkg.DummyJsObj = $newType(0, "Struct", "angularjs.DummyJsObj", "DummyJsObj", "github.com/gopherjs/go-angularjs", function(Object_) { + this.$val = this; + this.Object = Object_ !== undefined ? Object_ : $ifaceNil; + }); + Injector = $pkg.Injector = $newType(0, "Struct", "angularjs.Injector", "Injector", "github.com/gopherjs/go-angularjs", function(Injector_, providers_) { + this.$val = this; + this.Injector = Injector_ !== undefined ? Injector_ : $ifaceNil; + this.providers = providers_ !== undefined ? providers_ : false; + }); + Angular = $pkg.Angular = $newType(0, "Struct", "angularjs.Angular", "Angular", "github.com/gopherjs/go-angularjs", function(Inj_) { + this.$val = this; + this.Inj = Inj_ !== undefined ? Inj_ : ($ptrType(Injector)).nil; + }); + Module = $pkg.Module = $newType(0, "Struct", "angularjs.Module", "Module", "github.com/gopherjs/go-angularjs", function(Object_) { + this.$val = this; + this.Object = Object_ !== undefined ? Object_ : $ifaceNil; + }); + provider = $pkg.provider = $newType(8, "Interface", "angularjs.provider", "provider", "github.com/gopherjs/go-angularjs", null); + Provider = $pkg.Provider = $newType(0, "Struct", "angularjs.Provider", "Provider", "github.com/gopherjs/go-angularjs", function(Object_, angularName_) { + this.$val = this; + this.Object = Object_ !== undefined ? Object_ : $ifaceNil; + this.angularName = angularName_ !== undefined ? angularName_ : ""; + }); + Interval = $pkg.Interval = $newType(0, "Struct", "angularjs.Interval", "Interval", "github.com/gopherjs/go-angularjs", function(Provider_) { + this.$val = this; + this.Provider = Provider_ !== undefined ? Provider_ : ($ptrType(Provider)).nil; + }); + Scope = $pkg.Scope = $newType(0, "Struct", "angularjs.Scope", "Scope", "github.com/gopherjs/go-angularjs", function(Provider_) { + this.$val = this; + this.Provider = Provider_ !== undefined ? Provider_ : ($ptrType(Provider)).nil; + }); + JQueryElement = $pkg.JQueryElement = $newType(0, "Struct", "angularjs.JQueryElement", "JQueryElement", "github.com/gopherjs/go-angularjs", function(Object_) { + this.$val = this; + this.Object = Object_ !== undefined ? Object_ : $ifaceNil; + }); + Event = $pkg.Event = $newType(0, "Struct", "angularjs.Event", "Event", "github.com/gopherjs/go-angularjs", function(Object_, KeyCode_) { + this.$val = this; + this.Object = Object_ !== undefined ? Object_ : $ifaceNil; + this.KeyCode = KeyCode_ !== undefined ? KeyCode_ : 0; + }); + headersGetter = $pkg.headersGetter = $newType(4, "Func", "angularjs.headersGetter", "headersGetter", "github.com/gopherjs/go-angularjs", null); + HttpTransformFunc = $pkg.HttpTransformFunc = $newType(4, "Func", "angularjs.HttpTransformFunc", "HttpTransformFunc", "github.com/gopherjs/go-angularjs", null); + ReqMethod = $pkg.ReqMethod = $newType(0, "Struct", "angularjs.ReqMethod", "ReqMethod", "github.com/gopherjs/go-angularjs", function(Value_) { + this.$val = this; + this.Value = Value_ !== undefined ? Value_ : ""; + }); + ReqUrl = $pkg.ReqUrl = $newType(0, "Struct", "angularjs.ReqUrl", "ReqUrl", "github.com/gopherjs/go-angularjs", function(Value_) { + this.$val = this; + this.Value = Value_ !== undefined ? Value_ : ""; + }); + ReqParams = $pkg.ReqParams = $newType(0, "Struct", "angularjs.ReqParams", "ReqParams", "github.com/gopherjs/go-angularjs", function(Value_) { + this.$val = this; + this.Value = Value_ !== undefined ? Value_ : false; + }); + ReqData = $pkg.ReqData = $newType(0, "Struct", "angularjs.ReqData", "ReqData", "github.com/gopherjs/go-angularjs", function(Value_) { + this.$val = this; + this.Value = Value_ !== undefined ? Value_ : ""; + }); + ReqHeaders = $pkg.ReqHeaders = $newType(0, "Struct", "angularjs.ReqHeaders", "ReqHeaders", "github.com/gopherjs/go-angularjs", function(Value_) { + this.$val = this; + this.Value = Value_ !== undefined ? Value_ : false; + }); + ReqTransformReqFunc = $pkg.ReqTransformReqFunc = $newType(0, "Struct", "angularjs.ReqTransformReqFunc", "ReqTransformReqFunc", "github.com/gopherjs/go-angularjs", function(Value_) { + this.$val = this; + this.Value = Value_ !== undefined ? Value_ : $throwNilPointerError; + }); + ReqTransformRespFunc = $pkg.ReqTransformRespFunc = $newType(0, "Struct", "angularjs.ReqTransformRespFunc", "ReqTransformRespFunc", "github.com/gopherjs/go-angularjs", function(Value_) { + this.$val = this; + this.Value = Value_ !== undefined ? Value_ : $throwNilPointerError; + }); + ReqTimeout = $pkg.ReqTimeout = $newType(0, "Struct", "angularjs.ReqTimeout", "ReqTimeout", "github.com/gopherjs/go-angularjs", function(Value_) { + this.$val = this; + this.Value = Value_ !== undefined ? Value_ : 0; + }); + ReqSpec = $pkg.ReqSpec = $newType(0, "Struct", "angularjs.ReqSpec", "ReqSpec", "github.com/gopherjs/go-angularjs", function(Method_, Url_, Params_, Data_, Headers_, TransformReq_, TransformResp_, Timeout_) { + this.$val = this; + this.Method = Method_ !== undefined ? Method_ : new ReqMethod.Ptr(); + this.Url = Url_ !== undefined ? Url_ : new ReqUrl.Ptr(); + this.Params = Params_ !== undefined ? Params_ : new ReqParams.Ptr(); + this.Data = Data_ !== undefined ? Data_ : new ReqData.Ptr(); + this.Headers = Headers_ !== undefined ? Headers_ : new ReqHeaders.Ptr(); + this.TransformReq = TransformReq_ !== undefined ? TransformReq_ : new ReqTransformReqFunc.Ptr(); + this.TransformResp = TransformResp_ !== undefined ? TransformResp_ : new ReqTransformRespFunc.Ptr(); + this.Timeout = Timeout_ !== undefined ? Timeout_ : new ReqTimeout.Ptr(); + }); + ReqOpts = $pkg.ReqOpts = $newType(0, "Struct", "angularjs.ReqOpts", "ReqOpts", "github.com/gopherjs/go-angularjs", function(AngularOpts_) { + this.$val = this; + this.AngularOpts = AngularOpts_ !== undefined ? AngularOpts_ : new AngularOpts.Ptr(); + }); + HttpService = $pkg.HttpService = $newType(0, "Struct", "angularjs.HttpService", "HttpService", "github.com/gopherjs/go-angularjs", function(Provider_) { + this.$val = this; + this.Provider = Provider_ !== undefined ? Provider_ : ($ptrType(Provider)).nil; + }); + HttpProvider = $pkg.HttpProvider = $newType(0, "Struct", "angularjs.HttpProvider", "HttpProvider", "github.com/gopherjs/go-angularjs", function(Provider_) { + this.$val = this; + this.Provider = Provider_ !== undefined ? Provider_ : ($ptrType(Provider)).nil; + }); + httpMethod = $pkg.httpMethod = $newType(8, "String", "angularjs.httpMethod", "httpMethod", "github.com/gopherjs/go-angularjs", null); + Future = $pkg.Future = $newType(0, "Struct", "angularjs.Future", "Future", "github.com/gopherjs/go-angularjs", function(Object_) { + this.$val = this; + this.Object = Object_ !== undefined ? Object_ : $ifaceNil; + }); + RequestCallback = $pkg.RequestCallback = $newType(8, "Interface", "angularjs.RequestCallback", "RequestCallback", "github.com/gopherjs/go-angularjs", null); + RootScope = $pkg.RootScope = $newType(0, "Struct", "angularjs.RootScope", "RootScope", "github.com/gopherjs/go-angularjs", function(Provider_) { + this.$val = this; + this.Provider = Provider_ !== undefined ? Provider_ : ($ptrType(Provider)).nil; + }); + QProvider = $pkg.QProvider = $newType(0, "Struct", "angularjs.QProvider", "QProvider", "github.com/gopherjs/go-angularjs", function(Provider_) { + this.$val = this; + this.Provider = Provider_ !== undefined ? Provider_ : ($ptrType(Provider)).nil; + }); + RouteOpts = $pkg.RouteOpts = $newType(0, "Struct", "angularjs.RouteOpts", "RouteOpts", "github.com/gopherjs/go-angularjs", function(AngularOpts_) { + this.$val = this; + this.AngularOpts = AngularOpts_ !== undefined ? AngularOpts_ : new AngularOpts.Ptr(); + }); + RouteProvider = $pkg.RouteProvider = $newType(0, "Struct", "angularjs.RouteProvider", "RouteProvider", "github.com/gopherjs/go-angularjs", function(Provider_) { + this.$val = this; + this.Provider = Provider_ !== undefined ? Provider_ : ($ptrType(Provider)).nil; + }); + RouteParams = $pkg.RouteParams = $newType(0, "Struct", "angularjs.RouteParams", "RouteParams", "github.com/gopherjs/go-angularjs", function(Provider_) { + this.$val = this; + this.Provider = Provider_ !== undefined ? Provider_ : ($ptrType(Provider)).nil; + }); + AngularOpts.Ptr.prototype.toJs = function() { + var o; + o = this; + return o.OptionsProvider.ExportToMapWithTag("js"); }; - Scanner.prototype.interpretLineComment = function(text) { return this.$val.interpretLineComment(text); }; - Scanner.Ptr.prototype.scanComment = function() { - var $this = this, $args = arguments, $s = 0, s, offs, hasCR, ch, lit; - /* */ while (true) { switch ($s) { case 0: - s = $this; - offs = s.offset - 1 >> 0; - hasCR = false; - /* if (s.ch === 47) { */ if (s.ch === 47) {} else { $s = 2; continue; } - s.next(); - while (!((s.ch === 10)) && s.ch >= 0) { - if (s.ch === 13) { - hasCR = true; - } - s.next(); - } - if (offs === s.lineOffset) { - s.interpretLineComment($subslice(s.src, offs, s.offset)); - } - /* goto exit */ $s = 1; continue; - /* } */ case 2: - s.next(); - /* while (s.ch >= 0) { */ case 3: if(!(s.ch >= 0)) { $s = 4; continue; } - ch = s.ch; - if (ch === 13) { - hasCR = true; - } - s.next(); - /* if ((ch === 42) && (s.ch === 47)) { */ if ((ch === 42) && (s.ch === 47)) {} else { $s = 5; continue; } - s.next(); - /* goto exit */ $s = 1; continue; - /* } */ case 5: - /* } */ $s = 3; continue; case 4: - s.error(offs, "comment not terminated"); - /* exit: */ case 1: - lit = $subslice(s.src, offs, s.offset); - if (hasCR) { - lit = stripCR(lit); - } - return $bytesToString(lit); - /* */ case -1: } return; } + AngularOpts.prototype.toJs = function() { return this.$val.toJs(); }; + DummyJsObj.Ptr.prototype.Get = function(name) { + var obj; + obj = new DummyJsObj.Ptr(); $copy(obj, this, DummyJsObj); + return new obj.constructor.Struct(obj); }; - Scanner.prototype.scanComment = function() { return this.$val.scanComment(); }; - Scanner.Ptr.prototype.findLineEnd = function() { - var $deferred = [], $err = null, s, ch; + DummyJsObj.prototype.Get = function(name) { return this.$val.Get(name); }; + DummyJsObj.Ptr.prototype.Call = function(name, params) { + var obj; + obj = new DummyJsObj.Ptr(); $copy(obj, this, DummyJsObj); + return new obj.constructor.Struct(obj); + }; + DummyJsObj.prototype.Call = function(name, params) { return this.$val.Call(name, params); }; + AngularJs = $pkg.AngularJs = function() { + var obj = $ifaceNil, $deferred = [], $err = null; /* */ try { $deferFrames.push($deferred); - s = this; - $deferred.push([(function(offs) { - s.ch = 47; - s.offset = offs; - s.rdOffset = offs + 1 >> 0; - s.next(); - }), [s.offset - 1 >> 0]]); - while ((s.ch === 47) || (s.ch === 42)) { - if (s.ch === 47) { - return true; + $deferred.push([(function() { + var r, x$8; + r = $recover(); + if (!($interfaceIsEqual(r, $ifaceNil))) { + obj = (x$8 = new DummyJsObj.Ptr($ifaceNil), new x$8.constructor.Struct(x$8)); } - s.next(); - while (s.ch >= 0) { - ch = s.ch; - if (ch === 10) { - return true; - } - s.next(); - if ((ch === 42) && (s.ch === 47)) { - s.next(); - break; - } + }), []]); + obj = $global.angular; + return obj; + /* */ } catch(err) { $err = err; } finally { $deferFrames.pop(); $callDeferred($deferred, $err); return obj; } + }; + NewInjector = $pkg.NewInjector = function() { + var inj; + inj = new Injector.Ptr(inject.New(), $pkg.AngularProvidersList); + return inj; + }; + Injector.Ptr.prototype.requestedProviders = function(fn) { + var providers = ($sliceType(provider)).nil, inj, t, i, argType, ok, _tuple, _entry; + inj = this; + t = reflect.TypeOf(fn); + providers = ($sliceType(provider)).make(t.NumIn()); + i = 0; + while (i < t.NumIn()) { + argType = t.In(i).Elem(); + ok = false; + _tuple = (_entry = inj.providers[argType.$key()], _entry !== undefined ? [_entry.v, true] : [$ifaceNil, false]); (i < 0 || i >= providers.$length) ? $throwRuntimeError("index out of range") : providers.$array[providers.$offset + i] = _tuple[0]; ok = _tuple[1]; + if (!ok) { + $panic(new $String(fmt.Sprintf("Invalid provider type %v.", new ($sliceType($emptyInterface))([new $String(argType.Name())])))); } - s.skipWhitespace(); - if (s.ch < 0 || (s.ch === 10)) { - return true; + i = i + (1) >> 0; + } + return providers; + }; + Injector.prototype.requestedProviders = function(fn) { return this.$val.requestedProviders(fn); }; + Injector.Ptr.prototype._angularDeps = function(fn, transformFn) { + var inj, rp, deps, _ref, _i, i; + inj = this; + rp = inj.requestedProviders(fn); + deps = ($sliceType($emptyInterface)).make(rp.$length); + _ref = rp; + _i = 0; + while (_i < _ref.$length) { + i = _i; + (i < 0 || i >= deps.$length) ? $throwRuntimeError("index out of range") : deps.$array[deps.$offset + i] = new $String(((i < 0 || i >= rp.$length) ? $throwRuntimeError("index out of range") : rp.$array[rp.$offset + i]).AngularName()); + _i++; + } + deps = $append(deps, new ($funcType([($sliceType(js.Object))], [$emptyInterface], true))((function(providers) { + var in$1, _ref$1, _i$1, i$1, p, x$8; + in$1 = ($sliceType(reflect.Value)).make(rp.$length); + _ref$1 = rp; + _i$1 = 0; + while (_i$1 < _ref$1.$length) { + i$1 = _i$1; + p = ((_i$1 < 0 || _i$1 >= _ref$1.$length) ? $throwRuntimeError("index out of range") : _ref$1.$array[_ref$1.$offset + _i$1]); + p.SetJs(((i$1 < 0 || i$1 >= providers.$length) ? $throwRuntimeError("index out of range") : providers.$array[providers.$offset + i$1])); + $copy(((i$1 < 0 || i$1 >= in$1.$length) ? $throwRuntimeError("index out of range") : in$1.$array[in$1.$offset + i$1]), reflect.ValueOf(p), reflect.Value); + _i$1++; } - if (!((s.ch === 47))) { - return false; + if (reflect.TypeOf(fn).NumOut() > 0 && !(transformFn === $throwNilPointerError)) { + return transformFn($clone((x$8 = reflect.ValueOf(fn).Call(in$1), ((0 < 0 || 0 >= x$8.$length) ? $throwRuntimeError("index out of range") : x$8.$array[x$8.$offset + 0])), reflect.Value)).Interface(); } - s.next(); - } - return false; - /* */ } catch(err) { $err = err; return false; } finally { $deferFrames.pop(); $callDeferred($deferred, $err); } + reflect.ValueOf(fn).Call(in$1); + return $ifaceNil; + }))); + return deps; }; - Scanner.prototype.findLineEnd = function() { return this.$val.findLineEnd(); }; - isLetter = function(ch) { - return 97 <= ch && ch <= 122 || 65 <= ch && ch <= 90 || (ch === 95) || ch >= 128 && unicode.IsLetter(ch); + Injector.prototype._angularDeps = function(fn, transformFn) { return this.$val._angularDeps(fn, transformFn); }; + Injector.Ptr.prototype.angularDeps = function(fn) { + var inj; + inj = this; + return inj._angularDeps(fn, (function(v) { + return v; + })); }; - isDigit = function(ch) { - return 48 <= ch && ch <= 57 || ch >= 128 && unicode.IsDigit(ch); + Injector.prototype.angularDeps = function(fn) { return this.$val.angularDeps(fn); }; + InitAngular = $pkg.InitAngular = function() { + var ng; + ng = new Angular.Ptr(NewInjector()); + return ng; }; - Scanner.Ptr.prototype.scanIdentifier = function() { - var s, offs; - s = this; - offs = s.offset; - while (isLetter(s.ch) || isDigit(s.ch)) { - s.next(); - } - return $bytesToString($subslice(s.src, offs, s.offset)); + NewProvider = $pkg.NewProvider = function(name) { + var p; + p = new Provider.Ptr($ifaceNil, ""); + p.angularName = name; + return p; }; - Scanner.prototype.scanIdentifier = function() { return this.$val.scanIdentifier(); }; - digitVal = function(ch) { - if (48 <= ch && ch <= 57) { - return ((ch - 48 >> 0) >> 0); - } else if (97 <= ch && ch <= 102) { - return (((ch - 97 >> 0) + 10 >> 0) >> 0); - } else if (65 <= ch && ch <= 70) { - return (((ch - 65 >> 0) + 10 >> 0) >> 0); - } - return 16; + Provider.Ptr.prototype.SetJs = function(obj) { + var p; + p = this; + p.Object = obj; }; - Scanner.Ptr.prototype.scanMantissa = function(base) { - var s; - s = this; - while (digitVal(s.ch) < base) { - s.next(); - } + Provider.prototype.SetJs = function(obj) { return this.$val.SetJs(obj); }; + Provider.Ptr.prototype.AngularName = function() { + var p; + p = this; + return p.angularName; }; - Scanner.prototype.scanMantissa = function(base) { return this.$val.scanMantissa(base); }; - Scanner.Ptr.prototype.scanNumber = function(seenDecimalPoint) { - var $this = this, $args = arguments, $s = 0, s, offs, tok, offs$1, seenDecimalDigit; - /* */ while (true) { switch ($s) { case 0: - s = $this; - offs = s.offset; - tok = 5; - /* if (seenDecimalPoint) { */ if (seenDecimalPoint) {} else { $s = 4; continue; } - offs = offs - (1) >> 0; - tok = 6; - s.scanMantissa(10); - /* goto exponent */ $s = 1; continue; - /* } */ case 4: - /* if (s.ch === 48) { */ if (s.ch === 48) {} else { $s = 5; continue; } - offs$1 = s.offset; - s.next(); - /* if ((s.ch === 120) || (s.ch === 88)) { */ if ((s.ch === 120) || (s.ch === 88)) {} else { $s = 6; continue; } - s.next(); - s.scanMantissa(16); - if ((s.offset - offs$1 >> 0) <= 2) { - s.error(offs$1, "illegal hexadecimal number"); - } - /* } else { */ $s = 7; continue; case 6: - seenDecimalDigit = false; - s.scanMantissa(8); - if ((s.ch === 56) || (s.ch === 57)) { - seenDecimalDigit = true; - s.scanMantissa(10); - } - /* if ((s.ch === 46) || (s.ch === 101) || (s.ch === 69) || (s.ch === 105)) { */ if ((s.ch === 46) || (s.ch === 101) || (s.ch === 69) || (s.ch === 105)) {} else { $s = 8; continue; } - /* goto fraction */ $s = 2; continue; - /* } */ case 8: - if (seenDecimalDigit) { - s.error(offs$1, "illegal octal number"); - } - /* } */ case 7: - /* goto exit */ $s = 3; continue; - /* } */ case 5: - s.scanMantissa(10); - /* fraction: */ case 2: - if (s.ch === 46) { - tok = 6; - s.next(); - s.scanMantissa(10); - } - /* exponent: */ case 1: - if ((s.ch === 101) || (s.ch === 69)) { - tok = 6; - s.next(); - if ((s.ch === 45) || (s.ch === 43)) { - s.next(); - } - s.scanMantissa(10); - } - if (s.ch === 105) { - tok = 7; - s.next(); - } - /* exit: */ case 3: - return [tok, $bytesToString($subslice(s.src, offs, s.offset))]; - /* */ case -1: } return; } + Provider.prototype.AngularName = function() { return this.$val.AngularName(); }; + Module.Ptr.prototype.Config = function(fn) { + var m; + m = this; + m.Object.config($externalize($pkg.Ng.Inj.angularDeps(fn), ($sliceType($emptyInterface)))); }; - Scanner.prototype.scanNumber = function(seenDecimalPoint) { return this.$val.scanNumber(seenDecimalPoint); }; - Scanner.Ptr.prototype.scanEscape = function(quote) { - var s, offs, n, _tmp, _tmp$1, base, max, _ref, _tmp$2, _tmp$3, _tmp$4, _tmp$5, _tmp$6, _tmp$7, _tmp$8, _tmp$9, _tmp$10, _tmp$11, _tmp$12, _tmp$13, msg, x, d, msg$1; + Module.prototype.Config = function(fn) { return this.$val.Config(fn); }; + Module.Ptr.prototype.Factory = function(name, fn) { + var m; + m = this; + m.Object.factory($externalize(name, $String), $externalize($pkg.Ng.Inj.angularDeps(fn), ($sliceType($emptyInterface)))); + }; + Module.prototype.Factory = function(name, fn) { return this.$val.Factory(name, fn); }; + Module.Ptr.prototype.NewController = function(name, constructor) { + var m; + m = this; + m.Object.controller($externalize(name, $String), $externalize($pkg.Ng.Inj.angularDeps(constructor), ($sliceType($emptyInterface)))); + }; + Module.prototype.NewController = function(name, constructor) { return this.$val.NewController(name, constructor); }; + Module.Ptr.prototype.Filter = function(name, constructor) { + var m; + m = this; + m.Object.filter($externalize(name, $String), $externalize($pkg.Ng.Inj.angularDeps(constructor), ($sliceType($emptyInterface)))); + }; + Module.prototype.Filter = function(name, constructor) { return this.$val.Filter(name, constructor); }; + Scope.Ptr.prototype.Apply = function(f) { + var s; s = this; - offs = s.offset; - n = 0; - _tmp = 0; _tmp$1 = 0; base = _tmp; max = _tmp$1; - _ref = s.ch; - if (_ref === 97 || _ref === 98 || _ref === 102 || _ref === 110 || _ref === 114 || _ref === 116 || _ref === 118 || _ref === 92 || _ref === quote) { - s.next(); - return true; - } else if (_ref === 48 || _ref === 49 || _ref === 50 || _ref === 51 || _ref === 52 || _ref === 53 || _ref === 54 || _ref === 55) { - _tmp$2 = 3; _tmp$3 = 8; _tmp$4 = 255; n = _tmp$2; base = _tmp$3; max = _tmp$4; - } else if (_ref === 120) { - s.next(); - _tmp$5 = 2; _tmp$6 = 16; _tmp$7 = 255; n = _tmp$5; base = _tmp$6; max = _tmp$7; - } else if (_ref === 117) { - s.next(); - _tmp$8 = 4; _tmp$9 = 16; _tmp$10 = 1114111; n = _tmp$8; base = _tmp$9; max = _tmp$10; - } else if (_ref === 85) { - s.next(); - _tmp$11 = 8; _tmp$12 = 16; _tmp$13 = 1114111; n = _tmp$11; base = _tmp$12; max = _tmp$13; - } else { - msg = "unknown escape sequence"; - if (s.ch < 0) { - msg = "escape sequence not terminated"; - } - s.error(offs, msg); - return false; - } - x = 0; - while (n > 0) { - d = (digitVal(s.ch) >>> 0); - if (d >= base) { - msg$1 = fmt.Sprintf("illegal character %#U in escape sequence", new ($sliceType($emptyInterface))([new $Int32(s.ch)])); - if (s.ch < 0) { - msg$1 = "escape sequence not terminated"; - } - s.error(s.offset, msg$1); - return false; - } - x = ((((x >>> 16 << 16) * base >>> 0) + (x << 16 >>> 16) * base) >>> 0) + d >>> 0; - s.next(); - n = n - (1) >> 0; - } - if (x > max || 55296 <= x && x < 57344) { - s.error(offs, "escape sequence is invalid Unicode code point"); - return false; - } - return true; + s.Provider.Object.$apply($externalize(f, ($funcType([], [], false)))); }; - Scanner.prototype.scanEscape = function(quote) { return this.$val.scanEscape(quote); }; - Scanner.Ptr.prototype.scanRune = function() { - var s, offs, valid, n, ch; + Scope.prototype.Apply = function(f) { return this.$val.Apply(f); }; + Scope.Ptr.prototype.EvalAsync = function(f) { + var s; s = this; - offs = s.offset - 1 >> 0; - valid = true; - n = 0; - while (true) { - ch = s.ch; - if ((ch === 10) || ch < 0) { - if (valid) { - s.error(offs, "rune literal not terminated"); - valid = false; + s.Provider.Object.$evalAsync($externalize(f, ($funcType([], [], false)))); + }; + Scope.prototype.EvalAsync = function(f) { return this.$val.EvalAsync(f); }; + JQueryElement.Ptr.prototype.Prop = function(name) { + var e; + e = this; + return e.Object.prop($externalize(name, $String)); + }; + JQueryElement.prototype.Prop = function(name) { return this.$val.Prop(name); }; + JQueryElement.Ptr.prototype.SetProp = function(name, value) { + var e; + e = this; + e.Object.prop($externalize(name, $emptyInterface), $externalize(value, $emptyInterface)); + }; + JQueryElement.prototype.SetProp = function(name, value) { return this.$val.SetProp(name, value); }; + JQueryElement.Ptr.prototype.On = function(events, handler) { + var e; + e = this; + e.Object.on($externalize(events, $String), $externalize((function(e$1) { + handler(new Event.Ptr(e$1, 0)); + }), ($funcType([js.Object], [], false)))); + }; + JQueryElement.prototype.On = function(events, handler) { return this.$val.On(events, handler); }; + JQueryElement.Ptr.prototype.Val = function() { + var e; + e = this; + return e.Object.val(); + }; + JQueryElement.prototype.Val = function() { return this.$val.Val(); }; + JQueryElement.Ptr.prototype.SetVal = function(value) { + var e; + e = this; + e.Object.val($externalize(value, $emptyInterface)); + }; + JQueryElement.prototype.SetVal = function(value) { return this.$val.SetVal(value); }; + Event.Ptr.prototype.PreventDefault = function() { + var e; + e = this; + e.Object.preventDefault(); + }; + Event.prototype.PreventDefault = function() { return this.$val.PreventDefault(); }; + NewModule = $pkg.NewModule = function(name, requires) { + return new Module.Ptr(AngularJs().module($externalize(name, $String), $externalize(requires, ($sliceType($String))))); + }; + ElementById = $pkg.ElementById = function(id) { + return new JQueryElement.Ptr(AngularJs().element($global.document.getElementById($externalize(id, $String)))); + }; + ReqOpts.Ptr.prototype.Spec = function() { + var r; + r = this; + return $assertType(r.AngularOpts.OptionsProvider.Get(), ($ptrType(ReqSpec))); + }; + ReqOpts.prototype.Spec = function() { return this.$val.Spec(); }; + HttpConfig = $pkg.HttpConfig = function(opts) { + return new ReqOpts.Ptr(new AngularOpts.Ptr(options.NewOptions(new ReqSpec.Ptr(new ReqMethod.Ptr(), new ReqUrl.Ptr(), new ReqParams.Ptr(), new ReqData.Ptr(), new ReqHeaders.Ptr(), new ReqTransformReqFunc.Ptr(), new ReqTransformRespFunc.Ptr(), new ReqTimeout.Ptr())).Options(opts))); + }; + Future.Ptr.prototype.call = function(state, callback) { + var ft; + ft = this; + ft.Object[$externalize(state, $String)]($externalize((function(data, status, headers, config) { + var cbt, in$1, dparam, d, _ref, _tuple, ok, sdata, ok$1, _tuple$1, err; + cbt = reflect.TypeOf(callback); + in$1 = ($sliceType(reflect.Value)).make(cbt.NumIn()); + dparam = cbt.In(0); + d = new reflect.Value.Ptr(); $copy(d, new reflect.Value.Ptr(), reflect.Value); + _ref = dparam.Name(); + if (_ref === "string") { + _tuple = $assertType(data, $String, true); ok = _tuple[1]; + if (!ok) { + $panic(new $String("Type mismatch.")); } - break; - } - s.next(); - if (ch === 39) { - break; - } - n = n + (1) >> 0; - if (ch === 92) { - if (!s.scanEscape(39)) { - valid = false; + $copy(d, reflect.ValueOf(data), reflect.Value); + } else { + sdata = ""; + ok$1 = false; + _tuple$1 = $assertType(data, $String, true); sdata = _tuple$1[0]; ok$1 = _tuple$1[1]; + if (!ok$1) { + $panic(new $String("Something is wrong.")); + } + $copy(d, reflect.New(dparam), reflect.Value); + err = json.Unmarshal(new ($sliceType($Uint8))($stringToBytes(sdata)), d.Interface()); + if (!($interfaceIsEqual(err, $ifaceNil))) { + $panic(new $String(fmt.Sprintf("Response \"%v\" cannot be parsed to type %s. Error %v", new ($sliceType($emptyInterface))([new $String(sdata), dparam, new $String(err.Error())])))); } } - } - if (valid && !((n === 1))) { - s.error(offs, "illegal rune literal"); - } - return $bytesToString($subslice(s.src, offs, s.offset)); - }; - Scanner.prototype.scanRune = function() { return this.$val.scanRune(); }; - Scanner.Ptr.prototype.scanString = function() { - var s, offs, ch; - s = this; - offs = s.offset - 1 >> 0; - while (true) { - ch = s.ch; - if ((ch === 10) || ch < 0) { - s.error(offs, "string literal not terminated"); - break; - } - s.next(); - if (ch === 34) { - break; - } - if (ch === 92) { - s.scanEscape(34); + if (in$1.$length < 2) { + $panic(new $String("Can't map response to callback arguments. Should be func(data interface{}, status int)")); } - } - return $bytesToString($subslice(s.src, offs, s.offset)); + $copy(((0 < 0 || 0 >= in$1.$length) ? $throwRuntimeError("index out of range") : in$1.$array[in$1.$offset + 0]), d.Elem(), reflect.Value); + $copy(((1 < 0 || 1 >= in$1.$length) ? $throwRuntimeError("index out of range") : in$1.$array[in$1.$offset + 1]), reflect.ValueOf(new $Int(status)), reflect.Value); + reflect.ValueOf(callback).Call(in$1); + }), ($funcType([$emptyInterface, $Int, js.Object, js.Object], [], false)))); + return ft; }; - Scanner.prototype.scanString = function() { return this.$val.scanString(); }; - stripCR = function(b) { - var c, i, _ref, _i, ch; - c = ($sliceType($Uint8)).make(b.$length); - i = 0; - _ref = b; - _i = 0; - while (_i < _ref.$length) { - ch = ((_i < 0 || _i >= _ref.$length) ? $throwRuntimeError("index out of range") : _ref.$array[_ref.$offset + _i]); - if (!((ch === 13))) { - (i < 0 || i >= c.$length) ? $throwRuntimeError("index out of range") : c.$array[c.$offset + i] = ch; - i = i + (1) >> 0; - } - _i++; - } - return $subslice(c, 0, i); + Future.prototype.call = function(state, callback) { return this.$val.call(state, callback); }; + Future.Ptr.prototype.Success = function(callback) { + var ft; + ft = this; + return ft.call("success", callback); }; - Scanner.Ptr.prototype.scanRawString = function() { - var s, offs, hasCR, ch, lit; - s = this; - offs = s.offset - 1 >> 0; - hasCR = false; - while (true) { - ch = s.ch; - if (ch < 0) { - s.error(offs, "raw string literal not terminated"); - break; - } - s.next(); - if (ch === 96) { - break; - } - if (ch === 13) { - hasCR = true; - } - } - lit = $subslice(s.src, offs, s.offset); - if (hasCR) { - lit = stripCR(lit); - } - return $bytesToString(lit); + Future.prototype.Success = function(callback) { return this.$val.Success(callback); }; + Future.Ptr.prototype.Error = function(callback) { + var ft; + ft = this; + return ft.call("error", callback); }; - Scanner.prototype.scanRawString = function() { return this.$val.scanRawString(); }; - Scanner.Ptr.prototype.skipWhitespace = function() { - var s; + Future.prototype.Error = function(callback) { return this.$val.Error(callback); }; + HttpService.Ptr.prototype.SimpleRequest = function(method, url) { + var s, x$8, x$9; s = this; - while ((s.ch === 32) || (s.ch === 9) || (s.ch === 10) && !s.insertSemi || (s.ch === 13)) { - s.next(); - } + return s.Request(HttpConfig(new ($sliceType(options.Option))([(x$8 = new ReqMethod.Ptr(method), new x$8.constructor.Struct(x$8)), (x$9 = new ReqUrl.Ptr(url), new x$9.constructor.Struct(x$9))]))); }; - Scanner.prototype.skipWhitespace = function() { return this.$val.skipWhitespace(); }; - Scanner.Ptr.prototype.switch2 = function(tok0, tok1) { - var s; + HttpService.prototype.SimpleRequest = function(method, url) { return this.$val.SimpleRequest(method, url); }; + HttpService.Ptr.prototype.Request = function(spec) { + var s, x$8, future; s = this; - if (s.ch === 61) { - s.next(); - return tok1; + if (!spec.AngularOpts.OptionsProvider.IsSet("TransformReq")) { + spec.AngularOpts.OptionsProvider.Options(new ($sliceType(options.Option))([(x$8 = new ReqTransformRespFunc.Ptr((function(data, hg) { + return data; + })), new x$8.constructor.Struct(x$8))])); } - return tok0; + future = s.Provider.Object($externalize(spec.AngularOpts.toJs(), ($mapType($String, $emptyInterface)))); + return new Future.Ptr(future); }; - Scanner.prototype.switch2 = function(tok0, tok1) { return this.$val.switch2(tok0, tok1); }; - Scanner.Ptr.prototype.switch3 = function(tok0, tok1, ch2, tok2) { + HttpService.prototype.Request = function(spec) { return this.$val.Request(spec); }; + HttpService.Ptr.prototype.Get = function(url) { var s; s = this; - if (s.ch === 61) { - s.next(); - return tok1; - } - if (s.ch === ch2) { - s.next(); - return tok2; - } - return tok0; + return s.SimpleRequest("GET", url); }; - Scanner.prototype.switch3 = function(tok0, tok1, ch2, tok2) { return this.$val.switch3(tok0, tok1, ch2, tok2); }; - Scanner.Ptr.prototype.switch4 = function(tok0, tok1, ch2, tok2, tok3) { - var s; - s = this; - if (s.ch === 61) { - s.next(); - return tok1; - } - if (s.ch === ch2) { - s.next(); - if (s.ch === 61) { - s.next(); - return tok3; - } - return tok2; - } - return tok0; + HttpService.prototype.Get = function(url) { return this.$val.Get(url); }; + QProvider.Ptr.prototype.Defer = function() { + var q; + q = this; + return q.Provider.Object.defer(); }; - Scanner.prototype.switch4 = function(tok0, tok1, ch2, tok2, tok3) { return this.$val.switch4(tok0, tok1, ch2, tok2, tok3); }; - Scanner.Ptr.prototype.Scan = function() { - var $this = this, $args = arguments, pos = 0, tok = 0, lit = "", $s = 0, s, insertSemi, ch, _ref, _tuple, _ref$1, _tmp, _tmp$1, _tmp$2, _tmp$3, _tmp$4, _tmp$5, _tuple$1, _tmp$6, _tmp$7, _tmp$8; - /* */ while (true) { switch ($s) { case 0: - s = $this; - /* scanAgain: */ case 1: - s.skipWhitespace(); - pos = s.file.Pos(s.offset); - insertSemi = false; - ch = s.ch; - /* if (isLetter(ch)) { */ if (isLetter(ch)) {} else if (48 <= ch && ch <= 57) { $s = 2; continue; } else { $s = 3; continue; } - lit = s.scanIdentifier(); - if (lit.length > 1) { - tok = token.Lookup(lit); - _ref = tok; - if (_ref === 4 || _ref === 61 || _ref === 65 || _ref === 69 || _ref === 80) { - insertSemi = true; - } - } else { - insertSemi = true; - tok = 4; - } - /* } else if (48 <= ch && ch <= 57) { */ $s = 4; continue; case 2: - insertSemi = true; - _tuple = s.scanNumber(false); tok = _tuple[0]; lit = _tuple[1]; - /* } else { */ $s = 4; continue; case 3: - s.next(); - _ref$1 = ch; - /* if (_ref$1 === -1) { */ if (_ref$1 === -1) {} else if (_ref$1 === 10) { $s = 5; continue; } else if (_ref$1 === 34) { $s = 6; continue; } else if (_ref$1 === 39) { $s = 7; continue; } else if (_ref$1 === 96) { $s = 8; continue; } else if (_ref$1 === 58) { $s = 9; continue; } else if (_ref$1 === 46) { $s = 10; continue; } else if (_ref$1 === 44) { $s = 11; continue; } else if (_ref$1 === 59) { $s = 12; continue; } else if (_ref$1 === 40) { $s = 13; continue; } else if (_ref$1 === 41) { $s = 14; continue; } else if (_ref$1 === 91) { $s = 15; continue; } else if (_ref$1 === 93) { $s = 16; continue; } else if (_ref$1 === 123) { $s = 17; continue; } else if (_ref$1 === 125) { $s = 18; continue; } else if (_ref$1 === 43) { $s = 19; continue; } else if (_ref$1 === 45) { $s = 20; continue; } else if (_ref$1 === 42) { $s = 21; continue; } else if (_ref$1 === 47) { $s = 22; continue; } else if (_ref$1 === 37) { $s = 23; continue; } else if (_ref$1 === 94) { $s = 24; continue; } else if (_ref$1 === 60) { $s = 25; continue; } else if (_ref$1 === 62) { $s = 26; continue; } else if (_ref$1 === 61) { $s = 27; continue; } else if (_ref$1 === 33) { $s = 28; continue; } else if (_ref$1 === 38) { $s = 29; continue; } else if (_ref$1 === 124) { $s = 30; continue; } else { $s = 31; continue; } - if (s.insertSemi) { - s.insertSemi = false; - _tmp = pos; _tmp$1 = 57; _tmp$2 = "\n"; pos = _tmp; tok = _tmp$1; lit = _tmp$2; - return [pos, tok, lit]; - } - tok = 1; - /* } else if (_ref$1 === 10) { */ $s = 32; continue; case 5: - s.insertSemi = false; - _tmp$3 = pos; _tmp$4 = 57; _tmp$5 = "\n"; pos = _tmp$3; tok = _tmp$4; lit = _tmp$5; - return [pos, tok, lit]; - /* } else if (_ref$1 === 34) { */ $s = 32; continue; case 6: - insertSemi = true; - tok = 9; - lit = s.scanString(); - /* } else if (_ref$1 === 39) { */ $s = 32; continue; case 7: - insertSemi = true; - tok = 8; - lit = s.scanRune(); - /* } else if (_ref$1 === 96) { */ $s = 32; continue; case 8: - insertSemi = true; - tok = 9; - lit = s.scanRawString(); - /* } else if (_ref$1 === 58) { */ $s = 32; continue; case 9: - tok = s.switch2(58, 47); - /* } else if (_ref$1 === 46) { */ $s = 32; continue; case 10: - if (48 <= s.ch && s.ch <= 57) { - insertSemi = true; - _tuple$1 = s.scanNumber(true); tok = _tuple$1[0]; lit = _tuple$1[1]; - } else if (s.ch === 46) { - s.next(); - if (s.ch === 46) { - s.next(); - tok = 48; - } - } else { - tok = 53; - } - /* } else if (_ref$1 === 44) { */ $s = 32; continue; case 11: - tok = 52; - /* } else if (_ref$1 === 59) { */ $s = 32; continue; case 12: - tok = 57; - lit = ";"; - /* } else if (_ref$1 === 40) { */ $s = 32; continue; case 13: - tok = 49; - /* } else if (_ref$1 === 41) { */ $s = 32; continue; case 14: - insertSemi = true; - tok = 54; - /* } else if (_ref$1 === 91) { */ $s = 32; continue; case 15: - tok = 50; - /* } else if (_ref$1 === 93) { */ $s = 32; continue; case 16: - insertSemi = true; - tok = 55; - /* } else if (_ref$1 === 123) { */ $s = 32; continue; case 17: - tok = 51; - /* } else if (_ref$1 === 125) { */ $s = 32; continue; case 18: - insertSemi = true; - tok = 56; - /* } else if (_ref$1 === 43) { */ $s = 32; continue; case 19: - tok = s.switch3(12, 23, 43, 37); - if (tok === 37) { - insertSemi = true; - } - /* } else if (_ref$1 === 45) { */ $s = 32; continue; case 20: - tok = s.switch3(13, 24, 45, 38); - if (tok === 38) { - insertSemi = true; - } - /* } else if (_ref$1 === 42) { */ $s = 32; continue; case 21: - tok = s.switch2(14, 25); - /* } else if (_ref$1 === 47) { */ $s = 32; continue; case 22: - /* if ((s.ch === 47) || (s.ch === 42)) { */ if ((s.ch === 47) || (s.ch === 42)) {} else { $s = 33; continue; } - if (s.insertSemi && s.findLineEnd()) { - s.ch = 47; - s.offset = s.file.Offset(pos); - s.rdOffset = s.offset + 1 >> 0; - s.insertSemi = false; - _tmp$6 = pos; _tmp$7 = 57; _tmp$8 = "\n"; pos = _tmp$6; tok = _tmp$7; lit = _tmp$8; - return [pos, tok, lit]; - } - lit = s.scanComment(); - /* if (((s.mode & 1) >>> 0) === 0) { */ if (((s.mode & 1) >>> 0) === 0) {} else { $s = 35; continue; } - s.insertSemi = false; - /* goto scanAgain */ $s = 1; continue; - /* } */ case 35: - tok = 2; - /* } else { */ $s = 34; continue; case 33: - tok = s.switch2(15, 26); - /* } */ case 34: - /* } else if (_ref$1 === 37) { */ $s = 32; continue; case 23: - tok = s.switch2(16, 27); - /* } else if (_ref$1 === 94) { */ $s = 32; continue; case 24: - tok = s.switch2(19, 30); - /* } else if (_ref$1 === 60) { */ $s = 32; continue; case 25: - if (s.ch === 45) { - s.next(); - tok = 36; - } else { - tok = s.switch4(40, 45, 60, 20, 31); - } - /* } else if (_ref$1 === 62) { */ $s = 32; continue; case 26: - tok = s.switch4(41, 46, 62, 21, 32); - /* } else if (_ref$1 === 61) { */ $s = 32; continue; case 27: - tok = s.switch2(42, 39); - /* } else if (_ref$1 === 33) { */ $s = 32; continue; case 28: - tok = s.switch2(43, 44); - /* } else if (_ref$1 === 38) { */ $s = 32; continue; case 29: - if (s.ch === 94) { - s.next(); - tok = s.switch2(22, 33); - } else { - tok = s.switch3(17, 28, 38, 34); - } - /* } else if (_ref$1 === 124) { */ $s = 32; continue; case 30: - tok = s.switch3(18, 29, 124, 35); - /* } else { */ $s = 32; continue; case 31: - if (!((ch === 65279))) { - s.error(s.file.Offset(pos), fmt.Sprintf("illegal character %#U", new ($sliceType($emptyInterface))([new $Int32(ch)]))); - } - insertSemi = s.insertSemi; - tok = 0; - lit = $encodeRune(ch); - /* } */ case 32: - /* } */ case 4: - if (((s.mode & 2) >>> 0) === 0) { - s.insertSemi = insertSemi; + QProvider.prototype.Defer = function() { return this.$val.Defer(); }; + QProvider.Ptr.prototype.When = function(value) { + var q; + q = this; + return q.Provider.Object.when(value); + }; + QProvider.prototype.When = function(value) { return this.$val.When(value); }; + QProvider.Ptr.prototype.Reject = function(reason) { + var q; + q = this; + return q.Provider.Object.reject($externalize(reason, $String)); + }; + QProvider.prototype.Reject = function(reason) { return this.$val.Reject(reason); }; + QProvider.Ptr.prototype.All = function(promises) { + var q; + q = this; + return q.Provider.Object.all($externalize(promises, ($sliceType(js.Object)))); + }; + QProvider.prototype.All = function(promises) { return this.$val.All(promises); }; + QProvider.Ptr.prototype.NowOrLater = function(obj) { + var q; + q = this; + if ((obj === null) || (obj === undefined)) { + return q.When(obj); } - return [pos, tok, lit]; - /* */ case -1: } return; } + return obj; }; - Scanner.prototype.Scan = function() { return this.$val.Scan(); }; + QProvider.prototype.NowOrLater = function(obj) { return this.$val.NowOrLater(obj); }; + RouteProvider.Ptr.prototype.When = function(path, route) { + var r; + r = this; + r.Provider.Object.when($externalize(path, $String), $externalize(route.AngularOpts.toJs(), ($mapType($String, $emptyInterface)))); + return r; + }; + RouteProvider.prototype.When = function(path, route) { return this.$val.When(path, route); }; + RouteProvider.Ptr.prototype.Otherwise = function(route) { + var r; + r = this; + r.Provider.Object.otherwise($externalize(route.AngularOpts.toJs(), ($mapType($String, $emptyInterface)))); + }; + RouteProvider.prototype.Otherwise = function(route) { return this.$val.Otherwise(route); }; + RouteParams.Ptr.prototype.Get = function(name) { + var r; + r = this; + return $internalize(r.Provider.Object[$externalize(name, $String)], $String); + }; + RouteParams.prototype.Get = function(name) { return this.$val.Get(name); }; $pkg.$init = function() { - Error.methods = [["Error", "Error", "", $funcType([], [$String], false), -1]]; - ($ptrType(Error)).methods = [["Error", "Error", "", $funcType([], [$String], false), -1]]; - Error.init([["Pos", "Pos", "", token.Position, ""], ["Msg", "Msg", "", $String, ""]]); - ErrorList.methods = [["Err", "Err", "", $funcType([], [$error], false), -1], ["Error", "Error", "", $funcType([], [$String], false), -1], ["Len", "Len", "", $funcType([], [$Int], false), -1], ["Less", "Less", "", $funcType([$Int, $Int], [$Bool], false), -1], ["Sort", "Sort", "", $funcType([], [], false), -1], ["Swap", "Swap", "", $funcType([$Int, $Int], [], false), -1]]; - ($ptrType(ErrorList)).methods = [["Add", "Add", "", $funcType([token.Position, $String], [], false), -1], ["Err", "Err", "", $funcType([], [$error], false), -1], ["Error", "Error", "", $funcType([], [$String], false), -1], ["Len", "Len", "", $funcType([], [$Int], false), -1], ["Less", "Less", "", $funcType([$Int, $Int], [$Bool], false), -1], ["RemoveMultiples", "RemoveMultiples", "", $funcType([], [], false), -1], ["Reset", "Reset", "", $funcType([], [], false), -1], ["Sort", "Sort", "", $funcType([], [], false), -1], ["Swap", "Swap", "", $funcType([$Int, $Int], [], false), -1]]; - ErrorList.init(($ptrType(Error))); - ErrorHandler.init([token.Position, $String], [], false); - ($ptrType(Scanner)).methods = [["Init", "Init", "", $funcType([($ptrType(token.File)), ($sliceType($Uint8)), ErrorHandler, Mode], [], false), -1], ["Scan", "Scan", "", $funcType([], [token.Pos, token.Token, $String], false), -1], ["error", "error", "go/scanner", $funcType([$Int, $String], [], false), -1], ["findLineEnd", "findLineEnd", "go/scanner", $funcType([], [$Bool], false), -1], ["interpretLineComment", "interpretLineComment", "go/scanner", $funcType([($sliceType($Uint8))], [], false), -1], ["next", "next", "go/scanner", $funcType([], [], false), -1], ["scanComment", "scanComment", "go/scanner", $funcType([], [$String], false), -1], ["scanEscape", "scanEscape", "go/scanner", $funcType([$Int32], [$Bool], false), -1], ["scanIdentifier", "scanIdentifier", "go/scanner", $funcType([], [$String], false), -1], ["scanMantissa", "scanMantissa", "go/scanner", $funcType([$Int], [], false), -1], ["scanNumber", "scanNumber", "go/scanner", $funcType([$Bool], [token.Token, $String], false), -1], ["scanRawString", "scanRawString", "go/scanner", $funcType([], [$String], false), -1], ["scanRune", "scanRune", "go/scanner", $funcType([], [$String], false), -1], ["scanString", "scanString", "go/scanner", $funcType([], [$String], false), -1], ["skipWhitespace", "skipWhitespace", "go/scanner", $funcType([], [], false), -1], ["switch2", "switch2", "go/scanner", $funcType([token.Token, token.Token], [token.Token], false), -1], ["switch3", "switch3", "go/scanner", $funcType([token.Token, token.Token, $Int32, token.Token], [token.Token], false), -1], ["switch4", "switch4", "go/scanner", $funcType([token.Token, token.Token, $Int32, token.Token, token.Token], [token.Token], false), -1]]; - Scanner.init([["file", "file", "go/scanner", ($ptrType(token.File)), ""], ["dir", "dir", "go/scanner", $String, ""], ["src", "src", "go/scanner", ($sliceType($Uint8)), ""], ["err", "err", "go/scanner", ErrorHandler, ""], ["mode", "mode", "go/scanner", Mode, ""], ["ch", "ch", "go/scanner", $Int32, ""], ["offset", "offset", "go/scanner", $Int, ""], ["rdOffset", "rdOffset", "go/scanner", $Int, ""], ["lineOffset", "lineOffset", "go/scanner", $Int, ""], ["insertSemi", "insertSemi", "go/scanner", $Bool, ""], ["ErrorCount", "ErrorCount", "", $Int, ""]]); - prefix = new ($sliceType($Uint8))($stringToBytes("//line ")); + AngularOpts.methods = [["ExportToMap", "ExportToMap", "", $funcType([], [($mapType($String, $emptyInterface))], false), 0], ["ExportToMapWithTag", "ExportToMapWithTag", "", $funcType([$String], [($mapType($String, $emptyInterface))], false), 0], ["Get", "Get", "", $funcType([], [$emptyInterface], false), 0], ["IsSet", "IsSet", "", $funcType([$String], [$Bool], false), 0], ["Options", "Options", "", $funcType([($sliceType(options.Option))], [($ptrType(options.OptionsProvider))], true), 0]]; + ($ptrType(AngularOpts)).methods = [["ExportToMap", "ExportToMap", "", $funcType([], [($mapType($String, $emptyInterface))], false), 0], ["ExportToMapWithTag", "ExportToMapWithTag", "", $funcType([$String], [($mapType($String, $emptyInterface))], false), 0], ["Get", "Get", "", $funcType([], [$emptyInterface], false), 0], ["IsSet", "IsSet", "", $funcType([$String], [$Bool], false), 0], ["Options", "Options", "", $funcType([($sliceType(options.Option))], [($ptrType(options.OptionsProvider))], true), 0], ["toJs", "toJs", "github.com/gopherjs/go-angularjs", $funcType([], [($mapType($String, $emptyInterface))], false), -1]]; + AngularOpts.init([["OptionsProvider", "", "", ($ptrType(options.OptionsProvider)), ""]]); + DummyJsObj.methods = [["Bool", "Bool", "", $funcType([], [$Bool], false), 0], ["Call", "Call", "", $funcType([$String, ($sliceType($emptyInterface))], [js.Object], true), -1], ["Delete", "Delete", "", $funcType([$String], [], false), 0], ["Float", "Float", "", $funcType([], [$Float64], false), 0], ["Get", "Get", "", $funcType([$String], [js.Object], false), -1], ["Index", "Index", "", $funcType([$Int], [js.Object], false), 0], ["Int", "Int", "", $funcType([], [$Int], false), 0], ["Int64", "Int64", "", $funcType([], [$Int64], false), 0], ["Interface", "Interface", "", $funcType([], [$emptyInterface], false), 0], ["Invoke", "Invoke", "", $funcType([($sliceType($emptyInterface))], [js.Object], true), 0], ["IsNull", "IsNull", "", $funcType([], [$Bool], false), 0], ["IsUndefined", "IsUndefined", "", $funcType([], [$Bool], false), 0], ["Length", "Length", "", $funcType([], [$Int], false), 0], ["New", "New", "", $funcType([($sliceType($emptyInterface))], [js.Object], true), 0], ["Set", "Set", "", $funcType([$String, $emptyInterface], [], false), 0], ["SetIndex", "SetIndex", "", $funcType([$Int, $emptyInterface], [], false), 0], ["Str", "Str", "", $funcType([], [$String], false), 0], ["Uint64", "Uint64", "", $funcType([], [$Uint64], false), 0], ["Unsafe", "Unsafe", "", $funcType([], [$Uintptr], false), 0]]; + ($ptrType(DummyJsObj)).methods = [["Bool", "Bool", "", $funcType([], [$Bool], false), 0], ["Call", "Call", "", $funcType([$String, ($sliceType($emptyInterface))], [js.Object], true), -1], ["Delete", "Delete", "", $funcType([$String], [], false), 0], ["Float", "Float", "", $funcType([], [$Float64], false), 0], ["Get", "Get", "", $funcType([$String], [js.Object], false), -1], ["Index", "Index", "", $funcType([$Int], [js.Object], false), 0], ["Int", "Int", "", $funcType([], [$Int], false), 0], ["Int64", "Int64", "", $funcType([], [$Int64], false), 0], ["Interface", "Interface", "", $funcType([], [$emptyInterface], false), 0], ["Invoke", "Invoke", "", $funcType([($sliceType($emptyInterface))], [js.Object], true), 0], ["IsNull", "IsNull", "", $funcType([], [$Bool], false), 0], ["IsUndefined", "IsUndefined", "", $funcType([], [$Bool], false), 0], ["Length", "Length", "", $funcType([], [$Int], false), 0], ["New", "New", "", $funcType([($sliceType($emptyInterface))], [js.Object], true), 0], ["Set", "Set", "", $funcType([$String, $emptyInterface], [], false), 0], ["SetIndex", "SetIndex", "", $funcType([$Int, $emptyInterface], [], false), 0], ["Str", "Str", "", $funcType([], [$String], false), 0], ["Uint64", "Uint64", "", $funcType([], [$Uint64], false), 0], ["Unsafe", "Unsafe", "", $funcType([], [$Uintptr], false), 0]]; + DummyJsObj.init([["Object", "", "", js.Object, ""]]); + Injector.methods = [["Apply", "Apply", "", $funcType([$emptyInterface], [$error], false), 0], ["Get", "Get", "", $funcType([reflect.Type], [reflect.Value], false), 0], ["Invoke", "Invoke", "", $funcType([$emptyInterface], [($sliceType(reflect.Value)), $error], false), 0], ["Map", "Map", "", $funcType([$emptyInterface], [inject.TypeMapper], false), 0], ["MapTo", "MapTo", "", $funcType([$emptyInterface, $emptyInterface], [inject.TypeMapper], false), 0], ["Set", "Set", "", $funcType([reflect.Type, reflect.Value], [inject.TypeMapper], false), 0], ["SetParent", "SetParent", "", $funcType([inject.Injector], [], false), 0]]; + ($ptrType(Injector)).methods = [["Apply", "Apply", "", $funcType([$emptyInterface], [$error], false), 0], ["Get", "Get", "", $funcType([reflect.Type], [reflect.Value], false), 0], ["Invoke", "Invoke", "", $funcType([$emptyInterface], [($sliceType(reflect.Value)), $error], false), 0], ["Map", "Map", "", $funcType([$emptyInterface], [inject.TypeMapper], false), 0], ["MapTo", "MapTo", "", $funcType([$emptyInterface, $emptyInterface], [inject.TypeMapper], false), 0], ["Set", "Set", "", $funcType([reflect.Type, reflect.Value], [inject.TypeMapper], false), 0], ["SetParent", "SetParent", "", $funcType([inject.Injector], [], false), 0], ["_angularDeps", "_angularDeps", "github.com/gopherjs/go-angularjs", $funcType([$emptyInterface, ($funcType([reflect.Value], [reflect.Value], false))], [($sliceType($emptyInterface))], false), -1], ["angularDeps", "angularDeps", "github.com/gopherjs/go-angularjs", $funcType([$emptyInterface], [($sliceType($emptyInterface))], false), -1], ["requestedProviders", "requestedProviders", "github.com/gopherjs/go-angularjs", $funcType([$emptyInterface], [($sliceType(provider))], false), -1]]; + Injector.init([["Injector", "", "", inject.Injector, ""], ["providers", "providers", "github.com/gopherjs/go-angularjs", ($mapType(reflect.Type, provider)), ""]]); + Angular.init([["Inj", "Inj", "", ($ptrType(Injector)), ""]]); + Module.methods = [["Bool", "Bool", "", $funcType([], [$Bool], false), 0], ["Call", "Call", "", $funcType([$String, ($sliceType($emptyInterface))], [js.Object], true), 0], ["Delete", "Delete", "", $funcType([$String], [], false), 0], ["Float", "Float", "", $funcType([], [$Float64], false), 0], ["Get", "Get", "", $funcType([$String], [js.Object], false), 0], ["Index", "Index", "", $funcType([$Int], [js.Object], false), 0], ["Int", "Int", "", $funcType([], [$Int], false), 0], ["Int64", "Int64", "", $funcType([], [$Int64], false), 0], ["Interface", "Interface", "", $funcType([], [$emptyInterface], false), 0], ["Invoke", "Invoke", "", $funcType([($sliceType($emptyInterface))], [js.Object], true), 0], ["IsNull", "IsNull", "", $funcType([], [$Bool], false), 0], ["IsUndefined", "IsUndefined", "", $funcType([], [$Bool], false), 0], ["Length", "Length", "", $funcType([], [$Int], false), 0], ["New", "New", "", $funcType([($sliceType($emptyInterface))], [js.Object], true), 0], ["Set", "Set", "", $funcType([$String, $emptyInterface], [], false), 0], ["SetIndex", "SetIndex", "", $funcType([$Int, $emptyInterface], [], false), 0], ["Str", "Str", "", $funcType([], [$String], false), 0], ["Uint64", "Uint64", "", $funcType([], [$Uint64], false), 0], ["Unsafe", "Unsafe", "", $funcType([], [$Uintptr], false), 0]]; + ($ptrType(Module)).methods = [["Bool", "Bool", "", $funcType([], [$Bool], false), 0], ["Call", "Call", "", $funcType([$String, ($sliceType($emptyInterface))], [js.Object], true), 0], ["Config", "Config", "", $funcType([$emptyInterface], [], false), -1], ["Delete", "Delete", "", $funcType([$String], [], false), 0], ["Factory", "Factory", "", $funcType([$String, $emptyInterface], [], false), -1], ["Filter", "Filter", "", $funcType([$String, $emptyInterface], [], false), -1], ["Float", "Float", "", $funcType([], [$Float64], false), 0], ["Get", "Get", "", $funcType([$String], [js.Object], false), 0], ["Index", "Index", "", $funcType([$Int], [js.Object], false), 0], ["Int", "Int", "", $funcType([], [$Int], false), 0], ["Int64", "Int64", "", $funcType([], [$Int64], false), 0], ["Interface", "Interface", "", $funcType([], [$emptyInterface], false), 0], ["Invoke", "Invoke", "", $funcType([($sliceType($emptyInterface))], [js.Object], true), 0], ["IsNull", "IsNull", "", $funcType([], [$Bool], false), 0], ["IsUndefined", "IsUndefined", "", $funcType([], [$Bool], false), 0], ["Length", "Length", "", $funcType([], [$Int], false), 0], ["New", "New", "", $funcType([($sliceType($emptyInterface))], [js.Object], true), 0], ["NewController", "NewController", "", $funcType([$String, $emptyInterface], [], false), -1], ["Set", "Set", "", $funcType([$String, $emptyInterface], [], false), 0], ["SetIndex", "SetIndex", "", $funcType([$Int, $emptyInterface], [], false), 0], ["Str", "Str", "", $funcType([], [$String], false), 0], ["Uint64", "Uint64", "", $funcType([], [$Uint64], false), 0], ["Unsafe", "Unsafe", "", $funcType([], [$Uintptr], false), 0]]; + Module.init([["Object", "", "", js.Object, ""]]); + provider.init([["AngularName", "AngularName", "", $funcType([], [$String], false)], ["SetJs", "SetJs", "", $funcType([js.Object], [], false)]]); + Provider.methods = [["Bool", "Bool", "", $funcType([], [$Bool], false), 0], ["Call", "Call", "", $funcType([$String, ($sliceType($emptyInterface))], [js.Object], true), 0], ["Delete", "Delete", "", $funcType([$String], [], false), 0], ["Float", "Float", "", $funcType([], [$Float64], false), 0], ["Get", "Get", "", $funcType([$String], [js.Object], false), 0], ["Index", "Index", "", $funcType([$Int], [js.Object], false), 0], ["Int", "Int", "", $funcType([], [$Int], false), 0], ["Int64", "Int64", "", $funcType([], [$Int64], false), 0], ["Interface", "Interface", "", $funcType([], [$emptyInterface], false), 0], ["Invoke", "Invoke", "", $funcType([($sliceType($emptyInterface))], [js.Object], true), 0], ["IsNull", "IsNull", "", $funcType([], [$Bool], false), 0], ["IsUndefined", "IsUndefined", "", $funcType([], [$Bool], false), 0], ["Length", "Length", "", $funcType([], [$Int], false), 0], ["New", "New", "", $funcType([($sliceType($emptyInterface))], [js.Object], true), 0], ["Set", "Set", "", $funcType([$String, $emptyInterface], [], false), 0], ["SetIndex", "SetIndex", "", $funcType([$Int, $emptyInterface], [], false), 0], ["Str", "Str", "", $funcType([], [$String], false), 0], ["Uint64", "Uint64", "", $funcType([], [$Uint64], false), 0], ["Unsafe", "Unsafe", "", $funcType([], [$Uintptr], false), 0]]; + ($ptrType(Provider)).methods = [["AngularName", "AngularName", "", $funcType([], [$String], false), -1], ["Bool", "Bool", "", $funcType([], [$Bool], false), 0], ["Call", "Call", "", $funcType([$String, ($sliceType($emptyInterface))], [js.Object], true), 0], ["Delete", "Delete", "", $funcType([$String], [], false), 0], ["Float", "Float", "", $funcType([], [$Float64], false), 0], ["Get", "Get", "", $funcType([$String], [js.Object], false), 0], ["Index", "Index", "", $funcType([$Int], [js.Object], false), 0], ["Int", "Int", "", $funcType([], [$Int], false), 0], ["Int64", "Int64", "", $funcType([], [$Int64], false), 0], ["Interface", "Interface", "", $funcType([], [$emptyInterface], false), 0], ["Invoke", "Invoke", "", $funcType([($sliceType($emptyInterface))], [js.Object], true), 0], ["IsNull", "IsNull", "", $funcType([], [$Bool], false), 0], ["IsUndefined", "IsUndefined", "", $funcType([], [$Bool], false), 0], ["Length", "Length", "", $funcType([], [$Int], false), 0], ["New", "New", "", $funcType([($sliceType($emptyInterface))], [js.Object], true), 0], ["Set", "Set", "", $funcType([$String, $emptyInterface], [], false), 0], ["SetIndex", "SetIndex", "", $funcType([$Int, $emptyInterface], [], false), 0], ["SetJs", "SetJs", "", $funcType([js.Object], [], false), -1], ["Str", "Str", "", $funcType([], [$String], false), 0], ["Uint64", "Uint64", "", $funcType([], [$Uint64], false), 0], ["Unsafe", "Unsafe", "", $funcType([], [$Uintptr], false), 0]]; + Provider.init([["Object", "", "", js.Object, ""], ["angularName", "angularName", "github.com/gopherjs/go-angularjs", $String, ""]]); + Interval.methods = [["AngularName", "AngularName", "", $funcType([], [$String], false), 0], ["Bool", "Bool", "", $funcType([], [$Bool], false), 0], ["Call", "Call", "", $funcType([$String, ($sliceType($emptyInterface))], [js.Object], true), 0], ["Delete", "Delete", "", $funcType([$String], [], false), 0], ["Float", "Float", "", $funcType([], [$Float64], false), 0], ["Get", "Get", "", $funcType([$String], [js.Object], false), 0], ["Index", "Index", "", $funcType([$Int], [js.Object], false), 0], ["Int", "Int", "", $funcType([], [$Int], false), 0], ["Int64", "Int64", "", $funcType([], [$Int64], false), 0], ["Interface", "Interface", "", $funcType([], [$emptyInterface], false), 0], ["Invoke", "Invoke", "", $funcType([($sliceType($emptyInterface))], [js.Object], true), 0], ["IsNull", "IsNull", "", $funcType([], [$Bool], false), 0], ["IsUndefined", "IsUndefined", "", $funcType([], [$Bool], false), 0], ["Length", "Length", "", $funcType([], [$Int], false), 0], ["New", "New", "", $funcType([($sliceType($emptyInterface))], [js.Object], true), 0], ["Set", "Set", "", $funcType([$String, $emptyInterface], [], false), 0], ["SetIndex", "SetIndex", "", $funcType([$Int, $emptyInterface], [], false), 0], ["SetJs", "SetJs", "", $funcType([js.Object], [], false), 0], ["Str", "Str", "", $funcType([], [$String], false), 0], ["Uint64", "Uint64", "", $funcType([], [$Uint64], false), 0], ["Unsafe", "Unsafe", "", $funcType([], [$Uintptr], false), 0]]; + ($ptrType(Interval)).methods = [["AngularName", "AngularName", "", $funcType([], [$String], false), 0], ["Bool", "Bool", "", $funcType([], [$Bool], false), 0], ["Call", "Call", "", $funcType([$String, ($sliceType($emptyInterface))], [js.Object], true), 0], ["Delete", "Delete", "", $funcType([$String], [], false), 0], ["Float", "Float", "", $funcType([], [$Float64], false), 0], ["Get", "Get", "", $funcType([$String], [js.Object], false), 0], ["Index", "Index", "", $funcType([$Int], [js.Object], false), 0], ["Int", "Int", "", $funcType([], [$Int], false), 0], ["Int64", "Int64", "", $funcType([], [$Int64], false), 0], ["Interface", "Interface", "", $funcType([], [$emptyInterface], false), 0], ["Invoke", "Invoke", "", $funcType([($sliceType($emptyInterface))], [js.Object], true), 0], ["IsNull", "IsNull", "", $funcType([], [$Bool], false), 0], ["IsUndefined", "IsUndefined", "", $funcType([], [$Bool], false), 0], ["Length", "Length", "", $funcType([], [$Int], false), 0], ["New", "New", "", $funcType([($sliceType($emptyInterface))], [js.Object], true), 0], ["Set", "Set", "", $funcType([$String, $emptyInterface], [], false), 0], ["SetIndex", "SetIndex", "", $funcType([$Int, $emptyInterface], [], false), 0], ["SetJs", "SetJs", "", $funcType([js.Object], [], false), 0], ["Str", "Str", "", $funcType([], [$String], false), 0], ["Uint64", "Uint64", "", $funcType([], [$Uint64], false), 0], ["Unsafe", "Unsafe", "", $funcType([], [$Uintptr], false), 0]]; + Interval.init([["Provider", "", "", ($ptrType(Provider)), ""]]); + Scope.methods = [["AngularName", "AngularName", "", $funcType([], [$String], false), 0], ["Bool", "Bool", "", $funcType([], [$Bool], false), 0], ["Call", "Call", "", $funcType([$String, ($sliceType($emptyInterface))], [js.Object], true), 0], ["Delete", "Delete", "", $funcType([$String], [], false), 0], ["Float", "Float", "", $funcType([], [$Float64], false), 0], ["Get", "Get", "", $funcType([$String], [js.Object], false), 0], ["Index", "Index", "", $funcType([$Int], [js.Object], false), 0], ["Int", "Int", "", $funcType([], [$Int], false), 0], ["Int64", "Int64", "", $funcType([], [$Int64], false), 0], ["Interface", "Interface", "", $funcType([], [$emptyInterface], false), 0], ["Invoke", "Invoke", "", $funcType([($sliceType($emptyInterface))], [js.Object], true), 0], ["IsNull", "IsNull", "", $funcType([], [$Bool], false), 0], ["IsUndefined", "IsUndefined", "", $funcType([], [$Bool], false), 0], ["Length", "Length", "", $funcType([], [$Int], false), 0], ["New", "New", "", $funcType([($sliceType($emptyInterface))], [js.Object], true), 0], ["Set", "Set", "", $funcType([$String, $emptyInterface], [], false), 0], ["SetIndex", "SetIndex", "", $funcType([$Int, $emptyInterface], [], false), 0], ["SetJs", "SetJs", "", $funcType([js.Object], [], false), 0], ["Str", "Str", "", $funcType([], [$String], false), 0], ["Uint64", "Uint64", "", $funcType([], [$Uint64], false), 0], ["Unsafe", "Unsafe", "", $funcType([], [$Uintptr], false), 0]]; + ($ptrType(Scope)).methods = [["AngularName", "AngularName", "", $funcType([], [$String], false), 0], ["Apply", "Apply", "", $funcType([($funcType([], [], false))], [], false), -1], ["Bool", "Bool", "", $funcType([], [$Bool], false), 0], ["Call", "Call", "", $funcType([$String, ($sliceType($emptyInterface))], [js.Object], true), 0], ["Delete", "Delete", "", $funcType([$String], [], false), 0], ["EvalAsync", "EvalAsync", "", $funcType([($funcType([], [], false))], [], false), -1], ["Float", "Float", "", $funcType([], [$Float64], false), 0], ["Get", "Get", "", $funcType([$String], [js.Object], false), 0], ["Index", "Index", "", $funcType([$Int], [js.Object], false), 0], ["Int", "Int", "", $funcType([], [$Int], false), 0], ["Int64", "Int64", "", $funcType([], [$Int64], false), 0], ["Interface", "Interface", "", $funcType([], [$emptyInterface], false), 0], ["Invoke", "Invoke", "", $funcType([($sliceType($emptyInterface))], [js.Object], true), 0], ["IsNull", "IsNull", "", $funcType([], [$Bool], false), 0], ["IsUndefined", "IsUndefined", "", $funcType([], [$Bool], false), 0], ["Length", "Length", "", $funcType([], [$Int], false), 0], ["New", "New", "", $funcType([($sliceType($emptyInterface))], [js.Object], true), 0], ["Set", "Set", "", $funcType([$String, $emptyInterface], [], false), 0], ["SetIndex", "SetIndex", "", $funcType([$Int, $emptyInterface], [], false), 0], ["SetJs", "SetJs", "", $funcType([js.Object], [], false), 0], ["Str", "Str", "", $funcType([], [$String], false), 0], ["Uint64", "Uint64", "", $funcType([], [$Uint64], false), 0], ["Unsafe", "Unsafe", "", $funcType([], [$Uintptr], false), 0]]; + Scope.init([["Provider", "", "", ($ptrType(Provider)), ""]]); + JQueryElement.methods = [["Bool", "Bool", "", $funcType([], [$Bool], false), 0], ["Call", "Call", "", $funcType([$String, ($sliceType($emptyInterface))], [js.Object], true), 0], ["Delete", "Delete", "", $funcType([$String], [], false), 0], ["Float", "Float", "", $funcType([], [$Float64], false), 0], ["Get", "Get", "", $funcType([$String], [js.Object], false), 0], ["Index", "Index", "", $funcType([$Int], [js.Object], false), 0], ["Int", "Int", "", $funcType([], [$Int], false), 0], ["Int64", "Int64", "", $funcType([], [$Int64], false), 0], ["Interface", "Interface", "", $funcType([], [$emptyInterface], false), 0], ["Invoke", "Invoke", "", $funcType([($sliceType($emptyInterface))], [js.Object], true), 0], ["IsNull", "IsNull", "", $funcType([], [$Bool], false), 0], ["IsUndefined", "IsUndefined", "", $funcType([], [$Bool], false), 0], ["Length", "Length", "", $funcType([], [$Int], false), 0], ["New", "New", "", $funcType([($sliceType($emptyInterface))], [js.Object], true), 0], ["Set", "Set", "", $funcType([$String, $emptyInterface], [], false), 0], ["SetIndex", "SetIndex", "", $funcType([$Int, $emptyInterface], [], false), 0], ["Str", "Str", "", $funcType([], [$String], false), 0], ["Uint64", "Uint64", "", $funcType([], [$Uint64], false), 0], ["Unsafe", "Unsafe", "", $funcType([], [$Uintptr], false), 0]]; + ($ptrType(JQueryElement)).methods = [["Bool", "Bool", "", $funcType([], [$Bool], false), 0], ["Call", "Call", "", $funcType([$String, ($sliceType($emptyInterface))], [js.Object], true), 0], ["Delete", "Delete", "", $funcType([$String], [], false), 0], ["Float", "Float", "", $funcType([], [$Float64], false), 0], ["Get", "Get", "", $funcType([$String], [js.Object], false), 0], ["Index", "Index", "", $funcType([$Int], [js.Object], false), 0], ["Int", "Int", "", $funcType([], [$Int], false), 0], ["Int64", "Int64", "", $funcType([], [$Int64], false), 0], ["Interface", "Interface", "", $funcType([], [$emptyInterface], false), 0], ["Invoke", "Invoke", "", $funcType([($sliceType($emptyInterface))], [js.Object], true), 0], ["IsNull", "IsNull", "", $funcType([], [$Bool], false), 0], ["IsUndefined", "IsUndefined", "", $funcType([], [$Bool], false), 0], ["Length", "Length", "", $funcType([], [$Int], false), 0], ["New", "New", "", $funcType([($sliceType($emptyInterface))], [js.Object], true), 0], ["On", "On", "", $funcType([$String, ($funcType([($ptrType(Event))], [], false))], [], false), -1], ["Prop", "Prop", "", $funcType([$String], [js.Object], false), -1], ["Set", "Set", "", $funcType([$String, $emptyInterface], [], false), 0], ["SetIndex", "SetIndex", "", $funcType([$Int, $emptyInterface], [], false), 0], ["SetProp", "SetProp", "", $funcType([$emptyInterface, $emptyInterface], [], false), -1], ["SetVal", "SetVal", "", $funcType([$emptyInterface], [], false), -1], ["Str", "Str", "", $funcType([], [$String], false), 0], ["Uint64", "Uint64", "", $funcType([], [$Uint64], false), 0], ["Unsafe", "Unsafe", "", $funcType([], [$Uintptr], false), 0], ["Val", "Val", "", $funcType([], [js.Object], false), -1]]; + JQueryElement.init([["Object", "", "", js.Object, ""]]); + Event.methods = [["Bool", "Bool", "", $funcType([], [$Bool], false), 0], ["Call", "Call", "", $funcType([$String, ($sliceType($emptyInterface))], [js.Object], true), 0], ["Delete", "Delete", "", $funcType([$String], [], false), 0], ["Float", "Float", "", $funcType([], [$Float64], false), 0], ["Get", "Get", "", $funcType([$String], [js.Object], false), 0], ["Index", "Index", "", $funcType([$Int], [js.Object], false), 0], ["Int", "Int", "", $funcType([], [$Int], false), 0], ["Int64", "Int64", "", $funcType([], [$Int64], false), 0], ["Interface", "Interface", "", $funcType([], [$emptyInterface], false), 0], ["Invoke", "Invoke", "", $funcType([($sliceType($emptyInterface))], [js.Object], true), 0], ["IsNull", "IsNull", "", $funcType([], [$Bool], false), 0], ["IsUndefined", "IsUndefined", "", $funcType([], [$Bool], false), 0], ["Length", "Length", "", $funcType([], [$Int], false), 0], ["New", "New", "", $funcType([($sliceType($emptyInterface))], [js.Object], true), 0], ["Set", "Set", "", $funcType([$String, $emptyInterface], [], false), 0], ["SetIndex", "SetIndex", "", $funcType([$Int, $emptyInterface], [], false), 0], ["Str", "Str", "", $funcType([], [$String], false), 0], ["Uint64", "Uint64", "", $funcType([], [$Uint64], false), 0], ["Unsafe", "Unsafe", "", $funcType([], [$Uintptr], false), 0]]; + ($ptrType(Event)).methods = [["Bool", "Bool", "", $funcType([], [$Bool], false), 0], ["Call", "Call", "", $funcType([$String, ($sliceType($emptyInterface))], [js.Object], true), 0], ["Delete", "Delete", "", $funcType([$String], [], false), 0], ["Float", "Float", "", $funcType([], [$Float64], false), 0], ["Get", "Get", "", $funcType([$String], [js.Object], false), 0], ["Index", "Index", "", $funcType([$Int], [js.Object], false), 0], ["Int", "Int", "", $funcType([], [$Int], false), 0], ["Int64", "Int64", "", $funcType([], [$Int64], false), 0], ["Interface", "Interface", "", $funcType([], [$emptyInterface], false), 0], ["Invoke", "Invoke", "", $funcType([($sliceType($emptyInterface))], [js.Object], true), 0], ["IsNull", "IsNull", "", $funcType([], [$Bool], false), 0], ["IsUndefined", "IsUndefined", "", $funcType([], [$Bool], false), 0], ["Length", "Length", "", $funcType([], [$Int], false), 0], ["New", "New", "", $funcType([($sliceType($emptyInterface))], [js.Object], true), 0], ["PreventDefault", "PreventDefault", "", $funcType([], [], false), -1], ["Set", "Set", "", $funcType([$String, $emptyInterface], [], false), 0], ["SetIndex", "SetIndex", "", $funcType([$Int, $emptyInterface], [], false), 0], ["Str", "Str", "", $funcType([], [$String], false), 0], ["Uint64", "Uint64", "", $funcType([], [$Uint64], false), 0], ["Unsafe", "Unsafe", "", $funcType([], [$Uintptr], false), 0]]; + Event.init([["Object", "", "", js.Object, ""], ["KeyCode", "KeyCode", "", $Int, "js:\"keyCode\""]]); + headersGetter.init([$String], [$String], false); + HttpTransformFunc.init([$String, headersGetter], [$String], false); + ReqMethod.init([["Value", "Value", "", httpMethod, ""]]); + ReqUrl.init([["Value", "Value", "", $String, ""]]); + ReqParams.init([["Value", "Value", "", ($mapType($String, $String)), ""]]); + ReqData.init([["Value", "Value", "", $String, ""]]); + ReqHeaders.init([["Value", "Value", "", ($mapType($String, $String)), ""]]); + ReqTransformReqFunc.init([["Value", "Value", "", HttpTransformFunc, ""]]); + ReqTransformRespFunc.init([["Value", "Value", "", HttpTransformFunc, ""]]); + ReqTimeout.init([["Value", "Value", "", $Int, ""]]); + ReqSpec.init([["Method", "Method", "", ReqMethod, "js:\"method\""], ["Url", "Url", "", ReqUrl, "js:\"url\""], ["Params", "Params", "", ReqParams, "js:\"params\""], ["Data", "Data", "", ReqData, "js:\"data\""], ["Headers", "Headers", "", ReqHeaders, "js:\"headers\""], ["TransformReq", "TransformReq", "", ReqTransformReqFunc, "js:\"transformRequest\""], ["TransformResp", "TransformResp", "", ReqTransformRespFunc, "js:\"transformResponse\""], ["Timeout", "Timeout", "", ReqTimeout, "js:\"timeout\""]]); + ReqOpts.methods = [["ExportToMap", "ExportToMap", "", $funcType([], [($mapType($String, $emptyInterface))], false), 0], ["ExportToMapWithTag", "ExportToMapWithTag", "", $funcType([$String], [($mapType($String, $emptyInterface))], false), 0], ["Get", "Get", "", $funcType([], [$emptyInterface], false), 0], ["IsSet", "IsSet", "", $funcType([$String], [$Bool], false), 0], ["Options", "Options", "", $funcType([($sliceType(options.Option))], [($ptrType(options.OptionsProvider))], true), 0]]; + ($ptrType(ReqOpts)).methods = [["ExportToMap", "ExportToMap", "", $funcType([], [($mapType($String, $emptyInterface))], false), 0], ["ExportToMapWithTag", "ExportToMapWithTag", "", $funcType([$String], [($mapType($String, $emptyInterface))], false), 0], ["Get", "Get", "", $funcType([], [$emptyInterface], false), 0], ["IsSet", "IsSet", "", $funcType([$String], [$Bool], false), 0], ["Options", "Options", "", $funcType([($sliceType(options.Option))], [($ptrType(options.OptionsProvider))], true), 0], ["Spec", "Spec", "", $funcType([], [($ptrType(ReqSpec))], false), -1], ["toJs", "toJs", "github.com/gopherjs/go-angularjs", $funcType([], [($mapType($String, $emptyInterface))], false), 0]]; + ReqOpts.init([["AngularOpts", "", "", AngularOpts, ""]]); + HttpService.methods = [["AngularName", "AngularName", "", $funcType([], [$String], false), 0], ["Bool", "Bool", "", $funcType([], [$Bool], false), 0], ["Call", "Call", "", $funcType([$String, ($sliceType($emptyInterface))], [js.Object], true), 0], ["Delete", "Delete", "", $funcType([$String], [], false), 0], ["Float", "Float", "", $funcType([], [$Float64], false), 0], ["Index", "Index", "", $funcType([$Int], [js.Object], false), 0], ["Int", "Int", "", $funcType([], [$Int], false), 0], ["Int64", "Int64", "", $funcType([], [$Int64], false), 0], ["Interface", "Interface", "", $funcType([], [$emptyInterface], false), 0], ["Invoke", "Invoke", "", $funcType([($sliceType($emptyInterface))], [js.Object], true), 0], ["IsNull", "IsNull", "", $funcType([], [$Bool], false), 0], ["IsUndefined", "IsUndefined", "", $funcType([], [$Bool], false), 0], ["Length", "Length", "", $funcType([], [$Int], false), 0], ["New", "New", "", $funcType([($sliceType($emptyInterface))], [js.Object], true), 0], ["Set", "Set", "", $funcType([$String, $emptyInterface], [], false), 0], ["SetIndex", "SetIndex", "", $funcType([$Int, $emptyInterface], [], false), 0], ["SetJs", "SetJs", "", $funcType([js.Object], [], false), 0], ["Str", "Str", "", $funcType([], [$String], false), 0], ["Uint64", "Uint64", "", $funcType([], [$Uint64], false), 0], ["Unsafe", "Unsafe", "", $funcType([], [$Uintptr], false), 0]]; + ($ptrType(HttpService)).methods = [["AngularName", "AngularName", "", $funcType([], [$String], false), 0], ["Bool", "Bool", "", $funcType([], [$Bool], false), 0], ["Call", "Call", "", $funcType([$String, ($sliceType($emptyInterface))], [js.Object], true), 0], ["Delete", "Delete", "", $funcType([$String], [], false), 0], ["Float", "Float", "", $funcType([], [$Float64], false), 0], ["Get", "Get", "", $funcType([$String], [($ptrType(Future))], false), -1], ["Index", "Index", "", $funcType([$Int], [js.Object], false), 0], ["Int", "Int", "", $funcType([], [$Int], false), 0], ["Int64", "Int64", "", $funcType([], [$Int64], false), 0], ["Interface", "Interface", "", $funcType([], [$emptyInterface], false), 0], ["Invoke", "Invoke", "", $funcType([($sliceType($emptyInterface))], [js.Object], true), 0], ["IsNull", "IsNull", "", $funcType([], [$Bool], false), 0], ["IsUndefined", "IsUndefined", "", $funcType([], [$Bool], false), 0], ["Length", "Length", "", $funcType([], [$Int], false), 0], ["New", "New", "", $funcType([($sliceType($emptyInterface))], [js.Object], true), 0], ["Request", "Request", "", $funcType([($ptrType(ReqOpts))], [($ptrType(Future))], false), -1], ["Set", "Set", "", $funcType([$String, $emptyInterface], [], false), 0], ["SetIndex", "SetIndex", "", $funcType([$Int, $emptyInterface], [], false), 0], ["SetJs", "SetJs", "", $funcType([js.Object], [], false), 0], ["SimpleRequest", "SimpleRequest", "", $funcType([httpMethod, $String], [($ptrType(Future))], false), -1], ["Str", "Str", "", $funcType([], [$String], false), 0], ["Uint64", "Uint64", "", $funcType([], [$Uint64], false), 0], ["Unsafe", "Unsafe", "", $funcType([], [$Uintptr], false), 0]]; + HttpService.init([["Provider", "", "", ($ptrType(Provider)), ""]]); + HttpProvider.methods = [["AngularName", "AngularName", "", $funcType([], [$String], false), 0], ["Bool", "Bool", "", $funcType([], [$Bool], false), 0], ["Call", "Call", "", $funcType([$String, ($sliceType($emptyInterface))], [js.Object], true), 0], ["Delete", "Delete", "", $funcType([$String], [], false), 0], ["Float", "Float", "", $funcType([], [$Float64], false), 0], ["Get", "Get", "", $funcType([$String], [js.Object], false), 0], ["Index", "Index", "", $funcType([$Int], [js.Object], false), 0], ["Int", "Int", "", $funcType([], [$Int], false), 0], ["Int64", "Int64", "", $funcType([], [$Int64], false), 0], ["Interface", "Interface", "", $funcType([], [$emptyInterface], false), 0], ["Invoke", "Invoke", "", $funcType([($sliceType($emptyInterface))], [js.Object], true), 0], ["IsNull", "IsNull", "", $funcType([], [$Bool], false), 0], ["IsUndefined", "IsUndefined", "", $funcType([], [$Bool], false), 0], ["Length", "Length", "", $funcType([], [$Int], false), 0], ["New", "New", "", $funcType([($sliceType($emptyInterface))], [js.Object], true), 0], ["Set", "Set", "", $funcType([$String, $emptyInterface], [], false), 0], ["SetIndex", "SetIndex", "", $funcType([$Int, $emptyInterface], [], false), 0], ["SetJs", "SetJs", "", $funcType([js.Object], [], false), 0], ["Str", "Str", "", $funcType([], [$String], false), 0], ["Uint64", "Uint64", "", $funcType([], [$Uint64], false), 0], ["Unsafe", "Unsafe", "", $funcType([], [$Uintptr], false), 0]]; + ($ptrType(HttpProvider)).methods = [["AngularName", "AngularName", "", $funcType([], [$String], false), 0], ["Bool", "Bool", "", $funcType([], [$Bool], false), 0], ["Call", "Call", "", $funcType([$String, ($sliceType($emptyInterface))], [js.Object], true), 0], ["Delete", "Delete", "", $funcType([$String], [], false), 0], ["Float", "Float", "", $funcType([], [$Float64], false), 0], ["Get", "Get", "", $funcType([$String], [js.Object], false), 0], ["Index", "Index", "", $funcType([$Int], [js.Object], false), 0], ["Int", "Int", "", $funcType([], [$Int], false), 0], ["Int64", "Int64", "", $funcType([], [$Int64], false), 0], ["Interface", "Interface", "", $funcType([], [$emptyInterface], false), 0], ["Invoke", "Invoke", "", $funcType([($sliceType($emptyInterface))], [js.Object], true), 0], ["IsNull", "IsNull", "", $funcType([], [$Bool], false), 0], ["IsUndefined", "IsUndefined", "", $funcType([], [$Bool], false), 0], ["Length", "Length", "", $funcType([], [$Int], false), 0], ["New", "New", "", $funcType([($sliceType($emptyInterface))], [js.Object], true), 0], ["Set", "Set", "", $funcType([$String, $emptyInterface], [], false), 0], ["SetIndex", "SetIndex", "", $funcType([$Int, $emptyInterface], [], false), 0], ["SetJs", "SetJs", "", $funcType([js.Object], [], false), 0], ["Str", "Str", "", $funcType([], [$String], false), 0], ["Uint64", "Uint64", "", $funcType([], [$Uint64], false), 0], ["Unsafe", "Unsafe", "", $funcType([], [$Uintptr], false), 0]]; + HttpProvider.init([["Provider", "", "", ($ptrType(Provider)), ""]]); + Future.methods = [["Bool", "Bool", "", $funcType([], [$Bool], false), 0], ["Call", "Call", "", $funcType([$String, ($sliceType($emptyInterface))], [js.Object], true), 0], ["Delete", "Delete", "", $funcType([$String], [], false), 0], ["Float", "Float", "", $funcType([], [$Float64], false), 0], ["Get", "Get", "", $funcType([$String], [js.Object], false), 0], ["Index", "Index", "", $funcType([$Int], [js.Object], false), 0], ["Int", "Int", "", $funcType([], [$Int], false), 0], ["Int64", "Int64", "", $funcType([], [$Int64], false), 0], ["Interface", "Interface", "", $funcType([], [$emptyInterface], false), 0], ["Invoke", "Invoke", "", $funcType([($sliceType($emptyInterface))], [js.Object], true), 0], ["IsNull", "IsNull", "", $funcType([], [$Bool], false), 0], ["IsUndefined", "IsUndefined", "", $funcType([], [$Bool], false), 0], ["Length", "Length", "", $funcType([], [$Int], false), 0], ["New", "New", "", $funcType([($sliceType($emptyInterface))], [js.Object], true), 0], ["Set", "Set", "", $funcType([$String, $emptyInterface], [], false), 0], ["SetIndex", "SetIndex", "", $funcType([$Int, $emptyInterface], [], false), 0], ["Str", "Str", "", $funcType([], [$String], false), 0], ["Uint64", "Uint64", "", $funcType([], [$Uint64], false), 0], ["Unsafe", "Unsafe", "", $funcType([], [$Uintptr], false), 0]]; + ($ptrType(Future)).methods = [["Bool", "Bool", "", $funcType([], [$Bool], false), 0], ["Call", "Call", "", $funcType([$String, ($sliceType($emptyInterface))], [js.Object], true), 0], ["Delete", "Delete", "", $funcType([$String], [], false), 0], ["Error", "Error", "", $funcType([RequestCallback], [($ptrType(Future))], false), -1], ["Float", "Float", "", $funcType([], [$Float64], false), 0], ["Get", "Get", "", $funcType([$String], [js.Object], false), 0], ["Index", "Index", "", $funcType([$Int], [js.Object], false), 0], ["Int", "Int", "", $funcType([], [$Int], false), 0], ["Int64", "Int64", "", $funcType([], [$Int64], false), 0], ["Interface", "Interface", "", $funcType([], [$emptyInterface], false), 0], ["Invoke", "Invoke", "", $funcType([($sliceType($emptyInterface))], [js.Object], true), 0], ["IsNull", "IsNull", "", $funcType([], [$Bool], false), 0], ["IsUndefined", "IsUndefined", "", $funcType([], [$Bool], false), 0], ["Length", "Length", "", $funcType([], [$Int], false), 0], ["New", "New", "", $funcType([($sliceType($emptyInterface))], [js.Object], true), 0], ["Set", "Set", "", $funcType([$String, $emptyInterface], [], false), 0], ["SetIndex", "SetIndex", "", $funcType([$Int, $emptyInterface], [], false), 0], ["Str", "Str", "", $funcType([], [$String], false), 0], ["Success", "Success", "", $funcType([RequestCallback], [($ptrType(Future))], false), -1], ["Uint64", "Uint64", "", $funcType([], [$Uint64], false), 0], ["Unsafe", "Unsafe", "", $funcType([], [$Uintptr], false), 0], ["call", "call", "github.com/gopherjs/go-angularjs", $funcType([$String, RequestCallback], [($ptrType(Future))], false), -1]]; + Future.init([["Object", "", "", js.Object, ""]]); + RequestCallback.init([]); + RootScope.methods = [["AngularName", "AngularName", "", $funcType([], [$String], false), 0], ["Bool", "Bool", "", $funcType([], [$Bool], false), 0], ["Call", "Call", "", $funcType([$String, ($sliceType($emptyInterface))], [js.Object], true), 0], ["Delete", "Delete", "", $funcType([$String], [], false), 0], ["Float", "Float", "", $funcType([], [$Float64], false), 0], ["Get", "Get", "", $funcType([$String], [js.Object], false), 0], ["Index", "Index", "", $funcType([$Int], [js.Object], false), 0], ["Int", "Int", "", $funcType([], [$Int], false), 0], ["Int64", "Int64", "", $funcType([], [$Int64], false), 0], ["Interface", "Interface", "", $funcType([], [$emptyInterface], false), 0], ["Invoke", "Invoke", "", $funcType([($sliceType($emptyInterface))], [js.Object], true), 0], ["IsNull", "IsNull", "", $funcType([], [$Bool], false), 0], ["IsUndefined", "IsUndefined", "", $funcType([], [$Bool], false), 0], ["Length", "Length", "", $funcType([], [$Int], false), 0], ["New", "New", "", $funcType([($sliceType($emptyInterface))], [js.Object], true), 0], ["Set", "Set", "", $funcType([$String, $emptyInterface], [], false), 0], ["SetIndex", "SetIndex", "", $funcType([$Int, $emptyInterface], [], false), 0], ["SetJs", "SetJs", "", $funcType([js.Object], [], false), 0], ["Str", "Str", "", $funcType([], [$String], false), 0], ["Uint64", "Uint64", "", $funcType([], [$Uint64], false), 0], ["Unsafe", "Unsafe", "", $funcType([], [$Uintptr], false), 0]]; + ($ptrType(RootScope)).methods = [["AngularName", "AngularName", "", $funcType([], [$String], false), 0], ["Bool", "Bool", "", $funcType([], [$Bool], false), 0], ["Call", "Call", "", $funcType([$String, ($sliceType($emptyInterface))], [js.Object], true), 0], ["Delete", "Delete", "", $funcType([$String], [], false), 0], ["Float", "Float", "", $funcType([], [$Float64], false), 0], ["Get", "Get", "", $funcType([$String], [js.Object], false), 0], ["Index", "Index", "", $funcType([$Int], [js.Object], false), 0], ["Int", "Int", "", $funcType([], [$Int], false), 0], ["Int64", "Int64", "", $funcType([], [$Int64], false), 0], ["Interface", "Interface", "", $funcType([], [$emptyInterface], false), 0], ["Invoke", "Invoke", "", $funcType([($sliceType($emptyInterface))], [js.Object], true), 0], ["IsNull", "IsNull", "", $funcType([], [$Bool], false), 0], ["IsUndefined", "IsUndefined", "", $funcType([], [$Bool], false), 0], ["Length", "Length", "", $funcType([], [$Int], false), 0], ["New", "New", "", $funcType([($sliceType($emptyInterface))], [js.Object], true), 0], ["Set", "Set", "", $funcType([$String, $emptyInterface], [], false), 0], ["SetIndex", "SetIndex", "", $funcType([$Int, $emptyInterface], [], false), 0], ["SetJs", "SetJs", "", $funcType([js.Object], [], false), 0], ["Str", "Str", "", $funcType([], [$String], false), 0], ["Uint64", "Uint64", "", $funcType([], [$Uint64], false), 0], ["Unsafe", "Unsafe", "", $funcType([], [$Uintptr], false), 0]]; + RootScope.init([["Provider", "", "", ($ptrType(Provider)), ""]]); + QProvider.methods = [["AngularName", "AngularName", "", $funcType([], [$String], false), 0], ["Bool", "Bool", "", $funcType([], [$Bool], false), 0], ["Call", "Call", "", $funcType([$String, ($sliceType($emptyInterface))], [js.Object], true), 0], ["Delete", "Delete", "", $funcType([$String], [], false), 0], ["Float", "Float", "", $funcType([], [$Float64], false), 0], ["Get", "Get", "", $funcType([$String], [js.Object], false), 0], ["Index", "Index", "", $funcType([$Int], [js.Object], false), 0], ["Int", "Int", "", $funcType([], [$Int], false), 0], ["Int64", "Int64", "", $funcType([], [$Int64], false), 0], ["Interface", "Interface", "", $funcType([], [$emptyInterface], false), 0], ["Invoke", "Invoke", "", $funcType([($sliceType($emptyInterface))], [js.Object], true), 0], ["IsNull", "IsNull", "", $funcType([], [$Bool], false), 0], ["IsUndefined", "IsUndefined", "", $funcType([], [$Bool], false), 0], ["Length", "Length", "", $funcType([], [$Int], false), 0], ["New", "New", "", $funcType([($sliceType($emptyInterface))], [js.Object], true), 0], ["Set", "Set", "", $funcType([$String, $emptyInterface], [], false), 0], ["SetIndex", "SetIndex", "", $funcType([$Int, $emptyInterface], [], false), 0], ["SetJs", "SetJs", "", $funcType([js.Object], [], false), 0], ["Str", "Str", "", $funcType([], [$String], false), 0], ["Uint64", "Uint64", "", $funcType([], [$Uint64], false), 0], ["Unsafe", "Unsafe", "", $funcType([], [$Uintptr], false), 0]]; + ($ptrType(QProvider)).methods = [["All", "All", "", $funcType([($sliceType(js.Object))], [js.Object], false), -1], ["AngularName", "AngularName", "", $funcType([], [$String], false), 0], ["Bool", "Bool", "", $funcType([], [$Bool], false), 0], ["Call", "Call", "", $funcType([$String, ($sliceType($emptyInterface))], [js.Object], true), 0], ["Defer", "Defer", "", $funcType([], [js.Object], false), -1], ["Delete", "Delete", "", $funcType([$String], [], false), 0], ["Float", "Float", "", $funcType([], [$Float64], false), 0], ["Get", "Get", "", $funcType([$String], [js.Object], false), 0], ["Index", "Index", "", $funcType([$Int], [js.Object], false), 0], ["Int", "Int", "", $funcType([], [$Int], false), 0], ["Int64", "Int64", "", $funcType([], [$Int64], false), 0], ["Interface", "Interface", "", $funcType([], [$emptyInterface], false), 0], ["Invoke", "Invoke", "", $funcType([($sliceType($emptyInterface))], [js.Object], true), 0], ["IsNull", "IsNull", "", $funcType([], [$Bool], false), 0], ["IsUndefined", "IsUndefined", "", $funcType([], [$Bool], false), 0], ["Length", "Length", "", $funcType([], [$Int], false), 0], ["New", "New", "", $funcType([($sliceType($emptyInterface))], [js.Object], true), 0], ["NowOrLater", "NowOrLater", "", $funcType([js.Object], [$emptyInterface], false), -1], ["Reject", "Reject", "", $funcType([$String], [js.Object], false), -1], ["Set", "Set", "", $funcType([$String, $emptyInterface], [], false), 0], ["SetIndex", "SetIndex", "", $funcType([$Int, $emptyInterface], [], false), 0], ["SetJs", "SetJs", "", $funcType([js.Object], [], false), 0], ["Str", "Str", "", $funcType([], [$String], false), 0], ["Uint64", "Uint64", "", $funcType([], [$Uint64], false), 0], ["Unsafe", "Unsafe", "", $funcType([], [$Uintptr], false), 0], ["When", "When", "", $funcType([js.Object], [js.Object], false), -1]]; + QProvider.init([["Provider", "", "", ($ptrType(Provider)), ""]]); + RouteOpts.methods = [["ExportToMap", "ExportToMap", "", $funcType([], [($mapType($String, $emptyInterface))], false), 0], ["ExportToMapWithTag", "ExportToMapWithTag", "", $funcType([$String], [($mapType($String, $emptyInterface))], false), 0], ["Get", "Get", "", $funcType([], [$emptyInterface], false), 0], ["IsSet", "IsSet", "", $funcType([$String], [$Bool], false), 0], ["Options", "Options", "", $funcType([($sliceType(options.Option))], [($ptrType(options.OptionsProvider))], true), 0]]; + ($ptrType(RouteOpts)).methods = [["ExportToMap", "ExportToMap", "", $funcType([], [($mapType($String, $emptyInterface))], false), 0], ["ExportToMapWithTag", "ExportToMapWithTag", "", $funcType([$String], [($mapType($String, $emptyInterface))], false), 0], ["Get", "Get", "", $funcType([], [$emptyInterface], false), 0], ["IsSet", "IsSet", "", $funcType([$String], [$Bool], false), 0], ["Options", "Options", "", $funcType([($sliceType(options.Option))], [($ptrType(options.OptionsProvider))], true), 0], ["toJs", "toJs", "github.com/gopherjs/go-angularjs", $funcType([], [($mapType($String, $emptyInterface))], false), 0]]; + RouteOpts.init([["AngularOpts", "", "", AngularOpts, ""]]); + RouteProvider.methods = [["AngularName", "AngularName", "", $funcType([], [$String], false), 0], ["Bool", "Bool", "", $funcType([], [$Bool], false), 0], ["Call", "Call", "", $funcType([$String, ($sliceType($emptyInterface))], [js.Object], true), 0], ["Delete", "Delete", "", $funcType([$String], [], false), 0], ["Float", "Float", "", $funcType([], [$Float64], false), 0], ["Get", "Get", "", $funcType([$String], [js.Object], false), 0], ["Index", "Index", "", $funcType([$Int], [js.Object], false), 0], ["Int", "Int", "", $funcType([], [$Int], false), 0], ["Int64", "Int64", "", $funcType([], [$Int64], false), 0], ["Interface", "Interface", "", $funcType([], [$emptyInterface], false), 0], ["Invoke", "Invoke", "", $funcType([($sliceType($emptyInterface))], [js.Object], true), 0], ["IsNull", "IsNull", "", $funcType([], [$Bool], false), 0], ["IsUndefined", "IsUndefined", "", $funcType([], [$Bool], false), 0], ["Length", "Length", "", $funcType([], [$Int], false), 0], ["New", "New", "", $funcType([($sliceType($emptyInterface))], [js.Object], true), 0], ["Set", "Set", "", $funcType([$String, $emptyInterface], [], false), 0], ["SetIndex", "SetIndex", "", $funcType([$Int, $emptyInterface], [], false), 0], ["SetJs", "SetJs", "", $funcType([js.Object], [], false), 0], ["Str", "Str", "", $funcType([], [$String], false), 0], ["Uint64", "Uint64", "", $funcType([], [$Uint64], false), 0], ["Unsafe", "Unsafe", "", $funcType([], [$Uintptr], false), 0]]; + ($ptrType(RouteProvider)).methods = [["AngularName", "AngularName", "", $funcType([], [$String], false), 0], ["Bool", "Bool", "", $funcType([], [$Bool], false), 0], ["Call", "Call", "", $funcType([$String, ($sliceType($emptyInterface))], [js.Object], true), 0], ["Delete", "Delete", "", $funcType([$String], [], false), 0], ["Float", "Float", "", $funcType([], [$Float64], false), 0], ["Get", "Get", "", $funcType([$String], [js.Object], false), 0], ["Index", "Index", "", $funcType([$Int], [js.Object], false), 0], ["Int", "Int", "", $funcType([], [$Int], false), 0], ["Int64", "Int64", "", $funcType([], [$Int64], false), 0], ["Interface", "Interface", "", $funcType([], [$emptyInterface], false), 0], ["Invoke", "Invoke", "", $funcType([($sliceType($emptyInterface))], [js.Object], true), 0], ["IsNull", "IsNull", "", $funcType([], [$Bool], false), 0], ["IsUndefined", "IsUndefined", "", $funcType([], [$Bool], false), 0], ["Length", "Length", "", $funcType([], [$Int], false), 0], ["New", "New", "", $funcType([($sliceType($emptyInterface))], [js.Object], true), 0], ["Otherwise", "Otherwise", "", $funcType([($ptrType(RouteOpts))], [], false), -1], ["Set", "Set", "", $funcType([$String, $emptyInterface], [], false), 0], ["SetIndex", "SetIndex", "", $funcType([$Int, $emptyInterface], [], false), 0], ["SetJs", "SetJs", "", $funcType([js.Object], [], false), 0], ["Str", "Str", "", $funcType([], [$String], false), 0], ["Uint64", "Uint64", "", $funcType([], [$Uint64], false), 0], ["Unsafe", "Unsafe", "", $funcType([], [$Uintptr], false), 0], ["When", "When", "", $funcType([$String, ($ptrType(RouteOpts))], [($ptrType(RouteProvider))], false), -1]]; + RouteProvider.init([["Provider", "", "", ($ptrType(Provider)), ""]]); + RouteParams.methods = [["AngularName", "AngularName", "", $funcType([], [$String], false), 0], ["Bool", "Bool", "", $funcType([], [$Bool], false), 0], ["Call", "Call", "", $funcType([$String, ($sliceType($emptyInterface))], [js.Object], true), 0], ["Delete", "Delete", "", $funcType([$String], [], false), 0], ["Float", "Float", "", $funcType([], [$Float64], false), 0], ["Index", "Index", "", $funcType([$Int], [js.Object], false), 0], ["Int", "Int", "", $funcType([], [$Int], false), 0], ["Int64", "Int64", "", $funcType([], [$Int64], false), 0], ["Interface", "Interface", "", $funcType([], [$emptyInterface], false), 0], ["Invoke", "Invoke", "", $funcType([($sliceType($emptyInterface))], [js.Object], true), 0], ["IsNull", "IsNull", "", $funcType([], [$Bool], false), 0], ["IsUndefined", "IsUndefined", "", $funcType([], [$Bool], false), 0], ["Length", "Length", "", $funcType([], [$Int], false), 0], ["New", "New", "", $funcType([($sliceType($emptyInterface))], [js.Object], true), 0], ["Set", "Set", "", $funcType([$String, $emptyInterface], [], false), 0], ["SetIndex", "SetIndex", "", $funcType([$Int, $emptyInterface], [], false), 0], ["SetJs", "SetJs", "", $funcType([js.Object], [], false), 0], ["Str", "Str", "", $funcType([], [$String], false), 0], ["Uint64", "Uint64", "", $funcType([], [$Uint64], false), 0], ["Unsafe", "Unsafe", "", $funcType([], [$Uintptr], false), 0]]; + ($ptrType(RouteParams)).methods = [["AngularName", "AngularName", "", $funcType([], [$String], false), 0], ["Bool", "Bool", "", $funcType([], [$Bool], false), 0], ["Call", "Call", "", $funcType([$String, ($sliceType($emptyInterface))], [js.Object], true), 0], ["Delete", "Delete", "", $funcType([$String], [], false), 0], ["Float", "Float", "", $funcType([], [$Float64], false), 0], ["Get", "Get", "", $funcType([$String], [$String], false), -1], ["Index", "Index", "", $funcType([$Int], [js.Object], false), 0], ["Int", "Int", "", $funcType([], [$Int], false), 0], ["Int64", "Int64", "", $funcType([], [$Int64], false), 0], ["Interface", "Interface", "", $funcType([], [$emptyInterface], false), 0], ["Invoke", "Invoke", "", $funcType([($sliceType($emptyInterface))], [js.Object], true), 0], ["IsNull", "IsNull", "", $funcType([], [$Bool], false), 0], ["IsUndefined", "IsUndefined", "", $funcType([], [$Bool], false), 0], ["Length", "Length", "", $funcType([], [$Int], false), 0], ["New", "New", "", $funcType([($sliceType($emptyInterface))], [js.Object], true), 0], ["Set", "Set", "", $funcType([$String, $emptyInterface], [], false), 0], ["SetIndex", "SetIndex", "", $funcType([$Int, $emptyInterface], [], false), 0], ["SetJs", "SetJs", "", $funcType([js.Object], [], false), 0], ["Str", "Str", "", $funcType([], [$String], false), 0], ["Uint64", "Uint64", "", $funcType([], [$Uint64], false), 0], ["Unsafe", "Unsafe", "", $funcType([], [$Uintptr], false), 0]]; + RouteParams.init([["Provider", "", "", ($ptrType(Provider)), ""]]); + $pkg.AngularProvidersList = (_map = new $Map(), _key = reflect.TypeOf((x = new RouteProvider.Ptr(($ptrType(Provider)).nil), new x.constructor.Struct(x))), _map[_key.$key()] = { k: _key, v: new RouteProvider.Ptr(NewProvider("$routeProvider")) }, _key = reflect.TypeOf((x$1 = new HttpService.Ptr(($ptrType(Provider)).nil), new x$1.constructor.Struct(x$1))), _map[_key.$key()] = { k: _key, v: new HttpService.Ptr(NewProvider("$http")) }, _key = reflect.TypeOf((x$2 = new Scope.Ptr(($ptrType(Provider)).nil), new x$2.constructor.Struct(x$2))), _map[_key.$key()] = { k: _key, v: new Scope.Ptr(NewProvider("$scope")) }, _key = reflect.TypeOf((x$3 = new RootScope.Ptr(($ptrType(Provider)).nil), new x$3.constructor.Struct(x$3))), _map[_key.$key()] = { k: _key, v: new RootScope.Ptr(NewProvider("$rootScope")) }, _key = reflect.TypeOf((x$4 = new QProvider.Ptr(($ptrType(Provider)).nil), new x$4.constructor.Struct(x$4))), _map[_key.$key()] = { k: _key, v: new QProvider.Ptr(NewProvider("$q")) }, _key = reflect.TypeOf((x$5 = new HttpProvider.Ptr(($ptrType(Provider)).nil), new x$5.constructor.Struct(x$5))), _map[_key.$key()] = { k: _key, v: new HttpProvider.Ptr(NewProvider("$httpProvider")) }, _key = reflect.TypeOf((x$6 = new Interval.Ptr(($ptrType(Provider)).nil), new x$6.constructor.Struct(x$6))), _map[_key.$key()] = { k: _key, v: new Interval.Ptr(NewProvider("$interval")) }, _key = reflect.TypeOf((x$7 = new RouteParams.Ptr(($ptrType(Provider)).nil), new x$7.constructor.Struct(x$7))), _map[_key.$key()] = { k: _key, v: new RouteParams.Ptr(NewProvider("$routeParams")) }, _map); + $pkg.Ng = InitAngular(); }; return $pkg; })(); -$packages["go/ast"] = (function() { - var $pkg = {}, token = $packages["go/token"], strings = $packages["strings"], unicode = $packages["unicode"], utf8 = $packages["unicode/utf8"], bytes = $packages["bytes"], fmt = $packages["fmt"], sort = $packages["sort"], strconv = $packages["strconv"], io = $packages["io"], os = $packages["os"], reflect = $packages["reflect"], scanner = $packages["go/scanner"], Node, Expr, Stmt, Decl, Comment, CommentGroup, Field, FieldList, BadExpr, Ident, Ellipsis, BasicLit, FuncLit, CompositeLit, ParenExpr, SelectorExpr, IndexExpr, SliceExpr, TypeAssertExpr, CallExpr, StarExpr, UnaryExpr, BinaryExpr, KeyValueExpr, ChanDir, ArrayType, StructType, FuncType, InterfaceType, MapType, ChanType, BadStmt, DeclStmt, EmptyStmt, LabeledStmt, ExprStmt, SendStmt, IncDecStmt, AssignStmt, GoStmt, DeferStmt, ReturnStmt, BranchStmt, BlockStmt, IfStmt, CaseClause, SwitchStmt, TypeSwitchStmt, CommClause, SelectStmt, ForStmt, RangeStmt, Spec, ImportSpec, ValueSpec, TypeSpec, BadDecl, GenDecl, FuncDecl, File, Package, byPos, CommentMap, commentListReader, nodeStack, posSpan, byImportSpec, byCommentPos, Scope, Object, ObjKind, Visitor, inspector, objKindStrings, isWhitespace, stripTrailingWhitespace, NewIdent, IsExported, sortComments, nodeList, NewCommentMap, summary, SortImports, importPath, importName, importComment, collapse, sortSpecs, NewScope, NewObj, walkIdentList, walkExprList, walkStmtList, walkDeclList, Walk, Inspect; - Node = $pkg.Node = $newType(8, "Interface", "ast.Node", "Node", "go/ast", null); - Expr = $pkg.Expr = $newType(8, "Interface", "ast.Expr", "Expr", "go/ast", null); - Stmt = $pkg.Stmt = $newType(8, "Interface", "ast.Stmt", "Stmt", "go/ast", null); - Decl = $pkg.Decl = $newType(8, "Interface", "ast.Decl", "Decl", "go/ast", null); - Comment = $pkg.Comment = $newType(0, "Struct", "ast.Comment", "Comment", "go/ast", function(Slash_, Text_) { - this.$val = this; - this.Slash = Slash_ !== undefined ? Slash_ : 0; - this.Text = Text_ !== undefined ? Text_ : ""; - }); - CommentGroup = $pkg.CommentGroup = $newType(0, "Struct", "ast.CommentGroup", "CommentGroup", "go/ast", function(List_) { +$packages["go/token"] = (function() { + var $pkg = {}, testing = $packages["testing"], fmt = $packages["fmt"], sort = $packages["sort"], sync = $packages["sync"], strconv = $packages["strconv"], Position, Pos, File, lineInfo, FileSet, serializedFile, serializedFileSet, Token, tokens, keywords, searchLineInfos, NewFileSet, searchFiles, searchInts, init, Lookup; + Position = $pkg.Position = $newType(0, "Struct", "token.Position", "Position", "go/token", function(Filename_, Offset_, Line_, Column_) { this.$val = this; - this.List = List_ !== undefined ? List_ : ($sliceType(($ptrType(Comment)))).nil; + this.Filename = Filename_ !== undefined ? Filename_ : ""; + this.Offset = Offset_ !== undefined ? Offset_ : 0; + this.Line = Line_ !== undefined ? Line_ : 0; + this.Column = Column_ !== undefined ? Column_ : 0; }); - Field = $pkg.Field = $newType(0, "Struct", "ast.Field", "Field", "go/ast", function(Doc_, Names_, Type_, Tag_, Comment_) { + Pos = $pkg.Pos = $newType(4, "Int", "token.Pos", "Pos", "go/token", null); + File = $pkg.File = $newType(0, "Struct", "token.File", "File", "go/token", function(set_, name_, base_, size_, lines_, infos_) { this.$val = this; - this.Doc = Doc_ !== undefined ? Doc_ : ($ptrType(CommentGroup)).nil; - this.Names = Names_ !== undefined ? Names_ : ($sliceType(($ptrType(Ident)))).nil; - this.Type = Type_ !== undefined ? Type_ : $ifaceNil; - this.Tag = Tag_ !== undefined ? Tag_ : ($ptrType(BasicLit)).nil; - this.Comment = Comment_ !== undefined ? Comment_ : ($ptrType(CommentGroup)).nil; + this.set = set_ !== undefined ? set_ : ($ptrType(FileSet)).nil; + this.name = name_ !== undefined ? name_ : ""; + this.base = base_ !== undefined ? base_ : 0; + this.size = size_ !== undefined ? size_ : 0; + this.lines = lines_ !== undefined ? lines_ : ($sliceType($Int)).nil; + this.infos = infos_ !== undefined ? infos_ : ($sliceType(lineInfo)).nil; }); - FieldList = $pkg.FieldList = $newType(0, "Struct", "ast.FieldList", "FieldList", "go/ast", function(Opening_, List_, Closing_) { + lineInfo = $pkg.lineInfo = $newType(0, "Struct", "token.lineInfo", "lineInfo", "go/token", function(Offset_, Filename_, Line_) { this.$val = this; - this.Opening = Opening_ !== undefined ? Opening_ : 0; - this.List = List_ !== undefined ? List_ : ($sliceType(($ptrType(Field)))).nil; - this.Closing = Closing_ !== undefined ? Closing_ : 0; + this.Offset = Offset_ !== undefined ? Offset_ : 0; + this.Filename = Filename_ !== undefined ? Filename_ : ""; + this.Line = Line_ !== undefined ? Line_ : 0; }); - BadExpr = $pkg.BadExpr = $newType(0, "Struct", "ast.BadExpr", "BadExpr", "go/ast", function(From_, To_) { + FileSet = $pkg.FileSet = $newType(0, "Struct", "token.FileSet", "FileSet", "go/token", function(mutex_, base_, files_, last_) { this.$val = this; - this.From = From_ !== undefined ? From_ : 0; - this.To = To_ !== undefined ? To_ : 0; + this.mutex = mutex_ !== undefined ? mutex_ : new sync.RWMutex.Ptr(); + this.base = base_ !== undefined ? base_ : 0; + this.files = files_ !== undefined ? files_ : ($sliceType(($ptrType(File)))).nil; + this.last = last_ !== undefined ? last_ : ($ptrType(File)).nil; }); - Ident = $pkg.Ident = $newType(0, "Struct", "ast.Ident", "Ident", "go/ast", function(NamePos_, Name_, Obj_) { + serializedFile = $pkg.serializedFile = $newType(0, "Struct", "token.serializedFile", "serializedFile", "go/token", function(Name_, Base_, Size_, Lines_, Infos_) { this.$val = this; - this.NamePos = NamePos_ !== undefined ? NamePos_ : 0; this.Name = Name_ !== undefined ? Name_ : ""; - this.Obj = Obj_ !== undefined ? Obj_ : ($ptrType(Object)).nil; - }); - Ellipsis = $pkg.Ellipsis = $newType(0, "Struct", "ast.Ellipsis", "Ellipsis", "go/ast", function(Ellipsis_, Elt_) { - this.$val = this; - this.Ellipsis = Ellipsis_ !== undefined ? Ellipsis_ : 0; - this.Elt = Elt_ !== undefined ? Elt_ : $ifaceNil; - }); - BasicLit = $pkg.BasicLit = $newType(0, "Struct", "ast.BasicLit", "BasicLit", "go/ast", function(ValuePos_, Kind_, Value_) { - this.$val = this; - this.ValuePos = ValuePos_ !== undefined ? ValuePos_ : 0; - this.Kind = Kind_ !== undefined ? Kind_ : 0; - this.Value = Value_ !== undefined ? Value_ : ""; - }); - FuncLit = $pkg.FuncLit = $newType(0, "Struct", "ast.FuncLit", "FuncLit", "go/ast", function(Type_, Body_) { - this.$val = this; - this.Type = Type_ !== undefined ? Type_ : ($ptrType(FuncType)).nil; - this.Body = Body_ !== undefined ? Body_ : ($ptrType(BlockStmt)).nil; - }); - CompositeLit = $pkg.CompositeLit = $newType(0, "Struct", "ast.CompositeLit", "CompositeLit", "go/ast", function(Type_, Lbrace_, Elts_, Rbrace_) { - this.$val = this; - this.Type = Type_ !== undefined ? Type_ : $ifaceNil; - this.Lbrace = Lbrace_ !== undefined ? Lbrace_ : 0; - this.Elts = Elts_ !== undefined ? Elts_ : ($sliceType(Expr)).nil; - this.Rbrace = Rbrace_ !== undefined ? Rbrace_ : 0; - }); - ParenExpr = $pkg.ParenExpr = $newType(0, "Struct", "ast.ParenExpr", "ParenExpr", "go/ast", function(Lparen_, X_, Rparen_) { - this.$val = this; - this.Lparen = Lparen_ !== undefined ? Lparen_ : 0; - this.X = X_ !== undefined ? X_ : $ifaceNil; - this.Rparen = Rparen_ !== undefined ? Rparen_ : 0; - }); - SelectorExpr = $pkg.SelectorExpr = $newType(0, "Struct", "ast.SelectorExpr", "SelectorExpr", "go/ast", function(X_, Sel_) { - this.$val = this; - this.X = X_ !== undefined ? X_ : $ifaceNil; - this.Sel = Sel_ !== undefined ? Sel_ : ($ptrType(Ident)).nil; - }); - IndexExpr = $pkg.IndexExpr = $newType(0, "Struct", "ast.IndexExpr", "IndexExpr", "go/ast", function(X_, Lbrack_, Index_, Rbrack_) { - this.$val = this; - this.X = X_ !== undefined ? X_ : $ifaceNil; - this.Lbrack = Lbrack_ !== undefined ? Lbrack_ : 0; - this.Index = Index_ !== undefined ? Index_ : $ifaceNil; - this.Rbrack = Rbrack_ !== undefined ? Rbrack_ : 0; - }); - SliceExpr = $pkg.SliceExpr = $newType(0, "Struct", "ast.SliceExpr", "SliceExpr", "go/ast", function(X_, Lbrack_, Low_, High_, Max_, Slice3_, Rbrack_) { - this.$val = this; - this.X = X_ !== undefined ? X_ : $ifaceNil; - this.Lbrack = Lbrack_ !== undefined ? Lbrack_ : 0; - this.Low = Low_ !== undefined ? Low_ : $ifaceNil; - this.High = High_ !== undefined ? High_ : $ifaceNil; - this.Max = Max_ !== undefined ? Max_ : $ifaceNil; - this.Slice3 = Slice3_ !== undefined ? Slice3_ : false; - this.Rbrack = Rbrack_ !== undefined ? Rbrack_ : 0; - }); - TypeAssertExpr = $pkg.TypeAssertExpr = $newType(0, "Struct", "ast.TypeAssertExpr", "TypeAssertExpr", "go/ast", function(X_, Lparen_, Type_, Rparen_) { - this.$val = this; - this.X = X_ !== undefined ? X_ : $ifaceNil; - this.Lparen = Lparen_ !== undefined ? Lparen_ : 0; - this.Type = Type_ !== undefined ? Type_ : $ifaceNil; - this.Rparen = Rparen_ !== undefined ? Rparen_ : 0; - }); - CallExpr = $pkg.CallExpr = $newType(0, "Struct", "ast.CallExpr", "CallExpr", "go/ast", function(Fun_, Lparen_, Args_, Ellipsis_, Rparen_) { - this.$val = this; - this.Fun = Fun_ !== undefined ? Fun_ : $ifaceNil; - this.Lparen = Lparen_ !== undefined ? Lparen_ : 0; - this.Args = Args_ !== undefined ? Args_ : ($sliceType(Expr)).nil; - this.Ellipsis = Ellipsis_ !== undefined ? Ellipsis_ : 0; - this.Rparen = Rparen_ !== undefined ? Rparen_ : 0; - }); - StarExpr = $pkg.StarExpr = $newType(0, "Struct", "ast.StarExpr", "StarExpr", "go/ast", function(Star_, X_) { - this.$val = this; - this.Star = Star_ !== undefined ? Star_ : 0; - this.X = X_ !== undefined ? X_ : $ifaceNil; - }); - UnaryExpr = $pkg.UnaryExpr = $newType(0, "Struct", "ast.UnaryExpr", "UnaryExpr", "go/ast", function(OpPos_, Op_, X_) { - this.$val = this; - this.OpPos = OpPos_ !== undefined ? OpPos_ : 0; - this.Op = Op_ !== undefined ? Op_ : 0; - this.X = X_ !== undefined ? X_ : $ifaceNil; - }); - BinaryExpr = $pkg.BinaryExpr = $newType(0, "Struct", "ast.BinaryExpr", "BinaryExpr", "go/ast", function(X_, OpPos_, Op_, Y_) { - this.$val = this; - this.X = X_ !== undefined ? X_ : $ifaceNil; - this.OpPos = OpPos_ !== undefined ? OpPos_ : 0; - this.Op = Op_ !== undefined ? Op_ : 0; - this.Y = Y_ !== undefined ? Y_ : $ifaceNil; - }); - KeyValueExpr = $pkg.KeyValueExpr = $newType(0, "Struct", "ast.KeyValueExpr", "KeyValueExpr", "go/ast", function(Key_, Colon_, Value_) { - this.$val = this; - this.Key = Key_ !== undefined ? Key_ : $ifaceNil; - this.Colon = Colon_ !== undefined ? Colon_ : 0; - this.Value = Value_ !== undefined ? Value_ : $ifaceNil; - }); - ChanDir = $pkg.ChanDir = $newType(4, "Int", "ast.ChanDir", "ChanDir", "go/ast", null); - ArrayType = $pkg.ArrayType = $newType(0, "Struct", "ast.ArrayType", "ArrayType", "go/ast", function(Lbrack_, Len_, Elt_) { - this.$val = this; - this.Lbrack = Lbrack_ !== undefined ? Lbrack_ : 0; - this.Len = Len_ !== undefined ? Len_ : $ifaceNil; - this.Elt = Elt_ !== undefined ? Elt_ : $ifaceNil; - }); - StructType = $pkg.StructType = $newType(0, "Struct", "ast.StructType", "StructType", "go/ast", function(Struct_, Fields_, Incomplete_) { - this.$val = this; - this.Struct = Struct_ !== undefined ? Struct_ : 0; - this.Fields = Fields_ !== undefined ? Fields_ : ($ptrType(FieldList)).nil; - this.Incomplete = Incomplete_ !== undefined ? Incomplete_ : false; - }); - FuncType = $pkg.FuncType = $newType(0, "Struct", "ast.FuncType", "FuncType", "go/ast", function(Func_, Params_, Results_) { - this.$val = this; - this.Func = Func_ !== undefined ? Func_ : 0; - this.Params = Params_ !== undefined ? Params_ : ($ptrType(FieldList)).nil; - this.Results = Results_ !== undefined ? Results_ : ($ptrType(FieldList)).nil; - }); - InterfaceType = $pkg.InterfaceType = $newType(0, "Struct", "ast.InterfaceType", "InterfaceType", "go/ast", function(Interface_, Methods_, Incomplete_) { - this.$val = this; - this.Interface = Interface_ !== undefined ? Interface_ : 0; - this.Methods = Methods_ !== undefined ? Methods_ : ($ptrType(FieldList)).nil; - this.Incomplete = Incomplete_ !== undefined ? Incomplete_ : false; - }); - MapType = $pkg.MapType = $newType(0, "Struct", "ast.MapType", "MapType", "go/ast", function(Map_, Key_, Value_) { - this.$val = this; - this.Map = Map_ !== undefined ? Map_ : 0; - this.Key = Key_ !== undefined ? Key_ : $ifaceNil; - this.Value = Value_ !== undefined ? Value_ : $ifaceNil; - }); - ChanType = $pkg.ChanType = $newType(0, "Struct", "ast.ChanType", "ChanType", "go/ast", function(Begin_, Arrow_, Dir_, Value_) { - this.$val = this; - this.Begin = Begin_ !== undefined ? Begin_ : 0; - this.Arrow = Arrow_ !== undefined ? Arrow_ : 0; - this.Dir = Dir_ !== undefined ? Dir_ : 0; - this.Value = Value_ !== undefined ? Value_ : $ifaceNil; - }); - BadStmt = $pkg.BadStmt = $newType(0, "Struct", "ast.BadStmt", "BadStmt", "go/ast", function(From_, To_) { - this.$val = this; - this.From = From_ !== undefined ? From_ : 0; - this.To = To_ !== undefined ? To_ : 0; - }); - DeclStmt = $pkg.DeclStmt = $newType(0, "Struct", "ast.DeclStmt", "DeclStmt", "go/ast", function(Decl_) { - this.$val = this; - this.Decl = Decl_ !== undefined ? Decl_ : $ifaceNil; - }); - EmptyStmt = $pkg.EmptyStmt = $newType(0, "Struct", "ast.EmptyStmt", "EmptyStmt", "go/ast", function(Semicolon_) { - this.$val = this; - this.Semicolon = Semicolon_ !== undefined ? Semicolon_ : 0; - }); - LabeledStmt = $pkg.LabeledStmt = $newType(0, "Struct", "ast.LabeledStmt", "LabeledStmt", "go/ast", function(Label_, Colon_, Stmt_) { - this.$val = this; - this.Label = Label_ !== undefined ? Label_ : ($ptrType(Ident)).nil; - this.Colon = Colon_ !== undefined ? Colon_ : 0; - this.Stmt = Stmt_ !== undefined ? Stmt_ : $ifaceNil; - }); - ExprStmt = $pkg.ExprStmt = $newType(0, "Struct", "ast.ExprStmt", "ExprStmt", "go/ast", function(X_) { - this.$val = this; - this.X = X_ !== undefined ? X_ : $ifaceNil; - }); - SendStmt = $pkg.SendStmt = $newType(0, "Struct", "ast.SendStmt", "SendStmt", "go/ast", function(Chan_, Arrow_, Value_) { - this.$val = this; - this.Chan = Chan_ !== undefined ? Chan_ : $ifaceNil; - this.Arrow = Arrow_ !== undefined ? Arrow_ : 0; - this.Value = Value_ !== undefined ? Value_ : $ifaceNil; - }); - IncDecStmt = $pkg.IncDecStmt = $newType(0, "Struct", "ast.IncDecStmt", "IncDecStmt", "go/ast", function(X_, TokPos_, Tok_) { - this.$val = this; - this.X = X_ !== undefined ? X_ : $ifaceNil; - this.TokPos = TokPos_ !== undefined ? TokPos_ : 0; - this.Tok = Tok_ !== undefined ? Tok_ : 0; - }); - AssignStmt = $pkg.AssignStmt = $newType(0, "Struct", "ast.AssignStmt", "AssignStmt", "go/ast", function(Lhs_, TokPos_, Tok_, Rhs_) { - this.$val = this; - this.Lhs = Lhs_ !== undefined ? Lhs_ : ($sliceType(Expr)).nil; - this.TokPos = TokPos_ !== undefined ? TokPos_ : 0; - this.Tok = Tok_ !== undefined ? Tok_ : 0; - this.Rhs = Rhs_ !== undefined ? Rhs_ : ($sliceType(Expr)).nil; - }); - GoStmt = $pkg.GoStmt = $newType(0, "Struct", "ast.GoStmt", "GoStmt", "go/ast", function(Go_, Call_) { - this.$val = this; - this.Go = Go_ !== undefined ? Go_ : 0; - this.Call = Call_ !== undefined ? Call_ : ($ptrType(CallExpr)).nil; - }); - DeferStmt = $pkg.DeferStmt = $newType(0, "Struct", "ast.DeferStmt", "DeferStmt", "go/ast", function(Defer_, Call_) { - this.$val = this; - this.Defer = Defer_ !== undefined ? Defer_ : 0; - this.Call = Call_ !== undefined ? Call_ : ($ptrType(CallExpr)).nil; - }); - ReturnStmt = $pkg.ReturnStmt = $newType(0, "Struct", "ast.ReturnStmt", "ReturnStmt", "go/ast", function(Return_, Results_) { - this.$val = this; - this.Return = Return_ !== undefined ? Return_ : 0; - this.Results = Results_ !== undefined ? Results_ : ($sliceType(Expr)).nil; - }); - BranchStmt = $pkg.BranchStmt = $newType(0, "Struct", "ast.BranchStmt", "BranchStmt", "go/ast", function(TokPos_, Tok_, Label_) { - this.$val = this; - this.TokPos = TokPos_ !== undefined ? TokPos_ : 0; - this.Tok = Tok_ !== undefined ? Tok_ : 0; - this.Label = Label_ !== undefined ? Label_ : ($ptrType(Ident)).nil; - }); - BlockStmt = $pkg.BlockStmt = $newType(0, "Struct", "ast.BlockStmt", "BlockStmt", "go/ast", function(Lbrace_, List_, Rbrace_) { - this.$val = this; - this.Lbrace = Lbrace_ !== undefined ? Lbrace_ : 0; - this.List = List_ !== undefined ? List_ : ($sliceType(Stmt)).nil; - this.Rbrace = Rbrace_ !== undefined ? Rbrace_ : 0; - }); - IfStmt = $pkg.IfStmt = $newType(0, "Struct", "ast.IfStmt", "IfStmt", "go/ast", function(If_, Init_, Cond_, Body_, Else_) { - this.$val = this; - this.If = If_ !== undefined ? If_ : 0; - this.Init = Init_ !== undefined ? Init_ : $ifaceNil; - this.Cond = Cond_ !== undefined ? Cond_ : $ifaceNil; - this.Body = Body_ !== undefined ? Body_ : ($ptrType(BlockStmt)).nil; - this.Else = Else_ !== undefined ? Else_ : $ifaceNil; - }); - CaseClause = $pkg.CaseClause = $newType(0, "Struct", "ast.CaseClause", "CaseClause", "go/ast", function(Case_, List_, Colon_, Body_) { - this.$val = this; - this.Case = Case_ !== undefined ? Case_ : 0; - this.List = List_ !== undefined ? List_ : ($sliceType(Expr)).nil; - this.Colon = Colon_ !== undefined ? Colon_ : 0; - this.Body = Body_ !== undefined ? Body_ : ($sliceType(Stmt)).nil; - }); - SwitchStmt = $pkg.SwitchStmt = $newType(0, "Struct", "ast.SwitchStmt", "SwitchStmt", "go/ast", function(Switch_, Init_, Tag_, Body_) { - this.$val = this; - this.Switch = Switch_ !== undefined ? Switch_ : 0; - this.Init = Init_ !== undefined ? Init_ : $ifaceNil; - this.Tag = Tag_ !== undefined ? Tag_ : $ifaceNil; - this.Body = Body_ !== undefined ? Body_ : ($ptrType(BlockStmt)).nil; - }); - TypeSwitchStmt = $pkg.TypeSwitchStmt = $newType(0, "Struct", "ast.TypeSwitchStmt", "TypeSwitchStmt", "go/ast", function(Switch_, Init_, Assign_, Body_) { - this.$val = this; - this.Switch = Switch_ !== undefined ? Switch_ : 0; - this.Init = Init_ !== undefined ? Init_ : $ifaceNil; - this.Assign = Assign_ !== undefined ? Assign_ : $ifaceNil; - this.Body = Body_ !== undefined ? Body_ : ($ptrType(BlockStmt)).nil; - }); - CommClause = $pkg.CommClause = $newType(0, "Struct", "ast.CommClause", "CommClause", "go/ast", function(Case_, Comm_, Colon_, Body_) { - this.$val = this; - this.Case = Case_ !== undefined ? Case_ : 0; - this.Comm = Comm_ !== undefined ? Comm_ : $ifaceNil; - this.Colon = Colon_ !== undefined ? Colon_ : 0; - this.Body = Body_ !== undefined ? Body_ : ($sliceType(Stmt)).nil; + this.Base = Base_ !== undefined ? Base_ : 0; + this.Size = Size_ !== undefined ? Size_ : 0; + this.Lines = Lines_ !== undefined ? Lines_ : ($sliceType($Int)).nil; + this.Infos = Infos_ !== undefined ? Infos_ : ($sliceType(lineInfo)).nil; }); - SelectStmt = $pkg.SelectStmt = $newType(0, "Struct", "ast.SelectStmt", "SelectStmt", "go/ast", function(Select_, Body_) { + serializedFileSet = $pkg.serializedFileSet = $newType(0, "Struct", "token.serializedFileSet", "serializedFileSet", "go/token", function(Base_, Files_) { this.$val = this; - this.Select = Select_ !== undefined ? Select_ : 0; - this.Body = Body_ !== undefined ? Body_ : ($ptrType(BlockStmt)).nil; + this.Base = Base_ !== undefined ? Base_ : 0; + this.Files = Files_ !== undefined ? Files_ : ($sliceType(serializedFile)).nil; }); - ForStmt = $pkg.ForStmt = $newType(0, "Struct", "ast.ForStmt", "ForStmt", "go/ast", function(For_, Init_, Cond_, Post_, Body_) { - this.$val = this; - this.For = For_ !== undefined ? For_ : 0; - this.Init = Init_ !== undefined ? Init_ : $ifaceNil; - this.Cond = Cond_ !== undefined ? Cond_ : $ifaceNil; - this.Post = Post_ !== undefined ? Post_ : $ifaceNil; - this.Body = Body_ !== undefined ? Body_ : ($ptrType(BlockStmt)).nil; - }); - RangeStmt = $pkg.RangeStmt = $newType(0, "Struct", "ast.RangeStmt", "RangeStmt", "go/ast", function(For_, Key_, Value_, TokPos_, Tok_, X_, Body_) { - this.$val = this; - this.For = For_ !== undefined ? For_ : 0; - this.Key = Key_ !== undefined ? Key_ : $ifaceNil; - this.Value = Value_ !== undefined ? Value_ : $ifaceNil; - this.TokPos = TokPos_ !== undefined ? TokPos_ : 0; - this.Tok = Tok_ !== undefined ? Tok_ : 0; - this.X = X_ !== undefined ? X_ : $ifaceNil; - this.Body = Body_ !== undefined ? Body_ : ($ptrType(BlockStmt)).nil; - }); - Spec = $pkg.Spec = $newType(8, "Interface", "ast.Spec", "Spec", "go/ast", null); - ImportSpec = $pkg.ImportSpec = $newType(0, "Struct", "ast.ImportSpec", "ImportSpec", "go/ast", function(Doc_, Name_, Path_, Comment_, EndPos_) { - this.$val = this; - this.Doc = Doc_ !== undefined ? Doc_ : ($ptrType(CommentGroup)).nil; - this.Name = Name_ !== undefined ? Name_ : ($ptrType(Ident)).nil; - this.Path = Path_ !== undefined ? Path_ : ($ptrType(BasicLit)).nil; - this.Comment = Comment_ !== undefined ? Comment_ : ($ptrType(CommentGroup)).nil; - this.EndPos = EndPos_ !== undefined ? EndPos_ : 0; - }); - ValueSpec = $pkg.ValueSpec = $newType(0, "Struct", "ast.ValueSpec", "ValueSpec", "go/ast", function(Doc_, Names_, Type_, Values_, Comment_) { - this.$val = this; - this.Doc = Doc_ !== undefined ? Doc_ : ($ptrType(CommentGroup)).nil; - this.Names = Names_ !== undefined ? Names_ : ($sliceType(($ptrType(Ident)))).nil; - this.Type = Type_ !== undefined ? Type_ : $ifaceNil; - this.Values = Values_ !== undefined ? Values_ : ($sliceType(Expr)).nil; - this.Comment = Comment_ !== undefined ? Comment_ : ($ptrType(CommentGroup)).nil; - }); - TypeSpec = $pkg.TypeSpec = $newType(0, "Struct", "ast.TypeSpec", "TypeSpec", "go/ast", function(Doc_, Name_, Type_, Comment_) { - this.$val = this; - this.Doc = Doc_ !== undefined ? Doc_ : ($ptrType(CommentGroup)).nil; - this.Name = Name_ !== undefined ? Name_ : ($ptrType(Ident)).nil; - this.Type = Type_ !== undefined ? Type_ : $ifaceNil; - this.Comment = Comment_ !== undefined ? Comment_ : ($ptrType(CommentGroup)).nil; - }); - BadDecl = $pkg.BadDecl = $newType(0, "Struct", "ast.BadDecl", "BadDecl", "go/ast", function(From_, To_) { - this.$val = this; - this.From = From_ !== undefined ? From_ : 0; - this.To = To_ !== undefined ? To_ : 0; - }); - GenDecl = $pkg.GenDecl = $newType(0, "Struct", "ast.GenDecl", "GenDecl", "go/ast", function(Doc_, TokPos_, Tok_, Lparen_, Specs_, Rparen_) { - this.$val = this; - this.Doc = Doc_ !== undefined ? Doc_ : ($ptrType(CommentGroup)).nil; - this.TokPos = TokPos_ !== undefined ? TokPos_ : 0; - this.Tok = Tok_ !== undefined ? Tok_ : 0; - this.Lparen = Lparen_ !== undefined ? Lparen_ : 0; - this.Specs = Specs_ !== undefined ? Specs_ : ($sliceType(Spec)).nil; - this.Rparen = Rparen_ !== undefined ? Rparen_ : 0; - }); - FuncDecl = $pkg.FuncDecl = $newType(0, "Struct", "ast.FuncDecl", "FuncDecl", "go/ast", function(Doc_, Recv_, Name_, Type_, Body_) { - this.$val = this; - this.Doc = Doc_ !== undefined ? Doc_ : ($ptrType(CommentGroup)).nil; - this.Recv = Recv_ !== undefined ? Recv_ : ($ptrType(FieldList)).nil; - this.Name = Name_ !== undefined ? Name_ : ($ptrType(Ident)).nil; - this.Type = Type_ !== undefined ? Type_ : ($ptrType(FuncType)).nil; - this.Body = Body_ !== undefined ? Body_ : ($ptrType(BlockStmt)).nil; - }); - File = $pkg.File = $newType(0, "Struct", "ast.File", "File", "go/ast", function(Doc_, Package_, Name_, Decls_, Scope_, Imports_, Unresolved_, Comments_) { - this.$val = this; - this.Doc = Doc_ !== undefined ? Doc_ : ($ptrType(CommentGroup)).nil; - this.Package = Package_ !== undefined ? Package_ : 0; - this.Name = Name_ !== undefined ? Name_ : ($ptrType(Ident)).nil; - this.Decls = Decls_ !== undefined ? Decls_ : ($sliceType(Decl)).nil; - this.Scope = Scope_ !== undefined ? Scope_ : ($ptrType(Scope)).nil; - this.Imports = Imports_ !== undefined ? Imports_ : ($sliceType(($ptrType(ImportSpec)))).nil; - this.Unresolved = Unresolved_ !== undefined ? Unresolved_ : ($sliceType(($ptrType(Ident)))).nil; - this.Comments = Comments_ !== undefined ? Comments_ : ($sliceType(($ptrType(CommentGroup)))).nil; - }); - Package = $pkg.Package = $newType(0, "Struct", "ast.Package", "Package", "go/ast", function(Name_, Scope_, Imports_, Files_) { - this.$val = this; - this.Name = Name_ !== undefined ? Name_ : ""; - this.Scope = Scope_ !== undefined ? Scope_ : ($ptrType(Scope)).nil; - this.Imports = Imports_ !== undefined ? Imports_ : false; - this.Files = Files_ !== undefined ? Files_ : false; - }); - byPos = $pkg.byPos = $newType(12, "Slice", "ast.byPos", "byPos", "go/ast", null); - CommentMap = $pkg.CommentMap = $newType(4, "Map", "ast.CommentMap", "CommentMap", "go/ast", null); - commentListReader = $pkg.commentListReader = $newType(0, "Struct", "ast.commentListReader", "commentListReader", "go/ast", function(fset_, list_, index_, comment_, pos_, end_) { - this.$val = this; - this.fset = fset_ !== undefined ? fset_ : ($ptrType(token.FileSet)).nil; - this.list = list_ !== undefined ? list_ : ($sliceType(($ptrType(CommentGroup)))).nil; - this.index = index_ !== undefined ? index_ : 0; - this.comment = comment_ !== undefined ? comment_ : ($ptrType(CommentGroup)).nil; - this.pos = pos_ !== undefined ? pos_ : new token.Position.Ptr(); - this.end = end_ !== undefined ? end_ : new token.Position.Ptr(); - }); - nodeStack = $pkg.nodeStack = $newType(12, "Slice", "ast.nodeStack", "nodeStack", "go/ast", null); - posSpan = $pkg.posSpan = $newType(0, "Struct", "ast.posSpan", "posSpan", "go/ast", function(Start_, End_) { - this.$val = this; - this.Start = Start_ !== undefined ? Start_ : 0; - this.End = End_ !== undefined ? End_ : 0; - }); - byImportSpec = $pkg.byImportSpec = $newType(12, "Slice", "ast.byImportSpec", "byImportSpec", "go/ast", null); - byCommentPos = $pkg.byCommentPos = $newType(12, "Slice", "ast.byCommentPos", "byCommentPos", "go/ast", null); - Scope = $pkg.Scope = $newType(0, "Struct", "ast.Scope", "Scope", "go/ast", function(Outer_, Objects_) { - this.$val = this; - this.Outer = Outer_ !== undefined ? Outer_ : ($ptrType(Scope)).nil; - this.Objects = Objects_ !== undefined ? Objects_ : false; - }); - Object = $pkg.Object = $newType(0, "Struct", "ast.Object", "Object", "go/ast", function(Kind_, Name_, Decl_, Data_, Type_) { - this.$val = this; - this.Kind = Kind_ !== undefined ? Kind_ : 0; - this.Name = Name_ !== undefined ? Name_ : ""; - this.Decl = Decl_ !== undefined ? Decl_ : $ifaceNil; - this.Data = Data_ !== undefined ? Data_ : $ifaceNil; - this.Type = Type_ !== undefined ? Type_ : $ifaceNil; - }); - ObjKind = $pkg.ObjKind = $newType(4, "Int", "ast.ObjKind", "ObjKind", "go/ast", null); - Visitor = $pkg.Visitor = $newType(8, "Interface", "ast.Visitor", "Visitor", "go/ast", null); - inspector = $pkg.inspector = $newType(4, "Func", "ast.inspector", "inspector", "go/ast", null); - Comment.Ptr.prototype.Pos = function() { - var c; - c = this; - return c.Slash; + Token = $pkg.Token = $newType(4, "Int", "token.Token", "Token", "go/token", null); + Position.Ptr.prototype.IsValid = function() { + var pos; + pos = this; + return pos.Line > 0; }; - Comment.prototype.Pos = function() { return this.$val.Pos(); }; - Comment.Ptr.prototype.End = function() { - var c; - c = this; - return (((c.Slash >> 0) + c.Text.length >> 0) >> 0); + Position.prototype.IsValid = function() { return this.$val.IsValid(); }; + Position.Ptr.prototype.String = function() { + var pos, s; + pos = new Position.Ptr(); $copy(pos, this, Position); + s = pos.Filename; + if (pos.IsValid()) { + if (!(s === "")) { + s = s + (":"); + } + s = s + (fmt.Sprintf("%d:%d", new ($sliceType($emptyInterface))([new $Int(pos.Line), new $Int(pos.Column)]))); + } + if (s === "") { + s = "-"; + } + return s; }; - Comment.prototype.End = function() { return this.$val.End(); }; - CommentGroup.Ptr.prototype.Pos = function() { - var g, x; - g = this; - return (x = g.List, ((0 < 0 || 0 >= x.$length) ? $throwRuntimeError("index out of range") : x.$array[x.$offset + 0])).Pos(); + Position.prototype.String = function() { return this.$val.String(); }; + Pos.prototype.IsValid = function() { + var p; + p = this.$val !== undefined ? this.$val : this; + return !((p === 0)); }; - CommentGroup.prototype.Pos = function() { return this.$val.Pos(); }; - CommentGroup.Ptr.prototype.End = function() { - var g, x, x$1; - g = this; - return (x = g.List, x$1 = g.List.$length - 1 >> 0, ((x$1 < 0 || x$1 >= x.$length) ? $throwRuntimeError("index out of range") : x.$array[x.$offset + x$1])).End(); + $ptrType(Pos).prototype.IsValid = function() { return new Pos(this.$get()).IsValid(); }; + File.Ptr.prototype.Name = function() { + var f; + f = this; + return f.name; }; - CommentGroup.prototype.End = function() { return this.$val.End(); }; - isWhitespace = function(ch) { - return (ch === 32) || (ch === 9) || (ch === 10) || (ch === 13); + File.prototype.Name = function() { return this.$val.Name(); }; + File.Ptr.prototype.Base = function() { + var f; + f = this; + return f.base; }; - stripTrailingWhitespace = function(s) { - var i; - i = s.length; - while (i > 0 && isWhitespace(s.charCodeAt((i - 1 >> 0)))) { - i = i - (1) >> 0; + File.prototype.Base = function() { return this.$val.Base(); }; + File.Ptr.prototype.Size = function() { + var f; + f = this; + return f.size; + }; + File.prototype.Size = function() { return this.$val.Size(); }; + File.Ptr.prototype.LineCount = function() { + var f, n; + f = this; + f.set.mutex.RLock(); + n = f.lines.$length; + f.set.mutex.RUnlock(); + return n; + }; + File.prototype.LineCount = function() { return this.$val.LineCount(); }; + File.Ptr.prototype.AddLine = function(offset) { + var f, i, x, x$1; + f = this; + f.set.mutex.Lock(); + i = f.lines.$length; + if (((i === 0) || (x = f.lines, x$1 = i - 1 >> 0, ((x$1 < 0 || x$1 >= x.$length) ? $throwRuntimeError("index out of range") : x.$array[x.$offset + x$1])) < offset) && offset < f.size) { + f.lines = $append(f.lines, offset); } - return s.substring(0, i); + f.set.mutex.Unlock(); }; - CommentGroup.Ptr.prototype.Text = function() { - var g, comments, _ref, _i, i, c, lines, _ref$1, _i$1, c$1, _ref$2, cl, _ref$3, _i$2, l, n, _ref$4, _i$3, line, x, x$1; - g = this; - if (g === ($ptrType(CommentGroup)).nil) { - return ""; + File.prototype.AddLine = function(offset) { return this.$val.AddLine(offset); }; + File.Ptr.prototype.MergeLine = function(line) { + var $deferred = [], $err = null, f; + /* */ try { $deferFrames.push($deferred); + f = this; + if (line <= 0) { + $panic(new $String("illegal line number (line numbering starts at 1)")); } - comments = ($sliceType($String)).make(g.List.$length); - _ref = g.List; + f.set.mutex.Lock(); + $deferred.push([$methodVal(f.set.mutex, "Unlock"), []]); + if (line >= f.lines.$length) { + $panic(new $String("illegal line number")); + } + $copySlice($subslice(f.lines, line), $subslice(f.lines, (line + 1 >> 0))); + f.lines = $subslice(f.lines, 0, (f.lines.$length - 1 >> 0)); + /* */ } catch(err) { $err = err; } finally { $deferFrames.pop(); $callDeferred($deferred, $err); } + }; + File.prototype.MergeLine = function(line) { return this.$val.MergeLine(line); }; + File.Ptr.prototype.SetLines = function(lines) { + var f, size, _ref, _i, i, offset, x; + f = this; + size = f.size; + _ref = lines; _i = 0; while (_i < _ref.$length) { i = _i; - c = ((_i < 0 || _i >= _ref.$length) ? $throwRuntimeError("index out of range") : _ref.$array[_ref.$offset + _i]); - (i < 0 || i >= comments.$length) ? $throwRuntimeError("index out of range") : comments.$array[comments.$offset + i] = c.Text; + offset = ((_i < 0 || _i >= _ref.$length) ? $throwRuntimeError("index out of range") : _ref.$array[_ref.$offset + _i]); + if (i > 0 && offset <= (x = i - 1 >> 0, ((x < 0 || x >= lines.$length) ? $throwRuntimeError("index out of range") : lines.$array[lines.$offset + x])) || size <= offset) { + return false; + } _i++; } - lines = ($sliceType($String)).make(0, 10); - _ref$1 = comments; - _i$1 = 0; - while (_i$1 < _ref$1.$length) { - c$1 = ((_i$1 < 0 || _i$1 >= _ref$1.$length) ? $throwRuntimeError("index out of range") : _ref$1.$array[_ref$1.$offset + _i$1]); - _ref$2 = c$1.charCodeAt(1); - if (_ref$2 === 47) { - c$1 = c$1.substring(2); - if (c$1.length > 0 && (c$1.charCodeAt(0) === 32)) { - c$1 = c$1.substring(1); - } - } else if (_ref$2 === 42) { - c$1 = c$1.substring(2, (c$1.length - 2 >> 0)); - } - cl = strings.Split(c$1, "\n"); - _ref$3 = cl; - _i$2 = 0; - while (_i$2 < _ref$3.$length) { - l = ((_i$2 < 0 || _i$2 >= _ref$3.$length) ? $throwRuntimeError("index out of range") : _ref$3.$array[_ref$3.$offset + _i$2]); - lines = $append(lines, stripTrailingWhitespace(l)); - _i$2++; + f.set.mutex.Lock(); + f.lines = lines; + f.set.mutex.Unlock(); + return true; + }; + File.prototype.SetLines = function(lines) { return this.$val.SetLines(lines); }; + File.Ptr.prototype.SetLinesForContent = function(content) { + var f, lines, line, _ref, _i, offset, b; + f = this; + lines = ($sliceType($Int)).nil; + line = 0; + _ref = content; + _i = 0; + while (_i < _ref.$length) { + offset = _i; + b = ((_i < 0 || _i >= _ref.$length) ? $throwRuntimeError("index out of range") : _ref.$array[_ref.$offset + _i]); + if (line >= 0) { + lines = $append(lines, line); } - _i$1++; - } - n = 0; - _ref$4 = lines; - _i$3 = 0; - while (_i$3 < _ref$4.$length) { - line = ((_i$3 < 0 || _i$3 >= _ref$4.$length) ? $throwRuntimeError("index out of range") : _ref$4.$array[_ref$4.$offset + _i$3]); - if (!(line === "") || n > 0 && !((x = n - 1 >> 0, ((x < 0 || x >= lines.$length) ? $throwRuntimeError("index out of range") : lines.$array[lines.$offset + x])) === "")) { - (n < 0 || n >= lines.$length) ? $throwRuntimeError("index out of range") : lines.$array[lines.$offset + n] = line; - n = n + (1) >> 0; + line = -1; + if (b === 10) { + line = offset + 1 >> 0; } - _i$3++; - } - lines = $subslice(lines, 0, n); - if (n > 0 && !((x$1 = n - 1 >> 0, ((x$1 < 0 || x$1 >= lines.$length) ? $throwRuntimeError("index out of range") : lines.$array[lines.$offset + x$1])) === "")) { - lines = $append(lines, ""); + _i++; } - return strings.Join(lines, "\n"); + f.set.mutex.Lock(); + f.lines = lines; + f.set.mutex.Unlock(); }; - CommentGroup.prototype.Text = function() { return this.$val.Text(); }; - Field.Ptr.prototype.Pos = function() { - var f, x; + File.prototype.SetLinesForContent = function(content) { return this.$val.SetLinesForContent(content); }; + File.Ptr.prototype.AddLineInfo = function(offset, filename, line) { + var f, i, x, x$1; f = this; - if (f.Names.$length > 0) { - return (x = f.Names, ((0 < 0 || 0 >= x.$length) ? $throwRuntimeError("index out of range") : x.$array[x.$offset + 0])).Pos(); + f.set.mutex.Lock(); + i = f.infos.$length; + if ((i === 0) || (x = f.infos, x$1 = i - 1 >> 0, ((x$1 < 0 || x$1 >= x.$length) ? $throwRuntimeError("index out of range") : x.$array[x.$offset + x$1])).Offset < offset && offset < f.size) { + f.infos = $append(f.infos, new lineInfo.Ptr(offset, filename, line)); } - return f.Type.Pos(); + f.set.mutex.Unlock(); }; - Field.prototype.Pos = function() { return this.$val.Pos(); }; - Field.Ptr.prototype.End = function() { + File.prototype.AddLineInfo = function(offset, filename, line) { return this.$val.AddLineInfo(offset, filename, line); }; + File.Ptr.prototype.Pos = function(offset) { var f; f = this; - if (!(f.Tag === ($ptrType(BasicLit)).nil)) { - return f.Tag.End(); + if (offset > f.size) { + $panic(new $String("illegal file offset")); } - return f.Type.End(); + return ((f.base + offset >> 0) >> 0); }; - Field.prototype.End = function() { return this.$val.End(); }; - FieldList.Ptr.prototype.Pos = function() { - var f, x; + File.prototype.Pos = function(offset) { return this.$val.Pos(offset); }; + File.Ptr.prototype.Offset = function(p) { + var f; f = this; - if ((new token.Pos(f.Opening)).IsValid()) { - return f.Opening; - } - if (f.List.$length > 0) { - return (x = f.List, ((0 < 0 || 0 >= x.$length) ? $throwRuntimeError("index out of range") : x.$array[x.$offset + 0])).Pos(); + if ((p >> 0) < f.base || (p >> 0) > (f.base + f.size >> 0)) { + $panic(new $String("illegal Pos value")); } - return 0; + return (p >> 0) - f.base >> 0; }; - FieldList.prototype.Pos = function() { return this.$val.Pos(); }; - FieldList.Ptr.prototype.End = function() { - var f, n, x, x$1; + File.prototype.Offset = function(p) { return this.$val.Offset(p); }; + File.Ptr.prototype.Line = function(p) { + var f; f = this; - if ((new token.Pos(f.Closing)).IsValid()) { - return f.Closing + 1 >> 0; - } - n = f.List.$length; - if (n > 0) { - return (x = f.List, x$1 = n - 1 >> 0, ((x$1 < 0 || x$1 >= x.$length) ? $throwRuntimeError("index out of range") : x.$array[x.$offset + x$1])).End(); - } - return 0; + return f.Position(p).Line; }; - FieldList.prototype.End = function() { return this.$val.End(); }; - FieldList.Ptr.prototype.NumFields = function() { - var f, n, _ref, _i, g, m; + File.prototype.Line = function(p) { return this.$val.Line(p); }; + searchLineInfos = function(a, x) { + return sort.Search(a.$length, (function(i) { + return ((i < 0 || i >= a.$length) ? $throwRuntimeError("index out of range") : a.$array[a.$offset + i]).Offset > x; + })) - 1 >> 0; + }; + File.Ptr.prototype.info = function(offset) { + var filename = "", line = 0, column = 0, f, i, _tmp, _tmp$1, x, i$1, x$1, alt, i$2; f = this; - n = 0; - if (!(f === ($ptrType(FieldList)).nil)) { - _ref = f.List; - _i = 0; - while (_i < _ref.$length) { - g = ((_i < 0 || _i >= _ref.$length) ? $throwRuntimeError("index out of range") : _ref.$array[_ref.$offset + _i]); - m = g.Names.$length; - if (m === 0) { - m = 1; + filename = f.name; + i = searchInts(f.lines, offset); + if (i >= 0) { + _tmp = i + 1 >> 0; _tmp$1 = (offset - (x = f.lines, ((i < 0 || i >= x.$length) ? $throwRuntimeError("index out of range") : x.$array[x.$offset + i])) >> 0) + 1 >> 0; line = _tmp; column = _tmp$1; + } + if (f.infos.$length > 0) { + i$1 = searchLineInfos(f.infos, offset); + if (i$1 >= 0) { + alt = (x$1 = f.infos, ((i$1 < 0 || i$1 >= x$1.$length) ? $throwRuntimeError("index out of range") : x$1.$array[x$1.$offset + i$1])); + filename = alt.Filename; + i$2 = searchInts(f.lines, alt.Offset); + if (i$2 >= 0) { + line = line + (((alt.Line - i$2 >> 0) - 1 >> 0)) >> 0; } - n = n + (m) >> 0; - _i++; } } - return n; - }; - FieldList.prototype.NumFields = function() { return this.$val.NumFields(); }; - BadExpr.Ptr.prototype.Pos = function() { - var x; - x = this; - return x.From; + return [filename, line, column]; }; - BadExpr.prototype.Pos = function() { return this.$val.Pos(); }; - Ident.Ptr.prototype.Pos = function() { - var x; - x = this; - return x.NamePos; + File.prototype.info = function(offset) { return this.$val.info(offset); }; + File.Ptr.prototype.position = function(p) { + var pos = new Position.Ptr(), f, offset, _tuple; + f = this; + offset = (p >> 0) - f.base >> 0; + pos.Offset = offset; + _tuple = f.info(offset); pos.Filename = _tuple[0]; pos.Line = _tuple[1]; pos.Column = _tuple[2]; + return pos; }; - Ident.prototype.Pos = function() { return this.$val.Pos(); }; - Ellipsis.Ptr.prototype.Pos = function() { - var x; - x = this; - return x.Ellipsis; + File.prototype.position = function(p) { return this.$val.position(p); }; + File.Ptr.prototype.Position = function(p) { + var pos = new Position.Ptr(), f; + f = this; + if (!((p === 0))) { + if ((p >> 0) < f.base || (p >> 0) > (f.base + f.size >> 0)) { + $panic(new $String("illegal Pos value")); + } + $copy(pos, f.position(p), Position); + } + return pos; }; - Ellipsis.prototype.Pos = function() { return this.$val.Pos(); }; - BasicLit.Ptr.prototype.Pos = function() { - var x; - x = this; - return x.ValuePos; + File.prototype.Position = function(p) { return this.$val.Position(p); }; + NewFileSet = $pkg.NewFileSet = function() { + return new FileSet.Ptr(new sync.RWMutex.Ptr(), 1, ($sliceType(($ptrType(File)))).nil, ($ptrType(File)).nil); }; - BasicLit.prototype.Pos = function() { return this.$val.Pos(); }; - FuncLit.Ptr.prototype.Pos = function() { - var x; - x = this; - return x.Type.Pos(); + FileSet.Ptr.prototype.Base = function() { + var s, b; + s = this; + s.mutex.RLock(); + b = s.base; + s.mutex.RUnlock(); + return b; }; - FuncLit.prototype.Pos = function() { return this.$val.Pos(); }; - CompositeLit.Ptr.prototype.Pos = function() { - var x; - x = this; - if (!($interfaceIsEqual(x.Type, $ifaceNil))) { - return x.Type.Pos(); + FileSet.prototype.Base = function() { return this.$val.Base(); }; + FileSet.Ptr.prototype.AddFile = function(filename, base, size) { + var $deferred = [], $err = null, s, f; + /* */ try { $deferFrames.push($deferred); + s = this; + s.mutex.Lock(); + $deferred.push([$methodVal(s.mutex, "Unlock"), []]); + if (base < 0) { + base = s.base; } - return x.Lbrace; + if (base < s.base || size < 0) { + $panic(new $String("illegal base or size")); + } + f = new File.Ptr(s, filename, base, size, new ($sliceType($Int))([0]), ($sliceType(lineInfo)).nil); + base = base + ((size + 1 >> 0)) >> 0; + if (base < 0) { + $panic(new $String("token.Pos offset overflow (> 2G of source code in file set)")); + } + s.base = base; + s.files = $append(s.files, f); + s.last = f; + return f; + /* */ } catch(err) { $err = err; return ($ptrType(File)).nil; } finally { $deferFrames.pop(); $callDeferred($deferred, $err); } }; - CompositeLit.prototype.Pos = function() { return this.$val.Pos(); }; - ParenExpr.Ptr.prototype.Pos = function() { - var x; - x = this; - return x.Lparen; + FileSet.prototype.AddFile = function(filename, base, size) { return this.$val.AddFile(filename, base, size); }; + FileSet.Ptr.prototype.Iterate = function(f) { + var s, i, file, x; + s = this; + i = 0; + while (true) { + file = ($ptrType(File)).nil; + s.mutex.RLock(); + if (i < s.files.$length) { + file = (x = s.files, ((i < 0 || i >= x.$length) ? $throwRuntimeError("index out of range") : x.$array[x.$offset + i])); + } + s.mutex.RUnlock(); + if (file === ($ptrType(File)).nil || !f(file)) { + break; + } + i = i + (1) >> 0; + } }; - ParenExpr.prototype.Pos = function() { return this.$val.Pos(); }; - SelectorExpr.Ptr.prototype.Pos = function() { - var x; - x = this; - return x.X.Pos(); + FileSet.prototype.Iterate = function(f) { return this.$val.Iterate(f); }; + searchFiles = function(a, x) { + return sort.Search(a.$length, (function(i) { + return ((i < 0 || i >= a.$length) ? $throwRuntimeError("index out of range") : a.$array[a.$offset + i]).base > x; + })) - 1 >> 0; }; - SelectorExpr.prototype.Pos = function() { return this.$val.Pos(); }; - IndexExpr.Ptr.prototype.Pos = function() { - var x; - x = this; - return x.X.Pos(); - }; - IndexExpr.prototype.Pos = function() { return this.$val.Pos(); }; - SliceExpr.Ptr.prototype.Pos = function() { - var x; - x = this; - return x.X.Pos(); - }; - SliceExpr.prototype.Pos = function() { return this.$val.Pos(); }; - TypeAssertExpr.Ptr.prototype.Pos = function() { - var x; - x = this; - return x.X.Pos(); - }; - TypeAssertExpr.prototype.Pos = function() { return this.$val.Pos(); }; - CallExpr.Ptr.prototype.Pos = function() { - var x; - x = this; - return x.Fun.Pos(); - }; - CallExpr.prototype.Pos = function() { return this.$val.Pos(); }; - StarExpr.Ptr.prototype.Pos = function() { - var x; - x = this; - return x.Star; - }; - StarExpr.prototype.Pos = function() { return this.$val.Pos(); }; - UnaryExpr.Ptr.prototype.Pos = function() { - var x; - x = this; - return x.OpPos; - }; - UnaryExpr.prototype.Pos = function() { return this.$val.Pos(); }; - BinaryExpr.Ptr.prototype.Pos = function() { - var x; - x = this; - return x.X.Pos(); - }; - BinaryExpr.prototype.Pos = function() { return this.$val.Pos(); }; - KeyValueExpr.Ptr.prototype.Pos = function() { - var x; - x = this; - return x.Key.Pos(); - }; - KeyValueExpr.prototype.Pos = function() { return this.$val.Pos(); }; - ArrayType.Ptr.prototype.Pos = function() { - var x; - x = this; - return x.Lbrack; - }; - ArrayType.prototype.Pos = function() { return this.$val.Pos(); }; - StructType.Ptr.prototype.Pos = function() { - var x; - x = this; - return x.Struct; - }; - StructType.prototype.Pos = function() { return this.$val.Pos(); }; - FuncType.Ptr.prototype.Pos = function() { - var x; - x = this; - if ((new token.Pos(x.Func)).IsValid() || x.Params === ($ptrType(FieldList)).nil) { - return x.Func; + FileSet.Ptr.prototype.file = function(p) { + var s, f, i, x, f$1; + s = this; + s.mutex.RLock(); + f = s.last; + if (!(f === ($ptrType(File)).nil) && f.base <= (p >> 0) && (p >> 0) <= (f.base + f.size >> 0)) { + s.mutex.RUnlock(); + return f; } - return x.Params.Pos(); - }; - FuncType.prototype.Pos = function() { return this.$val.Pos(); }; - InterfaceType.Ptr.prototype.Pos = function() { - var x; - x = this; - return x.Interface; - }; - InterfaceType.prototype.Pos = function() { return this.$val.Pos(); }; - MapType.Ptr.prototype.Pos = function() { - var x; - x = this; - return x.Map; - }; - MapType.prototype.Pos = function() { return this.$val.Pos(); }; - ChanType.Ptr.prototype.Pos = function() { - var x; - x = this; - return x.Begin; - }; - ChanType.prototype.Pos = function() { return this.$val.Pos(); }; - BadExpr.Ptr.prototype.End = function() { - var x; - x = this; - return x.To; - }; - BadExpr.prototype.End = function() { return this.$val.End(); }; - Ident.Ptr.prototype.End = function() { - var x; - x = this; - return (((x.NamePos >> 0) + x.Name.length >> 0) >> 0); - }; - Ident.prototype.End = function() { return this.$val.End(); }; - Ellipsis.Ptr.prototype.End = function() { - var x; - x = this; - if (!($interfaceIsEqual(x.Elt, $ifaceNil))) { - return x.Elt.End(); + i = searchFiles(s.files, (p >> 0)); + if (i >= 0) { + f$1 = (x = s.files, ((i < 0 || i >= x.$length) ? $throwRuntimeError("index out of range") : x.$array[x.$offset + i])); + if ((p >> 0) <= (f$1.base + f$1.size >> 0)) { + s.mutex.RUnlock(); + s.mutex.Lock(); + s.last = f$1; + s.mutex.Unlock(); + return f$1; + } } - return x.Ellipsis + 3 >> 0; - }; - Ellipsis.prototype.End = function() { return this.$val.End(); }; - BasicLit.Ptr.prototype.End = function() { - var x; - x = this; - return (((x.ValuePos >> 0) + x.Value.length >> 0) >> 0); - }; - BasicLit.prototype.End = function() { return this.$val.End(); }; - FuncLit.Ptr.prototype.End = function() { - var x; - x = this; - return x.Body.End(); - }; - FuncLit.prototype.End = function() { return this.$val.End(); }; - CompositeLit.Ptr.prototype.End = function() { - var x; - x = this; - return x.Rbrace + 1 >> 0; - }; - CompositeLit.prototype.End = function() { return this.$val.End(); }; - ParenExpr.Ptr.prototype.End = function() { - var x; - x = this; - return x.Rparen + 1 >> 0; - }; - ParenExpr.prototype.End = function() { return this.$val.End(); }; - SelectorExpr.Ptr.prototype.End = function() { - var x; - x = this; - return x.Sel.End(); - }; - SelectorExpr.prototype.End = function() { return this.$val.End(); }; - IndexExpr.Ptr.prototype.End = function() { - var x; - x = this; - return x.Rbrack + 1 >> 0; - }; - IndexExpr.prototype.End = function() { return this.$val.End(); }; - SliceExpr.Ptr.prototype.End = function() { - var x; - x = this; - return x.Rbrack + 1 >> 0; - }; - SliceExpr.prototype.End = function() { return this.$val.End(); }; - TypeAssertExpr.Ptr.prototype.End = function() { - var x; - x = this; - return x.Rparen + 1 >> 0; - }; - TypeAssertExpr.prototype.End = function() { return this.$val.End(); }; - CallExpr.Ptr.prototype.End = function() { - var x; - x = this; - return x.Rparen + 1 >> 0; - }; - CallExpr.prototype.End = function() { return this.$val.End(); }; - StarExpr.Ptr.prototype.End = function() { - var x; - x = this; - return x.X.End(); - }; - StarExpr.prototype.End = function() { return this.$val.End(); }; - UnaryExpr.Ptr.prototype.End = function() { - var x; - x = this; - return x.X.End(); - }; - UnaryExpr.prototype.End = function() { return this.$val.End(); }; - BinaryExpr.Ptr.prototype.End = function() { - var x; - x = this; - return x.Y.End(); - }; - BinaryExpr.prototype.End = function() { return this.$val.End(); }; - KeyValueExpr.Ptr.prototype.End = function() { - var x; - x = this; - return x.Value.End(); - }; - KeyValueExpr.prototype.End = function() { return this.$val.End(); }; - ArrayType.Ptr.prototype.End = function() { - var x; - x = this; - return x.Elt.End(); - }; - ArrayType.prototype.End = function() { return this.$val.End(); }; - StructType.Ptr.prototype.End = function() { - var x; - x = this; - return x.Fields.End(); + s.mutex.RUnlock(); + return ($ptrType(File)).nil; }; - StructType.prototype.End = function() { return this.$val.End(); }; - FuncType.Ptr.prototype.End = function() { - var x; - x = this; - if (!(x.Results === ($ptrType(FieldList)).nil)) { - return x.Results.End(); + FileSet.prototype.file = function(p) { return this.$val.file(p); }; + FileSet.Ptr.prototype.File = function(p) { + var f = ($ptrType(File)).nil, s; + s = this; + if (!((p === 0))) { + f = s.file(p); } - return x.Params.End(); + return f; }; - FuncType.prototype.End = function() { return this.$val.End(); }; - InterfaceType.Ptr.prototype.End = function() { - var x; - x = this; - return x.Methods.End(); + FileSet.prototype.File = function(p) { return this.$val.File(p); }; + FileSet.Ptr.prototype.Position = function(p) { + var pos = new Position.Ptr(), s, f; + s = this; + if (!((p === 0))) { + f = s.file(p); + if (!(f === ($ptrType(File)).nil)) { + $copy(pos, f.position(p), Position); + } + } + return pos; }; - InterfaceType.prototype.End = function() { return this.$val.End(); }; - MapType.Ptr.prototype.End = function() { - var x; - x = this; - return x.Value.End(); + FileSet.prototype.Position = function(p) { return this.$val.Position(p); }; + searchInts = function(a, x) { + var _tmp, _tmp$1, i, j, _q, h; + _tmp = 0; _tmp$1 = a.$length; i = _tmp; j = _tmp$1; + while (i < j) { + h = i + (_q = ((j - i >> 0)) / 2, (_q === _q && _q !== 1/0 && _q !== -1/0) ? _q >> 0 : $throwRuntimeError("integer divide by zero")) >> 0; + if (((h < 0 || h >= a.$length) ? $throwRuntimeError("index out of range") : a.$array[a.$offset + h]) <= x) { + i = h + 1 >> 0; + } else { + j = h; + } + } + return i - 1 >> 0; }; - MapType.prototype.End = function() { return this.$val.End(); }; - ChanType.Ptr.prototype.End = function() { - var x; - x = this; - return x.Value.End(); + FileSet.Ptr.prototype.Read = function(decode) { + var s, ss, err, files, i, x, f; + s = this; + ss = new serializedFileSet.Ptr(); $copy(ss, new serializedFileSet.Ptr(), serializedFileSet); + err = decode(ss); + if (!($interfaceIsEqual(err, $ifaceNil))) { + return err; + } + s.mutex.Lock(); + s.base = ss.Base; + files = ($sliceType(($ptrType(File)))).make(ss.Files.$length); + i = 0; + while (i < ss.Files.$length) { + f = (x = ss.Files, ((i < 0 || i >= x.$length) ? $throwRuntimeError("index out of range") : x.$array[x.$offset + i])); + (i < 0 || i >= files.$length) ? $throwRuntimeError("index out of range") : files.$array[files.$offset + i] = new File.Ptr(s, f.Name, f.Base, f.Size, f.Lines, f.Infos); + i = i + (1) >> 0; + } + s.files = files; + s.last = ($ptrType(File)).nil; + s.mutex.Unlock(); + return $ifaceNil; }; - ChanType.prototype.End = function() { return this.$val.End(); }; - NewIdent = $pkg.NewIdent = function(name) { - return new Ident.Ptr(0, name, ($ptrType(Object)).nil); + FileSet.prototype.Read = function(decode) { return this.$val.Read(decode); }; + FileSet.Ptr.prototype.Write = function(encode) { + var s, ss, files, _ref, _i, i, f; + s = this; + ss = new serializedFileSet.Ptr(); $copy(ss, new serializedFileSet.Ptr(), serializedFileSet); + s.mutex.Lock(); + ss.Base = s.base; + files = ($sliceType(serializedFile)).make(s.files.$length); + _ref = s.files; + _i = 0; + while (_i < _ref.$length) { + i = _i; + f = ((_i < 0 || _i >= _ref.$length) ? $throwRuntimeError("index out of range") : _ref.$array[_ref.$offset + _i]); + $copy(((i < 0 || i >= files.$length) ? $throwRuntimeError("index out of range") : files.$array[files.$offset + i]), new serializedFile.Ptr(f.name, f.base, f.size, f.lines, f.infos), serializedFile); + _i++; + } + ss.Files = files; + s.mutex.Unlock(); + return encode(new ss.constructor.Struct(ss)); }; - IsExported = $pkg.IsExported = function(name) { - var _tuple, ch; - _tuple = utf8.DecodeRuneInString(name); ch = _tuple[0]; - return unicode.IsUpper(ch); + FileSet.prototype.Write = function(encode) { return this.$val.Write(encode); }; + Token.prototype.String = function() { + var tok, s; + tok = this.$val !== undefined ? this.$val : this; + s = ""; + if (0 <= tok && tok < 86) { + s = ((tok < 0 || tok >= tokens.length) ? $throwRuntimeError("index out of range") : tokens[tok]); + } + if (s === "") { + s = "token(" + strconv.Itoa((tok >> 0)) + ")"; + } + return s; }; - Ident.Ptr.prototype.IsExported = function() { - var id; - id = this; - return IsExported(id.Name); + $ptrType(Token).prototype.String = function() { return new Token(this.$get()).String(); }; + Token.prototype.Precedence = function() { + var op, _ref; + op = this.$val !== undefined ? this.$val : this; + _ref = op; + if (_ref === 35) { + return 1; + } else if (_ref === 34) { + return 2; + } else if (_ref === 39 || _ref === 44 || _ref === 40 || _ref === 45 || _ref === 41 || _ref === 46) { + return 3; + } else if (_ref === 12 || _ref === 13 || _ref === 18 || _ref === 19) { + return 4; + } else if (_ref === 14 || _ref === 15 || _ref === 16 || _ref === 20 || _ref === 21 || _ref === 17 || _ref === 22) { + return 5; + } + return 0; }; - Ident.prototype.IsExported = function() { return this.$val.IsExported(); }; - Ident.Ptr.prototype.String = function() { - var id; - id = this; - if (!(id === ($ptrType(Ident)).nil)) { - return id.Name; + $ptrType(Token).prototype.Precedence = function() { return new Token(this.$get()).Precedence(); }; + init = function() { + var i, _key; + keywords = new $Map(); + i = 61; + while (i < 86) { + _key = ((i < 0 || i >= tokens.length) ? $throwRuntimeError("index out of range") : tokens[i]); (keywords || $throwRuntimeError("assignment to entry in nil map"))[_key] = { k: _key, v: i }; + i = i + (1) >> 0; } - return ""; }; - Ident.prototype.String = function() { return this.$val.String(); }; - BadStmt.Ptr.prototype.Pos = function() { - var s; - s = this; - return s.From; + Lookup = $pkg.Lookup = function(ident) { + var _tuple, _entry, tok, is_keyword; + _tuple = (_entry = keywords[ident], _entry !== undefined ? [_entry.v, true] : [0, false]); tok = _tuple[0]; is_keyword = _tuple[1]; + if (is_keyword) { + return tok; + } + return 4; }; - BadStmt.prototype.Pos = function() { return this.$val.Pos(); }; - DeclStmt.Ptr.prototype.Pos = function() { - var s; - s = this; - return s.Decl.Pos(); + Token.prototype.IsLiteral = function() { + var tok; + tok = this.$val !== undefined ? this.$val : this; + return 3 < tok && tok < 10; }; - DeclStmt.prototype.Pos = function() { return this.$val.Pos(); }; - EmptyStmt.Ptr.prototype.Pos = function() { - var s; - s = this; - return s.Semicolon; + $ptrType(Token).prototype.IsLiteral = function() { return new Token(this.$get()).IsLiteral(); }; + Token.prototype.IsOperator = function() { + var tok; + tok = this.$val !== undefined ? this.$val : this; + return 11 < tok && tok < 59; }; - EmptyStmt.prototype.Pos = function() { return this.$val.Pos(); }; - LabeledStmt.Ptr.prototype.Pos = function() { - var s; - s = this; - return s.Label.Pos(); + $ptrType(Token).prototype.IsOperator = function() { return new Token(this.$get()).IsOperator(); }; + Token.prototype.IsKeyword = function() { + var tok; + tok = this.$val !== undefined ? this.$val : this; + return 60 < tok && tok < 86; }; - LabeledStmt.prototype.Pos = function() { return this.$val.Pos(); }; - ExprStmt.Ptr.prototype.Pos = function() { - var s; - s = this; - return s.X.Pos(); + $ptrType(Token).prototype.IsKeyword = function() { return new Token(this.$get()).IsKeyword(); }; + $pkg.$init = function() { + Position.methods = [["String", "String", "", $funcType([], [$String], false), -1]]; + ($ptrType(Position)).methods = [["IsValid", "IsValid", "", $funcType([], [$Bool], false), -1], ["String", "String", "", $funcType([], [$String], false), -1]]; + Position.init([["Filename", "Filename", "", $String, ""], ["Offset", "Offset", "", $Int, ""], ["Line", "Line", "", $Int, ""], ["Column", "Column", "", $Int, ""]]); + Pos.methods = [["IsValid", "IsValid", "", $funcType([], [$Bool], false), -1]]; + ($ptrType(Pos)).methods = [["IsValid", "IsValid", "", $funcType([], [$Bool], false), -1]]; + ($ptrType(File)).methods = [["AddLine", "AddLine", "", $funcType([$Int], [], false), -1], ["AddLineInfo", "AddLineInfo", "", $funcType([$Int, $String, $Int], [], false), -1], ["Base", "Base", "", $funcType([], [$Int], false), -1], ["Line", "Line", "", $funcType([Pos], [$Int], false), -1], ["LineCount", "LineCount", "", $funcType([], [$Int], false), -1], ["MergeLine", "MergeLine", "", $funcType([$Int], [], false), -1], ["Name", "Name", "", $funcType([], [$String], false), -1], ["Offset", "Offset", "", $funcType([Pos], [$Int], false), -1], ["Pos", "Pos", "", $funcType([$Int], [Pos], false), -1], ["Position", "Position", "", $funcType([Pos], [Position], false), -1], ["SetLines", "SetLines", "", $funcType([($sliceType($Int))], [$Bool], false), -1], ["SetLinesForContent", "SetLinesForContent", "", $funcType([($sliceType($Uint8))], [], false), -1], ["Size", "Size", "", $funcType([], [$Int], false), -1], ["info", "info", "go/token", $funcType([$Int], [$String, $Int, $Int], false), -1], ["position", "position", "go/token", $funcType([Pos], [Position], false), -1]]; + File.init([["set", "set", "go/token", ($ptrType(FileSet)), ""], ["name", "name", "go/token", $String, ""], ["base", "base", "go/token", $Int, ""], ["size", "size", "go/token", $Int, ""], ["lines", "lines", "go/token", ($sliceType($Int)), ""], ["infos", "infos", "go/token", ($sliceType(lineInfo)), ""]]); + lineInfo.init([["Offset", "Offset", "", $Int, ""], ["Filename", "Filename", "", $String, ""], ["Line", "Line", "", $Int, ""]]); + ($ptrType(FileSet)).methods = [["AddFile", "AddFile", "", $funcType([$String, $Int, $Int], [($ptrType(File))], false), -1], ["Base", "Base", "", $funcType([], [$Int], false), -1], ["File", "File", "", $funcType([Pos], [($ptrType(File))], false), -1], ["Iterate", "Iterate", "", $funcType([($funcType([($ptrType(File))], [$Bool], false))], [], false), -1], ["Position", "Position", "", $funcType([Pos], [Position], false), -1], ["Read", "Read", "", $funcType([($funcType([$emptyInterface], [$error], false))], [$error], false), -1], ["Write", "Write", "", $funcType([($funcType([$emptyInterface], [$error], false))], [$error], false), -1], ["file", "file", "go/token", $funcType([Pos], [($ptrType(File))], false), -1]]; + FileSet.init([["mutex", "mutex", "go/token", sync.RWMutex, ""], ["base", "base", "go/token", $Int, ""], ["files", "files", "go/token", ($sliceType(($ptrType(File)))), ""], ["last", "last", "go/token", ($ptrType(File)), ""]]); + serializedFile.init([["Name", "Name", "", $String, ""], ["Base", "Base", "", $Int, ""], ["Size", "Size", "", $Int, ""], ["Lines", "Lines", "", ($sliceType($Int)), ""], ["Infos", "Infos", "", ($sliceType(lineInfo)), ""]]); + serializedFileSet.init([["Base", "Base", "", $Int, ""], ["Files", "Files", "", ($sliceType(serializedFile)), ""]]); + Token.methods = [["IsKeyword", "IsKeyword", "", $funcType([], [$Bool], false), -1], ["IsLiteral", "IsLiteral", "", $funcType([], [$Bool], false), -1], ["IsOperator", "IsOperator", "", $funcType([], [$Bool], false), -1], ["Precedence", "Precedence", "", $funcType([], [$Int], false), -1], ["String", "String", "", $funcType([], [$String], false), -1]]; + ($ptrType(Token)).methods = [["IsKeyword", "IsKeyword", "", $funcType([], [$Bool], false), -1], ["IsLiteral", "IsLiteral", "", $funcType([], [$Bool], false), -1], ["IsOperator", "IsOperator", "", $funcType([], [$Bool], false), -1], ["Precedence", "Precedence", "", $funcType([], [$Int], false), -1], ["String", "String", "", $funcType([], [$String], false), -1]]; + keywords = false; + tokens = $toNativeArray("String", ["ILLEGAL", "EOF", "COMMENT", "", "IDENT", "INT", "FLOAT", "IMAG", "CHAR", "STRING", "", "", "+", "-", "*", "/", "%", "&", "|", "^", "<<", ">>", "&^", "+=", "-=", "*=", "/=", "%=", "&=", "|=", "^=", "<<=", ">>=", "&^=", "&&", "||", "<-", "++", "--", "==", "<", ">", "=", "!", "!=", "<=", ">=", ":=", "...", "(", "[", "{", ",", ".", ")", "]", "}", ";", ":", "", "", "break", "case", "chan", "const", "continue", "default", "defer", "else", "fallthrough", "for", "func", "go", "goto", "if", "import", "interface", "map", "package", "range", "return", "select", "struct", "switch", "type", "var"]); + init(); }; - ExprStmt.prototype.Pos = function() { return this.$val.Pos(); }; - SendStmt.Ptr.prototype.Pos = function() { - var s; - s = this; - return s.Chan.Pos(); + return $pkg; +})(); +$packages["encoding/binary"] = (function() { + var $pkg = {}, errors = $packages["errors"], io = $packages["io"], math = $packages["math"], reflect = $packages["reflect"], ByteOrder, bigEndian, encoder, overflow, Write, dataSize, sizeof, intDataSize; + ByteOrder = $pkg.ByteOrder = $newType(8, "Interface", "binary.ByteOrder", "ByteOrder", "encoding/binary", null); + bigEndian = $pkg.bigEndian = $newType(0, "Struct", "binary.bigEndian", "bigEndian", "encoding/binary", function() { + this.$val = this; + }); + encoder = $pkg.encoder = $newType(0, "Struct", "binary.encoder", "encoder", "encoding/binary", function(order_, buf_) { + this.$val = this; + this.order = order_ !== undefined ? order_ : $ifaceNil; + this.buf = buf_ !== undefined ? buf_ : ($sliceType($Uint8)).nil; + }); + bigEndian.Ptr.prototype.Uint16 = function(b) { + return ((((1 < 0 || 1 >= b.$length) ? $throwRuntimeError("index out of range") : b.$array[b.$offset + 1]) << 16 >>> 16) | ((((0 < 0 || 0 >= b.$length) ? $throwRuntimeError("index out of range") : b.$array[b.$offset + 0]) << 16 >>> 16) << 8 << 16 >>> 16)) >>> 0; }; - SendStmt.prototype.Pos = function() { return this.$val.Pos(); }; - IncDecStmt.Ptr.prototype.Pos = function() { - var s; - s = this; - return s.X.Pos(); + bigEndian.prototype.Uint16 = function(b) { return this.$val.Uint16(b); }; + bigEndian.Ptr.prototype.PutUint16 = function(b, v) { + (0 < 0 || 0 >= b.$length) ? $throwRuntimeError("index out of range") : b.$array[b.$offset + 0] = ((v >>> 8 << 16 >>> 16) << 24 >>> 24); + (1 < 0 || 1 >= b.$length) ? $throwRuntimeError("index out of range") : b.$array[b.$offset + 1] = (v << 24 >>> 24); }; - IncDecStmt.prototype.Pos = function() { return this.$val.Pos(); }; - AssignStmt.Ptr.prototype.Pos = function() { - var s, x; - s = this; - return (x = s.Lhs, ((0 < 0 || 0 >= x.$length) ? $throwRuntimeError("index out of range") : x.$array[x.$offset + 0])).Pos(); + bigEndian.prototype.PutUint16 = function(b, v) { return this.$val.PutUint16(b, v); }; + bigEndian.Ptr.prototype.Uint32 = function(b) { + return ((((((((3 < 0 || 3 >= b.$length) ? $throwRuntimeError("index out of range") : b.$array[b.$offset + 3]) >>> 0) | ((((2 < 0 || 2 >= b.$length) ? $throwRuntimeError("index out of range") : b.$array[b.$offset + 2]) >>> 0) << 8 >>> 0)) >>> 0) | ((((1 < 0 || 1 >= b.$length) ? $throwRuntimeError("index out of range") : b.$array[b.$offset + 1]) >>> 0) << 16 >>> 0)) >>> 0) | ((((0 < 0 || 0 >= b.$length) ? $throwRuntimeError("index out of range") : b.$array[b.$offset + 0]) >>> 0) << 24 >>> 0)) >>> 0; }; - AssignStmt.prototype.Pos = function() { return this.$val.Pos(); }; - GoStmt.Ptr.prototype.Pos = function() { - var s; - s = this; - return s.Go; + bigEndian.prototype.Uint32 = function(b) { return this.$val.Uint32(b); }; + bigEndian.Ptr.prototype.PutUint32 = function(b, v) { + (0 < 0 || 0 >= b.$length) ? $throwRuntimeError("index out of range") : b.$array[b.$offset + 0] = ((v >>> 24 >>> 0) << 24 >>> 24); + (1 < 0 || 1 >= b.$length) ? $throwRuntimeError("index out of range") : b.$array[b.$offset + 1] = ((v >>> 16 >>> 0) << 24 >>> 24); + (2 < 0 || 2 >= b.$length) ? $throwRuntimeError("index out of range") : b.$array[b.$offset + 2] = ((v >>> 8 >>> 0) << 24 >>> 24); + (3 < 0 || 3 >= b.$length) ? $throwRuntimeError("index out of range") : b.$array[b.$offset + 3] = (v << 24 >>> 24); }; - GoStmt.prototype.Pos = function() { return this.$val.Pos(); }; - DeferStmt.Ptr.prototype.Pos = function() { - var s; - s = this; - return s.Defer; + bigEndian.prototype.PutUint32 = function(b, v) { return this.$val.PutUint32(b, v); }; + bigEndian.Ptr.prototype.Uint64 = function(b) { + var x, x$1, x$2, x$3, x$4, x$5, x$6, x$7, x$8, x$9, x$10, x$11, x$12, x$13; + return (x = (x$1 = (x$2 = (x$3 = (x$4 = (x$5 = (x$6 = new $Uint64(0, ((7 < 0 || 7 >= b.$length) ? $throwRuntimeError("index out of range") : b.$array[b.$offset + 7])), x$7 = $shiftLeft64(new $Uint64(0, ((6 < 0 || 6 >= b.$length) ? $throwRuntimeError("index out of range") : b.$array[b.$offset + 6])), 8), new $Uint64(x$6.$high | x$7.$high, (x$6.$low | x$7.$low) >>> 0)), x$8 = $shiftLeft64(new $Uint64(0, ((5 < 0 || 5 >= b.$length) ? $throwRuntimeError("index out of range") : b.$array[b.$offset + 5])), 16), new $Uint64(x$5.$high | x$8.$high, (x$5.$low | x$8.$low) >>> 0)), x$9 = $shiftLeft64(new $Uint64(0, ((4 < 0 || 4 >= b.$length) ? $throwRuntimeError("index out of range") : b.$array[b.$offset + 4])), 24), new $Uint64(x$4.$high | x$9.$high, (x$4.$low | x$9.$low) >>> 0)), x$10 = $shiftLeft64(new $Uint64(0, ((3 < 0 || 3 >= b.$length) ? $throwRuntimeError("index out of range") : b.$array[b.$offset + 3])), 32), new $Uint64(x$3.$high | x$10.$high, (x$3.$low | x$10.$low) >>> 0)), x$11 = $shiftLeft64(new $Uint64(0, ((2 < 0 || 2 >= b.$length) ? $throwRuntimeError("index out of range") : b.$array[b.$offset + 2])), 40), new $Uint64(x$2.$high | x$11.$high, (x$2.$low | x$11.$low) >>> 0)), x$12 = $shiftLeft64(new $Uint64(0, ((1 < 0 || 1 >= b.$length) ? $throwRuntimeError("index out of range") : b.$array[b.$offset + 1])), 48), new $Uint64(x$1.$high | x$12.$high, (x$1.$low | x$12.$low) >>> 0)), x$13 = $shiftLeft64(new $Uint64(0, ((0 < 0 || 0 >= b.$length) ? $throwRuntimeError("index out of range") : b.$array[b.$offset + 0])), 56), new $Uint64(x.$high | x$13.$high, (x.$low | x$13.$low) >>> 0)); }; - DeferStmt.prototype.Pos = function() { return this.$val.Pos(); }; - ReturnStmt.Ptr.prototype.Pos = function() { - var s; - s = this; - return s.Return; + bigEndian.prototype.Uint64 = function(b) { return this.$val.Uint64(b); }; + bigEndian.Ptr.prototype.PutUint64 = function(b, v) { + (0 < 0 || 0 >= b.$length) ? $throwRuntimeError("index out of range") : b.$array[b.$offset + 0] = ($shiftRightUint64(v, 56).$low << 24 >>> 24); + (1 < 0 || 1 >= b.$length) ? $throwRuntimeError("index out of range") : b.$array[b.$offset + 1] = ($shiftRightUint64(v, 48).$low << 24 >>> 24); + (2 < 0 || 2 >= b.$length) ? $throwRuntimeError("index out of range") : b.$array[b.$offset + 2] = ($shiftRightUint64(v, 40).$low << 24 >>> 24); + (3 < 0 || 3 >= b.$length) ? $throwRuntimeError("index out of range") : b.$array[b.$offset + 3] = ($shiftRightUint64(v, 32).$low << 24 >>> 24); + (4 < 0 || 4 >= b.$length) ? $throwRuntimeError("index out of range") : b.$array[b.$offset + 4] = ($shiftRightUint64(v, 24).$low << 24 >>> 24); + (5 < 0 || 5 >= b.$length) ? $throwRuntimeError("index out of range") : b.$array[b.$offset + 5] = ($shiftRightUint64(v, 16).$low << 24 >>> 24); + (6 < 0 || 6 >= b.$length) ? $throwRuntimeError("index out of range") : b.$array[b.$offset + 6] = ($shiftRightUint64(v, 8).$low << 24 >>> 24); + (7 < 0 || 7 >= b.$length) ? $throwRuntimeError("index out of range") : b.$array[b.$offset + 7] = (v.$low << 24 >>> 24); }; - ReturnStmt.prototype.Pos = function() { return this.$val.Pos(); }; - BranchStmt.Ptr.prototype.Pos = function() { - var s; - s = this; - return s.TokPos; + bigEndian.prototype.PutUint64 = function(b, v) { return this.$val.PutUint64(b, v); }; + bigEndian.Ptr.prototype.String = function() { + return "BigEndian"; }; - BranchStmt.prototype.Pos = function() { return this.$val.Pos(); }; - BlockStmt.Ptr.prototype.Pos = function() { - var s; - s = this; - return s.Lbrace; + bigEndian.prototype.String = function() { return this.$val.String(); }; + bigEndian.Ptr.prototype.GoString = function() { + return "binary.BigEndian"; }; - BlockStmt.prototype.Pos = function() { return this.$val.Pos(); }; - IfStmt.Ptr.prototype.Pos = function() { - var s; - s = this; - return s.If; - }; - IfStmt.prototype.Pos = function() { return this.$val.Pos(); }; - CaseClause.Ptr.prototype.Pos = function() { - var s; - s = this; - return s.Case; - }; - CaseClause.prototype.Pos = function() { return this.$val.Pos(); }; - SwitchStmt.Ptr.prototype.Pos = function() { - var s; - s = this; - return s.Switch; - }; - SwitchStmt.prototype.Pos = function() { return this.$val.Pos(); }; - TypeSwitchStmt.Ptr.prototype.Pos = function() { - var s; - s = this; - return s.Switch; - }; - TypeSwitchStmt.prototype.Pos = function() { return this.$val.Pos(); }; - CommClause.Ptr.prototype.Pos = function() { - var s; - s = this; - return s.Case; - }; - CommClause.prototype.Pos = function() { return this.$val.Pos(); }; - SelectStmt.Ptr.prototype.Pos = function() { - var s; - s = this; - return s.Select; - }; - SelectStmt.prototype.Pos = function() { return this.$val.Pos(); }; - ForStmt.Ptr.prototype.Pos = function() { - var s; - s = this; - return s.For; - }; - ForStmt.prototype.Pos = function() { return this.$val.Pos(); }; - RangeStmt.Ptr.prototype.Pos = function() { - var s; - s = this; - return s.For; + bigEndian.prototype.GoString = function() { return this.$val.GoString(); }; + Write = $pkg.Write = function(w, order, data) { + var n, b, bs, v, _ref, _ref$1, _i, i, x, _ref$2, _i$1, i$1, x$1, _ref$3, _i$2, i$2, x$2, _ref$4, _i$3, i$3, x$3, _ref$5, _i$4, i$4, x$4, x$5, _ref$6, _i$5, i$5, x$6, _ref$7, _i$6, i$6, x$7, _tuple, err, v$1, _tuple$1, size, err$1, buf, e, _tuple$2; + n = intDataSize(data); + if (!((n === 0))) { + b = ($arrayType($Uint8, 8)).zero(); $copy(b, ($arrayType($Uint8, 8)).zero(), ($arrayType($Uint8, 8))); + bs = ($sliceType($Uint8)).nil; + if (n > 8) { + bs = ($sliceType($Uint8)).make(n); + } else { + bs = $subslice(new ($sliceType($Uint8))(b), 0, n); + } + _ref = data; + if ($assertType(_ref, ($ptrType($Int8)), true)[1]) { + v = _ref.$val; + bs = $subslice(new ($sliceType($Uint8))(b), 0, 1); + b[0] = (v.$get() << 24 >>> 24); + } else if ($assertType(_ref, $Int8, true)[1]) { + v = _ref.$val; + bs = $subslice(new ($sliceType($Uint8))(b), 0, 1); + b[0] = (v << 24 >>> 24); + } else if ($assertType(_ref, ($sliceType($Int8)), true)[1]) { + v = _ref.$val; + _ref$1 = v; + _i = 0; + while (_i < _ref$1.$length) { + i = _i; + x = ((_i < 0 || _i >= _ref$1.$length) ? $throwRuntimeError("index out of range") : _ref$1.$array[_ref$1.$offset + _i]); + (i < 0 || i >= bs.$length) ? $throwRuntimeError("index out of range") : bs.$array[bs.$offset + i] = (x << 24 >>> 24); + _i++; + } + } else if ($assertType(_ref, ($ptrType($Uint8)), true)[1]) { + v = _ref.$val; + bs = $subslice(new ($sliceType($Uint8))(b), 0, 1); + b[0] = v.$get(); + } else if ($assertType(_ref, $Uint8, true)[1]) { + v = _ref.$val; + bs = $subslice(new ($sliceType($Uint8))(b), 0, 1); + b[0] = v; + } else if ($assertType(_ref, ($sliceType($Uint8)), true)[1]) { + v = _ref.$val; + bs = v; + } else if ($assertType(_ref, ($ptrType($Int16)), true)[1]) { + v = _ref.$val; + bs = $subslice(new ($sliceType($Uint8))(b), 0, 2); + order.PutUint16(bs, (v.$get() << 16 >>> 16)); + } else if ($assertType(_ref, $Int16, true)[1]) { + v = _ref.$val; + bs = $subslice(new ($sliceType($Uint8))(b), 0, 2); + order.PutUint16(bs, (v << 16 >>> 16)); + } else if ($assertType(_ref, ($sliceType($Int16)), true)[1]) { + v = _ref.$val; + _ref$2 = v; + _i$1 = 0; + while (_i$1 < _ref$2.$length) { + i$1 = _i$1; + x$1 = ((_i$1 < 0 || _i$1 >= _ref$2.$length) ? $throwRuntimeError("index out of range") : _ref$2.$array[_ref$2.$offset + _i$1]); + order.PutUint16($subslice(bs, ((((2 >>> 16 << 16) * i$1 >> 0) + (2 << 16 >>> 16) * i$1) >> 0)), (x$1 << 16 >>> 16)); + _i$1++; + } + } else if ($assertType(_ref, ($ptrType($Uint16)), true)[1]) { + v = _ref.$val; + bs = $subslice(new ($sliceType($Uint8))(b), 0, 2); + order.PutUint16(bs, v.$get()); + } else if ($assertType(_ref, $Uint16, true)[1]) { + v = _ref.$val; + bs = $subslice(new ($sliceType($Uint8))(b), 0, 2); + order.PutUint16(bs, v); + } else if ($assertType(_ref, ($sliceType($Uint16)), true)[1]) { + v = _ref.$val; + _ref$3 = v; + _i$2 = 0; + while (_i$2 < _ref$3.$length) { + i$2 = _i$2; + x$2 = ((_i$2 < 0 || _i$2 >= _ref$3.$length) ? $throwRuntimeError("index out of range") : _ref$3.$array[_ref$3.$offset + _i$2]); + order.PutUint16($subslice(bs, ((((2 >>> 16 << 16) * i$2 >> 0) + (2 << 16 >>> 16) * i$2) >> 0)), x$2); + _i$2++; + } + } else if ($assertType(_ref, ($ptrType($Int32)), true)[1]) { + v = _ref.$val; + bs = $subslice(new ($sliceType($Uint8))(b), 0, 4); + order.PutUint32(bs, (v.$get() >>> 0)); + } else if ($assertType(_ref, $Int32, true)[1]) { + v = _ref.$val; + bs = $subslice(new ($sliceType($Uint8))(b), 0, 4); + order.PutUint32(bs, (v >>> 0)); + } else if ($assertType(_ref, ($sliceType($Int32)), true)[1]) { + v = _ref.$val; + _ref$4 = v; + _i$3 = 0; + while (_i$3 < _ref$4.$length) { + i$3 = _i$3; + x$3 = ((_i$3 < 0 || _i$3 >= _ref$4.$length) ? $throwRuntimeError("index out of range") : _ref$4.$array[_ref$4.$offset + _i$3]); + order.PutUint32($subslice(bs, ((((4 >>> 16 << 16) * i$3 >> 0) + (4 << 16 >>> 16) * i$3) >> 0)), (x$3 >>> 0)); + _i$3++; + } + } else if ($assertType(_ref, ($ptrType($Uint32)), true)[1]) { + v = _ref.$val; + bs = $subslice(new ($sliceType($Uint8))(b), 0, 4); + order.PutUint32(bs, v.$get()); + } else if ($assertType(_ref, $Uint32, true)[1]) { + v = _ref.$val; + bs = $subslice(new ($sliceType($Uint8))(b), 0, 4); + order.PutUint32(bs, v); + } else if ($assertType(_ref, ($sliceType($Uint32)), true)[1]) { + v = _ref.$val; + _ref$5 = v; + _i$4 = 0; + while (_i$4 < _ref$5.$length) { + i$4 = _i$4; + x$4 = ((_i$4 < 0 || _i$4 >= _ref$5.$length) ? $throwRuntimeError("index out of range") : _ref$5.$array[_ref$5.$offset + _i$4]); + order.PutUint32($subslice(bs, ((((4 >>> 16 << 16) * i$4 >> 0) + (4 << 16 >>> 16) * i$4) >> 0)), x$4); + _i$4++; + } + } else if ($assertType(_ref, ($ptrType($Int64)), true)[1]) { + v = _ref.$val; + bs = $subslice(new ($sliceType($Uint8))(b), 0, 8); + order.PutUint64(bs, (x$5 = v.$get(), new $Uint64(x$5.$high, x$5.$low))); + } else if ($assertType(_ref, $Int64, true)[1]) { + v = _ref.$val; + bs = $subslice(new ($sliceType($Uint8))(b), 0, 8); + order.PutUint64(bs, new $Uint64(v.$high, v.$low)); + } else if ($assertType(_ref, ($sliceType($Int64)), true)[1]) { + v = _ref.$val; + _ref$6 = v; + _i$5 = 0; + while (_i$5 < _ref$6.$length) { + i$5 = _i$5; + x$6 = ((_i$5 < 0 || _i$5 >= _ref$6.$length) ? $throwRuntimeError("index out of range") : _ref$6.$array[_ref$6.$offset + _i$5]); + order.PutUint64($subslice(bs, ((((8 >>> 16 << 16) * i$5 >> 0) + (8 << 16 >>> 16) * i$5) >> 0)), new $Uint64(x$6.$high, x$6.$low)); + _i$5++; + } + } else if ($assertType(_ref, ($ptrType($Uint64)), true)[1]) { + v = _ref.$val; + bs = $subslice(new ($sliceType($Uint8))(b), 0, 8); + order.PutUint64(bs, v.$get()); + } else if ($assertType(_ref, $Uint64, true)[1]) { + v = _ref.$val; + bs = $subslice(new ($sliceType($Uint8))(b), 0, 8); + order.PutUint64(bs, v); + } else if ($assertType(_ref, ($sliceType($Uint64)), true)[1]) { + v = _ref.$val; + _ref$7 = v; + _i$6 = 0; + while (_i$6 < _ref$7.$length) { + i$6 = _i$6; + x$7 = ((_i$6 < 0 || _i$6 >= _ref$7.$length) ? $throwRuntimeError("index out of range") : _ref$7.$array[_ref$7.$offset + _i$6]); + order.PutUint64($subslice(bs, ((((8 >>> 16 << 16) * i$6 >> 0) + (8 << 16 >>> 16) * i$6) >> 0)), x$7); + _i$6++; + } + } + _tuple = w.Write(bs); err = _tuple[1]; + return err; + } + v$1 = new reflect.Value.Ptr(); $copy(v$1, reflect.Indirect($clone(reflect.ValueOf(data), reflect.Value)), reflect.Value); + _tuple$1 = dataSize($clone(v$1, reflect.Value)); size = _tuple$1[0]; err$1 = _tuple$1[1]; + if (!($interfaceIsEqual(err$1, $ifaceNil))) { + return errors.New("binary.Write: " + err$1.Error()); + } + buf = ($sliceType($Uint8)).make(size); + e = new encoder.Ptr(order, buf); + e.value($clone(v$1, reflect.Value)); + _tuple$2 = w.Write(buf); err$1 = _tuple$2[1]; + return err$1; }; - RangeStmt.prototype.Pos = function() { return this.$val.Pos(); }; - BadStmt.Ptr.prototype.End = function() { - var s; - s = this; - return s.To; + dataSize = function(v) { + var _tuple, elem, err, x; + if (v.Kind() === 23) { + _tuple = sizeof(v.Type().Elem()); elem = _tuple[0]; err = _tuple[1]; + if (!($interfaceIsEqual(err, $ifaceNil))) { + return [0, err]; + } + return [(x = v.Len(), (((x >>> 16 << 16) * elem >> 0) + (x << 16 >>> 16) * elem) >> 0), $ifaceNil]; + } + return sizeof(v.Type()); }; - BadStmt.prototype.End = function() { return this.$val.End(); }; - DeclStmt.Ptr.prototype.End = function() { - var s; - s = this; - return s.Decl.End(); + sizeof = function(t) { + var _ref, _tuple, n, err, x, sum, _tmp, _tmp$1, i, n$1, _tuple$1, s, err$1; + _ref = t.Kind(); + if (_ref === 17) { + _tuple = sizeof(t.Elem()); n = _tuple[0]; err = _tuple[1]; + if (!($interfaceIsEqual(err, $ifaceNil))) { + return [0, err]; + } + return [(x = t.Len(), (((x >>> 16 << 16) * n >> 0) + (x << 16 >>> 16) * n) >> 0), $ifaceNil]; + } else if (_ref === 25) { + sum = 0; + _tmp = 0; _tmp$1 = t.NumField(); i = _tmp; n$1 = _tmp$1; + while (i < n$1) { + _tuple$1 = sizeof(t.Field(i).Type); s = _tuple$1[0]; err$1 = _tuple$1[1]; + if (!($interfaceIsEqual(err$1, $ifaceNil))) { + return [0, err$1]; + } + sum = sum + (s) >> 0; + i = i + (1) >> 0; + } + return [sum, $ifaceNil]; + } else if (_ref === 8 || _ref === 9 || _ref === 10 || _ref === 11 || _ref === 3 || _ref === 4 || _ref === 5 || _ref === 6 || _ref === 13 || _ref === 14 || _ref === 15 || _ref === 16) { + return [(t.Size() >> 0), $ifaceNil]; + } + return [0, errors.New("invalid type " + t.String())]; }; - DeclStmt.prototype.End = function() { return this.$val.End(); }; - EmptyStmt.Ptr.prototype.End = function() { - var s; - s = this; - return s.Semicolon + 1 >> 0; + encoder.Ptr.prototype.uint8 = function(x) { + var e, x$1; + e = this; + (x$1 = e.buf, (0 < 0 || 0 >= x$1.$length) ? $throwRuntimeError("index out of range") : x$1.$array[x$1.$offset + 0] = x); + e.buf = $subslice(e.buf, 1); }; - EmptyStmt.prototype.End = function() { return this.$val.End(); }; - LabeledStmt.Ptr.prototype.End = function() { - var s; - s = this; - return s.Stmt.End(); + encoder.prototype.uint8 = function(x) { return this.$val.uint8(x); }; + encoder.Ptr.prototype.uint16 = function(x) { + var e; + e = this; + e.order.PutUint16($subslice(e.buf, 0, 2), x); + e.buf = $subslice(e.buf, 2); }; - LabeledStmt.prototype.End = function() { return this.$val.End(); }; - ExprStmt.Ptr.prototype.End = function() { - var s; - s = this; - return s.X.End(); + encoder.prototype.uint16 = function(x) { return this.$val.uint16(x); }; + encoder.Ptr.prototype.uint32 = function(x) { + var e; + e = this; + e.order.PutUint32($subslice(e.buf, 0, 4), x); + e.buf = $subslice(e.buf, 4); }; - ExprStmt.prototype.End = function() { return this.$val.End(); }; - SendStmt.Ptr.prototype.End = function() { - var s; - s = this; - return s.Value.End(); + encoder.prototype.uint32 = function(x) { return this.$val.uint32(x); }; + encoder.Ptr.prototype.uint64 = function(x) { + var e; + e = this; + e.order.PutUint64($subslice(e.buf, 0, 8), x); + e.buf = $subslice(e.buf, 8); }; - SendStmt.prototype.End = function() { return this.$val.End(); }; - IncDecStmt.Ptr.prototype.End = function() { - var s; - s = this; - return s.TokPos + 2 >> 0; + encoder.prototype.uint64 = function(x) { return this.$val.uint64(x); }; + encoder.Ptr.prototype.int8 = function(x) { + var e; + e = this; + e.uint8((x << 24 >>> 24)); }; - IncDecStmt.prototype.End = function() { return this.$val.End(); }; - AssignStmt.Ptr.prototype.End = function() { - var s, x, x$1; - s = this; - return (x = s.Rhs, x$1 = s.Rhs.$length - 1 >> 0, ((x$1 < 0 || x$1 >= x.$length) ? $throwRuntimeError("index out of range") : x.$array[x.$offset + x$1])).End(); + encoder.prototype.int8 = function(x) { return this.$val.int8(x); }; + encoder.Ptr.prototype.int16 = function(x) { + var e; + e = this; + e.uint16((x << 16 >>> 16)); }; - AssignStmt.prototype.End = function() { return this.$val.End(); }; - GoStmt.Ptr.prototype.End = function() { - var s; - s = this; - return s.Call.End(); + encoder.prototype.int16 = function(x) { return this.$val.int16(x); }; + encoder.Ptr.prototype.int32 = function(x) { + var e; + e = this; + e.uint32((x >>> 0)); }; - GoStmt.prototype.End = function() { return this.$val.End(); }; - DeferStmt.Ptr.prototype.End = function() { - var s; - s = this; - return s.Call.End(); + encoder.prototype.int32 = function(x) { return this.$val.int32(x); }; + encoder.Ptr.prototype.int64 = function(x) { + var e; + e = this; + e.uint64(new $Uint64(x.$high, x.$low)); }; - DeferStmt.prototype.End = function() { return this.$val.End(); }; - ReturnStmt.Ptr.prototype.End = function() { - var s, n, x, x$1; - s = this; - n = s.Results.$length; - if (n > 0) { - return (x = s.Results, x$1 = n - 1 >> 0, ((x$1 < 0 || x$1 >= x.$length) ? $throwRuntimeError("index out of range") : x.$array[x.$offset + x$1])).End(); + encoder.prototype.int64 = function(x) { return this.$val.int64(x); }; + encoder.Ptr.prototype.value = function(v) { + var e, _ref, l, i, t, l$1, i$1, v$1, l$2, i$2, _ref$1, x, x$1, x$2, _ref$2, _ref$3, _ref$4, x$3, x$4; + e = this; + _ref = v.Kind(); + if (_ref === 17) { + l = v.Len(); + i = 0; + while (i < l) { + e.value($clone(v.Index(i), reflect.Value)); + i = i + (1) >> 0; + } + } else if (_ref === 25) { + t = v.Type(); + l$1 = v.NumField(); + i$1 = 0; + while (i$1 < l$1) { + v$1 = new reflect.Value.Ptr(); $copy(v$1, v.Field(i$1), reflect.Value); + if (v$1.CanSet() || !(t.Field(i$1).Name === "_")) { + e.value($clone(v$1, reflect.Value)); + } else { + e.skip($clone(v$1, reflect.Value)); + } + i$1 = i$1 + (1) >> 0; + } + } else if (_ref === 23) { + l$2 = v.Len(); + i$2 = 0; + while (i$2 < l$2) { + e.value($clone(v.Index(i$2), reflect.Value)); + i$2 = i$2 + (1) >> 0; + } + } else if (_ref === 2 || _ref === 3 || _ref === 4 || _ref === 5 || _ref === 6) { + _ref$1 = v.Type().Kind(); + if (_ref$1 === 3) { + e.int8(((x = v.Int(), x.$low + ((x.$high >> 31) * 4294967296)) << 24 >> 24)); + } else if (_ref$1 === 4) { + e.int16(((x$1 = v.Int(), x$1.$low + ((x$1.$high >> 31) * 4294967296)) << 16 >> 16)); + } else if (_ref$1 === 5) { + e.int32(((x$2 = v.Int(), x$2.$low + ((x$2.$high >> 31) * 4294967296)) >> 0)); + } else if (_ref$1 === 6) { + e.int64(v.Int()); + } + } else if (_ref === 7 || _ref === 8 || _ref === 9 || _ref === 10 || _ref === 11 || _ref === 12) { + _ref$2 = v.Type().Kind(); + if (_ref$2 === 8) { + e.uint8((v.Uint().$low << 24 >>> 24)); + } else if (_ref$2 === 9) { + e.uint16((v.Uint().$low << 16 >>> 16)); + } else if (_ref$2 === 10) { + e.uint32((v.Uint().$low >>> 0)); + } else if (_ref$2 === 11) { + e.uint64(v.Uint()); + } + } else if (_ref === 13 || _ref === 14) { + _ref$3 = v.Type().Kind(); + if (_ref$3 === 13) { + e.uint32(math.Float32bits(v.Float())); + } else if (_ref$3 === 14) { + e.uint64(math.Float64bits(v.Float())); + } + } else if (_ref === 15 || _ref === 16) { + _ref$4 = v.Type().Kind(); + if (_ref$4 === 15) { + x$3 = v.Complex(); + e.uint32(math.Float32bits(x$3.$real)); + e.uint32(math.Float32bits(x$3.$imag)); + } else if (_ref$4 === 16) { + x$4 = v.Complex(); + e.uint64(math.Float64bits(x$4.$real)); + e.uint64(math.Float64bits(x$4.$imag)); + } } - return s.Return + 6 >> 0; }; - ReturnStmt.prototype.End = function() { return this.$val.End(); }; - BranchStmt.Ptr.prototype.End = function() { - var s; - s = this; - if (!(s.Label === ($ptrType(Ident)).nil)) { - return s.Label.End(); + encoder.prototype.value = function(v) { return this.$val.value(v); }; + encoder.Ptr.prototype.skip = function(v) { + var e, _tuple, n, _ref, _i, i, x; + e = this; + _tuple = dataSize($clone(v, reflect.Value)); n = _tuple[0]; + _ref = $subslice(e.buf, 0, n); + _i = 0; + while (_i < _ref.$length) { + i = _i; + (x = e.buf, (i < 0 || i >= x.$length) ? $throwRuntimeError("index out of range") : x.$array[x.$offset + i] = 0); + _i++; } - return (((s.TokPos >> 0) + (new token.Token(s.Tok)).String().length >> 0) >> 0); - }; - BranchStmt.prototype.End = function() { return this.$val.End(); }; - BlockStmt.Ptr.prototype.End = function() { - var s; - s = this; - return s.Rbrace + 1 >> 0; + e.buf = $subslice(e.buf, n); }; - BlockStmt.prototype.End = function() { return this.$val.End(); }; - IfStmt.Ptr.prototype.End = function() { - var s; - s = this; - if (!($interfaceIsEqual(s.Else, $ifaceNil))) { - return s.Else.End(); + encoder.prototype.skip = function(v) { return this.$val.skip(v); }; + intDataSize = function(data) { + var data$1, _ref, x, x$1, x$2, x$3, x$4, x$5; + _ref = data; + if ($assertType(_ref, $Int8, true)[1] || $assertType(_ref, ($ptrType($Int8)), true)[1] || $assertType(_ref, ($ptrType($Uint8)), true)[1]) { + data$1 = _ref; + return 1; + } else if ($assertType(_ref, ($sliceType($Int8)), true)[1]) { + data$1 = _ref.$val; + return data$1.$length; + } else if ($assertType(_ref, ($sliceType($Uint8)), true)[1]) { + data$1 = _ref.$val; + return data$1.$length; + } else if ($assertType(_ref, $Int16, true)[1] || $assertType(_ref, ($ptrType($Int16)), true)[1] || $assertType(_ref, ($ptrType($Uint16)), true)[1]) { + data$1 = _ref; + return 2; + } else if ($assertType(_ref, ($sliceType($Int16)), true)[1]) { + data$1 = _ref.$val; + return (x = data$1.$length, (((2 >>> 16 << 16) * x >> 0) + (2 << 16 >>> 16) * x) >> 0); + } else if ($assertType(_ref, ($sliceType($Uint16)), true)[1]) { + data$1 = _ref.$val; + return (x$1 = data$1.$length, (((2 >>> 16 << 16) * x$1 >> 0) + (2 << 16 >>> 16) * x$1) >> 0); + } else if ($assertType(_ref, $Int32, true)[1] || $assertType(_ref, ($ptrType($Int32)), true)[1] || $assertType(_ref, ($ptrType($Uint32)), true)[1]) { + data$1 = _ref; + return 4; + } else if ($assertType(_ref, ($sliceType($Int32)), true)[1]) { + data$1 = _ref.$val; + return (x$2 = data$1.$length, (((4 >>> 16 << 16) * x$2 >> 0) + (4 << 16 >>> 16) * x$2) >> 0); + } else if ($assertType(_ref, ($sliceType($Uint32)), true)[1]) { + data$1 = _ref.$val; + return (x$3 = data$1.$length, (((4 >>> 16 << 16) * x$3 >> 0) + (4 << 16 >>> 16) * x$3) >> 0); + } else if ($assertType(_ref, $Int64, true)[1] || $assertType(_ref, ($ptrType($Int64)), true)[1] || $assertType(_ref, ($ptrType($Uint64)), true)[1]) { + data$1 = _ref; + return 8; + } else if ($assertType(_ref, ($sliceType($Int64)), true)[1]) { + data$1 = _ref.$val; + return (x$4 = data$1.$length, (((8 >>> 16 << 16) * x$4 >> 0) + (8 << 16 >>> 16) * x$4) >> 0); + } else if ($assertType(_ref, ($sliceType($Uint64)), true)[1]) { + data$1 = _ref.$val; + return (x$5 = data$1.$length, (((8 >>> 16 << 16) * x$5 >> 0) + (8 << 16 >>> 16) * x$5) >> 0); } - return s.Body.End(); + return 0; }; - IfStmt.prototype.End = function() { return this.$val.End(); }; - CaseClause.Ptr.prototype.End = function() { - var s, n, x, x$1; - s = this; - n = s.Body.$length; - if (n > 0) { - return (x = s.Body, x$1 = n - 1 >> 0, ((x$1 < 0 || x$1 >= x.$length) ? $throwRuntimeError("index out of range") : x.$array[x.$offset + x$1])).End(); - } - return s.Colon + 1 >> 0; + $pkg.$init = function() { + ByteOrder.init([["PutUint16", "PutUint16", "", $funcType([($sliceType($Uint8)), $Uint16], [], false)], ["PutUint32", "PutUint32", "", $funcType([($sliceType($Uint8)), $Uint32], [], false)], ["PutUint64", "PutUint64", "", $funcType([($sliceType($Uint8)), $Uint64], [], false)], ["String", "String", "", $funcType([], [$String], false)], ["Uint16", "Uint16", "", $funcType([($sliceType($Uint8))], [$Uint16], false)], ["Uint32", "Uint32", "", $funcType([($sliceType($Uint8))], [$Uint32], false)], ["Uint64", "Uint64", "", $funcType([($sliceType($Uint8))], [$Uint64], false)]]); + bigEndian.methods = [["GoString", "GoString", "", $funcType([], [$String], false), -1], ["PutUint16", "PutUint16", "", $funcType([($sliceType($Uint8)), $Uint16], [], false), -1], ["PutUint32", "PutUint32", "", $funcType([($sliceType($Uint8)), $Uint32], [], false), -1], ["PutUint64", "PutUint64", "", $funcType([($sliceType($Uint8)), $Uint64], [], false), -1], ["String", "String", "", $funcType([], [$String], false), -1], ["Uint16", "Uint16", "", $funcType([($sliceType($Uint8))], [$Uint16], false), -1], ["Uint32", "Uint32", "", $funcType([($sliceType($Uint8))], [$Uint32], false), -1], ["Uint64", "Uint64", "", $funcType([($sliceType($Uint8))], [$Uint64], false), -1]]; + ($ptrType(bigEndian)).methods = [["GoString", "GoString", "", $funcType([], [$String], false), -1], ["PutUint16", "PutUint16", "", $funcType([($sliceType($Uint8)), $Uint16], [], false), -1], ["PutUint32", "PutUint32", "", $funcType([($sliceType($Uint8)), $Uint32], [], false), -1], ["PutUint64", "PutUint64", "", $funcType([($sliceType($Uint8)), $Uint64], [], false), -1], ["String", "String", "", $funcType([], [$String], false), -1], ["Uint16", "Uint16", "", $funcType([($sliceType($Uint8))], [$Uint16], false), -1], ["Uint32", "Uint32", "", $funcType([($sliceType($Uint8))], [$Uint32], false), -1], ["Uint64", "Uint64", "", $funcType([($sliceType($Uint8))], [$Uint64], false), -1]]; + bigEndian.init([]); + ($ptrType(encoder)).methods = [["int16", "int16", "encoding/binary", $funcType([$Int16], [], false), -1], ["int32", "int32", "encoding/binary", $funcType([$Int32], [], false), -1], ["int64", "int64", "encoding/binary", $funcType([$Int64], [], false), -1], ["int8", "int8", "encoding/binary", $funcType([$Int8], [], false), -1], ["skip", "skip", "encoding/binary", $funcType([reflect.Value], [], false), -1], ["uint16", "uint16", "encoding/binary", $funcType([$Uint16], [], false), -1], ["uint32", "uint32", "encoding/binary", $funcType([$Uint32], [], false), -1], ["uint64", "uint64", "encoding/binary", $funcType([$Uint64], [], false), -1], ["uint8", "uint8", "encoding/binary", $funcType([$Uint8], [], false), -1], ["value", "value", "encoding/binary", $funcType([reflect.Value], [], false), -1]]; + encoder.init([["order", "order", "encoding/binary", ByteOrder, ""], ["buf", "buf", "encoding/binary", ($sliceType($Uint8)), ""]]); + $pkg.BigEndian = new bigEndian.Ptr(); + overflow = errors.New("binary: varint overflows a 64-bit integer"); }; - CaseClause.prototype.End = function() { return this.$val.End(); }; - SwitchStmt.Ptr.prototype.End = function() { - var s; - s = this; - return s.Body.End(); + return $pkg; +})(); +$packages["math/rand"] = (function() { + var $pkg = {}, math = $packages["math"], sync = $packages["sync"], Source, Rand, lockedSource, rngSource, ke, we, fe, kn, wn, fn, globalRand, rng_cooked, absInt32, NewSource, New, seedrand; + Source = $pkg.Source = $newType(8, "Interface", "rand.Source", "Source", "math/rand", null); + Rand = $pkg.Rand = $newType(0, "Struct", "rand.Rand", "Rand", "math/rand", function(src_) { + this.$val = this; + this.src = src_ !== undefined ? src_ : $ifaceNil; + }); + lockedSource = $pkg.lockedSource = $newType(0, "Struct", "rand.lockedSource", "lockedSource", "math/rand", function(lk_, src_) { + this.$val = this; + this.lk = lk_ !== undefined ? lk_ : new sync.Mutex.Ptr(); + this.src = src_ !== undefined ? src_ : $ifaceNil; + }); + rngSource = $pkg.rngSource = $newType(0, "Struct", "rand.rngSource", "rngSource", "math/rand", function(tap_, feed_, vec_) { + this.$val = this; + this.tap = tap_ !== undefined ? tap_ : 0; + this.feed = feed_ !== undefined ? feed_ : 0; + this.vec = vec_ !== undefined ? vec_ : ($arrayType($Int64, 607)).zero(); + }); + Rand.Ptr.prototype.ExpFloat64 = function() { + var r, j, i, x, x$1; + r = this; + while (true) { + j = r.Uint32(); + i = (j & 255) >>> 0; + x = j * $coerceFloat32(((i < 0 || i >= we.length) ? $throwRuntimeError("index out of range") : we[i])); + if (j < ((i < 0 || i >= ke.length) ? $throwRuntimeError("index out of range") : ke[i])) { + return x; + } + if (i === 0) { + return 7.69711747013105 - math.Log(r.Float64()); + } + if (((i < 0 || i >= fe.length) ? $throwRuntimeError("index out of range") : fe[i]) + r.Float64() * ((x$1 = i - 1 >>> 0, ((x$1 < 0 || x$1 >= fe.length) ? $throwRuntimeError("index out of range") : fe[x$1])) - ((i < 0 || i >= fe.length) ? $throwRuntimeError("index out of range") : fe[i])) < math.Exp(-x)) { + return x; + } + } }; - SwitchStmt.prototype.End = function() { return this.$val.End(); }; - TypeSwitchStmt.Ptr.prototype.End = function() { - var s; - s = this; - return s.Body.End(); + Rand.prototype.ExpFloat64 = function() { return this.$val.ExpFloat64(); }; + absInt32 = function(i) { + if (i < 0) { + return (-i >>> 0); + } + return (i >>> 0); }; - TypeSwitchStmt.prototype.End = function() { return this.$val.End(); }; - CommClause.Ptr.prototype.End = function() { - var s, n, x, x$1; - s = this; - n = s.Body.$length; - if (n > 0) { - return (x = s.Body, x$1 = n - 1 >> 0, ((x$1 < 0 || x$1 >= x.$length) ? $throwRuntimeError("index out of range") : x.$array[x.$offset + x$1])).End(); + Rand.Ptr.prototype.NormFloat64 = function() { + var r, j, i, x, y, x$1; + r = this; + while (true) { + j = (r.Uint32() >> 0); + i = j & 127; + x = j * $coerceFloat32(((i < 0 || i >= wn.length) ? $throwRuntimeError("index out of range") : wn[i])); + if (absInt32(j) < ((i < 0 || i >= kn.length) ? $throwRuntimeError("index out of range") : kn[i])) { + return x; + } + if (i === 0) { + while (true) { + x = -math.Log(r.Float64()) * 0.29047645161474317; + y = -math.Log(r.Float64()); + if (y + y >= x * x) { + break; + } + } + if (j > 0) { + return 3.442619855899 + x; + } + return -3.442619855899 - x; + } + if (((i < 0 || i >= fn.length) ? $throwRuntimeError("index out of range") : fn[i]) + r.Float64() * ((x$1 = i - 1 >> 0, ((x$1 < 0 || x$1 >= fn.length) ? $throwRuntimeError("index out of range") : fn[x$1])) - ((i < 0 || i >= fn.length) ? $throwRuntimeError("index out of range") : fn[i])) < math.Exp(-0.5 * x * x)) { + return x; + } } - return s.Colon + 1 >> 0; }; - CommClause.prototype.End = function() { return this.$val.End(); }; - SelectStmt.Ptr.prototype.End = function() { - var s; - s = this; - return s.Body.End(); + Rand.prototype.NormFloat64 = function() { return this.$val.NormFloat64(); }; + NewSource = $pkg.NewSource = function(seed) { + var rng; + rng = new rngSource.Ptr(); $copy(rng, new rngSource.Ptr(), rngSource); + rng.Seed(seed); + return rng; }; - SelectStmt.prototype.End = function() { return this.$val.End(); }; - ForStmt.Ptr.prototype.End = function() { - var s; - s = this; - return s.Body.End(); + New = $pkg.New = function(src) { + return new Rand.Ptr(src); }; - ForStmt.prototype.End = function() { return this.$val.End(); }; - RangeStmt.Ptr.prototype.End = function() { - var s; - s = this; - return s.Body.End(); + Rand.Ptr.prototype.Seed = function(seed) { + var r; + r = this; + r.src.Seed(seed); }; - RangeStmt.prototype.End = function() { return this.$val.End(); }; - ImportSpec.Ptr.prototype.Pos = function() { - var s; - s = this; - if (!(s.Name === ($ptrType(Ident)).nil)) { - return s.Name.Pos(); - } - return s.Path.Pos(); + Rand.prototype.Seed = function(seed) { return this.$val.Seed(seed); }; + Rand.Ptr.prototype.Int63 = function() { + var r; + r = this; + return r.src.Int63(); }; - ImportSpec.prototype.Pos = function() { return this.$val.Pos(); }; - ValueSpec.Ptr.prototype.Pos = function() { - var s, x; - s = this; - return (x = s.Names, ((0 < 0 || 0 >= x.$length) ? $throwRuntimeError("index out of range") : x.$array[x.$offset + 0])).Pos(); + Rand.prototype.Int63 = function() { return this.$val.Int63(); }; + Rand.Ptr.prototype.Uint32 = function() { + var r; + r = this; + return ($shiftRightInt64(r.Int63(), 31).$low >>> 0); }; - ValueSpec.prototype.Pos = function() { return this.$val.Pos(); }; - TypeSpec.Ptr.prototype.Pos = function() { - var s; - s = this; - return s.Name.Pos(); + Rand.prototype.Uint32 = function() { return this.$val.Uint32(); }; + Rand.Ptr.prototype.Int31 = function() { + var r, x; + r = this; + return ((x = $shiftRightInt64(r.Int63(), 32), x.$low + ((x.$high >> 31) * 4294967296)) >> 0); }; - TypeSpec.prototype.Pos = function() { return this.$val.Pos(); }; - ImportSpec.Ptr.prototype.End = function() { - var s; - s = this; - if (!((s.EndPos === 0))) { - return s.EndPos; - } - return s.Path.End(); + Rand.prototype.Int31 = function() { return this.$val.Int31(); }; + Rand.Ptr.prototype.Int = function() { + var r, u; + r = this; + u = (r.Int63().$low >>> 0); + return (((u << 1 >>> 0) >>> 1 >>> 0) >> 0); }; - ImportSpec.prototype.End = function() { return this.$val.End(); }; - ValueSpec.Ptr.prototype.End = function() { - var s, n, x, x$1, x$2, x$3; - s = this; - n = s.Values.$length; - if (n > 0) { - return (x = s.Values, x$1 = n - 1 >> 0, ((x$1 < 0 || x$1 >= x.$length) ? $throwRuntimeError("index out of range") : x.$array[x.$offset + x$1])).End(); + Rand.prototype.Int = function() { return this.$val.Int(); }; + Rand.Ptr.prototype.Int63n = function(n) { + var r, x, x$1, x$2, x$3, x$4, x$5, max, v; + r = this; + if ((n.$high < 0 || (n.$high === 0 && n.$low <= 0))) { + $panic(new $String("invalid argument to Int63n")); } - if (!($interfaceIsEqual(s.Type, $ifaceNil))) { - return s.Type.End(); + if ((x = (x$1 = new $Int64(n.$high - 0, n.$low - 1), new $Int64(n.$high & x$1.$high, (n.$low & x$1.$low) >>> 0)), (x.$high === 0 && x.$low === 0))) { + return (x$2 = r.Int63(), x$3 = new $Int64(n.$high - 0, n.$low - 1), new $Int64(x$2.$high & x$3.$high, (x$2.$low & x$3.$low) >>> 0)); } - return (x$2 = s.Names, x$3 = s.Names.$length - 1 >> 0, ((x$3 < 0 || x$3 >= x$2.$length) ? $throwRuntimeError("index out of range") : x$2.$array[x$2.$offset + x$3])).End(); - }; - ValueSpec.prototype.End = function() { return this.$val.End(); }; - TypeSpec.Ptr.prototype.End = function() { - var s; - s = this; - return s.Type.End(); - }; - TypeSpec.prototype.End = function() { return this.$val.End(); }; - BadDecl.Ptr.prototype.Pos = function() { - var d; - d = this; - return d.From; - }; - BadDecl.prototype.Pos = function() { return this.$val.Pos(); }; - GenDecl.Ptr.prototype.Pos = function() { - var d; - d = this; - return d.TokPos; - }; - GenDecl.prototype.Pos = function() { return this.$val.Pos(); }; - FuncDecl.Ptr.prototype.Pos = function() { - var d; - d = this; - return d.Type.Pos(); - }; - FuncDecl.prototype.Pos = function() { return this.$val.Pos(); }; - BadDecl.Ptr.prototype.End = function() { - var d; - d = this; - return d.To; - }; - BadDecl.prototype.End = function() { return this.$val.End(); }; - GenDecl.Ptr.prototype.End = function() { - var d, x; - d = this; - if ((new token.Pos(d.Rparen)).IsValid()) { - return d.Rparen + 1 >> 0; + max = (x$4 = (x$5 = $div64(new $Uint64(2147483648, 0), new $Uint64(n.$high, n.$low), true), new $Uint64(2147483647 - x$5.$high, 4294967295 - x$5.$low)), new $Int64(x$4.$high, x$4.$low)); + v = r.Int63(); + while ((v.$high > max.$high || (v.$high === max.$high && v.$low > max.$low))) { + v = r.Int63(); } - return (x = d.Specs, ((0 < 0 || 0 >= x.$length) ? $throwRuntimeError("index out of range") : x.$array[x.$offset + 0])).End(); + return $div64(v, n, true); }; - GenDecl.prototype.End = function() { return this.$val.End(); }; - FuncDecl.Ptr.prototype.End = function() { - var d; - d = this; - if (!(d.Body === ($ptrType(BlockStmt)).nil)) { - return d.Body.End(); + Rand.prototype.Int63n = function(n) { return this.$val.Int63n(n); }; + Rand.Ptr.prototype.Int31n = function(n) { + var r, _r, max, v, _r$1; + r = this; + if (n <= 0) { + $panic(new $String("invalid argument to Int31n")); } - return d.Type.End(); - }; - FuncDecl.prototype.End = function() { return this.$val.End(); }; - File.Ptr.prototype.Pos = function() { - var f; - f = this; - return f.Package; - }; - File.prototype.Pos = function() { return this.$val.Pos(); }; - File.Ptr.prototype.End = function() { - var f, n, x, x$1; - f = this; - n = f.Decls.$length; - if (n > 0) { - return (x = f.Decls, x$1 = n - 1 >> 0, ((x$1 < 0 || x$1 >= x.$length) ? $throwRuntimeError("index out of range") : x.$array[x.$offset + x$1])).End(); + if ((n & ((n - 1 >> 0))) === 0) { + return r.Int31() & ((n - 1 >> 0)); } - return f.Name.End(); - }; - File.prototype.End = function() { return this.$val.End(); }; - Package.Ptr.prototype.Pos = function() { - var p; - p = this; - return 0; - }; - Package.prototype.Pos = function() { return this.$val.Pos(); }; - Package.Ptr.prototype.End = function() { - var p; - p = this; - return 0; - }; - Package.prototype.End = function() { return this.$val.End(); }; - byPos.prototype.Len = function() { - var a; - a = this; - return a.$length; + max = ((2147483647 - (_r = 2147483648 % (n >>> 0), _r === _r ? _r : $throwRuntimeError("integer divide by zero")) >>> 0) >> 0); + v = r.Int31(); + while (v > max) { + v = r.Int31(); + } + return (_r$1 = v % n, _r$1 === _r$1 ? _r$1 : $throwRuntimeError("integer divide by zero")); }; - $ptrType(byPos).prototype.Len = function() { return this.$get().Len(); }; - byPos.prototype.Less = function(i, j) { - var a; - a = this; - return ((i < 0 || i >= a.$length) ? $throwRuntimeError("index out of range") : a.$array[a.$offset + i]).Pos() < ((j < 0 || j >= a.$length) ? $throwRuntimeError("index out of range") : a.$array[a.$offset + j]).Pos(); + Rand.prototype.Int31n = function(n) { return this.$val.Int31n(n); }; + Rand.Ptr.prototype.Intn = function(n) { + var r, x; + r = this; + if (n <= 0) { + $panic(new $String("invalid argument to Intn")); + } + if (n <= 2147483647) { + return (r.Int31n((n >> 0)) >> 0); + } + return ((x = r.Int63n(new $Int64(0, n)), x.$low + ((x.$high >> 31) * 4294967296)) >> 0); }; - $ptrType(byPos).prototype.Less = function(i, j) { return this.$get().Less(i, j); }; - byPos.prototype.Swap = function(i, j) { - var a, _tmp, _tmp$1; - a = this; - _tmp = ((j < 0 || j >= a.$length) ? $throwRuntimeError("index out of range") : a.$array[a.$offset + j]); _tmp$1 = ((i < 0 || i >= a.$length) ? $throwRuntimeError("index out of range") : a.$array[a.$offset + i]); (i < 0 || i >= a.$length) ? $throwRuntimeError("index out of range") : a.$array[a.$offset + i] = _tmp; (j < 0 || j >= a.$length) ? $throwRuntimeError("index out of range") : a.$array[a.$offset + j] = _tmp$1; + Rand.prototype.Intn = function(n) { return this.$val.Intn(n); }; + Rand.Ptr.prototype.Float64 = function() { + var r, f; + r = this; + f = $flatten64(r.Int63()) / 9.223372036854776e+18; + if (f === 1) { + f = 0; + } + return f; }; - $ptrType(byPos).prototype.Swap = function(i, j) { return this.$get().Swap(i, j); }; - sortComments = function(list) { - var orderedList; - orderedList = $subslice(new byPos(list.$array), list.$offset, list.$offset + list.$length); - if (!sort.IsSorted(orderedList)) { - sort.Sort(orderedList); + Rand.prototype.Float64 = function() { return this.$val.Float64(); }; + Rand.Ptr.prototype.Float32 = function() { + var r, f; + r = this; + f = r.Float64(); + if ($float32IsEqual(f, 1)) { + f = 0; } + return f; }; - CommentMap.prototype.addComment = function(n, c) { - var cmap, _entry, list, _key; - cmap = this.$val !== undefined ? this.$val : this; - list = (_entry = cmap[n.$key()], _entry !== undefined ? _entry.v : ($sliceType(($ptrType(CommentGroup)))).nil); - if (list.$length === 0) { - list = new ($sliceType(($ptrType(CommentGroup))))([c]); - } else { - list = $append(list, c); + Rand.prototype.Float32 = function() { return this.$val.Float32(); }; + Rand.Ptr.prototype.Perm = function(n) { + var r, m, i, j; + r = this; + m = ($sliceType($Int)).make(n); + i = 0; + while (i < n) { + j = r.Intn(i + 1 >> 0); + (i < 0 || i >= m.$length) ? $throwRuntimeError("index out of range") : m.$array[m.$offset + i] = ((j < 0 || j >= m.$length) ? $throwRuntimeError("index out of range") : m.$array[m.$offset + j]); + (j < 0 || j >= m.$length) ? $throwRuntimeError("index out of range") : m.$array[m.$offset + j] = i; + i = i + (1) >> 0; } - _key = n; (cmap || $throwRuntimeError("assignment to entry in nil map"))[_key.$key()] = { k: _key, v: list }; + return m; }; - $ptrType(CommentMap).prototype.addComment = function(n, c) { return new CommentMap(this.$get()).addComment(n, c); }; - nodeList = function(n) { - var list; - list = ($sliceType(Node)).nil; - Inspect(n, (function(n$1) { - var _ref; - _ref = n$1; - if (_ref === $ifaceNil || $assertType(_ref, ($ptrType(CommentGroup)), true)[1] || $assertType(_ref, ($ptrType(Comment)), true)[1]) { - return false; - } - list = $append(list, n$1); - return true; - })); - return list; + Rand.prototype.Perm = function(n) { return this.$val.Perm(n); }; + lockedSource.Ptr.prototype.Int63 = function() { + var n = new $Int64(0, 0), r; + r = this; + r.lk.Lock(); + n = r.src.Int63(); + r.lk.Unlock(); + return n; }; - commentListReader.Ptr.prototype.eol = function() { + lockedSource.prototype.Int63 = function() { return this.$val.Int63(); }; + lockedSource.Ptr.prototype.Seed = function(seed) { var r; r = this; - return r.index >= r.list.$length; + r.lk.Lock(); + r.src.Seed(seed); + r.lk.Unlock(); }; - commentListReader.prototype.eol = function() { return this.$val.eol(); }; - commentListReader.Ptr.prototype.next = function() { - var r, x, x$1; - r = this; - if (!r.eol()) { - r.comment = (x = r.list, x$1 = r.index, ((x$1 < 0 || x$1 >= x.$length) ? $throwRuntimeError("index out of range") : x.$array[x.$offset + x$1])); - $copy(r.pos, r.fset.Position(r.comment.Pos()), token.Position); - $copy(r.end, r.fset.Position(r.comment.End()), token.Position); - r.index = r.index + (1) >> 0; + lockedSource.prototype.Seed = function(seed) { return this.$val.Seed(seed); }; + seedrand = function(x) { + var _q, hi, _r, lo; + hi = (_q = x / 44488, (_q === _q && _q !== 1/0 && _q !== -1/0) ? _q >> 0 : $throwRuntimeError("integer divide by zero")); + lo = (_r = x % 44488, _r === _r ? _r : $throwRuntimeError("integer divide by zero")); + x = ((((48271 >>> 16 << 16) * lo >> 0) + (48271 << 16 >>> 16) * lo) >> 0) - ((((3399 >>> 16 << 16) * hi >> 0) + (3399 << 16 >>> 16) * hi) >> 0) >> 0; + if (x < 0) { + x = x + (2147483647) >> 0; } + return x; }; - commentListReader.prototype.next = function() { return this.$val.next(); }; - $ptrType(nodeStack).prototype.push = function(n) { - var s; - s = this; - s.pop(n.Pos()); - s.$set($append((s.$get()), n)); - }; - $ptrType(nodeStack).prototype.pop = function(pos) { - var top = $ifaceNil, s, i, x, x$1, x$2, x$3; - s = this; - i = s.$get().$length; - while (i > 0 && (x = s.$get(), x$1 = i - 1 >> 0, ((x$1 < 0 || x$1 >= x.$length) ? $throwRuntimeError("index out of range") : x.$array[x.$offset + x$1])).End() <= pos) { - top = (x$2 = s.$get(), x$3 = i - 1 >> 0, ((x$3 < 0 || x$3 >= x$2.$length) ? $throwRuntimeError("index out of range") : x$2.$array[x$2.$offset + x$3])); - i = i - (1) >> 0; + rngSource.Ptr.prototype.Seed = function(seed) { + var rng, x, x$1, i, u, x$2, x$3, x$4, x$5; + rng = this; + rng.tap = 0; + rng.feed = 334; + seed = $div64(seed, new $Int64(0, 2147483647), true); + if ((seed.$high < 0 || (seed.$high === 0 && seed.$low < 0))) { + seed = (x = new $Int64(0, 2147483647), new $Int64(seed.$high + x.$high, seed.$low + x.$low)); } - s.$set($subslice((s.$get()), 0, i)); - top = top; - return top; - }; - NewCommentMap = $pkg.NewCommentMap = function(fset, node, comments) { - var cmap, tmp, r, nodes, p, pend, pg, pgend, stack, _ref, _i, q, qpos, top, assoc, _ref$1; - if (comments.$length === 0) { - return false; + if ((seed.$high === 0 && seed.$low === 0)) { + seed = new $Int64(0, 89482311); } - cmap = new $Map(); - tmp = ($sliceType(($ptrType(CommentGroup)))).make(comments.$length); - $copySlice(tmp, comments); - sortComments(tmp); - r = new commentListReader.Ptr(fset, tmp, 0, ($ptrType(CommentGroup)).nil, new token.Position.Ptr(), new token.Position.Ptr()); - r.next(); - nodes = nodeList(node); - nodes = $append(nodes, $ifaceNil); - p = $ifaceNil; - pend = new token.Position.Ptr(); $copy(pend, new token.Position.Ptr(), token.Position); - pg = $ifaceNil; - pgend = new token.Position.Ptr(); $copy(pgend, new token.Position.Ptr(), token.Position); - stack = nodeStack.nil; - _ref = nodes; - _i = 0; - while (_i < _ref.$length) { - q = ((_i < 0 || _i >= _ref.$length) ? $throwRuntimeError("index out of range") : _ref.$array[_ref.$offset + _i]); - qpos = new token.Position.Ptr(); $copy(qpos, new token.Position.Ptr(), token.Position); - if (!($interfaceIsEqual(q, $ifaceNil))) { - $copy(qpos, fset.Position(q.Pos()), token.Position); - } else { - qpos.Offset = 1073741824; - qpos.Line = 1073741824; - } - while (r.end.Offset <= qpos.Offset) { - top = new ($ptrType(nodeStack))(function() { return stack; }, function($v) { stack = $v; }).pop(r.comment.Pos()); - if (!($interfaceIsEqual(top, $ifaceNil))) { - pg = top; - $copy(pgend, fset.Position(pg.End()), token.Position); - } - assoc = $ifaceNil; - if (!($interfaceIsEqual(pg, $ifaceNil)) && ((pgend.Line === r.pos.Line) || ((pgend.Line + 1 >> 0) === r.pos.Line) && (r.end.Line + 1 >> 0) < qpos.Line)) { - assoc = pg; - } else if (!($interfaceIsEqual(p, $ifaceNil)) && ((pend.Line === r.pos.Line) || ((pend.Line + 1 >> 0) === r.pos.Line) && (r.end.Line + 1 >> 0) < qpos.Line || $interfaceIsEqual(q, $ifaceNil))) { - assoc = p; - } else { - if ($interfaceIsEqual(q, $ifaceNil)) { - $panic(new $String("internal error: no comments should be associated with sentinel")); - } - assoc = q; - } - (new CommentMap(cmap)).addComment(assoc, r.comment); - if (r.eol()) { - return cmap; - } - r.next(); - } - p = q; - $copy(pend, fset.Position(p.End()), token.Position); - _ref$1 = q; - if ($assertType(_ref$1, ($ptrType(File)), true)[1] || $assertType(_ref$1, ($ptrType(Field)), true)[1] || $assertType(_ref$1, Decl, true)[1] || $assertType(_ref$1, Spec, true)[1] || $assertType(_ref$1, Stmt, true)[1]) { - new ($ptrType(nodeStack))(function() { return stack; }, function($v) { stack = $v; }).push(q); + x$1 = ((seed.$low + ((seed.$high >> 31) * 4294967296)) >> 0); + i = -20; + while (i < 607) { + x$1 = seedrand(x$1); + if (i >= 0) { + u = new $Int64(0, 0); + u = $shiftLeft64(new $Int64(0, x$1), 40); + x$1 = seedrand(x$1); + u = (x$2 = $shiftLeft64(new $Int64(0, x$1), 20), new $Int64(u.$high ^ x$2.$high, (u.$low ^ x$2.$low) >>> 0)); + x$1 = seedrand(x$1); + u = (x$3 = new $Int64(0, x$1), new $Int64(u.$high ^ x$3.$high, (u.$low ^ x$3.$low) >>> 0)); + u = (x$4 = ((i < 0 || i >= rng_cooked.length) ? $throwRuntimeError("index out of range") : rng_cooked[i]), new $Int64(u.$high ^ x$4.$high, (u.$low ^ x$4.$low) >>> 0)); + (x$5 = rng.vec, (i < 0 || i >= x$5.length) ? $throwRuntimeError("index out of range") : x$5[i] = new $Int64(u.$high & 2147483647, (u.$low & 4294967295) >>> 0)); } - _i++; + i = i + (1) >> 0; } - return cmap; }; - CommentMap.prototype.Update = function(old, new$1) { - var cmap, _entry, list, _entry$1, _key; - cmap = this.$val !== undefined ? this.$val : this; - list = (_entry = cmap[old.$key()], _entry !== undefined ? _entry.v : ($sliceType(($ptrType(CommentGroup)))).nil); - if (list.$length > 0) { - delete cmap[old.$key()]; - _key = new$1; (cmap || $throwRuntimeError("assignment to entry in nil map"))[_key.$key()] = { k: _key, v: $appendSlice((_entry$1 = cmap[new$1.$key()], _entry$1 !== undefined ? _entry$1.v : ($sliceType(($ptrType(CommentGroup)))).nil), list) }; + rngSource.prototype.Seed = function(seed) { return this.$val.Seed(seed); }; + rngSource.Ptr.prototype.Int63 = function() { + var rng, x, x$1, x$2, x$3, x$4, x$5, x$6, x$7, x$8, x$9; + rng = this; + rng.tap = rng.tap - (1) >> 0; + if (rng.tap < 0) { + rng.tap = rng.tap + (607) >> 0; } - return new$1; + rng.feed = rng.feed - (1) >> 0; + if (rng.feed < 0) { + rng.feed = rng.feed + (607) >> 0; + } + x$7 = (x = (x$1 = (x$2 = rng.vec, x$3 = rng.feed, ((x$3 < 0 || x$3 >= x$2.length) ? $throwRuntimeError("index out of range") : x$2[x$3])), x$4 = (x$5 = rng.vec, x$6 = rng.tap, ((x$6 < 0 || x$6 >= x$5.length) ? $throwRuntimeError("index out of range") : x$5[x$6])), new $Int64(x$1.$high + x$4.$high, x$1.$low + x$4.$low)), new $Int64(x.$high & 2147483647, (x.$low & 4294967295) >>> 0)); + (x$8 = rng.vec, x$9 = rng.feed, (x$9 < 0 || x$9 >= x$8.length) ? $throwRuntimeError("index out of range") : x$8[x$9] = x$7); + return x$7; }; - $ptrType(CommentMap).prototype.Update = function(old, new$1) { return new CommentMap(this.$get()).Update(old, new$1); }; - CommentMap.prototype.Filter = function(node) { - var cmap, umap; - cmap = this.$val !== undefined ? this.$val : this; - umap = new $Map(); - Inspect(node, (function(n) { - var _entry, g, _key; - g = (_entry = cmap[n.$key()], _entry !== undefined ? _entry.v : ($sliceType(($ptrType(CommentGroup)))).nil); - if (g.$length > 0) { - _key = n; (umap || $throwRuntimeError("assignment to entry in nil map"))[_key.$key()] = { k: _key, v: g }; - } - return true; - })); - return umap; + rngSource.prototype.Int63 = function() { return this.$val.Int63(); }; + $pkg.$init = function() { + Source.init([["Int63", "Int63", "", $funcType([], [$Int64], false)], ["Seed", "Seed", "", $funcType([$Int64], [], false)]]); + ($ptrType(Rand)).methods = [["ExpFloat64", "ExpFloat64", "", $funcType([], [$Float64], false), -1], ["Float32", "Float32", "", $funcType([], [$Float32], false), -1], ["Float64", "Float64", "", $funcType([], [$Float64], false), -1], ["Int", "Int", "", $funcType([], [$Int], false), -1], ["Int31", "Int31", "", $funcType([], [$Int32], false), -1], ["Int31n", "Int31n", "", $funcType([$Int32], [$Int32], false), -1], ["Int63", "Int63", "", $funcType([], [$Int64], false), -1], ["Int63n", "Int63n", "", $funcType([$Int64], [$Int64], false), -1], ["Intn", "Intn", "", $funcType([$Int], [$Int], false), -1], ["NormFloat64", "NormFloat64", "", $funcType([], [$Float64], false), -1], ["Perm", "Perm", "", $funcType([$Int], [($sliceType($Int))], false), -1], ["Seed", "Seed", "", $funcType([$Int64], [], false), -1], ["Uint32", "Uint32", "", $funcType([], [$Uint32], false), -1]]; + Rand.init([["src", "src", "math/rand", Source, ""]]); + ($ptrType(lockedSource)).methods = [["Int63", "Int63", "", $funcType([], [$Int64], false), -1], ["Seed", "Seed", "", $funcType([$Int64], [], false), -1]]; + lockedSource.init([["lk", "lk", "math/rand", sync.Mutex, ""], ["src", "src", "math/rand", Source, ""]]); + ($ptrType(rngSource)).methods = [["Int63", "Int63", "", $funcType([], [$Int64], false), -1], ["Seed", "Seed", "", $funcType([$Int64], [], false), -1]]; + rngSource.init([["tap", "tap", "math/rand", $Int, ""], ["feed", "feed", "math/rand", $Int, ""], ["vec", "vec", "math/rand", ($arrayType($Int64, 607)), ""]]); + ke = $toNativeArray("Uint32", [3801129273, 0, 2615860924, 3279400049, 3571300752, 3733536696, 3836274812, 3906990442, 3958562475, 3997804264, 4028649213, 4053523342, 4074002619, 4091154507, 4105727352, 4118261130, 4129155133, 4138710916, 4147160435, 4154685009, 4161428406, 4167506077, 4173011791, 4178022498, 4182601930, 4186803325, 4190671498, 4194244443, 4197554582, 4200629752, 4203493986, 4206168142, 4208670408, 4211016720, 4213221098, 4215295924, 4217252177, 4219099625, 4220846988, 4222502074, 4224071896, 4225562770, 4226980400, 4228329951, 4229616109, 4230843138, 4232014925, 4233135020, 4234206673, 4235232866, 4236216336, 4237159604, 4238064994, 4238934652, 4239770563, 4240574564, 4241348362, 4242093539, 4242811568, 4243503822, 4244171579, 4244816032, 4245438297, 4246039419, 4246620374, 4247182079, 4247725394, 4248251127, 4248760037, 4249252839, 4249730206, 4250192773, 4250641138, 4251075867, 4251497493, 4251906522, 4252303431, 4252688672, 4253062674, 4253425844, 4253778565, 4254121205, 4254454110, 4254777611, 4255092022, 4255397640, 4255694750, 4255983622, 4256264513, 4256537670, 4256803325, 4257061702, 4257313014, 4257557464, 4257795244, 4258026541, 4258251531, 4258470383, 4258683258, 4258890309, 4259091685, 4259287526, 4259477966, 4259663135, 4259843154, 4260018142, 4260188212, 4260353470, 4260514019, 4260669958, 4260821380, 4260968374, 4261111028, 4261249421, 4261383632, 4261513736, 4261639802, 4261761900, 4261880092, 4261994441, 4262105003, 4262211835, 4262314988, 4262414513, 4262510454, 4262602857, 4262691764, 4262777212, 4262859239, 4262937878, 4263013162, 4263085118, 4263153776, 4263219158, 4263281289, 4263340187, 4263395872, 4263448358, 4263497660, 4263543789, 4263586755, 4263626565, 4263663224, 4263696735, 4263727099, 4263754314, 4263778377, 4263799282, 4263817020, 4263831582, 4263842955, 4263851124, 4263856071, 4263857776, 4263856218, 4263851370, 4263843206, 4263831695, 4263816804, 4263798497, 4263776735, 4263751476, 4263722676, 4263690284, 4263654251, 4263614520, 4263571032, 4263523724, 4263472530, 4263417377, 4263358192, 4263294892, 4263227394, 4263155608, 4263079437, 4262998781, 4262913534, 4262823581, 4262728804, 4262629075, 4262524261, 4262414220, 4262298801, 4262177846, 4262051187, 4261918645, 4261780032, 4261635148, 4261483780, 4261325704, 4261160681, 4260988457, 4260808763, 4260621313, 4260425802, 4260221905, 4260009277, 4259787550, 4259556329, 4259315195, 4259063697, 4258801357, 4258527656, 4258242044, 4257943926, 4257632664, 4257307571, 4256967906, 4256612870, 4256241598, 4255853155, 4255446525, 4255020608, 4254574202, 4254106002, 4253614578, 4253098370, 4252555662, 4251984571, 4251383021, 4250748722, 4250079132, 4249371435, 4248622490, 4247828790, 4246986404, 4246090910, 4245137315, 4244119963, 4243032411, 4241867296, 4240616155, 4239269214, 4237815118, 4236240596, 4234530035, 4232664930, 4230623176, 4228378137, 4225897409, 4223141146, 4220059768, 4216590757, 4212654085, 4208145538, 4202926710, 4196809522, 4189531420, 4180713890, 4169789475, 4155865042, 4137444620, 4111806704, 4073393724, 4008685917, 3873074895]); + we = $toNativeArray("Float32", [2.0249555365836613e-09, 1.4866739783681027e-11, 2.4409616689036184e-11, 3.1968806074589295e-11, 3.844677007314168e-11, 4.42282044321729e-11, 4.951644302919611e-11, 5.443358958023836e-11, 5.905943789574764e-11, 6.34494193296753e-11, 6.764381416113352e-11, 7.167294535648239e-11, 7.556032188826833e-11, 7.932458162551725e-11, 8.298078890689453e-11, 8.654132271912474e-11, 9.001651507523079e-11, 9.341507428706208e-11, 9.674443190998971e-11, 1.0001099254308699e-10, 1.0322031424037093e-10, 1.0637725422757427e-10, 1.0948611461891744e-10, 1.1255067711157807e-10, 1.1557434870246297e-10, 1.1856014781042035e-10, 1.2151082917633005e-10, 1.2442885610752796e-10, 1.2731647680563896e-10, 1.3017574518325858e-10, 1.330085347417409e-10, 1.3581656632677408e-10, 1.386014220061682e-10, 1.413645728254309e-10, 1.4410737880776736e-10, 1.4683107507629245e-10, 1.4953686899854546e-10, 1.522258291641876e-10, 1.5489899640730442e-10, 1.575573282952547e-10, 1.6020171300645814e-10, 1.628330109637588e-10, 1.6545202707884954e-10, 1.68059510752272e-10, 1.7065616975120435e-10, 1.73242697965037e-10, 1.758197337720091e-10, 1.783878739169964e-10, 1.8094774290045024e-10, 1.834998542005195e-10, 1.8604476292871652e-10, 1.8858298256319017e-10, 1.9111498494872592e-10, 1.9364125580789704e-10, 1.9616222535212557e-10, 1.9867835154840918e-10, 2.011900368525943e-10, 2.0369768372052732e-10, 2.062016807302669e-10, 2.0870240258208383e-10, 2.1120022397624894e-10, 2.136955057352452e-10, 2.1618855317040442e-10, 2.1867974098199738e-10, 2.2116936060356807e-10, 2.2365774510202385e-10, 2.2614519978869652e-10, 2.2863201609713002e-10, 2.3111849933865614e-10, 2.3360494094681883e-10, 2.3609159072179864e-10, 2.3857874009713953e-10, 2.4106666662859766e-10, 2.4355562011635357e-10, 2.460458781161634e-10, 2.485376904282077e-10, 2.5103127909709144e-10, 2.5352694943414633e-10, 2.560248957284017e-10, 2.585253955356137e-10, 2.610286709003873e-10, 2.6353494386732734e-10, 2.6604446423661443e-10, 2.6855745405285347e-10, 2.71074163116225e-10, 2.7359478571575835e-10, 2.7611959940720965e-10, 2.786487707240326e-10, 2.8118254946640775e-10, 2.8372118543451563e-10, 2.8626484516180994e-10, 2.8881380620404684e-10, 2.9136826285025563e-10, 2.9392840938946563e-10, 2.96494523377433e-10, 2.990667713476114e-10, 3.016454031001814e-10, 3.042306406797479e-10, 3.068226783753403e-10, 3.09421765987139e-10, 3.12028125559749e-10, 3.1464195138219964e-10, 3.17263521010247e-10, 3.1989300097734485e-10, 3.225306410836737e-10, 3.2517669112941405e-10, 3.2783134540359526e-10, 3.3049485370639786e-10, 3.3316743808242677e-10, 3.3584937608743815e-10, 3.385408342548857e-10, 3.4124211789610115e-10, 3.4395342130011386e-10, 3.4667499426710435e-10, 3.494071143528288e-10, 3.521500313574677e-10, 3.54903967325626e-10, 3.576691720574843e-10, 3.6044595086437425e-10, 3.632345535464765e-10, 3.660352021483959e-10, 3.688482297370399e-10, 3.716738583570134e-10, 3.7451239331964814e-10, 3.773641121807003e-10, 3.802292924959261e-10, 3.831082673322328e-10, 3.8600128648980103e-10, 3.8890865527996255e-10, 3.9183070676962473e-10, 3.9476774627011935e-10, 3.977200790927782e-10, 4.006880383045086e-10, 4.0367195697221803e-10, 4.066721681628138e-10, 4.0968900494320337e-10, 4.127228558914453e-10, 4.15774054074447e-10, 4.188429603146915e-10, 4.2192993543466173e-10, 4.25035395767992e-10, 4.2815970213716525e-10, 4.313032986313914e-10, 4.3446651831757777e-10, 4.376498607960855e-10, 4.408536868893975e-10, 4.4407846844229937e-10, 4.4732464954400086e-10, 4.5059267428371186e-10, 4.538830145062178e-10, 4.5719619756745544e-10, 4.605326675566346e-10, 4.638929240741163e-10, 4.672775499869886e-10, 4.706869893844612e-10, 4.74121908400349e-10, 4.775827511238617e-10, 4.810701836888143e-10, 4.845848167178701e-10, 4.881271498113904e-10, 4.916979601254923e-10, 4.952977472605369e-10, 4.989272883726414e-10, 5.025872495956207e-10, 5.062783525744408e-10, 5.100013189540675e-10, 5.13756870379467e-10, 5.175458395179078e-10, 5.21369003525507e-10, 5.252272505806843e-10, 5.29121357839557e-10, 5.330522134805449e-10, 5.3702081670437e-10, 5.41028055689452e-10, 5.450749851476644e-10, 5.491624932574268e-10, 5.532918012640664e-10, 5.574638528571541e-10, 5.616799247931681e-10, 5.659410717839819e-10, 5.702485705860738e-10, 5.746036979559221e-10, 5.790077306500052e-10, 5.83462111958255e-10, 5.879682296594524e-10, 5.925275825546805e-10, 5.971417249561739e-10, 6.01812211176167e-10, 6.065408175714992e-10, 6.113292094767075e-10, 6.16179329782085e-10, 6.21092954844471e-10, 6.260721940876124e-10, 6.311191569352559e-10, 6.362359528111483e-10, 6.414249686947926e-10, 6.466885360545405e-10, 6.520292639144998e-10, 6.574497612987784e-10, 6.629528592760892e-10, 6.685415554485985e-10, 6.742187919073217e-10, 6.799880103436351e-10, 6.858525969377638e-10, 6.918161599145378e-10, 6.978825850545434e-10, 7.040559801829716e-10, 7.103406751696184e-10, 7.167412219288849e-10, 7.232625609532306e-10, 7.2990985477972e-10, 7.366885990123251e-10, 7.436047333442275e-10, 7.506645305355164e-10, 7.57874762946642e-10, 7.652426470272644e-10, 7.727759543385559e-10, 7.804830115532013e-10, 7.883728114777e-10, 7.964550685635174e-10, 8.047402189070851e-10, 8.132396422944055e-10, 8.219657177122031e-10, 8.309318788590758e-10, 8.401527806789488e-10, 8.496445214056791e-10, 8.594246980742071e-10, 8.695127395874636e-10, 8.799300732498239e-10, 8.90700457834015e-10, 9.01850316648023e-10, 9.134091816243028e-10, 9.254100818978372e-10, 9.37890431984556e-10, 9.508922538259412e-10, 9.64463842123564e-10, 9.78660263939446e-10, 9.935448019859905e-10, 1.0091912860943353e-09, 1.0256859805934937e-09, 1.0431305819125214e-09, 1.0616465484503124e-09, 1.0813799855569073e-09, 1.1025096391392708e-09, 1.1252564435793033e-09, 1.149898620766976e-09, 1.176793218427008e-09, 1.2064089727203964e-09, 1.2393785997488749e-09, 1.2765849488616254e-09, 1.319313880365769e-09, 1.36954347862428e-09, 1.4305497897382224e-09, 1.5083649884672923e-09, 1.6160853766322703e-09, 1.7921247819074893e-09]); + fe = $toNativeArray("Float32", [1, 0.9381436705589294, 0.900469958782196, 0.8717043399810791, 0.847785472869873, 0.8269932866096497, 0.8084216713905334, 0.7915276288986206, 0.7759568691253662, 0.7614634037017822, 0.7478685975074768, 0.7350381016731262, 0.7228676676750183, 0.7112747430801392, 0.7001926302909851, 0.6895664930343628, 0.6793505549430847, 0.669506311416626, 0.6600008606910706, 0.6508058309555054, 0.6418967247009277, 0.633251965045929, 0.62485271692276, 0.6166821718215942, 0.608725368976593, 0.6009689569473267, 0.5934008955955505, 0.5860103368759155, 0.5787873864173889, 0.5717230439186096, 0.5648092031478882, 0.5580382943153381, 0.5514034032821655, 0.5448982119560242, 0.5385168790817261, 0.5322538614273071, 0.526104211807251, 0.5200631618499756, 0.5141264200210571, 0.5082897543907166, 0.5025495290756226, 0.4969019889831543, 0.4913438558578491, 0.4858720004558563, 0.48048335313796997, 0.4751752018928528, 0.4699448347091675, 0.4647897481918335, 0.4597076177597046, 0.4546961486339569, 0.4497532546520233, 0.44487687945365906, 0.4400651156902313, 0.4353161156177521, 0.4306281507015228, 0.42599955201148987, 0.42142874002456665, 0.4169141948223114, 0.4124544560909271, 0.40804818272590637, 0.4036940038204193, 0.39939069747924805, 0.3951369822025299, 0.39093172550201416, 0.38677382469177246, 0.38266217708587646, 0.378595769405365, 0.37457355856895447, 0.37059465050697327, 0.366658091545105, 0.362762987613678, 0.358908474445343, 0.35509374737739563, 0.35131800174713135, 0.3475804924964905, 0.34388044476509094, 0.34021714329719543, 0.33658990263938904, 0.3329980671405792, 0.3294409513473511, 0.32591795921325684, 0.32242849469184875, 0.3189719021320343, 0.3155476748943329, 0.31215524673461914, 0.3087940812110901, 0.30546361207962036, 0.30216339230537415, 0.29889291524887085, 0.29565170407295227, 0.2924392819404602, 0.2892552316188812, 0.28609907627105713, 0.2829704284667969, 0.27986884117126465, 0.2767939269542694, 0.2737452983856201, 0.2707225978374481, 0.26772540807724, 0.26475343108177185, 0.2618062496185303, 0.258883535861969, 0.2559850215911865, 0.25311028957366943, 0.25025907158851624, 0.24743106961250305, 0.2446259707212448, 0.24184346199035645, 0.23908329010009766, 0.23634515702724457, 0.2336287796497345, 0.23093391954898834, 0.22826029360294342, 0.22560766339302063, 0.22297576069831848, 0.22036437690258026, 0.21777324378490448, 0.21520215272903442, 0.212650865316391, 0.21011915802955627, 0.20760682225227356, 0.20511364936828613, 0.20263944566249847, 0.20018397271633148, 0.19774706661701202, 0.1953285187482834, 0.19292815029621124, 0.19054576754570007, 0.18818120658397675, 0.18583425879478455, 0.18350479006767273, 0.18119260668754578, 0.17889754474163055, 0.17661945521831512, 0.17435817420482635, 0.1721135377883911, 0.16988539695739746, 0.16767361760139465, 0.16547803580760956, 0.16329853236675262, 0.16113494336605072, 0.1589871346950531, 0.15685498714447021, 0.15473836660385132, 0.15263713896274567, 0.1505511850118637, 0.1484803706407547, 0.14642459154129028, 0.1443837285041809, 0.14235764741897583, 0.1403462439775467, 0.13834942877292633, 0.136367067694664, 0.13439907133579254, 0.1324453204870224, 0.1305057406425476, 0.12858019769191742, 0.12666863203048706, 0.12477091699838638, 0.12288697808980942, 0.1210167184472084, 0.11916005611419678, 0.11731690168380737, 0.11548716574907303, 0.11367076635360718, 0.11186762899160385, 0.11007767915725708, 0.1083008274435997, 0.10653700679540634, 0.10478614270687103, 0.1030481606721878, 0.10132300108671188, 0.0996105819940567, 0.09791085124015808, 0.09622374176979065, 0.09454918652772903, 0.09288713335990906, 0.09123751521110535, 0.08960027992725372, 0.08797537535429001, 0.08636274188756943, 0.0847623273730278, 0.08317409455776215, 0.08159798383712769, 0.08003395050764084, 0.07848194986581802, 0.07694194465875626, 0.07541389018297195, 0.07389774918556213, 0.07239348441362381, 0.070901058614254, 0.06942043453454971, 0.06795158982276917, 0.06649449467658997, 0.06504911929368973, 0.06361543387174606, 0.06219341605901718, 0.06078304722905159, 0.0593843050301075, 0.05799717456102371, 0.05662164092063904, 0.05525768920779228, 0.05390531197190285, 0.05256449431180954, 0.05123523622751236, 0.04991753399372101, 0.04861138388514519, 0.047316793352365494, 0.04603376239538193, 0.044762298464775085, 0.04350241273641586, 0.04225412383675575, 0.04101744294166565, 0.039792392402887344, 0.03857899457216263, 0.03737728297710419, 0.03618728369474411, 0.03500903770327568, 0.03384258225560188, 0.0326879620552063, 0.031545232981443405, 0.030414443463087082, 0.0292956605553627, 0.028188949450850487, 0.027094384655356407, 0.02601204626262188, 0.024942025542259216, 0.023884421214461327, 0.022839335724711418, 0.021806888282299042, 0.020787203684449196, 0.019780423492193222, 0.018786700442433357, 0.017806200310587883, 0.016839107498526573, 0.015885621309280396, 0.014945968054234982, 0.01402039173990488, 0.013109165243804455, 0.012212592177093029, 0.011331013403832912, 0.010464809834957123, 0.009614413604140282, 0.008780314587056637, 0.007963077165186405, 0.007163353264331818, 0.0063819061033427715, 0.005619642324745655, 0.004877655766904354, 0.004157294984906912, 0.003460264764726162, 0.0027887988835573196, 0.0021459676790982485, 0.001536299823783338, 0.0009672692976891994, 0.0004541343660093844]); + kn = $toNativeArray("Uint32", [1991057938, 0, 1611602771, 1826899878, 1918584482, 1969227037, 2001281515, 2023368125, 2039498179, 2051788381, 2061460127, 2069267110, 2075699398, 2081089314, 2085670119, 2089610331, 2093034710, 2096037586, 2098691595, 2101053571, 2103168620, 2105072996, 2106796166, 2108362327, 2109791536, 2111100552, 2112303493, 2113412330, 2114437283, 2115387130, 2116269447, 2117090813, 2117856962, 2118572919, 2119243101, 2119871411, 2120461303, 2121015852, 2121537798, 2122029592, 2122493434, 2122931299, 2123344971, 2123736059, 2124106020, 2124456175, 2124787725, 2125101763, 2125399283, 2125681194, 2125948325, 2126201433, 2126441213, 2126668298, 2126883268, 2127086657, 2127278949, 2127460589, 2127631985, 2127793506, 2127945490, 2128088244, 2128222044, 2128347141, 2128463758, 2128572095, 2128672327, 2128764606, 2128849065, 2128925811, 2128994934, 2129056501, 2129110560, 2129157136, 2129196237, 2129227847, 2129251929, 2129268426, 2129277255, 2129278312, 2129271467, 2129256561, 2129233410, 2129201800, 2129161480, 2129112170, 2129053545, 2128985244, 2128906855, 2128817916, 2128717911, 2128606255, 2128482298, 2128345305, 2128194452, 2128028813, 2127847342, 2127648860, 2127432031, 2127195339, 2126937058, 2126655214, 2126347546, 2126011445, 2125643893, 2125241376, 2124799783, 2124314271, 2123779094, 2123187386, 2122530867, 2121799464, 2120980787, 2120059418, 2119015917, 2117825402, 2116455471, 2114863093, 2112989789, 2110753906, 2108037662, 2104664315, 2100355223, 2094642347, 2086670106, 2074676188, 2054300022, 2010539237]); + wn = $toNativeArray("Float32", [1.7290404663583558e-09, 1.2680928529462676e-10, 1.689751810696194e-10, 1.9862687883343e-10, 2.223243117382978e-10, 2.4244936613904144e-10, 2.601613091623989e-10, 2.761198769629658e-10, 2.9073962681813725e-10, 3.042996965518796e-10, 3.169979556627567e-10, 3.289802041894774e-10, 3.4035738116777736e-10, 3.5121602848242617e-10, 3.61625090983253e-10, 3.7164057942185025e-10, 3.813085680537398e-10, 3.906675816178762e-10, 3.997501218933053e-10, 4.0858399996679395e-10, 4.1719308563337165e-10, 4.255982233303257e-10, 4.3381759295968436e-10, 4.4186720948857783e-10, 4.497613115272969e-10, 4.57512583373898e-10, 4.6513240481438345e-10, 4.726310454117311e-10, 4.800177477726209e-10, 4.873009773476156e-10, 4.944885056978876e-10, 5.015873272284921e-10, 5.086040477664255e-10, 5.155446070048697e-10, 5.224146670812502e-10, 5.292193350214802e-10, 5.359634958068682e-10, 5.426517013518151e-10, 5.492881705038144e-10, 5.558769555769061e-10, 5.624218868405251e-10, 5.689264614971989e-10, 5.75394121238304e-10, 5.818281967329142e-10, 5.882316855831959e-10, 5.946076964136182e-10, 6.009590047817426e-10, 6.072883862451306e-10, 6.135985053390414e-10, 6.19892026598734e-10, 6.261713370037114e-10, 6.324390455780815e-10, 6.386973727678935e-10, 6.449488165749528e-10, 6.511955974453087e-10, 6.574400468473129e-10, 6.636843297158634e-10, 6.699307220081607e-10, 6.761814441702541e-10, 6.824387166481927e-10, 6.887046488657234e-10, 6.949815167800466e-10, 7.012714853260604e-10, 7.075767749498141e-10, 7.13899661608508e-10, 7.202424212593428e-10, 7.266072743483676e-10, 7.329966078550854e-10, 7.394128087589991e-10, 7.458582640396116e-10, 7.523354716987285e-10, 7.588469852493063e-10, 7.653954137154528e-10, 7.719834771435785e-10, 7.786139510912449e-10, 7.852897221383159e-10, 7.920137878869582e-10, 7.987892014504894e-10, 8.056192379868321e-10, 8.125072836762115e-10, 8.194568912323064e-10, 8.264716688799467e-10, 8.3355555791087e-10, 8.407127216614185e-10, 8.479473234679347e-10, 8.552640262671218e-10, 8.626675485068347e-10, 8.701631637464402e-10, 8.777562010564566e-10, 8.854524335966119e-10, 8.932581896381464e-10, 9.011799639857543e-10, 9.092249730890956e-10, 9.174008219758889e-10, 9.25715837318819e-10, 9.341788453909317e-10, 9.42799727177146e-10, 9.515889187738935e-10, 9.605578554783278e-10, 9.697193048552322e-10, 9.790869226478094e-10, 9.886760299337993e-10, 9.985036131254788e-10, 1.008588212947359e-09, 1.0189509236369076e-09, 1.0296150598776421e-09, 1.040606933955246e-09, 1.0519566329136865e-09, 1.0636980185552147e-09, 1.0758701707302976e-09, 1.0885182755160372e-09, 1.101694735439196e-09, 1.115461056855338e-09, 1.1298901814171813e-09, 1.1450695946990663e-09, 1.1611052119775422e-09, 1.178127595480305e-09, 1.1962995039027646e-09, 1.2158286599728285e-09, 1.2369856250415978e-09, 1.2601323318151003e-09, 1.2857697129220469e-09, 1.3146201904845611e-09, 1.3477839955200466e-09, 1.3870635751089821e-09, 1.43574030442295e-09, 1.5008658760251592e-09, 1.6030947680434338e-09]); + fn = $toNativeArray("Float32", [1, 0.963599681854248, 0.9362826943397522, 0.9130436182022095, 0.8922816514968872, 0.8732430338859558, 0.8555005788803101, 0.8387836217880249, 0.8229072093963623, 0.8077383041381836, 0.7931770086288452, 0.7791460752487183, 0.7655841708183289, 0.7524415850639343, 0.7396772503852844, 0.7272568941116333, 0.7151514887809753, 0.7033361196517944, 0.6917891502380371, 0.6804918646812439, 0.6694276928901672, 0.6585819721221924, 0.6479418277740479, 0.6374954581260681, 0.6272324919700623, 0.6171433925628662, 0.6072195172309875, 0.5974531769752502, 0.5878370404243469, 0.5783646702766418, 0.5690299868583679, 0.5598273873329163, 0.550751805305481, 0.5417983531951904, 0.5329626798629761, 0.5242405533790588, 0.5156282186508179, 0.5071220397949219, 0.49871864914894104, 0.4904148280620575, 0.48220765590667725, 0.47409430146217346, 0.466072142124176, 0.45813870429992676, 0.45029163360595703, 0.44252872467041016, 0.4348478317260742, 0.42724698781967163, 0.41972434520721436, 0.41227802634239197, 0.40490642189979553, 0.39760786294937134, 0.3903807997703552, 0.3832238018512726, 0.3761354684829712, 0.3691144585609436, 0.36215949058532715, 0.3552693724632263, 0.3484429717063904, 0.3416791558265686, 0.33497685194015503, 0.32833510637283325, 0.3217529058456421, 0.3152293860912323, 0.30876362323760986, 0.3023548424243927, 0.2960021495819092, 0.2897048592567444, 0.28346219658851624, 0.2772735059261322, 0.271138072013855, 0.2650552988052368, 0.25902456045150757, 0.25304529070854187, 0.24711695313453674, 0.24123899638652802, 0.23541094362735748, 0.22963231801986694, 0.22390270233154297, 0.21822164952754974, 0.21258877217769623, 0.20700371265411377, 0.20146611332893372, 0.1959756463766098, 0.19053204357624054, 0.18513499200344086, 0.17978426814079285, 0.1744796335697174, 0.16922089457511902, 0.16400785744190216, 0.1588403731584549, 0.15371830761432648, 0.14864157140254974, 0.14361007511615753, 0.13862377405166626, 0.13368265330791473, 0.12878671288490295, 0.12393598258495331, 0.11913054436445236, 0.11437050998210907, 0.10965602099895477, 0.1049872562289238, 0.10036443918943405, 0.09578784555196762, 0.09125780314207077, 0.08677466958761215, 0.08233889937400818, 0.07795098423957825, 0.07361150532960892, 0.06932111829519272, 0.06508058309555054, 0.06089077144861221, 0.05675266310572624, 0.05266740173101425, 0.048636294901371, 0.044660862535238266, 0.040742866694927216, 0.03688438981771469, 0.03308788686990738, 0.029356317594647408, 0.025693291798233986, 0.02210330404341221, 0.018592102453112602, 0.015167297795414925, 0.011839478276669979, 0.0086244847625494, 0.005548994988203049, 0.0026696291752159595]); + rng_cooked = $toNativeArray("Int64", [new $Int64(1173834291, 3952672746), new $Int64(1081821761, 3130416987), new $Int64(324977939, 3414273807), new $Int64(1241840476, 2806224363), new $Int64(669549340, 1997590414), new $Int64(2103305448, 2402795971), new $Int64(1663160183, 1140819369), new $Int64(1120601685, 1788868961), new $Int64(1848035537, 1089001426), new $Int64(1235702047, 873593504), new $Int64(1911387977, 581324885), new $Int64(492609478, 1609182556), new $Int64(1069394745, 1241596776), new $Int64(1895445337, 1771189259), new $Int64(772864846, 3467012610), new $Int64(2006957225, 2344407434), new $Int64(402115761, 782467244), new $Int64(26335124, 3404933915), new $Int64(1063924276, 618867887), new $Int64(1178782866, 520164395), new $Int64(555910815, 1341358184), new $Int64(632398609, 665794848), new $Int64(1527227641, 3183648150), new $Int64(1781176124, 696329606), new $Int64(1789146075, 4151988961), new $Int64(60039534, 998951326), new $Int64(1535158725, 1364957564), new $Int64(63173359, 4090230633), new $Int64(649454641, 4009697548), new $Int64(248009524, 2569622517), new $Int64(778703922, 3742421481), new $Int64(1038377625, 1506914633), new $Int64(1738099768, 1983412561), new $Int64(236311649, 1436266083), new $Int64(1035966148, 3922894967), new $Int64(810508934, 1792680179), new $Int64(563141142, 1188796351), new $Int64(1349617468, 405968250), new $Int64(1044074554, 433754187), new $Int64(870549669, 4073162024), new $Int64(1053232044, 433121399), new $Int64(2451824, 4162580594), new $Int64(2010221076, 4132415622), new $Int64(611252600, 3033822028), new $Int64(2016407895, 824682382), new $Int64(2366218, 3583765414), new $Int64(1522878809, 535386927), new $Int64(1637219058, 2286693689), new $Int64(1453075389, 2968466525), new $Int64(193683513, 1351410206), new $Int64(1863677552, 1412813499), new $Int64(492736522, 4126267639), new $Int64(512765208, 2105529399), new $Int64(2132966268, 2413882233), new $Int64(947457634, 32226200), new $Int64(1149341356, 2032329073), new $Int64(106485445, 1356518208), new $Int64(79673492, 3430061722), new $Int64(663048513, 3820169661), new $Int64(481498454, 2981816134), new $Int64(1017155588, 4184371017), new $Int64(206574701, 2119206761), new $Int64(1295374591, 2472200560), new $Int64(1587026100, 2853524696), new $Int64(1307803389, 1681119904), new $Int64(1972496813, 95608918), new $Int64(392686347, 3690479145), new $Int64(941912722, 1397922290), new $Int64(988169623, 1516129515), new $Int64(1827305493, 1547420459), new $Int64(1311333971, 1470949486), new $Int64(194013850, 1336785672), new $Int64(2102397034, 4131677129), new $Int64(755205548, 4246329084), new $Int64(1004983461, 3788585631), new $Int64(2081005363, 3080389532), new $Int64(1501045284, 2215402037), new $Int64(391002300, 1171593935), new $Int64(1408774047, 1423855166), new $Int64(1628305930, 2276716302), new $Int64(1779030508, 2068027241), new $Int64(1369359303, 3427553297), new $Int64(189241615, 3289637845), new $Int64(1057480830, 3486407650), new $Int64(634572984, 3071877822), new $Int64(1159653919, 3363620705), new $Int64(1213226718, 4159821533), new $Int64(2070861710, 1894661), new $Int64(1472989750, 1156868282), new $Int64(348271067, 776219088), new $Int64(1646054810, 2425634259), new $Int64(1716021749, 680510161), new $Int64(1573220192, 1310101429), new $Int64(1095885995, 2964454134), new $Int64(1821788136, 3467098407), new $Int64(1990672920, 2109628894), new $Int64(7834944, 1232604732), new $Int64(309412934, 3261916179), new $Int64(1699175360, 434597899), new $Int64(235436061, 1624796439), new $Int64(521080809, 3589632480), new $Int64(1198416575, 864579159), new $Int64(208735487, 1380889830), new $Int64(619206309, 2654509477), new $Int64(1419738251, 1468209306), new $Int64(403198876, 100794388), new $Int64(956062190, 2991674471), new $Int64(1938816907, 2224662036), new $Int64(1973824487, 977097250), new $Int64(1351320195, 726419512), new $Int64(1964023751, 1747974366), new $Int64(1394388465, 1556430604), new $Int64(1097991433, 1080776742), new $Int64(1761636690, 280794874), new $Int64(117767733, 919835643), new $Int64(1180474222, 3434019658), new $Int64(196069168, 2461941785), new $Int64(133215641, 3615001066), new $Int64(417204809, 3103414427), new $Int64(790056561, 3380809712), new $Int64(879802240, 2724693469), new $Int64(547796833, 598827710), new $Int64(300924196, 3452273442), new $Int64(2071705424, 649274915), new $Int64(1346182319, 2585724112), new $Int64(636549385, 3165579553), new $Int64(1185578221, 2635894283), new $Int64(2094573470, 2053289721), new $Int64(985976581, 3169337108), new $Int64(1170569632, 144717764), new $Int64(1079216270, 1383666384), new $Int64(2022678706, 681540375), new $Int64(1375448925, 537050586), new $Int64(182715304, 315246468), new $Int64(226402871, 849323088), new $Int64(1262421183, 45543944), new $Int64(1201038398, 2319052083), new $Int64(2106775454, 3613090841), new $Int64(560472520, 2992171180), new $Int64(1765620479, 2068244785), new $Int64(917538188, 4239862634), new $Int64(777927839, 3892253031), new $Int64(720683925, 958186149), new $Int64(1724185863, 1877702262), new $Int64(1357886971, 837674867), new $Int64(1837048883, 1507589294), new $Int64(1905518400, 873336795), new $Int64(267722611, 2764496274), new $Int64(341003118, 4196182374), new $Int64(1080717893, 550964545), new $Int64(818747069, 420611474), new $Int64(222653272, 204265180), new $Int64(1549974541, 1787046383), new $Int64(1215581865, 3102292318), new $Int64(418321538, 1552199393), new $Int64(1243493047, 980542004), new $Int64(267284263, 3293718720), new $Int64(1179528763, 3771917473), new $Int64(599484404, 2195808264), new $Int64(252818753, 3894702887), new $Int64(780007692, 2099949527), new $Int64(1424094358, 338442522), new $Int64(490737398, 637158004), new $Int64(419862118, 281976339), new $Int64(574970164, 3619802330), new $Int64(1715552825, 3084554784), new $Int64(882872465, 4129772886), new $Int64(43084605, 1680378557), new $Int64(525521057, 3339087776), new $Int64(1680500332, 4220317857), new $Int64(211654685, 2959322499), new $Int64(1675600481, 1488354890), new $Int64(1312620086, 3958162143), new $Int64(920972075, 2773705983), new $Int64(1876039582, 225908689), new $Int64(963748535, 908216283), new $Int64(1541787429, 3574646075), new $Int64(319760557, 1936937569), new $Int64(1519770881, 75492235), new $Int64(816689472, 1935193178), new $Int64(2142521206, 2018250883), new $Int64(455141620, 3943126022), new $Int64(1546084160, 3066544345), new $Int64(1932392669, 2793082663), new $Int64(908474287, 3297036421), new $Int64(1640597065, 2206987825), new $Int64(1594236910, 807894872), new $Int64(366158341, 766252117), new $Int64(2060649606, 3833114345), new $Int64(845619743, 1255067973), new $Int64(1201145605, 741697208), new $Int64(671241040, 2810093753), new $Int64(1109032642, 4229340371), new $Int64(1462188720, 1361684224), new $Int64(988084219, 1906263026), new $Int64(475781207, 3904421704), new $Int64(1523946520, 1769075545), new $Int64(1062308525, 2621599764), new $Int64(1279509432, 3431891480), new $Int64(404732502, 1871896503), new $Int64(128756421, 1412808876), new $Int64(1605404688, 952876175), new $Int64(1917039957, 1824438899), new $Int64(1662295856, 1005035476), new $Int64(1990909507, 527508597), new $Int64(1288873303, 3066806859), new $Int64(565995893, 3244940914), new $Int64(1257737460, 209092916), new $Int64(1899814242, 1242699167), new $Int64(1433653252, 456723774), new $Int64(1776978905, 1001252870), new $Int64(1468772157, 2026725874), new $Int64(857254202, 2137562569), new $Int64(765939740, 3183366709), new $Int64(1533887628, 2612072960), new $Int64(56977098, 1727148468), new $Int64(949899753, 3803658212), new $Int64(1883670356, 479946959), new $Int64(685713571, 1562982345), new $Int64(201241205, 1766109365), new $Int64(700596547, 3257093788), new $Int64(1962768719, 2365720207), new $Int64(93384808, 3742754173), new $Int64(1689098413, 2878193673), new $Int64(1096135042, 2174002182), new $Int64(1313222695, 3573511231), new $Int64(1392911121, 1760299077), new $Int64(771856457, 2260779833), new $Int64(1281464374, 1452805722), new $Int64(917811730, 2940011802), new $Int64(1890251082, 1886183802), new $Int64(893897673, 2514369088), new $Int64(1644345561, 3924317791), new $Int64(172616216, 500935732), new $Int64(1403501753, 676580929), new $Int64(581571365, 1184984890), new $Int64(1455515235, 1271474274), new $Int64(318728910, 3163791473), new $Int64(2051027584, 2842487377), new $Int64(1511537551, 2170968612), new $Int64(573262976, 3535856740), new $Int64(94256461, 1488599718), new $Int64(966951817, 3408913763), new $Int64(60951736, 2501050084), new $Int64(1272353200, 1639124157), new $Int64(138001144, 4088176393), new $Int64(1574896563, 3989947576), new $Int64(1982239940, 3414355209), new $Int64(1355154361, 2275136352), new $Int64(89709303, 2151835223), new $Int64(1216338715, 1654534827), new $Int64(1467562197, 377892833), new $Int64(1664767638, 660204544), new $Int64(85706799, 390828249), new $Int64(725310955, 3402783878), new $Int64(678849488, 3717936603), new $Int64(1113532086, 2211058823), new $Int64(1564224320, 2692150867), new $Int64(1952770442, 1928910388), new $Int64(788716862, 3931011137), new $Int64(1083670504, 1112701047), new $Int64(2079333076, 2452299106), new $Int64(1251318826, 2337204777), new $Int64(1774877857, 273889282), new $Int64(1798719843, 1462008793), new $Int64(2138834788, 1554494002), new $Int64(952516517, 182675323), new $Int64(548928884, 1882802136), new $Int64(589279648, 3700220025), new $Int64(381039426, 3083431543), new $Int64(1295624457, 3622207527), new $Int64(338126939, 432729309), new $Int64(480013522, 2391914317), new $Int64(297925497, 235747924), new $Int64(2120733629, 3088823825), new $Int64(1402403853, 2314658321), new $Int64(1165929723, 2957634338), new $Int64(501323675, 4117056981), new $Int64(1564699815, 1482500298), new $Int64(1406657158, 840489337), new $Int64(799522364, 3483178565), new $Int64(532129761, 2074004656), new $Int64(724246478, 3643392642), new $Int64(1482330167, 1583624461), new $Int64(1261660694, 287473085), new $Int64(1667835381, 3136843981), new $Int64(1138806821, 1266970974), new $Int64(135185781, 1998688839), new $Int64(392094735, 1492900209), new $Int64(1031326774, 1538112737), new $Int64(76914806, 2207265429), new $Int64(260686035, 963263315), new $Int64(1671145500, 2295892134), new $Int64(1068469660, 2002560897), new $Int64(1791233343, 1369254035), new $Int64(33436120, 3353312708), new $Int64(57507843, 947771099), new $Int64(201728503, 1747061399), new $Int64(1507240140, 2047354631), new $Int64(720000810, 4165367136), new $Int64(479265078, 3388864963), new $Int64(1195302398, 286492130), new $Int64(2045622690, 2795735007), new $Int64(1431753082, 3703961339), new $Int64(1999047161, 1797825479), new $Int64(1429039600, 1116589674), new $Int64(482063550, 2593309206), new $Int64(1329049334, 3404995677), new $Int64(1396904208, 3453462936), new $Int64(1014767077, 3016498634), new $Int64(75698599, 1650371545), new $Int64(1592007860, 212344364), new $Int64(1127766888, 3843932156), new $Int64(1399463792, 3573129983), new $Int64(1256901817, 665897820), new $Int64(1071492673, 1675628772), new $Int64(243225682, 2831752928), new $Int64(2120298836, 1486294219), new $Int64(193076235, 268782709), new $Int64(1145360145, 4186179080), new $Int64(624342951, 1613720397), new $Int64(857179861, 2703686015), new $Int64(1235864944, 2205342611), new $Int64(1474779655, 1411666394), new $Int64(619028749, 677744900), new $Int64(270855115, 4172867247), new $Int64(135494707, 2163418403), new $Int64(849547544, 2841526879), new $Int64(1029966689, 1082141470), new $Int64(377371856, 4046134367), new $Int64(51415528, 2142943655), new $Int64(1897659315, 3124627521), new $Int64(998228909, 219992939), new $Int64(1068692697, 1756846531), new $Int64(1283749206, 1225118210), new $Int64(1621625642, 1647770243), new $Int64(111523943, 444807907), new $Int64(2036369448, 3952076173), new $Int64(53201823, 1461839639), new $Int64(315761893, 3699250910), new $Int64(702974850, 1373688981), new $Int64(734022261, 147523747), new $Int64(100152742, 1211276581), new $Int64(1294440951, 2548832680), new $Int64(1144696256, 1995631888), new $Int64(154500578, 2011457303), new $Int64(796460974, 3057425772), new $Int64(667839456, 81484597), new $Int64(465502760, 3646681560), new $Int64(775020923, 635548515), new $Int64(602489502, 2508044581), new $Int64(353263531, 1014917157), new $Int64(719992433, 3214891315), new $Int64(852684611, 959582252), new $Int64(226415134, 3347040449), new $Int64(1784615552, 4102971975), new $Int64(397887437, 4078022210), new $Int64(1610679822, 2851767182), new $Int64(749162636, 1540160644), new $Int64(598384772, 1057290595), new $Int64(2034890660, 3907769253), new $Int64(579300318, 4248952684), new $Int64(1092907599, 132554364), new $Int64(1061621234, 1029351092), new $Int64(697840928, 2583007416), new $Int64(298619124, 1486185789), new $Int64(55905697, 2871589073), new $Int64(2017643612, 723203291), new $Int64(146250550, 2494333952), new $Int64(1064490251, 2230939180), new $Int64(342915576, 3943232912), new $Int64(1768732449, 2181367922), new $Int64(1418222537, 2889274791), new $Int64(1824032949, 2046728161), new $Int64(1653899792, 1376052477), new $Int64(1022327048, 381236993), new $Int64(1034385958, 3188942166), new $Int64(2073003539, 350070824), new $Int64(144881592, 61758415), new $Int64(1405659422, 3492950336), new $Int64(117440928, 3093818430), new $Int64(1693893113, 2962480613), new $Int64(235432940, 3154871160), new $Int64(511005079, 3228564679), new $Int64(610731502, 888276216), new $Int64(1200780674, 3574998604), new $Int64(870415268, 1967526716), new $Int64(591335707, 1554691298), new $Int64(574459414, 339944798), new $Int64(1223764147, 1154515356), new $Int64(1825645307, 967516237), new $Int64(1546195135, 596588202), new $Int64(279882768, 3764362170), new $Int64(492091056, 266611402), new $Int64(1754227768, 2047856075), new $Int64(1146757215, 21444105), new $Int64(1198058894, 3065563181), new $Int64(1915064845, 1140663212), new $Int64(633187674, 2323741028), new $Int64(2126290159, 3103873707), new $Int64(1008658319, 2766828349), new $Int64(1661896145, 1970872996), new $Int64(1628585413, 3766615585), new $Int64(1552335120, 2036813414), new $Int64(152606527, 3105536507), new $Int64(13954645, 3396176938), new $Int64(1426081645, 1377154485), new $Int64(2085644467, 3807014186), new $Int64(543009040, 3710110597), new $Int64(396058129, 916420443), new $Int64(734556788, 2103831255), new $Int64(381322154, 717331943), new $Int64(572884752, 3550505941), new $Int64(45939673, 378749927), new $Int64(149867929, 611017331), new $Int64(592130075, 758907650), new $Int64(1012992349, 154266815), new $Int64(1107028706, 1407468696), new $Int64(469292398, 970098704), new $Int64(1862426162, 1971660656), new $Int64(998365243, 3332747885), new $Int64(1947089649, 1935189867), new $Int64(1510248801, 203520055), new $Int64(842317902, 3916463034), new $Int64(1758884993, 3474113316), new $Int64(1036101639, 316544223), new $Int64(373738757, 1650844677), new $Int64(1240292229, 4267565603), new $Int64(1077208624, 2501167616), new $Int64(626831785, 3929401789), new $Int64(56122796, 337170252), new $Int64(1186981558, 2061966842), new $Int64(1843292800, 2508461464), new $Int64(206012532, 2791377107), new $Int64(1240791848, 1227227588), new $Int64(1813978778, 1709681848), new $Int64(1153692192, 3768820575), new $Int64(1145186199, 2887126398), new $Int64(700372314, 296561685), new $Int64(700300844, 3729960077), new $Int64(575172304, 372833036), new $Int64(2078875613, 2409779288), new $Int64(1829161290, 555274064), new $Int64(1041887929, 4239804901), new $Int64(1839403216, 3723486978), new $Int64(498390553, 2145871984), new $Int64(564717933, 3565480803), new $Int64(578829821, 2197313814), new $Int64(974785092, 3613674566), new $Int64(438638731, 3042093666), new $Int64(2050927384, 3324034321), new $Int64(869420878, 3708873369), new $Int64(946682149, 1698090092), new $Int64(1618900382, 4213940712), new $Int64(304003901, 2087477361), new $Int64(381315848, 2407950639), new $Int64(851258090, 3942568569), new $Int64(923583198, 4088074412), new $Int64(723260036, 2964773675), new $Int64(1473561819, 1539178386), new $Int64(1062961552, 2694849566), new $Int64(460977733, 2120273838), new $Int64(542912908, 2484608657), new $Int64(880846449, 2956190677), new $Int64(1970902366, 4223313749), new $Int64(662161910, 3502682327), new $Int64(705634754, 4133891139), new $Int64(1116124348, 1166449596), new $Int64(1038247601, 3362705993), new $Int64(93734798, 3892921029), new $Int64(1876124043, 786869787), new $Int64(1057490746, 1046342263), new $Int64(242763728, 493777327), new $Int64(1293910447, 3304827646), new $Int64(616460742, 125356352), new $Int64(499300063, 74094113), new $Int64(1351896723, 2500816079), new $Int64(1657235204, 514015239), new $Int64(1377565129, 543520454), new $Int64(107706923, 3614531153), new $Int64(2056746300, 2356753985), new $Int64(1390062617, 2018141668), new $Int64(131272971, 2087974891), new $Int64(644556607, 3166972343), new $Int64(372256200, 1517638666), new $Int64(1212207984, 173466846), new $Int64(1451709187, 4241513471), new $Int64(733932806, 2783126920), new $Int64(1972004134, 4167264826), new $Int64(29260506, 3907395640), new $Int64(1236582087, 1539634186), new $Int64(1551526350, 178241987), new $Int64(2034206012, 182168164), new $Int64(1044953189, 2386154934), new $Int64(1379126408, 4077374341), new $Int64(32803926, 1732699140), new $Int64(1726425903, 1041306002), new $Int64(1860414813, 2068001749), new $Int64(1005320202, 3208962910), new $Int64(844054010, 697710380), new $Int64(638124245, 2228431183), new $Int64(1337169671, 3554678728), new $Int64(1396494601, 173470263), new $Int64(2061597383, 3848297795), new $Int64(1220546671, 246236185), new $Int64(163293187, 2066374846), new $Int64(1771673660, 312890749), new $Int64(703378057, 3573310289), new $Int64(1548631747, 143166754), new $Int64(613554316, 2081511079), new $Int64(1197802104, 486038032), new $Int64(240999859, 2982218564), new $Int64(364901986, 1000939191), new $Int64(1902782651, 2750454885), new $Int64(1475638791, 3375313137), new $Int64(503615608, 881302957), new $Int64(638698903, 2514186393), new $Int64(443860803, 360024739), new $Int64(1399671872, 292500025), new $Int64(1381210821, 2276300752), new $Int64(521803381, 4069087683), new $Int64(208500981, 1637778212), new $Int64(720490469, 1676670893), new $Int64(1067262482, 3855174429), new $Int64(2114075974, 2067248671), new $Int64(2058057389, 2884561259), new $Int64(1341742553, 2456511185), new $Int64(983726246, 561175414), new $Int64(427994085, 432588903), new $Int64(885133709, 4059399550), new $Int64(2054387382, 1075014784), new $Int64(413651020, 2728058415), new $Int64(1839142064, 1299703678), new $Int64(1262333188, 2347583393), new $Int64(1285481956, 2468164145), new $Int64(989129637, 1140014346), new $Int64(2033889184, 1936972070), new $Int64(409904655, 3870530098), new $Int64(1662989391, 1717789158), new $Int64(1914486492, 1153452491), new $Int64(1157059232, 3948827651), new $Int64(790338018, 2101413152), new $Int64(1495744672, 3854091229), new $Int64(83644069, 4215565463), new $Int64(762206335, 1202710438), new $Int64(1582574611, 2072216740), new $Int64(705690639, 2066751068), new $Int64(33900336, 173902580), new $Int64(1405499842, 142459001), new $Int64(172391592, 1889151926), new $Int64(1648540523, 3034199774), new $Int64(1618587731, 516490102), new $Int64(93114264, 3692577783), new $Int64(68662295, 2953948865), new $Int64(1826544975, 4041040923), new $Int64(204965672, 592046130), new $Int64(1441840008, 384297211), new $Int64(95834184, 265863924), new $Int64(2101717619, 1333136237), new $Int64(1499611781, 1406273556), new $Int64(1074670496, 426305476), new $Int64(125704633, 2750898176), new $Int64(488068495, 1633944332), new $Int64(2037723464, 3236349343), new $Int64(444060402, 4013676611), new $Int64(1718532237, 2265047407), new $Int64(1433593806, 875071080), new $Int64(1804436145, 1418843655), new $Int64(2009228711, 451657300), new $Int64(1229446621, 1866374663), new $Int64(1653472867, 1551455622), new $Int64(577191481, 3560962459), new $Int64(1669204077, 3347903778), new $Int64(1849156454, 2675874918), new $Int64(316128071, 2762991672), new $Int64(530492383, 3689068477), new $Int64(844089962, 4071997905), new $Int64(1508155730, 1381702441), new $Int64(2089931018, 2373284878), new $Int64(1283216186, 2143983064), new $Int64(308739063, 1938207195), new $Int64(1754949306, 1188152253), new $Int64(1272345009, 615870490), new $Int64(742653194, 2662252621), new $Int64(1477718295, 3839976789), new $Int64(56149435, 306752547), new $Int64(720795581, 2162363077), new $Int64(2090431015, 2767224719), new $Int64(675859549, 2628837712), new $Int64(1678405918, 2967771969), new $Int64(1694285728, 499792248), new $Int64(403352367, 4285253508), new $Int64(962357072, 2856511070), new $Int64(679471692, 2526409716), new $Int64(353777175, 1240875658), new $Int64(1232590226, 2577342868), new $Int64(1146185433, 4136853496), new $Int64(670368674, 2403540137), new $Int64(1372824515, 1371410668), new $Int64(1970921600, 371758825), new $Int64(1706420536, 1528834084), new $Int64(2075795018, 1504757260), new $Int64(685663576, 699052551), new $Int64(1641940109, 3347789870), new $Int64(1951619734, 3430604759), new $Int64(2119672219, 1935601723), new $Int64(966789690, 834676166)]); + globalRand = New(new lockedSource.Ptr(new sync.Mutex.Ptr(), NewSource(new $Int64(0, 1)))); }; - $ptrType(CommentMap).prototype.Filter = function(node) { return new CommentMap(this.$get()).Filter(node); }; - CommentMap.prototype.Comments = function() { - var cmap, list, _ref, _i, _keys, _entry, e; - cmap = this.$val !== undefined ? this.$val : this; - list = ($sliceType(($ptrType(CommentGroup)))).make(0, $keys(cmap).length); - _ref = cmap; - _i = 0; - _keys = $keys(_ref); - while (_i < _keys.length) { - _entry = _ref[_keys[_i]]; - if (_entry === undefined) { - _i++; - continue; - } - e = _entry.v; - list = $appendSlice(list, e); - _i++; + return $pkg; +})(); +$packages["math/big"] = (function() { + var $pkg = {}, errors = $packages["errors"], fmt = $packages["fmt"], io = $packages["io"], rand = $packages["math/rand"], strings = $packages["strings"], math = $packages["math"], sync = $packages["sync"], binary = $packages["encoding/binary"], Word, Int, nat, divisor, Rat, intOne, natOne, natTwo, natTen, karatsubaThreshold, leafSize, cacheBase10, deBruijn32Lookup, deBruijn64Lookup, mulWW, divWW, addVV, subVV, addVW, subVW, shlVU, shrVU, mulAddVWW, addMulVVW, divWVW, bitLen, addWW_g, subWW_g, mulWW_g, mulAddWWW_g, bitLen_g, leadingZeros, divWW_g, addVV_g, subVV_g, addVW_g, subVW_g, shlVU_g, shrVU_g, mulAddVWW_g, addMulVVW_g, divWVW_g, NewInt, charset, writeMultiple, basicMul, karatsubaAdd, karatsubaSub, karatsuba, alias, addAt, max, karatsubaLen, hexValue, divisors, trailingZeroBits, greaterThan, NewRat, low64, quotToFloat, mulDenom, scaleDenom, ratTok; + Word = $pkg.Word = $newType(4, "Uintptr", "big.Word", "Word", "math/big", null); + Int = $pkg.Int = $newType(0, "Struct", "big.Int", "Int", "math/big", function(neg_, abs_) { + this.$val = this; + this.neg = neg_ !== undefined ? neg_ : false; + this.abs = abs_ !== undefined ? abs_ : nat.nil; + }); + nat = $pkg.nat = $newType(12, "Slice", "big.nat", "nat", "math/big", null); + divisor = $pkg.divisor = $newType(0, "Struct", "big.divisor", "divisor", "math/big", function(bbb_, nbits_, ndigits_) { + this.$val = this; + this.bbb = bbb_ !== undefined ? bbb_ : nat.nil; + this.nbits = nbits_ !== undefined ? nbits_ : 0; + this.ndigits = ndigits_ !== undefined ? ndigits_ : 0; + }); + Rat = $pkg.Rat = $newType(0, "Struct", "big.Rat", "Rat", "math/big", function(a_, b_) { + this.$val = this; + this.a = a_ !== undefined ? a_ : new Int.Ptr(); + this.b = b_ !== undefined ? b_ : new Int.Ptr(); + }); + mulWW = function(x, y) { + var z1 = 0, z0 = 0, _tuple; + _tuple = mulWW_g(x, y); z1 = _tuple[0]; z0 = _tuple[1]; + return [z1, z0]; + }; + divWW = function(x1, x0, y) { + var q = 0, r = 0, _tuple; + _tuple = divWW_g(x1, x0, y); q = _tuple[0]; r = _tuple[1]; + return [q, r]; + }; + addVV = function(z, x, y) { + var c = 0; + c = addVV_g(z, x, y); + return c; + }; + subVV = function(z, x, y) { + var c = 0; + c = subVV_g(z, x, y); + return c; + }; + addVW = function(z, x, y) { + var c = 0; + c = addVW_g(z, x, y); + return c; + }; + subVW = function(z, x, y) { + var c = 0; + c = subVW_g(z, x, y); + return c; + }; + shlVU = function(z, x, s) { + var c = 0; + c = shlVU_g(z, x, s); + return c; + }; + shrVU = function(z, x, s) { + var c = 0; + c = shrVU_g(z, x, s); + return c; + }; + mulAddVWW = function(z, x, y, r) { + var c = 0; + c = mulAddVWW_g(z, x, y, r); + return c; + }; + addMulVVW = function(z, x, y) { + var c = 0; + c = addMulVVW_g(z, x, y); + return c; + }; + divWVW = function(z, xn, x, y) { + var r = 0; + r = divWVW_g(z, xn, x, y); + return r; + }; + bitLen = function(x) { + var n = 0; + n = bitLen_g(x); + return n; + }; + addWW_g = function(x, y, c) { + var z1 = 0, z0 = 0, yc; + yc = y + c >>> 0; + z0 = x + yc >>> 0; + if (z0 < x || yc < y) { + z1 = 1; } - sortComments(list); - return list; + return [z1, z0]; }; - $ptrType(CommentMap).prototype.Comments = function() { return new CommentMap(this.$get()).Comments(); }; - summary = function(list) { - var buf, _ref, _i, group, _ref$1, _i$1, comment, bytes$1, _ref$2, _i$2, i, b, _ref$3; - buf = new bytes.Buffer.Ptr(); $copy(buf, new bytes.Buffer.Ptr(), bytes.Buffer); - _ref = list; - _i = 0; - loop: - while (_i < _ref.$length) { - group = ((_i < 0 || _i >= _ref.$length) ? $throwRuntimeError("index out of range") : _ref.$array[_ref.$offset + _i]); - _ref$1 = group.List; - _i$1 = 0; - while (_i$1 < _ref$1.$length) { - comment = ((_i$1 < 0 || _i$1 >= _ref$1.$length) ? $throwRuntimeError("index out of range") : _ref$1.$array[_ref$1.$offset + _i$1]); - if (buf.Len() >= 40) { - break loop; - } - buf.WriteString(comment.Text); - _i$1++; - } - _i++; + subWW_g = function(x, y, c) { + var z1 = 0, z0 = 0, yc; + yc = y + c >>> 0; + z0 = x - yc >>> 0; + if (z0 > x || yc < y) { + z1 = 1; } - if (buf.Len() > 40) { - buf.Truncate(37); - buf.WriteString("..."); + return [z1, z0]; + }; + mulWW_g = function(x, y) { + var z1 = 0, z0 = 0, x0, x1, y0, y1, w0, t, w1, w2; + x0 = (x & 65535) >>> 0; + x1 = x >>> 16 >>> 0; + y0 = (y & 65535) >>> 0; + y1 = y >>> 16 >>> 0; + w0 = (((x0 >>> 16 << 16) * y0 >>> 0) + (x0 << 16 >>> 16) * y0) >>> 0; + t = ((((x1 >>> 16 << 16) * y0 >>> 0) + (x1 << 16 >>> 16) * y0) >>> 0) + (w0 >>> 16 >>> 0) >>> 0; + w1 = (t & 65535) >>> 0; + w2 = t >>> 16 >>> 0; + w1 = w1 + (((((x0 >>> 16 << 16) * y1 >>> 0) + (x0 << 16 >>> 16) * y1) >>> 0)) >>> 0; + z1 = (((((x1 >>> 16 << 16) * y1 >>> 0) + (x1 << 16 >>> 16) * y1) >>> 0) + w2 >>> 0) + (w1 >>> 16 >>> 0) >>> 0; + z0 = (((x >>> 16 << 16) * y >>> 0) + (x << 16 >>> 16) * y) >>> 0; + return [z1, z0]; + }; + mulAddWWW_g = function(x, y, c) { + var z1 = 0, z0 = 0, _tuple, zz0; + _tuple = mulWW(x, y); z1 = _tuple[0]; zz0 = _tuple[1]; + z0 = zz0 + c >>> 0; + if (z0 < zz0) { + z1 = z1 + (1) >>> 0; } - bytes$1 = buf.Bytes(); - _ref$2 = bytes$1; - _i$2 = 0; - while (_i$2 < _ref$2.$length) { - i = _i$2; - b = ((_i$2 < 0 || _i$2 >= _ref$2.$length) ? $throwRuntimeError("index out of range") : _ref$2.$array[_ref$2.$offset + _i$2]); - _ref$3 = b; - if (_ref$3 === 9 || _ref$3 === 10 || _ref$3 === 13) { - (i < 0 || i >= bytes$1.$length) ? $throwRuntimeError("index out of range") : bytes$1.$array[bytes$1.$offset + i] = 32; - } - _i$2++; + return [z1, z0]; + }; + bitLen_g = function(x) { + var n = 0, y, y$1, y$2, y$3; + while (x >= 32768) { + n = n + (16) >> 0; + x = (y = (16), y < 32 ? (x >>> y) : 0) >>> 0; } - return $bytesToString(bytes$1); + if (x >= 128) { + x = (y$1 = (8), y$1 < 32 ? (x >>> y$1) : 0) >>> 0; + n = n + (8) >> 0; + } + if (x >= 8) { + x = (y$2 = (4), y$2 < 32 ? (x >>> y$2) : 0) >>> 0; + n = n + (4) >> 0; + } + if (x >= 2) { + x = (y$3 = (2), y$3 < 32 ? (x >>> y$3) : 0) >>> 0; + n = n + (2) >> 0; + } + if (x >= 1) { + n = n + (1) >> 0; + } + return n; }; - CommentMap.prototype.String = function() { - var cmap, buf, _ref, _i, _keys, _entry, node, comment, s, _tuple, ident, ok; - cmap = this.$val !== undefined ? this.$val : this; - buf = new bytes.Buffer.Ptr(); $copy(buf, new bytes.Buffer.Ptr(), bytes.Buffer); - fmt.Fprintln(buf, new ($sliceType($emptyInterface))([new $String("CommentMap {")])); - _ref = cmap; - _i = 0; - _keys = $keys(_ref); - while (_i < _keys.length) { - _entry = _ref[_keys[_i]]; - if (_entry === undefined) { - _i++; - continue; + leadingZeros = function(x) { + return ((32 - bitLen(x) >> 0) >>> 0); + }; + divWW_g = function(u1, u0, v) { + var q = 0, r = 0, _tmp, _tmp$1, s, y, vn1, vn0, y$1, y$2, un32, y$3, un10, un1, un0, _q, q1, rhat, un21, _q$1, q0, _tmp$2, _tmp$3, y$4; + if (u1 >= v) { + _tmp = 4294967295; _tmp$1 = 4294967295; q = _tmp; r = _tmp$1; + return [q, r]; + } + s = leadingZeros(v); + v = (y = (s), y < 32 ? (v << y) : 0) >>> 0; + vn1 = v >>> 16 >>> 0; + vn0 = (v & 65535) >>> 0; + un32 = (((y$1 = s, y$1 < 32 ? (u1 << y$1) : 0) >>> 0) | ((y$2 = ((32 - s >>> 0)), y$2 < 32 ? (u0 >>> y$2) : 0) >>> 0)) >>> 0; + un10 = (y$3 = s, y$3 < 32 ? (u0 << y$3) : 0) >>> 0; + un1 = un10 >>> 16 >>> 0; + un0 = (un10 & 65535) >>> 0; + q1 = (_q = un32 / vn1, (_q === _q && _q !== 1/0 && _q !== -1/0) ? _q >>> 0 : $throwRuntimeError("integer divide by zero")); + rhat = un32 - ((((q1 >>> 16 << 16) * vn1 >>> 0) + (q1 << 16 >>> 16) * vn1) >>> 0) >>> 0; + while (q1 >= 65536 || ((((q1 >>> 16 << 16) * vn0 >>> 0) + (q1 << 16 >>> 16) * vn0) >>> 0) > (((((65536 >>> 16 << 16) * rhat >>> 0) + (65536 << 16 >>> 16) * rhat) >>> 0) + un1 >>> 0)) { + q1 = q1 - (1) >>> 0; + rhat = rhat + (vn1) >>> 0; + if (rhat >= 65536) { + break; } - node = _entry.k; - comment = _entry.v; - s = ""; - _tuple = $assertType(node, ($ptrType(Ident)), true); ident = _tuple[0]; ok = _tuple[1]; - if (ok) { - s = ident.Name; - } else { - s = fmt.Sprintf("%T", new ($sliceType($emptyInterface))([node])); + } + un21 = (((((un32 >>> 16 << 16) * 65536 >>> 0) + (un32 << 16 >>> 16) * 65536) >>> 0) + un1 >>> 0) - ((((q1 >>> 16 << 16) * v >>> 0) + (q1 << 16 >>> 16) * v) >>> 0) >>> 0; + q0 = (_q$1 = un21 / vn1, (_q$1 === _q$1 && _q$1 !== 1/0 && _q$1 !== -1/0) ? _q$1 >>> 0 : $throwRuntimeError("integer divide by zero")); + rhat = un21 - ((((q0 >>> 16 << 16) * vn1 >>> 0) + (q0 << 16 >>> 16) * vn1) >>> 0) >>> 0; + while (q0 >= 65536 || ((((q0 >>> 16 << 16) * vn0 >>> 0) + (q0 << 16 >>> 16) * vn0) >>> 0) > (((((65536 >>> 16 << 16) * rhat >>> 0) + (65536 << 16 >>> 16) * rhat) >>> 0) + un0 >>> 0)) { + q0 = q0 - (1) >>> 0; + rhat = rhat + (vn1) >>> 0; + if (rhat >= 65536) { + break; } - fmt.Fprintf(buf, "\t%p %20s: %s\n", new ($sliceType($emptyInterface))([node, new $String(s), new $String(summary(comment))])); + } + _tmp$2 = ((((q1 >>> 16 << 16) * 65536 >>> 0) + (q1 << 16 >>> 16) * 65536) >>> 0) + q0 >>> 0; _tmp$3 = (y$4 = s, y$4 < 32 ? ((((((((un21 >>> 16 << 16) * 65536 >>> 0) + (un21 << 16 >>> 16) * 65536) >>> 0) + un0 >>> 0) - ((((q0 >>> 16 << 16) * v >>> 0) + (q0 << 16 >>> 16) * v) >>> 0) >>> 0)) >>> y$4) : 0) >>> 0; q = _tmp$2; r = _tmp$3; + return [q, r]; + }; + addVV_g = function(z, x, y) { + var c = 0, _ref, _i, i, _tuple; + _ref = z; + _i = 0; + while (_i < _ref.$length) { + i = _i; + _tuple = addWW_g(((i < 0 || i >= x.$length) ? $throwRuntimeError("index out of range") : x.$array[x.$offset + i]), ((i < 0 || i >= y.$length) ? $throwRuntimeError("index out of range") : y.$array[y.$offset + i]), c); c = _tuple[0]; (i < 0 || i >= z.$length) ? $throwRuntimeError("index out of range") : z.$array[z.$offset + i] = _tuple[1]; _i++; } - fmt.Fprintln(buf, new ($sliceType($emptyInterface))([new $String("}")])); - return buf.String(); + return c; }; - $ptrType(CommentMap).prototype.String = function() { return new CommentMap(this.$get()).String(); }; - SortImports = $pkg.SortImports = function(fset, f) { - var _ref, _i, d, _tuple, d$1, ok, i, specs, _ref$1, _i$1, j, s, x, x$1, x$2, x$3, lastSpec, lastLine, rParenLine; - _ref = f.Decls; + subVV_g = function(z, x, y) { + var c = 0, _ref, _i, i, _tuple; + _ref = z; _i = 0; while (_i < _ref.$length) { - d = ((_i < 0 || _i >= _ref.$length) ? $throwRuntimeError("index out of range") : _ref.$array[_ref.$offset + _i]); - _tuple = $assertType(d, ($ptrType(GenDecl)), true); d$1 = _tuple[0]; ok = _tuple[1]; - if (!ok || !((d$1.Tok === 75))) { - break; - } - if (!(new token.Pos(d$1.Lparen)).IsValid()) { - _i++; - continue; - } - i = 0; - specs = $subslice(d$1.Specs, 0, 0); - _ref$1 = d$1.Specs; - _i$1 = 0; - while (_i$1 < _ref$1.$length) { - j = _i$1; - s = ((_i$1 < 0 || _i$1 >= _ref$1.$length) ? $throwRuntimeError("index out of range") : _ref$1.$array[_ref$1.$offset + _i$1]); - if (j > i && fset.Position(s.Pos()).Line > (1 + fset.Position((x = d$1.Specs, x$1 = j - 1 >> 0, ((x$1 < 0 || x$1 >= x.$length) ? $throwRuntimeError("index out of range") : x.$array[x.$offset + x$1])).End()).Line >> 0)) { - specs = $appendSlice(specs, sortSpecs(fset, f, $subslice(d$1.Specs, i, j))); - i = j; - } - _i$1++; - } - specs = $appendSlice(specs, sortSpecs(fset, f, $subslice(d$1.Specs, i))); - d$1.Specs = specs; - if (d$1.Specs.$length > 0) { - lastSpec = (x$2 = d$1.Specs, x$3 = d$1.Specs.$length - 1 >> 0, ((x$3 < 0 || x$3 >= x$2.$length) ? $throwRuntimeError("index out of range") : x$2.$array[x$2.$offset + x$3])); - lastLine = fset.Position(lastSpec.Pos()).Line; - rParenLine = fset.Position(d$1.Rparen).Line; - if (rParenLine > (lastLine + 1 >> 0)) { - fset.File(d$1.Rparen).MergeLine(rParenLine - 1 >> 0); - } - } + i = _i; + _tuple = subWW_g(((i < 0 || i >= x.$length) ? $throwRuntimeError("index out of range") : x.$array[x.$offset + i]), ((i < 0 || i >= y.$length) ? $throwRuntimeError("index out of range") : y.$array[y.$offset + i]), c); c = _tuple[0]; (i < 0 || i >= z.$length) ? $throwRuntimeError("index out of range") : z.$array[z.$offset + i] = _tuple[1]; _i++; } + return c; }; - importPath = function(s) { - var _tuple, t, err; - _tuple = strconv.Unquote($assertType(s, ($ptrType(ImportSpec))).Path.Value); t = _tuple[0]; err = _tuple[1]; - if ($interfaceIsEqual(err, $ifaceNil)) { - return t; + addVW_g = function(z, x, y) { + var c = 0, _ref, _i, i, _tuple; + c = y; + _ref = z; + _i = 0; + while (_i < _ref.$length) { + i = _i; + _tuple = addWW_g(((i < 0 || i >= x.$length) ? $throwRuntimeError("index out of range") : x.$array[x.$offset + i]), c, 0); c = _tuple[0]; (i < 0 || i >= z.$length) ? $throwRuntimeError("index out of range") : z.$array[z.$offset + i] = _tuple[1]; + _i++; } - return ""; + return c; }; - importName = function(s) { - var n; - n = $assertType(s, ($ptrType(ImportSpec))).Name; - if (n === ($ptrType(Ident)).nil) { - return ""; + subVW_g = function(z, x, y) { + var c = 0, _ref, _i, i, _tuple; + c = y; + _ref = z; + _i = 0; + while (_i < _ref.$length) { + i = _i; + _tuple = subWW_g(((i < 0 || i >= x.$length) ? $throwRuntimeError("index out of range") : x.$array[x.$offset + i]), c, 0); c = _tuple[0]; (i < 0 || i >= z.$length) ? $throwRuntimeError("index out of range") : z.$array[z.$offset + i] = _tuple[1]; + _i++; } - return n.Name; + return c; }; - importComment = function(s) { - var c; - c = $assertType(s, ($ptrType(ImportSpec))).Comment; - if (c === ($ptrType(CommentGroup)).nil) { - return ""; + shlVU_g = function(z, x, s) { + var c = 0, n, nonAsciiName, x$1, w1, y, i, w, x$2, y$1, y$2, y$3; + n = z.$length; + if (n > 0) { + nonAsciiName = 32 - s >>> 0; + w1 = (x$1 = n - 1 >> 0, ((x$1 < 0 || x$1 >= x.$length) ? $throwRuntimeError("index out of range") : x.$array[x.$offset + x$1])); + c = (y = nonAsciiName, y < 32 ? (w1 >>> y) : 0) >>> 0; + i = n - 1 >> 0; + while (i > 0) { + w = w1; + w1 = (x$2 = i - 1 >> 0, ((x$2 < 0 || x$2 >= x.$length) ? $throwRuntimeError("index out of range") : x.$array[x.$offset + x$2])); + (i < 0 || i >= z.$length) ? $throwRuntimeError("index out of range") : z.$array[z.$offset + i] = (((y$1 = s, y$1 < 32 ? (w << y$1) : 0) >>> 0) | ((y$2 = nonAsciiName, y$2 < 32 ? (w1 >>> y$2) : 0) >>> 0)) >>> 0; + i = i - (1) >> 0; + } + (0 < 0 || 0 >= z.$length) ? $throwRuntimeError("index out of range") : z.$array[z.$offset + 0] = (y$3 = s, y$3 < 32 ? (w1 << y$3) : 0) >>> 0; } - return c.Text(); + return c; }; - collapse = function(prev, next) { - if (!(importPath(next) === importPath(prev)) || !(importName(next) === importName(prev))) { - return false; + shrVU_g = function(z, x, s) { + var c = 0, n, nonAsciiName, w1, y, i, w, x$1, y$1, y$2, y$3, x$2; + n = z.$length; + if (n > 0) { + nonAsciiName = 32 - s >>> 0; + w1 = ((0 < 0 || 0 >= x.$length) ? $throwRuntimeError("index out of range") : x.$array[x.$offset + 0]); + c = (y = nonAsciiName, y < 32 ? (w1 << y) : 0) >>> 0; + i = 0; + while (i < (n - 1 >> 0)) { + w = w1; + w1 = (x$1 = i + 1 >> 0, ((x$1 < 0 || x$1 >= x.$length) ? $throwRuntimeError("index out of range") : x.$array[x.$offset + x$1])); + (i < 0 || i >= z.$length) ? $throwRuntimeError("index out of range") : z.$array[z.$offset + i] = (((y$1 = s, y$1 < 32 ? (w >>> y$1) : 0) >>> 0) | ((y$2 = nonAsciiName, y$2 < 32 ? (w1 << y$2) : 0) >>> 0)) >>> 0; + i = i + (1) >> 0; + } + (x$2 = n - 1 >> 0, (x$2 < 0 || x$2 >= z.$length) ? $throwRuntimeError("index out of range") : z.$array[z.$offset + x$2] = (y$3 = s, y$3 < 32 ? (w1 >>> y$3) : 0) >>> 0); } - return $assertType(prev, ($ptrType(ImportSpec))).Comment === ($ptrType(CommentGroup)).nil; + return c; }; - sortSpecs = function(fset, f, specs) { - var pos, _ref, _i, i, s, x, lastLine, cstart, cend, _ref$1, _i$1, i$1, g, comments, importComment$1, _map, _key, specIndex, _ref$2, _i$2, g$1, x$1, s$1, _entry, _key$1, deduped, _ref$3, _i$3, i$2, s$2, x$2, p, _ref$4, _i$4, i$3, s$3, s$4, _ref$5, _entry$1, _i$5, g$2, _ref$6, _i$6, c; - if (specs.$length <= 1) { - return specs; + mulAddVWW_g = function(z, x, y, r) { + var c = 0, _ref, _i, i, _tuple; + c = r; + _ref = z; + _i = 0; + while (_i < _ref.$length) { + i = _i; + _tuple = mulAddWWW_g(((i < 0 || i >= x.$length) ? $throwRuntimeError("index out of range") : x.$array[x.$offset + i]), y, c); c = _tuple[0]; (i < 0 || i >= z.$length) ? $throwRuntimeError("index out of range") : z.$array[z.$offset + i] = _tuple[1]; + _i++; } - pos = ($sliceType(posSpan)).make(specs.$length); - _ref = specs; + return c; + }; + addMulVVW_g = function(z, x, y) { + var c = 0, _ref, _i, i, _tuple, z1, z0, _tuple$1; + _ref = z; _i = 0; while (_i < _ref.$length) { i = _i; - s = ((_i < 0 || _i >= _ref.$length) ? $throwRuntimeError("index out of range") : _ref.$array[_ref.$offset + _i]); - $copy(((i < 0 || i >= pos.$length) ? $throwRuntimeError("index out of range") : pos.$array[pos.$offset + i]), new posSpan.Ptr(s.Pos(), s.End()), posSpan); + _tuple = mulAddWWW_g(((i < 0 || i >= x.$length) ? $throwRuntimeError("index out of range") : x.$array[x.$offset + i]), y, ((i < 0 || i >= z.$length) ? $throwRuntimeError("index out of range") : z.$array[z.$offset + i])); z1 = _tuple[0]; z0 = _tuple[1]; + _tuple$1 = addWW_g(z0, c, 0); c = _tuple$1[0]; (i < 0 || i >= z.$length) ? $throwRuntimeError("index out of range") : z.$array[z.$offset + i] = _tuple$1[1]; + c = c + (z1) >>> 0; _i++; } - lastLine = fset.Position((x = pos.$length - 1 >> 0, ((x < 0 || x >= pos.$length) ? $throwRuntimeError("index out of range") : pos.$array[pos.$offset + x])).End).Line; - cstart = f.Comments.$length; - cend = f.Comments.$length; - _ref$1 = f.Comments; - _i$1 = 0; - while (_i$1 < _ref$1.$length) { - i$1 = _i$1; - g = ((_i$1 < 0 || _i$1 >= _ref$1.$length) ? $throwRuntimeError("index out of range") : _ref$1.$array[_ref$1.$offset + _i$1]); - if (g.Pos() < ((0 < 0 || 0 >= pos.$length) ? $throwRuntimeError("index out of range") : pos.$array[pos.$offset + 0]).Start) { - _i$1++; - continue; - } - if (i$1 < cstart) { - cstart = i$1; - } - if (fset.Position(g.End()).Line > lastLine) { - cend = i$1; - break; - } - _i$1++; + return c; + }; + divWVW_g = function(z, xn, x, y) { + var r = 0, i, _tuple; + r = xn; + i = z.$length - 1 >> 0; + while (i >= 0) { + _tuple = divWW_g(r, ((i < 0 || i >= x.$length) ? $throwRuntimeError("index out of range") : x.$array[x.$offset + i]), y); (i < 0 || i >= z.$length) ? $throwRuntimeError("index out of range") : z.$array[z.$offset + i] = _tuple[0]; r = _tuple[1]; + i = i - (1) >> 0; } - comments = $subslice(f.Comments, cstart, cend); - importComment$1 = (_map = new $Map(), _map); - specIndex = 0; - _ref$2 = comments; - _i$2 = 0; - while (_i$2 < _ref$2.$length) { - g$1 = ((_i$2 < 0 || _i$2 >= _ref$2.$length) ? $throwRuntimeError("index out of range") : _ref$2.$array[_ref$2.$offset + _i$2]); - while ((specIndex + 1 >> 0) < specs.$length && (x$1 = specIndex + 1 >> 0, ((x$1 < 0 || x$1 >= pos.$length) ? $throwRuntimeError("index out of range") : pos.$array[pos.$offset + x$1])).Start <= g$1.Pos()) { - specIndex = specIndex + (1) >> 0; - } - s$1 = $assertType(((specIndex < 0 || specIndex >= specs.$length) ? $throwRuntimeError("index out of range") : specs.$array[specs.$offset + specIndex]), ($ptrType(ImportSpec))); - _key$1 = s$1; (importComment$1 || $throwRuntimeError("assignment to entry in nil map"))[_key$1.$key()] = { k: _key$1, v: $append((_entry = importComment$1[s$1.$key()], _entry !== undefined ? _entry.v : ($sliceType(($ptrType(CommentGroup)))).nil), g$1) }; - _i$2++; + return r; + }; + Int.Ptr.prototype.Sign = function() { + var x; + x = this; + if (x.abs.$length === 0) { + return 0; } - sort.Sort($subslice(new byImportSpec(specs.$array), specs.$offset, specs.$offset + specs.$length)); - deduped = $subslice(specs, 0, 0); - _ref$3 = specs; - _i$3 = 0; - while (_i$3 < _ref$3.$length) { - i$2 = _i$3; - s$2 = ((_i$3 < 0 || _i$3 >= _ref$3.$length) ? $throwRuntimeError("index out of range") : _ref$3.$array[_ref$3.$offset + _i$3]); - if ((i$2 === (specs.$length - 1 >> 0)) || !collapse(s$2, (x$2 = i$2 + 1 >> 0, ((x$2 < 0 || x$2 >= specs.$length) ? $throwRuntimeError("index out of range") : specs.$array[specs.$offset + x$2])))) { - deduped = $append(deduped, s$2); - } else { - p = s$2.Pos(); - fset.File(p).MergeLine(fset.Position(p).Line); - } - _i$3++; + if (x.neg) { + return -1; } - specs = deduped; - _ref$4 = specs; - _i$4 = 0; - while (_i$4 < _ref$4.$length) { - i$3 = _i$4; - s$3 = ((_i$4 < 0 || _i$4 >= _ref$4.$length) ? $throwRuntimeError("index out of range") : _ref$4.$array[_ref$4.$offset + _i$4]); - s$4 = $assertType(s$3, ($ptrType(ImportSpec))); - if (!(s$4.Name === ($ptrType(Ident)).nil)) { - s$4.Name.NamePos = ((i$3 < 0 || i$3 >= pos.$length) ? $throwRuntimeError("index out of range") : pos.$array[pos.$offset + i$3]).Start; - } - s$4.Path.ValuePos = ((i$3 < 0 || i$3 >= pos.$length) ? $throwRuntimeError("index out of range") : pos.$array[pos.$offset + i$3]).Start; - s$4.EndPos = ((i$3 < 0 || i$3 >= pos.$length) ? $throwRuntimeError("index out of range") : pos.$array[pos.$offset + i$3]).End; - _ref$5 = (_entry$1 = importComment$1[s$4.$key()], _entry$1 !== undefined ? _entry$1.v : ($sliceType(($ptrType(CommentGroup)))).nil); - _i$5 = 0; - while (_i$5 < _ref$5.$length) { - g$2 = ((_i$5 < 0 || _i$5 >= _ref$5.$length) ? $throwRuntimeError("index out of range") : _ref$5.$array[_ref$5.$offset + _i$5]); - _ref$6 = g$2.List; - _i$6 = 0; - while (_i$6 < _ref$6.$length) { - c = ((_i$6 < 0 || _i$6 >= _ref$6.$length) ? $throwRuntimeError("index out of range") : _ref$6.$array[_ref$6.$offset + _i$6]); - c.Slash = ((i$3 < 0 || i$3 >= pos.$length) ? $throwRuntimeError("index out of range") : pos.$array[pos.$offset + i$3]).End; - _i$6++; - } - _i$5++; - } - _i$4++; + return 1; + }; + Int.prototype.Sign = function() { return this.$val.Sign(); }; + Int.Ptr.prototype.SetInt64 = function(x) { + var z, neg; + z = this; + neg = false; + if ((x.$high < 0 || (x.$high === 0 && x.$low < 0))) { + neg = true; + x = new $Int64(-x.$high, -x.$low); } - sort.Sort($subslice(new byCommentPos(comments.$array), comments.$offset, comments.$offset + comments.$length)); - return specs; + z.abs = z.abs.setUint64(new $Uint64(x.$high, x.$low)); + z.neg = neg; + return z; }; - byImportSpec.prototype.Len = function() { - var x; - x = this; - return x.$length; + Int.prototype.SetInt64 = function(x) { return this.$val.SetInt64(x); }; + Int.Ptr.prototype.SetUint64 = function(x) { + var z; + z = this; + z.abs = z.abs.setUint64(x); + z.neg = false; + return z; }; - $ptrType(byImportSpec).prototype.Len = function() { return this.$get().Len(); }; - byImportSpec.prototype.Swap = function(i, j) { - var x, _tmp, _tmp$1; - x = this; - _tmp = ((j < 0 || j >= x.$length) ? $throwRuntimeError("index out of range") : x.$array[x.$offset + j]); _tmp$1 = ((i < 0 || i >= x.$length) ? $throwRuntimeError("index out of range") : x.$array[x.$offset + i]); (i < 0 || i >= x.$length) ? $throwRuntimeError("index out of range") : x.$array[x.$offset + i] = _tmp; (j < 0 || j >= x.$length) ? $throwRuntimeError("index out of range") : x.$array[x.$offset + j] = _tmp$1; + Int.prototype.SetUint64 = function(x) { return this.$val.SetUint64(x); }; + NewInt = $pkg.NewInt = function(x) { + return new Int.Ptr().SetInt64(x); }; - $ptrType(byImportSpec).prototype.Swap = function(i, j) { return this.$get().Swap(i, j); }; - byImportSpec.prototype.Less = function(i, j) { - var x, ipath, jpath, iname, jname; - x = this; - ipath = importPath(((i < 0 || i >= x.$length) ? $throwRuntimeError("index out of range") : x.$array[x.$offset + i])); - jpath = importPath(((j < 0 || j >= x.$length) ? $throwRuntimeError("index out of range") : x.$array[x.$offset + j])); - if (!(ipath === jpath)) { - return ipath < jpath; - } - iname = importName(((i < 0 || i >= x.$length) ? $throwRuntimeError("index out of range") : x.$array[x.$offset + i])); - jname = importName(((j < 0 || j >= x.$length) ? $throwRuntimeError("index out of range") : x.$array[x.$offset + j])); - if (!(iname === jname)) { - return iname < jname; + Int.Ptr.prototype.Set = function(x) { + var z; + z = this; + if (!(z === x)) { + z.abs = z.abs.set(x.abs); + z.neg = x.neg; } - return importComment(((i < 0 || i >= x.$length) ? $throwRuntimeError("index out of range") : x.$array[x.$offset + i])) < importComment(((j < 0 || j >= x.$length) ? $throwRuntimeError("index out of range") : x.$array[x.$offset + j])); - }; - $ptrType(byImportSpec).prototype.Less = function(i, j) { return this.$get().Less(i, j); }; - byCommentPos.prototype.Len = function() { - var x; - x = this; - return x.$length; + return z; }; - $ptrType(byCommentPos).prototype.Len = function() { return this.$get().Len(); }; - byCommentPos.prototype.Swap = function(i, j) { - var x, _tmp, _tmp$1; + Int.prototype.Set = function(x) { return this.$val.Set(x); }; + Int.Ptr.prototype.Bits = function() { + var x, x$1; x = this; - _tmp = ((j < 0 || j >= x.$length) ? $throwRuntimeError("index out of range") : x.$array[x.$offset + j]); _tmp$1 = ((i < 0 || i >= x.$length) ? $throwRuntimeError("index out of range") : x.$array[x.$offset + i]); (i < 0 || i >= x.$length) ? $throwRuntimeError("index out of range") : x.$array[x.$offset + i] = _tmp; (j < 0 || j >= x.$length) ? $throwRuntimeError("index out of range") : x.$array[x.$offset + j] = _tmp$1; + return (x$1 = x.abs, $subslice(new ($sliceType(Word))(x$1.$array), x$1.$offset, x$1.$offset + x$1.$length)); }; - $ptrType(byCommentPos).prototype.Swap = function(i, j) { return this.$get().Swap(i, j); }; - byCommentPos.prototype.Less = function(i, j) { - var x; - x = this; - return ((i < 0 || i >= x.$length) ? $throwRuntimeError("index out of range") : x.$array[x.$offset + i]).Pos() < ((j < 0 || j >= x.$length) ? $throwRuntimeError("index out of range") : x.$array[x.$offset + j]).Pos(); + Int.prototype.Bits = function() { return this.$val.Bits(); }; + Int.Ptr.prototype.SetBits = function(abs) { + var z; + z = this; + z.abs = $subslice(new nat(abs.$array), abs.$offset, abs.$offset + abs.$length).norm(); + z.neg = false; + return z; }; - $ptrType(byCommentPos).prototype.Less = function(i, j) { return this.$get().Less(i, j); }; - NewScope = $pkg.NewScope = function(outer) { - return new Scope.Ptr(outer, new $Map()); + Int.prototype.SetBits = function(abs) { return this.$val.SetBits(abs); }; + Int.Ptr.prototype.Abs = function(x) { + var z; + z = this; + z.Set(x); + z.neg = false; + return z; }; - Scope.Ptr.prototype.Lookup = function(name) { - var s, _entry; - s = this; - return (_entry = s.Objects[name], _entry !== undefined ? _entry.v : ($ptrType(Object)).nil); + Int.prototype.Abs = function(x) { return this.$val.Abs(x); }; + Int.Ptr.prototype.Neg = function(x) { + var z; + z = this; + z.Set(x); + z.neg = z.abs.$length > 0 && !z.neg; + return z; }; - Scope.prototype.Lookup = function(name) { return this.$val.Lookup(name); }; - Scope.Ptr.prototype.Insert = function(obj) { - var alt = ($ptrType(Object)).nil, s, _entry, _key; - s = this; - alt = (_entry = s.Objects[obj.Name], _entry !== undefined ? _entry.v : ($ptrType(Object)).nil); - if (alt === ($ptrType(Object)).nil) { - _key = obj.Name; (s.Objects || $throwRuntimeError("assignment to entry in nil map"))[_key] = { k: _key, v: obj }; + Int.prototype.Neg = function(x) { return this.$val.Neg(x); }; + Int.Ptr.prototype.Add = function(x, y) { + var z, neg; + z = this; + neg = x.neg; + if (x.neg === y.neg) { + z.abs = z.abs.add(x.abs, y.abs); + } else { + if (x.abs.cmp(y.abs) >= 0) { + z.abs = z.abs.sub(x.abs, y.abs); + } else { + neg = !neg; + z.abs = z.abs.sub(y.abs, x.abs); + } } - return alt; + z.neg = z.abs.$length > 0 && neg; + return z; }; - Scope.prototype.Insert = function(obj) { return this.$val.Insert(obj); }; - Scope.Ptr.prototype.String = function() { - var s, buf, _ref, _i, _keys, _entry, obj; - s = this; - buf = new bytes.Buffer.Ptr(); $copy(buf, new bytes.Buffer.Ptr(), bytes.Buffer); - fmt.Fprintf(buf, "scope %p {", new ($sliceType($emptyInterface))([s])); - if (!(s === ($ptrType(Scope)).nil) && $keys(s.Objects).length > 0) { - fmt.Fprintln(buf, new ($sliceType($emptyInterface))([])); - _ref = s.Objects; - _i = 0; - _keys = $keys(_ref); - while (_i < _keys.length) { - _entry = _ref[_keys[_i]]; - if (_entry === undefined) { - _i++; - continue; - } - obj = _entry.v; - fmt.Fprintf(buf, "\t%s %s\n", new ($sliceType($emptyInterface))([new ObjKind(obj.Kind), new $String(obj.Name)])); - _i++; + Int.prototype.Add = function(x, y) { return this.$val.Add(x, y); }; + Int.Ptr.prototype.Sub = function(x, y) { + var z, neg; + z = this; + neg = x.neg; + if (!(x.neg === y.neg)) { + z.abs = z.abs.add(x.abs, y.abs); + } else { + if (x.abs.cmp(y.abs) >= 0) { + z.abs = z.abs.sub(x.abs, y.abs); + } else { + neg = !neg; + z.abs = z.abs.sub(y.abs, x.abs); } } - fmt.Fprintf(buf, "}\n", new ($sliceType($emptyInterface))([])); - return buf.String(); + z.neg = z.abs.$length > 0 && neg; + return z; }; - Scope.prototype.String = function() { return this.$val.String(); }; - NewObj = $pkg.NewObj = function(kind, name) { - return new Object.Ptr(kind, name, $ifaceNil, $ifaceNil, $ifaceNil); + Int.prototype.Sub = function(x, y) { return this.$val.Sub(x, y); }; + Int.Ptr.prototype.Mul = function(x, y) { + var z; + z = this; + z.abs = z.abs.mul(x.abs, y.abs); + z.neg = z.abs.$length > 0 && !(x.neg === y.neg); + return z; }; - Object.Ptr.prototype.Pos = function() { - var obj, name, d, _ref, _ref$1, _i, n, _ref$2, _i$1, n$1, _ref$3, _i$2, x, _tuple, ident, isIdent; - obj = this; - name = obj.Name; - _ref = obj.Decl; - if ($assertType(_ref, ($ptrType(Field)), true)[1]) { - d = _ref.$val; - _ref$1 = d.Names; - _i = 0; - while (_i < _ref$1.$length) { - n = ((_i < 0 || _i >= _ref$1.$length) ? $throwRuntimeError("index out of range") : _ref$1.$array[_ref$1.$offset + _i]); - if (n.Name === name) { - return n.Pos(); - } - _i++; - } - } else if ($assertType(_ref, ($ptrType(ImportSpec)), true)[1]) { - d = _ref.$val; - if (!(d.Name === ($ptrType(Ident)).nil) && d.Name.Name === name) { - return d.Name.Pos(); - } - return d.Path.Pos(); - } else if ($assertType(_ref, ($ptrType(ValueSpec)), true)[1]) { - d = _ref.$val; - _ref$2 = d.Names; - _i$1 = 0; - while (_i$1 < _ref$2.$length) { - n$1 = ((_i$1 < 0 || _i$1 >= _ref$2.$length) ? $throwRuntimeError("index out of range") : _ref$2.$array[_ref$2.$offset + _i$1]); - if (n$1.Name === name) { - return n$1.Pos(); - } - _i$1++; - } - } else if ($assertType(_ref, ($ptrType(TypeSpec)), true)[1]) { - d = _ref.$val; - if (d.Name.Name === name) { - return d.Name.Pos(); - } - } else if ($assertType(_ref, ($ptrType(FuncDecl)), true)[1]) { - d = _ref.$val; - if (d.Name.Name === name) { - return d.Name.Pos(); - } - } else if ($assertType(_ref, ($ptrType(LabeledStmt)), true)[1]) { - d = _ref.$val; - if (d.Label.Name === name) { - return d.Label.Pos(); + Int.prototype.Mul = function(x, y) { return this.$val.Mul(x, y); }; + Int.Ptr.prototype.MulRange = function(a, b) { + var z, neg, x, x$1, _tmp, _tmp$1; + z = this; + if ((a.$high > b.$high || (a.$high === b.$high && a.$low > b.$low))) { + return z.SetInt64(new $Int64(0, 1)); + } else if ((a.$high < 0 || (a.$high === 0 && a.$low <= 0)) && (b.$high > 0 || (b.$high === 0 && b.$low >= 0))) { + return z.SetInt64(new $Int64(0, 0)); + } + neg = false; + if ((a.$high < 0 || (a.$high === 0 && a.$low < 0))) { + neg = (x = (x$1 = new $Int64(b.$high - a.$high, b.$low - a.$low), new $Int64(x$1.$high & 0, (x$1.$low & 1) >>> 0)), (x.$high === 0 && x.$low === 0)); + _tmp = new $Int64(-b.$high, -b.$low); _tmp$1 = new $Int64(-a.$high, -a.$low); a = _tmp; b = _tmp$1; + } + z.abs = z.abs.mulRange(new $Uint64(a.$high, a.$low), new $Uint64(b.$high, b.$low)); + z.neg = neg; + return z; + }; + Int.prototype.MulRange = function(a, b) { return this.$val.MulRange(a, b); }; + Int.Ptr.prototype.Binomial = function(n, k) { + var z, _tmp, _tmp$1, a, b, x; + z = this; + _tmp = new Int.Ptr(); $copy(_tmp, new Int.Ptr(), Int); _tmp$1 = new Int.Ptr(); $copy(_tmp$1, new Int.Ptr(), Int); a = new Int.Ptr(); $copy(a, _tmp, Int); b = new Int.Ptr(); $copy(b, _tmp$1, Int); + a.MulRange((x = new $Int64(n.$high - k.$high, n.$low - k.$low), new $Int64(x.$high + 0, x.$low + 1)), n); + b.MulRange(new $Int64(0, 1), k); + return z.Quo(a, b); + }; + Int.prototype.Binomial = function(n, k) { return this.$val.Binomial(n, k); }; + Int.Ptr.prototype.Quo = function(x, y) { + var z, _tuple; + z = this; + _tuple = z.abs.div(nat.nil, x.abs, y.abs); z.abs = _tuple[0]; + z.neg = z.abs.$length > 0 && !(x.neg === y.neg); + return z; + }; + Int.prototype.Quo = function(x, y) { return this.$val.Quo(x, y); }; + Int.Ptr.prototype.Rem = function(x, y) { + var z, _tuple; + z = this; + _tuple = nat.nil.div(z.abs, x.abs, y.abs); z.abs = _tuple[1]; + z.neg = z.abs.$length > 0 && x.neg; + return z; + }; + Int.prototype.Rem = function(x, y) { return this.$val.Rem(x, y); }; + Int.Ptr.prototype.QuoRem = function(x, y, r) { + var z, _tuple, _tmp, _tmp$1; + z = this; + _tuple = z.abs.div(r.abs, x.abs, y.abs); z.abs = _tuple[0]; r.abs = _tuple[1]; + _tmp = z.abs.$length > 0 && !(x.neg === y.neg); _tmp$1 = r.abs.$length > 0 && x.neg; z.neg = _tmp; r.neg = _tmp$1; + return [z, r]; + }; + Int.prototype.QuoRem = function(x, y, r) { return this.$val.QuoRem(x, y, r); }; + Int.Ptr.prototype.Div = function(x, y) { + var z, y_neg, r; + z = this; + y_neg = y.neg; + r = new Int.Ptr(); $copy(r, new Int.Ptr(), Int); + z.QuoRem(x, y, r); + if (r.neg) { + if (y_neg) { + z.Add(z, intOne); + } else { + z.Sub(z, intOne); } - } else if ($assertType(_ref, ($ptrType(AssignStmt)), true)[1]) { - d = _ref.$val; - _ref$3 = d.Lhs; - _i$2 = 0; - while (_i$2 < _ref$3.$length) { - x = ((_i$2 < 0 || _i$2 >= _ref$3.$length) ? $throwRuntimeError("index out of range") : _ref$3.$array[_ref$3.$offset + _i$2]); - _tuple = $assertType(x, ($ptrType(Ident)), true); ident = _tuple[0]; isIdent = _tuple[1]; - if (isIdent && ident.Name === name) { - return ident.Pos(); - } - _i$2++; + } + return z; + }; + Int.prototype.Div = function(x, y) { return this.$val.Div(x, y); }; + Int.Ptr.prototype.Mod = function(x, y) { + var z, y0, q; + z = this; + y0 = y; + if (z === y || alias(z.abs, y.abs)) { + y0 = new Int.Ptr().Set(y); + } + q = new Int.Ptr(); $copy(q, new Int.Ptr(), Int); + q.QuoRem(x, y, z); + if (z.neg) { + if (y0.neg) { + z.Sub(z, y0); + } else { + z.Add(z, y0); } } - return 0; + return z; }; - Object.prototype.Pos = function() { return this.$val.Pos(); }; - ObjKind.prototype.String = function() { - var kind; - kind = this.$val !== undefined ? this.$val : this; - return ((kind < 0 || kind >= objKindStrings.length) ? $throwRuntimeError("index out of range") : objKindStrings[kind]); + Int.prototype.Mod = function(x, y) { return this.$val.Mod(x, y); }; + Int.Ptr.prototype.DivMod = function(x, y, m) { + var z, y0; + z = this; + y0 = y; + if (z === y || alias(z.abs, y.abs)) { + y0 = new Int.Ptr().Set(y); + } + z.QuoRem(x, y, m); + if (m.neg) { + if (y0.neg) { + z.Add(z, intOne); + m.Sub(m, y0); + } else { + z.Sub(z, intOne); + m.Add(m, y0); + } + } + return [z, m]; }; - $ptrType(ObjKind).prototype.String = function() { return new ObjKind(this.$get()).String(); }; - walkIdentList = function(v, list) { - var _ref, _i, x; - _ref = list; - _i = 0; - while (_i < _ref.$length) { - x = ((_i < 0 || _i >= _ref.$length) ? $throwRuntimeError("index out of range") : _ref.$array[_ref.$offset + _i]); - Walk(v, x); - _i++; + Int.prototype.DivMod = function(x, y, m) { return this.$val.DivMod(x, y, m); }; + Int.Ptr.prototype.Cmp = function(y) { + var r = 0, x; + x = this; + if (x.neg === y.neg) { + r = x.abs.cmp(y.abs); + if (x.neg) { + r = -r; + } + } else if (x.neg) { + r = -1; + } else { + r = 1; } + return r; }; - walkExprList = function(v, list) { - var _ref, _i, x; - _ref = list; - _i = 0; - while (_i < _ref.$length) { - x = ((_i < 0 || _i >= _ref.$length) ? $throwRuntimeError("index out of range") : _ref.$array[_ref.$offset + _i]); - Walk(v, x); - _i++; + Int.prototype.Cmp = function(y) { return this.$val.Cmp(y); }; + Int.Ptr.prototype.String = function() { + var x; + x = this; + if (x === ($ptrType(Int)).nil) { + return ""; + } else if (x.neg) { + return "-" + x.abs.decimalString(); } + return x.abs.decimalString(); }; - walkStmtList = function(v, list) { - var _ref, _i, x; - _ref = list; - _i = 0; - while (_i < _ref.$length) { - x = ((_i < 0 || _i >= _ref.$length) ? $throwRuntimeError("index out of range") : _ref.$array[_ref.$offset + _i]); - Walk(v, x); - _i++; + Int.prototype.String = function() { return this.$val.String(); }; + charset = function(ch) { + var _ref; + _ref = ch; + if (_ref === 98) { + return "0123456789abcdefghijklmnopqrstuvwxyz".substring(0, 2); + } else if (_ref === 111) { + return "0123456789abcdefghijklmnopqrstuvwxyz".substring(0, 8); + } else if (_ref === 100 || _ref === 115 || _ref === 118) { + return "0123456789abcdefghijklmnopqrstuvwxyz".substring(0, 10); + } else if (_ref === 120) { + return "0123456789abcdefghijklmnopqrstuvwxyz".substring(0, 16); + } else if (_ref === 88) { + return "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ".substring(0, 16); } + return ""; }; - walkDeclList = function(v, list) { - var _ref, _i, x; - _ref = list; - _i = 0; - while (_i < _ref.$length) { - x = ((_i < 0 || _i >= _ref.$length) ? $throwRuntimeError("index out of range") : _ref.$array[_ref.$offset + _i]); - Walk(v, x); - _i++; + writeMultiple = function(s, text, count) { + var b; + if (text.length > 0) { + b = new ($sliceType($Uint8))($stringToBytes(text)); + while (count > 0) { + s.Write(b); + count = count - (1) >> 0; + } } }; - Walk = $pkg.Walk = function(v, node) { - var n, _ref, _ref$1, _i, c, _ref$2, _i$1, f, _ref$3, _i$2, s, _ref$4, _i$3, _keys, _entry, f$1; - v = v.Visit(node); - if ($interfaceIsEqual(v, $ifaceNil)) { + Int.Ptr.prototype.Format = function(s, ch) { + var x, cs, sign, prefix, _ref, digits, left, zeroes, right, _tuple, precision, precisionSet, length, _tuple$1, width, widthSet, d; + x = this; + cs = charset(ch); + if (cs === "") { + fmt.Fprintf(s, "%%!%c(big.Int=%s)", new ($sliceType($emptyInterface))([new $Int32(ch), new $String(x.String())])); + return; + } else if (x === ($ptrType(Int)).nil) { + fmt.Fprint(s, new ($sliceType($emptyInterface))([new $String("")])); return; } - _ref = node; - if ($assertType(_ref, ($ptrType(Comment)), true)[1]) { - n = _ref.$val; - } else if ($assertType(_ref, ($ptrType(CommentGroup)), true)[1]) { - n = _ref.$val; - _ref$1 = n.List; - _i = 0; - while (_i < _ref$1.$length) { - c = ((_i < 0 || _i >= _ref$1.$length) ? $throwRuntimeError("index out of range") : _ref$1.$array[_ref$1.$offset + _i]); - Walk(v, c); - _i++; - } - } else if ($assertType(_ref, ($ptrType(Field)), true)[1]) { - n = _ref.$val; - if (!(n.Doc === ($ptrType(CommentGroup)).nil)) { - Walk(v, n.Doc); - } - walkIdentList(v, n.Names); - Walk(v, n.Type); - if (!(n.Tag === ($ptrType(BasicLit)).nil)) { - Walk(v, n.Tag); + sign = ""; + if (x.neg) { + sign = "-"; + } else if (s.Flag(43)) { + sign = "+"; + } else if (s.Flag(32)) { + sign = " "; + } + prefix = ""; + if (s.Flag(35)) { + _ref = ch; + if (_ref === 111) { + prefix = "0"; + } else if (_ref === 120) { + prefix = "0x"; + } else if (_ref === 88) { + prefix = "0X"; } - if (!(n.Comment === ($ptrType(CommentGroup)).nil)) { - Walk(v, n.Comment); + } + digits = x.abs.string(cs); + left = 0; + zeroes = 0; + right = 0; + _tuple = s.Precision(); precision = _tuple[0]; precisionSet = _tuple[1]; + if (precisionSet) { + if (digits.length < precision) { + zeroes = precision - digits.length >> 0; + } else if (digits === "0" && (precision === 0)) { + return; } - } else if ($assertType(_ref, ($ptrType(FieldList)), true)[1]) { - n = _ref.$val; - _ref$2 = n.List; - _i$1 = 0; - while (_i$1 < _ref$2.$length) { - f = ((_i$1 < 0 || _i$1 >= _ref$2.$length) ? $throwRuntimeError("index out of range") : _ref$2.$array[_ref$2.$offset + _i$1]); - Walk(v, f); - _i$1++; + } + length = ((sign.length + prefix.length >> 0) + zeroes >> 0) + digits.length >> 0; + _tuple$1 = s.Width(); width = _tuple$1[0]; widthSet = _tuple$1[1]; + if (widthSet && length < width) { + d = width - length >> 0; + if (s.Flag(45)) { + right = d; + } else if (s.Flag(48) && !precisionSet) { + zeroes = d; + } else { + left = d; } - } else if ($assertType(_ref, ($ptrType(BadExpr)), true)[1] || $assertType(_ref, ($ptrType(Ident)), true)[1] || $assertType(_ref, ($ptrType(BasicLit)), true)[1]) { - n = _ref; - } else if ($assertType(_ref, ($ptrType(Ellipsis)), true)[1]) { - n = _ref.$val; - if (!($interfaceIsEqual(n.Elt, $ifaceNil))) { - Walk(v, n.Elt); + } + writeMultiple(s, " ", left); + writeMultiple(s, sign, 1); + writeMultiple(s, prefix, 1); + writeMultiple(s, "0", zeroes); + writeMultiple(s, digits, 1); + writeMultiple(s, " ", right); + }; + Int.prototype.Format = function(s, ch) { return this.$val.Format(s, ch); }; + Int.Ptr.prototype.scan = function(r, base) { + var z, _tuple, ch, err, neg, _ref, _tuple$1; + z = this; + _tuple = r.ReadRune(); ch = _tuple[0]; err = _tuple[2]; + if (!($interfaceIsEqual(err, $ifaceNil))) { + return [($ptrType(Int)).nil, 0, err]; + } + neg = false; + _ref = ch; + if (_ref === 45) { + neg = true; + } else if (_ref === 43) { + } else { + r.UnreadRune(); + } + _tuple$1 = z.abs.scan(r, base); z.abs = _tuple$1[0]; base = _tuple$1[1]; err = _tuple$1[2]; + if (!($interfaceIsEqual(err, $ifaceNil))) { + return [($ptrType(Int)).nil, base, err]; + } + z.neg = z.abs.$length > 0 && neg; + return [z, base, $ifaceNil]; + }; + Int.prototype.scan = function(r, base) { return this.$val.scan(r, base); }; + Int.Ptr.prototype.Scan = function(s, ch) { + var z, base, _ref, _tuple, err; + z = this; + s.SkipSpace(); + base = 0; + _ref = ch; + if (_ref === 98) { + base = 2; + } else if (_ref === 111) { + base = 8; + } else if (_ref === 100) { + base = 10; + } else if (_ref === 120 || _ref === 88) { + base = 16; + } else if (_ref === 115 || _ref === 118) { + } else { + return errors.New("Int.Scan: invalid verb"); + } + _tuple = z.scan(s, base); err = _tuple[2]; + return err; + }; + Int.prototype.Scan = function(s, ch) { return this.$val.Scan(s, ch); }; + Int.Ptr.prototype.Int64 = function() { + var x, x$1, v; + x = this; + v = (x$1 = x.Uint64(), new $Int64(x$1.$high, x$1.$low)); + if (x.neg) { + v = new $Int64(-v.$high, -v.$low); + } + return v; + }; + Int.prototype.Int64 = function() { return this.$val.Int64(); }; + Int.Ptr.prototype.Uint64 = function() { + var x, x$1, x$2, v, x$3, x$4, x$5; + x = this; + if (x.abs.$length === 0) { + return new $Uint64(0, 0); + } + v = (x$1 = (x$2 = x.abs, ((0 < 0 || 0 >= x$2.$length) ? $throwRuntimeError("index out of range") : x$2.$array[x$2.$offset + 0])), new $Uint64(0, x$1.constructor === Number ? x$1 : 1)); + if (true && x.abs.$length > 1) { + v = (x$3 = $shiftLeft64((x$4 = (x$5 = x.abs, ((1 < 0 || 1 >= x$5.$length) ? $throwRuntimeError("index out of range") : x$5.$array[x$5.$offset + 1])), new $Uint64(0, x$4.constructor === Number ? x$4 : 1)), 32), new $Uint64(v.$high | x$3.$high, (v.$low | x$3.$low) >>> 0)); + } + return v; + }; + Int.prototype.Uint64 = function() { return this.$val.Uint64(); }; + Int.Ptr.prototype.SetString = function(s, base) { + var z, r, _tuple, err, _tuple$1; + z = this; + r = strings.NewReader(s); + _tuple = z.scan(r, base); err = _tuple[2]; + if (!($interfaceIsEqual(err, $ifaceNil))) { + return [($ptrType(Int)).nil, false]; + } + _tuple$1 = r.ReadRune(); err = _tuple$1[2]; + if (!($interfaceIsEqual(err, io.EOF))) { + return [($ptrType(Int)).nil, false]; + } + return [z, true]; + }; + Int.prototype.SetString = function(s, base) { return this.$val.SetString(s, base); }; + Int.Ptr.prototype.SetBytes = function(buf) { + var z; + z = this; + z.abs = z.abs.setBytes(buf); + z.neg = false; + return z; + }; + Int.prototype.SetBytes = function(buf) { return this.$val.SetBytes(buf); }; + Int.Ptr.prototype.Bytes = function() { + var x, x$1, buf; + x = this; + buf = ($sliceType($Uint8)).make((x$1 = x.abs.$length, (((x$1 >>> 16 << 16) * 4 >> 0) + (x$1 << 16 >>> 16) * 4) >> 0)); + return $subslice(buf, x.abs.bytes(buf)); + }; + Int.prototype.Bytes = function() { return this.$val.Bytes(); }; + Int.Ptr.prototype.BitLen = function() { + var x; + x = this; + return x.abs.bitLen(); + }; + Int.prototype.BitLen = function() { return this.$val.BitLen(); }; + Int.Ptr.prototype.Exp = function(x, y, m) { + var z, yWords, mWords; + z = this; + yWords = nat.nil; + if (!y.neg) { + yWords = y.abs; + } + mWords = nat.nil; + if (!(m === ($ptrType(Int)).nil)) { + mWords = m.abs; + } + z.abs = z.abs.expNN(x.abs, yWords, mWords); + z.neg = z.abs.$length > 0 && x.neg && yWords.$length > 0 && (((((0 < 0 || 0 >= yWords.$length) ? $throwRuntimeError("index out of range") : yWords.$array[yWords.$offset + 0]) & 1) >>> 0) === 1); + return z; + }; + Int.prototype.Exp = function(x, y, m) { return this.$val.Exp(x, y, m); }; + Int.Ptr.prototype.GCD = function(x, y, a, b) { + var z, A, B, X, Y, lastX, lastY, q, temp, r, _tuple, _tmp, _tmp$1; + z = this; + if (a.Sign() <= 0 || b.Sign() <= 0) { + z.SetInt64(new $Int64(0, 0)); + if (!(x === ($ptrType(Int)).nil)) { + x.SetInt64(new $Int64(0, 0)); } - } else if ($assertType(_ref, ($ptrType(FuncLit)), true)[1]) { - n = _ref.$val; - Walk(v, n.Type); - Walk(v, n.Body); - } else if ($assertType(_ref, ($ptrType(CompositeLit)), true)[1]) { - n = _ref.$val; - if (!($interfaceIsEqual(n.Type, $ifaceNil))) { - Walk(v, n.Type); + if (!(y === ($ptrType(Int)).nil)) { + y.SetInt64(new $Int64(0, 0)); + } + return z; + } + if (x === ($ptrType(Int)).nil && y === ($ptrType(Int)).nil) { + return z.binaryGCD(a, b); + } + A = new Int.Ptr().Set(a); + B = new Int.Ptr().Set(b); + X = new Int.Ptr(); + Y = new Int.Ptr().SetInt64(new $Int64(0, 1)); + lastX = new Int.Ptr().SetInt64(new $Int64(0, 1)); + lastY = new Int.Ptr(); + q = new Int.Ptr(); + temp = new Int.Ptr(); + while (B.abs.$length > 0) { + r = new Int.Ptr(); + _tuple = q.QuoRem(A, B, r); q = _tuple[0]; r = _tuple[1]; + _tmp = B; _tmp$1 = r; A = _tmp; B = _tmp$1; + temp.Set(X); + X.Mul(X, q); + X.neg = !X.neg; + X.Add(X, lastX); + lastX.Set(temp); + temp.Set(Y); + Y.Mul(Y, q); + Y.neg = !Y.neg; + Y.Add(Y, lastY); + lastY.Set(temp); + } + if (!(x === ($ptrType(Int)).nil)) { + $copy(x, lastX, Int); + } + if (!(y === ($ptrType(Int)).nil)) { + $copy(y, lastY, Int); + } + $copy(z, A, Int); + return z; + }; + Int.prototype.GCD = function(x, y, a, b) { return this.$val.GCD(x, y, a, b); }; + Int.Ptr.prototype.binaryGCD = function(a, b) { + var z, u, v, k, vk, t, x, _tmp, _tmp$1, _tmp$2, _tmp$3; + z = this; + u = z; + v = new Int.Ptr(); + if (a.abs.$length > b.abs.$length) { + u.Set(b); + v.Rem(a, b); + } else if (a.abs.$length < b.abs.$length) { + u.Set(a); + v.Rem(b, a); + } else { + u.Set(a); + v.Set(b); + } + if (v.abs.$length === 0) { + return u; + } + k = u.abs.trailingZeroBits(); + vk = v.abs.trailingZeroBits(); + if (vk < k) { + k = vk; + } + u.Rsh(u, k); + v.Rsh(v, k); + t = new Int.Ptr(); + if (!(((((x = u.abs, ((0 < 0 || 0 >= x.$length) ? $throwRuntimeError("index out of range") : x.$array[x.$offset + 0])) & 1) >>> 0) === 0))) { + t.Neg(v); + } else { + t.Set(u); + } + while (t.abs.$length > 0) { + t.Rsh(t, t.abs.trailingZeroBits()); + if (t.neg) { + _tmp = t; _tmp$1 = v; v = _tmp; t = _tmp$1; + v.neg = v.abs.$length > 0 && !v.neg; + } else { + _tmp$2 = t; _tmp$3 = u; u = _tmp$2; t = _tmp$3; + } + t.Sub(u, v); + } + return z.Lsh(u, k); + }; + Int.prototype.binaryGCD = function(a, b) { return this.$val.binaryGCD(a, b); }; + Int.Ptr.prototype.ProbablyPrime = function(n) { + var x; + x = this; + return !x.neg && x.abs.probablyPrime(n); + }; + Int.prototype.ProbablyPrime = function(n) { return this.$val.ProbablyPrime(n); }; + Int.Ptr.prototype.Rand = function(rnd, n) { + var z; + z = this; + z.neg = false; + if (n.neg === true || (n.abs.$length === 0)) { + z.abs = nat.nil; + return z; + } + z.abs = z.abs.random(rnd, n.abs, n.abs.bitLen()); + return z; + }; + Int.prototype.Rand = function(rnd, n) { return this.$val.Rand(rnd, n); }; + Int.Ptr.prototype.ModInverse = function(g, p) { + var z, d; + z = this; + d = new Int.Ptr(); $copy(d, new Int.Ptr(), Int); + d.GCD(z, ($ptrType(Int)).nil, g, p); + if (z.neg) { + z.Add(z, p); + } + return z; + }; + Int.prototype.ModInverse = function(g, p) { return this.$val.ModInverse(g, p); }; + Int.Ptr.prototype.Lsh = function(x, n) { + var z; + z = this; + z.abs = z.abs.shl(x.abs, n); + z.neg = x.neg; + return z; + }; + Int.prototype.Lsh = function(x, n) { return this.$val.Lsh(x, n); }; + Int.Ptr.prototype.Rsh = function(x, n) { + var z, t; + z = this; + if (x.neg) { + t = z.abs.sub(x.abs, natOne); + t = t.shr(t, n); + z.abs = t.add(t, natOne); + z.neg = true; + return z; + } + z.abs = z.abs.shr(x.abs, n); + z.neg = false; + return z; + }; + Int.prototype.Rsh = function(x, n) { return this.$val.Rsh(x, n); }; + Int.Ptr.prototype.Bit = function(i) { + var x, x$1, t; + x = this; + if (i === 0) { + if (x.abs.$length > 0) { + return ((((x$1 = x.abs, ((0 < 0 || 0 >= x$1.$length) ? $throwRuntimeError("index out of range") : x$1.$array[x$1.$offset + 0])) & 1) >>> 0) >>> 0); + } + return 0; + } + if (i < 0) { + $panic(new $String("negative bit index")); + } + if (x.neg) { + t = nat.nil.sub(x.abs, natOne); + return (t.bit((i >>> 0)) ^ 1) >>> 0; + } + return x.abs.bit((i >>> 0)); + }; + Int.prototype.Bit = function(i) { return this.$val.Bit(i); }; + Int.Ptr.prototype.SetBit = function(x, i, b) { + var z, t; + z = this; + if (i < 0) { + $panic(new $String("negative bit index")); + } + if (x.neg) { + t = z.abs.sub(x.abs, natOne); + t = t.setBit(t, (i >>> 0), (b ^ 1) >>> 0); + z.abs = t.add(t, natOne); + z.neg = z.abs.$length > 0; + return z; + } + z.abs = z.abs.setBit(x.abs, (i >>> 0), b); + z.neg = false; + return z; + }; + Int.prototype.SetBit = function(x, i, b) { return this.$val.SetBit(x, i, b); }; + Int.Ptr.prototype.And = function(x, y) { + var z, x1, y1, _tmp, _tmp$1, y1$1; + z = this; + if (x.neg === y.neg) { + if (x.neg) { + x1 = nat.nil.sub(x.abs, natOne); + y1 = nat.nil.sub(y.abs, natOne); + z.abs = z.abs.add(z.abs.or(x1, y1), natOne); + z.neg = true; + return z; + } + z.abs = z.abs.and(x.abs, y.abs); + z.neg = false; + return z; + } + if (x.neg) { + _tmp = y; _tmp$1 = x; x = _tmp; y = _tmp$1; + } + y1$1 = nat.nil.sub(y.abs, natOne); + z.abs = z.abs.andNot(x.abs, y1$1); + z.neg = false; + return z; + }; + Int.prototype.And = function(x, y) { return this.$val.And(x, y); }; + Int.Ptr.prototype.AndNot = function(x, y) { + var z, x1, y1, x1$1, y1$1; + z = this; + if (x.neg === y.neg) { + if (x.neg) { + x1 = nat.nil.sub(x.abs, natOne); + y1 = nat.nil.sub(y.abs, natOne); + z.abs = z.abs.andNot(y1, x1); + z.neg = false; + return z; + } + z.abs = z.abs.andNot(x.abs, y.abs); + z.neg = false; + return z; + } + if (x.neg) { + x1$1 = nat.nil.sub(x.abs, natOne); + z.abs = z.abs.add(z.abs.or(x1$1, y.abs), natOne); + z.neg = true; + return z; + } + y1$1 = nat.nil.add(y.abs, natOne); + z.abs = z.abs.and(x.abs, y1$1); + z.neg = false; + return z; + }; + Int.prototype.AndNot = function(x, y) { return this.$val.AndNot(x, y); }; + Int.Ptr.prototype.Or = function(x, y) { + var z, x1, y1, _tmp, _tmp$1, y1$1; + z = this; + if (x.neg === y.neg) { + if (x.neg) { + x1 = nat.nil.sub(x.abs, natOne); + y1 = nat.nil.sub(y.abs, natOne); + z.abs = z.abs.add(z.abs.and(x1, y1), natOne); + z.neg = true; + return z; + } + z.abs = z.abs.or(x.abs, y.abs); + z.neg = false; + return z; + } + if (x.neg) { + _tmp = y; _tmp$1 = x; x = _tmp; y = _tmp$1; + } + y1$1 = nat.nil.sub(y.abs, natOne); + z.abs = z.abs.add(z.abs.andNot(y1$1, x.abs), natOne); + z.neg = true; + return z; + }; + Int.prototype.Or = function(x, y) { return this.$val.Or(x, y); }; + Int.Ptr.prototype.Xor = function(x, y) { + var z, x1, y1, _tmp, _tmp$1, y1$1; + z = this; + if (x.neg === y.neg) { + if (x.neg) { + x1 = nat.nil.sub(x.abs, natOne); + y1 = nat.nil.sub(y.abs, natOne); + z.abs = z.abs.xor(x1, y1); + z.neg = false; + return z; + } + z.abs = z.abs.xor(x.abs, y.abs); + z.neg = false; + return z; + } + if (x.neg) { + _tmp = y; _tmp$1 = x; x = _tmp; y = _tmp$1; + } + y1$1 = nat.nil.sub(y.abs, natOne); + z.abs = z.abs.add(z.abs.xor(x.abs, y1$1), natOne); + z.neg = true; + return z; + }; + Int.prototype.Xor = function(x, y) { return this.$val.Xor(x, y); }; + Int.Ptr.prototype.Not = function(x) { + var z; + z = this; + if (x.neg) { + z.abs = z.abs.sub(x.abs, natOne); + z.neg = false; + return z; + } + z.abs = z.abs.add(x.abs, natOne); + z.neg = true; + return z; + }; + Int.prototype.Not = function(x) { return this.$val.Not(x); }; + Int.Ptr.prototype.GobEncode = function() { + var x, x$1, buf, i, b; + x = this; + if (x === ($ptrType(Int)).nil) { + return [($sliceType($Uint8)).nil, $ifaceNil]; + } + buf = ($sliceType($Uint8)).make((1 + (x$1 = x.abs.$length, (((x$1 >>> 16 << 16) * 4 >> 0) + (x$1 << 16 >>> 16) * 4) >> 0) >> 0)); + i = x.abs.bytes(buf) - 1 >> 0; + b = 2; + if (x.neg) { + b = (b | (1)) >>> 0; + } + (i < 0 || i >= buf.$length) ? $throwRuntimeError("index out of range") : buf.$array[buf.$offset + i] = b; + return [$subslice(buf, i), $ifaceNil]; + }; + Int.prototype.GobEncode = function() { return this.$val.GobEncode(); }; + Int.Ptr.prototype.GobDecode = function(buf) { + var z, b; + z = this; + if (buf.$length === 0) { + $copy(z, new Int.Ptr(false, nat.nil), Int); + return $ifaceNil; + } + b = ((0 < 0 || 0 >= buf.$length) ? $throwRuntimeError("index out of range") : buf.$array[buf.$offset + 0]); + if (!(((b >>> 1 << 24 >>> 24) === 1))) { + return errors.New(fmt.Sprintf("Int.GobDecode: encoding version %d not supported", new ($sliceType($emptyInterface))([new $Uint8((b >>> 1 << 24 >>> 24))]))); + } + z.neg = !((((b & 1) >>> 0) === 0)); + z.abs = z.abs.setBytes($subslice(buf, 1)); + return $ifaceNil; + }; + Int.prototype.GobDecode = function(buf) { return this.$val.GobDecode(buf); }; + Int.Ptr.prototype.MarshalJSON = function() { + var z; + z = this; + return [new ($sliceType($Uint8))($stringToBytes(z.String())), $ifaceNil]; + }; + Int.prototype.MarshalJSON = function() { return this.$val.MarshalJSON(); }; + Int.Ptr.prototype.UnmarshalJSON = function(text) { + var z, _tuple, ok; + z = this; + _tuple = z.SetString($bytesToString(text), 0); ok = _tuple[1]; + if (!ok) { + return fmt.Errorf("math/big: cannot unmarshal %q into a *big.Int", new ($sliceType($emptyInterface))([text])); + } + return $ifaceNil; + }; + Int.prototype.UnmarshalJSON = function(text) { return this.$val.UnmarshalJSON(text); }; + Int.Ptr.prototype.MarshalText = function() { + var text = ($sliceType($Uint8)).nil, err = $ifaceNil, z, _tmp, _tmp$1; + z = this; + _tmp = new ($sliceType($Uint8))($stringToBytes(z.String())); _tmp$1 = $ifaceNil; text = _tmp; err = _tmp$1; + return [text, err]; + }; + Int.prototype.MarshalText = function() { return this.$val.MarshalText(); }; + Int.Ptr.prototype.UnmarshalText = function(text) { + var z, _tuple, ok; + z = this; + _tuple = z.SetString($bytesToString(text), 0); ok = _tuple[1]; + if (!ok) { + return fmt.Errorf("math/big: cannot unmarshal %q into a *big.Int", new ($sliceType($emptyInterface))([text])); + } + return $ifaceNil; + }; + Int.prototype.UnmarshalText = function(text) { return this.$val.UnmarshalText(text); }; + nat.prototype.clear = function() { + var z, _ref, _i, i; + z = this; + _ref = z; + _i = 0; + while (_i < _ref.$length) { + i = _i; + (i < 0 || i >= z.$length) ? $throwRuntimeError("index out of range") : z.$array[z.$offset + i] = 0; + _i++; + } + }; + $ptrType(nat).prototype.clear = function() { return this.$get().clear(); }; + nat.prototype.norm = function() { + var z, i, x; + z = this; + i = z.$length; + while (i > 0 && ((x = i - 1 >> 0, ((x < 0 || x >= z.$length) ? $throwRuntimeError("index out of range") : z.$array[z.$offset + x])) === 0)) { + i = i - (1) >> 0; + } + return $subslice(z, 0, i); + }; + $ptrType(nat).prototype.norm = function() { return this.$get().norm(); }; + nat.prototype.make = function(n) { + var z; + z = this; + if (n <= z.$capacity) { + return $subslice(z, 0, n); + } + return nat.make(n, (n + 4 >> 0)); + }; + $ptrType(nat).prototype.make = function(n) { return this.$get().make(n); }; + nat.prototype.setWord = function(x) { + var z; + z = this; + if (x === 0) { + return z.make(0); + } + z = z.make(1); + (0 < 0 || 0 >= z.$length) ? $throwRuntimeError("index out of range") : z.$array[z.$offset + 0] = x; + return z; + }; + $ptrType(nat).prototype.setWord = function(x) { return this.$get().setWord(x); }; + nat.prototype.setUint64 = function(x) { + var z, w, x$1, n, t, _ref, _i, i; + z = this; + w = (x.$low >>> 0); + if ((x$1 = new $Uint64(0, w.constructor === Number ? w : 1), (x$1.$high === x.$high && x$1.$low === x.$low))) { + return z.setWord(w); + } + n = 0; + t = x; + while ((t.$high > 0 || (t.$high === 0 && t.$low > 0))) { + n = n + (1) >> 0; + t = $shiftRightUint64(t, (32)); + } + z = z.make(n); + _ref = z; + _i = 0; + while (_i < _ref.$length) { + i = _i; + (i < 0 || i >= z.$length) ? $throwRuntimeError("index out of range") : z.$array[z.$offset + i] = (new $Uint64(x.$high & 0, (x.$low & 4294967295) >>> 0).$low >>> 0); + x = $shiftRightUint64(x, (32)); + _i++; + } + return z; + }; + $ptrType(nat).prototype.setUint64 = function(x) { return this.$get().setUint64(x); }; + nat.prototype.set = function(x) { + var z; + z = this; + z = z.make(x.$length); + $copySlice(z, x); + return z; + }; + $ptrType(nat).prototype.set = function(x) { return this.$get().set(x); }; + nat.prototype.add = function(x, y) { + var z, m, n, x$1, c, x$2, x$3; + z = this; + m = x.$length; + n = y.$length; + if (m < n) { + return z.add(y, x); + } else if (m === 0) { + return z.make(0); + } else if (n === 0) { + return z.set(x); + } + z = z.make(m + 1 >> 0); + c = addVV((x$1 = $subslice(z, 0, n), $subslice(new ($sliceType(Word))(x$1.$array), x$1.$offset, x$1.$offset + x$1.$length)), $subslice(new ($sliceType(Word))(x.$array), x.$offset, x.$offset + x.$length), $subslice(new ($sliceType(Word))(y.$array), y.$offset, y.$offset + y.$length)); + if (m > n) { + c = addVW((x$2 = $subslice(z, n, m), $subslice(new ($sliceType(Word))(x$2.$array), x$2.$offset, x$2.$offset + x$2.$length)), (x$3 = $subslice(x, n), $subslice(new ($sliceType(Word))(x$3.$array), x$3.$offset, x$3.$offset + x$3.$length)), c); + } + (m < 0 || m >= z.$length) ? $throwRuntimeError("index out of range") : z.$array[z.$offset + m] = c; + return z.norm(); + }; + $ptrType(nat).prototype.add = function(x, y) { return this.$get().add(x, y); }; + nat.prototype.sub = function(x, y) { + var z, m, n, x$1, c, x$2, x$3; + z = this; + m = x.$length; + n = y.$length; + if (m < n) { + $panic(new $String("underflow")); + } else if (m === 0) { + return z.make(0); + } else if (n === 0) { + return z.set(x); + } + z = z.make(m); + c = subVV((x$1 = $subslice(z, 0, n), $subslice(new ($sliceType(Word))(x$1.$array), x$1.$offset, x$1.$offset + x$1.$length)), $subslice(new ($sliceType(Word))(x.$array), x.$offset, x.$offset + x.$length), $subslice(new ($sliceType(Word))(y.$array), y.$offset, y.$offset + y.$length)); + if (m > n) { + c = subVW((x$2 = $subslice(z, n), $subslice(new ($sliceType(Word))(x$2.$array), x$2.$offset, x$2.$offset + x$2.$length)), (x$3 = $subslice(x, n), $subslice(new ($sliceType(Word))(x$3.$array), x$3.$offset, x$3.$offset + x$3.$length)), c); + } + if (!((c === 0))) { + $panic(new $String("underflow")); + } + return z.norm(); + }; + $ptrType(nat).prototype.sub = function(x, y) { return this.$get().sub(x, y); }; + nat.prototype.cmp = function(y) { + var r = 0, x, m, n, i; + x = this; + m = x.$length; + n = y.$length; + if (!((m === n)) || (m === 0)) { + if (m < n) { + r = -1; + } else if (m > n) { + r = 1; + } + return r; + } + i = m - 1 >> 0; + while (i > 0 && (((i < 0 || i >= x.$length) ? $throwRuntimeError("index out of range") : x.$array[x.$offset + i]) === ((i < 0 || i >= y.$length) ? $throwRuntimeError("index out of range") : y.$array[y.$offset + i]))) { + i = i - (1) >> 0; + } + if (((i < 0 || i >= x.$length) ? $throwRuntimeError("index out of range") : x.$array[x.$offset + i]) < ((i < 0 || i >= y.$length) ? $throwRuntimeError("index out of range") : y.$array[y.$offset + i])) { + r = -1; + } else if (((i < 0 || i >= x.$length) ? $throwRuntimeError("index out of range") : x.$array[x.$offset + i]) > ((i < 0 || i >= y.$length) ? $throwRuntimeError("index out of range") : y.$array[y.$offset + i])) { + r = 1; + } + return r; + }; + $ptrType(nat).prototype.cmp = function(y) { return this.$get().cmp(y); }; + nat.prototype.mulAddWW = function(x, y, r) { + var z, m, x$1; + z = this; + m = x.$length; + if ((m === 0) || (y === 0)) { + return z.setWord(r); + } + z = z.make(m + 1 >> 0); + (m < 0 || m >= z.$length) ? $throwRuntimeError("index out of range") : z.$array[z.$offset + m] = mulAddVWW((x$1 = $subslice(z, 0, m), $subslice(new ($sliceType(Word))(x$1.$array), x$1.$offset, x$1.$offset + x$1.$length)), $subslice(new ($sliceType(Word))(x.$array), x.$offset, x.$offset + x.$length), y, r); + return z.norm(); + }; + $ptrType(nat).prototype.mulAddWW = function(x, y, r) { return this.$get().mulAddWW(x, y, r); }; + basicMul = function(z, x, y) { + var _ref, _i, i, d, x$1, x$2; + $subslice(z, 0, (x.$length + y.$length >> 0)).clear(); + _ref = y; + _i = 0; + while (_i < _ref.$length) { + i = _i; + d = ((_i < 0 || _i >= _ref.$length) ? $throwRuntimeError("index out of range") : _ref.$array[_ref.$offset + _i]); + if (!((d === 0))) { + (x$2 = x.$length + i >> 0, (x$2 < 0 || x$2 >= z.$length) ? $throwRuntimeError("index out of range") : z.$array[z.$offset + x$2] = addMulVVW((x$1 = $subslice(z, i, (i + x.$length >> 0)), $subslice(new ($sliceType(Word))(x$1.$array), x$1.$offset, x$1.$offset + x$1.$length)), $subslice(new ($sliceType(Word))(x.$array), x.$offset, x.$offset + x.$length), d)); + } + _i++; + } + }; + karatsubaAdd = function(z, x, n) { + var x$1, c, x$2, x$3; + c = addVV((x$1 = $subslice(z, 0, n), $subslice(new ($sliceType(Word))(x$1.$array), x$1.$offset, x$1.$offset + x$1.$length)), $subslice(new ($sliceType(Word))(z.$array), z.$offset, z.$offset + z.$length), $subslice(new ($sliceType(Word))(x.$array), x.$offset, x.$offset + x.$length)); + if (!((c === 0))) { + addVW((x$2 = $subslice(z, n, (n + (n >> 1 >> 0) >> 0)), $subslice(new ($sliceType(Word))(x$2.$array), x$2.$offset, x$2.$offset + x$2.$length)), (x$3 = $subslice(z, n), $subslice(new ($sliceType(Word))(x$3.$array), x$3.$offset, x$3.$offset + x$3.$length)), c); + } + }; + karatsubaSub = function(z, x, n) { + var x$1, c, x$2, x$3; + c = subVV((x$1 = $subslice(z, 0, n), $subslice(new ($sliceType(Word))(x$1.$array), x$1.$offset, x$1.$offset + x$1.$length)), $subslice(new ($sliceType(Word))(z.$array), z.$offset, z.$offset + z.$length), $subslice(new ($sliceType(Word))(x.$array), x.$offset, x.$offset + x.$length)); + if (!((c === 0))) { + subVW((x$2 = $subslice(z, n, (n + (n >> 1 >> 0) >> 0)), $subslice(new ($sliceType(Word))(x$2.$array), x$2.$offset, x$2.$offset + x$2.$length)), (x$3 = $subslice(z, n), $subslice(new ($sliceType(Word))(x$3.$array), x$3.$offset, x$3.$offset + x$3.$length)), c); + } + }; + karatsuba = function(z, x, y) { + var n, n2, _tmp, _tmp$1, x1, x0, _tmp$2, _tmp$3, y1, y0, s, xd, yd, p, r; + n = y.$length; + if (!(((n & 1) === 0)) || n < karatsubaThreshold || n < 2) { + basicMul(z, x, y); + return; + } + n2 = n >> 1 >> 0; + _tmp = $subslice(x, n2); _tmp$1 = $subslice(x, 0, n2); x1 = _tmp; x0 = _tmp$1; + _tmp$2 = $subslice(y, n2); _tmp$3 = $subslice(y, 0, n2); y1 = _tmp$2; y0 = _tmp$3; + karatsuba(z, x0, y0); + karatsuba($subslice(z, n), x1, y1); + s = 1; + xd = $subslice(z, ((((2 >>> 16 << 16) * n >> 0) + (2 << 16 >>> 16) * n) >> 0), (((((2 >>> 16 << 16) * n >> 0) + (2 << 16 >>> 16) * n) >> 0) + n2 >> 0)); + if (!((subVV($subslice(new ($sliceType(Word))(xd.$array), xd.$offset, xd.$offset + xd.$length), $subslice(new ($sliceType(Word))(x1.$array), x1.$offset, x1.$offset + x1.$length), $subslice(new ($sliceType(Word))(x0.$array), x0.$offset, x0.$offset + x0.$length)) === 0))) { + s = -s; + subVV($subslice(new ($sliceType(Word))(xd.$array), xd.$offset, xd.$offset + xd.$length), $subslice(new ($sliceType(Word))(x0.$array), x0.$offset, x0.$offset + x0.$length), $subslice(new ($sliceType(Word))(x1.$array), x1.$offset, x1.$offset + x1.$length)); + } + yd = $subslice(z, (((((2 >>> 16 << 16) * n >> 0) + (2 << 16 >>> 16) * n) >> 0) + n2 >> 0), ((((3 >>> 16 << 16) * n >> 0) + (3 << 16 >>> 16) * n) >> 0)); + if (!((subVV($subslice(new ($sliceType(Word))(yd.$array), yd.$offset, yd.$offset + yd.$length), $subslice(new ($sliceType(Word))(y0.$array), y0.$offset, y0.$offset + y0.$length), $subslice(new ($sliceType(Word))(y1.$array), y1.$offset, y1.$offset + y1.$length)) === 0))) { + s = -s; + subVV($subslice(new ($sliceType(Word))(yd.$array), yd.$offset, yd.$offset + yd.$length), $subslice(new ($sliceType(Word))(y1.$array), y1.$offset, y1.$offset + y1.$length), $subslice(new ($sliceType(Word))(y0.$array), y0.$offset, y0.$offset + y0.$length)); + } + p = $subslice(z, ((((n >>> 16 << 16) * 3 >> 0) + (n << 16 >>> 16) * 3) >> 0)); + karatsuba(p, xd, yd); + r = $subslice(z, ((((n >>> 16 << 16) * 4 >> 0) + (n << 16 >>> 16) * 4) >> 0)); + $copySlice(r, $subslice(z, 0, ((((n >>> 16 << 16) * 2 >> 0) + (n << 16 >>> 16) * 2) >> 0))); + karatsubaAdd($subslice(z, n2), r, n); + karatsubaAdd($subslice(z, n2), $subslice(r, n), n); + if (s > 0) { + karatsubaAdd($subslice(z, n2), p, n); + } else { + karatsubaSub($subslice(z, n2), p, n); + } + }; + alias = function(x, y) { + return x.$capacity > 0 && y.$capacity > 0 && $sliceIsEqual($subslice(x, 0, x.$capacity), (x.$capacity - 1 >> 0), $subslice(y, 0, y.$capacity), (y.$capacity - 1 >> 0)); + }; + addAt = function(z, x, i) { + var n, x$1, x$2, c, j, x$3, x$4; + n = x.$length; + if (n > 0) { + c = addVV((x$1 = $subslice(z, i, (i + n >> 0)), $subslice(new ($sliceType(Word))(x$1.$array), x$1.$offset, x$1.$offset + x$1.$length)), (x$2 = $subslice(z, i), $subslice(new ($sliceType(Word))(x$2.$array), x$2.$offset, x$2.$offset + x$2.$length)), $subslice(new ($sliceType(Word))(x.$array), x.$offset, x.$offset + x.$length)); + if (!((c === 0))) { + j = i + n >> 0; + if (j < z.$length) { + addVW((x$3 = $subslice(z, j), $subslice(new ($sliceType(Word))(x$3.$array), x$3.$offset, x$3.$offset + x$3.$length)), (x$4 = $subslice(z, j), $subslice(new ($sliceType(Word))(x$4.$array), x$4.$offset, x$4.$offset + x$4.$length)), c); + } + } + } + }; + max = function(x, y) { + if (x > y) { + return x; + } + return y; + }; + karatsubaLen = function(n) { + var i, y; + i = 0; + while (n > karatsubaThreshold) { + n = (n >> $min((1), 31)) >> 0; + i = i + (1) >>> 0; + } + return (y = i, y < 32 ? (n << y) : 0) >> 0; + }; + nat.prototype.mul = function(x, y) { + var z, m, n, k, x0, y0, t, x0$1, y1, y0$1, i, xi; + z = this; + m = x.$length; + n = y.$length; + if (m < n) { + return z.mul(y, x); + } else if ((m === 0) || (n === 0)) { + return z.make(0); + } else if (n === 1) { + return z.mulAddWW(x, ((0 < 0 || 0 >= y.$length) ? $throwRuntimeError("index out of range") : y.$array[y.$offset + 0]), 0); + } + if (alias(z, x) || alias(z, y)) { + z = nat.nil; + } + if (n < karatsubaThreshold) { + z = z.make(m + n >> 0); + basicMul(z, x, y); + return z.norm(); + } + k = karatsubaLen(n); + x0 = $subslice(x, 0, k); + y0 = $subslice(y, 0, k); + z = z.make(max((((6 >>> 16 << 16) * k >> 0) + (6 << 16 >>> 16) * k) >> 0, m + n >> 0)); + karatsuba(z, x0, y0); + z = $subslice(z, 0, (m + n >> 0)); + $subslice(z, ((((2 >>> 16 << 16) * k >> 0) + (2 << 16 >>> 16) * k) >> 0)).clear(); + if (k < n || !((m === n))) { + t = nat.nil; + x0$1 = x0.norm(); + y1 = $subslice(y, k); + t = t.mul(x0$1, y1); + addAt(z, t, k); + y0$1 = y0.norm(); + i = k; + while (i < x.$length) { + xi = $subslice(x, i); + if (xi.$length > k) { + xi = $subslice(xi, 0, k); + } + xi = xi.norm(); + t = t.mul(xi, y0$1); + addAt(z, t, i); + t = t.mul(xi, y1); + addAt(z, t, i + k >> 0); + i = i + (k) >> 0; + } + } + return z.norm(); + }; + $ptrType(nat).prototype.mul = function(x, y) { return this.$get().mul(x, y); }; + nat.prototype.mulRange = function(a, b) { + var z, x, m; + z = this; + if ((a.$high === 0 && a.$low === 0)) { + return z.setUint64(new $Uint64(0, 0)); + } else if ((a.$high > b.$high || (a.$high === b.$high && a.$low > b.$low))) { + return z.setUint64(new $Uint64(0, 1)); + } else if ((a.$high === b.$high && a.$low === b.$low)) { + return z.setUint64(a); + } else if ((x = new $Uint64(a.$high + 0, a.$low + 1), (x.$high === b.$high && x.$low === b.$low))) { + return z.mul(nat.nil.setUint64(a), nat.nil.setUint64(b)); + } + m = $div64((new $Uint64(a.$high + b.$high, a.$low + b.$low)), new $Uint64(0, 2), false); + return z.mul(nat.nil.mulRange(a, m), nat.nil.mulRange(new $Uint64(m.$high + 0, m.$low + 1), b)); + }; + $ptrType(nat).prototype.mulRange = function(a, b) { return this.$get().mulRange(a, b); }; + nat.prototype.divW = function(x, y) { + var q = nat.nil, r = 0, z, m; + z = this; + m = x.$length; + if (y === 0) { + $panic(new $String("division by zero")); + } else if (y === 1) { + q = z.set(x); + return [q, r]; + } else if (m === 0) { + q = z.make(0); + return [q, r]; + } + z = z.make(m); + r = divWVW($subslice(new ($sliceType(Word))(z.$array), z.$offset, z.$offset + z.$length), 0, $subslice(new ($sliceType(Word))(x.$array), x.$offset, x.$offset + x.$length), y); + q = z.norm(); + return [q, r]; + }; + $ptrType(nat).prototype.divW = function(x, y) { return this.$get().divW(x, y); }; + nat.prototype.div = function(z2, u, v) { + var q = nat.nil, r = nat.nil, z, r2, _tuple, _tuple$1; + z = this; + if (v.$length === 0) { + $panic(new $String("division by zero")); + } + if (u.cmp(v) < 0) { + q = z.make(0); + r = z2.set(u); + return [q, r]; + } + if (v.$length === 1) { + r2 = 0; + _tuple = z.divW(u, ((0 < 0 || 0 >= v.$length) ? $throwRuntimeError("index out of range") : v.$array[v.$offset + 0])); q = _tuple[0]; r2 = _tuple[1]; + r = z2.setWord(r2); + return [q, r]; + } + _tuple$1 = z.divLarge(z2, u, v); q = _tuple$1[0]; r = _tuple$1[1]; + return [q, r]; + }; + $ptrType(nat).prototype.div = function(z2, u, v) { return this.$get().div(z2, u, v); }; + nat.prototype.divLarge = function(u, uIn, v) { + var q = nat.nil, r = nat.nil, z, n, m, qhatv, x, shift, v1, x$1, x$2, j, qhat, x$3, x$4, rhat, _tuple, x$5, x$6, x$7, _tuple$1, x$8, x1, x2, x$9, prevRhat, x$10, _tuple$2, x$11, x$12, x$13, x$14, c, x$15, x$16, c$1, _lhs, _index, _tmp, _tmp$1; + z = this; + n = v.$length; + m = uIn.$length - n >> 0; + if (alias(z, uIn) || alias(z, v)) { + z = nat.nil; + } + q = z.make(m + 1 >> 0); + qhatv = nat.make((n + 1 >> 0)); + if (alias(u, uIn) || alias(u, v)) { + u = nat.nil; + } + u = u.make(uIn.$length + 1 >> 0); + u.clear(); + shift = leadingZeros((x = n - 1 >> 0, ((x < 0 || x >= v.$length) ? $throwRuntimeError("index out of range") : v.$array[v.$offset + x]))); + if (shift > 0) { + v1 = nat.make(n); + shlVU($subslice(new ($sliceType(Word))(v1.$array), v1.$offset, v1.$offset + v1.$length), $subslice(new ($sliceType(Word))(v.$array), v.$offset, v.$offset + v.$length), shift); + v = v1; + } + (x$2 = uIn.$length, (x$2 < 0 || x$2 >= u.$length) ? $throwRuntimeError("index out of range") : u.$array[u.$offset + x$2] = shlVU((x$1 = $subslice(u, 0, uIn.$length), $subslice(new ($sliceType(Word))(x$1.$array), x$1.$offset, x$1.$offset + x$1.$length)), $subslice(new ($sliceType(Word))(uIn.$array), uIn.$offset, uIn.$offset + uIn.$length), shift)); + j = m; + while (j >= 0) { + qhat = 4294967295; + if (!(((x$3 = j + n >> 0, ((x$3 < 0 || x$3 >= u.$length) ? $throwRuntimeError("index out of range") : u.$array[u.$offset + x$3])) === (x$4 = n - 1 >> 0, ((x$4 < 0 || x$4 >= v.$length) ? $throwRuntimeError("index out of range") : v.$array[v.$offset + x$4]))))) { + rhat = 0; + _tuple = divWW((x$5 = j + n >> 0, ((x$5 < 0 || x$5 >= u.$length) ? $throwRuntimeError("index out of range") : u.$array[u.$offset + x$5])), (x$6 = (j + n >> 0) - 1 >> 0, ((x$6 < 0 || x$6 >= u.$length) ? $throwRuntimeError("index out of range") : u.$array[u.$offset + x$6])), (x$7 = n - 1 >> 0, ((x$7 < 0 || x$7 >= v.$length) ? $throwRuntimeError("index out of range") : v.$array[v.$offset + x$7]))); qhat = _tuple[0]; rhat = _tuple[1]; + _tuple$1 = mulWW(qhat, (x$8 = n - 2 >> 0, ((x$8 < 0 || x$8 >= v.$length) ? $throwRuntimeError("index out of range") : v.$array[v.$offset + x$8]))); x1 = _tuple$1[0]; x2 = _tuple$1[1]; + while (greaterThan(x1, x2, rhat, (x$9 = (j + n >> 0) - 2 >> 0, ((x$9 < 0 || x$9 >= u.$length) ? $throwRuntimeError("index out of range") : u.$array[u.$offset + x$9])))) { + qhat = qhat - (1) >>> 0; + prevRhat = rhat; + rhat = rhat + ((x$10 = n - 1 >> 0, ((x$10 < 0 || x$10 >= v.$length) ? $throwRuntimeError("index out of range") : v.$array[v.$offset + x$10]))) >>> 0; + if (rhat < prevRhat) { + break; + } + _tuple$2 = mulWW(qhat, (x$11 = n - 2 >> 0, ((x$11 < 0 || x$11 >= v.$length) ? $throwRuntimeError("index out of range") : v.$array[v.$offset + x$11]))); x1 = _tuple$2[0]; x2 = _tuple$2[1]; + } + } + (n < 0 || n >= qhatv.$length) ? $throwRuntimeError("index out of range") : qhatv.$array[qhatv.$offset + n] = mulAddVWW((x$12 = $subslice(qhatv, 0, n), $subslice(new ($sliceType(Word))(x$12.$array), x$12.$offset, x$12.$offset + x$12.$length)), $subslice(new ($sliceType(Word))(v.$array), v.$offset, v.$offset + v.$length), qhat, 0); + c = subVV((x$13 = $subslice(u, j, (j + qhatv.$length >> 0)), $subslice(new ($sliceType(Word))(x$13.$array), x$13.$offset, x$13.$offset + x$13.$length)), (x$14 = $subslice(u, j), $subslice(new ($sliceType(Word))(x$14.$array), x$14.$offset, x$14.$offset + x$14.$length)), $subslice(new ($sliceType(Word))(qhatv.$array), qhatv.$offset, qhatv.$offset + qhatv.$length)); + if (!((c === 0))) { + c$1 = addVV((x$15 = $subslice(u, j, (j + n >> 0)), $subslice(new ($sliceType(Word))(x$15.$array), x$15.$offset, x$15.$offset + x$15.$length)), (x$16 = $subslice(u, j), $subslice(new ($sliceType(Word))(x$16.$array), x$16.$offset, x$16.$offset + x$16.$length)), $subslice(new ($sliceType(Word))(v.$array), v.$offset, v.$offset + v.$length)); + _lhs = u; _index = j + n >> 0; (_index < 0 || _index >= _lhs.$length) ? $throwRuntimeError("index out of range") : _lhs.$array[_lhs.$offset + _index] = ((_index < 0 || _index >= _lhs.$length) ? $throwRuntimeError("index out of range") : _lhs.$array[_lhs.$offset + _index]) + (c$1) >>> 0; + qhat = qhat - (1) >>> 0; + } + (j < 0 || j >= q.$length) ? $throwRuntimeError("index out of range") : q.$array[q.$offset + j] = qhat; + j = j - (1) >> 0; + } + q = q.norm(); + shrVU($subslice(new ($sliceType(Word))(u.$array), u.$offset, u.$offset + u.$length), $subslice(new ($sliceType(Word))(u.$array), u.$offset, u.$offset + u.$length), shift); + r = u.norm(); + _tmp = q; _tmp$1 = r; q = _tmp; r = _tmp$1; + return [q, r]; + }; + $ptrType(nat).prototype.divLarge = function(u, uIn, v) { return this.$get().divLarge(u, uIn, v); }; + nat.prototype.bitLen = function() { + var x, i; + x = this; + i = x.$length - 1 >> 0; + if (i >= 0) { + return ((((i >>> 16 << 16) * 32 >> 0) + (i << 16 >>> 16) * 32) >> 0) + bitLen(((i < 0 || i >= x.$length) ? $throwRuntimeError("index out of range") : x.$array[x.$offset + i])) >> 0; + } + return 0; + }; + $ptrType(nat).prototype.bitLen = function() { return this.$get().bitLen(); }; + hexValue = function(ch) { + var d; + d = 37; + if (48 <= ch && ch <= 57) { + d = ((ch - 48 >> 0) >> 0); + } else if (97 <= ch && ch <= 122) { + d = (((ch - 97 >> 0) + 10 >> 0) >> 0); + } else if (65 <= ch && ch <= 90) { + d = (((ch - 65 >> 0) + 10 >> 0) >> 0); + } + return (d >>> 0); + }; + nat.prototype.scan = function(r, base) { + var z, _tuple, ch, err, b, _tuple$1, _ref, _ref$1, _tuple$2, bb, dd, _q, max$1, d, x, _tuple$3; + z = this; + if (base < 0 || (base === 1) || 36 < base) { + return [z, 0, errors.New("illegal number base")]; + } + _tuple = r.ReadRune(); ch = _tuple[0]; err = _tuple[2]; + if (!($interfaceIsEqual(err, $ifaceNil))) { + return [z, 0, err]; + } + b = (base >>> 0); + if (base === 0) { + b = 10; + if (ch === 48) { + _tuple$1 = r.ReadRune(); ch = _tuple$1[0]; err = _tuple$1[2]; + _ref = err; + if ($interfaceIsEqual(_ref, $ifaceNil)) { + b = 8; + _ref$1 = ch; + if (_ref$1 === 120 || _ref$1 === 88) { + b = 16; + } else if (_ref$1 === 98 || _ref$1 === 66) { + b = 2; + } + if ((b === 2) || (b === 16)) { + _tuple$2 = r.ReadRune(); ch = _tuple$2[0]; err = _tuple$2[2]; + if (!($interfaceIsEqual(err, $ifaceNil))) { + return [z, 0, err]; + } + } + } else if ($interfaceIsEqual(_ref, io.EOF)) { + return [z.make(0), 10, $ifaceNil]; + } else { + return [z, 10, err]; + } } - walkExprList(v, n.Elts); - } else if ($assertType(_ref, ($ptrType(ParenExpr)), true)[1]) { - n = _ref.$val; - Walk(v, n.X); - } else if ($assertType(_ref, ($ptrType(SelectorExpr)), true)[1]) { - n = _ref.$val; - Walk(v, n.X); - Walk(v, n.Sel); - } else if ($assertType(_ref, ($ptrType(IndexExpr)), true)[1]) { - n = _ref.$val; - Walk(v, n.X); - Walk(v, n.Index); - } else if ($assertType(_ref, ($ptrType(SliceExpr)), true)[1]) { - n = _ref.$val; - Walk(v, n.X); - if (!($interfaceIsEqual(n.Low, $ifaceNil))) { - Walk(v, n.Low); + } + z = z.make(0); + bb = 1; + dd = 0; + max$1 = (_q = 4294967295 / b, (_q === _q && _q !== 1/0 && _q !== -1/0) ? _q >>> 0 : $throwRuntimeError("integer divide by zero")); + while (true) { + d = hexValue(ch); + if (d >= b) { + r.UnreadRune(); + break; } - if (!($interfaceIsEqual(n.High, $ifaceNil))) { - Walk(v, n.High); + if (bb <= max$1) { + bb = (x = b, (((bb >>> 16 << 16) * x >>> 0) + (bb << 16 >>> 16) * x) >>> 0); + dd = ((((dd >>> 16 << 16) * b >>> 0) + (dd << 16 >>> 16) * b) >>> 0) + d >>> 0; + } else { + z = z.mulAddWW(z, bb, dd); + bb = b; + dd = d; } - if (!($interfaceIsEqual(n.Max, $ifaceNil))) { - Walk(v, n.Max); + _tuple$3 = r.ReadRune(); ch = _tuple$3[0]; err = _tuple$3[2]; + if (!($interfaceIsEqual(err, $ifaceNil))) { + if (!($interfaceIsEqual(err, io.EOF))) { + return [z, (b >> 0), err]; + } + break; } - } else if ($assertType(_ref, ($ptrType(TypeAssertExpr)), true)[1]) { - n = _ref.$val; - Walk(v, n.X); - if (!($interfaceIsEqual(n.Type, $ifaceNil))) { - Walk(v, n.Type); + } + if (bb > 1) { + z = z.mulAddWW(z, bb, dd); + } else if ((base === 0) && (b === 8)) { + return [z, 10, $ifaceNil]; + } else if (!((base === 0)) || !((b === 8))) { + return [z, (b >> 0), errors.New("syntax error scanning number")]; + } + return [z.norm(), (b >> 0), $ifaceNil]; + }; + $ptrType(nat).prototype.scan = function(r, base) { return this.$get().scan(r, base); }; + nat.prototype.decimalString = function() { + var x; + x = this; + return x.string("0123456789abcdefghijklmnopqrstuvwxyz".substring(0, 10)); + }; + $ptrType(nat).prototype.decimalString = function() { return this.$get().decimalString(); }; + nat.prototype.string = function(charset$1) { + var x, b, i, s, shift, y, mask, w, nbits, k, y$1, y$2, y$3, y$4, bb, ndigits, _q, max$1, x$1, table, q, zero; + x = this; + b = (charset$1.length >>> 0); + if (b < 2 || false) { + $panic(new $String("illegal base")); + } else if (x.$length === 0) { + return $encodeRune(charset$1.charCodeAt(0)); + } + i = (x.bitLen() / math.Log2(b) >> 0) + 1 >> 0; + s = ($sliceType($Uint8)).make(i); + if (b === ((b & (-b >>> 0)) >>> 0)) { + shift = trailingZeroBits(b); + mask = ((y = shift, y < 32 ? (1 << y) : 0) >>> 0) - 1 >>> 0; + w = ((0 < 0 || 0 >= x.$length) ? $throwRuntimeError("index out of range") : x.$array[x.$offset + 0]); + nbits = 32; + k = 1; + while (k < x.$length) { + while (nbits >= shift) { + i = i - (1) >> 0; + (i < 0 || i >= s.$length) ? $throwRuntimeError("index out of range") : s.$array[s.$offset + i] = charset$1.charCodeAt(((w & mask) >>> 0)); + w = (y$1 = (shift), y$1 < 32 ? (w >>> y$1) : 0) >>> 0; + nbits = nbits - (shift) >>> 0; + } + if (nbits === 0) { + w = ((k < 0 || k >= x.$length) ? $throwRuntimeError("index out of range") : x.$array[x.$offset + k]); + nbits = 32; + } else { + w = (w | (((y$2 = nbits, y$2 < 32 ? (((k < 0 || k >= x.$length) ? $throwRuntimeError("index out of range") : x.$array[x.$offset + k]) << y$2) : 0) >>> 0))) >>> 0; + i = i - (1) >> 0; + (i < 0 || i >= s.$length) ? $throwRuntimeError("index out of range") : s.$array[s.$offset + i] = charset$1.charCodeAt(((w & mask) >>> 0)); + w = (y$3 = ((shift - nbits >>> 0)), y$3 < 32 ? (((k < 0 || k >= x.$length) ? $throwRuntimeError("index out of range") : x.$array[x.$offset + k]) >>> y$3) : 0) >>> 0; + nbits = 32 - ((shift - nbits >>> 0)) >>> 0; + } + k = k + (1) >> 0; } - } else if ($assertType(_ref, ($ptrType(CallExpr)), true)[1]) { - n = _ref.$val; - Walk(v, n.Fun); - walkExprList(v, n.Args); - } else if ($assertType(_ref, ($ptrType(StarExpr)), true)[1]) { - n = _ref.$val; - Walk(v, n.X); - } else if ($assertType(_ref, ($ptrType(UnaryExpr)), true)[1]) { - n = _ref.$val; - Walk(v, n.X); - } else if ($assertType(_ref, ($ptrType(BinaryExpr)), true)[1]) { - n = _ref.$val; - Walk(v, n.X); - Walk(v, n.Y); - } else if ($assertType(_ref, ($ptrType(KeyValueExpr)), true)[1]) { - n = _ref.$val; - Walk(v, n.Key); - Walk(v, n.Value); - } else if ($assertType(_ref, ($ptrType(ArrayType)), true)[1]) { - n = _ref.$val; - if (!($interfaceIsEqual(n.Len, $ifaceNil))) { - Walk(v, n.Len); + while (nbits >= 0 && !((w === 0))) { + i = i - (1) >> 0; + (i < 0 || i >= s.$length) ? $throwRuntimeError("index out of range") : s.$array[s.$offset + i] = charset$1.charCodeAt(((w & mask) >>> 0)); + w = (y$4 = (shift), y$4 < 32 ? (w >>> y$4) : 0) >>> 0; + nbits = nbits - (shift) >>> 0; } - Walk(v, n.Elt); - } else if ($assertType(_ref, ($ptrType(StructType)), true)[1]) { - n = _ref.$val; - Walk(v, n.Fields); - } else if ($assertType(_ref, ($ptrType(FuncType)), true)[1]) { - n = _ref.$val; - if (!(n.Params === ($ptrType(FieldList)).nil)) { - Walk(v, n.Params); + } else { + bb = b; + ndigits = 1; + max$1 = (_q = 4294967295 / b, (_q === _q && _q !== 1/0 && _q !== -1/0) ? _q >>> 0 : $throwRuntimeError("integer divide by zero")); + while (bb <= max$1) { + ndigits = ndigits + (1) >> 0; + bb = (x$1 = b, (((bb >>> 16 << 16) * x$1 >>> 0) + (bb << 16 >>> 16) * x$1) >>> 0); } - if (!(n.Results === ($ptrType(FieldList)).nil)) { - Walk(v, n.Results); + table = divisors(x.$length, b, ndigits, bb); + q = nat.nil.set(x); + q.convertWords(s, charset$1, b, ndigits, bb, table); + i = 0; + zero = charset$1.charCodeAt(0); + while (((i < 0 || i >= s.$length) ? $throwRuntimeError("index out of range") : s.$array[s.$offset + i]) === zero) { + i = i + (1) >> 0; } - } else if ($assertType(_ref, ($ptrType(InterfaceType)), true)[1]) { - n = _ref.$val; - Walk(v, n.Methods); - } else if ($assertType(_ref, ($ptrType(MapType)), true)[1]) { - n = _ref.$val; - Walk(v, n.Key); - Walk(v, n.Value); - } else if ($assertType(_ref, ($ptrType(ChanType)), true)[1]) { - n = _ref.$val; - Walk(v, n.Value); - } else if ($assertType(_ref, ($ptrType(BadStmt)), true)[1]) { - n = _ref.$val; - } else if ($assertType(_ref, ($ptrType(DeclStmt)), true)[1]) { - n = _ref.$val; - Walk(v, n.Decl); - } else if ($assertType(_ref, ($ptrType(EmptyStmt)), true)[1]) { - n = _ref.$val; - } else if ($assertType(_ref, ($ptrType(LabeledStmt)), true)[1]) { - n = _ref.$val; - Walk(v, n.Label); - Walk(v, n.Stmt); - } else if ($assertType(_ref, ($ptrType(ExprStmt)), true)[1]) { - n = _ref.$val; - Walk(v, n.X); - } else if ($assertType(_ref, ($ptrType(SendStmt)), true)[1]) { - n = _ref.$val; - Walk(v, n.Chan); - Walk(v, n.Value); - } else if ($assertType(_ref, ($ptrType(IncDecStmt)), true)[1]) { - n = _ref.$val; - Walk(v, n.X); - } else if ($assertType(_ref, ($ptrType(AssignStmt)), true)[1]) { - n = _ref.$val; - walkExprList(v, n.Lhs); - walkExprList(v, n.Rhs); - } else if ($assertType(_ref, ($ptrType(GoStmt)), true)[1]) { - n = _ref.$val; - Walk(v, n.Call); - } else if ($assertType(_ref, ($ptrType(DeferStmt)), true)[1]) { - n = _ref.$val; - Walk(v, n.Call); - } else if ($assertType(_ref, ($ptrType(ReturnStmt)), true)[1]) { - n = _ref.$val; - walkExprList(v, n.Results); - } else if ($assertType(_ref, ($ptrType(BranchStmt)), true)[1]) { - n = _ref.$val; - if (!(n.Label === ($ptrType(Ident)).nil)) { - Walk(v, n.Label); + } + return $bytesToString($subslice(s, i)); + }; + $ptrType(nat).prototype.string = function(charset$1) { return this.$get().string(charset$1); }; + nat.prototype.convertWords = function(s, charset$1, b, ndigits, bb, table) { + var q, r, index, maxLength, minLength, x, _tuple, h, i, r$1, _tuple$1, j, _q, t, _tuple$2, j$1, _r, _q$1, zero; + q = this; + if (!(table === ($sliceType(divisor)).nil)) { + r = nat.nil; + index = table.$length - 1 >> 0; + while (q.$length > leafSize) { + maxLength = q.bitLen(); + minLength = maxLength >> 1 >> 0; + while (index > 0 && (x = index - 1 >> 0, ((x < 0 || x >= table.$length) ? $throwRuntimeError("index out of range") : table.$array[table.$offset + x])).nbits > minLength) { + index = index - (1) >> 0; + } + if (((index < 0 || index >= table.$length) ? $throwRuntimeError("index out of range") : table.$array[table.$offset + index]).nbits >= maxLength && ((index < 0 || index >= table.$length) ? $throwRuntimeError("index out of range") : table.$array[table.$offset + index]).bbb.cmp(q) >= 0) { + index = index - (1) >> 0; + if (index < 0) { + $panic(new $String("internal inconsistency")); + } + } + _tuple = q.div(r, q, ((index < 0 || index >= table.$length) ? $throwRuntimeError("index out of range") : table.$array[table.$offset + index]).bbb); q = _tuple[0]; r = _tuple[1]; + h = s.$length - ((index < 0 || index >= table.$length) ? $throwRuntimeError("index out of range") : table.$array[table.$offset + index]).ndigits >> 0; + r.convertWords($subslice(s, h), charset$1, b, ndigits, bb, $subslice(table, 0, index)); + s = $subslice(s, 0, h); } - } else if ($assertType(_ref, ($ptrType(BlockStmt)), true)[1]) { - n = _ref.$val; - walkStmtList(v, n.List); - } else if ($assertType(_ref, ($ptrType(IfStmt)), true)[1]) { - n = _ref.$val; - if (!($interfaceIsEqual(n.Init, $ifaceNil))) { - Walk(v, n.Init); + } + i = s.$length; + r$1 = 0; + if (b === 10) { + while (q.$length > 0) { + _tuple$1 = q.divW(q, bb); q = _tuple$1[0]; r$1 = _tuple$1[1]; + j = 0; + while (j < ndigits && i > 0) { + i = i - (1) >> 0; + t = (_q = r$1 / 10, (_q === _q && _q !== 1/0 && _q !== -1/0) ? _q >>> 0 : $throwRuntimeError("integer divide by zero")); + (i < 0 || i >= s.$length) ? $throwRuntimeError("index out of range") : s.$array[s.$offset + i] = charset$1.charCodeAt((((r$1 - (t << 3 >>> 0) >>> 0) - t >>> 0) - t >>> 0)); + r$1 = t; + j = j + (1) >> 0; + } } - Walk(v, n.Cond); - Walk(v, n.Body); - if (!($interfaceIsEqual(n.Else, $ifaceNil))) { - Walk(v, n.Else); + } else { + while (q.$length > 0) { + _tuple$2 = q.divW(q, bb); q = _tuple$2[0]; r$1 = _tuple$2[1]; + j$1 = 0; + while (j$1 < ndigits && i > 0) { + i = i - (1) >> 0; + (i < 0 || i >= s.$length) ? $throwRuntimeError("index out of range") : s.$array[s.$offset + i] = charset$1.charCodeAt((_r = r$1 % b, _r === _r ? _r : $throwRuntimeError("integer divide by zero"))); + r$1 = (_q$1 = r$1 / (b), (_q$1 === _q$1 && _q$1 !== 1/0 && _q$1 !== -1/0) ? _q$1 >>> 0 : $throwRuntimeError("integer divide by zero")); + j$1 = j$1 + (1) >> 0; + } } - } else if ($assertType(_ref, ($ptrType(CaseClause)), true)[1]) { - n = _ref.$val; - walkExprList(v, n.List); - walkStmtList(v, n.Body); - } else if ($assertType(_ref, ($ptrType(SwitchStmt)), true)[1]) { - n = _ref.$val; - if (!($interfaceIsEqual(n.Init, $ifaceNil))) { - Walk(v, n.Init); + } + zero = charset$1.charCodeAt(0); + while (i > 0) { + i = i - (1) >> 0; + (i < 0 || i >= s.$length) ? $throwRuntimeError("index out of range") : s.$array[s.$offset + i] = zero; + } + }; + $ptrType(nat).prototype.convertWords = function(s, charset$1, b, ndigits, bb, table) { return this.$get().convertWords(s, charset$1, b, ndigits, bb, table); }; + nat.prototype.expWW = function(x, y) { + var z; + z = this; + return z.expNN(nat.nil.setWord(x), nat.nil.setWord(y), nat.nil); + }; + $ptrType(nat).prototype.expWW = function(x, y) { return this.$get().expWW(x, y); }; + divisors = function(m, b, ndigits, bb) { + var k, words, y, table, x, larger, i, x$1, x$2, x$3, x$4; + if ((leafSize === 0) || m <= leafSize) { + return ($sliceType(divisor)).nil; + } + k = 1; + words = leafSize; + while (words < (m >> 1 >> 0) && k < 64) { + k = k + (1) >> 0; + words = (y = (1), y < 32 ? (words << y) : 0) >> 0; + } + table = ($sliceType(divisor)).nil; + if (b === 10) { + cacheBase10.Mutex.Lock(); + table = $subslice(new ($sliceType(divisor))(cacheBase10.table), 0, k); + } else { + table = ($sliceType(divisor)).make(k); + } + if ((x = k - 1 >> 0, ((x < 0 || x >= table.$length) ? $throwRuntimeError("index out of range") : table.$array[table.$offset + x])).ndigits === 0) { + larger = nat.nil; + i = 0; + while (i < k) { + if (((i < 0 || i >= table.$length) ? $throwRuntimeError("index out of range") : table.$array[table.$offset + i]).ndigits === 0) { + if (i === 0) { + ((0 < 0 || 0 >= table.$length) ? $throwRuntimeError("index out of range") : table.$array[table.$offset + 0]).bbb = nat.nil.expWW(bb, (leafSize >>> 0)); + ((0 < 0 || 0 >= table.$length) ? $throwRuntimeError("index out of range") : table.$array[table.$offset + 0]).ndigits = (((ndigits >>> 16 << 16) * leafSize >> 0) + (ndigits << 16 >>> 16) * leafSize) >> 0; + } else { + ((i < 0 || i >= table.$length) ? $throwRuntimeError("index out of range") : table.$array[table.$offset + i]).bbb = nat.nil.mul((x$1 = i - 1 >> 0, ((x$1 < 0 || x$1 >= table.$length) ? $throwRuntimeError("index out of range") : table.$array[table.$offset + x$1])).bbb, (x$2 = i - 1 >> 0, ((x$2 < 0 || x$2 >= table.$length) ? $throwRuntimeError("index out of range") : table.$array[table.$offset + x$2])).bbb); + ((i < 0 || i >= table.$length) ? $throwRuntimeError("index out of range") : table.$array[table.$offset + i]).ndigits = (x$3 = (x$4 = i - 1 >> 0, ((x$4 < 0 || x$4 >= table.$length) ? $throwRuntimeError("index out of range") : table.$array[table.$offset + x$4])).ndigits, (((2 >>> 16 << 16) * x$3 >> 0) + (2 << 16 >>> 16) * x$3) >> 0); + } + larger = nat.nil.set(((i < 0 || i >= table.$length) ? $throwRuntimeError("index out of range") : table.$array[table.$offset + i]).bbb); + while (mulAddVWW($subslice(new ($sliceType(Word))(larger.$array), larger.$offset, larger.$offset + larger.$length), $subslice(new ($sliceType(Word))(larger.$array), larger.$offset, larger.$offset + larger.$length), b, 0) === 0) { + ((i < 0 || i >= table.$length) ? $throwRuntimeError("index out of range") : table.$array[table.$offset + i]).bbb = ((i < 0 || i >= table.$length) ? $throwRuntimeError("index out of range") : table.$array[table.$offset + i]).bbb.set(larger); + ((i < 0 || i >= table.$length) ? $throwRuntimeError("index out of range") : table.$array[table.$offset + i]).ndigits = ((i < 0 || i >= table.$length) ? $throwRuntimeError("index out of range") : table.$array[table.$offset + i]).ndigits + (1) >> 0; + } + ((i < 0 || i >= table.$length) ? $throwRuntimeError("index out of range") : table.$array[table.$offset + i]).nbits = ((i < 0 || i >= table.$length) ? $throwRuntimeError("index out of range") : table.$array[table.$offset + i]).bbb.bitLen(); + } + i = i + (1) >> 0; } - if (!($interfaceIsEqual(n.Tag, $ifaceNil))) { - Walk(v, n.Tag); + } + if (b === 10) { + cacheBase10.Mutex.Unlock(); + } + return table; + }; + trailingZeroBits = function(x) { + var _ref, x$1, x$2, x$3, x$4; + _ref = 32; + if (_ref === 32) { + return ((x$1 = ((x$2 = ((x & (-x >>> 0)) >>> 0), (((x$2 >>> 16 << 16) * 125613361 >>> 0) + (x$2 << 16 >>> 16) * 125613361) >>> 0)) >>> 27 >>> 0, ((x$1 < 0 || x$1 >= deBruijn32Lookup.$length) ? $throwRuntimeError("index out of range") : deBruijn32Lookup.$array[deBruijn32Lookup.$offset + x$1])) >>> 0); + } else if (_ref === 64) { + return ((x$3 = ((x$4 = ((x & (-x >>> 0)) >>> 0), (((x$4 >>> 16 << 16) * 3033172745 >>> 0) + (x$4 << 16 >>> 16) * 3033172745) >>> 0)) >>> 58 >>> 0, ((x$3 < 0 || x$3 >= deBruijn64Lookup.$length) ? $throwRuntimeError("index out of range") : deBruijn64Lookup.$array[deBruijn64Lookup.$offset + x$3])) >>> 0); + } else { + $panic(new $String("unknown word size")); + } + }; + nat.prototype.trailingZeroBits = function() { + var x, i; + x = this; + if (x.$length === 0) { + return 0; + } + i = 0; + while (((i < 0 || i >= x.$length) ? $throwRuntimeError("index out of range") : x.$array[x.$offset + i]) === 0) { + i = i + (1) >>> 0; + } + return ((((i >>> 16 << 16) * 32 >>> 0) + (i << 16 >>> 16) * 32) >>> 0) + trailingZeroBits(((i < 0 || i >= x.$length) ? $throwRuntimeError("index out of range") : x.$array[x.$offset + i])) >>> 0; + }; + $ptrType(nat).prototype.trailingZeroBits = function() { return this.$get().trailingZeroBits(); }; + nat.prototype.shl = function(x, s) { + var z, m, _q, n, x$1, _r; + z = this; + m = x.$length; + if (m === 0) { + return z.make(0); + } + n = m + ((_q = s / 32, (_q === _q && _q !== 1/0 && _q !== -1/0) ? _q >>> 0 : $throwRuntimeError("integer divide by zero")) >> 0) >> 0; + z = z.make(n + 1 >> 0); + (n < 0 || n >= z.$length) ? $throwRuntimeError("index out of range") : z.$array[z.$offset + n] = shlVU((x$1 = $subslice(z, (n - m >> 0), n), $subslice(new ($sliceType(Word))(x$1.$array), x$1.$offset, x$1.$offset + x$1.$length)), $subslice(new ($sliceType(Word))(x.$array), x.$offset, x.$offset + x.$length), (_r = s % 32, _r === _r ? _r : $throwRuntimeError("integer divide by zero"))); + $subslice(z, 0, (n - m >> 0)).clear(); + return z.norm(); + }; + $ptrType(nat).prototype.shl = function(x, s) { return this.$get().shl(x, s); }; + nat.prototype.shr = function(x, s) { + var z, m, _q, n, x$1, _r; + z = this; + m = x.$length; + n = m - ((_q = s / 32, (_q === _q && _q !== 1/0 && _q !== -1/0) ? _q >>> 0 : $throwRuntimeError("integer divide by zero")) >> 0) >> 0; + if (n <= 0) { + return z.make(0); + } + z = z.make(n); + shrVU($subslice(new ($sliceType(Word))(z.$array), z.$offset, z.$offset + z.$length), (x$1 = $subslice(x, (m - n >> 0)), $subslice(new ($sliceType(Word))(x$1.$array), x$1.$offset, x$1.$offset + x$1.$length)), (_r = s % 32, _r === _r ? _r : $throwRuntimeError("integer divide by zero"))); + return z.norm(); + }; + $ptrType(nat).prototype.shr = function(x, s) { return this.$get().shr(x, s); }; + nat.prototype.setBit = function(x, i, b) { + var z, _q, j, y, _r, m, n, _ref, _lhs, _index, _lhs$1, _index$1; + z = this; + j = ((_q = i / 32, (_q === _q && _q !== 1/0 && _q !== -1/0) ? _q >>> 0 : $throwRuntimeError("integer divide by zero")) >> 0); + m = (y = ((_r = i % 32, _r === _r ? _r : $throwRuntimeError("integer divide by zero"))), y < 32 ? (1 << y) : 0) >>> 0; + n = x.$length; + _ref = b; + if (_ref === 0) { + z = z.make(n); + $copySlice(z, x); + if (j >= n) { + return z; } - Walk(v, n.Body); - } else if ($assertType(_ref, ($ptrType(TypeSwitchStmt)), true)[1]) { - n = _ref.$val; - if (!($interfaceIsEqual(n.Init, $ifaceNil))) { - Walk(v, n.Init); + _lhs = z; _index = j; (_index < 0 || _index >= _lhs.$length) ? $throwRuntimeError("index out of range") : _lhs.$array[_lhs.$offset + _index] = ((_index < 0 || _index >= _lhs.$length) ? $throwRuntimeError("index out of range") : _lhs.$array[_lhs.$offset + _index]) & ~(m); + return z.norm(); + } else if (_ref === 1) { + if (j >= n) { + z = z.make(j + 1 >> 0); + $subslice(z, n).clear(); + } else { + z = z.make(n); } - Walk(v, n.Assign); - Walk(v, n.Body); - } else if ($assertType(_ref, ($ptrType(CommClause)), true)[1]) { - n = _ref.$val; - if (!($interfaceIsEqual(n.Comm, $ifaceNil))) { - Walk(v, n.Comm); + $copySlice(z, x); + _lhs$1 = z; _index$1 = j; (_index$1 < 0 || _index$1 >= _lhs$1.$length) ? $throwRuntimeError("index out of range") : _lhs$1.$array[_lhs$1.$offset + _index$1] = (((_index$1 < 0 || _index$1 >= _lhs$1.$length) ? $throwRuntimeError("index out of range") : _lhs$1.$array[_lhs$1.$offset + _index$1]) | (m)) >>> 0; + return z; + } + $panic(new $String("set bit is not 0 or 1")); + }; + $ptrType(nat).prototype.setBit = function(x, i, b) { return this.$get().setBit(x, i, b); }; + nat.prototype.bit = function(i) { + var z, _q, j, y, _r; + z = this; + j = ((_q = i / 32, (_q === _q && _q !== 1/0 && _q !== -1/0) ? _q >>> 0 : $throwRuntimeError("integer divide by zero")) >> 0); + if (j >= z.$length) { + return 0; + } + return (((((y = ((_r = i % 32, _r === _r ? _r : $throwRuntimeError("integer divide by zero"))), y < 32 ? (((j < 0 || j >= z.$length) ? $throwRuntimeError("index out of range") : z.$array[z.$offset + j]) >>> y) : 0) >>> 0) & 1) >>> 0) >>> 0); + }; + $ptrType(nat).prototype.bit = function(i) { return this.$get().bit(i); }; + nat.prototype.and = function(x, y) { + var z, m, n, i; + z = this; + m = x.$length; + n = y.$length; + if (m > n) { + m = n; + } + z = z.make(m); + i = 0; + while (i < m) { + (i < 0 || i >= z.$length) ? $throwRuntimeError("index out of range") : z.$array[z.$offset + i] = (((i < 0 || i >= x.$length) ? $throwRuntimeError("index out of range") : x.$array[x.$offset + i]) & ((i < 0 || i >= y.$length) ? $throwRuntimeError("index out of range") : y.$array[y.$offset + i])) >>> 0; + i = i + (1) >> 0; + } + return z.norm(); + }; + $ptrType(nat).prototype.and = function(x, y) { return this.$get().and(x, y); }; + nat.prototype.andNot = function(x, y) { + var z, m, n, i; + z = this; + m = x.$length; + n = y.$length; + if (n > m) { + n = m; + } + z = z.make(m); + i = 0; + while (i < n) { + (i < 0 || i >= z.$length) ? $throwRuntimeError("index out of range") : z.$array[z.$offset + i] = ((i < 0 || i >= x.$length) ? $throwRuntimeError("index out of range") : x.$array[x.$offset + i]) & ~((i < 0 || i >= y.$length) ? $throwRuntimeError("index out of range") : y.$array[y.$offset + i]); + i = i + (1) >> 0; + } + $copySlice($subslice(z, n, m), $subslice(x, n, m)); + return z.norm(); + }; + $ptrType(nat).prototype.andNot = function(x, y) { return this.$get().andNot(x, y); }; + nat.prototype.or = function(x, y) { + var z, m, n, s, _tmp, _tmp$1, i; + z = this; + m = x.$length; + n = y.$length; + s = x; + if (m < n) { + _tmp = m; _tmp$1 = n; n = _tmp; m = _tmp$1; + s = y; + } + z = z.make(m); + i = 0; + while (i < n) { + (i < 0 || i >= z.$length) ? $throwRuntimeError("index out of range") : z.$array[z.$offset + i] = (((i < 0 || i >= x.$length) ? $throwRuntimeError("index out of range") : x.$array[x.$offset + i]) | ((i < 0 || i >= y.$length) ? $throwRuntimeError("index out of range") : y.$array[y.$offset + i])) >>> 0; + i = i + (1) >> 0; + } + $copySlice($subslice(z, n, m), $subslice(s, n, m)); + return z.norm(); + }; + $ptrType(nat).prototype.or = function(x, y) { return this.$get().or(x, y); }; + nat.prototype.xor = function(x, y) { + var z, m, n, s, _tmp, _tmp$1, i; + z = this; + m = x.$length; + n = y.$length; + s = x; + if (m < n) { + _tmp = m; _tmp$1 = n; n = _tmp; m = _tmp$1; + s = y; + } + z = z.make(m); + i = 0; + while (i < n) { + (i < 0 || i >= z.$length) ? $throwRuntimeError("index out of range") : z.$array[z.$offset + i] = (((i < 0 || i >= x.$length) ? $throwRuntimeError("index out of range") : x.$array[x.$offset + i]) ^ ((i < 0 || i >= y.$length) ? $throwRuntimeError("index out of range") : y.$array[y.$offset + i])) >>> 0; + i = i + (1) >> 0; + } + $copySlice($subslice(z, n, m), $subslice(s, n, m)); + return z.norm(); + }; + $ptrType(nat).prototype.xor = function(x, y) { return this.$get().xor(x, y); }; + greaterThan = function(x1, x2, y1, y2) { + return x1 > y1 || (x1 === y1) && x2 > y2; + }; + nat.prototype.modW = function(d) { + var r = 0, x, q; + x = this; + q = nat.nil; + q = q.make(x.$length); + r = divWVW($subslice(new ($sliceType(Word))(q.$array), q.$offset, q.$offset + q.$length), 0, $subslice(new ($sliceType(Word))(x.$array), x.$offset, x.$offset + x.$length), d); + return r; + }; + $ptrType(nat).prototype.modW = function(d) { return this.$get().modW(d); }; + nat.prototype.random = function(rand$1, limit, n) { + var z, _r, bitLengthOfMSW, y, mask, _ref, _ref$1, _i, i, _ref$2, _i$1, i$1, _lhs, _index; + z = this; + if (alias(z, limit)) { + z = nat.nil; + } + z = z.make(limit.$length); + bitLengthOfMSW = ((_r = n % 32, _r === _r ? _r : $throwRuntimeError("integer divide by zero")) >>> 0); + if (bitLengthOfMSW === 0) { + bitLengthOfMSW = 32; + } + mask = ((((y = bitLengthOfMSW, y < 32 ? (1 << y) : 0) >>> 0)) - 1 >>> 0); + while (true) { + _ref = 32; + if (_ref === 32) { + _ref$1 = z; + _i = 0; + while (_i < _ref$1.$length) { + i = _i; + (i < 0 || i >= z.$length) ? $throwRuntimeError("index out of range") : z.$array[z.$offset + i] = (rand$1.Uint32() >>> 0); + _i++; + } + } else if (_ref === 64) { + _ref$2 = z; + _i$1 = 0; + while (_i$1 < _ref$2.$length) { + i$1 = _i$1; + (i$1 < 0 || i$1 >= z.$length) ? $throwRuntimeError("index out of range") : z.$array[z.$offset + i$1] = ((rand$1.Uint32() >>> 0) | ((rand$1.Uint32() >>> 0) << 32 >>> 0)) >>> 0; + _i$1++; + } + } else { + $panic(new $String("unknown word size")); } - walkStmtList(v, n.Body); - } else if ($assertType(_ref, ($ptrType(SelectStmt)), true)[1]) { - n = _ref.$val; - Walk(v, n.Body); - } else if ($assertType(_ref, ($ptrType(ForStmt)), true)[1]) { - n = _ref.$val; - if (!($interfaceIsEqual(n.Init, $ifaceNil))) { - Walk(v, n.Init); + _lhs = z; _index = limit.$length - 1 >> 0; (_index < 0 || _index >= _lhs.$length) ? $throwRuntimeError("index out of range") : _lhs.$array[_lhs.$offset + _index] = (((_index < 0 || _index >= _lhs.$length) ? $throwRuntimeError("index out of range") : _lhs.$array[_lhs.$offset + _index]) & (mask)) >>> 0; + if (z.cmp(limit) < 0) { + break; } - if (!($interfaceIsEqual(n.Cond, $ifaceNil))) { - Walk(v, n.Cond); + } + return z.norm(); + }; + $ptrType(nat).prototype.random = function(rand$1, limit, n) { return this.$get().random(rand$1, limit, n); }; + nat.prototype.expNN = function(x, y, m) { + var z, x$1, v, shift, y$1, q, w, _tmp, _tmp$1, zz, r, j, _tmp$2, _tmp$3, _tmp$4, _tmp$5, _tuple, _tmp$6, _tmp$7, _tmp$8, _tmp$9, y$2, i, j$1, _tmp$10, _tmp$11, _tmp$12, _tmp$13, _tuple$1, _tmp$14, _tmp$15, _tmp$16, _tmp$17, y$3; + z = this; + if (alias(z, x) || alias(z, y)) { + z = nat.nil; + } + if ((m.$length === 1) && (((0 < 0 || 0 >= m.$length) ? $throwRuntimeError("index out of range") : m.$array[m.$offset + 0]) === 1)) { + return z.setWord(0); + } + if (y.$length === 0) { + return z.setWord(1); + } + if (!((m.$length === 0))) { + z = z.make(m.$length); + } + z = z.set(x); + if (x.$length > 1 && y.$length > 1 && m.$length > 0) { + return z.expNNWindowed(x, y, m); + } + v = (x$1 = y.$length - 1 >> 0, ((x$1 < 0 || x$1 >= y.$length) ? $throwRuntimeError("index out of range") : y.$array[y.$offset + x$1])); + shift = leadingZeros(v) + 1 >>> 0; + v = (y$1 = (shift), y$1 < 32 ? (v << y$1) : 0) >>> 0; + q = nat.nil; + w = 32 - (shift >> 0) >> 0; + _tmp = nat.nil; _tmp$1 = nat.nil; zz = _tmp; r = _tmp$1; + j = 0; + while (j < w) { + zz = zz.mul(z, z); + _tmp$2 = z; _tmp$3 = zz; zz = _tmp$2; z = _tmp$3; + if (!((((v & 2147483648) >>> 0) === 0))) { + zz = zz.mul(z, x); + _tmp$4 = z; _tmp$5 = zz; zz = _tmp$4; z = _tmp$5; } - if (!($interfaceIsEqual(n.Post, $ifaceNil))) { - Walk(v, n.Post); + if (!((m.$length === 0))) { + _tuple = zz.div(r, z, m); zz = _tuple[0]; r = _tuple[1]; + _tmp$6 = q; _tmp$7 = z; _tmp$8 = zz; _tmp$9 = r; zz = _tmp$6; r = _tmp$7; q = _tmp$8; z = _tmp$9; } - Walk(v, n.Body); - } else if ($assertType(_ref, ($ptrType(RangeStmt)), true)[1]) { - n = _ref.$val; - Walk(v, n.Key); - if (!($interfaceIsEqual(n.Value, $ifaceNil))) { - Walk(v, n.Value); + v = (y$2 = (1), y$2 < 32 ? (v << y$2) : 0) >>> 0; + j = j + (1) >> 0; + } + i = y.$length - 2 >> 0; + while (i >= 0) { + v = ((i < 0 || i >= y.$length) ? $throwRuntimeError("index out of range") : y.$array[y.$offset + i]); + j$1 = 0; + while (j$1 < 32) { + zz = zz.mul(z, z); + _tmp$10 = z; _tmp$11 = zz; zz = _tmp$10; z = _tmp$11; + if (!((((v & 2147483648) >>> 0) === 0))) { + zz = zz.mul(z, x); + _tmp$12 = z; _tmp$13 = zz; zz = _tmp$12; z = _tmp$13; + } + if (!((m.$length === 0))) { + _tuple$1 = zz.div(r, z, m); zz = _tuple$1[0]; r = _tuple$1[1]; + _tmp$14 = q; _tmp$15 = z; _tmp$16 = zz; _tmp$17 = r; zz = _tmp$14; r = _tmp$15; q = _tmp$16; z = _tmp$17; + } + v = (y$3 = (1), y$3 < 32 ? (v << y$3) : 0) >>> 0; + j$1 = j$1 + (1) >> 0; } - Walk(v, n.X); - Walk(v, n.Body); - } else if ($assertType(_ref, ($ptrType(ImportSpec)), true)[1]) { - n = _ref.$val; - if (!(n.Doc === ($ptrType(CommentGroup)).nil)) { - Walk(v, n.Doc); + i = i - (1) >> 0; + } + return z.norm(); + }; + $ptrType(nat).prototype.expNN = function(x, y, m) { return this.$get().expNN(x, y, m); }; + nat.prototype.expNNWindowed = function(x, y, m) { + var z, _tmp, _tmp$1, zz, r, powers, i, _tmp$2, x$1, _q, x$2, _q$1, _tmp$3, _tmp$4, x$3, x$4, p2, p, p1, _tuple, _tmp$5, _tmp$6, _tuple$1, _tmp$7, _tmp$8, i$1, yi, j, _tmp$9, _tmp$10, _tuple$2, _tmp$11, _tmp$12, _tmp$13, _tmp$14, _tuple$3, _tmp$15, _tmp$16, _tmp$17, _tmp$18, _tuple$4, _tmp$19, _tmp$20, _tmp$21, _tmp$22, _tuple$5, _tmp$23, _tmp$24, x$5, _tmp$25, _tmp$26, _tuple$6, _tmp$27, _tmp$28, y$1; + z = this; + _tmp = nat.nil; _tmp$1 = nat.nil; zz = _tmp; r = _tmp$1; + powers = ($arrayType(nat, 16)).zero(); $copy(powers, ($arrayType(nat, 16)).zero(), ($arrayType(nat, 16))); + powers[0] = natOne; + powers[1] = x; + i = 2; + while (i < 16) { + _tmp$2 = new ($ptrType(nat))(function() { return (x$2 = (_q$1 = i / 2, (_q$1 === _q$1 && _q$1 !== 1/0 && _q$1 !== -1/0) ? _q$1 >> 0 : $throwRuntimeError("integer divide by zero")), ((x$2 < 0 || x$2 >= this.$target.length) ? $throwRuntimeError("index out of range") : this.$target[x$2])); }, function($v) { (x$1 = (_q = i / 2, (_q === _q && _q !== 1/0 && _q !== -1/0) ? _q >> 0 : $throwRuntimeError("integer divide by zero")), (x$1 < 0 || x$1 >= this.$target.length) ? $throwRuntimeError("index out of range") : this.$target[x$1] = $v); }, powers); _tmp$3 = new ($ptrType(nat))(function() { return ((i < 0 || i >= this.$target.length) ? $throwRuntimeError("index out of range") : this.$target[i]); }, function($v) { (i < 0 || i >= this.$target.length) ? $throwRuntimeError("index out of range") : this.$target[i] = $v; }, powers); _tmp$4 = new ($ptrType(nat))(function() { return (x$4 = i + 1 >> 0, ((x$4 < 0 || x$4 >= this.$target.length) ? $throwRuntimeError("index out of range") : this.$target[x$4])); }, function($v) { (x$3 = i + 1 >> 0, (x$3 < 0 || x$3 >= this.$target.length) ? $throwRuntimeError("index out of range") : this.$target[x$3] = $v); }, powers); p2 = _tmp$2; p = _tmp$3; p1 = _tmp$4; + p.$set(p.mul(p2.$get(), p2.$get())); + _tuple = zz.div(r, p.$get(), m); zz = _tuple[0]; r = _tuple[1]; + _tmp$5 = r; _tmp$6 = p.$get(); p.$set(_tmp$5); r = _tmp$6; + p1.$set(p1.mul(p.$get(), x)); + _tuple$1 = zz.div(r, p1.$get(), m); zz = _tuple$1[0]; r = _tuple$1[1]; + _tmp$7 = r; _tmp$8 = p1.$get(); p1.$set(_tmp$7); r = _tmp$8; + i = i + (2) >> 0; + } + z = z.setWord(1); + i$1 = y.$length - 1 >> 0; + while (i$1 >= 0) { + yi = ((i$1 < 0 || i$1 >= y.$length) ? $throwRuntimeError("index out of range") : y.$array[y.$offset + i$1]); + j = 0; + while (j < 32) { + if (!((i$1 === (y.$length - 1 >> 0))) || !((j === 0))) { + zz = zz.mul(z, z); + _tmp$9 = z; _tmp$10 = zz; zz = _tmp$9; z = _tmp$10; + _tuple$2 = zz.div(r, z, m); zz = _tuple$2[0]; r = _tuple$2[1]; + _tmp$11 = r; _tmp$12 = z; z = _tmp$11; r = _tmp$12; + zz = zz.mul(z, z); + _tmp$13 = z; _tmp$14 = zz; zz = _tmp$13; z = _tmp$14; + _tuple$3 = zz.div(r, z, m); zz = _tuple$3[0]; r = _tuple$3[1]; + _tmp$15 = r; _tmp$16 = z; z = _tmp$15; r = _tmp$16; + zz = zz.mul(z, z); + _tmp$17 = z; _tmp$18 = zz; zz = _tmp$17; z = _tmp$18; + _tuple$4 = zz.div(r, z, m); zz = _tuple$4[0]; r = _tuple$4[1]; + _tmp$19 = r; _tmp$20 = z; z = _tmp$19; r = _tmp$20; + zz = zz.mul(z, z); + _tmp$21 = z; _tmp$22 = zz; zz = _tmp$21; z = _tmp$22; + _tuple$5 = zz.div(r, z, m); zz = _tuple$5[0]; r = _tuple$5[1]; + _tmp$23 = r; _tmp$24 = z; z = _tmp$23; r = _tmp$24; + } + zz = zz.mul(z, (x$5 = yi >>> 28 >>> 0, ((x$5 < 0 || x$5 >= powers.length) ? $throwRuntimeError("index out of range") : powers[x$5]))); + _tmp$25 = z; _tmp$26 = zz; zz = _tmp$25; z = _tmp$26; + _tuple$6 = zz.div(r, z, m); zz = _tuple$6[0]; r = _tuple$6[1]; + _tmp$27 = r; _tmp$28 = z; z = _tmp$27; r = _tmp$28; + yi = (y$1 = (4), y$1 < 32 ? (yi << y$1) : 0) >>> 0; + j = j + (4) >> 0; } - if (!(n.Name === ($ptrType(Ident)).nil)) { - Walk(v, n.Name); + i$1 = i$1 - (1) >> 0; + } + return z.norm(); + }; + $ptrType(nat).prototype.expNNWindowed = function(x, y, m) { return this.$get().expNNWindowed(x, y, m); }; + nat.prototype.probablyPrime = function(reps) { + var n, _r, _ref, r, _ref$1, _r$1, _r$2, _r$3, _r$4, _r$5, _r$6, _r$7, _r$8, _r$9, _r$10, _r$11, _r$12, _r$13, _r$14, _r$15, nm1, k, q, nm3, x, rand$1, _tmp, _tmp$1, _tmp$2, x$1, y, quotient, nm3Len, i, j, _tuple; + n = this; + if (n.$length === 0) { + return false; + } + if (n.$length === 1) { + if (((0 < 0 || 0 >= n.$length) ? $throwRuntimeError("index out of range") : n.$array[n.$offset + 0]) < 2) { + return false; } - Walk(v, n.Path); - if (!(n.Comment === ($ptrType(CommentGroup)).nil)) { - Walk(v, n.Comment); + if ((_r = ((0 < 0 || 0 >= n.$length) ? $throwRuntimeError("index out of range") : n.$array[n.$offset + 0]) % 2, _r === _r ? _r : $throwRuntimeError("integer divide by zero")) === 0) { + return ((0 < 0 || 0 >= n.$length) ? $throwRuntimeError("index out of range") : n.$array[n.$offset + 0]) === 2; } - } else if ($assertType(_ref, ($ptrType(ValueSpec)), true)[1]) { - n = _ref.$val; - if (!(n.Doc === ($ptrType(CommentGroup)).nil)) { - Walk(v, n.Doc); + _ref = ((0 < 0 || 0 >= n.$length) ? $throwRuntimeError("index out of range") : n.$array[n.$offset + 0]); + if (_ref === 3 || _ref === 5 || _ref === 7 || _ref === 11 || _ref === 13 || _ref === 17 || _ref === 19 || _ref === 23 || _ref === 29 || _ref === 31 || _ref === 37 || _ref === 41 || _ref === 43 || _ref === 47 || _ref === 53) { + return true; } - walkIdentList(v, n.Names); - if (!($interfaceIsEqual(n.Type, $ifaceNil))) { - Walk(v, n.Type); + } + r = 0; + _ref$1 = 32; + if (_ref$1 === 32) { + r = n.modW(3234846615); + } else if (_ref$1 === 64) { + r = n.modW(820596253); + } else { + $panic(new $String("Unknown word size")); + } + if (((_r$1 = r % 3, _r$1 === _r$1 ? _r$1 : $throwRuntimeError("integer divide by zero")) === 0) || ((_r$2 = r % 5, _r$2 === _r$2 ? _r$2 : $throwRuntimeError("integer divide by zero")) === 0) || ((_r$3 = r % 7, _r$3 === _r$3 ? _r$3 : $throwRuntimeError("integer divide by zero")) === 0) || ((_r$4 = r % 11, _r$4 === _r$4 ? _r$4 : $throwRuntimeError("integer divide by zero")) === 0) || ((_r$5 = r % 13, _r$5 === _r$5 ? _r$5 : $throwRuntimeError("integer divide by zero")) === 0) || ((_r$6 = r % 17, _r$6 === _r$6 ? _r$6 : $throwRuntimeError("integer divide by zero")) === 0) || ((_r$7 = r % 19, _r$7 === _r$7 ? _r$7 : $throwRuntimeError("integer divide by zero")) === 0) || ((_r$8 = r % 23, _r$8 === _r$8 ? _r$8 : $throwRuntimeError("integer divide by zero")) === 0) || ((_r$9 = r % 29, _r$9 === _r$9 ? _r$9 : $throwRuntimeError("integer divide by zero")) === 0)) { + return false; + } + nm1 = nat.nil.sub(n, natOne); + k = nm1.trailingZeroBits(); + q = nat.nil.shr(nm1, k); + nm3 = nat.nil.sub(nm1, natTwo); + rand$1 = rand.New(rand.NewSource((x = ((0 < 0 || 0 >= n.$length) ? $throwRuntimeError("index out of range") : n.$array[n.$offset + 0]), new $Int64(0, x.constructor === Number ? x : 1)))); + _tmp = nat.nil; _tmp$1 = nat.nil; _tmp$2 = nat.nil; x$1 = _tmp; y = _tmp$1; quotient = _tmp$2; + nm3Len = nm3.bitLen(); + i = 0; + NextRandom: + while (i < reps) { + x$1 = x$1.random(rand$1, nm3, nm3Len); + x$1 = x$1.add(x$1, natTwo); + y = y.expNN(x$1, q, n); + if ((y.cmp(natOne) === 0) || (y.cmp(nm1) === 0)) { + i = i + (1) >> 0; + continue; } - walkExprList(v, n.Values); - if (!(n.Comment === ($ptrType(CommentGroup)).nil)) { - Walk(v, n.Comment); + j = 1; + while (j < k) { + y = y.mul(y, y); + _tuple = quotient.div(y, y, n); quotient = _tuple[0]; y = _tuple[1]; + if (y.cmp(nm1) === 0) { + i = i + (1) >> 0; + continue NextRandom; + } + if (y.cmp(natOne) === 0) { + return false; + } + j = j + (1) >>> 0; } - } else if ($assertType(_ref, ($ptrType(TypeSpec)), true)[1]) { - n = _ref.$val; - if (!(n.Doc === ($ptrType(CommentGroup)).nil)) { - Walk(v, n.Doc); + return false; + } + return true; + }; + $ptrType(nat).prototype.probablyPrime = function(reps) { return this.$get().probablyPrime(reps); }; + nat.prototype.bytes = function(buf) { + var i = 0, z, _ref, _i, d, j, y; + z = this; + i = buf.$length; + _ref = z; + _i = 0; + while (_i < _ref.$length) { + d = ((_i < 0 || _i >= _ref.$length) ? $throwRuntimeError("index out of range") : _ref.$array[_ref.$offset + _i]); + j = 0; + while (j < 4) { + i = i - (1) >> 0; + (i < 0 || i >= buf.$length) ? $throwRuntimeError("index out of range") : buf.$array[buf.$offset + i] = (d << 24 >>> 24); + d = (y = (8), y < 32 ? (d >>> y) : 0) >>> 0; + j = j + (1) >> 0; } - Walk(v, n.Name); - Walk(v, n.Type); - if (!(n.Comment === ($ptrType(CommentGroup)).nil)) { - Walk(v, n.Comment); + _i++; + } + while (i < buf.$length && (((i < 0 || i >= buf.$length) ? $throwRuntimeError("index out of range") : buf.$array[buf.$offset + i]) === 0)) { + i = i + (1) >> 0; + } + return i; + }; + $ptrType(nat).prototype.bytes = function(buf) { return this.$get().bytes(buf); }; + nat.prototype.setBytes = function(buf) { + var z, _q, k, s, d, i, y, x; + z = this; + z = z.make((_q = (((buf.$length + 4 >> 0) - 1 >> 0)) / 4, (_q === _q && _q !== 1/0 && _q !== -1/0) ? _q >> 0 : $throwRuntimeError("integer divide by zero"))); + k = 0; + s = 0; + d = 0; + i = buf.$length; + while (i > 0) { + d = (d | (((y = s, y < 32 ? (((x = i - 1 >> 0, ((x < 0 || x >= buf.$length) ? $throwRuntimeError("index out of range") : buf.$array[buf.$offset + x])) >>> 0) << y) : 0) >>> 0))) >>> 0; + s = s + (8) >>> 0; + if (s === 32) { + (k < 0 || k >= z.$length) ? $throwRuntimeError("index out of range") : z.$array[z.$offset + k] = d; + k = k + (1) >> 0; + s = 0; + d = 0; } - } else if ($assertType(_ref, ($ptrType(BadDecl)), true)[1]) { - n = _ref.$val; - } else if ($assertType(_ref, ($ptrType(GenDecl)), true)[1]) { - n = _ref.$val; - if (!(n.Doc === ($ptrType(CommentGroup)).nil)) { - Walk(v, n.Doc); + i = i - (1) >> 0; + } + if (k < z.$length) { + (k < 0 || k >= z.$length) ? $throwRuntimeError("index out of range") : z.$array[z.$offset + k] = d; + } + return z.norm(); + }; + $ptrType(nat).prototype.setBytes = function(buf) { return this.$get().setBytes(buf); }; + NewRat = $pkg.NewRat = function(a, b) { + return new Rat.Ptr().SetFrac64(a, b); + }; + Rat.Ptr.prototype.SetFloat64 = function(f) { + var z, bits, mantissa, x, exp, _ref, x$1, shift, x$2; + z = this; + bits = math.Float64bits(f); + mantissa = new $Uint64(bits.$high & 1048575, (bits.$low & 4294967295) >>> 0); + exp = ((x = $shiftRightUint64(bits, 52), new $Uint64(x.$high & 0, (x.$low & 2047) >>> 0)).$low >> 0); + _ref = exp; + if (_ref === 2047) { + return ($ptrType(Rat)).nil; + } else if (_ref === 0) { + exp = exp - (1022) >> 0; + } else { + mantissa = (x$1 = new $Uint64(1048576, 0), new $Uint64(mantissa.$high | x$1.$high, (mantissa.$low | x$1.$low) >>> 0)); + exp = exp - (1023) >> 0; + } + shift = 52 - exp >> 0; + while ((x$2 = new $Uint64(mantissa.$high & 0, (mantissa.$low & 1) >>> 0), (x$2.$high === 0 && x$2.$low === 0)) && shift > 0) { + mantissa = $shiftRightUint64(mantissa, (1)); + shift = shift - (1) >> 0; + } + z.a.SetUint64(mantissa); + z.a.neg = f < 0; + z.b.Set(intOne); + if (shift > 0) { + z.b.Lsh(z.b, (shift >>> 0)); + } else { + z.a.Lsh(z.a, (-shift >>> 0)); + } + return z.norm(); + }; + Rat.prototype.SetFloat64 = function(f) { return this.$val.SetFloat64(f); }; + low64 = function(z) { + var x, x$1, x$2, x$3, x$4; + if (z.$length === 0) { + return new $Uint64(0, 0); + } + if (true && z.$length > 1) { + return (x = $shiftLeft64((x$1 = ((1 < 0 || 1 >= z.$length) ? $throwRuntimeError("index out of range") : z.$array[z.$offset + 1]), new $Uint64(0, x$1.constructor === Number ? x$1 : 1)), 32), x$2 = (x$3 = ((0 < 0 || 0 >= z.$length) ? $throwRuntimeError("index out of range") : z.$array[z.$offset + 0]), new $Uint64(0, x$3.constructor === Number ? x$3 : 1)), new $Uint64(x.$high | x$2.$high, (x.$low | x$2.$low) >>> 0)); + } + return (x$4 = ((0 < 0 || 0 >= z.$length) ? $throwRuntimeError("index out of range") : z.$array[z.$offset + 0]), new $Uint64(0, x$4.constructor === Number ? x$4 : 1)); + }; + quotToFloat = function(a, b) { + var f = 0, exact = false, alen, _tmp, _tmp$1, blen, exp, _tmp$2, _tmp$3, a2, b2, shift, q, _tuple, r, mantissa, haveRem, x, x$1, x$2, shift$1, x$3, x$4, lostbits, x$5, x$6, x$7; + alen = a.bitLen(); + if (alen === 0) { + _tmp = 0; _tmp$1 = true; f = _tmp; exact = _tmp$1; + return [f, exact]; + } + blen = b.bitLen(); + if (blen === 0) { + $panic(new $String("division by zero")); + } + exp = alen - blen >> 0; + _tmp$2 = nat.nil; _tmp$3 = nat.nil; a2 = _tmp$2; b2 = _tmp$3; + a2 = a2.set(a); + b2 = b2.set(b); + shift = 54 - exp >> 0; + if (shift > 0) { + a2 = a2.shl(a2, (shift >>> 0)); + } else if (shift < 0) { + b2 = b2.shl(b2, (-shift >>> 0)); + } + q = nat.nil; + _tuple = q.div(a2, a2, b2); q = _tuple[0]; r = _tuple[1]; + mantissa = low64(q); + haveRem = r.$length > 0; + if ((x = $shiftRightUint64(mantissa, 54), (x.$high === 0 && x.$low === 1))) { + if ((x$1 = new $Uint64(mantissa.$high & 0, (mantissa.$low & 1) >>> 0), (x$1.$high === 0 && x$1.$low === 1))) { + haveRem = true; } - _ref$3 = n.Specs; - _i$2 = 0; - while (_i$2 < _ref$3.$length) { - s = ((_i$2 < 0 || _i$2 >= _ref$3.$length) ? $throwRuntimeError("index out of range") : _ref$3.$array[_ref$3.$offset + _i$2]); - Walk(v, s); - _i$2++; + mantissa = $shiftRightUint64(mantissa, (1)); + exp = exp + (1) >> 0; + } + if (!((x$2 = $shiftRightUint64(mantissa, 53), (x$2.$high === 0 && x$2.$low === 1)))) { + $panic(new $String("expected exactly 54 bits of result")); + } + if (-1074 <= exp && exp <= -1022) { + shift$1 = new $Uint64(0, (-1022 - ((exp - 1 >> 0)) >> 0)); + lostbits = (x$3 = (x$4 = $shiftLeft64(new $Uint64(0, 1), $flatten64(shift$1)), new $Uint64(x$4.$high - 0, x$4.$low - 1)), new $Uint64(mantissa.$high & x$3.$high, (mantissa.$low & x$3.$low) >>> 0)); + haveRem = haveRem || !((lostbits.$high === 0 && lostbits.$low === 0)); + mantissa = $shiftRightUint64(mantissa, $flatten64((shift$1))); + exp = -1021; + } + exact = !haveRem; + if (!((x$5 = new $Uint64(mantissa.$high & 0, (mantissa.$low & 1) >>> 0), (x$5.$high === 0 && x$5.$low === 0)))) { + exact = false; + if (haveRem || !((x$6 = new $Uint64(mantissa.$high & 0, (mantissa.$low & 2) >>> 0), (x$6.$high === 0 && x$6.$low === 0)))) { + mantissa = (x$7 = new $Uint64(0, 1), new $Uint64(mantissa.$high + x$7.$high, mantissa.$low + x$7.$low)); + if ((mantissa.$high > 4194304 || (mantissa.$high === 4194304 && mantissa.$low >= 0))) { + mantissa = $shiftRightUint64(mantissa, (1)); + exp = exp + (1) >> 0; + } } - } else if ($assertType(_ref, ($ptrType(FuncDecl)), true)[1]) { - n = _ref.$val; - if (!(n.Doc === ($ptrType(CommentGroup)).nil)) { - Walk(v, n.Doc); + } + mantissa = $shiftRightUint64(mantissa, (1)); + f = math.Ldexp($flatten64(mantissa), exp - 53 >> 0); + if (math.IsInf(f, 0)) { + exact = false; + } + return [f, exact]; + }; + Rat.Ptr.prototype.Float64 = function() { + var f = 0, exact = false, x, b, _tuple; + x = this; + b = x.b.abs; + if (b.$length === 0) { + b = b.set(natOne); + } + _tuple = quotToFloat(x.a.abs, b); f = _tuple[0]; exact = _tuple[1]; + if (x.a.neg) { + f = -f; + } + return [f, exact]; + }; + Rat.prototype.Float64 = function() { return this.$val.Float64(); }; + Rat.Ptr.prototype.SetFrac = function(a, b) { + var z, babs; + z = this; + z.a.neg = !(a.neg === b.neg); + babs = b.abs; + if (babs.$length === 0) { + $panic(new $String("division by zero")); + } + if (z.a === b || alias(z.a.abs, babs)) { + babs = nat.nil.set(babs); + } + z.a.abs = z.a.abs.set(a.abs); + z.b.abs = z.b.abs.set(babs); + return z.norm(); + }; + Rat.prototype.SetFrac = function(a, b) { return this.$val.SetFrac(a, b); }; + Rat.Ptr.prototype.SetFrac64 = function(a, b) { + var z; + z = this; + z.a.SetInt64(a); + if ((b.$high === 0 && b.$low === 0)) { + $panic(new $String("division by zero")); + } + if ((b.$high < 0 || (b.$high === 0 && b.$low < 0))) { + b = new $Int64(-b.$high, -b.$low); + z.a.neg = !z.a.neg; + } + z.b.abs = z.b.abs.setUint64(new $Uint64(b.$high, b.$low)); + return z.norm(); + }; + Rat.prototype.SetFrac64 = function(a, b) { return this.$val.SetFrac64(a, b); }; + Rat.Ptr.prototype.SetInt = function(x) { + var z; + z = this; + z.a.Set(x); + z.b.abs = z.b.abs.make(0); + return z; + }; + Rat.prototype.SetInt = function(x) { return this.$val.SetInt(x); }; + Rat.Ptr.prototype.SetInt64 = function(x) { + var z; + z = this; + z.a.SetInt64(x); + z.b.abs = z.b.abs.make(0); + return z; + }; + Rat.prototype.SetInt64 = function(x) { return this.$val.SetInt64(x); }; + Rat.Ptr.prototype.Set = function(x) { + var z; + z = this; + if (!(z === x)) { + z.a.Set(x.a); + z.b.Set(x.b); + } + return z; + }; + Rat.prototype.Set = function(x) { return this.$val.Set(x); }; + Rat.Ptr.prototype.Abs = function(x) { + var z; + z = this; + z.Set(x); + z.a.neg = false; + return z; + }; + Rat.prototype.Abs = function(x) { return this.$val.Abs(x); }; + Rat.Ptr.prototype.Neg = function(x) { + var z; + z = this; + z.Set(x); + z.a.neg = z.a.abs.$length > 0 && !z.a.neg; + return z; + }; + Rat.prototype.Neg = function(x) { return this.$val.Neg(x); }; + Rat.Ptr.prototype.Inv = function(x) { + var z, a, b, _tmp, _tmp$1; + z = this; + if (x.a.abs.$length === 0) { + $panic(new $String("division by zero")); + } + z.Set(x); + a = z.b.abs; + if (a.$length === 0) { + a = a.set(natOne); + } + b = z.a.abs; + if (b.cmp(natOne) === 0) { + b = b.make(0); + } + _tmp = a; _tmp$1 = b; z.a.abs = _tmp; z.b.abs = _tmp$1; + return z; + }; + Rat.prototype.Inv = function(x) { return this.$val.Inv(x); }; + Rat.Ptr.prototype.Sign = function() { + var x; + x = this; + return x.a.Sign(); + }; + Rat.prototype.Sign = function() { return this.$val.Sign(); }; + Rat.Ptr.prototype.IsInt = function() { + var x; + x = this; + return (x.b.abs.$length === 0) || (x.b.abs.cmp(natOne) === 0); + }; + Rat.prototype.IsInt = function() { return this.$val.IsInt(); }; + Rat.Ptr.prototype.Num = function() { + var x; + x = this; + return x.a; + }; + Rat.prototype.Num = function() { return this.$val.Num(); }; + Rat.Ptr.prototype.Denom = function() { + var x; + x = this; + x.b.neg = false; + if (x.b.abs.$length === 0) { + x.b.abs = x.b.abs.set(natOne); + } + return x.b; + }; + Rat.prototype.Denom = function() { return this.$val.Denom(); }; + Rat.Ptr.prototype.norm = function() { + var z, neg, f, _tuple, _tuple$1; + z = this; + if (z.a.abs.$length === 0) { + z.a.neg = false; + z.b.abs = z.b.abs.make(0); + } else if (z.b.abs.$length === 0) { + } else if (z.b.abs.cmp(natOne) === 0) { + z.b.abs = z.b.abs.make(0); + } else { + neg = z.a.neg; + z.a.neg = false; + z.b.neg = false; + f = NewInt(new $Int64(0, 0)).binaryGCD(z.a, z.b); + if (!((f.Cmp(intOne) === 0))) { + _tuple = z.a.abs.div(nat.nil, z.a.abs, f.abs); z.a.abs = _tuple[0]; + _tuple$1 = z.b.abs.div(nat.nil, z.b.abs, f.abs); z.b.abs = _tuple$1[0]; + if (z.b.abs.cmp(natOne) === 0) { + z.b.abs = z.b.abs.make(0); + } } - if (!(n.Recv === ($ptrType(FieldList)).nil)) { - Walk(v, n.Recv); + z.a.neg = neg; + } + return z; + }; + Rat.prototype.norm = function() { return this.$val.norm(); }; + mulDenom = function(z, x, y) { + if (x.$length === 0) { + return z.set(y); + } else if (y.$length === 0) { + return z.set(x); + } + return z.mul(x, y); + }; + scaleDenom = function(x, f) { + var z; + z = new Int.Ptr(); $copy(z, new Int.Ptr(), Int); + if (f.$length === 0) { + return z.Set(x); + } + z.abs = z.abs.mul(x.abs, f); + z.neg = x.neg; + return z; + }; + Rat.Ptr.prototype.Cmp = function(y) { + var x; + x = this; + return scaleDenom(x.a, y.b.abs).Cmp(scaleDenom(y.a, x.b.abs)); + }; + Rat.prototype.Cmp = function(y) { return this.$val.Cmp(y); }; + Rat.Ptr.prototype.Add = function(x, y) { + var z, a1, a2; + z = this; + a1 = scaleDenom(x.a, y.b.abs); + a2 = scaleDenom(y.a, x.b.abs); + z.a.Add(a1, a2); + z.b.abs = mulDenom(z.b.abs, x.b.abs, y.b.abs); + return z.norm(); + }; + Rat.prototype.Add = function(x, y) { return this.$val.Add(x, y); }; + Rat.Ptr.prototype.Sub = function(x, y) { + var z, a1, a2; + z = this; + a1 = scaleDenom(x.a, y.b.abs); + a2 = scaleDenom(y.a, x.b.abs); + z.a.Sub(a1, a2); + z.b.abs = mulDenom(z.b.abs, x.b.abs, y.b.abs); + return z.norm(); + }; + Rat.prototype.Sub = function(x, y) { return this.$val.Sub(x, y); }; + Rat.Ptr.prototype.Mul = function(x, y) { + var z; + z = this; + z.a.Mul(x.a, y.a); + z.b.abs = mulDenom(z.b.abs, x.b.abs, y.b.abs); + return z.norm(); + }; + Rat.prototype.Mul = function(x, y) { return this.$val.Mul(x, y); }; + Rat.Ptr.prototype.Quo = function(x, y) { + var z, a, b; + z = this; + if (y.a.abs.$length === 0) { + $panic(new $String("division by zero")); + } + a = scaleDenom(x.a, y.b.abs); + b = scaleDenom(y.a, x.b.abs); + z.a.abs = a.abs; + z.b.abs = b.abs; + z.a.neg = !(a.neg === b.neg); + return z.norm(); + }; + Rat.prototype.Quo = function(x, y) { return this.$val.Quo(x, y); }; + ratTok = function(ch) { + return strings.IndexRune("+-/0123456789.eE", ch) >= 0; + }; + Rat.Ptr.prototype.Scan = function(s, ch) { + var z, _tuple, tok, err, _tuple$1, ok; + z = this; + _tuple = s.Token(true, ratTok); tok = _tuple[0]; err = _tuple[1]; + if (!($interfaceIsEqual(err, $ifaceNil))) { + return err; + } + if (strings.IndexRune("efgEFGv", ch) < 0) { + return errors.New("Rat.Scan: invalid verb"); + } + _tuple$1 = z.SetString($bytesToString(tok)); ok = _tuple$1[1]; + if (!ok) { + return errors.New("Rat.Scan: invalid syntax"); + } + return $ifaceNil; + }; + Rat.prototype.Scan = function(s, ch) { return this.$val.Scan(s, ch); }; + Rat.Ptr.prototype.SetString = function(s) { + var z, sep, _tuple, ok, err, _tuple$1, e, exp, _tuple$2, ok$1, _tuple$3, ok$2, powTen; + z = this; + if (s.length === 0) { + return [($ptrType(Rat)).nil, false]; + } + sep = strings.Index(s, "/"); + if (sep >= 0) { + _tuple = z.a.SetString(s.substring(0, sep), 10); ok = _tuple[1]; + if (!ok) { + return [($ptrType(Rat)).nil, false]; } - Walk(v, n.Name); - Walk(v, n.Type); - if (!(n.Body === ($ptrType(BlockStmt)).nil)) { - Walk(v, n.Body); + s = s.substring((sep + 1 >> 0)); + err = $ifaceNil; + _tuple$1 = z.b.abs.scan(strings.NewReader(s), 10); z.b.abs = _tuple$1[0]; err = _tuple$1[2]; + if (!($interfaceIsEqual(err, $ifaceNil))) { + return [($ptrType(Rat)).nil, false]; } - } else if ($assertType(_ref, ($ptrType(File)), true)[1]) { - n = _ref.$val; - if (!(n.Doc === ($ptrType(CommentGroup)).nil)) { - Walk(v, n.Doc); + return [z.norm(), true]; + } + sep = strings.Index(s, "."); + e = strings.IndexAny(s, "eE"); + exp = new Int.Ptr(); $copy(exp, new Int.Ptr(), Int); + if (e >= 0) { + if (e < sep) { + return [($ptrType(Rat)).nil, false]; } - Walk(v, n.Name); - walkDeclList(v, n.Decls); - } else if ($assertType(_ref, ($ptrType(Package)), true)[1]) { - n = _ref.$val; - _ref$4 = n.Files; - _i$3 = 0; - _keys = $keys(_ref$4); - while (_i$3 < _keys.length) { - _entry = _ref$4[_keys[_i$3]]; - if (_entry === undefined) { - _i$3++; - continue; - } - f$1 = _entry.v; - Walk(v, f$1); - _i$3++; + _tuple$2 = exp.SetString(s.substring((e + 1 >> 0)), 10); ok$1 = _tuple$2[1]; + if (!ok$1) { + return [($ptrType(Rat)).nil, false]; } + s = s.substring(0, e); + } + if (sep >= 0) { + s = s.substring(0, sep) + s.substring((sep + 1 >> 0)); + exp.Sub(exp, NewInt(new $Int64(0, (s.length - sep >> 0)))); + } + _tuple$3 = z.a.SetString(s, 10); ok$2 = _tuple$3[1]; + if (!ok$2) { + return [($ptrType(Rat)).nil, false]; + } + powTen = nat.nil.expNN(natTen, exp.abs, nat.nil); + if (exp.neg) { + z.b.abs = powTen; + z.norm(); } else { - n = _ref; - fmt.Printf("ast.Walk: unexpected node type %T", new ($sliceType($emptyInterface))([n])); - $panic(new $String("ast.Walk")); + z.a.abs = z.a.abs.mul(z.a.abs, powTen); + z.b.abs = z.b.abs.make(0); } - v.Visit($ifaceNil); + return [z, true]; }; - inspector.prototype.Visit = function(node) { - var f; - f = this.$val !== undefined ? this.$val : this; - if (f(node)) { - return new inspector(f); + Rat.prototype.SetString = function(s) { return this.$val.SetString(s); }; + Rat.Ptr.prototype.String = function() { + var x, s; + x = this; + s = "/1"; + if (!((x.b.abs.$length === 0))) { + s = "/" + x.b.abs.decimalString(); } - return $ifaceNil; - }; - $ptrType(inspector).prototype.Visit = function(node) { return new inspector(this.$get()).Visit(node); }; - Inspect = $pkg.Inspect = function(node, f) { - Walk(new inspector(f), node); + return x.a.String() + s; }; - $pkg.$init = function() { - Node.init([["End", "End", "", $funcType([], [token.Pos], false)], ["Pos", "Pos", "", $funcType([], [token.Pos], false)]]); - Expr.init([["End", "End", "", $funcType([], [token.Pos], false)], ["Pos", "Pos", "", $funcType([], [token.Pos], false)], ["exprNode", "exprNode", "go/ast", $funcType([], [], false)]]); - Stmt.init([["End", "End", "", $funcType([], [token.Pos], false)], ["Pos", "Pos", "", $funcType([], [token.Pos], false)], ["stmtNode", "stmtNode", "go/ast", $funcType([], [], false)]]); - Decl.init([["End", "End", "", $funcType([], [token.Pos], false)], ["Pos", "Pos", "", $funcType([], [token.Pos], false)], ["declNode", "declNode", "go/ast", $funcType([], [], false)]]); - ($ptrType(Comment)).methods = [["End", "End", "", $funcType([], [token.Pos], false), -1], ["Pos", "Pos", "", $funcType([], [token.Pos], false), -1]]; - Comment.init([["Slash", "Slash", "", token.Pos, ""], ["Text", "Text", "", $String, ""]]); - ($ptrType(CommentGroup)).methods = [["End", "End", "", $funcType([], [token.Pos], false), -1], ["Pos", "Pos", "", $funcType([], [token.Pos], false), -1], ["Text", "Text", "", $funcType([], [$String], false), -1]]; - CommentGroup.init([["List", "List", "", ($sliceType(($ptrType(Comment)))), ""]]); - ($ptrType(Field)).methods = [["End", "End", "", $funcType([], [token.Pos], false), -1], ["Pos", "Pos", "", $funcType([], [token.Pos], false), -1]]; - Field.init([["Doc", "Doc", "", ($ptrType(CommentGroup)), ""], ["Names", "Names", "", ($sliceType(($ptrType(Ident)))), ""], ["Type", "Type", "", Expr, ""], ["Tag", "Tag", "", ($ptrType(BasicLit)), ""], ["Comment", "Comment", "", ($ptrType(CommentGroup)), ""]]); - ($ptrType(FieldList)).methods = [["End", "End", "", $funcType([], [token.Pos], false), -1], ["NumFields", "NumFields", "", $funcType([], [$Int], false), -1], ["Pos", "Pos", "", $funcType([], [token.Pos], false), -1]]; - FieldList.init([["Opening", "Opening", "", token.Pos, ""], ["List", "List", "", ($sliceType(($ptrType(Field)))), ""], ["Closing", "Closing", "", token.Pos, ""]]); - ($ptrType(BadExpr)).methods = [["End", "End", "", $funcType([], [token.Pos], false), -1], ["Pos", "Pos", "", $funcType([], [token.Pos], false), -1], ["exprNode", "exprNode", "go/ast", $funcType([], [], false), -1]]; - BadExpr.init([["From", "From", "", token.Pos, ""], ["To", "To", "", token.Pos, ""]]); - ($ptrType(Ident)).methods = [["End", "End", "", $funcType([], [token.Pos], false), -1], ["IsExported", "IsExported", "", $funcType([], [$Bool], false), -1], ["Pos", "Pos", "", $funcType([], [token.Pos], false), -1], ["String", "String", "", $funcType([], [$String], false), -1], ["exprNode", "exprNode", "go/ast", $funcType([], [], false), -1]]; - Ident.init([["NamePos", "NamePos", "", token.Pos, ""], ["Name", "Name", "", $String, ""], ["Obj", "Obj", "", ($ptrType(Object)), ""]]); - ($ptrType(Ellipsis)).methods = [["End", "End", "", $funcType([], [token.Pos], false), -1], ["Pos", "Pos", "", $funcType([], [token.Pos], false), -1], ["exprNode", "exprNode", "go/ast", $funcType([], [], false), -1]]; - Ellipsis.init([["Ellipsis", "Ellipsis", "", token.Pos, ""], ["Elt", "Elt", "", Expr, ""]]); - ($ptrType(BasicLit)).methods = [["End", "End", "", $funcType([], [token.Pos], false), -1], ["Pos", "Pos", "", $funcType([], [token.Pos], false), -1], ["exprNode", "exprNode", "go/ast", $funcType([], [], false), -1]]; - BasicLit.init([["ValuePos", "ValuePos", "", token.Pos, ""], ["Kind", "Kind", "", token.Token, ""], ["Value", "Value", "", $String, ""]]); - ($ptrType(FuncLit)).methods = [["End", "End", "", $funcType([], [token.Pos], false), -1], ["Pos", "Pos", "", $funcType([], [token.Pos], false), -1], ["exprNode", "exprNode", "go/ast", $funcType([], [], false), -1]]; - FuncLit.init([["Type", "Type", "", ($ptrType(FuncType)), ""], ["Body", "Body", "", ($ptrType(BlockStmt)), ""]]); - ($ptrType(CompositeLit)).methods = [["End", "End", "", $funcType([], [token.Pos], false), -1], ["Pos", "Pos", "", $funcType([], [token.Pos], false), -1], ["exprNode", "exprNode", "go/ast", $funcType([], [], false), -1]]; - CompositeLit.init([["Type", "Type", "", Expr, ""], ["Lbrace", "Lbrace", "", token.Pos, ""], ["Elts", "Elts", "", ($sliceType(Expr)), ""], ["Rbrace", "Rbrace", "", token.Pos, ""]]); - ($ptrType(ParenExpr)).methods = [["End", "End", "", $funcType([], [token.Pos], false), -1], ["Pos", "Pos", "", $funcType([], [token.Pos], false), -1], ["exprNode", "exprNode", "go/ast", $funcType([], [], false), -1]]; - ParenExpr.init([["Lparen", "Lparen", "", token.Pos, ""], ["X", "X", "", Expr, ""], ["Rparen", "Rparen", "", token.Pos, ""]]); - ($ptrType(SelectorExpr)).methods = [["End", "End", "", $funcType([], [token.Pos], false), -1], ["Pos", "Pos", "", $funcType([], [token.Pos], false), -1], ["exprNode", "exprNode", "go/ast", $funcType([], [], false), -1]]; - SelectorExpr.init([["X", "X", "", Expr, ""], ["Sel", "Sel", "", ($ptrType(Ident)), ""]]); - ($ptrType(IndexExpr)).methods = [["End", "End", "", $funcType([], [token.Pos], false), -1], ["Pos", "Pos", "", $funcType([], [token.Pos], false), -1], ["exprNode", "exprNode", "go/ast", $funcType([], [], false), -1]]; - IndexExpr.init([["X", "X", "", Expr, ""], ["Lbrack", "Lbrack", "", token.Pos, ""], ["Index", "Index", "", Expr, ""], ["Rbrack", "Rbrack", "", token.Pos, ""]]); - ($ptrType(SliceExpr)).methods = [["End", "End", "", $funcType([], [token.Pos], false), -1], ["Pos", "Pos", "", $funcType([], [token.Pos], false), -1], ["exprNode", "exprNode", "go/ast", $funcType([], [], false), -1]]; - SliceExpr.init([["X", "X", "", Expr, ""], ["Lbrack", "Lbrack", "", token.Pos, ""], ["Low", "Low", "", Expr, ""], ["High", "High", "", Expr, ""], ["Max", "Max", "", Expr, ""], ["Slice3", "Slice3", "", $Bool, ""], ["Rbrack", "Rbrack", "", token.Pos, ""]]); - ($ptrType(TypeAssertExpr)).methods = [["End", "End", "", $funcType([], [token.Pos], false), -1], ["Pos", "Pos", "", $funcType([], [token.Pos], false), -1], ["exprNode", "exprNode", "go/ast", $funcType([], [], false), -1]]; - TypeAssertExpr.init([["X", "X", "", Expr, ""], ["Lparen", "Lparen", "", token.Pos, ""], ["Type", "Type", "", Expr, ""], ["Rparen", "Rparen", "", token.Pos, ""]]); - ($ptrType(CallExpr)).methods = [["End", "End", "", $funcType([], [token.Pos], false), -1], ["Pos", "Pos", "", $funcType([], [token.Pos], false), -1], ["exprNode", "exprNode", "go/ast", $funcType([], [], false), -1]]; - CallExpr.init([["Fun", "Fun", "", Expr, ""], ["Lparen", "Lparen", "", token.Pos, ""], ["Args", "Args", "", ($sliceType(Expr)), ""], ["Ellipsis", "Ellipsis", "", token.Pos, ""], ["Rparen", "Rparen", "", token.Pos, ""]]); - ($ptrType(StarExpr)).methods = [["End", "End", "", $funcType([], [token.Pos], false), -1], ["Pos", "Pos", "", $funcType([], [token.Pos], false), -1], ["exprNode", "exprNode", "go/ast", $funcType([], [], false), -1]]; - StarExpr.init([["Star", "Star", "", token.Pos, ""], ["X", "X", "", Expr, ""]]); - ($ptrType(UnaryExpr)).methods = [["End", "End", "", $funcType([], [token.Pos], false), -1], ["Pos", "Pos", "", $funcType([], [token.Pos], false), -1], ["exprNode", "exprNode", "go/ast", $funcType([], [], false), -1]]; - UnaryExpr.init([["OpPos", "OpPos", "", token.Pos, ""], ["Op", "Op", "", token.Token, ""], ["X", "X", "", Expr, ""]]); - ($ptrType(BinaryExpr)).methods = [["End", "End", "", $funcType([], [token.Pos], false), -1], ["Pos", "Pos", "", $funcType([], [token.Pos], false), -1], ["exprNode", "exprNode", "go/ast", $funcType([], [], false), -1]]; - BinaryExpr.init([["X", "X", "", Expr, ""], ["OpPos", "OpPos", "", token.Pos, ""], ["Op", "Op", "", token.Token, ""], ["Y", "Y", "", Expr, ""]]); - ($ptrType(KeyValueExpr)).methods = [["End", "End", "", $funcType([], [token.Pos], false), -1], ["Pos", "Pos", "", $funcType([], [token.Pos], false), -1], ["exprNode", "exprNode", "go/ast", $funcType([], [], false), -1]]; - KeyValueExpr.init([["Key", "Key", "", Expr, ""], ["Colon", "Colon", "", token.Pos, ""], ["Value", "Value", "", Expr, ""]]); - ($ptrType(ArrayType)).methods = [["End", "End", "", $funcType([], [token.Pos], false), -1], ["Pos", "Pos", "", $funcType([], [token.Pos], false), -1], ["exprNode", "exprNode", "go/ast", $funcType([], [], false), -1]]; - ArrayType.init([["Lbrack", "Lbrack", "", token.Pos, ""], ["Len", "Len", "", Expr, ""], ["Elt", "Elt", "", Expr, ""]]); - ($ptrType(StructType)).methods = [["End", "End", "", $funcType([], [token.Pos], false), -1], ["Pos", "Pos", "", $funcType([], [token.Pos], false), -1], ["exprNode", "exprNode", "go/ast", $funcType([], [], false), -1]]; - StructType.init([["Struct", "Struct", "", token.Pos, ""], ["Fields", "Fields", "", ($ptrType(FieldList)), ""], ["Incomplete", "Incomplete", "", $Bool, ""]]); - ($ptrType(FuncType)).methods = [["End", "End", "", $funcType([], [token.Pos], false), -1], ["Pos", "Pos", "", $funcType([], [token.Pos], false), -1], ["exprNode", "exprNode", "go/ast", $funcType([], [], false), -1]]; - FuncType.init([["Func", "Func", "", token.Pos, ""], ["Params", "Params", "", ($ptrType(FieldList)), ""], ["Results", "Results", "", ($ptrType(FieldList)), ""]]); - ($ptrType(InterfaceType)).methods = [["End", "End", "", $funcType([], [token.Pos], false), -1], ["Pos", "Pos", "", $funcType([], [token.Pos], false), -1], ["exprNode", "exprNode", "go/ast", $funcType([], [], false), -1]]; - InterfaceType.init([["Interface", "Interface", "", token.Pos, ""], ["Methods", "Methods", "", ($ptrType(FieldList)), ""], ["Incomplete", "Incomplete", "", $Bool, ""]]); - ($ptrType(MapType)).methods = [["End", "End", "", $funcType([], [token.Pos], false), -1], ["Pos", "Pos", "", $funcType([], [token.Pos], false), -1], ["exprNode", "exprNode", "go/ast", $funcType([], [], false), -1]]; - MapType.init([["Map", "Map", "", token.Pos, ""], ["Key", "Key", "", Expr, ""], ["Value", "Value", "", Expr, ""]]); - ($ptrType(ChanType)).methods = [["End", "End", "", $funcType([], [token.Pos], false), -1], ["Pos", "Pos", "", $funcType([], [token.Pos], false), -1], ["exprNode", "exprNode", "go/ast", $funcType([], [], false), -1]]; - ChanType.init([["Begin", "Begin", "", token.Pos, ""], ["Arrow", "Arrow", "", token.Pos, ""], ["Dir", "Dir", "", ChanDir, ""], ["Value", "Value", "", Expr, ""]]); - ($ptrType(BadStmt)).methods = [["End", "End", "", $funcType([], [token.Pos], false), -1], ["Pos", "Pos", "", $funcType([], [token.Pos], false), -1], ["stmtNode", "stmtNode", "go/ast", $funcType([], [], false), -1]]; - BadStmt.init([["From", "From", "", token.Pos, ""], ["To", "To", "", token.Pos, ""]]); - ($ptrType(DeclStmt)).methods = [["End", "End", "", $funcType([], [token.Pos], false), -1], ["Pos", "Pos", "", $funcType([], [token.Pos], false), -1], ["stmtNode", "stmtNode", "go/ast", $funcType([], [], false), -1]]; - DeclStmt.init([["Decl", "Decl", "", Decl, ""]]); - ($ptrType(EmptyStmt)).methods = [["End", "End", "", $funcType([], [token.Pos], false), -1], ["Pos", "Pos", "", $funcType([], [token.Pos], false), -1], ["stmtNode", "stmtNode", "go/ast", $funcType([], [], false), -1]]; - EmptyStmt.init([["Semicolon", "Semicolon", "", token.Pos, ""]]); - ($ptrType(LabeledStmt)).methods = [["End", "End", "", $funcType([], [token.Pos], false), -1], ["Pos", "Pos", "", $funcType([], [token.Pos], false), -1], ["stmtNode", "stmtNode", "go/ast", $funcType([], [], false), -1]]; - LabeledStmt.init([["Label", "Label", "", ($ptrType(Ident)), ""], ["Colon", "Colon", "", token.Pos, ""], ["Stmt", "Stmt", "", Stmt, ""]]); - ($ptrType(ExprStmt)).methods = [["End", "End", "", $funcType([], [token.Pos], false), -1], ["Pos", "Pos", "", $funcType([], [token.Pos], false), -1], ["stmtNode", "stmtNode", "go/ast", $funcType([], [], false), -1]]; - ExprStmt.init([["X", "X", "", Expr, ""]]); - ($ptrType(SendStmt)).methods = [["End", "End", "", $funcType([], [token.Pos], false), -1], ["Pos", "Pos", "", $funcType([], [token.Pos], false), -1], ["stmtNode", "stmtNode", "go/ast", $funcType([], [], false), -1]]; - SendStmt.init([["Chan", "Chan", "", Expr, ""], ["Arrow", "Arrow", "", token.Pos, ""], ["Value", "Value", "", Expr, ""]]); - ($ptrType(IncDecStmt)).methods = [["End", "End", "", $funcType([], [token.Pos], false), -1], ["Pos", "Pos", "", $funcType([], [token.Pos], false), -1], ["stmtNode", "stmtNode", "go/ast", $funcType([], [], false), -1]]; - IncDecStmt.init([["X", "X", "", Expr, ""], ["TokPos", "TokPos", "", token.Pos, ""], ["Tok", "Tok", "", token.Token, ""]]); - ($ptrType(AssignStmt)).methods = [["End", "End", "", $funcType([], [token.Pos], false), -1], ["Pos", "Pos", "", $funcType([], [token.Pos], false), -1], ["stmtNode", "stmtNode", "go/ast", $funcType([], [], false), -1]]; - AssignStmt.init([["Lhs", "Lhs", "", ($sliceType(Expr)), ""], ["TokPos", "TokPos", "", token.Pos, ""], ["Tok", "Tok", "", token.Token, ""], ["Rhs", "Rhs", "", ($sliceType(Expr)), ""]]); - ($ptrType(GoStmt)).methods = [["End", "End", "", $funcType([], [token.Pos], false), -1], ["Pos", "Pos", "", $funcType([], [token.Pos], false), -1], ["stmtNode", "stmtNode", "go/ast", $funcType([], [], false), -1]]; - GoStmt.init([["Go", "Go", "", token.Pos, ""], ["Call", "Call", "", ($ptrType(CallExpr)), ""]]); - ($ptrType(DeferStmt)).methods = [["End", "End", "", $funcType([], [token.Pos], false), -1], ["Pos", "Pos", "", $funcType([], [token.Pos], false), -1], ["stmtNode", "stmtNode", "go/ast", $funcType([], [], false), -1]]; - DeferStmt.init([["Defer", "Defer", "", token.Pos, ""], ["Call", "Call", "", ($ptrType(CallExpr)), ""]]); - ($ptrType(ReturnStmt)).methods = [["End", "End", "", $funcType([], [token.Pos], false), -1], ["Pos", "Pos", "", $funcType([], [token.Pos], false), -1], ["stmtNode", "stmtNode", "go/ast", $funcType([], [], false), -1]]; - ReturnStmt.init([["Return", "Return", "", token.Pos, ""], ["Results", "Results", "", ($sliceType(Expr)), ""]]); - ($ptrType(BranchStmt)).methods = [["End", "End", "", $funcType([], [token.Pos], false), -1], ["Pos", "Pos", "", $funcType([], [token.Pos], false), -1], ["stmtNode", "stmtNode", "go/ast", $funcType([], [], false), -1]]; - BranchStmt.init([["TokPos", "TokPos", "", token.Pos, ""], ["Tok", "Tok", "", token.Token, ""], ["Label", "Label", "", ($ptrType(Ident)), ""]]); - ($ptrType(BlockStmt)).methods = [["End", "End", "", $funcType([], [token.Pos], false), -1], ["Pos", "Pos", "", $funcType([], [token.Pos], false), -1], ["stmtNode", "stmtNode", "go/ast", $funcType([], [], false), -1]]; - BlockStmt.init([["Lbrace", "Lbrace", "", token.Pos, ""], ["List", "List", "", ($sliceType(Stmt)), ""], ["Rbrace", "Rbrace", "", token.Pos, ""]]); - ($ptrType(IfStmt)).methods = [["End", "End", "", $funcType([], [token.Pos], false), -1], ["Pos", "Pos", "", $funcType([], [token.Pos], false), -1], ["stmtNode", "stmtNode", "go/ast", $funcType([], [], false), -1]]; - IfStmt.init([["If", "If", "", token.Pos, ""], ["Init", "Init", "", Stmt, ""], ["Cond", "Cond", "", Expr, ""], ["Body", "Body", "", ($ptrType(BlockStmt)), ""], ["Else", "Else", "", Stmt, ""]]); - ($ptrType(CaseClause)).methods = [["End", "End", "", $funcType([], [token.Pos], false), -1], ["Pos", "Pos", "", $funcType([], [token.Pos], false), -1], ["stmtNode", "stmtNode", "go/ast", $funcType([], [], false), -1]]; - CaseClause.init([["Case", "Case", "", token.Pos, ""], ["List", "List", "", ($sliceType(Expr)), ""], ["Colon", "Colon", "", token.Pos, ""], ["Body", "Body", "", ($sliceType(Stmt)), ""]]); - ($ptrType(SwitchStmt)).methods = [["End", "End", "", $funcType([], [token.Pos], false), -1], ["Pos", "Pos", "", $funcType([], [token.Pos], false), -1], ["stmtNode", "stmtNode", "go/ast", $funcType([], [], false), -1]]; - SwitchStmt.init([["Switch", "Switch", "", token.Pos, ""], ["Init", "Init", "", Stmt, ""], ["Tag", "Tag", "", Expr, ""], ["Body", "Body", "", ($ptrType(BlockStmt)), ""]]); - ($ptrType(TypeSwitchStmt)).methods = [["End", "End", "", $funcType([], [token.Pos], false), -1], ["Pos", "Pos", "", $funcType([], [token.Pos], false), -1], ["stmtNode", "stmtNode", "go/ast", $funcType([], [], false), -1]]; - TypeSwitchStmt.init([["Switch", "Switch", "", token.Pos, ""], ["Init", "Init", "", Stmt, ""], ["Assign", "Assign", "", Stmt, ""], ["Body", "Body", "", ($ptrType(BlockStmt)), ""]]); - ($ptrType(CommClause)).methods = [["End", "End", "", $funcType([], [token.Pos], false), -1], ["Pos", "Pos", "", $funcType([], [token.Pos], false), -1], ["stmtNode", "stmtNode", "go/ast", $funcType([], [], false), -1]]; - CommClause.init([["Case", "Case", "", token.Pos, ""], ["Comm", "Comm", "", Stmt, ""], ["Colon", "Colon", "", token.Pos, ""], ["Body", "Body", "", ($sliceType(Stmt)), ""]]); - ($ptrType(SelectStmt)).methods = [["End", "End", "", $funcType([], [token.Pos], false), -1], ["Pos", "Pos", "", $funcType([], [token.Pos], false), -1], ["stmtNode", "stmtNode", "go/ast", $funcType([], [], false), -1]]; - SelectStmt.init([["Select", "Select", "", token.Pos, ""], ["Body", "Body", "", ($ptrType(BlockStmt)), ""]]); - ($ptrType(ForStmt)).methods = [["End", "End", "", $funcType([], [token.Pos], false), -1], ["Pos", "Pos", "", $funcType([], [token.Pos], false), -1], ["stmtNode", "stmtNode", "go/ast", $funcType([], [], false), -1]]; - ForStmt.init([["For", "For", "", token.Pos, ""], ["Init", "Init", "", Stmt, ""], ["Cond", "Cond", "", Expr, ""], ["Post", "Post", "", Stmt, ""], ["Body", "Body", "", ($ptrType(BlockStmt)), ""]]); - ($ptrType(RangeStmt)).methods = [["End", "End", "", $funcType([], [token.Pos], false), -1], ["Pos", "Pos", "", $funcType([], [token.Pos], false), -1], ["stmtNode", "stmtNode", "go/ast", $funcType([], [], false), -1]]; - RangeStmt.init([["For", "For", "", token.Pos, ""], ["Key", "Key", "", Expr, ""], ["Value", "Value", "", Expr, ""], ["TokPos", "TokPos", "", token.Pos, ""], ["Tok", "Tok", "", token.Token, ""], ["X", "X", "", Expr, ""], ["Body", "Body", "", ($ptrType(BlockStmt)), ""]]); - Spec.init([["End", "End", "", $funcType([], [token.Pos], false)], ["Pos", "Pos", "", $funcType([], [token.Pos], false)], ["specNode", "specNode", "go/ast", $funcType([], [], false)]]); - ($ptrType(ImportSpec)).methods = [["End", "End", "", $funcType([], [token.Pos], false), -1], ["Pos", "Pos", "", $funcType([], [token.Pos], false), -1], ["specNode", "specNode", "go/ast", $funcType([], [], false), -1]]; - ImportSpec.init([["Doc", "Doc", "", ($ptrType(CommentGroup)), ""], ["Name", "Name", "", ($ptrType(Ident)), ""], ["Path", "Path", "", ($ptrType(BasicLit)), ""], ["Comment", "Comment", "", ($ptrType(CommentGroup)), ""], ["EndPos", "EndPos", "", token.Pos, ""]]); - ($ptrType(ValueSpec)).methods = [["End", "End", "", $funcType([], [token.Pos], false), -1], ["Pos", "Pos", "", $funcType([], [token.Pos], false), -1], ["specNode", "specNode", "go/ast", $funcType([], [], false), -1]]; - ValueSpec.init([["Doc", "Doc", "", ($ptrType(CommentGroup)), ""], ["Names", "Names", "", ($sliceType(($ptrType(Ident)))), ""], ["Type", "Type", "", Expr, ""], ["Values", "Values", "", ($sliceType(Expr)), ""], ["Comment", "Comment", "", ($ptrType(CommentGroup)), ""]]); - ($ptrType(TypeSpec)).methods = [["End", "End", "", $funcType([], [token.Pos], false), -1], ["Pos", "Pos", "", $funcType([], [token.Pos], false), -1], ["specNode", "specNode", "go/ast", $funcType([], [], false), -1]]; - TypeSpec.init([["Doc", "Doc", "", ($ptrType(CommentGroup)), ""], ["Name", "Name", "", ($ptrType(Ident)), ""], ["Type", "Type", "", Expr, ""], ["Comment", "Comment", "", ($ptrType(CommentGroup)), ""]]); - ($ptrType(BadDecl)).methods = [["End", "End", "", $funcType([], [token.Pos], false), -1], ["Pos", "Pos", "", $funcType([], [token.Pos], false), -1], ["declNode", "declNode", "go/ast", $funcType([], [], false), -1]]; - BadDecl.init([["From", "From", "", token.Pos, ""], ["To", "To", "", token.Pos, ""]]); - ($ptrType(GenDecl)).methods = [["End", "End", "", $funcType([], [token.Pos], false), -1], ["Pos", "Pos", "", $funcType([], [token.Pos], false), -1], ["declNode", "declNode", "go/ast", $funcType([], [], false), -1]]; - GenDecl.init([["Doc", "Doc", "", ($ptrType(CommentGroup)), ""], ["TokPos", "TokPos", "", token.Pos, ""], ["Tok", "Tok", "", token.Token, ""], ["Lparen", "Lparen", "", token.Pos, ""], ["Specs", "Specs", "", ($sliceType(Spec)), ""], ["Rparen", "Rparen", "", token.Pos, ""]]); - ($ptrType(FuncDecl)).methods = [["End", "End", "", $funcType([], [token.Pos], false), -1], ["Pos", "Pos", "", $funcType([], [token.Pos], false), -1], ["declNode", "declNode", "go/ast", $funcType([], [], false), -1]]; - FuncDecl.init([["Doc", "Doc", "", ($ptrType(CommentGroup)), ""], ["Recv", "Recv", "", ($ptrType(FieldList)), ""], ["Name", "Name", "", ($ptrType(Ident)), ""], ["Type", "Type", "", ($ptrType(FuncType)), ""], ["Body", "Body", "", ($ptrType(BlockStmt)), ""]]); - ($ptrType(File)).methods = [["End", "End", "", $funcType([], [token.Pos], false), -1], ["Pos", "Pos", "", $funcType([], [token.Pos], false), -1]]; - File.init([["Doc", "Doc", "", ($ptrType(CommentGroup)), ""], ["Package", "Package", "", token.Pos, ""], ["Name", "Name", "", ($ptrType(Ident)), ""], ["Decls", "Decls", "", ($sliceType(Decl)), ""], ["Scope", "Scope", "", ($ptrType(Scope)), ""], ["Imports", "Imports", "", ($sliceType(($ptrType(ImportSpec)))), ""], ["Unresolved", "Unresolved", "", ($sliceType(($ptrType(Ident)))), ""], ["Comments", "Comments", "", ($sliceType(($ptrType(CommentGroup)))), ""]]); - ($ptrType(Package)).methods = [["End", "End", "", $funcType([], [token.Pos], false), -1], ["Pos", "Pos", "", $funcType([], [token.Pos], false), -1]]; - Package.init([["Name", "Name", "", $String, ""], ["Scope", "Scope", "", ($ptrType(Scope)), ""], ["Imports", "Imports", "", ($mapType($String, ($ptrType(Object)))), ""], ["Files", "Files", "", ($mapType($String, ($ptrType(File)))), ""]]); - byPos.methods = [["Len", "Len", "", $funcType([], [$Int], false), -1], ["Less", "Less", "", $funcType([$Int, $Int], [$Bool], false), -1], ["Swap", "Swap", "", $funcType([$Int, $Int], [], false), -1]]; - ($ptrType(byPos)).methods = [["Len", "Len", "", $funcType([], [$Int], false), -1], ["Less", "Less", "", $funcType([$Int, $Int], [$Bool], false), -1], ["Swap", "Swap", "", $funcType([$Int, $Int], [], false), -1]]; - byPos.init(($ptrType(CommentGroup))); - CommentMap.methods = [["Comments", "Comments", "", $funcType([], [($sliceType(($ptrType(CommentGroup))))], false), -1], ["Filter", "Filter", "", $funcType([Node], [CommentMap], false), -1], ["String", "String", "", $funcType([], [$String], false), -1], ["Update", "Update", "", $funcType([Node, Node], [Node], false), -1], ["addComment", "addComment", "go/ast", $funcType([Node, ($ptrType(CommentGroup))], [], false), -1]]; - ($ptrType(CommentMap)).methods = [["Comments", "Comments", "", $funcType([], [($sliceType(($ptrType(CommentGroup))))], false), -1], ["Filter", "Filter", "", $funcType([Node], [CommentMap], false), -1], ["String", "String", "", $funcType([], [$String], false), -1], ["Update", "Update", "", $funcType([Node, Node], [Node], false), -1], ["addComment", "addComment", "go/ast", $funcType([Node, ($ptrType(CommentGroup))], [], false), -1]]; - CommentMap.init(Node, ($sliceType(($ptrType(CommentGroup))))); - ($ptrType(commentListReader)).methods = [["eol", "eol", "go/ast", $funcType([], [$Bool], false), -1], ["next", "next", "go/ast", $funcType([], [], false), -1]]; - commentListReader.init([["fset", "fset", "go/ast", ($ptrType(token.FileSet)), ""], ["list", "list", "go/ast", ($sliceType(($ptrType(CommentGroup)))), ""], ["index", "index", "go/ast", $Int, ""], ["comment", "comment", "go/ast", ($ptrType(CommentGroup)), ""], ["pos", "pos", "go/ast", token.Position, ""], ["end", "end", "go/ast", token.Position, ""]]); - ($ptrType(nodeStack)).methods = [["pop", "pop", "go/ast", $funcType([token.Pos], [Node], false), -1], ["push", "push", "go/ast", $funcType([Node], [], false), -1]]; - nodeStack.init(Node); - posSpan.init([["Start", "Start", "", token.Pos, ""], ["End", "End", "", token.Pos, ""]]); - byImportSpec.methods = [["Len", "Len", "", $funcType([], [$Int], false), -1], ["Less", "Less", "", $funcType([$Int, $Int], [$Bool], false), -1], ["Swap", "Swap", "", $funcType([$Int, $Int], [], false), -1]]; - ($ptrType(byImportSpec)).methods = [["Len", "Len", "", $funcType([], [$Int], false), -1], ["Less", "Less", "", $funcType([$Int, $Int], [$Bool], false), -1], ["Swap", "Swap", "", $funcType([$Int, $Int], [], false), -1]]; - byImportSpec.init(Spec); - byCommentPos.methods = [["Len", "Len", "", $funcType([], [$Int], false), -1], ["Less", "Less", "", $funcType([$Int, $Int], [$Bool], false), -1], ["Swap", "Swap", "", $funcType([$Int, $Int], [], false), -1]]; - ($ptrType(byCommentPos)).methods = [["Len", "Len", "", $funcType([], [$Int], false), -1], ["Less", "Less", "", $funcType([$Int, $Int], [$Bool], false), -1], ["Swap", "Swap", "", $funcType([$Int, $Int], [], false), -1]]; - byCommentPos.init(($ptrType(CommentGroup))); - ($ptrType(Scope)).methods = [["Insert", "Insert", "", $funcType([($ptrType(Object))], [($ptrType(Object))], false), -1], ["Lookup", "Lookup", "", $funcType([$String], [($ptrType(Object))], false), -1], ["String", "String", "", $funcType([], [$String], false), -1]]; - Scope.init([["Outer", "Outer", "", ($ptrType(Scope)), ""], ["Objects", "Objects", "", ($mapType($String, ($ptrType(Object)))), ""]]); - ($ptrType(Object)).methods = [["Pos", "Pos", "", $funcType([], [token.Pos], false), -1]]; - Object.init([["Kind", "Kind", "", ObjKind, ""], ["Name", "Name", "", $String, ""], ["Decl", "Decl", "", $emptyInterface, ""], ["Data", "Data", "", $emptyInterface, ""], ["Type", "Type", "", $emptyInterface, ""]]); - ObjKind.methods = [["String", "String", "", $funcType([], [$String], false), -1]]; - ($ptrType(ObjKind)).methods = [["String", "String", "", $funcType([], [$String], false), -1]]; - Visitor.init([["Visit", "Visit", "", $funcType([Node], [Visitor], false)]]); - inspector.methods = [["Visit", "Visit", "", $funcType([Node], [Visitor], false), -1]]; - ($ptrType(inspector)).methods = [["Visit", "Visit", "", $funcType([Node], [Visitor], false), -1]]; - inspector.init([Node], [$Bool], false); - objKindStrings = $toNativeArray("String", ["bad", "package", "const", "type", "var", "func", "label"]); + Rat.prototype.String = function() { return this.$val.String(); }; + Rat.Ptr.prototype.RatString = function() { + var x; + x = this; + if (x.IsInt()) { + return x.a.String(); + } + return x.String(); }; - return $pkg; -})(); -$packages["io/ioutil"] = (function() { - var $pkg = {}, bytes = $packages["bytes"], io = $packages["io"], os = $packages["os"], sort = $packages["sort"], sync = $packages["sync"], filepath = $packages["path/filepath"], strconv = $packages["strconv"], time = $packages["time"], byName, blackHolePool, readAll, ReadFile, ReadDir; - byName = $pkg.byName = $newType(12, "Slice", "ioutil.byName", "byName", "io/ioutil", null); - readAll = function(r, capacity) { - var b = ($sliceType($Uint8)).nil, err = $ifaceNil, $deferred = [], $err = null, buf, _tuple, _tmp, _tmp$1; - /* */ try { $deferFrames.push($deferred); - buf = bytes.NewBuffer(($sliceType($Uint8)).make(0, $flatten64(capacity))); - $deferred.push([(function() { - var e, _tuple, panicErr, ok; - e = $recover(); - if ($interfaceIsEqual(e, $ifaceNil)) { - return; - } - _tuple = $assertType(e, $error, true); panicErr = _tuple[0]; ok = _tuple[1]; - if (ok && $interfaceIsEqual(panicErr, bytes.ErrTooLarge)) { - err = panicErr; - } else { - $panic(e); + Rat.prototype.RatString = function() { return this.$val.RatString(); }; + Rat.Ptr.prototype.FloatString = function(prec) { + var x, s, _tuple, q, r, p, _tuple$1, r2, s$1, rs, leadingZeros$1; + x = this; + if (x.IsInt()) { + s = x.a.String(); + if (prec > 0) { + s = s + ("." + strings.Repeat("0", prec)); } - }), []]); - _tuple = buf.ReadFrom(r); err = _tuple[1]; - _tmp = buf.Bytes(); _tmp$1 = err; b = _tmp; err = _tmp$1; - return [b, err]; - /* */ } catch(err) { $err = err; } finally { $deferFrames.pop(); $callDeferred($deferred, $err); return [b, err]; } - }; - ReadFile = $pkg.ReadFile = function(filename) { - var $deferred = [], $err = null, _tuple, f, err, n, _tuple$1, fi, err$1, size; - /* */ try { $deferFrames.push($deferred); - _tuple = os.Open(filename); f = _tuple[0]; err = _tuple[1]; - if (!($interfaceIsEqual(err, $ifaceNil))) { - return [($sliceType($Uint8)).nil, err]; + return s; + } + _tuple = nat.nil.div(nat.nil, x.a.abs, x.b.abs); q = _tuple[0]; r = _tuple[1]; + p = natOne; + if (prec > 0) { + p = nat.nil.expNN(natTen, nat.nil.setUint64(new $Uint64(0, prec)), nat.nil); } - $deferred.push([$methodVal(f, "Close"), []]); - n = new $Int64(0, 0); - _tuple$1 = f.Stat(); fi = _tuple$1[0]; err$1 = _tuple$1[1]; - if ($interfaceIsEqual(err$1, $ifaceNil)) { - size = fi.Size(); - if ((size.$high < 0 || (size.$high === 0 && size.$low < 1000000000))) { - n = size; + r = r.mul(r, p); + _tuple$1 = r.div(nat.nil, r, x.b.abs); r = _tuple$1[0]; r2 = _tuple$1[1]; + r2 = r2.add(r2, r2); + if (x.b.abs.cmp(r2) <= 0) { + r = r.add(r, natOne); + if (r.cmp(p) >= 0) { + q = nat.nil.add(q, natOne); + r = nat.nil.sub(r, p); } } - return readAll(f, new $Int64(n.$high + 0, n.$low + 512)); - /* */ } catch(err) { $err = err; return [($sliceType($Uint8)).nil, $ifaceNil]; } finally { $deferFrames.pop(); $callDeferred($deferred, $err); } + s$1 = q.decimalString(); + if (x.a.neg) { + s$1 = "-" + s$1; + } + if (prec > 0) { + rs = r.decimalString(); + leadingZeros$1 = prec - rs.length >> 0; + s$1 = s$1 + ("." + strings.Repeat("0", leadingZeros$1) + rs); + } + return s$1; }; - byName.prototype.Len = function() { - var f; - f = this; - return f.$length; + Rat.prototype.FloatString = function(prec) { return this.$val.FloatString(prec); }; + Rat.Ptr.prototype.GobEncode = function() { + var x, x$1, buf, i, j, n, b; + x = this; + if (x === ($ptrType(Rat)).nil) { + return [($sliceType($Uint8)).nil, $ifaceNil]; + } + buf = ($sliceType($Uint8)).make((5 + (x$1 = (x.a.abs.$length + x.b.abs.$length >> 0), (((x$1 >>> 16 << 16) * 4 >> 0) + (x$1 << 16 >>> 16) * 4) >> 0) >> 0)); + i = x.b.abs.bytes(buf); + j = x.a.abs.bytes($subslice(buf, 0, i)); + n = i - j >> 0; + if (!((((n >>> 0) >> 0) === n))) { + return [($sliceType($Uint8)).nil, errors.New("Rat.GobEncode: numerator too large")]; + } + binary.BigEndian.PutUint32($subslice(buf, (j - 4 >> 0), j), (n >>> 0)); + j = j - (5) >> 0; + b = 2; + if (x.a.neg) { + b = (b | (1)) >>> 0; + } + (j < 0 || j >= buf.$length) ? $throwRuntimeError("index out of range") : buf.$array[buf.$offset + j] = b; + return [$subslice(buf, j), $ifaceNil]; }; - $ptrType(byName).prototype.Len = function() { return this.$get().Len(); }; - byName.prototype.Less = function(i, j) { - var f; - f = this; - return ((i < 0 || i >= f.$length) ? $throwRuntimeError("index out of range") : f.$array[f.$offset + i]).Name() < ((j < 0 || j >= f.$length) ? $throwRuntimeError("index out of range") : f.$array[f.$offset + j]).Name(); + Rat.prototype.GobEncode = function() { return this.$val.GobEncode(); }; + Rat.Ptr.prototype.GobDecode = function(buf) { + var z, b, i; + z = this; + if (buf.$length === 0) { + $copy(z, new Rat.Ptr(new Int.Ptr(), new Int.Ptr()), Rat); + return $ifaceNil; + } + b = ((0 < 0 || 0 >= buf.$length) ? $throwRuntimeError("index out of range") : buf.$array[buf.$offset + 0]); + if (!(((b >>> 1 << 24 >>> 24) === 1))) { + return errors.New(fmt.Sprintf("Rat.GobDecode: encoding version %d not supported", new ($sliceType($emptyInterface))([new $Uint8((b >>> 1 << 24 >>> 24))]))); + } + i = 5 + binary.BigEndian.Uint32($subslice(buf, 1, 5)) >>> 0; + z.a.neg = !((((b & 1) >>> 0) === 0)); + z.a.abs = z.a.abs.setBytes($subslice(buf, 5, i)); + z.b.abs = z.b.abs.setBytes($subslice(buf, i)); + return $ifaceNil; }; - $ptrType(byName).prototype.Less = function(i, j) { return this.$get().Less(i, j); }; - byName.prototype.Swap = function(i, j) { - var f, _tmp, _tmp$1; - f = this; - _tmp = ((j < 0 || j >= f.$length) ? $throwRuntimeError("index out of range") : f.$array[f.$offset + j]); _tmp$1 = ((i < 0 || i >= f.$length) ? $throwRuntimeError("index out of range") : f.$array[f.$offset + i]); (i < 0 || i >= f.$length) ? $throwRuntimeError("index out of range") : f.$array[f.$offset + i] = _tmp; (j < 0 || j >= f.$length) ? $throwRuntimeError("index out of range") : f.$array[f.$offset + j] = _tmp$1; + Rat.prototype.GobDecode = function(buf) { return this.$val.GobDecode(buf); }; + Rat.Ptr.prototype.MarshalText = function() { + var text = ($sliceType($Uint8)).nil, err = $ifaceNil, r, _tmp, _tmp$1; + r = this; + _tmp = new ($sliceType($Uint8))($stringToBytes(r.RatString())); _tmp$1 = $ifaceNil; text = _tmp; err = _tmp$1; + return [text, err]; }; - $ptrType(byName).prototype.Swap = function(i, j) { return this.$get().Swap(i, j); }; - ReadDir = $pkg.ReadDir = function(dirname) { - var _tuple, f, err, _tuple$1, list; - _tuple = os.Open(dirname); f = _tuple[0]; err = _tuple[1]; - if (!($interfaceIsEqual(err, $ifaceNil))) { - return [($sliceType(os.FileInfo)).nil, err]; - } - _tuple$1 = f.Readdir(-1); list = _tuple$1[0]; err = _tuple$1[1]; - f.Close(); - if (!($interfaceIsEqual(err, $ifaceNil))) { - return [($sliceType(os.FileInfo)).nil, err]; + Rat.prototype.MarshalText = function() { return this.$val.MarshalText(); }; + Rat.Ptr.prototype.UnmarshalText = function(text) { + var r, _tuple, ok; + r = this; + _tuple = r.SetString($bytesToString(text)); ok = _tuple[1]; + if (!ok) { + return fmt.Errorf("math/big: cannot unmarshal %q into a *big.Rat", new ($sliceType($emptyInterface))([text])); } - sort.Sort($subslice(new byName(list.$array), list.$offset, list.$offset + list.$length)); - return [list, $ifaceNil]; + return $ifaceNil; }; + Rat.prototype.UnmarshalText = function(text) { return this.$val.UnmarshalText(text); }; $pkg.$init = function() { - byName.methods = [["Len", "Len", "", $funcType([], [$Int], false), -1], ["Less", "Less", "", $funcType([$Int, $Int], [$Bool], false), -1], ["Swap", "Swap", "", $funcType([$Int, $Int], [], false), -1]]; - ($ptrType(byName)).methods = [["Len", "Len", "", $funcType([], [$Int], false), -1], ["Less", "Less", "", $funcType([$Int, $Int], [$Bool], false), -1], ["Swap", "Swap", "", $funcType([$Int, $Int], [], false), -1]]; - byName.init(os.FileInfo); - blackHolePool = new sync.Pool.Ptr(0, 0, ($sliceType($emptyInterface)).nil, (function() { - var b; - b = ($sliceType($Uint8)).make(8192); - return new ($ptrType(($sliceType($Uint8))))(function() { return b; }, function($v) { b = $v; }); - })); + ($ptrType(Int)).methods = [["Abs", "Abs", "", $funcType([($ptrType(Int))], [($ptrType(Int))], false), -1], ["Add", "Add", "", $funcType([($ptrType(Int)), ($ptrType(Int))], [($ptrType(Int))], false), -1], ["And", "And", "", $funcType([($ptrType(Int)), ($ptrType(Int))], [($ptrType(Int))], false), -1], ["AndNot", "AndNot", "", $funcType([($ptrType(Int)), ($ptrType(Int))], [($ptrType(Int))], false), -1], ["Binomial", "Binomial", "", $funcType([$Int64, $Int64], [($ptrType(Int))], false), -1], ["Bit", "Bit", "", $funcType([$Int], [$Uint], false), -1], ["BitLen", "BitLen", "", $funcType([], [$Int], false), -1], ["Bits", "Bits", "", $funcType([], [($sliceType(Word))], false), -1], ["Bytes", "Bytes", "", $funcType([], [($sliceType($Uint8))], false), -1], ["Cmp", "Cmp", "", $funcType([($ptrType(Int))], [$Int], false), -1], ["Div", "Div", "", $funcType([($ptrType(Int)), ($ptrType(Int))], [($ptrType(Int))], false), -1], ["DivMod", "DivMod", "", $funcType([($ptrType(Int)), ($ptrType(Int)), ($ptrType(Int))], [($ptrType(Int)), ($ptrType(Int))], false), -1], ["Exp", "Exp", "", $funcType([($ptrType(Int)), ($ptrType(Int)), ($ptrType(Int))], [($ptrType(Int))], false), -1], ["Format", "Format", "", $funcType([fmt.State, $Int32], [], false), -1], ["GCD", "GCD", "", $funcType([($ptrType(Int)), ($ptrType(Int)), ($ptrType(Int)), ($ptrType(Int))], [($ptrType(Int))], false), -1], ["GobDecode", "GobDecode", "", $funcType([($sliceType($Uint8))], [$error], false), -1], ["GobEncode", "GobEncode", "", $funcType([], [($sliceType($Uint8)), $error], false), -1], ["Int64", "Int64", "", $funcType([], [$Int64], false), -1], ["Lsh", "Lsh", "", $funcType([($ptrType(Int)), $Uint], [($ptrType(Int))], false), -1], ["MarshalJSON", "MarshalJSON", "", $funcType([], [($sliceType($Uint8)), $error], false), -1], ["MarshalText", "MarshalText", "", $funcType([], [($sliceType($Uint8)), $error], false), -1], ["Mod", "Mod", "", $funcType([($ptrType(Int)), ($ptrType(Int))], [($ptrType(Int))], false), -1], ["ModInverse", "ModInverse", "", $funcType([($ptrType(Int)), ($ptrType(Int))], [($ptrType(Int))], false), -1], ["Mul", "Mul", "", $funcType([($ptrType(Int)), ($ptrType(Int))], [($ptrType(Int))], false), -1], ["MulRange", "MulRange", "", $funcType([$Int64, $Int64], [($ptrType(Int))], false), -1], ["Neg", "Neg", "", $funcType([($ptrType(Int))], [($ptrType(Int))], false), -1], ["Not", "Not", "", $funcType([($ptrType(Int))], [($ptrType(Int))], false), -1], ["Or", "Or", "", $funcType([($ptrType(Int)), ($ptrType(Int))], [($ptrType(Int))], false), -1], ["ProbablyPrime", "ProbablyPrime", "", $funcType([$Int], [$Bool], false), -1], ["Quo", "Quo", "", $funcType([($ptrType(Int)), ($ptrType(Int))], [($ptrType(Int))], false), -1], ["QuoRem", "QuoRem", "", $funcType([($ptrType(Int)), ($ptrType(Int)), ($ptrType(Int))], [($ptrType(Int)), ($ptrType(Int))], false), -1], ["Rand", "Rand", "", $funcType([($ptrType(rand.Rand)), ($ptrType(Int))], [($ptrType(Int))], false), -1], ["Rem", "Rem", "", $funcType([($ptrType(Int)), ($ptrType(Int))], [($ptrType(Int))], false), -1], ["Rsh", "Rsh", "", $funcType([($ptrType(Int)), $Uint], [($ptrType(Int))], false), -1], ["Scan", "Scan", "", $funcType([fmt.ScanState, $Int32], [$error], false), -1], ["Set", "Set", "", $funcType([($ptrType(Int))], [($ptrType(Int))], false), -1], ["SetBit", "SetBit", "", $funcType([($ptrType(Int)), $Int, $Uint], [($ptrType(Int))], false), -1], ["SetBits", "SetBits", "", $funcType([($sliceType(Word))], [($ptrType(Int))], false), -1], ["SetBytes", "SetBytes", "", $funcType([($sliceType($Uint8))], [($ptrType(Int))], false), -1], ["SetInt64", "SetInt64", "", $funcType([$Int64], [($ptrType(Int))], false), -1], ["SetString", "SetString", "", $funcType([$String, $Int], [($ptrType(Int)), $Bool], false), -1], ["SetUint64", "SetUint64", "", $funcType([$Uint64], [($ptrType(Int))], false), -1], ["Sign", "Sign", "", $funcType([], [$Int], false), -1], ["String", "String", "", $funcType([], [$String], false), -1], ["Sub", "Sub", "", $funcType([($ptrType(Int)), ($ptrType(Int))], [($ptrType(Int))], false), -1], ["Uint64", "Uint64", "", $funcType([], [$Uint64], false), -1], ["UnmarshalJSON", "UnmarshalJSON", "", $funcType([($sliceType($Uint8))], [$error], false), -1], ["UnmarshalText", "UnmarshalText", "", $funcType([($sliceType($Uint8))], [$error], false), -1], ["Xor", "Xor", "", $funcType([($ptrType(Int)), ($ptrType(Int))], [($ptrType(Int))], false), -1], ["binaryGCD", "binaryGCD", "math/big", $funcType([($ptrType(Int)), ($ptrType(Int))], [($ptrType(Int))], false), -1], ["scan", "scan", "math/big", $funcType([io.RuneScanner, $Int], [($ptrType(Int)), $Int, $error], false), -1]]; + Int.init([["neg", "neg", "math/big", $Bool, ""], ["abs", "abs", "math/big", nat, ""]]); + nat.methods = [["add", "add", "math/big", $funcType([nat, nat], [nat], false), -1], ["and", "and", "math/big", $funcType([nat, nat], [nat], false), -1], ["andNot", "andNot", "math/big", $funcType([nat, nat], [nat], false), -1], ["bit", "bit", "math/big", $funcType([$Uint], [$Uint], false), -1], ["bitLen", "bitLen", "math/big", $funcType([], [$Int], false), -1], ["bytes", "bytes", "math/big", $funcType([($sliceType($Uint8))], [$Int], false), -1], ["clear", "clear", "math/big", $funcType([], [], false), -1], ["cmp", "cmp", "math/big", $funcType([nat], [$Int], false), -1], ["convertWords", "convertWords", "math/big", $funcType([($sliceType($Uint8)), $String, Word, $Int, Word, ($sliceType(divisor))], [], false), -1], ["decimalString", "decimalString", "math/big", $funcType([], [$String], false), -1], ["div", "div", "math/big", $funcType([nat, nat, nat], [nat, nat], false), -1], ["divLarge", "divLarge", "math/big", $funcType([nat, nat, nat], [nat, nat], false), -1], ["divW", "divW", "math/big", $funcType([nat, Word], [nat, Word], false), -1], ["expNN", "expNN", "math/big", $funcType([nat, nat, nat], [nat], false), -1], ["expNNWindowed", "expNNWindowed", "math/big", $funcType([nat, nat, nat], [nat], false), -1], ["expWW", "expWW", "math/big", $funcType([Word, Word], [nat], false), -1], ["make", "make", "math/big", $funcType([$Int], [nat], false), -1], ["modW", "modW", "math/big", $funcType([Word], [Word], false), -1], ["mul", "mul", "math/big", $funcType([nat, nat], [nat], false), -1], ["mulAddWW", "mulAddWW", "math/big", $funcType([nat, Word, Word], [nat], false), -1], ["mulRange", "mulRange", "math/big", $funcType([$Uint64, $Uint64], [nat], false), -1], ["norm", "norm", "math/big", $funcType([], [nat], false), -1], ["or", "or", "math/big", $funcType([nat, nat], [nat], false), -1], ["probablyPrime", "probablyPrime", "math/big", $funcType([$Int], [$Bool], false), -1], ["random", "random", "math/big", $funcType([($ptrType(rand.Rand)), nat, $Int], [nat], false), -1], ["scan", "scan", "math/big", $funcType([io.RuneScanner, $Int], [nat, $Int, $error], false), -1], ["set", "set", "math/big", $funcType([nat], [nat], false), -1], ["setBit", "setBit", "math/big", $funcType([nat, $Uint, $Uint], [nat], false), -1], ["setBytes", "setBytes", "math/big", $funcType([($sliceType($Uint8))], [nat], false), -1], ["setUint64", "setUint64", "math/big", $funcType([$Uint64], [nat], false), -1], ["setWord", "setWord", "math/big", $funcType([Word], [nat], false), -1], ["shl", "shl", "math/big", $funcType([nat, $Uint], [nat], false), -1], ["shr", "shr", "math/big", $funcType([nat, $Uint], [nat], false), -1], ["string", "string", "math/big", $funcType([$String], [$String], false), -1], ["sub", "sub", "math/big", $funcType([nat, nat], [nat], false), -1], ["trailingZeroBits", "trailingZeroBits", "math/big", $funcType([], [$Uint], false), -1], ["xor", "xor", "math/big", $funcType([nat, nat], [nat], false), -1]]; + ($ptrType(nat)).methods = [["add", "add", "math/big", $funcType([nat, nat], [nat], false), -1], ["and", "and", "math/big", $funcType([nat, nat], [nat], false), -1], ["andNot", "andNot", "math/big", $funcType([nat, nat], [nat], false), -1], ["bit", "bit", "math/big", $funcType([$Uint], [$Uint], false), -1], ["bitLen", "bitLen", "math/big", $funcType([], [$Int], false), -1], ["bytes", "bytes", "math/big", $funcType([($sliceType($Uint8))], [$Int], false), -1], ["clear", "clear", "math/big", $funcType([], [], false), -1], ["cmp", "cmp", "math/big", $funcType([nat], [$Int], false), -1], ["convertWords", "convertWords", "math/big", $funcType([($sliceType($Uint8)), $String, Word, $Int, Word, ($sliceType(divisor))], [], false), -1], ["decimalString", "decimalString", "math/big", $funcType([], [$String], false), -1], ["div", "div", "math/big", $funcType([nat, nat, nat], [nat, nat], false), -1], ["divLarge", "divLarge", "math/big", $funcType([nat, nat, nat], [nat, nat], false), -1], ["divW", "divW", "math/big", $funcType([nat, Word], [nat, Word], false), -1], ["expNN", "expNN", "math/big", $funcType([nat, nat, nat], [nat], false), -1], ["expNNWindowed", "expNNWindowed", "math/big", $funcType([nat, nat, nat], [nat], false), -1], ["expWW", "expWW", "math/big", $funcType([Word, Word], [nat], false), -1], ["make", "make", "math/big", $funcType([$Int], [nat], false), -1], ["modW", "modW", "math/big", $funcType([Word], [Word], false), -1], ["mul", "mul", "math/big", $funcType([nat, nat], [nat], false), -1], ["mulAddWW", "mulAddWW", "math/big", $funcType([nat, Word, Word], [nat], false), -1], ["mulRange", "mulRange", "math/big", $funcType([$Uint64, $Uint64], [nat], false), -1], ["norm", "norm", "math/big", $funcType([], [nat], false), -1], ["or", "or", "math/big", $funcType([nat, nat], [nat], false), -1], ["probablyPrime", "probablyPrime", "math/big", $funcType([$Int], [$Bool], false), -1], ["random", "random", "math/big", $funcType([($ptrType(rand.Rand)), nat, $Int], [nat], false), -1], ["scan", "scan", "math/big", $funcType([io.RuneScanner, $Int], [nat, $Int, $error], false), -1], ["set", "set", "math/big", $funcType([nat], [nat], false), -1], ["setBit", "setBit", "math/big", $funcType([nat, $Uint, $Uint], [nat], false), -1], ["setBytes", "setBytes", "math/big", $funcType([($sliceType($Uint8))], [nat], false), -1], ["setUint64", "setUint64", "math/big", $funcType([$Uint64], [nat], false), -1], ["setWord", "setWord", "math/big", $funcType([Word], [nat], false), -1], ["shl", "shl", "math/big", $funcType([nat, $Uint], [nat], false), -1], ["shr", "shr", "math/big", $funcType([nat, $Uint], [nat], false), -1], ["string", "string", "math/big", $funcType([$String], [$String], false), -1], ["sub", "sub", "math/big", $funcType([nat, nat], [nat], false), -1], ["trailingZeroBits", "trailingZeroBits", "math/big", $funcType([], [$Uint], false), -1], ["xor", "xor", "math/big", $funcType([nat, nat], [nat], false), -1]]; + nat.init(Word); + divisor.init([["bbb", "bbb", "math/big", nat, ""], ["nbits", "nbits", "math/big", $Int, ""], ["ndigits", "ndigits", "math/big", $Int, ""]]); + ($ptrType(Rat)).methods = [["Abs", "Abs", "", $funcType([($ptrType(Rat))], [($ptrType(Rat))], false), -1], ["Add", "Add", "", $funcType([($ptrType(Rat)), ($ptrType(Rat))], [($ptrType(Rat))], false), -1], ["Cmp", "Cmp", "", $funcType([($ptrType(Rat))], [$Int], false), -1], ["Denom", "Denom", "", $funcType([], [($ptrType(Int))], false), -1], ["Float64", "Float64", "", $funcType([], [$Float64, $Bool], false), -1], ["FloatString", "FloatString", "", $funcType([$Int], [$String], false), -1], ["GobDecode", "GobDecode", "", $funcType([($sliceType($Uint8))], [$error], false), -1], ["GobEncode", "GobEncode", "", $funcType([], [($sliceType($Uint8)), $error], false), -1], ["Inv", "Inv", "", $funcType([($ptrType(Rat))], [($ptrType(Rat))], false), -1], ["IsInt", "IsInt", "", $funcType([], [$Bool], false), -1], ["MarshalText", "MarshalText", "", $funcType([], [($sliceType($Uint8)), $error], false), -1], ["Mul", "Mul", "", $funcType([($ptrType(Rat)), ($ptrType(Rat))], [($ptrType(Rat))], false), -1], ["Neg", "Neg", "", $funcType([($ptrType(Rat))], [($ptrType(Rat))], false), -1], ["Num", "Num", "", $funcType([], [($ptrType(Int))], false), -1], ["Quo", "Quo", "", $funcType([($ptrType(Rat)), ($ptrType(Rat))], [($ptrType(Rat))], false), -1], ["RatString", "RatString", "", $funcType([], [$String], false), -1], ["Scan", "Scan", "", $funcType([fmt.ScanState, $Int32], [$error], false), -1], ["Set", "Set", "", $funcType([($ptrType(Rat))], [($ptrType(Rat))], false), -1], ["SetFloat64", "SetFloat64", "", $funcType([$Float64], [($ptrType(Rat))], false), -1], ["SetFrac", "SetFrac", "", $funcType([($ptrType(Int)), ($ptrType(Int))], [($ptrType(Rat))], false), -1], ["SetFrac64", "SetFrac64", "", $funcType([$Int64, $Int64], [($ptrType(Rat))], false), -1], ["SetInt", "SetInt", "", $funcType([($ptrType(Int))], [($ptrType(Rat))], false), -1], ["SetInt64", "SetInt64", "", $funcType([$Int64], [($ptrType(Rat))], false), -1], ["SetString", "SetString", "", $funcType([$String], [($ptrType(Rat)), $Bool], false), -1], ["Sign", "Sign", "", $funcType([], [$Int], false), -1], ["String", "String", "", $funcType([], [$String], false), -1], ["Sub", "Sub", "", $funcType([($ptrType(Rat)), ($ptrType(Rat))], [($ptrType(Rat))], false), -1], ["UnmarshalText", "UnmarshalText", "", $funcType([($sliceType($Uint8))], [$error], false), -1], ["norm", "norm", "math/big", $funcType([], [($ptrType(Rat))], false), -1]]; + Rat.init([["a", "a", "math/big", Int, ""], ["b", "b", "math/big", Int, ""]]); + cacheBase10 = new ($structType([["Mutex", "", "", sync.Mutex, ""], ["table", "table", "math/big", ($arrayType(divisor, 64)), ""]])).Ptr(); + natOne = new nat([1]); + intOne = new Int.Ptr(false, natOne); + natTwo = new nat([2]); + natTen = new nat([10]); + karatsubaThreshold = 40; + leafSize = 8; + deBruijn32Lookup = new ($sliceType($Uint8))([0, 1, 28, 2, 29, 14, 24, 3, 30, 22, 20, 15, 25, 17, 4, 8, 31, 27, 13, 23, 21, 19, 16, 7, 26, 12, 18, 6, 11, 5, 10, 9]); + deBruijn64Lookup = new ($sliceType($Uint8))([0, 1, 56, 2, 57, 49, 28, 3, 61, 58, 42, 50, 38, 29, 17, 4, 62, 47, 59, 36, 45, 43, 51, 22, 53, 39, 33, 30, 24, 18, 12, 5, 63, 55, 48, 27, 60, 41, 37, 16, 46, 35, 44, 21, 52, 32, 23, 11, 54, 26, 40, 15, 34, 20, 31, 10, 25, 14, 19, 9, 13, 8, 7, 6]); }; return $pkg; })(); -$packages["go/parser"] = (function() { - var $pkg = {}, bytes = $packages["bytes"], errors = $packages["errors"], ast = $packages["go/ast"], token = $packages["go/token"], io = $packages["io"], ioutil = $packages["io/ioutil"], os = $packages["os"], filepath = $packages["path/filepath"], strings = $packages["strings"], fmt = $packages["fmt"], scanner = $packages["go/scanner"], strconv = $packages["strconv"], unicode = $packages["unicode"], Mode, parser, bailout, parseSpecFunction, unresolved, readSource, ParseFile, trace, un, assert, syncStmt, syncDecl, isTypeName, isLiteralType, deref, unparen, isTypeSwitchAssert, isTypeSwitchGuard, isValidImport; - Mode = $pkg.Mode = $newType(4, "Uint", "parser.Mode", "Mode", "go/parser", null); - parser = $pkg.parser = $newType(0, "Struct", "parser.parser", "parser", "go/parser", function(file_, errors_, scanner_, mode_, trace_, indent_, comments_, leadComment_, lineComment_, pos_, tok_, lit_, syncPos_, syncCnt_, exprLev_, inRhs_, pkgScope_, topScope_, unresolved_, imports_, labelScope_, targetStack_) { +$packages["code.google.com/p/go.tools/go/exact"] = (function() { + var $pkg = {}, fmt = $packages["fmt"], token = $packages["go/token"], big = $packages["math/big"], strconv = $packages["strconv"], math = $packages["math"], Kind, Value, unknownVal, boolVal, stringVal, int64Val, intVal, floatVal, complexVal, minInt64, maxInt64, int1, rat0, normInt, normFloat, normComplex, MakeUnknown, MakeBool, MakeString, MakeInt64, MakeFloat64, MakeFromLiteral, BoolVal, StringVal, Int64Val, Uint64Val, Float32Val, Float64Val, BitLen, Sign, MakeImag, Real, Imag, is32bit, is63bit, UnaryOp, ord, match, BinaryOp, Shift, cmpZero, Compare, ratToFloat32; + Kind = $pkg.Kind = $newType(4, "Int", "exact.Kind", "Kind", "code.google.com/p/go.tools/go/exact", null); + Value = $pkg.Value = $newType(8, "Interface", "exact.Value", "Value", "code.google.com/p/go.tools/go/exact", null); + unknownVal = $pkg.unknownVal = $newType(0, "Struct", "exact.unknownVal", "unknownVal", "code.google.com/p/go.tools/go/exact", function() { this.$val = this; - this.file = file_ !== undefined ? file_ : ($ptrType(token.File)).nil; - this.errors = errors_ !== undefined ? errors_ : scanner.ErrorList.nil; - this.scanner = scanner_ !== undefined ? scanner_ : new scanner.Scanner.Ptr(); - this.mode = mode_ !== undefined ? mode_ : 0; - this.trace = trace_ !== undefined ? trace_ : false; - this.indent = indent_ !== undefined ? indent_ : 0; - this.comments = comments_ !== undefined ? comments_ : ($sliceType(($ptrType(ast.CommentGroup)))).nil; - this.leadComment = leadComment_ !== undefined ? leadComment_ : ($ptrType(ast.CommentGroup)).nil; - this.lineComment = lineComment_ !== undefined ? lineComment_ : ($ptrType(ast.CommentGroup)).nil; - this.pos = pos_ !== undefined ? pos_ : 0; - this.tok = tok_ !== undefined ? tok_ : 0; - this.lit = lit_ !== undefined ? lit_ : ""; - this.syncPos = syncPos_ !== undefined ? syncPos_ : 0; - this.syncCnt = syncCnt_ !== undefined ? syncCnt_ : 0; - this.exprLev = exprLev_ !== undefined ? exprLev_ : 0; - this.inRhs = inRhs_ !== undefined ? inRhs_ : false; - this.pkgScope = pkgScope_ !== undefined ? pkgScope_ : ($ptrType(ast.Scope)).nil; - this.topScope = topScope_ !== undefined ? topScope_ : ($ptrType(ast.Scope)).nil; - this.unresolved = unresolved_ !== undefined ? unresolved_ : ($sliceType(($ptrType(ast.Ident)))).nil; - this.imports = imports_ !== undefined ? imports_ : ($sliceType(($ptrType(ast.ImportSpec)))).nil; - this.labelScope = labelScope_ !== undefined ? labelScope_ : ($ptrType(ast.Scope)).nil; - this.targetStack = targetStack_ !== undefined ? targetStack_ : ($sliceType(($sliceType(($ptrType(ast.Ident)))))).nil; }); - bailout = $pkg.bailout = $newType(0, "Struct", "parser.bailout", "bailout", "go/parser", function() { + boolVal = $pkg.boolVal = $newType(1, "Bool", "exact.boolVal", "boolVal", "code.google.com/p/go.tools/go/exact", null); + stringVal = $pkg.stringVal = $newType(8, "String", "exact.stringVal", "stringVal", "code.google.com/p/go.tools/go/exact", null); + int64Val = $pkg.int64Val = $newType(8, "Int64", "exact.int64Val", "int64Val", "code.google.com/p/go.tools/go/exact", null); + intVal = $pkg.intVal = $newType(0, "Struct", "exact.intVal", "intVal", "code.google.com/p/go.tools/go/exact", function(val_) { this.$val = this; + this.val = val_ !== undefined ? val_ : ($ptrType(big.Int)).nil; }); - parseSpecFunction = $pkg.parseSpecFunction = $newType(4, "Func", "parser.parseSpecFunction", "parseSpecFunction", "go/parser", null); - readSource = function(filename, src) { - var s, _ref, buf, _tuple, err; - if (!($interfaceIsEqual(src, $ifaceNil))) { - _ref = src; - if ($assertType(_ref, $String, true)[1]) { - s = _ref.$val; - return [new ($sliceType($Uint8))($stringToBytes(s)), $ifaceNil]; - } else if ($assertType(_ref, ($sliceType($Uint8)), true)[1]) { - s = _ref.$val; - return [s, $ifaceNil]; - } else if ($assertType(_ref, ($ptrType(bytes.Buffer)), true)[1]) { - s = _ref.$val; - if (!(s === ($ptrType(bytes.Buffer)).nil)) { - return [s.Bytes(), $ifaceNil]; - } - } else if ($assertType(_ref, io.Reader, true)[1]) { - s = _ref; - buf = new bytes.Buffer.Ptr(); $copy(buf, new bytes.Buffer.Ptr(), bytes.Buffer); - _tuple = io.Copy(buf, s); err = _tuple[1]; - if (!($interfaceIsEqual(err, $ifaceNil))) { - return [($sliceType($Uint8)).nil, err]; - } - return [buf.Bytes(), $ifaceNil]; - } - return [($sliceType($Uint8)).nil, errors.New("invalid source")]; + floatVal = $pkg.floatVal = $newType(0, "Struct", "exact.floatVal", "floatVal", "code.google.com/p/go.tools/go/exact", function(val_) { + this.$val = this; + this.val = val_ !== undefined ? val_ : ($ptrType(big.Rat)).nil; + }); + complexVal = $pkg.complexVal = $newType(0, "Struct", "exact.complexVal", "complexVal", "code.google.com/p/go.tools/go/exact", function(re_, im_) { + this.$val = this; + this.re = re_ !== undefined ? re_ : ($ptrType(big.Rat)).nil; + this.im = im_ !== undefined ? im_ : ($ptrType(big.Rat)).nil; + }); + unknownVal.Ptr.prototype.Kind = function() { + return 0; + }; + unknownVal.prototype.Kind = function() { return this.$val.Kind(); }; + boolVal.prototype.Kind = function() { + return 1; + }; + $ptrType(boolVal).prototype.Kind = function() { return new boolVal(this.$get()).Kind(); }; + stringVal.prototype.Kind = function() { + return 2; + }; + $ptrType(stringVal).prototype.Kind = function() { return new stringVal(this.$get()).Kind(); }; + int64Val.prototype.Kind = function() { + return 3; + }; + $ptrType(int64Val).prototype.Kind = function() { return this.$get().Kind(); }; + intVal.Ptr.prototype.Kind = function() { + return 3; + }; + intVal.prototype.Kind = function() { return this.$val.Kind(); }; + floatVal.Ptr.prototype.Kind = function() { + return 4; + }; + floatVal.prototype.Kind = function() { return this.$val.Kind(); }; + complexVal.Ptr.prototype.Kind = function() { + return 5; + }; + complexVal.prototype.Kind = function() { return this.$val.Kind(); }; + unknownVal.Ptr.prototype.String = function() { + return "unknown"; + }; + unknownVal.prototype.String = function() { return this.$val.String(); }; + boolVal.prototype.String = function() { + var x; + x = this.$val !== undefined ? this.$val : this; + return fmt.Sprintf("%v", new ($sliceType($emptyInterface))([new $Bool(x)])); + }; + $ptrType(boolVal).prototype.String = function() { return new boolVal(this.$get()).String(); }; + stringVal.prototype.String = function() { + var x; + x = this.$val !== undefined ? this.$val : this; + return strconv.Quote(x); + }; + $ptrType(stringVal).prototype.String = function() { return new stringVal(this.$get()).String(); }; + int64Val.prototype.String = function() { + var x; + x = this; + return strconv.FormatInt(new $Int64(x.$high, x.$low), 10); + }; + $ptrType(int64Val).prototype.String = function() { return this.$get().String(); }; + intVal.Ptr.prototype.String = function() { + var x; + x = new intVal.Ptr(); $copy(x, this, intVal); + return x.val.String(); + }; + intVal.prototype.String = function() { return this.$val.String(); }; + floatVal.Ptr.prototype.String = function() { + var x; + x = new floatVal.Ptr(); $copy(x, this, floatVal); + return x.val.String(); + }; + floatVal.prototype.String = function() { return this.$val.String(); }; + complexVal.Ptr.prototype.String = function() { + var x; + x = new complexVal.Ptr(); $copy(x, this, complexVal); + return fmt.Sprintf("(%s + %si)", new ($sliceType($emptyInterface))([x.re, x.im])); + }; + complexVal.prototype.String = function() { return this.$val.String(); }; + normInt = function(x) { + var x$1, x$2; + if (minInt64.Cmp(x) <= 0 && x.Cmp(maxInt64) <= 0) { + return (x$1 = x.Int64(), new int64Val(x$1.$high, x$1.$low)); } - return ioutil.ReadFile(filename); + return (x$2 = new intVal.Ptr(x), new x$2.constructor.Struct(x$2)); }; - ParseFile = $pkg.ParseFile = function(fset, filename, src, mode) { - var f = ($ptrType(ast.File)).nil, err = $ifaceNil, $deferred = [], $err = null, _tuple, text, _tmp, _tmp$1, p; - /* */ try { $deferFrames.push($deferred); - _tuple = readSource(filename, src); text = _tuple[0]; err = _tuple[1]; - if (!($interfaceIsEqual(err, $ifaceNil))) { - _tmp = ($ptrType(ast.File)).nil; _tmp$1 = err; f = _tmp; err = _tmp$1; - return [f, err]; + normFloat = function(x) { + var x$1; + if (x.IsInt()) { + return normInt(x.Num()); } - p = new parser.Ptr(); $copy(p, new parser.Ptr(), parser); - $deferred.push([(function() { - var e; - e = $recover(); - if (!($interfaceIsEqual(e, $ifaceNil))) { - } - if (f === ($ptrType(ast.File)).nil) { - f = new ast.File.Ptr(($ptrType(ast.CommentGroup)).nil, 0, new ast.Ident.Ptr(), ($sliceType(ast.Decl)).nil, ast.NewScope(($ptrType(ast.Scope)).nil), ($sliceType(($ptrType(ast.ImportSpec)))).nil, ($sliceType(($ptrType(ast.Ident)))).nil, ($sliceType(($ptrType(ast.CommentGroup)))).nil); - } - p.errors.Sort(); - err = p.errors.Err(); - }), []]); - p.init(fset, filename, text, mode); - f = p.parseFile(); - return [f, err]; - /* */ } catch(err) { $err = err; } finally { $deferFrames.pop(); $callDeferred($deferred, $err); return [f, err]; } + return (x$1 = new floatVal.Ptr(x), new x$1.constructor.Struct(x$1)); }; - parser.Ptr.prototype.init = function(fset, filename, src, mode) { - var p, m, eh; - p = this; - p.file = fset.AddFile(filename, -1, src.$length); - m = 0; - if (!((((mode & 4) >>> 0) === 0))) { - m = 1; + normComplex = function(re, im) { + var x; + if (im.Sign() === 0) { + return normFloat(re); } - eh = (function(pos, msg) { - new ($ptrType(scanner.ErrorList))(function() { return this.$target.errors; }, function($v) { this.$target.errors = $v; }, p).Add($clone(pos, token.Position), msg); - }); - p.scanner.Init(p.file, src, eh, m); - p.mode = mode; - p.trace = !((((mode & 8) >>> 0) === 0)); - p.next(); + return (x = new complexVal.Ptr(re, im), new x.constructor.Struct(x)); }; - parser.prototype.init = function(fset, filename, src, mode) { return this.$val.init(fset, filename, src, mode); }; - parser.Ptr.prototype.openScope = function() { - var p; - p = this; - p.topScope = ast.NewScope(p.topScope); + MakeUnknown = $pkg.MakeUnknown = function() { + var x; + return (x = new unknownVal.Ptr(), new x.constructor.Struct(x)); }; - parser.prototype.openScope = function() { return this.$val.openScope(); }; - parser.Ptr.prototype.closeScope = function() { - var p; - p = this; - p.topScope = p.topScope.Outer; + MakeBool = $pkg.MakeBool = function(b) { + return new boolVal(b); }; - parser.prototype.closeScope = function() { return this.$val.closeScope(); }; - parser.Ptr.prototype.openLabelScope = function() { - var p; - p = this; - p.labelScope = ast.NewScope(p.labelScope); - p.targetStack = $append(p.targetStack, ($sliceType(($ptrType(ast.Ident)))).nil); + MakeString = $pkg.MakeString = function(s) { + return new stringVal(s); }; - parser.prototype.openLabelScope = function() { return this.$val.openLabelScope(); }; - parser.Ptr.prototype.closeLabelScope = function() { - var p, n, scope, _ref, x, _i, ident; - p = this; - n = p.targetStack.$length - 1 >> 0; - scope = p.labelScope; - _ref = (x = p.targetStack, ((n < 0 || n >= x.$length) ? $throwRuntimeError("index out of range") : x.$array[x.$offset + n])); - _i = 0; - while (_i < _ref.$length) { - ident = ((_i < 0 || _i >= _ref.$length) ? $throwRuntimeError("index out of range") : _ref.$array[_ref.$offset + _i]); - ident.Obj = scope.Lookup(ident.Name); - if (ident.Obj === ($ptrType(ast.Object)).nil && !((((p.mode & 16) >>> 0) === 0))) { - p.error(ident.Pos(), fmt.Sprintf("label %s undefined", new ($sliceType($emptyInterface))([new $String(ident.Name)]))); - } - _i++; + MakeInt64 = $pkg.MakeInt64 = function(x) { + return new int64Val(x.$high, x.$low); + }; + MakeFloat64 = $pkg.MakeFloat64 = function(x) { + var f, x$1; + f = new big.Rat.Ptr().SetFloat64(x); + if (!(f === ($ptrType(big.Rat)).nil)) { + return normFloat(f); } - p.targetStack = $subslice(p.targetStack, 0, n); - p.labelScope = p.labelScope.Outer; + return (x$1 = new unknownVal.Ptr(), new x$1.constructor.Struct(x$1)); }; - parser.prototype.closeLabelScope = function() { return this.$val.closeLabelScope(); }; - parser.Ptr.prototype.declare = function(decl, data, scope, kind, idents) { - var p, _ref, _i, ident, obj, alt, prevDecl, pos, x; - p = this; - _ref = idents; - _i = 0; - while (_i < _ref.$length) { - ident = ((_i < 0 || _i >= _ref.$length) ? $throwRuntimeError("index out of range") : _ref.$array[_ref.$offset + _i]); - assert(ident.Obj === ($ptrType(ast.Object)).nil, "identifier already declared or resolved"); - obj = ast.NewObj(kind, ident.Name); - obj.Decl = decl; - obj.Data = data; - ident.Obj = obj; - if (!(ident.Name === "_")) { - alt = scope.Insert(obj); - if (!(alt === ($ptrType(ast.Object)).nil) && !((((p.mode & 16) >>> 0) === 0))) { - prevDecl = ""; - pos = alt.Pos(); - if ((new token.Pos(pos)).IsValid()) { - prevDecl = fmt.Sprintf("\n\tprevious declaration at %s", new ($sliceType($emptyInterface))([(x = p.file.Position(pos), new x.constructor.Struct(x))])); - } - p.error(ident.Pos(), fmt.Sprintf("%s redeclared in this block%s", new ($sliceType($emptyInterface))([new $String(ident.Name), new $String(prevDecl)]))); + MakeFromLiteral = $pkg.MakeFromLiteral = function(lit, tok) { + var _ref, _tuple, x, err, _tuple$1, x$1, ok, x$2, _tuple$2, x$3, ok$1, n, _tuple$3, im, ok$2, n$1, _tuple$4, code, err$1, _tuple$5, s, err$2; + _ref = tok; + if (_ref === 5) { + _tuple = strconv.ParseInt(lit, 0, 64); x = _tuple[0]; err = _tuple[1]; + if ($interfaceIsEqual(err, $ifaceNil)) { + return new int64Val(x.$high, x.$low); + } + _tuple$1 = new big.Int.Ptr().SetString(lit, 0); x$1 = _tuple$1[0]; ok = _tuple$1[1]; + if (ok) { + return (x$2 = new intVal.Ptr(x$1), new x$2.constructor.Struct(x$2)); + } + } else if (_ref === 6) { + _tuple$2 = new big.Rat.Ptr().SetString(lit); x$3 = _tuple$2[0]; ok$1 = _tuple$2[1]; + if (ok$1) { + return normFloat(x$3); + } + } else if (_ref === 7) { + n = lit.length; + if (n > 0 && (lit.charCodeAt((n - 1 >> 0)) === 105)) { + _tuple$3 = new big.Rat.Ptr().SetString(lit.substring(0, (n - 1 >> 0))); im = _tuple$3[0]; ok$2 = _tuple$3[1]; + if (ok$2) { + return normComplex(big.NewRat(new $Int64(0, 0), new $Int64(0, 1)), im); } } - _i++; - } - }; - parser.prototype.declare = function(decl, data, scope, kind, idents) { return this.$val.declare(decl, data, scope, kind, idents); }; - parser.Ptr.prototype.shortVarDecl = function(decl, list) { - var p, n, _ref, _i, x, _tuple, ident, isIdent, obj, alt; - p = this; - n = 0; - _ref = list; - _i = 0; - while (_i < _ref.$length) { - x = ((_i < 0 || _i >= _ref.$length) ? $throwRuntimeError("index out of range") : _ref.$array[_ref.$offset + _i]); - _tuple = $assertType(x, ($ptrType(ast.Ident)), true); ident = _tuple[0]; isIdent = _tuple[1]; - if (isIdent) { - assert(ident.Obj === ($ptrType(ast.Object)).nil, "identifier already declared or resolved"); - obj = ast.NewObj(4, ident.Name); - obj.Decl = decl; - ident.Obj = obj; - if (!(ident.Name === "_")) { - alt = p.topScope.Insert(obj); - if (!(alt === ($ptrType(ast.Object)).nil)) { - ident.Obj = alt; - } else { - n = n + (1) >> 0; - } + } else if (_ref === 8) { + n$1 = lit.length; + if (n$1 >= 2) { + _tuple$4 = strconv.UnquoteChar(lit.substring(1, (n$1 - 1 >> 0)), 39); code = _tuple$4[0]; err$1 = _tuple$4[3]; + if ($interfaceIsEqual(err$1, $ifaceNil)) { + return new int64Val(0, code); } - } else { - p.errorExpected(x.Pos(), "identifier on left side of :="); } - _i++; + } else if (_ref === 9) { + _tuple$5 = strconv.Unquote(lit); s = _tuple$5[0]; err$2 = _tuple$5[1]; + if ($interfaceIsEqual(err$2, $ifaceNil)) { + return new stringVal(s); + } + } + return $ifaceNil; + }; + BoolVal = $pkg.BoolVal = function(x) { + var x$1, _ref; + _ref = x; + if ($assertType(_ref, boolVal, true)[1]) { + x$1 = _ref.$val; + return x$1; + } else if ($assertType(_ref, unknownVal, true)[1]) { + x$1 = _ref.$val; + return false; + } + $panic(new $String(fmt.Sprintf("%v not a Bool", new ($sliceType($emptyInterface))([x])))); + }; + StringVal = $pkg.StringVal = function(x) { + var x$1, _ref; + _ref = x; + if ($assertType(_ref, stringVal, true)[1]) { + x$1 = _ref.$val; + return x$1; + } else if ($assertType(_ref, unknownVal, true)[1]) { + x$1 = _ref.$val; + return ""; + } + $panic(new $String(fmt.Sprintf("%v not a String", new ($sliceType($emptyInterface))([x])))); + }; + Int64Val = $pkg.Int64Val = function(x) { + var x$1, _ref; + _ref = x; + if ($assertType(_ref, int64Val, true)[1]) { + x$1 = _ref.$val; + return [new $Int64(x$1.$high, x$1.$low), true]; + } else if ($assertType(_ref, intVal, true)[1]) { + x$1 = _ref.$val; + return [x$1.val.Int64(), x$1.val.BitLen() <= 63]; + } else if ($assertType(_ref, unknownVal, true)[1]) { + x$1 = _ref.$val; + return [new $Int64(0, 0), false]; + } + $panic(new $String(fmt.Sprintf("%v not an Int", new ($sliceType($emptyInterface))([x])))); + }; + Uint64Val = $pkg.Uint64Val = function(x) { + var x$1, _ref; + _ref = x; + if ($assertType(_ref, int64Val, true)[1]) { + x$1 = _ref.$val; + return [new $Uint64(x$1.$high, x$1.$low), (x$1.$high > 0 || (x$1.$high === 0 && x$1.$low >= 0))]; + } else if ($assertType(_ref, intVal, true)[1]) { + x$1 = _ref.$val; + return [x$1.val.Uint64(), x$1.val.Sign() >= 0 && x$1.val.BitLen() <= 64]; + } else if ($assertType(_ref, unknownVal, true)[1]) { + x$1 = _ref.$val; + return [new $Uint64(0, 0), false]; } - if ((n === 0) && !((((p.mode & 16) >>> 0) === 0))) { - p.error(((0 < 0 || 0 >= list.$length) ? $throwRuntimeError("index out of range") : list.$array[list.$offset + 0]).Pos(), "no new variables on left side of :="); + $panic(new $String(fmt.Sprintf("%v not an Int", new ($sliceType($emptyInterface))([x])))); + }; + Float32Val = $pkg.Float32Val = function(x) { + var x$1, _ref, f, x$2; + _ref = x; + if ($assertType(_ref, int64Val, true)[1]) { + x$1 = _ref.$val; + f = $flatten64(x$1); + return [f, (x$2 = new int64Val(0, f), (x$2.$high === x$1.$high && x$2.$low === x$1.$low))]; + } else if ($assertType(_ref, intVal, true)[1]) { + x$1 = _ref.$val; + return ratToFloat32(new big.Rat.Ptr().SetFrac(x$1.val, int1)); + } else if ($assertType(_ref, floatVal, true)[1]) { + x$1 = _ref.$val; + return ratToFloat32(x$1.val); + } else if ($assertType(_ref, unknownVal, true)[1]) { + x$1 = _ref.$val; + return [0, false]; } + $panic(new $String(fmt.Sprintf("%v not a Float", new ($sliceType($emptyInterface))([x])))); }; - parser.prototype.shortVarDecl = function(decl, list) { return this.$val.shortVarDecl(decl, list); }; - parser.Ptr.prototype.tryResolve = function(x, collectUnresolved) { - var p, _tuple, ident, s, obj; - p = this; - _tuple = $assertType(x, ($ptrType(ast.Ident)), true); ident = _tuple[0]; - if (ident === ($ptrType(ast.Ident)).nil) { - return; + Float64Val = $pkg.Float64Val = function(x) { + var x$1, _ref, f, x$2; + _ref = x; + if ($assertType(_ref, int64Val, true)[1]) { + x$1 = _ref.$val; + f = $flatten64(new $Int64(x$1.$high, x$1.$low)); + return [f, (x$2 = new int64Val(0, f), (x$2.$high === x$1.$high && x$2.$low === x$1.$low))]; + } else if ($assertType(_ref, intVal, true)[1]) { + x$1 = _ref.$val; + return new big.Rat.Ptr().SetFrac(x$1.val, int1).Float64(); + } else if ($assertType(_ref, floatVal, true)[1]) { + x$1 = _ref.$val; + return x$1.val.Float64(); + } else if ($assertType(_ref, unknownVal, true)[1]) { + x$1 = _ref.$val; + return [0, false]; } - assert(ident.Obj === ($ptrType(ast.Object)).nil, "identifier already declared or resolved"); - if (ident.Name === "_") { - return; + $panic(new $String(fmt.Sprintf("%v not a Float", new ($sliceType($emptyInterface))([x])))); + }; + BitLen = $pkg.BitLen = function(x) { + var x$1, _ref; + _ref = x; + if ($assertType(_ref, int64Val, true)[1]) { + x$1 = _ref.$val; + return new big.Int.Ptr().SetInt64(new $Int64(x$1.$high, x$1.$low)).BitLen(); + } else if ($assertType(_ref, intVal, true)[1]) { + x$1 = _ref.$val; + return x$1.val.BitLen(); + } else if ($assertType(_ref, unknownVal, true)[1]) { + x$1 = _ref.$val; + return 0; } - s = p.topScope; - while (!(s === ($ptrType(ast.Scope)).nil)) { - obj = s.Lookup(ident.Name); - if (!(obj === ($ptrType(ast.Object)).nil)) { - ident.Obj = obj; - return; + $panic(new $String(fmt.Sprintf("%v not an Int", new ($sliceType($emptyInterface))([x])))); + }; + Sign = $pkg.Sign = function(x) { + var x$1, _ref; + _ref = x; + if ($assertType(_ref, int64Val, true)[1]) { + x$1 = _ref.$val; + if ((x$1.$high < 0 || (x$1.$high === 0 && x$1.$low < 0))) { + return -1; + } else if ((x$1.$high > 0 || (x$1.$high === 0 && x$1.$low > 0))) { + return 1; } - s = s.Outer; + return 0; + } else if ($assertType(_ref, intVal, true)[1]) { + x$1 = _ref.$val; + return x$1.val.Sign(); + } else if ($assertType(_ref, floatVal, true)[1]) { + x$1 = _ref.$val; + return x$1.val.Sign(); + } else if ($assertType(_ref, complexVal, true)[1]) { + x$1 = _ref.$val; + return x$1.re.Sign() | x$1.im.Sign(); + } else if ($assertType(_ref, unknownVal, true)[1]) { + x$1 = _ref.$val; + return 1; } - if (collectUnresolved) { - ident.Obj = unresolved; - p.unresolved = $append(p.unresolved, ident); + $panic(new $String(fmt.Sprintf("%v not numeric", new ($sliceType($emptyInterface))([x])))); + }; + MakeImag = $pkg.MakeImag = function(x) { + var im, x$1, _ref; + im = ($ptrType(big.Rat)).nil; + _ref = x; + if ($assertType(_ref, unknownVal, true)[1]) { + x$1 = _ref.$val; + return new x$1.constructor.Struct(x$1); + } else if ($assertType(_ref, int64Val, true)[1]) { + x$1 = _ref.$val; + im = big.NewRat(new $Int64(x$1.$high, x$1.$low), new $Int64(0, 1)); + } else if ($assertType(_ref, intVal, true)[1]) { + x$1 = _ref.$val; + im = new big.Rat.Ptr().SetFrac(x$1.val, int1); + } else if ($assertType(_ref, floatVal, true)[1]) { + x$1 = _ref.$val; + im = x$1.val; + } else { + x$1 = _ref; + $panic(new $String(fmt.Sprintf("%v not Int or Float", new ($sliceType($emptyInterface))([x$1])))); } + return normComplex(rat0, im); }; - parser.prototype.tryResolve = function(x, collectUnresolved) { return this.$val.tryResolve(x, collectUnresolved); }; - parser.Ptr.prototype.resolve = function(x) { - var p; - p = this; - p.tryResolve(x, true); + Real = $pkg.Real = function(x) { + var x$1, _ref; + _ref = x; + if ($assertType(_ref, unknownVal, true)[1] || $assertType(_ref, int64Val, true)[1] || $assertType(_ref, intVal, true)[1] || $assertType(_ref, floatVal, true)[1]) { + x$1 = _ref; + return x$1; + } else if ($assertType(_ref, complexVal, true)[1]) { + x$1 = _ref.$val; + return normFloat(x$1.re); + } + $panic(new $String(fmt.Sprintf("%v not numeric", new ($sliceType($emptyInterface))([x])))); }; - parser.prototype.resolve = function(x) { return this.$val.resolve(x); }; - parser.Ptr.prototype.printTrace = function(a) { - var p, pos, x, i; - p = this; - pos = new token.Position.Ptr(); $copy(pos, p.file.Position(p.pos), token.Position); - fmt.Printf("%5d:%3d: ", new ($sliceType($emptyInterface))([new $Int(pos.Line), new $Int(pos.Column)])); - i = (x = p.indent, (((2 >>> 16 << 16) * x >> 0) + (2 << 16 >>> 16) * x) >> 0); - while (i > 64) { - fmt.Print(new ($sliceType($emptyInterface))([new $String(". . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ")])); - i = i - (64) >> 0; + Imag = $pkg.Imag = function(x) { + var x$1, _ref; + _ref = x; + if ($assertType(_ref, unknownVal, true)[1]) { + x$1 = _ref.$val; + return new x$1.constructor.Struct(x$1); + } else if ($assertType(_ref, int64Val, true)[1] || $assertType(_ref, intVal, true)[1] || $assertType(_ref, floatVal, true)[1]) { + x$1 = _ref; + return new int64Val(0, 0); + } else if ($assertType(_ref, complexVal, true)[1]) { + x$1 = _ref.$val; + return normFloat(x$1.im); } - fmt.Print(new ($sliceType($emptyInterface))([new $String(". . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ".substring(0, i))])); - fmt.Println(a); + $panic(new $String(fmt.Sprintf("%v not numeric", new ($sliceType($emptyInterface))([x])))); }; - parser.prototype.printTrace = function(a) { return this.$val.printTrace(a); }; - trace = function(p, msg) { - p.printTrace(new ($sliceType($emptyInterface))([new $String(msg), new $String("(")])); - p.indent = p.indent + (1) >> 0; - return p; + is32bit = function(x) { + return (-1 < x.$high || (-1 === x.$high && 2147483648 <= x.$low)) && (x.$high < 0 || (x.$high === 0 && x.$low <= 2147483647)); }; - un = function(p) { - p.indent = p.indent - (1) >> 0; - p.printTrace(new ($sliceType($emptyInterface))([new $String(")")])); + is63bit = function(x) { + return (-1073741824 < x.$high || (-1073741824 === x.$high && 0 <= x.$low)) && (x.$high < 1073741823 || (x.$high === 1073741823 && x.$low <= 4294967295)); }; - parser.Ptr.prototype.next0 = function() { - var p, s, _tuple; - p = this; - if (p.trace && (new token.Pos(p.pos)).IsValid()) { - s = (new token.Token(p.tok)).String(); - if ((new token.Token(p.tok)).IsLiteral()) { - p.printTrace(new ($sliceType($emptyInterface))([new $String(s), new $String(p.lit)])); - } else if ((new token.Token(p.tok)).IsOperator() || (new token.Token(p.tok)).IsKeyword()) { - p.printTrace(new ($sliceType($emptyInterface))([new $String("\"" + s + "\"")])); - } else { - p.printTrace(new ($sliceType($emptyInterface))([new $String(s)])); + UnaryOp = $pkg.UnaryOp = function(op, y, size) { + var $this = this, $args = arguments, $s = 0, _ref, _ref$1, y$1, _ref$2, z, z$1, y$2, _ref$3, x, s, y$3, _ref$4; + /* */ while (true) { switch ($s) { case 0: + _ref = op; + /* if (_ref === 12) { */ if (_ref === 12) {} else if (_ref === 13) { $s = 2; continue; } else if (_ref === 19) { $s = 3; continue; } else if (_ref === 43) { $s = 4; continue; } else { $s = 5; continue; } + _ref$1 = y; + if ($assertType(_ref$1, unknownVal, true)[1] || $assertType(_ref$1, int64Val, true)[1] || $assertType(_ref$1, intVal, true)[1] || $assertType(_ref$1, floatVal, true)[1] || $assertType(_ref$1, complexVal, true)[1]) { + return y; + } + /* } else if (_ref === 13) { */ $s = 5; continue; case 2: + _ref$2 = y; + if ($assertType(_ref$2, unknownVal, true)[1]) { + y$1 = _ref$2.$val; + return new y$1.constructor.Struct(y$1); + } else if ($assertType(_ref$2, int64Val, true)[1]) { + y$1 = _ref$2.$val; + z = new int64Val(-y$1.$high, -y$1.$low); + if (!((z.$high === y$1.$high && z.$low === y$1.$low))) { + return z; + } + return normInt(new big.Int.Ptr().Neg(big.NewInt(new $Int64(y$1.$high, y$1.$low)))); + } else if ($assertType(_ref$2, intVal, true)[1]) { + y$1 = _ref$2.$val; + return normInt(new big.Int.Ptr().Neg(y$1.val)); + } else if ($assertType(_ref$2, floatVal, true)[1]) { + y$1 = _ref$2.$val; + return normFloat(new big.Rat.Ptr().Neg(y$1.val)); + } else if ($assertType(_ref$2, complexVal, true)[1]) { + y$1 = _ref$2.$val; + return normComplex(new big.Rat.Ptr().Neg(y$1.re), new big.Rat.Ptr().Neg(y$1.im)); + } + /* } else if (_ref === 19) { */ $s = 5; continue; case 3: + z$1 = new big.Int.Ptr(); $copy(z$1, new big.Int.Ptr(), big.Int); + _ref$3 = y; + /* if ($assertType(_ref$3, unknownVal, true)[1]) { */ if ($assertType(_ref$3, unknownVal, true)[1]) {} else if ($assertType(_ref$3, int64Val, true)[1]) { $s = 6; continue; } else if ($assertType(_ref$3, intVal, true)[1]) { $s = 7; continue; } else { $s = 8; continue; } + y$2 = _ref$3.$val; + return new y$2.constructor.Struct(y$2); + /* } else if ($assertType(_ref$3, int64Val, true)[1]) { */ $s = 9; continue; case 6: + y$2 = _ref$3.$val; + z$1.Not(big.NewInt(new $Int64(y$2.$high, y$2.$low))); + /* } else if ($assertType(_ref$3, intVal, true)[1]) { */ $s = 9; continue; case 7: + y$2 = _ref$3.$val; + z$1.Not(y$2.val); + /* } else { */ $s = 9; continue; case 8: + y$2 = _ref$3; + /* goto Error */ $s = 1; continue; + /* } */ case 9: + if (size >= 0) { + s = (x = (size >>> 0), (((x >>> 16 << 16) * 8 >>> 0) + (x << 16 >>> 16) * 8) >>> 0); + z$1.AndNot(z$1, new big.Int.Ptr().Lsh(big.NewInt(new $Int64(-1, 4294967295)), s)); + } + return normInt(z$1); + /* } else if (_ref === 43) { */ $s = 5; continue; case 4: + _ref$4 = y; + if ($assertType(_ref$4, unknownVal, true)[1]) { + y$3 = _ref$4.$val; + return new y$3.constructor.Struct(y$3); + } else if ($assertType(_ref$4, boolVal, true)[1]) { + y$3 = _ref$4.$val; + return new boolVal(!y$3); + } + /* } */ case 5: + /* Error: */ case 1: + $panic(new $String(fmt.Sprintf("invalid unary operation %s%v", new ($sliceType($emptyInterface))([new token.Token(op), y])))); + /* */ case -1: } return; } + }; + ord = function(x) { + var _ref; + _ref = x; + if ($assertType(_ref, int64Val, true)[1]) { + return 1; + } else if ($assertType(_ref, intVal, true)[1]) { + return 2; + } else if ($assertType(_ref, floatVal, true)[1]) { + return 3; + } else if ($assertType(_ref, complexVal, true)[1]) { + return 4; + } else { + return 0; + } + }; + match = function(x, y) { + var result = $ifaceNil, result$1 = $ifaceNil, _tuple, _tmp, _tmp$1, x$1, _ref, _tmp$2, _tmp$3, _tmp$4, _tmp$5, y$1, _ref$1, _tmp$6, _tmp$7, _tmp$8, x$2, _tmp$9, _tmp$10, x$3, _tmp$11, _tmp$12, x$4, _tmp$13, y$2, _ref$2, _tmp$14, _tmp$15, _tmp$16, x$5, _tmp$17, _tmp$18, x$6, _tmp$19, y$3, _ref$3, _tmp$20, _tmp$21, _tmp$22, x$7, _tmp$23; + if (ord(x) > ord(y)) { + _tuple = match(y, x); y = _tuple[0]; x = _tuple[1]; + _tmp = x; _tmp$1 = y; result = _tmp; result$1 = _tmp$1; + return [result, result$1]; + } + _ref = x; + if ($assertType(_ref, unknownVal, true)[1]) { + x$1 = _ref.$val; + _tmp$2 = new x$1.constructor.Struct(x$1); _tmp$3 = new x$1.constructor.Struct(x$1); result = _tmp$2; result$1 = _tmp$3; + return [result, result$1]; + } else if ($assertType(_ref, boolVal, true)[1] || $assertType(_ref, stringVal, true)[1] || $assertType(_ref, complexVal, true)[1]) { + x$1 = _ref; + _tmp$4 = x$1; _tmp$5 = y; result = _tmp$4; result$1 = _tmp$5; + return [result, result$1]; + } else if ($assertType(_ref, int64Val, true)[1]) { + x$1 = _ref.$val; + _ref$1 = y; + if ($assertType(_ref$1, int64Val, true)[1]) { + y$1 = _ref$1.$val; + _tmp$6 = x$1; _tmp$7 = y$1; result = _tmp$6; result$1 = _tmp$7; + return [result, result$1]; + } else if ($assertType(_ref$1, intVal, true)[1]) { + y$1 = _ref$1.$val; + _tmp$8 = (x$2 = new intVal.Ptr(big.NewInt(new $Int64(x$1.$high, x$1.$low))), new x$2.constructor.Struct(x$2)); _tmp$9 = new y$1.constructor.Struct(y$1); result = _tmp$8; result$1 = _tmp$9; + return [result, result$1]; + } else if ($assertType(_ref$1, floatVal, true)[1]) { + y$1 = _ref$1.$val; + _tmp$10 = (x$3 = new floatVal.Ptr(big.NewRat(new $Int64(x$1.$high, x$1.$low), new $Int64(0, 1))), new x$3.constructor.Struct(x$3)); _tmp$11 = new y$1.constructor.Struct(y$1); result = _tmp$10; result$1 = _tmp$11; + return [result, result$1]; + } else if ($assertType(_ref$1, complexVal, true)[1]) { + y$1 = _ref$1.$val; + _tmp$12 = (x$4 = new complexVal.Ptr(big.NewRat(new $Int64(x$1.$high, x$1.$low), new $Int64(0, 1)), rat0), new x$4.constructor.Struct(x$4)); _tmp$13 = new y$1.constructor.Struct(y$1); result = _tmp$12; result$1 = _tmp$13; + return [result, result$1]; + } + } else if ($assertType(_ref, intVal, true)[1]) { + x$1 = _ref.$val; + _ref$2 = y; + if ($assertType(_ref$2, intVal, true)[1]) { + y$2 = _ref$2.$val; + _tmp$14 = new x$1.constructor.Struct(x$1); _tmp$15 = new y$2.constructor.Struct(y$2); result = _tmp$14; result$1 = _tmp$15; + return [result, result$1]; + } else if ($assertType(_ref$2, floatVal, true)[1]) { + y$2 = _ref$2.$val; + _tmp$16 = (x$5 = new floatVal.Ptr(new big.Rat.Ptr().SetFrac(x$1.val, int1)), new x$5.constructor.Struct(x$5)); _tmp$17 = new y$2.constructor.Struct(y$2); result = _tmp$16; result$1 = _tmp$17; + return [result, result$1]; + } else if ($assertType(_ref$2, complexVal, true)[1]) { + y$2 = _ref$2.$val; + _tmp$18 = (x$6 = new complexVal.Ptr(new big.Rat.Ptr().SetFrac(x$1.val, int1), rat0), new x$6.constructor.Struct(x$6)); _tmp$19 = new y$2.constructor.Struct(y$2); result = _tmp$18; result$1 = _tmp$19; + return [result, result$1]; + } + } else if ($assertType(_ref, floatVal, true)[1]) { + x$1 = _ref.$val; + _ref$3 = y; + if ($assertType(_ref$3, floatVal, true)[1]) { + y$3 = _ref$3.$val; + _tmp$20 = new x$1.constructor.Struct(x$1); _tmp$21 = new y$3.constructor.Struct(y$3); result = _tmp$20; result$1 = _tmp$21; + return [result, result$1]; + } else if ($assertType(_ref$3, complexVal, true)[1]) { + y$3 = _ref$3.$val; + _tmp$22 = (x$7 = new complexVal.Ptr(x$1.val, rat0), new x$7.constructor.Struct(x$7)); _tmp$23 = new y$3.constructor.Struct(y$3); result = _tmp$22; result$1 = _tmp$23; + return [result, result$1]; } } - _tuple = p.scanner.Scan(); p.pos = _tuple[0]; p.tok = _tuple[1]; p.lit = _tuple[2]; + $panic(new $String("unreachable")); }; - parser.prototype.next0 = function() { return this.$val.next0(); }; - parser.Ptr.prototype.consumeComment = function() { - var comment = ($ptrType(ast.Comment)).nil, endline = 0, p, i; - p = this; - endline = p.file.Line(p.pos); - if (p.lit.charCodeAt(1) === 42) { - i = 0; - while (i < p.lit.length) { - if (p.lit.charCodeAt(i) === 10) { - endline = endline + (1) >> 0; + BinaryOp = $pkg.BinaryOp = function(x, op, y) { + var $this = this, $args = arguments, $s = 0, _tuple, x$1, _ref, y$1, _ref$1, a, x$2, b, c, _ref$2, a$1, b$1, c$1, _ref$3, a$2, b$2, c$2, _ref$4, y$2, _tmp, _tmp$1, a$3, b$3, _tmp$2, _tmp$3, c$3, d, _tmp$4, _tmp$5, re, im, _ref$5, _tmp$6, _tmp$7, _tmp$8, _tmp$9, ac, bd, bc, ad, _tmp$10, _tmp$11, _tmp$12, _tmp$13, _tmp$14, _tmp$15, _tmp$16, ac$1, bd$1, bc$1, ad$1, s, cc, dd; + /* */ while (true) { switch ($s) { case 0: + _tuple = match(x, y); x = _tuple[0]; y = _tuple[1]; + _ref = x; + /* if ($assertType(_ref, unknownVal, true)[1]) { */ if ($assertType(_ref, unknownVal, true)[1]) {} else if ($assertType(_ref, boolVal, true)[1]) { $s = 2; continue; } else if ($assertType(_ref, int64Val, true)[1]) { $s = 3; continue; } else if ($assertType(_ref, intVal, true)[1]) { $s = 4; continue; } else if ($assertType(_ref, floatVal, true)[1]) { $s = 5; continue; } else if ($assertType(_ref, complexVal, true)[1]) { $s = 6; continue; } else if ($assertType(_ref, stringVal, true)[1]) { $s = 7; continue; } else { $s = 8; continue; } + x$1 = _ref.$val; + return new x$1.constructor.Struct(x$1); + /* } else if ($assertType(_ref, boolVal, true)[1]) { */ $s = 8; continue; case 2: + x$1 = _ref.$val; + y$1 = $assertType(y, boolVal); + _ref$1 = op; + if (_ref$1 === 34) { + return new boolVal(x$1 && y$1); + } else if (_ref$1 === 35) { + return new boolVal(x$1 || y$1); + } + /* } else if ($assertType(_ref, int64Val, true)[1]) { */ $s = 8; continue; case 3: + x$1 = _ref.$val; + a = new $Int64(x$1.$high, x$1.$low); + b = (x$2 = $assertType(y, int64Val), new $Int64(x$2.$high, x$2.$low)); + c = new $Int64(0, 0); + _ref$2 = op; + /* if (_ref$2 === 12) { */ if (_ref$2 === 12) {} else if (_ref$2 === 13) { $s = 9; continue; } else if (_ref$2 === 14) { $s = 10; continue; } else if (_ref$2 === 15) { $s = 11; continue; } else if (_ref$2 === 26) { $s = 12; continue; } else if (_ref$2 === 16) { $s = 13; continue; } else if (_ref$2 === 17) { $s = 14; continue; } else if (_ref$2 === 18) { $s = 15; continue; } else if (_ref$2 === 19) { $s = 16; continue; } else if (_ref$2 === 22) { $s = 17; continue; } else { $s = 18; continue; } + if (!is63bit(a) || !is63bit(b)) { + return normInt(new big.Int.Ptr().Add(big.NewInt(a), big.NewInt(b))); } - i = i + (1) >> 0; + c = new $Int64(a.$high + b.$high, a.$low + b.$low); + /* } else if (_ref$2 === 13) { */ $s = 19; continue; case 9: + if (!is63bit(a) || !is63bit(b)) { + return normInt(new big.Int.Ptr().Sub(big.NewInt(a), big.NewInt(b))); + } + c = new $Int64(a.$high - b.$high, a.$low - b.$low); + /* } else if (_ref$2 === 14) { */ $s = 19; continue; case 10: + if (!is32bit(a) || !is32bit(b)) { + return normInt(new big.Int.Ptr().Mul(big.NewInt(a), big.NewInt(b))); + } + c = $mul64(a, b); + /* } else if (_ref$2 === 15) { */ $s = 19; continue; case 11: + return normFloat(new big.Rat.Ptr().SetFrac(big.NewInt(a), big.NewInt(b))); + /* } else if (_ref$2 === 26) { */ $s = 19; continue; case 12: + c = $div64(a, b, false); + /* } else if (_ref$2 === 16) { */ $s = 19; continue; case 13: + c = $div64(a, b, true); + /* } else if (_ref$2 === 17) { */ $s = 19; continue; case 14: + c = new $Int64(a.$high & b.$high, (a.$low & b.$low) >>> 0); + /* } else if (_ref$2 === 18) { */ $s = 19; continue; case 15: + c = new $Int64(a.$high | b.$high, (a.$low | b.$low) >>> 0); + /* } else if (_ref$2 === 19) { */ $s = 19; continue; case 16: + c = new $Int64(a.$high ^ b.$high, (a.$low ^ b.$low) >>> 0); + /* } else if (_ref$2 === 22) { */ $s = 19; continue; case 17: + c = new $Int64(a.$high &~ b.$high, (a.$low &~ b.$low) >>> 0); + /* } else { */ $s = 19; continue; case 18: + /* goto Error */ $s = 1; continue; + /* } */ case 19: + return new int64Val(c.$high, c.$low); + /* } else if ($assertType(_ref, intVal, true)[1]) { */ $s = 8; continue; case 4: + x$1 = _ref.$val; + a$1 = x$1.val; + b$1 = $assertType(y, intVal).val; + c$1 = new big.Int.Ptr(); $copy(c$1, new big.Int.Ptr(), big.Int); + _ref$3 = op; + /* if (_ref$3 === 12) { */ if (_ref$3 === 12) {} else if (_ref$3 === 13) { $s = 20; continue; } else if (_ref$3 === 14) { $s = 21; continue; } else if (_ref$3 === 15) { $s = 22; continue; } else if (_ref$3 === 26) { $s = 23; continue; } else if (_ref$3 === 16) { $s = 24; continue; } else if (_ref$3 === 17) { $s = 25; continue; } else if (_ref$3 === 18) { $s = 26; continue; } else if (_ref$3 === 19) { $s = 27; continue; } else if (_ref$3 === 22) { $s = 28; continue; } else { $s = 29; continue; } + c$1.Add(a$1, b$1); + /* } else if (_ref$3 === 13) { */ $s = 30; continue; case 20: + c$1.Sub(a$1, b$1); + /* } else if (_ref$3 === 14) { */ $s = 30; continue; case 21: + c$1.Mul(a$1, b$1); + /* } else if (_ref$3 === 15) { */ $s = 30; continue; case 22: + return normFloat(new big.Rat.Ptr().SetFrac(a$1, b$1)); + /* } else if (_ref$3 === 26) { */ $s = 30; continue; case 23: + c$1.Quo(a$1, b$1); + /* } else if (_ref$3 === 16) { */ $s = 30; continue; case 24: + c$1.Rem(a$1, b$1); + /* } else if (_ref$3 === 17) { */ $s = 30; continue; case 25: + c$1.And(a$1, b$1); + /* } else if (_ref$3 === 18) { */ $s = 30; continue; case 26: + c$1.Or(a$1, b$1); + /* } else if (_ref$3 === 19) { */ $s = 30; continue; case 27: + c$1.Xor(a$1, b$1); + /* } else if (_ref$3 === 22) { */ $s = 30; continue; case 28: + c$1.AndNot(a$1, b$1); + /* } else { */ $s = 30; continue; case 29: + /* goto Error */ $s = 1; continue; + /* } */ case 30: + return normInt(c$1); + /* } else if ($assertType(_ref, floatVal, true)[1]) { */ $s = 8; continue; case 5: + x$1 = _ref.$val; + a$2 = x$1.val; + b$2 = $assertType(y, floatVal).val; + c$2 = new big.Rat.Ptr(); $copy(c$2, new big.Rat.Ptr(), big.Rat); + _ref$4 = op; + /* if (_ref$4 === 12) { */ if (_ref$4 === 12) {} else if (_ref$4 === 13) { $s = 31; continue; } else if (_ref$4 === 14) { $s = 32; continue; } else if (_ref$4 === 15) { $s = 33; continue; } else { $s = 34; continue; } + c$2.Add(a$2, b$2); + /* } else if (_ref$4 === 13) { */ $s = 35; continue; case 31: + c$2.Sub(a$2, b$2); + /* } else if (_ref$4 === 14) { */ $s = 35; continue; case 32: + c$2.Mul(a$2, b$2); + /* } else if (_ref$4 === 15) { */ $s = 35; continue; case 33: + c$2.Quo(a$2, b$2); + /* } else { */ $s = 35; continue; case 34: + /* goto Error */ $s = 1; continue; + /* } */ case 35: + return normFloat(c$2); + /* } else if ($assertType(_ref, complexVal, true)[1]) { */ $s = 8; continue; case 6: + x$1 = _ref.$val; + y$2 = new complexVal.Ptr(); $copy(y$2, $assertType(y, complexVal), complexVal); + _tmp = x$1.re; _tmp$1 = x$1.im; a$3 = _tmp; b$3 = _tmp$1; + _tmp$2 = y$2.re; _tmp$3 = y$2.im; c$3 = _tmp$2; d = _tmp$3; + _tmp$4 = new big.Rat.Ptr(); $copy(_tmp$4, new big.Rat.Ptr(), big.Rat); _tmp$5 = new big.Rat.Ptr(); $copy(_tmp$5, new big.Rat.Ptr(), big.Rat); re = new big.Rat.Ptr(); $copy(re, _tmp$4, big.Rat); im = new big.Rat.Ptr(); $copy(im, _tmp$5, big.Rat); + _ref$5 = op; + /* if (_ref$5 === 12) { */ if (_ref$5 === 12) {} else if (_ref$5 === 13) { $s = 36; continue; } else if (_ref$5 === 14) { $s = 37; continue; } else if (_ref$5 === 15) { $s = 38; continue; } else { $s = 39; continue; } + re.Add(a$3, c$3); + im.Add(b$3, d); + /* } else if (_ref$5 === 13) { */ $s = 40; continue; case 36: + re.Sub(a$3, c$3); + im.Sub(b$3, d); + /* } else if (_ref$5 === 14) { */ $s = 40; continue; case 37: + _tmp$6 = new big.Rat.Ptr(); $copy(_tmp$6, new big.Rat.Ptr(), big.Rat); _tmp$7 = new big.Rat.Ptr(); $copy(_tmp$7, new big.Rat.Ptr(), big.Rat); _tmp$8 = new big.Rat.Ptr(); $copy(_tmp$8, new big.Rat.Ptr(), big.Rat); _tmp$9 = new big.Rat.Ptr(); $copy(_tmp$9, new big.Rat.Ptr(), big.Rat); ac = new big.Rat.Ptr(); $copy(ac, _tmp$6, big.Rat); bd = new big.Rat.Ptr(); $copy(bd, _tmp$7, big.Rat); bc = new big.Rat.Ptr(); $copy(bc, _tmp$8, big.Rat); ad = new big.Rat.Ptr(); $copy(ad, _tmp$9, big.Rat); + ac.Mul(a$3, c$3); + bd.Mul(b$3, d); + bc.Mul(b$3, c$3); + ad.Mul(a$3, d); + re.Sub(ac, bd); + im.Add(bc, ad); + /* } else if (_ref$5 === 15) { */ $s = 40; continue; case 38: + _tmp$10 = new big.Rat.Ptr(); $copy(_tmp$10, new big.Rat.Ptr(), big.Rat); _tmp$11 = new big.Rat.Ptr(); $copy(_tmp$11, new big.Rat.Ptr(), big.Rat); _tmp$12 = new big.Rat.Ptr(); $copy(_tmp$12, new big.Rat.Ptr(), big.Rat); _tmp$13 = new big.Rat.Ptr(); $copy(_tmp$13, new big.Rat.Ptr(), big.Rat); _tmp$14 = new big.Rat.Ptr(); $copy(_tmp$14, new big.Rat.Ptr(), big.Rat); _tmp$15 = new big.Rat.Ptr(); $copy(_tmp$15, new big.Rat.Ptr(), big.Rat); _tmp$16 = new big.Rat.Ptr(); $copy(_tmp$16, new big.Rat.Ptr(), big.Rat); ac$1 = new big.Rat.Ptr(); $copy(ac$1, _tmp$10, big.Rat); bd$1 = new big.Rat.Ptr(); $copy(bd$1, _tmp$11, big.Rat); bc$1 = new big.Rat.Ptr(); $copy(bc$1, _tmp$12, big.Rat); ad$1 = new big.Rat.Ptr(); $copy(ad$1, _tmp$13, big.Rat); s = new big.Rat.Ptr(); $copy(s, _tmp$14, big.Rat); cc = new big.Rat.Ptr(); $copy(cc, _tmp$15, big.Rat); dd = new big.Rat.Ptr(); $copy(dd, _tmp$16, big.Rat); + ac$1.Mul(a$3, c$3); + bd$1.Mul(b$3, d); + bc$1.Mul(b$3, c$3); + ad$1.Mul(a$3, d); + cc.Mul(c$3, c$3); + dd.Mul(d, d); + s.Add(cc, dd); + re.Add(ac$1, bd$1); + re.Quo(re, s); + im.Sub(bc$1, ad$1); + im.Quo(im, s); + /* } else { */ $s = 40; continue; case 39: + /* goto Error */ $s = 1; continue; + /* } */ case 40: + return normComplex(re, im); + /* } else if ($assertType(_ref, stringVal, true)[1]) { */ $s = 8; continue; case 7: + x$1 = _ref.$val; + if (op === 12) { + return new stringVal(x$1 + $assertType(y, stringVal)); + } + /* } */ case 8: + /* Error: */ case 1: + $panic(new $String(fmt.Sprintf("invalid binary operation %v %s %v", new ($sliceType($emptyInterface))([x, new token.Token(op), y])))); + /* */ case -1: } return; } + }; + Shift = $pkg.Shift = function(x, op, s) { + var x$1, _ref, _ref$1, z, z$1, _ref$2; + _ref = x; + if ($assertType(_ref, unknownVal, true)[1]) { + x$1 = _ref.$val; + return new x$1.constructor.Struct(x$1); + } else if ($assertType(_ref, int64Val, true)[1]) { + x$1 = _ref.$val; + if (s === 0) { + return x$1; + } + _ref$1 = op; + if (_ref$1 === 20) { + z = big.NewInt(new $Int64(x$1.$high, x$1.$low)); + return normInt(z.Lsh(z, s)); + } else if (_ref$1 === 21) { + return $shiftRightInt64(x$1, s); + } + } else if ($assertType(_ref, intVal, true)[1]) { + x$1 = _ref.$val; + if (s === 0) { + return new x$1.constructor.Struct(x$1); + } + z$1 = new big.Int.Ptr(); $copy(z$1, new big.Int.Ptr(), big.Int); + _ref$2 = op; + if (_ref$2 === 20) { + return normInt(z$1.Lsh(x$1.val, s)); + } else if (_ref$2 === 21) { + return normInt(z$1.Rsh(x$1.val, s)); } } - comment = new ast.Comment.Ptr(p.pos, p.lit); - p.next0(); - return [comment, endline]; + $panic(new $String(fmt.Sprintf("invalid shift %v %s %d", new ($sliceType($emptyInterface))([x, new token.Token(op), new $Uint(s)])))); }; - parser.prototype.consumeComment = function() { return this.$val.consumeComment(); }; - parser.Ptr.prototype.consumeCommentGroup = function(n) { - var comments = ($ptrType(ast.CommentGroup)).nil, endline = 0, p, list, comment, _tuple; - p = this; - list = ($sliceType(($ptrType(ast.Comment)))).nil; - endline = p.file.Line(p.pos); - while ((p.tok === 2) && p.file.Line(p.pos) <= (endline + n >> 0)) { - comment = ($ptrType(ast.Comment)).nil; - _tuple = p.consumeComment(); comment = _tuple[0]; endline = _tuple[1]; - list = $append(list, comment); + cmpZero = function(x, op) { + var _ref; + _ref = op; + if (_ref === 39) { + return x === 0; + } else if (_ref === 44) { + return !((x === 0)); + } else if (_ref === 40) { + return x < 0; + } else if (_ref === 45) { + return x <= 0; + } else if (_ref === 41) { + return x > 0; + } else if (_ref === 46) { + return x >= 0; } - comments = new ast.CommentGroup.Ptr(list); - p.comments = $append(p.comments, comments); - return [comments, endline]; + $panic(new $String("unreachable")); }; - parser.prototype.consumeCommentGroup = function(n) { return this.$val.consumeCommentGroup(n); }; - parser.Ptr.prototype.next = function() { - var p, prev, comment, endline, _tuple, _tuple$1; - p = this; - p.leadComment = ($ptrType(ast.CommentGroup)).nil; - p.lineComment = ($ptrType(ast.CommentGroup)).nil; - prev = p.pos; - p.next0(); - if (p.tok === 2) { - comment = ($ptrType(ast.CommentGroup)).nil; - endline = 0; - if (p.file.Line(p.pos) === p.file.Line(prev)) { - _tuple = p.consumeCommentGroup(0); comment = _tuple[0]; endline = _tuple[1]; - if (!((p.file.Line(p.pos) === endline))) { - p.lineComment = comment; - } - } - endline = -1; - while (p.tok === 2) { - _tuple$1 = p.consumeCommentGroup(1); comment = _tuple$1[0]; endline = _tuple$1[1]; - } - if ((endline + 1 >> 0) === p.file.Line(p.pos)) { - p.leadComment = comment; + Compare = $pkg.Compare = function(x, op, y) { + var _tuple, x$1, _ref, y$1, _ref$1, y$2, _ref$2, y$3, re, im, _ref$3, y$4, _ref$4; + _tuple = match(x, y); x = _tuple[0]; y = _tuple[1]; + _ref = x; + if ($assertType(_ref, unknownVal, true)[1]) { + x$1 = _ref.$val; + return false; + } else if ($assertType(_ref, boolVal, true)[1]) { + x$1 = _ref.$val; + y$1 = $assertType(y, boolVal); + _ref$1 = op; + if (_ref$1 === 39) { + return x$1 === y$1; + } else if (_ref$1 === 44) { + return !(x$1 === y$1); } - } - }; - parser.prototype.next = function() { return this.$val.next(); }; - parser.Ptr.prototype.error = function(pos, msg) { - var p, epos, n, x, x$1, x$2; - p = this; - epos = new token.Position.Ptr(); $copy(epos, p.file.Position(pos), token.Position); - if (((p.mode & 32) >>> 0) === 0) { - n = p.errors.$length; - if (n > 0 && ((x = p.errors, x$1 = n - 1 >> 0, ((x$1 < 0 || x$1 >= x.$length) ? $throwRuntimeError("index out of range") : x.$array[x.$offset + x$1])).Pos.Line === epos.Line)) { - return; + } else if ($assertType(_ref, int64Val, true)[1]) { + x$1 = _ref.$val; + y$2 = $assertType(y, int64Val); + _ref$2 = op; + if (_ref$2 === 39) { + return (x$1.$high === y$2.$high && x$1.$low === y$2.$low); + } else if (_ref$2 === 44) { + return !((x$1.$high === y$2.$high && x$1.$low === y$2.$low)); + } else if (_ref$2 === 40) { + return (x$1.$high < y$2.$high || (x$1.$high === y$2.$high && x$1.$low < y$2.$low)); + } else if (_ref$2 === 45) { + return (x$1.$high < y$2.$high || (x$1.$high === y$2.$high && x$1.$low <= y$2.$low)); + } else if (_ref$2 === 41) { + return (x$1.$high > y$2.$high || (x$1.$high === y$2.$high && x$1.$low > y$2.$low)); + } else if (_ref$2 === 46) { + return (x$1.$high > y$2.$high || (x$1.$high === y$2.$high && x$1.$low >= y$2.$low)); } - if (n > 10) { - $panic((x$2 = new bailout.Ptr(), new x$2.constructor.Struct(x$2))); + } else if ($assertType(_ref, intVal, true)[1]) { + x$1 = _ref.$val; + return cmpZero(x$1.val.Cmp($assertType(y, intVal).val), op); + } else if ($assertType(_ref, floatVal, true)[1]) { + x$1 = _ref.$val; + return cmpZero(x$1.val.Cmp($assertType(y, floatVal).val), op); + } else if ($assertType(_ref, complexVal, true)[1]) { + x$1 = _ref.$val; + y$3 = new complexVal.Ptr(); $copy(y$3, $assertType(y, complexVal), complexVal); + re = x$1.re.Cmp(y$3.re); + im = x$1.im.Cmp(y$3.im); + _ref$3 = op; + if (_ref$3 === 39) { + return (re === 0) && (im === 0); + } else if (_ref$3 === 44) { + return !((re === 0)) || !((im === 0)); } - } - new ($ptrType(scanner.ErrorList))(function() { return this.$target.errors; }, function($v) { this.$target.errors = $v; }, p).Add($clone(epos, token.Position), msg); - }; - parser.prototype.error = function(pos, msg) { return this.$val.error(pos, msg); }; - parser.Ptr.prototype.errorExpected = function(pos, msg) { - var p; - p = this; - msg = "expected " + msg; - if (pos === p.pos) { - if ((p.tok === 57) && p.lit === "\n") { - msg = msg + (", found newline"); - } else { - msg = msg + (", found '" + (new token.Token(p.tok)).String() + "'"); - if ((new token.Token(p.tok)).IsLiteral()) { - msg = msg + (" " + p.lit); - } + } else if ($assertType(_ref, stringVal, true)[1]) { + x$1 = _ref.$val; + y$4 = $assertType(y, stringVal); + _ref$4 = op; + if (_ref$4 === 39) { + return x$1 === y$4; + } else if (_ref$4 === 44) { + return !(x$1 === y$4); + } else if (_ref$4 === 40) { + return x$1 < y$4; + } else if (_ref$4 === 45) { + return x$1 <= y$4; + } else if (_ref$4 === 41) { + return x$1 > y$4; + } else if (_ref$4 === 46) { + return x$1 >= y$4; } } - p.error(pos, msg); + $panic(new $String(fmt.Sprintf("invalid comparison %v %s %v", new ($sliceType($emptyInterface))([x, new token.Token(op), y])))); }; - parser.prototype.errorExpected = function(pos, msg) { return this.$val.errorExpected(pos, msg); }; - parser.Ptr.prototype.expect = function(tok) { - var p, pos; - p = this; - pos = p.pos; - if (!((p.tok === tok))) { - p.errorExpected(pos, "'" + (new token.Token(tok)).String() + "'"); + ratToFloat32 = function(x) { + var _tuple, x64, exact, x32; + _tuple = x.Float64(); x64 = _tuple[0]; exact = _tuple[1]; + x32 = x64; + if (math.IsInf($coerceFloat32(x32), 0)) { + exact = false; } - p.next(); - return pos; + return [x32, exact]; }; - parser.prototype.expect = function(tok) { return this.$val.expect(tok); }; - parser.Ptr.prototype.expectClosing = function(tok, context) { - var p; - p = this; - if (!((p.tok === tok)) && (p.tok === 57) && p.lit === "\n") { - p.error(p.pos, "missing ',' before newline in " + context); - p.next(); - } - return p.expect(tok); + $pkg.$init = function() { + Value.init([["Kind", "Kind", "", $funcType([], [Kind], false)], ["String", "String", "", $funcType([], [$String], false)], ["implementsValue", "implementsValue", "code.google.com/p/go.tools/go/exact", $funcType([], [], false)]]); + unknownVal.methods = [["Kind", "Kind", "", $funcType([], [Kind], false), -1], ["String", "String", "", $funcType([], [$String], false), -1], ["implementsValue", "implementsValue", "code.google.com/p/go.tools/go/exact", $funcType([], [], false), -1]]; + ($ptrType(unknownVal)).methods = [["Kind", "Kind", "", $funcType([], [Kind], false), -1], ["String", "String", "", $funcType([], [$String], false), -1], ["implementsValue", "implementsValue", "code.google.com/p/go.tools/go/exact", $funcType([], [], false), -1]]; + unknownVal.init([]); + boolVal.methods = [["Kind", "Kind", "", $funcType([], [Kind], false), -1], ["String", "String", "", $funcType([], [$String], false), -1], ["implementsValue", "implementsValue", "code.google.com/p/go.tools/go/exact", $funcType([], [], false), -1]]; + ($ptrType(boolVal)).methods = [["Kind", "Kind", "", $funcType([], [Kind], false), -1], ["String", "String", "", $funcType([], [$String], false), -1], ["implementsValue", "implementsValue", "code.google.com/p/go.tools/go/exact", $funcType([], [], false), -1]]; + stringVal.methods = [["Kind", "Kind", "", $funcType([], [Kind], false), -1], ["String", "String", "", $funcType([], [$String], false), -1], ["implementsValue", "implementsValue", "code.google.com/p/go.tools/go/exact", $funcType([], [], false), -1]]; + ($ptrType(stringVal)).methods = [["Kind", "Kind", "", $funcType([], [Kind], false), -1], ["String", "String", "", $funcType([], [$String], false), -1], ["implementsValue", "implementsValue", "code.google.com/p/go.tools/go/exact", $funcType([], [], false), -1]]; + int64Val.methods = [["Kind", "Kind", "", $funcType([], [Kind], false), -1], ["String", "String", "", $funcType([], [$String], false), -1], ["implementsValue", "implementsValue", "code.google.com/p/go.tools/go/exact", $funcType([], [], false), -1]]; + ($ptrType(int64Val)).methods = [["Kind", "Kind", "", $funcType([], [Kind], false), -1], ["String", "String", "", $funcType([], [$String], false), -1], ["implementsValue", "implementsValue", "code.google.com/p/go.tools/go/exact", $funcType([], [], false), -1]]; + intVal.methods = [["Kind", "Kind", "", $funcType([], [Kind], false), -1], ["String", "String", "", $funcType([], [$String], false), -1], ["implementsValue", "implementsValue", "code.google.com/p/go.tools/go/exact", $funcType([], [], false), -1]]; + ($ptrType(intVal)).methods = [["Kind", "Kind", "", $funcType([], [Kind], false), -1], ["String", "String", "", $funcType([], [$String], false), -1], ["implementsValue", "implementsValue", "code.google.com/p/go.tools/go/exact", $funcType([], [], false), -1]]; + intVal.init([["val", "val", "code.google.com/p/go.tools/go/exact", ($ptrType(big.Int)), ""]]); + floatVal.methods = [["Kind", "Kind", "", $funcType([], [Kind], false), -1], ["String", "String", "", $funcType([], [$String], false), -1], ["implementsValue", "implementsValue", "code.google.com/p/go.tools/go/exact", $funcType([], [], false), -1]]; + ($ptrType(floatVal)).methods = [["Kind", "Kind", "", $funcType([], [Kind], false), -1], ["String", "String", "", $funcType([], [$String], false), -1], ["implementsValue", "implementsValue", "code.google.com/p/go.tools/go/exact", $funcType([], [], false), -1]]; + floatVal.init([["val", "val", "code.google.com/p/go.tools/go/exact", ($ptrType(big.Rat)), ""]]); + complexVal.methods = [["Kind", "Kind", "", $funcType([], [Kind], false), -1], ["String", "String", "", $funcType([], [$String], false), -1], ["implementsValue", "implementsValue", "code.google.com/p/go.tools/go/exact", $funcType([], [], false), -1]]; + ($ptrType(complexVal)).methods = [["Kind", "Kind", "", $funcType([], [Kind], false), -1], ["String", "String", "", $funcType([], [$String], false), -1], ["implementsValue", "implementsValue", "code.google.com/p/go.tools/go/exact", $funcType([], [], false), -1]]; + complexVal.init([["re", "re", "code.google.com/p/go.tools/go/exact", ($ptrType(big.Rat)), ""], ["im", "im", "code.google.com/p/go.tools/go/exact", ($ptrType(big.Rat)), ""]]); + minInt64 = big.NewInt(new $Int64(-2147483648, 0)); + maxInt64 = big.NewInt(new $Int64(2147483647, 4294967295)); + int1 = big.NewInt(new $Int64(0, 1)); + rat0 = big.NewRat(new $Int64(0, 0), new $Int64(0, 1)); }; - parser.prototype.expectClosing = function(tok, context) { return this.$val.expectClosing(tok, context); }; - parser.Ptr.prototype.expectSemi = function() { - var p; - p = this; - if (!((p.tok === 54)) && !((p.tok === 56))) { - if (p.tok === 57) { - p.next(); - } else { - p.errorExpected(p.pos, "';'"); - syncStmt(p); - } + return $pkg; +})(); +$packages["container/heap"] = (function() { + var $pkg = {}, sort = $packages["sort"], Init, Pop, Fix, up, down; + Init = $pkg.Init = function(h) { + var n, _q, i; + n = h.Len(); + i = (_q = n / 2, (_q === _q && _q !== 1/0 && _q !== -1/0) ? _q >> 0 : $throwRuntimeError("integer divide by zero")) - 1 >> 0; + while (i >= 0) { + down(h, i, n); + i = i - (1) >> 0; } }; - parser.prototype.expectSemi = function() { return this.$val.expectSemi(); }; - parser.Ptr.prototype.atComma = function(context) { - var p; - p = this; - if (p.tok === 52) { - return true; - } - if ((p.tok === 57) && p.lit === "\n") { - p.error(p.pos, "missing ',' before newline in " + context); - return true; - } - return false; + Pop = $pkg.Pop = function(h) { + var n; + n = h.Len() - 1 >> 0; + h.Swap(0, n); + down(h, 0, n); + return h.Pop(); }; - parser.prototype.atComma = function(context) { return this.$val.atComma(context); }; - assert = function(cond, msg) { - if (!cond) { - $panic(new $String("go/parser internal error: " + msg)); - } + Fix = $pkg.Fix = function(h, i) { + down(h, i, h.Len()); + up(h, i); }; - syncStmt = function(p) { - var _ref; + up = function(h, j) { + var _q, i; while (true) { - _ref = p.tok; - if (_ref === 61 || _ref === 64 || _ref === 65 || _ref === 67 || _ref === 69 || _ref === 70 || _ref === 72 || _ref === 73 || _ref === 74 || _ref === 80 || _ref === 81 || _ref === 83 || _ref === 84 || _ref === 85) { - if ((p.pos === p.syncPos) && p.syncCnt < 10) { - p.syncCnt = p.syncCnt + (1) >> 0; - return; - } - if (p.pos > p.syncPos) { - p.syncPos = p.pos; - p.syncCnt = 0; - return; - } - } else if (_ref === 1) { - return; + i = (_q = ((j - 1 >> 0)) / 2, (_q === _q && _q !== 1/0 && _q !== -1/0) ? _q >> 0 : $throwRuntimeError("integer divide by zero")); + if ((i === j) || !h.Less(j, i)) { + break; } - p.next(); + h.Swap(i, j); + j = i; } }; - syncDecl = function(p) { - var _ref; + down = function(h, i, n) { + var j1, j, j2; while (true) { - _ref = p.tok; - if (_ref === 64 || _ref === 84 || _ref === 85) { - if ((p.pos === p.syncPos) && p.syncCnt < 10) { - p.syncCnt = p.syncCnt + (1) >> 0; - return; - } - if (p.pos > p.syncPos) { - p.syncPos = p.pos; - p.syncCnt = 0; - return; - } - } else if (_ref === 1) { - return; + j1 = ((((2 >>> 16 << 16) * i >> 0) + (2 << 16 >>> 16) * i) >> 0) + 1 >> 0; + if (j1 >= n || j1 < 0) { + break; } - p.next(); - } - }; - parser.Ptr.prototype.safePos = function(pos) { - var res = 0, $deferred = [], $err = null, p; - /* */ try { $deferFrames.push($deferred); - p = this; - $deferred.push([(function() { - if (!($interfaceIsEqual($recover(), $ifaceNil))) { - res = ((p.file.Base() + p.file.Size() >> 0) >> 0); + j = j1; + j2 = j1 + 1 >> 0; + if (j2 < n && !h.Less(j1, j2)) { + j = j2; } - }), []]); - p.file.Offset(pos); - res = pos; - return res; - /* */ } catch(err) { $err = err; } finally { $deferFrames.pop(); $callDeferred($deferred, $err); return res; } - }; - parser.prototype.safePos = function(pos) { return this.$val.safePos(pos); }; - parser.Ptr.prototype.parseIdent = function() { - var p, pos, name; - p = this; - pos = p.pos; - name = "_"; - if (p.tok === 4) { - name = p.lit; - p.next(); - } else { - p.expect(4); + if (!h.Less(j, i)) { + break; + } + h.Swap(i, j); + i = j; } - return new ast.Ident.Ptr(pos, name, ($ptrType(ast.Object)).nil); }; - parser.prototype.parseIdent = function() { return this.$val.parseIdent(); }; - parser.Ptr.prototype.parseIdentList = function() { - var list = ($sliceType(($ptrType(ast.Ident)))).nil, $deferred = [], $err = null, p; - /* */ try { $deferFrames.push($deferred); - p = this; - if (p.trace) { - $deferred.push([un, [trace(p, "IdentList")]]); - } - list = $append(list, p.parseIdent()); - while (p.tok === 52) { - p.next(); - list = $append(list, p.parseIdent()); - } - return list; - /* */ } catch(err) { $err = err; } finally { $deferFrames.pop(); $callDeferred($deferred, $err); return list; } + $pkg.$init = function() { }; - parser.prototype.parseIdentList = function() { return this.$val.parseIdentList(); }; - parser.Ptr.prototype.parseExprList = function(lhs) { - var list = ($sliceType(ast.Expr)).nil, $deferred = [], $err = null, p; - /* */ try { $deferFrames.push($deferred); - p = this; - if (p.trace) { - $deferred.push([un, [trace(p, "ExpressionList")]]); - } - list = $append(list, p.checkExpr(p.parseExpr(lhs))); - while (p.tok === 52) { - p.next(); - list = $append(list, p.checkExpr(p.parseExpr(lhs))); + return $pkg; +})(); +$packages["path/filepath"] = (function() { + var $pkg = {}, errors = $packages["errors"], os = $packages["os"], runtime = $packages["runtime"], sort = $packages["sort"], strings = $packages["strings"], utf8 = $packages["unicode/utf8"], bytes = $packages["bytes"], lazybuf, Clean, ToSlash, FromSlash, SplitList, Split, Join, EvalSymlinks, VolumeName, IsAbs, volumeNameLen, splitList, evalSymlinks; + lazybuf = $pkg.lazybuf = $newType(0, "Struct", "filepath.lazybuf", "lazybuf", "path/filepath", function(path_, buf_, w_, volAndPath_, volLen_) { + this.$val = this; + this.path = path_ !== undefined ? path_ : ""; + this.buf = buf_ !== undefined ? buf_ : ($sliceType($Uint8)).nil; + this.w = w_ !== undefined ? w_ : 0; + this.volAndPath = volAndPath_ !== undefined ? volAndPath_ : ""; + this.volLen = volLen_ !== undefined ? volLen_ : 0; + }); + lazybuf.Ptr.prototype.index = function(i) { + var b, x; + b = this; + if (!(b.buf === ($sliceType($Uint8)).nil)) { + return (x = b.buf, ((i < 0 || i >= x.$length) ? $throwRuntimeError("index out of range") : x.$array[x.$offset + i])); } - return list; - /* */ } catch(err) { $err = err; } finally { $deferFrames.pop(); $callDeferred($deferred, $err); return list; } + return b.path.charCodeAt(i); }; - parser.prototype.parseExprList = function(lhs) { return this.$val.parseExprList(lhs); }; - parser.Ptr.prototype.parseLhsList = function() { - var p, old, list, _ref, _ref$1, _i, x; - p = this; - old = p.inRhs; - p.inRhs = false; - list = p.parseExprList(true); - _ref = p.tok; - if (_ref === 47) { - } else if (_ref === 58) { - } else { - _ref$1 = list; - _i = 0; - while (_i < _ref$1.$length) { - x = ((_i < 0 || _i >= _ref$1.$length) ? $throwRuntimeError("index out of range") : _ref$1.$array[_ref$1.$offset + _i]); - p.resolve(x); - _i++; + lazybuf.prototype.index = function(i) { return this.$val.index(i); }; + lazybuf.Ptr.prototype.append = function(c) { + var b, x, x$1; + b = this; + if (b.buf === ($sliceType($Uint8)).nil) { + if (b.w < b.path.length && (b.path.charCodeAt(b.w) === c)) { + b.w = b.w + (1) >> 0; + return; } + b.buf = ($sliceType($Uint8)).make(b.path.length); + $copyString(b.buf, b.path.substring(0, b.w)); } - p.inRhs = old; - return list; - }; - parser.prototype.parseLhsList = function() { return this.$val.parseLhsList(); }; - parser.Ptr.prototype.parseRhsList = function() { - var p, old, list; - p = this; - old = p.inRhs; - p.inRhs = true; - list = p.parseExprList(false); - p.inRhs = old; - return list; + (x = b.buf, x$1 = b.w, (x$1 < 0 || x$1 >= x.$length) ? $throwRuntimeError("index out of range") : x.$array[x.$offset + x$1] = c); + b.w = b.w + (1) >> 0; }; - parser.prototype.parseRhsList = function() { return this.$val.parseRhsList(); }; - parser.Ptr.prototype.parseType = function() { - var $deferred = [], $err = null, p, typ, pos; - /* */ try { $deferFrames.push($deferred); - p = this; - if (p.trace) { - $deferred.push([un, [trace(p, "Type")]]); - } - typ = p.tryType(); - if ($interfaceIsEqual(typ, $ifaceNil)) { - pos = p.pos; - p.errorExpected(pos, "type"); - p.next(); - return new ast.BadExpr.Ptr(pos, p.pos); + lazybuf.prototype.append = function(c) { return this.$val.append(c); }; + lazybuf.Ptr.prototype.string = function() { + var b; + b = this; + if (b.buf === ($sliceType($Uint8)).nil) { + return b.volAndPath.substring(0, (b.volLen + b.w >> 0)); } - return typ; - /* */ } catch(err) { $err = err; return $ifaceNil; } finally { $deferFrames.pop(); $callDeferred($deferred, $err); } + return b.volAndPath.substring(0, b.volLen) + $bytesToString($subslice(b.buf, 0, b.w)); }; - parser.prototype.parseType = function() { return this.$val.parseType(); }; - parser.Ptr.prototype.parseTypeName = function() { - var $deferred = [], $err = null, p, ident, sel; - /* */ try { $deferFrames.push($deferred); - p = this; - if (p.trace) { - $deferred.push([un, [trace(p, "TypeName")]]); + lazybuf.prototype.string = function() { return this.$val.string(); }; + Clean = $pkg.Clean = function(path) { + var originalPath, volLen, rooted, n, out, _tmp, _tmp$1, r, dotdot, _tmp$2, _tmp$3; + originalPath = path; + volLen = volumeNameLen(path); + path = path.substring(volLen); + if (path === "") { + if (volLen > 1 && !((originalPath.charCodeAt(1) === 58))) { + return FromSlash(originalPath); + } + return originalPath + "."; } - ident = p.parseIdent(); - if (p.tok === 53) { - p.next(); - p.resolve(ident); - sel = p.parseIdent(); - return new ast.SelectorExpr.Ptr(ident, sel); + rooted = os.IsPathSeparator(path.charCodeAt(0)); + n = path.length; + out = new lazybuf.Ptr(path, ($sliceType($Uint8)).nil, 0, originalPath, volLen); + _tmp = 0; _tmp$1 = 0; r = _tmp; dotdot = _tmp$1; + if (rooted) { + out.append(47); + _tmp$2 = 1; _tmp$3 = 1; r = _tmp$2; dotdot = _tmp$3; } - return ident; - /* */ } catch(err) { $err = err; return $ifaceNil; } finally { $deferFrames.pop(); $callDeferred($deferred, $err); } - }; - parser.prototype.parseTypeName = function() { return this.$val.parseTypeName(); }; - parser.Ptr.prototype.parseArrayType = function() { - var $deferred = [], $err = null, p, lbrack, len, elt; - /* */ try { $deferFrames.push($deferred); - p = this; - if (p.trace) { - $deferred.push([un, [trace(p, "ArrayType")]]); + while (r < n) { + if (os.IsPathSeparator(path.charCodeAt(r))) { + r = r + (1) >> 0; + } else if ((path.charCodeAt(r) === 46) && (((r + 1 >> 0) === n) || os.IsPathSeparator(path.charCodeAt((r + 1 >> 0))))) { + r = r + (1) >> 0; + } else if ((path.charCodeAt(r) === 46) && (path.charCodeAt((r + 1 >> 0)) === 46) && (((r + 2 >> 0) === n) || os.IsPathSeparator(path.charCodeAt((r + 2 >> 0))))) { + r = r + (2) >> 0; + if (out.w > dotdot) { + out.w = out.w - (1) >> 0; + while (out.w > dotdot && !os.IsPathSeparator(out.index(out.w))) { + out.w = out.w - (1) >> 0; + } + } else if (!rooted) { + if (out.w > 0) { + out.append(47); + } + out.append(46); + out.append(46); + dotdot = out.w; + } + } else { + if (rooted && !((out.w === 1)) || !rooted && !((out.w === 0))) { + out.append(47); + } + while (r < n && !os.IsPathSeparator(path.charCodeAt(r))) { + out.append(path.charCodeAt(r)); + r = r + (1) >> 0; + } + } } - lbrack = p.expect(50); - len = $ifaceNil; - if (p.tok === 48) { - len = new ast.Ellipsis.Ptr(p.pos, $ifaceNil); - p.next(); - } else if (!((p.tok === 55))) { - len = p.parseRhs(); + if (out.w === 0) { + out.append(46); } - p.expect(55); - elt = p.parseType(); - return new ast.ArrayType.Ptr(lbrack, len, elt); - /* */ } catch(err) { $err = err; return $ifaceNil; } finally { $deferFrames.pop(); $callDeferred($deferred, $err); } + return FromSlash(out.string()); }; - parser.prototype.parseArrayType = function() { return this.$val.parseArrayType(); }; - parser.Ptr.prototype.makeIdentList = function(list) { - var p, idents, _ref, _i, i, x, _tuple, ident, isIdent, _tuple$1, isBad; - p = this; - idents = ($sliceType(($ptrType(ast.Ident)))).make(list.$length); - _ref = list; + ToSlash = $pkg.ToSlash = function(path) { + return path; + return strings.Replace(path, "/", "/", -1); + }; + FromSlash = $pkg.FromSlash = function(path) { + return path; + return strings.Replace(path, "/", "/", -1); + }; + SplitList = $pkg.SplitList = function(path) { + return splitList(path); + }; + Split = $pkg.Split = function(path) { + var dir = "", file = "", vol, i, _tmp, _tmp$1; + vol = VolumeName(path); + i = path.length - 1 >> 0; + while (i >= vol.length && !os.IsPathSeparator(path.charCodeAt(i))) { + i = i - (1) >> 0; + } + _tmp = path.substring(0, (i + 1 >> 0)); _tmp$1 = path.substring((i + 1 >> 0)); dir = _tmp; file = _tmp$1; + return [dir, file]; + }; + Join = $pkg.Join = function(elem) { + var _ref, _i, i, e; + _ref = elem; _i = 0; while (_i < _ref.$length) { i = _i; - x = ((_i < 0 || _i >= _ref.$length) ? $throwRuntimeError("index out of range") : _ref.$array[_ref.$offset + _i]); - _tuple = $assertType(x, ($ptrType(ast.Ident)), true); ident = _tuple[0]; isIdent = _tuple[1]; - if (!isIdent) { - _tuple$1 = $assertType(x, ($ptrType(ast.BadExpr)), true); isBad = _tuple$1[1]; - if (!isBad) { - p.errorExpected(x.Pos(), "identifier"); - } - ident = new ast.Ident.Ptr(x.Pos(), "_", ($ptrType(ast.Object)).nil); + e = ((_i < 0 || _i >= _ref.$length) ? $throwRuntimeError("index out of range") : _ref.$array[_ref.$offset + _i]); + if (!(e === "")) { + return Clean(strings.Join($subslice(elem, i), "/")); } - (i < 0 || i >= idents.$length) ? $throwRuntimeError("index out of range") : idents.$array[idents.$offset + i] = ident; _i++; } - return idents; + return ""; }; - parser.prototype.makeIdentList = function(list) { return this.$val.makeIdentList(list); }; - parser.Ptr.prototype.parseFieldDecl = function(scope) { - var $deferred = [], $err = null, p, doc, _tuple, list, typ, tag, idents, n, pos, x, field; - /* */ try { $deferFrames.push($deferred); - p = this; - if (p.trace) { - $deferred.push([un, [trace(p, "FieldDecl")]]); - } - doc = p.leadComment; - _tuple = p.parseVarList(false); list = _tuple[0]; typ = _tuple[1]; - tag = ($ptrType(ast.BasicLit)).nil; - if (p.tok === 9) { - tag = new ast.BasicLit.Ptr(p.pos, p.tok, p.lit); - p.next(); - } - idents = ($sliceType(($ptrType(ast.Ident)))).nil; - if (!($interfaceIsEqual(typ, $ifaceNil))) { - idents = p.makeIdentList(list); - } else { - typ = ((0 < 0 || 0 >= list.$length) ? $throwRuntimeError("index out of range") : list.$array[list.$offset + 0]); - n = list.$length; - if (n > 1 || !isTypeName(deref(typ))) { - pos = typ.Pos(); - p.errorExpected(pos, "anonymous field"); - typ = new ast.BadExpr.Ptr(pos, p.safePos((x = n - 1 >> 0, ((x < 0 || x >= list.$length) ? $throwRuntimeError("index out of range") : list.$array[list.$offset + x])).End())); - } - } - p.expectSemi(); - field = new ast.Field.Ptr(doc, idents, typ, tag, p.lineComment); - p.declare(field, $ifaceNil, scope, 4, idents); - p.resolve(typ); - return field; - /* */ } catch(err) { $err = err; return ($ptrType(ast.Field)).nil; } finally { $deferFrames.pop(); $callDeferred($deferred, $err); } + EvalSymlinks = $pkg.EvalSymlinks = function(path) { + return evalSymlinks(path); }; - parser.prototype.parseFieldDecl = function(scope) { return this.$val.parseFieldDecl(scope); }; - parser.Ptr.prototype.parseStructType = function() { - var $deferred = [], $err = null, p, pos, lbrace, scope, list, rbrace; - /* */ try { $deferFrames.push($deferred); - p = this; - if (p.trace) { - $deferred.push([un, [trace(p, "StructType")]]); - } - pos = p.expect(82); - lbrace = p.expect(51); - scope = ast.NewScope(($ptrType(ast.Scope)).nil); - list = ($sliceType(($ptrType(ast.Field)))).nil; - while ((p.tok === 4) || (p.tok === 14) || (p.tok === 49)) { - list = $append(list, p.parseFieldDecl(scope)); - } - rbrace = p.expect(56); - return new ast.StructType.Ptr(pos, new ast.FieldList.Ptr(lbrace, list, rbrace), false); - /* */ } catch(err) { $err = err; return ($ptrType(ast.StructType)).nil; } finally { $deferFrames.pop(); $callDeferred($deferred, $err); } + VolumeName = $pkg.VolumeName = function(path) { + var v = ""; + v = path.substring(0, volumeNameLen(path)); + return v; }; - parser.prototype.parseStructType = function() { return this.$val.parseStructType(); }; - parser.Ptr.prototype.parsePointerType = function() { - var $deferred = [], $err = null, p, star, base; - /* */ try { $deferFrames.push($deferred); - p = this; - if (p.trace) { - $deferred.push([un, [trace(p, "PointerType")]]); - } - star = p.expect(14); - base = p.parseType(); - return new ast.StarExpr.Ptr(star, base); - /* */ } catch(err) { $err = err; return ($ptrType(ast.StarExpr)).nil; } finally { $deferFrames.pop(); $callDeferred($deferred, $err); } + IsAbs = $pkg.IsAbs = function(path) { + return strings.HasPrefix(path, "/"); }; - parser.prototype.parsePointerType = function() { return this.$val.parsePointerType(); }; - parser.Ptr.prototype.tryVarType = function(isParam) { - var p, pos, typ; - p = this; - if (isParam && (p.tok === 48)) { - pos = p.pos; - p.next(); - typ = p.tryIdentOrType(); - if (!($interfaceIsEqual(typ, $ifaceNil))) { - p.resolve(typ); - } else { - p.error(pos, "'...' parameter is missing type"); - typ = new ast.BadExpr.Ptr(pos, p.pos); - } - return new ast.Ellipsis.Ptr(pos, typ); - } - return p.tryIdentOrType(); + volumeNameLen = function(path) { + return 0; }; - parser.prototype.tryVarType = function(isParam) { return this.$val.tryVarType(isParam); }; - parser.Ptr.prototype.parseVarType = function(isParam) { - var p, typ, pos; - p = this; - typ = p.tryVarType(isParam); - if ($interfaceIsEqual(typ, $ifaceNil)) { - pos = p.pos; - p.errorExpected(pos, "type"); - p.next(); - typ = new ast.BadExpr.Ptr(pos, p.pos); + splitList = function(path) { + if (path === "") { + return new ($sliceType($String))([]); } - return typ; + return strings.Split(path, ":"); }; - parser.prototype.parseVarType = function(isParam) { return this.$val.parseVarType(isParam); }; - parser.Ptr.prototype.parseVarList = function(isParam) { - var list = ($sliceType(ast.Expr)).nil, typ = $ifaceNil, $deferred = [], $err = null, p, typ$1; - /* */ try { $deferFrames.push($deferred); - p = this; - if (p.trace) { - $deferred.push([un, [trace(p, "VarList")]]); - } - typ$1 = p.parseVarType(isParam); - while (!($interfaceIsEqual(typ$1, $ifaceNil))) { - list = $append(list, typ$1); - if (!((p.tok === 52))) { - break; + evalSymlinks = function(path) { + var originalPath, b, n, i, p, _tmp, _tmp$1, _tmp$2, _tmp$3, _tuple, fi, err, _tuple$1, dest; + originalPath = path; + b = new bytes.Buffer.Ptr(); $copy(b, new bytes.Buffer.Ptr(), bytes.Buffer); + n = 0; + while (!(path === "")) { + if (n > 255) { + return ["", errors.New("EvalSymlinks: too many links in " + originalPath)]; } - p.next(); - typ$1 = p.tryVarType(isParam); - } - typ = p.tryVarType(isParam); - return [list, typ]; - /* */ } catch(err) { $err = err; } finally { $deferFrames.pop(); $callDeferred($deferred, $err); return [list, typ]; } - }; - parser.prototype.parseVarList = function(isParam) { return this.$val.parseVarList(isParam); }; - parser.Ptr.prototype.parseParameterList = function(scope, ellipsisOk) { - var params = ($sliceType(($ptrType(ast.Field)))).nil, $deferred = [], $err = null, p, _tuple, list, typ, idents, field, idents$1, typ$1, field$1, _ref, _i, i, typ$2; - /* */ try { $deferFrames.push($deferred); - p = this; - if (p.trace) { - $deferred.push([un, [trace(p, "ParameterList")]]); - } - _tuple = p.parseVarList(ellipsisOk); list = _tuple[0]; typ = _tuple[1]; - if (!($interfaceIsEqual(typ, $ifaceNil))) { - idents = p.makeIdentList(list); - field = new ast.Field.Ptr(($ptrType(ast.CommentGroup)).nil, idents, typ, ($ptrType(ast.BasicLit)).nil, ($ptrType(ast.CommentGroup)).nil); - params = $append(params, field); - p.declare(field, $ifaceNil, scope, 4, idents); - p.resolve(typ); - if (p.tok === 52) { - p.next(); + i = strings.IndexRune(path, 47); + p = ""; + if (i === -1) { + _tmp = path; _tmp$1 = ""; p = _tmp; path = _tmp$1; + } else { + _tmp$2 = path.substring(0, i); _tmp$3 = path.substring((i + 1 >> 0)); p = _tmp$2; path = _tmp$3; } - while (!((p.tok === 54)) && !((p.tok === 1))) { - idents$1 = p.parseIdentList(); - typ$1 = p.parseVarType(ellipsisOk); - field$1 = new ast.Field.Ptr(($ptrType(ast.CommentGroup)).nil, idents$1, typ$1, ($ptrType(ast.BasicLit)).nil, ($ptrType(ast.CommentGroup)).nil); - params = $append(params, field$1); - p.declare(field$1, $ifaceNil, scope, 4, idents$1); - p.resolve(typ$1); - if (!p.atComma("parameter list")) { - break; + if (p === "") { + if (b.Len() === 0) { + b.WriteRune(47); } - p.next(); + n = n + (1) >> 0; + continue; } - } else { - params = ($sliceType(($ptrType(ast.Field)))).make(list.$length); - _ref = list; - _i = 0; - while (_i < _ref.$length) { - i = _i; - typ$2 = ((_i < 0 || _i >= _ref.$length) ? $throwRuntimeError("index out of range") : _ref.$array[_ref.$offset + _i]); - p.resolve(typ$2); - (i < 0 || i >= params.$length) ? $throwRuntimeError("index out of range") : params.$array[params.$offset + i] = new ast.Field.Ptr(($ptrType(ast.CommentGroup)).nil, ($sliceType(($ptrType(ast.Ident)))).nil, typ$2, ($ptrType(ast.BasicLit)).nil, ($ptrType(ast.CommentGroup)).nil); - _i++; + _tuple = os.Lstat(b.String() + p); fi = _tuple[0]; err = _tuple[1]; + if (!($interfaceIsEqual(err, $ifaceNil))) { + return ["", err]; } + if (((fi.Mode() & 134217728) >>> 0) === 0) { + b.WriteString(p); + if (!(path === "")) { + b.WriteRune(47); + } + n = n + (1) >> 0; + continue; + } + _tuple$1 = os.Readlink(b.String() + p); dest = _tuple$1[0]; err = _tuple$1[1]; + if (!($interfaceIsEqual(err, $ifaceNil))) { + return ["", err]; + } + if (IsAbs(dest)) { + b.Reset(); + } + path = dest + "/" + path; + n = n + (1) >> 0; } - return params; - /* */ } catch(err) { $err = err; } finally { $deferFrames.pop(); $callDeferred($deferred, $err); return params; } - }; - parser.prototype.parseParameterList = function(scope, ellipsisOk) { return this.$val.parseParameterList(scope, ellipsisOk); }; - parser.Ptr.prototype.parseParameters = function(scope, ellipsisOk) { - var $deferred = [], $err = null, p, params, lparen, rparen; - /* */ try { $deferFrames.push($deferred); - p = this; - if (p.trace) { - $deferred.push([un, [trace(p, "Parameters")]]); - } - params = ($sliceType(($ptrType(ast.Field)))).nil; - lparen = p.expect(49); - if (!((p.tok === 54))) { - params = p.parseParameterList(scope, ellipsisOk); - } - rparen = p.expect(54); - return new ast.FieldList.Ptr(lparen, params, rparen); - /* */ } catch(err) { $err = err; return ($ptrType(ast.FieldList)).nil; } finally { $deferFrames.pop(); $callDeferred($deferred, $err); } + return [Clean(b.String()), $ifaceNil]; }; - parser.prototype.parseParameters = function(scope, ellipsisOk) { return this.$val.parseParameters(scope, ellipsisOk); }; - parser.Ptr.prototype.parseResult = function(scope) { - var $deferred = [], $err = null, p, typ, list; - /* */ try { $deferFrames.push($deferred); - p = this; - if (p.trace) { - $deferred.push([un, [trace(p, "Result")]]); - } - if (p.tok === 49) { - return p.parseParameters(scope, false); - } - typ = p.tryType(); - if (!($interfaceIsEqual(typ, $ifaceNil))) { - list = ($sliceType(($ptrType(ast.Field)))).make(1); - (0 < 0 || 0 >= list.$length) ? $throwRuntimeError("index out of range") : list.$array[list.$offset + 0] = new ast.Field.Ptr(($ptrType(ast.CommentGroup)).nil, ($sliceType(($ptrType(ast.Ident)))).nil, typ, ($ptrType(ast.BasicLit)).nil, ($ptrType(ast.CommentGroup)).nil); - return new ast.FieldList.Ptr(0, list, 0); - } - return ($ptrType(ast.FieldList)).nil; - /* */ } catch(err) { $err = err; return ($ptrType(ast.FieldList)).nil; } finally { $deferFrames.pop(); $callDeferred($deferred, $err); } + $pkg.$init = function() { + ($ptrType(lazybuf)).methods = [["append", "append", "path/filepath", $funcType([$Uint8], [], false), -1], ["index", "index", "path/filepath", $funcType([$Int], [$Uint8], false), -1], ["string", "string", "path/filepath", $funcType([], [$String], false), -1]]; + lazybuf.init([["path", "path", "path/filepath", $String, ""], ["buf", "buf", "path/filepath", ($sliceType($Uint8)), ""], ["w", "w", "path/filepath", $Int, ""], ["volAndPath", "volAndPath", "path/filepath", $String, ""], ["volLen", "volLen", "path/filepath", $Int, ""]]); + $pkg.ErrBadPattern = errors.New("syntax error in pattern"); + $pkg.SkipDir = errors.New("skip this directory"); }; - parser.prototype.parseResult = function(scope) { return this.$val.parseResult(scope); }; - parser.Ptr.prototype.parseSignature = function(scope) { - var params = ($ptrType(ast.FieldList)).nil, results = ($ptrType(ast.FieldList)).nil, $deferred = [], $err = null, p; - /* */ try { $deferFrames.push($deferred); - p = this; - if (p.trace) { - $deferred.push([un, [trace(p, "Signature")]]); + return $pkg; +})(); +$packages["go/scanner"] = (function() { + var $pkg = {}, fmt = $packages["fmt"], token = $packages["go/token"], io = $packages["io"], sort = $packages["sort"], bytes = $packages["bytes"], filepath = $packages["path/filepath"], strconv = $packages["strconv"], unicode = $packages["unicode"], utf8 = $packages["unicode/utf8"], Error, ErrorList, ErrorHandler, Scanner, Mode, prefix, isLetter, isDigit, digitVal, stripCR; + Error = $pkg.Error = $newType(0, "Struct", "scanner.Error", "Error", "go/scanner", function(Pos_, Msg_) { + this.$val = this; + this.Pos = Pos_ !== undefined ? Pos_ : new token.Position.Ptr(); + this.Msg = Msg_ !== undefined ? Msg_ : ""; + }); + ErrorList = $pkg.ErrorList = $newType(12, "Slice", "scanner.ErrorList", "ErrorList", "go/scanner", null); + ErrorHandler = $pkg.ErrorHandler = $newType(4, "Func", "scanner.ErrorHandler", "ErrorHandler", "go/scanner", null); + Scanner = $pkg.Scanner = $newType(0, "Struct", "scanner.Scanner", "Scanner", "go/scanner", function(file_, dir_, src_, err_, mode_, ch_, offset_, rdOffset_, lineOffset_, insertSemi_, ErrorCount_) { + this.$val = this; + this.file = file_ !== undefined ? file_ : ($ptrType(token.File)).nil; + this.dir = dir_ !== undefined ? dir_ : ""; + this.src = src_ !== undefined ? src_ : ($sliceType($Uint8)).nil; + this.err = err_ !== undefined ? err_ : $throwNilPointerError; + this.mode = mode_ !== undefined ? mode_ : 0; + this.ch = ch_ !== undefined ? ch_ : 0; + this.offset = offset_ !== undefined ? offset_ : 0; + this.rdOffset = rdOffset_ !== undefined ? rdOffset_ : 0; + this.lineOffset = lineOffset_ !== undefined ? lineOffset_ : 0; + this.insertSemi = insertSemi_ !== undefined ? insertSemi_ : false; + this.ErrorCount = ErrorCount_ !== undefined ? ErrorCount_ : 0; + }); + Mode = $pkg.Mode = $newType(4, "Uint", "scanner.Mode", "Mode", "go/scanner", null); + Error.Ptr.prototype.Error = function() { + var e; + e = new Error.Ptr(); $copy(e, this, Error); + if (!(e.Pos.Filename === "") || e.Pos.IsValid()) { + return e.Pos.String() + ": " + e.Msg; } - params = p.parseParameters(scope, true); - results = p.parseResult(scope); - return [params, results]; - /* */ } catch(err) { $err = err; } finally { $deferFrames.pop(); $callDeferred($deferred, $err); return [params, results]; } + return e.Msg; }; - parser.prototype.parseSignature = function(scope) { return this.$val.parseSignature(scope); }; - parser.Ptr.prototype.parseFuncType = function() { - var $deferred = [], $err = null, p, pos, scope, _tuple, params, results; - /* */ try { $deferFrames.push($deferred); + Error.prototype.Error = function() { return this.$val.Error(); }; + $ptrType(ErrorList).prototype.Add = function(pos, msg) { + var p; p = this; - if (p.trace) { - $deferred.push([un, [trace(p, "FuncType")]]); - } - pos = p.expect(71); - scope = ast.NewScope(p.topScope); - _tuple = p.parseSignature(scope); params = _tuple[0]; results = _tuple[1]; - return [new ast.FuncType.Ptr(pos, params, results), scope]; - /* */ } catch(err) { $err = err; return [($ptrType(ast.FuncType)).nil, ($ptrType(ast.Scope)).nil]; } finally { $deferFrames.pop(); $callDeferred($deferred, $err); } + p.$set($append(p.$get(), new Error.Ptr(pos, msg))); }; - parser.prototype.parseFuncType = function() { return this.$val.parseFuncType(); }; - parser.Ptr.prototype.parseMethodSpec = function(scope) { - var $deferred = [], $err = null, p, doc, idents, typ, x, _tuple, ident, isIdent, scope$1, _tuple$1, params, results, spec; - /* */ try { $deferFrames.push($deferred); + $ptrType(ErrorList).prototype.Reset = function() { + var p; p = this; - if (p.trace) { - $deferred.push([un, [trace(p, "MethodSpec")]]); - } - doc = p.leadComment; - idents = ($sliceType(($ptrType(ast.Ident)))).nil; - typ = $ifaceNil; - x = p.parseTypeName(); - _tuple = $assertType(x, ($ptrType(ast.Ident)), true); ident = _tuple[0]; isIdent = _tuple[1]; - if (isIdent && (p.tok === 49)) { - idents = new ($sliceType(($ptrType(ast.Ident))))([ident]); - scope$1 = ast.NewScope(($ptrType(ast.Scope)).nil); - _tuple$1 = p.parseSignature(scope$1); params = _tuple$1[0]; results = _tuple$1[1]; - typ = new ast.FuncType.Ptr(0, params, results); - } else { - typ = x; - p.resolve(typ); - } - p.expectSemi(); - spec = new ast.Field.Ptr(doc, idents, typ, ($ptrType(ast.BasicLit)).nil, p.lineComment); - p.declare(spec, $ifaceNil, scope, 5, idents); - return spec; - /* */ } catch(err) { $err = err; return ($ptrType(ast.Field)).nil; } finally { $deferFrames.pop(); $callDeferred($deferred, $err); } + p.$set($subslice((p.$get()), 0, 0)); }; - parser.prototype.parseMethodSpec = function(scope) { return this.$val.parseMethodSpec(scope); }; - parser.Ptr.prototype.parseInterfaceType = function() { - var $deferred = [], $err = null, p, pos, lbrace, scope, list, rbrace; - /* */ try { $deferFrames.push($deferred); + ErrorList.prototype.Len = function() { + var p; p = this; - if (p.trace) { - $deferred.push([un, [trace(p, "InterfaceType")]]); - } - pos = p.expect(76); - lbrace = p.expect(51); - scope = ast.NewScope(($ptrType(ast.Scope)).nil); - list = ($sliceType(($ptrType(ast.Field)))).nil; - while (p.tok === 4) { - list = $append(list, p.parseMethodSpec(scope)); - } - rbrace = p.expect(56); - return new ast.InterfaceType.Ptr(pos, new ast.FieldList.Ptr(lbrace, list, rbrace), false); - /* */ } catch(err) { $err = err; return ($ptrType(ast.InterfaceType)).nil; } finally { $deferFrames.pop(); $callDeferred($deferred, $err); } + return p.$length; }; - parser.prototype.parseInterfaceType = function() { return this.$val.parseInterfaceType(); }; - parser.Ptr.prototype.parseMapType = function() { - var $deferred = [], $err = null, p, pos, key, value; - /* */ try { $deferFrames.push($deferred); + $ptrType(ErrorList).prototype.Len = function() { return this.$get().Len(); }; + ErrorList.prototype.Swap = function(i, j) { + var p, _tmp, _tmp$1; p = this; - if (p.trace) { - $deferred.push([un, [trace(p, "MapType")]]); - } - pos = p.expect(77); - p.expect(50); - key = p.parseType(); - p.expect(55); - value = p.parseType(); - return new ast.MapType.Ptr(pos, key, value); - /* */ } catch(err) { $err = err; return ($ptrType(ast.MapType)).nil; } finally { $deferFrames.pop(); $callDeferred($deferred, $err); } + _tmp = ((j < 0 || j >= p.$length) ? $throwRuntimeError("index out of range") : p.$array[p.$offset + j]); _tmp$1 = ((i < 0 || i >= p.$length) ? $throwRuntimeError("index out of range") : p.$array[p.$offset + i]); (i < 0 || i >= p.$length) ? $throwRuntimeError("index out of range") : p.$array[p.$offset + i] = _tmp; (j < 0 || j >= p.$length) ? $throwRuntimeError("index out of range") : p.$array[p.$offset + j] = _tmp$1; }; - parser.prototype.parseMapType = function() { return this.$val.parseMapType(); }; - parser.Ptr.prototype.parseChanType = function() { - var $deferred = [], $err = null, p, pos, dir, arrow, value; - /* */ try { $deferFrames.push($deferred); + $ptrType(ErrorList).prototype.Swap = function(i, j) { return this.$get().Swap(i, j); }; + ErrorList.prototype.Less = function(i, j) { + var p, e, f; p = this; - if (p.trace) { - $deferred.push([un, [trace(p, "ChanType")]]); + e = ((i < 0 || i >= p.$length) ? $throwRuntimeError("index out of range") : p.$array[p.$offset + i]).Pos; + f = ((j < 0 || j >= p.$length) ? $throwRuntimeError("index out of range") : p.$array[p.$offset + j]).Pos; + if (e.Filename < f.Filename) { + return true; } - pos = p.pos; - dir = 3; - arrow = 0; - if (p.tok === 63) { - p.next(); - if (p.tok === 36) { - arrow = p.pos; - p.next(); - dir = 1; + if (e.Filename === f.Filename) { + if (e.Line < f.Line) { + return true; + } + if (e.Line === f.Line) { + return e.Column < f.Column; } - } else { - arrow = p.expect(36); - p.expect(63); - dir = 2; } - value = p.parseType(); - return new ast.ChanType.Ptr(pos, arrow, dir, value); - /* */ } catch(err) { $err = err; return ($ptrType(ast.ChanType)).nil; } finally { $deferFrames.pop(); $callDeferred($deferred, $err); } + return false; }; - parser.prototype.parseChanType = function() { return this.$val.parseChanType(); }; - parser.Ptr.prototype.tryIdentOrType = function() { - var p, _ref, _tuple, typ, lparen, typ$1, rparen; + $ptrType(ErrorList).prototype.Less = function(i, j) { return this.$get().Less(i, j); }; + ErrorList.prototype.Sort = function() { + var p; p = this; - _ref = p.tok; - if (_ref === 4) { - return p.parseTypeName(); - } else if (_ref === 50) { - return p.parseArrayType(); - } else if (_ref === 82) { - return p.parseStructType(); - } else if (_ref === 14) { - return p.parsePointerType(); - } else if (_ref === 71) { - _tuple = p.parseFuncType(); typ = _tuple[0]; - return typ; - } else if (_ref === 76) { - return p.parseInterfaceType(); - } else if (_ref === 77) { - return p.parseMapType(); - } else if (_ref === 63 || _ref === 36) { - return p.parseChanType(); - } else if (_ref === 49) { - lparen = p.pos; - p.next(); - typ$1 = p.parseType(); - rparen = p.expect(54); - return new ast.ParenExpr.Ptr(lparen, typ$1, rparen); + sort.Sort(p); + }; + $ptrType(ErrorList).prototype.Sort = function() { return this.$get().Sort(); }; + $ptrType(ErrorList).prototype.RemoveMultiples = function() { + var p, last, i, _ref, _i, e, x; + p = this; + sort.Sort(p); + last = new token.Position.Ptr(); $copy(last, new token.Position.Ptr(), token.Position); + i = 0; + _ref = p.$get(); + _i = 0; + while (_i < _ref.$length) { + e = ((_i < 0 || _i >= _ref.$length) ? $throwRuntimeError("index out of range") : _ref.$array[_ref.$offset + _i]); + if (!(e.Pos.Filename === last.Filename) || !((e.Pos.Line === last.Line))) { + $copy(last, e.Pos, token.Position); + (x = p.$get(), (i < 0 || i >= x.$length) ? $throwRuntimeError("index out of range") : x.$array[x.$offset + i] = e); + i = i + (1) >> 0; + } + _i++; } - return $ifaceNil; + p.$set($subslice((p.$get()), 0, i)); }; - parser.prototype.tryIdentOrType = function() { return this.$val.tryIdentOrType(); }; - parser.Ptr.prototype.tryType = function() { - var p, typ; + ErrorList.prototype.Error = function() { + var p, _ref; p = this; - typ = p.tryIdentOrType(); - if (!($interfaceIsEqual(typ, $ifaceNil))) { - p.resolve(typ); + _ref = p.$length; + if (_ref === 0) { + return "no errors"; + } else if (_ref === 1) { + return ((0 < 0 || 0 >= p.$length) ? $throwRuntimeError("index out of range") : p.$array[p.$offset + 0]).Error(); } - return typ; + return fmt.Sprintf("%s (and %d more errors)", new ($sliceType($emptyInterface))([((0 < 0 || 0 >= p.$length) ? $throwRuntimeError("index out of range") : p.$array[p.$offset + 0]), new $Int((p.$length - 1 >> 0))])); }; - parser.prototype.tryType = function() { return this.$val.tryType(); }; - parser.Ptr.prototype.parseStmtList = function() { - var list = ($sliceType(ast.Stmt)).nil, $deferred = [], $err = null, p; - /* */ try { $deferFrames.push($deferred); + $ptrType(ErrorList).prototype.Error = function() { return this.$get().Error(); }; + ErrorList.prototype.Err = function() { + var p; p = this; - if (p.trace) { - $deferred.push([un, [trace(p, "StatementList")]]); + if (p.$length === 0) { + return $ifaceNil; } - while (!((p.tok === 62)) && !((p.tok === 66)) && !((p.tok === 56)) && !((p.tok === 1))) { - list = $append(list, p.parseStmt()); + return p; + }; + $ptrType(ErrorList).prototype.Err = function() { return this.$get().Err(); }; + Scanner.Ptr.prototype.next = function() { + var s, _tmp, x, x$1, _tmp$1, r, w, _tuple; + s = this; + if (s.rdOffset < s.src.$length) { + s.offset = s.rdOffset; + if (s.ch === 10) { + s.lineOffset = s.offset; + s.file.AddLine(s.offset); + } + _tmp = ((x = s.src, x$1 = s.rdOffset, ((x$1 < 0 || x$1 >= x.$length) ? $throwRuntimeError("index out of range") : x.$array[x.$offset + x$1])) >> 0); _tmp$1 = 1; r = _tmp; w = _tmp$1; + if (r === 0) { + s.error(s.offset, "illegal character NUL"); + } else if (r >= 128) { + _tuple = utf8.DecodeRune($subslice(s.src, s.rdOffset)); r = _tuple[0]; w = _tuple[1]; + if ((r === 65533) && (w === 1)) { + s.error(s.offset, "illegal UTF-8 encoding"); + } else if ((r === 65279) && s.offset > 0) { + s.error(s.offset, "illegal byte order mark"); + } + } + s.rdOffset = s.rdOffset + (w) >> 0; + s.ch = r; + } else { + s.offset = s.src.$length; + if (s.ch === 10) { + s.lineOffset = s.offset; + s.file.AddLine(s.offset); + } + s.ch = -1; } - return list; - /* */ } catch(err) { $err = err; } finally { $deferFrames.pop(); $callDeferred($deferred, $err); return list; } }; - parser.prototype.parseStmtList = function() { return this.$val.parseStmtList(); }; - parser.Ptr.prototype.parseBody = function(scope) { - var $deferred = [], $err = null, p, lbrace, list, rbrace; - /* */ try { $deferFrames.push($deferred); - p = this; - if (p.trace) { - $deferred.push([un, [trace(p, "Body")]]); + Scanner.prototype.next = function() { return this.$val.next(); }; + Scanner.Ptr.prototype.Init = function(file, src, err, mode) { + var s, _tuple; + s = this; + if (!((file.Size() === src.$length))) { + $panic(new $String(fmt.Sprintf("file size (%d) does not match src len (%d)", new ($sliceType($emptyInterface))([new $Int(file.Size()), new $Int(src.$length)])))); + } + s.file = file; + _tuple = filepath.Split(file.Name()); s.dir = _tuple[0]; + s.src = src; + s.err = err; + s.mode = mode; + s.ch = 32; + s.offset = 0; + s.rdOffset = 0; + s.lineOffset = 0; + s.insertSemi = false; + s.ErrorCount = 0; + s.next(); + if (s.ch === 65279) { + s.next(); } - lbrace = p.expect(51); - p.topScope = scope; - p.openLabelScope(); - list = p.parseStmtList(); - p.closeLabelScope(); - p.closeScope(); - rbrace = p.expect(56); - return new ast.BlockStmt.Ptr(lbrace, list, rbrace); - /* */ } catch(err) { $err = err; return ($ptrType(ast.BlockStmt)).nil; } finally { $deferFrames.pop(); $callDeferred($deferred, $err); } }; - parser.prototype.parseBody = function(scope) { return this.$val.parseBody(scope); }; - parser.Ptr.prototype.parseBlockStmt = function() { - var $deferred = [], $err = null, p, lbrace, list, rbrace; - /* */ try { $deferFrames.push($deferred); - p = this; - if (p.trace) { - $deferred.push([un, [trace(p, "BlockStmt")]]); + Scanner.prototype.Init = function(file, src, err, mode) { return this.$val.Init(file, src, err, mode); }; + Scanner.Ptr.prototype.error = function(offs, msg) { + var s; + s = this; + if (!(s.err === $throwNilPointerError)) { + s.err($clone(s.file.Position(s.file.Pos(offs)), token.Position), msg); } - lbrace = p.expect(51); - p.openScope(); - list = p.parseStmtList(); - p.closeScope(); - rbrace = p.expect(56); - return new ast.BlockStmt.Ptr(lbrace, list, rbrace); - /* */ } catch(err) { $err = err; return ($ptrType(ast.BlockStmt)).nil; } finally { $deferFrames.pop(); $callDeferred($deferred, $err); } + s.ErrorCount = s.ErrorCount + (1) >> 0; }; - parser.prototype.parseBlockStmt = function() { return this.$val.parseBlockStmt(); }; - parser.Ptr.prototype.parseFuncTypeOrLit = function() { - var $deferred = [], $err = null, p, _tuple, typ, scope, body; - /* */ try { $deferFrames.push($deferred); - p = this; - if (p.trace) { - $deferred.push([un, [trace(p, "FuncTypeOrLit")]]); + Scanner.prototype.error = function(offs, msg) { return this.$val.error(offs, msg); }; + Scanner.Ptr.prototype.interpretLineComment = function(text) { + var s, i, _tuple, line, err, filename; + s = this; + if (bytes.HasPrefix(text, prefix)) { + i = bytes.LastIndex(text, new ($sliceType($Uint8))([58])); + if (i > 0) { + _tuple = strconv.Atoi($bytesToString($subslice(text, (i + 1 >> 0)))); line = _tuple[0]; err = _tuple[1]; + if ($interfaceIsEqual(err, $ifaceNil) && line > 0) { + filename = $bytesToString(bytes.TrimSpace($subslice(text, prefix.$length, i))); + if (!(filename === "")) { + filename = filepath.Clean(filename); + if (!filepath.IsAbs(filename)) { + filename = filepath.Join(new ($sliceType($String))([s.dir, filename])); + } + } + s.file.AddLineInfo((s.lineOffset + text.$length >> 0) + 1 >> 0, filename, line); + } + } } - _tuple = p.parseFuncType(); typ = _tuple[0]; scope = _tuple[1]; - if (!((p.tok === 51))) { - return typ; + }; + Scanner.prototype.interpretLineComment = function(text) { return this.$val.interpretLineComment(text); }; + Scanner.Ptr.prototype.scanComment = function() { + var $this = this, $args = arguments, $s = 0, s, offs, hasCR, ch, lit; + /* */ while (true) { switch ($s) { case 0: + s = $this; + offs = s.offset - 1 >> 0; + hasCR = false; + /* if (s.ch === 47) { */ if (s.ch === 47) {} else { $s = 2; continue; } + s.next(); + while (!((s.ch === 10)) && s.ch >= 0) { + if (s.ch === 13) { + hasCR = true; + } + s.next(); + } + if (offs === s.lineOffset) { + s.interpretLineComment($subslice(s.src, offs, s.offset)); + } + /* goto exit */ $s = 1; continue; + /* } */ case 2: + s.next(); + /* while (s.ch >= 0) { */ case 3: if(!(s.ch >= 0)) { $s = 4; continue; } + ch = s.ch; + if (ch === 13) { + hasCR = true; + } + s.next(); + /* if ((ch === 42) && (s.ch === 47)) { */ if ((ch === 42) && (s.ch === 47)) {} else { $s = 5; continue; } + s.next(); + /* goto exit */ $s = 1; continue; + /* } */ case 5: + /* } */ $s = 3; continue; case 4: + s.error(offs, "comment not terminated"); + /* exit: */ case 1: + lit = $subslice(s.src, offs, s.offset); + if (hasCR) { + lit = stripCR(lit); } - p.exprLev = p.exprLev + (1) >> 0; - body = p.parseBody(scope); - p.exprLev = p.exprLev - (1) >> 0; - return new ast.FuncLit.Ptr(typ, body); - /* */ } catch(err) { $err = err; return $ifaceNil; } finally { $deferFrames.pop(); $callDeferred($deferred, $err); } + return $bytesToString(lit); + /* */ case -1: } return; } }; - parser.prototype.parseFuncTypeOrLit = function() { return this.$val.parseFuncTypeOrLit(); }; - parser.Ptr.prototype.parseOperand = function(lhs) { - var $deferred = [], $err = null, p, _ref, x, x$1, lparen, x$2, rparen, typ, _tuple, isIdent, pos; + Scanner.prototype.scanComment = function() { return this.$val.scanComment(); }; + Scanner.Ptr.prototype.findLineEnd = function() { + var $deferred = [], $err = null, s, ch; /* */ try { $deferFrames.push($deferred); - p = this; - if (p.trace) { - $deferred.push([un, [trace(p, "Operand")]]); - } - _ref = p.tok; - if (_ref === 4) { - x = p.parseIdent(); - if (!lhs) { - p.resolve(x); + s = this; + $deferred.push([(function(offs) { + s.ch = 47; + s.offset = offs; + s.rdOffset = offs + 1 >> 0; + s.next(); + }), [s.offset - 1 >> 0]]); + while ((s.ch === 47) || (s.ch === 42)) { + if (s.ch === 47) { + return true; } - return x; - } else if (_ref === 5 || _ref === 6 || _ref === 7 || _ref === 8 || _ref === 9) { - x$1 = new ast.BasicLit.Ptr(p.pos, p.tok, p.lit); - p.next(); - return x$1; - } else if (_ref === 49) { - lparen = p.pos; - p.next(); - p.exprLev = p.exprLev + (1) >> 0; - x$2 = p.parseRhsOrType(); - p.exprLev = p.exprLev - (1) >> 0; - rparen = p.expect(54); - return new ast.ParenExpr.Ptr(lparen, x$2, rparen); - } else if (_ref === 71) { - return p.parseFuncTypeOrLit(); - } - typ = p.tryIdentOrType(); - if (!($interfaceIsEqual(typ, $ifaceNil))) { - _tuple = $assertType(typ, ($ptrType(ast.Ident)), true); isIdent = _tuple[1]; - assert(!isIdent, "type cannot be identifier"); - return typ; + s.next(); + while (s.ch >= 0) { + ch = s.ch; + if (ch === 10) { + return true; + } + s.next(); + if ((ch === 42) && (s.ch === 47)) { + s.next(); + break; + } + } + s.skipWhitespace(); + if (s.ch < 0 || (s.ch === 10)) { + return true; + } + if (!((s.ch === 47))) { + return false; + } + s.next(); } - pos = p.pos; - p.errorExpected(pos, "operand"); - syncStmt(p); - return new ast.BadExpr.Ptr(pos, p.pos); - /* */ } catch(err) { $err = err; return $ifaceNil; } finally { $deferFrames.pop(); $callDeferred($deferred, $err); } + return false; + /* */ } catch(err) { $err = err; return false; } finally { $deferFrames.pop(); $callDeferred($deferred, $err); } }; - parser.prototype.parseOperand = function(lhs) { return this.$val.parseOperand(lhs); }; - parser.Ptr.prototype.parseSelector = function(x) { - var $deferred = [], $err = null, p, sel; - /* */ try { $deferFrames.push($deferred); - p = this; - if (p.trace) { - $deferred.push([un, [trace(p, "Selector")]]); + Scanner.prototype.findLineEnd = function() { return this.$val.findLineEnd(); }; + isLetter = function(ch) { + return 97 <= ch && ch <= 122 || 65 <= ch && ch <= 90 || (ch === 95) || ch >= 128 && unicode.IsLetter(ch); + }; + isDigit = function(ch) { + return 48 <= ch && ch <= 57 || ch >= 128 && unicode.IsDigit(ch); + }; + Scanner.Ptr.prototype.scanIdentifier = function() { + var s, offs; + s = this; + offs = s.offset; + while (isLetter(s.ch) || isDigit(s.ch)) { + s.next(); } - sel = p.parseIdent(); - return new ast.SelectorExpr.Ptr(x, sel); - /* */ } catch(err) { $err = err; return $ifaceNil; } finally { $deferFrames.pop(); $callDeferred($deferred, $err); } + return $bytesToString($subslice(s.src, offs, s.offset)); }; - parser.prototype.parseSelector = function(x) { return this.$val.parseSelector(x); }; - parser.Ptr.prototype.parseTypeAssertion = function(x) { - var $deferred = [], $err = null, p, lparen, typ, rparen; - /* */ try { $deferFrames.push($deferred); - p = this; - if (p.trace) { - $deferred.push([un, [trace(p, "TypeAssertion")]]); + Scanner.prototype.scanIdentifier = function() { return this.$val.scanIdentifier(); }; + digitVal = function(ch) { + if (48 <= ch && ch <= 57) { + return ((ch - 48 >> 0) >> 0); + } else if (97 <= ch && ch <= 102) { + return (((ch - 97 >> 0) + 10 >> 0) >> 0); + } else if (65 <= ch && ch <= 70) { + return (((ch - 65 >> 0) + 10 >> 0) >> 0); } - lparen = p.expect(49); - typ = $ifaceNil; - if (p.tok === 84) { - p.next(); - } else { - typ = p.parseType(); + return 16; + }; + Scanner.Ptr.prototype.scanMantissa = function(base) { + var s; + s = this; + while (digitVal(s.ch) < base) { + s.next(); } - rparen = p.expect(54); - return new ast.TypeAssertExpr.Ptr(x, lparen, typ, rparen); - /* */ } catch(err) { $err = err; return $ifaceNil; } finally { $deferFrames.pop(); $callDeferred($deferred, $err); } }; - parser.prototype.parseTypeAssertion = function(x) { return this.$val.parseTypeAssertion(x); }; - parser.Ptr.prototype.parseIndexOrSlice = function(x) { - var $deferred = [], $err = null, p, lbrack, index, colons, ncolons, rbrack, slice3; - /* */ try { $deferFrames.push($deferred); - p = this; - if (p.trace) { - $deferred.push([un, [trace(p, "IndexOrSlice")]]); + Scanner.prototype.scanMantissa = function(base) { return this.$val.scanMantissa(base); }; + Scanner.Ptr.prototype.scanNumber = function(seenDecimalPoint) { + var $this = this, $args = arguments, $s = 0, s, offs, tok, offs$1, seenDecimalDigit; + /* */ while (true) { switch ($s) { case 0: + s = $this; + offs = s.offset; + tok = 5; + /* if (seenDecimalPoint) { */ if (seenDecimalPoint) {} else { $s = 4; continue; } + offs = offs - (1) >> 0; + tok = 6; + s.scanMantissa(10); + /* goto exponent */ $s = 1; continue; + /* } */ case 4: + /* if (s.ch === 48) { */ if (s.ch === 48) {} else { $s = 5; continue; } + offs$1 = s.offset; + s.next(); + /* if ((s.ch === 120) || (s.ch === 88)) { */ if ((s.ch === 120) || (s.ch === 88)) {} else { $s = 6; continue; } + s.next(); + s.scanMantissa(16); + if ((s.offset - offs$1 >> 0) <= 2) { + s.error(offs$1, "illegal hexadecimal number"); + } + /* } else { */ $s = 7; continue; case 6: + seenDecimalDigit = false; + s.scanMantissa(8); + if ((s.ch === 56) || (s.ch === 57)) { + seenDecimalDigit = true; + s.scanMantissa(10); + } + /* if ((s.ch === 46) || (s.ch === 101) || (s.ch === 69) || (s.ch === 105)) { */ if ((s.ch === 46) || (s.ch === 101) || (s.ch === 69) || (s.ch === 105)) {} else { $s = 8; continue; } + /* goto fraction */ $s = 2; continue; + /* } */ case 8: + if (seenDecimalDigit) { + s.error(offs$1, "illegal octal number"); + } + /* } */ case 7: + /* goto exit */ $s = 3; continue; + /* } */ case 5: + s.scanMantissa(10); + /* fraction: */ case 2: + if (s.ch === 46) { + tok = 6; + s.next(); + s.scanMantissa(10); } - lbrack = p.expect(50); - p.exprLev = p.exprLev + (1) >> 0; - index = ($arrayType(ast.Expr, 3)).zero(); $copy(index, ($arrayType(ast.Expr, 3)).zero(), ($arrayType(ast.Expr, 3))); - colons = ($arrayType(token.Pos, 2)).zero(); $copy(colons, ($arrayType(token.Pos, 2)).zero(), ($arrayType(token.Pos, 2))); - if (!((p.tok === 58))) { - index[0] = p.parseRhs(); + /* exponent: */ case 1: + if ((s.ch === 101) || (s.ch === 69)) { + tok = 6; + s.next(); + if ((s.ch === 45) || (s.ch === 43)) { + s.next(); + } + s.scanMantissa(10); } - ncolons = 0; - while ((p.tok === 58) && ncolons < 2) { - (ncolons < 0 || ncolons >= colons.length) ? $throwRuntimeError("index out of range") : colons[ncolons] = p.pos; - ncolons = ncolons + (1) >> 0; - p.next(); - if (!((p.tok === 58)) && !((p.tok === 55)) && !((p.tok === 1))) { - (ncolons < 0 || ncolons >= index.length) ? $throwRuntimeError("index out of range") : index[ncolons] = p.parseRhs(); + if (s.ch === 105) { + tok = 7; + s.next(); + } + /* exit: */ case 3: + return [tok, $bytesToString($subslice(s.src, offs, s.offset))]; + /* */ case -1: } return; } + }; + Scanner.prototype.scanNumber = function(seenDecimalPoint) { return this.$val.scanNumber(seenDecimalPoint); }; + Scanner.Ptr.prototype.scanEscape = function(quote) { + var s, offs, n, _tmp, _tmp$1, base, max, _ref, _tmp$2, _tmp$3, _tmp$4, _tmp$5, _tmp$6, _tmp$7, _tmp$8, _tmp$9, _tmp$10, _tmp$11, _tmp$12, _tmp$13, msg, x, d, msg$1; + s = this; + offs = s.offset; + n = 0; + _tmp = 0; _tmp$1 = 0; base = _tmp; max = _tmp$1; + _ref = s.ch; + if (_ref === 97 || _ref === 98 || _ref === 102 || _ref === 110 || _ref === 114 || _ref === 116 || _ref === 118 || _ref === 92 || _ref === quote) { + s.next(); + return true; + } else if (_ref === 48 || _ref === 49 || _ref === 50 || _ref === 51 || _ref === 52 || _ref === 53 || _ref === 54 || _ref === 55) { + _tmp$2 = 3; _tmp$3 = 8; _tmp$4 = 255; n = _tmp$2; base = _tmp$3; max = _tmp$4; + } else if (_ref === 120) { + s.next(); + _tmp$5 = 2; _tmp$6 = 16; _tmp$7 = 255; n = _tmp$5; base = _tmp$6; max = _tmp$7; + } else if (_ref === 117) { + s.next(); + _tmp$8 = 4; _tmp$9 = 16; _tmp$10 = 1114111; n = _tmp$8; base = _tmp$9; max = _tmp$10; + } else if (_ref === 85) { + s.next(); + _tmp$11 = 8; _tmp$12 = 16; _tmp$13 = 1114111; n = _tmp$11; base = _tmp$12; max = _tmp$13; + } else { + msg = "unknown escape sequence"; + if (s.ch < 0) { + msg = "escape sequence not terminated"; } + s.error(offs, msg); + return false; } - p.exprLev = p.exprLev - (1) >> 0; - rbrack = p.expect(55); - if (ncolons > 0) { - slice3 = false; - if (ncolons === 2) { - slice3 = true; - if ($interfaceIsEqual(index[1], $ifaceNil)) { - p.error(colons[0], "2nd index required in 3-index slice"); - index[1] = new ast.BadExpr.Ptr(colons[0] + 1 >> 0, colons[1]); - } - if ($interfaceIsEqual(index[2], $ifaceNil)) { - p.error(colons[1], "3rd index required in 3-index slice"); - index[2] = new ast.BadExpr.Ptr(colons[1] + 1 >> 0, rbrack); + x = 0; + while (n > 0) { + d = (digitVal(s.ch) >>> 0); + if (d >= base) { + msg$1 = fmt.Sprintf("illegal character %#U in escape sequence", new ($sliceType($emptyInterface))([new $Int32(s.ch)])); + if (s.ch < 0) { + msg$1 = "escape sequence not terminated"; } + s.error(s.offset, msg$1); + return false; } - return new ast.SliceExpr.Ptr(x, lbrack, index[0], index[1], index[2], slice3, rbrack); + x = ((((x >>> 16 << 16) * base >>> 0) + (x << 16 >>> 16) * base) >>> 0) + d >>> 0; + s.next(); + n = n - (1) >> 0; } - return new ast.IndexExpr.Ptr(x, lbrack, index[0], rbrack); - /* */ } catch(err) { $err = err; return $ifaceNil; } finally { $deferFrames.pop(); $callDeferred($deferred, $err); } - }; - parser.prototype.parseIndexOrSlice = function(x) { return this.$val.parseIndexOrSlice(x); }; - parser.Ptr.prototype.parseCallOrConversion = function(fun) { - var $deferred = [], $err = null, p, lparen, list, ellipsis, rparen; - /* */ try { $deferFrames.push($deferred); - p = this; - if (p.trace) { - $deferred.push([un, [trace(p, "CallOrConversion")]]); + if (x > max || 55296 <= x && x < 57344) { + s.error(offs, "escape sequence is invalid Unicode code point"); + return false; } - lparen = p.expect(49); - p.exprLev = p.exprLev + (1) >> 0; - list = ($sliceType(ast.Expr)).nil; - ellipsis = 0; - while (!((p.tok === 54)) && !((p.tok === 1)) && !(new token.Pos(ellipsis)).IsValid()) { - list = $append(list, p.parseRhsOrType()); - if (p.tok === 48) { - ellipsis = p.pos; - p.next(); + return true; + }; + Scanner.prototype.scanEscape = function(quote) { return this.$val.scanEscape(quote); }; + Scanner.Ptr.prototype.scanRune = function() { + var s, offs, valid, n, ch; + s = this; + offs = s.offset - 1 >> 0; + valid = true; + n = 0; + while (true) { + ch = s.ch; + if ((ch === 10) || ch < 0) { + if (valid) { + s.error(offs, "rune literal not terminated"); + valid = false; + } + break; + } + s.next(); + if (ch === 39) { + break; + } + n = n + (1) >> 0; + if (ch === 92) { + if (!s.scanEscape(39)) { + valid = false; + } } - if (!p.atComma("argument list")) { + } + if (valid && !((n === 1))) { + s.error(offs, "illegal rune literal"); + } + return $bytesToString($subslice(s.src, offs, s.offset)); + }; + Scanner.prototype.scanRune = function() { return this.$val.scanRune(); }; + Scanner.Ptr.prototype.scanString = function() { + var s, offs, ch; + s = this; + offs = s.offset - 1 >> 0; + while (true) { + ch = s.ch; + if ((ch === 10) || ch < 0) { + s.error(offs, "string literal not terminated"); break; } - p.next(); + s.next(); + if (ch === 34) { + break; + } + if (ch === 92) { + s.scanEscape(34); + } } - p.exprLev = p.exprLev - (1) >> 0; - rparen = p.expectClosing(54, "argument list"); - return new ast.CallExpr.Ptr(fun, lparen, list, ellipsis, rparen); - /* */ } catch(err) { $err = err; return ($ptrType(ast.CallExpr)).nil; } finally { $deferFrames.pop(); $callDeferred($deferred, $err); } + return $bytesToString($subslice(s.src, offs, s.offset)); }; - parser.prototype.parseCallOrConversion = function(fun) { return this.$val.parseCallOrConversion(fun); }; - parser.Ptr.prototype.parseElement = function(keyOk) { - var $deferred = [], $err = null, p, x, colon; - /* */ try { $deferFrames.push($deferred); - p = this; - if (p.trace) { - $deferred.push([un, [trace(p, "Element")]]); - } - if (p.tok === 51) { - return p.parseLiteralValue($ifaceNil); - } - x = p.checkExpr(p.parseExpr(keyOk)); - if (keyOk) { - if (p.tok === 58) { - colon = p.pos; - p.next(); - p.tryResolve(x, false); - return new ast.KeyValueExpr.Ptr(x, colon, p.parseElement(false)); + Scanner.prototype.scanString = function() { return this.$val.scanString(); }; + stripCR = function(b) { + var c, i, _ref, _i, ch; + c = ($sliceType($Uint8)).make(b.$length); + i = 0; + _ref = b; + _i = 0; + while (_i < _ref.$length) { + ch = ((_i < 0 || _i >= _ref.$length) ? $throwRuntimeError("index out of range") : _ref.$array[_ref.$offset + _i]); + if (!((ch === 13))) { + (i < 0 || i >= c.$length) ? $throwRuntimeError("index out of range") : c.$array[c.$offset + i] = ch; + i = i + (1) >> 0; } - p.resolve(x); + _i++; } - return x; - /* */ } catch(err) { $err = err; return $ifaceNil; } finally { $deferFrames.pop(); $callDeferred($deferred, $err); } + return $subslice(c, 0, i); }; - parser.prototype.parseElement = function(keyOk) { return this.$val.parseElement(keyOk); }; - parser.Ptr.prototype.parseElementList = function() { - var list = ($sliceType(ast.Expr)).nil, $deferred = [], $err = null, p; - /* */ try { $deferFrames.push($deferred); - p = this; - if (p.trace) { - $deferred.push([un, [trace(p, "ElementList")]]); - } - while (!((p.tok === 56)) && !((p.tok === 1))) { - list = $append(list, p.parseElement(true)); - if (!p.atComma("composite literal")) { + Scanner.Ptr.prototype.scanRawString = function() { + var s, offs, hasCR, ch, lit; + s = this; + offs = s.offset - 1 >> 0; + hasCR = false; + while (true) { + ch = s.ch; + if (ch < 0) { + s.error(offs, "raw string literal not terminated"); break; } - p.next(); - } - return list; - /* */ } catch(err) { $err = err; } finally { $deferFrames.pop(); $callDeferred($deferred, $err); return list; } - }; - parser.prototype.parseElementList = function() { return this.$val.parseElementList(); }; - parser.Ptr.prototype.parseLiteralValue = function(typ) { - var $deferred = [], $err = null, p, lbrace, elts, rbrace; - /* */ try { $deferFrames.push($deferred); - p = this; - if (p.trace) { - $deferred.push([un, [trace(p, "LiteralValue")]]); + s.next(); + if (ch === 96) { + break; + } + if (ch === 13) { + hasCR = true; + } } - lbrace = p.expect(51); - elts = ($sliceType(ast.Expr)).nil; - p.exprLev = p.exprLev + (1) >> 0; - if (!((p.tok === 56))) { - elts = p.parseElementList(); + lit = $subslice(s.src, offs, s.offset); + if (hasCR) { + lit = stripCR(lit); } - p.exprLev = p.exprLev - (1) >> 0; - rbrace = p.expectClosing(56, "composite literal"); - return new ast.CompositeLit.Ptr(typ, lbrace, elts, rbrace); - /* */ } catch(err) { $err = err; return $ifaceNil; } finally { $deferFrames.pop(); $callDeferred($deferred, $err); } + return $bytesToString(lit); }; - parser.prototype.parseLiteralValue = function(typ) { return this.$val.parseLiteralValue(typ); }; - parser.Ptr.prototype.checkExpr = function(x) { - var p, _ref; - p = this; - _ref = unparen(x); - if ($assertType(_ref, ($ptrType(ast.BadExpr)), true)[1]) { - } else if ($assertType(_ref, ($ptrType(ast.Ident)), true)[1]) { - } else if ($assertType(_ref, ($ptrType(ast.BasicLit)), true)[1]) { - } else if ($assertType(_ref, ($ptrType(ast.FuncLit)), true)[1]) { - } else if ($assertType(_ref, ($ptrType(ast.CompositeLit)), true)[1]) { - } else if ($assertType(_ref, ($ptrType(ast.ParenExpr)), true)[1]) { - $panic(new $String("unreachable")); - } else if ($assertType(_ref, ($ptrType(ast.SelectorExpr)), true)[1]) { - } else if ($assertType(_ref, ($ptrType(ast.IndexExpr)), true)[1]) { - } else if ($assertType(_ref, ($ptrType(ast.SliceExpr)), true)[1]) { - } else if ($assertType(_ref, ($ptrType(ast.TypeAssertExpr)), true)[1]) { - } else if ($assertType(_ref, ($ptrType(ast.CallExpr)), true)[1]) { - } else if ($assertType(_ref, ($ptrType(ast.StarExpr)), true)[1]) { - } else if ($assertType(_ref, ($ptrType(ast.UnaryExpr)), true)[1]) { - } else if ($assertType(_ref, ($ptrType(ast.BinaryExpr)), true)[1]) { - } else { - p.errorExpected(x.Pos(), "expression"); - x = new ast.BadExpr.Ptr(x.Pos(), p.safePos(x.End())); + Scanner.prototype.scanRawString = function() { return this.$val.scanRawString(); }; + Scanner.Ptr.prototype.skipWhitespace = function() { + var s; + s = this; + while ((s.ch === 32) || (s.ch === 9) || (s.ch === 10) && !s.insertSemi || (s.ch === 13)) { + s.next(); } - return x; }; - parser.prototype.checkExpr = function(x) { return this.$val.checkExpr(x); }; - isTypeName = function(x) { - var t, _ref, _tuple, isIdent; - _ref = x; - if ($assertType(_ref, ($ptrType(ast.BadExpr)), true)[1]) { - t = _ref.$val; - } else if ($assertType(_ref, ($ptrType(ast.Ident)), true)[1]) { - t = _ref.$val; - } else if ($assertType(_ref, ($ptrType(ast.SelectorExpr)), true)[1]) { - t = _ref.$val; - _tuple = $assertType(t.X, ($ptrType(ast.Ident)), true); isIdent = _tuple[1]; - return isIdent; - } else { - t = _ref; - return false; + Scanner.prototype.skipWhitespace = function() { return this.$val.skipWhitespace(); }; + Scanner.Ptr.prototype.switch2 = function(tok0, tok1) { + var s; + s = this; + if (s.ch === 61) { + s.next(); + return tok1; } - return true; + return tok0; }; - isLiteralType = function(x) { - var t, _ref, _tuple, isIdent; - _ref = x; - if ($assertType(_ref, ($ptrType(ast.BadExpr)), true)[1]) { - t = _ref.$val; - } else if ($assertType(_ref, ($ptrType(ast.Ident)), true)[1]) { - t = _ref.$val; - } else if ($assertType(_ref, ($ptrType(ast.SelectorExpr)), true)[1]) { - t = _ref.$val; - _tuple = $assertType(t.X, ($ptrType(ast.Ident)), true); isIdent = _tuple[1]; - return isIdent; - } else if ($assertType(_ref, ($ptrType(ast.ArrayType)), true)[1]) { - t = _ref.$val; - } else if ($assertType(_ref, ($ptrType(ast.StructType)), true)[1]) { - t = _ref.$val; - } else if ($assertType(_ref, ($ptrType(ast.MapType)), true)[1]) { - t = _ref.$val; - } else { - t = _ref; - return false; + Scanner.prototype.switch2 = function(tok0, tok1) { return this.$val.switch2(tok0, tok1); }; + Scanner.Ptr.prototype.switch3 = function(tok0, tok1, ch2, tok2) { + var s; + s = this; + if (s.ch === 61) { + s.next(); + return tok1; } - return true; + if (s.ch === ch2) { + s.next(); + return tok2; + } + return tok0; }; - deref = function(x) { - var _tuple, p, isPtr; - _tuple = $assertType(x, ($ptrType(ast.StarExpr)), true); p = _tuple[0]; isPtr = _tuple[1]; - if (isPtr) { - x = p.X; + Scanner.prototype.switch3 = function(tok0, tok1, ch2, tok2) { return this.$val.switch3(tok0, tok1, ch2, tok2); }; + Scanner.Ptr.prototype.switch4 = function(tok0, tok1, ch2, tok2, tok3) { + var s; + s = this; + if (s.ch === 61) { + s.next(); + return tok1; } - return x; + if (s.ch === ch2) { + s.next(); + if (s.ch === 61) { + s.next(); + return tok3; + } + return tok2; + } + return tok0; }; - unparen = function(x) { - var _tuple, p, isParen; - _tuple = $assertType(x, ($ptrType(ast.ParenExpr)), true); p = _tuple[0]; isParen = _tuple[1]; - if (isParen) { - x = unparen(p.X); + Scanner.prototype.switch4 = function(tok0, tok1, ch2, tok2, tok3) { return this.$val.switch4(tok0, tok1, ch2, tok2, tok3); }; + Scanner.Ptr.prototype.Scan = function() { + var $this = this, $args = arguments, pos = 0, tok = 0, lit = "", $s = 0, s, insertSemi, ch, _ref, _tuple, _ref$1, _tmp, _tmp$1, _tmp$2, _tmp$3, _tmp$4, _tmp$5, _tuple$1, _tmp$6, _tmp$7, _tmp$8; + /* */ while (true) { switch ($s) { case 0: + s = $this; + /* scanAgain: */ case 1: + s.skipWhitespace(); + pos = s.file.Pos(s.offset); + insertSemi = false; + ch = s.ch; + /* if (isLetter(ch)) { */ if (isLetter(ch)) {} else if (48 <= ch && ch <= 57) { $s = 2; continue; } else { $s = 3; continue; } + lit = s.scanIdentifier(); + if (lit.length > 1) { + tok = token.Lookup(lit); + _ref = tok; + if (_ref === 4 || _ref === 61 || _ref === 65 || _ref === 69 || _ref === 80) { + insertSemi = true; + } + } else { + insertSemi = true; + tok = 4; + } + /* } else if (48 <= ch && ch <= 57) { */ $s = 4; continue; case 2: + insertSemi = true; + _tuple = s.scanNumber(false); tok = _tuple[0]; lit = _tuple[1]; + /* } else { */ $s = 4; continue; case 3: + s.next(); + _ref$1 = ch; + /* if (_ref$1 === -1) { */ if (_ref$1 === -1) {} else if (_ref$1 === 10) { $s = 5; continue; } else if (_ref$1 === 34) { $s = 6; continue; } else if (_ref$1 === 39) { $s = 7; continue; } else if (_ref$1 === 96) { $s = 8; continue; } else if (_ref$1 === 58) { $s = 9; continue; } else if (_ref$1 === 46) { $s = 10; continue; } else if (_ref$1 === 44) { $s = 11; continue; } else if (_ref$1 === 59) { $s = 12; continue; } else if (_ref$1 === 40) { $s = 13; continue; } else if (_ref$1 === 41) { $s = 14; continue; } else if (_ref$1 === 91) { $s = 15; continue; } else if (_ref$1 === 93) { $s = 16; continue; } else if (_ref$1 === 123) { $s = 17; continue; } else if (_ref$1 === 125) { $s = 18; continue; } else if (_ref$1 === 43) { $s = 19; continue; } else if (_ref$1 === 45) { $s = 20; continue; } else if (_ref$1 === 42) { $s = 21; continue; } else if (_ref$1 === 47) { $s = 22; continue; } else if (_ref$1 === 37) { $s = 23; continue; } else if (_ref$1 === 94) { $s = 24; continue; } else if (_ref$1 === 60) { $s = 25; continue; } else if (_ref$1 === 62) { $s = 26; continue; } else if (_ref$1 === 61) { $s = 27; continue; } else if (_ref$1 === 33) { $s = 28; continue; } else if (_ref$1 === 38) { $s = 29; continue; } else if (_ref$1 === 124) { $s = 30; continue; } else { $s = 31; continue; } + if (s.insertSemi) { + s.insertSemi = false; + _tmp = pos; _tmp$1 = 57; _tmp$2 = "\n"; pos = _tmp; tok = _tmp$1; lit = _tmp$2; + return [pos, tok, lit]; + } + tok = 1; + /* } else if (_ref$1 === 10) { */ $s = 32; continue; case 5: + s.insertSemi = false; + _tmp$3 = pos; _tmp$4 = 57; _tmp$5 = "\n"; pos = _tmp$3; tok = _tmp$4; lit = _tmp$5; + return [pos, tok, lit]; + /* } else if (_ref$1 === 34) { */ $s = 32; continue; case 6: + insertSemi = true; + tok = 9; + lit = s.scanString(); + /* } else if (_ref$1 === 39) { */ $s = 32; continue; case 7: + insertSemi = true; + tok = 8; + lit = s.scanRune(); + /* } else if (_ref$1 === 96) { */ $s = 32; continue; case 8: + insertSemi = true; + tok = 9; + lit = s.scanRawString(); + /* } else if (_ref$1 === 58) { */ $s = 32; continue; case 9: + tok = s.switch2(58, 47); + /* } else if (_ref$1 === 46) { */ $s = 32; continue; case 10: + if (48 <= s.ch && s.ch <= 57) { + insertSemi = true; + _tuple$1 = s.scanNumber(true); tok = _tuple$1[0]; lit = _tuple$1[1]; + } else if (s.ch === 46) { + s.next(); + if (s.ch === 46) { + s.next(); + tok = 48; + } + } else { + tok = 53; + } + /* } else if (_ref$1 === 44) { */ $s = 32; continue; case 11: + tok = 52; + /* } else if (_ref$1 === 59) { */ $s = 32; continue; case 12: + tok = 57; + lit = ";"; + /* } else if (_ref$1 === 40) { */ $s = 32; continue; case 13: + tok = 49; + /* } else if (_ref$1 === 41) { */ $s = 32; continue; case 14: + insertSemi = true; + tok = 54; + /* } else if (_ref$1 === 91) { */ $s = 32; continue; case 15: + tok = 50; + /* } else if (_ref$1 === 93) { */ $s = 32; continue; case 16: + insertSemi = true; + tok = 55; + /* } else if (_ref$1 === 123) { */ $s = 32; continue; case 17: + tok = 51; + /* } else if (_ref$1 === 125) { */ $s = 32; continue; case 18: + insertSemi = true; + tok = 56; + /* } else if (_ref$1 === 43) { */ $s = 32; continue; case 19: + tok = s.switch3(12, 23, 43, 37); + if (tok === 37) { + insertSemi = true; + } + /* } else if (_ref$1 === 45) { */ $s = 32; continue; case 20: + tok = s.switch3(13, 24, 45, 38); + if (tok === 38) { + insertSemi = true; + } + /* } else if (_ref$1 === 42) { */ $s = 32; continue; case 21: + tok = s.switch2(14, 25); + /* } else if (_ref$1 === 47) { */ $s = 32; continue; case 22: + /* if ((s.ch === 47) || (s.ch === 42)) { */ if ((s.ch === 47) || (s.ch === 42)) {} else { $s = 33; continue; } + if (s.insertSemi && s.findLineEnd()) { + s.ch = 47; + s.offset = s.file.Offset(pos); + s.rdOffset = s.offset + 1 >> 0; + s.insertSemi = false; + _tmp$6 = pos; _tmp$7 = 57; _tmp$8 = "\n"; pos = _tmp$6; tok = _tmp$7; lit = _tmp$8; + return [pos, tok, lit]; + } + lit = s.scanComment(); + /* if (((s.mode & 1) >>> 0) === 0) { */ if (((s.mode & 1) >>> 0) === 0) {} else { $s = 35; continue; } + s.insertSemi = false; + /* goto scanAgain */ $s = 1; continue; + /* } */ case 35: + tok = 2; + /* } else { */ $s = 34; continue; case 33: + tok = s.switch2(15, 26); + /* } */ case 34: + /* } else if (_ref$1 === 37) { */ $s = 32; continue; case 23: + tok = s.switch2(16, 27); + /* } else if (_ref$1 === 94) { */ $s = 32; continue; case 24: + tok = s.switch2(19, 30); + /* } else if (_ref$1 === 60) { */ $s = 32; continue; case 25: + if (s.ch === 45) { + s.next(); + tok = 36; + } else { + tok = s.switch4(40, 45, 60, 20, 31); + } + /* } else if (_ref$1 === 62) { */ $s = 32; continue; case 26: + tok = s.switch4(41, 46, 62, 21, 32); + /* } else if (_ref$1 === 61) { */ $s = 32; continue; case 27: + tok = s.switch2(42, 39); + /* } else if (_ref$1 === 33) { */ $s = 32; continue; case 28: + tok = s.switch2(43, 44); + /* } else if (_ref$1 === 38) { */ $s = 32; continue; case 29: + if (s.ch === 94) { + s.next(); + tok = s.switch2(22, 33); + } else { + tok = s.switch3(17, 28, 38, 34); + } + /* } else if (_ref$1 === 124) { */ $s = 32; continue; case 30: + tok = s.switch3(18, 29, 124, 35); + /* } else { */ $s = 32; continue; case 31: + if (!((ch === 65279))) { + s.error(s.file.Offset(pos), fmt.Sprintf("illegal character %#U", new ($sliceType($emptyInterface))([new $Int32(ch)]))); + } + insertSemi = s.insertSemi; + tok = 0; + lit = $encodeRune(ch); + /* } */ case 32: + /* } */ case 4: + if (((s.mode & 2) >>> 0) === 0) { + s.insertSemi = insertSemi; } - return x; + return [pos, tok, lit]; + /* */ case -1: } return; } + }; + Scanner.prototype.Scan = function() { return this.$val.Scan(); }; + $pkg.$init = function() { + Error.methods = [["Error", "Error", "", $funcType([], [$String], false), -1]]; + ($ptrType(Error)).methods = [["Error", "Error", "", $funcType([], [$String], false), -1]]; + Error.init([["Pos", "Pos", "", token.Position, ""], ["Msg", "Msg", "", $String, ""]]); + ErrorList.methods = [["Err", "Err", "", $funcType([], [$error], false), -1], ["Error", "Error", "", $funcType([], [$String], false), -1], ["Len", "Len", "", $funcType([], [$Int], false), -1], ["Less", "Less", "", $funcType([$Int, $Int], [$Bool], false), -1], ["Sort", "Sort", "", $funcType([], [], false), -1], ["Swap", "Swap", "", $funcType([$Int, $Int], [], false), -1]]; + ($ptrType(ErrorList)).methods = [["Add", "Add", "", $funcType([token.Position, $String], [], false), -1], ["Err", "Err", "", $funcType([], [$error], false), -1], ["Error", "Error", "", $funcType([], [$String], false), -1], ["Len", "Len", "", $funcType([], [$Int], false), -1], ["Less", "Less", "", $funcType([$Int, $Int], [$Bool], false), -1], ["RemoveMultiples", "RemoveMultiples", "", $funcType([], [], false), -1], ["Reset", "Reset", "", $funcType([], [], false), -1], ["Sort", "Sort", "", $funcType([], [], false), -1], ["Swap", "Swap", "", $funcType([$Int, $Int], [], false), -1]]; + ErrorList.init(($ptrType(Error))); + ErrorHandler.init([token.Position, $String], [], false); + ($ptrType(Scanner)).methods = [["Init", "Init", "", $funcType([($ptrType(token.File)), ($sliceType($Uint8)), ErrorHandler, Mode], [], false), -1], ["Scan", "Scan", "", $funcType([], [token.Pos, token.Token, $String], false), -1], ["error", "error", "go/scanner", $funcType([$Int, $String], [], false), -1], ["findLineEnd", "findLineEnd", "go/scanner", $funcType([], [$Bool], false), -1], ["interpretLineComment", "interpretLineComment", "go/scanner", $funcType([($sliceType($Uint8))], [], false), -1], ["next", "next", "go/scanner", $funcType([], [], false), -1], ["scanComment", "scanComment", "go/scanner", $funcType([], [$String], false), -1], ["scanEscape", "scanEscape", "go/scanner", $funcType([$Int32], [$Bool], false), -1], ["scanIdentifier", "scanIdentifier", "go/scanner", $funcType([], [$String], false), -1], ["scanMantissa", "scanMantissa", "go/scanner", $funcType([$Int], [], false), -1], ["scanNumber", "scanNumber", "go/scanner", $funcType([$Bool], [token.Token, $String], false), -1], ["scanRawString", "scanRawString", "go/scanner", $funcType([], [$String], false), -1], ["scanRune", "scanRune", "go/scanner", $funcType([], [$String], false), -1], ["scanString", "scanString", "go/scanner", $funcType([], [$String], false), -1], ["skipWhitespace", "skipWhitespace", "go/scanner", $funcType([], [], false), -1], ["switch2", "switch2", "go/scanner", $funcType([token.Token, token.Token], [token.Token], false), -1], ["switch3", "switch3", "go/scanner", $funcType([token.Token, token.Token, $Int32, token.Token], [token.Token], false), -1], ["switch4", "switch4", "go/scanner", $funcType([token.Token, token.Token, $Int32, token.Token, token.Token], [token.Token], false), -1]]; + Scanner.init([["file", "file", "go/scanner", ($ptrType(token.File)), ""], ["dir", "dir", "go/scanner", $String, ""], ["src", "src", "go/scanner", ($sliceType($Uint8)), ""], ["err", "err", "go/scanner", ErrorHandler, ""], ["mode", "mode", "go/scanner", Mode, ""], ["ch", "ch", "go/scanner", $Int32, ""], ["offset", "offset", "go/scanner", $Int, ""], ["rdOffset", "rdOffset", "go/scanner", $Int, ""], ["lineOffset", "lineOffset", "go/scanner", $Int, ""], ["insertSemi", "insertSemi", "go/scanner", $Bool, ""], ["ErrorCount", "ErrorCount", "", $Int, ""]]); + prefix = new ($sliceType($Uint8))($stringToBytes("//line ")); + }; + return $pkg; +})(); +$packages["go/ast"] = (function() { + var $pkg = {}, token = $packages["go/token"], strings = $packages["strings"], unicode = $packages["unicode"], utf8 = $packages["unicode/utf8"], bytes = $packages["bytes"], fmt = $packages["fmt"], sort = $packages["sort"], strconv = $packages["strconv"], io = $packages["io"], os = $packages["os"], reflect = $packages["reflect"], scanner = $packages["go/scanner"], Node, Expr, Stmt, Decl, Comment, CommentGroup, Field, FieldList, BadExpr, Ident, Ellipsis, BasicLit, FuncLit, CompositeLit, ParenExpr, SelectorExpr, IndexExpr, SliceExpr, TypeAssertExpr, CallExpr, StarExpr, UnaryExpr, BinaryExpr, KeyValueExpr, ChanDir, ArrayType, StructType, FuncType, InterfaceType, MapType, ChanType, BadStmt, DeclStmt, EmptyStmt, LabeledStmt, ExprStmt, SendStmt, IncDecStmt, AssignStmt, GoStmt, DeferStmt, ReturnStmt, BranchStmt, BlockStmt, IfStmt, CaseClause, SwitchStmt, TypeSwitchStmt, CommClause, SelectStmt, ForStmt, RangeStmt, Spec, ImportSpec, ValueSpec, TypeSpec, BadDecl, GenDecl, FuncDecl, File, Package, byPos, CommentMap, commentListReader, nodeStack, posSpan, byImportSpec, byCommentPos, Scope, Object, ObjKind, Visitor, inspector, objKindStrings, isWhitespace, stripTrailingWhitespace, NewIdent, IsExported, sortComments, nodeList, NewCommentMap, summary, SortImports, importPath, importName, importComment, collapse, sortSpecs, NewScope, NewObj, walkIdentList, walkExprList, walkStmtList, walkDeclList, Walk, Inspect; + Node = $pkg.Node = $newType(8, "Interface", "ast.Node", "Node", "go/ast", null); + Expr = $pkg.Expr = $newType(8, "Interface", "ast.Expr", "Expr", "go/ast", null); + Stmt = $pkg.Stmt = $newType(8, "Interface", "ast.Stmt", "Stmt", "go/ast", null); + Decl = $pkg.Decl = $newType(8, "Interface", "ast.Decl", "Decl", "go/ast", null); + Comment = $pkg.Comment = $newType(0, "Struct", "ast.Comment", "Comment", "go/ast", function(Slash_, Text_) { + this.$val = this; + this.Slash = Slash_ !== undefined ? Slash_ : 0; + this.Text = Text_ !== undefined ? Text_ : ""; + }); + CommentGroup = $pkg.CommentGroup = $newType(0, "Struct", "ast.CommentGroup", "CommentGroup", "go/ast", function(List_) { + this.$val = this; + this.List = List_ !== undefined ? List_ : ($sliceType(($ptrType(Comment)))).nil; + }); + Field = $pkg.Field = $newType(0, "Struct", "ast.Field", "Field", "go/ast", function(Doc_, Names_, Type_, Tag_, Comment_) { + this.$val = this; + this.Doc = Doc_ !== undefined ? Doc_ : ($ptrType(CommentGroup)).nil; + this.Names = Names_ !== undefined ? Names_ : ($sliceType(($ptrType(Ident)))).nil; + this.Type = Type_ !== undefined ? Type_ : $ifaceNil; + this.Tag = Tag_ !== undefined ? Tag_ : ($ptrType(BasicLit)).nil; + this.Comment = Comment_ !== undefined ? Comment_ : ($ptrType(CommentGroup)).nil; + }); + FieldList = $pkg.FieldList = $newType(0, "Struct", "ast.FieldList", "FieldList", "go/ast", function(Opening_, List_, Closing_) { + this.$val = this; + this.Opening = Opening_ !== undefined ? Opening_ : 0; + this.List = List_ !== undefined ? List_ : ($sliceType(($ptrType(Field)))).nil; + this.Closing = Closing_ !== undefined ? Closing_ : 0; + }); + BadExpr = $pkg.BadExpr = $newType(0, "Struct", "ast.BadExpr", "BadExpr", "go/ast", function(From_, To_) { + this.$val = this; + this.From = From_ !== undefined ? From_ : 0; + this.To = To_ !== undefined ? To_ : 0; + }); + Ident = $pkg.Ident = $newType(0, "Struct", "ast.Ident", "Ident", "go/ast", function(NamePos_, Name_, Obj_) { + this.$val = this; + this.NamePos = NamePos_ !== undefined ? NamePos_ : 0; + this.Name = Name_ !== undefined ? Name_ : ""; + this.Obj = Obj_ !== undefined ? Obj_ : ($ptrType(Object)).nil; + }); + Ellipsis = $pkg.Ellipsis = $newType(0, "Struct", "ast.Ellipsis", "Ellipsis", "go/ast", function(Ellipsis_, Elt_) { + this.$val = this; + this.Ellipsis = Ellipsis_ !== undefined ? Ellipsis_ : 0; + this.Elt = Elt_ !== undefined ? Elt_ : $ifaceNil; + }); + BasicLit = $pkg.BasicLit = $newType(0, "Struct", "ast.BasicLit", "BasicLit", "go/ast", function(ValuePos_, Kind_, Value_) { + this.$val = this; + this.ValuePos = ValuePos_ !== undefined ? ValuePos_ : 0; + this.Kind = Kind_ !== undefined ? Kind_ : 0; + this.Value = Value_ !== undefined ? Value_ : ""; + }); + FuncLit = $pkg.FuncLit = $newType(0, "Struct", "ast.FuncLit", "FuncLit", "go/ast", function(Type_, Body_) { + this.$val = this; + this.Type = Type_ !== undefined ? Type_ : ($ptrType(FuncType)).nil; + this.Body = Body_ !== undefined ? Body_ : ($ptrType(BlockStmt)).nil; + }); + CompositeLit = $pkg.CompositeLit = $newType(0, "Struct", "ast.CompositeLit", "CompositeLit", "go/ast", function(Type_, Lbrace_, Elts_, Rbrace_) { + this.$val = this; + this.Type = Type_ !== undefined ? Type_ : $ifaceNil; + this.Lbrace = Lbrace_ !== undefined ? Lbrace_ : 0; + this.Elts = Elts_ !== undefined ? Elts_ : ($sliceType(Expr)).nil; + this.Rbrace = Rbrace_ !== undefined ? Rbrace_ : 0; + }); + ParenExpr = $pkg.ParenExpr = $newType(0, "Struct", "ast.ParenExpr", "ParenExpr", "go/ast", function(Lparen_, X_, Rparen_) { + this.$val = this; + this.Lparen = Lparen_ !== undefined ? Lparen_ : 0; + this.X = X_ !== undefined ? X_ : $ifaceNil; + this.Rparen = Rparen_ !== undefined ? Rparen_ : 0; + }); + SelectorExpr = $pkg.SelectorExpr = $newType(0, "Struct", "ast.SelectorExpr", "SelectorExpr", "go/ast", function(X_, Sel_) { + this.$val = this; + this.X = X_ !== undefined ? X_ : $ifaceNil; + this.Sel = Sel_ !== undefined ? Sel_ : ($ptrType(Ident)).nil; + }); + IndexExpr = $pkg.IndexExpr = $newType(0, "Struct", "ast.IndexExpr", "IndexExpr", "go/ast", function(X_, Lbrack_, Index_, Rbrack_) { + this.$val = this; + this.X = X_ !== undefined ? X_ : $ifaceNil; + this.Lbrack = Lbrack_ !== undefined ? Lbrack_ : 0; + this.Index = Index_ !== undefined ? Index_ : $ifaceNil; + this.Rbrack = Rbrack_ !== undefined ? Rbrack_ : 0; + }); + SliceExpr = $pkg.SliceExpr = $newType(0, "Struct", "ast.SliceExpr", "SliceExpr", "go/ast", function(X_, Lbrack_, Low_, High_, Max_, Slice3_, Rbrack_) { + this.$val = this; + this.X = X_ !== undefined ? X_ : $ifaceNil; + this.Lbrack = Lbrack_ !== undefined ? Lbrack_ : 0; + this.Low = Low_ !== undefined ? Low_ : $ifaceNil; + this.High = High_ !== undefined ? High_ : $ifaceNil; + this.Max = Max_ !== undefined ? Max_ : $ifaceNil; + this.Slice3 = Slice3_ !== undefined ? Slice3_ : false; + this.Rbrack = Rbrack_ !== undefined ? Rbrack_ : 0; + }); + TypeAssertExpr = $pkg.TypeAssertExpr = $newType(0, "Struct", "ast.TypeAssertExpr", "TypeAssertExpr", "go/ast", function(X_, Lparen_, Type_, Rparen_) { + this.$val = this; + this.X = X_ !== undefined ? X_ : $ifaceNil; + this.Lparen = Lparen_ !== undefined ? Lparen_ : 0; + this.Type = Type_ !== undefined ? Type_ : $ifaceNil; + this.Rparen = Rparen_ !== undefined ? Rparen_ : 0; + }); + CallExpr = $pkg.CallExpr = $newType(0, "Struct", "ast.CallExpr", "CallExpr", "go/ast", function(Fun_, Lparen_, Args_, Ellipsis_, Rparen_) { + this.$val = this; + this.Fun = Fun_ !== undefined ? Fun_ : $ifaceNil; + this.Lparen = Lparen_ !== undefined ? Lparen_ : 0; + this.Args = Args_ !== undefined ? Args_ : ($sliceType(Expr)).nil; + this.Ellipsis = Ellipsis_ !== undefined ? Ellipsis_ : 0; + this.Rparen = Rparen_ !== undefined ? Rparen_ : 0; + }); + StarExpr = $pkg.StarExpr = $newType(0, "Struct", "ast.StarExpr", "StarExpr", "go/ast", function(Star_, X_) { + this.$val = this; + this.Star = Star_ !== undefined ? Star_ : 0; + this.X = X_ !== undefined ? X_ : $ifaceNil; + }); + UnaryExpr = $pkg.UnaryExpr = $newType(0, "Struct", "ast.UnaryExpr", "UnaryExpr", "go/ast", function(OpPos_, Op_, X_) { + this.$val = this; + this.OpPos = OpPos_ !== undefined ? OpPos_ : 0; + this.Op = Op_ !== undefined ? Op_ : 0; + this.X = X_ !== undefined ? X_ : $ifaceNil; + }); + BinaryExpr = $pkg.BinaryExpr = $newType(0, "Struct", "ast.BinaryExpr", "BinaryExpr", "go/ast", function(X_, OpPos_, Op_, Y_) { + this.$val = this; + this.X = X_ !== undefined ? X_ : $ifaceNil; + this.OpPos = OpPos_ !== undefined ? OpPos_ : 0; + this.Op = Op_ !== undefined ? Op_ : 0; + this.Y = Y_ !== undefined ? Y_ : $ifaceNil; + }); + KeyValueExpr = $pkg.KeyValueExpr = $newType(0, "Struct", "ast.KeyValueExpr", "KeyValueExpr", "go/ast", function(Key_, Colon_, Value_) { + this.$val = this; + this.Key = Key_ !== undefined ? Key_ : $ifaceNil; + this.Colon = Colon_ !== undefined ? Colon_ : 0; + this.Value = Value_ !== undefined ? Value_ : $ifaceNil; + }); + ChanDir = $pkg.ChanDir = $newType(4, "Int", "ast.ChanDir", "ChanDir", "go/ast", null); + ArrayType = $pkg.ArrayType = $newType(0, "Struct", "ast.ArrayType", "ArrayType", "go/ast", function(Lbrack_, Len_, Elt_) { + this.$val = this; + this.Lbrack = Lbrack_ !== undefined ? Lbrack_ : 0; + this.Len = Len_ !== undefined ? Len_ : $ifaceNil; + this.Elt = Elt_ !== undefined ? Elt_ : $ifaceNil; + }); + StructType = $pkg.StructType = $newType(0, "Struct", "ast.StructType", "StructType", "go/ast", function(Struct_, Fields_, Incomplete_) { + this.$val = this; + this.Struct = Struct_ !== undefined ? Struct_ : 0; + this.Fields = Fields_ !== undefined ? Fields_ : ($ptrType(FieldList)).nil; + this.Incomplete = Incomplete_ !== undefined ? Incomplete_ : false; + }); + FuncType = $pkg.FuncType = $newType(0, "Struct", "ast.FuncType", "FuncType", "go/ast", function(Func_, Params_, Results_) { + this.$val = this; + this.Func = Func_ !== undefined ? Func_ : 0; + this.Params = Params_ !== undefined ? Params_ : ($ptrType(FieldList)).nil; + this.Results = Results_ !== undefined ? Results_ : ($ptrType(FieldList)).nil; + }); + InterfaceType = $pkg.InterfaceType = $newType(0, "Struct", "ast.InterfaceType", "InterfaceType", "go/ast", function(Interface_, Methods_, Incomplete_) { + this.$val = this; + this.Interface = Interface_ !== undefined ? Interface_ : 0; + this.Methods = Methods_ !== undefined ? Methods_ : ($ptrType(FieldList)).nil; + this.Incomplete = Incomplete_ !== undefined ? Incomplete_ : false; + }); + MapType = $pkg.MapType = $newType(0, "Struct", "ast.MapType", "MapType", "go/ast", function(Map_, Key_, Value_) { + this.$val = this; + this.Map = Map_ !== undefined ? Map_ : 0; + this.Key = Key_ !== undefined ? Key_ : $ifaceNil; + this.Value = Value_ !== undefined ? Value_ : $ifaceNil; + }); + ChanType = $pkg.ChanType = $newType(0, "Struct", "ast.ChanType", "ChanType", "go/ast", function(Begin_, Arrow_, Dir_, Value_) { + this.$val = this; + this.Begin = Begin_ !== undefined ? Begin_ : 0; + this.Arrow = Arrow_ !== undefined ? Arrow_ : 0; + this.Dir = Dir_ !== undefined ? Dir_ : 0; + this.Value = Value_ !== undefined ? Value_ : $ifaceNil; + }); + BadStmt = $pkg.BadStmt = $newType(0, "Struct", "ast.BadStmt", "BadStmt", "go/ast", function(From_, To_) { + this.$val = this; + this.From = From_ !== undefined ? From_ : 0; + this.To = To_ !== undefined ? To_ : 0; + }); + DeclStmt = $pkg.DeclStmt = $newType(0, "Struct", "ast.DeclStmt", "DeclStmt", "go/ast", function(Decl_) { + this.$val = this; + this.Decl = Decl_ !== undefined ? Decl_ : $ifaceNil; + }); + EmptyStmt = $pkg.EmptyStmt = $newType(0, "Struct", "ast.EmptyStmt", "EmptyStmt", "go/ast", function(Semicolon_) { + this.$val = this; + this.Semicolon = Semicolon_ !== undefined ? Semicolon_ : 0; + }); + LabeledStmt = $pkg.LabeledStmt = $newType(0, "Struct", "ast.LabeledStmt", "LabeledStmt", "go/ast", function(Label_, Colon_, Stmt_) { + this.$val = this; + this.Label = Label_ !== undefined ? Label_ : ($ptrType(Ident)).nil; + this.Colon = Colon_ !== undefined ? Colon_ : 0; + this.Stmt = Stmt_ !== undefined ? Stmt_ : $ifaceNil; + }); + ExprStmt = $pkg.ExprStmt = $newType(0, "Struct", "ast.ExprStmt", "ExprStmt", "go/ast", function(X_) { + this.$val = this; + this.X = X_ !== undefined ? X_ : $ifaceNil; + }); + SendStmt = $pkg.SendStmt = $newType(0, "Struct", "ast.SendStmt", "SendStmt", "go/ast", function(Chan_, Arrow_, Value_) { + this.$val = this; + this.Chan = Chan_ !== undefined ? Chan_ : $ifaceNil; + this.Arrow = Arrow_ !== undefined ? Arrow_ : 0; + this.Value = Value_ !== undefined ? Value_ : $ifaceNil; + }); + IncDecStmt = $pkg.IncDecStmt = $newType(0, "Struct", "ast.IncDecStmt", "IncDecStmt", "go/ast", function(X_, TokPos_, Tok_) { + this.$val = this; + this.X = X_ !== undefined ? X_ : $ifaceNil; + this.TokPos = TokPos_ !== undefined ? TokPos_ : 0; + this.Tok = Tok_ !== undefined ? Tok_ : 0; + }); + AssignStmt = $pkg.AssignStmt = $newType(0, "Struct", "ast.AssignStmt", "AssignStmt", "go/ast", function(Lhs_, TokPos_, Tok_, Rhs_) { + this.$val = this; + this.Lhs = Lhs_ !== undefined ? Lhs_ : ($sliceType(Expr)).nil; + this.TokPos = TokPos_ !== undefined ? TokPos_ : 0; + this.Tok = Tok_ !== undefined ? Tok_ : 0; + this.Rhs = Rhs_ !== undefined ? Rhs_ : ($sliceType(Expr)).nil; + }); + GoStmt = $pkg.GoStmt = $newType(0, "Struct", "ast.GoStmt", "GoStmt", "go/ast", function(Go_, Call_) { + this.$val = this; + this.Go = Go_ !== undefined ? Go_ : 0; + this.Call = Call_ !== undefined ? Call_ : ($ptrType(CallExpr)).nil; + }); + DeferStmt = $pkg.DeferStmt = $newType(0, "Struct", "ast.DeferStmt", "DeferStmt", "go/ast", function(Defer_, Call_) { + this.$val = this; + this.Defer = Defer_ !== undefined ? Defer_ : 0; + this.Call = Call_ !== undefined ? Call_ : ($ptrType(CallExpr)).nil; + }); + ReturnStmt = $pkg.ReturnStmt = $newType(0, "Struct", "ast.ReturnStmt", "ReturnStmt", "go/ast", function(Return_, Results_) { + this.$val = this; + this.Return = Return_ !== undefined ? Return_ : 0; + this.Results = Results_ !== undefined ? Results_ : ($sliceType(Expr)).nil; + }); + BranchStmt = $pkg.BranchStmt = $newType(0, "Struct", "ast.BranchStmt", "BranchStmt", "go/ast", function(TokPos_, Tok_, Label_) { + this.$val = this; + this.TokPos = TokPos_ !== undefined ? TokPos_ : 0; + this.Tok = Tok_ !== undefined ? Tok_ : 0; + this.Label = Label_ !== undefined ? Label_ : ($ptrType(Ident)).nil; + }); + BlockStmt = $pkg.BlockStmt = $newType(0, "Struct", "ast.BlockStmt", "BlockStmt", "go/ast", function(Lbrace_, List_, Rbrace_) { + this.$val = this; + this.Lbrace = Lbrace_ !== undefined ? Lbrace_ : 0; + this.List = List_ !== undefined ? List_ : ($sliceType(Stmt)).nil; + this.Rbrace = Rbrace_ !== undefined ? Rbrace_ : 0; + }); + IfStmt = $pkg.IfStmt = $newType(0, "Struct", "ast.IfStmt", "IfStmt", "go/ast", function(If_, Init_, Cond_, Body_, Else_) { + this.$val = this; + this.If = If_ !== undefined ? If_ : 0; + this.Init = Init_ !== undefined ? Init_ : $ifaceNil; + this.Cond = Cond_ !== undefined ? Cond_ : $ifaceNil; + this.Body = Body_ !== undefined ? Body_ : ($ptrType(BlockStmt)).nil; + this.Else = Else_ !== undefined ? Else_ : $ifaceNil; + }); + CaseClause = $pkg.CaseClause = $newType(0, "Struct", "ast.CaseClause", "CaseClause", "go/ast", function(Case_, List_, Colon_, Body_) { + this.$val = this; + this.Case = Case_ !== undefined ? Case_ : 0; + this.List = List_ !== undefined ? List_ : ($sliceType(Expr)).nil; + this.Colon = Colon_ !== undefined ? Colon_ : 0; + this.Body = Body_ !== undefined ? Body_ : ($sliceType(Stmt)).nil; + }); + SwitchStmt = $pkg.SwitchStmt = $newType(0, "Struct", "ast.SwitchStmt", "SwitchStmt", "go/ast", function(Switch_, Init_, Tag_, Body_) { + this.$val = this; + this.Switch = Switch_ !== undefined ? Switch_ : 0; + this.Init = Init_ !== undefined ? Init_ : $ifaceNil; + this.Tag = Tag_ !== undefined ? Tag_ : $ifaceNil; + this.Body = Body_ !== undefined ? Body_ : ($ptrType(BlockStmt)).nil; + }); + TypeSwitchStmt = $pkg.TypeSwitchStmt = $newType(0, "Struct", "ast.TypeSwitchStmt", "TypeSwitchStmt", "go/ast", function(Switch_, Init_, Assign_, Body_) { + this.$val = this; + this.Switch = Switch_ !== undefined ? Switch_ : 0; + this.Init = Init_ !== undefined ? Init_ : $ifaceNil; + this.Assign = Assign_ !== undefined ? Assign_ : $ifaceNil; + this.Body = Body_ !== undefined ? Body_ : ($ptrType(BlockStmt)).nil; + }); + CommClause = $pkg.CommClause = $newType(0, "Struct", "ast.CommClause", "CommClause", "go/ast", function(Case_, Comm_, Colon_, Body_) { + this.$val = this; + this.Case = Case_ !== undefined ? Case_ : 0; + this.Comm = Comm_ !== undefined ? Comm_ : $ifaceNil; + this.Colon = Colon_ !== undefined ? Colon_ : 0; + this.Body = Body_ !== undefined ? Body_ : ($sliceType(Stmt)).nil; + }); + SelectStmt = $pkg.SelectStmt = $newType(0, "Struct", "ast.SelectStmt", "SelectStmt", "go/ast", function(Select_, Body_) { + this.$val = this; + this.Select = Select_ !== undefined ? Select_ : 0; + this.Body = Body_ !== undefined ? Body_ : ($ptrType(BlockStmt)).nil; + }); + ForStmt = $pkg.ForStmt = $newType(0, "Struct", "ast.ForStmt", "ForStmt", "go/ast", function(For_, Init_, Cond_, Post_, Body_) { + this.$val = this; + this.For = For_ !== undefined ? For_ : 0; + this.Init = Init_ !== undefined ? Init_ : $ifaceNil; + this.Cond = Cond_ !== undefined ? Cond_ : $ifaceNil; + this.Post = Post_ !== undefined ? Post_ : $ifaceNil; + this.Body = Body_ !== undefined ? Body_ : ($ptrType(BlockStmt)).nil; + }); + RangeStmt = $pkg.RangeStmt = $newType(0, "Struct", "ast.RangeStmt", "RangeStmt", "go/ast", function(For_, Key_, Value_, TokPos_, Tok_, X_, Body_) { + this.$val = this; + this.For = For_ !== undefined ? For_ : 0; + this.Key = Key_ !== undefined ? Key_ : $ifaceNil; + this.Value = Value_ !== undefined ? Value_ : $ifaceNil; + this.TokPos = TokPos_ !== undefined ? TokPos_ : 0; + this.Tok = Tok_ !== undefined ? Tok_ : 0; + this.X = X_ !== undefined ? X_ : $ifaceNil; + this.Body = Body_ !== undefined ? Body_ : ($ptrType(BlockStmt)).nil; + }); + Spec = $pkg.Spec = $newType(8, "Interface", "ast.Spec", "Spec", "go/ast", null); + ImportSpec = $pkg.ImportSpec = $newType(0, "Struct", "ast.ImportSpec", "ImportSpec", "go/ast", function(Doc_, Name_, Path_, Comment_, EndPos_) { + this.$val = this; + this.Doc = Doc_ !== undefined ? Doc_ : ($ptrType(CommentGroup)).nil; + this.Name = Name_ !== undefined ? Name_ : ($ptrType(Ident)).nil; + this.Path = Path_ !== undefined ? Path_ : ($ptrType(BasicLit)).nil; + this.Comment = Comment_ !== undefined ? Comment_ : ($ptrType(CommentGroup)).nil; + this.EndPos = EndPos_ !== undefined ? EndPos_ : 0; + }); + ValueSpec = $pkg.ValueSpec = $newType(0, "Struct", "ast.ValueSpec", "ValueSpec", "go/ast", function(Doc_, Names_, Type_, Values_, Comment_) { + this.$val = this; + this.Doc = Doc_ !== undefined ? Doc_ : ($ptrType(CommentGroup)).nil; + this.Names = Names_ !== undefined ? Names_ : ($sliceType(($ptrType(Ident)))).nil; + this.Type = Type_ !== undefined ? Type_ : $ifaceNil; + this.Values = Values_ !== undefined ? Values_ : ($sliceType(Expr)).nil; + this.Comment = Comment_ !== undefined ? Comment_ : ($ptrType(CommentGroup)).nil; + }); + TypeSpec = $pkg.TypeSpec = $newType(0, "Struct", "ast.TypeSpec", "TypeSpec", "go/ast", function(Doc_, Name_, Type_, Comment_) { + this.$val = this; + this.Doc = Doc_ !== undefined ? Doc_ : ($ptrType(CommentGroup)).nil; + this.Name = Name_ !== undefined ? Name_ : ($ptrType(Ident)).nil; + this.Type = Type_ !== undefined ? Type_ : $ifaceNil; + this.Comment = Comment_ !== undefined ? Comment_ : ($ptrType(CommentGroup)).nil; + }); + BadDecl = $pkg.BadDecl = $newType(0, "Struct", "ast.BadDecl", "BadDecl", "go/ast", function(From_, To_) { + this.$val = this; + this.From = From_ !== undefined ? From_ : 0; + this.To = To_ !== undefined ? To_ : 0; + }); + GenDecl = $pkg.GenDecl = $newType(0, "Struct", "ast.GenDecl", "GenDecl", "go/ast", function(Doc_, TokPos_, Tok_, Lparen_, Specs_, Rparen_) { + this.$val = this; + this.Doc = Doc_ !== undefined ? Doc_ : ($ptrType(CommentGroup)).nil; + this.TokPos = TokPos_ !== undefined ? TokPos_ : 0; + this.Tok = Tok_ !== undefined ? Tok_ : 0; + this.Lparen = Lparen_ !== undefined ? Lparen_ : 0; + this.Specs = Specs_ !== undefined ? Specs_ : ($sliceType(Spec)).nil; + this.Rparen = Rparen_ !== undefined ? Rparen_ : 0; + }); + FuncDecl = $pkg.FuncDecl = $newType(0, "Struct", "ast.FuncDecl", "FuncDecl", "go/ast", function(Doc_, Recv_, Name_, Type_, Body_) { + this.$val = this; + this.Doc = Doc_ !== undefined ? Doc_ : ($ptrType(CommentGroup)).nil; + this.Recv = Recv_ !== undefined ? Recv_ : ($ptrType(FieldList)).nil; + this.Name = Name_ !== undefined ? Name_ : ($ptrType(Ident)).nil; + this.Type = Type_ !== undefined ? Type_ : ($ptrType(FuncType)).nil; + this.Body = Body_ !== undefined ? Body_ : ($ptrType(BlockStmt)).nil; + }); + File = $pkg.File = $newType(0, "Struct", "ast.File", "File", "go/ast", function(Doc_, Package_, Name_, Decls_, Scope_, Imports_, Unresolved_, Comments_) { + this.$val = this; + this.Doc = Doc_ !== undefined ? Doc_ : ($ptrType(CommentGroup)).nil; + this.Package = Package_ !== undefined ? Package_ : 0; + this.Name = Name_ !== undefined ? Name_ : ($ptrType(Ident)).nil; + this.Decls = Decls_ !== undefined ? Decls_ : ($sliceType(Decl)).nil; + this.Scope = Scope_ !== undefined ? Scope_ : ($ptrType(Scope)).nil; + this.Imports = Imports_ !== undefined ? Imports_ : ($sliceType(($ptrType(ImportSpec)))).nil; + this.Unresolved = Unresolved_ !== undefined ? Unresolved_ : ($sliceType(($ptrType(Ident)))).nil; + this.Comments = Comments_ !== undefined ? Comments_ : ($sliceType(($ptrType(CommentGroup)))).nil; + }); + Package = $pkg.Package = $newType(0, "Struct", "ast.Package", "Package", "go/ast", function(Name_, Scope_, Imports_, Files_) { + this.$val = this; + this.Name = Name_ !== undefined ? Name_ : ""; + this.Scope = Scope_ !== undefined ? Scope_ : ($ptrType(Scope)).nil; + this.Imports = Imports_ !== undefined ? Imports_ : false; + this.Files = Files_ !== undefined ? Files_ : false; + }); + byPos = $pkg.byPos = $newType(12, "Slice", "ast.byPos", "byPos", "go/ast", null); + CommentMap = $pkg.CommentMap = $newType(4, "Map", "ast.CommentMap", "CommentMap", "go/ast", null); + commentListReader = $pkg.commentListReader = $newType(0, "Struct", "ast.commentListReader", "commentListReader", "go/ast", function(fset_, list_, index_, comment_, pos_, end_) { + this.$val = this; + this.fset = fset_ !== undefined ? fset_ : ($ptrType(token.FileSet)).nil; + this.list = list_ !== undefined ? list_ : ($sliceType(($ptrType(CommentGroup)))).nil; + this.index = index_ !== undefined ? index_ : 0; + this.comment = comment_ !== undefined ? comment_ : ($ptrType(CommentGroup)).nil; + this.pos = pos_ !== undefined ? pos_ : new token.Position.Ptr(); + this.end = end_ !== undefined ? end_ : new token.Position.Ptr(); + }); + nodeStack = $pkg.nodeStack = $newType(12, "Slice", "ast.nodeStack", "nodeStack", "go/ast", null); + posSpan = $pkg.posSpan = $newType(0, "Struct", "ast.posSpan", "posSpan", "go/ast", function(Start_, End_) { + this.$val = this; + this.Start = Start_ !== undefined ? Start_ : 0; + this.End = End_ !== undefined ? End_ : 0; + }); + byImportSpec = $pkg.byImportSpec = $newType(12, "Slice", "ast.byImportSpec", "byImportSpec", "go/ast", null); + byCommentPos = $pkg.byCommentPos = $newType(12, "Slice", "ast.byCommentPos", "byCommentPos", "go/ast", null); + Scope = $pkg.Scope = $newType(0, "Struct", "ast.Scope", "Scope", "go/ast", function(Outer_, Objects_) { + this.$val = this; + this.Outer = Outer_ !== undefined ? Outer_ : ($ptrType(Scope)).nil; + this.Objects = Objects_ !== undefined ? Objects_ : false; + }); + Object = $pkg.Object = $newType(0, "Struct", "ast.Object", "Object", "go/ast", function(Kind_, Name_, Decl_, Data_, Type_) { + this.$val = this; + this.Kind = Kind_ !== undefined ? Kind_ : 0; + this.Name = Name_ !== undefined ? Name_ : ""; + this.Decl = Decl_ !== undefined ? Decl_ : $ifaceNil; + this.Data = Data_ !== undefined ? Data_ : $ifaceNil; + this.Type = Type_ !== undefined ? Type_ : $ifaceNil; + }); + ObjKind = $pkg.ObjKind = $newType(4, "Int", "ast.ObjKind", "ObjKind", "go/ast", null); + Visitor = $pkg.Visitor = $newType(8, "Interface", "ast.Visitor", "Visitor", "go/ast", null); + inspector = $pkg.inspector = $newType(4, "Func", "ast.inspector", "inspector", "go/ast", null); + Comment.Ptr.prototype.Pos = function() { + var c; + c = this; + return c.Slash; }; - parser.Ptr.prototype.checkExprOrType = function(x) { - var p, t, _ref, _tuple, len, isEllipsis; - p = this; - _ref = unparen(x); - if ($assertType(_ref, ($ptrType(ast.ParenExpr)), true)[1]) { - t = _ref.$val; - $panic(new $String("unreachable")); - } else if ($assertType(_ref, ($ptrType(ast.UnaryExpr)), true)[1]) { - t = _ref.$val; - } else if ($assertType(_ref, ($ptrType(ast.ArrayType)), true)[1]) { - t = _ref.$val; - _tuple = $assertType(t.Len, ($ptrType(ast.Ellipsis)), true); len = _tuple[0]; isEllipsis = _tuple[1]; - if (isEllipsis) { - p.error(len.Pos(), "expected array length, found '...'"); - x = new ast.BadExpr.Ptr(x.Pos(), p.safePos(x.End())); - } - } - return x; + Comment.prototype.Pos = function() { return this.$val.Pos(); }; + Comment.Ptr.prototype.End = function() { + var c; + c = this; + return (((c.Slash >> 0) + c.Text.length >> 0) >> 0); }; - parser.prototype.checkExprOrType = function(x) { return this.$val.checkExprOrType(x); }; - parser.Ptr.prototype.parsePrimaryExpr = function(lhs) { - var $deferred = [], $err = null, p, x, _ref, _ref$1, pos; - /* */ try { $deferFrames.push($deferred); - p = this; - if (p.trace) { - $deferred.push([un, [trace(p, "PrimaryExpr")]]); - } - x = p.parseOperand(lhs); - L: - while (true) { - _ref = p.tok; - if (_ref === 53) { - p.next(); - if (lhs) { - p.resolve(x); - } - _ref$1 = p.tok; - if (_ref$1 === 4) { - x = p.parseSelector(p.checkExprOrType(x)); - } else if (_ref$1 === 49) { - x = p.parseTypeAssertion(p.checkExpr(x)); - } else { - pos = p.pos; - p.errorExpected(pos, "selector or type assertion"); - p.next(); - x = new ast.BadExpr.Ptr(pos, p.pos); - } - } else if (_ref === 50) { - if (lhs) { - p.resolve(x); - } - x = p.parseIndexOrSlice(p.checkExpr(x)); - } else if (_ref === 49) { - if (lhs) { - p.resolve(x); - } - x = p.parseCallOrConversion(p.checkExprOrType(x)); - } else if (_ref === 51) { - if (isLiteralType(x) && (p.exprLev >= 0 || !isTypeName(x))) { - if (lhs) { - p.resolve(x); - } - x = p.parseLiteralValue(x); - } else { - break L; - } - } else { - break L; - } - lhs = false; - } - return x; - /* */ } catch(err) { $err = err; return $ifaceNil; } finally { $deferFrames.pop(); $callDeferred($deferred, $err); } + Comment.prototype.End = function() { return this.$val.End(); }; + CommentGroup.Ptr.prototype.Pos = function() { + var g, x; + g = this; + return (x = g.List, ((0 < 0 || 0 >= x.$length) ? $throwRuntimeError("index out of range") : x.$array[x.$offset + 0])).Pos(); }; - parser.prototype.parsePrimaryExpr = function(lhs) { return this.$val.parsePrimaryExpr(lhs); }; - parser.Ptr.prototype.parseUnaryExpr = function(lhs) { - var $deferred = [], $err = null, p, _ref, _tmp, _tmp$1, pos, op, x, arrow, x$1, _tuple, typ, ok, dir, _tmp$2, _tmp$3, _tmp$4, _tmp$5, _tmp$6, _tuple$1, pos$1, x$2; - /* */ try { $deferFrames.push($deferred); - p = this; - if (p.trace) { - $deferred.push([un, [trace(p, "UnaryExpr")]]); - } - _ref = p.tok; - if (_ref === 12 || _ref === 13 || _ref === 43 || _ref === 19 || _ref === 17) { - _tmp = p.pos; _tmp$1 = p.tok; pos = _tmp; op = _tmp$1; - p.next(); - x = p.parseUnaryExpr(false); - return new ast.UnaryExpr.Ptr(pos, op, p.checkExpr(x)); - } else if (_ref === 36) { - arrow = p.pos; - p.next(); - x$1 = p.parseUnaryExpr(false); - _tuple = $assertType(x$1, ($ptrType(ast.ChanType)), true); typ = _tuple[0]; ok = _tuple[1]; - if (ok) { - dir = 1; - while (ok && (dir === 1)) { - if (typ.Dir === 2) { - p.errorExpected(typ.Arrow, "'chan'"); - } - _tmp$2 = typ.Arrow; _tmp$3 = arrow; _tmp$4 = arrow; arrow = _tmp$2; typ.Begin = _tmp$3; typ.Arrow = _tmp$4; - _tmp$5 = typ.Dir; _tmp$6 = 2; dir = _tmp$5; typ.Dir = _tmp$6; - _tuple$1 = $assertType(typ.Value, ($ptrType(ast.ChanType)), true); typ = _tuple$1[0]; ok = _tuple$1[1]; - } - if (dir === 1) { - p.errorExpected(arrow, "channel type"); - } - return x$1; - } - return new ast.UnaryExpr.Ptr(arrow, 36, p.checkExpr(x$1)); - } else if (_ref === 14) { - pos$1 = p.pos; - p.next(); - x$2 = p.parseUnaryExpr(false); - return new ast.StarExpr.Ptr(pos$1, p.checkExprOrType(x$2)); - } - return p.parsePrimaryExpr(lhs); - /* */ } catch(err) { $err = err; return $ifaceNil; } finally { $deferFrames.pop(); $callDeferred($deferred, $err); } + CommentGroup.prototype.Pos = function() { return this.$val.Pos(); }; + CommentGroup.Ptr.prototype.End = function() { + var g, x, x$1; + g = this; + return (x = g.List, x$1 = g.List.$length - 1 >> 0, ((x$1 < 0 || x$1 >= x.$length) ? $throwRuntimeError("index out of range") : x.$array[x.$offset + x$1])).End(); }; - parser.prototype.parseUnaryExpr = function(lhs) { return this.$val.parseUnaryExpr(lhs); }; - parser.Ptr.prototype.tokPrec = function() { - var p, tok; - p = this; - tok = p.tok; - if (p.inRhs && (tok === 42)) { - tok = 39; - } - return [tok, (new token.Token(tok)).Precedence()]; + CommentGroup.prototype.End = function() { return this.$val.End(); }; + isWhitespace = function(ch) { + return (ch === 32) || (ch === 9) || (ch === 10) || (ch === 13); }; - parser.prototype.tokPrec = function() { return this.$val.tokPrec(); }; - parser.Ptr.prototype.parseBinaryExpr = function(lhs, prec1) { - var $deferred = [], $err = null, p, x, _tuple, prec, _tuple$1, op, oprec, pos, y; - /* */ try { $deferFrames.push($deferred); - p = this; - if (p.trace) { - $deferred.push([un, [trace(p, "BinaryExpr")]]); - } - x = p.parseUnaryExpr(lhs); - _tuple = p.tokPrec(); prec = _tuple[1]; - while (prec >= prec1) { - while (true) { - _tuple$1 = p.tokPrec(); op = _tuple$1[0]; oprec = _tuple$1[1]; - if (!((oprec === prec))) { - break; - } - pos = p.expect(op); - if (lhs) { - p.resolve(x); - lhs = false; - } - y = p.parseBinaryExpr(false, prec + 1 >> 0); - x = new ast.BinaryExpr.Ptr(p.checkExpr(x), pos, op, p.checkExpr(y)); - } - prec = prec - (1) >> 0; + stripTrailingWhitespace = function(s) { + var i; + i = s.length; + while (i > 0 && isWhitespace(s.charCodeAt((i - 1 >> 0)))) { + i = i - (1) >> 0; } - return x; - /* */ } catch(err) { $err = err; return $ifaceNil; } finally { $deferFrames.pop(); $callDeferred($deferred, $err); } + return s.substring(0, i); }; - parser.prototype.parseBinaryExpr = function(lhs, prec1) { return this.$val.parseBinaryExpr(lhs, prec1); }; - parser.Ptr.prototype.parseExpr = function(lhs) { - var $deferred = [], $err = null, p; - /* */ try { $deferFrames.push($deferred); - p = this; - if (p.trace) { - $deferred.push([un, [trace(p, "Expression")]]); + CommentGroup.Ptr.prototype.Text = function() { + var g, comments, _ref, _i, i, c, lines, _ref$1, _i$1, c$1, _ref$2, cl, _ref$3, _i$2, l, n, _ref$4, _i$3, line, x, x$1; + g = this; + if (g === ($ptrType(CommentGroup)).nil) { + return ""; } - return p.parseBinaryExpr(lhs, 1); - /* */ } catch(err) { $err = err; return $ifaceNil; } finally { $deferFrames.pop(); $callDeferred($deferred, $err); } - }; - parser.prototype.parseExpr = function(lhs) { return this.$val.parseExpr(lhs); }; - parser.Ptr.prototype.parseRhs = function() { - var p, old, x; - p = this; - old = p.inRhs; - p.inRhs = true; - x = p.checkExpr(p.parseExpr(false)); - p.inRhs = old; - return x; - }; - parser.prototype.parseRhs = function() { return this.$val.parseRhs(); }; - parser.Ptr.prototype.parseRhsOrType = function() { - var p, old, x; - p = this; - old = p.inRhs; - p.inRhs = true; - x = p.checkExprOrType(p.parseExpr(false)); - p.inRhs = old; - return x; - }; - parser.prototype.parseRhsOrType = function() { return this.$val.parseRhsOrType(); }; - parser.Ptr.prototype.parseSimpleStmt = function(mode) { - var $deferred = [], $err = null, p, x, _ref, _tmp, _tmp$1, pos, tok, y, isRange, pos$1, as, _ref$1, colon, _tuple, label, isIdent, stmt, arrow, y$1, s; - /* */ try { $deferFrames.push($deferred); - p = this; - if (p.trace) { - $deferred.push([un, [trace(p, "SimpleStmt")]]); + comments = ($sliceType($String)).make(g.List.$length); + _ref = g.List; + _i = 0; + while (_i < _ref.$length) { + i = _i; + c = ((_i < 0 || _i >= _ref.$length) ? $throwRuntimeError("index out of range") : _ref.$array[_ref.$offset + _i]); + (i < 0 || i >= comments.$length) ? $throwRuntimeError("index out of range") : comments.$array[comments.$offset + i] = c.Text; + _i++; } - x = p.parseLhsList(); - _ref = p.tok; - if (_ref === 47 || _ref === 42 || _ref === 23 || _ref === 24 || _ref === 25 || _ref === 26 || _ref === 27 || _ref === 28 || _ref === 29 || _ref === 30 || _ref === 31 || _ref === 32 || _ref === 33) { - _tmp = p.pos; _tmp$1 = p.tok; pos = _tmp; tok = _tmp$1; - p.next(); - y = ($sliceType(ast.Expr)).nil; - isRange = false; - if ((mode === 2) && (p.tok === 79) && ((tok === 47) || (tok === 42))) { - pos$1 = p.pos; - p.next(); - y = new ($sliceType(ast.Expr))([new ast.UnaryExpr.Ptr(pos$1, 79, p.parseRhs())]); - isRange = true; - } else { - y = p.parseRhsList(); + lines = ($sliceType($String)).make(0, 10); + _ref$1 = comments; + _i$1 = 0; + while (_i$1 < _ref$1.$length) { + c$1 = ((_i$1 < 0 || _i$1 >= _ref$1.$length) ? $throwRuntimeError("index out of range") : _ref$1.$array[_ref$1.$offset + _i$1]); + _ref$2 = c$1.charCodeAt(1); + if (_ref$2 === 47) { + c$1 = c$1.substring(2); + if (c$1.length > 0 && (c$1.charCodeAt(0) === 32)) { + c$1 = c$1.substring(1); + } + } else if (_ref$2 === 42) { + c$1 = c$1.substring(2, (c$1.length - 2 >> 0)); } - as = new ast.AssignStmt.Ptr(x, pos, tok, y); - if (tok === 47) { - p.shortVarDecl(as, x); + cl = strings.Split(c$1, "\n"); + _ref$3 = cl; + _i$2 = 0; + while (_i$2 < _ref$3.$length) { + l = ((_i$2 < 0 || _i$2 >= _ref$3.$length) ? $throwRuntimeError("index out of range") : _ref$3.$array[_ref$3.$offset + _i$2]); + lines = $append(lines, stripTrailingWhitespace(l)); + _i$2++; } - return [as, isRange]; - } - if (x.$length > 1) { - p.errorExpected(((0 < 0 || 0 >= x.$length) ? $throwRuntimeError("index out of range") : x.$array[x.$offset + 0]).Pos(), "1 expression"); + _i$1++; } - _ref$1 = p.tok; - if (_ref$1 === 58) { - colon = p.pos; - p.next(); - _tuple = $assertType(((0 < 0 || 0 >= x.$length) ? $throwRuntimeError("index out of range") : x.$array[x.$offset + 0]), ($ptrType(ast.Ident)), true); label = _tuple[0]; isIdent = _tuple[1]; - if ((mode === 1) && isIdent) { - stmt = new ast.LabeledStmt.Ptr(label, colon, p.parseStmt()); - p.declare(stmt, $ifaceNil, p.labelScope, 6, new ($sliceType(($ptrType(ast.Ident))))([label])); - return [stmt, false]; + n = 0; + _ref$4 = lines; + _i$3 = 0; + while (_i$3 < _ref$4.$length) { + line = ((_i$3 < 0 || _i$3 >= _ref$4.$length) ? $throwRuntimeError("index out of range") : _ref$4.$array[_ref$4.$offset + _i$3]); + if (!(line === "") || n > 0 && !((x = n - 1 >> 0, ((x < 0 || x >= lines.$length) ? $throwRuntimeError("index out of range") : lines.$array[lines.$offset + x])) === "")) { + (n < 0 || n >= lines.$length) ? $throwRuntimeError("index out of range") : lines.$array[lines.$offset + n] = line; + n = n + (1) >> 0; } - p.error(colon, "illegal label declaration"); - return [new ast.BadStmt.Ptr(((0 < 0 || 0 >= x.$length) ? $throwRuntimeError("index out of range") : x.$array[x.$offset + 0]).Pos(), colon + 1 >> 0), false]; - } else if (_ref$1 === 36) { - arrow = p.pos; - p.next(); - y$1 = p.parseRhs(); - return [new ast.SendStmt.Ptr(((0 < 0 || 0 >= x.$length) ? $throwRuntimeError("index out of range") : x.$array[x.$offset + 0]), arrow, y$1), false]; - } else if (_ref$1 === 37 || _ref$1 === 38) { - s = new ast.IncDecStmt.Ptr(((0 < 0 || 0 >= x.$length) ? $throwRuntimeError("index out of range") : x.$array[x.$offset + 0]), p.pos, p.tok); - p.next(); - return [s, false]; - } - return [new ast.ExprStmt.Ptr(((0 < 0 || 0 >= x.$length) ? $throwRuntimeError("index out of range") : x.$array[x.$offset + 0])), false]; - /* */ } catch(err) { $err = err; return [$ifaceNil, false]; } finally { $deferFrames.pop(); $callDeferred($deferred, $err); } - }; - parser.prototype.parseSimpleStmt = function(mode) { return this.$val.parseSimpleStmt(mode); }; - parser.Ptr.prototype.parseCallExpr = function(callType) { - var p, x, _tuple, call, isCall, _tuple$1, isBad; - p = this; - x = p.parseRhsOrType(); - _tuple = $assertType(x, ($ptrType(ast.CallExpr)), true); call = _tuple[0]; isCall = _tuple[1]; - if (isCall) { - return call; - } - _tuple$1 = $assertType(x, ($ptrType(ast.BadExpr)), true); isBad = _tuple$1[1]; - if (!isBad) { - p.error(p.safePos(x.End()), fmt.Sprintf("function must be invoked in %s statement", new ($sliceType($emptyInterface))([new $String(callType)]))); - } - return ($ptrType(ast.CallExpr)).nil; - }; - parser.prototype.parseCallExpr = function(callType) { return this.$val.parseCallExpr(callType); }; - parser.Ptr.prototype.parseGoStmt = function() { - var $deferred = [], $err = null, p, pos, call; - /* */ try { $deferFrames.push($deferred); - p = this; - if (p.trace) { - $deferred.push([un, [trace(p, "GoStmt")]]); + _i$3++; } - pos = p.expect(72); - call = p.parseCallExpr("go"); - p.expectSemi(); - if (call === ($ptrType(ast.CallExpr)).nil) { - return new ast.BadStmt.Ptr(pos, pos + 2 >> 0); + lines = $subslice(lines, 0, n); + if (n > 0 && !((x$1 = n - 1 >> 0, ((x$1 < 0 || x$1 >= lines.$length) ? $throwRuntimeError("index out of range") : lines.$array[lines.$offset + x$1])) === "")) { + lines = $append(lines, ""); } - return new ast.GoStmt.Ptr(pos, call); - /* */ } catch(err) { $err = err; return $ifaceNil; } finally { $deferFrames.pop(); $callDeferred($deferred, $err); } + return strings.Join(lines, "\n"); }; - parser.prototype.parseGoStmt = function() { return this.$val.parseGoStmt(); }; - parser.Ptr.prototype.parseDeferStmt = function() { - var $deferred = [], $err = null, p, pos, call; - /* */ try { $deferFrames.push($deferred); - p = this; - if (p.trace) { - $deferred.push([un, [trace(p, "DeferStmt")]]); - } - pos = p.expect(67); - call = p.parseCallExpr("defer"); - p.expectSemi(); - if (call === ($ptrType(ast.CallExpr)).nil) { - return new ast.BadStmt.Ptr(pos, pos + 5 >> 0); + CommentGroup.prototype.Text = function() { return this.$val.Text(); }; + Field.Ptr.prototype.Pos = function() { + var f, x; + f = this; + if (f.Names.$length > 0) { + return (x = f.Names, ((0 < 0 || 0 >= x.$length) ? $throwRuntimeError("index out of range") : x.$array[x.$offset + 0])).Pos(); } - return new ast.DeferStmt.Ptr(pos, call); - /* */ } catch(err) { $err = err; return $ifaceNil; } finally { $deferFrames.pop(); $callDeferred($deferred, $err); } + return f.Type.Pos(); }; - parser.prototype.parseDeferStmt = function() { return this.$val.parseDeferStmt(); }; - parser.Ptr.prototype.parseReturnStmt = function() { - var $deferred = [], $err = null, p, pos, x; - /* */ try { $deferFrames.push($deferred); - p = this; - if (p.trace) { - $deferred.push([un, [trace(p, "ReturnStmt")]]); - } - pos = p.pos; - p.expect(80); - x = ($sliceType(ast.Expr)).nil; - if (!((p.tok === 57)) && !((p.tok === 56))) { - x = p.parseRhsList(); + Field.prototype.Pos = function() { return this.$val.Pos(); }; + Field.Ptr.prototype.End = function() { + var f; + f = this; + if (!(f.Tag === ($ptrType(BasicLit)).nil)) { + return f.Tag.End(); } - p.expectSemi(); - return new ast.ReturnStmt.Ptr(pos, x); - /* */ } catch(err) { $err = err; return ($ptrType(ast.ReturnStmt)).nil; } finally { $deferFrames.pop(); $callDeferred($deferred, $err); } + return f.Type.End(); }; - parser.prototype.parseReturnStmt = function() { return this.$val.parseReturnStmt(); }; - parser.Ptr.prototype.parseBranchStmt = function(tok) { - var $deferred = [], $err = null, p, pos, label, n, x, x$1; - /* */ try { $deferFrames.push($deferred); - p = this; - if (p.trace) { - $deferred.push([un, [trace(p, "BranchStmt")]]); + Field.prototype.End = function() { return this.$val.End(); }; + FieldList.Ptr.prototype.Pos = function() { + var f, x; + f = this; + if ((new token.Pos(f.Opening)).IsValid()) { + return f.Opening; } - pos = p.expect(tok); - label = ($ptrType(ast.Ident)).nil; - if (!((tok === 69)) && (p.tok === 4)) { - label = p.parseIdent(); - n = p.targetStack.$length - 1 >> 0; - (x$1 = p.targetStack, (n < 0 || n >= x$1.$length) ? $throwRuntimeError("index out of range") : x$1.$array[x$1.$offset + n] = $append((x = p.targetStack, ((n < 0 || n >= x.$length) ? $throwRuntimeError("index out of range") : x.$array[x.$offset + n])), label)); + if (f.List.$length > 0) { + return (x = f.List, ((0 < 0 || 0 >= x.$length) ? $throwRuntimeError("index out of range") : x.$array[x.$offset + 0])).Pos(); } - p.expectSemi(); - return new ast.BranchStmt.Ptr(pos, tok, label); - /* */ } catch(err) { $err = err; return ($ptrType(ast.BranchStmt)).nil; } finally { $deferFrames.pop(); $callDeferred($deferred, $err); } + return 0; }; - parser.prototype.parseBranchStmt = function(tok) { return this.$val.parseBranchStmt(tok); }; - parser.Ptr.prototype.makeExpr = function(s, kind) { - var p, _tuple, es, isExpr; - p = this; - if ($interfaceIsEqual(s, $ifaceNil)) { - return $ifaceNil; + FieldList.prototype.Pos = function() { return this.$val.Pos(); }; + FieldList.Ptr.prototype.End = function() { + var f, n, x, x$1; + f = this; + if ((new token.Pos(f.Closing)).IsValid()) { + return f.Closing + 1 >> 0; } - _tuple = $assertType(s, ($ptrType(ast.ExprStmt)), true); es = _tuple[0]; isExpr = _tuple[1]; - if (isExpr) { - return p.checkExpr(es.X); + n = f.List.$length; + if (n > 0) { + return (x = f.List, x$1 = n - 1 >> 0, ((x$1 < 0 || x$1 >= x.$length) ? $throwRuntimeError("index out of range") : x.$array[x.$offset + x$1])).End(); } - p.error(s.Pos(), fmt.Sprintf("expected %s, found simple statement (missing parentheses around composite literal?)", new ($sliceType($emptyInterface))([new $String(kind)]))); - return new ast.BadExpr.Ptr(s.Pos(), p.safePos(s.End())); + return 0; }; - parser.prototype.makeExpr = function(s, kind) { return this.$val.makeExpr(s, kind); }; - parser.Ptr.prototype.parseIfStmt = function() { - var $deferred = [], $err = null, p, pos, s, x, prevLev, _tuple, body, else_; - /* */ try { $deferFrames.push($deferred); - p = this; - if (p.trace) { - $deferred.push([un, [trace(p, "IfStmt")]]); - } - pos = p.expect(74); - p.openScope(); - $deferred.push([$methodVal(p, "closeScope"), []]); - s = $ifaceNil; - x = $ifaceNil; - prevLev = p.exprLev; - p.exprLev = -1; - if (p.tok === 57) { - p.next(); - x = p.parseRhs(); - } else { - _tuple = p.parseSimpleStmt(0); s = _tuple[0]; - if (p.tok === 57) { - p.next(); - x = p.parseRhs(); - } else { - x = p.makeExpr(s, "boolean expression"); - s = $ifaceNil; + FieldList.prototype.End = function() { return this.$val.End(); }; + FieldList.Ptr.prototype.NumFields = function() { + var f, n, _ref, _i, g, m; + f = this; + n = 0; + if (!(f === ($ptrType(FieldList)).nil)) { + _ref = f.List; + _i = 0; + while (_i < _ref.$length) { + g = ((_i < 0 || _i >= _ref.$length) ? $throwRuntimeError("index out of range") : _ref.$array[_ref.$offset + _i]); + m = g.Names.$length; + if (m === 0) { + m = 1; + } + n = n + (m) >> 0; + _i++; } } - p.exprLev = prevLev; - body = p.parseBlockStmt(); - else_ = $ifaceNil; - if (p.tok === 68) { - p.next(); - else_ = p.parseStmt(); - } else { - p.expectSemi(); + return n; + }; + FieldList.prototype.NumFields = function() { return this.$val.NumFields(); }; + BadExpr.Ptr.prototype.Pos = function() { + var x; + x = this; + return x.From; + }; + BadExpr.prototype.Pos = function() { return this.$val.Pos(); }; + Ident.Ptr.prototype.Pos = function() { + var x; + x = this; + return x.NamePos; + }; + Ident.prototype.Pos = function() { return this.$val.Pos(); }; + Ellipsis.Ptr.prototype.Pos = function() { + var x; + x = this; + return x.Ellipsis; + }; + Ellipsis.prototype.Pos = function() { return this.$val.Pos(); }; + BasicLit.Ptr.prototype.Pos = function() { + var x; + x = this; + return x.ValuePos; + }; + BasicLit.prototype.Pos = function() { return this.$val.Pos(); }; + FuncLit.Ptr.prototype.Pos = function() { + var x; + x = this; + return x.Type.Pos(); + }; + FuncLit.prototype.Pos = function() { return this.$val.Pos(); }; + CompositeLit.Ptr.prototype.Pos = function() { + var x; + x = this; + if (!($interfaceIsEqual(x.Type, $ifaceNil))) { + return x.Type.Pos(); } - return new ast.IfStmt.Ptr(pos, s, x, body, else_); - /* */ } catch(err) { $err = err; return ($ptrType(ast.IfStmt)).nil; } finally { $deferFrames.pop(); $callDeferred($deferred, $err); } + return x.Lbrace; }; - parser.prototype.parseIfStmt = function() { return this.$val.parseIfStmt(); }; - parser.Ptr.prototype.parseTypeList = function() { - var list = ($sliceType(ast.Expr)).nil, $deferred = [], $err = null, p; - /* */ try { $deferFrames.push($deferred); - p = this; - if (p.trace) { - $deferred.push([un, [trace(p, "TypeList")]]); + CompositeLit.prototype.Pos = function() { return this.$val.Pos(); }; + ParenExpr.Ptr.prototype.Pos = function() { + var x; + x = this; + return x.Lparen; + }; + ParenExpr.prototype.Pos = function() { return this.$val.Pos(); }; + SelectorExpr.Ptr.prototype.Pos = function() { + var x; + x = this; + return x.X.Pos(); + }; + SelectorExpr.prototype.Pos = function() { return this.$val.Pos(); }; + IndexExpr.Ptr.prototype.Pos = function() { + var x; + x = this; + return x.X.Pos(); + }; + IndexExpr.prototype.Pos = function() { return this.$val.Pos(); }; + SliceExpr.Ptr.prototype.Pos = function() { + var x; + x = this; + return x.X.Pos(); + }; + SliceExpr.prototype.Pos = function() { return this.$val.Pos(); }; + TypeAssertExpr.Ptr.prototype.Pos = function() { + var x; + x = this; + return x.X.Pos(); + }; + TypeAssertExpr.prototype.Pos = function() { return this.$val.Pos(); }; + CallExpr.Ptr.prototype.Pos = function() { + var x; + x = this; + return x.Fun.Pos(); + }; + CallExpr.prototype.Pos = function() { return this.$val.Pos(); }; + StarExpr.Ptr.prototype.Pos = function() { + var x; + x = this; + return x.Star; + }; + StarExpr.prototype.Pos = function() { return this.$val.Pos(); }; + UnaryExpr.Ptr.prototype.Pos = function() { + var x; + x = this; + return x.OpPos; + }; + UnaryExpr.prototype.Pos = function() { return this.$val.Pos(); }; + BinaryExpr.Ptr.prototype.Pos = function() { + var x; + x = this; + return x.X.Pos(); + }; + BinaryExpr.prototype.Pos = function() { return this.$val.Pos(); }; + KeyValueExpr.Ptr.prototype.Pos = function() { + var x; + x = this; + return x.Key.Pos(); + }; + KeyValueExpr.prototype.Pos = function() { return this.$val.Pos(); }; + ArrayType.Ptr.prototype.Pos = function() { + var x; + x = this; + return x.Lbrack; + }; + ArrayType.prototype.Pos = function() { return this.$val.Pos(); }; + StructType.Ptr.prototype.Pos = function() { + var x; + x = this; + return x.Struct; + }; + StructType.prototype.Pos = function() { return this.$val.Pos(); }; + FuncType.Ptr.prototype.Pos = function() { + var x; + x = this; + if ((new token.Pos(x.Func)).IsValid() || x.Params === ($ptrType(FieldList)).nil) { + return x.Func; } - list = $append(list, p.parseType()); - while (p.tok === 52) { - p.next(); - list = $append(list, p.parseType()); + return x.Params.Pos(); + }; + FuncType.prototype.Pos = function() { return this.$val.Pos(); }; + InterfaceType.Ptr.prototype.Pos = function() { + var x; + x = this; + return x.Interface; + }; + InterfaceType.prototype.Pos = function() { return this.$val.Pos(); }; + MapType.Ptr.prototype.Pos = function() { + var x; + x = this; + return x.Map; + }; + MapType.prototype.Pos = function() { return this.$val.Pos(); }; + ChanType.Ptr.prototype.Pos = function() { + var x; + x = this; + return x.Begin; + }; + ChanType.prototype.Pos = function() { return this.$val.Pos(); }; + BadExpr.Ptr.prototype.End = function() { + var x; + x = this; + return x.To; + }; + BadExpr.prototype.End = function() { return this.$val.End(); }; + Ident.Ptr.prototype.End = function() { + var x; + x = this; + return (((x.NamePos >> 0) + x.Name.length >> 0) >> 0); + }; + Ident.prototype.End = function() { return this.$val.End(); }; + Ellipsis.Ptr.prototype.End = function() { + var x; + x = this; + if (!($interfaceIsEqual(x.Elt, $ifaceNil))) { + return x.Elt.End(); } - return list; - /* */ } catch(err) { $err = err; } finally { $deferFrames.pop(); $callDeferred($deferred, $err); return list; } + return x.Ellipsis + 3 >> 0; + }; + Ellipsis.prototype.End = function() { return this.$val.End(); }; + BasicLit.Ptr.prototype.End = function() { + var x; + x = this; + return (((x.ValuePos >> 0) + x.Value.length >> 0) >> 0); + }; + BasicLit.prototype.End = function() { return this.$val.End(); }; + FuncLit.Ptr.prototype.End = function() { + var x; + x = this; + return x.Body.End(); + }; + FuncLit.prototype.End = function() { return this.$val.End(); }; + CompositeLit.Ptr.prototype.End = function() { + var x; + x = this; + return x.Rbrace + 1 >> 0; + }; + CompositeLit.prototype.End = function() { return this.$val.End(); }; + ParenExpr.Ptr.prototype.End = function() { + var x; + x = this; + return x.Rparen + 1 >> 0; + }; + ParenExpr.prototype.End = function() { return this.$val.End(); }; + SelectorExpr.Ptr.prototype.End = function() { + var x; + x = this; + return x.Sel.End(); + }; + SelectorExpr.prototype.End = function() { return this.$val.End(); }; + IndexExpr.Ptr.prototype.End = function() { + var x; + x = this; + return x.Rbrack + 1 >> 0; + }; + IndexExpr.prototype.End = function() { return this.$val.End(); }; + SliceExpr.Ptr.prototype.End = function() { + var x; + x = this; + return x.Rbrack + 1 >> 0; + }; + SliceExpr.prototype.End = function() { return this.$val.End(); }; + TypeAssertExpr.Ptr.prototype.End = function() { + var x; + x = this; + return x.Rparen + 1 >> 0; + }; + TypeAssertExpr.prototype.End = function() { return this.$val.End(); }; + CallExpr.Ptr.prototype.End = function() { + var x; + x = this; + return x.Rparen + 1 >> 0; + }; + CallExpr.prototype.End = function() { return this.$val.End(); }; + StarExpr.Ptr.prototype.End = function() { + var x; + x = this; + return x.X.End(); + }; + StarExpr.prototype.End = function() { return this.$val.End(); }; + UnaryExpr.Ptr.prototype.End = function() { + var x; + x = this; + return x.X.End(); + }; + UnaryExpr.prototype.End = function() { return this.$val.End(); }; + BinaryExpr.Ptr.prototype.End = function() { + var x; + x = this; + return x.Y.End(); + }; + BinaryExpr.prototype.End = function() { return this.$val.End(); }; + KeyValueExpr.Ptr.prototype.End = function() { + var x; + x = this; + return x.Value.End(); + }; + KeyValueExpr.prototype.End = function() { return this.$val.End(); }; + ArrayType.Ptr.prototype.End = function() { + var x; + x = this; + return x.Elt.End(); + }; + ArrayType.prototype.End = function() { return this.$val.End(); }; + StructType.Ptr.prototype.End = function() { + var x; + x = this; + return x.Fields.End(); }; - parser.prototype.parseTypeList = function() { return this.$val.parseTypeList(); }; - parser.Ptr.prototype.parseCaseClause = function(typeSwitch) { - var $deferred = [], $err = null, p, pos, list, colon, body; - /* */ try { $deferFrames.push($deferred); - p = this; - if (p.trace) { - $deferred.push([un, [trace(p, "CaseClause")]]); - } - pos = p.pos; - list = ($sliceType(ast.Expr)).nil; - if (p.tok === 62) { - p.next(); - if (typeSwitch) { - list = p.parseTypeList(); - } else { - list = p.parseRhsList(); - } - } else { - p.expect(66); + StructType.prototype.End = function() { return this.$val.End(); }; + FuncType.Ptr.prototype.End = function() { + var x; + x = this; + if (!(x.Results === ($ptrType(FieldList)).nil)) { + return x.Results.End(); } - colon = p.expect(58); - p.openScope(); - body = p.parseStmtList(); - p.closeScope(); - return new ast.CaseClause.Ptr(pos, list, colon, body); - /* */ } catch(err) { $err = err; return ($ptrType(ast.CaseClause)).nil; } finally { $deferFrames.pop(); $callDeferred($deferred, $err); } + return x.Params.End(); }; - parser.prototype.parseCaseClause = function(typeSwitch) { return this.$val.parseCaseClause(typeSwitch); }; - isTypeSwitchAssert = function(x) { - var _tuple, a, ok; - _tuple = $assertType(x, ($ptrType(ast.TypeAssertExpr)), true); a = _tuple[0]; ok = _tuple[1]; - return ok && $interfaceIsEqual(a.Type, $ifaceNil); + FuncType.prototype.End = function() { return this.$val.End(); }; + InterfaceType.Ptr.prototype.End = function() { + var x; + x = this; + return x.Methods.End(); }; - isTypeSwitchGuard = function(s) { - var t, _ref, x; - _ref = s; - if ($assertType(_ref, ($ptrType(ast.ExprStmt)), true)[1]) { - t = _ref.$val; - return isTypeSwitchAssert(t.X); - } else if ($assertType(_ref, ($ptrType(ast.AssignStmt)), true)[1]) { - t = _ref.$val; - return (t.Lhs.$length === 1) && (t.Tok === 47) && (t.Rhs.$length === 1) && isTypeSwitchAssert((x = t.Rhs, ((0 < 0 || 0 >= x.$length) ? $throwRuntimeError("index out of range") : x.$array[x.$offset + 0]))); - } - return false; + InterfaceType.prototype.End = function() { return this.$val.End(); }; + MapType.Ptr.prototype.End = function() { + var x; + x = this; + return x.Value.End(); }; - parser.Ptr.prototype.parseSwitchStmt = function() { - var $deferred = [], $err = null, p, pos, _tmp, _tmp$1, s1, s2, prevLev, _tuple, _tuple$1, typeSwitch, lbrace, list, rbrace, body; - /* */ try { $deferFrames.push($deferred); - p = this; - if (p.trace) { - $deferred.push([un, [trace(p, "SwitchStmt")]]); - } - pos = p.expect(83); - p.openScope(); - $deferred.push([$methodVal(p, "closeScope"), []]); - _tmp = $ifaceNil; _tmp$1 = $ifaceNil; s1 = _tmp; s2 = _tmp$1; - if (!((p.tok === 51))) { - prevLev = p.exprLev; - p.exprLev = -1; - if (!((p.tok === 57))) { - _tuple = p.parseSimpleStmt(0); s2 = _tuple[0]; - } - if (p.tok === 57) { - p.next(); - s1 = s2; - s2 = $ifaceNil; - if (!((p.tok === 51))) { - p.openScope(); - $deferred.push([$methodVal(p, "closeScope"), []]); - _tuple$1 = p.parseSimpleStmt(0); s2 = _tuple$1[0]; - } - } - p.exprLev = prevLev; - } - typeSwitch = isTypeSwitchGuard(s2); - lbrace = p.expect(51); - list = ($sliceType(ast.Stmt)).nil; - while ((p.tok === 62) || (p.tok === 66)) { - list = $append(list, p.parseCaseClause(typeSwitch)); - } - rbrace = p.expect(56); - p.expectSemi(); - body = new ast.BlockStmt.Ptr(lbrace, list, rbrace); - if (typeSwitch) { - return new ast.TypeSwitchStmt.Ptr(pos, s1, s2, body); - } - return new ast.SwitchStmt.Ptr(pos, s1, p.makeExpr(s2, "switch expression"), body); - /* */ } catch(err) { $err = err; return $ifaceNil; } finally { $deferFrames.pop(); $callDeferred($deferred, $err); } + MapType.prototype.End = function() { return this.$val.End(); }; + ChanType.Ptr.prototype.End = function() { + var x; + x = this; + return x.Value.End(); }; - parser.prototype.parseSwitchStmt = function() { return this.$val.parseSwitchStmt(); }; - parser.Ptr.prototype.parseCommClause = function() { - var $deferred = [], $err = null, p, pos, comm, lhs, arrow, rhs, tok, pos$1, rhs$1, as, colon, body; - /* */ try { $deferFrames.push($deferred); - p = this; - if (p.trace) { - $deferred.push([un, [trace(p, "CommClause")]]); - } - p.openScope(); - pos = p.pos; - comm = $ifaceNil; - if (p.tok === 62) { - p.next(); - lhs = p.parseLhsList(); - if (p.tok === 36) { - if (lhs.$length > 1) { - p.errorExpected(((0 < 0 || 0 >= lhs.$length) ? $throwRuntimeError("index out of range") : lhs.$array[lhs.$offset + 0]).Pos(), "1 expression"); - } - arrow = p.pos; - p.next(); - rhs = p.parseRhs(); - comm = new ast.SendStmt.Ptr(((0 < 0 || 0 >= lhs.$length) ? $throwRuntimeError("index out of range") : lhs.$array[lhs.$offset + 0]), arrow, rhs); - } else { - tok = p.tok; - if ((tok === 42) || (tok === 47)) { - if (lhs.$length > 2) { - p.errorExpected(((0 < 0 || 0 >= lhs.$length) ? $throwRuntimeError("index out of range") : lhs.$array[lhs.$offset + 0]).Pos(), "1 or 2 expressions"); - lhs = $subslice(lhs, 0, 2); - } - pos$1 = p.pos; - p.next(); - rhs$1 = p.parseRhs(); - as = new ast.AssignStmt.Ptr(lhs, pos$1, tok, new ($sliceType(ast.Expr))([rhs$1])); - if (tok === 47) { - p.shortVarDecl(as, lhs); - } - comm = as; - } else { - if (lhs.$length > 1) { - p.errorExpected(((0 < 0 || 0 >= lhs.$length) ? $throwRuntimeError("index out of range") : lhs.$array[lhs.$offset + 0]).Pos(), "1 expression"); - } - comm = new ast.ExprStmt.Ptr(((0 < 0 || 0 >= lhs.$length) ? $throwRuntimeError("index out of range") : lhs.$array[lhs.$offset + 0])); - } - } - } else { - p.expect(66); - } - colon = p.expect(58); - body = p.parseStmtList(); - p.closeScope(); - return new ast.CommClause.Ptr(pos, comm, colon, body); - /* */ } catch(err) { $err = err; return ($ptrType(ast.CommClause)).nil; } finally { $deferFrames.pop(); $callDeferred($deferred, $err); } + ChanType.prototype.End = function() { return this.$val.End(); }; + NewIdent = $pkg.NewIdent = function(name) { + return new Ident.Ptr(0, name, ($ptrType(Object)).nil); }; - parser.prototype.parseCommClause = function() { return this.$val.parseCommClause(); }; - parser.Ptr.prototype.parseSelectStmt = function() { - var $deferred = [], $err = null, p, pos, lbrace, list, rbrace, body; - /* */ try { $deferFrames.push($deferred); - p = this; - if (p.trace) { - $deferred.push([un, [trace(p, "SelectStmt")]]); - } - pos = p.expect(81); - lbrace = p.expect(51); - list = ($sliceType(ast.Stmt)).nil; - while ((p.tok === 62) || (p.tok === 66)) { - list = $append(list, p.parseCommClause()); - } - rbrace = p.expect(56); - p.expectSemi(); - body = new ast.BlockStmt.Ptr(lbrace, list, rbrace); - return new ast.SelectStmt.Ptr(pos, body); - /* */ } catch(err) { $err = err; return ($ptrType(ast.SelectStmt)).nil; } finally { $deferFrames.pop(); $callDeferred($deferred, $err); } + IsExported = $pkg.IsExported = function(name) { + var _tuple, ch; + _tuple = utf8.DecodeRuneInString(name); ch = _tuple[0]; + return unicode.IsUpper(ch); }; - parser.prototype.parseSelectStmt = function() { return this.$val.parseSelectStmt(); }; - parser.Ptr.prototype.parseForStmt = function() { - var $deferred = [], $err = null, p, pos, _tmp, _tmp$1, _tmp$2, s1, s2, s3, isRange, prevLev, _tuple, _tuple$1, _tuple$2, body, as, _tmp$3, _tmp$4, key, value, _ref, _tmp$5, x, _tmp$6, x$1, x$2, x$3, x$4, x$5; - /* */ try { $deferFrames.push($deferred); - p = this; - if (p.trace) { - $deferred.push([un, [trace(p, "ForStmt")]]); - } - pos = p.expect(70); - p.openScope(); - $deferred.push([$methodVal(p, "closeScope"), []]); - _tmp = $ifaceNil; _tmp$1 = $ifaceNil; _tmp$2 = $ifaceNil; s1 = _tmp; s2 = _tmp$1; s3 = _tmp$2; - isRange = false; - if (!((p.tok === 51))) { - prevLev = p.exprLev; - p.exprLev = -1; - if (!((p.tok === 57))) { - _tuple = p.parseSimpleStmt(2); s2 = _tuple[0]; isRange = _tuple[1]; - } - if (!isRange && (p.tok === 57)) { - p.next(); - s1 = s2; - s2 = $ifaceNil; - if (!((p.tok === 57))) { - _tuple$1 = p.parseSimpleStmt(0); s2 = _tuple$1[0]; - } - p.expectSemi(); - if (!((p.tok === 51))) { - _tuple$2 = p.parseSimpleStmt(0); s3 = _tuple$2[0]; - } - } - p.exprLev = prevLev; - } - body = p.parseBlockStmt(); - p.expectSemi(); - if (isRange) { - as = $assertType(s2, ($ptrType(ast.AssignStmt))); - _tmp$3 = $ifaceNil; _tmp$4 = $ifaceNil; key = _tmp$3; value = _tmp$4; - _ref = as.Lhs.$length; - if (_ref === 2) { - _tmp$5 = (x = as.Lhs, ((0 < 0 || 0 >= x.$length) ? $throwRuntimeError("index out of range") : x.$array[x.$offset + 0])); _tmp$6 = (x$1 = as.Lhs, ((1 < 0 || 1 >= x$1.$length) ? $throwRuntimeError("index out of range") : x$1.$array[x$1.$offset + 1])); key = _tmp$5; value = _tmp$6; - } else if (_ref === 1) { - key = (x$2 = as.Lhs, ((0 < 0 || 0 >= x$2.$length) ? $throwRuntimeError("index out of range") : x$2.$array[x$2.$offset + 0])); - } else { - p.errorExpected((x$3 = as.Lhs, ((0 < 0 || 0 >= x$3.$length) ? $throwRuntimeError("index out of range") : x$3.$array[x$3.$offset + 0])).Pos(), "1 or 2 expressions"); - return new ast.BadStmt.Ptr(pos, p.safePos(body.End())); - } - x$5 = $assertType((x$4 = as.Rhs, ((0 < 0 || 0 >= x$4.$length) ? $throwRuntimeError("index out of range") : x$4.$array[x$4.$offset + 0])), ($ptrType(ast.UnaryExpr))).X; - return new ast.RangeStmt.Ptr(pos, key, value, as.TokPos, as.Tok, x$5, body); - } - return new ast.ForStmt.Ptr(pos, s1, p.makeExpr(s2, "boolean or range expression"), s3, body); - /* */ } catch(err) { $err = err; return $ifaceNil; } finally { $deferFrames.pop(); $callDeferred($deferred, $err); } + Ident.Ptr.prototype.IsExported = function() { + var id; + id = this; + return IsExported(id.Name); }; - parser.prototype.parseForStmt = function() { return this.$val.parseForStmt(); }; - parser.Ptr.prototype.parseStmt = function() { - var s = $ifaceNil, $deferred = [], $err = null, p, _ref, _tuple, _tuple$1, isLabeledStmt, pos; - /* */ try { $deferFrames.push($deferred); - p = this; - if (p.trace) { - $deferred.push([un, [trace(p, "Statement")]]); - } - _ref = p.tok; - if (_ref === 64 || _ref === 84 || _ref === 85) { - s = new ast.DeclStmt.Ptr(p.parseDecl(syncStmt)); - } else if (_ref === 4 || _ref === 5 || _ref === 6 || _ref === 7 || _ref === 8 || _ref === 9 || _ref === 71 || _ref === 49 || _ref === 50 || _ref === 82 || _ref === 12 || _ref === 13 || _ref === 14 || _ref === 17 || _ref === 19 || _ref === 36 || _ref === 43) { - _tuple = p.parseSimpleStmt(1); s = _tuple[0]; - _tuple$1 = $assertType(s, ($ptrType(ast.LabeledStmt)), true); isLabeledStmt = _tuple$1[1]; - if (!isLabeledStmt) { - p.expectSemi(); - } - } else if (_ref === 72) { - s = p.parseGoStmt(); - } else if (_ref === 67) { - s = p.parseDeferStmt(); - } else if (_ref === 80) { - s = p.parseReturnStmt(); - } else if (_ref === 61 || _ref === 65 || _ref === 73 || _ref === 69) { - s = p.parseBranchStmt(p.tok); - } else if (_ref === 51) { - s = p.parseBlockStmt(); - p.expectSemi(); - } else if (_ref === 74) { - s = p.parseIfStmt(); - } else if (_ref === 83) { - s = p.parseSwitchStmt(); - } else if (_ref === 81) { - s = p.parseSelectStmt(); - } else if (_ref === 70) { - s = p.parseForStmt(); - } else if (_ref === 57) { - s = new ast.EmptyStmt.Ptr(p.pos); - p.next(); - } else if (_ref === 56) { - s = new ast.EmptyStmt.Ptr(p.pos); - } else { - pos = p.pos; - p.errorExpected(pos, "statement"); - syncStmt(p); - s = new ast.BadStmt.Ptr(pos, p.pos); + Ident.prototype.IsExported = function() { return this.$val.IsExported(); }; + Ident.Ptr.prototype.String = function() { + var id; + id = this; + if (!(id === ($ptrType(Ident)).nil)) { + return id.Name; } - return s; - /* */ } catch(err) { $err = err; } finally { $deferFrames.pop(); $callDeferred($deferred, $err); return s; } + return ""; }; - parser.prototype.parseStmt = function() { return this.$val.parseStmt(); }; - isValidImport = function(lit) { - var _tuple, s, _ref, _i, _rune, r; - _tuple = strconv.Unquote(lit); s = _tuple[0]; - _ref = s; - _i = 0; - while (_i < _ref.length) { - _rune = $decodeRune(_ref, _i); - r = _rune[0]; - if (!unicode.IsGraphic(r) || unicode.IsSpace(r) || strings.ContainsRune("!\"#$%&'()*,:;<=>?[\\]^{|}`\xEF\xBF\xBD", r)) { - return false; - } - _i += _rune[1]; - } - return !(s === ""); + Ident.prototype.String = function() { return this.$val.String(); }; + BadStmt.Ptr.prototype.Pos = function() { + var s; + s = this; + return s.From; }; - parser.Ptr.prototype.parseImportSpec = function(doc, param, param$1) { - var $deferred = [], $err = null, p, ident, _ref, pos, path, spec; - /* */ try { $deferFrames.push($deferred); - p = this; - if (p.trace) { - $deferred.push([un, [trace(p, "ImportSpec")]]); - } - ident = ($ptrType(ast.Ident)).nil; - _ref = p.tok; - if (_ref === 53) { - ident = new ast.Ident.Ptr(p.pos, ".", ($ptrType(ast.Object)).nil); - p.next(); - } else if (_ref === 4) { - ident = p.parseIdent(); - } - pos = p.pos; - path = ""; - if (p.tok === 9) { - path = p.lit; - if (!isValidImport(path)) { - p.error(pos, "invalid import path: " + path); - } - p.next(); - } else { - p.expect(9); - } - p.expectSemi(); - spec = new ast.ImportSpec.Ptr(doc, ident, new ast.BasicLit.Ptr(pos, 9, path), p.lineComment, 0); - p.imports = $append(p.imports, spec); - return spec; - /* */ } catch(err) { $err = err; return $ifaceNil; } finally { $deferFrames.pop(); $callDeferred($deferred, $err); } + BadStmt.prototype.Pos = function() { return this.$val.Pos(); }; + DeclStmt.Ptr.prototype.Pos = function() { + var s; + s = this; + return s.Decl.Pos(); }; - parser.prototype.parseImportSpec = function(doc, param, param$1) { return this.$val.parseImportSpec(doc, param, param$1); }; - parser.Ptr.prototype.parseValueSpec = function(doc, keyword, iota) { - var $deferred = [], $err = null, p, idents, typ, values, spec, kind; - /* */ try { $deferFrames.push($deferred); - p = this; - if (p.trace) { - $deferred.push([un, [trace(p, (new token.Token(keyword)).String() + "Spec")]]); - } - idents = p.parseIdentList(); - typ = p.tryType(); - values = ($sliceType(ast.Expr)).nil; - if (p.tok === 42) { - p.next(); - values = p.parseRhsList(); - } - p.expectSemi(); - spec = new ast.ValueSpec.Ptr(doc, idents, typ, values, p.lineComment); - kind = 2; - if (keyword === 85) { - kind = 4; - } - p.declare(spec, new $Int(iota), p.topScope, kind, idents); - return spec; - /* */ } catch(err) { $err = err; return $ifaceNil; } finally { $deferFrames.pop(); $callDeferred($deferred, $err); } + DeclStmt.prototype.Pos = function() { return this.$val.Pos(); }; + EmptyStmt.Ptr.prototype.Pos = function() { + var s; + s = this; + return s.Semicolon; }; - parser.prototype.parseValueSpec = function(doc, keyword, iota) { return this.$val.parseValueSpec(doc, keyword, iota); }; - parser.Ptr.prototype.parseTypeSpec = function(doc, param, param$1) { - var $deferred = [], $err = null, p, ident, spec; - /* */ try { $deferFrames.push($deferred); - p = this; - if (p.trace) { - $deferred.push([un, [trace(p, "TypeSpec")]]); - } - ident = p.parseIdent(); - spec = new ast.TypeSpec.Ptr(doc, ident, $ifaceNil, ($ptrType(ast.CommentGroup)).nil); - p.declare(spec, $ifaceNil, p.topScope, 3, new ($sliceType(($ptrType(ast.Ident))))([ident])); - spec.Type = p.parseType(); - p.expectSemi(); - spec.Comment = p.lineComment; - return spec; - /* */ } catch(err) { $err = err; return $ifaceNil; } finally { $deferFrames.pop(); $callDeferred($deferred, $err); } + EmptyStmt.prototype.Pos = function() { return this.$val.Pos(); }; + LabeledStmt.Ptr.prototype.Pos = function() { + var s; + s = this; + return s.Label.Pos(); }; - parser.prototype.parseTypeSpec = function(doc, param, param$1) { return this.$val.parseTypeSpec(doc, param, param$1); }; - parser.Ptr.prototype.parseGenDecl = function(keyword, f) { - var $deferred = [], $err = null, p, doc, pos, _tmp, _tmp$1, lparen, rparen, list, iota; - /* */ try { $deferFrames.push($deferred); - p = this; - if (p.trace) { - $deferred.push([un, [trace(p, "GenDecl(" + (new token.Token(keyword)).String() + ")")]]); - } - doc = p.leadComment; - pos = p.expect(keyword); - _tmp = 0; _tmp$1 = 0; lparen = _tmp; rparen = _tmp$1; - list = ($sliceType(ast.Spec)).nil; - if (p.tok === 49) { - lparen = p.pos; - p.next(); - iota = 0; - while (!((p.tok === 54)) && !((p.tok === 1))) { - list = $append(list, f(p.leadComment, keyword, iota)); - iota = iota + (1) >> 0; - } - rparen = p.expect(54); - p.expectSemi(); - } else { - list = $append(list, f(($ptrType(ast.CommentGroup)).nil, keyword, 0)); - } - return new ast.GenDecl.Ptr(doc, pos, keyword, lparen, list, rparen); - /* */ } catch(err) { $err = err; return ($ptrType(ast.GenDecl)).nil; } finally { $deferFrames.pop(); $callDeferred($deferred, $err); } + LabeledStmt.prototype.Pos = function() { return this.$val.Pos(); }; + ExprStmt.Ptr.prototype.Pos = function() { + var s; + s = this; + return s.X.Pos(); + }; + ExprStmt.prototype.Pos = function() { return this.$val.Pos(); }; + SendStmt.Ptr.prototype.Pos = function() { + var s; + s = this; + return s.Chan.Pos(); + }; + SendStmt.prototype.Pos = function() { return this.$val.Pos(); }; + IncDecStmt.Ptr.prototype.Pos = function() { + var s; + s = this; + return s.X.Pos(); + }; + IncDecStmt.prototype.Pos = function() { return this.$val.Pos(); }; + AssignStmt.Ptr.prototype.Pos = function() { + var s, x; + s = this; + return (x = s.Lhs, ((0 < 0 || 0 >= x.$length) ? $throwRuntimeError("index out of range") : x.$array[x.$offset + 0])).Pos(); + }; + AssignStmt.prototype.Pos = function() { return this.$val.Pos(); }; + GoStmt.Ptr.prototype.Pos = function() { + var s; + s = this; + return s.Go; + }; + GoStmt.prototype.Pos = function() { return this.$val.Pos(); }; + DeferStmt.Ptr.prototype.Pos = function() { + var s; + s = this; + return s.Defer; + }; + DeferStmt.prototype.Pos = function() { return this.$val.Pos(); }; + ReturnStmt.Ptr.prototype.Pos = function() { + var s; + s = this; + return s.Return; + }; + ReturnStmt.prototype.Pos = function() { return this.$val.Pos(); }; + BranchStmt.Ptr.prototype.Pos = function() { + var s; + s = this; + return s.TokPos; + }; + BranchStmt.prototype.Pos = function() { return this.$val.Pos(); }; + BlockStmt.Ptr.prototype.Pos = function() { + var s; + s = this; + return s.Lbrace; + }; + BlockStmt.prototype.Pos = function() { return this.$val.Pos(); }; + IfStmt.Ptr.prototype.Pos = function() { + var s; + s = this; + return s.If; + }; + IfStmt.prototype.Pos = function() { return this.$val.Pos(); }; + CaseClause.Ptr.prototype.Pos = function() { + var s; + s = this; + return s.Case; + }; + CaseClause.prototype.Pos = function() { return this.$val.Pos(); }; + SwitchStmt.Ptr.prototype.Pos = function() { + var s; + s = this; + return s.Switch; + }; + SwitchStmt.prototype.Pos = function() { return this.$val.Pos(); }; + TypeSwitchStmt.Ptr.prototype.Pos = function() { + var s; + s = this; + return s.Switch; + }; + TypeSwitchStmt.prototype.Pos = function() { return this.$val.Pos(); }; + CommClause.Ptr.prototype.Pos = function() { + var s; + s = this; + return s.Case; }; - parser.prototype.parseGenDecl = function(keyword, f) { return this.$val.parseGenDecl(keyword, f); }; - parser.Ptr.prototype.parseReceiver = function(scope) { - var $deferred = [], $err = null, p, par, x, recv, base, _tuple, isIdent, _tuple$1, isBad; - /* */ try { $deferFrames.push($deferred); - p = this; - if (p.trace) { - $deferred.push([un, [trace(p, "Receiver")]]); - } - par = p.parseParameters(scope, false); - if (!((par.NumFields() === 1))) { - p.errorExpected(par.Opening, "exactly one receiver"); - par.List = new ($sliceType(($ptrType(ast.Field))))([new ast.Field.Ptr(($ptrType(ast.CommentGroup)).nil, ($sliceType(($ptrType(ast.Ident)))).nil, new ast.BadExpr.Ptr(par.Opening, par.Closing + 1 >> 0), ($ptrType(ast.BasicLit)).nil, ($ptrType(ast.CommentGroup)).nil)]); - return par; - } - recv = (x = par.List, ((0 < 0 || 0 >= x.$length) ? $throwRuntimeError("index out of range") : x.$array[x.$offset + 0])); - base = deref(recv.Type); - _tuple = $assertType(base, ($ptrType(ast.Ident)), true); isIdent = _tuple[1]; - if (!isIdent) { - _tuple$1 = $assertType(base, ($ptrType(ast.BadExpr)), true); isBad = _tuple$1[1]; - if (!isBad) { - p.errorExpected(base.Pos(), "(unqualified) identifier"); - } - par.List = new ($sliceType(($ptrType(ast.Field))))([new ast.Field.Ptr(($ptrType(ast.CommentGroup)).nil, ($sliceType(($ptrType(ast.Ident)))).nil, new ast.BadExpr.Ptr(recv.Pos(), p.safePos(recv.End())), ($ptrType(ast.BasicLit)).nil, ($ptrType(ast.CommentGroup)).nil)]); - } - return par; - /* */ } catch(err) { $err = err; return ($ptrType(ast.FieldList)).nil; } finally { $deferFrames.pop(); $callDeferred($deferred, $err); } + CommClause.prototype.Pos = function() { return this.$val.Pos(); }; + SelectStmt.Ptr.prototype.Pos = function() { + var s; + s = this; + return s.Select; }; - parser.prototype.parseReceiver = function(scope) { return this.$val.parseReceiver(scope); }; - parser.Ptr.prototype.parseFuncDecl = function() { - var $deferred = [], $err = null, p, doc, pos, scope, recv, ident, _tuple, params, results, body, decl; - /* */ try { $deferFrames.push($deferred); - p = this; - if (p.trace) { - $deferred.push([un, [trace(p, "FunctionDecl")]]); - } - doc = p.leadComment; - pos = p.expect(71); - scope = ast.NewScope(p.topScope); - recv = ($ptrType(ast.FieldList)).nil; - if (p.tok === 49) { - recv = p.parseReceiver(scope); - } - ident = p.parseIdent(); - _tuple = p.parseSignature(scope); params = _tuple[0]; results = _tuple[1]; - body = ($ptrType(ast.BlockStmt)).nil; - if (p.tok === 51) { - body = p.parseBody(scope); - } - p.expectSemi(); - decl = new ast.FuncDecl.Ptr(doc, recv, ident, new ast.FuncType.Ptr(pos, params, results), body); - if (recv === ($ptrType(ast.FieldList)).nil) { - if (!(ident.Name === "init")) { - p.declare(decl, $ifaceNil, p.pkgScope, 5, new ($sliceType(($ptrType(ast.Ident))))([ident])); - } - } - return decl; - /* */ } catch(err) { $err = err; return ($ptrType(ast.FuncDecl)).nil; } finally { $deferFrames.pop(); $callDeferred($deferred, $err); } + SelectStmt.prototype.Pos = function() { return this.$val.Pos(); }; + ForStmt.Ptr.prototype.Pos = function() { + var s; + s = this; + return s.For; }; - parser.prototype.parseFuncDecl = function() { return this.$val.parseFuncDecl(); }; - parser.Ptr.prototype.parseDecl = function(sync) { - var $deferred = [], $err = null, p, f, _ref, pos; - /* */ try { $deferFrames.push($deferred); - p = this; - if (p.trace) { - $deferred.push([un, [trace(p, "Declaration")]]); - } - f = $throwNilPointerError; - _ref = p.tok; - if (_ref === 64 || _ref === 85) { - f = $methodVal(p, "parseValueSpec"); - } else if (_ref === 84) { - f = $methodVal(p, "parseTypeSpec"); - } else if (_ref === 71) { - return p.parseFuncDecl(); - } else { - pos = p.pos; - p.errorExpected(pos, "declaration"); - sync(p); - return new ast.BadDecl.Ptr(pos, p.pos); - } - return p.parseGenDecl(p.tok, f); - /* */ } catch(err) { $err = err; return $ifaceNil; } finally { $deferFrames.pop(); $callDeferred($deferred, $err); } + ForStmt.prototype.Pos = function() { return this.$val.Pos(); }; + RangeStmt.Ptr.prototype.Pos = function() { + var s; + s = this; + return s.For; }; - parser.prototype.parseDecl = function(sync) { return this.$val.parseDecl(sync); }; - parser.Ptr.prototype.parseFile = function() { - var $deferred = [], $err = null, p, doc, pos, ident, decls, i, _ref, _i, ident$1, x; - /* */ try { $deferFrames.push($deferred); - p = this; - if (p.trace) { - $deferred.push([un, [trace(p, "File")]]); - } - if (!((p.errors.Len() === 0))) { - return ($ptrType(ast.File)).nil; - } - doc = p.leadComment; - pos = p.expect(78); - ident = p.parseIdent(); - if (ident.Name === "_" && !((((p.mode & 16) >>> 0) === 0))) { - p.error(p.pos, "invalid package name _"); - } - p.expectSemi(); - if (!((p.errors.Len() === 0))) { - return ($ptrType(ast.File)).nil; - } - p.openScope(); - p.pkgScope = p.topScope; - decls = ($sliceType(ast.Decl)).nil; - if (((p.mode & 1) >>> 0) === 0) { - while (p.tok === 75) { - decls = $append(decls, p.parseGenDecl(75, $methodVal(p, "parseImportSpec"))); - } - if (((p.mode & 2) >>> 0) === 0) { - while (!((p.tok === 1))) { - decls = $append(decls, p.parseDecl(syncDecl)); - } - } - } - p.closeScope(); - assert(p.topScope === ($ptrType(ast.Scope)).nil, "unbalanced scopes"); - assert(p.labelScope === ($ptrType(ast.Scope)).nil, "unbalanced label scopes"); - i = 0; - _ref = p.unresolved; - _i = 0; - while (_i < _ref.$length) { - ident$1 = ((_i < 0 || _i >= _ref.$length) ? $throwRuntimeError("index out of range") : _ref.$array[_ref.$offset + _i]); - assert(ident$1.Obj === unresolved, "object already resolved"); - ident$1.Obj = p.pkgScope.Lookup(ident$1.Name); - if (ident$1.Obj === ($ptrType(ast.Object)).nil) { - (x = p.unresolved, (i < 0 || i >= x.$length) ? $throwRuntimeError("index out of range") : x.$array[x.$offset + i] = ident$1); - i = i + (1) >> 0; - } - _i++; - } - return new ast.File.Ptr(doc, pos, ident, decls, p.pkgScope, p.imports, $subslice(p.unresolved, 0, i), p.comments); - /* */ } catch(err) { $err = err; return ($ptrType(ast.File)).nil; } finally { $deferFrames.pop(); $callDeferred($deferred, $err); } + RangeStmt.prototype.Pos = function() { return this.$val.Pos(); }; + BadStmt.Ptr.prototype.End = function() { + var s; + s = this; + return s.To; }; - parser.prototype.parseFile = function() { return this.$val.parseFile(); }; - $pkg.$init = function() { - ($ptrType(parser)).methods = [["atComma", "atComma", "go/parser", $funcType([$String], [$Bool], false), -1], ["checkExpr", "checkExpr", "go/parser", $funcType([ast.Expr], [ast.Expr], false), -1], ["checkExprOrType", "checkExprOrType", "go/parser", $funcType([ast.Expr], [ast.Expr], false), -1], ["closeLabelScope", "closeLabelScope", "go/parser", $funcType([], [], false), -1], ["closeScope", "closeScope", "go/parser", $funcType([], [], false), -1], ["consumeComment", "consumeComment", "go/parser", $funcType([], [($ptrType(ast.Comment)), $Int], false), -1], ["consumeCommentGroup", "consumeCommentGroup", "go/parser", $funcType([$Int], [($ptrType(ast.CommentGroup)), $Int], false), -1], ["declare", "declare", "go/parser", $funcType([$emptyInterface, $emptyInterface, ($ptrType(ast.Scope)), ast.ObjKind, ($sliceType(($ptrType(ast.Ident))))], [], true), -1], ["error", "error", "go/parser", $funcType([token.Pos, $String], [], false), -1], ["errorExpected", "errorExpected", "go/parser", $funcType([token.Pos, $String], [], false), -1], ["expect", "expect", "go/parser", $funcType([token.Token], [token.Pos], false), -1], ["expectClosing", "expectClosing", "go/parser", $funcType([token.Token, $String], [token.Pos], false), -1], ["expectSemi", "expectSemi", "go/parser", $funcType([], [], false), -1], ["init", "init", "go/parser", $funcType([($ptrType(token.FileSet)), $String, ($sliceType($Uint8)), Mode], [], false), -1], ["makeExpr", "makeExpr", "go/parser", $funcType([ast.Stmt, $String], [ast.Expr], false), -1], ["makeIdentList", "makeIdentList", "go/parser", $funcType([($sliceType(ast.Expr))], [($sliceType(($ptrType(ast.Ident))))], false), -1], ["next", "next", "go/parser", $funcType([], [], false), -1], ["next0", "next0", "go/parser", $funcType([], [], false), -1], ["openLabelScope", "openLabelScope", "go/parser", $funcType([], [], false), -1], ["openScope", "openScope", "go/parser", $funcType([], [], false), -1], ["parseArrayType", "parseArrayType", "go/parser", $funcType([], [ast.Expr], false), -1], ["parseBinaryExpr", "parseBinaryExpr", "go/parser", $funcType([$Bool, $Int], [ast.Expr], false), -1], ["parseBlockStmt", "parseBlockStmt", "go/parser", $funcType([], [($ptrType(ast.BlockStmt))], false), -1], ["parseBody", "parseBody", "go/parser", $funcType([($ptrType(ast.Scope))], [($ptrType(ast.BlockStmt))], false), -1], ["parseBranchStmt", "parseBranchStmt", "go/parser", $funcType([token.Token], [($ptrType(ast.BranchStmt))], false), -1], ["parseCallExpr", "parseCallExpr", "go/parser", $funcType([$String], [($ptrType(ast.CallExpr))], false), -1], ["parseCallOrConversion", "parseCallOrConversion", "go/parser", $funcType([ast.Expr], [($ptrType(ast.CallExpr))], false), -1], ["parseCaseClause", "parseCaseClause", "go/parser", $funcType([$Bool], [($ptrType(ast.CaseClause))], false), -1], ["parseChanType", "parseChanType", "go/parser", $funcType([], [($ptrType(ast.ChanType))], false), -1], ["parseCommClause", "parseCommClause", "go/parser", $funcType([], [($ptrType(ast.CommClause))], false), -1], ["parseDecl", "parseDecl", "go/parser", $funcType([($funcType([($ptrType(parser))], [], false))], [ast.Decl], false), -1], ["parseDeferStmt", "parseDeferStmt", "go/parser", $funcType([], [ast.Stmt], false), -1], ["parseElement", "parseElement", "go/parser", $funcType([$Bool], [ast.Expr], false), -1], ["parseElementList", "parseElementList", "go/parser", $funcType([], [($sliceType(ast.Expr))], false), -1], ["parseExpr", "parseExpr", "go/parser", $funcType([$Bool], [ast.Expr], false), -1], ["parseExprList", "parseExprList", "go/parser", $funcType([$Bool], [($sliceType(ast.Expr))], false), -1], ["parseFieldDecl", "parseFieldDecl", "go/parser", $funcType([($ptrType(ast.Scope))], [($ptrType(ast.Field))], false), -1], ["parseFile", "parseFile", "go/parser", $funcType([], [($ptrType(ast.File))], false), -1], ["parseForStmt", "parseForStmt", "go/parser", $funcType([], [ast.Stmt], false), -1], ["parseFuncDecl", "parseFuncDecl", "go/parser", $funcType([], [($ptrType(ast.FuncDecl))], false), -1], ["parseFuncType", "parseFuncType", "go/parser", $funcType([], [($ptrType(ast.FuncType)), ($ptrType(ast.Scope))], false), -1], ["parseFuncTypeOrLit", "parseFuncTypeOrLit", "go/parser", $funcType([], [ast.Expr], false), -1], ["parseGenDecl", "parseGenDecl", "go/parser", $funcType([token.Token, parseSpecFunction], [($ptrType(ast.GenDecl))], false), -1], ["parseGoStmt", "parseGoStmt", "go/parser", $funcType([], [ast.Stmt], false), -1], ["parseIdent", "parseIdent", "go/parser", $funcType([], [($ptrType(ast.Ident))], false), -1], ["parseIdentList", "parseIdentList", "go/parser", $funcType([], [($sliceType(($ptrType(ast.Ident))))], false), -1], ["parseIfStmt", "parseIfStmt", "go/parser", $funcType([], [($ptrType(ast.IfStmt))], false), -1], ["parseImportSpec", "parseImportSpec", "go/parser", $funcType([($ptrType(ast.CommentGroup)), token.Token, $Int], [ast.Spec], false), -1], ["parseIndexOrSlice", "parseIndexOrSlice", "go/parser", $funcType([ast.Expr], [ast.Expr], false), -1], ["parseInterfaceType", "parseInterfaceType", "go/parser", $funcType([], [($ptrType(ast.InterfaceType))], false), -1], ["parseLhsList", "parseLhsList", "go/parser", $funcType([], [($sliceType(ast.Expr))], false), -1], ["parseLiteralValue", "parseLiteralValue", "go/parser", $funcType([ast.Expr], [ast.Expr], false), -1], ["parseMapType", "parseMapType", "go/parser", $funcType([], [($ptrType(ast.MapType))], false), -1], ["parseMethodSpec", "parseMethodSpec", "go/parser", $funcType([($ptrType(ast.Scope))], [($ptrType(ast.Field))], false), -1], ["parseOperand", "parseOperand", "go/parser", $funcType([$Bool], [ast.Expr], false), -1], ["parseParameterList", "parseParameterList", "go/parser", $funcType([($ptrType(ast.Scope)), $Bool], [($sliceType(($ptrType(ast.Field))))], false), -1], ["parseParameters", "parseParameters", "go/parser", $funcType([($ptrType(ast.Scope)), $Bool], [($ptrType(ast.FieldList))], false), -1], ["parsePointerType", "parsePointerType", "go/parser", $funcType([], [($ptrType(ast.StarExpr))], false), -1], ["parsePrimaryExpr", "parsePrimaryExpr", "go/parser", $funcType([$Bool], [ast.Expr], false), -1], ["parseReceiver", "parseReceiver", "go/parser", $funcType([($ptrType(ast.Scope))], [($ptrType(ast.FieldList))], false), -1], ["parseResult", "parseResult", "go/parser", $funcType([($ptrType(ast.Scope))], [($ptrType(ast.FieldList))], false), -1], ["parseReturnStmt", "parseReturnStmt", "go/parser", $funcType([], [($ptrType(ast.ReturnStmt))], false), -1], ["parseRhs", "parseRhs", "go/parser", $funcType([], [ast.Expr], false), -1], ["parseRhsList", "parseRhsList", "go/parser", $funcType([], [($sliceType(ast.Expr))], false), -1], ["parseRhsOrType", "parseRhsOrType", "go/parser", $funcType([], [ast.Expr], false), -1], ["parseSelectStmt", "parseSelectStmt", "go/parser", $funcType([], [($ptrType(ast.SelectStmt))], false), -1], ["parseSelector", "parseSelector", "go/parser", $funcType([ast.Expr], [ast.Expr], false), -1], ["parseSignature", "parseSignature", "go/parser", $funcType([($ptrType(ast.Scope))], [($ptrType(ast.FieldList)), ($ptrType(ast.FieldList))], false), -1], ["parseSimpleStmt", "parseSimpleStmt", "go/parser", $funcType([$Int], [ast.Stmt, $Bool], false), -1], ["parseStmt", "parseStmt", "go/parser", $funcType([], [ast.Stmt], false), -1], ["parseStmtList", "parseStmtList", "go/parser", $funcType([], [($sliceType(ast.Stmt))], false), -1], ["parseStructType", "parseStructType", "go/parser", $funcType([], [($ptrType(ast.StructType))], false), -1], ["parseSwitchStmt", "parseSwitchStmt", "go/parser", $funcType([], [ast.Stmt], false), -1], ["parseType", "parseType", "go/parser", $funcType([], [ast.Expr], false), -1], ["parseTypeAssertion", "parseTypeAssertion", "go/parser", $funcType([ast.Expr], [ast.Expr], false), -1], ["parseTypeList", "parseTypeList", "go/parser", $funcType([], [($sliceType(ast.Expr))], false), -1], ["parseTypeName", "parseTypeName", "go/parser", $funcType([], [ast.Expr], false), -1], ["parseTypeSpec", "parseTypeSpec", "go/parser", $funcType([($ptrType(ast.CommentGroup)), token.Token, $Int], [ast.Spec], false), -1], ["parseUnaryExpr", "parseUnaryExpr", "go/parser", $funcType([$Bool], [ast.Expr], false), -1], ["parseValueSpec", "parseValueSpec", "go/parser", $funcType([($ptrType(ast.CommentGroup)), token.Token, $Int], [ast.Spec], false), -1], ["parseVarList", "parseVarList", "go/parser", $funcType([$Bool], [($sliceType(ast.Expr)), ast.Expr], false), -1], ["parseVarType", "parseVarType", "go/parser", $funcType([$Bool], [ast.Expr], false), -1], ["printTrace", "printTrace", "go/parser", $funcType([($sliceType($emptyInterface))], [], true), -1], ["resolve", "resolve", "go/parser", $funcType([ast.Expr], [], false), -1], ["safePos", "safePos", "go/parser", $funcType([token.Pos], [token.Pos], false), -1], ["shortVarDecl", "shortVarDecl", "go/parser", $funcType([($ptrType(ast.AssignStmt)), ($sliceType(ast.Expr))], [], false), -1], ["tokPrec", "tokPrec", "go/parser", $funcType([], [token.Token, $Int], false), -1], ["tryIdentOrType", "tryIdentOrType", "go/parser", $funcType([], [ast.Expr], false), -1], ["tryResolve", "tryResolve", "go/parser", $funcType([ast.Expr, $Bool], [], false), -1], ["tryType", "tryType", "go/parser", $funcType([], [ast.Expr], false), -1], ["tryVarType", "tryVarType", "go/parser", $funcType([$Bool], [ast.Expr], false), -1]]; - parser.init([["file", "file", "go/parser", ($ptrType(token.File)), ""], ["errors", "errors", "go/parser", scanner.ErrorList, ""], ["scanner", "scanner", "go/parser", scanner.Scanner, ""], ["mode", "mode", "go/parser", Mode, ""], ["trace", "trace", "go/parser", $Bool, ""], ["indent", "indent", "go/parser", $Int, ""], ["comments", "comments", "go/parser", ($sliceType(($ptrType(ast.CommentGroup)))), ""], ["leadComment", "leadComment", "go/parser", ($ptrType(ast.CommentGroup)), ""], ["lineComment", "lineComment", "go/parser", ($ptrType(ast.CommentGroup)), ""], ["pos", "pos", "go/parser", token.Pos, ""], ["tok", "tok", "go/parser", token.Token, ""], ["lit", "lit", "go/parser", $String, ""], ["syncPos", "syncPos", "go/parser", token.Pos, ""], ["syncCnt", "syncCnt", "go/parser", $Int, ""], ["exprLev", "exprLev", "go/parser", $Int, ""], ["inRhs", "inRhs", "go/parser", $Bool, ""], ["pkgScope", "pkgScope", "go/parser", ($ptrType(ast.Scope)), ""], ["topScope", "topScope", "go/parser", ($ptrType(ast.Scope)), ""], ["unresolved", "unresolved", "go/parser", ($sliceType(($ptrType(ast.Ident)))), ""], ["imports", "imports", "go/parser", ($sliceType(($ptrType(ast.ImportSpec)))), ""], ["labelScope", "labelScope", "go/parser", ($ptrType(ast.Scope)), ""], ["targetStack", "targetStack", "go/parser", ($sliceType(($sliceType(($ptrType(ast.Ident)))))), ""]]); - bailout.init([]); - parseSpecFunction.init([($ptrType(ast.CommentGroup)), token.Token, $Int], [ast.Spec], false); - unresolved = new ast.Object.Ptr(); + BadStmt.prototype.End = function() { return this.$val.End(); }; + DeclStmt.Ptr.prototype.End = function() { + var s; + s = this; + return s.Decl.End(); }; - return $pkg; -})(); -$packages["path"] = (function() { - var $pkg = {}, errors = $packages["errors"], strings = $packages["strings"], utf8 = $packages["unicode/utf8"], Split, Base; - Split = $pkg.Split = function(path) { - var dir = "", file = "", i, _tmp, _tmp$1; - i = strings.LastIndex(path, "/"); - _tmp = path.substring(0, (i + 1 >> 0)); _tmp$1 = path.substring((i + 1 >> 0)); dir = _tmp; file = _tmp$1; - return [dir, file]; + DeclStmt.prototype.End = function() { return this.$val.End(); }; + EmptyStmt.Ptr.prototype.End = function() { + var s; + s = this; + return s.Semicolon + 1 >> 0; }; - Base = $pkg.Base = function(path) { - var i; - if (path === "") { - return "."; - } - while (path.length > 0 && (path.charCodeAt((path.length - 1 >> 0)) === 47)) { - path = path.substring(0, (path.length - 1 >> 0)); - } - i = strings.LastIndex(path, "/"); - if (i >= 0) { - path = path.substring((i + 1 >> 0)); - } - if (path === "") { - return "/"; - } - return path; + EmptyStmt.prototype.End = function() { return this.$val.End(); }; + LabeledStmt.Ptr.prototype.End = function() { + var s; + s = this; + return s.Stmt.End(); }; - $pkg.$init = function() { - $pkg.ErrBadPattern = errors.New("syntax error in pattern"); + LabeledStmt.prototype.End = function() { return this.$val.End(); }; + ExprStmt.Ptr.prototype.End = function() { + var s; + s = this; + return s.X.End(); }; - return $pkg; -})(); -$packages["code.google.com/p/go.tools/go/types"] = (function() { - var $pkg = {}, bytes = $packages["bytes"], fmt = $packages["fmt"], ast = $packages["go/ast"], token = $packages["go/token"], exact = $packages["code.google.com/p/go.tools/go/exact"], strings = $packages["strings"], parser = $packages["go/parser"], math = $packages["math"], heap = $packages["container/heap"], sort = $packages["sort"], sync = $packages["sync"], errors = $packages["errors"], path = $packages["path"], strconv = $packages["strconv"], unicode = $packages["unicode"], io = $packages["io"], Error, Importer, Config, Info, TypeAndValue, Initializer, getter, exprInfo, funcInfo, context, Checker, bailout, opPredicates, exprKind, objNode, nodeQueue, block, embeddedType, MethodSet, fieldSet, methodSet, byUniqueName, Object, object, PkgName, Const, TypeName, Var, Func, Label, Builtin, Nil, objset, operandMode, operand, inSourceOrder, Package, ifacePair, declInfo, Scope, SelectionKind, Selection, Sizes, StdSizes, stmtContext, Type, BasicKind, BasicInfo, Basic, Array, Slice, Struct, Pointer, Tuple, Signature, Interface, Map, Chan, ChanDir, Named, byUniqueTypeName, byUniqueMethodName, builtinId, unaryOpPredicates, binaryOpPredicates, emptyMethodSet, operandModeString, basicSizes, stdSizes, universeIota, aliases, predeclaredConsts, predeclaredFuncs, _map, _key, _map$1, _key$1, Implements, makeSig, implicitArrayDeref, unparen, unpack, NewChecker, isUintptr, isUnsafePointer, isPointer, isBytesOrRunes, underlying, assert, unreachable, isShift, isComparison, fitsFloat32, roundFloat32, fitsFloat64, roundFloat64, representableConst, ExprString, WriteExpr, writeSigExpr, writeFieldList, slice3, sliceMax, findPath, valIndex, dependencyGraph, LookupFieldOrMethod, lookupFieldOrMethod, consolidateMultiples, MissingMethod, assertableTo, deref, derefStructPtr, concat, fieldIndex, lookupMethod, NewMethodSet, ptrRecv, Id, NewPkgName, NewConst, NewTypeName, NewVar, NewParam, NewField, NewFunc, NewLabel, newBuiltin, writeObject, ObjectString, writeFuncName, operandString, orderedSetObjects, NewPackage, isNamed, isBoolean, isInteger, isUnsigned, isFloat, isComplex, isNumeric, isString, isTyped, isUntyped, isOrdered, isConstType, isInterface, Comparable, hasNil, Identical, identical, defaultType, validatedImportPath, hasBreak, hasBreakList, NewScope, SelectionString, align, assignOp, NewArray, NewSlice, NewStruct, NewPointer, NewTuple, NewSignature, NewInterface, NewMap, NewChan, NewNamed, TypeString, WriteType, writeType, writeTuple, WriteSignature, writeSignature, anonymousFieldIdent, defPredeclaredTypes, defPredeclaredConsts, defPredeclaredNil, defPredeclaredFuncs, init, def; - Error = $pkg.Error = $newType(0, "Struct", "types.Error", "Error", "code.google.com/p/go.tools/go/types", function(Fset_, Pos_, Msg_, Soft_) { - this.$val = this; - this.Fset = Fset_ !== undefined ? Fset_ : ($ptrType(token.FileSet)).nil; - this.Pos = Pos_ !== undefined ? Pos_ : 0; - this.Msg = Msg_ !== undefined ? Msg_ : ""; - this.Soft = Soft_ !== undefined ? Soft_ : false; - }); - Importer = $pkg.Importer = $newType(4, "Func", "types.Importer", "Importer", "code.google.com/p/go.tools/go/types", null); - Config = $pkg.Config = $newType(0, "Struct", "types.Config", "Config", "code.google.com/p/go.tools/go/types", function(IgnoreFuncBodies_, FakeImportC_, Packages_, Error_, Import_, Sizes_) { - this.$val = this; - this.IgnoreFuncBodies = IgnoreFuncBodies_ !== undefined ? IgnoreFuncBodies_ : false; - this.FakeImportC = FakeImportC_ !== undefined ? FakeImportC_ : false; - this.Packages = Packages_ !== undefined ? Packages_ : false; - this.Error = Error_ !== undefined ? Error_ : $throwNilPointerError; - this.Import = Import_ !== undefined ? Import_ : $throwNilPointerError; - this.Sizes = Sizes_ !== undefined ? Sizes_ : $ifaceNil; - }); - Info = $pkg.Info = $newType(0, "Struct", "types.Info", "Info", "code.google.com/p/go.tools/go/types", function(Types_, Defs_, Uses_, Implicits_, Selections_, Scopes_, InitOrder_) { - this.$val = this; - this.Types = Types_ !== undefined ? Types_ : false; - this.Defs = Defs_ !== undefined ? Defs_ : false; - this.Uses = Uses_ !== undefined ? Uses_ : false; - this.Implicits = Implicits_ !== undefined ? Implicits_ : false; - this.Selections = Selections_ !== undefined ? Selections_ : false; - this.Scopes = Scopes_ !== undefined ? Scopes_ : false; - this.InitOrder = InitOrder_ !== undefined ? InitOrder_ : ($sliceType(($ptrType(Initializer)))).nil; - }); - TypeAndValue = $pkg.TypeAndValue = $newType(0, "Struct", "types.TypeAndValue", "TypeAndValue", "code.google.com/p/go.tools/go/types", function(mode_, Type_, Value_) { - this.$val = this; - this.mode = mode_ !== undefined ? mode_ : 0; - this.Type = Type_ !== undefined ? Type_ : $ifaceNil; - this.Value = Value_ !== undefined ? Value_ : $ifaceNil; - }); - Initializer = $pkg.Initializer = $newType(0, "Struct", "types.Initializer", "Initializer", "code.google.com/p/go.tools/go/types", function(Lhs_, Rhs_) { - this.$val = this; - this.Lhs = Lhs_ !== undefined ? Lhs_ : ($sliceType(($ptrType(Var)))).nil; - this.Rhs = Rhs_ !== undefined ? Rhs_ : $ifaceNil; - }); - getter = $pkg.getter = $newType(4, "Func", "types.getter", "getter", "code.google.com/p/go.tools/go/types", null); - exprInfo = $pkg.exprInfo = $newType(0, "Struct", "types.exprInfo", "exprInfo", "code.google.com/p/go.tools/go/types", function(isLhs_, mode_, typ_, val_) { - this.$val = this; - this.isLhs = isLhs_ !== undefined ? isLhs_ : false; - this.mode = mode_ !== undefined ? mode_ : 0; - this.typ = typ_ !== undefined ? typ_ : ($ptrType(Basic)).nil; - this.val = val_ !== undefined ? val_ : $ifaceNil; - }); - funcInfo = $pkg.funcInfo = $newType(0, "Struct", "types.funcInfo", "funcInfo", "code.google.com/p/go.tools/go/types", function(name_, decl_, sig_, body_) { - this.$val = this; - this.name = name_ !== undefined ? name_ : ""; - this.decl = decl_ !== undefined ? decl_ : ($ptrType(declInfo)).nil; - this.sig = sig_ !== undefined ? sig_ : ($ptrType(Signature)).nil; - this.body = body_ !== undefined ? body_ : ($ptrType(ast.BlockStmt)).nil; - }); - context = $pkg.context = $newType(0, "Struct", "types.context", "context", "code.google.com/p/go.tools/go/types", function(decl_, scope_, iota_, sig_, hasLabel_, hasCallOrRecv_) { - this.$val = this; - this.decl = decl_ !== undefined ? decl_ : ($ptrType(declInfo)).nil; - this.scope = scope_ !== undefined ? scope_ : ($ptrType(Scope)).nil; - this.iota = iota_ !== undefined ? iota_ : $ifaceNil; - this.sig = sig_ !== undefined ? sig_ : ($ptrType(Signature)).nil; - this.hasLabel = hasLabel_ !== undefined ? hasLabel_ : false; - this.hasCallOrRecv = hasCallOrRecv_ !== undefined ? hasCallOrRecv_ : false; - }); - Checker = $pkg.Checker = $newType(0, "Struct", "types.Checker", "Checker", "code.google.com/p/go.tools/go/types", function(conf_, fset_, pkg_, Info_, objMap_, files_, fileScopes_, dotImports_, firstErr_, methods_, untyped_, funcs_, delayed_, context_, indent_) { - this.$val = this; - this.conf = conf_ !== undefined ? conf_ : ($ptrType(Config)).nil; - this.fset = fset_ !== undefined ? fset_ : ($ptrType(token.FileSet)).nil; - this.pkg = pkg_ !== undefined ? pkg_ : ($ptrType(Package)).nil; - this.Info = Info_ !== undefined ? Info_ : ($ptrType(Info)).nil; - this.objMap = objMap_ !== undefined ? objMap_ : false; - this.files = files_ !== undefined ? files_ : ($sliceType(($ptrType(ast.File)))).nil; - this.fileScopes = fileScopes_ !== undefined ? fileScopes_ : ($sliceType(($ptrType(Scope)))).nil; - this.dotImports = dotImports_ !== undefined ? dotImports_ : ($sliceType(($mapType(($ptrType(Package)), token.Pos)))).nil; - this.firstErr = firstErr_ !== undefined ? firstErr_ : $ifaceNil; - this.methods = methods_ !== undefined ? methods_ : false; - this.untyped = untyped_ !== undefined ? untyped_ : false; - this.funcs = funcs_ !== undefined ? funcs_ : ($sliceType(funcInfo)).nil; - this.delayed = delayed_ !== undefined ? delayed_ : ($sliceType(($funcType([], [], false)))).nil; - this.context = context_ !== undefined ? context_ : new context.Ptr(); - this.indent = indent_ !== undefined ? indent_ : 0; - }); - bailout = $pkg.bailout = $newType(0, "Struct", "types.bailout", "bailout", "code.google.com/p/go.tools/go/types", function() { - this.$val = this; - }); - opPredicates = $pkg.opPredicates = $newType(4, "Map", "types.opPredicates", "opPredicates", "code.google.com/p/go.tools/go/types", null); - exprKind = $pkg.exprKind = $newType(4, "Int", "types.exprKind", "exprKind", "code.google.com/p/go.tools/go/types", null); - objNode = $pkg.objNode = $newType(0, "Struct", "types.objNode", "objNode", "code.google.com/p/go.tools/go/types", function(obj_, in$1_, out_, index_, mark_) { - this.$val = this; - this.obj = obj_ !== undefined ? obj_ : $ifaceNil; - this.in$1 = in$1_ !== undefined ? in$1_ : 0; - this.out = out_ !== undefined ? out_ : ($sliceType(($ptrType(objNode)))).nil; - this.index = index_ !== undefined ? index_ : 0; - this.mark = mark_ !== undefined ? mark_ : 0; - }); - nodeQueue = $pkg.nodeQueue = $newType(12, "Slice", "types.nodeQueue", "nodeQueue", "code.google.com/p/go.tools/go/types", null); - block = $pkg.block = $newType(0, "Struct", "types.block", "block", "code.google.com/p/go.tools/go/types", function(parent_, lstmt_, labels_) { - this.$val = this; - this.parent = parent_ !== undefined ? parent_ : ($ptrType(block)).nil; - this.lstmt = lstmt_ !== undefined ? lstmt_ : ($ptrType(ast.LabeledStmt)).nil; - this.labels = labels_ !== undefined ? labels_ : false; - }); - embeddedType = $pkg.embeddedType = $newType(0, "Struct", "types.embeddedType", "embeddedType", "code.google.com/p/go.tools/go/types", function(typ_, index_, indirect_, multiples_) { - this.$val = this; - this.typ = typ_ !== undefined ? typ_ : ($ptrType(Named)).nil; - this.index = index_ !== undefined ? index_ : ($sliceType($Int)).nil; - this.indirect = indirect_ !== undefined ? indirect_ : false; - this.multiples = multiples_ !== undefined ? multiples_ : false; - }); - MethodSet = $pkg.MethodSet = $newType(0, "Struct", "types.MethodSet", "MethodSet", "code.google.com/p/go.tools/go/types", function(list_) { - this.$val = this; - this.list = list_ !== undefined ? list_ : ($sliceType(($ptrType(Selection)))).nil; - }); - fieldSet = $pkg.fieldSet = $newType(4, "Map", "types.fieldSet", "fieldSet", "code.google.com/p/go.tools/go/types", null); - methodSet = $pkg.methodSet = $newType(4, "Map", "types.methodSet", "methodSet", "code.google.com/p/go.tools/go/types", null); - byUniqueName = $pkg.byUniqueName = $newType(12, "Slice", "types.byUniqueName", "byUniqueName", "code.google.com/p/go.tools/go/types", null); - Object = $pkg.Object = $newType(8, "Interface", "types.Object", "Object", "code.google.com/p/go.tools/go/types", null); - object = $pkg.object = $newType(0, "Struct", "types.object", "object", "code.google.com/p/go.tools/go/types", function(parent_, pos_, pkg_, name_, typ_, used_) { - this.$val = this; - this.parent = parent_ !== undefined ? parent_ : ($ptrType(Scope)).nil; - this.pos = pos_ !== undefined ? pos_ : 0; - this.pkg = pkg_ !== undefined ? pkg_ : ($ptrType(Package)).nil; - this.name = name_ !== undefined ? name_ : ""; - this.typ = typ_ !== undefined ? typ_ : $ifaceNil; - this.used = used_ !== undefined ? used_ : false; - }); - PkgName = $pkg.PkgName = $newType(0, "Struct", "types.PkgName", "PkgName", "code.google.com/p/go.tools/go/types", function(object_, imported_) { - this.$val = this; - this.object = object_ !== undefined ? object_ : new object.Ptr(); - this.imported = imported_ !== undefined ? imported_ : ($ptrType(Package)).nil; - }); - Const = $pkg.Const = $newType(0, "Struct", "types.Const", "Const", "code.google.com/p/go.tools/go/types", function(object_, val_, visited_) { - this.$val = this; - this.object = object_ !== undefined ? object_ : new object.Ptr(); - this.val = val_ !== undefined ? val_ : $ifaceNil; - this.visited = visited_ !== undefined ? visited_ : false; - }); - TypeName = $pkg.TypeName = $newType(0, "Struct", "types.TypeName", "TypeName", "code.google.com/p/go.tools/go/types", function(object_) { - this.$val = this; - this.object = object_ !== undefined ? object_ : new object.Ptr(); - }); - Var = $pkg.Var = $newType(0, "Struct", "types.Var", "Var", "code.google.com/p/go.tools/go/types", function(object_, anonymous_, visited_, isField_) { - this.$val = this; - this.object = object_ !== undefined ? object_ : new object.Ptr(); - this.anonymous = anonymous_ !== undefined ? anonymous_ : false; - this.visited = visited_ !== undefined ? visited_ : false; - this.isField = isField_ !== undefined ? isField_ : false; - }); - Func = $pkg.Func = $newType(0, "Struct", "types.Func", "Func", "code.google.com/p/go.tools/go/types", function(object_) { - this.$val = this; - this.object = object_ !== undefined ? object_ : new object.Ptr(); - }); - Label = $pkg.Label = $newType(0, "Struct", "types.Label", "Label", "code.google.com/p/go.tools/go/types", function(object_) { - this.$val = this; - this.object = object_ !== undefined ? object_ : new object.Ptr(); - }); - Builtin = $pkg.Builtin = $newType(0, "Struct", "types.Builtin", "Builtin", "code.google.com/p/go.tools/go/types", function(object_, id_) { - this.$val = this; - this.object = object_ !== undefined ? object_ : new object.Ptr(); - this.id = id_ !== undefined ? id_ : 0; - }); - Nil = $pkg.Nil = $newType(0, "Struct", "types.Nil", "Nil", "code.google.com/p/go.tools/go/types", function(object_) { - this.$val = this; - this.object = object_ !== undefined ? object_ : new object.Ptr(); - }); - objset = $pkg.objset = $newType(4, "Map", "types.objset", "objset", "code.google.com/p/go.tools/go/types", null); - operandMode = $pkg.operandMode = $newType(1, "Uint8", "types.operandMode", "operandMode", "code.google.com/p/go.tools/go/types", null); - operand = $pkg.operand = $newType(0, "Struct", "types.operand", "operand", "code.google.com/p/go.tools/go/types", function(mode_, expr_, typ_, val_, id_) { - this.$val = this; - this.mode = mode_ !== undefined ? mode_ : 0; - this.expr = expr_ !== undefined ? expr_ : $ifaceNil; - this.typ = typ_ !== undefined ? typ_ : $ifaceNil; - this.val = val_ !== undefined ? val_ : $ifaceNil; - this.id = id_ !== undefined ? id_ : 0; - }); - inSourceOrder = $pkg.inSourceOrder = $newType(12, "Slice", "types.inSourceOrder", "inSourceOrder", "code.google.com/p/go.tools/go/types", null); - Package = $pkg.Package = $newType(0, "Struct", "types.Package", "Package", "code.google.com/p/go.tools/go/types", function(path_, name_, scope_, complete_, imports_, fake_) { - this.$val = this; - this.path = path_ !== undefined ? path_ : ""; - this.name = name_ !== undefined ? name_ : ""; - this.scope = scope_ !== undefined ? scope_ : ($ptrType(Scope)).nil; - this.complete = complete_ !== undefined ? complete_ : false; - this.imports = imports_ !== undefined ? imports_ : ($sliceType(($ptrType(Package)))).nil; - this.fake = fake_ !== undefined ? fake_ : false; - }); - ifacePair = $pkg.ifacePair = $newType(0, "Struct", "types.ifacePair", "ifacePair", "code.google.com/p/go.tools/go/types", function(x_, y_, prev_) { - this.$val = this; - this.x = x_ !== undefined ? x_ : ($ptrType(Interface)).nil; - this.y = y_ !== undefined ? y_ : ($ptrType(Interface)).nil; - this.prev = prev_ !== undefined ? prev_ : ($ptrType(ifacePair)).nil; - }); - declInfo = $pkg.declInfo = $newType(0, "Struct", "types.declInfo", "declInfo", "code.google.com/p/go.tools/go/types", function(file_, lhs_, typ_, init_, fdecl_, deps_, mark_) { - this.$val = this; - this.file = file_ !== undefined ? file_ : ($ptrType(Scope)).nil; - this.lhs = lhs_ !== undefined ? lhs_ : ($sliceType(($ptrType(Var)))).nil; - this.typ = typ_ !== undefined ? typ_ : $ifaceNil; - this.init = init_ !== undefined ? init_ : $ifaceNil; - this.fdecl = fdecl_ !== undefined ? fdecl_ : ($ptrType(ast.FuncDecl)).nil; - this.deps = deps_ !== undefined ? deps_ : false; - this.mark = mark_ !== undefined ? mark_ : 0; - }); - Scope = $pkg.Scope = $newType(0, "Struct", "types.Scope", "Scope", "code.google.com/p/go.tools/go/types", function(parent_, children_, comment_, elems_) { - this.$val = this; - this.parent = parent_ !== undefined ? parent_ : ($ptrType(Scope)).nil; - this.children = children_ !== undefined ? children_ : ($sliceType(($ptrType(Scope)))).nil; - this.comment = comment_ !== undefined ? comment_ : ""; - this.elems = elems_ !== undefined ? elems_ : false; - }); - SelectionKind = $pkg.SelectionKind = $newType(4, "Int", "types.SelectionKind", "SelectionKind", "code.google.com/p/go.tools/go/types", null); - Selection = $pkg.Selection = $newType(0, "Struct", "types.Selection", "Selection", "code.google.com/p/go.tools/go/types", function(kind_, recv_, obj_, index_, indirect_) { - this.$val = this; - this.kind = kind_ !== undefined ? kind_ : 0; - this.recv = recv_ !== undefined ? recv_ : $ifaceNil; - this.obj = obj_ !== undefined ? obj_ : $ifaceNil; - this.index = index_ !== undefined ? index_ : ($sliceType($Int)).nil; - this.indirect = indirect_ !== undefined ? indirect_ : false; - }); - Sizes = $pkg.Sizes = $newType(8, "Interface", "types.Sizes", "Sizes", "code.google.com/p/go.tools/go/types", null); - StdSizes = $pkg.StdSizes = $newType(0, "Struct", "types.StdSizes", "StdSizes", "code.google.com/p/go.tools/go/types", function(WordSize_, MaxAlign_) { - this.$val = this; - this.WordSize = WordSize_ !== undefined ? WordSize_ : new $Int64(0, 0); - this.MaxAlign = MaxAlign_ !== undefined ? MaxAlign_ : new $Int64(0, 0); - }); - stmtContext = $pkg.stmtContext = $newType(4, "Uint", "types.stmtContext", "stmtContext", "code.google.com/p/go.tools/go/types", null); - Type = $pkg.Type = $newType(8, "Interface", "types.Type", "Type", "code.google.com/p/go.tools/go/types", null); - BasicKind = $pkg.BasicKind = $newType(4, "Int", "types.BasicKind", "BasicKind", "code.google.com/p/go.tools/go/types", null); - BasicInfo = $pkg.BasicInfo = $newType(4, "Int", "types.BasicInfo", "BasicInfo", "code.google.com/p/go.tools/go/types", null); - Basic = $pkg.Basic = $newType(0, "Struct", "types.Basic", "Basic", "code.google.com/p/go.tools/go/types", function(kind_, info_, name_) { - this.$val = this; - this.kind = kind_ !== undefined ? kind_ : 0; - this.info = info_ !== undefined ? info_ : 0; - this.name = name_ !== undefined ? name_ : ""; - }); - Array = $pkg.Array = $newType(0, "Struct", "types.Array", "Array", "code.google.com/p/go.tools/go/types", function(len_, elem_) { - this.$val = this; - this.len = len_ !== undefined ? len_ : new $Int64(0, 0); - this.elem = elem_ !== undefined ? elem_ : $ifaceNil; - }); - Slice = $pkg.Slice = $newType(0, "Struct", "types.Slice", "Slice", "code.google.com/p/go.tools/go/types", function(elem_) { - this.$val = this; - this.elem = elem_ !== undefined ? elem_ : $ifaceNil; - }); - Struct = $pkg.Struct = $newType(0, "Struct", "types.Struct", "Struct", "code.google.com/p/go.tools/go/types", function(fields_, tags_, offsets_) { - this.$val = this; - this.fields = fields_ !== undefined ? fields_ : ($sliceType(($ptrType(Var)))).nil; - this.tags = tags_ !== undefined ? tags_ : ($sliceType($String)).nil; - this.offsets = offsets_ !== undefined ? offsets_ : ($sliceType($Int64)).nil; - }); - Pointer = $pkg.Pointer = $newType(0, "Struct", "types.Pointer", "Pointer", "code.google.com/p/go.tools/go/types", function(base_) { - this.$val = this; - this.base = base_ !== undefined ? base_ : $ifaceNil; - }); - Tuple = $pkg.Tuple = $newType(0, "Struct", "types.Tuple", "Tuple", "code.google.com/p/go.tools/go/types", function(vars_) { - this.$val = this; - this.vars = vars_ !== undefined ? vars_ : ($sliceType(($ptrType(Var)))).nil; - }); - Signature = $pkg.Signature = $newType(0, "Struct", "types.Signature", "Signature", "code.google.com/p/go.tools/go/types", function(scope_, recv_, params_, results_, variadic_) { - this.$val = this; - this.scope = scope_ !== undefined ? scope_ : ($ptrType(Scope)).nil; - this.recv = recv_ !== undefined ? recv_ : ($ptrType(Var)).nil; - this.params = params_ !== undefined ? params_ : ($ptrType(Tuple)).nil; - this.results = results_ !== undefined ? results_ : ($ptrType(Tuple)).nil; - this.variadic = variadic_ !== undefined ? variadic_ : false; - }); - Interface = $pkg.Interface = $newType(0, "Struct", "types.Interface", "Interface", "code.google.com/p/go.tools/go/types", function(methods_, embeddeds_, allMethods_) { - this.$val = this; - this.methods = methods_ !== undefined ? methods_ : ($sliceType(($ptrType(Func)))).nil; - this.embeddeds = embeddeds_ !== undefined ? embeddeds_ : ($sliceType(($ptrType(Named)))).nil; - this.allMethods = allMethods_ !== undefined ? allMethods_ : ($sliceType(($ptrType(Func)))).nil; - }); - Map = $pkg.Map = $newType(0, "Struct", "types.Map", "Map", "code.google.com/p/go.tools/go/types", function(key_, elem_) { - this.$val = this; - this.key = key_ !== undefined ? key_ : $ifaceNil; - this.elem = elem_ !== undefined ? elem_ : $ifaceNil; - }); - Chan = $pkg.Chan = $newType(0, "Struct", "types.Chan", "Chan", "code.google.com/p/go.tools/go/types", function(dir_, elem_) { - this.$val = this; - this.dir = dir_ !== undefined ? dir_ : 0; - this.elem = elem_ !== undefined ? elem_ : $ifaceNil; - }); - ChanDir = $pkg.ChanDir = $newType(4, "Int", "types.ChanDir", "ChanDir", "code.google.com/p/go.tools/go/types", null); - Named = $pkg.Named = $newType(0, "Struct", "types.Named", "Named", "code.google.com/p/go.tools/go/types", function(obj_, underlying_, methods_) { - this.$val = this; - this.obj = obj_ !== undefined ? obj_ : ($ptrType(TypeName)).nil; - this.underlying = underlying_ !== undefined ? underlying_ : $ifaceNil; - this.methods = methods_ !== undefined ? methods_ : ($sliceType(($ptrType(Func)))).nil; - }); - byUniqueTypeName = $pkg.byUniqueTypeName = $newType(12, "Slice", "types.byUniqueTypeName", "byUniqueTypeName", "code.google.com/p/go.tools/go/types", null); - byUniqueMethodName = $pkg.byUniqueMethodName = $newType(12, "Slice", "types.byUniqueMethodName", "byUniqueMethodName", "code.google.com/p/go.tools/go/types", null); - builtinId = $pkg.builtinId = $newType(4, "Int", "types.builtinId", "builtinId", "code.google.com/p/go.tools/go/types", null); - Error.Ptr.prototype.Error = function() { - var err, x; - err = new Error.Ptr(); $copy(err, this, Error); - return fmt.Sprintf("%s: %s", new ($sliceType($emptyInterface))([(x = err.Fset.Position(err.Pos), new x.constructor.Struct(x)), new $String(err.Msg)])); + ExprStmt.prototype.End = function() { return this.$val.End(); }; + SendStmt.Ptr.prototype.End = function() { + var s; + s = this; + return s.Value.End(); + }; + SendStmt.prototype.End = function() { return this.$val.End(); }; + IncDecStmt.Ptr.prototype.End = function() { + var s; + s = this; + return s.TokPos + 2 >> 0; }; - Error.prototype.Error = function() { return this.$val.Error(); }; - Info.Ptr.prototype.TypeOf = function(e) { - var info, _tuple, _entry, t, ok, _tuple$1, id, ok$1; - info = this; - _tuple = (_entry = info.Types[e.$key()], _entry !== undefined ? [_entry.v, true] : [new TypeAndValue.Ptr(), false]); t = new TypeAndValue.Ptr(); $copy(t, _tuple[0], TypeAndValue); ok = _tuple[1]; - if (ok) { - return t.Type; + IncDecStmt.prototype.End = function() { return this.$val.End(); }; + AssignStmt.Ptr.prototype.End = function() { + var s, x, x$1; + s = this; + return (x = s.Rhs, x$1 = s.Rhs.$length - 1 >> 0, ((x$1 < 0 || x$1 >= x.$length) ? $throwRuntimeError("index out of range") : x.$array[x.$offset + x$1])).End(); + }; + AssignStmt.prototype.End = function() { return this.$val.End(); }; + GoStmt.Ptr.prototype.End = function() { + var s; + s = this; + return s.Call.End(); + }; + GoStmt.prototype.End = function() { return this.$val.End(); }; + DeferStmt.Ptr.prototype.End = function() { + var s; + s = this; + return s.Call.End(); + }; + DeferStmt.prototype.End = function() { return this.$val.End(); }; + ReturnStmt.Ptr.prototype.End = function() { + var s, n, x, x$1; + s = this; + n = s.Results.$length; + if (n > 0) { + return (x = s.Results, x$1 = n - 1 >> 0, ((x$1 < 0 || x$1 >= x.$length) ? $throwRuntimeError("index out of range") : x.$array[x.$offset + x$1])).End(); } - _tuple$1 = $assertType(e, ($ptrType(ast.Ident)), true); id = _tuple$1[0]; ok$1 = _tuple$1[1]; - if (ok$1) { - return info.ObjectOf(id).Type(); + return s.Return + 6 >> 0; + }; + ReturnStmt.prototype.End = function() { return this.$val.End(); }; + BranchStmt.Ptr.prototype.End = function() { + var s; + s = this; + if (!(s.Label === ($ptrType(Ident)).nil)) { + return s.Label.End(); } - return $ifaceNil; + return (((s.TokPos >> 0) + (new token.Token(s.Tok)).String().length >> 0) >> 0); }; - Info.prototype.TypeOf = function(e) { return this.$val.TypeOf(e); }; - Info.Ptr.prototype.ObjectOf = function(id) { - var info, _tuple, _entry, obj, ok, _entry$1; - info = this; - _tuple = (_entry = info.Defs[id.$key()], _entry !== undefined ? [_entry.v, true] : [$ifaceNil, false]); obj = _tuple[0]; ok = _tuple[1]; - if (ok) { - return obj; + BranchStmt.prototype.End = function() { return this.$val.End(); }; + BlockStmt.Ptr.prototype.End = function() { + var s; + s = this; + return s.Rbrace + 1 >> 0; + }; + BlockStmt.prototype.End = function() { return this.$val.End(); }; + IfStmt.Ptr.prototype.End = function() { + var s; + s = this; + if (!($interfaceIsEqual(s.Else, $ifaceNil))) { + return s.Else.End(); } - return (_entry$1 = info.Uses[id.$key()], _entry$1 !== undefined ? _entry$1.v : $ifaceNil); + return s.Body.End(); }; - Info.prototype.ObjectOf = function(id) { return this.$val.ObjectOf(id); }; - TypeAndValue.Ptr.prototype.IsVoid = function() { - var tv; - tv = new TypeAndValue.Ptr(); $copy(tv, this, TypeAndValue); - return tv.mode === 1; + IfStmt.prototype.End = function() { return this.$val.End(); }; + CaseClause.Ptr.prototype.End = function() { + var s, n, x, x$1; + s = this; + n = s.Body.$length; + if (n > 0) { + return (x = s.Body, x$1 = n - 1 >> 0, ((x$1 < 0 || x$1 >= x.$length) ? $throwRuntimeError("index out of range") : x.$array[x.$offset + x$1])).End(); + } + return s.Colon + 1 >> 0; }; - TypeAndValue.prototype.IsVoid = function() { return this.$val.IsVoid(); }; - TypeAndValue.Ptr.prototype.IsType = function() { - var tv; - tv = new TypeAndValue.Ptr(); $copy(tv, this, TypeAndValue); - return tv.mode === 3; + CaseClause.prototype.End = function() { return this.$val.End(); }; + SwitchStmt.Ptr.prototype.End = function() { + var s; + s = this; + return s.Body.End(); }; - TypeAndValue.prototype.IsType = function() { return this.$val.IsType(); }; - TypeAndValue.Ptr.prototype.IsBuiltin = function() { - var tv; - tv = new TypeAndValue.Ptr(); $copy(tv, this, TypeAndValue); - return tv.mode === 2; + SwitchStmt.prototype.End = function() { return this.$val.End(); }; + TypeSwitchStmt.Ptr.prototype.End = function() { + var s; + s = this; + return s.Body.End(); }; - TypeAndValue.prototype.IsBuiltin = function() { return this.$val.IsBuiltin(); }; - TypeAndValue.Ptr.prototype.IsValue = function() { - var tv, _ref; - tv = new TypeAndValue.Ptr(); $copy(tv, this, TypeAndValue); - _ref = tv.mode; - if (_ref === 4 || _ref === 5 || _ref === 6 || _ref === 7 || _ref === 8) { - return true; + TypeSwitchStmt.prototype.End = function() { return this.$val.End(); }; + CommClause.Ptr.prototype.End = function() { + var s, n, x, x$1; + s = this; + n = s.Body.$length; + if (n > 0) { + return (x = s.Body, x$1 = n - 1 >> 0, ((x$1 < 0 || x$1 >= x.$length) ? $throwRuntimeError("index out of range") : x.$array[x.$offset + x$1])).End(); } - return false; - }; - TypeAndValue.prototype.IsValue = function() { return this.$val.IsValue(); }; - TypeAndValue.Ptr.prototype.IsNil = function() { - var tv; - tv = new TypeAndValue.Ptr(); $copy(tv, this, TypeAndValue); - return (tv.mode === 7) && $interfaceIsEqual(tv.Type, $pkg.Typ[25]); + return s.Colon + 1 >> 0; }; - TypeAndValue.prototype.IsNil = function() { return this.$val.IsNil(); }; - TypeAndValue.Ptr.prototype.Addressable = function() { - var tv; - tv = new TypeAndValue.Ptr(); $copy(tv, this, TypeAndValue); - return tv.mode === 5; + CommClause.prototype.End = function() { return this.$val.End(); }; + SelectStmt.Ptr.prototype.End = function() { + var s; + s = this; + return s.Body.End(); }; - TypeAndValue.prototype.Addressable = function() { return this.$val.Addressable(); }; - TypeAndValue.Ptr.prototype.Assignable = function() { - var tv; - tv = new TypeAndValue.Ptr(); $copy(tv, this, TypeAndValue); - return (tv.mode === 5) || (tv.mode === 6); + SelectStmt.prototype.End = function() { return this.$val.End(); }; + ForStmt.Ptr.prototype.End = function() { + var s; + s = this; + return s.Body.End(); }; - TypeAndValue.prototype.Assignable = function() { return this.$val.Assignable(); }; - TypeAndValue.Ptr.prototype.HasOk = function() { - var tv; - tv = new TypeAndValue.Ptr(); $copy(tv, this, TypeAndValue); - return (tv.mode === 8) || (tv.mode === 6); + ForStmt.prototype.End = function() { return this.$val.End(); }; + RangeStmt.Ptr.prototype.End = function() { + var s; + s = this; + return s.Body.End(); }; - TypeAndValue.prototype.HasOk = function() { return this.$val.HasOk(); }; - Initializer.Ptr.prototype.String = function() { - var init$1, buf, _ref, _i, i, lhs; - init$1 = this; - buf = new bytes.Buffer.Ptr(); $copy(buf, new bytes.Buffer.Ptr(), bytes.Buffer); - _ref = init$1.Lhs; - _i = 0; - while (_i < _ref.$length) { - i = _i; - lhs = ((_i < 0 || _i >= _ref.$length) ? $throwRuntimeError("index out of range") : _ref.$array[_ref.$offset + _i]); - if (i > 0) { - buf.WriteString(", "); - } - buf.WriteString(lhs.object.Name()); - _i++; + RangeStmt.prototype.End = function() { return this.$val.End(); }; + ImportSpec.Ptr.prototype.Pos = function() { + var s; + s = this; + if (!(s.Name === ($ptrType(Ident)).nil)) { + return s.Name.Pos(); } - buf.WriteString(" = "); - WriteExpr(buf, init$1.Rhs); - return buf.String(); + return s.Path.Pos(); }; - Initializer.prototype.String = function() { return this.$val.String(); }; - Config.Ptr.prototype.Check = function(path$1, fset, files, info) { - var conf, pkg; - conf = this; - pkg = NewPackage(path$1, ""); - return [pkg, NewChecker(conf, fset, pkg, info).Files(files)]; + ImportSpec.prototype.Pos = function() { return this.$val.Pos(); }; + ValueSpec.Ptr.prototype.Pos = function() { + var s, x; + s = this; + return (x = s.Names, ((0 < 0 || 0 >= x.$length) ? $throwRuntimeError("index out of range") : x.$array[x.$offset + 0])).Pos(); }; - Config.prototype.Check = function(path$1, fset, files, info) { return this.$val.Check(path$1, fset, files, info); }; - Implements = $pkg.Implements = function(V, T) { - var _tuple, f; - _tuple = MissingMethod(V, T, true); f = _tuple[0]; - return f === ($ptrType(Func)).nil; + ValueSpec.prototype.Pos = function() { return this.$val.Pos(); }; + TypeSpec.Ptr.prototype.Pos = function() { + var s; + s = this; + return s.Name.Pos(); }; - Checker.Ptr.prototype.assignment = function(x, T) { - var check, _ref, _tuple, t, target; - check = this; - _ref = x.mode; - if (_ref === 0) { - return true; - } else if (_ref === 4 || _ref === 5 || _ref === 6 || _ref === 7 || _ref === 8) { - } else { - unreachable(); + TypeSpec.prototype.Pos = function() { return this.$val.Pos(); }; + ImportSpec.Ptr.prototype.End = function() { + var s; + s = this; + if (!((s.EndPos === 0))) { + return s.EndPos; } - _tuple = $assertType(x.typ, ($ptrType(Tuple)), true); t = _tuple[0]; - if (!(t === ($ptrType(Tuple)).nil)) { - assert(t.Len() > 1); - check.errorf(x.pos(), "%d-valued expression %s used as single value", new ($sliceType($emptyInterface))([new $Int(t.Len()), x])); - x.mode = 0; - return false; + return s.Path.End(); + }; + ImportSpec.prototype.End = function() { return this.$val.End(); }; + ValueSpec.Ptr.prototype.End = function() { + var s, n, x, x$1, x$2, x$3; + s = this; + n = s.Values.$length; + if (n > 0) { + return (x = s.Values, x$1 = n - 1 >> 0, ((x$1 < 0 || x$1 >= x.$length) ? $throwRuntimeError("index out of range") : x.$array[x.$offset + x$1])).End(); } - if (isUntyped(x.typ)) { - target = T; - if ($interfaceIsEqual(T, $ifaceNil) || isInterface(T)) { - if ($interfaceIsEqual(T, $ifaceNil) && $interfaceIsEqual(x.typ, $pkg.Typ[25])) { - check.errorf(x.pos(), "use of untyped nil", new ($sliceType($emptyInterface))([])); - x.mode = 0; - return false; - } - target = defaultType(x.typ); - } - check.convertUntyped(x, target); - if (x.mode === 0) { - return false; - } + if (!($interfaceIsEqual(s.Type, $ifaceNil))) { + return s.Type.End(); } - return $interfaceIsEqual(T, $ifaceNil) || x.assignableTo(check.conf, T); + return (x$2 = s.Names, x$3 = s.Names.$length - 1 >> 0, ((x$3 < 0 || x$3 >= x$2.$length) ? $throwRuntimeError("index out of range") : x$2.$array[x$2.$offset + x$3])).End(); }; - Checker.prototype.assignment = function(x, T) { return this.$val.assignment(x, T); }; - Checker.Ptr.prototype.initConst = function(lhs, x) { - var check; - check = this; - if ((x.mode === 0) || $interfaceIsEqual(x.typ, $pkg.Typ[0]) || $interfaceIsEqual(lhs.object.typ, $pkg.Typ[0])) { - if ($interfaceIsEqual(lhs.object.typ, $ifaceNil)) { - lhs.object.typ = $pkg.Typ[0]; - } - return; + ValueSpec.prototype.End = function() { return this.$val.End(); }; + TypeSpec.Ptr.prototype.End = function() { + var s; + s = this; + return s.Type.End(); + }; + TypeSpec.prototype.End = function() { return this.$val.End(); }; + BadDecl.Ptr.prototype.Pos = function() { + var d; + d = this; + return d.From; + }; + BadDecl.prototype.Pos = function() { return this.$val.Pos(); }; + GenDecl.Ptr.prototype.Pos = function() { + var d; + d = this; + return d.TokPos; + }; + GenDecl.prototype.Pos = function() { return this.$val.Pos(); }; + FuncDecl.Ptr.prototype.Pos = function() { + var d; + d = this; + return d.Type.Pos(); + }; + FuncDecl.prototype.Pos = function() { return this.$val.Pos(); }; + BadDecl.Ptr.prototype.End = function() { + var d; + d = this; + return d.To; + }; + BadDecl.prototype.End = function() { return this.$val.End(); }; + GenDecl.Ptr.prototype.End = function() { + var d, x; + d = this; + if ((new token.Pos(d.Rparen)).IsValid()) { + return d.Rparen + 1 >> 0; } - if (!((x.mode === 4))) { - check.errorf(x.pos(), "%s is not constant", new ($sliceType($emptyInterface))([x])); - if ($interfaceIsEqual(lhs.object.typ, $ifaceNil)) { - lhs.object.typ = $pkg.Typ[0]; - } - return; + return (x = d.Specs, ((0 < 0 || 0 >= x.$length) ? $throwRuntimeError("index out of range") : x.$array[x.$offset + 0])).End(); + }; + GenDecl.prototype.End = function() { return this.$val.End(); }; + FuncDecl.Ptr.prototype.End = function() { + var d; + d = this; + if (!(d.Body === ($ptrType(BlockStmt)).nil)) { + return d.Body.End(); } - assert(isConstType(x.typ)); - if ($interfaceIsEqual(lhs.object.typ, $ifaceNil)) { - lhs.object.typ = x.typ; + return d.Type.End(); + }; + FuncDecl.prototype.End = function() { return this.$val.End(); }; + File.Ptr.prototype.Pos = function() { + var f; + f = this; + return f.Package; + }; + File.prototype.Pos = function() { return this.$val.Pos(); }; + File.Ptr.prototype.End = function() { + var f, n, x, x$1; + f = this; + n = f.Decls.$length; + if (n > 0) { + return (x = f.Decls, x$1 = n - 1 >> 0, ((x$1 < 0 || x$1 >= x.$length) ? $throwRuntimeError("index out of range") : x.$array[x.$offset + x$1])).End(); } - if (!check.assignment(x, lhs.object.typ)) { - if (!((x.mode === 0))) { - check.errorf(x.pos(), "cannot define constant %s (type %s) as %s", new ($sliceType($emptyInterface))([new $String(lhs.object.Name()), lhs.object.typ, x])); - } - return; + return f.Name.End(); + }; + File.prototype.End = function() { return this.$val.End(); }; + Package.Ptr.prototype.Pos = function() { + var p; + p = this; + return 0; + }; + Package.prototype.Pos = function() { return this.$val.Pos(); }; + Package.Ptr.prototype.End = function() { + var p; + p = this; + return 0; + }; + Package.prototype.End = function() { return this.$val.End(); }; + byPos.prototype.Len = function() { + var a; + a = this; + return a.$length; + }; + $ptrType(byPos).prototype.Len = function() { return this.$get().Len(); }; + byPos.prototype.Less = function(i, j) { + var a; + a = this; + return ((i < 0 || i >= a.$length) ? $throwRuntimeError("index out of range") : a.$array[a.$offset + i]).Pos() < ((j < 0 || j >= a.$length) ? $throwRuntimeError("index out of range") : a.$array[a.$offset + j]).Pos(); + }; + $ptrType(byPos).prototype.Less = function(i, j) { return this.$get().Less(i, j); }; + byPos.prototype.Swap = function(i, j) { + var a, _tmp, _tmp$1; + a = this; + _tmp = ((j < 0 || j >= a.$length) ? $throwRuntimeError("index out of range") : a.$array[a.$offset + j]); _tmp$1 = ((i < 0 || i >= a.$length) ? $throwRuntimeError("index out of range") : a.$array[a.$offset + i]); (i < 0 || i >= a.$length) ? $throwRuntimeError("index out of range") : a.$array[a.$offset + i] = _tmp; (j < 0 || j >= a.$length) ? $throwRuntimeError("index out of range") : a.$array[a.$offset + j] = _tmp$1; + }; + $ptrType(byPos).prototype.Swap = function(i, j) { return this.$get().Swap(i, j); }; + sortComments = function(list) { + var orderedList; + orderedList = $subslice(new byPos(list.$array), list.$offset, list.$offset + list.$length); + if (!sort.IsSorted(orderedList)) { + sort.Sort(orderedList); } - lhs.val = x.val; }; - Checker.prototype.initConst = function(lhs, x) { return this.$val.initConst(lhs, x); }; - Checker.Ptr.prototype.initVar = function(lhs, x, result) { - var check, typ; - check = this; - if ((x.mode === 0) || $interfaceIsEqual(x.typ, $pkg.Typ[0]) || $interfaceIsEqual(lhs.object.typ, $pkg.Typ[0])) { - if ($interfaceIsEqual(lhs.object.typ, $ifaceNil)) { - lhs.object.typ = $pkg.Typ[0]; - } - return $ifaceNil; + CommentMap.prototype.addComment = function(n, c) { + var cmap, _entry, list, _key; + cmap = this.$val !== undefined ? this.$val : this; + list = (_entry = cmap[n.$key()], _entry !== undefined ? _entry.v : ($sliceType(($ptrType(CommentGroup)))).nil); + if (list.$length === 0) { + list = new ($sliceType(($ptrType(CommentGroup))))([c]); + } else { + list = $append(list, c); } - if ($interfaceIsEqual(lhs.object.typ, $ifaceNil)) { - typ = x.typ; - if (isUntyped(typ)) { - if ($interfaceIsEqual(typ, $pkg.Typ[25])) { - check.errorf(x.pos(), "use of untyped nil", new ($sliceType($emptyInterface))([])); - lhs.object.typ = $pkg.Typ[0]; - return $ifaceNil; - } - typ = defaultType(typ); + _key = n; (cmap || $throwRuntimeError("assignment to entry in nil map"))[_key.$key()] = { k: _key, v: list }; + }; + $ptrType(CommentMap).prototype.addComment = function(n, c) { return new CommentMap(this.$get()).addComment(n, c); }; + nodeList = function(n) { + var list; + list = ($sliceType(Node)).nil; + Inspect(n, (function(n$1) { + var _ref; + _ref = n$1; + if (_ref === $ifaceNil || $assertType(_ref, ($ptrType(CommentGroup)), true)[1] || $assertType(_ref, ($ptrType(Comment)), true)[1]) { + return false; } - lhs.object.typ = typ; + list = $append(list, n$1); + return true; + })); + return list; + }; + commentListReader.Ptr.prototype.eol = function() { + var r; + r = this; + return r.index >= r.list.$length; + }; + commentListReader.prototype.eol = function() { return this.$val.eol(); }; + commentListReader.Ptr.prototype.next = function() { + var r, x, x$1; + r = this; + if (!r.eol()) { + r.comment = (x = r.list, x$1 = r.index, ((x$1 < 0 || x$1 >= x.$length) ? $throwRuntimeError("index out of range") : x.$array[x.$offset + x$1])); + $copy(r.pos, r.fset.Position(r.comment.Pos()), token.Position); + $copy(r.end, r.fset.Position(r.comment.End()), token.Position); + r.index = r.index + (1) >> 0; } - if (!check.assignment(x, lhs.object.typ)) { - if (!((x.mode === 0))) { - if (result) { - check.errorf(x.pos(), "cannot return %s as value of type %s", new ($sliceType($emptyInterface))([x, lhs.object.typ])); - } else { - check.errorf(x.pos(), "cannot initialize %s with %s", new ($sliceType($emptyInterface))([lhs, x])); - } - } - return $ifaceNil; + }; + commentListReader.prototype.next = function() { return this.$val.next(); }; + $ptrType(nodeStack).prototype.push = function(n) { + var s; + s = this; + s.pop(n.Pos()); + s.$set($append((s.$get()), n)); + }; + $ptrType(nodeStack).prototype.pop = function(pos) { + var top = $ifaceNil, s, i, x, x$1, x$2, x$3; + s = this; + i = s.$get().$length; + while (i > 0 && (x = s.$get(), x$1 = i - 1 >> 0, ((x$1 < 0 || x$1 >= x.$length) ? $throwRuntimeError("index out of range") : x.$array[x.$offset + x$1])).End() <= pos) { + top = (x$2 = s.$get(), x$3 = i - 1 >> 0, ((x$3 < 0 || x$3 >= x$2.$length) ? $throwRuntimeError("index out of range") : x$2.$array[x$2.$offset + x$3])); + i = i - (1) >> 0; } - return x.typ; + s.$set($subslice((s.$get()), 0, i)); + top = top; + return top; }; - Checker.prototype.initVar = function(lhs, x, result) { return this.$val.initVar(lhs, x, result); }; - Checker.Ptr.prototype.assignVar = function(lhs, x) { - var check, _tuple, ident, v, v_used, obj, _tuple$1, z, _ref; - check = this; - if ((x.mode === 0) || $interfaceIsEqual(x.typ, $pkg.Typ[0])) { - return $ifaceNil; + NewCommentMap = $pkg.NewCommentMap = function(fset, node, comments) { + var cmap, tmp, r, nodes, p, pend, pg, pgend, stack, _ref, _i, q, qpos, top, assoc, _ref$1; + if (comments.$length === 0) { + return false; } - _tuple = $assertType(unparen(lhs), ($ptrType(ast.Ident)), true); ident = _tuple[0]; - if (!(ident === ($ptrType(ast.Ident)).nil) && ident.Name === "_") { - check.recordDef(ident, $ifaceNil); - if (!check.assignment(x, $ifaceNil)) { - assert(x.mode === 0); - x.typ = $ifaceNil; + cmap = new $Map(); + tmp = ($sliceType(($ptrType(CommentGroup)))).make(comments.$length); + $copySlice(tmp, comments); + sortComments(tmp); + r = new commentListReader.Ptr(fset, tmp, 0, ($ptrType(CommentGroup)).nil, new token.Position.Ptr(), new token.Position.Ptr()); + r.next(); + nodes = nodeList(node); + nodes = $append(nodes, $ifaceNil); + p = $ifaceNil; + pend = new token.Position.Ptr(); $copy(pend, new token.Position.Ptr(), token.Position); + pg = $ifaceNil; + pgend = new token.Position.Ptr(); $copy(pgend, new token.Position.Ptr(), token.Position); + stack = nodeStack.nil; + _ref = nodes; + _i = 0; + while (_i < _ref.$length) { + q = ((_i < 0 || _i >= _ref.$length) ? $throwRuntimeError("index out of range") : _ref.$array[_ref.$offset + _i]); + qpos = new token.Position.Ptr(); $copy(qpos, new token.Position.Ptr(), token.Position); + if (!($interfaceIsEqual(q, $ifaceNil))) { + $copy(qpos, fset.Position(q.Pos()), token.Position); + } else { + qpos.Offset = 1073741824; + qpos.Line = 1073741824; } - return x.typ; - } - v = ($ptrType(Var)).nil; - v_used = false; - if (!(ident === ($ptrType(ast.Ident)).nil)) { - obj = check.context.scope.LookupParent(ident.Name); - if (!($interfaceIsEqual(obj, $ifaceNil))) { - _tuple$1 = $assertType(obj, ($ptrType(Var)), true); v = _tuple$1[0]; - if (!(v === ($ptrType(Var)).nil)) { - v_used = v.object.used; + while (r.end.Offset <= qpos.Offset) { + top = new ($ptrType(nodeStack))(function() { return stack; }, function($v) { stack = $v; }).pop(r.comment.Pos()); + if (!($interfaceIsEqual(top, $ifaceNil))) { + pg = top; + $copy(pgend, fset.Position(pg.End()), token.Position); + } + assoc = $ifaceNil; + if (!($interfaceIsEqual(pg, $ifaceNil)) && ((pgend.Line === r.pos.Line) || ((pgend.Line + 1 >> 0) === r.pos.Line) && (r.end.Line + 1 >> 0) < qpos.Line)) { + assoc = pg; + } else if (!($interfaceIsEqual(p, $ifaceNil)) && ((pend.Line === r.pos.Line) || ((pend.Line + 1 >> 0) === r.pos.Line) && (r.end.Line + 1 >> 0) < qpos.Line || $interfaceIsEqual(q, $ifaceNil))) { + assoc = p; + } else { + if ($interfaceIsEqual(q, $ifaceNil)) { + $panic(new $String("internal error: no comments should be associated with sentinel")); + } + assoc = q; + } + (new CommentMap(cmap)).addComment(assoc, r.comment); + if (r.eol()) { + return cmap; } + r.next(); } + p = q; + $copy(pend, fset.Position(p.End()), token.Position); + _ref$1 = q; + if ($assertType(_ref$1, ($ptrType(File)), true)[1] || $assertType(_ref$1, ($ptrType(Field)), true)[1] || $assertType(_ref$1, Decl, true)[1] || $assertType(_ref$1, Spec, true)[1] || $assertType(_ref$1, Stmt, true)[1]) { + new ($ptrType(nodeStack))(function() { return stack; }, function($v) { stack = $v; }).push(q); + } + _i++; } - z = new operand.Ptr(); $copy(z, new operand.Ptr(), operand); - check.expr(z, lhs); - if (!(v === ($ptrType(Var)).nil)) { - v.object.used = v_used; - } - if ((z.mode === 0) || $interfaceIsEqual(z.typ, $pkg.Typ[0])) { - return $ifaceNil; - } - _ref = z.mode; - if (_ref === 0) { - return $ifaceNil; - } else if (_ref === 5 || _ref === 6) { - } else { - check.errorf(z.pos(), "cannot assign to %s", new ($sliceType($emptyInterface))([z])); - return $ifaceNil; + return cmap; + }; + CommentMap.prototype.Update = function(old, new$1) { + var cmap, _entry, list, _entry$1, _key; + cmap = this.$val !== undefined ? this.$val : this; + list = (_entry = cmap[old.$key()], _entry !== undefined ? _entry.v : ($sliceType(($ptrType(CommentGroup)))).nil); + if (list.$length > 0) { + delete cmap[old.$key()]; + _key = new$1; (cmap || $throwRuntimeError("assignment to entry in nil map"))[_key.$key()] = { k: _key, v: $appendSlice((_entry$1 = cmap[new$1.$key()], _entry$1 !== undefined ? _entry$1.v : ($sliceType(($ptrType(CommentGroup)))).nil), list) }; } - if (!check.assignment(x, z.typ)) { - if (!((x.mode === 0))) { - check.errorf(x.pos(), "cannot assign %s to %s", new ($sliceType($emptyInterface))([x, z])); + return new$1; + }; + $ptrType(CommentMap).prototype.Update = function(old, new$1) { return new CommentMap(this.$get()).Update(old, new$1); }; + CommentMap.prototype.Filter = function(node) { + var cmap, umap; + cmap = this.$val !== undefined ? this.$val : this; + umap = new $Map(); + Inspect(node, (function(n) { + var _entry, g, _key; + g = (_entry = cmap[n.$key()], _entry !== undefined ? _entry.v : ($sliceType(($ptrType(CommentGroup)))).nil); + if (g.$length > 0) { + _key = n; (umap || $throwRuntimeError("assignment to entry in nil map"))[_key.$key()] = { k: _key, v: g }; } - return $ifaceNil; - } - return x.typ; + return true; + })); + return umap; }; - Checker.prototype.assignVar = function(lhs, x) { return this.$val.assignVar(lhs, x); }; - Checker.Ptr.prototype.initVars = function(lhs, rhs, returnPos) { - var check, l, _tuple, get, r, commaOk, _ref, _i, obj, x, a, _ref$1, _i$1, i, _ref$2, _i$2, i$1, lhs$1; - check = this; - l = lhs.$length; - _tuple = unpack((function(x, i) { - check.expr(x, ((i < 0 || i >= rhs.$length) ? $throwRuntimeError("index out of range") : rhs.$array[rhs.$offset + i])); - }), rhs.$length, (l === 2) && !(new token.Pos(returnPos)).IsValid()); get = _tuple[0]; r = _tuple[1]; commaOk = _tuple[2]; - if (!((l === r))) { - _ref = lhs; - _i = 0; - while (_i < _ref.$length) { - obj = ((_i < 0 || _i >= _ref.$length) ? $throwRuntimeError("index out of range") : _ref.$array[_ref.$offset + _i]); - if ($interfaceIsEqual(obj.object.typ, $ifaceNil)) { - obj.object.typ = $pkg.Typ[0]; - } + $ptrType(CommentMap).prototype.Filter = function(node) { return new CommentMap(this.$get()).Filter(node); }; + CommentMap.prototype.Comments = function() { + var cmap, list, _ref, _i, _keys, _entry, e; + cmap = this.$val !== undefined ? this.$val : this; + list = ($sliceType(($ptrType(CommentGroup)))).make(0, $keys(cmap).length); + _ref = cmap; + _i = 0; + _keys = $keys(_ref); + while (_i < _keys.length) { + _entry = _ref[_keys[_i]]; + if (_entry === undefined) { _i++; + continue; } - check.use(rhs); - if ((new token.Pos(returnPos)).IsValid()) { - check.errorf(returnPos, "wrong number of return values (want %d, got %d)", new ($sliceType($emptyInterface))([new $Int(l), new $Int(r)])); - return; - } - check.errorf(((0 < 0 || 0 >= rhs.$length) ? $throwRuntimeError("index out of range") : rhs.$array[rhs.$offset + 0]).Pos(), "assignment count mismatch (%d vs %d)", new ($sliceType($emptyInterface))([new $Int(l), new $Int(r)])); - return; + e = _entry.v; + list = $appendSlice(list, e); + _i++; } - x = new operand.Ptr(); $copy(x, new operand.Ptr(), operand); - if (commaOk) { - a = ($arrayType(Type, 2)).zero(); $copy(a, ($arrayType(Type, 2)).zero(), ($arrayType(Type, 2))); - _ref$1 = a; + sortComments(list); + return list; + }; + $ptrType(CommentMap).prototype.Comments = function() { return new CommentMap(this.$get()).Comments(); }; + summary = function(list) { + var buf, _ref, _i, group, _ref$1, _i$1, comment, bytes$1, _ref$2, _i$2, i, b, _ref$3; + buf = new bytes.Buffer.Ptr(); $copy(buf, new bytes.Buffer.Ptr(), bytes.Buffer); + _ref = list; + _i = 0; + loop: + while (_i < _ref.$length) { + group = ((_i < 0 || _i >= _ref.$length) ? $throwRuntimeError("index out of range") : _ref.$array[_ref.$offset + _i]); + _ref$1 = group.List; _i$1 = 0; - while (_i$1 < 2) { - i = _i$1; - get(x, i); - (i < 0 || i >= a.length) ? $throwRuntimeError("index out of range") : a[i] = check.initVar(((i < 0 || i >= lhs.$length) ? $throwRuntimeError("index out of range") : lhs.$array[lhs.$offset + i]), x, (new token.Pos(returnPos)).IsValid()); + while (_i$1 < _ref$1.$length) { + comment = ((_i$1 < 0 || _i$1 >= _ref$1.$length) ? $throwRuntimeError("index out of range") : _ref$1.$array[_ref$1.$offset + _i$1]); + if (buf.Len() >= 40) { + break loop; + } + buf.WriteString(comment.Text); _i$1++; } - check.recordCommaOkTypes(((0 < 0 || 0 >= rhs.$length) ? $throwRuntimeError("index out of range") : rhs.$array[rhs.$offset + 0]), $clone(a, ($arrayType(Type, 2)))); - return; + _i++; } - _ref$2 = lhs; + if (buf.Len() > 40) { + buf.Truncate(37); + buf.WriteString("..."); + } + bytes$1 = buf.Bytes(); + _ref$2 = bytes$1; _i$2 = 0; while (_i$2 < _ref$2.$length) { - i$1 = _i$2; - lhs$1 = ((_i$2 < 0 || _i$2 >= _ref$2.$length) ? $throwRuntimeError("index out of range") : _ref$2.$array[_ref$2.$offset + _i$2]); - get(x, i$1); - check.initVar(lhs$1, x, (new token.Pos(returnPos)).IsValid()); + i = _i$2; + b = ((_i$2 < 0 || _i$2 >= _ref$2.$length) ? $throwRuntimeError("index out of range") : _ref$2.$array[_ref$2.$offset + _i$2]); + _ref$3 = b; + if (_ref$3 === 9 || _ref$3 === 10 || _ref$3 === 13) { + (i < 0 || i >= bytes$1.$length) ? $throwRuntimeError("index out of range") : bytes$1.$array[bytes$1.$offset + i] = 32; + } _i$2++; } + return $bytesToString(bytes$1); }; - Checker.prototype.initVars = function(lhs, rhs, returnPos) { return this.$val.initVars(lhs, rhs, returnPos); }; - Checker.Ptr.prototype.assignVars = function(lhs, rhs) { - var check, l, _tuple, get, r, commaOk, x, a, _ref, _i, i, _ref$1, _i$1, i$1, lhs$1; - check = this; - l = lhs.$length; - _tuple = unpack((function(x, i) { - check.expr(x, ((i < 0 || i >= rhs.$length) ? $throwRuntimeError("index out of range") : rhs.$array[rhs.$offset + i])); - }), rhs.$length, l === 2); get = _tuple[0]; r = _tuple[1]; commaOk = _tuple[2]; - if (!((l === r))) { - check.errorf(((0 < 0 || 0 >= rhs.$length) ? $throwRuntimeError("index out of range") : rhs.$array[rhs.$offset + 0]).Pos(), "assignment count mismatch (%d vs %d)", new ($sliceType($emptyInterface))([new $Int(l), new $Int(r)])); - check.use(rhs); - return; - } - x = new operand.Ptr(); $copy(x, new operand.Ptr(), operand); - if (commaOk) { - a = ($arrayType(Type, 2)).zero(); $copy(a, ($arrayType(Type, 2)).zero(), ($arrayType(Type, 2))); - _ref = a; - _i = 0; - while (_i < 2) { - i = _i; - get(x, i); - (i < 0 || i >= a.length) ? $throwRuntimeError("index out of range") : a[i] = check.assignVar(((i < 0 || i >= lhs.$length) ? $throwRuntimeError("index out of range") : lhs.$array[lhs.$offset + i]), x); + CommentMap.prototype.String = function() { + var cmap, buf, _ref, _i, _keys, _entry, node, comment, s, _tuple, ident, ok; + cmap = this.$val !== undefined ? this.$val : this; + buf = new bytes.Buffer.Ptr(); $copy(buf, new bytes.Buffer.Ptr(), bytes.Buffer); + fmt.Fprintln(buf, new ($sliceType($emptyInterface))([new $String("CommentMap {")])); + _ref = cmap; + _i = 0; + _keys = $keys(_ref); + while (_i < _keys.length) { + _entry = _ref[_keys[_i]]; + if (_entry === undefined) { _i++; + continue; } - check.recordCommaOkTypes(((0 < 0 || 0 >= rhs.$length) ? $throwRuntimeError("index out of range") : rhs.$array[rhs.$offset + 0]), $clone(a, ($arrayType(Type, 2)))); - return; - } - _ref$1 = lhs; - _i$1 = 0; - while (_i$1 < _ref$1.$length) { - i$1 = _i$1; - lhs$1 = ((_i$1 < 0 || _i$1 >= _ref$1.$length) ? $throwRuntimeError("index out of range") : _ref$1.$array[_ref$1.$offset + _i$1]); - get(x, i$1); - check.assignVar(lhs$1, x); - _i$1++; + node = _entry.k; + comment = _entry.v; + s = ""; + _tuple = $assertType(node, ($ptrType(Ident)), true); ident = _tuple[0]; ok = _tuple[1]; + if (ok) { + s = ident.Name; + } else { + s = fmt.Sprintf("%T", new ($sliceType($emptyInterface))([node])); + } + fmt.Fprintf(buf, "\t%p %20s: %s\n", new ($sliceType($emptyInterface))([node, new $String(s), new $String(summary(comment))])); + _i++; } + fmt.Fprintln(buf, new ($sliceType($emptyInterface))([new $String("}")])); + return buf.String(); }; - Checker.prototype.assignVars = function(lhs, rhs) { return this.$val.assignVars(lhs, rhs); }; - Checker.Ptr.prototype.shortVarDecl = function(pos, lhs, rhs) { - var check, scope, newVars, lhsVars, _ref, _i, i, lhs$1, obj, _tuple, ident, name, alt, _tuple$1, alt$1, _ref$1, _i$1, obj$1; - check = this; - scope = check.context.scope; - newVars = ($sliceType(($ptrType(Var)))).nil; - lhsVars = ($sliceType(($ptrType(Var)))).make(lhs.$length); - _ref = lhs; + $ptrType(CommentMap).prototype.String = function() { return new CommentMap(this.$get()).String(); }; + SortImports = $pkg.SortImports = function(fset, f) { + var _ref, _i, d, _tuple, d$1, ok, i, specs, _ref$1, _i$1, j, s, x, x$1, x$2, x$3, lastSpec, lastLine, rParenLine; + _ref = f.Decls; _i = 0; while (_i < _ref.$length) { - i = _i; - lhs$1 = ((_i < 0 || _i >= _ref.$length) ? $throwRuntimeError("index out of range") : _ref.$array[_ref.$offset + _i]); - obj = ($ptrType(Var)).nil; - _tuple = $assertType(lhs$1, ($ptrType(ast.Ident)), true); ident = _tuple[0]; - if (!(ident === ($ptrType(ast.Ident)).nil)) { - name = ident.Name; - alt = scope.Lookup(name); - if (!($interfaceIsEqual(alt, $ifaceNil))) { - _tuple$1 = $assertType(alt, ($ptrType(Var)), true); alt$1 = _tuple$1[0]; - if (!(alt$1 === ($ptrType(Var)).nil)) { - obj = alt$1; - } else { - check.errorf(lhs$1.Pos(), "cannot assign to %s", new ($sliceType($emptyInterface))([lhs$1])); - } - check.recordUse(ident, alt); - } else { - obj = NewVar(ident.Pos(), check.pkg, name, $ifaceNil); - if (!(name === "_")) { - newVars = $append(newVars, obj); - } - check.recordDef(ident, obj); - } - } else { - check.errorf(lhs$1.Pos(), "cannot declare %s", new ($sliceType($emptyInterface))([lhs$1])); + d = ((_i < 0 || _i >= _ref.$length) ? $throwRuntimeError("index out of range") : _ref.$array[_ref.$offset + _i]); + _tuple = $assertType(d, ($ptrType(GenDecl)), true); d$1 = _tuple[0]; ok = _tuple[1]; + if (!ok || !((d$1.Tok === 75))) { + break; } - if (obj === ($ptrType(Var)).nil) { - obj = NewVar(lhs$1.Pos(), check.pkg, "_", $ifaceNil); + if (!(new token.Pos(d$1.Lparen)).IsValid()) { + _i++; + continue; } - (i < 0 || i >= lhsVars.$length) ? $throwRuntimeError("index out of range") : lhsVars.$array[lhsVars.$offset + i] = obj; - _i++; - } - check.initVars(lhsVars, rhs, 0); - if (newVars.$length > 0) { - _ref$1 = newVars; + i = 0; + specs = $subslice(d$1.Specs, 0, 0); + _ref$1 = d$1.Specs; _i$1 = 0; while (_i$1 < _ref$1.$length) { - obj$1 = ((_i$1 < 0 || _i$1 >= _ref$1.$length) ? $throwRuntimeError("index out of range") : _ref$1.$array[_ref$1.$offset + _i$1]); - check.declare(scope, ($ptrType(ast.Ident)).nil, obj$1); + j = _i$1; + s = ((_i$1 < 0 || _i$1 >= _ref$1.$length) ? $throwRuntimeError("index out of range") : _ref$1.$array[_ref$1.$offset + _i$1]); + if (j > i && fset.Position(s.Pos()).Line > (1 + fset.Position((x = d$1.Specs, x$1 = j - 1 >> 0, ((x$1 < 0 || x$1 >= x.$length) ? $throwRuntimeError("index out of range") : x.$array[x.$offset + x$1])).End()).Line >> 0)) { + specs = $appendSlice(specs, sortSpecs(fset, f, $subslice(d$1.Specs, i, j))); + i = j; + } _i$1++; } - } else { - check.softErrorf(pos, "no new variables on left side of :=", new ($sliceType($emptyInterface))([])); + specs = $appendSlice(specs, sortSpecs(fset, f, $subslice(d$1.Specs, i))); + d$1.Specs = specs; + if (d$1.Specs.$length > 0) { + lastSpec = (x$2 = d$1.Specs, x$3 = d$1.Specs.$length - 1 >> 0, ((x$3 < 0 || x$3 >= x$2.$length) ? $throwRuntimeError("index out of range") : x$2.$array[x$2.$offset + x$3])); + lastLine = fset.Position(lastSpec.Pos()).Line; + rParenLine = fset.Position(d$1.Rparen).Line; + if (rParenLine > (lastLine + 1 >> 0)) { + fset.File(d$1.Rparen).MergeLine(rParenLine - 1 >> 0); + } + } + _i++; } }; - Checker.prototype.shortVarDecl = function(pos, lhs, rhs) { return this.$val.shortVarDecl(pos, lhs, rhs); }; - Checker.Ptr.prototype.builtin = function(x, call, id) { - var result = false, $deferred = [], $err = null, check, bin, arg, nargs, _ref, _tuple, msg, _ref$1, S, T, _tuple$1, s, alist, sig, sig$1, mode, typ, val, t, _ref$2, _tuple$2, c, y, realT, complexT, _ref$3, dst, _tuple$3, t$1, y$1, src, t$2, _ref$4, _tuple$4, m, k, _ref$5, x$1, arg0, T$1, min, _ref$6, sizes, _ref$7, _i, arg$1, _tuple$5, s$1, ok, x$2, x$3, x$4, params, x$5, T$2, T$3, params$1, i, x$6, arg0$1, _tuple$6, selx, base, sel, _tuple$7, obj, index, indirect, _ref$8, offs, t$3, x1, _ref$9, _i$1, arg$2; - /* */ try { $deferFrames.push($deferred); - check = this; - bin = new ($structType([["name", "name", "code.google.com/p/go.tools/go/types", $String, ""], ["nargs", "nargs", "code.google.com/p/go.tools/go/types", $Int, ""], ["variadic", "variadic", "code.google.com/p/go.tools/go/types", $Bool, ""], ["kind", "kind", "code.google.com/p/go.tools/go/types", exprKind, ""]])).Ptr(); $copy(bin, ((id < 0 || id >= predeclaredFuncs.length) ? $throwRuntimeError("index out of range") : predeclaredFuncs[id]), ($structType([["name", "name", "code.google.com/p/go.tools/go/types", $String, ""], ["nargs", "nargs", "code.google.com/p/go.tools/go/types", $Int, ""], ["variadic", "variadic", "code.google.com/p/go.tools/go/types", $Bool, ""], ["kind", "kind", "code.google.com/p/go.tools/go/types", exprKind, ""]]))); - if ((new token.Pos(call.Ellipsis)).IsValid() && !((id === 0))) { - check.invalidOp(call.Ellipsis, "invalid use of ... with built-in %s", new ($sliceType($emptyInterface))([new $String(bin.name)])); - check.use(call.Args); - return result; + importPath = function(s) { + var _tuple, t, err; + _tuple = strconv.Unquote($assertType(s, ($ptrType(ImportSpec))).Path.Value); t = _tuple[0]; err = _tuple[1]; + if ($interfaceIsEqual(err, $ifaceNil)) { + return t; } - if ((id === 7) || (id === 1)) { - $deferred.push([(function(b) { - check.context.hasCallOrRecv = b; - }), [check.context.hasCallOrRecv]]); - check.context.hasCallOrRecv = false; + return ""; + }; + importName = function(s) { + var n; + n = $assertType(s, ($ptrType(ImportSpec))).Name; + if (n === ($ptrType(Ident)).nil) { + return ""; } - arg = $throwNilPointerError; - nargs = call.Args.$length; - _ref = id; - if (_ref === 8 || _ref === 9 || _ref === 16 || _ref === 19) { - } else { - _tuple = unpack((function(x$1, i) { - var x$2; - check.expr(x$1, (x$2 = call.Args, ((i < 0 || i >= x$2.$length) ? $throwRuntimeError("index out of range") : x$2.$array[x$2.$offset + i]))); - }), nargs, false); arg = _tuple[0]; nargs = _tuple[1]; - if (nargs > 0) { - arg(x, 0); - if (x.mode === 0) { - return result; - } - } + return n.Name; + }; + importComment = function(s) { + var c; + c = $assertType(s, ($ptrType(ImportSpec))).Comment; + if (c === ($ptrType(CommentGroup)).nil) { + return ""; } - msg = ""; - if (nargs < bin.nargs) { - msg = "not enough"; - } else if (!bin.variadic && nargs > bin.nargs) { - msg = "too many"; + return c.Text(); + }; + collapse = function(prev, next) { + if (!(importPath(next) === importPath(prev)) || !(importName(next) === importName(prev))) { + return false; } - if (!(msg === "")) { - check.invalidOp(call.Rparen, "%s arguments for %s (expected %d, found %d)", new ($sliceType($emptyInterface))([new $String(msg), call, new $Int(bin.nargs), new $Int(nargs)])); - return result; + return $assertType(prev, ($ptrType(ImportSpec))).Comment === ($ptrType(CommentGroup)).nil; + }; + sortSpecs = function(fset, f, specs) { + var pos, _ref, _i, i, s, x, lastLine, cstart, cend, _ref$1, _i$1, i$1, g, comments, importComment$1, _map, _key, specIndex, _ref$2, _i$2, g$1, x$1, s$1, _entry, _key$1, deduped, _ref$3, _i$3, i$2, s$2, x$2, p, _ref$4, _i$4, i$3, s$3, s$4, _ref$5, _entry$1, _i$5, g$2, _ref$6, _i$6, c; + if (specs.$length <= 1) { + return specs; } - _ref$1 = id; - switch (0) { default: if (_ref$1 === 0) { - S = x.typ; - T = $ifaceNil; - _tuple$1 = $assertType(S.Underlying(), ($ptrType(Slice)), true); s = _tuple$1[0]; - if (!(s === ($ptrType(Slice)).nil)) { - T = s.elem; - } else { - check.invalidArg(x.pos(), "%s is not a slice", new ($sliceType($emptyInterface))([x])); - return result; - } - alist = new ($sliceType(operand))([$clone(x, operand)]); - if ((nargs === 2) && (new token.Pos(call.Ellipsis)).IsValid() && x.assignableTo(check.conf, NewSlice($pkg.UniverseByte))) { - arg(x, 1); - if (x.mode === 0) { - return result; - } - if (isString(x.typ)) { - if (!(check.Info.Types === false)) { - sig = makeSig(S, new ($sliceType(Type))([S, x.typ])); - sig.variadic = true; - check.recordBuiltinType(call.Fun, sig); - } - x.mode = 7; - x.typ = S; - break; - } - alist = $append(alist, x); - } - sig$1 = makeSig(S, new ($sliceType(Type))([S, NewSlice(T)])); - sig$1.variadic = true; - check.arguments$(x, call, sig$1, (function(x$1, i) { - if (i < alist.$length) { - $copy(x$1, ((i < 0 || i >= alist.$length) ? $throwRuntimeError("index out of range") : alist.$array[alist.$offset + i]), operand); - return; - } - arg(x$1, i); - }), nargs); - x.mode = 7; - x.typ = S; - if (!(check.Info.Types === false)) { - check.recordBuiltinType(call.Fun, sig$1); - } - } else if (_ref$1 === 1 || _ref$1 === 7) { - mode = 0; - typ = $ifaceNil; - val = $ifaceNil; - typ = implicitArrayDeref(x.typ.Underlying()); - _ref$2 = typ; - if ($assertType(_ref$2, ($ptrType(Basic)), true)[1]) { - t = _ref$2.$val; - if (isString(t) && (id === 7)) { - if (x.mode === 4) { - mode = 4; - val = exact.MakeInt64(new $Int64(0, exact.StringVal(x.val).length)); - } else { - mode = 7; - } - } - } else if ($assertType(_ref$2, ($ptrType(Array)), true)[1]) { - t = _ref$2.$val; - mode = 7; - if (!check.context.hasCallOrRecv) { - mode = 4; - val = exact.MakeInt64(t.len); - } - } else if ($assertType(_ref$2, ($ptrType(Slice)), true)[1] || $assertType(_ref$2, ($ptrType(Chan)), true)[1]) { - t = _ref$2; - mode = 7; - } else if ($assertType(_ref$2, ($ptrType(Map)), true)[1]) { - t = _ref$2.$val; - if (id === 7) { - mode = 7; - } - } - if (mode === 0) { - check.invalidArg(x.pos(), "%s for %s", new ($sliceType($emptyInterface))([x, new $String(bin.name)])); - return result; - } - x.mode = mode; - x.typ = $pkg.Typ[2]; - x.val = val; - if (!(check.Info.Types === false) && !((mode === 4))) { - check.recordBuiltinType(call.Fun, makeSig(x.typ, new ($sliceType(Type))([typ]))); - } - } else if (_ref$1 === 2) { - _tuple$2 = $assertType(x.typ.Underlying(), ($ptrType(Chan)), true); c = _tuple$2[0]; - if (c === ($ptrType(Chan)).nil) { - check.invalidArg(x.pos(), "%s is not a channel", new ($sliceType($emptyInterface))([x])); - return result; - } - if (c.dir === 2) { - check.invalidArg(x.pos(), "%s must not be a receive-only channel", new ($sliceType($emptyInterface))([x])); - return result; - } - x.mode = 1; - if (!(check.Info.Types === false)) { - check.recordBuiltinType(call.Fun, makeSig($ifaceNil, new ($sliceType(Type))([c]))); - } - } else if (_ref$1 === 3) { - if (!check.complexArg(x)) { - return result; - } - y = new operand.Ptr(); $copy(y, new operand.Ptr(), operand); - arg(y, 1); - if (y.mode === 0) { - return result; - } - if (!check.complexArg(y)) { - return result; + pos = ($sliceType(posSpan)).make(specs.$length); + _ref = specs; + _i = 0; + while (_i < _ref.$length) { + i = _i; + s = ((_i < 0 || _i >= _ref.$length) ? $throwRuntimeError("index out of range") : _ref.$array[_ref.$offset + _i]); + $copy(((i < 0 || i >= pos.$length) ? $throwRuntimeError("index out of range") : pos.$array[pos.$offset + i]), new posSpan.Ptr(s.Pos(), s.End()), posSpan); + _i++; + } + lastLine = fset.Position((x = pos.$length - 1 >> 0, ((x < 0 || x >= pos.$length) ? $throwRuntimeError("index out of range") : pos.$array[pos.$offset + x])).End).Line; + cstart = f.Comments.$length; + cend = f.Comments.$length; + _ref$1 = f.Comments; + _i$1 = 0; + while (_i$1 < _ref$1.$length) { + i$1 = _i$1; + g = ((_i$1 < 0 || _i$1 >= _ref$1.$length) ? $throwRuntimeError("index out of range") : _ref$1.$array[_ref$1.$offset + _i$1]); + if (g.Pos() < ((0 < 0 || 0 >= pos.$length) ? $throwRuntimeError("index out of range") : pos.$array[pos.$offset + 0]).Start) { + _i$1++; + continue; } - check.convertUntyped(x, y.typ); - if (x.mode === 0) { - return result; + if (i$1 < cstart) { + cstart = i$1; } - check.convertUntyped(y, x.typ); - if (y.mode === 0) { - return result; + if (fset.Position(g.End()).Line > lastLine) { + cend = i$1; + break; } - if (!Identical(x.typ, y.typ)) { - check.invalidArg(x.pos(), "mismatched types %s and %s", new ($sliceType($emptyInterface))([x.typ, y.typ])); - return result; + _i$1++; + } + comments = $subslice(f.Comments, cstart, cend); + importComment$1 = (_map = new $Map(), _map); + specIndex = 0; + _ref$2 = comments; + _i$2 = 0; + while (_i$2 < _ref$2.$length) { + g$1 = ((_i$2 < 0 || _i$2 >= _ref$2.$length) ? $throwRuntimeError("index out of range") : _ref$2.$array[_ref$2.$offset + _i$2]); + while ((specIndex + 1 >> 0) < specs.$length && (x$1 = specIndex + 1 >> 0, ((x$1 < 0 || x$1 >= pos.$length) ? $throwRuntimeError("index out of range") : pos.$array[pos.$offset + x$1])).Start <= g$1.Pos()) { + specIndex = specIndex + (1) >> 0; } - if ((x.mode === 4) && (y.mode === 4)) { - x.val = exact.BinaryOp(x.val, 12, exact.MakeImag(y.val)); + s$1 = $assertType(((specIndex < 0 || specIndex >= specs.$length) ? $throwRuntimeError("index out of range") : specs.$array[specs.$offset + specIndex]), ($ptrType(ImportSpec))); + _key$1 = s$1; (importComment$1 || $throwRuntimeError("assignment to entry in nil map"))[_key$1.$key()] = { k: _key$1, v: $append((_entry = importComment$1[s$1.$key()], _entry !== undefined ? _entry.v : ($sliceType(($ptrType(CommentGroup)))).nil), g$1) }; + _i$2++; + } + sort.Sort($subslice(new byImportSpec(specs.$array), specs.$offset, specs.$offset + specs.$length)); + deduped = $subslice(specs, 0, 0); + _ref$3 = specs; + _i$3 = 0; + while (_i$3 < _ref$3.$length) { + i$2 = _i$3; + s$2 = ((_i$3 < 0 || _i$3 >= _ref$3.$length) ? $throwRuntimeError("index out of range") : _ref$3.$array[_ref$3.$offset + _i$3]); + if ((i$2 === (specs.$length - 1 >> 0)) || !collapse(s$2, (x$2 = i$2 + 1 >> 0, ((x$2 < 0 || x$2 >= specs.$length) ? $throwRuntimeError("index out of range") : specs.$array[specs.$offset + x$2])))) { + deduped = $append(deduped, s$2); } else { - x.mode = 7; + p = s$2.Pos(); + fset.File(p).MergeLine(fset.Position(p).Line); } - realT = x.typ; - complexT = $pkg.Typ[0]; - _ref$3 = $assertType(realT.Underlying(), ($ptrType(Basic))).kind; - if (_ref$3 === 13) { - complexT = $pkg.Typ[15]; - } else if (_ref$3 === 14) { - complexT = $pkg.Typ[16]; - } else if (_ref$3 === 20 || _ref$3 === 21 || _ref$3 === 22) { - if (x.mode === 4) { - realT = $assertType(defaultType(realT), ($ptrType(Basic))); - complexT = $pkg.Typ[23]; - } else { - realT = $pkg.Typ[14]; - complexT = $pkg.Typ[16]; - } - } else { - check.invalidArg(x.pos(), "float32 or float64 arguments expected", new ($sliceType($emptyInterface))([])); - return result; + _i$3++; + } + specs = deduped; + _ref$4 = specs; + _i$4 = 0; + while (_i$4 < _ref$4.$length) { + i$3 = _i$4; + s$3 = ((_i$4 < 0 || _i$4 >= _ref$4.$length) ? $throwRuntimeError("index out of range") : _ref$4.$array[_ref$4.$offset + _i$4]); + s$4 = $assertType(s$3, ($ptrType(ImportSpec))); + if (!(s$4.Name === ($ptrType(Ident)).nil)) { + s$4.Name.NamePos = ((i$3 < 0 || i$3 >= pos.$length) ? $throwRuntimeError("index out of range") : pos.$array[pos.$offset + i$3]).Start; } - x.typ = complexT; - if (!(check.Info.Types === false) && !((x.mode === 4))) { - check.recordBuiltinType(call.Fun, makeSig(complexT, new ($sliceType(Type))([realT, realT]))); + s$4.Path.ValuePos = ((i$3 < 0 || i$3 >= pos.$length) ? $throwRuntimeError("index out of range") : pos.$array[pos.$offset + i$3]).Start; + s$4.EndPos = ((i$3 < 0 || i$3 >= pos.$length) ? $throwRuntimeError("index out of range") : pos.$array[pos.$offset + i$3]).End; + _ref$5 = (_entry$1 = importComment$1[s$4.$key()], _entry$1 !== undefined ? _entry$1.v : ($sliceType(($ptrType(CommentGroup)))).nil); + _i$5 = 0; + while (_i$5 < _ref$5.$length) { + g$2 = ((_i$5 < 0 || _i$5 >= _ref$5.$length) ? $throwRuntimeError("index out of range") : _ref$5.$array[_ref$5.$offset + _i$5]); + _ref$6 = g$2.List; + _i$6 = 0; + while (_i$6 < _ref$6.$length) { + c = ((_i$6 < 0 || _i$6 >= _ref$6.$length) ? $throwRuntimeError("index out of range") : _ref$6.$array[_ref$6.$offset + _i$6]); + c.Slash = ((i$3 < 0 || i$3 >= pos.$length) ? $throwRuntimeError("index out of range") : pos.$array[pos.$offset + i$3]).End; + _i$6++; + } + _i$5++; } - if (!((x.mode === 4))) { - check.updateExprType(x.expr, realT, true); - check.updateExprType(y.expr, realT, true); + _i$4++; + } + sort.Sort($subslice(new byCommentPos(comments.$array), comments.$offset, comments.$offset + comments.$length)); + return specs; + }; + byImportSpec.prototype.Len = function() { + var x; + x = this; + return x.$length; + }; + $ptrType(byImportSpec).prototype.Len = function() { return this.$get().Len(); }; + byImportSpec.prototype.Swap = function(i, j) { + var x, _tmp, _tmp$1; + x = this; + _tmp = ((j < 0 || j >= x.$length) ? $throwRuntimeError("index out of range") : x.$array[x.$offset + j]); _tmp$1 = ((i < 0 || i >= x.$length) ? $throwRuntimeError("index out of range") : x.$array[x.$offset + i]); (i < 0 || i >= x.$length) ? $throwRuntimeError("index out of range") : x.$array[x.$offset + i] = _tmp; (j < 0 || j >= x.$length) ? $throwRuntimeError("index out of range") : x.$array[x.$offset + j] = _tmp$1; + }; + $ptrType(byImportSpec).prototype.Swap = function(i, j) { return this.$get().Swap(i, j); }; + byImportSpec.prototype.Less = function(i, j) { + var x, ipath, jpath, iname, jname; + x = this; + ipath = importPath(((i < 0 || i >= x.$length) ? $throwRuntimeError("index out of range") : x.$array[x.$offset + i])); + jpath = importPath(((j < 0 || j >= x.$length) ? $throwRuntimeError("index out of range") : x.$array[x.$offset + j])); + if (!(ipath === jpath)) { + return ipath < jpath; + } + iname = importName(((i < 0 || i >= x.$length) ? $throwRuntimeError("index out of range") : x.$array[x.$offset + i])); + jname = importName(((j < 0 || j >= x.$length) ? $throwRuntimeError("index out of range") : x.$array[x.$offset + j])); + if (!(iname === jname)) { + return iname < jname; + } + return importComment(((i < 0 || i >= x.$length) ? $throwRuntimeError("index out of range") : x.$array[x.$offset + i])) < importComment(((j < 0 || j >= x.$length) ? $throwRuntimeError("index out of range") : x.$array[x.$offset + j])); + }; + $ptrType(byImportSpec).prototype.Less = function(i, j) { return this.$get().Less(i, j); }; + byCommentPos.prototype.Len = function() { + var x; + x = this; + return x.$length; + }; + $ptrType(byCommentPos).prototype.Len = function() { return this.$get().Len(); }; + byCommentPos.prototype.Swap = function(i, j) { + var x, _tmp, _tmp$1; + x = this; + _tmp = ((j < 0 || j >= x.$length) ? $throwRuntimeError("index out of range") : x.$array[x.$offset + j]); _tmp$1 = ((i < 0 || i >= x.$length) ? $throwRuntimeError("index out of range") : x.$array[x.$offset + i]); (i < 0 || i >= x.$length) ? $throwRuntimeError("index out of range") : x.$array[x.$offset + i] = _tmp; (j < 0 || j >= x.$length) ? $throwRuntimeError("index out of range") : x.$array[x.$offset + j] = _tmp$1; + }; + $ptrType(byCommentPos).prototype.Swap = function(i, j) { return this.$get().Swap(i, j); }; + byCommentPos.prototype.Less = function(i, j) { + var x; + x = this; + return ((i < 0 || i >= x.$length) ? $throwRuntimeError("index out of range") : x.$array[x.$offset + i]).Pos() < ((j < 0 || j >= x.$length) ? $throwRuntimeError("index out of range") : x.$array[x.$offset + j]).Pos(); + }; + $ptrType(byCommentPos).prototype.Less = function(i, j) { return this.$get().Less(i, j); }; + NewScope = $pkg.NewScope = function(outer) { + return new Scope.Ptr(outer, new $Map()); + }; + Scope.Ptr.prototype.Lookup = function(name) { + var s, _entry; + s = this; + return (_entry = s.Objects[name], _entry !== undefined ? _entry.v : ($ptrType(Object)).nil); + }; + Scope.prototype.Lookup = function(name) { return this.$val.Lookup(name); }; + Scope.Ptr.prototype.Insert = function(obj) { + var alt = ($ptrType(Object)).nil, s, _entry, _key; + s = this; + alt = (_entry = s.Objects[obj.Name], _entry !== undefined ? _entry.v : ($ptrType(Object)).nil); + if (alt === ($ptrType(Object)).nil) { + _key = obj.Name; (s.Objects || $throwRuntimeError("assignment to entry in nil map"))[_key] = { k: _key, v: obj }; + } + return alt; + }; + Scope.prototype.Insert = function(obj) { return this.$val.Insert(obj); }; + Scope.Ptr.prototype.String = function() { + var s, buf, _ref, _i, _keys, _entry, obj; + s = this; + buf = new bytes.Buffer.Ptr(); $copy(buf, new bytes.Buffer.Ptr(), bytes.Buffer); + fmt.Fprintf(buf, "scope %p {", new ($sliceType($emptyInterface))([s])); + if (!(s === ($ptrType(Scope)).nil) && $keys(s.Objects).length > 0) { + fmt.Fprintln(buf, new ($sliceType($emptyInterface))([])); + _ref = s.Objects; + _i = 0; + _keys = $keys(_ref); + while (_i < _keys.length) { + _entry = _ref[_keys[_i]]; + if (_entry === undefined) { + _i++; + continue; + } + obj = _entry.v; + fmt.Fprintf(buf, "\t%s %s\n", new ($sliceType($emptyInterface))([new ObjKind(obj.Kind), new $String(obj.Name)])); + _i++; } - } else if (_ref$1 === 4) { - dst = $ifaceNil; - _tuple$3 = $assertType(x.typ.Underlying(), ($ptrType(Slice)), true); t$1 = _tuple$3[0]; - if (!(t$1 === ($ptrType(Slice)).nil)) { - dst = t$1.elem; + } + fmt.Fprintf(buf, "}\n", new ($sliceType($emptyInterface))([])); + return buf.String(); + }; + Scope.prototype.String = function() { return this.$val.String(); }; + NewObj = $pkg.NewObj = function(kind, name) { + return new Object.Ptr(kind, name, $ifaceNil, $ifaceNil, $ifaceNil); + }; + Object.Ptr.prototype.Pos = function() { + var obj, name, d, _ref, _ref$1, _i, n, _ref$2, _i$1, n$1, _ref$3, _i$2, x, _tuple, ident, isIdent; + obj = this; + name = obj.Name; + _ref = obj.Decl; + if ($assertType(_ref, ($ptrType(Field)), true)[1]) { + d = _ref.$val; + _ref$1 = d.Names; + _i = 0; + while (_i < _ref$1.$length) { + n = ((_i < 0 || _i >= _ref$1.$length) ? $throwRuntimeError("index out of range") : _ref$1.$array[_ref$1.$offset + _i]); + if (n.Name === name) { + return n.Pos(); + } + _i++; } - y$1 = new operand.Ptr(); $copy(y$1, new operand.Ptr(), operand); - arg(y$1, 1); - if (y$1.mode === 0) { - return result; + } else if ($assertType(_ref, ($ptrType(ImportSpec)), true)[1]) { + d = _ref.$val; + if (!(d.Name === ($ptrType(Ident)).nil) && d.Name.Name === name) { + return d.Name.Pos(); } - src = $ifaceNil; - _ref$4 = y$1.typ.Underlying(); - if ($assertType(_ref$4, ($ptrType(Basic)), true)[1]) { - t$2 = _ref$4.$val; - if (isString(y$1.typ)) { - src = $pkg.UniverseByte; + return d.Path.Pos(); + } else if ($assertType(_ref, ($ptrType(ValueSpec)), true)[1]) { + d = _ref.$val; + _ref$2 = d.Names; + _i$1 = 0; + while (_i$1 < _ref$2.$length) { + n$1 = ((_i$1 < 0 || _i$1 >= _ref$2.$length) ? $throwRuntimeError("index out of range") : _ref$2.$array[_ref$2.$offset + _i$1]); + if (n$1.Name === name) { + return n$1.Pos(); } - } else if ($assertType(_ref$4, ($ptrType(Slice)), true)[1]) { - t$2 = _ref$4.$val; - src = t$2.elem; + _i$1++; } - if ($interfaceIsEqual(dst, $ifaceNil) || $interfaceIsEqual(src, $ifaceNil)) { - check.invalidArg(x.pos(), "copy expects slice arguments; found %s and %s", new ($sliceType($emptyInterface))([x, y$1])); - return result; + } else if ($assertType(_ref, ($ptrType(TypeSpec)), true)[1]) { + d = _ref.$val; + if (d.Name.Name === name) { + return d.Name.Pos(); } - if (!Identical(dst, src)) { - check.invalidArg(x.pos(), "arguments to copy %s and %s have different element types %s and %s", new ($sliceType($emptyInterface))([x, y$1, dst, src])); - return result; + } else if ($assertType(_ref, ($ptrType(FuncDecl)), true)[1]) { + d = _ref.$val; + if (d.Name.Name === name) { + return d.Name.Pos(); } - if (!(check.Info.Types === false)) { - check.recordBuiltinType(call.Fun, makeSig($pkg.Typ[2], new ($sliceType(Type))([x.typ, y$1.typ]))); + } else if ($assertType(_ref, ($ptrType(LabeledStmt)), true)[1]) { + d = _ref.$val; + if (d.Label.Name === name) { + return d.Label.Pos(); } - x.mode = 7; - x.typ = $pkg.Typ[2]; - } else if (_ref$1 === 5) { - _tuple$4 = $assertType(x.typ.Underlying(), ($ptrType(Map)), true); m = _tuple$4[0]; - if (m === ($ptrType(Map)).nil) { - check.invalidArg(x.pos(), "%s is not a map", new ($sliceType($emptyInterface))([x])); - return result; + } else if ($assertType(_ref, ($ptrType(AssignStmt)), true)[1]) { + d = _ref.$val; + _ref$3 = d.Lhs; + _i$2 = 0; + while (_i$2 < _ref$3.$length) { + x = ((_i$2 < 0 || _i$2 >= _ref$3.$length) ? $throwRuntimeError("index out of range") : _ref$3.$array[_ref$3.$offset + _i$2]); + _tuple = $assertType(x, ($ptrType(Ident)), true); ident = _tuple[0]; isIdent = _tuple[1]; + if (isIdent && ident.Name === name) { + return ident.Pos(); + } + _i$2++; } - arg(x, 1); - if (x.mode === 0) { - return result; + } + return 0; + }; + Object.prototype.Pos = function() { return this.$val.Pos(); }; + ObjKind.prototype.String = function() { + var kind; + kind = this.$val !== undefined ? this.$val : this; + return ((kind < 0 || kind >= objKindStrings.length) ? $throwRuntimeError("index out of range") : objKindStrings[kind]); + }; + $ptrType(ObjKind).prototype.String = function() { return new ObjKind(this.$get()).String(); }; + walkIdentList = function(v, list) { + var _ref, _i, x; + _ref = list; + _i = 0; + while (_i < _ref.$length) { + x = ((_i < 0 || _i >= _ref.$length) ? $throwRuntimeError("index out of range") : _ref.$array[_ref.$offset + _i]); + Walk(v, x); + _i++; + } + }; + walkExprList = function(v, list) { + var _ref, _i, x; + _ref = list; + _i = 0; + while (_i < _ref.$length) { + x = ((_i < 0 || _i >= _ref.$length) ? $throwRuntimeError("index out of range") : _ref.$array[_ref.$offset + _i]); + Walk(v, x); + _i++; + } + }; + walkStmtList = function(v, list) { + var _ref, _i, x; + _ref = list; + _i = 0; + while (_i < _ref.$length) { + x = ((_i < 0 || _i >= _ref.$length) ? $throwRuntimeError("index out of range") : _ref.$array[_ref.$offset + _i]); + Walk(v, x); + _i++; + } + }; + walkDeclList = function(v, list) { + var _ref, _i, x; + _ref = list; + _i = 0; + while (_i < _ref.$length) { + x = ((_i < 0 || _i >= _ref.$length) ? $throwRuntimeError("index out of range") : _ref.$array[_ref.$offset + _i]); + Walk(v, x); + _i++; + } + }; + Walk = $pkg.Walk = function(v, node) { + var n, _ref, _ref$1, _i, c, _ref$2, _i$1, f, _ref$3, _i$2, s, _ref$4, _i$3, _keys, _entry, f$1; + v = v.Visit(node); + if ($interfaceIsEqual(v, $ifaceNil)) { + return; + } + _ref = node; + if ($assertType(_ref, ($ptrType(Comment)), true)[1]) { + n = _ref.$val; + } else if ($assertType(_ref, ($ptrType(CommentGroup)), true)[1]) { + n = _ref.$val; + _ref$1 = n.List; + _i = 0; + while (_i < _ref$1.$length) { + c = ((_i < 0 || _i >= _ref$1.$length) ? $throwRuntimeError("index out of range") : _ref$1.$array[_ref$1.$offset + _i]); + Walk(v, c); + _i++; } - if (!x.assignableTo(check.conf, m.key)) { - check.invalidArg(x.pos(), "%s is not assignable to %s", new ($sliceType($emptyInterface))([x, m.key])); - return result; + } else if ($assertType(_ref, ($ptrType(Field)), true)[1]) { + n = _ref.$val; + if (!(n.Doc === ($ptrType(CommentGroup)).nil)) { + Walk(v, n.Doc); } - x.mode = 1; - if (!(check.Info.Types === false)) { - check.recordBuiltinType(call.Fun, makeSig($ifaceNil, new ($sliceType(Type))([m, m.key]))); + walkIdentList(v, n.Names); + Walk(v, n.Type); + if (!(n.Tag === ($ptrType(BasicLit)).nil)) { + Walk(v, n.Tag); } - } else if (_ref$1 === 6 || _ref$1 === 13) { - if (!isComplex(x.typ)) { - check.invalidArg(x.pos(), "%s must be a complex number", new ($sliceType($emptyInterface))([x])); - return result; + if (!(n.Comment === ($ptrType(CommentGroup)).nil)) { + Walk(v, n.Comment); } - if (x.mode === 4) { - if (id === 13) { - x.val = exact.Real(x.val); - } else { - x.val = exact.Imag(x.val); - } - } else { - x.mode = 7; + } else if ($assertType(_ref, ($ptrType(FieldList)), true)[1]) { + n = _ref.$val; + _ref$2 = n.List; + _i$1 = 0; + while (_i$1 < _ref$2.$length) { + f = ((_i$1 < 0 || _i$1 >= _ref$2.$length) ? $throwRuntimeError("index out of range") : _ref$2.$array[_ref$2.$offset + _i$1]); + Walk(v, f); + _i$1++; } - k = 0; - _ref$5 = $assertType(x.typ.Underlying(), ($ptrType(Basic))).kind; - if (_ref$5 === 15) { - k = 13; - } else if (_ref$5 === 16) { - k = 14; - } else if (_ref$5 === 23) { - k = 22; - } else { - unreachable(); + } else if ($assertType(_ref, ($ptrType(BadExpr)), true)[1] || $assertType(_ref, ($ptrType(Ident)), true)[1] || $assertType(_ref, ($ptrType(BasicLit)), true)[1]) { + n = _ref; + } else if ($assertType(_ref, ($ptrType(Ellipsis)), true)[1]) { + n = _ref.$val; + if (!($interfaceIsEqual(n.Elt, $ifaceNil))) { + Walk(v, n.Elt); } - if (!(check.Info.Types === false) && !((x.mode === 4))) { - check.recordBuiltinType(call.Fun, makeSig(((k < 0 || k >= $pkg.Typ.length) ? $throwRuntimeError("index out of range") : $pkg.Typ[k]), new ($sliceType(Type))([x.typ]))); + } else if ($assertType(_ref, ($ptrType(FuncLit)), true)[1]) { + n = _ref.$val; + Walk(v, n.Type); + Walk(v, n.Body); + } else if ($assertType(_ref, ($ptrType(CompositeLit)), true)[1]) { + n = _ref.$val; + if (!($interfaceIsEqual(n.Type, $ifaceNil))) { + Walk(v, n.Type); } - x.typ = ((k < 0 || k >= $pkg.Typ.length) ? $throwRuntimeError("index out of range") : $pkg.Typ[k]); - } else if (_ref$1 === 8) { - arg0 = (x$1 = call.Args, ((0 < 0 || 0 >= x$1.$length) ? $throwRuntimeError("index out of range") : x$1.$array[x$1.$offset + 0])); - T$1 = check.typ(arg0); - if ($interfaceIsEqual(T$1, $pkg.Typ[0])) { - return result; + walkExprList(v, n.Elts); + } else if ($assertType(_ref, ($ptrType(ParenExpr)), true)[1]) { + n = _ref.$val; + Walk(v, n.X); + } else if ($assertType(_ref, ($ptrType(SelectorExpr)), true)[1]) { + n = _ref.$val; + Walk(v, n.X); + Walk(v, n.Sel); + } else if ($assertType(_ref, ($ptrType(IndexExpr)), true)[1]) { + n = _ref.$val; + Walk(v, n.X); + Walk(v, n.Index); + } else if ($assertType(_ref, ($ptrType(SliceExpr)), true)[1]) { + n = _ref.$val; + Walk(v, n.X); + if (!($interfaceIsEqual(n.Low, $ifaceNil))) { + Walk(v, n.Low); } - min = 0; - _ref$6 = T$1.Underlying(); - if ($assertType(_ref$6, ($ptrType(Slice)), true)[1]) { - min = 2; - } else if ($assertType(_ref$6, ($ptrType(Map)), true)[1] || $assertType(_ref$6, ($ptrType(Chan)), true)[1]) { - min = 1; - } else { - check.invalidArg(arg0.Pos(), "cannot make %s; type must be slice, map, or channel", new ($sliceType($emptyInterface))([arg0])); - return result; + if (!($interfaceIsEqual(n.High, $ifaceNil))) { + Walk(v, n.High); } - if (nargs < min || (min + 1 >> 0) < nargs) { - check.errorf(call.Pos(), "%s expects %d or %d arguments; found %d", new ($sliceType($emptyInterface))([call, new $Int(min), new $Int((min + 1 >> 0)), new $Int(nargs)])); - return result; + if (!($interfaceIsEqual(n.Max, $ifaceNil))) { + Walk(v, n.Max); } - sizes = ($sliceType($Int64)).nil; - _ref$7 = $subslice(call.Args, 1); - _i = 0; - while (_i < _ref$7.$length) { - arg$1 = ((_i < 0 || _i >= _ref$7.$length) ? $throwRuntimeError("index out of range") : _ref$7.$array[_ref$7.$offset + _i]); - _tuple$5 = check.index(arg$1, new $Int64(-1, 4294967295)); s$1 = _tuple$5[0]; ok = _tuple$5[1]; - if (ok && (s$1.$high > 0 || (s$1.$high === 0 && s$1.$low >= 0))) { - sizes = $append(sizes, s$1); - } - _i++; + } else if ($assertType(_ref, ($ptrType(TypeAssertExpr)), true)[1]) { + n = _ref.$val; + Walk(v, n.X); + if (!($interfaceIsEqual(n.Type, $ifaceNil))) { + Walk(v, n.Type); } - if ((sizes.$length === 2) && (x$2 = ((0 < 0 || 0 >= sizes.$length) ? $throwRuntimeError("index out of range") : sizes.$array[sizes.$offset + 0]), x$3 = ((1 < 0 || 1 >= sizes.$length) ? $throwRuntimeError("index out of range") : sizes.$array[sizes.$offset + 1]), (x$2.$high > x$3.$high || (x$2.$high === x$3.$high && x$2.$low > x$3.$low)))) { - check.invalidArg((x$4 = call.Args, ((1 < 0 || 1 >= x$4.$length) ? $throwRuntimeError("index out of range") : x$4.$array[x$4.$offset + 1])).Pos(), "length and capacity swapped", new ($sliceType($emptyInterface))([])); + } else if ($assertType(_ref, ($ptrType(CallExpr)), true)[1]) { + n = _ref.$val; + Walk(v, n.Fun); + walkExprList(v, n.Args); + } else if ($assertType(_ref, ($ptrType(StarExpr)), true)[1]) { + n = _ref.$val; + Walk(v, n.X); + } else if ($assertType(_ref, ($ptrType(UnaryExpr)), true)[1]) { + n = _ref.$val; + Walk(v, n.X); + } else if ($assertType(_ref, ($ptrType(BinaryExpr)), true)[1]) { + n = _ref.$val; + Walk(v, n.X); + Walk(v, n.Y); + } else if ($assertType(_ref, ($ptrType(KeyValueExpr)), true)[1]) { + n = _ref.$val; + Walk(v, n.Key); + Walk(v, n.Value); + } else if ($assertType(_ref, ($ptrType(ArrayType)), true)[1]) { + n = _ref.$val; + if (!($interfaceIsEqual(n.Len, $ifaceNil))) { + Walk(v, n.Len); } - x.mode = 7; - x.typ = T$1; - if (!(check.Info.Types === false)) { - params = $toNativeArray("Interface", [T$1, $pkg.Typ[2], $pkg.Typ[2]]); - check.recordBuiltinType(call.Fun, makeSig(x.typ, $subslice(new ($sliceType(Type))(params), 0, (1 + sizes.$length >> 0)))); + Walk(v, n.Elt); + } else if ($assertType(_ref, ($ptrType(StructType)), true)[1]) { + n = _ref.$val; + Walk(v, n.Fields); + } else if ($assertType(_ref, ($ptrType(FuncType)), true)[1]) { + n = _ref.$val; + if (!(n.Params === ($ptrType(FieldList)).nil)) { + Walk(v, n.Params); } - } else if (_ref$1 === 9) { - T$2 = check.typ((x$5 = call.Args, ((0 < 0 || 0 >= x$5.$length) ? $throwRuntimeError("index out of range") : x$5.$array[x$5.$offset + 0]))); - if ($interfaceIsEqual(T$2, $pkg.Typ[0])) { - return result; + if (!(n.Results === ($ptrType(FieldList)).nil)) { + Walk(v, n.Results); } - x.mode = 7; - x.typ = new Pointer.Ptr(T$2); - if (!(check.Info.Types === false)) { - check.recordBuiltinType(call.Fun, makeSig(x.typ, new ($sliceType(Type))([T$2]))); + } else if ($assertType(_ref, ($ptrType(InterfaceType)), true)[1]) { + n = _ref.$val; + Walk(v, n.Methods); + } else if ($assertType(_ref, ($ptrType(MapType)), true)[1]) { + n = _ref.$val; + Walk(v, n.Key); + Walk(v, n.Value); + } else if ($assertType(_ref, ($ptrType(ChanType)), true)[1]) { + n = _ref.$val; + Walk(v, n.Value); + } else if ($assertType(_ref, ($ptrType(BadStmt)), true)[1]) { + n = _ref.$val; + } else if ($assertType(_ref, ($ptrType(DeclStmt)), true)[1]) { + n = _ref.$val; + Walk(v, n.Decl); + } else if ($assertType(_ref, ($ptrType(EmptyStmt)), true)[1]) { + n = _ref.$val; + } else if ($assertType(_ref, ($ptrType(LabeledStmt)), true)[1]) { + n = _ref.$val; + Walk(v, n.Label); + Walk(v, n.Stmt); + } else if ($assertType(_ref, ($ptrType(ExprStmt)), true)[1]) { + n = _ref.$val; + Walk(v, n.X); + } else if ($assertType(_ref, ($ptrType(SendStmt)), true)[1]) { + n = _ref.$val; + Walk(v, n.Chan); + Walk(v, n.Value); + } else if ($assertType(_ref, ($ptrType(IncDecStmt)), true)[1]) { + n = _ref.$val; + Walk(v, n.X); + } else if ($assertType(_ref, ($ptrType(AssignStmt)), true)[1]) { + n = _ref.$val; + walkExprList(v, n.Lhs); + walkExprList(v, n.Rhs); + } else if ($assertType(_ref, ($ptrType(GoStmt)), true)[1]) { + n = _ref.$val; + Walk(v, n.Call); + } else if ($assertType(_ref, ($ptrType(DeferStmt)), true)[1]) { + n = _ref.$val; + Walk(v, n.Call); + } else if ($assertType(_ref, ($ptrType(ReturnStmt)), true)[1]) { + n = _ref.$val; + walkExprList(v, n.Results); + } else if ($assertType(_ref, ($ptrType(BranchStmt)), true)[1]) { + n = _ref.$val; + if (!(n.Label === ($ptrType(Ident)).nil)) { + Walk(v, n.Label); } - } else if (_ref$1 === 10) { - T$3 = new Interface.Ptr(); - if (!check.assignment(x, T$3)) { - assert(x.mode === 0); - return result; + } else if ($assertType(_ref, ($ptrType(BlockStmt)), true)[1]) { + n = _ref.$val; + walkStmtList(v, n.List); + } else if ($assertType(_ref, ($ptrType(IfStmt)), true)[1]) { + n = _ref.$val; + if (!($interfaceIsEqual(n.Init, $ifaceNil))) { + Walk(v, n.Init); } - x.mode = 1; - if (!(check.Info.Types === false)) { - check.recordBuiltinType(call.Fun, makeSig($ifaceNil, new ($sliceType(Type))([T$3]))); + Walk(v, n.Cond); + Walk(v, n.Body); + if (!($interfaceIsEqual(n.Else, $ifaceNil))) { + Walk(v, n.Else); } - } else if (_ref$1 === 11 || _ref$1 === 12) { - params$1 = ($sliceType(Type)).nil; - if (nargs > 0) { - params$1 = ($sliceType(Type)).make(nargs); - i = 0; - while (i < nargs) { - if (i > 0) { - arg(x, i); - } - if (!check.assignment(x, $ifaceNil)) { - assert(x.mode === 0); - return result; - } - (i < 0 || i >= params$1.$length) ? $throwRuntimeError("index out of range") : params$1.$array[params$1.$offset + i] = x.typ; - i = i + (1) >> 0; - } + } else if ($assertType(_ref, ($ptrType(CaseClause)), true)[1]) { + n = _ref.$val; + walkExprList(v, n.List); + walkStmtList(v, n.Body); + } else if ($assertType(_ref, ($ptrType(SwitchStmt)), true)[1]) { + n = _ref.$val; + if (!($interfaceIsEqual(n.Init, $ifaceNil))) { + Walk(v, n.Init); } - x.mode = 1; - if (!(check.Info.Types === false)) { - check.recordBuiltinType(call.Fun, makeSig($ifaceNil, params$1)); + if (!($interfaceIsEqual(n.Tag, $ifaceNil))) { + Walk(v, n.Tag); } - } else if (_ref$1 === 14) { - x.mode = 7; - x.typ = new Interface.Ptr(); - if (!(check.Info.Types === false)) { - check.recordBuiltinType(call.Fun, makeSig(x.typ, new ($sliceType(Type))([]))); + Walk(v, n.Body); + } else if ($assertType(_ref, ($ptrType(TypeSwitchStmt)), true)[1]) { + n = _ref.$val; + if (!($interfaceIsEqual(n.Init, $ifaceNil))) { + Walk(v, n.Init); } - } else if (_ref$1 === 15) { - if (!check.assignment(x, $ifaceNil)) { - assert(x.mode === 0); - return result; + Walk(v, n.Assign); + Walk(v, n.Body); + } else if ($assertType(_ref, ($ptrType(CommClause)), true)[1]) { + n = _ref.$val; + if (!($interfaceIsEqual(n.Comm, $ifaceNil))) { + Walk(v, n.Comm); } - x.mode = 4; - x.val = exact.MakeInt64(check.conf.alignof(x.typ)); - x.typ = $pkg.Typ[12]; - } else if (_ref$1 === 16) { - arg0$1 = (x$6 = call.Args, ((0 < 0 || 0 >= x$6.$length) ? $throwRuntimeError("index out of range") : x$6.$array[x$6.$offset + 0])); - _tuple$6 = $assertType(unparen(arg0$1), ($ptrType(ast.SelectorExpr)), true); selx = _tuple$6[0]; - if (selx === ($ptrType(ast.SelectorExpr)).nil) { - check.invalidArg(arg0$1.Pos(), "%s is not a selector expression", new ($sliceType($emptyInterface))([arg0$1])); - check.use(new ($sliceType(ast.Expr))([arg0$1])); - return result; + walkStmtList(v, n.Body); + } else if ($assertType(_ref, ($ptrType(SelectStmt)), true)[1]) { + n = _ref.$val; + Walk(v, n.Body); + } else if ($assertType(_ref, ($ptrType(ForStmt)), true)[1]) { + n = _ref.$val; + if (!($interfaceIsEqual(n.Init, $ifaceNil))) { + Walk(v, n.Init); } - check.expr(x, selx.X); - if (x.mode === 0) { - return result; + if (!($interfaceIsEqual(n.Cond, $ifaceNil))) { + Walk(v, n.Cond); } - base = derefStructPtr(x.typ); - sel = selx.Sel.Name; - _tuple$7 = LookupFieldOrMethod(base, false, check.pkg, sel); obj = _tuple$7[0]; index = _tuple$7[1]; indirect = _tuple$7[2]; - _ref$8 = obj; - if (_ref$8 === $ifaceNil) { - check.invalidArg(x.pos(), "%s has no single field %s", new ($sliceType($emptyInterface))([base, new $String(sel)])); - return result; - } else if ($assertType(_ref$8, ($ptrType(Func)), true)[1]) { - check.invalidArg(arg0$1.Pos(), "%s is a method value", new ($sliceType($emptyInterface))([arg0$1])); - return result; + if (!($interfaceIsEqual(n.Post, $ifaceNil))) { + Walk(v, n.Post); } - if (indirect) { - check.invalidArg(x.pos(), "field %s is embedded via a pointer in %s", new ($sliceType($emptyInterface))([new $String(sel), base])); - return result; + Walk(v, n.Body); + } else if ($assertType(_ref, ($ptrType(RangeStmt)), true)[1]) { + n = _ref.$val; + Walk(v, n.Key); + if (!($interfaceIsEqual(n.Value, $ifaceNil))) { + Walk(v, n.Value); } - check.recordSelection(selx, 0, base, obj, index, false); - offs = check.conf.offsetof(base, index); - x.mode = 4; - x.val = exact.MakeInt64(offs); - x.typ = $pkg.Typ[12]; - } else if (_ref$1 === 17) { - if (!check.assignment(x, $ifaceNil)) { - assert(x.mode === 0); - return result; + Walk(v, n.X); + Walk(v, n.Body); + } else if ($assertType(_ref, ($ptrType(ImportSpec)), true)[1]) { + n = _ref.$val; + if (!(n.Doc === ($ptrType(CommentGroup)).nil)) { + Walk(v, n.Doc); } - x.mode = 4; - x.val = exact.MakeInt64(check.conf.sizeof(x.typ)); - x.typ = $pkg.Typ[12]; - } else if (_ref$1 === 18) { - if (!((x.mode === 4)) || !isBoolean(x.typ)) { - check.invalidArg(x.pos(), "%s is not a boolean constant", new ($sliceType($emptyInterface))([x])); - return result; + if (!(n.Name === ($ptrType(Ident)).nil)) { + Walk(v, n.Name); } - if (!((x.val.Kind() === 1))) { - check.errorf(x.pos(), "internal error: value of %s should be a boolean constant", new ($sliceType($emptyInterface))([x])); - return result; + Walk(v, n.Path); + if (!(n.Comment === ($ptrType(CommentGroup)).nil)) { + Walk(v, n.Comment); } - if (!exact.BoolVal(x.val)) { - check.errorf(call.Pos(), "%s failed", new ($sliceType($emptyInterface))([call])); + } else if ($assertType(_ref, ($ptrType(ValueSpec)), true)[1]) { + n = _ref.$val; + if (!(n.Doc === ($ptrType(CommentGroup)).nil)) { + Walk(v, n.Doc); } - } else if (_ref$1 === 19) { - if (nargs === 0) { - check.dump("%s: trace() without arguments", new ($sliceType($emptyInterface))([new token.Pos(call.Pos())])); - x.mode = 1; - break; + walkIdentList(v, n.Names); + if (!($interfaceIsEqual(n.Type, $ifaceNil))) { + Walk(v, n.Type); } - t$3 = new operand.Ptr(); $copy(t$3, new operand.Ptr(), operand); - x1 = x; - _ref$9 = call.Args; - _i$1 = 0; - while (_i$1 < _ref$9.$length) { - arg$2 = ((_i$1 < 0 || _i$1 >= _ref$9.$length) ? $throwRuntimeError("index out of range") : _ref$9.$array[_ref$9.$offset + _i$1]); - check.rawExpr(x1, arg$2, $ifaceNil); - check.dump("%s: %s", new ($sliceType($emptyInterface))([new token.Pos(x1.pos()), x1])); - x1 = t$3; - _i$1++; + walkExprList(v, n.Values); + if (!(n.Comment === ($ptrType(CommentGroup)).nil)) { + Walk(v, n.Comment); } - } else { - unreachable(); - } } - result = true; - return result; - /* */ } catch(err) { $err = err; } finally { $deferFrames.pop(); $callDeferred($deferred, $err); return result; } - }; - Checker.prototype.builtin = function(x, call, id) { return this.$val.builtin(x, call, id); }; - makeSig = function(res, args) { - var list, _ref, _i, i, param, params, result; - list = ($sliceType(($ptrType(Var)))).make(args.$length); - _ref = args; - _i = 0; - while (_i < _ref.$length) { - i = _i; - param = ((_i < 0 || _i >= _ref.$length) ? $throwRuntimeError("index out of range") : _ref.$array[_ref.$offset + _i]); - (i < 0 || i >= list.$length) ? $throwRuntimeError("index out of range") : list.$array[list.$offset + i] = NewVar(0, ($ptrType(Package)).nil, "", defaultType(param)); - _i++; - } - params = NewTuple(list); - result = ($ptrType(Tuple)).nil; - if (!($interfaceIsEqual(res, $ifaceNil))) { - assert(!isUntyped(res)); - result = NewTuple(new ($sliceType(($ptrType(Var))))([NewVar(0, ($ptrType(Package)).nil, "", res)])); - } - return new Signature.Ptr(($ptrType(Scope)).nil, ($ptrType(Var)).nil, params, result, false); - }; - implicitArrayDeref = function(typ) { - var _tuple, p, ok, _tuple$1, a, ok$1; - _tuple = $assertType(typ, ($ptrType(Pointer)), true); p = _tuple[0]; ok = _tuple[1]; - if (ok) { - _tuple$1 = $assertType(p.base.Underlying(), ($ptrType(Array)), true); a = _tuple$1[0]; ok$1 = _tuple$1[1]; - if (ok$1) { - return a; + } else if ($assertType(_ref, ($ptrType(TypeSpec)), true)[1]) { + n = _ref.$val; + if (!(n.Doc === ($ptrType(CommentGroup)).nil)) { + Walk(v, n.Doc); } - } - return typ; - }; - unparen = function(x) { - var _tuple, p, ok; - _tuple = $assertType(x, ($ptrType(ast.ParenExpr)), true); p = _tuple[0]; ok = _tuple[1]; - if (ok) { - return unparen(p.X); - } - return x; - }; - Checker.Ptr.prototype.complexArg = function(x) { - var check, _tuple, t; - check = this; - _tuple = $assertType(x.typ.Underlying(), ($ptrType(Basic)), true); t = _tuple[0]; - if (!(t === ($ptrType(Basic)).nil) && (!(((t.info & 8) === 0)) || (t.kind === 20) || (t.kind === 21))) { - return true; - } - check.invalidArg(x.pos(), "%s must be a float32, float64, or an untyped non-complex numeric constant", new ($sliceType($emptyInterface))([x])); - return false; - }; - Checker.prototype.complexArg = function(x) { return this.$val.complexArg(x); }; - Checker.Ptr.prototype.call = function(x, e) { - var check, _ref, T, n, _ref$1, x$1, x$2, x$3, id, _tuple, sig, _tuple$1, arg, n$1, _ref$2, x$4; - check = this; - check.exprOrType(x, e.Fun); - _ref = x.mode; - if (_ref === 0) { - check.use(e.Args); - x.mode = 0; - x.expr = e; - return 2; - } else if (_ref === 3) { - T = x.typ; - x.mode = 0; - n = e.Args.$length; - _ref$1 = n; - if (_ref$1 === 0) { - check.errorf(e.Rparen, "missing argument in conversion to %s", new ($sliceType($emptyInterface))([T])); - } else if (_ref$1 === 1) { - check.expr(x, (x$1 = e.Args, ((0 < 0 || 0 >= x$1.$length) ? $throwRuntimeError("index out of range") : x$1.$array[x$1.$offset + 0]))); - if (!((x.mode === 0))) { - check.conversion(x, T); - } - } else { - check.errorf((x$2 = e.Args, x$3 = n - 1 >> 0, ((x$3 < 0 || x$3 >= x$2.$length) ? $throwRuntimeError("index out of range") : x$2.$array[x$2.$offset + x$3])).Pos(), "too many arguments in conversion to %s", new ($sliceType($emptyInterface))([T])); + Walk(v, n.Name); + Walk(v, n.Type); + if (!(n.Comment === ($ptrType(CommentGroup)).nil)) { + Walk(v, n.Comment); } - x.expr = e; - return 0; - } else if (_ref === 2) { - id = x.id; - if (!check.builtin(x, e, id)) { - x.mode = 0; + } else if ($assertType(_ref, ($ptrType(BadDecl)), true)[1]) { + n = _ref.$val; + } else if ($assertType(_ref, ($ptrType(GenDecl)), true)[1]) { + n = _ref.$val; + if (!(n.Doc === ($ptrType(CommentGroup)).nil)) { + Walk(v, n.Doc); } - x.expr = e; - if (!((x.mode === 0)) && !((x.mode === 4))) { - check.context.hasCallOrRecv = true; + _ref$3 = n.Specs; + _i$2 = 0; + while (_i$2 < _ref$3.$length) { + s = ((_i$2 < 0 || _i$2 >= _ref$3.$length) ? $throwRuntimeError("index out of range") : _ref$3.$array[_ref$3.$offset + _i$2]); + Walk(v, s); + _i$2++; } - return ((id < 0 || id >= predeclaredFuncs.length) ? $throwRuntimeError("index out of range") : predeclaredFuncs[id]).kind; - } else { - _tuple = $assertType(x.typ.Underlying(), ($ptrType(Signature)), true); sig = _tuple[0]; - if (sig === ($ptrType(Signature)).nil) { - check.invalidOp(x.pos(), "cannot call non-function %s", new ($sliceType($emptyInterface))([x])); - x.mode = 0; - x.expr = e; - return 2; + } else if ($assertType(_ref, ($ptrType(FuncDecl)), true)[1]) { + n = _ref.$val; + if (!(n.Doc === ($ptrType(CommentGroup)).nil)) { + Walk(v, n.Doc); } - _tuple$1 = unpack((function(x$4, i) { - var x$5; - check.expr(x$4, (x$5 = e.Args, ((i < 0 || i >= x$5.$length) ? $throwRuntimeError("index out of range") : x$5.$array[x$5.$offset + i]))); - }), e.Args.$length, false); arg = _tuple$1[0]; n$1 = _tuple$1[1]; - check.arguments$(x, e, sig, arg, n$1); - _ref$2 = sig.results.Len(); - if (_ref$2 === 0) { - x.mode = 1; - } else if (_ref$2 === 1) { - x.mode = 7; - x.typ = (x$4 = sig.results.vars, ((0 < 0 || 0 >= x$4.$length) ? $throwRuntimeError("index out of range") : x$4.$array[x$4.$offset + 0])).object.typ; - } else { - x.mode = 7; - x.typ = sig.results; + if (!(n.Recv === ($ptrType(FieldList)).nil)) { + Walk(v, n.Recv); } - x.expr = e; - check.context.hasCallOrRecv = true; - return 2; - } - }; - Checker.prototype.call = function(x, e) { return this.$val.call(x, e); }; - Checker.Ptr.prototype.use = function(arg) { - var check, x, _ref, _i, e; - check = this; - x = new operand.Ptr(); $copy(x, new operand.Ptr(), operand); - _ref = arg; - _i = 0; - while (_i < _ref.$length) { - e = ((_i < 0 || _i >= _ref.$length) ? $throwRuntimeError("index out of range") : _ref.$array[_ref.$offset + _i]); - check.rawExpr(x, e, $ifaceNil); - _i++; - } - }; - Checker.prototype.use = function(arg) { return this.$val.use(arg); }; - unpack = function(get, n, allowCommaOk) { - var x0, _tuple, t, ok, a; - if (n === 1) { - x0 = new operand.Ptr(); $copy(x0, new operand.Ptr(), operand); - get(x0, 0); - if (x0.mode === 0) { - return [(function(x, i) { - if (!((i === 0))) { - unreachable(); - } - x.mode = 0; - }), 1, false]; + Walk(v, n.Name); + Walk(v, n.Type); + if (!(n.Body === ($ptrType(BlockStmt)).nil)) { + Walk(v, n.Body); } - _tuple = $assertType(x0.typ, ($ptrType(Tuple)), true); t = _tuple[0]; ok = _tuple[1]; - if (ok) { - return [(function(x, i) { - x.mode = 7; - x.expr = x0.expr; - x.typ = t.At(i).object.typ; - }), t.Len(), false]; + } else if ($assertType(_ref, ($ptrType(File)), true)[1]) { + n = _ref.$val; + if (!(n.Doc === ($ptrType(CommentGroup)).nil)) { + Walk(v, n.Doc); } - if ((x0.mode === 6) || (x0.mode === 8)) { - if (allowCommaOk) { - a = $toNativeArray("Interface", [x0.typ, $pkg.Typ[19]]); - return [(function(x, i) { - x.mode = 7; - x.expr = x0.expr; - x.typ = ((i < 0 || i >= a.length) ? $throwRuntimeError("index out of range") : a[i]); - }), 2, true]; + Walk(v, n.Name); + walkDeclList(v, n.Decls); + } else if ($assertType(_ref, ($ptrType(Package)), true)[1]) { + n = _ref.$val; + _ref$4 = n.Files; + _i$3 = 0; + _keys = $keys(_ref$4); + while (_i$3 < _keys.length) { + _entry = _ref$4[_keys[_i$3]]; + if (_entry === undefined) { + _i$3++; + continue; } - x0.mode = 7; + f$1 = _entry.v; + Walk(v, f$1); + _i$3++; } - return [(function(x, i) { - if (!((i === 0))) { - unreachable(); - } - $copy(x, x0, operand); - }), 1, false]; + } else { + n = _ref; + fmt.Printf("ast.Walk: unexpected node type %T", new ($sliceType($emptyInterface))([n])); + $panic(new $String("ast.Walk")); } - return [get, n, false]; + v.Visit($ifaceNil); }; - Checker.Ptr.prototype.arguments$ = function(x, call, sig, arg, n) { - var check, passSlice, i; - check = this; - passSlice = false; - if ((new token.Pos(call.Ellipsis)).IsValid()) { - if (sig.variadic) { - passSlice = true; - } else { - check.errorf(call.Ellipsis, "cannot use ... in call to non-variadic %s", new ($sliceType($emptyInterface))([call.Fun])); - } - } - i = 0; - while (i < n) { - arg(x, i); - if (!((x.mode === 0))) { - check.argument(sig, i, x, passSlice && (i === (n - 1 >> 0))); - } - i = i + (1) >> 0; - } - if (sig.variadic) { - n = n + (1) >> 0; - } - if (n < sig.params.Len()) { - check.errorf(call.Rparen, "too few arguments in call to %s", new ($sliceType($emptyInterface))([call.Fun])); + inspector.prototype.Visit = function(node) { + var f; + f = this.$val !== undefined ? this.$val : this; + if (f(node)) { + return new inspector(f); } + return $ifaceNil; }; - Checker.prototype.arguments$ = function(x, call, sig, arg, n) { return this.$val.arguments$(x, call, sig, arg, n); }; - Checker.Ptr.prototype.argument = function(sig, i, x, passSlice) { - var check, n, typ, x$1, x$2, x$3, _tuple, ok; - check = this; - n = sig.params.Len(); - typ = $ifaceNil; - if (i < n) { - typ = (x$1 = sig.params.vars, ((i < 0 || i >= x$1.$length) ? $throwRuntimeError("index out of range") : x$1.$array[x$1.$offset + i])).object.typ; - } else if (sig.variadic) { - typ = (x$2 = sig.params.vars, x$3 = n - 1 >> 0, ((x$3 < 0 || x$3 >= x$2.$length) ? $throwRuntimeError("index out of range") : x$2.$array[x$2.$offset + x$3])).object.typ; - } else { - check.errorf(x.pos(), "too many arguments", new ($sliceType($emptyInterface))([])); - return; - } - if (passSlice) { - if (!((i === (n - 1 >> 0)))) { - check.errorf(x.pos(), "can only use ... with matching parameter", new ($sliceType($emptyInterface))([])); - return; - } - _tuple = $assertType(x.typ.Underlying(), ($ptrType(Slice)), true); ok = _tuple[1]; - if (!ok) { - check.errorf(x.pos(), "cannot use %s as parameter of type %s", new ($sliceType($emptyInterface))([x, typ])); - return; - } - } else if (sig.variadic && i >= (n - 1 >> 0)) { - typ = $assertType(typ, ($ptrType(Slice))).elem; - } - if (!check.assignment(x, typ) && !((x.mode === 0))) { - check.errorf(x.pos(), "cannot pass argument %s to parameter of type %s", new ($sliceType($emptyInterface))([x, typ])); - } + $ptrType(inspector).prototype.Visit = function(node) { return new inspector(this.$get()).Visit(node); }; + Inspect = $pkg.Inspect = function(node, f) { + Walk(new inspector(f), node); + }; + $pkg.$init = function() { + Node.init([["End", "End", "", $funcType([], [token.Pos], false)], ["Pos", "Pos", "", $funcType([], [token.Pos], false)]]); + Expr.init([["End", "End", "", $funcType([], [token.Pos], false)], ["Pos", "Pos", "", $funcType([], [token.Pos], false)], ["exprNode", "exprNode", "go/ast", $funcType([], [], false)]]); + Stmt.init([["End", "End", "", $funcType([], [token.Pos], false)], ["Pos", "Pos", "", $funcType([], [token.Pos], false)], ["stmtNode", "stmtNode", "go/ast", $funcType([], [], false)]]); + Decl.init([["End", "End", "", $funcType([], [token.Pos], false)], ["Pos", "Pos", "", $funcType([], [token.Pos], false)], ["declNode", "declNode", "go/ast", $funcType([], [], false)]]); + ($ptrType(Comment)).methods = [["End", "End", "", $funcType([], [token.Pos], false), -1], ["Pos", "Pos", "", $funcType([], [token.Pos], false), -1]]; + Comment.init([["Slash", "Slash", "", token.Pos, ""], ["Text", "Text", "", $String, ""]]); + ($ptrType(CommentGroup)).methods = [["End", "End", "", $funcType([], [token.Pos], false), -1], ["Pos", "Pos", "", $funcType([], [token.Pos], false), -1], ["Text", "Text", "", $funcType([], [$String], false), -1]]; + CommentGroup.init([["List", "List", "", ($sliceType(($ptrType(Comment)))), ""]]); + ($ptrType(Field)).methods = [["End", "End", "", $funcType([], [token.Pos], false), -1], ["Pos", "Pos", "", $funcType([], [token.Pos], false), -1]]; + Field.init([["Doc", "Doc", "", ($ptrType(CommentGroup)), ""], ["Names", "Names", "", ($sliceType(($ptrType(Ident)))), ""], ["Type", "Type", "", Expr, ""], ["Tag", "Tag", "", ($ptrType(BasicLit)), ""], ["Comment", "Comment", "", ($ptrType(CommentGroup)), ""]]); + ($ptrType(FieldList)).methods = [["End", "End", "", $funcType([], [token.Pos], false), -1], ["NumFields", "NumFields", "", $funcType([], [$Int], false), -1], ["Pos", "Pos", "", $funcType([], [token.Pos], false), -1]]; + FieldList.init([["Opening", "Opening", "", token.Pos, ""], ["List", "List", "", ($sliceType(($ptrType(Field)))), ""], ["Closing", "Closing", "", token.Pos, ""]]); + ($ptrType(BadExpr)).methods = [["End", "End", "", $funcType([], [token.Pos], false), -1], ["Pos", "Pos", "", $funcType([], [token.Pos], false), -1], ["exprNode", "exprNode", "go/ast", $funcType([], [], false), -1]]; + BadExpr.init([["From", "From", "", token.Pos, ""], ["To", "To", "", token.Pos, ""]]); + ($ptrType(Ident)).methods = [["End", "End", "", $funcType([], [token.Pos], false), -1], ["IsExported", "IsExported", "", $funcType([], [$Bool], false), -1], ["Pos", "Pos", "", $funcType([], [token.Pos], false), -1], ["String", "String", "", $funcType([], [$String], false), -1], ["exprNode", "exprNode", "go/ast", $funcType([], [], false), -1]]; + Ident.init([["NamePos", "NamePos", "", token.Pos, ""], ["Name", "Name", "", $String, ""], ["Obj", "Obj", "", ($ptrType(Object)), ""]]); + ($ptrType(Ellipsis)).methods = [["End", "End", "", $funcType([], [token.Pos], false), -1], ["Pos", "Pos", "", $funcType([], [token.Pos], false), -1], ["exprNode", "exprNode", "go/ast", $funcType([], [], false), -1]]; + Ellipsis.init([["Ellipsis", "Ellipsis", "", token.Pos, ""], ["Elt", "Elt", "", Expr, ""]]); + ($ptrType(BasicLit)).methods = [["End", "End", "", $funcType([], [token.Pos], false), -1], ["Pos", "Pos", "", $funcType([], [token.Pos], false), -1], ["exprNode", "exprNode", "go/ast", $funcType([], [], false), -1]]; + BasicLit.init([["ValuePos", "ValuePos", "", token.Pos, ""], ["Kind", "Kind", "", token.Token, ""], ["Value", "Value", "", $String, ""]]); + ($ptrType(FuncLit)).methods = [["End", "End", "", $funcType([], [token.Pos], false), -1], ["Pos", "Pos", "", $funcType([], [token.Pos], false), -1], ["exprNode", "exprNode", "go/ast", $funcType([], [], false), -1]]; + FuncLit.init([["Type", "Type", "", ($ptrType(FuncType)), ""], ["Body", "Body", "", ($ptrType(BlockStmt)), ""]]); + ($ptrType(CompositeLit)).methods = [["End", "End", "", $funcType([], [token.Pos], false), -1], ["Pos", "Pos", "", $funcType([], [token.Pos], false), -1], ["exprNode", "exprNode", "go/ast", $funcType([], [], false), -1]]; + CompositeLit.init([["Type", "Type", "", Expr, ""], ["Lbrace", "Lbrace", "", token.Pos, ""], ["Elts", "Elts", "", ($sliceType(Expr)), ""], ["Rbrace", "Rbrace", "", token.Pos, ""]]); + ($ptrType(ParenExpr)).methods = [["End", "End", "", $funcType([], [token.Pos], false), -1], ["Pos", "Pos", "", $funcType([], [token.Pos], false), -1], ["exprNode", "exprNode", "go/ast", $funcType([], [], false), -1]]; + ParenExpr.init([["Lparen", "Lparen", "", token.Pos, ""], ["X", "X", "", Expr, ""], ["Rparen", "Rparen", "", token.Pos, ""]]); + ($ptrType(SelectorExpr)).methods = [["End", "End", "", $funcType([], [token.Pos], false), -1], ["Pos", "Pos", "", $funcType([], [token.Pos], false), -1], ["exprNode", "exprNode", "go/ast", $funcType([], [], false), -1]]; + SelectorExpr.init([["X", "X", "", Expr, ""], ["Sel", "Sel", "", ($ptrType(Ident)), ""]]); + ($ptrType(IndexExpr)).methods = [["End", "End", "", $funcType([], [token.Pos], false), -1], ["Pos", "Pos", "", $funcType([], [token.Pos], false), -1], ["exprNode", "exprNode", "go/ast", $funcType([], [], false), -1]]; + IndexExpr.init([["X", "X", "", Expr, ""], ["Lbrack", "Lbrack", "", token.Pos, ""], ["Index", "Index", "", Expr, ""], ["Rbrack", "Rbrack", "", token.Pos, ""]]); + ($ptrType(SliceExpr)).methods = [["End", "End", "", $funcType([], [token.Pos], false), -1], ["Pos", "Pos", "", $funcType([], [token.Pos], false), -1], ["exprNode", "exprNode", "go/ast", $funcType([], [], false), -1]]; + SliceExpr.init([["X", "X", "", Expr, ""], ["Lbrack", "Lbrack", "", token.Pos, ""], ["Low", "Low", "", Expr, ""], ["High", "High", "", Expr, ""], ["Max", "Max", "", Expr, ""], ["Slice3", "Slice3", "", $Bool, ""], ["Rbrack", "Rbrack", "", token.Pos, ""]]); + ($ptrType(TypeAssertExpr)).methods = [["End", "End", "", $funcType([], [token.Pos], false), -1], ["Pos", "Pos", "", $funcType([], [token.Pos], false), -1], ["exprNode", "exprNode", "go/ast", $funcType([], [], false), -1]]; + TypeAssertExpr.init([["X", "X", "", Expr, ""], ["Lparen", "Lparen", "", token.Pos, ""], ["Type", "Type", "", Expr, ""], ["Rparen", "Rparen", "", token.Pos, ""]]); + ($ptrType(CallExpr)).methods = [["End", "End", "", $funcType([], [token.Pos], false), -1], ["Pos", "Pos", "", $funcType([], [token.Pos], false), -1], ["exprNode", "exprNode", "go/ast", $funcType([], [], false), -1]]; + CallExpr.init([["Fun", "Fun", "", Expr, ""], ["Lparen", "Lparen", "", token.Pos, ""], ["Args", "Args", "", ($sliceType(Expr)), ""], ["Ellipsis", "Ellipsis", "", token.Pos, ""], ["Rparen", "Rparen", "", token.Pos, ""]]); + ($ptrType(StarExpr)).methods = [["End", "End", "", $funcType([], [token.Pos], false), -1], ["Pos", "Pos", "", $funcType([], [token.Pos], false), -1], ["exprNode", "exprNode", "go/ast", $funcType([], [], false), -1]]; + StarExpr.init([["Star", "Star", "", token.Pos, ""], ["X", "X", "", Expr, ""]]); + ($ptrType(UnaryExpr)).methods = [["End", "End", "", $funcType([], [token.Pos], false), -1], ["Pos", "Pos", "", $funcType([], [token.Pos], false), -1], ["exprNode", "exprNode", "go/ast", $funcType([], [], false), -1]]; + UnaryExpr.init([["OpPos", "OpPos", "", token.Pos, ""], ["Op", "Op", "", token.Token, ""], ["X", "X", "", Expr, ""]]); + ($ptrType(BinaryExpr)).methods = [["End", "End", "", $funcType([], [token.Pos], false), -1], ["Pos", "Pos", "", $funcType([], [token.Pos], false), -1], ["exprNode", "exprNode", "go/ast", $funcType([], [], false), -1]]; + BinaryExpr.init([["X", "X", "", Expr, ""], ["OpPos", "OpPos", "", token.Pos, ""], ["Op", "Op", "", token.Token, ""], ["Y", "Y", "", Expr, ""]]); + ($ptrType(KeyValueExpr)).methods = [["End", "End", "", $funcType([], [token.Pos], false), -1], ["Pos", "Pos", "", $funcType([], [token.Pos], false), -1], ["exprNode", "exprNode", "go/ast", $funcType([], [], false), -1]]; + KeyValueExpr.init([["Key", "Key", "", Expr, ""], ["Colon", "Colon", "", token.Pos, ""], ["Value", "Value", "", Expr, ""]]); + ($ptrType(ArrayType)).methods = [["End", "End", "", $funcType([], [token.Pos], false), -1], ["Pos", "Pos", "", $funcType([], [token.Pos], false), -1], ["exprNode", "exprNode", "go/ast", $funcType([], [], false), -1]]; + ArrayType.init([["Lbrack", "Lbrack", "", token.Pos, ""], ["Len", "Len", "", Expr, ""], ["Elt", "Elt", "", Expr, ""]]); + ($ptrType(StructType)).methods = [["End", "End", "", $funcType([], [token.Pos], false), -1], ["Pos", "Pos", "", $funcType([], [token.Pos], false), -1], ["exprNode", "exprNode", "go/ast", $funcType([], [], false), -1]]; + StructType.init([["Struct", "Struct", "", token.Pos, ""], ["Fields", "Fields", "", ($ptrType(FieldList)), ""], ["Incomplete", "Incomplete", "", $Bool, ""]]); + ($ptrType(FuncType)).methods = [["End", "End", "", $funcType([], [token.Pos], false), -1], ["Pos", "Pos", "", $funcType([], [token.Pos], false), -1], ["exprNode", "exprNode", "go/ast", $funcType([], [], false), -1]]; + FuncType.init([["Func", "Func", "", token.Pos, ""], ["Params", "Params", "", ($ptrType(FieldList)), ""], ["Results", "Results", "", ($ptrType(FieldList)), ""]]); + ($ptrType(InterfaceType)).methods = [["End", "End", "", $funcType([], [token.Pos], false), -1], ["Pos", "Pos", "", $funcType([], [token.Pos], false), -1], ["exprNode", "exprNode", "go/ast", $funcType([], [], false), -1]]; + InterfaceType.init([["Interface", "Interface", "", token.Pos, ""], ["Methods", "Methods", "", ($ptrType(FieldList)), ""], ["Incomplete", "Incomplete", "", $Bool, ""]]); + ($ptrType(MapType)).methods = [["End", "End", "", $funcType([], [token.Pos], false), -1], ["Pos", "Pos", "", $funcType([], [token.Pos], false), -1], ["exprNode", "exprNode", "go/ast", $funcType([], [], false), -1]]; + MapType.init([["Map", "Map", "", token.Pos, ""], ["Key", "Key", "", Expr, ""], ["Value", "Value", "", Expr, ""]]); + ($ptrType(ChanType)).methods = [["End", "End", "", $funcType([], [token.Pos], false), -1], ["Pos", "Pos", "", $funcType([], [token.Pos], false), -1], ["exprNode", "exprNode", "go/ast", $funcType([], [], false), -1]]; + ChanType.init([["Begin", "Begin", "", token.Pos, ""], ["Arrow", "Arrow", "", token.Pos, ""], ["Dir", "Dir", "", ChanDir, ""], ["Value", "Value", "", Expr, ""]]); + ($ptrType(BadStmt)).methods = [["End", "End", "", $funcType([], [token.Pos], false), -1], ["Pos", "Pos", "", $funcType([], [token.Pos], false), -1], ["stmtNode", "stmtNode", "go/ast", $funcType([], [], false), -1]]; + BadStmt.init([["From", "From", "", token.Pos, ""], ["To", "To", "", token.Pos, ""]]); + ($ptrType(DeclStmt)).methods = [["End", "End", "", $funcType([], [token.Pos], false), -1], ["Pos", "Pos", "", $funcType([], [token.Pos], false), -1], ["stmtNode", "stmtNode", "go/ast", $funcType([], [], false), -1]]; + DeclStmt.init([["Decl", "Decl", "", Decl, ""]]); + ($ptrType(EmptyStmt)).methods = [["End", "End", "", $funcType([], [token.Pos], false), -1], ["Pos", "Pos", "", $funcType([], [token.Pos], false), -1], ["stmtNode", "stmtNode", "go/ast", $funcType([], [], false), -1]]; + EmptyStmt.init([["Semicolon", "Semicolon", "", token.Pos, ""]]); + ($ptrType(LabeledStmt)).methods = [["End", "End", "", $funcType([], [token.Pos], false), -1], ["Pos", "Pos", "", $funcType([], [token.Pos], false), -1], ["stmtNode", "stmtNode", "go/ast", $funcType([], [], false), -1]]; + LabeledStmt.init([["Label", "Label", "", ($ptrType(Ident)), ""], ["Colon", "Colon", "", token.Pos, ""], ["Stmt", "Stmt", "", Stmt, ""]]); + ($ptrType(ExprStmt)).methods = [["End", "End", "", $funcType([], [token.Pos], false), -1], ["Pos", "Pos", "", $funcType([], [token.Pos], false), -1], ["stmtNode", "stmtNode", "go/ast", $funcType([], [], false), -1]]; + ExprStmt.init([["X", "X", "", Expr, ""]]); + ($ptrType(SendStmt)).methods = [["End", "End", "", $funcType([], [token.Pos], false), -1], ["Pos", "Pos", "", $funcType([], [token.Pos], false), -1], ["stmtNode", "stmtNode", "go/ast", $funcType([], [], false), -1]]; + SendStmt.init([["Chan", "Chan", "", Expr, ""], ["Arrow", "Arrow", "", token.Pos, ""], ["Value", "Value", "", Expr, ""]]); + ($ptrType(IncDecStmt)).methods = [["End", "End", "", $funcType([], [token.Pos], false), -1], ["Pos", "Pos", "", $funcType([], [token.Pos], false), -1], ["stmtNode", "stmtNode", "go/ast", $funcType([], [], false), -1]]; + IncDecStmt.init([["X", "X", "", Expr, ""], ["TokPos", "TokPos", "", token.Pos, ""], ["Tok", "Tok", "", token.Token, ""]]); + ($ptrType(AssignStmt)).methods = [["End", "End", "", $funcType([], [token.Pos], false), -1], ["Pos", "Pos", "", $funcType([], [token.Pos], false), -1], ["stmtNode", "stmtNode", "go/ast", $funcType([], [], false), -1]]; + AssignStmt.init([["Lhs", "Lhs", "", ($sliceType(Expr)), ""], ["TokPos", "TokPos", "", token.Pos, ""], ["Tok", "Tok", "", token.Token, ""], ["Rhs", "Rhs", "", ($sliceType(Expr)), ""]]); + ($ptrType(GoStmt)).methods = [["End", "End", "", $funcType([], [token.Pos], false), -1], ["Pos", "Pos", "", $funcType([], [token.Pos], false), -1], ["stmtNode", "stmtNode", "go/ast", $funcType([], [], false), -1]]; + GoStmt.init([["Go", "Go", "", token.Pos, ""], ["Call", "Call", "", ($ptrType(CallExpr)), ""]]); + ($ptrType(DeferStmt)).methods = [["End", "End", "", $funcType([], [token.Pos], false), -1], ["Pos", "Pos", "", $funcType([], [token.Pos], false), -1], ["stmtNode", "stmtNode", "go/ast", $funcType([], [], false), -1]]; + DeferStmt.init([["Defer", "Defer", "", token.Pos, ""], ["Call", "Call", "", ($ptrType(CallExpr)), ""]]); + ($ptrType(ReturnStmt)).methods = [["End", "End", "", $funcType([], [token.Pos], false), -1], ["Pos", "Pos", "", $funcType([], [token.Pos], false), -1], ["stmtNode", "stmtNode", "go/ast", $funcType([], [], false), -1]]; + ReturnStmt.init([["Return", "Return", "", token.Pos, ""], ["Results", "Results", "", ($sliceType(Expr)), ""]]); + ($ptrType(BranchStmt)).methods = [["End", "End", "", $funcType([], [token.Pos], false), -1], ["Pos", "Pos", "", $funcType([], [token.Pos], false), -1], ["stmtNode", "stmtNode", "go/ast", $funcType([], [], false), -1]]; + BranchStmt.init([["TokPos", "TokPos", "", token.Pos, ""], ["Tok", "Tok", "", token.Token, ""], ["Label", "Label", "", ($ptrType(Ident)), ""]]); + ($ptrType(BlockStmt)).methods = [["End", "End", "", $funcType([], [token.Pos], false), -1], ["Pos", "Pos", "", $funcType([], [token.Pos], false), -1], ["stmtNode", "stmtNode", "go/ast", $funcType([], [], false), -1]]; + BlockStmt.init([["Lbrace", "Lbrace", "", token.Pos, ""], ["List", "List", "", ($sliceType(Stmt)), ""], ["Rbrace", "Rbrace", "", token.Pos, ""]]); + ($ptrType(IfStmt)).methods = [["End", "End", "", $funcType([], [token.Pos], false), -1], ["Pos", "Pos", "", $funcType([], [token.Pos], false), -1], ["stmtNode", "stmtNode", "go/ast", $funcType([], [], false), -1]]; + IfStmt.init([["If", "If", "", token.Pos, ""], ["Init", "Init", "", Stmt, ""], ["Cond", "Cond", "", Expr, ""], ["Body", "Body", "", ($ptrType(BlockStmt)), ""], ["Else", "Else", "", Stmt, ""]]); + ($ptrType(CaseClause)).methods = [["End", "End", "", $funcType([], [token.Pos], false), -1], ["Pos", "Pos", "", $funcType([], [token.Pos], false), -1], ["stmtNode", "stmtNode", "go/ast", $funcType([], [], false), -1]]; + CaseClause.init([["Case", "Case", "", token.Pos, ""], ["List", "List", "", ($sliceType(Expr)), ""], ["Colon", "Colon", "", token.Pos, ""], ["Body", "Body", "", ($sliceType(Stmt)), ""]]); + ($ptrType(SwitchStmt)).methods = [["End", "End", "", $funcType([], [token.Pos], false), -1], ["Pos", "Pos", "", $funcType([], [token.Pos], false), -1], ["stmtNode", "stmtNode", "go/ast", $funcType([], [], false), -1]]; + SwitchStmt.init([["Switch", "Switch", "", token.Pos, ""], ["Init", "Init", "", Stmt, ""], ["Tag", "Tag", "", Expr, ""], ["Body", "Body", "", ($ptrType(BlockStmt)), ""]]); + ($ptrType(TypeSwitchStmt)).methods = [["End", "End", "", $funcType([], [token.Pos], false), -1], ["Pos", "Pos", "", $funcType([], [token.Pos], false), -1], ["stmtNode", "stmtNode", "go/ast", $funcType([], [], false), -1]]; + TypeSwitchStmt.init([["Switch", "Switch", "", token.Pos, ""], ["Init", "Init", "", Stmt, ""], ["Assign", "Assign", "", Stmt, ""], ["Body", "Body", "", ($ptrType(BlockStmt)), ""]]); + ($ptrType(CommClause)).methods = [["End", "End", "", $funcType([], [token.Pos], false), -1], ["Pos", "Pos", "", $funcType([], [token.Pos], false), -1], ["stmtNode", "stmtNode", "go/ast", $funcType([], [], false), -1]]; + CommClause.init([["Case", "Case", "", token.Pos, ""], ["Comm", "Comm", "", Stmt, ""], ["Colon", "Colon", "", token.Pos, ""], ["Body", "Body", "", ($sliceType(Stmt)), ""]]); + ($ptrType(SelectStmt)).methods = [["End", "End", "", $funcType([], [token.Pos], false), -1], ["Pos", "Pos", "", $funcType([], [token.Pos], false), -1], ["stmtNode", "stmtNode", "go/ast", $funcType([], [], false), -1]]; + SelectStmt.init([["Select", "Select", "", token.Pos, ""], ["Body", "Body", "", ($ptrType(BlockStmt)), ""]]); + ($ptrType(ForStmt)).methods = [["End", "End", "", $funcType([], [token.Pos], false), -1], ["Pos", "Pos", "", $funcType([], [token.Pos], false), -1], ["stmtNode", "stmtNode", "go/ast", $funcType([], [], false), -1]]; + ForStmt.init([["For", "For", "", token.Pos, ""], ["Init", "Init", "", Stmt, ""], ["Cond", "Cond", "", Expr, ""], ["Post", "Post", "", Stmt, ""], ["Body", "Body", "", ($ptrType(BlockStmt)), ""]]); + ($ptrType(RangeStmt)).methods = [["End", "End", "", $funcType([], [token.Pos], false), -1], ["Pos", "Pos", "", $funcType([], [token.Pos], false), -1], ["stmtNode", "stmtNode", "go/ast", $funcType([], [], false), -1]]; + RangeStmt.init([["For", "For", "", token.Pos, ""], ["Key", "Key", "", Expr, ""], ["Value", "Value", "", Expr, ""], ["TokPos", "TokPos", "", token.Pos, ""], ["Tok", "Tok", "", token.Token, ""], ["X", "X", "", Expr, ""], ["Body", "Body", "", ($ptrType(BlockStmt)), ""]]); + Spec.init([["End", "End", "", $funcType([], [token.Pos], false)], ["Pos", "Pos", "", $funcType([], [token.Pos], false)], ["specNode", "specNode", "go/ast", $funcType([], [], false)]]); + ($ptrType(ImportSpec)).methods = [["End", "End", "", $funcType([], [token.Pos], false), -1], ["Pos", "Pos", "", $funcType([], [token.Pos], false), -1], ["specNode", "specNode", "go/ast", $funcType([], [], false), -1]]; + ImportSpec.init([["Doc", "Doc", "", ($ptrType(CommentGroup)), ""], ["Name", "Name", "", ($ptrType(Ident)), ""], ["Path", "Path", "", ($ptrType(BasicLit)), ""], ["Comment", "Comment", "", ($ptrType(CommentGroup)), ""], ["EndPos", "EndPos", "", token.Pos, ""]]); + ($ptrType(ValueSpec)).methods = [["End", "End", "", $funcType([], [token.Pos], false), -1], ["Pos", "Pos", "", $funcType([], [token.Pos], false), -1], ["specNode", "specNode", "go/ast", $funcType([], [], false), -1]]; + ValueSpec.init([["Doc", "Doc", "", ($ptrType(CommentGroup)), ""], ["Names", "Names", "", ($sliceType(($ptrType(Ident)))), ""], ["Type", "Type", "", Expr, ""], ["Values", "Values", "", ($sliceType(Expr)), ""], ["Comment", "Comment", "", ($ptrType(CommentGroup)), ""]]); + ($ptrType(TypeSpec)).methods = [["End", "End", "", $funcType([], [token.Pos], false), -1], ["Pos", "Pos", "", $funcType([], [token.Pos], false), -1], ["specNode", "specNode", "go/ast", $funcType([], [], false), -1]]; + TypeSpec.init([["Doc", "Doc", "", ($ptrType(CommentGroup)), ""], ["Name", "Name", "", ($ptrType(Ident)), ""], ["Type", "Type", "", Expr, ""], ["Comment", "Comment", "", ($ptrType(CommentGroup)), ""]]); + ($ptrType(BadDecl)).methods = [["End", "End", "", $funcType([], [token.Pos], false), -1], ["Pos", "Pos", "", $funcType([], [token.Pos], false), -1], ["declNode", "declNode", "go/ast", $funcType([], [], false), -1]]; + BadDecl.init([["From", "From", "", token.Pos, ""], ["To", "To", "", token.Pos, ""]]); + ($ptrType(GenDecl)).methods = [["End", "End", "", $funcType([], [token.Pos], false), -1], ["Pos", "Pos", "", $funcType([], [token.Pos], false), -1], ["declNode", "declNode", "go/ast", $funcType([], [], false), -1]]; + GenDecl.init([["Doc", "Doc", "", ($ptrType(CommentGroup)), ""], ["TokPos", "TokPos", "", token.Pos, ""], ["Tok", "Tok", "", token.Token, ""], ["Lparen", "Lparen", "", token.Pos, ""], ["Specs", "Specs", "", ($sliceType(Spec)), ""], ["Rparen", "Rparen", "", token.Pos, ""]]); + ($ptrType(FuncDecl)).methods = [["End", "End", "", $funcType([], [token.Pos], false), -1], ["Pos", "Pos", "", $funcType([], [token.Pos], false), -1], ["declNode", "declNode", "go/ast", $funcType([], [], false), -1]]; + FuncDecl.init([["Doc", "Doc", "", ($ptrType(CommentGroup)), ""], ["Recv", "Recv", "", ($ptrType(FieldList)), ""], ["Name", "Name", "", ($ptrType(Ident)), ""], ["Type", "Type", "", ($ptrType(FuncType)), ""], ["Body", "Body", "", ($ptrType(BlockStmt)), ""]]); + ($ptrType(File)).methods = [["End", "End", "", $funcType([], [token.Pos], false), -1], ["Pos", "Pos", "", $funcType([], [token.Pos], false), -1]]; + File.init([["Doc", "Doc", "", ($ptrType(CommentGroup)), ""], ["Package", "Package", "", token.Pos, ""], ["Name", "Name", "", ($ptrType(Ident)), ""], ["Decls", "Decls", "", ($sliceType(Decl)), ""], ["Scope", "Scope", "", ($ptrType(Scope)), ""], ["Imports", "Imports", "", ($sliceType(($ptrType(ImportSpec)))), ""], ["Unresolved", "Unresolved", "", ($sliceType(($ptrType(Ident)))), ""], ["Comments", "Comments", "", ($sliceType(($ptrType(CommentGroup)))), ""]]); + ($ptrType(Package)).methods = [["End", "End", "", $funcType([], [token.Pos], false), -1], ["Pos", "Pos", "", $funcType([], [token.Pos], false), -1]]; + Package.init([["Name", "Name", "", $String, ""], ["Scope", "Scope", "", ($ptrType(Scope)), ""], ["Imports", "Imports", "", ($mapType($String, ($ptrType(Object)))), ""], ["Files", "Files", "", ($mapType($String, ($ptrType(File)))), ""]]); + byPos.methods = [["Len", "Len", "", $funcType([], [$Int], false), -1], ["Less", "Less", "", $funcType([$Int, $Int], [$Bool], false), -1], ["Swap", "Swap", "", $funcType([$Int, $Int], [], false), -1]]; + ($ptrType(byPos)).methods = [["Len", "Len", "", $funcType([], [$Int], false), -1], ["Less", "Less", "", $funcType([$Int, $Int], [$Bool], false), -1], ["Swap", "Swap", "", $funcType([$Int, $Int], [], false), -1]]; + byPos.init(($ptrType(CommentGroup))); + CommentMap.methods = [["Comments", "Comments", "", $funcType([], [($sliceType(($ptrType(CommentGroup))))], false), -1], ["Filter", "Filter", "", $funcType([Node], [CommentMap], false), -1], ["String", "String", "", $funcType([], [$String], false), -1], ["Update", "Update", "", $funcType([Node, Node], [Node], false), -1], ["addComment", "addComment", "go/ast", $funcType([Node, ($ptrType(CommentGroup))], [], false), -1]]; + ($ptrType(CommentMap)).methods = [["Comments", "Comments", "", $funcType([], [($sliceType(($ptrType(CommentGroup))))], false), -1], ["Filter", "Filter", "", $funcType([Node], [CommentMap], false), -1], ["String", "String", "", $funcType([], [$String], false), -1], ["Update", "Update", "", $funcType([Node, Node], [Node], false), -1], ["addComment", "addComment", "go/ast", $funcType([Node, ($ptrType(CommentGroup))], [], false), -1]]; + CommentMap.init(Node, ($sliceType(($ptrType(CommentGroup))))); + ($ptrType(commentListReader)).methods = [["eol", "eol", "go/ast", $funcType([], [$Bool], false), -1], ["next", "next", "go/ast", $funcType([], [], false), -1]]; + commentListReader.init([["fset", "fset", "go/ast", ($ptrType(token.FileSet)), ""], ["list", "list", "go/ast", ($sliceType(($ptrType(CommentGroup)))), ""], ["index", "index", "go/ast", $Int, ""], ["comment", "comment", "go/ast", ($ptrType(CommentGroup)), ""], ["pos", "pos", "go/ast", token.Position, ""], ["end", "end", "go/ast", token.Position, ""]]); + ($ptrType(nodeStack)).methods = [["pop", "pop", "go/ast", $funcType([token.Pos], [Node], false), -1], ["push", "push", "go/ast", $funcType([Node], [], false), -1]]; + nodeStack.init(Node); + posSpan.init([["Start", "Start", "", token.Pos, ""], ["End", "End", "", token.Pos, ""]]); + byImportSpec.methods = [["Len", "Len", "", $funcType([], [$Int], false), -1], ["Less", "Less", "", $funcType([$Int, $Int], [$Bool], false), -1], ["Swap", "Swap", "", $funcType([$Int, $Int], [], false), -1]]; + ($ptrType(byImportSpec)).methods = [["Len", "Len", "", $funcType([], [$Int], false), -1], ["Less", "Less", "", $funcType([$Int, $Int], [$Bool], false), -1], ["Swap", "Swap", "", $funcType([$Int, $Int], [], false), -1]]; + byImportSpec.init(Spec); + byCommentPos.methods = [["Len", "Len", "", $funcType([], [$Int], false), -1], ["Less", "Less", "", $funcType([$Int, $Int], [$Bool], false), -1], ["Swap", "Swap", "", $funcType([$Int, $Int], [], false), -1]]; + ($ptrType(byCommentPos)).methods = [["Len", "Len", "", $funcType([], [$Int], false), -1], ["Less", "Less", "", $funcType([$Int, $Int], [$Bool], false), -1], ["Swap", "Swap", "", $funcType([$Int, $Int], [], false), -1]]; + byCommentPos.init(($ptrType(CommentGroup))); + ($ptrType(Scope)).methods = [["Insert", "Insert", "", $funcType([($ptrType(Object))], [($ptrType(Object))], false), -1], ["Lookup", "Lookup", "", $funcType([$String], [($ptrType(Object))], false), -1], ["String", "String", "", $funcType([], [$String], false), -1]]; + Scope.init([["Outer", "Outer", "", ($ptrType(Scope)), ""], ["Objects", "Objects", "", ($mapType($String, ($ptrType(Object)))), ""]]); + ($ptrType(Object)).methods = [["Pos", "Pos", "", $funcType([], [token.Pos], false), -1]]; + Object.init([["Kind", "Kind", "", ObjKind, ""], ["Name", "Name", "", $String, ""], ["Decl", "Decl", "", $emptyInterface, ""], ["Data", "Data", "", $emptyInterface, ""], ["Type", "Type", "", $emptyInterface, ""]]); + ObjKind.methods = [["String", "String", "", $funcType([], [$String], false), -1]]; + ($ptrType(ObjKind)).methods = [["String", "String", "", $funcType([], [$String], false), -1]]; + Visitor.init([["Visit", "Visit", "", $funcType([Node], [Visitor], false)]]); + inspector.methods = [["Visit", "Visit", "", $funcType([Node], [Visitor], false), -1]]; + ($ptrType(inspector)).methods = [["Visit", "Visit", "", $funcType([Node], [Visitor], false), -1]]; + inspector.init([Node], [$Bool], false); + objKindStrings = $toNativeArray("String", ["bad", "package", "const", "type", "var", "func", "label"]); }; - Checker.prototype.argument = function(sig, i, x, passSlice) { return this.$val.argument(sig, i, x, passSlice); }; - Checker.Ptr.prototype.selector = function(x, e) { - var $this = this, $args = arguments, $s = 0, check, obj, index, indirect, sel, _tuple, ident, ok, _tuple$1, pkg, exp, exp$1, _ref, _tuple$2, _tuple$3, m, params, sig, obj$1, _ref$1, sig$1; - /* */ while (true) { switch ($s) { case 0: - check = $this; - obj = $ifaceNil; - index = ($sliceType($Int)).nil; - indirect = false; - sel = e.Sel.Name; - _tuple = $assertType(e.X, ($ptrType(ast.Ident)), true); ident = _tuple[0]; ok = _tuple[1]; - /* if (ok) { */ if (ok) {} else { $s = 2; continue; } - _tuple$1 = $assertType(check.context.scope.LookupParent(ident.Name), ($ptrType(PkgName)), true); pkg = _tuple$1[0]; - /* if (!(pkg === ($ptrType(PkgName)).nil)) { */ if (!(pkg === ($ptrType(PkgName)).nil)) {} else { $s = 3; continue; } - check.recordUse(ident, pkg); - pkg.object.used = true; - exp = pkg.imported.scope.Lookup(sel); - /* if ($interfaceIsEqual(exp, $ifaceNil)) { */ if ($interfaceIsEqual(exp, $ifaceNil)) {} else { $s = 4; continue; } - if (!pkg.imported.fake) { - check.errorf(e.Pos(), "%s not declared by package %s", new ($sliceType($emptyInterface))([new $String(sel), ident])); - } - /* goto Error */ $s = 1; continue; - /* } */ case 4: - if (!exp.Exported()) { - check.errorf(e.Pos(), "%s not exported by package %s", new ($sliceType($emptyInterface))([new $String(sel), ident])); - } - check.recordUse(e.Sel, exp); - _ref = exp; - if ($assertType(_ref, ($ptrType(Const)), true)[1]) { - exp$1 = _ref.$val; - assert(!($interfaceIsEqual(exp$1.Val(), $ifaceNil))); - x.mode = 4; - x.typ = exp$1.object.typ; - x.val = exp$1.val; - } else if ($assertType(_ref, ($ptrType(TypeName)), true)[1]) { - exp$1 = _ref.$val; - x.mode = 3; - x.typ = exp$1.object.typ; - } else if ($assertType(_ref, ($ptrType(Var)), true)[1]) { - exp$1 = _ref.$val; - x.mode = 5; - x.typ = exp$1.object.typ; - } else if ($assertType(_ref, ($ptrType(Func)), true)[1]) { - exp$1 = _ref.$val; - x.mode = 7; - x.typ = exp$1.object.typ; - } else if ($assertType(_ref, ($ptrType(Builtin)), true)[1]) { - exp$1 = _ref.$val; - x.mode = 2; - x.typ = exp$1.object.typ; - x.id = exp$1.id; - } else { - exp$1 = _ref; - unreachable(); - } - x.expr = e; + return $pkg; +})(); +$packages["io/ioutil"] = (function() { + var $pkg = {}, bytes = $packages["bytes"], io = $packages["io"], os = $packages["os"], sort = $packages["sort"], sync = $packages["sync"], filepath = $packages["path/filepath"], strconv = $packages["strconv"], time = $packages["time"], byName, blackHolePool, readAll, ReadFile, ReadDir; + byName = $pkg.byName = $newType(12, "Slice", "ioutil.byName", "byName", "io/ioutil", null); + readAll = function(r, capacity) { + var b = ($sliceType($Uint8)).nil, err = $ifaceNil, $deferred = [], $err = null, buf, _tuple, _tmp, _tmp$1; + /* */ try { $deferFrames.push($deferred); + buf = bytes.NewBuffer(($sliceType($Uint8)).make(0, $flatten64(capacity))); + $deferred.push([(function() { + var e, _tuple, panicErr, ok; + e = $recover(); + if ($interfaceIsEqual(e, $ifaceNil)) { return; - /* } */ case 3: - /* } */ case 2: - check.exprOrType(x, e.X); - /* if (x.mode === 0) { */ if (x.mode === 0) {} else { $s = 5; continue; } - /* goto Error */ $s = 1; continue; - /* } */ case 5: - _tuple$2 = LookupFieldOrMethod(x.typ, x.mode === 5, check.pkg, sel); obj = _tuple$2[0]; index = _tuple$2[1]; indirect = _tuple$2[2]; - /* if ($interfaceIsEqual(obj, $ifaceNil)) { */ if ($interfaceIsEqual(obj, $ifaceNil)) {} else { $s = 6; continue; } - if (!(index === ($sliceType($Int)).nil)) { - check.invalidOp(e.Pos(), "ambiguous selector %s", new ($sliceType($emptyInterface))([new $String(sel)])); - } else if (indirect) { - check.invalidOp(e.Pos(), "%s is not in method set of %s", new ($sliceType($emptyInterface))([new $String(sel), x.typ])); - } else { - check.invalidOp(e.Pos(), "%s has no field or method %s", new ($sliceType($emptyInterface))([x, new $String(sel)])); - } - /* goto Error */ $s = 1; continue; - /* } */ case 6: - /* if (x.mode === 3) { */ if (x.mode === 3) {} else { $s = 7; continue; } - _tuple$3 = $assertType(obj, ($ptrType(Func)), true); m = _tuple$3[0]; - /* if (m === ($ptrType(Func)).nil) { */ if (m === ($ptrType(Func)).nil) {} else { $s = 9; continue; } - check.invalidOp(e.Pos(), "%s has no method %s", new ($sliceType($emptyInterface))([x, new $String(sel)])); - /* goto Error */ $s = 1; continue; - /* } */ case 9: - check.recordSelection(e, 2, x.typ, m, index, indirect); - params = ($sliceType(($ptrType(Var)))).nil; - sig = $assertType(m.object.typ, ($ptrType(Signature))); - if (!(sig.params === ($ptrType(Tuple)).nil)) { - params = sig.params.vars; } - x.mode = 7; - x.typ = new Signature.Ptr(($ptrType(Scope)).nil, ($ptrType(Var)).nil, NewTuple($appendSlice(new ($sliceType(($ptrType(Var))))([NewVar(0, check.pkg, "", x.typ)]), params)), sig.results, sig.variadic); - check.addDeclDep(m); - /* } else { */ $s = 8; continue; case 7: - _ref$1 = obj; - if ($assertType(_ref$1, ($ptrType(Var)), true)[1]) { - obj$1 = _ref$1.$val; - check.recordSelection(e, 0, x.typ, obj$1, index, indirect); - if ((x.mode === 5) || indirect) { - x.mode = 5; - } else { - x.mode = 7; - } - x.typ = obj$1.object.typ; - } else if ($assertType(_ref$1, ($ptrType(Func)), true)[1]) { - obj$1 = _ref$1.$val; - check.recordSelection(e, 1, x.typ, obj$1, index, indirect); - x.mode = 7; - sig$1 = new Signature.Ptr(); $copy(sig$1, $assertType(obj$1.object.typ, ($ptrType(Signature))), Signature); - sig$1.recv = ($ptrType(Var)).nil; - x.typ = sig$1; - check.addDeclDep(obj$1); + _tuple = $assertType(e, $error, true); panicErr = _tuple[0]; ok = _tuple[1]; + if (ok && $interfaceIsEqual(panicErr, bytes.ErrTooLarge)) { + err = panicErr; } else { - obj$1 = _ref$1; - unreachable(); + $panic(e); } - /* } */ case 8: - x.expr = e; - return; - /* Error: */ case 1: - x.mode = 0; - x.expr = e; - /* */ case -1: } return; } + }), []]); + _tuple = buf.ReadFrom(r); err = _tuple[1]; + _tmp = buf.Bytes(); _tmp$1 = err; b = _tmp; err = _tmp$1; + return [b, err]; + /* */ } catch(err) { $err = err; } finally { $deferFrames.pop(); $callDeferred($deferred, $err); return [b, err]; } }; - Checker.prototype.selector = function(x, e) { return this.$val.selector(x, e); }; - Checker.Ptr.prototype.addDeclDep = function(to) { - var check, from, _tuple, _entry, found; - check = this; - from = check.context.decl; - if (from === ($ptrType(declInfo)).nil) { - return; - } - _tuple = (_entry = check.objMap[to.$key()], _entry !== undefined ? [_entry.v, true] : [($ptrType(declInfo)).nil, false]); found = _tuple[1]; - if (!found) { - return; + ReadFile = $pkg.ReadFile = function(filename) { + var $deferred = [], $err = null, _tuple, f, err, n, _tuple$1, fi, err$1, size; + /* */ try { $deferFrames.push($deferred); + _tuple = os.Open(filename); f = _tuple[0]; err = _tuple[1]; + if (!($interfaceIsEqual(err, $ifaceNil))) { + return [($sliceType($Uint8)).nil, err]; } - from.addDep(to); - }; - Checker.prototype.addDeclDep = function(to) { return this.$val.addDeclDep(to); }; - Checker.Ptr.prototype.assocMethod = function(tname, meth) { - var check, m, _entry, _key$2; - check = this; - m = check.methods; - if (m === false) { - m = new $Map(); - check.methods = m; + $deferred.push([$methodVal(f, "Close"), []]); + n = new $Int64(0, 0); + _tuple$1 = f.Stat(); fi = _tuple$1[0]; err$1 = _tuple$1[1]; + if ($interfaceIsEqual(err$1, $ifaceNil)) { + size = fi.Size(); + if ((size.$high < 0 || (size.$high === 0 && size.$low < 1000000000))) { + n = size; + } } - _key$2 = tname; (m || $throwRuntimeError("assignment to entry in nil map"))[_key$2] = { k: _key$2, v: $append((_entry = m[tname], _entry !== undefined ? _entry.v : ($sliceType(($ptrType(Func)))).nil), meth) }; + return readAll(f, new $Int64(n.$high + 0, n.$low + 512)); + /* */ } catch(err) { $err = err; return [($sliceType($Uint8)).nil, $ifaceNil]; } finally { $deferFrames.pop(); $callDeferred($deferred, $err); } }; - Checker.prototype.assocMethod = function(tname, meth) { return this.$val.assocMethod(tname, meth); }; - Checker.Ptr.prototype.rememberUntyped = function(e, lhs, mode, typ, val) { - var check, m, _key$2; - check = this; - m = check.untyped; - if (m === false) { - m = new $Map(); - check.untyped = m; - } - _key$2 = e; (m || $throwRuntimeError("assignment to entry in nil map"))[_key$2.$key()] = { k: _key$2, v: new exprInfo.Ptr(lhs, mode, typ, val) }; + byName.prototype.Len = function() { + var f; + f = this; + return f.$length; }; - Checker.prototype.rememberUntyped = function(e, lhs, mode, typ, val) { return this.$val.rememberUntyped(e, lhs, mode, typ, val); }; - Checker.Ptr.prototype.later = function(name, decl, sig, body) { - var check; - check = this; - check.funcs = $append(check.funcs, new funcInfo.Ptr(name, decl, sig, body)); + $ptrType(byName).prototype.Len = function() { return this.$get().Len(); }; + byName.prototype.Less = function(i, j) { + var f; + f = this; + return ((i < 0 || i >= f.$length) ? $throwRuntimeError("index out of range") : f.$array[f.$offset + i]).Name() < ((j < 0 || j >= f.$length) ? $throwRuntimeError("index out of range") : f.$array[f.$offset + j]).Name(); }; - Checker.prototype.later = function(name, decl, sig, body) { return this.$val.later(name, decl, sig, body); }; - Checker.Ptr.prototype.delay = function(f) { - var check; - check = this; - check.delayed = $append(check.delayed, f); + $ptrType(byName).prototype.Less = function(i, j) { return this.$get().Less(i, j); }; + byName.prototype.Swap = function(i, j) { + var f, _tmp, _tmp$1; + f = this; + _tmp = ((j < 0 || j >= f.$length) ? $throwRuntimeError("index out of range") : f.$array[f.$offset + j]); _tmp$1 = ((i < 0 || i >= f.$length) ? $throwRuntimeError("index out of range") : f.$array[f.$offset + i]); (i < 0 || i >= f.$length) ? $throwRuntimeError("index out of range") : f.$array[f.$offset + i] = _tmp; (j < 0 || j >= f.$length) ? $throwRuntimeError("index out of range") : f.$array[f.$offset + j] = _tmp$1; }; - Checker.prototype.delay = function(f) { return this.$val.delay(f); }; - NewChecker = $pkg.NewChecker = function(conf, fset, pkg, info) { - if (conf === ($ptrType(Config)).nil) { - conf = new Config.Ptr(); - } - if (conf.Packages === false) { - conf.Packages = new $Map(); + $ptrType(byName).prototype.Swap = function(i, j) { return this.$get().Swap(i, j); }; + ReadDir = $pkg.ReadDir = function(dirname) { + var _tuple, f, err, _tuple$1, list; + _tuple = os.Open(dirname); f = _tuple[0]; err = _tuple[1]; + if (!($interfaceIsEqual(err, $ifaceNil))) { + return [($sliceType(os.FileInfo)).nil, err]; } - if (info === ($ptrType(Info)).nil) { - info = new Info.Ptr(); + _tuple$1 = f.Readdir(-1); list = _tuple$1[0]; err = _tuple$1[1]; + f.Close(); + if (!($interfaceIsEqual(err, $ifaceNil))) { + return [($sliceType(os.FileInfo)).nil, err]; } - return new Checker.Ptr(conf, fset, pkg, info, new $Map(), ($sliceType(($ptrType(ast.File)))).nil, ($sliceType(($ptrType(Scope)))).nil, ($sliceType(($mapType(($ptrType(Package)), token.Pos)))).nil, $ifaceNil, false, false, ($sliceType(funcInfo)).nil, ($sliceType(($funcType([], [], false)))).nil, new context.Ptr(), 0); + sort.Sort($subslice(new byName(list.$array), list.$offset, list.$offset + list.$length)); + return [list, $ifaceNil]; }; - Checker.Ptr.prototype.initFiles = function(files) { - var check, pkg, _ref, _i, i, file, name, _ref$1, comment, pos, fileScope; - check = this; - check.files = ($sliceType(($ptrType(ast.File)))).nil; - check.fileScopes = ($sliceType(($ptrType(Scope)))).nil; - check.dotImports = ($sliceType(($mapType(($ptrType(Package)), token.Pos)))).nil; - check.firstErr = $ifaceNil; - check.methods = false; - check.untyped = false; - check.funcs = ($sliceType(funcInfo)).nil; - check.delayed = ($sliceType(($funcType([], [], false)))).nil; - pkg = check.pkg; - _ref = files; - _i = 0; - while (_i < _ref.$length) { - i = _i; - file = ((_i < 0 || _i >= _ref.$length) ? $throwRuntimeError("index out of range") : _ref.$array[_ref.$offset + _i]); - name = file.Name.Name; - _ref$1 = pkg.name; - if (_ref$1 === "") { - if (!(name === "_")) { - pkg.name = name; - } else { - check.errorf(file.Name.Pos(), "invalid package name _", new ($sliceType($emptyInterface))([])); - } - check.files = $append(check.files, file); - comment = ""; - pos = file.Pos(); - if ((new token.Pos(pos)).IsValid()) { - comment = "file " + check.fset.File(pos).Name(); - } else { - comment = fmt.Sprintf("file[%d]", new ($sliceType($emptyInterface))([new $Int(i)])); + $pkg.$init = function() { + byName.methods = [["Len", "Len", "", $funcType([], [$Int], false), -1], ["Less", "Less", "", $funcType([$Int, $Int], [$Bool], false), -1], ["Swap", "Swap", "", $funcType([$Int, $Int], [], false), -1]]; + ($ptrType(byName)).methods = [["Len", "Len", "", $funcType([], [$Int], false), -1], ["Less", "Less", "", $funcType([$Int, $Int], [$Bool], false), -1], ["Swap", "Swap", "", $funcType([$Int, $Int], [], false), -1]]; + byName.init(os.FileInfo); + blackHolePool = new sync.Pool.Ptr(0, 0, ($sliceType($emptyInterface)).nil, (function() { + var b; + b = ($sliceType($Uint8)).make(8192); + return new ($ptrType(($sliceType($Uint8))))(function() { return b; }, function($v) { b = $v; }); + })); + }; + return $pkg; +})(); +$packages["go/parser"] = (function() { + var $pkg = {}, bytes = $packages["bytes"], errors = $packages["errors"], ast = $packages["go/ast"], token = $packages["go/token"], io = $packages["io"], ioutil = $packages["io/ioutil"], os = $packages["os"], filepath = $packages["path/filepath"], strings = $packages["strings"], fmt = $packages["fmt"], scanner = $packages["go/scanner"], strconv = $packages["strconv"], unicode = $packages["unicode"], Mode, parser, bailout, parseSpecFunction, unresolved, readSource, ParseFile, trace, un, assert, syncStmt, syncDecl, isTypeName, isLiteralType, deref, unparen, isTypeSwitchAssert, isTypeSwitchGuard, isValidImport; + Mode = $pkg.Mode = $newType(4, "Uint", "parser.Mode", "Mode", "go/parser", null); + parser = $pkg.parser = $newType(0, "Struct", "parser.parser", "parser", "go/parser", function(file_, errors_, scanner_, mode_, trace_, indent_, comments_, leadComment_, lineComment_, pos_, tok_, lit_, syncPos_, syncCnt_, exprLev_, inRhs_, pkgScope_, topScope_, unresolved_, imports_, labelScope_, targetStack_) { + this.$val = this; + this.file = file_ !== undefined ? file_ : ($ptrType(token.File)).nil; + this.errors = errors_ !== undefined ? errors_ : scanner.ErrorList.nil; + this.scanner = scanner_ !== undefined ? scanner_ : new scanner.Scanner.Ptr(); + this.mode = mode_ !== undefined ? mode_ : 0; + this.trace = trace_ !== undefined ? trace_ : false; + this.indent = indent_ !== undefined ? indent_ : 0; + this.comments = comments_ !== undefined ? comments_ : ($sliceType(($ptrType(ast.CommentGroup)))).nil; + this.leadComment = leadComment_ !== undefined ? leadComment_ : ($ptrType(ast.CommentGroup)).nil; + this.lineComment = lineComment_ !== undefined ? lineComment_ : ($ptrType(ast.CommentGroup)).nil; + this.pos = pos_ !== undefined ? pos_ : 0; + this.tok = tok_ !== undefined ? tok_ : 0; + this.lit = lit_ !== undefined ? lit_ : ""; + this.syncPos = syncPos_ !== undefined ? syncPos_ : 0; + this.syncCnt = syncCnt_ !== undefined ? syncCnt_ : 0; + this.exprLev = exprLev_ !== undefined ? exprLev_ : 0; + this.inRhs = inRhs_ !== undefined ? inRhs_ : false; + this.pkgScope = pkgScope_ !== undefined ? pkgScope_ : ($ptrType(ast.Scope)).nil; + this.topScope = topScope_ !== undefined ? topScope_ : ($ptrType(ast.Scope)).nil; + this.unresolved = unresolved_ !== undefined ? unresolved_ : ($sliceType(($ptrType(ast.Ident)))).nil; + this.imports = imports_ !== undefined ? imports_ : ($sliceType(($ptrType(ast.ImportSpec)))).nil; + this.labelScope = labelScope_ !== undefined ? labelScope_ : ($ptrType(ast.Scope)).nil; + this.targetStack = targetStack_ !== undefined ? targetStack_ : ($sliceType(($sliceType(($ptrType(ast.Ident)))))).nil; + }); + bailout = $pkg.bailout = $newType(0, "Struct", "parser.bailout", "bailout", "go/parser", function() { + this.$val = this; + }); + parseSpecFunction = $pkg.parseSpecFunction = $newType(4, "Func", "parser.parseSpecFunction", "parseSpecFunction", "go/parser", null); + readSource = function(filename, src) { + var s, _ref, buf, _tuple, err; + if (!($interfaceIsEqual(src, $ifaceNil))) { + _ref = src; + if ($assertType(_ref, $String, true)[1]) { + s = _ref.$val; + return [new ($sliceType($Uint8))($stringToBytes(s)), $ifaceNil]; + } else if ($assertType(_ref, ($sliceType($Uint8)), true)[1]) { + s = _ref.$val; + return [s, $ifaceNil]; + } else if ($assertType(_ref, ($ptrType(bytes.Buffer)), true)[1]) { + s = _ref.$val; + if (!(s === ($ptrType(bytes.Buffer)).nil)) { + return [s.Bytes(), $ifaceNil]; } - fileScope = NewScope(pkg.scope, comment); - check.recordScope(file, fileScope); - check.fileScopes = $append(check.fileScopes, fileScope); - check.dotImports = $append(check.dotImports, false); - } else if (_ref$1 === name) { - check.files = $append(check.files, file); - comment = ""; - pos = file.Pos(); - if ((new token.Pos(pos)).IsValid()) { - comment = "file " + check.fset.File(pos).Name(); - } else { - comment = fmt.Sprintf("file[%d]", new ($sliceType($emptyInterface))([new $Int(i)])); + } else if ($assertType(_ref, io.Reader, true)[1]) { + s = _ref; + buf = new bytes.Buffer.Ptr(); $copy(buf, new bytes.Buffer.Ptr(), bytes.Buffer); + _tuple = io.Copy(buf, s); err = _tuple[1]; + if (!($interfaceIsEqual(err, $ifaceNil))) { + return [($sliceType($Uint8)).nil, err]; } - fileScope = NewScope(pkg.scope, comment); - check.recordScope(file, fileScope); - check.fileScopes = $append(check.fileScopes, fileScope); - check.dotImports = $append(check.dotImports, false); - } else { - check.errorf(file.Package, "package %s; expected %s", new ($sliceType($emptyInterface))([new $String(name), new $String(pkg.name)])); + return [buf.Bytes(), $ifaceNil]; } - _i++; + return [($sliceType($Uint8)).nil, errors.New("invalid source")]; } + return ioutil.ReadFile(filename); }; - Checker.prototype.initFiles = function(files) { return this.$val.initFiles(files); }; - Checker.Ptr.prototype.handleBailout = function(err) { - var check, p, _ref; - check = this; - _ref = $recover(); - if (_ref === $ifaceNil || $assertType(_ref, bailout, true)[1]) { - p = _ref; - err.$set(check.firstErr); - } else { - p = _ref; - $panic(p); + ParseFile = $pkg.ParseFile = function(fset, filename, src, mode) { + var f = ($ptrType(ast.File)).nil, err = $ifaceNil, $deferred = [], $err = null, _tuple, text, _tmp, _tmp$1, p; + /* */ try { $deferFrames.push($deferred); + _tuple = readSource(filename, src); text = _tuple[0]; err = _tuple[1]; + if (!($interfaceIsEqual(err, $ifaceNil))) { + _tmp = ($ptrType(ast.File)).nil; _tmp$1 = err; f = _tmp; err = _tmp$1; + return [f, err]; } + p = new parser.Ptr(); $copy(p, new parser.Ptr(), parser); + $deferred.push([(function() { + var e; + e = $recover(); + if (!($interfaceIsEqual(e, $ifaceNil))) { + } + if (f === ($ptrType(ast.File)).nil) { + f = new ast.File.Ptr(($ptrType(ast.CommentGroup)).nil, 0, new ast.Ident.Ptr(), ($sliceType(ast.Decl)).nil, ast.NewScope(($ptrType(ast.Scope)).nil), ($sliceType(($ptrType(ast.ImportSpec)))).nil, ($sliceType(($ptrType(ast.Ident)))).nil, ($sliceType(($ptrType(ast.CommentGroup)))).nil); + } + p.errors.Sort(); + err = p.errors.Err(); + }), []]); + p.init(fset, filename, text, mode); + f = p.parseFile(); + return [f, err]; + /* */ } catch(err) { $err = err; } finally { $deferFrames.pop(); $callDeferred($deferred, $err); return [f, err]; } }; - Checker.prototype.handleBailout = function(err) { return this.$val.handleBailout(err); }; - Checker.Ptr.prototype.Files = function(files) { - var err = $ifaceNil, $deferred = [], $err = null, check, _ref, _i, f; - /* */ try { $deferFrames.push($deferred); - check = this; - $deferred.push([$methodVal(check, "handleBailout"), [new ($ptrType($error))(function() { return err; }, function($v) { err = $v; })]]); - check.initFiles(files); - check.collectObjects(); - check.packageObjects(check.resolveOrder()); - check.functionBodies(); - check.initOrder(); - check.unusedImports(); - _ref = check.delayed; + parser.Ptr.prototype.init = function(fset, filename, src, mode) { + var p, m, eh; + p = this; + p.file = fset.AddFile(filename, -1, src.$length); + m = 0; + if (!((((mode & 4) >>> 0) === 0))) { + m = 1; + } + eh = (function(pos, msg) { + new ($ptrType(scanner.ErrorList))(function() { return this.$target.errors; }, function($v) { this.$target.errors = $v; }, p).Add($clone(pos, token.Position), msg); + }); + p.scanner.Init(p.file, src, eh, m); + p.mode = mode; + p.trace = !((((mode & 8) >>> 0) === 0)); + p.next(); + }; + parser.prototype.init = function(fset, filename, src, mode) { return this.$val.init(fset, filename, src, mode); }; + parser.Ptr.prototype.openScope = function() { + var p; + p = this; + p.topScope = ast.NewScope(p.topScope); + }; + parser.prototype.openScope = function() { return this.$val.openScope(); }; + parser.Ptr.prototype.closeScope = function() { + var p; + p = this; + p.topScope = p.topScope.Outer; + }; + parser.prototype.closeScope = function() { return this.$val.closeScope(); }; + parser.Ptr.prototype.openLabelScope = function() { + var p; + p = this; + p.labelScope = ast.NewScope(p.labelScope); + p.targetStack = $append(p.targetStack, ($sliceType(($ptrType(ast.Ident)))).nil); + }; + parser.prototype.openLabelScope = function() { return this.$val.openLabelScope(); }; + parser.Ptr.prototype.closeLabelScope = function() { + var p, n, scope, _ref, x, _i, ident; + p = this; + n = p.targetStack.$length - 1 >> 0; + scope = p.labelScope; + _ref = (x = p.targetStack, ((n < 0 || n >= x.$length) ? $throwRuntimeError("index out of range") : x.$array[x.$offset + n])); _i = 0; while (_i < _ref.$length) { - f = ((_i < 0 || _i >= _ref.$length) ? $throwRuntimeError("index out of range") : _ref.$array[_ref.$offset + _i]); - f(); + ident = ((_i < 0 || _i >= _ref.$length) ? $throwRuntimeError("index out of range") : _ref.$array[_ref.$offset + _i]); + ident.Obj = scope.Lookup(ident.Name); + if (ident.Obj === ($ptrType(ast.Object)).nil && !((((p.mode & 16) >>> 0) === 0))) { + p.error(ident.Pos(), fmt.Sprintf("label %s undefined", new ($sliceType($emptyInterface))([new $String(ident.Name)]))); + } _i++; } - check.recordUntyped(); - check.pkg.complete = true; - return err; - /* */ } catch(err) { $err = err; } finally { $deferFrames.pop(); $callDeferred($deferred, $err); return err; } + p.targetStack = $subslice(p.targetStack, 0, n); + p.labelScope = p.labelScope.Outer; }; - Checker.prototype.Files = function(files) { return this.$val.Files(files); }; - Checker.Ptr.prototype.recordUntyped = function() { - var check, _ref, _i, _keys, _entry, x, info; - check = this; - if (true && check.Info.Types === false) { - return; - } - _ref = check.untyped; + parser.prototype.closeLabelScope = function() { return this.$val.closeLabelScope(); }; + parser.Ptr.prototype.declare = function(decl, data, scope, kind, idents) { + var p, _ref, _i, ident, obj, alt, prevDecl, pos, x; + p = this; + _ref = idents; _i = 0; - _keys = $keys(_ref); - while (_i < _keys.length) { - _entry = _ref[_keys[_i]]; - if (_entry === undefined) { - _i++; - continue; + while (_i < _ref.$length) { + ident = ((_i < 0 || _i >= _ref.$length) ? $throwRuntimeError("index out of range") : _ref.$array[_ref.$offset + _i]); + assert(ident.Obj === ($ptrType(ast.Object)).nil, "identifier already declared or resolved"); + obj = ast.NewObj(kind, ident.Name); + obj.Decl = decl; + obj.Data = data; + ident.Obj = obj; + if (!(ident.Name === "_")) { + alt = scope.Insert(obj); + if (!(alt === ($ptrType(ast.Object)).nil) && !((((p.mode & 16) >>> 0) === 0))) { + prevDecl = ""; + pos = alt.Pos(); + if ((new token.Pos(pos)).IsValid()) { + prevDecl = fmt.Sprintf("\n\tprevious declaration at %s", new ($sliceType($emptyInterface))([(x = p.file.Position(pos), new x.constructor.Struct(x))])); + } + p.error(ident.Pos(), fmt.Sprintf("%s redeclared in this block%s", new ($sliceType($emptyInterface))([new $String(ident.Name), new $String(prevDecl)]))); + } } - x = _entry.k; - info = new exprInfo.Ptr(); $copy(info, _entry.v, exprInfo); - check.recordTypeAndValue(x, info.mode, info.typ, info.val); _i++; } }; - Checker.prototype.recordUntyped = function() { return this.$val.recordUntyped(); }; - Checker.Ptr.prototype.recordTypeAndValue = function(x, mode, typ, val) { - var check, m, _key$2; - check = this; - assert(!($interfaceIsEqual(x, $ifaceNil))); - assert(!($interfaceIsEqual(typ, $ifaceNil))); - if (mode === 0) { - return; - } - assert(!($interfaceIsEqual(typ, $ifaceNil))); - if (mode === 4) { - assert(!($interfaceIsEqual(val, $ifaceNil))); - assert($interfaceIsEqual(typ, $pkg.Typ[0]) || isConstType(typ)); - } - m = check.Info.Types; - if (!(m === false)) { - _key$2 = x; (m || $throwRuntimeError("assignment to entry in nil map"))[_key$2.$key()] = { k: _key$2, v: new TypeAndValue.Ptr(mode, typ, val) }; - } - }; - Checker.prototype.recordTypeAndValue = function(x, mode, typ, val) { return this.$val.recordTypeAndValue(x, mode, typ, val); }; - Checker.Ptr.prototype.recordBuiltinType = function(f, sig) { - var check, p, _ref; - check = this; - while (true) { - check.recordTypeAndValue(f, 2, sig, $ifaceNil); - _ref = f; - if ($assertType(_ref, ($ptrType(ast.Ident)), true)[1]) { - p = _ref.$val; - return; - } else if ($assertType(_ref, ($ptrType(ast.ParenExpr)), true)[1]) { - p = _ref.$val; - f = p.X; + parser.prototype.declare = function(decl, data, scope, kind, idents) { return this.$val.declare(decl, data, scope, kind, idents); }; + parser.Ptr.prototype.shortVarDecl = function(decl, list) { + var p, n, _ref, _i, x, _tuple, ident, isIdent, obj, alt; + p = this; + n = 0; + _ref = list; + _i = 0; + while (_i < _ref.$length) { + x = ((_i < 0 || _i >= _ref.$length) ? $throwRuntimeError("index out of range") : _ref.$array[_ref.$offset + _i]); + _tuple = $assertType(x, ($ptrType(ast.Ident)), true); ident = _tuple[0]; isIdent = _tuple[1]; + if (isIdent) { + assert(ident.Obj === ($ptrType(ast.Object)).nil, "identifier already declared or resolved"); + obj = ast.NewObj(4, ident.Name); + obj.Decl = decl; + ident.Obj = obj; + if (!(ident.Name === "_")) { + alt = p.topScope.Insert(obj); + if (!(alt === ($ptrType(ast.Object)).nil)) { + ident.Obj = alt; + } else { + n = n + (1) >> 0; + } + } } else { - p = _ref; - unreachable(); + p.errorExpected(x.Pos(), "identifier on left side of :="); } + _i++; + } + if ((n === 0) && !((((p.mode & 16) >>> 0) === 0))) { + p.error(((0 < 0 || 0 >= list.$length) ? $throwRuntimeError("index out of range") : list.$array[list.$offset + 0]).Pos(), "no new variables on left side of :="); } }; - Checker.prototype.recordBuiltinType = function(f, sig) { return this.$val.recordBuiltinType(f, sig); }; - Checker.Ptr.prototype.recordCommaOkTypes = function(x, a) { - var check, m, _entry, tv, pos, _key$2, _tuple, p; - check = this; - assert(!($interfaceIsEqual(x, $ifaceNil))); - if ($interfaceIsEqual(a[0], $ifaceNil) || $interfaceIsEqual(a[1], $ifaceNil)) { + parser.prototype.shortVarDecl = function(decl, list) { return this.$val.shortVarDecl(decl, list); }; + parser.Ptr.prototype.tryResolve = function(x, collectUnresolved) { + var p, _tuple, ident, s, obj; + p = this; + _tuple = $assertType(x, ($ptrType(ast.Ident)), true); ident = _tuple[0]; + if (ident === ($ptrType(ast.Ident)).nil) { return; } - assert(isTyped(a[0]) && isTyped(a[1]) && isBoolean(a[1])); - m = check.Info.Types; - if (!(m === false)) { - while (true) { - tv = new TypeAndValue.Ptr(); $copy(tv, (_entry = m[x.$key()], _entry !== undefined ? _entry.v : new TypeAndValue.Ptr()), TypeAndValue); - assert(!($interfaceIsEqual(tv.Type, $ifaceNil))); - pos = x.Pos(); - tv.Type = NewTuple(new ($sliceType(($ptrType(Var))))([NewVar(pos, check.pkg, "", a[0]), NewVar(pos, check.pkg, "", a[1])])); - _key$2 = x; (m || $throwRuntimeError("assignment to entry in nil map"))[_key$2.$key()] = { k: _key$2, v: tv }; - _tuple = $assertType(x, ($ptrType(ast.ParenExpr)), true); p = _tuple[0]; - if (p === ($ptrType(ast.ParenExpr)).nil) { - break; - } - x = p.X; + assert(ident.Obj === ($ptrType(ast.Object)).nil, "identifier already declared or resolved"); + if (ident.Name === "_") { + return; + } + s = p.topScope; + while (!(s === ($ptrType(ast.Scope)).nil)) { + obj = s.Lookup(ident.Name); + if (!(obj === ($ptrType(ast.Object)).nil)) { + ident.Obj = obj; + return; } + s = s.Outer; } - }; - Checker.prototype.recordCommaOkTypes = function(x, a) { return this.$val.recordCommaOkTypes(x, a); }; - Checker.Ptr.prototype.recordDef = function(id, obj) { - var check, m, _key$2; - check = this; - assert(!(id === ($ptrType(ast.Ident)).nil)); - m = check.Info.Defs; - if (!(m === false)) { - _key$2 = id; (m || $throwRuntimeError("assignment to entry in nil map"))[_key$2.$key()] = { k: _key$2, v: obj }; + if (collectUnresolved) { + ident.Obj = unresolved; + p.unresolved = $append(p.unresolved, ident); } }; - Checker.prototype.recordDef = function(id, obj) { return this.$val.recordDef(id, obj); }; - Checker.Ptr.prototype.recordUse = function(id, obj) { - var check, m, _key$2; - check = this; - assert(!(id === ($ptrType(ast.Ident)).nil)); - assert(!($interfaceIsEqual(obj, $ifaceNil))); - m = check.Info.Uses; - if (!(m === false)) { - _key$2 = id; (m || $throwRuntimeError("assignment to entry in nil map"))[_key$2.$key()] = { k: _key$2, v: obj }; - } + parser.prototype.tryResolve = function(x, collectUnresolved) { return this.$val.tryResolve(x, collectUnresolved); }; + parser.Ptr.prototype.resolve = function(x) { + var p; + p = this; + p.tryResolve(x, true); }; - Checker.prototype.recordUse = function(id, obj) { return this.$val.recordUse(id, obj); }; - Checker.Ptr.prototype.recordImplicit = function(node, obj) { - var check, m, _key$2; - check = this; - assert(!($interfaceIsEqual(node, $ifaceNil))); - assert(!($interfaceIsEqual(obj, $ifaceNil))); - m = check.Info.Implicits; - if (!(m === false)) { - _key$2 = node; (m || $throwRuntimeError("assignment to entry in nil map"))[_key$2.$key()] = { k: _key$2, v: obj }; + parser.prototype.resolve = function(x) { return this.$val.resolve(x); }; + parser.Ptr.prototype.printTrace = function(a) { + var p, pos, x, i; + p = this; + pos = new token.Position.Ptr(); $copy(pos, p.file.Position(p.pos), token.Position); + fmt.Printf("%5d:%3d: ", new ($sliceType($emptyInterface))([new $Int(pos.Line), new $Int(pos.Column)])); + i = (x = p.indent, (((2 >>> 16 << 16) * x >> 0) + (2 << 16 >>> 16) * x) >> 0); + while (i > 64) { + fmt.Print(new ($sliceType($emptyInterface))([new $String(". . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ")])); + i = i - (64) >> 0; } + fmt.Print(new ($sliceType($emptyInterface))([new $String(". . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ".substring(0, i))])); + fmt.Println(a); }; - Checker.prototype.recordImplicit = function(node, obj) { return this.$val.recordImplicit(node, obj); }; - Checker.Ptr.prototype.recordSelection = function(x, kind, recv, obj, index, indirect) { - var check, m, _key$2; - check = this; - assert(!($interfaceIsEqual(obj, $ifaceNil)) && ($interfaceIsEqual(recv, $ifaceNil) || index.$length > 0)); - check.recordUse(x.Sel, obj); - m = check.Info.Selections; - if (!(m === false)) { - _key$2 = x; (m || $throwRuntimeError("assignment to entry in nil map"))[_key$2.$key()] = { k: _key$2, v: new Selection.Ptr(kind, recv, obj, index, indirect) }; - } + parser.prototype.printTrace = function(a) { return this.$val.printTrace(a); }; + trace = function(p, msg) { + p.printTrace(new ($sliceType($emptyInterface))([new $String(msg), new $String("(")])); + p.indent = p.indent + (1) >> 0; + return p; }; - Checker.prototype.recordSelection = function(x, kind, recv, obj, index, indirect) { return this.$val.recordSelection(x, kind, recv, obj, index, indirect); }; - Checker.Ptr.prototype.recordScope = function(node, scope) { - var check, m, _key$2; - check = this; - assert(!($interfaceIsEqual(node, $ifaceNil))); - assert(!(scope === ($ptrType(Scope)).nil)); - m = check.Info.Scopes; - if (!(m === false)) { - _key$2 = node; (m || $throwRuntimeError("assignment to entry in nil map"))[_key$2.$key()] = { k: _key$2, v: scope }; - } + un = function(p) { + p.indent = p.indent - (1) >> 0; + p.printTrace(new ($sliceType($emptyInterface))([new $String(")")])); }; - Checker.prototype.recordScope = function(node, scope) { return this.$val.recordScope(node, scope); }; - Checker.Ptr.prototype.conversion = function(x, T) { - var check, constArg, ok, t, codepoint, _tuple, i, ok$1, final$1; - check = this; - constArg = x.mode === 4; - ok = false; - if (constArg && isConstType(T)) { - t = $assertType(T.Underlying(), ($ptrType(Basic))); - if (representableConst(x.val, check.conf, t.kind, new ($ptrType(exact.Value))(function() { return this.$target.val; }, function($v) { this.$target.val = $v; }, x))) { - ok = true; - } else if (x.isInteger() && isString(t)) { - codepoint = new $Int64(-1, 4294967295); - _tuple = exact.Int64Val(x.val); i = _tuple[0]; ok$1 = _tuple[1]; - if (ok$1) { - codepoint = i; - } - x.val = exact.MakeString($encodeRune(codepoint.$low)); - ok = true; - } - } else if (x.convertibleTo(check.conf, T)) { - x.mode = 7; - ok = true; - } - if (!ok) { - check.errorf(x.pos(), "cannot convert %s to %s", new ($sliceType($emptyInterface))([x, T])); - x.mode = 0; - return; - } - final$1 = x.typ; - if (isUntyped(x.typ)) { - final$1 = T; - if (isInterface(T) || constArg && !isConstType(T)) { - final$1 = defaultType(x.typ); + parser.Ptr.prototype.next0 = function() { + var p, s, _tuple; + p = this; + if (p.trace && (new token.Pos(p.pos)).IsValid()) { + s = (new token.Token(p.tok)).String(); + if ((new token.Token(p.tok)).IsLiteral()) { + p.printTrace(new ($sliceType($emptyInterface))([new $String(s), new $String(p.lit)])); + } else if ((new token.Token(p.tok)).IsOperator() || (new token.Token(p.tok)).IsKeyword()) { + p.printTrace(new ($sliceType($emptyInterface))([new $String("\"" + s + "\"")])); + } else { + p.printTrace(new ($sliceType($emptyInterface))([new $String(s)])); } - check.updateExprType(x.expr, final$1, true); } - x.typ = T; + _tuple = p.scanner.Scan(); p.pos = _tuple[0]; p.tok = _tuple[1]; p.lit = _tuple[2]; }; - Checker.prototype.conversion = function(x, T) { return this.$val.conversion(x, T); }; - operand.Ptr.prototype.convertibleTo = function(conf, T) { - var x, V, Vu, Tu, _tuple, V$1, ok, _tuple$1, T$1, ok$1; - x = this; - if (x.assignableTo(conf, T)) { - return true; - } - V = x.typ; - Vu = V.Underlying(); - Tu = T.Underlying(); - if (Identical(Vu, Tu)) { - return true; - } - _tuple = $assertType(V, ($ptrType(Pointer)), true); V$1 = _tuple[0]; ok = _tuple[1]; - if (ok) { - _tuple$1 = $assertType(T, ($ptrType(Pointer)), true); T$1 = _tuple$1[0]; ok$1 = _tuple$1[1]; - if (ok$1) { - if (Identical(V$1.base.Underlying(), T$1.base.Underlying())) { - return true; + parser.prototype.next0 = function() { return this.$val.next0(); }; + parser.Ptr.prototype.consumeComment = function() { + var comment = ($ptrType(ast.Comment)).nil, endline = 0, p, i; + p = this; + endline = p.file.Line(p.pos); + if (p.lit.charCodeAt(1) === 42) { + i = 0; + while (i < p.lit.length) { + if (p.lit.charCodeAt(i) === 10) { + endline = endline + (1) >> 0; } + i = i + (1) >> 0; } } - if ((isInteger(V) || isFloat(V)) && (isInteger(T) || isFloat(T))) { - return true; - } - if (isComplex(V) && isComplex(T)) { - return true; - } - if ((isInteger(V) || isBytesOrRunes(Vu)) && isString(T)) { - return true; - } - if (isString(V) && isBytesOrRunes(Tu)) { - return true; - } - if ((isPointer(Vu) || isUintptr(Vu)) && isUnsafePointer(T)) { - return true; - } - if (isUnsafePointer(V) && (isPointer(Tu) || isUintptr(Tu))) { - return true; - } - return false; - }; - operand.prototype.convertibleTo = function(conf, T) { return this.$val.convertibleTo(conf, T); }; - isUintptr = function(typ) { - var _tuple, t, ok; - _tuple = $assertType(typ.Underlying(), ($ptrType(Basic)), true); t = _tuple[0]; ok = _tuple[1]; - return ok && (t.kind === 12); - }; - isUnsafePointer = function(typ) { - var _tuple, t, ok; - _tuple = $assertType(typ.Underlying(), ($ptrType(Basic)), true); t = _tuple[0]; ok = _tuple[1]; - return ok && (t.kind === 18); - }; - isPointer = function(typ) { - var _tuple, ok; - _tuple = $assertType(typ.Underlying(), ($ptrType(Pointer)), true); ok = _tuple[1]; - return ok; + comment = new ast.Comment.Ptr(p.pos, p.lit); + p.next0(); + return [comment, endline]; }; - isBytesOrRunes = function(typ) { - var _tuple, s, ok, _tuple$1, t, ok$1; - _tuple = $assertType(typ, ($ptrType(Slice)), true); s = _tuple[0]; ok = _tuple[1]; - if (ok) { - _tuple$1 = $assertType(s.elem.Underlying(), ($ptrType(Basic)), true); t = _tuple$1[0]; ok$1 = _tuple$1[1]; - return ok$1 && ((t.kind === 8) || (t.kind === 5)); + parser.prototype.consumeComment = function() { return this.$val.consumeComment(); }; + parser.Ptr.prototype.consumeCommentGroup = function(n) { + var comments = ($ptrType(ast.CommentGroup)).nil, endline = 0, p, list, comment, _tuple; + p = this; + list = ($sliceType(($ptrType(ast.Comment)))).nil; + endline = p.file.Line(p.pos); + while ((p.tok === 2) && p.file.Line(p.pos) <= (endline + n >> 0)) { + comment = ($ptrType(ast.Comment)).nil; + _tuple = p.consumeComment(); comment = _tuple[0]; endline = _tuple[1]; + list = $append(list, comment); } - return false; + comments = new ast.CommentGroup.Ptr(list); + p.comments = $append(p.comments, comments); + return [comments, endline]; }; - Checker.Ptr.prototype.reportAltDecl = function(obj) { - var check, pos; - check = this; - pos = obj.Pos(); - if ((new token.Pos(pos)).IsValid()) { - check.errorf(pos, "\tother declaration of %s", new ($sliceType($emptyInterface))([new $String(obj.Name())])); + parser.prototype.consumeCommentGroup = function(n) { return this.$val.consumeCommentGroup(n); }; + parser.Ptr.prototype.next = function() { + var p, prev, comment, endline, _tuple, _tuple$1; + p = this; + p.leadComment = ($ptrType(ast.CommentGroup)).nil; + p.lineComment = ($ptrType(ast.CommentGroup)).nil; + prev = p.pos; + p.next0(); + if (p.tok === 2) { + comment = ($ptrType(ast.CommentGroup)).nil; + endline = 0; + if (p.file.Line(p.pos) === p.file.Line(prev)) { + _tuple = p.consumeCommentGroup(0); comment = _tuple[0]; endline = _tuple[1]; + if (!((p.file.Line(p.pos) === endline))) { + p.lineComment = comment; + } + } + endline = -1; + while (p.tok === 2) { + _tuple$1 = p.consumeCommentGroup(1); comment = _tuple$1[0]; endline = _tuple$1[1]; + } + if ((endline + 1 >> 0) === p.file.Line(p.pos)) { + p.leadComment = comment; + } } }; - Checker.prototype.reportAltDecl = function(obj) { return this.$val.reportAltDecl(obj); }; - Checker.Ptr.prototype.declare = function(scope, id, obj) { - var check, alt; - check = this; - if (!(obj.Name() === "_")) { - alt = scope.Insert(obj); - if (!($interfaceIsEqual(alt, $ifaceNil))) { - check.errorf(obj.Pos(), "%s redeclared in this block", new ($sliceType($emptyInterface))([new $String(obj.Name())])); - check.reportAltDecl(alt); + parser.prototype.next = function() { return this.$val.next(); }; + parser.Ptr.prototype.error = function(pos, msg) { + var p, epos, n, x, x$1, x$2; + p = this; + epos = new token.Position.Ptr(); $copy(epos, p.file.Position(pos), token.Position); + if (((p.mode & 32) >>> 0) === 0) { + n = p.errors.$length; + if (n > 0 && ((x = p.errors, x$1 = n - 1 >> 0, ((x$1 < 0 || x$1 >= x.$length) ? $throwRuntimeError("index out of range") : x.$array[x.$offset + x$1])).Pos.Line === epos.Line)) { return; } + if (n > 10) { + $panic((x$2 = new bailout.Ptr(), new x$2.constructor.Struct(x$2))); + } } - if (!(id === ($ptrType(ast.Ident)).nil)) { - check.recordDef(id, obj); - } + new ($ptrType(scanner.ErrorList))(function() { return this.$target.errors; }, function($v) { this.$target.errors = $v; }, p).Add($clone(epos, token.Position), msg); }; - Checker.prototype.declare = function(scope, id, obj) { return this.$val.declare(scope, id, obj); }; - Checker.Ptr.prototype.objDecl = function(obj, def$1, path$1) { - var $deferred = [], $err = null, check, _entry, d, obj$1, _ref; - /* */ try { $deferFrames.push($deferred); - check = this; - if (!($interfaceIsEqual(obj.Type(), $ifaceNil))) { - return; - } - d = (_entry = check.objMap[obj.$key()], _entry !== undefined ? _entry.v : ($ptrType(declInfo)).nil); - if (d === ($ptrType(declInfo)).nil) { - check.dump("%s: %s should have been declared", new ($sliceType($emptyInterface))([new token.Pos(obj.Pos()), new $String(obj.Name())])); - unreachable(); - } - $deferred.push([(function(ctxt) { - $copy(check.context, ctxt, context); - }), [$clone(check.context, context)]]); - $copy(check.context, new context.Ptr(($ptrType(declInfo)).nil, d.file, $ifaceNil, ($ptrType(Signature)).nil, false, false), context); - _ref = obj; - if ($assertType(_ref, ($ptrType(Const)), true)[1]) { - obj$1 = _ref.$val; - check.context.decl = d; - check.constDecl(obj$1, d.typ, d.init); - } else if ($assertType(_ref, ($ptrType(Var)), true)[1]) { - obj$1 = _ref.$val; - check.context.decl = d; - check.varDecl(obj$1, d.lhs, d.typ, d.init); - } else if ($assertType(_ref, ($ptrType(TypeName)), true)[1]) { - obj$1 = _ref.$val; - check.typeDecl(obj$1, d.typ, def$1, path$1); - } else if ($assertType(_ref, ($ptrType(Func)), true)[1]) { - obj$1 = _ref.$val; - check.funcDecl(obj$1, d); - } else { - obj$1 = _ref; - unreachable(); + parser.prototype.error = function(pos, msg) { return this.$val.error(pos, msg); }; + parser.Ptr.prototype.errorExpected = function(pos, msg) { + var p; + p = this; + msg = "expected " + msg; + if (pos === p.pos) { + if ((p.tok === 57) && p.lit === "\n") { + msg = msg + (", found newline"); + } else { + msg = msg + (", found '" + (new token.Token(p.tok)).String() + "'"); + if ((new token.Token(p.tok)).IsLiteral()) { + msg = msg + (" " + p.lit); + } + } } - /* */ } catch(err) { $err = err; } finally { $deferFrames.pop(); $callDeferred($deferred, $err); } + p.error(pos, msg); }; - Checker.prototype.objDecl = function(obj, def$1, path$1) { return this.$val.objDecl(obj, def$1, path$1); }; - Checker.Ptr.prototype.constDecl = function(obj, typ, init$1) { - var $deferred = [], $err = null, check, t, x; - /* */ try { $deferFrames.push($deferred); - check = this; - assert($interfaceIsEqual(obj.object.typ, $ifaceNil)); - if (obj.visited) { - obj.object.typ = $pkg.Typ[0]; - return; - } - obj.visited = true; - assert($interfaceIsEqual(check.context.iota, $ifaceNil)); - check.context.iota = obj.val; - $deferred.push([(function() { - check.context.iota = $ifaceNil; - }), []]); - obj.val = exact.MakeUnknown(); - if (!($interfaceIsEqual(typ, $ifaceNil))) { - t = check.typ(typ); - if (!isConstType(t)) { - check.errorf(typ.Pos(), "invalid constant type %s", new ($sliceType($emptyInterface))([t])); - obj.object.typ = $pkg.Typ[0]; - return; - } - obj.object.typ = t; + parser.prototype.errorExpected = function(pos, msg) { return this.$val.errorExpected(pos, msg); }; + parser.Ptr.prototype.expect = function(tok) { + var p, pos; + p = this; + pos = p.pos; + if (!((p.tok === tok))) { + p.errorExpected(pos, "'" + (new token.Token(tok)).String() + "'"); } - x = new operand.Ptr(); $copy(x, new operand.Ptr(), operand); - if (!($interfaceIsEqual(init$1, $ifaceNil))) { - check.expr(x, init$1); + p.next(); + return pos; + }; + parser.prototype.expect = function(tok) { return this.$val.expect(tok); }; + parser.Ptr.prototype.expectClosing = function(tok, context) { + var p; + p = this; + if (!((p.tok === tok)) && (p.tok === 57) && p.lit === "\n") { + p.error(p.pos, "missing ',' before newline in " + context); + p.next(); } - check.initConst(obj, x); - /* */ } catch(err) { $err = err; } finally { $deferFrames.pop(); $callDeferred($deferred, $err); } + return p.expect(tok); }; - Checker.prototype.constDecl = function(obj, typ, init$1) { return this.$val.constDecl(obj, typ, init$1); }; - Checker.Ptr.prototype.varDecl = function(obj, lhs, typ, init$1) { - var check, x; - check = this; - assert($interfaceIsEqual(obj.object.typ, $ifaceNil)); - if (obj.visited) { - obj.object.typ = $pkg.Typ[0]; - return; + parser.prototype.expectClosing = function(tok, context) { return this.$val.expectClosing(tok, context); }; + parser.Ptr.prototype.expectSemi = function() { + var p; + p = this; + if (!((p.tok === 54)) && !((p.tok === 56))) { + if (p.tok === 57) { + p.next(); + } else { + p.errorExpected(p.pos, "';'"); + syncStmt(p); + } } - obj.visited = true; - assert($interfaceIsEqual(check.context.iota, $ifaceNil)); - if (!($interfaceIsEqual(typ, $ifaceNil))) { - obj.object.typ = check.typ(typ); + }; + parser.prototype.expectSemi = function() { return this.$val.expectSemi(); }; + parser.Ptr.prototype.atComma = function(context) { + var p; + p = this; + if (p.tok === 52) { + return true; } - if ($interfaceIsEqual(init$1, $ifaceNil)) { - if ($interfaceIsEqual(typ, $ifaceNil)) { - obj.object.typ = $pkg.Typ[0]; - } - return; + if ((p.tok === 57) && p.lit === "\n") { + p.error(p.pos, "missing ',' before newline in " + context); + return true; } - if (lhs === ($sliceType(($ptrType(Var)))).nil || (lhs.$length === 1)) { - assert(lhs === ($sliceType(($ptrType(Var)))).nil || ((0 < 0 || 0 >= lhs.$length) ? $throwRuntimeError("index out of range") : lhs.$array[lhs.$offset + 0]) === obj); - x = new operand.Ptr(); $copy(x, new operand.Ptr(), operand); - check.expr(x, init$1); - check.initVar(obj, x, false); - return; + return false; + }; + parser.prototype.atComma = function(context) { return this.$val.atComma(context); }; + assert = function(cond, msg) { + if (!cond) { + $panic(new $String("go/parser internal error: " + msg)); } - check.initVars(lhs, new ($sliceType(ast.Expr))([init$1]), 0); }; - Checker.prototype.varDecl = function(obj, lhs, typ, init$1) { return this.$val.varDecl(obj, lhs, typ, init$1); }; - underlying = function(typ) { - var _tuple, n; + syncStmt = function(p) { + var _ref; while (true) { - _tuple = $assertType(typ, ($ptrType(Named)), true); n = _tuple[0]; - if (n === ($ptrType(Named)).nil) { - break; + _ref = p.tok; + if (_ref === 61 || _ref === 64 || _ref === 65 || _ref === 67 || _ref === 69 || _ref === 70 || _ref === 72 || _ref === 73 || _ref === 74 || _ref === 80 || _ref === 81 || _ref === 83 || _ref === 84 || _ref === 85) { + if ((p.pos === p.syncPos) && p.syncCnt < 10) { + p.syncCnt = p.syncCnt + (1) >> 0; + return; + } + if (p.pos > p.syncPos) { + p.syncPos = p.pos; + p.syncCnt = 0; + return; + } + } else if (_ref === 1) { + return; } - typ = n.underlying; + p.next(); } - return typ; }; - Named.Ptr.prototype.setUnderlying = function(typ) { - var n; - n = this; - if (!(n === ($ptrType(Named)).nil)) { - n.underlying = typ; + syncDecl = function(p) { + var _ref; + while (true) { + _ref = p.tok; + if (_ref === 64 || _ref === 84 || _ref === 85) { + if ((p.pos === p.syncPos) && p.syncCnt < 10) { + p.syncCnt = p.syncCnt + (1) >> 0; + return; + } + if (p.pos > p.syncPos) { + p.syncPos = p.pos; + p.syncCnt = 0; + return; + } + } else if (_ref === 1) { + return; + } + p.next(); } }; - Named.prototype.setUnderlying = function(typ) { return this.$val.setUnderlying(typ); }; - Checker.Ptr.prototype.typeDecl = function(obj, typ, def$1, path$1) { - var check, named; - check = this; - assert($interfaceIsEqual(obj.object.typ, $ifaceNil)); - assert($interfaceIsEqual(check.context.iota, $ifaceNil)); - named = new Named.Ptr(obj, $ifaceNil, ($sliceType(($ptrType(Func)))).nil); - def$1.setUnderlying(named); - obj.object.typ = named; - check.typExpr(typ, named, $append(path$1, obj)); - named.underlying = underlying(named.underlying); - check.addMethodDecls(obj); - }; - Checker.prototype.typeDecl = function(obj, typ, def$1, path$1) { return this.$val.typeDecl(obj, typ, def$1, path$1); }; - Checker.Ptr.prototype.addMethodDecls = function(obj) { - var check, _entry, methods, mset, base, _tuple, t, _ref, _i, fld, _ref$1, _i$1, m, _ref$2, _i$2, m$1, alt, _ref$3; - check = this; - methods = (_entry = check.methods[obj.object.name], _entry !== undefined ? _entry.v : ($sliceType(($ptrType(Func)))).nil); - if (methods.$length === 0) { - return; - } - delete check.methods[obj.object.name]; - mset = false; - base = $assertType(obj.object.typ, ($ptrType(Named))); - _tuple = $assertType(base.underlying, ($ptrType(Struct)), true); t = _tuple[0]; - if (!(t === ($ptrType(Struct)).nil)) { - _ref = t.fields; - _i = 0; - while (_i < _ref.$length) { - fld = ((_i < 0 || _i >= _ref.$length) ? $throwRuntimeError("index out of range") : _ref.$array[_ref.$offset + _i]); - if (!(fld.object.name === "_")) { - assert($interfaceIsEqual(new ($ptrType(objset))(function() { return mset; }, function($v) { mset = $v; }).insert(fld), $ifaceNil)); - } - _i++; + parser.Ptr.prototype.safePos = function(pos) { + var res = 0, $deferred = [], $err = null, p; + /* */ try { $deferFrames.push($deferred); + p = this; + $deferred.push([(function() { + if (!($interfaceIsEqual($recover(), $ifaceNil))) { + res = ((p.file.Base() + p.file.Size() >> 0) >> 0); } + }), []]); + p.file.Offset(pos); + res = pos; + return res; + /* */ } catch(err) { $err = err; } finally { $deferFrames.pop(); $callDeferred($deferred, $err); return res; } + }; + parser.prototype.safePos = function(pos) { return this.$val.safePos(pos); }; + parser.Ptr.prototype.parseIdent = function() { + var p, pos, name; + p = this; + pos = p.pos; + name = "_"; + if (p.tok === 4) { + name = p.lit; + p.next(); + } else { + p.expect(4); } - _ref$1 = base.methods; - _i$1 = 0; - while (_i$1 < _ref$1.$length) { - m = ((_i$1 < 0 || _i$1 >= _ref$1.$length) ? $throwRuntimeError("index out of range") : _ref$1.$array[_ref$1.$offset + _i$1]); - assert(!(m.object.name === "_")); - assert($interfaceIsEqual(new ($ptrType(objset))(function() { return mset; }, function($v) { mset = $v; }).insert(m), $ifaceNil)); - _i$1++; + return new ast.Ident.Ptr(pos, name, ($ptrType(ast.Object)).nil); + }; + parser.prototype.parseIdent = function() { return this.$val.parseIdent(); }; + parser.Ptr.prototype.parseIdentList = function() { + var list = ($sliceType(($ptrType(ast.Ident)))).nil, $deferred = [], $err = null, p; + /* */ try { $deferFrames.push($deferred); + p = this; + if (p.trace) { + $deferred.push([un, [trace(p, "IdentList")]]); } - _ref$2 = methods; - _i$2 = 0; - while (_i$2 < _ref$2.$length) { - m$1 = ((_i$2 < 0 || _i$2 >= _ref$2.$length) ? $throwRuntimeError("index out of range") : _ref$2.$array[_ref$2.$offset + _i$2]); - if (!(m$1.object.name === "_")) { - alt = new ($ptrType(objset))(function() { return mset; }, function($v) { mset = $v; }).insert(m$1); - if (!($interfaceIsEqual(alt, $ifaceNil))) { - _ref$3 = alt; - if ($assertType(_ref$3, ($ptrType(Var)), true)[1]) { - check.errorf(m$1.object.pos, "field and method with the same name %s", new ($sliceType($emptyInterface))([new $String(m$1.object.name)])); - } else if ($assertType(_ref$3, ($ptrType(Func)), true)[1]) { - check.errorf(m$1.object.pos, "method %s already declared for %s", new ($sliceType($emptyInterface))([new $String(m$1.object.name), base])); - } else { - unreachable(); - } - check.reportAltDecl(alt); - _i$2++; - continue; - } - } - check.objDecl(m$1, ($ptrType(Named)).nil, ($sliceType(($ptrType(TypeName)))).nil); - if (!(m$1.object.name === "_")) { - base.methods = $append(base.methods, m$1); - } - _i$2++; + list = $append(list, p.parseIdent()); + while (p.tok === 52) { + p.next(); + list = $append(list, p.parseIdent()); } + return list; + /* */ } catch(err) { $err = err; } finally { $deferFrames.pop(); $callDeferred($deferred, $err); return list; } }; - Checker.prototype.addMethodDecls = function(obj) { return this.$val.addMethodDecls(obj); }; - Checker.Ptr.prototype.funcDecl = function(obj, decl) { - var check, sig, fdecl; - check = this; - assert($interfaceIsEqual(obj.object.typ, $ifaceNil)); - assert($interfaceIsEqual(check.context.iota, $ifaceNil)); - sig = new Signature.Ptr(); - obj.object.typ = sig; - fdecl = decl.fdecl; - check.funcType(sig, fdecl.Recv, fdecl.Type); - if (sig.recv === ($ptrType(Var)).nil && obj.object.name === "init" && (sig.params.Len() > 0 || sig.results.Len() > 0)) { - check.errorf(fdecl.Pos(), "func init must have no arguments and no return values", new ($sliceType($emptyInterface))([])); + parser.prototype.parseIdentList = function() { return this.$val.parseIdentList(); }; + parser.Ptr.prototype.parseExprList = function(lhs) { + var list = ($sliceType(ast.Expr)).nil, $deferred = [], $err = null, p; + /* */ try { $deferFrames.push($deferred); + p = this; + if (p.trace) { + $deferred.push([un, [trace(p, "ExpressionList")]]); } - if (!check.conf.IgnoreFuncBodies && !(fdecl.Body === ($ptrType(ast.BlockStmt)).nil)) { - check.later(obj.object.name, decl, sig, fdecl.Body); + list = $append(list, p.checkExpr(p.parseExpr(lhs))); + while (p.tok === 52) { + p.next(); + list = $append(list, p.checkExpr(p.parseExpr(lhs))); } + return list; + /* */ } catch(err) { $err = err; } finally { $deferFrames.pop(); $callDeferred($deferred, $err); return list; } }; - Checker.prototype.funcDecl = function(obj, decl) { return this.$val.funcDecl(obj, decl); }; - Checker.Ptr.prototype.declStmt = function(decl) { - var check, pkg, d, _ref, last, _ref$1, _i, iota, spec, s, _ref$2, _ref$3, lhs, _ref$4, _i$1, i, name, obj, init$1, x, _ref$5, _i$2, i$1, name$1, lhs0, _ref$6, _i$3, i$2, name$2, _ref$7, _i$4, i$3, obj$1, lhs$1, init$2, _ref$8, x$1, x$2, x$3, _ref$9, _i$5, i$4, name$3, obj$2; - check = this; - pkg = check.pkg; - _ref = decl; - if ($assertType(_ref, ($ptrType(ast.BadDecl)), true)[1]) { - d = _ref.$val; - } else if ($assertType(_ref, ($ptrType(ast.GenDecl)), true)[1]) { - d = _ref.$val; - last = ($ptrType(ast.ValueSpec)).nil; - _ref$1 = d.Specs; + parser.prototype.parseExprList = function(lhs) { return this.$val.parseExprList(lhs); }; + parser.Ptr.prototype.parseLhsList = function() { + var p, old, list, _ref, _ref$1, _i, x; + p = this; + old = p.inRhs; + p.inRhs = false; + list = p.parseExprList(true); + _ref = p.tok; + if (_ref === 47) { + } else if (_ref === 58) { + } else { + _ref$1 = list; _i = 0; while (_i < _ref$1.$length) { - iota = _i; - spec = ((_i < 0 || _i >= _ref$1.$length) ? $throwRuntimeError("index out of range") : _ref$1.$array[_ref$1.$offset + _i]); - _ref$2 = spec; - if ($assertType(_ref$2, ($ptrType(ast.ValueSpec)), true)[1]) { - s = _ref$2.$val; - _ref$3 = d.Tok; - if (_ref$3 === 64) { - if (!($interfaceIsEqual(s.Type, $ifaceNil)) || s.Values.$length > 0) { - last = s; - } else if (last === ($ptrType(ast.ValueSpec)).nil) { - last = new ast.ValueSpec.Ptr(); - } - lhs = ($sliceType(($ptrType(Const)))).make(s.Names.$length); - _ref$4 = s.Names; - _i$1 = 0; - while (_i$1 < _ref$4.$length) { - i = _i$1; - name = ((_i$1 < 0 || _i$1 >= _ref$4.$length) ? $throwRuntimeError("index out of range") : _ref$4.$array[_ref$4.$offset + _i$1]); - obj = NewConst(name.Pos(), pkg, name.Name, $ifaceNil, exact.MakeInt64(new $Int64(0, iota))); - (i < 0 || i >= lhs.$length) ? $throwRuntimeError("index out of range") : lhs.$array[lhs.$offset + i] = obj; - init$1 = $ifaceNil; - if (i < last.Values.$length) { - init$1 = (x = last.Values, ((i < 0 || i >= x.$length) ? $throwRuntimeError("index out of range") : x.$array[x.$offset + i])); - } - check.constDecl(obj, last.Type, init$1); - _i$1++; - } - check.arityMatch(s, last); - _ref$5 = s.Names; - _i$2 = 0; - while (_i$2 < _ref$5.$length) { - i$1 = _i$2; - name$1 = ((_i$2 < 0 || _i$2 >= _ref$5.$length) ? $throwRuntimeError("index out of range") : _ref$5.$array[_ref$5.$offset + _i$2]); - check.declare(check.context.scope, name$1, ((i$1 < 0 || i$1 >= lhs.$length) ? $throwRuntimeError("index out of range") : lhs.$array[lhs.$offset + i$1])); - _i$2++; - } - } else if (_ref$3 === 85) { - lhs0 = ($sliceType(($ptrType(Var)))).make(s.Names.$length); - _ref$6 = s.Names; - _i$3 = 0; - while (_i$3 < _ref$6.$length) { - i$2 = _i$3; - name$2 = ((_i$3 < 0 || _i$3 >= _ref$6.$length) ? $throwRuntimeError("index out of range") : _ref$6.$array[_ref$6.$offset + _i$3]); - (i$2 < 0 || i$2 >= lhs0.$length) ? $throwRuntimeError("index out of range") : lhs0.$array[lhs0.$offset + i$2] = NewVar(name$2.Pos(), pkg, name$2.Name, $ifaceNil); - _i$3++; - } - _ref$7 = lhs0; - _i$4 = 0; - while (_i$4 < _ref$7.$length) { - i$3 = _i$4; - obj$1 = ((_i$4 < 0 || _i$4 >= _ref$7.$length) ? $throwRuntimeError("index out of range") : _ref$7.$array[_ref$7.$offset + _i$4]); - lhs$1 = ($sliceType(($ptrType(Var)))).nil; - init$2 = $ifaceNil; - _ref$8 = s.Values.$length; - if (_ref$8 === s.Names.$length) { - init$2 = (x$1 = s.Values, ((i$3 < 0 || i$3 >= x$1.$length) ? $throwRuntimeError("index out of range") : x$1.$array[x$1.$offset + i$3])); - } else if (_ref$8 === 1) { - lhs$1 = lhs0; - init$2 = (x$2 = s.Values, ((0 < 0 || 0 >= x$2.$length) ? $throwRuntimeError("index out of range") : x$2.$array[x$2.$offset + 0])); - } else { - if (i$3 < s.Values.$length) { - init$2 = (x$3 = s.Values, ((i$3 < 0 || i$3 >= x$3.$length) ? $throwRuntimeError("index out of range") : x$3.$array[x$3.$offset + i$3])); - } - } - check.varDecl(obj$1, lhs$1, s.Type, init$2); - if (s.Values.$length === 1) { - break; - } - _i$4++; - } - check.arityMatch(s, ($ptrType(ast.ValueSpec)).nil); - _ref$9 = s.Names; - _i$5 = 0; - while (_i$5 < _ref$9.$length) { - i$4 = _i$5; - name$3 = ((_i$5 < 0 || _i$5 >= _ref$9.$length) ? $throwRuntimeError("index out of range") : _ref$9.$array[_ref$9.$offset + _i$5]); - check.declare(check.context.scope, name$3, ((i$4 < 0 || i$4 >= lhs0.$length) ? $throwRuntimeError("index out of range") : lhs0.$array[lhs0.$offset + i$4])); - _i$5++; - } - } else { - check.invalidAST(s.Pos(), "invalid token %s", new ($sliceType($emptyInterface))([new token.Token(d.Tok)])); - } - } else if ($assertType(_ref$2, ($ptrType(ast.TypeSpec)), true)[1]) { - s = _ref$2.$val; - obj$2 = NewTypeName(s.Name.Pos(), pkg, s.Name.Name, $ifaceNil); - check.declare(check.context.scope, s.Name, obj$2); - check.typeDecl(obj$2, s.Type, ($ptrType(Named)).nil, ($sliceType(($ptrType(TypeName)))).nil); - } else { - s = _ref$2; - check.invalidAST(s.Pos(), "const, type, or var declaration expected", new ($sliceType($emptyInterface))([])); - } + x = ((_i < 0 || _i >= _ref$1.$length) ? $throwRuntimeError("index out of range") : _ref$1.$array[_ref$1.$offset + _i]); + p.resolve(x); _i++; } - } else { - d = _ref; - check.invalidAST(d.Pos(), "unknown ast.Decl node %T", new ($sliceType($emptyInterface))([d])); } + p.inRhs = old; + return list; }; - Checker.prototype.declStmt = function(decl) { return this.$val.declStmt(decl); }; - assert = function(p) { - if (!p) { - $panic(new $String("assertion failed")); + parser.prototype.parseLhsList = function() { return this.$val.parseLhsList(); }; + parser.Ptr.prototype.parseRhsList = function() { + var p, old, list; + p = this; + old = p.inRhs; + p.inRhs = true; + list = p.parseExprList(false); + p.inRhs = old; + return list; + }; + parser.prototype.parseRhsList = function() { return this.$val.parseRhsList(); }; + parser.Ptr.prototype.parseType = function() { + var $deferred = [], $err = null, p, typ, pos; + /* */ try { $deferFrames.push($deferred); + p = this; + if (p.trace) { + $deferred.push([un, [trace(p, "Type")]]); } + typ = p.tryType(); + if ($interfaceIsEqual(typ, $ifaceNil)) { + pos = p.pos; + p.errorExpected(pos, "type"); + p.next(); + return new ast.BadExpr.Ptr(pos, p.pos); + } + return typ; + /* */ } catch(err) { $err = err; return $ifaceNil; } finally { $deferFrames.pop(); $callDeferred($deferred, $err); } }; - unreachable = function() { - $panic(new $String("unreachable")); + parser.prototype.parseType = function() { return this.$val.parseType(); }; + parser.Ptr.prototype.parseTypeName = function() { + var $deferred = [], $err = null, p, ident, sel; + /* */ try { $deferFrames.push($deferred); + p = this; + if (p.trace) { + $deferred.push([un, [trace(p, "TypeName")]]); + } + ident = p.parseIdent(); + if (p.tok === 53) { + p.next(); + p.resolve(ident); + sel = p.parseIdent(); + return new ast.SelectorExpr.Ptr(ident, sel); + } + return ident; + /* */ } catch(err) { $err = err; return $ifaceNil; } finally { $deferFrames.pop(); $callDeferred($deferred, $err); } }; - Checker.Ptr.prototype.sprintf = function(format, args) { - var check, _ref, _i, i, arg, a, _ref$1; - check = this; - _ref = args; + parser.prototype.parseTypeName = function() { return this.$val.parseTypeName(); }; + parser.Ptr.prototype.parseArrayType = function() { + var $deferred = [], $err = null, p, lbrack, len, elt; + /* */ try { $deferFrames.push($deferred); + p = this; + if (p.trace) { + $deferred.push([un, [trace(p, "ArrayType")]]); + } + lbrack = p.expect(50); + len = $ifaceNil; + if (p.tok === 48) { + len = new ast.Ellipsis.Ptr(p.pos, $ifaceNil); + p.next(); + } else if (!((p.tok === 55))) { + len = p.parseRhs(); + } + p.expect(55); + elt = p.parseType(); + return new ast.ArrayType.Ptr(lbrack, len, elt); + /* */ } catch(err) { $err = err; return $ifaceNil; } finally { $deferFrames.pop(); $callDeferred($deferred, $err); } + }; + parser.prototype.parseArrayType = function() { return this.$val.parseArrayType(); }; + parser.Ptr.prototype.makeIdentList = function(list) { + var p, idents, _ref, _i, i, x, _tuple, ident, isIdent, _tuple$1, isBad; + p = this; + idents = ($sliceType(($ptrType(ast.Ident)))).make(list.$length); + _ref = list; _i = 0; while (_i < _ref.$length) { i = _i; - arg = ((_i < 0 || _i >= _ref.$length) ? $throwRuntimeError("index out of range") : _ref.$array[_ref.$offset + _i]); - _ref$1 = arg; - if (_ref$1 === $ifaceNil) { - a = _ref$1; - arg = new $String(""); - } else if ($assertType(_ref$1, operand, true)[1]) { - a = _ref$1.$val; - $panic(new $String("internal error: should always pass *operand")); - } else if ($assertType(_ref$1, ($ptrType(operand)), true)[1]) { - a = _ref$1.$val; - arg = new $String(operandString(check.pkg, a)); - } else if ($assertType(_ref$1, token.Pos, true)[1]) { - a = _ref$1.$val; - arg = new $String(check.fset.Position(a).String()); - } else if ($assertType(_ref$1, ast.Expr, true)[1]) { - a = _ref$1; - arg = new $String(ExprString(a)); - } else if ($assertType(_ref$1, Object, true)[1]) { - a = _ref$1; - arg = new $String(ObjectString(check.pkg, a)); - } else if ($assertType(_ref$1, Type, true)[1]) { - a = _ref$1; - arg = new $String(TypeString(check.pkg, a)); + x = ((_i < 0 || _i >= _ref.$length) ? $throwRuntimeError("index out of range") : _ref.$array[_ref.$offset + _i]); + _tuple = $assertType(x, ($ptrType(ast.Ident)), true); ident = _tuple[0]; isIdent = _tuple[1]; + if (!isIdent) { + _tuple$1 = $assertType(x, ($ptrType(ast.BadExpr)), true); isBad = _tuple$1[1]; + if (!isBad) { + p.errorExpected(x.Pos(), "identifier"); + } + ident = new ast.Ident.Ptr(x.Pos(), "_", ($ptrType(ast.Object)).nil); } - (i < 0 || i >= args.$length) ? $throwRuntimeError("index out of range") : args.$array[args.$offset + i] = arg; + (i < 0 || i >= idents.$length) ? $throwRuntimeError("index out of range") : idents.$array[idents.$offset + i] = ident; _i++; } - return fmt.Sprintf(format, args); - }; - Checker.prototype.sprintf = function(format, args) { return this.$val.sprintf(format, args); }; - Checker.Ptr.prototype.dump = function(format, args) { - var check; - check = this; - fmt.Println(new ($sliceType($emptyInterface))([new $String(check.sprintf(format, args))])); + return idents; }; - Checker.prototype.dump = function(format, args) { return this.$val.dump(format, args); }; - Checker.Ptr.prototype.err = function(pos, msg, soft) { - var check, err, f, x; - check = this; - err = new Error.Ptr(check.fset, pos, msg, soft); - if ($interfaceIsEqual(check.firstErr, $ifaceNil)) { - check.firstErr = new err.constructor.Struct(err); + parser.prototype.makeIdentList = function(list) { return this.$val.makeIdentList(list); }; + parser.Ptr.prototype.parseFieldDecl = function(scope) { + var $deferred = [], $err = null, p, doc, _tuple, list, typ, tag, idents, n, pos, x, field; + /* */ try { $deferFrames.push($deferred); + p = this; + if (p.trace) { + $deferred.push([un, [trace(p, "FieldDecl")]]); + } + doc = p.leadComment; + _tuple = p.parseVarList(false); list = _tuple[0]; typ = _tuple[1]; + tag = ($ptrType(ast.BasicLit)).nil; + if (p.tok === 9) { + tag = new ast.BasicLit.Ptr(p.pos, p.tok, p.lit); + p.next(); } - f = check.conf.Error; - if (f === $throwNilPointerError) { - $panic((x = new bailout.Ptr(), new x.constructor.Struct(x))); + idents = ($sliceType(($ptrType(ast.Ident)))).nil; + if (!($interfaceIsEqual(typ, $ifaceNil))) { + idents = p.makeIdentList(list); + } else { + typ = ((0 < 0 || 0 >= list.$length) ? $throwRuntimeError("index out of range") : list.$array[list.$offset + 0]); + n = list.$length; + if (n > 1 || !isTypeName(deref(typ))) { + pos = typ.Pos(); + p.errorExpected(pos, "anonymous field"); + typ = new ast.BadExpr.Ptr(pos, p.safePos((x = n - 1 >> 0, ((x < 0 || x >= list.$length) ? $throwRuntimeError("index out of range") : list.$array[list.$offset + x])).End())); + } } - f(new err.constructor.Struct(err)); - }; - Checker.prototype.err = function(pos, msg, soft) { return this.$val.err(pos, msg, soft); }; - Checker.Ptr.prototype.error = function(pos, msg) { - var check; - check = this; - check.err(pos, msg, false); - }; - Checker.prototype.error = function(pos, msg) { return this.$val.error(pos, msg); }; - Checker.Ptr.prototype.errorf = function(pos, format, args) { - var check; - check = this; - check.err(pos, check.sprintf(format, args), false); + p.expectSemi(); + field = new ast.Field.Ptr(doc, idents, typ, tag, p.lineComment); + p.declare(field, $ifaceNil, scope, 4, idents); + p.resolve(typ); + return field; + /* */ } catch(err) { $err = err; return ($ptrType(ast.Field)).nil; } finally { $deferFrames.pop(); $callDeferred($deferred, $err); } }; - Checker.prototype.errorf = function(pos, format, args) { return this.$val.errorf(pos, format, args); }; - Checker.Ptr.prototype.softErrorf = function(pos, format, args) { - var check; - check = this; - check.err(pos, check.sprintf(format, args), true); + parser.prototype.parseFieldDecl = function(scope) { return this.$val.parseFieldDecl(scope); }; + parser.Ptr.prototype.parseStructType = function() { + var $deferred = [], $err = null, p, pos, lbrace, scope, list, rbrace; + /* */ try { $deferFrames.push($deferred); + p = this; + if (p.trace) { + $deferred.push([un, [trace(p, "StructType")]]); + } + pos = p.expect(82); + lbrace = p.expect(51); + scope = ast.NewScope(($ptrType(ast.Scope)).nil); + list = ($sliceType(($ptrType(ast.Field)))).nil; + while ((p.tok === 4) || (p.tok === 14) || (p.tok === 49)) { + list = $append(list, p.parseFieldDecl(scope)); + } + rbrace = p.expect(56); + return new ast.StructType.Ptr(pos, new ast.FieldList.Ptr(lbrace, list, rbrace), false); + /* */ } catch(err) { $err = err; return ($ptrType(ast.StructType)).nil; } finally { $deferFrames.pop(); $callDeferred($deferred, $err); } }; - Checker.prototype.softErrorf = function(pos, format, args) { return this.$val.softErrorf(pos, format, args); }; - Checker.Ptr.prototype.invalidAST = function(pos, format, args) { - var check; - check = this; - check.errorf(pos, "invalid AST: " + format, args); + parser.prototype.parseStructType = function() { return this.$val.parseStructType(); }; + parser.Ptr.prototype.parsePointerType = function() { + var $deferred = [], $err = null, p, star, base; + /* */ try { $deferFrames.push($deferred); + p = this; + if (p.trace) { + $deferred.push([un, [trace(p, "PointerType")]]); + } + star = p.expect(14); + base = p.parseType(); + return new ast.StarExpr.Ptr(star, base); + /* */ } catch(err) { $err = err; return ($ptrType(ast.StarExpr)).nil; } finally { $deferFrames.pop(); $callDeferred($deferred, $err); } }; - Checker.prototype.invalidAST = function(pos, format, args) { return this.$val.invalidAST(pos, format, args); }; - Checker.Ptr.prototype.invalidArg = function(pos, format, args) { - var check; - check = this; - check.errorf(pos, "invalid argument: " + format, args); + parser.prototype.parsePointerType = function() { return this.$val.parsePointerType(); }; + parser.Ptr.prototype.tryVarType = function(isParam) { + var p, pos, typ; + p = this; + if (isParam && (p.tok === 48)) { + pos = p.pos; + p.next(); + typ = p.tryIdentOrType(); + if (!($interfaceIsEqual(typ, $ifaceNil))) { + p.resolve(typ); + } else { + p.error(pos, "'...' parameter is missing type"); + typ = new ast.BadExpr.Ptr(pos, p.pos); + } + return new ast.Ellipsis.Ptr(pos, typ); + } + return p.tryIdentOrType(); }; - Checker.prototype.invalidArg = function(pos, format, args) { return this.$val.invalidArg(pos, format, args); }; - Checker.Ptr.prototype.invalidOp = function(pos, format, args) { - var check; - check = this; - check.errorf(pos, "invalid operation: " + format, args); + parser.prototype.tryVarType = function(isParam) { return this.$val.tryVarType(isParam); }; + parser.Ptr.prototype.parseVarType = function(isParam) { + var p, typ, pos; + p = this; + typ = p.tryVarType(isParam); + if ($interfaceIsEqual(typ, $ifaceNil)) { + pos = p.pos; + p.errorExpected(pos, "type"); + p.next(); + typ = new ast.BadExpr.Ptr(pos, p.pos); + } + return typ; }; - Checker.prototype.invalidOp = function(pos, format, args) { return this.$val.invalidOp(pos, format, args); }; - Checker.Ptr.prototype.op = function(m, x, op) { - var check, _entry, pred; - check = this; - pred = (_entry = m[op], _entry !== undefined ? _entry.v : $throwNilPointerError); - if (!(pred === $throwNilPointerError)) { - if (!pred(x.typ)) { - check.invalidOp(x.pos(), "operator %s not defined for %s", new ($sliceType($emptyInterface))([new token.Token(op), x])); - return false; + parser.prototype.parseVarType = function(isParam) { return this.$val.parseVarType(isParam); }; + parser.Ptr.prototype.parseVarList = function(isParam) { + var list = ($sliceType(ast.Expr)).nil, typ = $ifaceNil, $deferred = [], $err = null, p, typ$1; + /* */ try { $deferFrames.push($deferred); + p = this; + if (p.trace) { + $deferred.push([un, [trace(p, "VarList")]]); + } + typ$1 = p.parseVarType(isParam); + while (!($interfaceIsEqual(typ$1, $ifaceNil))) { + list = $append(list, typ$1); + if (!((p.tok === 52))) { + break; } - } else { - check.invalidAST(x.pos(), "unknown operator %s", new ($sliceType($emptyInterface))([new token.Token(op)])); - return false; + p.next(); + typ$1 = p.tryVarType(isParam); } - return true; + typ = p.tryVarType(isParam); + return [list, typ]; + /* */ } catch(err) { $err = err; } finally { $deferFrames.pop(); $callDeferred($deferred, $err); return [list, typ]; } }; - Checker.prototype.op = function(m, x, op) { return this.$val.op(m, x, op); }; - Checker.Ptr.prototype.unary = function(x, op) { - var check, _ref, _tuple, ok, _tuple$1, typ, ok$1, typ$1, size, x$1; - check = this; - _ref = op; - if (_ref === 17) { - _tuple = $assertType(unparen(x.expr), ($ptrType(ast.CompositeLit)), true); ok = _tuple[1]; - if (!ok && !((x.mode === 5))) { - check.invalidOp(x.pos(), "cannot take address of %s", new ($sliceType($emptyInterface))([x])); - x.mode = 0; - return; + parser.prototype.parseVarList = function(isParam) { return this.$val.parseVarList(isParam); }; + parser.Ptr.prototype.parseParameterList = function(scope, ellipsisOk) { + var params = ($sliceType(($ptrType(ast.Field)))).nil, $deferred = [], $err = null, p, _tuple, list, typ, idents, field, idents$1, typ$1, field$1, _ref, _i, i, typ$2; + /* */ try { $deferFrames.push($deferred); + p = this; + if (p.trace) { + $deferred.push([un, [trace(p, "ParameterList")]]); + } + _tuple = p.parseVarList(ellipsisOk); list = _tuple[0]; typ = _tuple[1]; + if (!($interfaceIsEqual(typ, $ifaceNil))) { + idents = p.makeIdentList(list); + field = new ast.Field.Ptr(($ptrType(ast.CommentGroup)).nil, idents, typ, ($ptrType(ast.BasicLit)).nil, ($ptrType(ast.CommentGroup)).nil); + params = $append(params, field); + p.declare(field, $ifaceNil, scope, 4, idents); + p.resolve(typ); + if (p.tok === 52) { + p.next(); } - x.mode = 7; - x.typ = new Pointer.Ptr(x.typ); - return; - } else if (_ref === 36) { - _tuple$1 = $assertType(x.typ.Underlying(), ($ptrType(Chan)), true); typ = _tuple$1[0]; ok$1 = _tuple$1[1]; - if (!ok$1) { - check.invalidOp(x.pos(), "cannot receive from non-channel %s", new ($sliceType($emptyInterface))([x])); - x.mode = 0; - return; + while (!((p.tok === 54)) && !((p.tok === 1))) { + idents$1 = p.parseIdentList(); + typ$1 = p.parseVarType(ellipsisOk); + field$1 = new ast.Field.Ptr(($ptrType(ast.CommentGroup)).nil, idents$1, typ$1, ($ptrType(ast.BasicLit)).nil, ($ptrType(ast.CommentGroup)).nil); + params = $append(params, field$1); + p.declare(field$1, $ifaceNil, scope, 4, idents$1); + p.resolve(typ$1); + if (!p.atComma("parameter list")) { + break; + } + p.next(); } - if (typ.dir === 1) { - check.invalidOp(x.pos(), "cannot receive from send-only channel %s", new ($sliceType($emptyInterface))([x])); - x.mode = 0; - return; + } else { + params = ($sliceType(($ptrType(ast.Field)))).make(list.$length); + _ref = list; + _i = 0; + while (_i < _ref.$length) { + i = _i; + typ$2 = ((_i < 0 || _i >= _ref.$length) ? $throwRuntimeError("index out of range") : _ref.$array[_ref.$offset + _i]); + p.resolve(typ$2); + (i < 0 || i >= params.$length) ? $throwRuntimeError("index out of range") : params.$array[params.$offset + i] = new ast.Field.Ptr(($ptrType(ast.CommentGroup)).nil, ($sliceType(($ptrType(ast.Ident)))).nil, typ$2, ($ptrType(ast.BasicLit)).nil, ($ptrType(ast.CommentGroup)).nil); + _i++; } - x.mode = 8; - x.typ = typ.elem; - check.context.hasCallOrRecv = true; - return; } - if (!check.op(unaryOpPredicates, x, op)) { - x.mode = 0; - return; + return params; + /* */ } catch(err) { $err = err; } finally { $deferFrames.pop(); $callDeferred($deferred, $err); return params; } + }; + parser.prototype.parseParameterList = function(scope, ellipsisOk) { return this.$val.parseParameterList(scope, ellipsisOk); }; + parser.Ptr.prototype.parseParameters = function(scope, ellipsisOk) { + var $deferred = [], $err = null, p, params, lparen, rparen; + /* */ try { $deferFrames.push($deferred); + p = this; + if (p.trace) { + $deferred.push([un, [trace(p, "Parameters")]]); } - if (x.mode === 4) { - typ$1 = $assertType(x.typ.Underlying(), ($ptrType(Basic))); - size = -1; - if (isUnsigned(typ$1)) { - size = ((x$1 = check.conf.sizeof(typ$1), x$1.$low + ((x$1.$high >> 31) * 4294967296)) >> 0); - } - x.val = exact.UnaryOp(op, x.val, size); - if (isTyped(typ$1)) { - check.representable(x, typ$1); - } - return; + params = ($sliceType(($ptrType(ast.Field)))).nil; + lparen = p.expect(49); + if (!((p.tok === 54))) { + params = p.parseParameterList(scope, ellipsisOk); } - x.mode = 7; + rparen = p.expect(54); + return new ast.FieldList.Ptr(lparen, params, rparen); + /* */ } catch(err) { $err = err; return ($ptrType(ast.FieldList)).nil; } finally { $deferFrames.pop(); $callDeferred($deferred, $err); } }; - Checker.prototype.unary = function(x, op) { return this.$val.unary(x, op); }; - isShift = function(op) { - return (op === 20) || (op === 21); + parser.prototype.parseParameters = function(scope, ellipsisOk) { return this.$val.parseParameters(scope, ellipsisOk); }; + parser.Ptr.prototype.parseResult = function(scope) { + var $deferred = [], $err = null, p, typ, list; + /* */ try { $deferFrames.push($deferred); + p = this; + if (p.trace) { + $deferred.push([un, [trace(p, "Result")]]); + } + if (p.tok === 49) { + return p.parseParameters(scope, false); + } + typ = p.tryType(); + if (!($interfaceIsEqual(typ, $ifaceNil))) { + list = ($sliceType(($ptrType(ast.Field)))).make(1); + (0 < 0 || 0 >= list.$length) ? $throwRuntimeError("index out of range") : list.$array[list.$offset + 0] = new ast.Field.Ptr(($ptrType(ast.CommentGroup)).nil, ($sliceType(($ptrType(ast.Ident)))).nil, typ, ($ptrType(ast.BasicLit)).nil, ($ptrType(ast.CommentGroup)).nil); + return new ast.FieldList.Ptr(0, list, 0); + } + return ($ptrType(ast.FieldList)).nil; + /* */ } catch(err) { $err = err; return ($ptrType(ast.FieldList)).nil; } finally { $deferFrames.pop(); $callDeferred($deferred, $err); } }; - isComparison = function(op) { - var _ref; - _ref = op; - if (_ref === 39 || _ref === 44 || _ref === 40 || _ref === 45 || _ref === 41 || _ref === 46) { - return true; + parser.prototype.parseResult = function(scope) { return this.$val.parseResult(scope); }; + parser.Ptr.prototype.parseSignature = function(scope) { + var params = ($ptrType(ast.FieldList)).nil, results = ($ptrType(ast.FieldList)).nil, $deferred = [], $err = null, p; + /* */ try { $deferFrames.push($deferred); + p = this; + if (p.trace) { + $deferred.push([un, [trace(p, "Signature")]]); } - return false; + params = p.parseParameters(scope, true); + results = p.parseResult(scope); + return [params, results]; + /* */ } catch(err) { $err = err; } finally { $deferFrames.pop(); $callDeferred($deferred, $err); return [params, results]; } }; - fitsFloat32 = function(x) { - var _tuple, f32, f; - _tuple = exact.Float32Val(x); f32 = _tuple[0]; - f = $coerceFloat32(f32); - return !math.IsInf(f, 0); + parser.prototype.parseSignature = function(scope) { return this.$val.parseSignature(scope); }; + parser.Ptr.prototype.parseFuncType = function() { + var $deferred = [], $err = null, p, pos, scope, _tuple, params, results; + /* */ try { $deferFrames.push($deferred); + p = this; + if (p.trace) { + $deferred.push([un, [trace(p, "FuncType")]]); + } + pos = p.expect(71); + scope = ast.NewScope(p.topScope); + _tuple = p.parseSignature(scope); params = _tuple[0]; results = _tuple[1]; + return [new ast.FuncType.Ptr(pos, params, results), scope]; + /* */ } catch(err) { $err = err; return [($ptrType(ast.FuncType)).nil, ($ptrType(ast.Scope)).nil]; } finally { $deferFrames.pop(); $callDeferred($deferred, $err); } }; - roundFloat32 = function(x) { - var _tuple, f32, f; - _tuple = exact.Float32Val(x); f32 = _tuple[0]; - f = $coerceFloat32(f32); - if (!math.IsInf(f, 0)) { - return exact.MakeFloat64(f); + parser.prototype.parseFuncType = function() { return this.$val.parseFuncType(); }; + parser.Ptr.prototype.parseMethodSpec = function(scope) { + var $deferred = [], $err = null, p, doc, idents, typ, x, _tuple, ident, isIdent, scope$1, _tuple$1, params, results, spec; + /* */ try { $deferFrames.push($deferred); + p = this; + if (p.trace) { + $deferred.push([un, [trace(p, "MethodSpec")]]); } - return $ifaceNil; + doc = p.leadComment; + idents = ($sliceType(($ptrType(ast.Ident)))).nil; + typ = $ifaceNil; + x = p.parseTypeName(); + _tuple = $assertType(x, ($ptrType(ast.Ident)), true); ident = _tuple[0]; isIdent = _tuple[1]; + if (isIdent && (p.tok === 49)) { + idents = new ($sliceType(($ptrType(ast.Ident))))([ident]); + scope$1 = ast.NewScope(($ptrType(ast.Scope)).nil); + _tuple$1 = p.parseSignature(scope$1); params = _tuple$1[0]; results = _tuple$1[1]; + typ = new ast.FuncType.Ptr(0, params, results); + } else { + typ = x; + p.resolve(typ); + } + p.expectSemi(); + spec = new ast.Field.Ptr(doc, idents, typ, ($ptrType(ast.BasicLit)).nil, p.lineComment); + p.declare(spec, $ifaceNil, scope, 5, idents); + return spec; + /* */ } catch(err) { $err = err; return ($ptrType(ast.Field)).nil; } finally { $deferFrames.pop(); $callDeferred($deferred, $err); } }; - fitsFloat64 = function(x) { - var _tuple, f; - _tuple = exact.Float64Val(x); f = _tuple[0]; - return !math.IsInf(f, 0); + parser.prototype.parseMethodSpec = function(scope) { return this.$val.parseMethodSpec(scope); }; + parser.Ptr.prototype.parseInterfaceType = function() { + var $deferred = [], $err = null, p, pos, lbrace, scope, list, rbrace; + /* */ try { $deferFrames.push($deferred); + p = this; + if (p.trace) { + $deferred.push([un, [trace(p, "InterfaceType")]]); + } + pos = p.expect(76); + lbrace = p.expect(51); + scope = ast.NewScope(($ptrType(ast.Scope)).nil); + list = ($sliceType(($ptrType(ast.Field)))).nil; + while (p.tok === 4) { + list = $append(list, p.parseMethodSpec(scope)); + } + rbrace = p.expect(56); + return new ast.InterfaceType.Ptr(pos, new ast.FieldList.Ptr(lbrace, list, rbrace), false); + /* */ } catch(err) { $err = err; return ($ptrType(ast.InterfaceType)).nil; } finally { $deferFrames.pop(); $callDeferred($deferred, $err); } }; - roundFloat64 = function(x) { - var _tuple, f; - _tuple = exact.Float64Val(x); f = _tuple[0]; - if (!math.IsInf(f, 0)) { - return exact.MakeFloat64(f); + parser.prototype.parseInterfaceType = function() { return this.$val.parseInterfaceType(); }; + parser.Ptr.prototype.parseMapType = function() { + var $deferred = [], $err = null, p, pos, key, value; + /* */ try { $deferFrames.push($deferred); + p = this; + if (p.trace) { + $deferred.push([un, [trace(p, "MapType")]]); } - return $ifaceNil; + pos = p.expect(77); + p.expect(50); + key = p.parseType(); + p.expect(55); + value = p.parseType(); + return new ast.MapType.Ptr(pos, key, value); + /* */ } catch(err) { $err = err; return ($ptrType(ast.MapType)).nil; } finally { $deferFrames.pop(); $callDeferred($deferred, $err); } }; - representableConst = function(x, conf, as, rounded) { - var _ref, _tuple, x$1, ok, _ref$1, x$2, s, x$3, x$4, x$5, x$6, s$1, x$7, x$8, n, _ref$2, x$9, s$2, r, r$1, _ref$3, r$2, r$3, _ref$4, re, im, re$1, im$1; - _ref = x.Kind(); - if (_ref === 0) { - return true; - } else if (_ref === 1) { - return (as === 1) || (as === 19); - } else if (_ref === 3) { - _tuple = exact.Int64Val(x); x$1 = _tuple[0]; ok = _tuple[1]; - if (ok) { - _ref$1 = as; - if (_ref$1 === 2) { - s = (x$2 = (conf.sizeof(((as < 0 || as >= $pkg.Typ.length) ? $throwRuntimeError("index out of range") : $pkg.Typ[as])).$low >>> 0), (((x$2 >>> 16 << 16) * 8 >>> 0) + (x$2 << 16 >>> 16) * 8) >>> 0); - return (x$3 = $shiftLeft64(new $Int64(-1, 4294967295), ((s - 1 >>> 0))), (x$3.$high < x$1.$high || (x$3.$high === x$1.$high && x$3.$low <= x$1.$low))) && (x$4 = (x$5 = $shiftLeft64(new $Int64(0, 1), ((s - 1 >>> 0))), new $Int64(x$5.$high - 0, x$5.$low - 1)), (x$1.$high < x$4.$high || (x$1.$high === x$4.$high && x$1.$low <= x$4.$low))); - } else if (_ref$1 === 3) { - return (-1 < x$1.$high || (-1 === x$1.$high && 4294967168 <= x$1.$low)) && (x$1.$high < 0 || (x$1.$high === 0 && x$1.$low <= 127)); - } else if (_ref$1 === 4) { - return (-1 < x$1.$high || (-1 === x$1.$high && 4294934528 <= x$1.$low)) && (x$1.$high < 0 || (x$1.$high === 0 && x$1.$low <= 32767)); - } else if (_ref$1 === 5) { - return (-1 < x$1.$high || (-1 === x$1.$high && 2147483648 <= x$1.$low)) && (x$1.$high < 0 || (x$1.$high === 0 && x$1.$low <= 2147483647)); - } else if (_ref$1 === 6) { - return true; - } else if (_ref$1 === 7 || _ref$1 === 12) { - s$1 = (x$6 = (conf.sizeof(((as < 0 || as >= $pkg.Typ.length) ? $throwRuntimeError("index out of range") : $pkg.Typ[as])).$low >>> 0), (((x$6 >>> 16 << 16) * 8 >>> 0) + (x$6 << 16 >>> 16) * 8) >>> 0); - if (s$1 < 64) { - return (0 < x$1.$high || (0 === x$1.$high && 0 <= x$1.$low)) && (x$7 = (x$8 = $shiftLeft64(new $Int64(0, 1), s$1), new $Int64(x$8.$high - 0, x$8.$low - 1)), (x$1.$high < x$7.$high || (x$1.$high === x$7.$high && x$1.$low <= x$7.$low))); - } - return (0 < x$1.$high || (0 === x$1.$high && 0 <= x$1.$low)); - } else if (_ref$1 === 8) { - return (0 < x$1.$high || (0 === x$1.$high && 0 <= x$1.$low)) && (x$1.$high < 0 || (x$1.$high === 0 && x$1.$low <= 255)); - } else if (_ref$1 === 9) { - return (0 < x$1.$high || (0 === x$1.$high && 0 <= x$1.$low)) && (x$1.$high < 0 || (x$1.$high === 0 && x$1.$low <= 65535)); - } else if (_ref$1 === 10) { - return (0 < x$1.$high || (0 === x$1.$high && 0 <= x$1.$low)) && (x$1.$high < 0 || (x$1.$high === 0 && x$1.$low <= 4294967295)); - } else if (_ref$1 === 11) { - return (0 < x$1.$high || (0 === x$1.$high && 0 <= x$1.$low)); - } else if (_ref$1 === 13 || _ref$1 === 14 || _ref$1 === 15 || _ref$1 === 16 || _ref$1 === 20 || _ref$1 === 22 || _ref$1 === 23) { - return true; - } - } - n = exact.BitLen(x); - _ref$2 = as; - if (_ref$2 === 7 || _ref$2 === 12) { - s$2 = (x$9 = (conf.sizeof(((as < 0 || as >= $pkg.Typ.length) ? $throwRuntimeError("index out of range") : $pkg.Typ[as])).$low >>> 0), (((x$9 >>> 16 << 16) * 8 >>> 0) + (x$9 << 16 >>> 16) * 8) >>> 0); - return exact.Sign(x) >= 0 && n <= (s$2 >> 0); - } else if (_ref$2 === 11) { - return exact.Sign(x) >= 0 && n <= 64; - } else if (_ref$2 === 13 || _ref$2 === 15) { - if (rounded === ($ptrType(exact.Value)).nil) { - return fitsFloat32(x); - } - r = roundFloat32(x); - if (!($interfaceIsEqual(r, $ifaceNil))) { - rounded.$set(r); - return true; - } - } else if (_ref$2 === 14 || _ref$2 === 16) { - if (rounded === ($ptrType(exact.Value)).nil) { - return fitsFloat64(x); - } - r$1 = roundFloat64(x); - if (!($interfaceIsEqual(r$1, $ifaceNil))) { - rounded.$set(r$1); - return true; - } - } else if (_ref$2 === 20 || _ref$2 === 22 || _ref$2 === 23) { - return true; - } - } else if (_ref === 4) { - _ref$3 = as; - if (_ref$3 === 13 || _ref$3 === 15) { - if (rounded === ($ptrType(exact.Value)).nil) { - return fitsFloat32(x); - } - r$2 = roundFloat32(x); - if (!($interfaceIsEqual(r$2, $ifaceNil))) { - rounded.$set(r$2); - return true; - } - } else if (_ref$3 === 14 || _ref$3 === 16) { - if (rounded === ($ptrType(exact.Value)).nil) { - return fitsFloat64(x); - } - r$3 = roundFloat64(x); - if (!($interfaceIsEqual(r$3, $ifaceNil))) { - rounded.$set(r$3); - return true; - } - } else if (_ref$3 === 22 || _ref$3 === 23) { - return true; - } - } else if (_ref === 5) { - _ref$4 = as; - if (_ref$4 === 15) { - if (rounded === ($ptrType(exact.Value)).nil) { - return fitsFloat32(exact.Real(x)) && fitsFloat32(exact.Imag(x)); - } - re = roundFloat32(exact.Real(x)); - im = roundFloat32(exact.Imag(x)); - if (!($interfaceIsEqual(re, $ifaceNil)) && !($interfaceIsEqual(im, $ifaceNil))) { - rounded.$set(exact.BinaryOp(re, 12, exact.MakeImag(im))); - return true; - } - } else if (_ref$4 === 16) { - if (rounded === ($ptrType(exact.Value)).nil) { - return fitsFloat64(exact.Real(x)) && fitsFloat64(exact.Imag(x)); - } - re$1 = roundFloat64(exact.Real(x)); - im$1 = roundFloat64(exact.Imag(x)); - if (!($interfaceIsEqual(re$1, $ifaceNil)) && !($interfaceIsEqual(im$1, $ifaceNil))) { - rounded.$set(exact.BinaryOp(re$1, 12, exact.MakeImag(im$1))); - return true; - } - } else if (_ref$4 === 23) { - return true; + parser.prototype.parseMapType = function() { return this.$val.parseMapType(); }; + parser.Ptr.prototype.parseChanType = function() { + var $deferred = [], $err = null, p, pos, dir, arrow, value; + /* */ try { $deferFrames.push($deferred); + p = this; + if (p.trace) { + $deferred.push([un, [trace(p, "ChanType")]]); + } + pos = p.pos; + dir = 3; + arrow = 0; + if (p.tok === 63) { + p.next(); + if (p.tok === 36) { + arrow = p.pos; + p.next(); + dir = 1; } - } else if (_ref === 2) { - return (as === 17) || (as === 24); } else { - unreachable(); + arrow = p.expect(36); + p.expect(63); + dir = 2; } - return false; + value = p.parseType(); + return new ast.ChanType.Ptr(pos, arrow, dir, value); + /* */ } catch(err) { $err = err; return ($ptrType(ast.ChanType)).nil; } finally { $deferFrames.pop(); $callDeferred($deferred, $err); } }; - Checker.Ptr.prototype.representable = function(x, typ) { - var check, msg; - check = this; - assert(x.mode === 4); - if (!representableConst(x.val, check.conf, typ.kind, new ($ptrType(exact.Value))(function() { return this.$target.val; }, function($v) { this.$target.val = $v; }, x))) { - msg = ""; - if (isNumeric(x.typ) && isNumeric(typ)) { - if (!isInteger(x.typ) && isInteger(typ)) { - msg = "%s truncated to %s"; - } else { - msg = "%s overflows %s"; - } - } else { - msg = "cannot convert %s to %s"; - } - check.errorf(x.pos(), msg, new ($sliceType($emptyInterface))([x, typ])); - x.mode = 0; + parser.prototype.parseChanType = function() { return this.$val.parseChanType(); }; + parser.Ptr.prototype.tryIdentOrType = function() { + var p, _ref, _tuple, typ, lparen, typ$1, rparen; + p = this; + _ref = p.tok; + if (_ref === 4) { + return p.parseTypeName(); + } else if (_ref === 50) { + return p.parseArrayType(); + } else if (_ref === 82) { + return p.parseStructType(); + } else if (_ref === 14) { + return p.parsePointerType(); + } else if (_ref === 71) { + _tuple = p.parseFuncType(); typ = _tuple[0]; + return typ; + } else if (_ref === 76) { + return p.parseInterfaceType(); + } else if (_ref === 77) { + return p.parseMapType(); + } else if (_ref === 63 || _ref === 36) { + return p.parseChanType(); + } else if (_ref === 49) { + lparen = p.pos; + p.next(); + typ$1 = p.parseType(); + rparen = p.expect(54); + return new ast.ParenExpr.Ptr(lparen, typ$1, rparen); } + return $ifaceNil; }; - Checker.prototype.representable = function(x, typ) { return this.$val.representable(x, typ); }; - Checker.Ptr.prototype.updateExprType = function(x, typ, final$1) { - var check, _tuple, _entry, old, found, x$1, _ref, _key$2; - check = this; - _tuple = (_entry = check.untyped[x.$key()], _entry !== undefined ? [_entry.v, true] : [new exprInfo.Ptr(), false]); old = new exprInfo.Ptr(); $copy(old, _tuple[0], exprInfo); found = _tuple[1]; - if (!found) { - return; + parser.prototype.tryIdentOrType = function() { return this.$val.tryIdentOrType(); }; + parser.Ptr.prototype.tryType = function() { + var p, typ; + p = this; + typ = p.tryIdentOrType(); + if (!($interfaceIsEqual(typ, $ifaceNil))) { + p.resolve(typ); } - _ref = x; - switch (0) { default: if ($assertType(_ref, ($ptrType(ast.BadExpr)), true)[1] || $assertType(_ref, ($ptrType(ast.FuncLit)), true)[1] || $assertType(_ref, ($ptrType(ast.CompositeLit)), true)[1] || $assertType(_ref, ($ptrType(ast.IndexExpr)), true)[1] || $assertType(_ref, ($ptrType(ast.SliceExpr)), true)[1] || $assertType(_ref, ($ptrType(ast.TypeAssertExpr)), true)[1] || $assertType(_ref, ($ptrType(ast.StarExpr)), true)[1] || $assertType(_ref, ($ptrType(ast.KeyValueExpr)), true)[1] || $assertType(_ref, ($ptrType(ast.ArrayType)), true)[1] || $assertType(_ref, ($ptrType(ast.StructType)), true)[1] || $assertType(_ref, ($ptrType(ast.FuncType)), true)[1] || $assertType(_ref, ($ptrType(ast.InterfaceType)), true)[1] || $assertType(_ref, ($ptrType(ast.MapType)), true)[1] || $assertType(_ref, ($ptrType(ast.ChanType)), true)[1]) { - x$1 = _ref; - return; - } else if ($assertType(_ref, ($ptrType(ast.CallExpr)), true)[1]) { - x$1 = _ref.$val; - } else if ($assertType(_ref, ($ptrType(ast.Ident)), true)[1] || $assertType(_ref, ($ptrType(ast.BasicLit)), true)[1] || $assertType(_ref, ($ptrType(ast.SelectorExpr)), true)[1]) { - x$1 = _ref; - } else if ($assertType(_ref, ($ptrType(ast.ParenExpr)), true)[1]) { - x$1 = _ref.$val; - check.updateExprType(x$1.X, typ, final$1); - } else if ($assertType(_ref, ($ptrType(ast.UnaryExpr)), true)[1]) { - x$1 = _ref.$val; - if (!($interfaceIsEqual(old.val, $ifaceNil))) { - break; - } - check.updateExprType(x$1.X, typ, final$1); - } else if ($assertType(_ref, ($ptrType(ast.BinaryExpr)), true)[1]) { - x$1 = _ref.$val; - if (!($interfaceIsEqual(old.val, $ifaceNil))) { - break; - } - if (isComparison(x$1.Op)) { - } else if (isShift(x$1.Op)) { - check.updateExprType(x$1.X, typ, final$1); - } else { - check.updateExprType(x$1.X, typ, final$1); - check.updateExprType(x$1.Y, typ, final$1); - } - } else { - x$1 = _ref; - unreachable(); - } } - if (!final$1 && isUntyped(typ)) { - old.typ = $assertType(typ.Underlying(), ($ptrType(Basic))); - _key$2 = x; (check.untyped || $throwRuntimeError("assignment to entry in nil map"))[_key$2.$key()] = { k: _key$2, v: old }; - return; + return typ; + }; + parser.prototype.tryType = function() { return this.$val.tryType(); }; + parser.Ptr.prototype.parseStmtList = function() { + var list = ($sliceType(ast.Stmt)).nil, $deferred = [], $err = null, p; + /* */ try { $deferFrames.push($deferred); + p = this; + if (p.trace) { + $deferred.push([un, [trace(p, "StatementList")]]); } - delete check.untyped[x.$key()]; - if (old.isLhs && !isInteger(typ)) { - check.invalidOp(x.Pos(), "shifted operand %s (type %s) must be integer", new ($sliceType($emptyInterface))([x, typ])); - return; + while (!((p.tok === 62)) && !((p.tok === 66)) && !((p.tok === 56)) && !((p.tok === 1))) { + list = $append(list, p.parseStmt()); } - check.recordTypeAndValue(x, old.mode, typ, old.val); + return list; + /* */ } catch(err) { $err = err; } finally { $deferFrames.pop(); $callDeferred($deferred, $err); return list; } }; - Checker.prototype.updateExprType = function(x, typ, final$1) { return this.$val.updateExprType(x, typ, final$1); }; - Checker.Ptr.prototype.updateExprVal = function(x, val) { - var check, _tuple, _entry, info, ok, _key$2; - check = this; - _tuple = (_entry = check.untyped[x.$key()], _entry !== undefined ? [_entry.v, true] : [new exprInfo.Ptr(), false]); info = new exprInfo.Ptr(); $copy(info, _tuple[0], exprInfo); ok = _tuple[1]; - if (ok) { - info.val = val; - _key$2 = x; (check.untyped || $throwRuntimeError("assignment to entry in nil map"))[_key$2.$key()] = { k: _key$2, v: info }; + parser.prototype.parseStmtList = function() { return this.$val.parseStmtList(); }; + parser.Ptr.prototype.parseBody = function(scope) { + var $deferred = [], $err = null, p, lbrace, list, rbrace; + /* */ try { $deferFrames.push($deferred); + p = this; + if (p.trace) { + $deferred.push([un, [trace(p, "Body")]]); } + lbrace = p.expect(51); + p.topScope = scope; + p.openLabelScope(); + list = p.parseStmtList(); + p.closeLabelScope(); + p.closeScope(); + rbrace = p.expect(56); + return new ast.BlockStmt.Ptr(lbrace, list, rbrace); + /* */ } catch(err) { $err = err; return ($ptrType(ast.BlockStmt)).nil; } finally { $deferFrames.pop(); $callDeferred($deferred, $err); } }; - Checker.prototype.updateExprVal = function(x, val) { return this.$val.updateExprVal(x, val); }; - Checker.Ptr.prototype.convertUntyped = function(x, target) { - var $this = this, $args = arguments, $s = 0, check, xkind, tkind, t, _ref, _ref$1; - /* */ while (true) { switch ($s) { case 0: - check = $this; - if ((x.mode === 0) || isTyped(x.typ) || $interfaceIsEqual(target, $pkg.Typ[0])) { - return; + parser.prototype.parseBody = function(scope) { return this.$val.parseBody(scope); }; + parser.Ptr.prototype.parseBlockStmt = function() { + var $deferred = [], $err = null, p, lbrace, list, rbrace; + /* */ try { $deferFrames.push($deferred); + p = this; + if (p.trace) { + $deferred.push([un, [trace(p, "BlockStmt")]]); } - /* if (isUntyped(target)) { */ if (isUntyped(target)) {} else { $s = 2; continue; } - xkind = $assertType(x.typ, ($ptrType(Basic))).kind; - tkind = $assertType(target, ($ptrType(Basic))).kind; - /* if (isNumeric(x.typ) && isNumeric(target)) { */ if (isNumeric(x.typ) && isNumeric(target)) {} else if (!((xkind === tkind))) { $s = 3; continue; } else { $s = 4; continue; } - if (xkind < tkind) { - x.typ = target; - check.updateExprType(x.expr, target, false); - } - /* } else if (!((xkind === tkind))) { */ $s = 4; continue; case 3: - /* goto Error */ $s = 1; continue; - /* } */ case 4: - return; - /* } */ case 2: - _ref = target.Underlying(); - /* if ($assertType(_ref, ($ptrType(Basic)), true)[1]) { */ if ($assertType(_ref, ($ptrType(Basic)), true)[1]) {} else if ($assertType(_ref, ($ptrType(Interface)), true)[1]) { $s = 5; continue; } else if ($assertType(_ref, ($ptrType(Pointer)), true)[1] || $assertType(_ref, ($ptrType(Signature)), true)[1] || $assertType(_ref, ($ptrType(Slice)), true)[1] || $assertType(_ref, ($ptrType(Map)), true)[1] || $assertType(_ref, ($ptrType(Chan)), true)[1]) { $s = 6; continue; } else { $s = 7; continue; } - t = _ref.$val; - /* if (x.mode === 4) { */ if (x.mode === 4) {} else { $s = 9; continue; } - check.representable(x, t); - if (x.mode === 0) { - return; - } - check.updateExprVal(x.expr, x.val); - /* } else { */ $s = 10; continue; case 9: - _ref$1 = $assertType(x.typ, ($ptrType(Basic))).kind; - /* if (_ref$1 === 19) { */ if (_ref$1 === 19) {} else if (_ref$1 === 20 || _ref$1 === 21 || _ref$1 === 22 || _ref$1 === 23) { $s = 11; continue; } else if (_ref$1 === 24) { $s = 12; continue; } else if (_ref$1 === 25) { $s = 13; continue; } else { $s = 14; continue; } - /* if (!isBoolean(target)) { */ if (!isBoolean(target)) {} else { $s = 16; continue; } - /* goto Error */ $s = 1; continue; - /* } */ case 16: - /* } else if (_ref$1 === 20 || _ref$1 === 21 || _ref$1 === 22 || _ref$1 === 23) { */ $s = 15; continue; case 11: - /* if (!isNumeric(target)) { */ if (!isNumeric(target)) {} else { $s = 17; continue; } - /* goto Error */ $s = 1; continue; - /* } */ case 17: - /* } else if (_ref$1 === 24) { */ $s = 15; continue; case 12: - unreachable(); - /* } else if (_ref$1 === 25) { */ $s = 15; continue; case 13: - /* if (!hasNil(target)) { */ if (!hasNil(target)) {} else { $s = 18; continue; } - /* goto Error */ $s = 1; continue; - /* } */ case 18: - /* } else { */ $s = 15; continue; case 14: - /* goto Error */ $s = 1; continue; - /* } */ case 15: - /* } */ case 10: - /* } else if ($assertType(_ref, ($ptrType(Interface)), true)[1]) { */ $s = 8; continue; case 5: - t = _ref.$val; - /* if (!x.isNil() && !t.Empty()) { */ if (!x.isNil() && !t.Empty()) {} else { $s = 19; continue; } - /* goto Error */ $s = 1; continue; - /* } */ case 19: - /* if (x.isNil()) { */ if (x.isNil()) {} else { $s = 20; continue; } - target = $pkg.Typ[25]; - /* } else { */ $s = 21; continue; case 20: - /* if (!t.Empty()) { */ if (!t.Empty()) {} else { $s = 22; continue; } - /* goto Error */ $s = 1; continue; - /* } */ case 22: - target = defaultType(x.typ); - /* } */ case 21: - /* } else if ($assertType(_ref, ($ptrType(Pointer)), true)[1] || $assertType(_ref, ($ptrType(Signature)), true)[1] || $assertType(_ref, ($ptrType(Slice)), true)[1] || $assertType(_ref, ($ptrType(Map)), true)[1] || $assertType(_ref, ($ptrType(Chan)), true)[1]) { */ $s = 8; continue; case 6: - t = _ref; - /* if (!x.isNil()) { */ if (!x.isNil()) {} else { $s = 23; continue; } - /* goto Error */ $s = 1; continue; - /* } */ case 23: - target = $pkg.Typ[25]; - /* } else { */ $s = 8; continue; case 7: - t = _ref; - /* goto Error */ $s = 1; continue; - /* } */ case 8: - x.typ = target; - check.updateExprType(x.expr, target, true); - return; - /* Error: */ case 1: - check.errorf(x.pos(), "cannot convert %s to %s", new ($sliceType($emptyInterface))([x, target])); - x.mode = 0; - /* */ case -1: } return; } + lbrace = p.expect(51); + p.openScope(); + list = p.parseStmtList(); + p.closeScope(); + rbrace = p.expect(56); + return new ast.BlockStmt.Ptr(lbrace, list, rbrace); + /* */ } catch(err) { $err = err; return ($ptrType(ast.BlockStmt)).nil; } finally { $deferFrames.pop(); $callDeferred($deferred, $err); } }; - Checker.prototype.convertUntyped = function(x, target) { return this.$val.convertUntyped(x, target); }; - Checker.Ptr.prototype.comparison = function(x, y, op) { - var check, err, defined, _ref, typ; - check = this; - err = ""; - if (x.assignableTo(check.conf, y.typ) || y.assignableTo(check.conf, x.typ)) { - defined = false; - _ref = op; - if (_ref === 39 || _ref === 44) { - defined = Comparable(x.typ) || x.isNil() && hasNil(y.typ) || y.isNil() && hasNil(x.typ); - } else if (_ref === 40 || _ref === 45 || _ref === 41 || _ref === 46) { - defined = isOrdered(x.typ); - } else { - unreachable(); - } - if (!defined) { - typ = x.typ; - if (x.isNil()) { - typ = y.typ; - } - err = check.sprintf("operator %s not defined for %s", new ($sliceType($emptyInterface))([new token.Token(op), typ])); - } - } else { - err = check.sprintf("mismatched types %s and %s", new ($sliceType($emptyInterface))([x.typ, y.typ])); - } - if (!(err === "")) { - check.errorf(x.pos(), "cannot compare %s %s %s (%s)", new ($sliceType($emptyInterface))([x.expr, new token.Token(op), y.expr, new $String(err)])); - x.mode = 0; - return; + parser.prototype.parseBlockStmt = function() { return this.$val.parseBlockStmt(); }; + parser.Ptr.prototype.parseFuncTypeOrLit = function() { + var $deferred = [], $err = null, p, _tuple, typ, scope, body; + /* */ try { $deferFrames.push($deferred); + p = this; + if (p.trace) { + $deferred.push([un, [trace(p, "FuncTypeOrLit")]]); } - if ((x.mode === 4) && (y.mode === 4)) { - x.val = exact.MakeBool(exact.Compare(x.val, op, y.val)); - } else { - x.mode = 7; - check.updateExprType(x.expr, defaultType(x.typ), true); - check.updateExprType(y.expr, defaultType(y.typ), true); + _tuple = p.parseFuncType(); typ = _tuple[0]; scope = _tuple[1]; + if (!((p.tok === 51))) { + return typ; } - x.typ = $pkg.Typ[19]; + p.exprLev = p.exprLev + (1) >> 0; + body = p.parseBody(scope); + p.exprLev = p.exprLev - (1) >> 0; + return new ast.FuncLit.Ptr(typ, body); + /* */ } catch(err) { $err = err; return $ifaceNil; } finally { $deferFrames.pop(); $callDeferred($deferred, $err); } }; - Checker.prototype.comparison = function(x, y, op) { return this.$val.comparison(x, y, op); }; - Checker.Ptr.prototype.shift = function(x, y, op) { - var check, untypedx, _tuple, s, ok, _tuple$1, _entry, info, found, _key$2; - check = this; - untypedx = isUntyped(x.typ); - if (!isInteger(x.typ) && (!untypedx || !representableConst(x.val, ($ptrType(Config)).nil, 20, ($ptrType(exact.Value)).nil))) { - check.invalidOp(x.pos(), "shifted operand %s must be integer", new ($sliceType($emptyInterface))([x])); - x.mode = 0; - return; - } - if (isInteger(y.typ) && isUnsigned(y.typ)) { - } else if (isUntyped(y.typ)) { - check.convertUntyped(y, $pkg.Typ[20]); - if (y.mode === 0) { - x.mode = 0; - return; - } - } else { - check.invalidOp(y.pos(), "shift count %s must be unsigned integer", new ($sliceType($emptyInterface))([y])); - x.mode = 0; - return; + parser.prototype.parseFuncTypeOrLit = function() { return this.$val.parseFuncTypeOrLit(); }; + parser.Ptr.prototype.parseOperand = function(lhs) { + var $deferred = [], $err = null, p, _ref, x, x$1, lparen, x$2, rparen, typ, _tuple, isIdent, pos; + /* */ try { $deferFrames.push($deferred); + p = this; + if (p.trace) { + $deferred.push([un, [trace(p, "Operand")]]); } - if (x.mode === 4) { - if (y.mode === 4) { - _tuple = exact.Uint64Val(y.val); s = _tuple[0]; ok = _tuple[1]; - if (!ok || (s.$high > 0 || (s.$high === 0 && s.$low > 1074))) { - check.invalidOp(y.pos(), "stupid shift count %s", new ($sliceType($emptyInterface))([y])); - x.mode = 0; - return; - } - if (!isInteger(x.typ)) { - x.typ = $pkg.Typ[20]; - } - x.val = exact.Shift(x.val, op, (s.$low >>> 0)); - return; - } - if (untypedx) { - _tuple$1 = (_entry = check.untyped[x.expr.$key()], _entry !== undefined ? [_entry.v, true] : [new exprInfo.Ptr(), false]); info = new exprInfo.Ptr(); $copy(info, _tuple$1[0], exprInfo); found = _tuple$1[1]; - assert(found); - info.isLhs = true; - _key$2 = x.expr; (check.untyped || $throwRuntimeError("assignment to entry in nil map"))[_key$2.$key()] = { k: _key$2, v: info }; - x.mode = 7; - return; + _ref = p.tok; + if (_ref === 4) { + x = p.parseIdent(); + if (!lhs) { + p.resolve(x); } + return x; + } else if (_ref === 5 || _ref === 6 || _ref === 7 || _ref === 8 || _ref === 9) { + x$1 = new ast.BasicLit.Ptr(p.pos, p.tok, p.lit); + p.next(); + return x$1; + } else if (_ref === 49) { + lparen = p.pos; + p.next(); + p.exprLev = p.exprLev + (1) >> 0; + x$2 = p.parseRhsOrType(); + p.exprLev = p.exprLev - (1) >> 0; + rparen = p.expect(54); + return new ast.ParenExpr.Ptr(lparen, x$2, rparen); + } else if (_ref === 71) { + return p.parseFuncTypeOrLit(); } - if ((y.mode === 4) && exact.Sign(y.val) < 0) { - check.invalidOp(y.pos(), "shift count %s must not be negative", new ($sliceType($emptyInterface))([y])); - } - if (!isInteger(x.typ)) { - check.invalidOp(x.pos(), "shifted operand %s must be integer", new ($sliceType($emptyInterface))([x])); - x.mode = 0; - return; + typ = p.tryIdentOrType(); + if (!($interfaceIsEqual(typ, $ifaceNil))) { + _tuple = $assertType(typ, ($ptrType(ast.Ident)), true); isIdent = _tuple[1]; + assert(!isIdent, "type cannot be identifier"); + return typ; } - x.mode = 7; + pos = p.pos; + p.errorExpected(pos, "operand"); + syncStmt(p); + return new ast.BadExpr.Ptr(pos, p.pos); + /* */ } catch(err) { $err = err; return $ifaceNil; } finally { $deferFrames.pop(); $callDeferred($deferred, $err); } }; - Checker.prototype.shift = function(x, y, op) { return this.$val.shift(x, y, op); }; - Checker.Ptr.prototype.binary = function(x, lhs, rhs, op) { - var check, y, typ; - check = this; - y = new operand.Ptr(); $copy(y, new operand.Ptr(), operand); - check.expr(x, lhs); - check.expr(y, rhs); - if (x.mode === 0) { - return; + parser.prototype.parseOperand = function(lhs) { return this.$val.parseOperand(lhs); }; + parser.Ptr.prototype.parseSelector = function(x) { + var $deferred = [], $err = null, p, sel; + /* */ try { $deferFrames.push($deferred); + p = this; + if (p.trace) { + $deferred.push([un, [trace(p, "Selector")]]); } - if (y.mode === 0) { - x.mode = 0; - x.expr = y.expr; - return; + sel = p.parseIdent(); + return new ast.SelectorExpr.Ptr(x, sel); + /* */ } catch(err) { $err = err; return $ifaceNil; } finally { $deferFrames.pop(); $callDeferred($deferred, $err); } + }; + parser.prototype.parseSelector = function(x) { return this.$val.parseSelector(x); }; + parser.Ptr.prototype.parseTypeAssertion = function(x) { + var $deferred = [], $err = null, p, lparen, typ, rparen; + /* */ try { $deferFrames.push($deferred); + p = this; + if (p.trace) { + $deferred.push([un, [trace(p, "TypeAssertion")]]); } - if (isShift(op)) { - check.shift(x, y, op); - return; + lparen = p.expect(49); + typ = $ifaceNil; + if (p.tok === 84) { + p.next(); + } else { + typ = p.parseType(); } - check.convertUntyped(x, y.typ); - if (x.mode === 0) { - return; + rparen = p.expect(54); + return new ast.TypeAssertExpr.Ptr(x, lparen, typ, rparen); + /* */ } catch(err) { $err = err; return $ifaceNil; } finally { $deferFrames.pop(); $callDeferred($deferred, $err); } + }; + parser.prototype.parseTypeAssertion = function(x) { return this.$val.parseTypeAssertion(x); }; + parser.Ptr.prototype.parseIndexOrSlice = function(x) { + var $deferred = [], $err = null, p, lbrack, index, colons, ncolons, rbrack, slice3; + /* */ try { $deferFrames.push($deferred); + p = this; + if (p.trace) { + $deferred.push([un, [trace(p, "IndexOrSlice")]]); } - check.convertUntyped(y, x.typ); - if (y.mode === 0) { - x.mode = 0; - return; + lbrack = p.expect(50); + p.exprLev = p.exprLev + (1) >> 0; + index = ($arrayType(ast.Expr, 3)).zero(); $copy(index, ($arrayType(ast.Expr, 3)).zero(), ($arrayType(ast.Expr, 3))); + colons = ($arrayType(token.Pos, 2)).zero(); $copy(colons, ($arrayType(token.Pos, 2)).zero(), ($arrayType(token.Pos, 2))); + if (!((p.tok === 58))) { + index[0] = p.parseRhs(); } - if (isComparison(op)) { - check.comparison(x, y, op); - return; + ncolons = 0; + while ((p.tok === 58) && ncolons < 2) { + (ncolons < 0 || ncolons >= colons.length) ? $throwRuntimeError("index out of range") : colons[ncolons] = p.pos; + ncolons = ncolons + (1) >> 0; + p.next(); + if (!((p.tok === 58)) && !((p.tok === 55)) && !((p.tok === 1))) { + (ncolons < 0 || ncolons >= index.length) ? $throwRuntimeError("index out of range") : index[ncolons] = p.parseRhs(); + } } - if (!Identical(x.typ, y.typ)) { - if (!($interfaceIsEqual(x.typ, $pkg.Typ[0])) && !($interfaceIsEqual(y.typ, $pkg.Typ[0]))) { - check.invalidOp(x.pos(), "mismatched types %s and %s", new ($sliceType($emptyInterface))([x.typ, y.typ])); + p.exprLev = p.exprLev - (1) >> 0; + rbrack = p.expect(55); + if (ncolons > 0) { + slice3 = false; + if (ncolons === 2) { + slice3 = true; + if ($interfaceIsEqual(index[1], $ifaceNil)) { + p.error(colons[0], "2nd index required in 3-index slice"); + index[1] = new ast.BadExpr.Ptr(colons[0] + 1 >> 0, colons[1]); + } + if ($interfaceIsEqual(index[2], $ifaceNil)) { + p.error(colons[1], "3rd index required in 3-index slice"); + index[2] = new ast.BadExpr.Ptr(colons[1] + 1 >> 0, rbrack); + } } - x.mode = 0; - return; + return new ast.SliceExpr.Ptr(x, lbrack, index[0], index[1], index[2], slice3, rbrack); } - if (!check.op(binaryOpPredicates, x, op)) { - x.mode = 0; - return; + return new ast.IndexExpr.Ptr(x, lbrack, index[0], rbrack); + /* */ } catch(err) { $err = err; return $ifaceNil; } finally { $deferFrames.pop(); $callDeferred($deferred, $err); } + }; + parser.prototype.parseIndexOrSlice = function(x) { return this.$val.parseIndexOrSlice(x); }; + parser.Ptr.prototype.parseCallOrConversion = function(fun) { + var $deferred = [], $err = null, p, lparen, list, ellipsis, rparen; + /* */ try { $deferFrames.push($deferred); + p = this; + if (p.trace) { + $deferred.push([un, [trace(p, "CallOrConversion")]]); } - if (((op === 15) || (op === 16)) && ((x.mode === 4) || isInteger(x.typ)) && (y.mode === 4) && (exact.Sign(y.val) === 0)) { - check.invalidOp(y.pos(), "division by zero", new ($sliceType($emptyInterface))([])); - x.mode = 0; - return; + lparen = p.expect(49); + p.exprLev = p.exprLev + (1) >> 0; + list = ($sliceType(ast.Expr)).nil; + ellipsis = 0; + while (!((p.tok === 54)) && !((p.tok === 1)) && !(new token.Pos(ellipsis)).IsValid()) { + list = $append(list, p.parseRhsOrType()); + if (p.tok === 48) { + ellipsis = p.pos; + p.next(); + } + if (!p.atComma("argument list")) { + break; + } + p.next(); + } + p.exprLev = p.exprLev - (1) >> 0; + rparen = p.expectClosing(54, "argument list"); + return new ast.CallExpr.Ptr(fun, lparen, list, ellipsis, rparen); + /* */ } catch(err) { $err = err; return ($ptrType(ast.CallExpr)).nil; } finally { $deferFrames.pop(); $callDeferred($deferred, $err); } + }; + parser.prototype.parseCallOrConversion = function(fun) { return this.$val.parseCallOrConversion(fun); }; + parser.Ptr.prototype.parseElement = function(keyOk) { + var $deferred = [], $err = null, p, x, colon; + /* */ try { $deferFrames.push($deferred); + p = this; + if (p.trace) { + $deferred.push([un, [trace(p, "Element")]]); } - if ((x.mode === 4) && (y.mode === 4)) { - typ = $assertType(x.typ.Underlying(), ($ptrType(Basic))); - if ((op === 15) && isInteger(typ)) { - op = 26; - } - x.val = exact.BinaryOp(x.val, op, y.val); - if (isTyped(typ)) { - check.representable(x, typ); + if (p.tok === 51) { + return p.parseLiteralValue($ifaceNil); + } + x = p.checkExpr(p.parseExpr(keyOk)); + if (keyOk) { + if (p.tok === 58) { + colon = p.pos; + p.next(); + p.tryResolve(x, false); + return new ast.KeyValueExpr.Ptr(x, colon, p.parseElement(false)); } - return; + p.resolve(x); } - x.mode = 7; + return x; + /* */ } catch(err) { $err = err; return $ifaceNil; } finally { $deferFrames.pop(); $callDeferred($deferred, $err); } }; - Checker.prototype.binary = function(x, lhs, rhs, op) { return this.$val.binary(x, lhs, rhs, op); }; - Checker.Ptr.prototype.index = function(index, max) { - var i = new $Int64(0, 0), valid = false, check, x, _tuple, _tmp, _tmp$1, _tmp$2, _tmp$3, _tmp$4, _tmp$5; - check = this; - x = new operand.Ptr(); $copy(x, new operand.Ptr(), operand); - check.expr(x, index); - if (x.mode === 0) { - return [i, valid]; + parser.prototype.parseElement = function(keyOk) { return this.$val.parseElement(keyOk); }; + parser.Ptr.prototype.parseElementList = function() { + var list = ($sliceType(ast.Expr)).nil, $deferred = [], $err = null, p; + /* */ try { $deferFrames.push($deferred); + p = this; + if (p.trace) { + $deferred.push([un, [trace(p, "ElementList")]]); } - check.convertUntyped(x, $pkg.Typ[2]); - if (x.mode === 0) { - return [i, valid]; + while (!((p.tok === 56)) && !((p.tok === 1))) { + list = $append(list, p.parseElement(true)); + if (!p.atComma("composite literal")) { + break; + } + p.next(); } - if (!isInteger(x.typ)) { - check.invalidArg(x.pos(), "index %s must be integer", new ($sliceType($emptyInterface))([x])); - return [i, valid]; + return list; + /* */ } catch(err) { $err = err; } finally { $deferFrames.pop(); $callDeferred($deferred, $err); return list; } + }; + parser.prototype.parseElementList = function() { return this.$val.parseElementList(); }; + parser.Ptr.prototype.parseLiteralValue = function(typ) { + var $deferred = [], $err = null, p, lbrace, elts, rbrace; + /* */ try { $deferFrames.push($deferred); + p = this; + if (p.trace) { + $deferred.push([un, [trace(p, "LiteralValue")]]); } - if (x.mode === 4) { - if (exact.Sign(x.val) < 0) { - check.invalidArg(x.pos(), "index %s must not be negative", new ($sliceType($emptyInterface))([x])); - return [i, valid]; - } - _tuple = exact.Int64Val(x.val); i = _tuple[0]; valid = _tuple[1]; - if (!valid || (max.$high > 0 || (max.$high === 0 && max.$low >= 0)) && (i.$high > max.$high || (i.$high === max.$high && i.$low >= max.$low))) { - check.errorf(x.pos(), "index %s is out of bounds", new ($sliceType($emptyInterface))([x])); - _tmp = i; _tmp$1 = false; i = _tmp; valid = _tmp$1; - return [i, valid]; - } - _tmp$2 = i; _tmp$3 = true; i = _tmp$2; valid = _tmp$3; - return [i, valid]; + lbrace = p.expect(51); + elts = ($sliceType(ast.Expr)).nil; + p.exprLev = p.exprLev + (1) >> 0; + if (!((p.tok === 56))) { + elts = p.parseElementList(); } - _tmp$4 = new $Int64(-1, 4294967295); _tmp$5 = true; i = _tmp$4; valid = _tmp$5; - return [i, valid]; + p.exprLev = p.exprLev - (1) >> 0; + rbrace = p.expectClosing(56, "composite literal"); + return new ast.CompositeLit.Ptr(typ, lbrace, elts, rbrace); + /* */ } catch(err) { $err = err; return $ifaceNil; } finally { $deferFrames.pop(); $callDeferred($deferred, $err); } }; - Checker.prototype.index = function(index, max) { return this.$val.index(index, max); }; - Checker.Ptr.prototype.indexedElts = function(elts, typ, length) { - var check, visited, _tmp, _tmp$1, index, max, _ref, _i, e, validIndex, eval$1, _tuple, kv, _tuple$1, i, ok, _entry, _key$2, x, x$1; - check = this; - visited = new $Map(); - _tmp = new $Int64(0, 0); _tmp$1 = new $Int64(0, 0); index = _tmp; max = _tmp$1; - _ref = elts; - _i = 0; - while (_i < _ref.$length) { - e = ((_i < 0 || _i >= _ref.$length) ? $throwRuntimeError("index out of range") : _ref.$array[_ref.$offset + _i]); - validIndex = false; - eval$1 = e; - _tuple = $assertType(e, ($ptrType(ast.KeyValueExpr)), true); kv = _tuple[0]; - if (!(kv === ($ptrType(ast.KeyValueExpr)).nil)) { - _tuple$1 = check.index(kv.Key, length); i = _tuple$1[0]; ok = _tuple$1[1]; - if (ok) { - if ((i.$high > 0 || (i.$high === 0 && i.$low >= 0))) { - index = i; - validIndex = true; - } else { - check.errorf(e.Pos(), "index %s must be integer constant", new ($sliceType($emptyInterface))([kv.Key])); - } - } - eval$1 = kv.Value; - } else if ((length.$high > 0 || (length.$high === 0 && length.$low >= 0)) && (index.$high > length.$high || (index.$high === length.$high && index.$low >= length.$low))) { - check.errorf(e.Pos(), "index %d is out of bounds (>= %d)", new ($sliceType($emptyInterface))([index, length])); - } else { - validIndex = true; - } - if (validIndex) { - if ((_entry = visited[index.$key()], _entry !== undefined ? _entry.v : false)) { - check.errorf(e.Pos(), "duplicate index %d in array or slice literal", new ($sliceType($emptyInterface))([index])); - } - _key$2 = index; (visited || $throwRuntimeError("assignment to entry in nil map"))[_key$2.$key()] = { k: _key$2, v: true }; - } - index = (x = new $Int64(0, 1), new $Int64(index.$high + x.$high, index.$low + x.$low)); - if ((index.$high > max.$high || (index.$high === max.$high && index.$low > max.$low))) { - max = index; - } - x$1 = new operand.Ptr(); $copy(x$1, new operand.Ptr(), operand); - check.exprWithHint(x$1, eval$1, typ); - if (!check.assignment(x$1, typ) && !((x$1.mode === 0))) { - check.errorf(x$1.pos(), "cannot use %s as %s value in array or slice literal", new ($sliceType($emptyInterface))([x$1, typ])); - } - _i++; + parser.prototype.parseLiteralValue = function(typ) { return this.$val.parseLiteralValue(typ); }; + parser.Ptr.prototype.checkExpr = function(x) { + var p, _ref; + p = this; + _ref = unparen(x); + if ($assertType(_ref, ($ptrType(ast.BadExpr)), true)[1]) { + } else if ($assertType(_ref, ($ptrType(ast.Ident)), true)[1]) { + } else if ($assertType(_ref, ($ptrType(ast.BasicLit)), true)[1]) { + } else if ($assertType(_ref, ($ptrType(ast.FuncLit)), true)[1]) { + } else if ($assertType(_ref, ($ptrType(ast.CompositeLit)), true)[1]) { + } else if ($assertType(_ref, ($ptrType(ast.ParenExpr)), true)[1]) { + $panic(new $String("unreachable")); + } else if ($assertType(_ref, ($ptrType(ast.SelectorExpr)), true)[1]) { + } else if ($assertType(_ref, ($ptrType(ast.IndexExpr)), true)[1]) { + } else if ($assertType(_ref, ($ptrType(ast.SliceExpr)), true)[1]) { + } else if ($assertType(_ref, ($ptrType(ast.TypeAssertExpr)), true)[1]) { + } else if ($assertType(_ref, ($ptrType(ast.CallExpr)), true)[1]) { + } else if ($assertType(_ref, ($ptrType(ast.StarExpr)), true)[1]) { + } else if ($assertType(_ref, ($ptrType(ast.UnaryExpr)), true)[1]) { + } else if ($assertType(_ref, ($ptrType(ast.BinaryExpr)), true)[1]) { + } else { + p.errorExpected(x.Pos(), "expression"); + x = new ast.BadExpr.Ptr(x.Pos(), p.safePos(x.End())); } - return max; + return x; }; - Checker.prototype.indexedElts = function(elts, typ, length) { return this.$val.indexedElts(elts, typ, length); }; - Checker.Ptr.prototype.rawExpr = function(x, e, hint) { - var $deferred = [], $err = null, check, kind, typ, val, _ref; - /* */ try { $deferFrames.push($deferred); - check = this; - kind = check.exprInternal(x, e, hint); - typ = $ifaceNil; - val = $ifaceNil; - _ref = x.mode; - if (_ref === 0) { - typ = $pkg.Typ[0]; - } else if (_ref === 1) { - typ = ($ptrType(Tuple)).nil; - } else if (_ref === 4) { - typ = x.typ; - val = x.val; + parser.prototype.checkExpr = function(x) { return this.$val.checkExpr(x); }; + isTypeName = function(x) { + var t, _ref, _tuple, isIdent; + _ref = x; + if ($assertType(_ref, ($ptrType(ast.BadExpr)), true)[1]) { + t = _ref.$val; + } else if ($assertType(_ref, ($ptrType(ast.Ident)), true)[1]) { + t = _ref.$val; + } else if ($assertType(_ref, ($ptrType(ast.SelectorExpr)), true)[1]) { + t = _ref.$val; + _tuple = $assertType(t.X, ($ptrType(ast.Ident)), true); isIdent = _tuple[1]; + return isIdent; } else { - typ = x.typ; + t = _ref; + return false; } - assert(!($interfaceIsEqual(x.expr, $ifaceNil)) && !($interfaceIsEqual(typ, $ifaceNil))); - if (isUntyped(typ)) { - check.rememberUntyped(x.expr, false, x.mode, $assertType(typ, ($ptrType(Basic))), val); + return true; + }; + isLiteralType = function(x) { + var t, _ref, _tuple, isIdent; + _ref = x; + if ($assertType(_ref, ($ptrType(ast.BadExpr)), true)[1]) { + t = _ref.$val; + } else if ($assertType(_ref, ($ptrType(ast.Ident)), true)[1]) { + t = _ref.$val; + } else if ($assertType(_ref, ($ptrType(ast.SelectorExpr)), true)[1]) { + t = _ref.$val; + _tuple = $assertType(t.X, ($ptrType(ast.Ident)), true); isIdent = _tuple[1]; + return isIdent; + } else if ($assertType(_ref, ($ptrType(ast.ArrayType)), true)[1]) { + t = _ref.$val; + } else if ($assertType(_ref, ($ptrType(ast.StructType)), true)[1]) { + t = _ref.$val; + } else if ($assertType(_ref, ($ptrType(ast.MapType)), true)[1]) { + t = _ref.$val; } else { - check.recordTypeAndValue(e, x.mode, typ, val); + t = _ref; + return false; } - return kind; - /* */ } catch(err) { $err = err; return 0; } finally { $deferFrames.pop(); $callDeferred($deferred, $err); } + return true; }; - Checker.prototype.rawExpr = function(x, e, hint) { return this.$val.rawExpr(x, e, hint); }; - Checker.Ptr.prototype.exprInternal = function(x, e, hint) { - var $this = this, $args = arguments, $s = 0, check, e$1, _ref, _tuple, sig, ok, typ, openArray, _tuple$1, atyp, _tuple$2, ellip, _tuple$3, typ$1, utyp, _ref$1, fields, _tuple$4, x$1, ok$1, visited, _ref$2, _i, e$2, _tuple$5, kv, _tuple$6, key, i, fld, etyp, _ref$3, _i$1, i$1, e$3, _tuple$7, kv$1, etyp$1, n, visited$1, _ref$4, _i$2, e$4, _tuple$8, kv$2, duplicate, _tuple$9, ok$2, _ref$5, _entry, _i$3, vtyp, _entry$1, _key$2, _tuple$10, _entry$2, _key$3, kind, valid, length, typ$2, _ref$6, _tuple$11, typ$3, key$1, valid$1, length$1, typ$4, _ref$7, _tuple$12, typ$5, ind, _ref$8, _i$4, i$2, expr, x$2, max, _tuple$13, t, ok$3, _ref$9, _i$5, i$3, x$3, _ref$10, _i$6, y, _tuple$14, xtyp, T, _ref$11, _tuple$15, typ$6, ok$4, x$4; - /* */ while (true) { switch ($s) { case 0: - check = $this; - x.mode = 0; - x.typ = $pkg.Typ[0]; - _ref = e; - /* if ($assertType(_ref, ($ptrType(ast.BadExpr)), true)[1]) { */ if ($assertType(_ref, ($ptrType(ast.BadExpr)), true)[1]) {} else if ($assertType(_ref, ($ptrType(ast.Ident)), true)[1]) { $s = 2; continue; } else if ($assertType(_ref, ($ptrType(ast.Ellipsis)), true)[1]) { $s = 3; continue; } else if ($assertType(_ref, ($ptrType(ast.BasicLit)), true)[1]) { $s = 4; continue; } else if ($assertType(_ref, ($ptrType(ast.FuncLit)), true)[1]) { $s = 5; continue; } else if ($assertType(_ref, ($ptrType(ast.CompositeLit)), true)[1]) { $s = 6; continue; } else if ($assertType(_ref, ($ptrType(ast.ParenExpr)), true)[1]) { $s = 7; continue; } else if ($assertType(_ref, ($ptrType(ast.SelectorExpr)), true)[1]) { $s = 8; continue; } else if ($assertType(_ref, ($ptrType(ast.IndexExpr)), true)[1]) { $s = 9; continue; } else if ($assertType(_ref, ($ptrType(ast.SliceExpr)), true)[1]) { $s = 10; continue; } else if ($assertType(_ref, ($ptrType(ast.TypeAssertExpr)), true)[1]) { $s = 11; continue; } else if ($assertType(_ref, ($ptrType(ast.CallExpr)), true)[1]) { $s = 12; continue; } else if ($assertType(_ref, ($ptrType(ast.StarExpr)), true)[1]) { $s = 13; continue; } else if ($assertType(_ref, ($ptrType(ast.UnaryExpr)), true)[1]) { $s = 14; continue; } else if ($assertType(_ref, ($ptrType(ast.BinaryExpr)), true)[1]) { $s = 15; continue; } else if ($assertType(_ref, ($ptrType(ast.KeyValueExpr)), true)[1]) { $s = 16; continue; } else if ($assertType(_ref, ($ptrType(ast.ArrayType)), true)[1] || $assertType(_ref, ($ptrType(ast.StructType)), true)[1] || $assertType(_ref, ($ptrType(ast.FuncType)), true)[1] || $assertType(_ref, ($ptrType(ast.InterfaceType)), true)[1] || $assertType(_ref, ($ptrType(ast.MapType)), true)[1] || $assertType(_ref, ($ptrType(ast.ChanType)), true)[1]) { $s = 17; continue; } else { $s = 18; continue; } - e$1 = _ref.$val; - /* goto Error */ $s = 1; continue; - /* } else if ($assertType(_ref, ($ptrType(ast.Ident)), true)[1]) { */ $s = 19; continue; case 2: - e$1 = _ref.$val; - check.ident(x, e$1, ($ptrType(Named)).nil, ($sliceType(($ptrType(TypeName)))).nil); - /* } else if ($assertType(_ref, ($ptrType(ast.Ellipsis)), true)[1]) { */ $s = 19; continue; case 3: - e$1 = _ref.$val; - check.error(e$1.Pos(), "invalid use of '...'"); - /* goto Error */ $s = 1; continue; - /* } else if ($assertType(_ref, ($ptrType(ast.BasicLit)), true)[1]) { */ $s = 19; continue; case 4: - e$1 = _ref.$val; - x.setConst(e$1.Kind, e$1.Value); - /* if (x.mode === 0) { */ if (x.mode === 0) {} else { $s = 20; continue; } - check.invalidAST(e$1.Pos(), "invalid literal %v", new ($sliceType($emptyInterface))([new $String(e$1.Value)])); - /* goto Error */ $s = 1; continue; - /* } */ case 20: - /* } else if ($assertType(_ref, ($ptrType(ast.FuncLit)), true)[1]) { */ $s = 19; continue; case 5: - e$1 = _ref.$val; - _tuple = $assertType(check.typ(e$1.Type), ($ptrType(Signature)), true); sig = _tuple[0]; ok = _tuple[1]; - /* if (ok) { */ if (ok) {} else { $s = 21; continue; } - check.funcBody(check.context.decl, "", sig, e$1.Body); - x.mode = 7; - x.typ = sig; - /* } else { */ $s = 22; continue; case 21: - check.invalidAST(e$1.Pos(), "invalid function literal %s", new ($sliceType($emptyInterface))([e$1])); - /* goto Error */ $s = 1; continue; - /* } */ case 22: - /* } else if ($assertType(_ref, ($ptrType(ast.CompositeLit)), true)[1]) { */ $s = 19; continue; case 6: - e$1 = _ref.$val; - typ = hint; - openArray = false; - if (!($interfaceIsEqual(e$1.Type, $ifaceNil))) { - typ = $ifaceNil; - _tuple$1 = $assertType(e$1.Type, ($ptrType(ast.ArrayType)), true); atyp = _tuple$1[0]; - if (!(atyp === ($ptrType(ast.ArrayType)).nil) && !($interfaceIsEqual(atyp.Len, $ifaceNil))) { - _tuple$2 = $assertType(atyp.Len, ($ptrType(ast.Ellipsis)), true); ellip = _tuple$2[0]; - if (!(ellip === ($ptrType(ast.Ellipsis)).nil) && $interfaceIsEqual(ellip.Elt, $ifaceNil)) { - typ = new Array.Ptr(new $Int64(-1, 4294967295), check.typ(atyp.Elt)); - openArray = true; - } - } - if ($interfaceIsEqual(typ, $ifaceNil)) { - typ = check.typ(e$1.Type); - } + deref = function(x) { + var _tuple, p, isPtr; + _tuple = $assertType(x, ($ptrType(ast.StarExpr)), true); p = _tuple[0]; isPtr = _tuple[1]; + if (isPtr) { + x = p.X; + } + return x; + }; + unparen = function(x) { + var _tuple, p, isParen; + _tuple = $assertType(x, ($ptrType(ast.ParenExpr)), true); p = _tuple[0]; isParen = _tuple[1]; + if (isParen) { + x = unparen(p.X); + } + return x; + }; + parser.Ptr.prototype.checkExprOrType = function(x) { + var p, t, _ref, _tuple, len, isEllipsis; + p = this; + _ref = unparen(x); + if ($assertType(_ref, ($ptrType(ast.ParenExpr)), true)[1]) { + t = _ref.$val; + $panic(new $String("unreachable")); + } else if ($assertType(_ref, ($ptrType(ast.UnaryExpr)), true)[1]) { + t = _ref.$val; + } else if ($assertType(_ref, ($ptrType(ast.ArrayType)), true)[1]) { + t = _ref.$val; + _tuple = $assertType(t.Len, ($ptrType(ast.Ellipsis)), true); len = _tuple[0]; isEllipsis = _tuple[1]; + if (isEllipsis) { + p.error(len.Pos(), "expected array length, found '...'"); + x = new ast.BadExpr.Ptr(x.Pos(), p.safePos(x.End())); } - /* if ($interfaceIsEqual(typ, $ifaceNil)) { */ if ($interfaceIsEqual(typ, $ifaceNil)) {} else { $s = 23; continue; } - check.error(e$1.Pos(), "missing type in composite literal"); - /* goto Error */ $s = 1; continue; - /* } */ case 23: - _tuple$3 = deref(typ); typ$1 = _tuple$3[0]; - _ref$1 = typ$1.Underlying(); - /* switch (0) { default: if ($assertType(_ref$1, ($ptrType(Struct)), true)[1]) { */ if ($assertType(_ref$1, ($ptrType(Struct)), true)[1]) {} else if ($assertType(_ref$1, ($ptrType(Array)), true)[1]) { $s = 24; continue; } else if ($assertType(_ref$1, ($ptrType(Slice)), true)[1]) { $s = 25; continue; } else if ($assertType(_ref$1, ($ptrType(Map)), true)[1]) { $s = 26; continue; } else { $s = 27; continue; } - utyp = _ref$1.$val; - if (e$1.Elts.$length === 0) { - /* break; */ $s = 28; continue; + } + return x; + }; + parser.prototype.checkExprOrType = function(x) { return this.$val.checkExprOrType(x); }; + parser.Ptr.prototype.parsePrimaryExpr = function(lhs) { + var $deferred = [], $err = null, p, x, _ref, _ref$1, pos; + /* */ try { $deferFrames.push($deferred); + p = this; + if (p.trace) { + $deferred.push([un, [trace(p, "PrimaryExpr")]]); + } + x = p.parseOperand(lhs); + L: + while (true) { + _ref = p.tok; + if (_ref === 53) { + p.next(); + if (lhs) { + p.resolve(x); } - fields = utyp.fields; - _tuple$4 = $assertType((x$1 = e$1.Elts, ((0 < 0 || 0 >= x$1.$length) ? $throwRuntimeError("index out of range") : x$1.$array[x$1.$offset + 0])), ($ptrType(ast.KeyValueExpr)), true); ok$1 = _tuple$4[1]; - if (ok$1) { - visited = ($sliceType($Bool)).make(fields.$length); - _ref$2 = e$1.Elts; - _i = 0; - while (_i < _ref$2.$length) { - e$2 = ((_i < 0 || _i >= _ref$2.$length) ? $throwRuntimeError("index out of range") : _ref$2.$array[_ref$2.$offset + _i]); - _tuple$5 = $assertType(e$2, ($ptrType(ast.KeyValueExpr)), true); kv = _tuple$5[0]; - if (kv === ($ptrType(ast.KeyValueExpr)).nil) { - check.error(e$2.Pos(), "mixture of field:value and value elements in struct literal"); - _i++; - continue; - } - _tuple$6 = $assertType(kv.Key, ($ptrType(ast.Ident)), true); key = _tuple$6[0]; - if (key === ($ptrType(ast.Ident)).nil) { - check.errorf(kv.Pos(), "invalid field name %s in struct literal", new ($sliceType($emptyInterface))([kv.Key])); - _i++; - continue; - } - i = fieldIndex(utyp.fields, check.pkg, key.Name); - if (i < 0) { - check.errorf(kv.Pos(), "unknown field %s in struct literal", new ($sliceType($emptyInterface))([new $String(key.Name)])); - _i++; - continue; - } - fld = ((i < 0 || i >= fields.$length) ? $throwRuntimeError("index out of range") : fields.$array[fields.$offset + i]); - check.recordUse(key, fld); - if (((i < 0 || i >= visited.$length) ? $throwRuntimeError("index out of range") : visited.$array[visited.$offset + i])) { - check.errorf(kv.Pos(), "duplicate field name %s in struct literal", new ($sliceType($emptyInterface))([new $String(key.Name)])); - _i++; - continue; - } - (i < 0 || i >= visited.$length) ? $throwRuntimeError("index out of range") : visited.$array[visited.$offset + i] = true; - check.expr(x, kv.Value); - etyp = fld.object.typ; - if (!check.assignment(x, etyp)) { - if (!((x.mode === 0))) { - check.errorf(x.pos(), "cannot use %s as %s value in struct literal", new ($sliceType($emptyInterface))([x, etyp])); - } - _i++; - continue; - } - _i++; - } + _ref$1 = p.tok; + if (_ref$1 === 4) { + x = p.parseSelector(p.checkExprOrType(x)); + } else if (_ref$1 === 49) { + x = p.parseTypeAssertion(p.checkExpr(x)); } else { - _ref$3 = e$1.Elts; - _i$1 = 0; - while (_i$1 < _ref$3.$length) { - i$1 = _i$1; - e$3 = ((_i$1 < 0 || _i$1 >= _ref$3.$length) ? $throwRuntimeError("index out of range") : _ref$3.$array[_ref$3.$offset + _i$1]); - _tuple$7 = $assertType(e$3, ($ptrType(ast.KeyValueExpr)), true); kv$1 = _tuple$7[0]; - if (!(kv$1 === ($ptrType(ast.KeyValueExpr)).nil)) { - check.error(kv$1.Pos(), "mixture of field:value and value elements in struct literal"); - _i$1++; - continue; - } - check.expr(x, e$3); - if (i$1 >= fields.$length) { - check.error(x.pos(), "too many values in struct literal"); - break; - } - etyp$1 = ((i$1 < 0 || i$1 >= fields.$length) ? $throwRuntimeError("index out of range") : fields.$array[fields.$offset + i$1]).object.typ; - if (!check.assignment(x, etyp$1)) { - if (!((x.mode === 0))) { - check.errorf(x.pos(), "cannot use %s as %s value in struct literal", new ($sliceType($emptyInterface))([x, etyp$1])); - } - _i$1++; - continue; - } - _i$1++; - } - if (e$1.Elts.$length < fields.$length) { - check.error(e$1.Rbrace, "too few values in struct literal"); - } - } - /* } else if ($assertType(_ref$1, ($ptrType(Array)), true)[1]) { */ $s = 28; continue; case 24: - utyp = _ref$1.$val; - n = check.indexedElts(e$1.Elts, utyp.elem, utyp.len); - if (openArray) { - utyp.len = n; - } - /* } else if ($assertType(_ref$1, ($ptrType(Slice)), true)[1]) { */ $s = 28; continue; case 25: - utyp = _ref$1.$val; - check.indexedElts(e$1.Elts, utyp.elem, new $Int64(-1, 4294967295)); - /* } else if ($assertType(_ref$1, ($ptrType(Map)), true)[1]) { */ $s = 28; continue; case 26: - utyp = _ref$1.$val; - visited$1 = new $Map(); - _ref$4 = e$1.Elts; - _i$2 = 0; - while (_i$2 < _ref$4.$length) { - e$4 = ((_i$2 < 0 || _i$2 >= _ref$4.$length) ? $throwRuntimeError("index out of range") : _ref$4.$array[_ref$4.$offset + _i$2]); - _tuple$8 = $assertType(e$4, ($ptrType(ast.KeyValueExpr)), true); kv$2 = _tuple$8[0]; - if (kv$2 === ($ptrType(ast.KeyValueExpr)).nil) { - check.error(e$4.Pos(), "missing key in map literal"); - _i$2++; - continue; - } - check.expr(x, kv$2.Key); - if (!check.assignment(x, utyp.key)) { - if (!((x.mode === 0))) { - check.errorf(x.pos(), "cannot use %s as %s key in map literal", new ($sliceType($emptyInterface))([x, utyp.key])); - } - _i$2++; - continue; - } - if (x.mode === 4) { - duplicate = false; - _tuple$9 = $assertType(utyp.key.Underlying(), ($ptrType(Interface)), true); ok$2 = _tuple$9[1]; - if (ok$2) { - _ref$5 = (_entry = visited$1[x.val.$key()], _entry !== undefined ? _entry.v : ($sliceType(Type)).nil); - _i$3 = 0; - while (_i$3 < _ref$5.$length) { - vtyp = ((_i$3 < 0 || _i$3 >= _ref$5.$length) ? $throwRuntimeError("index out of range") : _ref$5.$array[_ref$5.$offset + _i$3]); - if (Identical(vtyp, x.typ)) { - duplicate = true; - break; - } - _i$3++; - } - _key$2 = x.val; (visited$1 || $throwRuntimeError("assignment to entry in nil map"))[_key$2.$key()] = { k: _key$2, v: $append((_entry$1 = visited$1[x.val.$key()], _entry$1 !== undefined ? _entry$1.v : ($sliceType(Type)).nil), x.typ) }; - } else { - _tuple$10 = (_entry$2 = visited$1[x.val.$key()], _entry$2 !== undefined ? [_entry$2.v, true] : [($sliceType(Type)).nil, false]); duplicate = _tuple$10[1]; - _key$3 = x.val; (visited$1 || $throwRuntimeError("assignment to entry in nil map"))[_key$3.$key()] = { k: _key$3, v: ($sliceType(Type)).nil }; - } - if (duplicate) { - check.errorf(x.pos(), "duplicate key %s in map literal", new ($sliceType($emptyInterface))([x.val])); - _i$2++; - continue; - } - } - check.exprWithHint(x, kv$2.Value, utyp.elem); - if (!check.assignment(x, utyp.elem)) { - if (!((x.mode === 0))) { - check.errorf(x.pos(), "cannot use %s as %s value in map literal", new ($sliceType($emptyInterface))([x, utyp.elem])); - } - _i$2++; - continue; - } - _i$2++; - } - /* } else { */ $s = 28; continue; case 27: - utyp = _ref$1; - check.errorf(e$1.Pos(), "invalid composite literal type %s", new ($sliceType($emptyInterface))([typ$1])); - /* goto Error */ $s = 1; continue; - /* } } */ case 28: - x.mode = 7; - x.typ = typ; - /* } else if ($assertType(_ref, ($ptrType(ast.ParenExpr)), true)[1]) { */ $s = 19; continue; case 7: - e$1 = _ref.$val; - kind = check.rawExpr(x, e$1.X, $ifaceNil); - x.expr = e$1; - return kind; - /* } else if ($assertType(_ref, ($ptrType(ast.SelectorExpr)), true)[1]) { */ $s = 19; continue; case 8: - e$1 = _ref.$val; - check.selector(x, e$1); - /* } else if ($assertType(_ref, ($ptrType(ast.IndexExpr)), true)[1]) { */ $s = 19; continue; case 9: - e$1 = _ref.$val; - check.expr(x, e$1.X); - /* if (x.mode === 0) { */ if (x.mode === 0) {} else { $s = 29; continue; } - /* goto Error */ $s = 1; continue; - /* } */ case 29: - valid = false; - length = new $Int64(-1, 4294967295); - _ref$6 = x.typ.Underlying(); - /* if ($assertType(_ref$6, ($ptrType(Basic)), true)[1]) { */ if ($assertType(_ref$6, ($ptrType(Basic)), true)[1]) {} else if ($assertType(_ref$6, ($ptrType(Array)), true)[1]) { $s = 30; continue; } else if ($assertType(_ref$6, ($ptrType(Pointer)), true)[1]) { $s = 31; continue; } else if ($assertType(_ref$6, ($ptrType(Slice)), true)[1]) { $s = 32; continue; } else if ($assertType(_ref$6, ($ptrType(Map)), true)[1]) { $s = 33; continue; } else { $s = 34; continue; } - typ$2 = _ref$6.$val; - if (isString(typ$2)) { - valid = true; - if (x.mode === 4) { - length = new $Int64(0, exact.StringVal(x.val).length); - } - x.mode = 7; - x.typ = $pkg.UniverseByte; - } - /* } else if ($assertType(_ref$6, ($ptrType(Array)), true)[1]) { */ $s = 34; continue; case 30: - typ$2 = _ref$6.$val; - valid = true; - length = typ$2.len; - if (!((x.mode === 5))) { - x.mode = 7; + pos = p.pos; + p.errorExpected(pos, "selector or type assertion"); + p.next(); + x = new ast.BadExpr.Ptr(pos, p.pos); } - x.typ = typ$2.elem; - /* } else if ($assertType(_ref$6, ($ptrType(Pointer)), true)[1]) { */ $s = 34; continue; case 31: - typ$2 = _ref$6.$val; - _tuple$11 = $assertType(typ$2.base.Underlying(), ($ptrType(Array)), true); typ$3 = _tuple$11[0]; - if (!(typ$3 === ($ptrType(Array)).nil)) { - valid = true; - length = typ$3.len; - x.mode = 5; - x.typ = typ$3.elem; + } else if (_ref === 50) { + if (lhs) { + p.resolve(x); } - /* } else if ($assertType(_ref$6, ($ptrType(Slice)), true)[1]) { */ $s = 34; continue; case 32: - typ$2 = _ref$6.$val; - valid = true; - x.mode = 5; - x.typ = typ$2.elem; - /* } else if ($assertType(_ref$6, ($ptrType(Map)), true)[1]) { */ $s = 34; continue; case 33: - typ$2 = _ref$6.$val; - key$1 = new operand.Ptr(); $copy(key$1, new operand.Ptr(), operand); - check.expr(key$1, e$1.Index); - /* if (!check.assignment(key$1, typ$2.key)) { */ if (!check.assignment(key$1, typ$2.key)) {} else { $s = 35; continue; } - if (!((key$1.mode === 0))) { - check.invalidOp(key$1.pos(), "cannot use %s as map index of type %s", new ($sliceType($emptyInterface))([key$1, typ$2.key])); - } - /* goto Error */ $s = 1; continue; - /* } */ case 35: - x.mode = 6; - x.typ = typ$2.elem; - x.expr = e$1; - return 1; - /* } */ case 34: - /* if (!valid) { */ if (!valid) {} else { $s = 36; continue; } - check.invalidOp(x.pos(), "cannot index %s", new ($sliceType($emptyInterface))([x])); - /* goto Error */ $s = 1; continue; - /* } */ case 36: - /* if ($interfaceIsEqual(e$1.Index, $ifaceNil)) { */ if ($interfaceIsEqual(e$1.Index, $ifaceNil)) {} else { $s = 37; continue; } - check.invalidAST(e$1.Pos(), "missing index for %s", new ($sliceType($emptyInterface))([x])); - /* goto Error */ $s = 1; continue; - /* } */ case 37: - check.index(e$1.Index, length); - /* } else if ($assertType(_ref, ($ptrType(ast.SliceExpr)), true)[1]) { */ $s = 19; continue; case 10: - e$1 = _ref.$val; - check.expr(x, e$1.X); - /* if (x.mode === 0) { */ if (x.mode === 0) {} else { $s = 38; continue; } - /* goto Error */ $s = 1; continue; - /* } */ case 38: - valid$1 = false; - length$1 = new $Int64(-1, 4294967295); - _ref$7 = x.typ.Underlying(); - /* if ($assertType(_ref$7, ($ptrType(Basic)), true)[1]) { */ if ($assertType(_ref$7, ($ptrType(Basic)), true)[1]) {} else if ($assertType(_ref$7, ($ptrType(Array)), true)[1]) { $s = 39; continue; } else if ($assertType(_ref$7, ($ptrType(Pointer)), true)[1]) { $s = 40; continue; } else if ($assertType(_ref$7, ($ptrType(Slice)), true)[1]) { $s = 41; continue; } else { $s = 42; continue; } - typ$4 = _ref$7.$val; - /* if (isString(typ$4)) { */ if (isString(typ$4)) {} else { $s = 43; continue; } - /* if (slice3(e$1)) { */ if (slice3(e$1)) {} else { $s = 44; continue; } - check.invalidOp(x.pos(), "3-index slice of string", new ($sliceType($emptyInterface))([])); - /* goto Error */ $s = 1; continue; - /* } */ case 44: - valid$1 = true; - if (x.mode === 4) { - length$1 = new $Int64(0, exact.StringVal(x.val).length); - } - if (typ$4.kind === 24) { - x.typ = $pkg.Typ[17]; - } - /* } */ case 43: - /* } else if ($assertType(_ref$7, ($ptrType(Array)), true)[1]) { */ $s = 42; continue; case 39: - typ$4 = _ref$7.$val; - valid$1 = true; - length$1 = typ$4.len; - /* if (!((x.mode === 5))) { */ if (!((x.mode === 5))) {} else { $s = 45; continue; } - check.invalidOp(x.pos(), "cannot slice %s (value not addressable)", new ($sliceType($emptyInterface))([x])); - /* goto Error */ $s = 1; continue; - /* } */ case 45: - x.typ = new Slice.Ptr(typ$4.elem); - /* } else if ($assertType(_ref$7, ($ptrType(Pointer)), true)[1]) { */ $s = 42; continue; case 40: - typ$4 = _ref$7.$val; - _tuple$12 = $assertType(typ$4.base.Underlying(), ($ptrType(Array)), true); typ$5 = _tuple$12[0]; - if (!(typ$5 === ($ptrType(Array)).nil)) { - valid$1 = true; - length$1 = typ$5.len; - x.typ = new Slice.Ptr(typ$5.elem); + x = p.parseIndexOrSlice(p.checkExpr(x)); + } else if (_ref === 49) { + if (lhs) { + p.resolve(x); } - /* } else if ($assertType(_ref$7, ($ptrType(Slice)), true)[1]) { */ $s = 42; continue; case 41: - typ$4 = _ref$7.$val; - valid$1 = true; - /* } */ case 42: - /* if (!valid$1) { */ if (!valid$1) {} else { $s = 46; continue; } - check.invalidOp(x.pos(), "cannot slice %s", new ($sliceType($emptyInterface))([x])); - /* goto Error */ $s = 1; continue; - /* } */ case 46: - x.mode = 7; - /* if (slice3(e$1) && ($interfaceIsEqual(e$1.High, $ifaceNil) || $interfaceIsEqual(sliceMax(e$1), $ifaceNil))) { */ if (slice3(e$1) && ($interfaceIsEqual(e$1.High, $ifaceNil) || $interfaceIsEqual(sliceMax(e$1), $ifaceNil))) {} else { $s = 47; continue; } - check.error(e$1.Rbrack, "2nd and 3rd index required in 3-index slice"); - /* goto Error */ $s = 1; continue; - /* } */ case 47: - ind = ($arrayType($Int64, 3)).zero(); $copy(ind, ($arrayType($Int64, 3)).zero(), ($arrayType($Int64, 3))); - _ref$8 = new ($sliceType(ast.Expr))([e$1.Low, e$1.High, sliceMax(e$1)]); - _i$4 = 0; - while (_i$4 < _ref$8.$length) { - i$2 = _i$4; - expr = ((_i$4 < 0 || _i$4 >= _ref$8.$length) ? $throwRuntimeError("index out of range") : _ref$8.$array[_ref$8.$offset + _i$4]); - x$2 = new $Int64(-1, 4294967295); - if (!($interfaceIsEqual(expr, $ifaceNil))) { - max = new $Int64(-1, 4294967295); - if ((length$1.$high > 0 || (length$1.$high === 0 && length$1.$low >= 0))) { - max = new $Int64(length$1.$high + 0, length$1.$low + 1); - } - _tuple$13 = check.index(expr, max); t = _tuple$13[0]; ok$3 = _tuple$13[1]; - if (ok$3 && (t.$high > 0 || (t.$high === 0 && t.$low >= 0))) { - x$2 = t; + x = p.parseCallOrConversion(p.checkExprOrType(x)); + } else if (_ref === 51) { + if (isLiteralType(x) && (p.exprLev >= 0 || !isTypeName(x))) { + if (lhs) { + p.resolve(x); } - } else if (i$2 === 0) { - x$2 = new $Int64(0, 0); - } else if ((length$1.$high > 0 || (length$1.$high === 0 && length$1.$low >= 0))) { - x$2 = length$1; + x = p.parseLiteralValue(x); + } else { + break L; } - (i$2 < 0 || i$2 >= ind.length) ? $throwRuntimeError("index out of range") : ind[i$2] = x$2; - _i$4++; + } else { + break L; } - _ref$9 = $subslice(new ($sliceType($Int64))(ind), 0, 2); - _i$5 = 0; - L: - while (_i$5 < _ref$9.$length) { - i$3 = _i$5; - x$3 = ((_i$5 < 0 || _i$5 >= _ref$9.$length) ? $throwRuntimeError("index out of range") : _ref$9.$array[_ref$9.$offset + _i$5]); - if ((x$3.$high > 0 || (x$3.$high === 0 && x$3.$low > 0))) { - _ref$10 = $subslice(new ($sliceType($Int64))(ind), (i$3 + 1 >> 0)); - _i$6 = 0; - while (_i$6 < _ref$10.$length) { - y = ((_i$6 < 0 || _i$6 >= _ref$10.$length) ? $throwRuntimeError("index out of range") : _ref$10.$array[_ref$10.$offset + _i$6]); - if ((y.$high > 0 || (y.$high === 0 && y.$low >= 0)) && (x$3.$high > y.$high || (x$3.$high === y.$high && x$3.$low > y.$low))) { - check.errorf(e$1.Rbrack, "invalid slice indices: %d > %d", new ($sliceType($emptyInterface))([x$3, y])); - break L; - } - _i$6++; + lhs = false; + } + return x; + /* */ } catch(err) { $err = err; return $ifaceNil; } finally { $deferFrames.pop(); $callDeferred($deferred, $err); } + }; + parser.prototype.parsePrimaryExpr = function(lhs) { return this.$val.parsePrimaryExpr(lhs); }; + parser.Ptr.prototype.parseUnaryExpr = function(lhs) { + var $deferred = [], $err = null, p, _ref, _tmp, _tmp$1, pos, op, x, arrow, x$1, _tuple, typ, ok, dir, _tmp$2, _tmp$3, _tmp$4, _tmp$5, _tmp$6, _tuple$1, pos$1, x$2; + /* */ try { $deferFrames.push($deferred); + p = this; + if (p.trace) { + $deferred.push([un, [trace(p, "UnaryExpr")]]); + } + _ref = p.tok; + if (_ref === 12 || _ref === 13 || _ref === 43 || _ref === 19 || _ref === 17) { + _tmp = p.pos; _tmp$1 = p.tok; pos = _tmp; op = _tmp$1; + p.next(); + x = p.parseUnaryExpr(false); + return new ast.UnaryExpr.Ptr(pos, op, p.checkExpr(x)); + } else if (_ref === 36) { + arrow = p.pos; + p.next(); + x$1 = p.parseUnaryExpr(false); + _tuple = $assertType(x$1, ($ptrType(ast.ChanType)), true); typ = _tuple[0]; ok = _tuple[1]; + if (ok) { + dir = 1; + while (ok && (dir === 1)) { + if (typ.Dir === 2) { + p.errorExpected(typ.Arrow, "'chan'"); } + _tmp$2 = typ.Arrow; _tmp$3 = arrow; _tmp$4 = arrow; arrow = _tmp$2; typ.Begin = _tmp$3; typ.Arrow = _tmp$4; + _tmp$5 = typ.Dir; _tmp$6 = 2; dir = _tmp$5; typ.Dir = _tmp$6; + _tuple$1 = $assertType(typ.Value, ($ptrType(ast.ChanType)), true); typ = _tuple$1[0]; ok = _tuple$1[1]; } - _i$5++; + if (dir === 1) { + p.errorExpected(arrow, "channel type"); + } + return x$1; } - /* } else if ($assertType(_ref, ($ptrType(ast.TypeAssertExpr)), true)[1]) { */ $s = 19; continue; case 11: - e$1 = _ref.$val; - check.expr(x, e$1.X); - /* if (x.mode === 0) { */ if (x.mode === 0) {} else { $s = 48; continue; } - /* goto Error */ $s = 1; continue; - /* } */ case 48: - _tuple$14 = $assertType(x.typ.Underlying(), ($ptrType(Interface)), true); xtyp = _tuple$14[0]; - /* if (xtyp === ($ptrType(Interface)).nil) { */ if (xtyp === ($ptrType(Interface)).nil) {} else { $s = 49; continue; } - check.invalidOp(x.pos(), "%s is not an interface", new ($sliceType($emptyInterface))([x])); - /* goto Error */ $s = 1; continue; - /* } */ case 49: - /* if ($interfaceIsEqual(e$1.Type, $ifaceNil)) { */ if ($interfaceIsEqual(e$1.Type, $ifaceNil)) {} else { $s = 50; continue; } - check.invalidAST(e$1.Pos(), "use of .(type) outside type switch", new ($sliceType($emptyInterface))([])); - /* goto Error */ $s = 1; continue; - /* } */ case 50: - T = check.typ(e$1.Type); - /* if ($interfaceIsEqual(T, $pkg.Typ[0])) { */ if ($interfaceIsEqual(T, $pkg.Typ[0])) {} else { $s = 51; continue; } - /* goto Error */ $s = 1; continue; - /* } */ case 51: - check.typeAssertion(x.pos(), x, xtyp, T); - x.mode = 8; - x.typ = T; - /* } else if ($assertType(_ref, ($ptrType(ast.CallExpr)), true)[1]) { */ $s = 19; continue; case 12: - e$1 = _ref.$val; - return check.call(x, e$1); - /* } else if ($assertType(_ref, ($ptrType(ast.StarExpr)), true)[1]) { */ $s = 19; continue; case 13: - e$1 = _ref.$val; - check.exprOrType(x, e$1.X); - _ref$11 = x.mode; - /* if (_ref$11 === 0) { */ if (_ref$11 === 0) {} else if (_ref$11 === 3) { $s = 52; continue; } else { $s = 53; continue; } - /* goto Error */ $s = 1; continue; - /* } else if (_ref$11 === 3) { */ $s = 54; continue; case 52: - x.typ = new Pointer.Ptr(x.typ); - /* } else { */ $s = 54; continue; case 53: - _tuple$15 = $assertType(x.typ.Underlying(), ($ptrType(Pointer)), true); typ$6 = _tuple$15[0]; ok$4 = _tuple$15[1]; - /* if (ok$4) { */ if (ok$4) {} else { $s = 55; continue; } - x.mode = 5; - x.typ = typ$6.base; - /* } else { */ $s = 56; continue; case 55: - check.invalidOp(x.pos(), "cannot indirect %s", new ($sliceType($emptyInterface))([x])); - /* goto Error */ $s = 1; continue; - /* } */ case 56: - /* } */ case 54: - /* } else if ($assertType(_ref, ($ptrType(ast.UnaryExpr)), true)[1]) { */ $s = 19; continue; case 14: - e$1 = _ref.$val; - check.expr(x, e$1.X); - /* if (x.mode === 0) { */ if (x.mode === 0) {} else { $s = 57; continue; } - /* goto Error */ $s = 1; continue; - /* } */ case 57: - check.unary(x, e$1.Op); - /* if (x.mode === 0) { */ if (x.mode === 0) {} else { $s = 58; continue; } - /* goto Error */ $s = 1; continue; - /* } */ case 58: - if (e$1.Op === 36) { - x.expr = e$1; - return 2; + return new ast.UnaryExpr.Ptr(arrow, 36, p.checkExpr(x$1)); + } else if (_ref === 14) { + pos$1 = p.pos; + p.next(); + x$2 = p.parseUnaryExpr(false); + return new ast.StarExpr.Ptr(pos$1, p.checkExprOrType(x$2)); + } + return p.parsePrimaryExpr(lhs); + /* */ } catch(err) { $err = err; return $ifaceNil; } finally { $deferFrames.pop(); $callDeferred($deferred, $err); } + }; + parser.prototype.parseUnaryExpr = function(lhs) { return this.$val.parseUnaryExpr(lhs); }; + parser.Ptr.prototype.tokPrec = function() { + var p, tok; + p = this; + tok = p.tok; + if (p.inRhs && (tok === 42)) { + tok = 39; + } + return [tok, (new token.Token(tok)).Precedence()]; + }; + parser.prototype.tokPrec = function() { return this.$val.tokPrec(); }; + parser.Ptr.prototype.parseBinaryExpr = function(lhs, prec1) { + var $deferred = [], $err = null, p, x, _tuple, prec, _tuple$1, op, oprec, pos, y; + /* */ try { $deferFrames.push($deferred); + p = this; + if (p.trace) { + $deferred.push([un, [trace(p, "BinaryExpr")]]); + } + x = p.parseUnaryExpr(lhs); + _tuple = p.tokPrec(); prec = _tuple[1]; + while (prec >= prec1) { + while (true) { + _tuple$1 = p.tokPrec(); op = _tuple$1[0]; oprec = _tuple$1[1]; + if (!((oprec === prec))) { + break; + } + pos = p.expect(op); + if (lhs) { + p.resolve(x); + lhs = false; + } + y = p.parseBinaryExpr(false, prec + 1 >> 0); + x = new ast.BinaryExpr.Ptr(p.checkExpr(x), pos, op, p.checkExpr(y)); } - /* } else if ($assertType(_ref, ($ptrType(ast.BinaryExpr)), true)[1]) { */ $s = 19; continue; case 15: - e$1 = _ref.$val; - check.binary(x, e$1.X, e$1.Y, e$1.Op); - /* if (x.mode === 0) { */ if (x.mode === 0) {} else { $s = 59; continue; } - /* goto Error */ $s = 1; continue; - /* } */ case 59: - /* } else if ($assertType(_ref, ($ptrType(ast.KeyValueExpr)), true)[1]) { */ $s = 19; continue; case 16: - e$1 = _ref.$val; - check.invalidAST(e$1.Pos(), "no key:value expected", new ($sliceType($emptyInterface))([])); - /* goto Error */ $s = 1; continue; - /* } else if ($assertType(_ref, ($ptrType(ast.ArrayType)), true)[1] || $assertType(_ref, ($ptrType(ast.StructType)), true)[1] || $assertType(_ref, ($ptrType(ast.FuncType)), true)[1] || $assertType(_ref, ($ptrType(ast.InterfaceType)), true)[1] || $assertType(_ref, ($ptrType(ast.MapType)), true)[1] || $assertType(_ref, ($ptrType(ast.ChanType)), true)[1]) { */ $s = 19; continue; case 17: - e$1 = _ref; - x.mode = 3; - x.typ = check.typ(e$1); - /* } else { */ $s = 19; continue; case 18: - e$1 = _ref; - $panic(new $String(fmt.Sprintf("%s: unknown expression type %T", new ($sliceType($emptyInterface))([(x$4 = check.fset.Position(e$1.Pos()), new x$4.constructor.Struct(x$4)), e$1])))); - /* } */ case 19: - x.expr = e; - return 1; - /* Error: */ case 1: - x.mode = 0; - x.expr = e; - return 2; - /* */ case -1: } return; } + prec = prec - (1) >> 0; + } + return x; + /* */ } catch(err) { $err = err; return $ifaceNil; } finally { $deferFrames.pop(); $callDeferred($deferred, $err); } }; - Checker.prototype.exprInternal = function(x, e, hint) { return this.$val.exprInternal(x, e, hint); }; - Checker.Ptr.prototype.typeAssertion = function(pos, x, xtyp, T) { - var check, _tuple, method, wrongType, msg; - check = this; - _tuple = assertableTo(xtyp, T); method = _tuple[0]; wrongType = _tuple[1]; - if (method === ($ptrType(Func)).nil) { - return; + parser.prototype.parseBinaryExpr = function(lhs, prec1) { return this.$val.parseBinaryExpr(lhs, prec1); }; + parser.Ptr.prototype.parseExpr = function(lhs) { + var $deferred = [], $err = null, p; + /* */ try { $deferFrames.push($deferred); + p = this; + if (p.trace) { + $deferred.push([un, [trace(p, "Expression")]]); + } + return p.parseBinaryExpr(lhs, 1); + /* */ } catch(err) { $err = err; return $ifaceNil; } finally { $deferFrames.pop(); $callDeferred($deferred, $err); } + }; + parser.prototype.parseExpr = function(lhs) { return this.$val.parseExpr(lhs); }; + parser.Ptr.prototype.parseRhs = function() { + var p, old, x; + p = this; + old = p.inRhs; + p.inRhs = true; + x = p.checkExpr(p.parseExpr(false)); + p.inRhs = old; + return x; + }; + parser.prototype.parseRhs = function() { return this.$val.parseRhs(); }; + parser.Ptr.prototype.parseRhsOrType = function() { + var p, old, x; + p = this; + old = p.inRhs; + p.inRhs = true; + x = p.checkExprOrType(p.parseExpr(false)); + p.inRhs = old; + return x; + }; + parser.prototype.parseRhsOrType = function() { return this.$val.parseRhsOrType(); }; + parser.Ptr.prototype.parseSimpleStmt = function(mode) { + var $deferred = [], $err = null, p, x, _ref, _tmp, _tmp$1, pos, tok, y, isRange, pos$1, as, _ref$1, colon, _tuple, label, isIdent, stmt, arrow, y$1, s; + /* */ try { $deferFrames.push($deferred); + p = this; + if (p.trace) { + $deferred.push([un, [trace(p, "SimpleStmt")]]); + } + x = p.parseLhsList(); + _ref = p.tok; + if (_ref === 47 || _ref === 42 || _ref === 23 || _ref === 24 || _ref === 25 || _ref === 26 || _ref === 27 || _ref === 28 || _ref === 29 || _ref === 30 || _ref === 31 || _ref === 32 || _ref === 33) { + _tmp = p.pos; _tmp$1 = p.tok; pos = _tmp; tok = _tmp$1; + p.next(); + y = ($sliceType(ast.Expr)).nil; + isRange = false; + if ((mode === 2) && (p.tok === 79) && ((tok === 47) || (tok === 42))) { + pos$1 = p.pos; + p.next(); + y = new ($sliceType(ast.Expr))([new ast.UnaryExpr.Ptr(pos$1, 79, p.parseRhs())]); + isRange = true; + } else { + y = p.parseRhsList(); + } + as = new ast.AssignStmt.Ptr(x, pos, tok, y); + if (tok === 47) { + p.shortVarDecl(as, x); + } + return [as, isRange]; + } + if (x.$length > 1) { + p.errorExpected(((0 < 0 || 0 >= x.$length) ? $throwRuntimeError("index out of range") : x.$array[x.$offset + 0]).Pos(), "1 expression"); + } + _ref$1 = p.tok; + if (_ref$1 === 58) { + colon = p.pos; + p.next(); + _tuple = $assertType(((0 < 0 || 0 >= x.$length) ? $throwRuntimeError("index out of range") : x.$array[x.$offset + 0]), ($ptrType(ast.Ident)), true); label = _tuple[0]; isIdent = _tuple[1]; + if ((mode === 1) && isIdent) { + stmt = new ast.LabeledStmt.Ptr(label, colon, p.parseStmt()); + p.declare(stmt, $ifaceNil, p.labelScope, 6, new ($sliceType(($ptrType(ast.Ident))))([label])); + return [stmt, false]; + } + p.error(colon, "illegal label declaration"); + return [new ast.BadStmt.Ptr(((0 < 0 || 0 >= x.$length) ? $throwRuntimeError("index out of range") : x.$array[x.$offset + 0]).Pos(), colon + 1 >> 0), false]; + } else if (_ref$1 === 36) { + arrow = p.pos; + p.next(); + y$1 = p.parseRhs(); + return [new ast.SendStmt.Ptr(((0 < 0 || 0 >= x.$length) ? $throwRuntimeError("index out of range") : x.$array[x.$offset + 0]), arrow, y$1), false]; + } else if (_ref$1 === 37 || _ref$1 === 38) { + s = new ast.IncDecStmt.Ptr(((0 < 0 || 0 >= x.$length) ? $throwRuntimeError("index out of range") : x.$array[x.$offset + 0]), p.pos, p.tok); + p.next(); + return [s, false]; + } + return [new ast.ExprStmt.Ptr(((0 < 0 || 0 >= x.$length) ? $throwRuntimeError("index out of range") : x.$array[x.$offset + 0])), false]; + /* */ } catch(err) { $err = err; return [$ifaceNil, false]; } finally { $deferFrames.pop(); $callDeferred($deferred, $err); } + }; + parser.prototype.parseSimpleStmt = function(mode) { return this.$val.parseSimpleStmt(mode); }; + parser.Ptr.prototype.parseCallExpr = function(callType) { + var p, x, _tuple, call, isCall, _tuple$1, isBad; + p = this; + x = p.parseRhsOrType(); + _tuple = $assertType(x, ($ptrType(ast.CallExpr)), true); call = _tuple[0]; isCall = _tuple[1]; + if (isCall) { + return call; + } + _tuple$1 = $assertType(x, ($ptrType(ast.BadExpr)), true); isBad = _tuple$1[1]; + if (!isBad) { + p.error(p.safePos(x.End()), fmt.Sprintf("function must be invoked in %s statement", new ($sliceType($emptyInterface))([new $String(callType)]))); + } + return ($ptrType(ast.CallExpr)).nil; + }; + parser.prototype.parseCallExpr = function(callType) { return this.$val.parseCallExpr(callType); }; + parser.Ptr.prototype.parseGoStmt = function() { + var $deferred = [], $err = null, p, pos, call; + /* */ try { $deferFrames.push($deferred); + p = this; + if (p.trace) { + $deferred.push([un, [trace(p, "GoStmt")]]); + } + pos = p.expect(72); + call = p.parseCallExpr("go"); + p.expectSemi(); + if (call === ($ptrType(ast.CallExpr)).nil) { + return new ast.BadStmt.Ptr(pos, pos + 2 >> 0); + } + return new ast.GoStmt.Ptr(pos, call); + /* */ } catch(err) { $err = err; return $ifaceNil; } finally { $deferFrames.pop(); $callDeferred($deferred, $err); } + }; + parser.prototype.parseGoStmt = function() { return this.$val.parseGoStmt(); }; + parser.Ptr.prototype.parseDeferStmt = function() { + var $deferred = [], $err = null, p, pos, call; + /* */ try { $deferFrames.push($deferred); + p = this; + if (p.trace) { + $deferred.push([un, [trace(p, "DeferStmt")]]); + } + pos = p.expect(67); + call = p.parseCallExpr("defer"); + p.expectSemi(); + if (call === ($ptrType(ast.CallExpr)).nil) { + return new ast.BadStmt.Ptr(pos, pos + 5 >> 0); + } + return new ast.DeferStmt.Ptr(pos, call); + /* */ } catch(err) { $err = err; return $ifaceNil; } finally { $deferFrames.pop(); $callDeferred($deferred, $err); } + }; + parser.prototype.parseDeferStmt = function() { return this.$val.parseDeferStmt(); }; + parser.Ptr.prototype.parseReturnStmt = function() { + var $deferred = [], $err = null, p, pos, x; + /* */ try { $deferFrames.push($deferred); + p = this; + if (p.trace) { + $deferred.push([un, [trace(p, "ReturnStmt")]]); + } + pos = p.pos; + p.expect(80); + x = ($sliceType(ast.Expr)).nil; + if (!((p.tok === 57)) && !((p.tok === 56))) { + x = p.parseRhsList(); + } + p.expectSemi(); + return new ast.ReturnStmt.Ptr(pos, x); + /* */ } catch(err) { $err = err; return ($ptrType(ast.ReturnStmt)).nil; } finally { $deferFrames.pop(); $callDeferred($deferred, $err); } + }; + parser.prototype.parseReturnStmt = function() { return this.$val.parseReturnStmt(); }; + parser.Ptr.prototype.parseBranchStmt = function(tok) { + var $deferred = [], $err = null, p, pos, label, n, x, x$1; + /* */ try { $deferFrames.push($deferred); + p = this; + if (p.trace) { + $deferred.push([un, [trace(p, "BranchStmt")]]); + } + pos = p.expect(tok); + label = ($ptrType(ast.Ident)).nil; + if (!((tok === 69)) && (p.tok === 4)) { + label = p.parseIdent(); + n = p.targetStack.$length - 1 >> 0; + (x$1 = p.targetStack, (n < 0 || n >= x$1.$length) ? $throwRuntimeError("index out of range") : x$1.$array[x$1.$offset + n] = $append((x = p.targetStack, ((n < 0 || n >= x.$length) ? $throwRuntimeError("index out of range") : x.$array[x.$offset + n])), label)); + } + p.expectSemi(); + return new ast.BranchStmt.Ptr(pos, tok, label); + /* */ } catch(err) { $err = err; return ($ptrType(ast.BranchStmt)).nil; } finally { $deferFrames.pop(); $callDeferred($deferred, $err); } + }; + parser.prototype.parseBranchStmt = function(tok) { return this.$val.parseBranchStmt(tok); }; + parser.Ptr.prototype.makeExpr = function(s, kind) { + var p, _tuple, es, isExpr; + p = this; + if ($interfaceIsEqual(s, $ifaceNil)) { + return $ifaceNil; + } + _tuple = $assertType(s, ($ptrType(ast.ExprStmt)), true); es = _tuple[0]; isExpr = _tuple[1]; + if (isExpr) { + return p.checkExpr(es.X); + } + p.error(s.Pos(), fmt.Sprintf("expected %s, found simple statement (missing parentheses around composite literal?)", new ($sliceType($emptyInterface))([new $String(kind)]))); + return new ast.BadExpr.Ptr(s.Pos(), p.safePos(s.End())); + }; + parser.prototype.makeExpr = function(s, kind) { return this.$val.makeExpr(s, kind); }; + parser.Ptr.prototype.parseIfStmt = function() { + var $deferred = [], $err = null, p, pos, s, x, prevLev, _tuple, body, else_; + /* */ try { $deferFrames.push($deferred); + p = this; + if (p.trace) { + $deferred.push([un, [trace(p, "IfStmt")]]); } - msg = ""; - if (wrongType) { - msg = "wrong type for method"; + pos = p.expect(74); + p.openScope(); + $deferred.push([$methodVal(p, "closeScope"), []]); + s = $ifaceNil; + x = $ifaceNil; + prevLev = p.exprLev; + p.exprLev = -1; + if (p.tok === 57) { + p.next(); + x = p.parseRhs(); } else { - msg = "missing method"; + _tuple = p.parseSimpleStmt(0); s = _tuple[0]; + if (p.tok === 57) { + p.next(); + x = p.parseRhs(); + } else { + x = p.makeExpr(s, "boolean expression"); + s = $ifaceNil; + } } - check.errorf(pos, "%s cannot have dynamic type %s (%s %s)", new ($sliceType($emptyInterface))([x, T, new $String(msg), new $String(method.object.name)])); - }; - Checker.prototype.typeAssertion = function(pos, x, xtyp, T) { return this.$val.typeAssertion(pos, x, xtyp, T); }; - Checker.Ptr.prototype.expr = function(x, e) { - var check, msg, _ref; - check = this; - check.rawExpr(x, e, $ifaceNil); - msg = ""; - _ref = x.mode; - if (_ref === 1) { - msg = "used as value"; - } else if (_ref === 2) { - msg = "must be called"; - } else if (_ref === 3) { - msg = "is not an expression"; + p.exprLev = prevLev; + body = p.parseBlockStmt(); + else_ = $ifaceNil; + if (p.tok === 68) { + p.next(); + else_ = p.parseStmt(); } else { - return; + p.expectSemi(); } - check.errorf(x.pos(), "%s %s", new ($sliceType($emptyInterface))([x, new $String(msg)])); - x.mode = 0; + return new ast.IfStmt.Ptr(pos, s, x, body, else_); + /* */ } catch(err) { $err = err; return ($ptrType(ast.IfStmt)).nil; } finally { $deferFrames.pop(); $callDeferred($deferred, $err); } }; - Checker.prototype.expr = function(x, e) { return this.$val.expr(x, e); }; - Checker.Ptr.prototype.exprWithHint = function(x, e, hint) { - var check, msg, _ref; - check = this; - assert(!($interfaceIsEqual(hint, $ifaceNil))); - check.rawExpr(x, e, hint); - msg = ""; - _ref = x.mode; - if (_ref === 1) { - msg = "used as value"; - } else if (_ref === 2) { - msg = "must be called"; - } else if (_ref === 3) { - msg = "is not an expression"; - } else { - return; + parser.prototype.parseIfStmt = function() { return this.$val.parseIfStmt(); }; + parser.Ptr.prototype.parseTypeList = function() { + var list = ($sliceType(ast.Expr)).nil, $deferred = [], $err = null, p; + /* */ try { $deferFrames.push($deferred); + p = this; + if (p.trace) { + $deferred.push([un, [trace(p, "TypeList")]]); } - check.errorf(x.pos(), "%s %s", new ($sliceType($emptyInterface))([x, new $String(msg)])); - x.mode = 0; + list = $append(list, p.parseType()); + while (p.tok === 52) { + p.next(); + list = $append(list, p.parseType()); + } + return list; + /* */ } catch(err) { $err = err; } finally { $deferFrames.pop(); $callDeferred($deferred, $err); return list; } }; - Checker.prototype.exprWithHint = function(x, e, hint) { return this.$val.exprWithHint(x, e, hint); }; - Checker.Ptr.prototype.exprOrType = function(x, e) { - var check; - check = this; - check.rawExpr(x, e, $ifaceNil); - if (x.mode === 1) { - check.errorf(x.pos(), "%s used as value or type", new ($sliceType($emptyInterface))([x])); - x.mode = 0; + parser.prototype.parseTypeList = function() { return this.$val.parseTypeList(); }; + parser.Ptr.prototype.parseCaseClause = function(typeSwitch) { + var $deferred = [], $err = null, p, pos, list, colon, body; + /* */ try { $deferFrames.push($deferred); + p = this; + if (p.trace) { + $deferred.push([un, [trace(p, "CaseClause")]]); + } + pos = p.pos; + list = ($sliceType(ast.Expr)).nil; + if (p.tok === 62) { + p.next(); + if (typeSwitch) { + list = p.parseTypeList(); + } else { + list = p.parseRhsList(); + } + } else { + p.expect(66); } + colon = p.expect(58); + p.openScope(); + body = p.parseStmtList(); + p.closeScope(); + return new ast.CaseClause.Ptr(pos, list, colon, body); + /* */ } catch(err) { $err = err; return ($ptrType(ast.CaseClause)).nil; } finally { $deferFrames.pop(); $callDeferred($deferred, $err); } }; - Checker.prototype.exprOrType = function(x, e) { return this.$val.exprOrType(x, e); }; - ExprString = $pkg.ExprString = function(x) { - var buf; - buf = new bytes.Buffer.Ptr(); $copy(buf, new bytes.Buffer.Ptr(), bytes.Buffer); - WriteExpr(buf, x); - return buf.String(); + parser.prototype.parseCaseClause = function(typeSwitch) { return this.$val.parseCaseClause(typeSwitch); }; + isTypeSwitchAssert = function(x) { + var _tuple, a, ok; + _tuple = $assertType(x, ($ptrType(ast.TypeAssertExpr)), true); a = _tuple[0]; ok = _tuple[1]; + return ok && $interfaceIsEqual(a.Type, $ifaceNil); }; - WriteExpr = $pkg.WriteExpr = function(buf, x) { - var x$1, _ref, _ref$1, _i, i, arg, s, _ref$2; - _ref = x; - if ($assertType(_ref, ($ptrType(ast.Ident)), true)[1]) { - x$1 = _ref.$val; - buf.WriteString(x$1.Name); - } else if ($assertType(_ref, ($ptrType(ast.Ellipsis)), true)[1]) { - x$1 = _ref.$val; - buf.WriteString("..."); - if (!($interfaceIsEqual(x$1.Elt, $ifaceNil))) { - WriteExpr(buf, x$1.Elt); - } - } else if ($assertType(_ref, ($ptrType(ast.BasicLit)), true)[1]) { - x$1 = _ref.$val; - buf.WriteString(x$1.Value); - } else if ($assertType(_ref, ($ptrType(ast.FuncLit)), true)[1]) { - x$1 = _ref.$val; - buf.WriteByte(40); - WriteExpr(buf, x$1.Type); - buf.WriteString(" literal)"); - } else if ($assertType(_ref, ($ptrType(ast.CompositeLit)), true)[1]) { - x$1 = _ref.$val; - buf.WriteByte(40); - WriteExpr(buf, x$1.Type); - buf.WriteString(" literal)"); - } else if ($assertType(_ref, ($ptrType(ast.ParenExpr)), true)[1]) { - x$1 = _ref.$val; - buf.WriteByte(40); - WriteExpr(buf, x$1.X); - buf.WriteByte(41); - } else if ($assertType(_ref, ($ptrType(ast.SelectorExpr)), true)[1]) { - x$1 = _ref.$val; - WriteExpr(buf, x$1.X); - buf.WriteByte(46); - buf.WriteString(x$1.Sel.Name); - } else if ($assertType(_ref, ($ptrType(ast.IndexExpr)), true)[1]) { - x$1 = _ref.$val; - WriteExpr(buf, x$1.X); - buf.WriteByte(91); - WriteExpr(buf, x$1.Index); - buf.WriteByte(93); - } else if ($assertType(_ref, ($ptrType(ast.SliceExpr)), true)[1]) { - x$1 = _ref.$val; - WriteExpr(buf, x$1.X); - buf.WriteByte(91); - if (!($interfaceIsEqual(x$1.Low, $ifaceNil))) { - WriteExpr(buf, x$1.Low); - } - buf.WriteByte(58); - if (!($interfaceIsEqual(x$1.High, $ifaceNil))) { - WriteExpr(buf, x$1.High); + isTypeSwitchGuard = function(s) { + var t, _ref, x; + _ref = s; + if ($assertType(_ref, ($ptrType(ast.ExprStmt)), true)[1]) { + t = _ref.$val; + return isTypeSwitchAssert(t.X); + } else if ($assertType(_ref, ($ptrType(ast.AssignStmt)), true)[1]) { + t = _ref.$val; + return (t.Lhs.$length === 1) && (t.Tok === 47) && (t.Rhs.$length === 1) && isTypeSwitchAssert((x = t.Rhs, ((0 < 0 || 0 >= x.$length) ? $throwRuntimeError("index out of range") : x.$array[x.$offset + 0]))); + } + return false; + }; + parser.Ptr.prototype.parseSwitchStmt = function() { + var $deferred = [], $err = null, p, pos, _tmp, _tmp$1, s1, s2, prevLev, _tuple, _tuple$1, typeSwitch, lbrace, list, rbrace, body; + /* */ try { $deferFrames.push($deferred); + p = this; + if (p.trace) { + $deferred.push([un, [trace(p, "SwitchStmt")]]); + } + pos = p.expect(83); + p.openScope(); + $deferred.push([$methodVal(p, "closeScope"), []]); + _tmp = $ifaceNil; _tmp$1 = $ifaceNil; s1 = _tmp; s2 = _tmp$1; + if (!((p.tok === 51))) { + prevLev = p.exprLev; + p.exprLev = -1; + if (!((p.tok === 57))) { + _tuple = p.parseSimpleStmt(0); s2 = _tuple[0]; } - if (x$1.Slice3) { - buf.WriteByte(58); - if (!($interfaceIsEqual(x$1.Max, $ifaceNil))) { - WriteExpr(buf, x$1.Max); + if (p.tok === 57) { + p.next(); + s1 = s2; + s2 = $ifaceNil; + if (!((p.tok === 51))) { + p.openScope(); + $deferred.push([$methodVal(p, "closeScope"), []]); + _tuple$1 = p.parseSimpleStmt(0); s2 = _tuple$1[0]; } } - buf.WriteByte(93); - } else if ($assertType(_ref, ($ptrType(ast.TypeAssertExpr)), true)[1]) { - x$1 = _ref.$val; - WriteExpr(buf, x$1.X); - buf.WriteString(".("); - WriteExpr(buf, x$1.Type); - buf.WriteByte(41); - } else if ($assertType(_ref, ($ptrType(ast.CallExpr)), true)[1]) { - x$1 = _ref.$val; - WriteExpr(buf, x$1.Fun); - buf.WriteByte(40); - _ref$1 = x$1.Args; - _i = 0; - while (_i < _ref$1.$length) { - i = _i; - arg = ((_i < 0 || _i >= _ref$1.$length) ? $throwRuntimeError("index out of range") : _ref$1.$array[_ref$1.$offset + _i]); - if (i > 0) { - buf.WriteString(", "); + p.exprLev = prevLev; + } + typeSwitch = isTypeSwitchGuard(s2); + lbrace = p.expect(51); + list = ($sliceType(ast.Stmt)).nil; + while ((p.tok === 62) || (p.tok === 66)) { + list = $append(list, p.parseCaseClause(typeSwitch)); + } + rbrace = p.expect(56); + p.expectSemi(); + body = new ast.BlockStmt.Ptr(lbrace, list, rbrace); + if (typeSwitch) { + return new ast.TypeSwitchStmt.Ptr(pos, s1, s2, body); + } + return new ast.SwitchStmt.Ptr(pos, s1, p.makeExpr(s2, "switch expression"), body); + /* */ } catch(err) { $err = err; return $ifaceNil; } finally { $deferFrames.pop(); $callDeferred($deferred, $err); } + }; + parser.prototype.parseSwitchStmt = function() { return this.$val.parseSwitchStmt(); }; + parser.Ptr.prototype.parseCommClause = function() { + var $deferred = [], $err = null, p, pos, comm, lhs, arrow, rhs, tok, pos$1, rhs$1, as, colon, body; + /* */ try { $deferFrames.push($deferred); + p = this; + if (p.trace) { + $deferred.push([un, [trace(p, "CommClause")]]); + } + p.openScope(); + pos = p.pos; + comm = $ifaceNil; + if (p.tok === 62) { + p.next(); + lhs = p.parseLhsList(); + if (p.tok === 36) { + if (lhs.$length > 1) { + p.errorExpected(((0 < 0 || 0 >= lhs.$length) ? $throwRuntimeError("index out of range") : lhs.$array[lhs.$offset + 0]).Pos(), "1 expression"); } - WriteExpr(buf, arg); - _i++; - } - if ((new token.Pos(x$1.Ellipsis)).IsValid()) { - buf.WriteString("..."); - } - buf.WriteByte(41); - } else if ($assertType(_ref, ($ptrType(ast.StarExpr)), true)[1]) { - x$1 = _ref.$val; - buf.WriteByte(42); - WriteExpr(buf, x$1.X); - } else if ($assertType(_ref, ($ptrType(ast.UnaryExpr)), true)[1]) { - x$1 = _ref.$val; - buf.WriteString((new token.Token(x$1.Op)).String()); - WriteExpr(buf, x$1.X); - } else if ($assertType(_ref, ($ptrType(ast.BinaryExpr)), true)[1]) { - x$1 = _ref.$val; - WriteExpr(buf, x$1.X); - buf.WriteByte(32); - buf.WriteString((new token.Token(x$1.Op)).String()); - buf.WriteByte(32); - WriteExpr(buf, x$1.Y); - } else if ($assertType(_ref, ($ptrType(ast.ArrayType)), true)[1]) { - x$1 = _ref.$val; - buf.WriteByte(91); - if (!($interfaceIsEqual(x$1.Len, $ifaceNil))) { - WriteExpr(buf, x$1.Len); - } - buf.WriteByte(93); - WriteExpr(buf, x$1.Elt); - } else if ($assertType(_ref, ($ptrType(ast.StructType)), true)[1]) { - x$1 = _ref.$val; - buf.WriteString("struct{"); - writeFieldList(buf, x$1.Fields, "; ", false); - buf.WriteByte(125); - } else if ($assertType(_ref, ($ptrType(ast.FuncType)), true)[1]) { - x$1 = _ref.$val; - buf.WriteString("func"); - writeSigExpr(buf, x$1); - } else if ($assertType(_ref, ($ptrType(ast.InterfaceType)), true)[1]) { - x$1 = _ref.$val; - buf.WriteString("interface{"); - writeFieldList(buf, x$1.Methods, "; ", true); - buf.WriteByte(125); - } else if ($assertType(_ref, ($ptrType(ast.MapType)), true)[1]) { - x$1 = _ref.$val; - buf.WriteString("map["); - WriteExpr(buf, x$1.Key); - buf.WriteByte(93); - WriteExpr(buf, x$1.Value); - } else if ($assertType(_ref, ($ptrType(ast.ChanType)), true)[1]) { - x$1 = _ref.$val; - s = ""; - _ref$2 = x$1.Dir; - if (_ref$2 === 1) { - s = "chan<- "; - } else if (_ref$2 === 2) { - s = "<-chan "; + arrow = p.pos; + p.next(); + rhs = p.parseRhs(); + comm = new ast.SendStmt.Ptr(((0 < 0 || 0 >= lhs.$length) ? $throwRuntimeError("index out of range") : lhs.$array[lhs.$offset + 0]), arrow, rhs); } else { - s = "chan "; + tok = p.tok; + if ((tok === 42) || (tok === 47)) { + if (lhs.$length > 2) { + p.errorExpected(((0 < 0 || 0 >= lhs.$length) ? $throwRuntimeError("index out of range") : lhs.$array[lhs.$offset + 0]).Pos(), "1 or 2 expressions"); + lhs = $subslice(lhs, 0, 2); + } + pos$1 = p.pos; + p.next(); + rhs$1 = p.parseRhs(); + as = new ast.AssignStmt.Ptr(lhs, pos$1, tok, new ($sliceType(ast.Expr))([rhs$1])); + if (tok === 47) { + p.shortVarDecl(as, lhs); + } + comm = as; + } else { + if (lhs.$length > 1) { + p.errorExpected(((0 < 0 || 0 >= lhs.$length) ? $throwRuntimeError("index out of range") : lhs.$array[lhs.$offset + 0]).Pos(), "1 expression"); + } + comm = new ast.ExprStmt.Ptr(((0 < 0 || 0 >= lhs.$length) ? $throwRuntimeError("index out of range") : lhs.$array[lhs.$offset + 0])); + } } - buf.WriteString(s); - WriteExpr(buf, x$1.Value); } else { - x$1 = _ref; - buf.WriteString("(bad expr)"); + p.expect(66); } + colon = p.expect(58); + body = p.parseStmtList(); + p.closeScope(); + return new ast.CommClause.Ptr(pos, comm, colon, body); + /* */ } catch(err) { $err = err; return ($ptrType(ast.CommClause)).nil; } finally { $deferFrames.pop(); $callDeferred($deferred, $err); } }; - writeSigExpr = function(buf, sig) { - var res, n, x, x$1; - buf.WriteByte(40); - writeFieldList(buf, sig.Params, ", ", false); - buf.WriteByte(41); - res = sig.Results; - n = res.NumFields(); - if (n === 0) { - return; + parser.prototype.parseCommClause = function() { return this.$val.parseCommClause(); }; + parser.Ptr.prototype.parseSelectStmt = function() { + var $deferred = [], $err = null, p, pos, lbrace, list, rbrace, body; + /* */ try { $deferFrames.push($deferred); + p = this; + if (p.trace) { + $deferred.push([un, [trace(p, "SelectStmt")]]); } - buf.WriteByte(32); - if ((n === 1) && ((x = res.List, ((0 < 0 || 0 >= x.$length) ? $throwRuntimeError("index out of range") : x.$array[x.$offset + 0])).Names.$length === 0)) { - WriteExpr(buf, (x$1 = res.List, ((0 < 0 || 0 >= x$1.$length) ? $throwRuntimeError("index out of range") : x$1.$array[x$1.$offset + 0])).Type); - return; + pos = p.expect(81); + lbrace = p.expect(51); + list = ($sliceType(ast.Stmt)).nil; + while ((p.tok === 62) || (p.tok === 66)) { + list = $append(list, p.parseCommClause()); } - buf.WriteByte(40); - writeFieldList(buf, res, ", ", false); - buf.WriteByte(41); + rbrace = p.expect(56); + p.expectSemi(); + body = new ast.BlockStmt.Ptr(lbrace, list, rbrace); + return new ast.SelectStmt.Ptr(pos, body); + /* */ } catch(err) { $err = err; return ($ptrType(ast.SelectStmt)).nil; } finally { $deferFrames.pop(); $callDeferred($deferred, $err); } }; - writeFieldList = function(buf, fields, sep, iface) { - var _ref, _i, i, f, _ref$1, _i$1, i$1, name, _tuple, sig; - _ref = fields.List; - _i = 0; - while (_i < _ref.$length) { - i = _i; - f = ((_i < 0 || _i >= _ref.$length) ? $throwRuntimeError("index out of range") : _ref.$array[_ref.$offset + _i]); - if (i > 0) { - buf.WriteString(sep); + parser.prototype.parseSelectStmt = function() { return this.$val.parseSelectStmt(); }; + parser.Ptr.prototype.parseForStmt = function() { + var $deferred = [], $err = null, p, pos, _tmp, _tmp$1, _tmp$2, s1, s2, s3, isRange, prevLev, _tuple, _tuple$1, _tuple$2, body, as, _tmp$3, _tmp$4, key, value, _ref, _tmp$5, x, _tmp$6, x$1, x$2, x$3, x$4, x$5; + /* */ try { $deferFrames.push($deferred); + p = this; + if (p.trace) { + $deferred.push([un, [trace(p, "ForStmt")]]); + } + pos = p.expect(70); + p.openScope(); + $deferred.push([$methodVal(p, "closeScope"), []]); + _tmp = $ifaceNil; _tmp$1 = $ifaceNil; _tmp$2 = $ifaceNil; s1 = _tmp; s2 = _tmp$1; s3 = _tmp$2; + isRange = false; + if (!((p.tok === 51))) { + prevLev = p.exprLev; + p.exprLev = -1; + if (!((p.tok === 57))) { + _tuple = p.parseSimpleStmt(2); s2 = _tuple[0]; isRange = _tuple[1]; } - _ref$1 = f.Names; - _i$1 = 0; - while (_i$1 < _ref$1.$length) { - i$1 = _i$1; - name = ((_i$1 < 0 || _i$1 >= _ref$1.$length) ? $throwRuntimeError("index out of range") : _ref$1.$array[_ref$1.$offset + _i$1]); - if (i$1 > 0) { - buf.WriteString(", "); + if (!isRange && (p.tok === 57)) { + p.next(); + s1 = s2; + s2 = $ifaceNil; + if (!((p.tok === 57))) { + _tuple$1 = p.parseSimpleStmt(0); s2 = _tuple$1[0]; } - buf.WriteString(name.Name); - _i$1++; - } - _tuple = $assertType(f.Type, ($ptrType(ast.FuncType)), true); sig = _tuple[0]; - if (!(sig === ($ptrType(ast.FuncType)).nil) && iface) { - writeSigExpr(buf, sig); - _i++; - continue; - } - if (f.Names.$length > 0) { - buf.WriteByte(32); - } - WriteExpr(buf, f.Type); - _i++; - } - }; - slice3 = function(x) { - return x.Slice3; - }; - sliceMax = function(x) { - return x.Max; - }; - Checker.Ptr.prototype.initOrder = function() { - var check, x, pq, mark, emitted, n, cycle, i, _ref, _i, out, _tuple, v, _entry, info, _entry$1, _key$2, infoLhs, init$1; - check = this; - check.Info.InitOrder = $subslice(check.Info.InitOrder, 0, 0); - pq = (x = dependencyGraph(check.objMap), $subslice(new nodeQueue(x.$array), x.$offset, x.$offset + x.$length)); - heap.Init(new ($ptrType(nodeQueue))(function() { return pq; }, function($v) { pq = $v; })); - mark = 0; - emitted = new $Map(); - while (pq.$length > 0) { - n = $assertType(heap.Pop(new ($ptrType(nodeQueue))(function() { return pq; }, function($v) { pq = $v; })), ($ptrType(objNode))); - if (n.in$1 > 0) { - mark = mark + (1) >> 0; - cycle = findPath(n, n, mark); - i = valIndex(cycle); - if (i >= 0) { - check.reportCycle(cycle, i); + p.expectSemi(); + if (!((p.tok === 51))) { + _tuple$2 = p.parseSimpleStmt(0); s3 = _tuple$2[0]; } } - _ref = n.out; - _i = 0; - while (_i < _ref.$length) { - out = ((_i < 0 || _i >= _ref.$length) ? $throwRuntimeError("index out of range") : _ref.$array[_ref.$offset + _i]); - out.in$1 = out.in$1 - (1) >> 0; - heap.Fix(new ($ptrType(nodeQueue))(function() { return pq; }, function($v) { pq = $v; }), out.index); - _i++; - } - _tuple = $assertType(n.obj, ($ptrType(Var)), true); v = _tuple[0]; - info = (_entry = check.objMap[v.$key()], _entry !== undefined ? _entry.v : ($ptrType(declInfo)).nil); - if (v === ($ptrType(Var)).nil || !info.hasInitializer()) { - continue; - } - if ((_entry$1 = emitted[info.$key()], _entry$1 !== undefined ? _entry$1.v : false)) { - continue; - } - _key$2 = info; (emitted || $throwRuntimeError("assignment to entry in nil map"))[_key$2.$key()] = { k: _key$2, v: true }; - infoLhs = info.lhs; - if (infoLhs === ($sliceType(($ptrType(Var)))).nil) { - infoLhs = new ($sliceType(($ptrType(Var))))([v]); + p.exprLev = prevLev; + } + body = p.parseBlockStmt(); + p.expectSemi(); + if (isRange) { + as = $assertType(s2, ($ptrType(ast.AssignStmt))); + _tmp$3 = $ifaceNil; _tmp$4 = $ifaceNil; key = _tmp$3; value = _tmp$4; + _ref = as.Lhs.$length; + if (_ref === 2) { + _tmp$5 = (x = as.Lhs, ((0 < 0 || 0 >= x.$length) ? $throwRuntimeError("index out of range") : x.$array[x.$offset + 0])); _tmp$6 = (x$1 = as.Lhs, ((1 < 0 || 1 >= x$1.$length) ? $throwRuntimeError("index out of range") : x$1.$array[x$1.$offset + 1])); key = _tmp$5; value = _tmp$6; + } else if (_ref === 1) { + key = (x$2 = as.Lhs, ((0 < 0 || 0 >= x$2.$length) ? $throwRuntimeError("index out of range") : x$2.$array[x$2.$offset + 0])); + } else { + p.errorExpected((x$3 = as.Lhs, ((0 < 0 || 0 >= x$3.$length) ? $throwRuntimeError("index out of range") : x$3.$array[x$3.$offset + 0])).Pos(), "1 or 2 expressions"); + return new ast.BadStmt.Ptr(pos, p.safePos(body.End())); } - init$1 = new Initializer.Ptr(infoLhs, info.init); - check.Info.InitOrder = $append(check.Info.InitOrder, init$1); + x$5 = $assertType((x$4 = as.Rhs, ((0 < 0 || 0 >= x$4.$length) ? $throwRuntimeError("index out of range") : x$4.$array[x$4.$offset + 0])), ($ptrType(ast.UnaryExpr))).X; + return new ast.RangeStmt.Ptr(pos, key, value, as.TokPos, as.Tok, x$5, body); } + return new ast.ForStmt.Ptr(pos, s1, p.makeExpr(s2, "boolean or range expression"), s3, body); + /* */ } catch(err) { $err = err; return $ifaceNil; } finally { $deferFrames.pop(); $callDeferred($deferred, $err); } }; - Checker.prototype.initOrder = function() { return this.$val.initOrder(); }; - findPath = function(a, z, mark) { - var _ref, _i, n, P; - if (a.mark === mark) { - return ($sliceType(($ptrType(objNode)))).nil; + parser.prototype.parseForStmt = function() { return this.$val.parseForStmt(); }; + parser.Ptr.prototype.parseStmt = function() { + var s = $ifaceNil, $deferred = [], $err = null, p, _ref, _tuple, _tuple$1, isLabeledStmt, pos; + /* */ try { $deferFrames.push($deferred); + p = this; + if (p.trace) { + $deferred.push([un, [trace(p, "Statement")]]); } - a.mark = mark; - _ref = a.out; - _i = 0; - while (_i < _ref.$length) { - n = ((_i < 0 || _i >= _ref.$length) ? $throwRuntimeError("index out of range") : _ref.$array[_ref.$offset + _i]); - if (n === z) { - return new ($sliceType(($ptrType(objNode))))([z]); - } - P = findPath(n, z, mark); - if (!(P === ($sliceType(($ptrType(objNode)))).nil)) { - return $append(P, n); + _ref = p.tok; + if (_ref === 64 || _ref === 84 || _ref === 85) { + s = new ast.DeclStmt.Ptr(p.parseDecl(syncStmt)); + } else if (_ref === 4 || _ref === 5 || _ref === 6 || _ref === 7 || _ref === 8 || _ref === 9 || _ref === 71 || _ref === 49 || _ref === 50 || _ref === 82 || _ref === 12 || _ref === 13 || _ref === 14 || _ref === 17 || _ref === 19 || _ref === 36 || _ref === 43) { + _tuple = p.parseSimpleStmt(1); s = _tuple[0]; + _tuple$1 = $assertType(s, ($ptrType(ast.LabeledStmt)), true); isLabeledStmt = _tuple$1[1]; + if (!isLabeledStmt) { + p.expectSemi(); } - _i++; + } else if (_ref === 72) { + s = p.parseGoStmt(); + } else if (_ref === 67) { + s = p.parseDeferStmt(); + } else if (_ref === 80) { + s = p.parseReturnStmt(); + } else if (_ref === 61 || _ref === 65 || _ref === 73 || _ref === 69) { + s = p.parseBranchStmt(p.tok); + } else if (_ref === 51) { + s = p.parseBlockStmt(); + p.expectSemi(); + } else if (_ref === 74) { + s = p.parseIfStmt(); + } else if (_ref === 83) { + s = p.parseSwitchStmt(); + } else if (_ref === 81) { + s = p.parseSelectStmt(); + } else if (_ref === 70) { + s = p.parseForStmt(); + } else if (_ref === 57) { + s = new ast.EmptyStmt.Ptr(p.pos); + p.next(); + } else if (_ref === 56) { + s = new ast.EmptyStmt.Ptr(p.pos); + } else { + pos = p.pos; + p.errorExpected(pos, "statement"); + syncStmt(p); + s = new ast.BadStmt.Ptr(pos, p.pos); } - return ($sliceType(($ptrType(objNode)))).nil; + return s; + /* */ } catch(err) { $err = err; } finally { $deferFrames.pop(); $callDeferred($deferred, $err); return s; } }; - valIndex = function(a) { - var _ref, _i, i, n, _ref$1; - _ref = a; + parser.prototype.parseStmt = function() { return this.$val.parseStmt(); }; + isValidImport = function(lit) { + var _tuple, s, _ref, _i, _rune, r; + _tuple = strconv.Unquote(lit); s = _tuple[0]; + _ref = s; _i = 0; - while (_i < _ref.$length) { - i = _i; - n = ((_i < 0 || _i >= _ref.$length) ? $throwRuntimeError("index out of range") : _ref.$array[_ref.$offset + _i]); - _ref$1 = n.obj; - if ($assertType(_ref$1, ($ptrType(Const)), true)[1] || $assertType(_ref$1, ($ptrType(Var)), true)[1]) { - return i; + while (_i < _ref.length) { + _rune = $decodeRune(_ref, _i); + r = _rune[0]; + if (!unicode.IsGraphic(r) || unicode.IsSpace(r) || strings.ContainsRune("!\"#$%&'()*,:;<=>?[\\]^{|}`\xEF\xBF\xBD", r)) { + return false; } - _i++; + _i += _rune[1]; } - return -1; + return !(s === ""); }; - Checker.Ptr.prototype.reportCycle = function(cycle, i) { - var check, obj, _ref, _i; - check = this; - obj = ((i < 0 || i >= cycle.$length) ? $throwRuntimeError("index out of range") : cycle.$array[cycle.$offset + i]).obj; - check.errorf(obj.Pos(), "initialization cycle for %s", new ($sliceType($emptyInterface))([new $String(obj.Name())])); - _ref = cycle; - _i = 0; - while (_i < _ref.$length) { - check.errorf(obj.Pos(), "\t%s refers to", new ($sliceType($emptyInterface))([new $String(obj.Name())])); - i = i + (1) >> 0; - if (i >= cycle.$length) { - i = 0; - } - obj = ((i < 0 || i >= cycle.$length) ? $throwRuntimeError("index out of range") : cycle.$array[cycle.$offset + i]).obj; - _i++; + parser.Ptr.prototype.parseImportSpec = function(doc, param, param$1) { + var $deferred = [], $err = null, p, ident, _ref, pos, path, spec; + /* */ try { $deferFrames.push($deferred); + p = this; + if (p.trace) { + $deferred.push([un, [trace(p, "ImportSpec")]]); } - check.errorf(obj.Pos(), "\t%s", new ($sliceType($emptyInterface))([new $String(obj.Name())])); - }; - Checker.prototype.reportCycle = function(cycle, i) { return this.$val.reportCycle(cycle, i); }; - dependencyGraph = function(objMap) { - var M, _ref, _i, _keys, _entry, obj, _key$2, G, i, _ref$1, _i$1, _keys$1, _entry$1, obj$1, n, _entry$2, deps, _ref$2, _i$2, _keys$2, _entry$3, d, _entry$4, d$1; - M = new $Map(); - _ref = objMap; - _i = 0; - _keys = $keys(_ref); - while (_i < _keys.length) { - _entry = _ref[_keys[_i]]; - if (_entry === undefined) { - _i++; - continue; - } - obj = _entry.k; - _key$2 = obj; (M || $throwRuntimeError("assignment to entry in nil map"))[_key$2.$key()] = { k: _key$2, v: new objNode.Ptr(obj, 0, ($sliceType(($ptrType(objNode)))).nil, 0, 0) }; - _i++; + ident = ($ptrType(ast.Ident)).nil; + _ref = p.tok; + if (_ref === 53) { + ident = new ast.Ident.Ptr(p.pos, ".", ($ptrType(ast.Object)).nil); + p.next(); + } else if (_ref === 4) { + ident = p.parseIdent(); } - G = ($sliceType(($ptrType(objNode)))).make($keys(M).length); - i = 0; - _ref$1 = M; - _i$1 = 0; - _keys$1 = $keys(_ref$1); - while (_i$1 < _keys$1.length) { - _entry$1 = _ref$1[_keys$1[_i$1]]; - if (_entry$1 === undefined) { - _i$1++; - continue; - } - obj$1 = _entry$1.k; - n = _entry$1.v; - deps = (_entry$2 = objMap[obj$1.$key()], _entry$2 !== undefined ? _entry$2.v : ($ptrType(declInfo)).nil).deps; - n.in$1 = $keys(deps).length; - _ref$2 = deps; - _i$2 = 0; - _keys$2 = $keys(_ref$2); - while (_i$2 < _keys$2.length) { - _entry$3 = _ref$2[_keys$2[_i$2]]; - if (_entry$3 === undefined) { - _i$2++; - continue; - } - d = _entry$3.k; - d$1 = (_entry$4 = M[d.$key()], _entry$4 !== undefined ? _entry$4.v : ($ptrType(objNode)).nil); - d$1.out = $append(d$1.out, n); - _i$2++; + pos = p.pos; + path = ""; + if (p.tok === 9) { + path = p.lit; + if (!isValidImport(path)) { + p.error(pos, "invalid import path: " + path); } - (i < 0 || i >= G.$length) ? $throwRuntimeError("index out of range") : G.$array[G.$offset + i] = n; - n.index = i; - i = i + (1) >> 0; - _i$1++; + p.next(); + } else { + p.expect(9); } - return G; - }; - nodeQueue.prototype.Len = function() { - var a; - a = this; - return a.$length; - }; - $ptrType(nodeQueue).prototype.Len = function() { return this.$get().Len(); }; - nodeQueue.prototype.Swap = function(i, j) { - var a, _tmp, _tmp$1, x, y, _tmp$2, _tmp$3, _tmp$4, _tmp$5; - a = this; - _tmp = ((i < 0 || i >= a.$length) ? $throwRuntimeError("index out of range") : a.$array[a.$offset + i]); _tmp$1 = ((j < 0 || j >= a.$length) ? $throwRuntimeError("index out of range") : a.$array[a.$offset + j]); x = _tmp; y = _tmp$1; - _tmp$2 = y; _tmp$3 = x; (i < 0 || i >= a.$length) ? $throwRuntimeError("index out of range") : a.$array[a.$offset + i] = _tmp$2; (j < 0 || j >= a.$length) ? $throwRuntimeError("index out of range") : a.$array[a.$offset + j] = _tmp$3; - _tmp$4 = j; _tmp$5 = i; x.index = _tmp$4; y.index = _tmp$5; - }; - $ptrType(nodeQueue).prototype.Swap = function(i, j) { return this.$get().Swap(i, j); }; - nodeQueue.prototype.Less = function(i, j) { - var a, _tmp, _tmp$1, x, y; - a = this; - _tmp = ((i < 0 || i >= a.$length) ? $throwRuntimeError("index out of range") : a.$array[a.$offset + i]); _tmp$1 = ((j < 0 || j >= a.$length) ? $throwRuntimeError("index out of range") : a.$array[a.$offset + j]); x = _tmp; y = _tmp$1; - return x.in$1 < y.in$1 || (x.in$1 === y.in$1) && x.obj.Pos() < y.obj.Pos(); - }; - $ptrType(nodeQueue).prototype.Less = function(i, j) { return this.$get().Less(i, j); }; - $ptrType(nodeQueue).prototype.Push = function(x) { - var a; - a = this; - $panic(new $String("unreachable")); - }; - $ptrType(nodeQueue).prototype.Pop = function() { - var a, n, x, x$1, x$2; - a = this; - n = a.$get().$length; - x$2 = (x = a.$get(), x$1 = n - 1 >> 0, ((x$1 < 0 || x$1 >= x.$length) ? $throwRuntimeError("index out of range") : x.$array[x.$offset + x$1])); - x$2.index = -1; - a.$set($subslice((a.$get()), 0, (n - 1 >> 0))); - return x$2; + p.expectSemi(); + spec = new ast.ImportSpec.Ptr(doc, ident, new ast.BasicLit.Ptr(pos, 9, path), p.lineComment, 0); + p.imports = $append(p.imports, spec); + return spec; + /* */ } catch(err) { $err = err; return $ifaceNil; } finally { $deferFrames.pop(); $callDeferred($deferred, $err); } }; - Checker.Ptr.prototype.labels = function(body) { - var check, all, fwdJumps, _ref, _i, jmp, msg, name, alt, _ref$1, _i$1, _keys, _entry, obj, lbl; - check = this; - all = NewScope(($ptrType(Scope)).nil, "label"); - fwdJumps = check.blockBranches(all, ($ptrType(block)).nil, ($ptrType(ast.LabeledStmt)).nil, body.List); - _ref = fwdJumps; - _i = 0; - while (_i < _ref.$length) { - jmp = ((_i < 0 || _i >= _ref.$length) ? $throwRuntimeError("index out of range") : _ref.$array[_ref.$offset + _i]); - msg = ""; - name = jmp.Label.Name; - alt = all.Lookup(name); - if (!($interfaceIsEqual(alt, $ifaceNil))) { - msg = "goto %s jumps into block"; - $assertType(alt, ($ptrType(Label))).object.used = true; - } else { - msg = "label %s not declared"; - } - check.errorf(jmp.Label.Pos(), msg, new ($sliceType($emptyInterface))([new $String(name)])); - _i++; + parser.prototype.parseImportSpec = function(doc, param, param$1) { return this.$val.parseImportSpec(doc, param, param$1); }; + parser.Ptr.prototype.parseValueSpec = function(doc, keyword, iota) { + var $deferred = [], $err = null, p, idents, typ, values, spec, kind; + /* */ try { $deferFrames.push($deferred); + p = this; + if (p.trace) { + $deferred.push([un, [trace(p, (new token.Token(keyword)).String() + "Spec")]]); } - _ref$1 = all.elems; - _i$1 = 0; - _keys = $keys(_ref$1); - while (_i$1 < _keys.length) { - _entry = _ref$1[_keys[_i$1]]; - if (_entry === undefined) { - _i$1++; - continue; - } - obj = _entry.v; - lbl = $assertType(obj, ($ptrType(Label))); - if (!lbl.object.used) { - check.softErrorf(lbl.object.pos, "label %s declared but not used", new ($sliceType($emptyInterface))([new $String(lbl.object.name)])); - } - _i$1++; + idents = p.parseIdentList(); + typ = p.tryType(); + values = ($sliceType(ast.Expr)).nil; + if (p.tok === 42) { + p.next(); + values = p.parseRhsList(); } - }; - Checker.prototype.labels = function(body) { return this.$val.labels(body); }; - block.Ptr.prototype.insert = function(s) { - var b, name, labels, _key$2; - b = this; - name = s.Label.Name; - labels = b.labels; - if (labels === false) { - labels = new $Map(); - b.labels = labels; + p.expectSemi(); + spec = new ast.ValueSpec.Ptr(doc, idents, typ, values, p.lineComment); + kind = 2; + if (keyword === 85) { + kind = 4; } - _key$2 = name; (labels || $throwRuntimeError("assignment to entry in nil map"))[_key$2] = { k: _key$2, v: s }; + p.declare(spec, new $Int(iota), p.topScope, kind, idents); + return spec; + /* */ } catch(err) { $err = err; return $ifaceNil; } finally { $deferFrames.pop(); $callDeferred($deferred, $err); } }; - block.prototype.insert = function(s) { return this.$val.insert(s); }; - block.Ptr.prototype.gotoTarget = function(name) { - var b, s, _entry, t; - b = this; - s = b; - while (!(s === ($ptrType(block)).nil)) { - t = (_entry = s.labels[name], _entry !== undefined ? _entry.v : ($ptrType(ast.LabeledStmt)).nil); - if (!(t === ($ptrType(ast.LabeledStmt)).nil)) { - return t; - } - s = s.parent; + parser.prototype.parseValueSpec = function(doc, keyword, iota) { return this.$val.parseValueSpec(doc, keyword, iota); }; + parser.Ptr.prototype.parseTypeSpec = function(doc, param, param$1) { + var $deferred = [], $err = null, p, ident, spec; + /* */ try { $deferFrames.push($deferred); + p = this; + if (p.trace) { + $deferred.push([un, [trace(p, "TypeSpec")]]); } - return ($ptrType(ast.LabeledStmt)).nil; + ident = p.parseIdent(); + spec = new ast.TypeSpec.Ptr(doc, ident, $ifaceNil, ($ptrType(ast.CommentGroup)).nil); + p.declare(spec, $ifaceNil, p.topScope, 3, new ($sliceType(($ptrType(ast.Ident))))([ident])); + spec.Type = p.parseType(); + p.expectSemi(); + spec.Comment = p.lineComment; + return spec; + /* */ } catch(err) { $err = err; return $ifaceNil; } finally { $deferFrames.pop(); $callDeferred($deferred, $err); } }; - block.prototype.gotoTarget = function(name) { return this.$val.gotoTarget(name); }; - block.Ptr.prototype.enclosingTarget = function(name) { - var b, s, t; - b = this; - s = b; - while (!(s === ($ptrType(block)).nil)) { - t = s.lstmt; - if (!(t === ($ptrType(ast.LabeledStmt)).nil) && t.Label.Name === name) { - return t; + parser.prototype.parseTypeSpec = function(doc, param, param$1) { return this.$val.parseTypeSpec(doc, param, param$1); }; + parser.Ptr.prototype.parseGenDecl = function(keyword, f) { + var $deferred = [], $err = null, p, doc, pos, _tmp, _tmp$1, lparen, rparen, list, iota; + /* */ try { $deferFrames.push($deferred); + p = this; + if (p.trace) { + $deferred.push([un, [trace(p, "GenDecl(" + (new token.Token(keyword)).String() + ")")]]); + } + doc = p.leadComment; + pos = p.expect(keyword); + _tmp = 0; _tmp$1 = 0; lparen = _tmp; rparen = _tmp$1; + list = ($sliceType(ast.Spec)).nil; + if (p.tok === 49) { + lparen = p.pos; + p.next(); + iota = 0; + while (!((p.tok === 54)) && !((p.tok === 1))) { + list = $append(list, f(p.leadComment, keyword, iota)); + iota = iota + (1) >> 0; } - s = s.parent; + rparen = p.expect(54); + p.expectSemi(); + } else { + list = $append(list, f(($ptrType(ast.CommentGroup)).nil, keyword, 0)); } - return ($ptrType(ast.LabeledStmt)).nil; + return new ast.GenDecl.Ptr(doc, pos, keyword, lparen, list, rparen); + /* */ } catch(err) { $err = err; return ($ptrType(ast.GenDecl)).nil; } finally { $deferFrames.pop(); $callDeferred($deferred, $err); } }; - block.prototype.enclosingTarget = function(name) { return this.$val.enclosingTarget(name); }; - Checker.Ptr.prototype.blockBranches = function(all, parent, lstmt, list) { - var check, b, varDeclPos, _tmp, _tmp$1, fwdJumps, badJumps, recordVarDecl, jumpsOverVarDecl, blockBranches, stmtBranches, _ref, _i, s; - check = this; - b = new block.Ptr(parent, lstmt, false); - varDeclPos = 0; - _tmp = ($sliceType(($ptrType(ast.BranchStmt)))).nil; _tmp$1 = ($sliceType(($ptrType(ast.BranchStmt)))).nil; fwdJumps = _tmp; badJumps = _tmp$1; - recordVarDecl = (function(pos) { - varDeclPos = pos; - badJumps = $appendSlice($subslice(badJumps, 0, 0), fwdJumps); - }); - jumpsOverVarDecl = (function(jmp) { - var _ref, _i, bad; - if ((new token.Pos(varDeclPos)).IsValid()) { - _ref = badJumps; - _i = 0; - while (_i < _ref.$length) { - bad = ((_i < 0 || _i >= _ref.$length) ? $throwRuntimeError("index out of range") : _ref.$array[_ref.$offset + _i]); - if (jmp === bad) { - return true; - } - _i++; - } - } - return false; - }); - blockBranches = (function(lstmt$1, list$1) { - fwdJumps = $appendSlice(fwdJumps, check.blockBranches(all, b, lstmt$1, list$1)); - }); - stmtBranches = $throwNilPointerError; - stmtBranches = (function(s) { - var s$1, _ref, _tuple, d, name, lbl, alt, i, _ref$1, _i, jmp, name$1, _ref$2, valid, t, _ref$3, valid$1, t$1, _ref$4, obj; - _ref = s; - if ($assertType(_ref, ($ptrType(ast.DeclStmt)), true)[1]) { - s$1 = _ref.$val; - _tuple = $assertType(s$1.Decl, ($ptrType(ast.GenDecl)), true); d = _tuple[0]; - if (!(d === ($ptrType(ast.GenDecl)).nil) && (d.Tok === 85)) { - recordVarDecl(d.Pos()); - } - } else if ($assertType(_ref, ($ptrType(ast.LabeledStmt)), true)[1]) { - s$1 = _ref.$val; - name = s$1.Label.Name; - if (!(name === "_")) { - lbl = NewLabel(s$1.Label.Pos(), check.pkg, name); - alt = all.Insert(lbl); - if (!($interfaceIsEqual(alt, $ifaceNil))) { - check.softErrorf(lbl.object.pos, "label %s already declared", new ($sliceType($emptyInterface))([new $String(name)])); - check.reportAltDecl(alt); - } else { - b.insert(s$1); - check.recordDef(s$1.Label, lbl); - } - i = 0; - _ref$1 = fwdJumps; - _i = 0; - while (_i < _ref$1.$length) { - jmp = ((_i < 0 || _i >= _ref$1.$length) ? $throwRuntimeError("index out of range") : _ref$1.$array[_ref$1.$offset + _i]); - if (jmp.Label.Name === name) { - lbl.object.used = true; - check.recordUse(jmp.Label, lbl); - if (jumpsOverVarDecl(jmp)) { - check.softErrorf(jmp.Label.Pos(), "goto %s jumps over variable declaration at line %d", new ($sliceType($emptyInterface))([new $String(name), new $Int(check.fset.Position(varDeclPos).Line)])); - } - } else { - (i < 0 || i >= fwdJumps.$length) ? $throwRuntimeError("index out of range") : fwdJumps.$array[fwdJumps.$offset + i] = jmp; - i = i + (1) >> 0; - } - _i++; - } - fwdJumps = $subslice(fwdJumps, 0, i); - lstmt = s$1; - } - stmtBranches(s$1.Stmt); - } else if ($assertType(_ref, ($ptrType(ast.BranchStmt)), true)[1]) { - s$1 = _ref.$val; - if (s$1.Label === ($ptrType(ast.Ident)).nil) { - return; - } - name$1 = s$1.Label.Name; - _ref$2 = s$1.Tok; - if (_ref$2 === 61) { - valid = false; - t = b.enclosingTarget(name$1); - if (!(t === ($ptrType(ast.LabeledStmt)).nil)) { - _ref$3 = t.Stmt; - if ($assertType(_ref$3, ($ptrType(ast.SwitchStmt)), true)[1] || $assertType(_ref$3, ($ptrType(ast.TypeSwitchStmt)), true)[1] || $assertType(_ref$3, ($ptrType(ast.SelectStmt)), true)[1] || $assertType(_ref$3, ($ptrType(ast.ForStmt)), true)[1] || $assertType(_ref$3, ($ptrType(ast.RangeStmt)), true)[1]) { - valid = true; - } - } - if (!valid) { - check.errorf(s$1.Label.Pos(), "invalid break label %s", new ($sliceType($emptyInterface))([new $String(name$1)])); - return; - } - } else if (_ref$2 === 65) { - valid$1 = false; - t$1 = b.enclosingTarget(name$1); - if (!(t$1 === ($ptrType(ast.LabeledStmt)).nil)) { - _ref$4 = t$1.Stmt; - if ($assertType(_ref$4, ($ptrType(ast.ForStmt)), true)[1] || $assertType(_ref$4, ($ptrType(ast.RangeStmt)), true)[1]) { - valid$1 = true; - } - } - if (!valid$1) { - check.errorf(s$1.Label.Pos(), "invalid continue label %s", new ($sliceType($emptyInterface))([new $String(name$1)])); - return; - } - } else if (_ref$2 === 73) { - if (b.gotoTarget(name$1) === ($ptrType(ast.LabeledStmt)).nil) { - fwdJumps = $append(fwdJumps, s$1); - return; - } - } else { - check.invalidAST(s$1.Pos(), "branch statement: %s %s", new ($sliceType($emptyInterface))([new token.Token(s$1.Tok), new $String(name$1)])); - return; - } - obj = all.Lookup(name$1); - $assertType(obj, ($ptrType(Label))).object.used = true; - check.recordUse(s$1.Label, obj); - } else if ($assertType(_ref, ($ptrType(ast.AssignStmt)), true)[1]) { - s$1 = _ref.$val; - if (s$1.Tok === 47) { - recordVarDecl(s$1.Pos()); - } - } else if ($assertType(_ref, ($ptrType(ast.BlockStmt)), true)[1]) { - s$1 = _ref.$val; - blockBranches(lstmt, s$1.List); - } else if ($assertType(_ref, ($ptrType(ast.IfStmt)), true)[1]) { - s$1 = _ref.$val; - stmtBranches(s$1.Body); - if (!($interfaceIsEqual(s$1.Else, $ifaceNil))) { - stmtBranches(s$1.Else); - } - } else if ($assertType(_ref, ($ptrType(ast.CaseClause)), true)[1]) { - s$1 = _ref.$val; - blockBranches(($ptrType(ast.LabeledStmt)).nil, s$1.Body); - } else if ($assertType(_ref, ($ptrType(ast.SwitchStmt)), true)[1]) { - s$1 = _ref.$val; - stmtBranches(s$1.Body); - } else if ($assertType(_ref, ($ptrType(ast.TypeSwitchStmt)), true)[1]) { - s$1 = _ref.$val; - stmtBranches(s$1.Body); - } else if ($assertType(_ref, ($ptrType(ast.CommClause)), true)[1]) { - s$1 = _ref.$val; - blockBranches(($ptrType(ast.LabeledStmt)).nil, s$1.Body); - } else if ($assertType(_ref, ($ptrType(ast.SelectStmt)), true)[1]) { - s$1 = _ref.$val; - stmtBranches(s$1.Body); - } else if ($assertType(_ref, ($ptrType(ast.ForStmt)), true)[1]) { - s$1 = _ref.$val; - stmtBranches(s$1.Body); - } else if ($assertType(_ref, ($ptrType(ast.RangeStmt)), true)[1]) { - s$1 = _ref.$val; - stmtBranches(s$1.Body); + parser.prototype.parseGenDecl = function(keyword, f) { return this.$val.parseGenDecl(keyword, f); }; + parser.Ptr.prototype.parseReceiver = function(scope) { + var $deferred = [], $err = null, p, par, x, recv, base, _tuple, isIdent, _tuple$1, isBad; + /* */ try { $deferFrames.push($deferred); + p = this; + if (p.trace) { + $deferred.push([un, [trace(p, "Receiver")]]); + } + par = p.parseParameters(scope, false); + if (!((par.NumFields() === 1))) { + p.errorExpected(par.Opening, "exactly one receiver"); + par.List = new ($sliceType(($ptrType(ast.Field))))([new ast.Field.Ptr(($ptrType(ast.CommentGroup)).nil, ($sliceType(($ptrType(ast.Ident)))).nil, new ast.BadExpr.Ptr(par.Opening, par.Closing + 1 >> 0), ($ptrType(ast.BasicLit)).nil, ($ptrType(ast.CommentGroup)).nil)]); + return par; + } + recv = (x = par.List, ((0 < 0 || 0 >= x.$length) ? $throwRuntimeError("index out of range") : x.$array[x.$offset + 0])); + base = deref(recv.Type); + _tuple = $assertType(base, ($ptrType(ast.Ident)), true); isIdent = _tuple[1]; + if (!isIdent) { + _tuple$1 = $assertType(base, ($ptrType(ast.BadExpr)), true); isBad = _tuple$1[1]; + if (!isBad) { + p.errorExpected(base.Pos(), "(unqualified) identifier"); } - }); - _ref = list; - _i = 0; - while (_i < _ref.$length) { - s = ((_i < 0 || _i >= _ref.$length) ? $throwRuntimeError("index out of range") : _ref.$array[_ref.$offset + _i]); - stmtBranches(s); - _i++; + par.List = new ($sliceType(($ptrType(ast.Field))))([new ast.Field.Ptr(($ptrType(ast.CommentGroup)).nil, ($sliceType(($ptrType(ast.Ident)))).nil, new ast.BadExpr.Ptr(recv.Pos(), p.safePos(recv.End())), ($ptrType(ast.BasicLit)).nil, ($ptrType(ast.CommentGroup)).nil)]); } - return fwdJumps; + return par; + /* */ } catch(err) { $err = err; return ($ptrType(ast.FieldList)).nil; } finally { $deferFrames.pop(); $callDeferred($deferred, $err); } }; - Checker.prototype.blockBranches = function(all, parent, lstmt, list) { return this.$val.blockBranches(all, parent, lstmt, list); }; - LookupFieldOrMethod = $pkg.LookupFieldOrMethod = function(T, addressable, pkg, name) { - var obj = $ifaceNil, index = ($sliceType($Int)).nil, indirect = false, _tuple, t, _tuple$1, p, _tuple$2, _tuple$3, ok, _tmp, _tmp$1, _tmp$2, _tuple$4; - _tuple = $assertType(T, ($ptrType(Named)), true); t = _tuple[0]; - if (!(t === ($ptrType(Named)).nil)) { - _tuple$1 = $assertType(t.underlying, ($ptrType(Pointer)), true); p = _tuple$1[0]; - if (!(p === ($ptrType(Pointer)).nil)) { - _tuple$2 = lookupFieldOrMethod(p, false, pkg, name); obj = _tuple$2[0]; index = _tuple$2[1]; indirect = _tuple$2[2]; - _tuple$3 = $assertType(obj, ($ptrType(Func)), true); ok = _tuple$3[1]; - if (ok) { - _tmp = $ifaceNil; _tmp$1 = ($sliceType($Int)).nil; _tmp$2 = false; obj = _tmp; index = _tmp$1; indirect = _tmp$2; - return [obj, index, indirect]; - } - return [obj, index, indirect]; + parser.prototype.parseReceiver = function(scope) { return this.$val.parseReceiver(scope); }; + parser.Ptr.prototype.parseFuncDecl = function() { + var $deferred = [], $err = null, p, doc, pos, scope, recv, ident, _tuple, params, results, body, decl; + /* */ try { $deferFrames.push($deferred); + p = this; + if (p.trace) { + $deferred.push([un, [trace(p, "FunctionDecl")]]); + } + doc = p.leadComment; + pos = p.expect(71); + scope = ast.NewScope(p.topScope); + recv = ($ptrType(ast.FieldList)).nil; + if (p.tok === 49) { + recv = p.parseReceiver(scope); + } + ident = p.parseIdent(); + _tuple = p.parseSignature(scope); params = _tuple[0]; results = _tuple[1]; + body = ($ptrType(ast.BlockStmt)).nil; + if (p.tok === 51) { + body = p.parseBody(scope); + } + p.expectSemi(); + decl = new ast.FuncDecl.Ptr(doc, recv, ident, new ast.FuncType.Ptr(pos, params, results), body); + if (recv === ($ptrType(ast.FieldList)).nil) { + if (!(ident.Name === "init")) { + p.declare(decl, $ifaceNil, p.pkgScope, 5, new ($sliceType(($ptrType(ast.Ident))))([ident])); } } - _tuple$4 = lookupFieldOrMethod(T, addressable, pkg, name); obj = _tuple$4[0]; index = _tuple$4[1]; indirect = _tuple$4[2]; - return [obj, index, indirect]; + return decl; + /* */ } catch(err) { $err = err; return ($ptrType(ast.FuncDecl)).nil; } finally { $deferFrames.pop(); $callDeferred($deferred, $err); } }; - lookupFieldOrMethod = function(T, addressable, pkg, name) { - var obj = $ifaceNil, index = ($sliceType($Int)).nil, indirect = false, _tuple, typ, isPtr, _tuple$1, named, utyp, _tuple$2, ok, current, seen, next, _ref, _i, e, _entry, _key$2, _tuple$3, i, m, _tmp, _tmp$1, _tmp$2, t, _ref$1, _ref$2, _i$1, i$1, f, _tmp$3, _tmp$4, _tmp$5, _tuple$4, typ$1, isPtr$1, _tuple$5, t$1, _tuple$6, i$2, m$1, _tmp$6, _tmp$7, _tmp$8, _tuple$7, f$1, _tmp$9, _tmp$10, _tmp$11, _tmp$12, _tmp$13, _tmp$14; - if (name === "_") { - return [obj, index, indirect]; + parser.prototype.parseFuncDecl = function() { return this.$val.parseFuncDecl(); }; + parser.Ptr.prototype.parseDecl = function(sync) { + var $deferred = [], $err = null, p, f, _ref, pos; + /* */ try { $deferFrames.push($deferred); + p = this; + if (p.trace) { + $deferred.push([un, [trace(p, "Declaration")]]); } - _tuple = deref(T); typ = _tuple[0]; isPtr = _tuple[1]; - _tuple$1 = $assertType(typ, ($ptrType(Named)), true); named = _tuple$1[0]; - if (isPtr) { - utyp = typ; - if (!(named === ($ptrType(Named)).nil)) { - utyp = named.underlying; - } - _tuple$2 = $assertType(utyp, ($ptrType(Interface)), true); ok = _tuple$2[1]; - if (ok) { - return [obj, index, indirect]; - } + f = $throwNilPointerError; + _ref = p.tok; + if (_ref === 64 || _ref === 85) { + f = $methodVal(p, "parseValueSpec"); + } else if (_ref === 84) { + f = $methodVal(p, "parseTypeSpec"); + } else if (_ref === 71) { + return p.parseFuncDecl(); + } else { + pos = p.pos; + p.errorExpected(pos, "declaration"); + sync(p); + return new ast.BadDecl.Ptr(pos, p.pos); } - current = new ($sliceType(embeddedType))([new embeddedType.Ptr(named, ($sliceType($Int)).nil, isPtr, false)]); - seen = false; - while (current.$length > 0) { - next = ($sliceType(embeddedType)).nil; - _ref = current; - _i = 0; - while (_i < _ref.$length) { - e = new embeddedType.Ptr(); $copy(e, ((_i < 0 || _i >= _ref.$length) ? $throwRuntimeError("index out of range") : _ref.$array[_ref.$offset + _i]), embeddedType); - if (!(e.typ === ($ptrType(Named)).nil)) { - if ((_entry = seen[e.typ.$key()], _entry !== undefined ? _entry.v : false)) { - _i++; - continue; - } - if (seen === false) { - seen = new $Map(); - } - _key$2 = e.typ; (seen || $throwRuntimeError("assignment to entry in nil map"))[_key$2.$key()] = { k: _key$2, v: true }; - _tuple$3 = lookupMethod(e.typ.methods, pkg, name); i = _tuple$3[0]; m = _tuple$3[1]; - if (!(m === ($ptrType(Func)).nil)) { - assert(!($interfaceIsEqual(m.object.typ, $ifaceNil))); - index = concat(e.index, i); - if (!($interfaceIsEqual(obj, $ifaceNil)) || e.multiples) { - _tmp = $ifaceNil; _tmp$1 = index; _tmp$2 = false; obj = _tmp; index = _tmp$1; indirect = _tmp$2; - return [obj, index, indirect]; - } - obj = m; - indirect = e.indirect; - _i++; - continue; - } - typ = e.typ.underlying; - } - _ref$1 = typ; - if ($assertType(_ref$1, ($ptrType(Struct)), true)[1]) { - t = _ref$1.$val; - _ref$2 = t.fields; - _i$1 = 0; - while (_i$1 < _ref$2.$length) { - i$1 = _i$1; - f = ((_i$1 < 0 || _i$1 >= _ref$2.$length) ? $throwRuntimeError("index out of range") : _ref$2.$array[_ref$2.$offset + _i$1]); - if (f.object.sameId(pkg, name)) { - assert(!($interfaceIsEqual(f.object.typ, $ifaceNil))); - index = concat(e.index, i$1); - if (!($interfaceIsEqual(obj, $ifaceNil)) || e.multiples) { - _tmp$3 = $ifaceNil; _tmp$4 = index; _tmp$5 = false; obj = _tmp$3; index = _tmp$4; indirect = _tmp$5; - return [obj, index, indirect]; - } - obj = f; - indirect = e.indirect; - _i$1++; - continue; - } - if ($interfaceIsEqual(obj, $ifaceNil) && f.anonymous) { - _tuple$4 = deref(f.object.typ); typ$1 = _tuple$4[0]; isPtr$1 = _tuple$4[1]; - _tuple$5 = $assertType(typ$1, ($ptrType(Named)), true); t$1 = _tuple$5[0]; - if (!(t$1 === ($ptrType(Named)).nil)) { - next = $append(next, new embeddedType.Ptr(t$1, concat(e.index, i$1), e.indirect || isPtr$1, e.multiples)); - } - } - _i$1++; - } - } else if ($assertType(_ref$1, ($ptrType(Interface)), true)[1]) { - t = _ref$1.$val; - _tuple$6 = lookupMethod(t.allMethods, pkg, name); i$2 = _tuple$6[0]; m$1 = _tuple$6[1]; - if (!(m$1 === ($ptrType(Func)).nil)) { - assert(!($interfaceIsEqual(m$1.object.typ, $ifaceNil))); - index = concat(e.index, i$2); - if (!($interfaceIsEqual(obj, $ifaceNil)) || e.multiples) { - _tmp$6 = $ifaceNil; _tmp$7 = index; _tmp$8 = false; obj = _tmp$6; index = _tmp$7; indirect = _tmp$8; - return [obj, index, indirect]; - } - obj = m$1; - indirect = e.indirect; - } - } - _i++; + return p.parseGenDecl(p.tok, f); + /* */ } catch(err) { $err = err; return $ifaceNil; } finally { $deferFrames.pop(); $callDeferred($deferred, $err); } + }; + parser.prototype.parseDecl = function(sync) { return this.$val.parseDecl(sync); }; + parser.Ptr.prototype.parseFile = function() { + var $deferred = [], $err = null, p, doc, pos, ident, decls, i, _ref, _i, ident$1, x; + /* */ try { $deferFrames.push($deferred); + p = this; + if (p.trace) { + $deferred.push([un, [trace(p, "File")]]); + } + if (!((p.errors.Len() === 0))) { + return ($ptrType(ast.File)).nil; + } + doc = p.leadComment; + pos = p.expect(78); + ident = p.parseIdent(); + if (ident.Name === "_" && !((((p.mode & 16) >>> 0) === 0))) { + p.error(p.pos, "invalid package name _"); + } + p.expectSemi(); + if (!((p.errors.Len() === 0))) { + return ($ptrType(ast.File)).nil; + } + p.openScope(); + p.pkgScope = p.topScope; + decls = ($sliceType(ast.Decl)).nil; + if (((p.mode & 1) >>> 0) === 0) { + while (p.tok === 75) { + decls = $append(decls, p.parseGenDecl(75, $methodVal(p, "parseImportSpec"))); } - if (!($interfaceIsEqual(obj, $ifaceNil))) { - _tuple$7 = $assertType(obj, ($ptrType(Func)), true); f$1 = _tuple$7[0]; - if (!(f$1 === ($ptrType(Func)).nil) && ptrRecv(f$1) && !indirect && !addressable) { - _tmp$9 = $ifaceNil; _tmp$10 = ($sliceType($Int)).nil; _tmp$11 = true; obj = _tmp$9; index = _tmp$10; indirect = _tmp$11; - return [obj, index, indirect]; + if (((p.mode & 2) >>> 0) === 0) { + while (!((p.tok === 1))) { + decls = $append(decls, p.parseDecl(syncDecl)); } - return [obj, index, indirect]; } - current = consolidateMultiples(next); } - _tmp$12 = $ifaceNil; _tmp$13 = ($sliceType($Int)).nil; _tmp$14 = false; obj = _tmp$12; index = _tmp$13; indirect = _tmp$14; - return [obj, index, indirect]; + p.closeScope(); + assert(p.topScope === ($ptrType(ast.Scope)).nil, "unbalanced scopes"); + assert(p.labelScope === ($ptrType(ast.Scope)).nil, "unbalanced label scopes"); + i = 0; + _ref = p.unresolved; + _i = 0; + while (_i < _ref.$length) { + ident$1 = ((_i < 0 || _i >= _ref.$length) ? $throwRuntimeError("index out of range") : _ref.$array[_ref.$offset + _i]); + assert(ident$1.Obj === unresolved, "object already resolved"); + ident$1.Obj = p.pkgScope.Lookup(ident$1.Name); + if (ident$1.Obj === ($ptrType(ast.Object)).nil) { + (x = p.unresolved, (i < 0 || i >= x.$length) ? $throwRuntimeError("index out of range") : x.$array[x.$offset + i] = ident$1); + i = i + (1) >> 0; + } + _i++; + } + return new ast.File.Ptr(doc, pos, ident, decls, p.pkgScope, p.imports, $subslice(p.unresolved, 0, i), p.comments); + /* */ } catch(err) { $err = err; return ($ptrType(ast.File)).nil; } finally { $deferFrames.pop(); $callDeferred($deferred, $err); } + }; + parser.prototype.parseFile = function() { return this.$val.parseFile(); }; + $pkg.$init = function() { + ($ptrType(parser)).methods = [["atComma", "atComma", "go/parser", $funcType([$String], [$Bool], false), -1], ["checkExpr", "checkExpr", "go/parser", $funcType([ast.Expr], [ast.Expr], false), -1], ["checkExprOrType", "checkExprOrType", "go/parser", $funcType([ast.Expr], [ast.Expr], false), -1], ["closeLabelScope", "closeLabelScope", "go/parser", $funcType([], [], false), -1], ["closeScope", "closeScope", "go/parser", $funcType([], [], false), -1], ["consumeComment", "consumeComment", "go/parser", $funcType([], [($ptrType(ast.Comment)), $Int], false), -1], ["consumeCommentGroup", "consumeCommentGroup", "go/parser", $funcType([$Int], [($ptrType(ast.CommentGroup)), $Int], false), -1], ["declare", "declare", "go/parser", $funcType([$emptyInterface, $emptyInterface, ($ptrType(ast.Scope)), ast.ObjKind, ($sliceType(($ptrType(ast.Ident))))], [], true), -1], ["error", "error", "go/parser", $funcType([token.Pos, $String], [], false), -1], ["errorExpected", "errorExpected", "go/parser", $funcType([token.Pos, $String], [], false), -1], ["expect", "expect", "go/parser", $funcType([token.Token], [token.Pos], false), -1], ["expectClosing", "expectClosing", "go/parser", $funcType([token.Token, $String], [token.Pos], false), -1], ["expectSemi", "expectSemi", "go/parser", $funcType([], [], false), -1], ["init", "init", "go/parser", $funcType([($ptrType(token.FileSet)), $String, ($sliceType($Uint8)), Mode], [], false), -1], ["makeExpr", "makeExpr", "go/parser", $funcType([ast.Stmt, $String], [ast.Expr], false), -1], ["makeIdentList", "makeIdentList", "go/parser", $funcType([($sliceType(ast.Expr))], [($sliceType(($ptrType(ast.Ident))))], false), -1], ["next", "next", "go/parser", $funcType([], [], false), -1], ["next0", "next0", "go/parser", $funcType([], [], false), -1], ["openLabelScope", "openLabelScope", "go/parser", $funcType([], [], false), -1], ["openScope", "openScope", "go/parser", $funcType([], [], false), -1], ["parseArrayType", "parseArrayType", "go/parser", $funcType([], [ast.Expr], false), -1], ["parseBinaryExpr", "parseBinaryExpr", "go/parser", $funcType([$Bool, $Int], [ast.Expr], false), -1], ["parseBlockStmt", "parseBlockStmt", "go/parser", $funcType([], [($ptrType(ast.BlockStmt))], false), -1], ["parseBody", "parseBody", "go/parser", $funcType([($ptrType(ast.Scope))], [($ptrType(ast.BlockStmt))], false), -1], ["parseBranchStmt", "parseBranchStmt", "go/parser", $funcType([token.Token], [($ptrType(ast.BranchStmt))], false), -1], ["parseCallExpr", "parseCallExpr", "go/parser", $funcType([$String], [($ptrType(ast.CallExpr))], false), -1], ["parseCallOrConversion", "parseCallOrConversion", "go/parser", $funcType([ast.Expr], [($ptrType(ast.CallExpr))], false), -1], ["parseCaseClause", "parseCaseClause", "go/parser", $funcType([$Bool], [($ptrType(ast.CaseClause))], false), -1], ["parseChanType", "parseChanType", "go/parser", $funcType([], [($ptrType(ast.ChanType))], false), -1], ["parseCommClause", "parseCommClause", "go/parser", $funcType([], [($ptrType(ast.CommClause))], false), -1], ["parseDecl", "parseDecl", "go/parser", $funcType([($funcType([($ptrType(parser))], [], false))], [ast.Decl], false), -1], ["parseDeferStmt", "parseDeferStmt", "go/parser", $funcType([], [ast.Stmt], false), -1], ["parseElement", "parseElement", "go/parser", $funcType([$Bool], [ast.Expr], false), -1], ["parseElementList", "parseElementList", "go/parser", $funcType([], [($sliceType(ast.Expr))], false), -1], ["parseExpr", "parseExpr", "go/parser", $funcType([$Bool], [ast.Expr], false), -1], ["parseExprList", "parseExprList", "go/parser", $funcType([$Bool], [($sliceType(ast.Expr))], false), -1], ["parseFieldDecl", "parseFieldDecl", "go/parser", $funcType([($ptrType(ast.Scope))], [($ptrType(ast.Field))], false), -1], ["parseFile", "parseFile", "go/parser", $funcType([], [($ptrType(ast.File))], false), -1], ["parseForStmt", "parseForStmt", "go/parser", $funcType([], [ast.Stmt], false), -1], ["parseFuncDecl", "parseFuncDecl", "go/parser", $funcType([], [($ptrType(ast.FuncDecl))], false), -1], ["parseFuncType", "parseFuncType", "go/parser", $funcType([], [($ptrType(ast.FuncType)), ($ptrType(ast.Scope))], false), -1], ["parseFuncTypeOrLit", "parseFuncTypeOrLit", "go/parser", $funcType([], [ast.Expr], false), -1], ["parseGenDecl", "parseGenDecl", "go/parser", $funcType([token.Token, parseSpecFunction], [($ptrType(ast.GenDecl))], false), -1], ["parseGoStmt", "parseGoStmt", "go/parser", $funcType([], [ast.Stmt], false), -1], ["parseIdent", "parseIdent", "go/parser", $funcType([], [($ptrType(ast.Ident))], false), -1], ["parseIdentList", "parseIdentList", "go/parser", $funcType([], [($sliceType(($ptrType(ast.Ident))))], false), -1], ["parseIfStmt", "parseIfStmt", "go/parser", $funcType([], [($ptrType(ast.IfStmt))], false), -1], ["parseImportSpec", "parseImportSpec", "go/parser", $funcType([($ptrType(ast.CommentGroup)), token.Token, $Int], [ast.Spec], false), -1], ["parseIndexOrSlice", "parseIndexOrSlice", "go/parser", $funcType([ast.Expr], [ast.Expr], false), -1], ["parseInterfaceType", "parseInterfaceType", "go/parser", $funcType([], [($ptrType(ast.InterfaceType))], false), -1], ["parseLhsList", "parseLhsList", "go/parser", $funcType([], [($sliceType(ast.Expr))], false), -1], ["parseLiteralValue", "parseLiteralValue", "go/parser", $funcType([ast.Expr], [ast.Expr], false), -1], ["parseMapType", "parseMapType", "go/parser", $funcType([], [($ptrType(ast.MapType))], false), -1], ["parseMethodSpec", "parseMethodSpec", "go/parser", $funcType([($ptrType(ast.Scope))], [($ptrType(ast.Field))], false), -1], ["parseOperand", "parseOperand", "go/parser", $funcType([$Bool], [ast.Expr], false), -1], ["parseParameterList", "parseParameterList", "go/parser", $funcType([($ptrType(ast.Scope)), $Bool], [($sliceType(($ptrType(ast.Field))))], false), -1], ["parseParameters", "parseParameters", "go/parser", $funcType([($ptrType(ast.Scope)), $Bool], [($ptrType(ast.FieldList))], false), -1], ["parsePointerType", "parsePointerType", "go/parser", $funcType([], [($ptrType(ast.StarExpr))], false), -1], ["parsePrimaryExpr", "parsePrimaryExpr", "go/parser", $funcType([$Bool], [ast.Expr], false), -1], ["parseReceiver", "parseReceiver", "go/parser", $funcType([($ptrType(ast.Scope))], [($ptrType(ast.FieldList))], false), -1], ["parseResult", "parseResult", "go/parser", $funcType([($ptrType(ast.Scope))], [($ptrType(ast.FieldList))], false), -1], ["parseReturnStmt", "parseReturnStmt", "go/parser", $funcType([], [($ptrType(ast.ReturnStmt))], false), -1], ["parseRhs", "parseRhs", "go/parser", $funcType([], [ast.Expr], false), -1], ["parseRhsList", "parseRhsList", "go/parser", $funcType([], [($sliceType(ast.Expr))], false), -1], ["parseRhsOrType", "parseRhsOrType", "go/parser", $funcType([], [ast.Expr], false), -1], ["parseSelectStmt", "parseSelectStmt", "go/parser", $funcType([], [($ptrType(ast.SelectStmt))], false), -1], ["parseSelector", "parseSelector", "go/parser", $funcType([ast.Expr], [ast.Expr], false), -1], ["parseSignature", "parseSignature", "go/parser", $funcType([($ptrType(ast.Scope))], [($ptrType(ast.FieldList)), ($ptrType(ast.FieldList))], false), -1], ["parseSimpleStmt", "parseSimpleStmt", "go/parser", $funcType([$Int], [ast.Stmt, $Bool], false), -1], ["parseStmt", "parseStmt", "go/parser", $funcType([], [ast.Stmt], false), -1], ["parseStmtList", "parseStmtList", "go/parser", $funcType([], [($sliceType(ast.Stmt))], false), -1], ["parseStructType", "parseStructType", "go/parser", $funcType([], [($ptrType(ast.StructType))], false), -1], ["parseSwitchStmt", "parseSwitchStmt", "go/parser", $funcType([], [ast.Stmt], false), -1], ["parseType", "parseType", "go/parser", $funcType([], [ast.Expr], false), -1], ["parseTypeAssertion", "parseTypeAssertion", "go/parser", $funcType([ast.Expr], [ast.Expr], false), -1], ["parseTypeList", "parseTypeList", "go/parser", $funcType([], [($sliceType(ast.Expr))], false), -1], ["parseTypeName", "parseTypeName", "go/parser", $funcType([], [ast.Expr], false), -1], ["parseTypeSpec", "parseTypeSpec", "go/parser", $funcType([($ptrType(ast.CommentGroup)), token.Token, $Int], [ast.Spec], false), -1], ["parseUnaryExpr", "parseUnaryExpr", "go/parser", $funcType([$Bool], [ast.Expr], false), -1], ["parseValueSpec", "parseValueSpec", "go/parser", $funcType([($ptrType(ast.CommentGroup)), token.Token, $Int], [ast.Spec], false), -1], ["parseVarList", "parseVarList", "go/parser", $funcType([$Bool], [($sliceType(ast.Expr)), ast.Expr], false), -1], ["parseVarType", "parseVarType", "go/parser", $funcType([$Bool], [ast.Expr], false), -1], ["printTrace", "printTrace", "go/parser", $funcType([($sliceType($emptyInterface))], [], true), -1], ["resolve", "resolve", "go/parser", $funcType([ast.Expr], [], false), -1], ["safePos", "safePos", "go/parser", $funcType([token.Pos], [token.Pos], false), -1], ["shortVarDecl", "shortVarDecl", "go/parser", $funcType([($ptrType(ast.AssignStmt)), ($sliceType(ast.Expr))], [], false), -1], ["tokPrec", "tokPrec", "go/parser", $funcType([], [token.Token, $Int], false), -1], ["tryIdentOrType", "tryIdentOrType", "go/parser", $funcType([], [ast.Expr], false), -1], ["tryResolve", "tryResolve", "go/parser", $funcType([ast.Expr, $Bool], [], false), -1], ["tryType", "tryType", "go/parser", $funcType([], [ast.Expr], false), -1], ["tryVarType", "tryVarType", "go/parser", $funcType([$Bool], [ast.Expr], false), -1]]; + parser.init([["file", "file", "go/parser", ($ptrType(token.File)), ""], ["errors", "errors", "go/parser", scanner.ErrorList, ""], ["scanner", "scanner", "go/parser", scanner.Scanner, ""], ["mode", "mode", "go/parser", Mode, ""], ["trace", "trace", "go/parser", $Bool, ""], ["indent", "indent", "go/parser", $Int, ""], ["comments", "comments", "go/parser", ($sliceType(($ptrType(ast.CommentGroup)))), ""], ["leadComment", "leadComment", "go/parser", ($ptrType(ast.CommentGroup)), ""], ["lineComment", "lineComment", "go/parser", ($ptrType(ast.CommentGroup)), ""], ["pos", "pos", "go/parser", token.Pos, ""], ["tok", "tok", "go/parser", token.Token, ""], ["lit", "lit", "go/parser", $String, ""], ["syncPos", "syncPos", "go/parser", token.Pos, ""], ["syncCnt", "syncCnt", "go/parser", $Int, ""], ["exprLev", "exprLev", "go/parser", $Int, ""], ["inRhs", "inRhs", "go/parser", $Bool, ""], ["pkgScope", "pkgScope", "go/parser", ($ptrType(ast.Scope)), ""], ["topScope", "topScope", "go/parser", ($ptrType(ast.Scope)), ""], ["unresolved", "unresolved", "go/parser", ($sliceType(($ptrType(ast.Ident)))), ""], ["imports", "imports", "go/parser", ($sliceType(($ptrType(ast.ImportSpec)))), ""], ["labelScope", "labelScope", "go/parser", ($ptrType(ast.Scope)), ""], ["targetStack", "targetStack", "go/parser", ($sliceType(($sliceType(($ptrType(ast.Ident)))))), ""]]); + bailout.init([]); + parseSpecFunction.init([($ptrType(ast.CommentGroup)), token.Token, $Int], [ast.Spec], false); + unresolved = new ast.Object.Ptr(); + }; + return $pkg; +})(); +$packages["path"] = (function() { + var $pkg = {}, errors = $packages["errors"], strings = $packages["strings"], utf8 = $packages["unicode/utf8"], Split, Base; + Split = $pkg.Split = function(path) { + var dir = "", file = "", i, _tmp, _tmp$1; + i = strings.LastIndex(path, "/"); + _tmp = path.substring(0, (i + 1 >> 0)); _tmp$1 = path.substring((i + 1 >> 0)); dir = _tmp; file = _tmp$1; + return [dir, file]; + }; + Base = $pkg.Base = function(path) { + var i; + if (path === "") { + return "."; + } + while (path.length > 0 && (path.charCodeAt((path.length - 1 >> 0)) === 47)) { + path = path.substring(0, (path.length - 1 >> 0)); + } + i = strings.LastIndex(path, "/"); + if (i >= 0) { + path = path.substring((i + 1 >> 0)); + } + if (path === "") { + return "/"; + } + return path; + }; + $pkg.$init = function() { + $pkg.ErrBadPattern = errors.New("syntax error in pattern"); + }; + return $pkg; +})(); +$packages["code.google.com/p/go.tools/go/types"] = (function() { + var $pkg = {}, bytes = $packages["bytes"], fmt = $packages["fmt"], ast = $packages["go/ast"], token = $packages["go/token"], exact = $packages["code.google.com/p/go.tools/go/exact"], strings = $packages["strings"], parser = $packages["go/parser"], math = $packages["math"], heap = $packages["container/heap"], sort = $packages["sort"], sync = $packages["sync"], errors = $packages["errors"], path = $packages["path"], strconv = $packages["strconv"], unicode = $packages["unicode"], io = $packages["io"], Error, Importer, Config, Info, TypeAndValue, Initializer, getter, exprInfo, funcInfo, context, Checker, bailout, opPredicates, exprKind, objNode, nodeQueue, block, embeddedType, MethodSet, fieldSet, methodSet, byUniqueName, Object, object, PkgName, Const, TypeName, Var, Func, Label, Builtin, Nil, objset, operandMode, operand, inSourceOrder, Package, ifacePair, declInfo, Scope, SelectionKind, Selection, Sizes, StdSizes, stmtContext, Type, BasicKind, BasicInfo, Basic, Array, Slice, Struct, Pointer, Tuple, Signature, Interface, Map, Chan, ChanDir, Named, byUniqueTypeName, byUniqueMethodName, builtinId, unaryOpPredicates, binaryOpPredicates, emptyMethodSet, operandModeString, basicSizes, stdSizes, universeIota, aliases, predeclaredConsts, predeclaredFuncs, _map, _key, _map$1, _key$1, Implements, makeSig, implicitArrayDeref, unparen, unpack, NewChecker, isUintptr, isUnsafePointer, isPointer, isBytesOrRunes, underlying, assert, unreachable, isShift, isComparison, fitsFloat32, roundFloat32, fitsFloat64, roundFloat64, representableConst, ExprString, WriteExpr, writeSigExpr, writeFieldList, slice3, sliceMax, findPath, valIndex, dependencyGraph, LookupFieldOrMethod, lookupFieldOrMethod, consolidateMultiples, MissingMethod, assertableTo, deref, derefStructPtr, concat, fieldIndex, lookupMethod, NewMethodSet, ptrRecv, Id, NewPkgName, NewConst, NewTypeName, NewVar, NewParam, NewField, NewFunc, NewLabel, newBuiltin, writeObject, ObjectString, writeFuncName, operandString, orderedSetObjects, NewPackage, isNamed, isBoolean, isInteger, isUnsigned, isFloat, isComplex, isNumeric, isString, isTyped, isUntyped, isOrdered, isConstType, isInterface, Comparable, hasNil, Identical, identical, defaultType, validatedImportPath, hasBreak, hasBreakList, NewScope, SelectionString, align, assignOp, NewArray, NewSlice, NewStruct, NewPointer, NewTuple, NewSignature, NewInterface, NewMap, NewChan, NewNamed, TypeString, WriteType, writeType, writeTuple, WriteSignature, writeSignature, anonymousFieldIdent, defPredeclaredTypes, defPredeclaredConsts, defPredeclaredNil, defPredeclaredFuncs, init, def; + Error = $pkg.Error = $newType(0, "Struct", "types.Error", "Error", "code.google.com/p/go.tools/go/types", function(Fset_, Pos_, Msg_, Soft_) { + this.$val = this; + this.Fset = Fset_ !== undefined ? Fset_ : ($ptrType(token.FileSet)).nil; + this.Pos = Pos_ !== undefined ? Pos_ : 0; + this.Msg = Msg_ !== undefined ? Msg_ : ""; + this.Soft = Soft_ !== undefined ? Soft_ : false; + }); + Importer = $pkg.Importer = $newType(4, "Func", "types.Importer", "Importer", "code.google.com/p/go.tools/go/types", null); + Config = $pkg.Config = $newType(0, "Struct", "types.Config", "Config", "code.google.com/p/go.tools/go/types", function(IgnoreFuncBodies_, FakeImportC_, Packages_, Error_, Import_, Sizes_) { + this.$val = this; + this.IgnoreFuncBodies = IgnoreFuncBodies_ !== undefined ? IgnoreFuncBodies_ : false; + this.FakeImportC = FakeImportC_ !== undefined ? FakeImportC_ : false; + this.Packages = Packages_ !== undefined ? Packages_ : false; + this.Error = Error_ !== undefined ? Error_ : $throwNilPointerError; + this.Import = Import_ !== undefined ? Import_ : $throwNilPointerError; + this.Sizes = Sizes_ !== undefined ? Sizes_ : $ifaceNil; + }); + Info = $pkg.Info = $newType(0, "Struct", "types.Info", "Info", "code.google.com/p/go.tools/go/types", function(Types_, Defs_, Uses_, Implicits_, Selections_, Scopes_, InitOrder_) { + this.$val = this; + this.Types = Types_ !== undefined ? Types_ : false; + this.Defs = Defs_ !== undefined ? Defs_ : false; + this.Uses = Uses_ !== undefined ? Uses_ : false; + this.Implicits = Implicits_ !== undefined ? Implicits_ : false; + this.Selections = Selections_ !== undefined ? Selections_ : false; + this.Scopes = Scopes_ !== undefined ? Scopes_ : false; + this.InitOrder = InitOrder_ !== undefined ? InitOrder_ : ($sliceType(($ptrType(Initializer)))).nil; + }); + TypeAndValue = $pkg.TypeAndValue = $newType(0, "Struct", "types.TypeAndValue", "TypeAndValue", "code.google.com/p/go.tools/go/types", function(mode_, Type_, Value_) { + this.$val = this; + this.mode = mode_ !== undefined ? mode_ : 0; + this.Type = Type_ !== undefined ? Type_ : $ifaceNil; + this.Value = Value_ !== undefined ? Value_ : $ifaceNil; + }); + Initializer = $pkg.Initializer = $newType(0, "Struct", "types.Initializer", "Initializer", "code.google.com/p/go.tools/go/types", function(Lhs_, Rhs_) { + this.$val = this; + this.Lhs = Lhs_ !== undefined ? Lhs_ : ($sliceType(($ptrType(Var)))).nil; + this.Rhs = Rhs_ !== undefined ? Rhs_ : $ifaceNil; + }); + getter = $pkg.getter = $newType(4, "Func", "types.getter", "getter", "code.google.com/p/go.tools/go/types", null); + exprInfo = $pkg.exprInfo = $newType(0, "Struct", "types.exprInfo", "exprInfo", "code.google.com/p/go.tools/go/types", function(isLhs_, mode_, typ_, val_) { + this.$val = this; + this.isLhs = isLhs_ !== undefined ? isLhs_ : false; + this.mode = mode_ !== undefined ? mode_ : 0; + this.typ = typ_ !== undefined ? typ_ : ($ptrType(Basic)).nil; + this.val = val_ !== undefined ? val_ : $ifaceNil; + }); + funcInfo = $pkg.funcInfo = $newType(0, "Struct", "types.funcInfo", "funcInfo", "code.google.com/p/go.tools/go/types", function(name_, decl_, sig_, body_) { + this.$val = this; + this.name = name_ !== undefined ? name_ : ""; + this.decl = decl_ !== undefined ? decl_ : ($ptrType(declInfo)).nil; + this.sig = sig_ !== undefined ? sig_ : ($ptrType(Signature)).nil; + this.body = body_ !== undefined ? body_ : ($ptrType(ast.BlockStmt)).nil; + }); + context = $pkg.context = $newType(0, "Struct", "types.context", "context", "code.google.com/p/go.tools/go/types", function(decl_, scope_, iota_, sig_, hasLabel_, hasCallOrRecv_) { + this.$val = this; + this.decl = decl_ !== undefined ? decl_ : ($ptrType(declInfo)).nil; + this.scope = scope_ !== undefined ? scope_ : ($ptrType(Scope)).nil; + this.iota = iota_ !== undefined ? iota_ : $ifaceNil; + this.sig = sig_ !== undefined ? sig_ : ($ptrType(Signature)).nil; + this.hasLabel = hasLabel_ !== undefined ? hasLabel_ : false; + this.hasCallOrRecv = hasCallOrRecv_ !== undefined ? hasCallOrRecv_ : false; + }); + Checker = $pkg.Checker = $newType(0, "Struct", "types.Checker", "Checker", "code.google.com/p/go.tools/go/types", function(conf_, fset_, pkg_, Info_, objMap_, files_, fileScopes_, dotImports_, firstErr_, methods_, untyped_, funcs_, delayed_, context_, indent_) { + this.$val = this; + this.conf = conf_ !== undefined ? conf_ : ($ptrType(Config)).nil; + this.fset = fset_ !== undefined ? fset_ : ($ptrType(token.FileSet)).nil; + this.pkg = pkg_ !== undefined ? pkg_ : ($ptrType(Package)).nil; + this.Info = Info_ !== undefined ? Info_ : ($ptrType(Info)).nil; + this.objMap = objMap_ !== undefined ? objMap_ : false; + this.files = files_ !== undefined ? files_ : ($sliceType(($ptrType(ast.File)))).nil; + this.fileScopes = fileScopes_ !== undefined ? fileScopes_ : ($sliceType(($ptrType(Scope)))).nil; + this.dotImports = dotImports_ !== undefined ? dotImports_ : ($sliceType(($mapType(($ptrType(Package)), token.Pos)))).nil; + this.firstErr = firstErr_ !== undefined ? firstErr_ : $ifaceNil; + this.methods = methods_ !== undefined ? methods_ : false; + this.untyped = untyped_ !== undefined ? untyped_ : false; + this.funcs = funcs_ !== undefined ? funcs_ : ($sliceType(funcInfo)).nil; + this.delayed = delayed_ !== undefined ? delayed_ : ($sliceType(($funcType([], [], false)))).nil; + this.context = context_ !== undefined ? context_ : new context.Ptr(); + this.indent = indent_ !== undefined ? indent_ : 0; + }); + bailout = $pkg.bailout = $newType(0, "Struct", "types.bailout", "bailout", "code.google.com/p/go.tools/go/types", function() { + this.$val = this; + }); + opPredicates = $pkg.opPredicates = $newType(4, "Map", "types.opPredicates", "opPredicates", "code.google.com/p/go.tools/go/types", null); + exprKind = $pkg.exprKind = $newType(4, "Int", "types.exprKind", "exprKind", "code.google.com/p/go.tools/go/types", null); + objNode = $pkg.objNode = $newType(0, "Struct", "types.objNode", "objNode", "code.google.com/p/go.tools/go/types", function(obj_, in$1_, out_, index_, mark_) { + this.$val = this; + this.obj = obj_ !== undefined ? obj_ : $ifaceNil; + this.in$1 = in$1_ !== undefined ? in$1_ : 0; + this.out = out_ !== undefined ? out_ : ($sliceType(($ptrType(objNode)))).nil; + this.index = index_ !== undefined ? index_ : 0; + this.mark = mark_ !== undefined ? mark_ : 0; + }); + nodeQueue = $pkg.nodeQueue = $newType(12, "Slice", "types.nodeQueue", "nodeQueue", "code.google.com/p/go.tools/go/types", null); + block = $pkg.block = $newType(0, "Struct", "types.block", "block", "code.google.com/p/go.tools/go/types", function(parent_, lstmt_, labels_) { + this.$val = this; + this.parent = parent_ !== undefined ? parent_ : ($ptrType(block)).nil; + this.lstmt = lstmt_ !== undefined ? lstmt_ : ($ptrType(ast.LabeledStmt)).nil; + this.labels = labels_ !== undefined ? labels_ : false; + }); + embeddedType = $pkg.embeddedType = $newType(0, "Struct", "types.embeddedType", "embeddedType", "code.google.com/p/go.tools/go/types", function(typ_, index_, indirect_, multiples_) { + this.$val = this; + this.typ = typ_ !== undefined ? typ_ : ($ptrType(Named)).nil; + this.index = index_ !== undefined ? index_ : ($sliceType($Int)).nil; + this.indirect = indirect_ !== undefined ? indirect_ : false; + this.multiples = multiples_ !== undefined ? multiples_ : false; + }); + MethodSet = $pkg.MethodSet = $newType(0, "Struct", "types.MethodSet", "MethodSet", "code.google.com/p/go.tools/go/types", function(list_) { + this.$val = this; + this.list = list_ !== undefined ? list_ : ($sliceType(($ptrType(Selection)))).nil; + }); + fieldSet = $pkg.fieldSet = $newType(4, "Map", "types.fieldSet", "fieldSet", "code.google.com/p/go.tools/go/types", null); + methodSet = $pkg.methodSet = $newType(4, "Map", "types.methodSet", "methodSet", "code.google.com/p/go.tools/go/types", null); + byUniqueName = $pkg.byUniqueName = $newType(12, "Slice", "types.byUniqueName", "byUniqueName", "code.google.com/p/go.tools/go/types", null); + Object = $pkg.Object = $newType(8, "Interface", "types.Object", "Object", "code.google.com/p/go.tools/go/types", null); + object = $pkg.object = $newType(0, "Struct", "types.object", "object", "code.google.com/p/go.tools/go/types", function(parent_, pos_, pkg_, name_, typ_, order__, used_) { + this.$val = this; + this.parent = parent_ !== undefined ? parent_ : ($ptrType(Scope)).nil; + this.pos = pos_ !== undefined ? pos_ : 0; + this.pkg = pkg_ !== undefined ? pkg_ : ($ptrType(Package)).nil; + this.name = name_ !== undefined ? name_ : ""; + this.typ = typ_ !== undefined ? typ_ : $ifaceNil; + this.order_ = order__ !== undefined ? order__ : 0; + this.used = used_ !== undefined ? used_ : false; + }); + PkgName = $pkg.PkgName = $newType(0, "Struct", "types.PkgName", "PkgName", "code.google.com/p/go.tools/go/types", function(object_, imported_) { + this.$val = this; + this.object = object_ !== undefined ? object_ : new object.Ptr(); + this.imported = imported_ !== undefined ? imported_ : ($ptrType(Package)).nil; + }); + Const = $pkg.Const = $newType(0, "Struct", "types.Const", "Const", "code.google.com/p/go.tools/go/types", function(object_, val_, visited_) { + this.$val = this; + this.object = object_ !== undefined ? object_ : new object.Ptr(); + this.val = val_ !== undefined ? val_ : $ifaceNil; + this.visited = visited_ !== undefined ? visited_ : false; + }); + TypeName = $pkg.TypeName = $newType(0, "Struct", "types.TypeName", "TypeName", "code.google.com/p/go.tools/go/types", function(object_) { + this.$val = this; + this.object = object_ !== undefined ? object_ : new object.Ptr(); + }); + Var = $pkg.Var = $newType(0, "Struct", "types.Var", "Var", "code.google.com/p/go.tools/go/types", function(object_, anonymous_, visited_, isField_) { + this.$val = this; + this.object = object_ !== undefined ? object_ : new object.Ptr(); + this.anonymous = anonymous_ !== undefined ? anonymous_ : false; + this.visited = visited_ !== undefined ? visited_ : false; + this.isField = isField_ !== undefined ? isField_ : false; + }); + Func = $pkg.Func = $newType(0, "Struct", "types.Func", "Func", "code.google.com/p/go.tools/go/types", function(object_) { + this.$val = this; + this.object = object_ !== undefined ? object_ : new object.Ptr(); + }); + Label = $pkg.Label = $newType(0, "Struct", "types.Label", "Label", "code.google.com/p/go.tools/go/types", function(object_) { + this.$val = this; + this.object = object_ !== undefined ? object_ : new object.Ptr(); + }); + Builtin = $pkg.Builtin = $newType(0, "Struct", "types.Builtin", "Builtin", "code.google.com/p/go.tools/go/types", function(object_, id_) { + this.$val = this; + this.object = object_ !== undefined ? object_ : new object.Ptr(); + this.id = id_ !== undefined ? id_ : 0; + }); + Nil = $pkg.Nil = $newType(0, "Struct", "types.Nil", "Nil", "code.google.com/p/go.tools/go/types", function(object_) { + this.$val = this; + this.object = object_ !== undefined ? object_ : new object.Ptr(); + }); + objset = $pkg.objset = $newType(4, "Map", "types.objset", "objset", "code.google.com/p/go.tools/go/types", null); + operandMode = $pkg.operandMode = $newType(1, "Uint8", "types.operandMode", "operandMode", "code.google.com/p/go.tools/go/types", null); + operand = $pkg.operand = $newType(0, "Struct", "types.operand", "operand", "code.google.com/p/go.tools/go/types", function(mode_, expr_, typ_, val_, id_) { + this.$val = this; + this.mode = mode_ !== undefined ? mode_ : 0; + this.expr = expr_ !== undefined ? expr_ : $ifaceNil; + this.typ = typ_ !== undefined ? typ_ : $ifaceNil; + this.val = val_ !== undefined ? val_ : $ifaceNil; + this.id = id_ !== undefined ? id_ : 0; + }); + inSourceOrder = $pkg.inSourceOrder = $newType(12, "Slice", "types.inSourceOrder", "inSourceOrder", "code.google.com/p/go.tools/go/types", null); + Package = $pkg.Package = $newType(0, "Struct", "types.Package", "Package", "code.google.com/p/go.tools/go/types", function(path_, name_, scope_, complete_, imports_, fake_) { + this.$val = this; + this.path = path_ !== undefined ? path_ : ""; + this.name = name_ !== undefined ? name_ : ""; + this.scope = scope_ !== undefined ? scope_ : ($ptrType(Scope)).nil; + this.complete = complete_ !== undefined ? complete_ : false; + this.imports = imports_ !== undefined ? imports_ : ($sliceType(($ptrType(Package)))).nil; + this.fake = fake_ !== undefined ? fake_ : false; + }); + ifacePair = $pkg.ifacePair = $newType(0, "Struct", "types.ifacePair", "ifacePair", "code.google.com/p/go.tools/go/types", function(x_, y_, prev_) { + this.$val = this; + this.x = x_ !== undefined ? x_ : ($ptrType(Interface)).nil; + this.y = y_ !== undefined ? y_ : ($ptrType(Interface)).nil; + this.prev = prev_ !== undefined ? prev_ : ($ptrType(ifacePair)).nil; + }); + declInfo = $pkg.declInfo = $newType(0, "Struct", "types.declInfo", "declInfo", "code.google.com/p/go.tools/go/types", function(file_, lhs_, typ_, init_, fdecl_, deps_, mark_) { + this.$val = this; + this.file = file_ !== undefined ? file_ : ($ptrType(Scope)).nil; + this.lhs = lhs_ !== undefined ? lhs_ : ($sliceType(($ptrType(Var)))).nil; + this.typ = typ_ !== undefined ? typ_ : $ifaceNil; + this.init = init_ !== undefined ? init_ : $ifaceNil; + this.fdecl = fdecl_ !== undefined ? fdecl_ : ($ptrType(ast.FuncDecl)).nil; + this.deps = deps_ !== undefined ? deps_ : false; + this.mark = mark_ !== undefined ? mark_ : 0; + }); + Scope = $pkg.Scope = $newType(0, "Struct", "types.Scope", "Scope", "code.google.com/p/go.tools/go/types", function(parent_, children_, comment_, elems_) { + this.$val = this; + this.parent = parent_ !== undefined ? parent_ : ($ptrType(Scope)).nil; + this.children = children_ !== undefined ? children_ : ($sliceType(($ptrType(Scope)))).nil; + this.comment = comment_ !== undefined ? comment_ : ""; + this.elems = elems_ !== undefined ? elems_ : false; + }); + SelectionKind = $pkg.SelectionKind = $newType(4, "Int", "types.SelectionKind", "SelectionKind", "code.google.com/p/go.tools/go/types", null); + Selection = $pkg.Selection = $newType(0, "Struct", "types.Selection", "Selection", "code.google.com/p/go.tools/go/types", function(kind_, recv_, obj_, index_, indirect_) { + this.$val = this; + this.kind = kind_ !== undefined ? kind_ : 0; + this.recv = recv_ !== undefined ? recv_ : $ifaceNil; + this.obj = obj_ !== undefined ? obj_ : $ifaceNil; + this.index = index_ !== undefined ? index_ : ($sliceType($Int)).nil; + this.indirect = indirect_ !== undefined ? indirect_ : false; + }); + Sizes = $pkg.Sizes = $newType(8, "Interface", "types.Sizes", "Sizes", "code.google.com/p/go.tools/go/types", null); + StdSizes = $pkg.StdSizes = $newType(0, "Struct", "types.StdSizes", "StdSizes", "code.google.com/p/go.tools/go/types", function(WordSize_, MaxAlign_) { + this.$val = this; + this.WordSize = WordSize_ !== undefined ? WordSize_ : new $Int64(0, 0); + this.MaxAlign = MaxAlign_ !== undefined ? MaxAlign_ : new $Int64(0, 0); + }); + stmtContext = $pkg.stmtContext = $newType(4, "Uint", "types.stmtContext", "stmtContext", "code.google.com/p/go.tools/go/types", null); + Type = $pkg.Type = $newType(8, "Interface", "types.Type", "Type", "code.google.com/p/go.tools/go/types", null); + BasicKind = $pkg.BasicKind = $newType(4, "Int", "types.BasicKind", "BasicKind", "code.google.com/p/go.tools/go/types", null); + BasicInfo = $pkg.BasicInfo = $newType(4, "Int", "types.BasicInfo", "BasicInfo", "code.google.com/p/go.tools/go/types", null); + Basic = $pkg.Basic = $newType(0, "Struct", "types.Basic", "Basic", "code.google.com/p/go.tools/go/types", function(kind_, info_, name_) { + this.$val = this; + this.kind = kind_ !== undefined ? kind_ : 0; + this.info = info_ !== undefined ? info_ : 0; + this.name = name_ !== undefined ? name_ : ""; + }); + Array = $pkg.Array = $newType(0, "Struct", "types.Array", "Array", "code.google.com/p/go.tools/go/types", function(len_, elem_) { + this.$val = this; + this.len = len_ !== undefined ? len_ : new $Int64(0, 0); + this.elem = elem_ !== undefined ? elem_ : $ifaceNil; + }); + Slice = $pkg.Slice = $newType(0, "Struct", "types.Slice", "Slice", "code.google.com/p/go.tools/go/types", function(elem_) { + this.$val = this; + this.elem = elem_ !== undefined ? elem_ : $ifaceNil; + }); + Struct = $pkg.Struct = $newType(0, "Struct", "types.Struct", "Struct", "code.google.com/p/go.tools/go/types", function(fields_, tags_, offsets_) { + this.$val = this; + this.fields = fields_ !== undefined ? fields_ : ($sliceType(($ptrType(Var)))).nil; + this.tags = tags_ !== undefined ? tags_ : ($sliceType($String)).nil; + this.offsets = offsets_ !== undefined ? offsets_ : ($sliceType($Int64)).nil; + }); + Pointer = $pkg.Pointer = $newType(0, "Struct", "types.Pointer", "Pointer", "code.google.com/p/go.tools/go/types", function(base_) { + this.$val = this; + this.base = base_ !== undefined ? base_ : $ifaceNil; + }); + Tuple = $pkg.Tuple = $newType(0, "Struct", "types.Tuple", "Tuple", "code.google.com/p/go.tools/go/types", function(vars_) { + this.$val = this; + this.vars = vars_ !== undefined ? vars_ : ($sliceType(($ptrType(Var)))).nil; + }); + Signature = $pkg.Signature = $newType(0, "Struct", "types.Signature", "Signature", "code.google.com/p/go.tools/go/types", function(scope_, recv_, params_, results_, variadic_) { + this.$val = this; + this.scope = scope_ !== undefined ? scope_ : ($ptrType(Scope)).nil; + this.recv = recv_ !== undefined ? recv_ : ($ptrType(Var)).nil; + this.params = params_ !== undefined ? params_ : ($ptrType(Tuple)).nil; + this.results = results_ !== undefined ? results_ : ($ptrType(Tuple)).nil; + this.variadic = variadic_ !== undefined ? variadic_ : false; + }); + Interface = $pkg.Interface = $newType(0, "Struct", "types.Interface", "Interface", "code.google.com/p/go.tools/go/types", function(methods_, embeddeds_, allMethods_) { + this.$val = this; + this.methods = methods_ !== undefined ? methods_ : ($sliceType(($ptrType(Func)))).nil; + this.embeddeds = embeddeds_ !== undefined ? embeddeds_ : ($sliceType(($ptrType(Named)))).nil; + this.allMethods = allMethods_ !== undefined ? allMethods_ : ($sliceType(($ptrType(Func)))).nil; + }); + Map = $pkg.Map = $newType(0, "Struct", "types.Map", "Map", "code.google.com/p/go.tools/go/types", function(key_, elem_) { + this.$val = this; + this.key = key_ !== undefined ? key_ : $ifaceNil; + this.elem = elem_ !== undefined ? elem_ : $ifaceNil; + }); + Chan = $pkg.Chan = $newType(0, "Struct", "types.Chan", "Chan", "code.google.com/p/go.tools/go/types", function(dir_, elem_) { + this.$val = this; + this.dir = dir_ !== undefined ? dir_ : 0; + this.elem = elem_ !== undefined ? elem_ : $ifaceNil; + }); + ChanDir = $pkg.ChanDir = $newType(4, "Int", "types.ChanDir", "ChanDir", "code.google.com/p/go.tools/go/types", null); + Named = $pkg.Named = $newType(0, "Struct", "types.Named", "Named", "code.google.com/p/go.tools/go/types", function(obj_, underlying_, methods_) { + this.$val = this; + this.obj = obj_ !== undefined ? obj_ : ($ptrType(TypeName)).nil; + this.underlying = underlying_ !== undefined ? underlying_ : $ifaceNil; + this.methods = methods_ !== undefined ? methods_ : ($sliceType(($ptrType(Func)))).nil; + }); + byUniqueTypeName = $pkg.byUniqueTypeName = $newType(12, "Slice", "types.byUniqueTypeName", "byUniqueTypeName", "code.google.com/p/go.tools/go/types", null); + byUniqueMethodName = $pkg.byUniqueMethodName = $newType(12, "Slice", "types.byUniqueMethodName", "byUniqueMethodName", "code.google.com/p/go.tools/go/types", null); + builtinId = $pkg.builtinId = $newType(4, "Int", "types.builtinId", "builtinId", "code.google.com/p/go.tools/go/types", null); + Error.Ptr.prototype.Error = function() { + var err, x; + err = new Error.Ptr(); $copy(err, this, Error); + return fmt.Sprintf("%s: %s", new ($sliceType($emptyInterface))([(x = err.Fset.Position(err.Pos), new x.constructor.Struct(x)), new $String(err.Msg)])); }; - consolidateMultiples = function(list) { - var n, prev, _ref, _i, e, _tuple, _entry, i, found, _key$2; - if (list.$length <= 1) { - return list; + Error.prototype.Error = function() { return this.$val.Error(); }; + Info.Ptr.prototype.TypeOf = function(e) { + var info, _tuple, _entry, t, ok, _tuple$1, id, ok$1; + info = this; + _tuple = (_entry = info.Types[e.$key()], _entry !== undefined ? [_entry.v, true] : [new TypeAndValue.Ptr(), false]); t = new TypeAndValue.Ptr(); $copy(t, _tuple[0], TypeAndValue); ok = _tuple[1]; + if (ok) { + return t.Type; } - n = 0; - prev = new $Map(); - _ref = list; - _i = 0; - while (_i < _ref.$length) { - e = new embeddedType.Ptr(); $copy(e, ((_i < 0 || _i >= _ref.$length) ? $throwRuntimeError("index out of range") : _ref.$array[_ref.$offset + _i]), embeddedType); - _tuple = (_entry = prev[e.typ.$key()], _entry !== undefined ? [_entry.v, true] : [0, false]); i = _tuple[0]; found = _tuple[1]; - if (found) { - ((i < 0 || i >= list.$length) ? $throwRuntimeError("index out of range") : list.$array[list.$offset + i]).multiples = true; - } else { - _key$2 = e.typ; (prev || $throwRuntimeError("assignment to entry in nil map"))[_key$2.$key()] = { k: _key$2, v: n }; - $copy(((n < 0 || n >= list.$length) ? $throwRuntimeError("index out of range") : list.$array[list.$offset + n]), e, embeddedType); - n = n + (1) >> 0; - } - _i++; + _tuple$1 = $assertType(e, ($ptrType(ast.Ident)), true); id = _tuple$1[0]; ok$1 = _tuple$1[1]; + if (ok$1) { + return info.ObjectOf(id).Type(); } - return $subslice(list, 0, n); + return $ifaceNil; }; - MissingMethod = $pkg.MissingMethod = function(V, T, static$1) { - var method = ($ptrType(Func)).nil, wrongType = false, _tuple, ityp, _ref, _i, m, _tuple$1, obj, _tmp, _tmp$1, _tmp$2, _tmp$3, _ref$1, _i$1, m$1, _tuple$2, obj$1, _tuple$3, f, _tmp$4, _tmp$5, _tmp$6, _tmp$7; - if (T.Empty()) { - return [method, wrongType]; - } - _tuple = $assertType(V.Underlying(), ($ptrType(Interface)), true); ityp = _tuple[0]; - if (!(ityp === ($ptrType(Interface)).nil)) { - _ref = T.allMethods; - _i = 0; - while (_i < _ref.$length) { - m = ((_i < 0 || _i >= _ref.$length) ? $throwRuntimeError("index out of range") : _ref.$array[_ref.$offset + _i]); - _tuple$1 = lookupMethod(ityp.allMethods, m.object.pkg, m.object.name); obj = _tuple$1[1]; - if (obj === ($ptrType(Func)).nil) { - if (static$1) { - _tmp = m; _tmp$1 = false; method = _tmp; wrongType = _tmp$1; - return [method, wrongType]; - } - } else if (!Identical(obj.object.Type(), m.object.typ)) { - _tmp$2 = m; _tmp$3 = true; method = _tmp$2; wrongType = _tmp$3; - return [method, wrongType]; - } - _i++; - } - return [method, wrongType]; - } - _ref$1 = T.allMethods; - _i$1 = 0; - while (_i$1 < _ref$1.$length) { - m$1 = ((_i$1 < 0 || _i$1 >= _ref$1.$length) ? $throwRuntimeError("index out of range") : _ref$1.$array[_ref$1.$offset + _i$1]); - _tuple$2 = lookupFieldOrMethod(V, false, m$1.object.pkg, m$1.object.name); obj$1 = _tuple$2[0]; - _tuple$3 = $assertType(obj$1, ($ptrType(Func)), true); f = _tuple$3[0]; - if (f === ($ptrType(Func)).nil) { - _tmp$4 = m$1; _tmp$5 = false; method = _tmp$4; wrongType = _tmp$5; - return [method, wrongType]; - } - if (!Identical(f.object.typ, m$1.object.typ)) { - _tmp$6 = m$1; _tmp$7 = true; method = _tmp$6; wrongType = _tmp$7; - return [method, wrongType]; - } - _i$1++; + Info.prototype.TypeOf = function(e) { return this.$val.TypeOf(e); }; + Info.Ptr.prototype.ObjectOf = function(id) { + var info, _tuple, _entry, obj, ok, _entry$1; + info = this; + _tuple = (_entry = info.Defs[id.$key()], _entry !== undefined ? [_entry.v, true] : [$ifaceNil, false]); obj = _tuple[0]; ok = _tuple[1]; + if (ok) { + return obj; } - return [method, wrongType]; + return (_entry$1 = info.Uses[id.$key()], _entry$1 !== undefined ? _entry$1.v : $ifaceNil); }; - assertableTo = function(V, T) { - var method = ($ptrType(Func)).nil, wrongType = false, _tuple, ok, _tuple$1; - _tuple = $assertType(T.Underlying(), ($ptrType(Interface)), true); ok = _tuple[1]; - if (ok && true) { - return [method, wrongType]; - } - _tuple$1 = MissingMethod(T, V, false); method = _tuple$1[0]; wrongType = _tuple$1[1]; - return [method, wrongType]; + Info.prototype.ObjectOf = function(id) { return this.$val.ObjectOf(id); }; + TypeAndValue.Ptr.prototype.IsVoid = function() { + var tv; + tv = new TypeAndValue.Ptr(); $copy(tv, this, TypeAndValue); + return tv.mode === 1; }; - deref = function(typ) { - var _tuple, p; - _tuple = $assertType(typ, ($ptrType(Pointer)), true); p = _tuple[0]; - if (!(p === ($ptrType(Pointer)).nil)) { - return [p.base, true]; - } - return [typ, false]; + TypeAndValue.prototype.IsVoid = function() { return this.$val.IsVoid(); }; + TypeAndValue.Ptr.prototype.IsType = function() { + var tv; + tv = new TypeAndValue.Ptr(); $copy(tv, this, TypeAndValue); + return tv.mode === 3; }; - derefStructPtr = function(typ) { - var _tuple, p, _tuple$1, ok; - _tuple = $assertType(typ.Underlying(), ($ptrType(Pointer)), true); p = _tuple[0]; - if (!(p === ($ptrType(Pointer)).nil)) { - _tuple$1 = $assertType(p.base.Underlying(), ($ptrType(Struct)), true); ok = _tuple$1[1]; - if (ok) { - return p.base; - } + TypeAndValue.prototype.IsType = function() { return this.$val.IsType(); }; + TypeAndValue.Ptr.prototype.IsBuiltin = function() { + var tv; + tv = new TypeAndValue.Ptr(); $copy(tv, this, TypeAndValue); + return tv.mode === 2; + }; + TypeAndValue.prototype.IsBuiltin = function() { return this.$val.IsBuiltin(); }; + TypeAndValue.Ptr.prototype.IsValue = function() { + var tv, _ref; + tv = new TypeAndValue.Ptr(); $copy(tv, this, TypeAndValue); + _ref = tv.mode; + if (_ref === 4 || _ref === 5 || _ref === 6 || _ref === 7 || _ref === 8) { + return true; } - return typ; + return false; }; - concat = function(list, i) { - var t; - t = ($sliceType($Int)).nil; - t = $appendSlice(t, list); - return $append(t, i); + TypeAndValue.prototype.IsValue = function() { return this.$val.IsValue(); }; + TypeAndValue.Ptr.prototype.IsNil = function() { + var tv; + tv = new TypeAndValue.Ptr(); $copy(tv, this, TypeAndValue); + return (tv.mode === 7) && $interfaceIsEqual(tv.Type, $pkg.Typ[25]); }; - fieldIndex = function(fields, pkg, name) { - var _ref, _i, i, f; - if (!(name === "_")) { - _ref = fields; - _i = 0; - while (_i < _ref.$length) { - i = _i; - f = ((_i < 0 || _i >= _ref.$length) ? $throwRuntimeError("index out of range") : _ref.$array[_ref.$offset + _i]); - if (f.object.sameId(pkg, name)) { - return i; - } - _i++; - } - } - return -1; + TypeAndValue.prototype.IsNil = function() { return this.$val.IsNil(); }; + TypeAndValue.Ptr.prototype.Addressable = function() { + var tv; + tv = new TypeAndValue.Ptr(); $copy(tv, this, TypeAndValue); + return tv.mode === 5; }; - lookupMethod = function(methods, pkg, name) { - var _ref, _i, i, m; - if (!(name === "_")) { - _ref = methods; - _i = 0; - while (_i < _ref.$length) { - i = _i; - m = ((_i < 0 || _i >= _ref.$length) ? $throwRuntimeError("index out of range") : _ref.$array[_ref.$offset + _i]); - if (m.object.sameId(pkg, name)) { - return [i, m]; - } - _i++; - } - } - return [-1, ($ptrType(Func)).nil]; + TypeAndValue.prototype.Addressable = function() { return this.$val.Addressable(); }; + TypeAndValue.Ptr.prototype.Assignable = function() { + var tv; + tv = new TypeAndValue.Ptr(); $copy(tv, this, TypeAndValue); + return (tv.mode === 5) || (tv.mode === 6); }; - MethodSet.Ptr.prototype.String = function() { - var s, buf, _ref, _i, f; - s = this; - if (s.Len() === 0) { - return "MethodSet {}"; - } + TypeAndValue.prototype.Assignable = function() { return this.$val.Assignable(); }; + TypeAndValue.Ptr.prototype.HasOk = function() { + var tv; + tv = new TypeAndValue.Ptr(); $copy(tv, this, TypeAndValue); + return (tv.mode === 8) || (tv.mode === 6); + }; + TypeAndValue.prototype.HasOk = function() { return this.$val.HasOk(); }; + Initializer.Ptr.prototype.String = function() { + var init$1, buf, _ref, _i, i, lhs; + init$1 = this; buf = new bytes.Buffer.Ptr(); $copy(buf, new bytes.Buffer.Ptr(), bytes.Buffer); - fmt.Fprintln(buf, new ($sliceType($emptyInterface))([new $String("MethodSet {")])); - _ref = s.list; + _ref = init$1.Lhs; _i = 0; while (_i < _ref.$length) { - f = ((_i < 0 || _i >= _ref.$length) ? $throwRuntimeError("index out of range") : _ref.$array[_ref.$offset + _i]); - fmt.Fprintf(buf, "\t%s\n", new ($sliceType($emptyInterface))([f])); + i = _i; + lhs = ((_i < 0 || _i >= _ref.$length) ? $throwRuntimeError("index out of range") : _ref.$array[_ref.$offset + _i]); + if (i > 0) { + buf.WriteString(", "); + } + buf.WriteString(lhs.object.Name()); _i++; } - fmt.Fprintln(buf, new ($sliceType($emptyInterface))([new $String("}")])); + buf.WriteString(" = "); + WriteExpr(buf, init$1.Rhs); return buf.String(); }; - MethodSet.prototype.String = function() { return this.$val.String(); }; - MethodSet.Ptr.prototype.Len = function() { - var s; - s = this; - return s.list.$length; + Initializer.prototype.String = function() { return this.$val.String(); }; + Config.Ptr.prototype.Check = function(path$1, fset, files, info) { + var conf, pkg; + conf = this; + pkg = NewPackage(path$1, ""); + return [pkg, NewChecker(conf, fset, pkg, info).Files(files)]; }; - MethodSet.prototype.Len = function() { return this.$val.Len(); }; - MethodSet.Ptr.prototype.At = function(i) { - var s, x; - s = this; - return (x = s.list, ((i < 0 || i >= x.$length) ? $throwRuntimeError("index out of range") : x.$array[x.$offset + i])); + Config.prototype.Check = function(path$1, fset, files, info) { return this.$val.Check(path$1, fset, files, info); }; + Implements = $pkg.Implements = function(V, T) { + var _tuple, f; + _tuple = MissingMethod(V, T, true); f = _tuple[0]; + return f === ($ptrType(Func)).nil; }; - MethodSet.prototype.At = function(i) { return this.$val.At(i); }; - MethodSet.Ptr.prototype.Lookup = function(pkg, name) { - var s, key, i, x, m; - s = this; - if (s.Len() === 0) { - return ($ptrType(Selection)).nil; + Checker.Ptr.prototype.assignment = function(x, T) { + var check, _ref, _tuple, t, target; + check = this; + _ref = x.mode; + if (_ref === 0) { + return true; + } else if (_ref === 4 || _ref === 5 || _ref === 6 || _ref === 7 || _ref === 8) { + } else { + unreachable(); } - key = Id(pkg, name); - i = sort.Search(s.list.$length, (function(i) { - var x, m; - m = (x = s.list, ((i < 0 || i >= x.$length) ? $throwRuntimeError("index out of range") : x.$array[x.$offset + i])); - return m.obj.Id() >= key; - })); - if (i < s.list.$length) { - m = (x = s.list, ((i < 0 || i >= x.$length) ? $throwRuntimeError("index out of range") : x.$array[x.$offset + i])); - if (m.obj.Id() === key) { - return m; + _tuple = $assertType(x.typ, ($ptrType(Tuple)), true); t = _tuple[0]; + if (!(t === ($ptrType(Tuple)).nil)) { + assert(t.Len() > 1); + check.errorf(x.pos(), "%d-valued expression %s used as single value", new ($sliceType($emptyInterface))([new $Int(t.Len()), x])); + x.mode = 0; + return false; + } + if (isUntyped(x.typ)) { + target = T; + if ($interfaceIsEqual(T, $ifaceNil) || isInterface(T)) { + if ($interfaceIsEqual(T, $ifaceNil) && $interfaceIsEqual(x.typ, $pkg.Typ[25])) { + check.errorf(x.pos(), "use of untyped nil", new ($sliceType($emptyInterface))([])); + x.mode = 0; + return false; + } + target = defaultType(x.typ); + } + check.convertUntyped(x, target); + if (x.mode === 0) { + return false; } } - return ($ptrType(Selection)).nil; + return $interfaceIsEqual(T, $ifaceNil) || x.assignableTo(check.conf, T); }; - MethodSet.prototype.Lookup = function(pkg, name) { return this.$val.Lookup(pkg, name); }; - NewMethodSet = $pkg.NewMethodSet = function(T) { - var base, _tuple, typ, isPtr, _tuple$1, named, utyp, _tuple$2, ok, current, seen, next, fset, mset, _ref, _i, e, _entry, _key$2, t, _ref$1, _ref$2, _i$1, i, f, _tuple$3, typ$1, isPtr$1, _tuple$4, t$1, _ref$3, _i$2, _keys, _entry$1, k, m, _tuple$5, _entry$2, found, _tuple$6, _entry$3, found$1, _key$3, _ref$4, _i$3, _keys$1, _entry$4, k$1, f$1, _tuple$7, _entry$5, found$2, _key$4, list, _ref$5, _i$4, _keys$2, _entry$6, m$1; - base = false; - _tuple = deref(T); typ = _tuple[0]; isPtr = _tuple[1]; - _tuple$1 = $assertType(typ, ($ptrType(Named)), true); named = _tuple$1[0]; - if (isPtr) { - utyp = typ; - if (!(named === ($ptrType(Named)).nil)) { - utyp = named.underlying; + Checker.prototype.assignment = function(x, T) { return this.$val.assignment(x, T); }; + Checker.Ptr.prototype.initConst = function(lhs, x) { + var check; + check = this; + if ((x.mode === 0) || $interfaceIsEqual(x.typ, $pkg.Typ[0]) || $interfaceIsEqual(lhs.object.typ, $pkg.Typ[0])) { + if ($interfaceIsEqual(lhs.object.typ, $ifaceNil)) { + lhs.object.typ = $pkg.Typ[0]; } - _tuple$2 = $assertType(utyp, ($ptrType(Interface)), true); ok = _tuple$2[1]; - if (ok) { - return emptyMethodSet; + return; + } + if (!((x.mode === 4))) { + check.errorf(x.pos(), "%s is not constant", new ($sliceType($emptyInterface))([x])); + if ($interfaceIsEqual(lhs.object.typ, $ifaceNil)) { + lhs.object.typ = $pkg.Typ[0]; } + return; } - current = new ($sliceType(embeddedType))([new embeddedType.Ptr(named, ($sliceType($Int)).nil, isPtr, false)]); - seen = false; - while (current.$length > 0) { - next = ($sliceType(embeddedType)).nil; - fset = false; - mset = false; - _ref = current; - _i = 0; - while (_i < _ref.$length) { - e = new embeddedType.Ptr(); $copy(e, ((_i < 0 || _i >= _ref.$length) ? $throwRuntimeError("index out of range") : _ref.$array[_ref.$offset + _i]), embeddedType); - if (!(e.typ === ($ptrType(Named)).nil)) { - if ((_entry = seen[e.typ.$key()], _entry !== undefined ? _entry.v : false)) { - _i++; - continue; - } - if (seen === false) { - seen = new $Map(); - } - _key$2 = e.typ; (seen || $throwRuntimeError("assignment to entry in nil map"))[_key$2.$key()] = { k: _key$2, v: true }; - mset = (new methodSet(mset)).add(e.typ.methods, e.index, e.indirect, e.multiples); - typ = e.typ.underlying; - } - _ref$1 = typ; - if ($assertType(_ref$1, ($ptrType(Struct)), true)[1]) { - t = _ref$1.$val; - _ref$2 = t.fields; - _i$1 = 0; - while (_i$1 < _ref$2.$length) { - i = _i$1; - f = ((_i$1 < 0 || _i$1 >= _ref$2.$length) ? $throwRuntimeError("index out of range") : _ref$2.$array[_ref$2.$offset + _i$1]); - fset = (new fieldSet(fset)).add(f, e.multiples); - if (f.anonymous) { - _tuple$3 = deref(f.object.typ); typ$1 = _tuple$3[0]; isPtr$1 = _tuple$3[1]; - _tuple$4 = $assertType(typ$1, ($ptrType(Named)), true); t$1 = _tuple$4[0]; - if (!(t$1 === ($ptrType(Named)).nil)) { - next = $append(next, new embeddedType.Ptr(t$1, concat(e.index, i), e.indirect || isPtr$1, e.multiples)); - } - } - _i$1++; - } - } else if ($assertType(_ref$1, ($ptrType(Interface)), true)[1]) { - t = _ref$1.$val; - mset = (new methodSet(mset)).add(t.allMethods, e.index, true, e.multiples); - } - _i++; + assert(isConstType(x.typ)); + if ($interfaceIsEqual(lhs.object.typ, $ifaceNil)) { + lhs.object.typ = x.typ; + } + if (!check.assignment(x, lhs.object.typ)) { + if (!((x.mode === 0))) { + check.errorf(x.pos(), "cannot define constant %s (type %s) as %s", new ($sliceType($emptyInterface))([new $String(lhs.object.Name()), lhs.object.typ, x])); } - _ref$3 = mset; - _i$2 = 0; - _keys = $keys(_ref$3); - while (_i$2 < _keys.length) { - _entry$1 = _ref$3[_keys[_i$2]]; - if (_entry$1 === undefined) { - _i$2++; - continue; - } - k = _entry$1.k; - m = _entry$1.v; - _tuple$5 = (_entry$2 = base[k], _entry$2 !== undefined ? [_entry$2.v, true] : [($ptrType(Selection)).nil, false]); found = _tuple$5[1]; - if (!found) { - _tuple$6 = (_entry$3 = fset[k], _entry$3 !== undefined ? [_entry$3.v, true] : [($ptrType(Var)).nil, false]); found$1 = _tuple$6[1]; - if (found$1) { - m = ($ptrType(Selection)).nil; - } - if (base === false) { - base = new $Map(); - } - _key$3 = k; (base || $throwRuntimeError("assignment to entry in nil map"))[_key$3] = { k: _key$3, v: m }; + return; + } + lhs.val = x.val; + }; + Checker.prototype.initConst = function(lhs, x) { return this.$val.initConst(lhs, x); }; + Checker.Ptr.prototype.initVar = function(lhs, x, result) { + var check, typ; + check = this; + if ((x.mode === 0) || $interfaceIsEqual(x.typ, $pkg.Typ[0]) || $interfaceIsEqual(lhs.object.typ, $pkg.Typ[0])) { + if ($interfaceIsEqual(lhs.object.typ, $ifaceNil)) { + lhs.object.typ = $pkg.Typ[0]; + } + return $ifaceNil; + } + if ($interfaceIsEqual(lhs.object.typ, $ifaceNil)) { + typ = x.typ; + if (isUntyped(typ)) { + if ($interfaceIsEqual(typ, $pkg.Typ[25])) { + check.errorf(x.pos(), "use of untyped nil", new ($sliceType($emptyInterface))([])); + lhs.object.typ = $pkg.Typ[0]; + return $ifaceNil; } - _i$2++; + typ = defaultType(typ); } - _ref$4 = fset; - _i$3 = 0; - _keys$1 = $keys(_ref$4); - while (_i$3 < _keys$1.length) { - _entry$4 = _ref$4[_keys$1[_i$3]]; - if (_entry$4 === undefined) { - _i$3++; - continue; + lhs.object.typ = typ; + } + if (!check.assignment(x, lhs.object.typ)) { + if (!((x.mode === 0))) { + if (result) { + check.errorf(x.pos(), "cannot return %s as value of type %s", new ($sliceType($emptyInterface))([x, lhs.object.typ])); + } else { + check.errorf(x.pos(), "cannot initialize %s with %s", new ($sliceType($emptyInterface))([lhs, x])); } - k$1 = _entry$4.k; - f$1 = _entry$4.v; - if (f$1 === ($ptrType(Var)).nil) { - _tuple$7 = (_entry$5 = base[k$1], _entry$5 !== undefined ? [_entry$5.v, true] : [($ptrType(Selection)).nil, false]); found$2 = _tuple$7[1]; - if (!found$2) { - if (base === false) { - base = new $Map(); - } - _key$4 = k$1; (base || $throwRuntimeError("assignment to entry in nil map"))[_key$4] = { k: _key$4, v: ($ptrType(Selection)).nil }; - } + } + return $ifaceNil; + } + return x.typ; + }; + Checker.prototype.initVar = function(lhs, x, result) { return this.$val.initVar(lhs, x, result); }; + Checker.Ptr.prototype.assignVar = function(lhs, x) { + var check, _tuple, ident, v, v_used, obj, _tuple$1, z, _ref; + check = this; + if ((x.mode === 0) || $interfaceIsEqual(x.typ, $pkg.Typ[0])) { + return $ifaceNil; + } + _tuple = $assertType(unparen(lhs), ($ptrType(ast.Ident)), true); ident = _tuple[0]; + if (!(ident === ($ptrType(ast.Ident)).nil) && ident.Name === "_") { + check.recordDef(ident, $ifaceNil); + if (!check.assignment(x, $ifaceNil)) { + assert(x.mode === 0); + x.typ = $ifaceNil; + } + return x.typ; + } + v = ($ptrType(Var)).nil; + v_used = false; + if (!(ident === ($ptrType(ast.Ident)).nil)) { + obj = check.context.scope.LookupParent(ident.Name); + if (!($interfaceIsEqual(obj, $ifaceNil))) { + _tuple$1 = $assertType(obj, ($ptrType(Var)), true); v = _tuple$1[0]; + if (!(v === ($ptrType(Var)).nil)) { + v_used = v.object.used; } - _i$3++; } - current = consolidateMultiples(next); } - if ($keys(base).length === 0) { - return emptyMethodSet; + z = new operand.Ptr(); $copy(z, new operand.Ptr(), operand); + check.expr(z, lhs); + if (!(v === ($ptrType(Var)).nil)) { + v.object.used = v_used; } - list = ($sliceType(($ptrType(Selection)))).nil; - _ref$5 = base; - _i$4 = 0; - _keys$2 = $keys(_ref$5); - while (_i$4 < _keys$2.length) { - _entry$6 = _ref$5[_keys$2[_i$4]]; - if (_entry$6 === undefined) { - _i$4++; - continue; - } - m$1 = _entry$6.v; - if (!(m$1 === ($ptrType(Selection)).nil)) { - m$1.recv = T; - list = $append(list, m$1); + if ((z.mode === 0) || $interfaceIsEqual(z.typ, $pkg.Typ[0])) { + return $ifaceNil; + } + _ref = z.mode; + if (_ref === 0) { + return $ifaceNil; + } else if (_ref === 5 || _ref === 6) { + } else { + check.errorf(z.pos(), "cannot assign to %s", new ($sliceType($emptyInterface))([z])); + return $ifaceNil; + } + if (!check.assignment(x, z.typ)) { + if (!((x.mode === 0))) { + check.errorf(x.pos(), "cannot assign %s to %s", new ($sliceType($emptyInterface))([x, z])); } - _i$4++; + return $ifaceNil; } - sort.Sort($subslice(new byUniqueName(list.$array), list.$offset, list.$offset + list.$length)); - return new MethodSet.Ptr(list); + return x.typ; }; - fieldSet.prototype.add = function(f, multiples) { - var s, key, _tuple, _entry, found, _key$2, _key$3; - s = this.$val !== undefined ? this.$val : this; - if (s === false) { - s = new $Map(); + Checker.prototype.assignVar = function(lhs, x) { return this.$val.assignVar(lhs, x); }; + Checker.Ptr.prototype.initVars = function(lhs, rhs, returnPos) { + var check, l, _tuple, get, r, commaOk, _ref, _i, obj, x, a, _ref$1, _i$1, i, _ref$2, _i$2, i$1, lhs$1; + check = this; + l = lhs.$length; + _tuple = unpack((function(x, i) { + check.expr(x, ((i < 0 || i >= rhs.$length) ? $throwRuntimeError("index out of range") : rhs.$array[rhs.$offset + i])); + }), rhs.$length, (l === 2) && !(new token.Pos(returnPos)).IsValid()); get = _tuple[0]; r = _tuple[1]; commaOk = _tuple[2]; + if (get === $throwNilPointerError || !((l === r))) { + _ref = lhs; + _i = 0; + while (_i < _ref.$length) { + obj = ((_i < 0 || _i >= _ref.$length) ? $throwRuntimeError("index out of range") : _ref.$array[_ref.$offset + _i]); + if ($interfaceIsEqual(obj.object.typ, $ifaceNil)) { + obj.object.typ = $pkg.Typ[0]; + } + _i++; + } + if (get === $throwNilPointerError) { + return; + } + check.useGetter(get, r); + if ((new token.Pos(returnPos)).IsValid()) { + check.errorf(returnPos, "wrong number of return values (want %d, got %d)", new ($sliceType($emptyInterface))([new $Int(l), new $Int(r)])); + return; + } + check.errorf(((0 < 0 || 0 >= rhs.$length) ? $throwRuntimeError("index out of range") : rhs.$array[rhs.$offset + 0]).Pos(), "assignment count mismatch (%d vs %d)", new ($sliceType($emptyInterface))([new $Int(l), new $Int(r)])); + return; } - key = f.object.Id(); - if (!multiples) { - _tuple = (_entry = s[key], _entry !== undefined ? [_entry.v, true] : [($ptrType(Var)).nil, false]); found = _tuple[1]; - if (!found) { - _key$2 = key; (s || $throwRuntimeError("assignment to entry in nil map"))[_key$2] = { k: _key$2, v: f }; - return s; + x = new operand.Ptr(); $copy(x, new operand.Ptr(), operand); + if (commaOk) { + a = ($arrayType(Type, 2)).zero(); $copy(a, ($arrayType(Type, 2)).zero(), ($arrayType(Type, 2))); + _ref$1 = a; + _i$1 = 0; + while (_i$1 < 2) { + i = _i$1; + get(x, i); + (i < 0 || i >= a.length) ? $throwRuntimeError("index out of range") : a[i] = check.initVar(((i < 0 || i >= lhs.$length) ? $throwRuntimeError("index out of range") : lhs.$array[lhs.$offset + i]), x, (new token.Pos(returnPos)).IsValid()); + _i$1++; } + check.recordCommaOkTypes(((0 < 0 || 0 >= rhs.$length) ? $throwRuntimeError("index out of range") : rhs.$array[rhs.$offset + 0]), $clone(a, ($arrayType(Type, 2)))); + return; + } + _ref$2 = lhs; + _i$2 = 0; + while (_i$2 < _ref$2.$length) { + i$1 = _i$2; + lhs$1 = ((_i$2 < 0 || _i$2 >= _ref$2.$length) ? $throwRuntimeError("index out of range") : _ref$2.$array[_ref$2.$offset + _i$2]); + get(x, i$1); + check.initVar(lhs$1, x, (new token.Pos(returnPos)).IsValid()); + _i$2++; } - _key$3 = key; (s || $throwRuntimeError("assignment to entry in nil map"))[_key$3] = { k: _key$3, v: ($ptrType(Var)).nil }; - return s; }; - $ptrType(fieldSet).prototype.add = function(f, multiples) { return new fieldSet(this.$get()).add(f, multiples); }; - methodSet.prototype.add = function(list, index, indirect, multiples) { - var s, _ref, _i, i, f, key, _tuple, _entry, found, _key$2, _key$3; - s = this.$val !== undefined ? this.$val : this; - if (list.$length === 0) { - return s; + Checker.prototype.initVars = function(lhs, rhs, returnPos) { return this.$val.initVars(lhs, rhs, returnPos); }; + Checker.Ptr.prototype.assignVars = function(lhs, rhs) { + var check, l, _tuple, get, r, commaOk, x, a, _ref, _i, i, _ref$1, _i$1, i$1, lhs$1; + check = this; + l = lhs.$length; + _tuple = unpack((function(x, i) { + check.expr(x, ((i < 0 || i >= rhs.$length) ? $throwRuntimeError("index out of range") : rhs.$array[rhs.$offset + i])); + }), rhs.$length, l === 2); get = _tuple[0]; r = _tuple[1]; commaOk = _tuple[2]; + if (get === $throwNilPointerError) { + return; } - if (s === false) { - s = new $Map(); + if (!((l === r))) { + check.useGetter(get, r); + check.errorf(((0 < 0 || 0 >= rhs.$length) ? $throwRuntimeError("index out of range") : rhs.$array[rhs.$offset + 0]).Pos(), "assignment count mismatch (%d vs %d)", new ($sliceType($emptyInterface))([new $Int(l), new $Int(r)])); + return; } - _ref = list; + x = new operand.Ptr(); $copy(x, new operand.Ptr(), operand); + if (commaOk) { + a = ($arrayType(Type, 2)).zero(); $copy(a, ($arrayType(Type, 2)).zero(), ($arrayType(Type, 2))); + _ref = a; + _i = 0; + while (_i < 2) { + i = _i; + get(x, i); + (i < 0 || i >= a.length) ? $throwRuntimeError("index out of range") : a[i] = check.assignVar(((i < 0 || i >= lhs.$length) ? $throwRuntimeError("index out of range") : lhs.$array[lhs.$offset + i]), x); + _i++; + } + check.recordCommaOkTypes(((0 < 0 || 0 >= rhs.$length) ? $throwRuntimeError("index out of range") : rhs.$array[rhs.$offset + 0]), $clone(a, ($arrayType(Type, 2)))); + return; + } + _ref$1 = lhs; + _i$1 = 0; + while (_i$1 < _ref$1.$length) { + i$1 = _i$1; + lhs$1 = ((_i$1 < 0 || _i$1 >= _ref$1.$length) ? $throwRuntimeError("index out of range") : _ref$1.$array[_ref$1.$offset + _i$1]); + get(x, i$1); + check.assignVar(lhs$1, x); + _i$1++; + } + }; + Checker.prototype.assignVars = function(lhs, rhs) { return this.$val.assignVars(lhs, rhs); }; + Checker.Ptr.prototype.shortVarDecl = function(pos, lhs, rhs) { + var check, scope, newVars, lhsVars, _ref, _i, i, lhs$1, obj, _tuple, ident, name, alt, _tuple$1, alt$1, _ref$1, _i$1, obj$1; + check = this; + scope = check.context.scope; + newVars = ($sliceType(($ptrType(Var)))).nil; + lhsVars = ($sliceType(($ptrType(Var)))).make(lhs.$length); + _ref = lhs; _i = 0; while (_i < _ref.$length) { i = _i; - f = ((_i < 0 || _i >= _ref.$length) ? $throwRuntimeError("index out of range") : _ref.$array[_ref.$offset + _i]); - key = f.object.Id(); - if (!multiples) { - _tuple = (_entry = s[key], _entry !== undefined ? [_entry.v, true] : [($ptrType(Selection)).nil, false]); found = _tuple[1]; - if (!found && (indirect || !ptrRecv(f))) { - _key$2 = key; (s || $throwRuntimeError("assignment to entry in nil map"))[_key$2] = { k: _key$2, v: new Selection.Ptr(1, $ifaceNil, f, concat(index, i), indirect) }; - _i++; - continue; + lhs$1 = ((_i < 0 || _i >= _ref.$length) ? $throwRuntimeError("index out of range") : _ref.$array[_ref.$offset + _i]); + obj = ($ptrType(Var)).nil; + _tuple = $assertType(lhs$1, ($ptrType(ast.Ident)), true); ident = _tuple[0]; + if (!(ident === ($ptrType(ast.Ident)).nil)) { + name = ident.Name; + alt = scope.Lookup(name); + if (!($interfaceIsEqual(alt, $ifaceNil))) { + _tuple$1 = $assertType(alt, ($ptrType(Var)), true); alt$1 = _tuple$1[0]; + if (!(alt$1 === ($ptrType(Var)).nil)) { + obj = alt$1; + } else { + check.errorf(lhs$1.Pos(), "cannot assign to %s", new ($sliceType($emptyInterface))([lhs$1])); + } + check.recordUse(ident, alt); + } else { + obj = NewVar(ident.Pos(), check.pkg, name, $ifaceNil); + if (!(name === "_")) { + newVars = $append(newVars, obj); + } + check.recordDef(ident, obj); } + } else { + check.errorf(lhs$1.Pos(), "cannot declare %s", new ($sliceType($emptyInterface))([lhs$1])); } - _key$3 = key; (s || $throwRuntimeError("assignment to entry in nil map"))[_key$3] = { k: _key$3, v: ($ptrType(Selection)).nil }; + if (obj === ($ptrType(Var)).nil) { + obj = NewVar(lhs$1.Pos(), check.pkg, "_", $ifaceNil); + } + (i < 0 || i >= lhsVars.$length) ? $throwRuntimeError("index out of range") : lhsVars.$array[lhsVars.$offset + i] = obj; _i++; } - return s; - }; - $ptrType(methodSet).prototype.add = function(list, index, indirect, multiples) { return new methodSet(this.$get()).add(list, index, indirect, multiples); }; - ptrRecv = function(f) { - var _tuple, isPtr; - _tuple = deref($assertType(f.object.typ, ($ptrType(Signature))).recv.object.typ); isPtr = _tuple[1]; - return isPtr; - }; - byUniqueName.prototype.Len = function() { - var a; - a = this; - return a.$length; - }; - $ptrType(byUniqueName).prototype.Len = function() { return this.$get().Len(); }; - byUniqueName.prototype.Less = function(i, j) { - var a; - a = this; - return ((i < 0 || i >= a.$length) ? $throwRuntimeError("index out of range") : a.$array[a.$offset + i]).obj.Id() < ((j < 0 || j >= a.$length) ? $throwRuntimeError("index out of range") : a.$array[a.$offset + j]).obj.Id(); - }; - $ptrType(byUniqueName).prototype.Less = function(i, j) { return this.$get().Less(i, j); }; - byUniqueName.prototype.Swap = function(i, j) { - var a, _tmp, _tmp$1; - a = this; - _tmp = ((j < 0 || j >= a.$length) ? $throwRuntimeError("index out of range") : a.$array[a.$offset + j]); _tmp$1 = ((i < 0 || i >= a.$length) ? $throwRuntimeError("index out of range") : a.$array[a.$offset + i]); (i < 0 || i >= a.$length) ? $throwRuntimeError("index out of range") : a.$array[a.$offset + i] = _tmp; (j < 0 || j >= a.$length) ? $throwRuntimeError("index out of range") : a.$array[a.$offset + j] = _tmp$1; - }; - $ptrType(byUniqueName).prototype.Swap = function(i, j) { return this.$get().Swap(i, j); }; - Id = $pkg.Id = function(pkg, name) { - var path$1; - if (ast.IsExported(name)) { - return name; - } - path$1 = "_"; - if (!(pkg === ($ptrType(Package)).nil)) { - path$1 = pkg.path; - if (path$1 === "") { - path$1 = "_"; + check.initVars(lhsVars, rhs, 0); + if (newVars.$length > 0) { + _ref$1 = newVars; + _i$1 = 0; + while (_i$1 < _ref$1.$length) { + obj$1 = ((_i$1 < 0 || _i$1 >= _ref$1.$length) ? $throwRuntimeError("index out of range") : _ref$1.$array[_ref$1.$offset + _i$1]); + check.declare(scope, ($ptrType(ast.Ident)).nil, obj$1); + _i$1++; } + } else { + check.softErrorf(pos, "no new variables on left side of :=", new ($sliceType($emptyInterface))([])); } - return path$1 + "." + name; - }; - object.Ptr.prototype.Parent = function() { - var obj; - obj = this; - return obj.parent; - }; - object.prototype.Parent = function() { return this.$val.Parent(); }; - object.Ptr.prototype.Pos = function() { - var obj; - obj = this; - return obj.pos; - }; - object.prototype.Pos = function() { return this.$val.Pos(); }; - object.Ptr.prototype.Pkg = function() { - var obj; - obj = this; - return obj.pkg; }; - object.prototype.Pkg = function() { return this.$val.Pkg(); }; - object.Ptr.prototype.Name = function() { - var obj; - obj = this; - return obj.name; - }; - object.prototype.Name = function() { return this.$val.Name(); }; - object.Ptr.prototype.Type = function() { - var obj; - obj = this; - return obj.typ; - }; - object.prototype.Type = function() { return this.$val.Type(); }; - object.Ptr.prototype.Exported = function() { - var obj; - obj = this; - return ast.IsExported(obj.name); - }; - object.prototype.Exported = function() { return this.$val.Exported(); }; - object.Ptr.prototype.Id = function() { - var obj; - obj = this; - return Id(obj.pkg, obj.name); - }; - object.prototype.Id = function() { return this.$val.Id(); }; - object.Ptr.prototype.String = function() { - var obj; - obj = this; - $panic(new $String("abstract")); - }; - object.prototype.String = function() { return this.$val.String(); }; - object.Ptr.prototype.isUsed = function() { - var obj; - obj = this; - return obj.used; - }; - object.prototype.isUsed = function() { return this.$val.isUsed(); }; - object.Ptr.prototype.setParent = function(parent) { - var obj; - obj = this; - obj.parent = parent; - }; - object.prototype.setParent = function(parent) { return this.$val.setParent(parent); }; - object.Ptr.prototype.sameId = function(pkg, name) { - var obj; - obj = this; - if (!(name === obj.name)) { - return false; + Checker.prototype.shortVarDecl = function(pos, lhs, rhs) { return this.$val.shortVarDecl(pos, lhs, rhs); }; + Checker.Ptr.prototype.builtin = function(x, call, id) { + var result = false, $deferred = [], $err = null, check, bin, arg, nargs, _ref, _tuple, msg, _ref$1, S, T, _tuple$1, s, alist, sig, sig$1, mode, typ, val, t, _ref$2, _tuple$2, c, y, realT, complexT, _ref$3, dst, _tuple$3, t$1, y$1, src, t$2, _ref$4, _tuple$4, m, k, _ref$5, x$1, arg0, T$1, min, _ref$6, sizes, _ref$7, _i, arg$1, _tuple$5, s$1, ok, x$2, x$3, x$4, params, x$5, T$2, T$3, params$1, i, x$6, arg0$1, _tuple$6, selx, base, sel, _tuple$7, obj, index, indirect, _ref$8, offs, t$3, x1, _ref$9, _i$1, arg$2; + /* */ try { $deferFrames.push($deferred); + check = this; + bin = new ($structType([["name", "name", "code.google.com/p/go.tools/go/types", $String, ""], ["nargs", "nargs", "code.google.com/p/go.tools/go/types", $Int, ""], ["variadic", "variadic", "code.google.com/p/go.tools/go/types", $Bool, ""], ["kind", "kind", "code.google.com/p/go.tools/go/types", exprKind, ""]])).Ptr(); $copy(bin, ((id < 0 || id >= predeclaredFuncs.length) ? $throwRuntimeError("index out of range") : predeclaredFuncs[id]), ($structType([["name", "name", "code.google.com/p/go.tools/go/types", $String, ""], ["nargs", "nargs", "code.google.com/p/go.tools/go/types", $Int, ""], ["variadic", "variadic", "code.google.com/p/go.tools/go/types", $Bool, ""], ["kind", "kind", "code.google.com/p/go.tools/go/types", exprKind, ""]]))); + if ((new token.Pos(call.Ellipsis)).IsValid() && !((id === 0))) { + check.invalidOp(call.Ellipsis, "invalid use of ... with built-in %s", new ($sliceType($emptyInterface))([new $String(bin.name)])); + check.use(call.Args); + return result; } - if (obj.Exported()) { - return true; + if ((id === 7) || (id === 1)) { + $deferred.push([(function(b) { + check.context.hasCallOrRecv = b; + }), [check.context.hasCallOrRecv]]); + check.context.hasCallOrRecv = false; } - if (pkg === ($ptrType(Package)).nil || obj.pkg === ($ptrType(Package)).nil) { - return pkg === obj.pkg; + arg = $throwNilPointerError; + nargs = call.Args.$length; + _ref = id; + if (_ref === 8 || _ref === 9 || _ref === 16 || _ref === 19) { + } else { + _tuple = unpack((function(x$1, i) { + var x$2; + check.expr(x$1, (x$2 = call.Args, ((i < 0 || i >= x$2.$length) ? $throwRuntimeError("index out of range") : x$2.$array[x$2.$offset + i]))); + }), nargs, false); arg = _tuple[0]; nargs = _tuple[1]; + if (arg === $throwNilPointerError) { + x.mode = 0; + return result; + } + if (nargs > 0) { + arg(x, 0); + if (x.mode === 0) { + return result; + } + } } - return pkg.path === obj.pkg.path; - }; - object.prototype.sameId = function(pkg, name) { return this.$val.sameId(pkg, name); }; - NewPkgName = $pkg.NewPkgName = function(pos, pkg, name, imported) { - return new PkgName.Ptr(new object.Ptr(($ptrType(Scope)).nil, pos, pkg, name, $pkg.Typ[0], false), imported); - }; - PkgName.Ptr.prototype.Imported = function() { - var obj; - obj = this; - return obj.imported; - }; - PkgName.prototype.Imported = function() { return this.$val.Imported(); }; - NewConst = $pkg.NewConst = function(pos, pkg, name, typ, val) { - return new Const.Ptr(new object.Ptr(($ptrType(Scope)).nil, pos, pkg, name, typ, false), val, false); - }; - Const.Ptr.prototype.Val = function() { - var obj; - obj = this; - return obj.val; - }; - Const.prototype.Val = function() { return this.$val.Val(); }; - NewTypeName = $pkg.NewTypeName = function(pos, pkg, name, typ) { - return new TypeName.Ptr(new object.Ptr(($ptrType(Scope)).nil, pos, pkg, name, typ, false)); - }; - NewVar = $pkg.NewVar = function(pos, pkg, name, typ) { - return new Var.Ptr(new object.Ptr(($ptrType(Scope)).nil, pos, pkg, name, typ, false), false, false, false); - }; - NewParam = $pkg.NewParam = function(pos, pkg, name, typ) { - return new Var.Ptr(new object.Ptr(($ptrType(Scope)).nil, pos, pkg, name, typ, true), false, false, false); - }; - NewField = $pkg.NewField = function(pos, pkg, name, typ, anonymous) { - return new Var.Ptr(new object.Ptr(($ptrType(Scope)).nil, pos, pkg, name, typ, false), anonymous, false, true); - }; - Var.Ptr.prototype.Anonymous = function() { - var obj; - obj = this; - return obj.anonymous; - }; - Var.prototype.Anonymous = function() { return this.$val.Anonymous(); }; - Var.Ptr.prototype.IsField = function() { - var obj; - obj = this; - return obj.isField; - }; - Var.prototype.IsField = function() { return this.$val.IsField(); }; - NewFunc = $pkg.NewFunc = function(pos, pkg, name, sig) { - var typ; - typ = $ifaceNil; - if (!(sig === ($ptrType(Signature)).nil)) { - typ = sig; + msg = ""; + if (nargs < bin.nargs) { + msg = "not enough"; + } else if (!bin.variadic && nargs > bin.nargs) { + msg = "too many"; } - return new Func.Ptr(new object.Ptr(($ptrType(Scope)).nil, pos, pkg, name, typ, false)); - }; - Func.Ptr.prototype.FullName = function() { - var obj, buf; - obj = this; - buf = new bytes.Buffer.Ptr(); $copy(buf, new bytes.Buffer.Ptr(), bytes.Buffer); - writeFuncName(buf, ($ptrType(Package)).nil, obj); - return buf.String(); - }; - Func.prototype.FullName = function() { return this.$val.FullName(); }; - Func.Ptr.prototype.Scope = function() { - var obj; - obj = this; - return $assertType(obj.object.typ, ($ptrType(Signature))).scope; - }; - Func.prototype.Scope = function() { return this.$val.Scope(); }; - NewLabel = $pkg.NewLabel = function(pos, pkg, name) { - return new Label.Ptr(new object.Ptr(($ptrType(Scope)).nil, pos, pkg, name, $pkg.Typ[0], false)); - }; - newBuiltin = function(id) { - return new Builtin.Ptr(new object.Ptr(($ptrType(Scope)).nil, 0, ($ptrType(Package)).nil, ((id < 0 || id >= predeclaredFuncs.length) ? $throwRuntimeError("index out of range") : predeclaredFuncs[id]).name, $pkg.Typ[0], false), id); - }; - writeObject = function(buf, this$1, obj) { - var typ, obj$1, _ref, path$1, pkg; - typ = obj.Type(); - _ref = obj; - if ($assertType(_ref, ($ptrType(PkgName)), true)[1]) { - obj$1 = _ref.$val; - fmt.Fprintf(buf, "package %s", new ($sliceType($emptyInterface))([new $String(obj$1.object.Name())])); - path$1 = obj$1.imported.path; - if (!(path$1 === "") && !(path$1 === obj$1.object.name)) { - fmt.Fprintf(buf, " (%q)", new ($sliceType($emptyInterface))([new $String(path$1)])); + if (!(msg === "")) { + check.invalidOp(call.Rparen, "%s arguments for %s (expected %d, found %d)", new ($sliceType($emptyInterface))([new $String(msg), call, new $Int(bin.nargs), new $Int(nargs)])); + return result; + } + _ref$1 = id; + switch (0) { default: if (_ref$1 === 0) { + S = x.typ; + T = $ifaceNil; + _tuple$1 = $assertType(S.Underlying(), ($ptrType(Slice)), true); s = _tuple$1[0]; + if (!(s === ($ptrType(Slice)).nil)) { + T = s.elem; + } else { + check.invalidArg(x.pos(), "%s is not a slice", new ($sliceType($emptyInterface))([x])); + return result; + } + alist = new ($sliceType(operand))([$clone(x, operand)]); + if ((nargs === 2) && (new token.Pos(call.Ellipsis)).IsValid() && x.assignableTo(check.conf, NewSlice($pkg.UniverseByte))) { + arg(x, 1); + if (x.mode === 0) { + return result; + } + if (isString(x.typ)) { + if (!(check.Info.Types === false)) { + sig = makeSig(S, new ($sliceType(Type))([S, x.typ])); + sig.variadic = true; + check.recordBuiltinType(call.Fun, sig); + } + x.mode = 7; + x.typ = S; + break; + } + alist = $append(alist, x); + } + sig$1 = makeSig(S, new ($sliceType(Type))([S, NewSlice(T)])); + sig$1.variadic = true; + check.arguments$(x, call, sig$1, (function(x$1, i) { + if (i < alist.$length) { + $copy(x$1, ((i < 0 || i >= alist.$length) ? $throwRuntimeError("index out of range") : alist.$array[alist.$offset + i]), operand); + return; + } + arg(x$1, i); + }), nargs); + x.mode = 7; + x.typ = S; + if (!(check.Info.Types === false)) { + check.recordBuiltinType(call.Fun, sig$1); + } + } else if (_ref$1 === 1 || _ref$1 === 7) { + mode = 0; + typ = $ifaceNil; + val = $ifaceNil; + typ = implicitArrayDeref(x.typ.Underlying()); + _ref$2 = typ; + if ($assertType(_ref$2, ($ptrType(Basic)), true)[1]) { + t = _ref$2.$val; + if (isString(t) && (id === 7)) { + if (x.mode === 4) { + mode = 4; + val = exact.MakeInt64(new $Int64(0, exact.StringVal(x.val).length)); + } else { + mode = 7; + } + } + } else if ($assertType(_ref$2, ($ptrType(Array)), true)[1]) { + t = _ref$2.$val; + mode = 7; + if (!check.context.hasCallOrRecv) { + mode = 4; + val = exact.MakeInt64(t.len); + } + } else if ($assertType(_ref$2, ($ptrType(Slice)), true)[1] || $assertType(_ref$2, ($ptrType(Chan)), true)[1]) { + t = _ref$2; + mode = 7; + } else if ($assertType(_ref$2, ($ptrType(Map)), true)[1]) { + t = _ref$2.$val; + if (id === 7) { + mode = 7; + } + } + if (mode === 0) { + check.invalidArg(x.pos(), "%s for %s", new ($sliceType($emptyInterface))([x, new $String(bin.name)])); + return result; + } + x.mode = mode; + x.typ = $pkg.Typ[2]; + x.val = val; + if (!(check.Info.Types === false) && !((mode === 4))) { + check.recordBuiltinType(call.Fun, makeSig(x.typ, new ($sliceType(Type))([typ]))); + } + } else if (_ref$1 === 2) { + _tuple$2 = $assertType(x.typ.Underlying(), ($ptrType(Chan)), true); c = _tuple$2[0]; + if (c === ($ptrType(Chan)).nil) { + check.invalidArg(x.pos(), "%s is not a channel", new ($sliceType($emptyInterface))([x])); + return result; } - return; - } else if ($assertType(_ref, ($ptrType(Const)), true)[1]) { - obj$1 = _ref.$val; - buf.WriteString("const"); - } else if ($assertType(_ref, ($ptrType(TypeName)), true)[1]) { - obj$1 = _ref.$val; - buf.WriteString("type"); - typ = typ.Underlying(); - } else if ($assertType(_ref, ($ptrType(Var)), true)[1]) { - obj$1 = _ref.$val; - if (obj$1.isField) { - buf.WriteString("field"); + if (c.dir === 2) { + check.invalidArg(x.pos(), "%s must not be a receive-only channel", new ($sliceType($emptyInterface))([x])); + return result; + } + x.mode = 1; + if (!(check.Info.Types === false)) { + check.recordBuiltinType(call.Fun, makeSig($ifaceNil, new ($sliceType(Type))([c]))); + } + } else if (_ref$1 === 3) { + if (!check.complexArg(x)) { + return result; + } + y = new operand.Ptr(); $copy(y, new operand.Ptr(), operand); + arg(y, 1); + if (y.mode === 0) { + return result; + } + if (!check.complexArg(y)) { + return result; + } + check.convertUntyped(x, y.typ); + if (x.mode === 0) { + return result; + } + check.convertUntyped(y, x.typ); + if (y.mode === 0) { + return result; + } + if (!Identical(x.typ, y.typ)) { + check.invalidArg(x.pos(), "mismatched types %s and %s", new ($sliceType($emptyInterface))([x.typ, y.typ])); + return result; + } + if ((x.mode === 4) && (y.mode === 4)) { + x.val = exact.BinaryOp(x.val, 12, exact.MakeImag(y.val)); } else { - buf.WriteString("var"); + x.mode = 7; } - } else if ($assertType(_ref, ($ptrType(Func)), true)[1]) { - obj$1 = _ref.$val; - buf.WriteString("func "); - writeFuncName(buf, this$1, obj$1); - if (!($interfaceIsEqual(typ, $ifaceNil))) { - WriteSignature(buf, this$1, $assertType(typ, ($ptrType(Signature)))); + realT = x.typ; + complexT = $pkg.Typ[0]; + _ref$3 = $assertType(realT.Underlying(), ($ptrType(Basic))).kind; + if (_ref$3 === 13) { + complexT = $pkg.Typ[15]; + } else if (_ref$3 === 14) { + complexT = $pkg.Typ[16]; + } else if (_ref$3 === 20 || _ref$3 === 21 || _ref$3 === 22) { + if (x.mode === 4) { + realT = $assertType(defaultType(realT), ($ptrType(Basic))); + complexT = $pkg.Typ[23]; + } else { + realT = $pkg.Typ[14]; + complexT = $pkg.Typ[16]; + } + } else { + check.invalidArg(x.pos(), "float32 or float64 arguments expected", new ($sliceType($emptyInterface))([])); + return result; } - return; - } else if ($assertType(_ref, ($ptrType(Label)), true)[1]) { - obj$1 = _ref.$val; - buf.WriteString("label"); - typ = $ifaceNil; - } else if ($assertType(_ref, ($ptrType(Builtin)), true)[1]) { - obj$1 = _ref.$val; - buf.WriteString("builtin"); - typ = $ifaceNil; - } else if ($assertType(_ref, ($ptrType(Nil)), true)[1]) { - obj$1 = _ref.$val; - buf.WriteString("nil"); - return; - } else { - obj$1 = _ref; - $panic(new $String(fmt.Sprintf("writeObject(%T)", new ($sliceType($emptyInterface))([obj$1])))); - } - buf.WriteByte(32); - pkg = obj.Pkg(); - if (!(pkg === ($ptrType(Package)).nil) && !(this$1 === pkg) && $interfaceIsEqual(pkg.scope.Lookup(obj.Name()), obj)) { - buf.WriteString(pkg.path); - buf.WriteByte(46); - } - buf.WriteString(obj.Name()); - if (!($interfaceIsEqual(typ, $ifaceNil))) { - buf.WriteByte(32); - WriteType(buf, this$1, typ); - } - }; - ObjectString = $pkg.ObjectString = function(this$1, obj) { - var buf; - buf = new bytes.Buffer.Ptr(); $copy(buf, new bytes.Buffer.Ptr(), bytes.Buffer); - writeObject(buf, this$1, obj); - return buf.String(); - }; - PkgName.Ptr.prototype.String = function() { - var obj; - obj = this; - return ObjectString(($ptrType(Package)).nil, obj); - }; - PkgName.prototype.String = function() { return this.$val.String(); }; - Const.Ptr.prototype.String = function() { - var obj; - obj = this; - return ObjectString(($ptrType(Package)).nil, obj); - }; - Const.prototype.String = function() { return this.$val.String(); }; - TypeName.Ptr.prototype.String = function() { - var obj; - obj = this; - return ObjectString(($ptrType(Package)).nil, obj); - }; - TypeName.prototype.String = function() { return this.$val.String(); }; - Var.Ptr.prototype.String = function() { - var obj; - obj = this; - return ObjectString(($ptrType(Package)).nil, obj); - }; - Var.prototype.String = function() { return this.$val.String(); }; - Func.Ptr.prototype.String = function() { - var obj; - obj = this; - return ObjectString(($ptrType(Package)).nil, obj); - }; - Func.prototype.String = function() { return this.$val.String(); }; - Label.Ptr.prototype.String = function() { - var obj; - obj = this; - return ObjectString(($ptrType(Package)).nil, obj); - }; - Label.prototype.String = function() { return this.$val.String(); }; - Builtin.Ptr.prototype.String = function() { - var obj; - obj = this; - return ObjectString(($ptrType(Package)).nil, obj); - }; - Builtin.prototype.String = function() { return this.$val.String(); }; - Nil.Ptr.prototype.String = function() { - var obj; - obj = this; - return ObjectString(($ptrType(Package)).nil, obj); - }; - Nil.prototype.String = function() { return this.$val.String(); }; - writeFuncName = function(buf, this$1, f) { - var sig, recv, _tuple, ok; - if (!($interfaceIsEqual(f.object.typ, $ifaceNil))) { - sig = $assertType(f.object.typ, ($ptrType(Signature))); - recv = sig.Recv(); - if (!(recv === ($ptrType(Var)).nil)) { - buf.WriteByte(40); - _tuple = $assertType(recv.object.Type(), ($ptrType(Interface)), true); ok = _tuple[1]; - if (ok) { - buf.WriteString("interface"); + x.typ = complexT; + if (!(check.Info.Types === false) && !((x.mode === 4))) { + check.recordBuiltinType(call.Fun, makeSig(complexT, new ($sliceType(Type))([realT, realT]))); + } + if (!((x.mode === 4))) { + check.updateExprType(x.expr, realT, true); + check.updateExprType(y.expr, realT, true); + } + } else if (_ref$1 === 4) { + dst = $ifaceNil; + _tuple$3 = $assertType(x.typ.Underlying(), ($ptrType(Slice)), true); t$1 = _tuple$3[0]; + if (!(t$1 === ($ptrType(Slice)).nil)) { + dst = t$1.elem; + } + y$1 = new operand.Ptr(); $copy(y$1, new operand.Ptr(), operand); + arg(y$1, 1); + if (y$1.mode === 0) { + return result; + } + src = $ifaceNil; + _ref$4 = y$1.typ.Underlying(); + if ($assertType(_ref$4, ($ptrType(Basic)), true)[1]) { + t$2 = _ref$4.$val; + if (isString(y$1.typ)) { + src = $pkg.UniverseByte; + } + } else if ($assertType(_ref$4, ($ptrType(Slice)), true)[1]) { + t$2 = _ref$4.$val; + src = t$2.elem; + } + if ($interfaceIsEqual(dst, $ifaceNil) || $interfaceIsEqual(src, $ifaceNil)) { + check.invalidArg(x.pos(), "copy expects slice arguments; found %s and %s", new ($sliceType($emptyInterface))([x, y$1])); + return result; + } + if (!Identical(dst, src)) { + check.invalidArg(x.pos(), "arguments to copy %s and %s have different element types %s and %s", new ($sliceType($emptyInterface))([x, y$1, dst, src])); + return result; + } + if (!(check.Info.Types === false)) { + check.recordBuiltinType(call.Fun, makeSig($pkg.Typ[2], new ($sliceType(Type))([x.typ, y$1.typ]))); + } + x.mode = 7; + x.typ = $pkg.Typ[2]; + } else if (_ref$1 === 5) { + _tuple$4 = $assertType(x.typ.Underlying(), ($ptrType(Map)), true); m = _tuple$4[0]; + if (m === ($ptrType(Map)).nil) { + check.invalidArg(x.pos(), "%s is not a map", new ($sliceType($emptyInterface))([x])); + return result; + } + arg(x, 1); + if (x.mode === 0) { + return result; + } + if (!x.assignableTo(check.conf, m.key)) { + check.invalidArg(x.pos(), "%s is not assignable to %s", new ($sliceType($emptyInterface))([x, m.key])); + return result; + } + x.mode = 1; + if (!(check.Info.Types === false)) { + check.recordBuiltinType(call.Fun, makeSig($ifaceNil, new ($sliceType(Type))([m, m.key]))); + } + } else if (_ref$1 === 6 || _ref$1 === 13) { + if (!isComplex(x.typ)) { + check.invalidArg(x.pos(), "%s must be a complex number", new ($sliceType($emptyInterface))([x])); + return result; + } + if (x.mode === 4) { + if (id === 13) { + x.val = exact.Real(x.val); } else { - WriteType(buf, this$1, recv.object.Type()); + x.val = exact.Imag(x.val); } - buf.WriteByte(41); - buf.WriteByte(46); - } else if (!(f.object.pkg === ($ptrType(Package)).nil) && !(f.object.pkg === this$1)) { - buf.WriteString(f.object.pkg.path); - buf.WriteByte(46); + } else { + x.mode = 7; } - } - buf.WriteString(f.object.name); - }; - $ptrType(objset).prototype.insert = function(obj) { - var s, id, _entry, alt, _key$2; - s = this; - id = obj.Id(); - alt = (_entry = (s.$get())[id], _entry !== undefined ? _entry.v : $ifaceNil); - if (!($interfaceIsEqual(alt, $ifaceNil))) { - return alt; - } - if (s.$get() === false) { - s.$set(new $Map()); - } - _key$2 = id; (s.$get() || $throwRuntimeError("assignment to entry in nil map"))[_key$2] = { k: _key$2, v: obj }; - return $ifaceNil; - }; - operand.Ptr.prototype.pos = function() { - var x; - x = this; - if ($interfaceIsEqual(x.expr, $ifaceNil)) { - return 0; - } - return x.expr.Pos(); - }; - operand.prototype.pos = function() { return this.$val.pos(); }; - operandString = function(this$1, x) { - var buf, expr, _ref, x$1, hasType, _ref$1, x$2, s; - buf = new bytes.Buffer.Ptr(); $copy(buf, new bytes.Buffer.Ptr(), bytes.Buffer); - expr = ""; - if (!($interfaceIsEqual(x.expr, $ifaceNil))) { - expr = ExprString(x.expr); - } else { - _ref = x.mode; - if (_ref === 2) { - expr = (x$1 = x.id, ((x$1 < 0 || x$1 >= predeclaredFuncs.length) ? $throwRuntimeError("index out of range") : predeclaredFuncs[x$1])).name; - } else if (_ref === 3) { - expr = TypeString(this$1, x.typ); - } else if (_ref === 4) { - expr = x.val.String(); + k = 0; + _ref$5 = $assertType(x.typ.Underlying(), ($ptrType(Basic))).kind; + if (_ref$5 === 15) { + k = 13; + } else if (_ref$5 === 16) { + k = 14; + } else if (_ref$5 === 23) { + k = 22; + } else { + unreachable(); } - } - if (!(expr === "")) { - buf.WriteString(expr); - buf.WriteString(" ("); - } - hasType = false; - _ref$1 = x.mode; - switch (0) { default: if (_ref$1 === 0 || _ref$1 === 1 || _ref$1 === 2 || _ref$1 === 3) { - } else { - if (isUntyped(x.typ)) { - buf.WriteString($assertType(x.typ, ($ptrType(Basic))).name); - buf.WriteByte(32); - break; + if (!(check.Info.Types === false) && !((x.mode === 4))) { + check.recordBuiltinType(call.Fun, makeSig(((k < 0 || k >= $pkg.Typ.length) ? $throwRuntimeError("index out of range") : $pkg.Typ[k]), new ($sliceType(Type))([x.typ]))); } - hasType = true; - } } - buf.WriteString((x$2 = x.mode, ((x$2 < 0 || x$2 >= operandModeString.length) ? $throwRuntimeError("index out of range") : operandModeString[x$2]))); - if (x.mode === 4) { - s = x.val.String(); - if (!(s === expr)) { - buf.WriteByte(32); - buf.WriteString(s); + x.typ = ((k < 0 || k >= $pkg.Typ.length) ? $throwRuntimeError("index out of range") : $pkg.Typ[k]); + } else if (_ref$1 === 8) { + arg0 = (x$1 = call.Args, ((0 < 0 || 0 >= x$1.$length) ? $throwRuntimeError("index out of range") : x$1.$array[x$1.$offset + 0])); + T$1 = check.typ(arg0); + if ($interfaceIsEqual(T$1, $pkg.Typ[0])) { + return result; } - } - if (hasType) { - if (!($interfaceIsEqual(x.typ, $pkg.Typ[0]))) { - buf.WriteString(" of type "); - WriteType(buf, this$1, x.typ); + min = 0; + _ref$6 = T$1.Underlying(); + if ($assertType(_ref$6, ($ptrType(Slice)), true)[1]) { + min = 2; + } else if ($assertType(_ref$6, ($ptrType(Map)), true)[1] || $assertType(_ref$6, ($ptrType(Chan)), true)[1]) { + min = 1; } else { - buf.WriteString(" with invalid type"); + check.invalidArg(arg0.Pos(), "cannot make %s; type must be slice, map, or channel", new ($sliceType($emptyInterface))([arg0])); + return result; } - } - if (!(expr === "")) { - buf.WriteByte(41); - } - return buf.String(); - }; - operand.Ptr.prototype.String = function() { - var x; - x = this; - return operandString(($ptrType(Package)).nil, x); - }; - operand.prototype.String = function() { return this.$val.String(); }; - operand.Ptr.prototype.setConst = function(tok, lit) { - var x, val, kind, _ref; - x = this; - val = exact.MakeFromLiteral(lit, tok); - if ($interfaceIsEqual(val, $ifaceNil)) { - x.mode = 0; - return; - } - kind = 0; - _ref = tok; - if (_ref === 5) { - kind = 20; - } else if (_ref === 6) { - kind = 22; - } else if (_ref === 7) { - kind = 23; - } else if (_ref === 8) { - kind = 21; - } else if (_ref === 9) { - kind = 24; - } - x.mode = 4; - x.typ = ((kind < 0 || kind >= $pkg.Typ.length) ? $throwRuntimeError("index out of range") : $pkg.Typ[kind]); - x.val = val; - }; - operand.prototype.setConst = function(tok, lit) { return this.$val.setConst(tok, lit); }; - operand.Ptr.prototype.isNil = function() { - var x; - x = this; - return (x.mode === 7) && $interfaceIsEqual(x.typ, $pkg.Typ[25]); - }; - operand.prototype.isNil = function() { return this.$val.isNil(); }; - operand.Ptr.prototype.assignableTo = function(conf, T) { - var x, V, Vu, Tu, _tuple, Ti, ok, _tuple$1, Vc, ok$1, _tuple$2, Tc, ok$2, t, _ref, t$1, _ref$1, _tuple$3, Vb; - x = this; - if ((x.mode === 0) || $interfaceIsEqual(T, $pkg.Typ[0])) { - return true; - } - V = x.typ; - if (Identical(V, T)) { - return true; - } - Vu = V.Underlying(); - Tu = T.Underlying(); - _tuple = $assertType(Tu, ($ptrType(Interface)), true); Ti = _tuple[0]; ok = _tuple[1]; - if (ok) { - if (Implements(x.typ, Ti)) { - return true; + if (nargs < min || (min + 1 >> 0) < nargs) { + check.errorf(call.Pos(), "%s expects %d or %d arguments; found %d", new ($sliceType($emptyInterface))([call, new $Int(min), new $Int((min + 1 >> 0)), new $Int(nargs)])); + return result; + } + sizes = ($sliceType($Int64)).nil; + _ref$7 = $subslice(call.Args, 1); + _i = 0; + while (_i < _ref$7.$length) { + arg$1 = ((_i < 0 || _i >= _ref$7.$length) ? $throwRuntimeError("index out of range") : _ref$7.$array[_ref$7.$offset + _i]); + _tuple$5 = check.index(arg$1, new $Int64(-1, 4294967295)); s$1 = _tuple$5[0]; ok = _tuple$5[1]; + if (ok && (s$1.$high > 0 || (s$1.$high === 0 && s$1.$low >= 0))) { + sizes = $append(sizes, s$1); + } + _i++; + } + if ((sizes.$length === 2) && (x$2 = ((0 < 0 || 0 >= sizes.$length) ? $throwRuntimeError("index out of range") : sizes.$array[sizes.$offset + 0]), x$3 = ((1 < 0 || 1 >= sizes.$length) ? $throwRuntimeError("index out of range") : sizes.$array[sizes.$offset + 1]), (x$2.$high > x$3.$high || (x$2.$high === x$3.$high && x$2.$low > x$3.$low)))) { + check.invalidArg((x$4 = call.Args, ((1 < 0 || 1 >= x$4.$length) ? $throwRuntimeError("index out of range") : x$4.$array[x$4.$offset + 1])).Pos(), "length and capacity swapped", new ($sliceType($emptyInterface))([])); + } + x.mode = 7; + x.typ = T$1; + if (!(check.Info.Types === false)) { + params = $toNativeArray("Interface", [T$1, $pkg.Typ[2], $pkg.Typ[2]]); + check.recordBuiltinType(call.Fun, makeSig(x.typ, $subslice(new ($sliceType(Type))(params), 0, (1 + sizes.$length >> 0)))); + } + } else if (_ref$1 === 9) { + T$2 = check.typ((x$5 = call.Args, ((0 < 0 || 0 >= x$5.$length) ? $throwRuntimeError("index out of range") : x$5.$array[x$5.$offset + 0]))); + if ($interfaceIsEqual(T$2, $pkg.Typ[0])) { + return result; + } + x.mode = 7; + x.typ = new Pointer.Ptr(T$2); + if (!(check.Info.Types === false)) { + check.recordBuiltinType(call.Fun, makeSig(x.typ, new ($sliceType(Type))([T$2]))); + } + } else if (_ref$1 === 10) { + T$3 = new Interface.Ptr(); + if (!check.assignment(x, T$3)) { + assert(x.mode === 0); + return result; + } + x.mode = 1; + if (!(check.Info.Types === false)) { + check.recordBuiltinType(call.Fun, makeSig($ifaceNil, new ($sliceType(Type))([T$3]))); + } + } else if (_ref$1 === 11 || _ref$1 === 12) { + params$1 = ($sliceType(Type)).nil; + if (nargs > 0) { + params$1 = ($sliceType(Type)).make(nargs); + i = 0; + while (i < nargs) { + if (i > 0) { + arg(x, i); + } + if (!check.assignment(x, $ifaceNil)) { + assert(x.mode === 0); + return result; + } + (i < 0 || i >= params$1.$length) ? $throwRuntimeError("index out of range") : params$1.$array[params$1.$offset + i] = x.typ; + i = i + (1) >> 0; + } + } + x.mode = 1; + if (!(check.Info.Types === false)) { + check.recordBuiltinType(call.Fun, makeSig($ifaceNil, params$1)); + } + } else if (_ref$1 === 14) { + x.mode = 7; + x.typ = new Interface.Ptr(); + if (!(check.Info.Types === false)) { + check.recordBuiltinType(call.Fun, makeSig(x.typ, new ($sliceType(Type))([]))); + } + } else if (_ref$1 === 15) { + if (!check.assignment(x, $ifaceNil)) { + assert(x.mode === 0); + return result; + } + x.mode = 4; + x.val = exact.MakeInt64(check.conf.alignof(x.typ)); + x.typ = $pkg.Typ[12]; + } else if (_ref$1 === 16) { + arg0$1 = (x$6 = call.Args, ((0 < 0 || 0 >= x$6.$length) ? $throwRuntimeError("index out of range") : x$6.$array[x$6.$offset + 0])); + _tuple$6 = $assertType(unparen(arg0$1), ($ptrType(ast.SelectorExpr)), true); selx = _tuple$6[0]; + if (selx === ($ptrType(ast.SelectorExpr)).nil) { + check.invalidArg(arg0$1.Pos(), "%s is not a selector expression", new ($sliceType($emptyInterface))([arg0$1])); + check.use(new ($sliceType(ast.Expr))([arg0$1])); + return result; + } + check.expr(x, selx.X); + if (x.mode === 0) { + return result; + } + base = derefStructPtr(x.typ); + sel = selx.Sel.Name; + _tuple$7 = LookupFieldOrMethod(base, false, check.pkg, sel); obj = _tuple$7[0]; index = _tuple$7[1]; indirect = _tuple$7[2]; + _ref$8 = obj; + if (_ref$8 === $ifaceNil) { + check.invalidArg(x.pos(), "%s has no single field %s", new ($sliceType($emptyInterface))([base, new $String(sel)])); + return result; + } else if ($assertType(_ref$8, ($ptrType(Func)), true)[1]) { + check.invalidArg(arg0$1.Pos(), "%s is a method value", new ($sliceType($emptyInterface))([arg0$1])); + return result; + } + if (indirect) { + check.invalidArg(x.pos(), "field %s is embedded via a pointer in %s", new ($sliceType($emptyInterface))([new $String(sel), base])); + return result; + } + check.recordSelection(selx, 0, base, obj, index, false); + offs = check.conf.offsetof(base, index); + x.mode = 4; + x.val = exact.MakeInt64(offs); + x.typ = $pkg.Typ[12]; + } else if (_ref$1 === 17) { + if (!check.assignment(x, $ifaceNil)) { + assert(x.mode === 0); + return result; } - } - if (Identical(Vu, Tu) && (!isNamed(V) || !isNamed(T))) { - return true; - } - _tuple$1 = $assertType(Vu, ($ptrType(Chan)), true); Vc = _tuple$1[0]; ok$1 = _tuple$1[1]; - if (ok$1 && (Vc.dir === 0)) { - _tuple$2 = $assertType(Tu, ($ptrType(Chan)), true); Tc = _tuple$2[0]; ok$2 = _tuple$2[1]; - if (ok$2 && Identical(Vc.elem, Tc.elem)) { - return !isNamed(V) || !isNamed(T); + x.mode = 4; + x.val = exact.MakeInt64(check.conf.sizeof(x.typ)); + x.typ = $pkg.Typ[12]; + } else if (_ref$1 === 18) { + if (!((x.mode === 4)) || !isBoolean(x.typ)) { + check.invalidArg(x.pos(), "%s is not a boolean constant", new ($sliceType($emptyInterface))([x])); + return result; } - } - if (x.isNil()) { - _ref = Tu; - if ($assertType(_ref, ($ptrType(Basic)), true)[1]) { - t = _ref.$val; - if (t.kind === 18) { - return true; - } - } else if ($assertType(_ref, ($ptrType(Pointer)), true)[1] || $assertType(_ref, ($ptrType(Signature)), true)[1] || $assertType(_ref, ($ptrType(Slice)), true)[1] || $assertType(_ref, ($ptrType(Map)), true)[1] || $assertType(_ref, ($ptrType(Chan)), true)[1] || $assertType(_ref, ($ptrType(Interface)), true)[1]) { - t = _ref; - return true; + if (!((x.val.Kind() === 1))) { + check.errorf(x.pos(), "internal error: value of %s should be a boolean constant", new ($sliceType($emptyInterface))([x])); + return result; } - return false; - } - if (isUntyped(Vu)) { - _ref$1 = Tu; - if ($assertType(_ref$1, ($ptrType(Basic)), true)[1]) { - t$1 = _ref$1.$val; - if (x.mode === 4) { - return representableConst(x.val, conf, t$1.kind, ($ptrType(exact.Value)).nil); - } - _tuple$3 = $assertType(Vu, ($ptrType(Basic)), true); Vb = _tuple$3[0]; - if (!(Vb === ($ptrType(Basic)).nil)) { - return (Vb.kind === 19) && isBoolean(Tu); - } - } else if ($assertType(_ref$1, ($ptrType(Interface)), true)[1]) { - t$1 = _ref$1.$val; - return x.isNil() || t$1.Empty(); - } else if ($assertType(_ref$1, ($ptrType(Pointer)), true)[1] || $assertType(_ref$1, ($ptrType(Signature)), true)[1] || $assertType(_ref$1, ($ptrType(Slice)), true)[1] || $assertType(_ref$1, ($ptrType(Map)), true)[1] || $assertType(_ref$1, ($ptrType(Chan)), true)[1]) { - t$1 = _ref$1; - return x.isNil(); + if (!exact.BoolVal(x.val)) { + check.errorf(call.Pos(), "%s failed", new ($sliceType($emptyInterface))([call])); } - } - return false; - }; - operand.prototype.assignableTo = function(conf, T) { return this.$val.assignableTo(conf, T); }; - operand.Ptr.prototype.isInteger = function() { - var x; - x = this; - return (x.mode === 0) || isInteger(x.typ) || (x.mode === 4) && representableConst(x.val, ($ptrType(Config)).nil, 20, ($ptrType(exact.Value)).nil); - }; - operand.prototype.isInteger = function() { return this.$val.isInteger(); }; - Checker.Ptr.prototype.resolveOrder = function() { - var check, _tmp, _tmp$1, ifaces, others, _ref, _i, _keys, _entry, obj, ityp, _ref$1, _i$1, f, _tuple, ident, embedded, _entry$1, order, _ref$2, _i$2, obj$1; - check = this; - _tmp = ($sliceType(Object)).nil; _tmp$1 = ($sliceType(Object)).nil; ifaces = _tmp; others = _tmp$1; - _ref = check.objMap; - _i = 0; - _keys = $keys(_ref); - while (_i < _keys.length) { - _entry = _ref[_keys[_i]]; - if (_entry === undefined) { - _i++; - continue; + } else if (_ref$1 === 19) { + if (nargs === 0) { + check.dump("%s: trace() without arguments", new ($sliceType($emptyInterface))([new token.Pos(call.Pos())])); + x.mode = 1; + break; } - obj = _entry.k; - ityp = check.interfaceFor(obj); - if (!(ityp === ($ptrType(ast.InterfaceType)).nil)) { - ifaces = $append(ifaces, obj); - _ref$1 = ityp.Methods.List; - _i$1 = 0; - while (_i$1 < _ref$1.$length) { - f = ((_i$1 < 0 || _i$1 >= _ref$1.$length) ? $throwRuntimeError("index out of range") : _ref$1.$array[_ref$1.$offset + _i$1]); - if (f.Names.$length === 0) { - _tuple = $assertType(f.Type, ($ptrType(ast.Ident)), true); ident = _tuple[0]; - if (!(ident === ($ptrType(ast.Ident)).nil)) { - embedded = check.pkg.scope.Lookup(ident.Name); - if (!(check.interfaceFor(embedded) === ($ptrType(ast.InterfaceType)).nil)) { - (_entry$1 = check.objMap[obj.$key()], _entry$1 !== undefined ? _entry$1.v : ($ptrType(declInfo)).nil).addDep(embedded); - } - } - } - _i$1++; - } - } else { - others = $append(others, obj); + t$3 = new operand.Ptr(); $copy(t$3, new operand.Ptr(), operand); + x1 = x; + _ref$9 = call.Args; + _i$1 = 0; + while (_i$1 < _ref$9.$length) { + arg$2 = ((_i$1 < 0 || _i$1 >= _ref$9.$length) ? $throwRuntimeError("index out of range") : _ref$9.$array[_ref$9.$offset + _i$1]); + check.rawExpr(x1, arg$2, $ifaceNil); + check.dump("%s: %s", new ($sliceType($emptyInterface))([new token.Pos(x1.pos()), x1])); + x1 = t$3; + _i$1++; } - _i++; - } - order = ($sliceType(Object)).nil; - sort.Sort($subslice(new inSourceOrder(ifaces.$array), ifaces.$offset, ifaces.$offset + ifaces.$length)); - _ref$2 = ifaces; - _i$2 = 0; - while (_i$2 < _ref$2.$length) { - obj$1 = ((_i$2 < 0 || _i$2 >= _ref$2.$length) ? $throwRuntimeError("index out of range") : _ref$2.$array[_ref$2.$offset + _i$2]); - check.appendInPostOrder(new ($ptrType(($sliceType(Object))))(function() { return order; }, function($v) { order = $v; }), obj$1); - _i$2++; - } - sort.Sort($subslice(new inSourceOrder(others.$array), others.$offset, others.$offset + others.$length)); - return $appendSlice(order, others); - }; - Checker.prototype.resolveOrder = function() { return this.$val.resolveOrder(); }; - Checker.Ptr.prototype.interfaceFor = function(obj) { - var check, _tuple, tname, _entry, d, _tuple$1, ityp; - check = this; - _tuple = $assertType(obj, ($ptrType(TypeName)), true); tname = _tuple[0]; - if (tname === ($ptrType(TypeName)).nil) { - return ($ptrType(ast.InterfaceType)).nil; - } - d = (_entry = check.objMap[obj.$key()], _entry !== undefined ? _entry.v : ($ptrType(declInfo)).nil); - if (d === ($ptrType(declInfo)).nil) { - check.dump("%s: %s should have been declared", new ($sliceType($emptyInterface))([new token.Pos(obj.Pos()), new $String(obj.Name())])); + } else { unreachable(); - } - if ($interfaceIsEqual(d.typ, $ifaceNil)) { - return ($ptrType(ast.InterfaceType)).nil; - } - _tuple$1 = $assertType(d.typ, ($ptrType(ast.InterfaceType)), true); ityp = _tuple$1[0]; - return ityp; + } } + result = true; + return result; + /* */ } catch(err) { $err = err; } finally { $deferFrames.pop(); $callDeferred($deferred, $err); return result; } }; - Checker.prototype.interfaceFor = function(obj) { return this.$val.interfaceFor(obj); }; - Checker.Ptr.prototype.appendInPostOrder = function(order, obj) { - var check, _entry, d, _ref, _i, obj$1; - check = this; - d = (_entry = check.objMap[obj.$key()], _entry !== undefined ? _entry.v : ($ptrType(declInfo)).nil); - if (!((d.mark === 0))) { - return; - } - d.mark = 1; - _ref = orderedSetObjects(d.deps); + Checker.prototype.builtin = function(x, call, id) { return this.$val.builtin(x, call, id); }; + makeSig = function(res, args) { + var list, _ref, _i, i, param, params, result; + list = ($sliceType(($ptrType(Var)))).make(args.$length); + _ref = args; _i = 0; while (_i < _ref.$length) { - obj$1 = ((_i < 0 || _i >= _ref.$length) ? $throwRuntimeError("index out of range") : _ref.$array[_ref.$offset + _i]); - check.appendInPostOrder(order, obj$1); - _i++; - } - order.$set($append(order.$get(), obj)); - }; - Checker.prototype.appendInPostOrder = function(order, obj) { return this.$val.appendInPostOrder(order, obj); }; - orderedSetObjects = function(set) { - var list, i, _ref, _i, _keys, _entry, obj; - list = ($sliceType(Object)).make($keys(set).length); - i = 0; - _ref = set; - _i = 0; - _keys = $keys(_ref); - while (_i < _keys.length) { - _entry = _ref[_keys[_i]]; - if (_entry === undefined) { - _i++; - continue; - } - obj = _entry.k; - (i < 0 || i >= list.$length) ? $throwRuntimeError("index out of range") : list.$array[list.$offset + i] = obj; - i = i + (1) >> 0; + i = _i; + param = ((_i < 0 || _i >= _ref.$length) ? $throwRuntimeError("index out of range") : _ref.$array[_ref.$offset + _i]); + (i < 0 || i >= list.$length) ? $throwRuntimeError("index out of range") : list.$array[list.$offset + i] = NewVar(0, ($ptrType(Package)).nil, "", defaultType(param)); _i++; } - sort.Sort($subslice(new inSourceOrder(list.$array), list.$offset, list.$offset + list.$length)); - return list; - }; - inSourceOrder.prototype.Len = function() { - var a; - a = this; - return a.$length; - }; - $ptrType(inSourceOrder).prototype.Len = function() { return this.$get().Len(); }; - inSourceOrder.prototype.Less = function(i, j) { - var a; - a = this; - return ((i < 0 || i >= a.$length) ? $throwRuntimeError("index out of range") : a.$array[a.$offset + i]).Pos() < ((j < 0 || j >= a.$length) ? $throwRuntimeError("index out of range") : a.$array[a.$offset + j]).Pos(); - }; - $ptrType(inSourceOrder).prototype.Less = function(i, j) { return this.$get().Less(i, j); }; - inSourceOrder.prototype.Swap = function(i, j) { - var a, _tmp, _tmp$1; - a = this; - _tmp = ((j < 0 || j >= a.$length) ? $throwRuntimeError("index out of range") : a.$array[a.$offset + j]); _tmp$1 = ((i < 0 || i >= a.$length) ? $throwRuntimeError("index out of range") : a.$array[a.$offset + i]); (i < 0 || i >= a.$length) ? $throwRuntimeError("index out of range") : a.$array[a.$offset + i] = _tmp; (j < 0 || j >= a.$length) ? $throwRuntimeError("index out of range") : a.$array[a.$offset + j] = _tmp$1; - }; - $ptrType(inSourceOrder).prototype.Swap = function(i, j) { return this.$get().Swap(i, j); }; - NewPackage = $pkg.NewPackage = function(path$1, name) { - var scope; - if (name === "_") { - $panic(new $String("invalid package name _")); + params = NewTuple(list); + result = ($ptrType(Tuple)).nil; + if (!($interfaceIsEqual(res, $ifaceNil))) { + assert(!isUntyped(res)); + result = NewTuple(new ($sliceType(($ptrType(Var))))([NewVar(0, ($ptrType(Package)).nil, "", res)])); } - scope = NewScope($pkg.Universe, fmt.Sprintf("package %q", new ($sliceType($emptyInterface))([new $String(path$1)]))); - return new Package.Ptr(path$1, name, scope, false, ($sliceType(($ptrType(Package)))).nil, false); - }; - Package.Ptr.prototype.Path = function() { - var pkg; - pkg = this; - return pkg.path; - }; - Package.prototype.Path = function() { return this.$val.Path(); }; - Package.Ptr.prototype.Name = function() { - var pkg; - pkg = this; - return pkg.name; - }; - Package.prototype.Name = function() { return this.$val.Name(); }; - Package.Ptr.prototype.Scope = function() { - var pkg; - pkg = this; - return pkg.scope; - }; - Package.prototype.Scope = function() { return this.$val.Scope(); }; - Package.Ptr.prototype.Complete = function() { - var pkg; - pkg = this; - return pkg.complete; - }; - Package.prototype.Complete = function() { return this.$val.Complete(); }; - Package.Ptr.prototype.MarkComplete = function() { - var pkg; - pkg = this; - pkg.complete = true; - }; - Package.prototype.MarkComplete = function() { return this.$val.MarkComplete(); }; - Package.Ptr.prototype.Imports = function() { - var pkg; - pkg = this; - return pkg.imports; - }; - Package.prototype.Imports = function() { return this.$val.Imports(); }; - Package.Ptr.prototype.SetImports = function(list) { - var pkg; - pkg = this; - pkg.imports = list; - }; - Package.prototype.SetImports = function(list) { return this.$val.SetImports(list); }; - Package.Ptr.prototype.String = function() { - var pkg; - pkg = this; - return fmt.Sprintf("package %s (%q)", new ($sliceType($emptyInterface))([new $String(pkg.name), new $String(pkg.path)])); + return new Signature.Ptr(($ptrType(Scope)).nil, ($ptrType(Var)).nil, params, result, false); }; - Package.prototype.String = function() { return this.$val.String(); }; - isNamed = function(typ) { - var _tuple, ok, _tuple$1, ok$1; - _tuple = $assertType(typ, ($ptrType(Basic)), true); ok = _tuple[1]; + implicitArrayDeref = function(typ) { + var _tuple, p, ok, _tuple$1, a, ok$1; + _tuple = $assertType(typ, ($ptrType(Pointer)), true); p = _tuple[0]; ok = _tuple[1]; if (ok) { - return ok; + _tuple$1 = $assertType(p.base.Underlying(), ($ptrType(Array)), true); a = _tuple$1[0]; ok$1 = _tuple$1[1]; + if (ok$1) { + return a; + } } - _tuple$1 = $assertType(typ, ($ptrType(Named)), true); ok$1 = _tuple$1[1]; - return ok$1; - }; - isBoolean = function(typ) { - var _tuple, t, ok; - _tuple = $assertType(typ.Underlying(), ($ptrType(Basic)), true); t = _tuple[0]; ok = _tuple[1]; - return ok && !(((t.info & 1) === 0)); - }; - isInteger = function(typ) { - var _tuple, t, ok; - _tuple = $assertType(typ.Underlying(), ($ptrType(Basic)), true); t = _tuple[0]; ok = _tuple[1]; - return ok && !(((t.info & 2) === 0)); - }; - isUnsigned = function(typ) { - var _tuple, t, ok; - _tuple = $assertType(typ.Underlying(), ($ptrType(Basic)), true); t = _tuple[0]; ok = _tuple[1]; - return ok && !(((t.info & 4) === 0)); - }; - isFloat = function(typ) { - var _tuple, t, ok; - _tuple = $assertType(typ.Underlying(), ($ptrType(Basic)), true); t = _tuple[0]; ok = _tuple[1]; - return ok && !(((t.info & 8) === 0)); - }; - isComplex = function(typ) { - var _tuple, t, ok; - _tuple = $assertType(typ.Underlying(), ($ptrType(Basic)), true); t = _tuple[0]; ok = _tuple[1]; - return ok && !(((t.info & 16) === 0)); - }; - isNumeric = function(typ) { - var _tuple, t, ok; - _tuple = $assertType(typ.Underlying(), ($ptrType(Basic)), true); t = _tuple[0]; ok = _tuple[1]; - return ok && !(((t.info & 26) === 0)); - }; - isString = function(typ) { - var _tuple, t, ok; - _tuple = $assertType(typ.Underlying(), ($ptrType(Basic)), true); t = _tuple[0]; ok = _tuple[1]; - return ok && !(((t.info & 32) === 0)); - }; - isTyped = function(typ) { - var _tuple, t, ok; - _tuple = $assertType(typ.Underlying(), ($ptrType(Basic)), true); t = _tuple[0]; ok = _tuple[1]; - return !ok || ((t.info & 64) === 0); - }; - isUntyped = function(typ) { - var _tuple, t, ok; - _tuple = $assertType(typ.Underlying(), ($ptrType(Basic)), true); t = _tuple[0]; ok = _tuple[1]; - return ok && !(((t.info & 64) === 0)); - }; - isOrdered = function(typ) { - var _tuple, t, ok; - _tuple = $assertType(typ.Underlying(), ($ptrType(Basic)), true); t = _tuple[0]; ok = _tuple[1]; - return ok && !(((t.info & 42) === 0)); - }; - isConstType = function(typ) { - var _tuple, t, ok; - _tuple = $assertType(typ.Underlying(), ($ptrType(Basic)), true); t = _tuple[0]; ok = _tuple[1]; - return ok && !(((t.info & 59) === 0)); - }; - isInterface = function(typ) { - var _tuple, ok; - _tuple = $assertType(typ.Underlying(), ($ptrType(Interface)), true); ok = _tuple[1]; - return ok; + return typ; }; - Comparable = $pkg.Comparable = function(T) { - var t, _ref, _ref$1, _i, f; - _ref = T.Underlying(); - if ($assertType(_ref, ($ptrType(Basic)), true)[1]) { - t = _ref.$val; - return !((t.kind === 25)); - } else if ($assertType(_ref, ($ptrType(Pointer)), true)[1] || $assertType(_ref, ($ptrType(Interface)), true)[1] || $assertType(_ref, ($ptrType(Chan)), true)[1]) { - t = _ref; - return true; - } else if ($assertType(_ref, ($ptrType(Struct)), true)[1]) { - t = _ref.$val; - _ref$1 = t.fields; - _i = 0; - while (_i < _ref$1.$length) { - f = ((_i < 0 || _i >= _ref$1.$length) ? $throwRuntimeError("index out of range") : _ref$1.$array[_ref$1.$offset + _i]); - if (!Comparable(f.object.typ)) { - return false; - } - _i++; - } - return true; - } else if ($assertType(_ref, ($ptrType(Array)), true)[1]) { - t = _ref.$val; - return Comparable(t.elem); + unparen = function(x) { + var _tuple, p, ok; + _tuple = $assertType(x, ($ptrType(ast.ParenExpr)), true); p = _tuple[0]; ok = _tuple[1]; + if (ok) { + return unparen(p.X); } - return false; + return x; }; - hasNil = function(typ) { - var t, _ref; - _ref = typ.Underlying(); - if ($assertType(_ref, ($ptrType(Basic)), true)[1]) { - t = _ref.$val; - return t.kind === 18; - } else if ($assertType(_ref, ($ptrType(Slice)), true)[1] || $assertType(_ref, ($ptrType(Pointer)), true)[1] || $assertType(_ref, ($ptrType(Signature)), true)[1] || $assertType(_ref, ($ptrType(Interface)), true)[1] || $assertType(_ref, ($ptrType(Map)), true)[1] || $assertType(_ref, ($ptrType(Chan)), true)[1]) { - t = _ref; + Checker.Ptr.prototype.complexArg = function(x) { + var check, _tuple, t; + check = this; + _tuple = $assertType(x.typ.Underlying(), ($ptrType(Basic)), true); t = _tuple[0]; + if (!(t === ($ptrType(Basic)).nil) && (!(((t.info & 8) === 0)) || (t.kind === 20) || (t.kind === 21))) { return true; } + check.invalidArg(x.pos(), "%s must be a float32, float64, or an untyped non-complex numeric constant", new ($sliceType($emptyInterface))([x])); return false; }; - Identical = $pkg.Identical = function(x, y) { - return identical(x, y, ($ptrType(ifacePair)).nil); - }; - ifacePair.Ptr.prototype.identical = function(q) { - var p; - p = this; - return p.x === q.x && p.y === q.y || p.x === q.y && p.y === q.x; - }; - ifacePair.prototype.identical = function(q) { return this.$val.identical(q); }; - identical = function(x, y, p) { - var x$1, _ref, _tuple, y$1, ok, _tuple$1, y$2, ok$1, x$2, x$3, _tuple$2, y$3, ok$2, _tuple$3, y$4, ok$3, _ref$1, _i, i, f, x$4, g, _tuple$4, y$5, ok$4, _tuple$5, y$6, ok$5, _ref$2, _i$1, i$1, v, x$5, w, _tuple$6, y$7, ok$6, _tuple$7, y$8, ok$7, a, b, q, _ref$3, _i$2, i$2, f$1, g$1, _tuple$8, y$9, ok$8, _tuple$9, y$10, ok$9, _tuple$10, y$11, ok$10; - if ($interfaceIsEqual(x, y)) { - return true; - } - _ref = x; - if ($assertType(_ref, ($ptrType(Basic)), true)[1]) { - x$1 = _ref.$val; - _tuple = $assertType(y, ($ptrType(Basic)), true); y$1 = _tuple[0]; ok = _tuple[1]; - if (ok) { - return x$1.kind === y$1.kind; - } - } else if ($assertType(_ref, ($ptrType(Array)), true)[1]) { - x$1 = _ref.$val; - _tuple$1 = $assertType(y, ($ptrType(Array)), true); y$2 = _tuple$1[0]; ok$1 = _tuple$1[1]; - if (ok$1) { - return (x$2 = x$1.len, x$3 = y$2.len, (x$2.$high === x$3.$high && x$2.$low === x$3.$low)) && identical(x$1.elem, y$2.elem, p); - } - } else if ($assertType(_ref, ($ptrType(Slice)), true)[1]) { - x$1 = _ref.$val; - _tuple$2 = $assertType(y, ($ptrType(Slice)), true); y$3 = _tuple$2[0]; ok$2 = _tuple$2[1]; - if (ok$2) { - return identical(x$1.elem, y$3.elem, p); - } - } else if ($assertType(_ref, ($ptrType(Struct)), true)[1]) { - x$1 = _ref.$val; - _tuple$3 = $assertType(y, ($ptrType(Struct)), true); y$4 = _tuple$3[0]; ok$3 = _tuple$3[1]; - if (ok$3) { - if (x$1.NumFields() === y$4.NumFields()) { - _ref$1 = x$1.fields; - _i = 0; - while (_i < _ref$1.$length) { - i = _i; - f = ((_i < 0 || _i >= _ref$1.$length) ? $throwRuntimeError("index out of range") : _ref$1.$array[_ref$1.$offset + _i]); - g = (x$4 = y$4.fields, ((i < 0 || i >= x$4.$length) ? $throwRuntimeError("index out of range") : x$4.$array[x$4.$offset + i])); - if (!(f.anonymous === g.anonymous) || !(x$1.Tag(i) === y$4.Tag(i)) || !f.object.sameId(g.object.pkg, g.object.name) || !identical(f.object.typ, g.object.typ, p)) { - return false; - } - _i++; - } - return true; - } - } - } else if ($assertType(_ref, ($ptrType(Pointer)), true)[1]) { - x$1 = _ref.$val; - _tuple$4 = $assertType(y, ($ptrType(Pointer)), true); y$5 = _tuple$4[0]; ok$4 = _tuple$4[1]; - if (ok$4) { - return identical(x$1.base, y$5.base, p); - } - } else if ($assertType(_ref, ($ptrType(Tuple)), true)[1]) { - x$1 = _ref.$val; - _tuple$5 = $assertType(y, ($ptrType(Tuple)), true); y$6 = _tuple$5[0]; ok$5 = _tuple$5[1]; - if (ok$5) { - if (x$1.Len() === y$6.Len()) { - if (!(x$1 === ($ptrType(Tuple)).nil)) { - _ref$2 = x$1.vars; - _i$1 = 0; - while (_i$1 < _ref$2.$length) { - i$1 = _i$1; - v = ((_i$1 < 0 || _i$1 >= _ref$2.$length) ? $throwRuntimeError("index out of range") : _ref$2.$array[_ref$2.$offset + _i$1]); - w = (x$5 = y$6.vars, ((i$1 < 0 || i$1 >= x$5.$length) ? $throwRuntimeError("index out of range") : x$5.$array[x$5.$offset + i$1])); - if (!identical(v.object.typ, w.object.typ, p)) { - return false; - } - _i$1++; - } - } - return true; - } - } - } else if ($assertType(_ref, ($ptrType(Signature)), true)[1]) { - x$1 = _ref.$val; - _tuple$6 = $assertType(y, ($ptrType(Signature)), true); y$7 = _tuple$6[0]; ok$6 = _tuple$6[1]; - if (ok$6) { - return x$1.variadic === y$7.variadic && identical(x$1.params, y$7.params, p) && identical(x$1.results, y$7.results, p); - } - } else if ($assertType(_ref, ($ptrType(Interface)), true)[1]) { - x$1 = _ref.$val; - _tuple$7 = $assertType(y, ($ptrType(Interface)), true); y$8 = _tuple$7[0]; ok$7 = _tuple$7[1]; - if (ok$7) { - a = x$1.allMethods; - b = y$8.allMethods; - if (a.$length === b.$length) { - q = new ifacePair.Ptr(x$1, y$8, p); - while (!(p === ($ptrType(ifacePair)).nil)) { - if (p.identical(q)) { - return true; - } - p = p.prev; - } - _ref$3 = a; - _i$2 = 0; - while (_i$2 < _ref$3.$length) { - i$2 = _i$2; - f$1 = ((_i$2 < 0 || _i$2 >= _ref$3.$length) ? $throwRuntimeError("index out of range") : _ref$3.$array[_ref$3.$offset + _i$2]); - g$1 = ((i$2 < 0 || i$2 >= b.$length) ? $throwRuntimeError("index out of range") : b.$array[b.$offset + i$2]); - if (!(f$1.object.Id() === g$1.object.Id()) || !identical(f$1.object.typ, g$1.object.typ, q)) { - return false; - } - _i$2++; - } - return true; + Checker.prototype.complexArg = function(x) { return this.$val.complexArg(x); }; + Checker.Ptr.prototype.call = function(x, e) { + var check, _ref, T, n, _ref$1, x$1, x$2, x$3, id, _tuple, sig, _tuple$1, arg, n$1, _ref$2, x$4; + check = this; + check.exprOrType(x, e.Fun); + _ref = x.mode; + if (_ref === 0) { + check.use(e.Args); + x.mode = 0; + x.expr = e; + return 2; + } else if (_ref === 3) { + T = x.typ; + x.mode = 0; + n = e.Args.$length; + _ref$1 = n; + if (_ref$1 === 0) { + check.errorf(e.Rparen, "missing argument in conversion to %s", new ($sliceType($emptyInterface))([T])); + } else if (_ref$1 === 1) { + check.expr(x, (x$1 = e.Args, ((0 < 0 || 0 >= x$1.$length) ? $throwRuntimeError("index out of range") : x$1.$array[x$1.$offset + 0]))); + if (!((x.mode === 0))) { + check.conversion(x, T); } + } else { + check.errorf((x$2 = e.Args, x$3 = n - 1 >> 0, ((x$3 < 0 || x$3 >= x$2.$length) ? $throwRuntimeError("index out of range") : x$2.$array[x$2.$offset + x$3])).Pos(), "too many arguments in conversion to %s", new ($sliceType($emptyInterface))([T])); } - } else if ($assertType(_ref, ($ptrType(Map)), true)[1]) { - x$1 = _ref.$val; - _tuple$8 = $assertType(y, ($ptrType(Map)), true); y$9 = _tuple$8[0]; ok$8 = _tuple$8[1]; - if (ok$8) { - return identical(x$1.key, y$9.key, p) && identical(x$1.elem, y$9.elem, p); - } - } else if ($assertType(_ref, ($ptrType(Chan)), true)[1]) { - x$1 = _ref.$val; - _tuple$9 = $assertType(y, ($ptrType(Chan)), true); y$10 = _tuple$9[0]; ok$9 = _tuple$9[1]; - if (ok$9) { - return (x$1.dir === y$10.dir) && identical(x$1.elem, y$10.elem, p); + x.expr = e; + return 0; + } else if (_ref === 2) { + id = x.id; + if (!check.builtin(x, e, id)) { + x.mode = 0; } - } else if ($assertType(_ref, ($ptrType(Named)), true)[1]) { - x$1 = _ref.$val; - _tuple$10 = $assertType(y, ($ptrType(Named)), true); y$11 = _tuple$10[0]; ok$10 = _tuple$10[1]; - if (ok$10) { - return x$1.obj === y$11.obj; + x.expr = e; + if (!((x.mode === 0)) && !((x.mode === 4))) { + check.context.hasCallOrRecv = true; } + return ((id < 0 || id >= predeclaredFuncs.length) ? $throwRuntimeError("index out of range") : predeclaredFuncs[id]).kind; } else { - x$1 = _ref; - unreachable(); - } - return false; - }; - defaultType = function(typ) { - var _tuple, t, ok, _ref; - _tuple = $assertType(typ, ($ptrType(Basic)), true); t = _tuple[0]; ok = _tuple[1]; - if (ok) { - _ref = t.kind; - if (_ref === 19) { - return $pkg.Typ[1]; - } else if (_ref === 20) { - return $pkg.Typ[2]; - } else if (_ref === 21) { - return $pkg.UniverseRune; - } else if (_ref === 22) { - return $pkg.Typ[14]; - } else if (_ref === 23) { - return $pkg.Typ[16]; - } else if (_ref === 24) { - return $pkg.Typ[17]; + _tuple = $assertType(x.typ.Underlying(), ($ptrType(Signature)), true); sig = _tuple[0]; + if (sig === ($ptrType(Signature)).nil) { + check.invalidOp(x.pos(), "cannot call non-function %s", new ($sliceType($emptyInterface))([x])); + x.mode = 0; + x.expr = e; + return 2; + } + _tuple$1 = unpack((function(x$4, i) { + var x$5; + check.expr(x$4, (x$5 = e.Args, ((i < 0 || i >= x$5.$length) ? $throwRuntimeError("index out of range") : x$5.$array[x$5.$offset + i]))); + }), e.Args.$length, false); arg = _tuple$1[0]; n$1 = _tuple$1[1]; + if (arg === $throwNilPointerError) { + x.mode = 0; + x.expr = e; + return 2; + } + check.arguments$(x, e, sig, arg, n$1); + _ref$2 = sig.results.Len(); + if (_ref$2 === 0) { + x.mode = 1; + } else if (_ref$2 === 1) { + x.mode = 7; + x.typ = (x$4 = sig.results.vars, ((0 < 0 || 0 >= x$4.$length) ? $throwRuntimeError("index out of range") : x$4.$array[x$4.$offset + 0])).object.typ; + } else { + x.mode = 7; + x.typ = sig.results; } + x.expr = e; + check.context.hasCallOrRecv = true; + return 2; } - return typ; - }; - declInfo.Ptr.prototype.hasInitializer = function() { - var d; - d = this; - return !($interfaceIsEqual(d.init, $ifaceNil)) || !(d.fdecl === ($ptrType(ast.FuncDecl)).nil) && !(d.fdecl.Body === ($ptrType(ast.BlockStmt)).nil); }; - declInfo.prototype.hasInitializer = function() { return this.$val.hasInitializer(); }; - declInfo.Ptr.prototype.addDep = function(obj) { - var d, m, _key$2; - d = this; - m = d.deps; - if (m === false) { - m = new $Map(); - d.deps = m; + Checker.prototype.call = function(x, e) { return this.$val.call(x, e); }; + Checker.Ptr.prototype.use = function(arg) { + var check, x, _ref, _i, e; + check = this; + x = new operand.Ptr(); $copy(x, new operand.Ptr(), operand); + _ref = arg; + _i = 0; + while (_i < _ref.$length) { + e = ((_i < 0 || _i >= _ref.$length) ? $throwRuntimeError("index out of range") : _ref.$array[_ref.$offset + _i]); + check.rawExpr(x, e, $ifaceNil); + _i++; } - _key$2 = obj; (m || $throwRuntimeError("assignment to entry in nil map"))[_key$2.$key()] = { k: _key$2, v: true }; }; - declInfo.prototype.addDep = function(obj) { return this.$val.addDep(obj); }; - Checker.Ptr.prototype.arityMatch = function(s, init$1) { - var check, l, r, x, n, x$1, n$1; + Checker.prototype.use = function(arg) { return this.$val.use(arg); }; + Checker.Ptr.prototype.useGetter = function(get, n) { + var check, x, i; check = this; - l = s.Names.$length; - r = s.Values.$length; - if (!(init$1 === ($ptrType(ast.ValueSpec)).nil)) { - r = init$1.Values.$length; + x = new operand.Ptr(); $copy(x, new operand.Ptr(), operand); + i = 0; + while (i < n) { + get(x, i); + i = i + (1) >> 0; } - if (init$1 === ($ptrType(ast.ValueSpec)).nil && (r === 0)) { - if ($interfaceIsEqual(s.Type, $ifaceNil)) { - check.errorf(s.Pos(), "missing type or init expr", new ($sliceType($emptyInterface))([])); + }; + Checker.prototype.useGetter = function(get, n) { return this.$val.useGetter(get, n); }; + unpack = function(get, n, allowCommaOk) { + var x0, _tuple, t, ok, a; + if (n === 1) { + x0 = new operand.Ptr(); $copy(x0, new operand.Ptr(), operand); + get(x0, 0); + if (x0.mode === 0) { + return [$throwNilPointerError, 0, false]; } - } else if (l < r) { - if (l < s.Values.$length) { - n = (x = s.Values, ((l < 0 || l >= x.$length) ? $throwRuntimeError("index out of range") : x.$array[x.$offset + l])); - check.errorf(n.Pos(), "extra init expr %s", new ($sliceType($emptyInterface))([n])); - } else { - check.errorf(s.Pos(), "extra init expr at %s", new ($sliceType($emptyInterface))([new token.Pos(init$1.Pos())])); + _tuple = $assertType(x0.typ, ($ptrType(Tuple)), true); t = _tuple[0]; ok = _tuple[1]; + if (ok) { + return [(function(x, i) { + x.mode = 7; + x.expr = x0.expr; + x.typ = t.At(i).object.typ; + }), t.Len(), false]; } - } else if (l > r && (!(init$1 === ($ptrType(ast.ValueSpec)).nil) || !((r === 1)))) { - n$1 = (x$1 = s.Names, ((r < 0 || r >= x$1.$length) ? $throwRuntimeError("index out of range") : x$1.$array[x$1.$offset + r])); - check.errorf(n$1.Pos(), "missing init expr for %s", new ($sliceType($emptyInterface))([n$1])); + if ((x0.mode === 6) || (x0.mode === 8)) { + if (allowCommaOk) { + a = $toNativeArray("Interface", [x0.typ, $pkg.Typ[19]]); + return [(function(x, i) { + x.mode = 7; + x.expr = x0.expr; + x.typ = ((i < 0 || i >= a.length) ? $throwRuntimeError("index out of range") : a[i]); + }), 2, true]; + } + x0.mode = 7; + } + return [(function(x, i) { + if (!((i === 0))) { + unreachable(); + } + $copy(x, x0, operand); + }), 1, false]; } + return [get, n, false]; }; - Checker.prototype.arityMatch = function(s, init$1) { return this.$val.arityMatch(s, init$1); }; - validatedImportPath = function(path$1) { - var _tuple, s, err, _ref, _i, _rune, r; - _tuple = strconv.Unquote(path$1); s = _tuple[0]; err = _tuple[1]; - if (!($interfaceIsEqual(err, $ifaceNil))) { - return ["", err]; - } - if (s === "") { - return ["", fmt.Errorf("empty string", new ($sliceType($emptyInterface))([]))]; + Checker.Ptr.prototype.arguments$ = function(x, call, sig, arg, n) { + var check, passSlice, i; + check = this; + passSlice = false; + if ((new token.Pos(call.Ellipsis)).IsValid()) { + if (sig.variadic) { + passSlice = true; + } else { + check.errorf(call.Ellipsis, "cannot use ... in call to non-variadic %s", new ($sliceType($emptyInterface))([call.Fun])); + } } - _ref = s; - _i = 0; - while (_i < _ref.length) { - _rune = $decodeRune(_ref, _i); - r = _rune[0]; - if (!unicode.IsGraphic(r) || unicode.IsSpace(r) || strings.ContainsRune("!\"#$%&'()*,:;<=>?[\\]^{|}`\xEF\xBF\xBD", r)) { - return [s, fmt.Errorf("invalid character %#U", new ($sliceType($emptyInterface))([new $Int32(r)]))]; + i = 0; + while (i < n) { + arg(x, i); + if (!((x.mode === 0))) { + check.argument(sig, i, x, passSlice && (i === (n - 1 >> 0))); } - _i += _rune[1]; + i = i + (1) >> 0; + } + if (sig.variadic) { + n = n + (1) >> 0; + } + if (n < sig.params.Len()) { + check.errorf(call.Rparen, "too few arguments in call to %s", new ($sliceType($emptyInterface))([call.Fun])); } - return [s, $ifaceNil]; }; - Checker.Ptr.prototype.declarePkgObj = function(ident, obj, d) { - var check, _key$2; + Checker.prototype.arguments$ = function(x, call, sig, arg, n) { return this.$val.arguments$(x, call, sig, arg, n); }; + Checker.Ptr.prototype.argument = function(sig, i, x, passSlice) { + var check, n, typ, x$1, x$2, x$3, _tuple, ok; check = this; - assert(ident.Name === obj.Name()); - if (ident.Name === "init") { - check.errorf(ident.Pos(), "cannot declare init - must be func", new ($sliceType($emptyInterface))([])); + n = sig.params.Len(); + typ = $ifaceNil; + if (i < n) { + typ = (x$1 = sig.params.vars, ((i < 0 || i >= x$1.$length) ? $throwRuntimeError("index out of range") : x$1.$array[x$1.$offset + i])).object.typ; + } else if (sig.variadic) { + typ = (x$2 = sig.params.vars, x$3 = n - 1 >> 0, ((x$3 < 0 || x$3 >= x$2.$length) ? $throwRuntimeError("index out of range") : x$2.$array[x$2.$offset + x$3])).object.typ; + } else { + check.errorf(x.pos(), "too many arguments", new ($sliceType($emptyInterface))([])); return; } - check.declare(check.pkg.scope, ident, obj); - _key$2 = obj; (check.objMap || $throwRuntimeError("assignment to entry in nil map"))[_key$2.$key()] = { k: _key$2, v: d }; - }; - Checker.prototype.declarePkgObj = function(ident, obj, d) { return this.$val.declarePkgObj(ident, obj, d); }; - Checker.Ptr.prototype.collectObjects = function() { - var check, pkg, importer, pkgImports, _ref, _i, imp, _key$2, _ref$1, _i$1, fileNo, file, x, fileScope, _ref$2, _i$2, decl, d, _ref$3, last, _ref$4, _i$3, iota, spec, s, _ref$5, imp$1, _tuple, path$1, err, err$1, _tuple$1, _entry, _key$3, name, obj, _ref$6, _i$4, _keys, _entry$1, obj$1, x$1, posSet, x$2, _key$4, _ref$7, _ref$8, _i$5, i, name$1, obj$2, init$1, x$3, d$1, lhs, d1, x$4, _ref$9, _i$6, i$1, name$2, obj$3, d$2, init$2, x$5, obj$4, name$3, obj$5, list, typ, _tuple$2, ptr, _tuple$3, base, info, _key$5, _ref$10, _i$7, scope, _ref$11, _i$8, _keys$1, _entry$2, obj$6, alt, _tuple$4, pkg$1, ok; - check = this; - pkg = check.pkg; - importer = check.conf.Import; - if (importer === $throwNilPointerError) { - if ($pkg.DefaultImport === $throwNilPointerError) { - $panic(new $String("no Config.Import or DefaultImport (missing import _ \"code.google.com/p/go.tools/go/gcimporter\"?)")); + if (passSlice) { + if (!((i === (n - 1 >> 0)))) { + check.errorf(x.pos(), "can only use ... with matching parameter", new ($sliceType($emptyInterface))([])); + return; } - importer = $pkg.DefaultImport; + _tuple = $assertType(x.typ.Underlying(), ($ptrType(Slice)), true); ok = _tuple[1]; + if (!ok) { + check.errorf(x.pos(), "cannot use %s as parameter of type %s", new ($sliceType($emptyInterface))([x, typ])); + return; + } + } else if (sig.variadic && i >= (n - 1 >> 0)) { + typ = $assertType(typ, ($ptrType(Slice))).elem; } - pkgImports = new $Map(); - _ref = pkg.imports; - _i = 0; - while (_i < _ref.$length) { - imp = ((_i < 0 || _i >= _ref.$length) ? $throwRuntimeError("index out of range") : _ref.$array[_ref.$offset + _i]); - _key$2 = imp; (pkgImports || $throwRuntimeError("assignment to entry in nil map"))[_key$2.$key()] = { k: _key$2, v: true }; - _i++; + if (!check.assignment(x, typ) && !((x.mode === 0))) { + check.errorf(x.pos(), "cannot pass argument %s to parameter of type %s", new ($sliceType($emptyInterface))([x, typ])); } - _ref$1 = check.files; - _i$1 = 0; - while (_i$1 < _ref$1.$length) { - fileNo = _i$1; - file = ((_i$1 < 0 || _i$1 >= _ref$1.$length) ? $throwRuntimeError("index out of range") : _ref$1.$array[_ref$1.$offset + _i$1]); - check.recordDef(file.Name, $ifaceNil); - fileScope = (x = check.fileScopes, ((fileNo < 0 || fileNo >= x.$length) ? $throwRuntimeError("index out of range") : x.$array[x.$offset + fileNo])); - _ref$2 = file.Decls; - _i$2 = 0; - while (_i$2 < _ref$2.$length) { - decl = ((_i$2 < 0 || _i$2 >= _ref$2.$length) ? $throwRuntimeError("index out of range") : _ref$2.$array[_ref$2.$offset + _i$2]); - _ref$3 = decl; - if ($assertType(_ref$3, ($ptrType(ast.BadDecl)), true)[1]) { - d = _ref$3.$val; - } else if ($assertType(_ref$3, ($ptrType(ast.GenDecl)), true)[1]) { - d = _ref$3.$val; - last = ($ptrType(ast.ValueSpec)).nil; - _ref$4 = d.Specs; - _i$3 = 0; - while (_i$3 < _ref$4.$length) { - iota = _i$3; - spec = ((_i$3 < 0 || _i$3 >= _ref$4.$length) ? $throwRuntimeError("index out of range") : _ref$4.$array[_ref$4.$offset + _i$3]); - _ref$5 = spec; - if ($assertType(_ref$5, ($ptrType(ast.ImportSpec)), true)[1]) { - s = _ref$5.$val; - imp$1 = ($ptrType(Package)).nil; - _tuple = validatedImportPath(s.Path.Value); path$1 = _tuple[0]; err = _tuple[1]; - if (!($interfaceIsEqual(err, $ifaceNil))) { - check.errorf(s.Path.Pos(), "invalid import path (%s)", new ($sliceType($emptyInterface))([err])); - _i$3++; - continue; - } - if (path$1 === "C" && check.conf.FakeImportC) { - imp$1 = NewPackage("C", "C"); - imp$1.fake = true; - } else { - err$1 = $ifaceNil; - _tuple$1 = importer(check.conf.Packages, path$1); imp$1 = _tuple$1[0]; err$1 = _tuple$1[1]; - if (imp$1 === ($ptrType(Package)).nil && $interfaceIsEqual(err$1, $ifaceNil)) { - err$1 = errors.New("Config.Import returned nil but no error"); - } - if (!($interfaceIsEqual(err$1, $ifaceNil))) { - check.errorf(s.Path.Pos(), "could not import %s (%s)", new ($sliceType($emptyInterface))([new $String(path$1), err$1])); - _i$3++; - continue; - } - } - if (!(_entry = pkgImports[imp$1.$key()], _entry !== undefined ? _entry.v : false)) { - _key$3 = imp$1; (pkgImports || $throwRuntimeError("assignment to entry in nil map"))[_key$3.$key()] = { k: _key$3, v: true }; - if (!(imp$1 === $pkg.Unsafe)) { - pkg.imports = $append(pkg.imports, imp$1); - } - } - name = imp$1.name; - if (!(s.Name === ($ptrType(ast.Ident)).nil)) { - name = s.Name.Name; - if (name === "init") { - check.errorf(s.Name.Pos(), "cannot declare init - must be func", new ($sliceType($emptyInterface))([])); - _i$3++; - continue; - } - } - obj = NewPkgName(s.Pos(), pkg, name, imp$1); - if (!(s.Name === ($ptrType(ast.Ident)).nil)) { - check.recordDef(s.Name, obj); - } else { - check.recordImplicit(s, obj); - } - if (name === ".") { - _ref$6 = imp$1.scope.elems; - _i$4 = 0; - _keys = $keys(_ref$6); - while (_i$4 < _keys.length) { - _entry$1 = _ref$6[_keys[_i$4]]; - if (_entry$1 === undefined) { - _i$4++; - continue; - } - obj$1 = _entry$1.v; - if (obj$1.Exported()) { - check.declare(fileScope, ($ptrType(ast.Ident)).nil, obj$1); - check.recordImplicit(s, obj$1); - } - _i$4++; - } - posSet = (x$1 = check.dotImports, ((fileNo < 0 || fileNo >= x$1.$length) ? $throwRuntimeError("index out of range") : x$1.$array[x$1.$offset + fileNo])); - if (posSet === false) { - posSet = new $Map(); - (x$2 = check.dotImports, (fileNo < 0 || fileNo >= x$2.$length) ? $throwRuntimeError("index out of range") : x$2.$array[x$2.$offset + fileNo] = posSet); - } - _key$4 = imp$1; (posSet || $throwRuntimeError("assignment to entry in nil map"))[_key$4.$key()] = { k: _key$4, v: s.Pos() }; - } else { - check.declare(fileScope, ($ptrType(ast.Ident)).nil, obj); - } - } else if ($assertType(_ref$5, ($ptrType(ast.ValueSpec)), true)[1]) { - s = _ref$5.$val; - _ref$7 = d.Tok; - if (_ref$7 === 64) { - if (!($interfaceIsEqual(s.Type, $ifaceNil)) || s.Values.$length > 0) { - last = s; - } else if (last === ($ptrType(ast.ValueSpec)).nil) { - last = new ast.ValueSpec.Ptr(); - } - _ref$8 = s.Names; - _i$5 = 0; - while (_i$5 < _ref$8.$length) { - i = _i$5; - name$1 = ((_i$5 < 0 || _i$5 >= _ref$8.$length) ? $throwRuntimeError("index out of range") : _ref$8.$array[_ref$8.$offset + _i$5]); - obj$2 = NewConst(name$1.Pos(), pkg, name$1.Name, $ifaceNil, exact.MakeInt64(new $Int64(0, iota))); - init$1 = $ifaceNil; - if (i < last.Values.$length) { - init$1 = (x$3 = last.Values, ((i < 0 || i >= x$3.$length) ? $throwRuntimeError("index out of range") : x$3.$array[x$3.$offset + i])); - } - d$1 = new declInfo.Ptr(fileScope, ($sliceType(($ptrType(Var)))).nil, last.Type, init$1, ($ptrType(ast.FuncDecl)).nil, false, 0); - check.declarePkgObj(name$1, obj$2, d$1); - _i$5++; - } - check.arityMatch(s, last); - } else if (_ref$7 === 85) { - lhs = ($sliceType(($ptrType(Var)))).make(s.Names.$length); - d1 = ($ptrType(declInfo)).nil; - if (s.Values.$length === 1) { - d1 = new declInfo.Ptr(fileScope, lhs, s.Type, (x$4 = s.Values, ((0 < 0 || 0 >= x$4.$length) ? $throwRuntimeError("index out of range") : x$4.$array[x$4.$offset + 0])), ($ptrType(ast.FuncDecl)).nil, false, 0); - } - _ref$9 = s.Names; - _i$6 = 0; - while (_i$6 < _ref$9.$length) { - i$1 = _i$6; - name$2 = ((_i$6 < 0 || _i$6 >= _ref$9.$length) ? $throwRuntimeError("index out of range") : _ref$9.$array[_ref$9.$offset + _i$6]); - obj$3 = NewVar(name$2.Pos(), pkg, name$2.Name, $ifaceNil); - (i$1 < 0 || i$1 >= lhs.$length) ? $throwRuntimeError("index out of range") : lhs.$array[lhs.$offset + i$1] = obj$3; - d$2 = d1; - if (d$2 === ($ptrType(declInfo)).nil) { - init$2 = $ifaceNil; - if (i$1 < s.Values.$length) { - init$2 = (x$5 = s.Values, ((i$1 < 0 || i$1 >= x$5.$length) ? $throwRuntimeError("index out of range") : x$5.$array[x$5.$offset + i$1])); - } - d$2 = new declInfo.Ptr(fileScope, ($sliceType(($ptrType(Var)))).nil, s.Type, init$2, ($ptrType(ast.FuncDecl)).nil, false, 0); - } - check.declarePkgObj(name$2, obj$3, d$2); - _i$6++; - } - check.arityMatch(s, ($ptrType(ast.ValueSpec)).nil); - } else { - check.invalidAST(s.Pos(), "invalid token %s", new ($sliceType($emptyInterface))([new token.Token(d.Tok)])); - } - } else if ($assertType(_ref$5, ($ptrType(ast.TypeSpec)), true)[1]) { - s = _ref$5.$val; - obj$4 = NewTypeName(s.Name.Pos(), pkg, s.Name.Name, $ifaceNil); - check.declarePkgObj(s.Name, obj$4, new declInfo.Ptr(fileScope, ($sliceType(($ptrType(Var)))).nil, s.Type, $ifaceNil, ($ptrType(ast.FuncDecl)).nil, false, 0)); - } else { - s = _ref$5; - check.invalidAST(s.Pos(), "unknown ast.Spec node %T", new ($sliceType($emptyInterface))([s])); - } - _i$3++; - } - } else if ($assertType(_ref$3, ($ptrType(ast.FuncDecl)), true)[1]) { - d = _ref$3.$val; - name$3 = d.Name.Name; - obj$5 = NewFunc(d.Name.Pos(), pkg, name$3, ($ptrType(Signature)).nil); - if (d.Recv === ($ptrType(ast.FieldList)).nil) { - if (name$3 === "init") { - obj$5.object.parent = pkg.scope; - check.recordDef(d.Name, obj$5); - if (d.Body === ($ptrType(ast.BlockStmt)).nil) { - check.softErrorf(obj$5.object.pos, "missing function body", new ($sliceType($emptyInterface))([])); - } - } else { - check.declare(pkg.scope, d.Name, obj$5); - } - } else { - check.recordDef(d.Name, obj$5); - list = d.Recv.List; - if (list.$length > 0) { - typ = ((0 < 0 || 0 >= list.$length) ? $throwRuntimeError("index out of range") : list.$array[list.$offset + 0]).Type; - _tuple$2 = $assertType(typ, ($ptrType(ast.StarExpr)), true); ptr = _tuple$2[0]; - if (!(ptr === ($ptrType(ast.StarExpr)).nil)) { - typ = ptr.X; - } - _tuple$3 = $assertType(typ, ($ptrType(ast.Ident)), true); base = _tuple$3[0]; - if (!(base === ($ptrType(ast.Ident)).nil) && !(base.Name === "_")) { - check.assocMethod(base.Name, obj$5); - } - } + }; + Checker.prototype.argument = function(sig, i, x, passSlice) { return this.$val.argument(sig, i, x, passSlice); }; + Checker.Ptr.prototype.selector = function(x, e) { + var $this = this, $args = arguments, $s = 0, check, obj, index, indirect, sel, _tuple, ident, ok, _tuple$1, pkg, exp, exp$1, _ref, _tuple$2, _tuple$3, m, params, sig, obj$1, _ref$1, sig$1; + /* */ while (true) { switch ($s) { case 0: + check = $this; + obj = $ifaceNil; + index = ($sliceType($Int)).nil; + indirect = false; + sel = e.Sel.Name; + _tuple = $assertType(e.X, ($ptrType(ast.Ident)), true); ident = _tuple[0]; ok = _tuple[1]; + /* if (ok) { */ if (ok) {} else { $s = 2; continue; } + _tuple$1 = $assertType(check.context.scope.LookupParent(ident.Name), ($ptrType(PkgName)), true); pkg = _tuple$1[0]; + /* if (!(pkg === ($ptrType(PkgName)).nil)) { */ if (!(pkg === ($ptrType(PkgName)).nil)) {} else { $s = 3; continue; } + check.recordUse(ident, pkg); + pkg.object.used = true; + exp = pkg.imported.scope.Lookup(sel); + /* if ($interfaceIsEqual(exp, $ifaceNil)) { */ if ($interfaceIsEqual(exp, $ifaceNil)) {} else { $s = 4; continue; } + if (!pkg.imported.fake) { + check.errorf(e.Pos(), "%s not declared by package %s", new ($sliceType($emptyInterface))([new $String(sel), ident])); } - info = new declInfo.Ptr(fileScope, ($sliceType(($ptrType(Var)))).nil, $ifaceNil, $ifaceNil, d, false, 0); - _key$5 = obj$5; (check.objMap || $throwRuntimeError("assignment to entry in nil map"))[_key$5.$key()] = { k: _key$5, v: info }; + /* goto Error */ $s = 1; continue; + /* } */ case 4: + if (!exp.Exported()) { + check.errorf(e.Pos(), "%s not exported by package %s", new ($sliceType($emptyInterface))([new $String(sel), ident])); + } + check.recordUse(e.Sel, exp); + _ref = exp; + if ($assertType(_ref, ($ptrType(Const)), true)[1]) { + exp$1 = _ref.$val; + assert(!($interfaceIsEqual(exp$1.Val(), $ifaceNil))); + x.mode = 4; + x.typ = exp$1.object.typ; + x.val = exp$1.val; + } else if ($assertType(_ref, ($ptrType(TypeName)), true)[1]) { + exp$1 = _ref.$val; + x.mode = 3; + x.typ = exp$1.object.typ; + } else if ($assertType(_ref, ($ptrType(Var)), true)[1]) { + exp$1 = _ref.$val; + x.mode = 5; + x.typ = exp$1.object.typ; + } else if ($assertType(_ref, ($ptrType(Func)), true)[1]) { + exp$1 = _ref.$val; + x.mode = 7; + x.typ = exp$1.object.typ; + } else if ($assertType(_ref, ($ptrType(Builtin)), true)[1]) { + exp$1 = _ref.$val; + x.mode = 2; + x.typ = exp$1.object.typ; + x.id = exp$1.id; + } else { + exp$1 = _ref; + unreachable(); + } + x.expr = e; + return; + /* } */ case 3: + /* } */ case 2: + check.exprOrType(x, e.X); + /* if (x.mode === 0) { */ if (x.mode === 0) {} else { $s = 5; continue; } + /* goto Error */ $s = 1; continue; + /* } */ case 5: + _tuple$2 = LookupFieldOrMethod(x.typ, x.mode === 5, check.pkg, sel); obj = _tuple$2[0]; index = _tuple$2[1]; indirect = _tuple$2[2]; + /* if ($interfaceIsEqual(obj, $ifaceNil)) { */ if ($interfaceIsEqual(obj, $ifaceNil)) {} else { $s = 6; continue; } + if (!(index === ($sliceType($Int)).nil)) { + check.invalidOp(e.Pos(), "ambiguous selector %s", new ($sliceType($emptyInterface))([new $String(sel)])); + } else if (indirect) { + check.invalidOp(e.Pos(), "%s is not in method set of %s", new ($sliceType($emptyInterface))([new $String(sel), x.typ])); + } else { + check.invalidOp(e.Pos(), "%s has no field or method %s", new ($sliceType($emptyInterface))([x, new $String(sel)])); + } + /* goto Error */ $s = 1; continue; + /* } */ case 6: + /* if (x.mode === 3) { */ if (x.mode === 3) {} else { $s = 7; continue; } + _tuple$3 = $assertType(obj, ($ptrType(Func)), true); m = _tuple$3[0]; + /* if (m === ($ptrType(Func)).nil) { */ if (m === ($ptrType(Func)).nil) {} else { $s = 9; continue; } + check.invalidOp(e.Pos(), "%s has no method %s", new ($sliceType($emptyInterface))([x, new $String(sel)])); + /* goto Error */ $s = 1; continue; + /* } */ case 9: + check.recordSelection(e, 2, x.typ, m, index, indirect); + params = ($sliceType(($ptrType(Var)))).nil; + sig = $assertType(m.object.typ, ($ptrType(Signature))); + if (!(sig.params === ($ptrType(Tuple)).nil)) { + params = sig.params.vars; + } + x.mode = 7; + x.typ = new Signature.Ptr(($ptrType(Scope)).nil, ($ptrType(Var)).nil, NewTuple($appendSlice(new ($sliceType(($ptrType(Var))))([NewVar(0, check.pkg, "", x.typ)]), params)), sig.results, sig.variadic); + check.addDeclDep(m); + /* } else { */ $s = 8; continue; case 7: + _ref$1 = obj; + if ($assertType(_ref$1, ($ptrType(Var)), true)[1]) { + obj$1 = _ref$1.$val; + check.recordSelection(e, 0, x.typ, obj$1, index, indirect); + if ((x.mode === 5) || indirect) { + x.mode = 5; } else { - d = _ref$3; - check.invalidAST(d.Pos(), "unknown ast.Decl node %T", new ($sliceType($emptyInterface))([d])); + x.mode = 7; } - _i$2++; + x.typ = obj$1.object.typ; + } else if ($assertType(_ref$1, ($ptrType(Func)), true)[1]) { + obj$1 = _ref$1.$val; + check.recordSelection(e, 1, x.typ, obj$1, index, indirect); + x.mode = 7; + sig$1 = new Signature.Ptr(); $copy(sig$1, $assertType(obj$1.object.typ, ($ptrType(Signature))), Signature); + sig$1.recv = ($ptrType(Var)).nil; + x.typ = sig$1; + check.addDeclDep(obj$1); + } else { + obj$1 = _ref$1; + unreachable(); } - _i$1++; + /* } */ case 8: + x.expr = e; + return; + /* Error: */ case 1: + x.mode = 0; + x.expr = e; + /* */ case -1: } return; } + }; + Checker.prototype.selector = function(x, e) { return this.$val.selector(x, e); }; + Checker.Ptr.prototype.addDeclDep = function(to) { + var check, from, _tuple, _entry, found; + check = this; + from = check.context.decl; + if (from === ($ptrType(declInfo)).nil) { + return; } - _ref$10 = check.fileScopes; - _i$7 = 0; - while (_i$7 < _ref$10.$length) { - scope = ((_i$7 < 0 || _i$7 >= _ref$10.$length) ? $throwRuntimeError("index out of range") : _ref$10.$array[_ref$10.$offset + _i$7]); - _ref$11 = scope.elems; - _i$8 = 0; - _keys$1 = $keys(_ref$11); - while (_i$8 < _keys$1.length) { - _entry$2 = _ref$11[_keys$1[_i$8]]; - if (_entry$2 === undefined) { - _i$8++; - continue; - } - obj$6 = _entry$2.v; - alt = pkg.scope.Lookup(obj$6.Name()); - if (!($interfaceIsEqual(alt, $ifaceNil))) { - _tuple$4 = $assertType(obj$6, ($ptrType(PkgName)), true); pkg$1 = _tuple$4[0]; ok = _tuple$4[1]; - if (ok) { - check.errorf(alt.Pos(), "%s already declared through import of %s", new ($sliceType($emptyInterface))([new $String(alt.Name()), pkg$1.Imported()])); - check.reportAltDecl(pkg$1); - } else { - check.errorf(alt.Pos(), "%s already declared through dot-import of %s", new ($sliceType($emptyInterface))([new $String(alt.Name()), obj$6.Pkg()])); - check.reportAltDecl(obj$6); - } - } - _i$8++; - } - _i$7++; + _tuple = (_entry = check.objMap[to.$key()], _entry !== undefined ? [_entry.v, true] : [($ptrType(declInfo)).nil, false]); found = _tuple[1]; + if (!found) { + return; } + from.addDep(to); }; - Checker.prototype.collectObjects = function() { return this.$val.collectObjects(); }; - Checker.Ptr.prototype.packageObjects = function(objList) { - var check, _ref, _i, obj, _tuple, obj$1, typePath, _ref$1, _i$1, obj$2; + Checker.prototype.addDeclDep = function(to) { return this.$val.addDeclDep(to); }; + Checker.Ptr.prototype.assocMethod = function(tname, meth) { + var check, m, _entry, _key$2; check = this; - _ref = objList; + m = check.methods; + if (m === false) { + m = new $Map(); + check.methods = m; + } + _key$2 = tname; (m || $throwRuntimeError("assignment to entry in nil map"))[_key$2] = { k: _key$2, v: $append((_entry = m[tname], _entry !== undefined ? _entry.v : ($sliceType(($ptrType(Func)))).nil), meth) }; + }; + Checker.prototype.assocMethod = function(tname, meth) { return this.$val.assocMethod(tname, meth); }; + Checker.Ptr.prototype.rememberUntyped = function(e, lhs, mode, typ, val) { + var check, m, _key$2; + check = this; + m = check.untyped; + if (m === false) { + m = new $Map(); + check.untyped = m; + } + _key$2 = e; (m || $throwRuntimeError("assignment to entry in nil map"))[_key$2.$key()] = { k: _key$2, v: new exprInfo.Ptr(lhs, mode, typ, val) }; + }; + Checker.prototype.rememberUntyped = function(e, lhs, mode, typ, val) { return this.$val.rememberUntyped(e, lhs, mode, typ, val); }; + Checker.Ptr.prototype.later = function(name, decl, sig, body) { + var check; + check = this; + check.funcs = $append(check.funcs, new funcInfo.Ptr(name, decl, sig, body)); + }; + Checker.prototype.later = function(name, decl, sig, body) { return this.$val.later(name, decl, sig, body); }; + Checker.Ptr.prototype.delay = function(f) { + var check; + check = this; + check.delayed = $append(check.delayed, f); + }; + Checker.prototype.delay = function(f) { return this.$val.delay(f); }; + NewChecker = $pkg.NewChecker = function(conf, fset, pkg, info) { + if (conf === ($ptrType(Config)).nil) { + conf = new Config.Ptr(); + } + if (conf.Packages === false) { + conf.Packages = new $Map(); + } + if (info === ($ptrType(Info)).nil) { + info = new Info.Ptr(); + } + return new Checker.Ptr(conf, fset, pkg, info, new $Map(), ($sliceType(($ptrType(ast.File)))).nil, ($sliceType(($ptrType(Scope)))).nil, ($sliceType(($mapType(($ptrType(Package)), token.Pos)))).nil, $ifaceNil, false, false, ($sliceType(funcInfo)).nil, ($sliceType(($funcType([], [], false)))).nil, new context.Ptr(), 0); + }; + Checker.Ptr.prototype.initFiles = function(files) { + var check, pkg, _ref, _i, i, file, name, _ref$1, comment, pos, fileScope; + check = this; + check.files = ($sliceType(($ptrType(ast.File)))).nil; + check.fileScopes = ($sliceType(($ptrType(Scope)))).nil; + check.dotImports = ($sliceType(($mapType(($ptrType(Package)), token.Pos)))).nil; + check.firstErr = $ifaceNil; + check.methods = false; + check.untyped = false; + check.funcs = ($sliceType(funcInfo)).nil; + check.delayed = ($sliceType(($funcType([], [], false)))).nil; + pkg = check.pkg; + _ref = files; _i = 0; while (_i < _ref.$length) { - obj = ((_i < 0 || _i >= _ref.$length) ? $throwRuntimeError("index out of range") : _ref.$array[_ref.$offset + _i]); - _tuple = $assertType(obj, ($ptrType(TypeName)), true); obj$1 = _tuple[0]; - if (!(obj$1 === ($ptrType(TypeName)).nil) && !($interfaceIsEqual(obj$1.object.typ, $ifaceNil))) { - check.addMethodDecls(obj$1); + i = _i; + file = ((_i < 0 || _i >= _ref.$length) ? $throwRuntimeError("index out of range") : _ref.$array[_ref.$offset + _i]); + name = file.Name.Name; + _ref$1 = pkg.name; + if (_ref$1 === "") { + if (!(name === "_")) { + pkg.name = name; + } else { + check.errorf(file.Name.Pos(), "invalid package name _", new ($sliceType($emptyInterface))([])); + } + check.files = $append(check.files, file); + comment = ""; + pos = file.Pos(); + if ((new token.Pos(pos)).IsValid()) { + comment = "file " + check.fset.File(pos).Name(); + } else { + comment = fmt.Sprintf("file[%d]", new ($sliceType($emptyInterface))([new $Int(i)])); + } + fileScope = NewScope(pkg.scope, comment); + check.recordScope(file, fileScope); + check.fileScopes = $append(check.fileScopes, fileScope); + check.dotImports = $append(check.dotImports, false); + } else if (_ref$1 === name) { + check.files = $append(check.files, file); + comment = ""; + pos = file.Pos(); + if ((new token.Pos(pos)).IsValid()) { + comment = "file " + check.fset.File(pos).Name(); + } else { + comment = fmt.Sprintf("file[%d]", new ($sliceType($emptyInterface))([new $Int(i)])); + } + fileScope = NewScope(pkg.scope, comment); + check.recordScope(file, fileScope); + check.fileScopes = $append(check.fileScopes, fileScope); + check.dotImports = $append(check.dotImports, false); + } else { + check.errorf(file.Package, "package %s; expected %s", new ($sliceType($emptyInterface))([new $String(name), new $String(pkg.name)])); } _i++; } - typePath = ($sliceType(($ptrType(TypeName)))).make(0, 8); - _ref$1 = objList; - _i$1 = 0; - while (_i$1 < _ref$1.$length) { - obj$2 = ((_i$1 < 0 || _i$1 >= _ref$1.$length) ? $throwRuntimeError("index out of range") : _ref$1.$array[_ref$1.$offset + _i$1]); - check.objDecl(obj$2, ($ptrType(Named)).nil, typePath); - _i$1++; + }; + Checker.prototype.initFiles = function(files) { return this.$val.initFiles(files); }; + Checker.Ptr.prototype.handleBailout = function(err) { + var check, p, _ref; + check = this; + _ref = $recover(); + if (_ref === $ifaceNil || $assertType(_ref, bailout, true)[1]) { + p = _ref; + err.$set(check.firstErr); + } else { + p = _ref; + $panic(p); } - check.methods = false; }; - Checker.prototype.packageObjects = function(objList) { return this.$val.packageObjects(objList); }; - Checker.Ptr.prototype.functionBodies = function() { - var check, _ref, _i, f; + Checker.prototype.handleBailout = function(err) { return this.$val.handleBailout(err); }; + Checker.Ptr.prototype.Files = function(files) { + var err = $ifaceNil, $deferred = [], $err = null, check, _ref, _i, f; + /* */ try { $deferFrames.push($deferred); check = this; - _ref = check.funcs; + $deferred.push([$methodVal(check, "handleBailout"), [new ($ptrType($error))(function() { return err; }, function($v) { err = $v; })]]); + check.initFiles(files); + check.collectObjects(); + check.packageObjects(check.resolveOrder()); + check.functionBodies(); + check.initOrder(); + check.unusedImports(); + _ref = check.delayed; _i = 0; while (_i < _ref.$length) { - f = new funcInfo.Ptr(); $copy(f, ((_i < 0 || _i >= _ref.$length) ? $throwRuntimeError("index out of range") : _ref.$array[_ref.$offset + _i]), funcInfo); - check.funcBody(f.decl, f.name, f.sig, f.body); + f = ((_i < 0 || _i >= _ref.$length) ? $throwRuntimeError("index out of range") : _ref.$array[_ref.$offset + _i]); + f(); _i++; } + check.recordUntyped(); + check.pkg.complete = true; + return err; + /* */ } catch(err) { $err = err; } finally { $deferFrames.pop(); $callDeferred($deferred, $err); return err; } }; - Checker.prototype.functionBodies = function() { return this.$val.functionBodies(); }; - Checker.Ptr.prototype.unusedImports = function() { - var check, _ref, _i, i, scope, usedDotImports, _ref$1, _i$1, _keys, _entry, obj, obj$1, _ref$2, path$1, base, _key$2, _ref$3, x, _i$2, _keys$1, _entry$1, pkg, pos, _entry$2; + Checker.prototype.Files = function(files) { return this.$val.Files(files); }; + Checker.Ptr.prototype.recordUntyped = function() { + var check, _ref, _i, _keys, _entry, x, info; check = this; - if (check.conf.IgnoreFuncBodies) { + if (true && check.Info.Types === false) { return; } - _ref = check.fileScopes; + _ref = check.untyped; _i = 0; - while (_i < _ref.$length) { - i = _i; - scope = ((_i < 0 || _i >= _ref.$length) ? $throwRuntimeError("index out of range") : _ref.$array[_ref.$offset + _i]); - usedDotImports = false; - _ref$1 = scope.elems; - _i$1 = 0; - _keys = $keys(_ref$1); - while (_i$1 < _keys.length) { - _entry = _ref$1[_keys[_i$1]]; - if (_entry === undefined) { - _i$1++; - continue; - } - obj = _entry.v; - _ref$2 = obj; - if ($assertType(_ref$2, ($ptrType(PkgName)), true)[1]) { - obj$1 = _ref$2.$val; - if (!obj$1.object.used) { - path$1 = obj$1.imported.path; - base = path.Base(path$1); - if (obj$1.object.name === base) { - check.softErrorf(obj$1.object.pos, "%q imported but not used", new ($sliceType($emptyInterface))([new $String(path$1)])); - } else { - check.softErrorf(obj$1.object.pos, "%q imported but not used as %s", new ($sliceType($emptyInterface))([new $String(path$1), new $String(obj$1.object.name)])); - } - } - } else { - obj$1 = _ref$2; - if (obj$1.isUsed()) { - if (usedDotImports === false) { - usedDotImports = new $Map(); - } - _key$2 = obj$1.Pkg(); (usedDotImports || $throwRuntimeError("assignment to entry in nil map"))[_key$2.$key()] = { k: _key$2, v: true }; - } - } - _i$1++; - } - _ref$3 = (x = check.dotImports, ((i < 0 || i >= x.$length) ? $throwRuntimeError("index out of range") : x.$array[x.$offset + i])); - _i$2 = 0; - _keys$1 = $keys(_ref$3); - while (_i$2 < _keys$1.length) { - _entry$1 = _ref$3[_keys$1[_i$2]]; - if (_entry$1 === undefined) { - _i$2++; - continue; - } - pkg = _entry$1.k; - pos = _entry$1.v; - if (!(_entry$2 = usedDotImports[pkg.$key()], _entry$2 !== undefined ? _entry$2.v : false)) { - check.softErrorf(pos, "%q imported but not used", new ($sliceType($emptyInterface))([new $String(pkg.path)])); - } - _i$2++; + _keys = $keys(_ref); + while (_i < _keys.length) { + _entry = _ref[_keys[_i]]; + if (_entry === undefined) { + _i++; + continue; } + x = _entry.k; + info = new exprInfo.Ptr(); $copy(info, _entry.v, exprInfo); + check.recordTypeAndValue(x, info.mode, info.typ, info.val); _i++; } }; - Checker.prototype.unusedImports = function() { return this.$val.unusedImports(); }; - Checker.Ptr.prototype.isTerminating = function(s, label) { - var check, s$1, _ref, _tuple, call, _tuple$1, id, obj, _tuple$2, b, _ref$1, _i, s$2, cc; + Checker.prototype.recordUntyped = function() { return this.$val.recordUntyped(); }; + Checker.Ptr.prototype.recordTypeAndValue = function(x, mode, typ, val) { + var check, m, _key$2; check = this; - _ref = s; - if ($assertType(_ref, ($ptrType(ast.BadStmt)), true)[1] || $assertType(_ref, ($ptrType(ast.DeclStmt)), true)[1] || $assertType(_ref, ($ptrType(ast.EmptyStmt)), true)[1] || $assertType(_ref, ($ptrType(ast.SendStmt)), true)[1] || $assertType(_ref, ($ptrType(ast.IncDecStmt)), true)[1] || $assertType(_ref, ($ptrType(ast.AssignStmt)), true)[1] || $assertType(_ref, ($ptrType(ast.GoStmt)), true)[1] || $assertType(_ref, ($ptrType(ast.DeferStmt)), true)[1] || $assertType(_ref, ($ptrType(ast.RangeStmt)), true)[1]) { - s$1 = _ref; - } else if ($assertType(_ref, ($ptrType(ast.LabeledStmt)), true)[1]) { - s$1 = _ref.$val; - return check.isTerminating(s$1.Stmt, s$1.Label.Name); - } else if ($assertType(_ref, ($ptrType(ast.ExprStmt)), true)[1]) { - s$1 = _ref.$val; - _tuple = $assertType(unparen(s$1.X), ($ptrType(ast.CallExpr)), true); call = _tuple[0]; - if (!(call === ($ptrType(ast.CallExpr)).nil)) { - _tuple$1 = $assertType(call.Fun, ($ptrType(ast.Ident)), true); id = _tuple$1[0]; - if (!(id === ($ptrType(ast.Ident)).nil)) { - obj = check.context.scope.LookupParent(id.Name); - if (!($interfaceIsEqual(obj, $ifaceNil))) { - _tuple$2 = $assertType(obj, ($ptrType(Builtin)), true); b = _tuple$2[0]; - if (!(b === ($ptrType(Builtin)).nil) && (b.id === 10)) { - return true; - } - } + assert(!($interfaceIsEqual(x, $ifaceNil))); + assert(!($interfaceIsEqual(typ, $ifaceNil))); + if (mode === 0) { + return; + } + assert(!($interfaceIsEqual(typ, $ifaceNil))); + if (mode === 4) { + assert(!($interfaceIsEqual(val, $ifaceNil))); + assert($interfaceIsEqual(typ, $pkg.Typ[0]) || isConstType(typ)); + } + m = check.Info.Types; + if (!(m === false)) { + _key$2 = x; (m || $throwRuntimeError("assignment to entry in nil map"))[_key$2.$key()] = { k: _key$2, v: new TypeAndValue.Ptr(mode, typ, val) }; + } + }; + Checker.prototype.recordTypeAndValue = function(x, mode, typ, val) { return this.$val.recordTypeAndValue(x, mode, typ, val); }; + Checker.Ptr.prototype.recordBuiltinType = function(f, sig) { + var check, p, _ref; + check = this; + while (true) { + check.recordTypeAndValue(f, 2, sig, $ifaceNil); + _ref = f; + if ($assertType(_ref, ($ptrType(ast.Ident)), true)[1]) { + p = _ref.$val; + return; + } else if ($assertType(_ref, ($ptrType(ast.ParenExpr)), true)[1]) { + p = _ref.$val; + f = p.X; + } else { + p = _ref; + unreachable(); + } + } + }; + Checker.prototype.recordBuiltinType = function(f, sig) { return this.$val.recordBuiltinType(f, sig); }; + Checker.Ptr.prototype.recordCommaOkTypes = function(x, a) { + var check, m, _entry, tv, pos, _key$2, _tuple, p; + check = this; + assert(!($interfaceIsEqual(x, $ifaceNil))); + if ($interfaceIsEqual(a[0], $ifaceNil) || $interfaceIsEqual(a[1], $ifaceNil)) { + return; + } + assert(isTyped(a[0]) && isTyped(a[1]) && isBoolean(a[1])); + m = check.Info.Types; + if (!(m === false)) { + while (true) { + tv = new TypeAndValue.Ptr(); $copy(tv, (_entry = m[x.$key()], _entry !== undefined ? _entry.v : new TypeAndValue.Ptr()), TypeAndValue); + assert(!($interfaceIsEqual(tv.Type, $ifaceNil))); + pos = x.Pos(); + tv.Type = NewTuple(new ($sliceType(($ptrType(Var))))([NewVar(pos, check.pkg, "", a[0]), NewVar(pos, check.pkg, "", a[1])])); + _key$2 = x; (m || $throwRuntimeError("assignment to entry in nil map"))[_key$2.$key()] = { k: _key$2, v: tv }; + _tuple = $assertType(x, ($ptrType(ast.ParenExpr)), true); p = _tuple[0]; + if (p === ($ptrType(ast.ParenExpr)).nil) { + break; } + x = p.X; } - } else if ($assertType(_ref, ($ptrType(ast.ReturnStmt)), true)[1]) { - s$1 = _ref.$val; - return true; - } else if ($assertType(_ref, ($ptrType(ast.BranchStmt)), true)[1]) { - s$1 = _ref.$val; - if ((s$1.Tok === 73) || (s$1.Tok === 69)) { - return true; + } + }; + Checker.prototype.recordCommaOkTypes = function(x, a) { return this.$val.recordCommaOkTypes(x, a); }; + Checker.Ptr.prototype.recordDef = function(id, obj) { + var check, m, _key$2; + check = this; + assert(!(id === ($ptrType(ast.Ident)).nil)); + m = check.Info.Defs; + if (!(m === false)) { + _key$2 = id; (m || $throwRuntimeError("assignment to entry in nil map"))[_key$2.$key()] = { k: _key$2, v: obj }; + } + }; + Checker.prototype.recordDef = function(id, obj) { return this.$val.recordDef(id, obj); }; + Checker.Ptr.prototype.recordUse = function(id, obj) { + var check, m, _key$2; + check = this; + assert(!(id === ($ptrType(ast.Ident)).nil)); + assert(!($interfaceIsEqual(obj, $ifaceNil))); + m = check.Info.Uses; + if (!(m === false)) { + _key$2 = id; (m || $throwRuntimeError("assignment to entry in nil map"))[_key$2.$key()] = { k: _key$2, v: obj }; + } + }; + Checker.prototype.recordUse = function(id, obj) { return this.$val.recordUse(id, obj); }; + Checker.Ptr.prototype.recordImplicit = function(node, obj) { + var check, m, _key$2; + check = this; + assert(!($interfaceIsEqual(node, $ifaceNil))); + assert(!($interfaceIsEqual(obj, $ifaceNil))); + m = check.Info.Implicits; + if (!(m === false)) { + _key$2 = node; (m || $throwRuntimeError("assignment to entry in nil map"))[_key$2.$key()] = { k: _key$2, v: obj }; + } + }; + Checker.prototype.recordImplicit = function(node, obj) { return this.$val.recordImplicit(node, obj); }; + Checker.Ptr.prototype.recordSelection = function(x, kind, recv, obj, index, indirect) { + var check, m, _key$2; + check = this; + assert(!($interfaceIsEqual(obj, $ifaceNil)) && ($interfaceIsEqual(recv, $ifaceNil) || index.$length > 0)); + check.recordUse(x.Sel, obj); + m = check.Info.Selections; + if (!(m === false)) { + _key$2 = x; (m || $throwRuntimeError("assignment to entry in nil map"))[_key$2.$key()] = { k: _key$2, v: new Selection.Ptr(kind, recv, obj, index, indirect) }; + } + }; + Checker.prototype.recordSelection = function(x, kind, recv, obj, index, indirect) { return this.$val.recordSelection(x, kind, recv, obj, index, indirect); }; + Checker.Ptr.prototype.recordScope = function(node, scope) { + var check, m, _key$2; + check = this; + assert(!($interfaceIsEqual(node, $ifaceNil))); + assert(!(scope === ($ptrType(Scope)).nil)); + m = check.Info.Scopes; + if (!(m === false)) { + _key$2 = node; (m || $throwRuntimeError("assignment to entry in nil map"))[_key$2.$key()] = { k: _key$2, v: scope }; + } + }; + Checker.prototype.recordScope = function(node, scope) { return this.$val.recordScope(node, scope); }; + Checker.Ptr.prototype.conversion = function(x, T) { + var check, constArg, ok, t, codepoint, _tuple, i, ok$1, final$1; + check = this; + constArg = x.mode === 4; + ok = false; + if (constArg && isConstType(T)) { + t = $assertType(T.Underlying(), ($ptrType(Basic))); + if (representableConst(x.val, check.conf, t.kind, new ($ptrType(exact.Value))(function() { return this.$target.val; }, function($v) { this.$target.val = $v; }, x))) { + ok = true; + } else if (x.isInteger() && isString(t)) { + codepoint = new $Int64(-1, 4294967295); + _tuple = exact.Int64Val(x.val); i = _tuple[0]; ok$1 = _tuple[1]; + if (ok$1) { + codepoint = i; + } + x.val = exact.MakeString($encodeRune(codepoint.$low)); + ok = true; } - } else if ($assertType(_ref, ($ptrType(ast.BlockStmt)), true)[1]) { - s$1 = _ref.$val; - return check.isTerminatingList(s$1.List, ""); - } else if ($assertType(_ref, ($ptrType(ast.IfStmt)), true)[1]) { - s$1 = _ref.$val; - if (!($interfaceIsEqual(s$1.Else, $ifaceNil)) && check.isTerminating(s$1.Body, "") && check.isTerminating(s$1.Else, "")) { - return true; + } else if (x.convertibleTo(check.conf, T)) { + x.mode = 7; + ok = true; + } + if (!ok) { + check.errorf(x.pos(), "cannot convert %s to %s", new ($sliceType($emptyInterface))([x, T])); + x.mode = 0; + return; + } + final$1 = x.typ; + if (isUntyped(x.typ)) { + final$1 = T; + if (isInterface(T) || constArg && !isConstType(T)) { + final$1 = defaultType(x.typ); } - } else if ($assertType(_ref, ($ptrType(ast.SwitchStmt)), true)[1]) { - s$1 = _ref.$val; - return check.isTerminatingSwitch(s$1.Body, label); - } else if ($assertType(_ref, ($ptrType(ast.TypeSwitchStmt)), true)[1]) { - s$1 = _ref.$val; - return check.isTerminatingSwitch(s$1.Body, label); - } else if ($assertType(_ref, ($ptrType(ast.SelectStmt)), true)[1]) { - s$1 = _ref.$val; - _ref$1 = s$1.Body.List; - _i = 0; - while (_i < _ref$1.$length) { - s$2 = ((_i < 0 || _i >= _ref$1.$length) ? $throwRuntimeError("index out of range") : _ref$1.$array[_ref$1.$offset + _i]); - cc = $assertType(s$2, ($ptrType(ast.CommClause))); - if (!check.isTerminatingList(cc.Body, "") || hasBreakList(cc.Body, label, true)) { - return false; + check.updateExprType(x.expr, final$1, true); + } + x.typ = T; + }; + Checker.prototype.conversion = function(x, T) { return this.$val.conversion(x, T); }; + operand.Ptr.prototype.convertibleTo = function(conf, T) { + var x, V, Vu, Tu, _tuple, V$1, ok, _tuple$1, T$1, ok$1; + x = this; + if (x.assignableTo(conf, T)) { + return true; + } + V = x.typ; + Vu = V.Underlying(); + Tu = T.Underlying(); + if (Identical(Vu, Tu)) { + return true; + } + _tuple = $assertType(V, ($ptrType(Pointer)), true); V$1 = _tuple[0]; ok = _tuple[1]; + if (ok) { + _tuple$1 = $assertType(T, ($ptrType(Pointer)), true); T$1 = _tuple$1[0]; ok$1 = _tuple$1[1]; + if (ok$1) { + if (Identical(V$1.base.Underlying(), T$1.base.Underlying())) { + return true; } - _i++; } + } + if ((isInteger(V) || isFloat(V)) && (isInteger(T) || isFloat(T))) { + return true; + } + if (isComplex(V) && isComplex(T)) { + return true; + } + if ((isInteger(V) || isBytesOrRunes(Vu)) && isString(T)) { + return true; + } + if (isString(V) && isBytesOrRunes(Tu)) { + return true; + } + if ((isPointer(Vu) || isUintptr(Vu)) && isUnsafePointer(T)) { + return true; + } + if (isUnsafePointer(V) && (isPointer(Tu) || isUintptr(Tu))) { return true; - } else if ($assertType(_ref, ($ptrType(ast.ForStmt)), true)[1]) { - s$1 = _ref.$val; - if ($interfaceIsEqual(s$1.Cond, $ifaceNil) && !hasBreak(s$1.Body, label, true)) { - return true; - } - } else { - s$1 = _ref; - unreachable(); } return false; }; - Checker.prototype.isTerminating = function(s, label) { return this.$val.isTerminating(s, label); }; - Checker.Ptr.prototype.isTerminatingList = function(list, label) { - var check, n, x; + operand.prototype.convertibleTo = function(conf, T) { return this.$val.convertibleTo(conf, T); }; + isUintptr = function(typ) { + var _tuple, t, ok; + _tuple = $assertType(typ.Underlying(), ($ptrType(Basic)), true); t = _tuple[0]; ok = _tuple[1]; + return ok && (t.kind === 12); + }; + isUnsafePointer = function(typ) { + var _tuple, t, ok; + _tuple = $assertType(typ.Underlying(), ($ptrType(Basic)), true); t = _tuple[0]; ok = _tuple[1]; + return ok && (t.kind === 18); + }; + isPointer = function(typ) { + var _tuple, ok; + _tuple = $assertType(typ.Underlying(), ($ptrType(Pointer)), true); ok = _tuple[1]; + return ok; + }; + isBytesOrRunes = function(typ) { + var _tuple, s, ok, _tuple$1, t, ok$1; + _tuple = $assertType(typ, ($ptrType(Slice)), true); s = _tuple[0]; ok = _tuple[1]; + if (ok) { + _tuple$1 = $assertType(s.elem.Underlying(), ($ptrType(Basic)), true); t = _tuple$1[0]; ok$1 = _tuple$1[1]; + return ok$1 && ((t.kind === 8) || (t.kind === 5)); + } + return false; + }; + Checker.Ptr.prototype.reportAltDecl = function(obj) { + var check, pos; check = this; - n = list.$length; - return n > 0 && check.isTerminating((x = n - 1 >> 0, ((x < 0 || x >= list.$length) ? $throwRuntimeError("index out of range") : list.$array[list.$offset + x])), label); + pos = obj.Pos(); + if ((new token.Pos(pos)).IsValid()) { + check.errorf(pos, "\tother declaration of %s", new ($sliceType($emptyInterface))([new $String(obj.Name())])); + } }; - Checker.prototype.isTerminatingList = function(list, label) { return this.$val.isTerminatingList(list, label); }; - Checker.Ptr.prototype.isTerminatingSwitch = function(body, label) { - var check, hasDefault, _ref, _i, s, cc; + Checker.prototype.reportAltDecl = function(obj) { return this.$val.reportAltDecl(obj); }; + Checker.Ptr.prototype.declare = function(scope, id, obj) { + var check, alt; check = this; - hasDefault = false; - _ref = body.List; - _i = 0; - while (_i < _ref.$length) { - s = ((_i < 0 || _i >= _ref.$length) ? $throwRuntimeError("index out of range") : _ref.$array[_ref.$offset + _i]); - cc = $assertType(s, ($ptrType(ast.CaseClause))); - if (cc.List === ($sliceType(ast.Expr)).nil) { - hasDefault = true; - } - if (!check.isTerminatingList(cc.Body, "") || hasBreakList(cc.Body, label, true)) { - return false; + if (!(obj.Name() === "_")) { + alt = scope.Insert(obj); + if (!($interfaceIsEqual(alt, $ifaceNil))) { + check.errorf(obj.Pos(), "%s redeclared in this block", new ($sliceType($emptyInterface))([new $String(obj.Name())])); + check.reportAltDecl(alt); + return; } - _i++; } - return hasDefault; + if (!(id === ($ptrType(ast.Ident)).nil)) { + check.recordDef(id, obj); + } }; - Checker.prototype.isTerminatingSwitch = function(body, label) { return this.$val.isTerminatingSwitch(body, label); }; - hasBreak = function(s, label, implicit) { - var s$1, _ref; - _ref = s; - if ($assertType(_ref, ($ptrType(ast.BadStmt)), true)[1] || $assertType(_ref, ($ptrType(ast.DeclStmt)), true)[1] || $assertType(_ref, ($ptrType(ast.EmptyStmt)), true)[1] || $assertType(_ref, ($ptrType(ast.ExprStmt)), true)[1] || $assertType(_ref, ($ptrType(ast.SendStmt)), true)[1] || $assertType(_ref, ($ptrType(ast.IncDecStmt)), true)[1] || $assertType(_ref, ($ptrType(ast.AssignStmt)), true)[1] || $assertType(_ref, ($ptrType(ast.GoStmt)), true)[1] || $assertType(_ref, ($ptrType(ast.DeferStmt)), true)[1] || $assertType(_ref, ($ptrType(ast.ReturnStmt)), true)[1]) { - s$1 = _ref; - } else if ($assertType(_ref, ($ptrType(ast.LabeledStmt)), true)[1]) { - s$1 = _ref.$val; - return hasBreak(s$1.Stmt, label, implicit); - } else if ($assertType(_ref, ($ptrType(ast.BranchStmt)), true)[1]) { - s$1 = _ref.$val; - if (s$1.Tok === 61) { - if (s$1.Label === ($ptrType(ast.Ident)).nil) { - return implicit; - } - if (s$1.Label.Name === label) { - return true; - } - } - } else if ($assertType(_ref, ($ptrType(ast.BlockStmt)), true)[1]) { - s$1 = _ref.$val; - return hasBreakList(s$1.List, label, implicit); - } else if ($assertType(_ref, ($ptrType(ast.IfStmt)), true)[1]) { - s$1 = _ref.$val; - if (hasBreak(s$1.Body, label, implicit) || !($interfaceIsEqual(s$1.Else, $ifaceNil)) && hasBreak(s$1.Else, label, implicit)) { - return true; - } - } else if ($assertType(_ref, ($ptrType(ast.CaseClause)), true)[1]) { - s$1 = _ref.$val; - return hasBreakList(s$1.Body, label, implicit); - } else if ($assertType(_ref, ($ptrType(ast.SwitchStmt)), true)[1]) { - s$1 = _ref.$val; - if (!(label === "") && hasBreak(s$1.Body, label, false)) { - return true; - } - } else if ($assertType(_ref, ($ptrType(ast.TypeSwitchStmt)), true)[1]) { - s$1 = _ref.$val; - if (!(label === "") && hasBreak(s$1.Body, label, false)) { - return true; - } - } else if ($assertType(_ref, ($ptrType(ast.CommClause)), true)[1]) { - s$1 = _ref.$val; - return hasBreakList(s$1.Body, label, implicit); - } else if ($assertType(_ref, ($ptrType(ast.SelectStmt)), true)[1]) { - s$1 = _ref.$val; - if (!(label === "") && hasBreak(s$1.Body, label, false)) { - return true; - } - } else if ($assertType(_ref, ($ptrType(ast.ForStmt)), true)[1]) { - s$1 = _ref.$val; - if (!(label === "") && hasBreak(s$1.Body, label, false)) { - return true; - } - } else if ($assertType(_ref, ($ptrType(ast.RangeStmt)), true)[1]) { - s$1 = _ref.$val; - if (!(label === "") && hasBreak(s$1.Body, label, false)) { - return true; - } + Checker.prototype.declare = function(scope, id, obj) { return this.$val.declare(scope, id, obj); }; + Checker.Ptr.prototype.objDecl = function(obj, def$1, path$1) { + var $deferred = [], $err = null, check, _entry, d, obj$1, _ref; + /* */ try { $deferFrames.push($deferred); + check = this; + if (!($interfaceIsEqual(obj.Type(), $ifaceNil))) { + return; + } + d = (_entry = check.objMap[obj.$key()], _entry !== undefined ? _entry.v : ($ptrType(declInfo)).nil); + if (d === ($ptrType(declInfo)).nil) { + check.dump("%s: %s should have been declared", new ($sliceType($emptyInterface))([new token.Pos(obj.Pos()), new $String(obj.Name())])); + unreachable(); + } + $deferred.push([(function(ctxt) { + $copy(check.context, ctxt, context); + }), [$clone(check.context, context)]]); + $copy(check.context, new context.Ptr(($ptrType(declInfo)).nil, d.file, $ifaceNil, ($ptrType(Signature)).nil, false, false), context); + _ref = obj; + if ($assertType(_ref, ($ptrType(Const)), true)[1]) { + obj$1 = _ref.$val; + check.context.decl = d; + check.constDecl(obj$1, d.typ, d.init); + } else if ($assertType(_ref, ($ptrType(Var)), true)[1]) { + obj$1 = _ref.$val; + check.context.decl = d; + check.varDecl(obj$1, d.lhs, d.typ, d.init); + } else if ($assertType(_ref, ($ptrType(TypeName)), true)[1]) { + obj$1 = _ref.$val; + check.typeDecl(obj$1, d.typ, def$1, path$1); + } else if ($assertType(_ref, ($ptrType(Func)), true)[1]) { + obj$1 = _ref.$val; + check.funcDecl(obj$1, d); } else { - s$1 = _ref; + obj$1 = _ref; unreachable(); } - return false; + /* */ } catch(err) { $err = err; } finally { $deferFrames.pop(); $callDeferred($deferred, $err); } }; - hasBreakList = function(list, label, implicit) { - var _ref, _i, s; - _ref = list; - _i = 0; - while (_i < _ref.$length) { - s = ((_i < 0 || _i >= _ref.$length) ? $throwRuntimeError("index out of range") : _ref.$array[_ref.$offset + _i]); - if (hasBreak(s, label, implicit)) { - return true; + Checker.prototype.objDecl = function(obj, def$1, path$1) { return this.$val.objDecl(obj, def$1, path$1); }; + Checker.Ptr.prototype.constDecl = function(obj, typ, init$1) { + var $deferred = [], $err = null, check, t, x; + /* */ try { $deferFrames.push($deferred); + check = this; + assert($interfaceIsEqual(obj.object.typ, $ifaceNil)); + if (obj.visited) { + obj.object.typ = $pkg.Typ[0]; + return; + } + obj.visited = true; + assert($interfaceIsEqual(check.context.iota, $ifaceNil)); + check.context.iota = obj.val; + $deferred.push([(function() { + check.context.iota = $ifaceNil; + }), []]); + obj.val = exact.MakeUnknown(); + if (!($interfaceIsEqual(typ, $ifaceNil))) { + t = check.typ(typ); + if (!isConstType(t)) { + check.errorf(typ.Pos(), "invalid constant type %s", new ($sliceType($emptyInterface))([t])); + obj.object.typ = $pkg.Typ[0]; + return; } - _i++; + obj.object.typ = t; } - return false; + x = new operand.Ptr(); $copy(x, new operand.Ptr(), operand); + if (!($interfaceIsEqual(init$1, $ifaceNil))) { + check.expr(x, init$1); + } + check.initConst(obj, x); + /* */ } catch(err) { $err = err; } finally { $deferFrames.pop(); $callDeferred($deferred, $err); } }; - NewScope = $pkg.NewScope = function(parent, comment) { - var s; - s = new Scope.Ptr(parent, ($sliceType(($ptrType(Scope)))).nil, comment, false); - if (!(parent === ($ptrType(Scope)).nil) && !(parent === $pkg.Universe)) { - parent.children = $append(parent.children, s); + Checker.prototype.constDecl = function(obj, typ, init$1) { return this.$val.constDecl(obj, typ, init$1); }; + Checker.Ptr.prototype.varDecl = function(obj, lhs, typ, init$1) { + var check, x; + check = this; + assert($interfaceIsEqual(obj.object.typ, $ifaceNil)); + if (obj.visited) { + obj.object.typ = $pkg.Typ[0]; + return; } - return s; + obj.visited = true; + assert($interfaceIsEqual(check.context.iota, $ifaceNil)); + if (!($interfaceIsEqual(typ, $ifaceNil))) { + obj.object.typ = check.typ(typ); + } + if ($interfaceIsEqual(init$1, $ifaceNil)) { + if ($interfaceIsEqual(typ, $ifaceNil)) { + obj.object.typ = $pkg.Typ[0]; + } + return; + } + if (lhs === ($sliceType(($ptrType(Var)))).nil || (lhs.$length === 1)) { + assert(lhs === ($sliceType(($ptrType(Var)))).nil || ((0 < 0 || 0 >= lhs.$length) ? $throwRuntimeError("index out of range") : lhs.$array[lhs.$offset + 0]) === obj); + x = new operand.Ptr(); $copy(x, new operand.Ptr(), operand); + check.expr(x, init$1); + check.initVar(obj, x, false); + return; + } + check.initVars(lhs, new ($sliceType(ast.Expr))([init$1]), 0); }; - Scope.Ptr.prototype.Parent = function() { - var s; - s = this; - return s.parent; + Checker.prototype.varDecl = function(obj, lhs, typ, init$1) { return this.$val.varDecl(obj, lhs, typ, init$1); }; + underlying = function(typ) { + var _tuple, n; + while (true) { + _tuple = $assertType(typ, ($ptrType(Named)), true); n = _tuple[0]; + if (n === ($ptrType(Named)).nil) { + break; + } + typ = n.underlying; + } + return typ; }; - Scope.prototype.Parent = function() { return this.$val.Parent(); }; - Scope.Ptr.prototype.Len = function() { - var s; - s = this; - return $keys(s.elems).length; + Named.Ptr.prototype.setUnderlying = function(typ) { + var n; + n = this; + if (!(n === ($ptrType(Named)).nil)) { + n.underlying = typ; + } }; - Scope.prototype.Len = function() { return this.$val.Len(); }; - Scope.Ptr.prototype.Names = function() { - var s, names, i, _ref, _i, _keys, _entry, name; - s = this; - names = ($sliceType($String)).make($keys(s.elems).length); - i = 0; - _ref = s.elems; - _i = 0; - _keys = $keys(_ref); - while (_i < _keys.length) { - _entry = _ref[_keys[_i]]; - if (_entry === undefined) { + Named.prototype.setUnderlying = function(typ) { return this.$val.setUnderlying(typ); }; + Checker.Ptr.prototype.typeDecl = function(obj, typ, def$1, path$1) { + var check, named; + check = this; + assert($interfaceIsEqual(obj.object.typ, $ifaceNil)); + assert($interfaceIsEqual(check.context.iota, $ifaceNil)); + named = new Named.Ptr(obj, $ifaceNil, ($sliceType(($ptrType(Func)))).nil); + def$1.setUnderlying(named); + obj.object.typ = named; + check.typExpr(typ, named, $append(path$1, obj)); + named.underlying = underlying(named.underlying); + check.addMethodDecls(obj); + }; + Checker.prototype.typeDecl = function(obj, typ, def$1, path$1) { return this.$val.typeDecl(obj, typ, def$1, path$1); }; + Checker.Ptr.prototype.addMethodDecls = function(obj) { + var check, _entry, methods, mset, base, _tuple, t, _ref, _i, fld, _ref$1, _i$1, m, _ref$2, _i$2, m$1, alt, _ref$3; + check = this; + methods = (_entry = check.methods[obj.object.name], _entry !== undefined ? _entry.v : ($sliceType(($ptrType(Func)))).nil); + if (methods.$length === 0) { + return; + } + delete check.methods[obj.object.name]; + mset = false; + base = $assertType(obj.object.typ, ($ptrType(Named))); + _tuple = $assertType(base.underlying, ($ptrType(Struct)), true); t = _tuple[0]; + if (!(t === ($ptrType(Struct)).nil)) { + _ref = t.fields; + _i = 0; + while (_i < _ref.$length) { + fld = ((_i < 0 || _i >= _ref.$length) ? $throwRuntimeError("index out of range") : _ref.$array[_ref.$offset + _i]); + if (!(fld.object.name === "_")) { + assert($interfaceIsEqual(new ($ptrType(objset))(function() { return mset; }, function($v) { mset = $v; }).insert(fld), $ifaceNil)); + } _i++; - continue; } - name = _entry.k; - (i < 0 || i >= names.$length) ? $throwRuntimeError("index out of range") : names.$array[names.$offset + i] = name; - i = i + (1) >> 0; - _i++; } - sort.Strings(names); - return names; - }; - Scope.prototype.Names = function() { return this.$val.Names(); }; - Scope.Ptr.prototype.NumChildren = function() { - var s; - s = this; - return s.children.$length; - }; - Scope.prototype.NumChildren = function() { return this.$val.NumChildren(); }; - Scope.Ptr.prototype.Child = function(i) { - var s, x; - s = this; - return (x = s.children, ((i < 0 || i >= x.$length) ? $throwRuntimeError("index out of range") : x.$array[x.$offset + i])); + _ref$1 = base.methods; + _i$1 = 0; + while (_i$1 < _ref$1.$length) { + m = ((_i$1 < 0 || _i$1 >= _ref$1.$length) ? $throwRuntimeError("index out of range") : _ref$1.$array[_ref$1.$offset + _i$1]); + assert(!(m.object.name === "_")); + assert($interfaceIsEqual(new ($ptrType(objset))(function() { return mset; }, function($v) { mset = $v; }).insert(m), $ifaceNil)); + _i$1++; + } + _ref$2 = methods; + _i$2 = 0; + while (_i$2 < _ref$2.$length) { + m$1 = ((_i$2 < 0 || _i$2 >= _ref$2.$length) ? $throwRuntimeError("index out of range") : _ref$2.$array[_ref$2.$offset + _i$2]); + if (!(m$1.object.name === "_")) { + alt = new ($ptrType(objset))(function() { return mset; }, function($v) { mset = $v; }).insert(m$1); + if (!($interfaceIsEqual(alt, $ifaceNil))) { + _ref$3 = alt; + if ($assertType(_ref$3, ($ptrType(Var)), true)[1]) { + check.errorf(m$1.object.pos, "field and method with the same name %s", new ($sliceType($emptyInterface))([new $String(m$1.object.name)])); + } else if ($assertType(_ref$3, ($ptrType(Func)), true)[1]) { + check.errorf(m$1.object.pos, "method %s already declared for %s", new ($sliceType($emptyInterface))([new $String(m$1.object.name), base])); + } else { + unreachable(); + } + check.reportAltDecl(alt); + _i$2++; + continue; + } + } + check.objDecl(m$1, ($ptrType(Named)).nil, ($sliceType(($ptrType(TypeName)))).nil); + if (!(m$1.object.name === "_")) { + base.methods = $append(base.methods, m$1); + } + _i$2++; + } }; - Scope.prototype.Child = function(i) { return this.$val.Child(i); }; - Scope.Ptr.prototype.Lookup = function(name) { - var s, _entry; - s = this; - return (_entry = s.elems[name], _entry !== undefined ? _entry.v : $ifaceNil); + Checker.prototype.addMethodDecls = function(obj) { return this.$val.addMethodDecls(obj); }; + Checker.Ptr.prototype.funcDecl = function(obj, decl) { + var check, sig, fdecl; + check = this; + assert($interfaceIsEqual(obj.object.typ, $ifaceNil)); + assert($interfaceIsEqual(check.context.iota, $ifaceNil)); + sig = new Signature.Ptr(); + obj.object.typ = sig; + fdecl = decl.fdecl; + check.funcType(sig, fdecl.Recv, fdecl.Type); + if (sig.recv === ($ptrType(Var)).nil && obj.object.name === "init" && (sig.params.Len() > 0 || sig.results.Len() > 0)) { + check.errorf(fdecl.Pos(), "func init must have no arguments and no return values", new ($sliceType($emptyInterface))([])); + } + if (!check.conf.IgnoreFuncBodies && !(fdecl.Body === ($ptrType(ast.BlockStmt)).nil)) { + check.later(obj.object.name, decl, sig, fdecl.Body); + } }; - Scope.prototype.Lookup = function(name) { return this.$val.Lookup(name); }; - Scope.Ptr.prototype.LookupParent = function(name) { - var s, _entry, obj; - s = this; - while (!(s === ($ptrType(Scope)).nil)) { - obj = (_entry = s.elems[name], _entry !== undefined ? _entry.v : $ifaceNil); - if (!($interfaceIsEqual(obj, $ifaceNil))) { - return obj; + Checker.prototype.funcDecl = function(obj, decl) { return this.$val.funcDecl(obj, decl); }; + Checker.Ptr.prototype.declStmt = function(decl) { + var check, pkg, d, _ref, last, _ref$1, _i, iota, spec, s, _ref$2, _ref$3, lhs, _ref$4, _i$1, i, name, obj, init$1, x, _ref$5, _i$2, i$1, name$1, lhs0, _ref$6, _i$3, i$2, name$2, _ref$7, _i$4, i$3, obj$1, lhs$1, init$2, _ref$8, x$1, x$2, x$3, _ref$9, _i$5, i$4, name$3, obj$2; + check = this; + pkg = check.pkg; + _ref = decl; + if ($assertType(_ref, ($ptrType(ast.BadDecl)), true)[1]) { + d = _ref.$val; + } else if ($assertType(_ref, ($ptrType(ast.GenDecl)), true)[1]) { + d = _ref.$val; + last = ($ptrType(ast.ValueSpec)).nil; + _ref$1 = d.Specs; + _i = 0; + while (_i < _ref$1.$length) { + iota = _i; + spec = ((_i < 0 || _i >= _ref$1.$length) ? $throwRuntimeError("index out of range") : _ref$1.$array[_ref$1.$offset + _i]); + _ref$2 = spec; + if ($assertType(_ref$2, ($ptrType(ast.ValueSpec)), true)[1]) { + s = _ref$2.$val; + _ref$3 = d.Tok; + if (_ref$3 === 64) { + if (!($interfaceIsEqual(s.Type, $ifaceNil)) || s.Values.$length > 0) { + last = s; + } else if (last === ($ptrType(ast.ValueSpec)).nil) { + last = new ast.ValueSpec.Ptr(); + } + lhs = ($sliceType(($ptrType(Const)))).make(s.Names.$length); + _ref$4 = s.Names; + _i$1 = 0; + while (_i$1 < _ref$4.$length) { + i = _i$1; + name = ((_i$1 < 0 || _i$1 >= _ref$4.$length) ? $throwRuntimeError("index out of range") : _ref$4.$array[_ref$4.$offset + _i$1]); + obj = NewConst(name.Pos(), pkg, name.Name, $ifaceNil, exact.MakeInt64(new $Int64(0, iota))); + (i < 0 || i >= lhs.$length) ? $throwRuntimeError("index out of range") : lhs.$array[lhs.$offset + i] = obj; + init$1 = $ifaceNil; + if (i < last.Values.$length) { + init$1 = (x = last.Values, ((i < 0 || i >= x.$length) ? $throwRuntimeError("index out of range") : x.$array[x.$offset + i])); + } + check.constDecl(obj, last.Type, init$1); + _i$1++; + } + check.arityMatch(s, last); + _ref$5 = s.Names; + _i$2 = 0; + while (_i$2 < _ref$5.$length) { + i$1 = _i$2; + name$1 = ((_i$2 < 0 || _i$2 >= _ref$5.$length) ? $throwRuntimeError("index out of range") : _ref$5.$array[_ref$5.$offset + _i$2]); + check.declare(check.context.scope, name$1, ((i$1 < 0 || i$1 >= lhs.$length) ? $throwRuntimeError("index out of range") : lhs.$array[lhs.$offset + i$1])); + _i$2++; + } + } else if (_ref$3 === 85) { + lhs0 = ($sliceType(($ptrType(Var)))).make(s.Names.$length); + _ref$6 = s.Names; + _i$3 = 0; + while (_i$3 < _ref$6.$length) { + i$2 = _i$3; + name$2 = ((_i$3 < 0 || _i$3 >= _ref$6.$length) ? $throwRuntimeError("index out of range") : _ref$6.$array[_ref$6.$offset + _i$3]); + (i$2 < 0 || i$2 >= lhs0.$length) ? $throwRuntimeError("index out of range") : lhs0.$array[lhs0.$offset + i$2] = NewVar(name$2.Pos(), pkg, name$2.Name, $ifaceNil); + _i$3++; + } + _ref$7 = lhs0; + _i$4 = 0; + while (_i$4 < _ref$7.$length) { + i$3 = _i$4; + obj$1 = ((_i$4 < 0 || _i$4 >= _ref$7.$length) ? $throwRuntimeError("index out of range") : _ref$7.$array[_ref$7.$offset + _i$4]); + lhs$1 = ($sliceType(($ptrType(Var)))).nil; + init$2 = $ifaceNil; + _ref$8 = s.Values.$length; + if (_ref$8 === s.Names.$length) { + init$2 = (x$1 = s.Values, ((i$3 < 0 || i$3 >= x$1.$length) ? $throwRuntimeError("index out of range") : x$1.$array[x$1.$offset + i$3])); + } else if (_ref$8 === 1) { + lhs$1 = lhs0; + init$2 = (x$2 = s.Values, ((0 < 0 || 0 >= x$2.$length) ? $throwRuntimeError("index out of range") : x$2.$array[x$2.$offset + 0])); + } else { + if (i$3 < s.Values.$length) { + init$2 = (x$3 = s.Values, ((i$3 < 0 || i$3 >= x$3.$length) ? $throwRuntimeError("index out of range") : x$3.$array[x$3.$offset + i$3])); + } + } + check.varDecl(obj$1, lhs$1, s.Type, init$2); + if (s.Values.$length === 1) { + break; + } + _i$4++; + } + check.arityMatch(s, ($ptrType(ast.ValueSpec)).nil); + _ref$9 = s.Names; + _i$5 = 0; + while (_i$5 < _ref$9.$length) { + i$4 = _i$5; + name$3 = ((_i$5 < 0 || _i$5 >= _ref$9.$length) ? $throwRuntimeError("index out of range") : _ref$9.$array[_ref$9.$offset + _i$5]); + check.declare(check.context.scope, name$3, ((i$4 < 0 || i$4 >= lhs0.$length) ? $throwRuntimeError("index out of range") : lhs0.$array[lhs0.$offset + i$4])); + _i$5++; + } + } else { + check.invalidAST(s.Pos(), "invalid token %s", new ($sliceType($emptyInterface))([new token.Token(d.Tok)])); + } + } else if ($assertType(_ref$2, ($ptrType(ast.TypeSpec)), true)[1]) { + s = _ref$2.$val; + obj$2 = NewTypeName(s.Name.Pos(), pkg, s.Name.Name, $ifaceNil); + check.declare(check.context.scope, s.Name, obj$2); + check.typeDecl(obj$2, s.Type, ($ptrType(Named)).nil, ($sliceType(($ptrType(TypeName)))).nil); + } else { + s = _ref$2; + check.invalidAST(s.Pos(), "const, type, or var declaration expected", new ($sliceType($emptyInterface))([])); + } + _i++; } - s = s.parent; + } else { + d = _ref; + check.invalidAST(d.Pos(), "unknown ast.Decl node %T", new ($sliceType($emptyInterface))([d])); } - return $ifaceNil; }; - Scope.prototype.LookupParent = function(name) { return this.$val.LookupParent(name); }; - Scope.Ptr.prototype.Insert = function(obj) { - var s, name, _entry, alt, _key$2; - s = this; - name = obj.Name(); - alt = (_entry = s.elems[name], _entry !== undefined ? _entry.v : $ifaceNil); - if (!($interfaceIsEqual(alt, $ifaceNil))) { - return alt; - } - if (s.elems === false) { - s.elems = new $Map(); - } - _key$2 = name; (s.elems || $throwRuntimeError("assignment to entry in nil map"))[_key$2] = { k: _key$2, v: obj }; - if (obj.Parent() === ($ptrType(Scope)).nil) { - obj.setParent(s); + Checker.prototype.declStmt = function(decl) { return this.$val.declStmt(decl); }; + assert = function(p) { + if (!p) { + $panic(new $String("assertion failed")); } - return $ifaceNil; }; - Scope.prototype.Insert = function(obj) { return this.$val.Insert(obj); }; - Scope.Ptr.prototype.WriteTo = function(w, n, recurse) { - var s, indn, indn1, _ref, _i, name, _entry, _ref$1, _i$1, s$1; - s = this; - indn = strings.Repeat(". ", n); - fmt.Fprintf(w, "%s%s scope %p {", new ($sliceType($emptyInterface))([new $String(indn), new $String(s.comment), s])); - if ($keys(s.elems).length === 0) { - fmt.Fprintf(w, "}\n", new ($sliceType($emptyInterface))([])); - return; - } - fmt.Fprintln(w, new ($sliceType($emptyInterface))([])); - indn1 = indn + ". "; - _ref = s.Names(); + unreachable = function() { + $panic(new $String("unreachable")); + }; + Checker.Ptr.prototype.sprintf = function(format, args) { + var check, _ref, _i, i, arg, a, _ref$1; + check = this; + _ref = args; _i = 0; while (_i < _ref.$length) { - name = ((_i < 0 || _i >= _ref.$length) ? $throwRuntimeError("index out of range") : _ref.$array[_ref.$offset + _i]); - fmt.Fprintf(w, "%s%s\n", new ($sliceType($emptyInterface))([new $String(indn1), (_entry = s.elems[name], _entry !== undefined ? _entry.v : $ifaceNil)])); - _i++; - } - if (recurse) { - _ref$1 = s.children; - _i$1 = 0; - while (_i$1 < _ref$1.$length) { - s$1 = ((_i$1 < 0 || _i$1 >= _ref$1.$length) ? $throwRuntimeError("index out of range") : _ref$1.$array[_ref$1.$offset + _i$1]); - fmt.Fprintln(w, new ($sliceType($emptyInterface))([])); - s$1.WriteTo(w, n + 1 >> 0, recurse); - _i$1++; + i = _i; + arg = ((_i < 0 || _i >= _ref.$length) ? $throwRuntimeError("index out of range") : _ref.$array[_ref.$offset + _i]); + _ref$1 = arg; + if (_ref$1 === $ifaceNil) { + a = _ref$1; + arg = new $String(""); + } else if ($assertType(_ref$1, operand, true)[1]) { + a = _ref$1.$val; + $panic(new $String("internal error: should always pass *operand")); + } else if ($assertType(_ref$1, ($ptrType(operand)), true)[1]) { + a = _ref$1.$val; + arg = new $String(operandString(check.pkg, a)); + } else if ($assertType(_ref$1, token.Pos, true)[1]) { + a = _ref$1.$val; + arg = new $String(check.fset.Position(a).String()); + } else if ($assertType(_ref$1, ast.Expr, true)[1]) { + a = _ref$1; + arg = new $String(ExprString(a)); + } else if ($assertType(_ref$1, Object, true)[1]) { + a = _ref$1; + arg = new $String(ObjectString(check.pkg, a)); + } else if ($assertType(_ref$1, Type, true)[1]) { + a = _ref$1; + arg = new $String(TypeString(check.pkg, a)); } + (i < 0 || i >= args.$length) ? $throwRuntimeError("index out of range") : args.$array[args.$offset + i] = arg; + _i++; } - fmt.Fprintf(w, "%s}", new ($sliceType($emptyInterface))([new $String(indn)])); + return fmt.Sprintf(format, args); }; - Scope.prototype.WriteTo = function(w, n, recurse) { return this.$val.WriteTo(w, n, recurse); }; - Scope.Ptr.prototype.String = function() { - var s, buf; - s = this; - buf = new bytes.Buffer.Ptr(); $copy(buf, new bytes.Buffer.Ptr(), bytes.Buffer); - s.WriteTo(buf, 0, false); - return buf.String(); + Checker.prototype.sprintf = function(format, args) { return this.$val.sprintf(format, args); }; + Checker.Ptr.prototype.dump = function(format, args) { + var check; + check = this; + fmt.Println(new ($sliceType($emptyInterface))([new $String(check.sprintf(format, args))])); }; - Scope.prototype.String = function() { return this.$val.String(); }; - Selection.Ptr.prototype.Kind = function() { - var s; - s = this; - return s.kind; + Checker.prototype.dump = function(format, args) { return this.$val.dump(format, args); }; + Checker.Ptr.prototype.err = function(pos, msg, soft) { + var check, err, f, x; + check = this; + err = new Error.Ptr(check.fset, pos, msg, soft); + if ($interfaceIsEqual(check.firstErr, $ifaceNil)) { + check.firstErr = new err.constructor.Struct(err); + } + f = check.conf.Error; + if (f === $throwNilPointerError) { + $panic((x = new bailout.Ptr(), new x.constructor.Struct(x))); + } + f(new err.constructor.Struct(err)); }; - Selection.prototype.Kind = function() { return this.$val.Kind(); }; - Selection.Ptr.prototype.Recv = function() { - var s; - s = this; - return s.recv; + Checker.prototype.err = function(pos, msg, soft) { return this.$val.err(pos, msg, soft); }; + Checker.Ptr.prototype.error = function(pos, msg) { + var check; + check = this; + check.err(pos, msg, false); }; - Selection.prototype.Recv = function() { return this.$val.Recv(); }; - Selection.Ptr.prototype.Obj = function() { - var s; - s = this; - return s.obj; + Checker.prototype.error = function(pos, msg) { return this.$val.error(pos, msg); }; + Checker.Ptr.prototype.errorf = function(pos, format, args) { + var check; + check = this; + check.err(pos, check.sprintf(format, args), false); }; - Selection.prototype.Obj = function() { return this.$val.Obj(); }; - Selection.Ptr.prototype.Type = function() { - var s, _ref, sig, recv, sig$1, arg0, params; - s = this; - _ref = s.kind; - if (_ref === 1) { - sig = new Signature.Ptr(); $copy(sig, $assertType($assertType(s.obj, ($ptrType(Func))).object.typ, ($ptrType(Signature))), Signature); - recv = new Var.Ptr(); $copy(recv, sig.recv, Var); - recv.object.typ = s.recv; - sig.recv = recv; - return sig; - } else if (_ref === 2) { - sig$1 = new Signature.Ptr(); $copy(sig$1, $assertType($assertType(s.obj, ($ptrType(Func))).object.typ, ($ptrType(Signature))), Signature); - arg0 = new Var.Ptr(); $copy(arg0, sig$1.recv, Var); - sig$1.recv = ($ptrType(Var)).nil; - arg0.object.typ = s.recv; - params = ($sliceType(($ptrType(Var)))).nil; - if (!(sig$1.params === ($ptrType(Tuple)).nil)) { - params = sig$1.params.vars; - } - sig$1.params = NewTuple($appendSlice(new ($sliceType(($ptrType(Var))))([arg0]), params)); - return sig$1; - } - return s.obj.Type(); + Checker.prototype.errorf = function(pos, format, args) { return this.$val.errorf(pos, format, args); }; + Checker.Ptr.prototype.softErrorf = function(pos, format, args) { + var check; + check = this; + check.err(pos, check.sprintf(format, args), true); }; - Selection.prototype.Type = function() { return this.$val.Type(); }; - Selection.Ptr.prototype.Index = function() { - var s; - s = this; - return s.index; + Checker.prototype.softErrorf = function(pos, format, args) { return this.$val.softErrorf(pos, format, args); }; + Checker.Ptr.prototype.invalidAST = function(pos, format, args) { + var check; + check = this; + check.errorf(pos, "invalid AST: " + format, args); }; - Selection.prototype.Index = function() { return this.$val.Index(); }; - Selection.Ptr.prototype.Indirect = function() { - var s; - s = this; - return s.indirect; + Checker.prototype.invalidAST = function(pos, format, args) { return this.$val.invalidAST(pos, format, args); }; + Checker.Ptr.prototype.invalidArg = function(pos, format, args) { + var check; + check = this; + check.errorf(pos, "invalid argument: " + format, args); }; - Selection.prototype.Indirect = function() { return this.$val.Indirect(); }; - Selection.Ptr.prototype.String = function() { - var s; - s = this; - return SelectionString(($ptrType(Package)).nil, s); + Checker.prototype.invalidArg = function(pos, format, args) { return this.$val.invalidArg(pos, format, args); }; + Checker.Ptr.prototype.invalidOp = function(pos, format, args) { + var check; + check = this; + check.errorf(pos, "invalid operation: " + format, args); }; - Selection.prototype.String = function() { return this.$val.String(); }; - SelectionString = $pkg.SelectionString = function(this$1, s) { - var k, _ref, buf, T; - k = ""; - _ref = s.kind; - if (_ref === 0) { - k = "field "; - } else if (_ref === 1) { - k = "method "; - } else if (_ref === 2) { - k = "method expr "; - } else { - unreachable(); - } - buf = new bytes.Buffer.Ptr(); $copy(buf, new bytes.Buffer.Ptr(), bytes.Buffer); - buf.WriteString(k); - buf.WriteByte(40); - WriteType(buf, this$1, s.Recv()); - fmt.Fprintf(buf, ") %s", new ($sliceType($emptyInterface))([new $String(s.obj.Name())])); - T = s.Type(); - if (s.kind === 0) { - buf.WriteByte(32); - WriteType(buf, this$1, T); + Checker.prototype.invalidOp = function(pos, format, args) { return this.$val.invalidOp(pos, format, args); }; + Checker.Ptr.prototype.op = function(m, x, op) { + var check, _entry, pred; + check = this; + pred = (_entry = m[op], _entry !== undefined ? _entry.v : $throwNilPointerError); + if (!(pred === $throwNilPointerError)) { + if (!pred(x.typ)) { + check.invalidOp(x.pos(), "operator %s not defined for %s", new ($sliceType($emptyInterface))([new token.Token(op), x])); + return false; + } } else { - WriteSignature(buf, this$1, $assertType(T, ($ptrType(Signature)))); + check.invalidAST(x.pos(), "unknown operator %s", new ($sliceType($emptyInterface))([new token.Token(op)])); + return false; } - return buf.String(); + return true; }; - StdSizes.Ptr.prototype.Alignof = function(T) { - var s, t, _ref, max, _ref$1, _i, f, a, a$1, x; - s = this; - _ref = T.Underlying(); - if ($assertType(_ref, ($ptrType(Array)), true)[1]) { - t = _ref.$val; - return s.Alignof(t.elem); - } else if ($assertType(_ref, ($ptrType(Struct)), true)[1]) { - t = _ref.$val; - max = new $Int64(0, 1); - _ref$1 = t.fields; - _i = 0; - while (_i < _ref$1.$length) { - f = ((_i < 0 || _i >= _ref$1.$length) ? $throwRuntimeError("index out of range") : _ref$1.$array[_ref$1.$offset + _i]); - a = s.Alignof(f.object.typ); - if ((a.$high > max.$high || (a.$high === max.$high && a.$low > max.$low))) { - max = a; - } - _i++; + Checker.prototype.op = function(m, x, op) { return this.$val.op(m, x, op); }; + Checker.Ptr.prototype.unary = function(x, op) { + var check, _ref, _tuple, ok, _tuple$1, typ, ok$1, typ$1, size, x$1; + check = this; + _ref = op; + if (_ref === 17) { + _tuple = $assertType(unparen(x.expr), ($ptrType(ast.CompositeLit)), true); ok = _tuple[1]; + if (!ok && !((x.mode === 5))) { + check.invalidOp(x.pos(), "cannot take address of %s", new ($sliceType($emptyInterface))([x])); + x.mode = 0; + return; } - return max; + x.mode = 7; + x.typ = new Pointer.Ptr(x.typ); + return; + } else if (_ref === 36) { + _tuple$1 = $assertType(x.typ.Underlying(), ($ptrType(Chan)), true); typ = _tuple$1[0]; ok$1 = _tuple$1[1]; + if (!ok$1) { + check.invalidOp(x.pos(), "cannot receive from non-channel %s", new ($sliceType($emptyInterface))([x])); + x.mode = 0; + return; + } + if (typ.dir === 1) { + check.invalidOp(x.pos(), "cannot receive from send-only channel %s", new ($sliceType($emptyInterface))([x])); + x.mode = 0; + return; + } + x.mode = 8; + x.typ = typ.elem; + check.context.hasCallOrRecv = true; + return; } - a$1 = s.Sizeof(T); - if ((a$1.$high < 0 || (a$1.$high === 0 && a$1.$low < 1))) { - return new $Int64(0, 1); + if (!check.op(unaryOpPredicates, x, op)) { + x.mode = 0; + return; } - if ((x = s.MaxAlign, (a$1.$high > x.$high || (a$1.$high === x.$high && a$1.$low > x.$low)))) { - return s.MaxAlign; + if (x.mode === 4) { + typ$1 = $assertType(x.typ.Underlying(), ($ptrType(Basic))); + size = -1; + if (isUnsigned(typ$1)) { + size = ((x$1 = check.conf.sizeof(typ$1), x$1.$low + ((x$1.$high >> 31) * 4294967296)) >> 0); + } + x.val = exact.UnaryOp(op, x.val, size); + if (isTyped(typ$1)) { + check.representable(x, typ$1); + } + return; } - return a$1; + x.mode = 7; }; - StdSizes.prototype.Alignof = function(T) { return this.$val.Alignof(T); }; - StdSizes.Ptr.prototype.Offsetsof = function(fields) { - var s, offsets, o, _ref, _i, i, f, a, x; - s = this; - offsets = ($sliceType($Int64)).make(fields.$length); - o = new $Int64(0, 0); - _ref = fields; - _i = 0; - while (_i < _ref.$length) { - i = _i; - f = ((_i < 0 || _i >= _ref.$length) ? $throwRuntimeError("index out of range") : _ref.$array[_ref.$offset + _i]); - a = s.Alignof(f.object.typ); - o = align(o, a); - (i < 0 || i >= offsets.$length) ? $throwRuntimeError("index out of range") : offsets.$array[offsets.$offset + i] = o; - o = (x = s.Sizeof(f.object.typ), new $Int64(o.$high + x.$high, o.$low + x.$low)); - _i++; + Checker.prototype.unary = function(x, op) { return this.$val.unary(x, op); }; + isShift = function(op) { + return (op === 20) || (op === 21); + }; + isComparison = function(op) { + var _ref; + _ref = op; + if (_ref === 39 || _ref === 44 || _ref === 40 || _ref === 45 || _ref === 41 || _ref === 46) { + return true; } - return offsets; + return false; }; - StdSizes.prototype.Offsetsof = function(fields) { return this.$val.Offsetsof(fields); }; - StdSizes.Ptr.prototype.Sizeof = function(T) { - var s, t, _ref, k, s$1, a, z, n, offsets, x, x$1, x$2, x$3, x$4; - s = this; - _ref = T.Underlying(); - if ($assertType(_ref, ($ptrType(Basic)), true)[1]) { - t = _ref.$val; - assert(isTyped(T)); - k = t.kind; - if ((k >> 0) < 17) { - s$1 = ((k < 0 || k >= basicSizes.length) ? $throwRuntimeError("index out of range") : basicSizes[k]); - if (s$1 > 0) { - return new $Int64(0, s$1); + fitsFloat32 = function(x) { + var _tuple, f32, f; + _tuple = exact.Float32Val(x); f32 = _tuple[0]; + f = $coerceFloat32(f32); + return !math.IsInf(f, 0); + }; + roundFloat32 = function(x) { + var _tuple, f32, f; + _tuple = exact.Float32Val(x); f32 = _tuple[0]; + f = $coerceFloat32(f32); + if (!math.IsInf(f, 0)) { + return exact.MakeFloat64(f); + } + return $ifaceNil; + }; + fitsFloat64 = function(x) { + var _tuple, f; + _tuple = exact.Float64Val(x); f = _tuple[0]; + return !math.IsInf(f, 0); + }; + roundFloat64 = function(x) { + var _tuple, f; + _tuple = exact.Float64Val(x); f = _tuple[0]; + if (!math.IsInf(f, 0)) { + return exact.MakeFloat64(f); + } + return $ifaceNil; + }; + representableConst = function(x, conf, as, rounded) { + var _ref, _tuple, x$1, ok, _ref$1, x$2, s, x$3, x$4, x$5, x$6, s$1, x$7, x$8, n, _ref$2, x$9, s$2, r, r$1, _ref$3, r$2, r$3, _ref$4, re, im, re$1, im$1; + _ref = x.Kind(); + if (_ref === 0) { + return true; + } else if (_ref === 1) { + return (as === 1) || (as === 19); + } else if (_ref === 3) { + _tuple = exact.Int64Val(x); x$1 = _tuple[0]; ok = _tuple[1]; + if (ok) { + _ref$1 = as; + if (_ref$1 === 2) { + s = (x$2 = (conf.sizeof(((as < 0 || as >= $pkg.Typ.length) ? $throwRuntimeError("index out of range") : $pkg.Typ[as])).$low >>> 0), (((x$2 >>> 16 << 16) * 8 >>> 0) + (x$2 << 16 >>> 16) * 8) >>> 0); + return (x$3 = $shiftLeft64(new $Int64(-1, 4294967295), ((s - 1 >>> 0))), (x$3.$high < x$1.$high || (x$3.$high === x$1.$high && x$3.$low <= x$1.$low))) && (x$4 = (x$5 = $shiftLeft64(new $Int64(0, 1), ((s - 1 >>> 0))), new $Int64(x$5.$high - 0, x$5.$low - 1)), (x$1.$high < x$4.$high || (x$1.$high === x$4.$high && x$1.$low <= x$4.$low))); + } else if (_ref$1 === 3) { + return (-1 < x$1.$high || (-1 === x$1.$high && 4294967168 <= x$1.$low)) && (x$1.$high < 0 || (x$1.$high === 0 && x$1.$low <= 127)); + } else if (_ref$1 === 4) { + return (-1 < x$1.$high || (-1 === x$1.$high && 4294934528 <= x$1.$low)) && (x$1.$high < 0 || (x$1.$high === 0 && x$1.$low <= 32767)); + } else if (_ref$1 === 5) { + return (-1 < x$1.$high || (-1 === x$1.$high && 2147483648 <= x$1.$low)) && (x$1.$high < 0 || (x$1.$high === 0 && x$1.$low <= 2147483647)); + } else if (_ref$1 === 6) { + return true; + } else if (_ref$1 === 7 || _ref$1 === 12) { + s$1 = (x$6 = (conf.sizeof(((as < 0 || as >= $pkg.Typ.length) ? $throwRuntimeError("index out of range") : $pkg.Typ[as])).$low >>> 0), (((x$6 >>> 16 << 16) * 8 >>> 0) + (x$6 << 16 >>> 16) * 8) >>> 0); + if (s$1 < 64) { + return (0 < x$1.$high || (0 === x$1.$high && 0 <= x$1.$low)) && (x$7 = (x$8 = $shiftLeft64(new $Int64(0, 1), s$1), new $Int64(x$8.$high - 0, x$8.$low - 1)), (x$1.$high < x$7.$high || (x$1.$high === x$7.$high && x$1.$low <= x$7.$low))); + } + return (0 < x$1.$high || (0 === x$1.$high && 0 <= x$1.$low)); + } else if (_ref$1 === 8) { + return (0 < x$1.$high || (0 === x$1.$high && 0 <= x$1.$low)) && (x$1.$high < 0 || (x$1.$high === 0 && x$1.$low <= 255)); + } else if (_ref$1 === 9) { + return (0 < x$1.$high || (0 === x$1.$high && 0 <= x$1.$low)) && (x$1.$high < 0 || (x$1.$high === 0 && x$1.$low <= 65535)); + } else if (_ref$1 === 10) { + return (0 < x$1.$high || (0 === x$1.$high && 0 <= x$1.$low)) && (x$1.$high < 0 || (x$1.$high === 0 && x$1.$low <= 4294967295)); + } else if (_ref$1 === 11) { + return (0 < x$1.$high || (0 === x$1.$high && 0 <= x$1.$low)); + } else if (_ref$1 === 13 || _ref$1 === 14 || _ref$1 === 15 || _ref$1 === 16 || _ref$1 === 20 || _ref$1 === 22 || _ref$1 === 23) { + return true; } } - if (k === 17) { - return $mul64(s.WordSize, new $Int64(0, 2)); - } - } else if ($assertType(_ref, ($ptrType(Array)), true)[1]) { - t = _ref.$val; - a = s.Alignof(t.elem); - z = s.Sizeof(t.elem); - return $mul64(align(z, a), t.len); - } else if ($assertType(_ref, ($ptrType(Slice)), true)[1]) { - t = _ref.$val; - return $mul64(s.WordSize, new $Int64(0, 3)); - } else if ($assertType(_ref, ($ptrType(Struct)), true)[1]) { - t = _ref.$val; - n = t.NumFields(); - if (n === 0) { - return new $Int64(0, 0); - } - offsets = t.offsets; - if (t.offsets === ($sliceType($Int64)).nil) { - offsets = s.Offsetsof(t.fields); - t.offsets = offsets; + n = exact.BitLen(x); + _ref$2 = as; + if (_ref$2 === 7 || _ref$2 === 12) { + s$2 = (x$9 = (conf.sizeof(((as < 0 || as >= $pkg.Typ.length) ? $throwRuntimeError("index out of range") : $pkg.Typ[as])).$low >>> 0), (((x$9 >>> 16 << 16) * 8 >>> 0) + (x$9 << 16 >>> 16) * 8) >>> 0); + return exact.Sign(x) >= 0 && n <= (s$2 >> 0); + } else if (_ref$2 === 11) { + return exact.Sign(x) >= 0 && n <= 64; + } else if (_ref$2 === 13 || _ref$2 === 15) { + if (rounded === ($ptrType(exact.Value)).nil) { + return fitsFloat32(x); + } + r = roundFloat32(x); + if (!($interfaceIsEqual(r, $ifaceNil))) { + rounded.$set(r); + return true; + } + } else if (_ref$2 === 14 || _ref$2 === 16) { + if (rounded === ($ptrType(exact.Value)).nil) { + return fitsFloat64(x); + } + r$1 = roundFloat64(x); + if (!($interfaceIsEqual(r$1, $ifaceNil))) { + rounded.$set(r$1); + return true; + } + } else if (_ref$2 === 20 || _ref$2 === 22 || _ref$2 === 23) { + return true; } - return (x = (x$1 = n - 1 >> 0, ((x$1 < 0 || x$1 >= offsets.$length) ? $throwRuntimeError("index out of range") : offsets.$array[offsets.$offset + x$1])), x$2 = s.Sizeof((x$3 = t.fields, x$4 = n - 1 >> 0, ((x$4 < 0 || x$4 >= x$3.$length) ? $throwRuntimeError("index out of range") : x$3.$array[x$3.$offset + x$4])).object.typ), new $Int64(x.$high + x$2.$high, x.$low + x$2.$low)); - } else if ($assertType(_ref, ($ptrType(Interface)), true)[1]) { - t = _ref.$val; - return $mul64(s.WordSize, new $Int64(0, 2)); - } - return s.WordSize; - }; - StdSizes.prototype.Sizeof = function(T) { return this.$val.Sizeof(T); }; - Config.Ptr.prototype.alignof = function(T) { - var conf, s, a; - conf = this; - s = conf.Sizes; - if (!($interfaceIsEqual(s, $ifaceNil))) { - a = s.Alignof(T); - if ((a.$high > 0 || (a.$high === 0 && a.$low >= 1))) { - return a; + } else if (_ref === 4) { + _ref$3 = as; + if (_ref$3 === 13 || _ref$3 === 15) { + if (rounded === ($ptrType(exact.Value)).nil) { + return fitsFloat32(x); + } + r$2 = roundFloat32(x); + if (!($interfaceIsEqual(r$2, $ifaceNil))) { + rounded.$set(r$2); + return true; + } + } else if (_ref$3 === 14 || _ref$3 === 16) { + if (rounded === ($ptrType(exact.Value)).nil) { + return fitsFloat64(x); + } + r$3 = roundFloat64(x); + if (!($interfaceIsEqual(r$3, $ifaceNil))) { + rounded.$set(r$3); + return true; + } + } else if (_ref$3 === 22 || _ref$3 === 23) { + return true; } - $panic(new $String("Config.Sizes.Alignof returned an alignment < 1")); + } else if (_ref === 5) { + _ref$4 = as; + if (_ref$4 === 15) { + if (rounded === ($ptrType(exact.Value)).nil) { + return fitsFloat32(exact.Real(x)) && fitsFloat32(exact.Imag(x)); + } + re = roundFloat32(exact.Real(x)); + im = roundFloat32(exact.Imag(x)); + if (!($interfaceIsEqual(re, $ifaceNil)) && !($interfaceIsEqual(im, $ifaceNil))) { + rounded.$set(exact.BinaryOp(re, 12, exact.MakeImag(im))); + return true; + } + } else if (_ref$4 === 16) { + if (rounded === ($ptrType(exact.Value)).nil) { + return fitsFloat64(exact.Real(x)) && fitsFloat64(exact.Imag(x)); + } + re$1 = roundFloat64(exact.Real(x)); + im$1 = roundFloat64(exact.Imag(x)); + if (!($interfaceIsEqual(re$1, $ifaceNil)) && !($interfaceIsEqual(im$1, $ifaceNil))) { + rounded.$set(exact.BinaryOp(re$1, 12, exact.MakeImag(im$1))); + return true; + } + } else if (_ref$4 === 23) { + return true; + } + } else if (_ref === 2) { + return (as === 17) || (as === 24); + } else { + unreachable(); } - return stdSizes.Alignof(T); + return false; }; - Config.prototype.alignof = function(T) { return this.$val.alignof(T); }; - Config.Ptr.prototype.offsetsof = function(T) { - var conf, offsets, s, _ref, _i, o; - conf = this; - offsets = T.offsets; - if (offsets === ($sliceType($Int64)).nil && T.NumFields() > 0) { - s = conf.Sizes; - if (!($interfaceIsEqual(s, $ifaceNil))) { - offsets = s.Offsetsof(T.fields); - if (!((offsets.$length === T.NumFields()))) { - $panic(new $String("Config.Sizes.Offsetsof returned the wrong number of offsets")); - } - _ref = offsets; - _i = 0; - while (_i < _ref.$length) { - o = ((_i < 0 || _i >= _ref.$length) ? $throwRuntimeError("index out of range") : _ref.$array[_ref.$offset + _i]); - if ((o.$high < 0 || (o.$high === 0 && o.$low < 0))) { - $panic(new $String("Config.Sizes.Offsetsof returned an offset < 0")); - } - _i++; + Checker.Ptr.prototype.representable = function(x, typ) { + var check, msg; + check = this; + assert(x.mode === 4); + if (!representableConst(x.val, check.conf, typ.kind, new ($ptrType(exact.Value))(function() { return this.$target.val; }, function($v) { this.$target.val = $v; }, x))) { + msg = ""; + if (isNumeric(x.typ) && isNumeric(typ)) { + if (!isInteger(x.typ) && isInteger(typ)) { + msg = "%s truncated to %s"; + } else { + msg = "%s overflows %s"; } } else { - offsets = stdSizes.Offsetsof(T.fields); + msg = "cannot convert %s to %s"; } - T.offsets = offsets; + check.errorf(x.pos(), msg, new ($sliceType($emptyInterface))([x, typ])); + x.mode = 0; } - return offsets; }; - Config.prototype.offsetsof = function(T) { return this.$val.offsetsof(T); }; - Config.Ptr.prototype.offsetof = function(typ, index) { - var conf, o, _ref, _i, i, s, x, x$1, x$2; - conf = this; - o = new $Int64(0, 0); - _ref = index; - _i = 0; - while (_i < _ref.$length) { - i = ((_i < 0 || _i >= _ref.$length) ? $throwRuntimeError("index out of range") : _ref.$array[_ref.$offset + _i]); - s = $assertType(typ.Underlying(), ($ptrType(Struct))); - o = (x = (x$1 = conf.offsetsof(s), ((i < 0 || i >= x$1.$length) ? $throwRuntimeError("index out of range") : x$1.$array[x$1.$offset + i])), new $Int64(o.$high + x.$high, o.$low + x.$low)); - typ = (x$2 = s.fields, ((i < 0 || i >= x$2.$length) ? $throwRuntimeError("index out of range") : x$2.$array[x$2.$offset + i])).object.typ; - _i++; + Checker.prototype.representable = function(x, typ) { return this.$val.representable(x, typ); }; + Checker.Ptr.prototype.updateExprType = function(x, typ, final$1) { + var check, _tuple, _entry, old, found, x$1, _ref, _key$2; + check = this; + _tuple = (_entry = check.untyped[x.$key()], _entry !== undefined ? [_entry.v, true] : [new exprInfo.Ptr(), false]); old = new exprInfo.Ptr(); $copy(old, _tuple[0], exprInfo); found = _tuple[1]; + if (!found) { + return; } - return o; - }; - Config.prototype.offsetof = function(typ, index) { return this.$val.offsetof(typ, index); }; - Config.Ptr.prototype.sizeof = function(T) { - var conf, s, z; - conf = this; - s = conf.Sizes; - if (!($interfaceIsEqual(s, $ifaceNil))) { - z = s.Sizeof(T); - if ((z.$high > 0 || (z.$high === 0 && z.$low >= 0))) { - return z; + _ref = x; + switch (0) { default: if ($assertType(_ref, ($ptrType(ast.BadExpr)), true)[1] || $assertType(_ref, ($ptrType(ast.FuncLit)), true)[1] || $assertType(_ref, ($ptrType(ast.CompositeLit)), true)[1] || $assertType(_ref, ($ptrType(ast.IndexExpr)), true)[1] || $assertType(_ref, ($ptrType(ast.SliceExpr)), true)[1] || $assertType(_ref, ($ptrType(ast.TypeAssertExpr)), true)[1] || $assertType(_ref, ($ptrType(ast.StarExpr)), true)[1] || $assertType(_ref, ($ptrType(ast.KeyValueExpr)), true)[1] || $assertType(_ref, ($ptrType(ast.ArrayType)), true)[1] || $assertType(_ref, ($ptrType(ast.StructType)), true)[1] || $assertType(_ref, ($ptrType(ast.FuncType)), true)[1] || $assertType(_ref, ($ptrType(ast.InterfaceType)), true)[1] || $assertType(_ref, ($ptrType(ast.MapType)), true)[1] || $assertType(_ref, ($ptrType(ast.ChanType)), true)[1]) { + x$1 = _ref; + return; + } else if ($assertType(_ref, ($ptrType(ast.CallExpr)), true)[1]) { + x$1 = _ref.$val; + } else if ($assertType(_ref, ($ptrType(ast.Ident)), true)[1] || $assertType(_ref, ($ptrType(ast.BasicLit)), true)[1] || $assertType(_ref, ($ptrType(ast.SelectorExpr)), true)[1]) { + x$1 = _ref; + } else if ($assertType(_ref, ($ptrType(ast.ParenExpr)), true)[1]) { + x$1 = _ref.$val; + check.updateExprType(x$1.X, typ, final$1); + } else if ($assertType(_ref, ($ptrType(ast.UnaryExpr)), true)[1]) { + x$1 = _ref.$val; + if (!($interfaceIsEqual(old.val, $ifaceNil))) { + break; } - $panic(new $String("Config.Sizes.Sizeof returned a size < 0")); + check.updateExprType(x$1.X, typ, final$1); + } else if ($assertType(_ref, ($ptrType(ast.BinaryExpr)), true)[1]) { + x$1 = _ref.$val; + if (!($interfaceIsEqual(old.val, $ifaceNil))) { + break; + } + if (isComparison(x$1.Op)) { + } else if (isShift(x$1.Op)) { + check.updateExprType(x$1.X, typ, final$1); + } else { + check.updateExprType(x$1.X, typ, final$1); + check.updateExprType(x$1.Y, typ, final$1); + } + } else { + x$1 = _ref; + unreachable(); + } } + if (!final$1 && isUntyped(typ)) { + old.typ = $assertType(typ.Underlying(), ($ptrType(Basic))); + _key$2 = x; (check.untyped || $throwRuntimeError("assignment to entry in nil map"))[_key$2.$key()] = { k: _key$2, v: old }; + return; } - return stdSizes.Sizeof(T); - }; - Config.prototype.sizeof = function(T) { return this.$val.sizeof(T); }; - align = function(x, a) { - var x$1, y, x$2; - y = (x$1 = new $Int64(x.$high + a.$high, x.$low + a.$low), new $Int64(x$1.$high - 0, x$1.$low - 1)); - return (x$2 = $div64(y, a, true), new $Int64(y.$high - x$2.$high, y.$low - x$2.$low)); + delete check.untyped[x.$key()]; + if (old.isLhs && !isInteger(typ)) { + check.invalidOp(x.Pos(), "shifted operand %s (type %s) must be integer", new ($sliceType($emptyInterface))([x, typ])); + return; + } + check.recordTypeAndValue(x, old.mode, typ, old.val); }; - Checker.Ptr.prototype.funcBody = function(decl, name, sig, body) { - var $deferred = [], $err = null, check; - /* */ try { $deferFrames.push($deferred); + Checker.prototype.updateExprType = function(x, typ, final$1) { return this.$val.updateExprType(x, typ, final$1); }; + Checker.Ptr.prototype.updateExprVal = function(x, val) { + var check, _tuple, _entry, info, ok, _key$2; check = this; - $deferred.push([(function(ctxt, indent) { - $copy(check.context, ctxt, context); - check.indent = indent; - }), [$clone(check.context, context), check.indent]]); - $copy(check.context, new context.Ptr(decl, sig.scope, $ifaceNil, sig, false, false), context); - check.indent = 0; - check.stmtList(0, body.List); - if (check.context.hasLabel) { - check.labels(body); + _tuple = (_entry = check.untyped[x.$key()], _entry !== undefined ? [_entry.v, true] : [new exprInfo.Ptr(), false]); info = new exprInfo.Ptr(); $copy(info, _tuple[0], exprInfo); ok = _tuple[1]; + if (ok) { + info.val = val; + _key$2 = x; (check.untyped || $throwRuntimeError("assignment to entry in nil map"))[_key$2.$key()] = { k: _key$2, v: info }; } - if (sig.results.Len() > 0 && !check.isTerminating(body, "")) { - check.error(body.Rbrace, "missing return"); + }; + Checker.prototype.updateExprVal = function(x, val) { return this.$val.updateExprVal(x, val); }; + Checker.Ptr.prototype.convertUntyped = function(x, target) { + var $this = this, $args = arguments, $s = 0, check, xkind, tkind, t, _ref, _ref$1; + /* */ while (true) { switch ($s) { case 0: + check = $this; + if ((x.mode === 0) || isTyped(x.typ) || $interfaceIsEqual(target, $pkg.Typ[0])) { + return; } - check.usage(sig.scope); - /* */ } catch(err) { $err = err; } finally { $deferFrames.pop(); $callDeferred($deferred, $err); } + /* if (isUntyped(target)) { */ if (isUntyped(target)) {} else { $s = 2; continue; } + xkind = $assertType(x.typ, ($ptrType(Basic))).kind; + tkind = $assertType(target, ($ptrType(Basic))).kind; + /* if (isNumeric(x.typ) && isNumeric(target)) { */ if (isNumeric(x.typ) && isNumeric(target)) {} else if (!((xkind === tkind))) { $s = 3; continue; } else { $s = 4; continue; } + if (xkind < tkind) { + x.typ = target; + check.updateExprType(x.expr, target, false); + } + /* } else if (!((xkind === tkind))) { */ $s = 4; continue; case 3: + /* goto Error */ $s = 1; continue; + /* } */ case 4: + return; + /* } */ case 2: + _ref = target.Underlying(); + /* if ($assertType(_ref, ($ptrType(Basic)), true)[1]) { */ if ($assertType(_ref, ($ptrType(Basic)), true)[1]) {} else if ($assertType(_ref, ($ptrType(Interface)), true)[1]) { $s = 5; continue; } else if ($assertType(_ref, ($ptrType(Pointer)), true)[1] || $assertType(_ref, ($ptrType(Signature)), true)[1] || $assertType(_ref, ($ptrType(Slice)), true)[1] || $assertType(_ref, ($ptrType(Map)), true)[1] || $assertType(_ref, ($ptrType(Chan)), true)[1]) { $s = 6; continue; } else { $s = 7; continue; } + t = _ref.$val; + /* if (x.mode === 4) { */ if (x.mode === 4) {} else { $s = 9; continue; } + check.representable(x, t); + if (x.mode === 0) { + return; + } + check.updateExprVal(x.expr, x.val); + /* } else { */ $s = 10; continue; case 9: + _ref$1 = $assertType(x.typ, ($ptrType(Basic))).kind; + /* if (_ref$1 === 19) { */ if (_ref$1 === 19) {} else if (_ref$1 === 20 || _ref$1 === 21 || _ref$1 === 22 || _ref$1 === 23) { $s = 11; continue; } else if (_ref$1 === 24) { $s = 12; continue; } else if (_ref$1 === 25) { $s = 13; continue; } else { $s = 14; continue; } + /* if (!isBoolean(target)) { */ if (!isBoolean(target)) {} else { $s = 16; continue; } + /* goto Error */ $s = 1; continue; + /* } */ case 16: + /* } else if (_ref$1 === 20 || _ref$1 === 21 || _ref$1 === 22 || _ref$1 === 23) { */ $s = 15; continue; case 11: + /* if (!isNumeric(target)) { */ if (!isNumeric(target)) {} else { $s = 17; continue; } + /* goto Error */ $s = 1; continue; + /* } */ case 17: + /* } else if (_ref$1 === 24) { */ $s = 15; continue; case 12: + unreachable(); + /* } else if (_ref$1 === 25) { */ $s = 15; continue; case 13: + /* if (!hasNil(target)) { */ if (!hasNil(target)) {} else { $s = 18; continue; } + /* goto Error */ $s = 1; continue; + /* } */ case 18: + /* } else { */ $s = 15; continue; case 14: + /* goto Error */ $s = 1; continue; + /* } */ case 15: + /* } */ case 10: + /* } else if ($assertType(_ref, ($ptrType(Interface)), true)[1]) { */ $s = 8; continue; case 5: + t = _ref.$val; + /* if (!x.isNil() && !t.Empty()) { */ if (!x.isNil() && !t.Empty()) {} else { $s = 19; continue; } + /* goto Error */ $s = 1; continue; + /* } */ case 19: + /* if (x.isNil()) { */ if (x.isNil()) {} else { $s = 20; continue; } + target = $pkg.Typ[25]; + /* } else { */ $s = 21; continue; case 20: + /* if (!t.Empty()) { */ if (!t.Empty()) {} else { $s = 22; continue; } + /* goto Error */ $s = 1; continue; + /* } */ case 22: + target = defaultType(x.typ); + /* } */ case 21: + /* } else if ($assertType(_ref, ($ptrType(Pointer)), true)[1] || $assertType(_ref, ($ptrType(Signature)), true)[1] || $assertType(_ref, ($ptrType(Slice)), true)[1] || $assertType(_ref, ($ptrType(Map)), true)[1] || $assertType(_ref, ($ptrType(Chan)), true)[1]) { */ $s = 8; continue; case 6: + t = _ref; + /* if (!x.isNil()) { */ if (!x.isNil()) {} else { $s = 23; continue; } + /* goto Error */ $s = 1; continue; + /* } */ case 23: + target = $pkg.Typ[25]; + /* } else { */ $s = 8; continue; case 7: + t = _ref; + /* goto Error */ $s = 1; continue; + /* } */ case 8: + x.typ = target; + check.updateExprType(x.expr, target, true); + return; + /* Error: */ case 1: + check.errorf(x.pos(), "cannot convert %s to %s", new ($sliceType($emptyInterface))([x, target])); + x.mode = 0; + /* */ case -1: } return; } }; - Checker.prototype.funcBody = function(decl, name, sig, body) { return this.$val.funcBody(decl, name, sig, body); }; - Checker.Ptr.prototype.usage = function(scope) { - var check, _ref, _i, _keys, _entry, obj, _tuple, v, _ref$1, _i$1, scope$1; + Checker.prototype.convertUntyped = function(x, target) { return this.$val.convertUntyped(x, target); }; + Checker.Ptr.prototype.comparison = function(x, y, op) { + var check, err, defined, _ref, typ; check = this; - _ref = scope.elems; - _i = 0; - _keys = $keys(_ref); - while (_i < _keys.length) { - _entry = _ref[_keys[_i]]; - if (_entry === undefined) { - _i++; - continue; + err = ""; + if (x.assignableTo(check.conf, y.typ) || y.assignableTo(check.conf, x.typ)) { + defined = false; + _ref = op; + if (_ref === 39 || _ref === 44) { + defined = Comparable(x.typ) || x.isNil() && hasNil(y.typ) || y.isNil() && hasNil(x.typ); + } else if (_ref === 40 || _ref === 45 || _ref === 41 || _ref === 46) { + defined = isOrdered(x.typ); + } else { + unreachable(); } - obj = _entry.v; - _tuple = $assertType(obj, ($ptrType(Var)), true); v = _tuple[0]; - if (!(v === ($ptrType(Var)).nil) && !v.object.used) { - check.softErrorf(v.object.pos, "%s declared but not used", new ($sliceType($emptyInterface))([new $String(v.object.name)])); + if (!defined) { + typ = x.typ; + if (x.isNil()) { + typ = y.typ; + } + err = check.sprintf("operator %s not defined for %s", new ($sliceType($emptyInterface))([new token.Token(op), typ])); } - _i++; + } else { + err = check.sprintf("mismatched types %s and %s", new ($sliceType($emptyInterface))([x.typ, y.typ])); } - _ref$1 = scope.children; - _i$1 = 0; - while (_i$1 < _ref$1.$length) { - scope$1 = ((_i$1 < 0 || _i$1 >= _ref$1.$length) ? $throwRuntimeError("index out of range") : _ref$1.$array[_ref$1.$offset + _i$1]); - check.usage(scope$1); - _i$1++; + if (!(err === "")) { + check.errorf(x.pos(), "cannot compare %s %s %s (%s)", new ($sliceType($emptyInterface))([x.expr, new token.Token(op), y.expr, new $String(err)])); + x.mode = 0; + return; } - }; - Checker.prototype.usage = function(scope) { return this.$val.usage(scope); }; - Checker.Ptr.prototype.initStmt = function(s) { - var check; - check = this; - if (!($interfaceIsEqual(s, $ifaceNil))) { - check.stmt(0, s); + if ((x.mode === 4) && (y.mode === 4)) { + x.val = exact.MakeBool(exact.Compare(x.val, op, y.val)); + } else { + x.mode = 7; + check.updateExprType(x.expr, defaultType(x.typ), true); + check.updateExprType(y.expr, defaultType(y.typ), true); } + x.typ = $pkg.Typ[19]; }; - Checker.prototype.initStmt = function(s) { return this.$val.initStmt(s); }; - Checker.Ptr.prototype.stmtList = function(ctxt, list) { - var check, ok, inner, _ref, _i, i, s, inner$1; + Checker.prototype.comparison = function(x, y, op) { return this.$val.comparison(x, y, op); }; + Checker.Ptr.prototype.shift = function(x, y, op) { + var check, untypedx, _tuple, s, ok, _tuple$1, _entry, info, found, _key$2; check = this; - ok = !((((ctxt & 1) >>> 0) === 0)); - inner = ctxt & ~1; - _ref = list; - _i = 0; - while (_i < _ref.$length) { - i = _i; - s = ((_i < 0 || _i >= _ref.$length) ? $throwRuntimeError("index out of range") : _ref.$array[_ref.$offset + _i]); - inner$1 = inner; - if (ok && ((i + 1 >> 0) === list.$length)) { - inner$1 = (inner$1 | (1)) >>> 0; + untypedx = isUntyped(x.typ); + if (!isInteger(x.typ) && (!untypedx || !representableConst(x.val, ($ptrType(Config)).nil, 20, ($ptrType(exact.Value)).nil))) { + check.invalidOp(x.pos(), "shifted operand %s must be integer", new ($sliceType($emptyInterface))([x])); + x.mode = 0; + return; + } + if (isInteger(y.typ) && isUnsigned(y.typ)) { + } else if (isUntyped(y.typ)) { + check.convertUntyped(y, $pkg.Typ[20]); + if (y.mode === 0) { + x.mode = 0; + return; } - check.stmt(inner$1, s); - _i++; + } else { + check.invalidOp(y.pos(), "shift count %s must be unsigned integer", new ($sliceType($emptyInterface))([y])); + x.mode = 0; + return; } - }; - Checker.prototype.stmtList = function(ctxt, list) { return this.$val.stmtList(ctxt, list); }; - Checker.Ptr.prototype.multipleDefaults = function(list) { - var check, first, _ref, _i, s, d, c, _ref$1; - check = this; - first = $ifaceNil; - _ref = list; - _i = 0; - while (_i < _ref.$length) { - s = ((_i < 0 || _i >= _ref.$length) ? $throwRuntimeError("index out of range") : _ref.$array[_ref.$offset + _i]); - d = $ifaceNil; - _ref$1 = s; - if ($assertType(_ref$1, ($ptrType(ast.CaseClause)), true)[1]) { - c = _ref$1.$val; - if (c.List.$length === 0) { - d = s; + if (x.mode === 4) { + if (y.mode === 4) { + _tuple = exact.Uint64Val(y.val); s = _tuple[0]; ok = _tuple[1]; + if (!ok || (s.$high > 0 || (s.$high === 0 && s.$low > 1074))) { + check.invalidOp(y.pos(), "stupid shift count %s", new ($sliceType($emptyInterface))([y])); + x.mode = 0; + return; } - } else if ($assertType(_ref$1, ($ptrType(ast.CommClause)), true)[1]) { - c = _ref$1.$val; - if ($interfaceIsEqual(c.Comm, $ifaceNil)) { - d = s; + if (!isInteger(x.typ)) { + x.typ = $pkg.Typ[20]; } - } else { - c = _ref$1; - check.invalidAST(s.Pos(), "case/communication clause expected", new ($sliceType($emptyInterface))([])); + x.val = exact.Shift(x.val, op, (s.$low >>> 0)); + return; } - if (!($interfaceIsEqual(d, $ifaceNil))) { - if (!($interfaceIsEqual(first, $ifaceNil))) { - check.errorf(d.Pos(), "multiple defaults (first at %s)", new ($sliceType($emptyInterface))([new token.Pos(first.Pos())])); - } else { - first = d; - } + if (untypedx) { + _tuple$1 = (_entry = check.untyped[x.expr.$key()], _entry !== undefined ? [_entry.v, true] : [new exprInfo.Ptr(), false]); info = new exprInfo.Ptr(); $copy(info, _tuple$1[0], exprInfo); found = _tuple$1[1]; + assert(found); + info.isLhs = true; + _key$2 = x.expr; (check.untyped || $throwRuntimeError("assignment to entry in nil map"))[_key$2.$key()] = { k: _key$2, v: info }; + x.mode = 7; + return; } - _i++; } - }; - Checker.prototype.multipleDefaults = function(list) { return this.$val.multipleDefaults(list); }; - Checker.Ptr.prototype.openScope = function(s, comment) { - var check, scope; - check = this; - scope = NewScope(check.context.scope, comment); - check.recordScope(s, scope); - check.context.scope = scope; - }; - Checker.prototype.openScope = function(s, comment) { return this.$val.openScope(s, comment); }; - Checker.Ptr.prototype.closeScope = function() { - var check; - check = this; - check.context.scope = check.context.scope.Parent(); - }; - Checker.prototype.closeScope = function() { return this.$val.closeScope(); }; - assignOp = function(op) { - if (23 <= op && op <= 33) { - return op + -11 >> 0; + if ((y.mode === 4) && exact.Sign(y.val) < 0) { + check.invalidOp(y.pos(), "shift count %s must not be negative", new ($sliceType($emptyInterface))([y])); } - return 0; + if (!isInteger(x.typ)) { + check.invalidOp(x.pos(), "shifted operand %s must be integer", new ($sliceType($emptyInterface))([x])); + x.mode = 0; + return; + } + x.mode = 7; }; - Checker.Ptr.prototype.suspendedCall = function(keyword, call) { - var check, x, msg, _ref; + Checker.prototype.shift = function(x, y, op) { return this.$val.shift(x, y, op); }; + Checker.Ptr.prototype.binary = function(x, lhs, rhs, op) { + var check, y, typ; check = this; - x = new operand.Ptr(); $copy(x, new operand.Ptr(), operand); - msg = ""; - _ref = check.rawExpr(x, call, $ifaceNil); - if (_ref === 0) { - msg = "requires function call, not conversion"; - } else if (_ref === 1) { - msg = "discards result of"; - } else if (_ref === 2) { + y = new operand.Ptr(); $copy(y, new operand.Ptr(), operand); + check.expr(x, lhs); + check.expr(y, rhs); + if (x.mode === 0) { return; - } else { - unreachable(); } - check.errorf(x.pos(), "%s %s %s", new ($sliceType($emptyInterface))([new $String(keyword), new $String(msg), x])); + if (y.mode === 0) { + x.mode = 0; + x.expr = y.expr; + return; + } + if (isShift(op)) { + check.shift(x, y, op); + return; + } + check.convertUntyped(x, y.typ); + if (x.mode === 0) { + return; + } + check.convertUntyped(y, x.typ); + if (y.mode === 0) { + x.mode = 0; + return; + } + if (isComparison(op)) { + check.comparison(x, y, op); + return; + } + if (!Identical(x.typ, y.typ)) { + if (!($interfaceIsEqual(x.typ, $pkg.Typ[0])) && !($interfaceIsEqual(y.typ, $pkg.Typ[0]))) { + check.invalidOp(x.pos(), "mismatched types %s and %s", new ($sliceType($emptyInterface))([x.typ, y.typ])); + } + x.mode = 0; + return; + } + if (!check.op(binaryOpPredicates, x, op)) { + x.mode = 0; + return; + } + if (((op === 15) || (op === 16)) && ((x.mode === 4) || isInteger(x.typ)) && (y.mode === 4) && (exact.Sign(y.val) === 0)) { + check.invalidOp(y.pos(), "division by zero", new ($sliceType($emptyInterface))([])); + x.mode = 0; + return; + } + if ((x.mode === 4) && (y.mode === 4)) { + typ = $assertType(x.typ.Underlying(), ($ptrType(Basic))); + if ((op === 15) && isInteger(typ)) { + op = 26; + } + x.val = exact.BinaryOp(x.val, op, y.val); + if (isTyped(typ)) { + check.representable(x, typ); + } + return; + } + x.mode = 7; }; - Checker.prototype.suspendedCall = function(keyword, call) { return this.$val.suspendedCall(keyword, call); }; - Checker.Ptr.prototype.caseValues = function(x, values) { - var check, _ref, _i, e, y; + Checker.prototype.binary = function(x, lhs, rhs, op) { return this.$val.binary(x, lhs, rhs, op); }; + Checker.Ptr.prototype.index = function(index, max) { + var i = new $Int64(0, 0), valid = false, check, x, _tuple, _tmp, _tmp$1, _tmp$2, _tmp$3, _tmp$4, _tmp$5; check = this; - _ref = values; - _i = 0; - while (_i < _ref.$length) { - e = ((_i < 0 || _i >= _ref.$length) ? $throwRuntimeError("index out of range") : _ref.$array[_ref.$offset + _i]); - y = new operand.Ptr(); $copy(y, new operand.Ptr(), operand); - check.expr(y, e); - if (y.mode === 0) { - return; - } - check.convertUntyped(y, x.typ); - if (y.mode === 0) { - return; + x = new operand.Ptr(); $copy(x, new operand.Ptr(), operand); + check.expr(x, index); + if (x.mode === 0) { + return [i, valid]; + } + check.convertUntyped(x, $pkg.Typ[2]); + if (x.mode === 0) { + return [i, valid]; + } + if (!isInteger(x.typ)) { + check.invalidArg(x.pos(), "index %s must be integer", new ($sliceType($emptyInterface))([x])); + return [i, valid]; + } + if (x.mode === 4) { + if (exact.Sign(x.val) < 0) { + check.invalidArg(x.pos(), "index %s must not be negative", new ($sliceType($emptyInterface))([x])); + return [i, valid]; } - check.convertUntyped(x, y.typ); - if (x.mode === 0) { - return; + _tuple = exact.Int64Val(x.val); i = _tuple[0]; valid = _tuple[1]; + if (!valid || (max.$high > 0 || (max.$high === 0 && max.$low >= 0)) && (i.$high > max.$high || (i.$high === max.$high && i.$low >= max.$low))) { + check.errorf(x.pos(), "index %s is out of bounds", new ($sliceType($emptyInterface))([x])); + _tmp = i; _tmp$1 = false; i = _tmp; valid = _tmp$1; + return [i, valid]; } - check.comparison(y, x, 39); - _i++; + _tmp$2 = i; _tmp$3 = true; i = _tmp$2; valid = _tmp$3; + return [i, valid]; } + _tmp$4 = new $Int64(-1, 4294967295); _tmp$5 = true; i = _tmp$4; valid = _tmp$5; + return [i, valid]; }; - Checker.prototype.caseValues = function(x, values) { return this.$val.caseValues(x, values); }; - Checker.Ptr.prototype.caseTypes = function(x, xtyp, types, seen) { - var T = $ifaceNil, check, _ref, _i, e, _ref$1, _i$1, _keys, _entry, t, pos, _key$2; + Checker.prototype.index = function(index, max) { return this.$val.index(index, max); }; + Checker.Ptr.prototype.indexedElts = function(elts, typ, length) { + var check, visited, _tmp, _tmp$1, index, max, _ref, _i, e, validIndex, eval$1, _tuple, kv, _tuple$1, i, ok, _entry, _key$2, x, x$1; check = this; - _ref = types; + visited = new $Map(); + _tmp = new $Int64(0, 0); _tmp$1 = new $Int64(0, 0); index = _tmp; max = _tmp$1; + _ref = elts; _i = 0; - L: while (_i < _ref.$length) { e = ((_i < 0 || _i >= _ref.$length) ? $throwRuntimeError("index out of range") : _ref.$array[_ref.$offset + _i]); - T = check.typOrNil(e); - if ($interfaceIsEqual(T, $pkg.Typ[0])) { - _i++; - continue; - } - _ref$1 = seen; - _i$1 = 0; - _keys = $keys(_ref$1); - while (_i$1 < _keys.length) { - _entry = _ref$1[_keys[_i$1]]; - if (_entry === undefined) { - _i$1++; - continue; + validIndex = false; + eval$1 = e; + _tuple = $assertType(e, ($ptrType(ast.KeyValueExpr)), true); kv = _tuple[0]; + if (!(kv === ($ptrType(ast.KeyValueExpr)).nil)) { + _tuple$1 = check.index(kv.Key, length); i = _tuple$1[0]; ok = _tuple$1[1]; + if (ok) { + if ((i.$high > 0 || (i.$high === 0 && i.$low >= 0))) { + index = i; + validIndex = true; + } else { + check.errorf(e.Pos(), "index %s must be integer constant", new ($sliceType($emptyInterface))([kv.Key])); + } } - t = _entry.k; - pos = _entry.v; - if ($interfaceIsEqual(T, $ifaceNil) && $interfaceIsEqual(t, $ifaceNil) || !($interfaceIsEqual(T, $ifaceNil)) && !($interfaceIsEqual(t, $ifaceNil)) && Identical(T, t)) { - check.error(e.Pos(), "duplicate case in type switch"); - check.errorf(pos, "\tprevious case %s", new ($sliceType($emptyInterface))([T])); - _i++; - continue L; + eval$1 = kv.Value; + } else if ((length.$high > 0 || (length.$high === 0 && length.$low >= 0)) && (index.$high > length.$high || (index.$high === length.$high && index.$low >= length.$low))) { + check.errorf(e.Pos(), "index %d is out of bounds (>= %d)", new ($sliceType($emptyInterface))([index, length])); + } else { + validIndex = true; + } + if (validIndex) { + if ((_entry = visited[index.$key()], _entry !== undefined ? _entry.v : false)) { + check.errorf(e.Pos(), "duplicate index %d in array or slice literal", new ($sliceType($emptyInterface))([index])); } - _i$1++; + _key$2 = index; (visited || $throwRuntimeError("assignment to entry in nil map"))[_key$2.$key()] = { k: _key$2, v: true }; } - _key$2 = T; (seen || $throwRuntimeError("assignment to entry in nil map"))[_key$2.$key()] = { k: _key$2, v: e.Pos() }; - if (!($interfaceIsEqual(T, $ifaceNil))) { - check.typeAssertion(e.Pos(), x, xtyp, T); + index = (x = new $Int64(0, 1), new $Int64(index.$high + x.$high, index.$low + x.$low)); + if ((index.$high > max.$high || (index.$high === max.$high && index.$low > max.$low))) { + max = index; + } + x$1 = new operand.Ptr(); $copy(x$1, new operand.Ptr(), operand); + check.exprWithHint(x$1, eval$1, typ); + if (!check.assignment(x$1, typ) && !((x$1.mode === 0))) { + check.errorf(x$1.pos(), "cannot use %s as %s value in array or slice literal", new ($sliceType($emptyInterface))([x$1, typ])); } _i++; } - return T; + return max; }; - Checker.prototype.caseTypes = function(x, xtyp, types, seen) { return this.$val.caseTypes(x, xtyp, types, seen); }; - Checker.Ptr.prototype.stmt = function(ctxt, s) { - var $deferred = [], $err = null, check, inner, s$1, _ref, x, kind, msg, _ref$1, _tmp, _tmp$1, ch, x$1, _tuple, tch, ok, op, _ref$2, x$2, Y, _ref$3, op$1, x$3, x$4, x$5, x$6, res, x$7, _ref$4, _i, obj, alt, x$8, _ref$5, x$9, x$10, _ref$6, _i$1, i, c, _tuple$1, clause, inner$1, lhs, rhs, guard, _ref$7, _tuple$2, x$11, x$12, _tuple$3, expr, x$13, _tuple$4, xtyp, lhsVars, seen, _ref$8, _i$2, s$2, _tuple$5, clause$1, T, obj$1, used, _ref$9, _i$3, v, _ref$10, _i$4, s$3, _tuple$6, clause$2, valid, rhs$1, s$4, _ref$11, x$14, _tuple$7, x$15, x$16, decl, x$17, _tmp$2, _tmp$3, key, val, typ, _ref$12, _tuple$8, typ$1, lhs$1, rhs$2, vars, _ref$13, _i$5, i$1, lhs$2, obj$2, _tuple$9, ident, name, _ref$14, _i$6, obj$3, _ref$15, _i$7, i$2, lhs$3; + Checker.prototype.indexedElts = function(elts, typ, length) { return this.$val.indexedElts(elts, typ, length); }; + Checker.Ptr.prototype.rawExpr = function(x, e, hint) { + var $deferred = [], $err = null, check, kind, typ, val, _ref; /* */ try { $deferFrames.push($deferred); check = this; - assert($interfaceIsEqual(check.context.iota, $ifaceNil)); - inner = ctxt & ~1; - _ref = s; - if ($assertType(_ref, ($ptrType(ast.BadStmt)), true)[1] || $assertType(_ref, ($ptrType(ast.EmptyStmt)), true)[1]) { - s$1 = _ref; - } else if ($assertType(_ref, ($ptrType(ast.DeclStmt)), true)[1]) { - s$1 = _ref.$val; - check.declStmt(s$1.Decl); - } else if ($assertType(_ref, ($ptrType(ast.LabeledStmt)), true)[1]) { - s$1 = _ref.$val; - check.context.hasLabel = true; - check.stmt(ctxt, s$1.Stmt); - } else if ($assertType(_ref, ($ptrType(ast.ExprStmt)), true)[1]) { - s$1 = _ref.$val; - x = new operand.Ptr(); $copy(x, new operand.Ptr(), operand); - kind = check.rawExpr(x, s$1.X, $ifaceNil); - msg = ""; - _ref$1 = x.mode; - if (_ref$1 === 2) { - msg = "must be called"; - } else if (_ref$1 === 3) { - msg = "is not an expression"; - } else { - if (kind === 2) { - return; + kind = check.exprInternal(x, e, hint); + typ = $ifaceNil; + val = $ifaceNil; + _ref = x.mode; + if (_ref === 0) { + typ = $pkg.Typ[0]; + } else if (_ref === 1) { + typ = ($ptrType(Tuple)).nil; + } else if (_ref === 4) { + typ = x.typ; + val = x.val; + } else { + typ = x.typ; + } + assert(!($interfaceIsEqual(x.expr, $ifaceNil)) && !($interfaceIsEqual(typ, $ifaceNil))); + if (isUntyped(typ)) { + check.rememberUntyped(x.expr, false, x.mode, $assertType(typ, ($ptrType(Basic))), val); + } else { + check.recordTypeAndValue(e, x.mode, typ, val); + } + return kind; + /* */ } catch(err) { $err = err; return 0; } finally { $deferFrames.pop(); $callDeferred($deferred, $err); } + }; + Checker.prototype.rawExpr = function(x, e, hint) { return this.$val.rawExpr(x, e, hint); }; + Checker.Ptr.prototype.exprInternal = function(x, e, hint) { + var $this = this, $args = arguments, $s = 0, check, e$1, _ref, _tuple, sig, ok, typ, openArray, _tuple$1, atyp, _tuple$2, ellip, _tuple$3, typ$1, utyp, _ref$1, fields, _tuple$4, x$1, ok$1, visited, _ref$2, _i, e$2, _tuple$5, kv, _tuple$6, key, i, fld, etyp, _ref$3, _i$1, i$1, e$3, _tuple$7, kv$1, etyp$1, n, visited$1, _ref$4, _i$2, e$4, _tuple$8, kv$2, duplicate, _tuple$9, ok$2, _ref$5, _entry, _i$3, vtyp, _entry$1, _key$2, _tuple$10, _entry$2, _key$3, kind, valid, length, typ$2, _ref$6, _tuple$11, typ$3, key$1, valid$1, length$1, typ$4, _ref$7, _tuple$12, typ$5, ind, _ref$8, _i$4, i$2, expr, x$2, max, _tuple$13, t, ok$3, _ref$9, _i$5, i$3, x$3, _ref$10, _i$6, y, _tuple$14, xtyp, T, _ref$11, _tuple$15, typ$6, ok$4, x$4; + /* */ while (true) { switch ($s) { case 0: + check = $this; + x.mode = 0; + x.typ = $pkg.Typ[0]; + _ref = e; + /* if ($assertType(_ref, ($ptrType(ast.BadExpr)), true)[1]) { */ if ($assertType(_ref, ($ptrType(ast.BadExpr)), true)[1]) {} else if ($assertType(_ref, ($ptrType(ast.Ident)), true)[1]) { $s = 2; continue; } else if ($assertType(_ref, ($ptrType(ast.Ellipsis)), true)[1]) { $s = 3; continue; } else if ($assertType(_ref, ($ptrType(ast.BasicLit)), true)[1]) { $s = 4; continue; } else if ($assertType(_ref, ($ptrType(ast.FuncLit)), true)[1]) { $s = 5; continue; } else if ($assertType(_ref, ($ptrType(ast.CompositeLit)), true)[1]) { $s = 6; continue; } else if ($assertType(_ref, ($ptrType(ast.ParenExpr)), true)[1]) { $s = 7; continue; } else if ($assertType(_ref, ($ptrType(ast.SelectorExpr)), true)[1]) { $s = 8; continue; } else if ($assertType(_ref, ($ptrType(ast.IndexExpr)), true)[1]) { $s = 9; continue; } else if ($assertType(_ref, ($ptrType(ast.SliceExpr)), true)[1]) { $s = 10; continue; } else if ($assertType(_ref, ($ptrType(ast.TypeAssertExpr)), true)[1]) { $s = 11; continue; } else if ($assertType(_ref, ($ptrType(ast.CallExpr)), true)[1]) { $s = 12; continue; } else if ($assertType(_ref, ($ptrType(ast.StarExpr)), true)[1]) { $s = 13; continue; } else if ($assertType(_ref, ($ptrType(ast.UnaryExpr)), true)[1]) { $s = 14; continue; } else if ($assertType(_ref, ($ptrType(ast.BinaryExpr)), true)[1]) { $s = 15; continue; } else if ($assertType(_ref, ($ptrType(ast.KeyValueExpr)), true)[1]) { $s = 16; continue; } else if ($assertType(_ref, ($ptrType(ast.ArrayType)), true)[1] || $assertType(_ref, ($ptrType(ast.StructType)), true)[1] || $assertType(_ref, ($ptrType(ast.FuncType)), true)[1] || $assertType(_ref, ($ptrType(ast.InterfaceType)), true)[1] || $assertType(_ref, ($ptrType(ast.MapType)), true)[1] || $assertType(_ref, ($ptrType(ast.ChanType)), true)[1]) { $s = 17; continue; } else { $s = 18; continue; } + e$1 = _ref.$val; + /* goto Error */ $s = 1; continue; + /* } else if ($assertType(_ref, ($ptrType(ast.Ident)), true)[1]) { */ $s = 19; continue; case 2: + e$1 = _ref.$val; + check.ident(x, e$1, ($ptrType(Named)).nil, ($sliceType(($ptrType(TypeName)))).nil); + /* } else if ($assertType(_ref, ($ptrType(ast.Ellipsis)), true)[1]) { */ $s = 19; continue; case 3: + e$1 = _ref.$val; + check.error(e$1.Pos(), "invalid use of '...'"); + /* goto Error */ $s = 1; continue; + /* } else if ($assertType(_ref, ($ptrType(ast.BasicLit)), true)[1]) { */ $s = 19; continue; case 4: + e$1 = _ref.$val; + x.setConst(e$1.Kind, e$1.Value); + /* if (x.mode === 0) { */ if (x.mode === 0) {} else { $s = 20; continue; } + check.invalidAST(e$1.Pos(), "invalid literal %v", new ($sliceType($emptyInterface))([new $String(e$1.Value)])); + /* goto Error */ $s = 1; continue; + /* } */ case 20: + /* } else if ($assertType(_ref, ($ptrType(ast.FuncLit)), true)[1]) { */ $s = 19; continue; case 5: + e$1 = _ref.$val; + _tuple = $assertType(check.typ(e$1.Type), ($ptrType(Signature)), true); sig = _tuple[0]; ok = _tuple[1]; + /* if (ok) { */ if (ok) {} else { $s = 21; continue; } + check.funcBody(check.context.decl, "", sig, e$1.Body); + x.mode = 7; + x.typ = sig; + /* } else { */ $s = 22; continue; case 21: + check.invalidAST(e$1.Pos(), "invalid function literal %s", new ($sliceType($emptyInterface))([e$1])); + /* goto Error */ $s = 1; continue; + /* } */ case 22: + /* } else if ($assertType(_ref, ($ptrType(ast.CompositeLit)), true)[1]) { */ $s = 19; continue; case 6: + e$1 = _ref.$val; + typ = hint; + openArray = false; + if (!($interfaceIsEqual(e$1.Type, $ifaceNil))) { + typ = $ifaceNil; + _tuple$1 = $assertType(e$1.Type, ($ptrType(ast.ArrayType)), true); atyp = _tuple$1[0]; + if (!(atyp === ($ptrType(ast.ArrayType)).nil) && !($interfaceIsEqual(atyp.Len, $ifaceNil))) { + _tuple$2 = $assertType(atyp.Len, ($ptrType(ast.Ellipsis)), true); ellip = _tuple$2[0]; + if (!(ellip === ($ptrType(ast.Ellipsis)).nil) && $interfaceIsEqual(ellip.Elt, $ifaceNil)) { + typ = new Array.Ptr(new $Int64(-1, 4294967295), check.typ(atyp.Elt)); + openArray = true; + } } - msg = "is not used"; - } - check.errorf(x.pos(), "%s %s", new ($sliceType($emptyInterface))([x, new $String(msg)])); - } else if ($assertType(_ref, ($ptrType(ast.SendStmt)), true)[1]) { - s$1 = _ref.$val; - _tmp = new operand.Ptr(); $copy(_tmp, new operand.Ptr(), operand); _tmp$1 = new operand.Ptr(); $copy(_tmp$1, new operand.Ptr(), operand); ch = new operand.Ptr(); $copy(ch, _tmp, operand); x$1 = new operand.Ptr(); $copy(x$1, _tmp$1, operand); - check.expr(ch, s$1.Chan); - check.expr(x$1, s$1.Value); - if ((ch.mode === 0) || (x$1.mode === 0)) { - return; - } - _tuple = $assertType(ch.typ.Underlying(), ($ptrType(Chan)), true); tch = _tuple[0]; ok = _tuple[1]; - if (!ok || (tch.dir === 2) || !check.assignment(x$1, tch.elem)) { - if (!((x$1.mode === 0))) { - check.invalidOp(ch.pos(), "cannot send %s to channel %s", new ($sliceType($emptyInterface))([x$1, ch])); + if ($interfaceIsEqual(typ, $ifaceNil)) { + typ = check.typ(e$1.Type); } } - } else if ($assertType(_ref, ($ptrType(ast.IncDecStmt)), true)[1]) { - s$1 = _ref.$val; - op = 0; - _ref$2 = s$1.Tok; - if (_ref$2 === 37) { - op = 12; - } else if (_ref$2 === 38) { - op = 13; - } else { - check.invalidAST(s$1.TokPos, "unknown inc/dec operation %s", new ($sliceType($emptyInterface))([new token.Token(s$1.Tok)])); - return; - } - x$2 = new operand.Ptr(); $copy(x$2, new operand.Ptr(), operand); - Y = new ast.BasicLit.Ptr(s$1.X.Pos(), 5, "1"); - check.binary(x$2, s$1.X, Y, op); - if (x$2.mode === 0) { - return; - } - check.assignVar(s$1.X, x$2); - } else if ($assertType(_ref, ($ptrType(ast.AssignStmt)), true)[1]) { - s$1 = _ref.$val; - _ref$3 = s$1.Tok; - if (_ref$3 === 42 || _ref$3 === 47) { - if (s$1.Lhs.$length === 0) { - check.invalidAST(s$1.Pos(), "missing lhs in assignment", new ($sliceType($emptyInterface))([])); - return; - } - if (s$1.Tok === 47) { - check.shortVarDecl(s$1.TokPos, s$1.Lhs, s$1.Rhs); - } else { - check.assignVars(s$1.Lhs, s$1.Rhs); - } - } else { - if (!((s$1.Lhs.$length === 1)) || !((s$1.Rhs.$length === 1))) { - check.errorf(s$1.TokPos, "assignment operation %s requires single-valued expressions", new ($sliceType($emptyInterface))([new token.Token(s$1.Tok)])); - return; - } - op$1 = assignOp(s$1.Tok); - if (op$1 === 0) { - check.invalidAST(s$1.TokPos, "unknown assignment operation %s", new ($sliceType($emptyInterface))([new token.Token(s$1.Tok)])); - return; - } - x$3 = new operand.Ptr(); $copy(x$3, new operand.Ptr(), operand); - check.binary(x$3, (x$4 = s$1.Lhs, ((0 < 0 || 0 >= x$4.$length) ? $throwRuntimeError("index out of range") : x$4.$array[x$4.$offset + 0])), (x$5 = s$1.Rhs, ((0 < 0 || 0 >= x$5.$length) ? $throwRuntimeError("index out of range") : x$5.$array[x$5.$offset + 0])), op$1); - if (x$3.mode === 0) { - return; + /* if ($interfaceIsEqual(typ, $ifaceNil)) { */ if ($interfaceIsEqual(typ, $ifaceNil)) {} else { $s = 23; continue; } + check.error(e$1.Pos(), "missing type in composite literal"); + /* goto Error */ $s = 1; continue; + /* } */ case 23: + _tuple$3 = deref(typ); typ$1 = _tuple$3[0]; + _ref$1 = typ$1.Underlying(); + /* switch (0) { default: if ($assertType(_ref$1, ($ptrType(Struct)), true)[1]) { */ if ($assertType(_ref$1, ($ptrType(Struct)), true)[1]) {} else if ($assertType(_ref$1, ($ptrType(Array)), true)[1]) { $s = 24; continue; } else if ($assertType(_ref$1, ($ptrType(Slice)), true)[1]) { $s = 25; continue; } else if ($assertType(_ref$1, ($ptrType(Map)), true)[1]) { $s = 26; continue; } else { $s = 27; continue; } + utyp = _ref$1.$val; + if (e$1.Elts.$length === 0) { + /* break; */ $s = 28; continue; } - check.assignVar((x$6 = s$1.Lhs, ((0 < 0 || 0 >= x$6.$length) ? $throwRuntimeError("index out of range") : x$6.$array[x$6.$offset + 0])), x$3); - } - } else if ($assertType(_ref, ($ptrType(ast.GoStmt)), true)[1]) { - s$1 = _ref.$val; - check.suspendedCall("go", s$1.Call); - } else if ($assertType(_ref, ($ptrType(ast.DeferStmt)), true)[1]) { - s$1 = _ref.$val; - check.suspendedCall("defer", s$1.Call); - } else if ($assertType(_ref, ($ptrType(ast.ReturnStmt)), true)[1]) { - s$1 = _ref.$val; - res = check.context.sig.results; - if (res.Len() > 0) { - if ((s$1.Results.$length === 0) && !((x$7 = res.vars, ((0 < 0 || 0 >= x$7.$length) ? $throwRuntimeError("index out of range") : x$7.$array[x$7.$offset + 0])).object.name === "")) { - _ref$4 = res.vars; + fields = utyp.fields; + _tuple$4 = $assertType((x$1 = e$1.Elts, ((0 < 0 || 0 >= x$1.$length) ? $throwRuntimeError("index out of range") : x$1.$array[x$1.$offset + 0])), ($ptrType(ast.KeyValueExpr)), true); ok$1 = _tuple$4[1]; + if (ok$1) { + visited = ($sliceType($Bool)).make(fields.$length); + _ref$2 = e$1.Elts; _i = 0; - while (_i < _ref$4.$length) { - obj = ((_i < 0 || _i >= _ref$4.$length) ? $throwRuntimeError("index out of range") : _ref$4.$array[_ref$4.$offset + _i]); - alt = check.context.scope.LookupParent(obj.object.name); - if (!($interfaceIsEqual(alt, $ifaceNil)) && !($interfaceIsEqual(alt, obj))) { - check.errorf(s$1.Pos(), "result parameter %s not in scope at return", new ($sliceType($emptyInterface))([new $String(obj.object.name)])); - check.errorf(alt.Pos(), "\tinner declaration of %s", new ($sliceType($emptyInterface))([obj])); + while (_i < _ref$2.$length) { + e$2 = ((_i < 0 || _i >= _ref$2.$length) ? $throwRuntimeError("index out of range") : _ref$2.$array[_ref$2.$offset + _i]); + _tuple$5 = $assertType(e$2, ($ptrType(ast.KeyValueExpr)), true); kv = _tuple$5[0]; + if (kv === ($ptrType(ast.KeyValueExpr)).nil) { + check.error(e$2.Pos(), "mixture of field:value and value elements in struct literal"); + _i++; + continue; + } + _tuple$6 = $assertType(kv.Key, ($ptrType(ast.Ident)), true); key = _tuple$6[0]; + if (key === ($ptrType(ast.Ident)).nil) { + check.errorf(kv.Pos(), "invalid field name %s in struct literal", new ($sliceType($emptyInterface))([kv.Key])); + _i++; + continue; + } + i = fieldIndex(utyp.fields, check.pkg, key.Name); + if (i < 0) { + check.errorf(kv.Pos(), "unknown field %s in struct literal", new ($sliceType($emptyInterface))([new $String(key.Name)])); + _i++; + continue; + } + fld = ((i < 0 || i >= fields.$length) ? $throwRuntimeError("index out of range") : fields.$array[fields.$offset + i]); + check.recordUse(key, fld); + if (((i < 0 || i >= visited.$length) ? $throwRuntimeError("index out of range") : visited.$array[visited.$offset + i])) { + check.errorf(kv.Pos(), "duplicate field name %s in struct literal", new ($sliceType($emptyInterface))([new $String(key.Name)])); + _i++; + continue; + } + (i < 0 || i >= visited.$length) ? $throwRuntimeError("index out of range") : visited.$array[visited.$offset + i] = true; + check.expr(x, kv.Value); + etyp = fld.object.typ; + if (!check.assignment(x, etyp)) { + if (!((x.mode === 0))) { + check.errorf(x.pos(), "cannot use %s as %s value in struct literal", new ($sliceType($emptyInterface))([x, etyp])); + } + _i++; + continue; } _i++; } } else { - check.initVars(res.vars, s$1.Results, s$1.Return); - } - } else if (s$1.Results.$length > 0) { - check.error((x$8 = s$1.Results, ((0 < 0 || 0 >= x$8.$length) ? $throwRuntimeError("index out of range") : x$8.$array[x$8.$offset + 0])).Pos(), "no result values expected"); - check.use(s$1.Results); - } - } else if ($assertType(_ref, ($ptrType(ast.BranchStmt)), true)[1]) { - s$1 = _ref.$val; - if (!(s$1.Label === ($ptrType(ast.Ident)).nil)) { - check.context.hasLabel = true; - return; - } - _ref$5 = s$1.Tok; - if (_ref$5 === 61) { - if (((ctxt & 2) >>> 0) === 0) { - check.error(s$1.Pos(), "break not in for, switch, or select statement"); - } - } else if (_ref$5 === 65) { - if (((ctxt & 4) >>> 0) === 0) { - check.error(s$1.Pos(), "continue not in for statement"); - } - } else if (_ref$5 === 69) { - if (((ctxt & 1) >>> 0) === 0) { - check.error(s$1.Pos(), "fallthrough statement out of place"); - } - } else { - check.invalidAST(s$1.Pos(), "branch statement: %s", new ($sliceType($emptyInterface))([new token.Token(s$1.Tok)])); - } - } else if ($assertType(_ref, ($ptrType(ast.BlockStmt)), true)[1]) { - s$1 = _ref.$val; - check.openScope(s$1, "block"); - $deferred.push([$methodVal(check, "closeScope"), []]); - check.stmtList(inner, s$1.List); - } else if ($assertType(_ref, ($ptrType(ast.IfStmt)), true)[1]) { - s$1 = _ref.$val; - check.openScope(s$1, "if"); - $deferred.push([$methodVal(check, "closeScope"), []]); - check.initStmt(s$1.Init); - x$9 = new operand.Ptr(); $copy(x$9, new operand.Ptr(), operand); - check.expr(x$9, s$1.Cond); - if (!((x$9.mode === 0)) && !isBoolean(x$9.typ)) { - check.error(s$1.Cond.Pos(), "non-boolean condition in if statement"); - } - check.stmt(inner, s$1.Body); - if (!($interfaceIsEqual(s$1.Else, $ifaceNil))) { - check.stmt(inner, s$1.Else); - } - } else if ($assertType(_ref, ($ptrType(ast.SwitchStmt)), true)[1]) { - s$1 = _ref.$val; - inner = (inner | (2)) >>> 0; - check.openScope(s$1, "switch"); - $deferred.push([$methodVal(check, "closeScope"), []]); - check.initStmt(s$1.Init); - x$10 = new operand.Ptr(); $copy(x$10, new operand.Ptr(), operand); - if (!($interfaceIsEqual(s$1.Tag, $ifaceNil))) { - check.expr(x$10, s$1.Tag); - } else { - x$10.mode = 4; - x$10.typ = $pkg.Typ[1]; - x$10.val = exact.MakeBool(true); - x$10.expr = new ast.Ident.Ptr(s$1.Body.Lbrace, "true", ($ptrType(ast.Object)).nil); - } - check.multipleDefaults(s$1.Body.List); - _ref$6 = s$1.Body.List; - _i$1 = 0; - while (_i$1 < _ref$6.$length) { - i = _i$1; - c = ((_i$1 < 0 || _i$1 >= _ref$6.$length) ? $throwRuntimeError("index out of range") : _ref$6.$array[_ref$6.$offset + _i$1]); - _tuple$1 = $assertType(c, ($ptrType(ast.CaseClause)), true); clause = _tuple$1[0]; - if (clause === ($ptrType(ast.CaseClause)).nil) { - check.invalidAST(c.Pos(), "incorrect expression switch case", new ($sliceType($emptyInterface))([])); - _i$1++; - continue; - } - if (!((x$10.mode === 0))) { - check.caseValues($clone(x$10, operand), clause.List); - } - check.openScope(clause, "case"); - inner$1 = inner; - if ((i + 1 >> 0) < s$1.Body.List.$length) { - inner$1 = (inner$1 | (1)) >>> 0; - } - check.stmtList(inner$1, clause.Body); - check.closeScope(); - _i$1++; - } - } else if ($assertType(_ref, ($ptrType(ast.TypeSwitchStmt)), true)[1]) { - s$1 = _ref.$val; - inner = (inner | (2)) >>> 0; - check.openScope(s$1, "type switch"); - $deferred.push([$methodVal(check, "closeScope"), []]); - check.initStmt(s$1.Init); - lhs = ($ptrType(ast.Ident)).nil; - rhs = $ifaceNil; - _ref$7 = s$1.Assign; - if ($assertType(_ref$7, ($ptrType(ast.ExprStmt)), true)[1]) { - guard = _ref$7.$val; - rhs = guard.X; - } else if ($assertType(_ref$7, ($ptrType(ast.AssignStmt)), true)[1]) { - guard = _ref$7.$val; - if (!((guard.Lhs.$length === 1)) || !((guard.Tok === 47)) || !((guard.Rhs.$length === 1))) { - check.invalidAST(s$1.Pos(), "incorrect form of type switch guard", new ($sliceType($emptyInterface))([])); - return; - } - _tuple$2 = $assertType((x$11 = guard.Lhs, ((0 < 0 || 0 >= x$11.$length) ? $throwRuntimeError("index out of range") : x$11.$array[x$11.$offset + 0])), ($ptrType(ast.Ident)), true); lhs = _tuple$2[0]; - if (lhs === ($ptrType(ast.Ident)).nil) { - check.invalidAST(s$1.Pos(), "incorrect form of type switch guard", new ($sliceType($emptyInterface))([])); - return; - } - check.recordDef(lhs, $ifaceNil); - rhs = (x$12 = guard.Rhs, ((0 < 0 || 0 >= x$12.$length) ? $throwRuntimeError("index out of range") : x$12.$array[x$12.$offset + 0])); - } else { - guard = _ref$7; - check.invalidAST(s$1.Pos(), "incorrect form of type switch guard", new ($sliceType($emptyInterface))([])); - return; - } - _tuple$3 = $assertType(rhs, ($ptrType(ast.TypeAssertExpr)), true); expr = _tuple$3[0]; - if (expr === ($ptrType(ast.TypeAssertExpr)).nil || !($interfaceIsEqual(expr.Type, $ifaceNil))) { - check.invalidAST(s$1.Pos(), "incorrect form of type switch guard", new ($sliceType($emptyInterface))([])); - return; - } - x$13 = new operand.Ptr(); $copy(x$13, new operand.Ptr(), operand); - check.expr(x$13, expr.X); - if (x$13.mode === 0) { - return; - } - _tuple$4 = $assertType(x$13.typ.Underlying(), ($ptrType(Interface)), true); xtyp = _tuple$4[0]; - if (xtyp === ($ptrType(Interface)).nil) { - check.errorf(x$13.pos(), "%s is not an interface", new ($sliceType($emptyInterface))([x$13])); - return; - } - check.multipleDefaults(s$1.Body.List); - lhsVars = ($sliceType(($ptrType(Var)))).nil; - seen = new $Map(); - _ref$8 = s$1.Body.List; - _i$2 = 0; - while (_i$2 < _ref$8.$length) { - s$2 = ((_i$2 < 0 || _i$2 >= _ref$8.$length) ? $throwRuntimeError("index out of range") : _ref$8.$array[_ref$8.$offset + _i$2]); - _tuple$5 = $assertType(s$2, ($ptrType(ast.CaseClause)), true); clause$1 = _tuple$5[0]; - if (clause$1 === ($ptrType(ast.CaseClause)).nil) { - check.invalidAST(s$2.Pos(), "incorrect type switch case", new ($sliceType($emptyInterface))([])); - _i$2++; - continue; - } - T = check.caseTypes(x$13, xtyp, clause$1.List, seen); - check.openScope(clause$1, "case"); - if (!(lhs === ($ptrType(ast.Ident)).nil)) { - if (!((clause$1.List.$length === 1)) || $interfaceIsEqual(T, $ifaceNil)) { - T = x$13.typ; - } - obj$1 = NewVar(lhs.Pos(), check.pkg, lhs.Name, T); - check.declare(check.context.scope, ($ptrType(ast.Ident)).nil, obj$1); - check.recordImplicit(clause$1, obj$1); - lhsVars = $append(lhsVars, obj$1); - } - check.stmtList(inner, clause$1.Body); - check.closeScope(); - _i$2++; - } - if (!(lhs === ($ptrType(ast.Ident)).nil)) { - used = false; - _ref$9 = lhsVars; - _i$3 = 0; - while (_i$3 < _ref$9.$length) { - v = ((_i$3 < 0 || _i$3 >= _ref$9.$length) ? $throwRuntimeError("index out of range") : _ref$9.$array[_ref$9.$offset + _i$3]); - if (v.object.used) { - used = true; + _ref$3 = e$1.Elts; + _i$1 = 0; + while (_i$1 < _ref$3.$length) { + i$1 = _i$1; + e$3 = ((_i$1 < 0 || _i$1 >= _ref$3.$length) ? $throwRuntimeError("index out of range") : _ref$3.$array[_ref$3.$offset + _i$1]); + _tuple$7 = $assertType(e$3, ($ptrType(ast.KeyValueExpr)), true); kv$1 = _tuple$7[0]; + if (!(kv$1 === ($ptrType(ast.KeyValueExpr)).nil)) { + check.error(kv$1.Pos(), "mixture of field:value and value elements in struct literal"); + _i$1++; + continue; + } + check.expr(x, e$3); + if (i$1 >= fields.$length) { + check.error(x.pos(), "too many values in struct literal"); + break; + } + etyp$1 = ((i$1 < 0 || i$1 >= fields.$length) ? $throwRuntimeError("index out of range") : fields.$array[fields.$offset + i$1]).object.typ; + if (!check.assignment(x, etyp$1)) { + if (!((x.mode === 0))) { + check.errorf(x.pos(), "cannot use %s as %s value in struct literal", new ($sliceType($emptyInterface))([x, etyp$1])); + } + _i$1++; + continue; + } + _i$1++; + } + if (e$1.Elts.$length < fields.$length) { + check.error(e$1.Rbrace, "too few values in struct literal"); } - v.object.used = true; - _i$3++; - } - if (!used) { - check.softErrorf(lhs.Pos(), "%s declared but not used", new ($sliceType($emptyInterface))([new $String(lhs.Name)])); } - } - } else if ($assertType(_ref, ($ptrType(ast.SelectStmt)), true)[1]) { - s$1 = _ref.$val; - inner = (inner | (2)) >>> 0; - check.multipleDefaults(s$1.Body.List); - _ref$10 = s$1.Body.List; - _i$4 = 0; - while (_i$4 < _ref$10.$length) { - s$3 = ((_i$4 < 0 || _i$4 >= _ref$10.$length) ? $throwRuntimeError("index out of range") : _ref$10.$array[_ref$10.$offset + _i$4]); - _tuple$6 = $assertType(s$3, ($ptrType(ast.CommClause)), true); clause$2 = _tuple$6[0]; - if (clause$2 === ($ptrType(ast.CommClause)).nil) { - _i$4++; - continue; + /* } else if ($assertType(_ref$1, ($ptrType(Array)), true)[1]) { */ $s = 28; continue; case 24: + utyp = _ref$1.$val; + n = check.indexedElts(e$1.Elts, utyp.elem, utyp.len); + if (openArray) { + utyp.len = n; } - valid = false; - rhs$1 = $ifaceNil; - _ref$11 = clause$2.Comm; - if (_ref$11 === $ifaceNil || $assertType(_ref$11, ($ptrType(ast.SendStmt)), true)[1]) { - s$4 = _ref$11; - valid = true; - } else if ($assertType(_ref$11, ($ptrType(ast.AssignStmt)), true)[1]) { - s$4 = _ref$11.$val; - if (s$4.Rhs.$length === 1) { - rhs$1 = (x$14 = s$4.Rhs, ((0 < 0 || 0 >= x$14.$length) ? $throwRuntimeError("index out of range") : x$14.$array[x$14.$offset + 0])); + /* } else if ($assertType(_ref$1, ($ptrType(Slice)), true)[1]) { */ $s = 28; continue; case 25: + utyp = _ref$1.$val; + check.indexedElts(e$1.Elts, utyp.elem, new $Int64(-1, 4294967295)); + /* } else if ($assertType(_ref$1, ($ptrType(Map)), true)[1]) { */ $s = 28; continue; case 26: + utyp = _ref$1.$val; + visited$1 = new $Map(); + _ref$4 = e$1.Elts; + _i$2 = 0; + while (_i$2 < _ref$4.$length) { + e$4 = ((_i$2 < 0 || _i$2 >= _ref$4.$length) ? $throwRuntimeError("index out of range") : _ref$4.$array[_ref$4.$offset + _i$2]); + _tuple$8 = $assertType(e$4, ($ptrType(ast.KeyValueExpr)), true); kv$2 = _tuple$8[0]; + if (kv$2 === ($ptrType(ast.KeyValueExpr)).nil) { + check.error(e$4.Pos(), "missing key in map literal"); + _i$2++; + continue; } - } else if ($assertType(_ref$11, ($ptrType(ast.ExprStmt)), true)[1]) { - s$4 = _ref$11.$val; - rhs$1 = s$4.X; - } - if (!($interfaceIsEqual(rhs$1, $ifaceNil))) { - _tuple$7 = $assertType(unparen(rhs$1), ($ptrType(ast.UnaryExpr)), true); x$15 = _tuple$7[0]; - if (!(x$15 === ($ptrType(ast.UnaryExpr)).nil) && (x$15.Op === 36)) { - valid = true; + check.expr(x, kv$2.Key); + if (!check.assignment(x, utyp.key)) { + if (!((x.mode === 0))) { + check.errorf(x.pos(), "cannot use %s as %s key in map literal", new ($sliceType($emptyInterface))([x, utyp.key])); + } + _i$2++; + continue; } + if (x.mode === 4) { + duplicate = false; + _tuple$9 = $assertType(utyp.key.Underlying(), ($ptrType(Interface)), true); ok$2 = _tuple$9[1]; + if (ok$2) { + _ref$5 = (_entry = visited$1[x.val.$key()], _entry !== undefined ? _entry.v : ($sliceType(Type)).nil); + _i$3 = 0; + while (_i$3 < _ref$5.$length) { + vtyp = ((_i$3 < 0 || _i$3 >= _ref$5.$length) ? $throwRuntimeError("index out of range") : _ref$5.$array[_ref$5.$offset + _i$3]); + if (Identical(vtyp, x.typ)) { + duplicate = true; + break; + } + _i$3++; + } + _key$2 = x.val; (visited$1 || $throwRuntimeError("assignment to entry in nil map"))[_key$2.$key()] = { k: _key$2, v: $append((_entry$1 = visited$1[x.val.$key()], _entry$1 !== undefined ? _entry$1.v : ($sliceType(Type)).nil), x.typ) }; + } else { + _tuple$10 = (_entry$2 = visited$1[x.val.$key()], _entry$2 !== undefined ? [_entry$2.v, true] : [($sliceType(Type)).nil, false]); duplicate = _tuple$10[1]; + _key$3 = x.val; (visited$1 || $throwRuntimeError("assignment to entry in nil map"))[_key$3.$key()] = { k: _key$3, v: ($sliceType(Type)).nil }; + } + if (duplicate) { + check.errorf(x.pos(), "duplicate key %s in map literal", new ($sliceType($emptyInterface))([x.val])); + _i$2++; + continue; + } + } + check.exprWithHint(x, kv$2.Value, utyp.elem); + if (!check.assignment(x, utyp.elem)) { + if (!((x.mode === 0))) { + check.errorf(x.pos(), "cannot use %s as %s value in map literal", new ($sliceType($emptyInterface))([x, utyp.elem])); + } + _i$2++; + continue; + } + _i$2++; } - if (!valid) { - check.error(clause$2.Comm.Pos(), "select case must be send or receive (possibly with assignment)"); - _i$4++; - continue; - } - check.openScope(s$3, "case"); - $deferred.push([$methodVal(check, "closeScope"), []]); - if (!($interfaceIsEqual(clause$2.Comm, $ifaceNil))) { - check.stmt(inner, clause$2.Comm); - } - check.stmtList(inner, clause$2.Body); - _i$4++; - } - } else if ($assertType(_ref, ($ptrType(ast.ForStmt)), true)[1]) { - s$1 = _ref.$val; - inner = (inner | (6)) >>> 0; - check.openScope(s$1, "for"); - $deferred.push([$methodVal(check, "closeScope"), []]); - check.initStmt(s$1.Init); - if (!($interfaceIsEqual(s$1.Cond, $ifaceNil))) { - x$16 = new operand.Ptr(); $copy(x$16, new operand.Ptr(), operand); - check.expr(x$16, s$1.Cond); - if (!((x$16.mode === 0)) && !isBoolean(x$16.typ)) { - check.error(s$1.Cond.Pos(), "non-boolean condition in for statement"); - } - } - check.initStmt(s$1.Post); - check.stmt(inner, s$1.Body); - } else if ($assertType(_ref, ($ptrType(ast.RangeStmt)), true)[1]) { - s$1 = _ref.$val; - inner = (inner | (6)) >>> 0; - check.openScope(s$1, "for"); - $deferred.push([$methodVal(check, "closeScope"), []]); - decl = s$1.Tok === 47; - x$17 = new operand.Ptr(); $copy(x$17, new operand.Ptr(), operand); - check.expr(x$17, s$1.X); - if (x$17.mode === 0) { - if (!decl) { - check.stmt(inner, s$1.Body); - } - return; - } - _tmp$2 = $ifaceNil; _tmp$3 = $ifaceNil; key = _tmp$2; val = _tmp$3; - _ref$12 = x$17.typ.Underlying(); - if ($assertType(_ref$12, ($ptrType(Basic)), true)[1]) { - typ = _ref$12.$val; - if (isString(typ)) { - key = $pkg.Typ[2]; - val = $pkg.UniverseRune; - } - } else if ($assertType(_ref$12, ($ptrType(Array)), true)[1]) { - typ = _ref$12.$val; - key = $pkg.Typ[2]; - val = typ.elem; - } else if ($assertType(_ref$12, ($ptrType(Slice)), true)[1]) { - typ = _ref$12.$val; - key = $pkg.Typ[2]; - val = typ.elem; - } else if ($assertType(_ref$12, ($ptrType(Pointer)), true)[1]) { - typ = _ref$12.$val; - _tuple$8 = $assertType(typ.base.Underlying(), ($ptrType(Array)), true); typ$1 = _tuple$8[0]; - if (!(typ$1 === ($ptrType(Array)).nil)) { - key = $pkg.Typ[2]; - val = typ$1.elem; - } - } else if ($assertType(_ref$12, ($ptrType(Map)), true)[1]) { - typ = _ref$12.$val; - key = typ.key; - val = typ.elem; - } else if ($assertType(_ref$12, ($ptrType(Chan)), true)[1]) { - typ = _ref$12.$val; - key = typ.elem; - val = $pkg.Typ[0]; - if (typ.dir === 1) { - check.errorf(x$17.pos(), "cannot range over send-only channel %s", new ($sliceType($emptyInterface))([x$17])); + /* } else { */ $s = 28; continue; case 27: + utyp = _ref$1; + check.errorf(e$1.Pos(), "invalid composite literal type %s", new ($sliceType($emptyInterface))([typ$1])); + /* goto Error */ $s = 1; continue; + /* } } */ case 28: + x.mode = 7; + x.typ = typ; + /* } else if ($assertType(_ref, ($ptrType(ast.ParenExpr)), true)[1]) { */ $s = 19; continue; case 7: + e$1 = _ref.$val; + kind = check.rawExpr(x, e$1.X, $ifaceNil); + x.expr = e$1; + return kind; + /* } else if ($assertType(_ref, ($ptrType(ast.SelectorExpr)), true)[1]) { */ $s = 19; continue; case 8: + e$1 = _ref.$val; + check.selector(x, e$1); + /* } else if ($assertType(_ref, ($ptrType(ast.IndexExpr)), true)[1]) { */ $s = 19; continue; case 9: + e$1 = _ref.$val; + check.expr(x, e$1.X); + /* if (x.mode === 0) { */ if (x.mode === 0) {} else { $s = 29; continue; } + /* goto Error */ $s = 1; continue; + /* } */ case 29: + valid = false; + length = new $Int64(-1, 4294967295); + _ref$6 = x.typ.Underlying(); + /* if ($assertType(_ref$6, ($ptrType(Basic)), true)[1]) { */ if ($assertType(_ref$6, ($ptrType(Basic)), true)[1]) {} else if ($assertType(_ref$6, ($ptrType(Array)), true)[1]) { $s = 30; continue; } else if ($assertType(_ref$6, ($ptrType(Pointer)), true)[1]) { $s = 31; continue; } else if ($assertType(_ref$6, ($ptrType(Slice)), true)[1]) { $s = 32; continue; } else if ($assertType(_ref$6, ($ptrType(Map)), true)[1]) { $s = 33; continue; } else { $s = 34; continue; } + typ$2 = _ref$6.$val; + if (isString(typ$2)) { + valid = true; + if (x.mode === 4) { + length = new $Int64(0, exact.StringVal(x.val).length); + } + x.mode = 7; + x.typ = $pkg.UniverseByte; } - if (!($interfaceIsEqual(s$1.Value, $ifaceNil))) { - check.errorf(s$1.Value.Pos(), "iteration over %s permits only one iteration variable", new ($sliceType($emptyInterface))([x$17])); + /* } else if ($assertType(_ref$6, ($ptrType(Array)), true)[1]) { */ $s = 34; continue; case 30: + typ$2 = _ref$6.$val; + valid = true; + length = typ$2.len; + if (!((x.mode === 5))) { + x.mode = 7; } - } - if ($interfaceIsEqual(key, $ifaceNil)) { - check.errorf(x$17.pos(), "cannot range over %s", new ($sliceType($emptyInterface))([x$17])); - if (!decl) { - check.stmt(inner, s$1.Body); + x.typ = typ$2.elem; + /* } else if ($assertType(_ref$6, ($ptrType(Pointer)), true)[1]) { */ $s = 34; continue; case 31: + typ$2 = _ref$6.$val; + _tuple$11 = $assertType(typ$2.base.Underlying(), ($ptrType(Array)), true); typ$3 = _tuple$11[0]; + if (!(typ$3 === ($ptrType(Array)).nil)) { + valid = true; + length = typ$3.len; + x.mode = 5; + x.typ = typ$3.elem; } - return; - } - lhs$1 = $toNativeArray("Interface", [s$1.Key, s$1.Value]); - rhs$2 = $toNativeArray("Interface", [key, val]); - if (decl) { - vars = ($sliceType(($ptrType(Var)))).nil; - _ref$13 = lhs$1; - _i$5 = 0; - while (_i$5 < 2) { - i$1 = _i$5; - lhs$2 = ((_i$5 < 0 || _i$5 >= _ref$13.length) ? $throwRuntimeError("index out of range") : _ref$13[_i$5]); - if ($interfaceIsEqual(lhs$2, $ifaceNil)) { - _i$5++; - continue; + /* } else if ($assertType(_ref$6, ($ptrType(Slice)), true)[1]) { */ $s = 34; continue; case 32: + typ$2 = _ref$6.$val; + valid = true; + x.mode = 5; + x.typ = typ$2.elem; + /* } else if ($assertType(_ref$6, ($ptrType(Map)), true)[1]) { */ $s = 34; continue; case 33: + typ$2 = _ref$6.$val; + key$1 = new operand.Ptr(); $copy(key$1, new operand.Ptr(), operand); + check.expr(key$1, e$1.Index); + /* if (!check.assignment(key$1, typ$2.key)) { */ if (!check.assignment(key$1, typ$2.key)) {} else { $s = 35; continue; } + if (!((key$1.mode === 0))) { + check.invalidOp(key$1.pos(), "cannot use %s as map index of type %s", new ($sliceType($emptyInterface))([key$1, typ$2.key])); } - obj$2 = ($ptrType(Var)).nil; - _tuple$9 = $assertType(lhs$2, ($ptrType(ast.Ident)), true); ident = _tuple$9[0]; - if (!(ident === ($ptrType(ast.Ident)).nil)) { - name = ident.Name; - obj$2 = NewVar(ident.Pos(), check.pkg, name, $ifaceNil); - check.recordDef(ident, obj$2); - if (!(name === "_")) { - vars = $append(vars, obj$2); - } - } else { - check.errorf(lhs$2.Pos(), "cannot declare %s", new ($sliceType($emptyInterface))([lhs$2])); - obj$2 = NewVar(lhs$2.Pos(), check.pkg, "_", $ifaceNil); + /* goto Error */ $s = 1; continue; + /* } */ case 35: + x.mode = 6; + x.typ = typ$2.elem; + x.expr = e$1; + return 1; + /* } */ case 34: + /* if (!valid) { */ if (!valid) {} else { $s = 36; continue; } + check.invalidOp(x.pos(), "cannot index %s", new ($sliceType($emptyInterface))([x])); + /* goto Error */ $s = 1; continue; + /* } */ case 36: + /* if ($interfaceIsEqual(e$1.Index, $ifaceNil)) { */ if ($interfaceIsEqual(e$1.Index, $ifaceNil)) {} else { $s = 37; continue; } + check.invalidAST(e$1.Pos(), "missing index for %s", new ($sliceType($emptyInterface))([x])); + /* goto Error */ $s = 1; continue; + /* } */ case 37: + check.index(e$1.Index, length); + /* } else if ($assertType(_ref, ($ptrType(ast.SliceExpr)), true)[1]) { */ $s = 19; continue; case 10: + e$1 = _ref.$val; + check.expr(x, e$1.X); + /* if (x.mode === 0) { */ if (x.mode === 0) {} else { $s = 38; continue; } + /* goto Error */ $s = 1; continue; + /* } */ case 38: + valid$1 = false; + length$1 = new $Int64(-1, 4294967295); + _ref$7 = x.typ.Underlying(); + /* if ($assertType(_ref$7, ($ptrType(Basic)), true)[1]) { */ if ($assertType(_ref$7, ($ptrType(Basic)), true)[1]) {} else if ($assertType(_ref$7, ($ptrType(Array)), true)[1]) { $s = 39; continue; } else if ($assertType(_ref$7, ($ptrType(Pointer)), true)[1]) { $s = 40; continue; } else if ($assertType(_ref$7, ($ptrType(Slice)), true)[1]) { $s = 41; continue; } else { $s = 42; continue; } + typ$4 = _ref$7.$val; + /* if (isString(typ$4)) { */ if (isString(typ$4)) {} else { $s = 43; continue; } + /* if (slice3(e$1)) { */ if (slice3(e$1)) {} else { $s = 44; continue; } + check.invalidOp(x.pos(), "3-index slice of string", new ($sliceType($emptyInterface))([])); + /* goto Error */ $s = 1; continue; + /* } */ case 44: + valid$1 = true; + if (x.mode === 4) { + length$1 = new $Int64(0, exact.StringVal(x.val).length); } - x$17.mode = 7; - x$17.expr = lhs$2; - x$17.typ = ((i$1 < 0 || i$1 >= rhs$2.length) ? $throwRuntimeError("index out of range") : rhs$2[i$1]); - check.initVar(obj$2, x$17, false); - _i$5++; - } - if (vars.$length > 0) { - _ref$14 = vars; - _i$6 = 0; - while (_i$6 < _ref$14.$length) { - obj$3 = ((_i$6 < 0 || _i$6 >= _ref$14.$length) ? $throwRuntimeError("index out of range") : _ref$14.$array[_ref$14.$offset + _i$6]); - check.declare(check.context.scope, ($ptrType(ast.Ident)).nil, obj$3); - _i$6++; + if (typ$4.kind === 24) { + x.typ = $pkg.Typ[17]; } - } else { - check.error(s$1.TokPos, "no new variables on left side of :="); + /* } */ case 43: + /* } else if ($assertType(_ref$7, ($ptrType(Array)), true)[1]) { */ $s = 42; continue; case 39: + typ$4 = _ref$7.$val; + valid$1 = true; + length$1 = typ$4.len; + /* if (!((x.mode === 5))) { */ if (!((x.mode === 5))) {} else { $s = 45; continue; } + check.invalidOp(x.pos(), "cannot slice %s (value not addressable)", new ($sliceType($emptyInterface))([x])); + /* goto Error */ $s = 1; continue; + /* } */ case 45: + x.typ = new Slice.Ptr(typ$4.elem); + /* } else if ($assertType(_ref$7, ($ptrType(Pointer)), true)[1]) { */ $s = 42; continue; case 40: + typ$4 = _ref$7.$val; + _tuple$12 = $assertType(typ$4.base.Underlying(), ($ptrType(Array)), true); typ$5 = _tuple$12[0]; + if (!(typ$5 === ($ptrType(Array)).nil)) { + valid$1 = true; + length$1 = typ$5.len; + x.typ = new Slice.Ptr(typ$5.elem); } - } else { - _ref$15 = lhs$1; - _i$7 = 0; - while (_i$7 < 2) { - i$2 = _i$7; - lhs$3 = ((_i$7 < 0 || _i$7 >= _ref$15.length) ? $throwRuntimeError("index out of range") : _ref$15[_i$7]); - if ($interfaceIsEqual(lhs$3, $ifaceNil)) { - _i$7++; - continue; + /* } else if ($assertType(_ref$7, ($ptrType(Slice)), true)[1]) { */ $s = 42; continue; case 41: + typ$4 = _ref$7.$val; + valid$1 = true; + /* } */ case 42: + /* if (!valid$1) { */ if (!valid$1) {} else { $s = 46; continue; } + check.invalidOp(x.pos(), "cannot slice %s", new ($sliceType($emptyInterface))([x])); + /* goto Error */ $s = 1; continue; + /* } */ case 46: + x.mode = 7; + /* if (slice3(e$1) && ($interfaceIsEqual(e$1.High, $ifaceNil) || $interfaceIsEqual(sliceMax(e$1), $ifaceNil))) { */ if (slice3(e$1) && ($interfaceIsEqual(e$1.High, $ifaceNil) || $interfaceIsEqual(sliceMax(e$1), $ifaceNil))) {} else { $s = 47; continue; } + check.error(e$1.Rbrack, "2nd and 3rd index required in 3-index slice"); + /* goto Error */ $s = 1; continue; + /* } */ case 47: + ind = ($arrayType($Int64, 3)).zero(); $copy(ind, ($arrayType($Int64, 3)).zero(), ($arrayType($Int64, 3))); + _ref$8 = new ($sliceType(ast.Expr))([e$1.Low, e$1.High, sliceMax(e$1)]); + _i$4 = 0; + while (_i$4 < _ref$8.$length) { + i$2 = _i$4; + expr = ((_i$4 < 0 || _i$4 >= _ref$8.$length) ? $throwRuntimeError("index out of range") : _ref$8.$array[_ref$8.$offset + _i$4]); + x$2 = new $Int64(-1, 4294967295); + if (!($interfaceIsEqual(expr, $ifaceNil))) { + max = new $Int64(-1, 4294967295); + if ((length$1.$high > 0 || (length$1.$high === 0 && length$1.$low >= 0))) { + max = new $Int64(length$1.$high + 0, length$1.$low + 1); } - x$17.mode = 7; - x$17.expr = lhs$3; - x$17.typ = ((i$2 < 0 || i$2 >= rhs$2.length) ? $throwRuntimeError("index out of range") : rhs$2[i$2]); - check.assignVar(lhs$3, x$17); - _i$7++; + _tuple$13 = check.index(expr, max); t = _tuple$13[0]; ok$3 = _tuple$13[1]; + if (ok$3 && (t.$high > 0 || (t.$high === 0 && t.$low >= 0))) { + x$2 = t; + } + } else if (i$2 === 0) { + x$2 = new $Int64(0, 0); + } else if ((length$1.$high > 0 || (length$1.$high === 0 && length$1.$low >= 0))) { + x$2 = length$1; } + (i$2 < 0 || i$2 >= ind.length) ? $throwRuntimeError("index out of range") : ind[i$2] = x$2; + _i$4++; } - check.stmt(inner, s$1.Body); - } else { - s$1 = _ref; - check.error(s$1.Pos(), "invalid statement"); - } - /* */ } catch(err) { $err = err; } finally { $deferFrames.pop(); $callDeferred($deferred, $err); } - }; - Checker.prototype.stmt = function(ctxt, s) { return this.$val.stmt(ctxt, s); }; - Basic.Ptr.prototype.Kind = function() { - var b; - b = this; - return b.kind; - }; - Basic.prototype.Kind = function() { return this.$val.Kind(); }; - Basic.Ptr.prototype.Info = function() { - var b; - b = this; - return b.info; - }; - Basic.prototype.Info = function() { return this.$val.Info(); }; - Basic.Ptr.prototype.Name = function() { - var b; - b = this; - return b.name; - }; - Basic.prototype.Name = function() { return this.$val.Name(); }; - NewArray = $pkg.NewArray = function(elem, len) { - return new Array.Ptr(len, elem); - }; - Array.Ptr.prototype.Len = function() { - var a; - a = this; - return a.len; - }; - Array.prototype.Len = function() { return this.$val.Len(); }; - Array.Ptr.prototype.Elem = function() { - var a; - a = this; - return a.elem; - }; - Array.prototype.Elem = function() { return this.$val.Elem(); }; - NewSlice = $pkg.NewSlice = function(elem) { - return new Slice.Ptr(elem); - }; - Slice.Ptr.prototype.Elem = function() { - var s; - s = this; - return s.elem; - }; - Slice.prototype.Elem = function() { return this.$val.Elem(); }; - NewStruct = $pkg.NewStruct = function(fields, tags) { - var fset, _ref, _i, f; - fset = false; - _ref = fields; - _i = 0; - while (_i < _ref.$length) { - f = ((_i < 0 || _i >= _ref.$length) ? $throwRuntimeError("index out of range") : _ref.$array[_ref.$offset + _i]); - if (!(f.object.name === "_") && !($interfaceIsEqual(new ($ptrType(objset))(function() { return fset; }, function($v) { fset = $v; }).insert(f), $ifaceNil))) { - $panic(new $String("multiple fields with the same name")); - } - _i++; - } - if (tags.$length > fields.$length) { - $panic(new $String("more tags than fields")); - } - return new Struct.Ptr(fields, tags, ($sliceType($Int64)).nil); - }; - Struct.Ptr.prototype.NumFields = function() { - var s; - s = this; - return s.fields.$length; - }; - Struct.prototype.NumFields = function() { return this.$val.NumFields(); }; - Struct.Ptr.prototype.Field = function(i) { - var s, x; - s = this; - return (x = s.fields, ((i < 0 || i >= x.$length) ? $throwRuntimeError("index out of range") : x.$array[x.$offset + i])); - }; - Struct.prototype.Field = function(i) { return this.$val.Field(i); }; - Struct.Ptr.prototype.Tag = function(i) { - var s, x; - s = this; - if (i < s.tags.$length) { - return (x = s.tags, ((i < 0 || i >= x.$length) ? $throwRuntimeError("index out of range") : x.$array[x.$offset + i])); - } - return ""; - }; - Struct.prototype.Tag = function(i) { return this.$val.Tag(i); }; - NewPointer = $pkg.NewPointer = function(elem) { - return new Pointer.Ptr(elem); - }; - Pointer.Ptr.prototype.Elem = function() { - var p; - p = this; - return p.base; - }; - Pointer.prototype.Elem = function() { return this.$val.Elem(); }; - NewTuple = $pkg.NewTuple = function(x) { - if (x.$length > 0) { - return new Tuple.Ptr(x); - } - return ($ptrType(Tuple)).nil; - }; - Tuple.Ptr.prototype.Len = function() { - var t; - t = this; - if (!(t === ($ptrType(Tuple)).nil)) { - return t.vars.$length; - } - return 0; - }; - Tuple.prototype.Len = function() { return this.$val.Len(); }; - Tuple.Ptr.prototype.At = function(i) { - var t, x; - t = this; - return (x = t.vars, ((i < 0 || i >= x.$length) ? $throwRuntimeError("index out of range") : x.$array[x.$offset + i])); - }; - Tuple.prototype.At = function(i) { return this.$val.At(i); }; - NewSignature = $pkg.NewSignature = function(scope, recv, params, results, variadic) { - var n, _tuple, ok; - if (variadic) { - n = params.Len(); - if (n === 0) { - $panic(new $String("types.NewSignature: variadic function must have at least one parameter")); - } - _tuple = $assertType(params.At(n - 1 >> 0).object.typ, ($ptrType(Slice)), true); ok = _tuple[1]; - if (!ok) { - $panic(new $String("types.NewSignature: variadic parameter must be of unnamed slice type")); + _ref$9 = $subslice(new ($sliceType($Int64))(ind), 0, 2); + _i$5 = 0; + L: + while (_i$5 < _ref$9.$length) { + i$3 = _i$5; + x$3 = ((_i$5 < 0 || _i$5 >= _ref$9.$length) ? $throwRuntimeError("index out of range") : _ref$9.$array[_ref$9.$offset + _i$5]); + if ((x$3.$high > 0 || (x$3.$high === 0 && x$3.$low > 0))) { + _ref$10 = $subslice(new ($sliceType($Int64))(ind), (i$3 + 1 >> 0)); + _i$6 = 0; + while (_i$6 < _ref$10.$length) { + y = ((_i$6 < 0 || _i$6 >= _ref$10.$length) ? $throwRuntimeError("index out of range") : _ref$10.$array[_ref$10.$offset + _i$6]); + if ((y.$high > 0 || (y.$high === 0 && y.$low >= 0)) && (x$3.$high > y.$high || (x$3.$high === y.$high && x$3.$low > y.$low))) { + check.errorf(e$1.Rbrack, "invalid slice indices: %d > %d", new ($sliceType($emptyInterface))([x$3, y])); + break L; + } + _i$6++; + } + } + _i$5++; } - } - return new Signature.Ptr(scope, recv, params, results, variadic); - }; - Signature.Ptr.prototype.Recv = function() { - var s; - s = this; - return s.recv; - }; - Signature.prototype.Recv = function() { return this.$val.Recv(); }; - Signature.Ptr.prototype.Params = function() { - var s; - s = this; - return s.params; - }; - Signature.prototype.Params = function() { return this.$val.Params(); }; - Signature.Ptr.prototype.Results = function() { - var s; - s = this; - return s.results; - }; - Signature.prototype.Results = function() { return this.$val.Results(); }; - Signature.Ptr.prototype.Variadic = function() { - var s; - s = this; - return s.variadic; - }; - Signature.prototype.Variadic = function() { return this.$val.Variadic(); }; - NewInterface = $pkg.NewInterface = function(methods, embeddeds) { - var typ, mset, _ref, _i, m; - typ = new Interface.Ptr(); - mset = false; - _ref = methods; - _i = 0; - while (_i < _ref.$length) { - m = ((_i < 0 || _i >= _ref.$length) ? $throwRuntimeError("index out of range") : _ref.$array[_ref.$offset + _i]); - if (!($interfaceIsEqual(new ($ptrType(objset))(function() { return mset; }, function($v) { mset = $v; }).insert(m), $ifaceNil))) { - $panic(new $String("multiple methods with the same name")); + /* } else if ($assertType(_ref, ($ptrType(ast.TypeAssertExpr)), true)[1]) { */ $s = 19; continue; case 11: + e$1 = _ref.$val; + check.expr(x, e$1.X); + /* if (x.mode === 0) { */ if (x.mode === 0) {} else { $s = 48; continue; } + /* goto Error */ $s = 1; continue; + /* } */ case 48: + _tuple$14 = $assertType(x.typ.Underlying(), ($ptrType(Interface)), true); xtyp = _tuple$14[0]; + /* if (xtyp === ($ptrType(Interface)).nil) { */ if (xtyp === ($ptrType(Interface)).nil) {} else { $s = 49; continue; } + check.invalidOp(x.pos(), "%s is not an interface", new ($sliceType($emptyInterface))([x])); + /* goto Error */ $s = 1; continue; + /* } */ case 49: + /* if ($interfaceIsEqual(e$1.Type, $ifaceNil)) { */ if ($interfaceIsEqual(e$1.Type, $ifaceNil)) {} else { $s = 50; continue; } + check.invalidAST(e$1.Pos(), "use of .(type) outside type switch", new ($sliceType($emptyInterface))([])); + /* goto Error */ $s = 1; continue; + /* } */ case 50: + T = check.typ(e$1.Type); + /* if ($interfaceIsEqual(T, $pkg.Typ[0])) { */ if ($interfaceIsEqual(T, $pkg.Typ[0])) {} else { $s = 51; continue; } + /* goto Error */ $s = 1; continue; + /* } */ case 51: + check.typeAssertion(x.pos(), x, xtyp, T); + x.mode = 8; + x.typ = T; + /* } else if ($assertType(_ref, ($ptrType(ast.CallExpr)), true)[1]) { */ $s = 19; continue; case 12: + e$1 = _ref.$val; + return check.call(x, e$1); + /* } else if ($assertType(_ref, ($ptrType(ast.StarExpr)), true)[1]) { */ $s = 19; continue; case 13: + e$1 = _ref.$val; + check.exprOrType(x, e$1.X); + _ref$11 = x.mode; + /* if (_ref$11 === 0) { */ if (_ref$11 === 0) {} else if (_ref$11 === 3) { $s = 52; continue; } else { $s = 53; continue; } + /* goto Error */ $s = 1; continue; + /* } else if (_ref$11 === 3) { */ $s = 54; continue; case 52: + x.typ = new Pointer.Ptr(x.typ); + /* } else { */ $s = 54; continue; case 53: + _tuple$15 = $assertType(x.typ.Underlying(), ($ptrType(Pointer)), true); typ$6 = _tuple$15[0]; ok$4 = _tuple$15[1]; + /* if (ok$4) { */ if (ok$4) {} else { $s = 55; continue; } + x.mode = 5; + x.typ = typ$6.base; + /* } else { */ $s = 56; continue; case 55: + check.invalidOp(x.pos(), "cannot indirect %s", new ($sliceType($emptyInterface))([x])); + /* goto Error */ $s = 1; continue; + /* } */ case 56: + /* } */ case 54: + /* } else if ($assertType(_ref, ($ptrType(ast.UnaryExpr)), true)[1]) { */ $s = 19; continue; case 14: + e$1 = _ref.$val; + check.expr(x, e$1.X); + /* if (x.mode === 0) { */ if (x.mode === 0) {} else { $s = 57; continue; } + /* goto Error */ $s = 1; continue; + /* } */ case 57: + check.unary(x, e$1.Op); + /* if (x.mode === 0) { */ if (x.mode === 0) {} else { $s = 58; continue; } + /* goto Error */ $s = 1; continue; + /* } */ case 58: + if (e$1.Op === 36) { + x.expr = e$1; + return 2; } - $assertType(m.object.typ, ($ptrType(Signature))).recv = NewVar(m.object.pos, m.object.pkg, "", typ); - _i++; - } - sort.Sort($subslice(new byUniqueMethodName(methods.$array), methods.$offset, methods.$offset + methods.$length)); - if (embeddeds === ($sliceType(($ptrType(Named)))).nil) { - sort.Sort($subslice(new byUniqueTypeName(embeddeds.$array), embeddeds.$offset, embeddeds.$offset + embeddeds.$length)); - } - typ.methods = methods; - typ.embeddeds = embeddeds; - return typ; - }; - Interface.Ptr.prototype.NumExplicitMethods = function() { - var t; - t = this; - return t.methods.$length; - }; - Interface.prototype.NumExplicitMethods = function() { return this.$val.NumExplicitMethods(); }; - Interface.Ptr.prototype.ExplicitMethod = function(i) { - var t, x; - t = this; - return (x = t.methods, ((i < 0 || i >= x.$length) ? $throwRuntimeError("index out of range") : x.$array[x.$offset + i])); - }; - Interface.prototype.ExplicitMethod = function(i) { return this.$val.ExplicitMethod(i); }; - Interface.Ptr.prototype.NumEmbeddeds = function() { - var t; - t = this; - return t.embeddeds.$length; - }; - Interface.prototype.NumEmbeddeds = function() { return this.$val.NumEmbeddeds(); }; - Interface.Ptr.prototype.Embedded = function(i) { - var t, x; - t = this; - return (x = t.embeddeds, ((i < 0 || i >= x.$length) ? $throwRuntimeError("index out of range") : x.$array[x.$offset + i])); - }; - Interface.prototype.Embedded = function(i) { return this.$val.Embedded(i); }; - Interface.Ptr.prototype.NumMethods = function() { - var t; - t = this; - return t.allMethods.$length; - }; - Interface.prototype.NumMethods = function() { return this.$val.NumMethods(); }; - Interface.Ptr.prototype.Method = function(i) { - var t, x; - t = this; - return (x = t.allMethods, ((i < 0 || i >= x.$length) ? $throwRuntimeError("index out of range") : x.$array[x.$offset + i])); - }; - Interface.prototype.Method = function(i) { return this.$val.Method(i); }; - Interface.Ptr.prototype.Empty = function() { - var t; - t = this; - return t.allMethods.$length === 0; + /* } else if ($assertType(_ref, ($ptrType(ast.BinaryExpr)), true)[1]) { */ $s = 19; continue; case 15: + e$1 = _ref.$val; + check.binary(x, e$1.X, e$1.Y, e$1.Op); + /* if (x.mode === 0) { */ if (x.mode === 0) {} else { $s = 59; continue; } + /* goto Error */ $s = 1; continue; + /* } */ case 59: + /* } else if ($assertType(_ref, ($ptrType(ast.KeyValueExpr)), true)[1]) { */ $s = 19; continue; case 16: + e$1 = _ref.$val; + check.invalidAST(e$1.Pos(), "no key:value expected", new ($sliceType($emptyInterface))([])); + /* goto Error */ $s = 1; continue; + /* } else if ($assertType(_ref, ($ptrType(ast.ArrayType)), true)[1] || $assertType(_ref, ($ptrType(ast.StructType)), true)[1] || $assertType(_ref, ($ptrType(ast.FuncType)), true)[1] || $assertType(_ref, ($ptrType(ast.InterfaceType)), true)[1] || $assertType(_ref, ($ptrType(ast.MapType)), true)[1] || $assertType(_ref, ($ptrType(ast.ChanType)), true)[1]) { */ $s = 19; continue; case 17: + e$1 = _ref; + x.mode = 3; + x.typ = check.typ(e$1); + /* } else { */ $s = 19; continue; case 18: + e$1 = _ref; + $panic(new $String(fmt.Sprintf("%s: unknown expression type %T", new ($sliceType($emptyInterface))([(x$4 = check.fset.Position(e$1.Pos()), new x$4.constructor.Struct(x$4)), e$1])))); + /* } */ case 19: + x.expr = e; + return 1; + /* Error: */ case 1: + x.mode = 0; + x.expr = e; + return 2; + /* */ case -1: } return; } }; - Interface.prototype.Empty = function() { return this.$val.Empty(); }; - Interface.Ptr.prototype.Complete = function() { - var t, allMethods, _ref, _i, et, it, _ref$1, _i$1, tm, newm, newmtyp; - t = this; - if (!(t.allMethods === ($sliceType(($ptrType(Func)))).nil)) { - return t; + Checker.prototype.exprInternal = function(x, e, hint) { return this.$val.exprInternal(x, e, hint); }; + Checker.Ptr.prototype.typeAssertion = function(pos, x, xtyp, T) { + var check, _tuple, method, wrongType, msg; + check = this; + _tuple = assertableTo(xtyp, T); method = _tuple[0]; wrongType = _tuple[1]; + if (method === ($ptrType(Func)).nil) { + return; } - allMethods = ($sliceType(($ptrType(Func)))).nil; - if (t.embeddeds === ($sliceType(($ptrType(Named)))).nil) { - if (t.methods === ($sliceType(($ptrType(Func)))).nil) { - allMethods = ($sliceType(($ptrType(Func)))).make(0, 1); - } else { - allMethods = t.methods; - } + msg = ""; + if (wrongType) { + msg = "wrong type for method"; } else { - allMethods = $appendSlice(allMethods, t.methods); - _ref = t.embeddeds; - _i = 0; - while (_i < _ref.$length) { - et = ((_i < 0 || _i >= _ref.$length) ? $throwRuntimeError("index out of range") : _ref.$array[_ref.$offset + _i]); - it = $assertType(et.Underlying(), ($ptrType(Interface))); - it.Complete(); - _ref$1 = it.allMethods; - _i$1 = 0; - while (_i$1 < _ref$1.$length) { - tm = ((_i$1 < 0 || _i$1 >= _ref$1.$length) ? $throwRuntimeError("index out of range") : _ref$1.$array[_ref$1.$offset + _i$1]); - newm = new Func.Ptr(); $copy(newm, tm, Func); - newmtyp = new Signature.Ptr(); $copy(newmtyp, $assertType(tm.object.typ, ($ptrType(Signature))), Signature); - newm.object.typ = newmtyp; - newmtyp.recv = NewVar(newm.object.pos, newm.object.pkg, "", t); - allMethods = $append(allMethods, newm); - _i$1++; - } - _i++; - } - sort.Sort($subslice(new byUniqueMethodName(allMethods.$array), allMethods.$offset, allMethods.$offset + allMethods.$length)); + msg = "missing method"; } - t.allMethods = allMethods; - return t; - }; - Interface.prototype.Complete = function() { return this.$val.Complete(); }; - NewMap = $pkg.NewMap = function(key, elem) { - return new Map.Ptr(key, elem); - }; - Map.Ptr.prototype.Key = function() { - var m; - m = this; - return m.key; - }; - Map.prototype.Key = function() { return this.$val.Key(); }; - Map.Ptr.prototype.Elem = function() { - var m; - m = this; - return m.elem; - }; - Map.prototype.Elem = function() { return this.$val.Elem(); }; - NewChan = $pkg.NewChan = function(dir, elem) { - return new Chan.Ptr(dir, elem); - }; - Chan.Ptr.prototype.Dir = function() { - var c; - c = this; - return c.dir; - }; - Chan.prototype.Dir = function() { return this.$val.Dir(); }; - Chan.Ptr.prototype.Elem = function() { - var c; - c = this; - return c.elem; + check.errorf(pos, "%s cannot have dynamic type %s (%s %s)", new ($sliceType($emptyInterface))([x, T, new $String(msg), new $String(method.object.name)])); }; - Chan.prototype.Elem = function() { return this.$val.Elem(); }; - NewNamed = $pkg.NewNamed = function(obj, underlying$1, methods) { - var _tuple, ok, typ; - _tuple = $assertType(underlying$1, ($ptrType(Named)), true); ok = _tuple[1]; - if (ok) { - $panic(new $String("types.NewNamed: underlying type must not be *Named")); - } - typ = new Named.Ptr(obj, underlying$1, methods); - if ($interfaceIsEqual(obj.object.typ, $ifaceNil)) { - obj.object.typ = typ; + Checker.prototype.typeAssertion = function(pos, x, xtyp, T) { return this.$val.typeAssertion(pos, x, xtyp, T); }; + Checker.Ptr.prototype.expr = function(x, e) { + var check, msg, _ref; + check = this; + check.rawExpr(x, e, $ifaceNil); + msg = ""; + _ref = x.mode; + if (_ref === 1) { + msg = "used as value"; + } else if (_ref === 2) { + msg = "must be called"; + } else if (_ref === 3) { + msg = "is not an expression"; + } else { + return; } - return typ; - }; - Named.Ptr.prototype.Obj = function() { - var t; - t = this; - return t.obj; - }; - Named.prototype.Obj = function() { return this.$val.Obj(); }; - Named.Ptr.prototype.NumMethods = function() { - var t; - t = this; - return t.methods.$length; - }; - Named.prototype.NumMethods = function() { return this.$val.NumMethods(); }; - Named.Ptr.prototype.Method = function(i) { - var t, x; - t = this; - return (x = t.methods, ((i < 0 || i >= x.$length) ? $throwRuntimeError("index out of range") : x.$array[x.$offset + i])); + check.errorf(x.pos(), "%s %s", new ($sliceType($emptyInterface))([x, new $String(msg)])); + x.mode = 0; }; - Named.prototype.Method = function(i) { return this.$val.Method(i); }; - Named.Ptr.prototype.SetUnderlying = function(underlying$1) { - var t, _tuple, ok; - t = this; - if ($interfaceIsEqual(underlying$1, $ifaceNil)) { - $panic(new $String("types.Named.SetUnderlying: underlying type must not be nil")); - } - _tuple = $assertType(underlying$1, ($ptrType(Named)), true); ok = _tuple[1]; - if (ok) { - $panic(new $String("types.Named.SetUnderlying: underlying type must not be *Named")); + Checker.prototype.expr = function(x, e) { return this.$val.expr(x, e); }; + Checker.Ptr.prototype.exprWithHint = function(x, e, hint) { + var check, msg, _ref; + check = this; + assert(!($interfaceIsEqual(hint, $ifaceNil))); + check.rawExpr(x, e, hint); + msg = ""; + _ref = x.mode; + if (_ref === 1) { + msg = "used as value"; + } else if (_ref === 2) { + msg = "must be called"; + } else if (_ref === 3) { + msg = "is not an expression"; + } else { + return; } - t.underlying = underlying$1; + check.errorf(x.pos(), "%s %s", new ($sliceType($emptyInterface))([x, new $String(msg)])); + x.mode = 0; }; - Named.prototype.SetUnderlying = function(underlying$1) { return this.$val.SetUnderlying(underlying$1); }; - Named.Ptr.prototype.AddMethod = function(m) { - var t, _tuple, i; - t = this; - _tuple = lookupMethod(t.methods, m.object.pkg, m.object.name); i = _tuple[0]; - if (i < 0) { - t.methods = $append(t.methods, m); + Checker.prototype.exprWithHint = function(x, e, hint) { return this.$val.exprWithHint(x, e, hint); }; + Checker.Ptr.prototype.exprOrType = function(x, e) { + var check; + check = this; + check.rawExpr(x, e, $ifaceNil); + if (x.mode === 1) { + check.errorf(x.pos(), "%s used as value or type", new ($sliceType($emptyInterface))([x])); + x.mode = 0; } }; - Named.prototype.AddMethod = function(m) { return this.$val.AddMethod(m); }; - Basic.Ptr.prototype.Underlying = function() { - var t; - t = this; - return t; - }; - Basic.prototype.Underlying = function() { return this.$val.Underlying(); }; - Array.Ptr.prototype.Underlying = function() { - var t; - t = this; - return t; - }; - Array.prototype.Underlying = function() { return this.$val.Underlying(); }; - Slice.Ptr.prototype.Underlying = function() { - var t; - t = this; - return t; - }; - Slice.prototype.Underlying = function() { return this.$val.Underlying(); }; - Struct.Ptr.prototype.Underlying = function() { - var t; - t = this; - return t; - }; - Struct.prototype.Underlying = function() { return this.$val.Underlying(); }; - Pointer.Ptr.prototype.Underlying = function() { - var t; - t = this; - return t; - }; - Pointer.prototype.Underlying = function() { return this.$val.Underlying(); }; - Tuple.Ptr.prototype.Underlying = function() { - var t; - t = this; - return t; - }; - Tuple.prototype.Underlying = function() { return this.$val.Underlying(); }; - Signature.Ptr.prototype.Underlying = function() { - var t; - t = this; - return t; - }; - Signature.prototype.Underlying = function() { return this.$val.Underlying(); }; - Interface.Ptr.prototype.Underlying = function() { - var t; - t = this; - return t; - }; - Interface.prototype.Underlying = function() { return this.$val.Underlying(); }; - Map.Ptr.prototype.Underlying = function() { - var t; - t = this; - return t; - }; - Map.prototype.Underlying = function() { return this.$val.Underlying(); }; - Chan.Ptr.prototype.Underlying = function() { - var t; - t = this; - return t; - }; - Chan.prototype.Underlying = function() { return this.$val.Underlying(); }; - Named.Ptr.prototype.Underlying = function() { - var t; - t = this; - return t.underlying; - }; - Named.prototype.Underlying = function() { return this.$val.Underlying(); }; - Basic.Ptr.prototype.String = function() { - var t; - t = this; - return TypeString(($ptrType(Package)).nil, t); - }; - Basic.prototype.String = function() { return this.$val.String(); }; - Array.Ptr.prototype.String = function() { - var t; - t = this; - return TypeString(($ptrType(Package)).nil, t); - }; - Array.prototype.String = function() { return this.$val.String(); }; - Slice.Ptr.prototype.String = function() { - var t; - t = this; - return TypeString(($ptrType(Package)).nil, t); - }; - Slice.prototype.String = function() { return this.$val.String(); }; - Struct.Ptr.prototype.String = function() { - var t; - t = this; - return TypeString(($ptrType(Package)).nil, t); - }; - Struct.prototype.String = function() { return this.$val.String(); }; - Pointer.Ptr.prototype.String = function() { - var t; - t = this; - return TypeString(($ptrType(Package)).nil, t); - }; - Pointer.prototype.String = function() { return this.$val.String(); }; - Tuple.Ptr.prototype.String = function() { - var t; - t = this; - return TypeString(($ptrType(Package)).nil, t); - }; - Tuple.prototype.String = function() { return this.$val.String(); }; - Signature.Ptr.prototype.String = function() { - var t; - t = this; - return TypeString(($ptrType(Package)).nil, t); - }; - Signature.prototype.String = function() { return this.$val.String(); }; - Interface.Ptr.prototype.String = function() { - var t; - t = this; - return TypeString(($ptrType(Package)).nil, t); - }; - Interface.prototype.String = function() { return this.$val.String(); }; - Map.Ptr.prototype.String = function() { - var t; - t = this; - return TypeString(($ptrType(Package)).nil, t); - }; - Map.prototype.String = function() { return this.$val.String(); }; - Chan.Ptr.prototype.String = function() { - var t; - t = this; - return TypeString(($ptrType(Package)).nil, t); - }; - Chan.prototype.String = function() { return this.$val.String(); }; - Named.Ptr.prototype.String = function() { - var t; - t = this; - return TypeString(($ptrType(Package)).nil, t); - }; - Named.prototype.String = function() { return this.$val.String(); }; - TypeString = $pkg.TypeString = function(this$1, typ) { + Checker.prototype.exprOrType = function(x, e) { return this.$val.exprOrType(x, e); }; + ExprString = $pkg.ExprString = function(x) { var buf; buf = new bytes.Buffer.Ptr(); $copy(buf, new bytes.Buffer.Ptr(), bytes.Buffer); - WriteType(buf, this$1, typ); + WriteExpr(buf, x); return buf.String(); }; - WriteType = $pkg.WriteType = function(buf, this$1, typ) { - writeType(buf, this$1, typ, ($sliceType(Type)).make(8)); - }; - writeType = function(buf, this$1, typ, visited) { - var _ref, _i, t, t$1, _ref$1, _ref$2, _ref$3, _i$1, i, f, tag, _ref$4, _i$2, i$1, m, _ref$5, _i$3, i$2, m$1, _ref$6, _i$4, i$3, typ$1, s, parens, _ref$7, _tuple, c, s$1, obj, pkg; - _ref = visited; - _i = 0; - while (_i < _ref.$length) { - t = ((_i < 0 || _i >= _ref.$length) ? $throwRuntimeError("index out of range") : _ref.$array[_ref.$offset + _i]); - if ($interfaceIsEqual(t, typ)) { - fmt.Fprintf(buf, "\xE2\x97\x8B%T", new ($sliceType($emptyInterface))([typ])); - return; + WriteExpr = $pkg.WriteExpr = function(buf, x) { + var x$1, _ref, _ref$1, _i, i, arg, s, _ref$2; + _ref = x; + if ($assertType(_ref, ($ptrType(ast.Ident)), true)[1]) { + x$1 = _ref.$val; + buf.WriteString(x$1.Name); + } else if ($assertType(_ref, ($ptrType(ast.Ellipsis)), true)[1]) { + x$1 = _ref.$val; + buf.WriteString("..."); + if (!($interfaceIsEqual(x$1.Elt, $ifaceNil))) { + WriteExpr(buf, x$1.Elt); } - _i++; - } - visited = $append(visited, typ); - _ref$1 = typ; - if (_ref$1 === $ifaceNil) { - t$1 = _ref$1; - buf.WriteString(""); - } else if ($assertType(_ref$1, ($ptrType(Basic)), true)[1]) { - t$1 = _ref$1.$val; - if (t$1.kind === 18) { - buf.WriteString("unsafe."); + } else if ($assertType(_ref, ($ptrType(ast.BasicLit)), true)[1]) { + x$1 = _ref.$val; + buf.WriteString(x$1.Value); + } else if ($assertType(_ref, ($ptrType(ast.FuncLit)), true)[1]) { + x$1 = _ref.$val; + buf.WriteByte(40); + WriteExpr(buf, x$1.Type); + buf.WriteString(" literal)"); + } else if ($assertType(_ref, ($ptrType(ast.CompositeLit)), true)[1]) { + x$1 = _ref.$val; + buf.WriteByte(40); + WriteExpr(buf, x$1.Type); + buf.WriteString(" literal)"); + } else if ($assertType(_ref, ($ptrType(ast.ParenExpr)), true)[1]) { + x$1 = _ref.$val; + buf.WriteByte(40); + WriteExpr(buf, x$1.X); + buf.WriteByte(41); + } else if ($assertType(_ref, ($ptrType(ast.SelectorExpr)), true)[1]) { + x$1 = _ref.$val; + WriteExpr(buf, x$1.X); + buf.WriteByte(46); + buf.WriteString(x$1.Sel.Name); + } else if ($assertType(_ref, ($ptrType(ast.IndexExpr)), true)[1]) { + x$1 = _ref.$val; + WriteExpr(buf, x$1.X); + buf.WriteByte(91); + WriteExpr(buf, x$1.Index); + buf.WriteByte(93); + } else if ($assertType(_ref, ($ptrType(ast.SliceExpr)), true)[1]) { + x$1 = _ref.$val; + WriteExpr(buf, x$1.X); + buf.WriteByte(91); + if (!($interfaceIsEqual(x$1.Low, $ifaceNil))) { + WriteExpr(buf, x$1.Low); } - if ($pkg.GcCompatibilityMode) { - _ref$2 = t$1.kind; - if (_ref$2 === 8) { - t$1 = $pkg.Typ[8]; - } else if (_ref$2 === 5) { - t$1 = $pkg.Typ[5]; + buf.WriteByte(58); + if (!($interfaceIsEqual(x$1.High, $ifaceNil))) { + WriteExpr(buf, x$1.High); + } + if (x$1.Slice3) { + buf.WriteByte(58); + if (!($interfaceIsEqual(x$1.Max, $ifaceNil))) { + WriteExpr(buf, x$1.Max); } } - buf.WriteString(t$1.name); - } else if ($assertType(_ref$1, ($ptrType(Array)), true)[1]) { - t$1 = _ref$1.$val; - fmt.Fprintf(buf, "[%d]", new ($sliceType($emptyInterface))([t$1.len])); - writeType(buf, this$1, t$1.elem, visited); - } else if ($assertType(_ref$1, ($ptrType(Slice)), true)[1]) { - t$1 = _ref$1.$val; - buf.WriteString("[]"); - writeType(buf, this$1, t$1.elem, visited); - } else if ($assertType(_ref$1, ($ptrType(Struct)), true)[1]) { - t$1 = _ref$1.$val; - buf.WriteString("struct{"); - _ref$3 = t$1.fields; - _i$1 = 0; - while (_i$1 < _ref$3.$length) { - i = _i$1; - f = ((_i$1 < 0 || _i$1 >= _ref$3.$length) ? $throwRuntimeError("index out of range") : _ref$3.$array[_ref$3.$offset + _i$1]); + buf.WriteByte(93); + } else if ($assertType(_ref, ($ptrType(ast.TypeAssertExpr)), true)[1]) { + x$1 = _ref.$val; + WriteExpr(buf, x$1.X); + buf.WriteString(".("); + WriteExpr(buf, x$1.Type); + buf.WriteByte(41); + } else if ($assertType(_ref, ($ptrType(ast.CallExpr)), true)[1]) { + x$1 = _ref.$val; + WriteExpr(buf, x$1.Fun); + buf.WriteByte(40); + _ref$1 = x$1.Args; + _i = 0; + while (_i < _ref$1.$length) { + i = _i; + arg = ((_i < 0 || _i >= _ref$1.$length) ? $throwRuntimeError("index out of range") : _ref$1.$array[_ref$1.$offset + _i]); if (i > 0) { - buf.WriteString("; "); - } - if (!f.anonymous) { - buf.WriteString(f.object.name); - buf.WriteByte(32); - } - writeType(buf, this$1, f.object.typ, visited); - tag = t$1.Tag(i); - if (!(tag === "")) { - fmt.Fprintf(buf, " %q", new ($sliceType($emptyInterface))([new $String(tag)])); + buf.WriteString(", "); } - _i$1++; + WriteExpr(buf, arg); + _i++; } - buf.WriteByte(125); - } else if ($assertType(_ref$1, ($ptrType(Pointer)), true)[1]) { - t$1 = _ref$1.$val; + if ((new token.Pos(x$1.Ellipsis)).IsValid()) { + buf.WriteString("..."); + } + buf.WriteByte(41); + } else if ($assertType(_ref, ($ptrType(ast.StarExpr)), true)[1]) { + x$1 = _ref.$val; buf.WriteByte(42); - writeType(buf, this$1, t$1.base, visited); - } else if ($assertType(_ref$1, ($ptrType(Tuple)), true)[1]) { - t$1 = _ref$1.$val; - writeTuple(buf, this$1, t$1, false, visited); - } else if ($assertType(_ref$1, ($ptrType(Signature)), true)[1]) { - t$1 = _ref$1.$val; + WriteExpr(buf, x$1.X); + } else if ($assertType(_ref, ($ptrType(ast.UnaryExpr)), true)[1]) { + x$1 = _ref.$val; + buf.WriteString((new token.Token(x$1.Op)).String()); + WriteExpr(buf, x$1.X); + } else if ($assertType(_ref, ($ptrType(ast.BinaryExpr)), true)[1]) { + x$1 = _ref.$val; + WriteExpr(buf, x$1.X); + buf.WriteByte(32); + buf.WriteString((new token.Token(x$1.Op)).String()); + buf.WriteByte(32); + WriteExpr(buf, x$1.Y); + } else if ($assertType(_ref, ($ptrType(ast.ArrayType)), true)[1]) { + x$1 = _ref.$val; + buf.WriteByte(91); + if (!($interfaceIsEqual(x$1.Len, $ifaceNil))) { + WriteExpr(buf, x$1.Len); + } + buf.WriteByte(93); + WriteExpr(buf, x$1.Elt); + } else if ($assertType(_ref, ($ptrType(ast.StructType)), true)[1]) { + x$1 = _ref.$val; + buf.WriteString("struct{"); + writeFieldList(buf, x$1.Fields, "; ", false); + buf.WriteByte(125); + } else if ($assertType(_ref, ($ptrType(ast.FuncType)), true)[1]) { + x$1 = _ref.$val; buf.WriteString("func"); - writeSignature(buf, this$1, t$1, visited); - } else if ($assertType(_ref$1, ($ptrType(Interface)), true)[1]) { - t$1 = _ref$1.$val; + writeSigExpr(buf, x$1); + } else if ($assertType(_ref, ($ptrType(ast.InterfaceType)), true)[1]) { + x$1 = _ref.$val; buf.WriteString("interface{"); - if ($pkg.GcCompatibilityMode) { - _ref$4 = t$1.allMethods; - _i$2 = 0; - while (_i$2 < _ref$4.$length) { - i$1 = _i$2; - m = ((_i$2 < 0 || _i$2 >= _ref$4.$length) ? $throwRuntimeError("index out of range") : _ref$4.$array[_ref$4.$offset + _i$2]); - if (i$1 > 0) { - buf.WriteString("; "); - } - buf.WriteString(m.object.name); - writeSignature(buf, this$1, $assertType(m.object.typ, ($ptrType(Signature))), visited); - _i$2++; - } - } else { - _ref$5 = t$1.methods; - _i$3 = 0; - while (_i$3 < _ref$5.$length) { - i$2 = _i$3; - m$1 = ((_i$3 < 0 || _i$3 >= _ref$5.$length) ? $throwRuntimeError("index out of range") : _ref$5.$array[_ref$5.$offset + _i$3]); - if (i$2 > 0) { - buf.WriteString("; "); - } - buf.WriteString(m$1.object.name); - writeSignature(buf, this$1, $assertType(m$1.object.typ, ($ptrType(Signature))), visited); - _i$3++; - } - _ref$6 = t$1.embeddeds; - _i$4 = 0; - while (_i$4 < _ref$6.$length) { - i$3 = _i$4; - typ$1 = ((_i$4 < 0 || _i$4 >= _ref$6.$length) ? $throwRuntimeError("index out of range") : _ref$6.$array[_ref$6.$offset + _i$4]); - if (i$3 > 0 || t$1.methods.$length > 0) { - buf.WriteString("; "); - } - writeType(buf, this$1, typ$1, visited); - _i$4++; - } - } + writeFieldList(buf, x$1.Methods, "; ", true); buf.WriteByte(125); - } else if ($assertType(_ref$1, ($ptrType(Map)), true)[1]) { - t$1 = _ref$1.$val; + } else if ($assertType(_ref, ($ptrType(ast.MapType)), true)[1]) { + x$1 = _ref.$val; buf.WriteString("map["); - writeType(buf, this$1, t$1.key, visited); + WriteExpr(buf, x$1.Key); buf.WriteByte(93); - writeType(buf, this$1, t$1.elem, visited); - } else if ($assertType(_ref$1, ($ptrType(Chan)), true)[1]) { - t$1 = _ref$1.$val; + WriteExpr(buf, x$1.Value); + } else if ($assertType(_ref, ($ptrType(ast.ChanType)), true)[1]) { + x$1 = _ref.$val; s = ""; - parens = false; - _ref$7 = t$1.dir; - if (_ref$7 === 0) { - s = "chan "; - _tuple = $assertType(t$1.elem, ($ptrType(Chan)), true); c = _tuple[0]; - if (!(c === ($ptrType(Chan)).nil) && (c.dir === 2)) { - parens = true; - } - } else if (_ref$7 === 1) { + _ref$2 = x$1.Dir; + if (_ref$2 === 1) { s = "chan<- "; - } else if (_ref$7 === 2) { + } else if (_ref$2 === 2) { s = "<-chan "; } else { - $panic(new $String("unreachable")); + s = "chan "; } buf.WriteString(s); - if (parens) { - buf.WriteByte(40); - } - writeType(buf, this$1, t$1.elem, visited); - if (parens) { - buf.WriteByte(41); - } - } else if ($assertType(_ref$1, ($ptrType(Named)), true)[1]) { - t$1 = _ref$1.$val; - s$1 = ""; - obj = t$1.obj; - if (!(obj === ($ptrType(TypeName)).nil)) { - pkg = obj.object.pkg; - if (!(pkg === ($ptrType(Package)).nil) && !(pkg === this$1)) { - buf.WriteString(pkg.path); - buf.WriteByte(46); - } - s$1 = obj.object.name; - } - buf.WriteString(s$1); + WriteExpr(buf, x$1.Value); } else { - t$1 = _ref$1; - buf.WriteString(t$1.String()); + x$1 = _ref; + buf.WriteString("(bad expr)"); } }; - writeTuple = function(buf, this$1, tup, variadic, visited) { - var _ref, _i, i, v, typ, _tuple, s, ok, _tuple$1, t, ok$1; + writeSigExpr = function(buf, sig) { + var res, n, x, x$1; buf.WriteByte(40); - if (!(tup === ($ptrType(Tuple)).nil)) { - _ref = tup.vars; - _i = 0; - while (_i < _ref.$length) { - i = _i; - v = ((_i < 0 || _i >= _ref.$length) ? $throwRuntimeError("index out of range") : _ref.$array[_ref.$offset + _i]); - if (i > 0) { + writeFieldList(buf, sig.Params, ", ", false); + buf.WriteByte(41); + res = sig.Results; + n = res.NumFields(); + if (n === 0) { + return; + } + buf.WriteByte(32); + if ((n === 1) && ((x = res.List, ((0 < 0 || 0 >= x.$length) ? $throwRuntimeError("index out of range") : x.$array[x.$offset + 0])).Names.$length === 0)) { + WriteExpr(buf, (x$1 = res.List, ((0 < 0 || 0 >= x$1.$length) ? $throwRuntimeError("index out of range") : x$1.$array[x$1.$offset + 0])).Type); + return; + } + buf.WriteByte(40); + writeFieldList(buf, res, ", ", false); + buf.WriteByte(41); + }; + writeFieldList = function(buf, fields, sep, iface) { + var _ref, _i, i, f, _ref$1, _i$1, i$1, name, _tuple, sig; + _ref = fields.List; + _i = 0; + while (_i < _ref.$length) { + i = _i; + f = ((_i < 0 || _i >= _ref.$length) ? $throwRuntimeError("index out of range") : _ref.$array[_ref.$offset + _i]); + if (i > 0) { + buf.WriteString(sep); + } + _ref$1 = f.Names; + _i$1 = 0; + while (_i$1 < _ref$1.$length) { + i$1 = _i$1; + name = ((_i$1 < 0 || _i$1 >= _ref$1.$length) ? $throwRuntimeError("index out of range") : _ref$1.$array[_ref$1.$offset + _i$1]); + if (i$1 > 0) { buf.WriteString(", "); } - if (!(v.object.name === "")) { - buf.WriteString(v.object.name); - buf.WriteByte(32); - } - typ = v.object.typ; - if (variadic && (i === (tup.vars.$length - 1 >> 0))) { - _tuple = $assertType(typ, ($ptrType(Slice)), true); s = _tuple[0]; ok = _tuple[1]; - if (ok) { - buf.WriteString("..."); - typ = s.elem; - } else { - _tuple$1 = $assertType(typ.Underlying(), ($ptrType(Basic)), true); t = _tuple$1[0]; ok$1 = _tuple$1[1]; - if (!ok$1 || !((t.kind === 17))) { - $panic(new $String("internal error: string type expected")); - } - writeType(buf, this$1, typ, visited); - buf.WriteString("..."); - _i++; - continue; - } + buf.WriteString(name.Name); + _i$1++; + } + _tuple = $assertType(f.Type, ($ptrType(ast.FuncType)), true); sig = _tuple[0]; + if (!(sig === ($ptrType(ast.FuncType)).nil) && iface) { + writeSigExpr(buf, sig); + _i++; + continue; + } + if (f.Names.$length > 0) { + buf.WriteByte(32); + } + WriteExpr(buf, f.Type); + _i++; + } + }; + slice3 = function(x) { + return x.Slice3; + }; + sliceMax = function(x) { + return x.Max; + }; + Checker.Ptr.prototype.initOrder = function() { + var check, x, pq, mark, emitted, n, cycle, i, _ref, _i, out, _tuple, v, _entry, info, _entry$1, _key$2, infoLhs, init$1; + check = this; + check.Info.InitOrder = $subslice(check.Info.InitOrder, 0, 0); + pq = (x = dependencyGraph(check.objMap), $subslice(new nodeQueue(x.$array), x.$offset, x.$offset + x.$length)); + heap.Init(new ($ptrType(nodeQueue))(function() { return pq; }, function($v) { pq = $v; })); + mark = 0; + emitted = new $Map(); + while (pq.$length > 0) { + n = $assertType(heap.Pop(new ($ptrType(nodeQueue))(function() { return pq; }, function($v) { pq = $v; })), ($ptrType(objNode))); + if (n.in$1 > 0) { + mark = mark + (1) >> 0; + cycle = findPath(n, n, mark); + i = valIndex(cycle); + if (i >= 0) { + check.reportCycle(cycle, i); } - writeType(buf, this$1, typ, visited); + } + _ref = n.out; + _i = 0; + while (_i < _ref.$length) { + out = ((_i < 0 || _i >= _ref.$length) ? $throwRuntimeError("index out of range") : _ref.$array[_ref.$offset + _i]); + out.in$1 = out.in$1 - (1) >> 0; + heap.Fix(new ($ptrType(nodeQueue))(function() { return pq; }, function($v) { pq = $v; }), out.index); _i++; } + _tuple = $assertType(n.obj, ($ptrType(Var)), true); v = _tuple[0]; + info = (_entry = check.objMap[v.$key()], _entry !== undefined ? _entry.v : ($ptrType(declInfo)).nil); + if (v === ($ptrType(Var)).nil || !info.hasInitializer()) { + continue; + } + if ((_entry$1 = emitted[info.$key()], _entry$1 !== undefined ? _entry$1.v : false)) { + continue; + } + _key$2 = info; (emitted || $throwRuntimeError("assignment to entry in nil map"))[_key$2.$key()] = { k: _key$2, v: true }; + infoLhs = info.lhs; + if (infoLhs === ($sliceType(($ptrType(Var)))).nil) { + infoLhs = new ($sliceType(($ptrType(Var))))([v]); + } + init$1 = new Initializer.Ptr(infoLhs, info.init); + check.Info.InitOrder = $append(check.Info.InitOrder, init$1); } - buf.WriteByte(41); }; - WriteSignature = $pkg.WriteSignature = function(buf, this$1, sig) { - writeSignature(buf, this$1, sig, ($sliceType(Type)).make(8)); + Checker.prototype.initOrder = function() { return this.$val.initOrder(); }; + findPath = function(a, z, mark) { + var _ref, _i, n, P; + if (a.mark === mark) { + return ($sliceType(($ptrType(objNode)))).nil; + } + a.mark = mark; + _ref = a.out; + _i = 0; + while (_i < _ref.$length) { + n = ((_i < 0 || _i >= _ref.$length) ? $throwRuntimeError("index out of range") : _ref.$array[_ref.$offset + _i]); + if (n === z) { + return new ($sliceType(($ptrType(objNode))))([z]); + } + P = findPath(n, z, mark); + if (!(P === ($sliceType(($ptrType(objNode)))).nil)) { + return $append(P, n); + } + _i++; + } + return ($sliceType(($ptrType(objNode)))).nil; }; - writeSignature = function(buf, this$1, sig, visited) { - var n, x, x$1; - writeTuple(buf, this$1, sig.params, sig.variadic, visited); - n = sig.results.Len(); - if (n === 0) { - return; + valIndex = function(a) { + var _ref, _i, i, n, _ref$1; + _ref = a; + _i = 0; + while (_i < _ref.$length) { + i = _i; + n = ((_i < 0 || _i >= _ref.$length) ? $throwRuntimeError("index out of range") : _ref.$array[_ref.$offset + _i]); + _ref$1 = n.obj; + if ($assertType(_ref$1, ($ptrType(Const)), true)[1] || $assertType(_ref$1, ($ptrType(Var)), true)[1]) { + return i; + } + _i++; } - buf.WriteByte(32); - if ((n === 1) && (x = sig.results.vars, ((0 < 0 || 0 >= x.$length) ? $throwRuntimeError("index out of range") : x.$array[x.$offset + 0])).object.name === "") { - writeType(buf, this$1, (x$1 = sig.results.vars, ((0 < 0 || 0 >= x$1.$length) ? $throwRuntimeError("index out of range") : x$1.$array[x$1.$offset + 0])).object.typ, visited); - return; + return -1; + }; + Checker.Ptr.prototype.reportCycle = function(cycle, i) { + var check, obj, _ref, _i; + check = this; + obj = ((i < 0 || i >= cycle.$length) ? $throwRuntimeError("index out of range") : cycle.$array[cycle.$offset + i]).obj; + check.errorf(obj.Pos(), "initialization cycle for %s", new ($sliceType($emptyInterface))([new $String(obj.Name())])); + _ref = cycle; + _i = 0; + while (_i < _ref.$length) { + check.errorf(obj.Pos(), "\t%s refers to", new ($sliceType($emptyInterface))([new $String(obj.Name())])); + i = i + (1) >> 0; + if (i >= cycle.$length) { + i = 0; + } + obj = ((i < 0 || i >= cycle.$length) ? $throwRuntimeError("index out of range") : cycle.$array[cycle.$offset + i]).obj; + _i++; } - writeTuple(buf, this$1, sig.results, false, visited); + check.errorf(obj.Pos(), "\t%s", new ($sliceType($emptyInterface))([new $String(obj.Name())])); + }; + Checker.prototype.reportCycle = function(cycle, i) { return this.$val.reportCycle(cycle, i); }; + dependencyGraph = function(objMap) { + var M, _ref, _i, _keys, _entry, obj, _key$2, G, i, _ref$1, _i$1, _keys$1, _entry$1, obj$1, n, _entry$2, deps, _ref$2, _i$2, _keys$2, _entry$3, d, _entry$4, d$1; + M = new $Map(); + _ref = objMap; + _i = 0; + _keys = $keys(_ref); + while (_i < _keys.length) { + _entry = _ref[_keys[_i]]; + if (_entry === undefined) { + _i++; + continue; + } + obj = _entry.k; + _key$2 = obj; (M || $throwRuntimeError("assignment to entry in nil map"))[_key$2.$key()] = { k: _key$2, v: new objNode.Ptr(obj, 0, ($sliceType(($ptrType(objNode)))).nil, 0, 0) }; + _i++; + } + G = ($sliceType(($ptrType(objNode)))).make($keys(M).length); + i = 0; + _ref$1 = M; + _i$1 = 0; + _keys$1 = $keys(_ref$1); + while (_i$1 < _keys$1.length) { + _entry$1 = _ref$1[_keys$1[_i$1]]; + if (_entry$1 === undefined) { + _i$1++; + continue; + } + obj$1 = _entry$1.k; + n = _entry$1.v; + deps = (_entry$2 = objMap[obj$1.$key()], _entry$2 !== undefined ? _entry$2.v : ($ptrType(declInfo)).nil).deps; + n.in$1 = $keys(deps).length; + _ref$2 = deps; + _i$2 = 0; + _keys$2 = $keys(_ref$2); + while (_i$2 < _keys$2.length) { + _entry$3 = _ref$2[_keys$2[_i$2]]; + if (_entry$3 === undefined) { + _i$2++; + continue; + } + d = _entry$3.k; + d$1 = (_entry$4 = M[d.$key()], _entry$4 !== undefined ? _entry$4.v : ($ptrType(objNode)).nil); + d$1.out = $append(d$1.out, n); + _i$2++; + } + (i < 0 || i >= G.$length) ? $throwRuntimeError("index out of range") : G.$array[G.$offset + i] = n; + n.index = i; + i = i + (1) >> 0; + _i$1++; + } + return G; + }; + nodeQueue.prototype.Len = function() { + var a; + a = this; + return a.$length; + }; + $ptrType(nodeQueue).prototype.Len = function() { return this.$get().Len(); }; + nodeQueue.prototype.Swap = function(i, j) { + var a, _tmp, _tmp$1, x, y, _tmp$2, _tmp$3, _tmp$4, _tmp$5; + a = this; + _tmp = ((i < 0 || i >= a.$length) ? $throwRuntimeError("index out of range") : a.$array[a.$offset + i]); _tmp$1 = ((j < 0 || j >= a.$length) ? $throwRuntimeError("index out of range") : a.$array[a.$offset + j]); x = _tmp; y = _tmp$1; + _tmp$2 = y; _tmp$3 = x; (i < 0 || i >= a.$length) ? $throwRuntimeError("index out of range") : a.$array[a.$offset + i] = _tmp$2; (j < 0 || j >= a.$length) ? $throwRuntimeError("index out of range") : a.$array[a.$offset + j] = _tmp$3; + _tmp$4 = j; _tmp$5 = i; x.index = _tmp$4; y.index = _tmp$5; + }; + $ptrType(nodeQueue).prototype.Swap = function(i, j) { return this.$get().Swap(i, j); }; + nodeQueue.prototype.Less = function(i, j) { + var a, _tmp, _tmp$1, x, y; + a = this; + _tmp = ((i < 0 || i >= a.$length) ? $throwRuntimeError("index out of range") : a.$array[a.$offset + i]); _tmp$1 = ((j < 0 || j >= a.$length) ? $throwRuntimeError("index out of range") : a.$array[a.$offset + j]); x = _tmp; y = _tmp$1; + return x.in$1 < y.in$1 || (x.in$1 === y.in$1) && x.obj.order() < y.obj.order(); + }; + $ptrType(nodeQueue).prototype.Less = function(i, j) { return this.$get().Less(i, j); }; + $ptrType(nodeQueue).prototype.Push = function(x) { + var a; + a = this; + $panic(new $String("unreachable")); }; - Checker.Ptr.prototype.ident = function(x, e, def$1, path$1) { - var check, obj, typ, obj$1, _ref, _ref$1, _i, i, prev, _ref$2, _i$1, obj$2; + $ptrType(nodeQueue).prototype.Pop = function() { + var a, n, x, x$1, x$2; + a = this; + n = a.$get().$length; + x$2 = (x = a.$get(), x$1 = n - 1 >> 0, ((x$1 < 0 || x$1 >= x.$length) ? $throwRuntimeError("index out of range") : x.$array[x.$offset + x$1])); + x$2.index = -1; + a.$set($subslice((a.$get()), 0, (n - 1 >> 0))); + return x$2; + }; + Checker.Ptr.prototype.labels = function(body) { + var check, all, fwdJumps, _ref, _i, jmp, msg, name, alt, _ref$1, _i$1, _keys, _entry, obj, lbl; check = this; - x.mode = 0; - x.expr = e; - obj = check.context.scope.LookupParent(e.Name); - if ($interfaceIsEqual(obj, $ifaceNil)) { - if (e.Name === "_") { - check.errorf(e.Pos(), "cannot use _ as value or type", new ($sliceType($emptyInterface))([])); + all = NewScope(($ptrType(Scope)).nil, "label"); + fwdJumps = check.blockBranches(all, ($ptrType(block)).nil, ($ptrType(ast.LabeledStmt)).nil, body.List); + _ref = fwdJumps; + _i = 0; + while (_i < _ref.$length) { + jmp = ((_i < 0 || _i >= _ref.$length) ? $throwRuntimeError("index out of range") : _ref.$array[_ref.$offset + _i]); + msg = ""; + name = jmp.Label.Name; + alt = all.Lookup(name); + if (!($interfaceIsEqual(alt, $ifaceNil))) { + msg = "goto %s jumps into block"; + $assertType(alt, ($ptrType(Label))).object.used = true; } else { - check.errorf(e.Pos(), "undeclared name: %s", new ($sliceType($emptyInterface))([new $String(e.Name)])); + msg = "label %s not declared"; } - return; + check.errorf(jmp.Label.Pos(), msg, new ($sliceType($emptyInterface))([new $String(name)])); + _i++; } - check.recordUse(e, obj); - check.objDecl(obj, def$1, path$1); - typ = obj.Type(); - assert(!($interfaceIsEqual(typ, $ifaceNil))); - _ref = obj; - if ($assertType(_ref, ($ptrType(PkgName)), true)[1]) { - obj$1 = _ref.$val; - check.errorf(e.Pos(), "use of package %s not in selector", new ($sliceType($emptyInterface))([new $String(obj$1.object.name)])); - return; - } else if ($assertType(_ref, ($ptrType(Const)), true)[1]) { - obj$1 = _ref.$val; - obj$1.object.used = true; - check.addDeclDep(obj$1); - if ($interfaceIsEqual(typ, $pkg.Typ[0])) { - return; - } - if (obj$1 === universeIota) { - if ($interfaceIsEqual(check.context.iota, $ifaceNil)) { - check.errorf(e.Pos(), "cannot use iota outside constant declaration", new ($sliceType($emptyInterface))([])); - return; - } - x.val = check.context.iota; - } else { - x.val = obj$1.val; + _ref$1 = all.elems; + _i$1 = 0; + _keys = $keys(_ref$1); + while (_i$1 < _keys.length) { + _entry = _ref$1[_keys[_i$1]]; + if (_entry === undefined) { + _i$1++; + continue; } - assert(!($interfaceIsEqual(x.val, $ifaceNil))); - x.mode = 4; - } else if ($assertType(_ref, ($ptrType(TypeName)), true)[1]) { - obj$1 = _ref.$val; - obj$1.object.used = true; - x.mode = 3; - _ref$1 = path$1; - _i = 0; - while (_i < _ref$1.$length) { - i = _i; - prev = ((_i < 0 || _i >= _ref$1.$length) ? $throwRuntimeError("index out of range") : _ref$1.$array[_ref$1.$offset + _i]); - if (prev === obj$1) { - check.errorf(obj$1.object.pos, "illegal cycle in declaration of %s", new ($sliceType($emptyInterface))([new $String(obj$1.object.name)])); - _ref$2 = $subslice(path$1, i); - _i$1 = 0; - while (_i$1 < _ref$2.$length) { - obj$2 = ((_i$1 < 0 || _i$1 >= _ref$2.$length) ? $throwRuntimeError("index out of range") : _ref$2.$array[_ref$2.$offset + _i$1]); - check.errorf(obj$2.object.Pos(), "\t%s refers to", new ($sliceType($emptyInterface))([new $String(obj$2.object.Name())])); - _i$1++; - } - check.errorf(obj$1.object.Pos(), "\t%s", new ($sliceType($emptyInterface))([new $String(obj$1.object.Name())])); - typ = $pkg.Typ[0]; - break; - } - _i++; + obj = _entry.v; + lbl = $assertType(obj, ($ptrType(Label))); + if (!lbl.object.used) { + check.softErrorf(lbl.object.pos, "label %s declared but not used", new ($sliceType($emptyInterface))([new $String(lbl.object.name)])); } - } else if ($assertType(_ref, ($ptrType(Var)), true)[1]) { - obj$1 = _ref.$val; - obj$1.object.used = true; - check.addDeclDep(obj$1); - x.mode = 5; - } else if ($assertType(_ref, ($ptrType(Func)), true)[1]) { - obj$1 = _ref.$val; - obj$1.object.used = true; - check.addDeclDep(obj$1); - x.mode = 7; - } else if ($assertType(_ref, ($ptrType(Builtin)), true)[1]) { - obj$1 = _ref.$val; - obj$1.object.used = true; - x.id = obj$1.id; - x.mode = 2; - } else if ($assertType(_ref, ($ptrType(Nil)), true)[1]) { - obj$1 = _ref.$val; - x.mode = 7; - } else { - obj$1 = _ref; - unreachable(); + _i$1++; } - x.typ = typ; }; - Checker.prototype.ident = function(x, e, def$1, path$1) { return this.$val.ident(x, e, def$1, path$1); }; - Checker.Ptr.prototype.typExpr = function(e, def$1, path$1) { - var T = $ifaceNil, $deferred = [], $err = null, check; - /* */ try { $deferFrames.push($deferred); - check = this; - T = check.typExprInternal(e, def$1, path$1); - assert(isTyped(T)); - check.recordTypeAndValue(e, 3, T, $ifaceNil); - return T; - /* */ } catch(err) { $err = err; } finally { $deferFrames.pop(); $callDeferred($deferred, $err); return T; } + Checker.prototype.labels = function(body) { return this.$val.labels(body); }; + block.Ptr.prototype.insert = function(s) { + var b, name, labels, _key$2; + b = this; + name = s.Label.Name; + labels = b.labels; + if (labels === false) { + labels = new $Map(); + b.labels = labels; + } + _key$2 = name; (labels || $throwRuntimeError("assignment to entry in nil map"))[_key$2] = { k: _key$2, v: s }; }; - Checker.prototype.typExpr = function(e, def$1, path$1) { return this.$val.typExpr(e, def$1, path$1); }; - Checker.Ptr.prototype.typ = function(e) { - var check; - check = this; - return check.typExpr(e, ($ptrType(Named)).nil, ($sliceType(($ptrType(TypeName)))).nil); + block.prototype.insert = function(s) { return this.$val.insert(s); }; + block.Ptr.prototype.gotoTarget = function(name) { + var b, s, _entry, t; + b = this; + s = b; + while (!(s === ($ptrType(block)).nil)) { + t = (_entry = s.labels[name], _entry !== undefined ? _entry.v : ($ptrType(ast.LabeledStmt)).nil); + if (!(t === ($ptrType(ast.LabeledStmt)).nil)) { + return t; + } + s = s.parent; + } + return ($ptrType(ast.LabeledStmt)).nil; }; - Checker.prototype.typ = function(e) { return this.$val.typ(e); }; - Checker.Ptr.prototype.funcType = function(sig, recvPar, ftyp) { - var check, scope, _tuple, recvList, _tuple$1, params, variadic, _tuple$2, results, recv, _ref, x, _tuple$3, t, err, _tuple$4, T, u, _ref$1; + block.prototype.gotoTarget = function(name) { return this.$val.gotoTarget(name); }; + block.Ptr.prototype.enclosingTarget = function(name) { + var b, s, t; + b = this; + s = b; + while (!(s === ($ptrType(block)).nil)) { + t = s.lstmt; + if (!(t === ($ptrType(ast.LabeledStmt)).nil) && t.Label.Name === name) { + return t; + } + s = s.parent; + } + return ($ptrType(ast.LabeledStmt)).nil; + }; + block.prototype.enclosingTarget = function(name) { return this.$val.enclosingTarget(name); }; + Checker.Ptr.prototype.blockBranches = function(all, parent, lstmt, list) { + var check, b, varDeclPos, _tmp, _tmp$1, fwdJumps, badJumps, recordVarDecl, jumpsOverVarDecl, blockBranches, stmtBranches, _ref, _i, s; check = this; - scope = NewScope(check.context.scope, "function"); - check.recordScope(ftyp, scope); - _tuple = check.collectParams(scope, recvPar, false); recvList = _tuple[0]; - _tuple$1 = check.collectParams(scope, ftyp.Params, true); params = _tuple$1[0]; variadic = _tuple$1[1]; - _tuple$2 = check.collectParams(scope, ftyp.Results, false); results = _tuple$2[0]; - if (!(recvPar === ($ptrType(ast.FieldList)).nil)) { - recv = ($ptrType(Var)).nil; - _ref = recvList.$length; - if (_ref === 0) { - check.error(recvPar.Pos(), "method is missing receiver"); - recv = NewParam(0, ($ptrType(Package)).nil, "", $pkg.Typ[0]); - } else if (_ref === 1) { - recv = ((0 < 0 || 0 >= recvList.$length) ? $throwRuntimeError("index out of range") : recvList.$array[recvList.$offset + 0]); - } else { - check.error((x = recvList.$length - 1 >> 0, ((x < 0 || x >= recvList.$length) ? $throwRuntimeError("index out of range") : recvList.$array[recvList.$offset + x])).object.Pos(), "method must have exactly one receiver"); - recv = ((0 < 0 || 0 >= recvList.$length) ? $throwRuntimeError("index out of range") : recvList.$array[recvList.$offset + 0]); + b = new block.Ptr(parent, lstmt, false); + varDeclPos = 0; + _tmp = ($sliceType(($ptrType(ast.BranchStmt)))).nil; _tmp$1 = ($sliceType(($ptrType(ast.BranchStmt)))).nil; fwdJumps = _tmp; badJumps = _tmp$1; + recordVarDecl = (function(pos) { + varDeclPos = pos; + badJumps = $appendSlice($subslice(badJumps, 0, 0), fwdJumps); + }); + jumpsOverVarDecl = (function(jmp) { + var _ref, _i, bad; + if ((new token.Pos(varDeclPos)).IsValid()) { + _ref = badJumps; + _i = 0; + while (_i < _ref.$length) { + bad = ((_i < 0 || _i >= _ref.$length) ? $throwRuntimeError("index out of range") : _ref.$array[_ref.$offset + _i]); + if (jmp === bad) { + return true; + } + _i++; + } } - _tuple$3 = deref(recv.object.typ); t = _tuple$3[0]; - if (!($interfaceIsEqual(t, $pkg.Typ[0]))) { - err = ""; - _tuple$4 = $assertType(t, ($ptrType(Named)), true); T = _tuple$4[0]; - if (!(T === ($ptrType(Named)).nil)) { - if (!(T.obj.object.pkg === check.pkg)) { - err = "type not defined in this package"; + return false; + }); + blockBranches = (function(lstmt$1, list$1) { + fwdJumps = $appendSlice(fwdJumps, check.blockBranches(all, b, lstmt$1, list$1)); + }); + stmtBranches = $throwNilPointerError; + stmtBranches = (function(s) { + var s$1, _ref, _tuple, d, name, lbl, alt, i, _ref$1, _i, jmp, name$1, _ref$2, valid, t, _ref$3, valid$1, t$1, _ref$4, obj; + _ref = s; + if ($assertType(_ref, ($ptrType(ast.DeclStmt)), true)[1]) { + s$1 = _ref.$val; + _tuple = $assertType(s$1.Decl, ($ptrType(ast.GenDecl)), true); d = _tuple[0]; + if (!(d === ($ptrType(ast.GenDecl)).nil) && (d.Tok === 85)) { + recordVarDecl(d.Pos()); + } + } else if ($assertType(_ref, ($ptrType(ast.LabeledStmt)), true)[1]) { + s$1 = _ref.$val; + name = s$1.Label.Name; + if (!(name === "_")) { + lbl = NewLabel(s$1.Label.Pos(), check.pkg, name); + alt = all.Insert(lbl); + if (!($interfaceIsEqual(alt, $ifaceNil))) { + check.softErrorf(lbl.object.pos, "label %s already declared", new ($sliceType($emptyInterface))([new $String(name)])); + check.reportAltDecl(alt); } else { - _ref$1 = T.underlying; - if ($assertType(_ref$1, ($ptrType(Basic)), true)[1]) { - u = _ref$1.$val; - if (u.kind === 18) { - err = "unsafe.Pointer"; + b.insert(s$1); + check.recordDef(s$1.Label, lbl); + } + i = 0; + _ref$1 = fwdJumps; + _i = 0; + while (_i < _ref$1.$length) { + jmp = ((_i < 0 || _i >= _ref$1.$length) ? $throwRuntimeError("index out of range") : _ref$1.$array[_ref$1.$offset + _i]); + if (jmp.Label.Name === name) { + lbl.object.used = true; + check.recordUse(jmp.Label, lbl); + if (jumpsOverVarDecl(jmp)) { + check.softErrorf(jmp.Label.Pos(), "goto %s jumps over variable declaration at line %d", new ($sliceType($emptyInterface))([new $String(name), new $Int(check.fset.Position(varDeclPos).Line)])); } - } else if ($assertType(_ref$1, ($ptrType(Pointer)), true)[1] || $assertType(_ref$1, ($ptrType(Interface)), true)[1]) { - u = _ref$1; - err = "pointer or interface type"; + } else { + (i < 0 || i >= fwdJumps.$length) ? $throwRuntimeError("index out of range") : fwdJumps.$array[fwdJumps.$offset + i] = jmp; + i = i + (1) >> 0; + } + _i++; + } + fwdJumps = $subslice(fwdJumps, 0, i); + lstmt = s$1; + } + stmtBranches(s$1.Stmt); + } else if ($assertType(_ref, ($ptrType(ast.BranchStmt)), true)[1]) { + s$1 = _ref.$val; + if (s$1.Label === ($ptrType(ast.Ident)).nil) { + return; + } + name$1 = s$1.Label.Name; + _ref$2 = s$1.Tok; + if (_ref$2 === 61) { + valid = false; + t = b.enclosingTarget(name$1); + if (!(t === ($ptrType(ast.LabeledStmt)).nil)) { + _ref$3 = t.Stmt; + if ($assertType(_ref$3, ($ptrType(ast.SwitchStmt)), true)[1] || $assertType(_ref$3, ($ptrType(ast.TypeSwitchStmt)), true)[1] || $assertType(_ref$3, ($ptrType(ast.SelectStmt)), true)[1] || $assertType(_ref$3, ($ptrType(ast.ForStmt)), true)[1] || $assertType(_ref$3, ($ptrType(ast.RangeStmt)), true)[1]) { + valid = true; + } + } + if (!valid) { + check.errorf(s$1.Label.Pos(), "invalid break label %s", new ($sliceType($emptyInterface))([new $String(name$1)])); + return; + } + } else if (_ref$2 === 65) { + valid$1 = false; + t$1 = b.enclosingTarget(name$1); + if (!(t$1 === ($ptrType(ast.LabeledStmt)).nil)) { + _ref$4 = t$1.Stmt; + if ($assertType(_ref$4, ($ptrType(ast.ForStmt)), true)[1] || $assertType(_ref$4, ($ptrType(ast.RangeStmt)), true)[1]) { + valid$1 = true; } } + if (!valid$1) { + check.errorf(s$1.Label.Pos(), "invalid continue label %s", new ($sliceType($emptyInterface))([new $String(name$1)])); + return; + } + } else if (_ref$2 === 73) { + if (b.gotoTarget(name$1) === ($ptrType(ast.LabeledStmt)).nil) { + fwdJumps = $append(fwdJumps, s$1); + return; + } } else { - err = "basic or unnamed type"; + check.invalidAST(s$1.Pos(), "branch statement: %s %s", new ($sliceType($emptyInterface))([new token.Token(s$1.Tok), new $String(name$1)])); + return; } - if (!(err === "")) { - check.errorf(recv.object.pos, "invalid receiver %s (%s)", new ($sliceType($emptyInterface))([recv.object.typ, new $String(err)])); + obj = all.Lookup(name$1); + $assertType(obj, ($ptrType(Label))).object.used = true; + check.recordUse(s$1.Label, obj); + } else if ($assertType(_ref, ($ptrType(ast.AssignStmt)), true)[1]) { + s$1 = _ref.$val; + if (s$1.Tok === 47) { + recordVarDecl(s$1.Pos()); } - } - sig.recv = recv; - } - sig.scope = scope; - sig.params = NewTuple(params); - sig.results = NewTuple(results); - sig.variadic = variadic; - return sig; - }; - Checker.prototype.funcType = function(sig, recvPar, ftyp) { return this.$val.funcType(sig, recvPar, ftyp); }; - Checker.Ptr.prototype.typExprInternal = function(e, def$1, path$1) { - var check, e$1, _ref, x, _ref$1, typ, x$1, _ref$2, typ$1, typ$2, typ$3, typ$4, typ$5, typ$6, typ$7, typ$8, typ$9, dir, _ref$3, typ$10; - check = this; - _ref = e; - if ($assertType(_ref, ($ptrType(ast.BadExpr)), true)[1]) { - e$1 = _ref.$val; - } else if ($assertType(_ref, ($ptrType(ast.Ident)), true)[1]) { - e$1 = _ref.$val; - x = new operand.Ptr(); $copy(x, new operand.Ptr(), operand); - check.ident(x, e$1, def$1, path$1); - _ref$1 = x.mode; - if (_ref$1 === 3) { - typ = x.typ; - def$1.setUnderlying(typ); - return typ; - } else if (_ref$1 === 0) { - } else if (_ref$1 === 1) { - check.errorf(x.pos(), "%s used as type", new ($sliceType($emptyInterface))([x])); - } else { - check.errorf(x.pos(), "%s is not a type", new ($sliceType($emptyInterface))([x])); - } - } else if ($assertType(_ref, ($ptrType(ast.SelectorExpr)), true)[1]) { - e$1 = _ref.$val; - x$1 = new operand.Ptr(); $copy(x$1, new operand.Ptr(), operand); - check.selector(x$1, e$1); - _ref$2 = x$1.mode; - if (_ref$2 === 3) { - typ$1 = x$1.typ; - def$1.setUnderlying(typ$1); - return typ$1; - } else if (_ref$2 === 0) { - } else if (_ref$2 === 1) { - check.errorf(x$1.pos(), "%s used as type", new ($sliceType($emptyInterface))([x$1])); - } else { - check.errorf(x$1.pos(), "%s is not a type", new ($sliceType($emptyInterface))([x$1])); - } - } else if ($assertType(_ref, ($ptrType(ast.ParenExpr)), true)[1]) { - e$1 = _ref.$val; - return check.typExpr(e$1.X, def$1, path$1); - } else if ($assertType(_ref, ($ptrType(ast.ArrayType)), true)[1]) { - e$1 = _ref.$val; - if (!($interfaceIsEqual(e$1.Len, $ifaceNil))) { - typ$2 = new Array.Ptr(); - def$1.setUnderlying(typ$2); - typ$2.len = check.arrayLength(e$1.Len); - typ$2.elem = check.typExpr(e$1.Elt, ($ptrType(Named)).nil, path$1); - return typ$2; - } else { - typ$3 = new Slice.Ptr(); - def$1.setUnderlying(typ$3); - typ$3.elem = check.typ(e$1.Elt); - return typ$3; - } - } else if ($assertType(_ref, ($ptrType(ast.StructType)), true)[1]) { - e$1 = _ref.$val; - typ$4 = new Struct.Ptr(); - def$1.setUnderlying(typ$4); - check.structType(typ$4, e$1, path$1); - return typ$4; - } else if ($assertType(_ref, ($ptrType(ast.StarExpr)), true)[1]) { - e$1 = _ref.$val; - typ$5 = new Pointer.Ptr(); - def$1.setUnderlying(typ$5); - typ$5.base = check.typ(e$1.X); - return typ$5; - } else if ($assertType(_ref, ($ptrType(ast.FuncType)), true)[1]) { - e$1 = _ref.$val; - typ$6 = new Signature.Ptr(); - def$1.setUnderlying(typ$6); - check.funcType(typ$6, ($ptrType(ast.FieldList)).nil, e$1); - return typ$6; - } else if ($assertType(_ref, ($ptrType(ast.InterfaceType)), true)[1]) { - e$1 = _ref.$val; - typ$7 = new Interface.Ptr(); - def$1.setUnderlying(typ$7); - check.interfaceType(typ$7, e$1, def$1, path$1); - return typ$7; - } else if ($assertType(_ref, ($ptrType(ast.MapType)), true)[1]) { - e$1 = _ref.$val; - typ$8 = new Map.Ptr(); - def$1.setUnderlying(typ$8); - typ$8.key = check.typ(e$1.Key); - typ$8.elem = check.typ(e$1.Value); - check.delay((function() { - if (!Comparable(typ$8.key)) { - check.errorf(e$1.Key.Pos(), "invalid map key type %s", new ($sliceType($emptyInterface))([typ$8.key])); + } else if ($assertType(_ref, ($ptrType(ast.BlockStmt)), true)[1]) { + s$1 = _ref.$val; + blockBranches(lstmt, s$1.List); + } else if ($assertType(_ref, ($ptrType(ast.IfStmt)), true)[1]) { + s$1 = _ref.$val; + stmtBranches(s$1.Body); + if (!($interfaceIsEqual(s$1.Else, $ifaceNil))) { + stmtBranches(s$1.Else); } - })); - return typ$8; - } else if ($assertType(_ref, ($ptrType(ast.ChanType)), true)[1]) { - e$1 = _ref.$val; - typ$9 = new Chan.Ptr(); - def$1.setUnderlying(typ$9); - dir = 0; - _ref$3 = e$1.Dir; - if (_ref$3 === 3) { - } else if (_ref$3 === 1) { - dir = 1; - } else if (_ref$3 === 2) { - dir = 2; - } else { - check.invalidAST(e$1.Pos(), "unknown channel direction %d", new ($sliceType($emptyInterface))([new ast.ChanDir(e$1.Dir)])); + } else if ($assertType(_ref, ($ptrType(ast.CaseClause)), true)[1]) { + s$1 = _ref.$val; + blockBranches(($ptrType(ast.LabeledStmt)).nil, s$1.Body); + } else if ($assertType(_ref, ($ptrType(ast.SwitchStmt)), true)[1]) { + s$1 = _ref.$val; + stmtBranches(s$1.Body); + } else if ($assertType(_ref, ($ptrType(ast.TypeSwitchStmt)), true)[1]) { + s$1 = _ref.$val; + stmtBranches(s$1.Body); + } else if ($assertType(_ref, ($ptrType(ast.CommClause)), true)[1]) { + s$1 = _ref.$val; + blockBranches(($ptrType(ast.LabeledStmt)).nil, s$1.Body); + } else if ($assertType(_ref, ($ptrType(ast.SelectStmt)), true)[1]) { + s$1 = _ref.$val; + stmtBranches(s$1.Body); + } else if ($assertType(_ref, ($ptrType(ast.ForStmt)), true)[1]) { + s$1 = _ref.$val; + stmtBranches(s$1.Body); + } else if ($assertType(_ref, ($ptrType(ast.RangeStmt)), true)[1]) { + s$1 = _ref.$val; + stmtBranches(s$1.Body); } - typ$9.dir = dir; - typ$9.elem = check.typ(e$1.Value); - return typ$9; - } else { - e$1 = _ref; - check.errorf(e$1.Pos(), "%s is not a type", new ($sliceType($emptyInterface))([e$1])); + }); + _ref = list; + _i = 0; + while (_i < _ref.$length) { + s = ((_i < 0 || _i >= _ref.$length) ? $throwRuntimeError("index out of range") : _ref.$array[_ref.$offset + _i]); + stmtBranches(s); + _i++; } - typ$10 = $pkg.Typ[0]; - def$1.setUnderlying(typ$10); - return typ$10; + return fwdJumps; }; - Checker.prototype.typExprInternal = function(e, def$1, path$1) { return this.$val.typExprInternal(e, def$1, path$1); }; - Checker.Ptr.prototype.typOrNil = function(e) { - var check, x, _ref; - check = this; - x = new operand.Ptr(); $copy(x, new operand.Ptr(), operand); - check.rawExpr(x, e, $ifaceNil); - _ref = x.mode; - if (_ref === 0) { - } else if (_ref === 1) { - check.errorf(x.pos(), "%s used as type", new ($sliceType($emptyInterface))([x])); - } else if (_ref === 3) { - return x.typ; - } else if (_ref === 7) { - if (x.isNil()) { - return $ifaceNil; + Checker.prototype.blockBranches = function(all, parent, lstmt, list) { return this.$val.blockBranches(all, parent, lstmt, list); }; + LookupFieldOrMethod = $pkg.LookupFieldOrMethod = function(T, addressable, pkg, name) { + var obj = $ifaceNil, index = ($sliceType($Int)).nil, indirect = false, _tuple, t, _tuple$1, p, _tuple$2, _tuple$3, ok, _tmp, _tmp$1, _tmp$2, _tuple$4; + _tuple = $assertType(T, ($ptrType(Named)), true); t = _tuple[0]; + if (!(t === ($ptrType(Named)).nil)) { + _tuple$1 = $assertType(t.underlying, ($ptrType(Pointer)), true); p = _tuple$1[0]; + if (!(p === ($ptrType(Pointer)).nil)) { + _tuple$2 = lookupFieldOrMethod(p, false, pkg, name); obj = _tuple$2[0]; index = _tuple$2[1]; indirect = _tuple$2[2]; + _tuple$3 = $assertType(obj, ($ptrType(Func)), true); ok = _tuple$3[1]; + if (ok) { + _tmp = $ifaceNil; _tmp$1 = ($sliceType($Int)).nil; _tmp$2 = false; obj = _tmp; index = _tmp$1; indirect = _tmp$2; + return [obj, index, indirect]; + } + return [obj, index, indirect]; } - check.errorf(x.pos(), "%s is not a type", new ($sliceType($emptyInterface))([x])); - } else { - check.errorf(x.pos(), "%s is not a type", new ($sliceType($emptyInterface))([x])); } - return $pkg.Typ[0]; + _tuple$4 = lookupFieldOrMethod(T, addressable, pkg, name); obj = _tuple$4[0]; index = _tuple$4[1]; indirect = _tuple$4[2]; + return [obj, index, indirect]; }; - Checker.prototype.typOrNil = function(e) { return this.$val.typOrNil(e); }; - Checker.Ptr.prototype.arrayLength = function(e) { - var check, x, _tuple, n, ok; - check = this; - x = new operand.Ptr(); $copy(x, new operand.Ptr(), operand); - check.expr(x, e); - if (!((x.mode === 4))) { - if (!((x.mode === 0))) { - check.errorf(x.pos(), "array length %s must be constant", new ($sliceType($emptyInterface))([x])); - } - return new $Int64(0, 0); + lookupFieldOrMethod = function(T, addressable, pkg, name) { + var obj = $ifaceNil, index = ($sliceType($Int)).nil, indirect = false, _tuple, typ, isPtr, _tuple$1, named, utyp, _tuple$2, ok, current, seen, next, _ref, _i, e, _entry, _key$2, _tuple$3, i, m, _tmp, _tmp$1, _tmp$2, t, _ref$1, _ref$2, _i$1, i$1, f, _tmp$3, _tmp$4, _tmp$5, _tuple$4, typ$1, isPtr$1, _tuple$5, t$1, _tuple$6, i$2, m$1, _tmp$6, _tmp$7, _tmp$8, _tuple$7, f$1, _tmp$9, _tmp$10, _tmp$11, _tmp$12, _tmp$13, _tmp$14; + if (name === "_") { + return [obj, index, indirect]; } - if (!x.isInteger()) { - check.errorf(x.pos(), "array length %s must be integer", new ($sliceType($emptyInterface))([x])); - return new $Int64(0, 0); + _tuple = deref(T); typ = _tuple[0]; isPtr = _tuple[1]; + _tuple$1 = $assertType(typ, ($ptrType(Named)), true); named = _tuple$1[0]; + if (isPtr) { + utyp = typ; + if (!(named === ($ptrType(Named)).nil)) { + utyp = named.underlying; + } + _tuple$2 = $assertType(utyp, ($ptrType(Interface)), true); ok = _tuple$2[1]; + if (ok) { + return [obj, index, indirect]; + } } - _tuple = exact.Int64Val(x.val); n = _tuple[0]; ok = _tuple[1]; - if (!ok || (n.$high < 0 || (n.$high === 0 && n.$low < 0))) { - check.errorf(x.pos(), "invalid array length %s", new ($sliceType($emptyInterface))([x])); - return new $Int64(0, 0); + current = new ($sliceType(embeddedType))([new embeddedType.Ptr(named, ($sliceType($Int)).nil, isPtr, false)]); + seen = false; + while (current.$length > 0) { + next = ($sliceType(embeddedType)).nil; + _ref = current; + _i = 0; + while (_i < _ref.$length) { + e = new embeddedType.Ptr(); $copy(e, ((_i < 0 || _i >= _ref.$length) ? $throwRuntimeError("index out of range") : _ref.$array[_ref.$offset + _i]), embeddedType); + if (!(e.typ === ($ptrType(Named)).nil)) { + if ((_entry = seen[e.typ.$key()], _entry !== undefined ? _entry.v : false)) { + _i++; + continue; + } + if (seen === false) { + seen = new $Map(); + } + _key$2 = e.typ; (seen || $throwRuntimeError("assignment to entry in nil map"))[_key$2.$key()] = { k: _key$2, v: true }; + _tuple$3 = lookupMethod(e.typ.methods, pkg, name); i = _tuple$3[0]; m = _tuple$3[1]; + if (!(m === ($ptrType(Func)).nil)) { + assert(!($interfaceIsEqual(m.object.typ, $ifaceNil))); + index = concat(e.index, i); + if (!($interfaceIsEqual(obj, $ifaceNil)) || e.multiples) { + _tmp = $ifaceNil; _tmp$1 = index; _tmp$2 = false; obj = _tmp; index = _tmp$1; indirect = _tmp$2; + return [obj, index, indirect]; + } + obj = m; + indirect = e.indirect; + _i++; + continue; + } + typ = e.typ.underlying; + } + _ref$1 = typ; + if ($assertType(_ref$1, ($ptrType(Struct)), true)[1]) { + t = _ref$1.$val; + _ref$2 = t.fields; + _i$1 = 0; + while (_i$1 < _ref$2.$length) { + i$1 = _i$1; + f = ((_i$1 < 0 || _i$1 >= _ref$2.$length) ? $throwRuntimeError("index out of range") : _ref$2.$array[_ref$2.$offset + _i$1]); + if (f.object.sameId(pkg, name)) { + assert(!($interfaceIsEqual(f.object.typ, $ifaceNil))); + index = concat(e.index, i$1); + if (!($interfaceIsEqual(obj, $ifaceNil)) || e.multiples) { + _tmp$3 = $ifaceNil; _tmp$4 = index; _tmp$5 = false; obj = _tmp$3; index = _tmp$4; indirect = _tmp$5; + return [obj, index, indirect]; + } + obj = f; + indirect = e.indirect; + _i$1++; + continue; + } + if ($interfaceIsEqual(obj, $ifaceNil) && f.anonymous) { + _tuple$4 = deref(f.object.typ); typ$1 = _tuple$4[0]; isPtr$1 = _tuple$4[1]; + _tuple$5 = $assertType(typ$1, ($ptrType(Named)), true); t$1 = _tuple$5[0]; + if (!(t$1 === ($ptrType(Named)).nil)) { + next = $append(next, new embeddedType.Ptr(t$1, concat(e.index, i$1), e.indirect || isPtr$1, e.multiples)); + } + } + _i$1++; + } + } else if ($assertType(_ref$1, ($ptrType(Interface)), true)[1]) { + t = _ref$1.$val; + _tuple$6 = lookupMethod(t.allMethods, pkg, name); i$2 = _tuple$6[0]; m$1 = _tuple$6[1]; + if (!(m$1 === ($ptrType(Func)).nil)) { + assert(!($interfaceIsEqual(m$1.object.typ, $ifaceNil))); + index = concat(e.index, i$2); + if (!($interfaceIsEqual(obj, $ifaceNil)) || e.multiples) { + _tmp$6 = $ifaceNil; _tmp$7 = index; _tmp$8 = false; obj = _tmp$6; index = _tmp$7; indirect = _tmp$8; + return [obj, index, indirect]; + } + obj = m$1; + indirect = e.indirect; + } + } + _i++; + } + if (!($interfaceIsEqual(obj, $ifaceNil))) { + _tuple$7 = $assertType(obj, ($ptrType(Func)), true); f$1 = _tuple$7[0]; + if (!(f$1 === ($ptrType(Func)).nil) && ptrRecv(f$1) && !indirect && !addressable) { + _tmp$9 = $ifaceNil; _tmp$10 = ($sliceType($Int)).nil; _tmp$11 = true; obj = _tmp$9; index = _tmp$10; indirect = _tmp$11; + return [obj, index, indirect]; + } + return [obj, index, indirect]; + } + current = consolidateMultiples(next); } - return n; + _tmp$12 = $ifaceNil; _tmp$13 = ($sliceType($Int)).nil; _tmp$14 = false; obj = _tmp$12; index = _tmp$13; indirect = _tmp$14; + return [obj, index, indirect]; }; - Checker.prototype.arrayLength = function(e) { return this.$val.arrayLength(e); }; - Checker.Ptr.prototype.collectParams = function(scope, list, variadicOk) { - var params = ($sliceType(($ptrType(Var)))).nil, variadic = false, check, _tmp, _tmp$1, named, anonymous, _ref, _i, i, field, ftype, _tuple, t, typ, _ref$1, _i$1, name, par, par$1, x, last; - check = this; - if (list === ($ptrType(ast.FieldList)).nil) { - return [params, variadic]; + consolidateMultiples = function(list) { + var n, prev, _ref, _i, e, _tuple, _entry, i, found, _key$2; + if (list.$length <= 1) { + return list; } - _tmp = false; _tmp$1 = false; named = _tmp; anonymous = _tmp$1; - _ref = list.List; + n = 0; + prev = new $Map(); + _ref = list; _i = 0; while (_i < _ref.$length) { - i = _i; - field = ((_i < 0 || _i >= _ref.$length) ? $throwRuntimeError("index out of range") : _ref.$array[_ref.$offset + _i]); - ftype = field.Type; - _tuple = $assertType(ftype, ($ptrType(ast.Ellipsis)), true); t = _tuple[0]; - if (!(t === ($ptrType(ast.Ellipsis)).nil)) { - ftype = t.Elt; - if (variadicOk && (i === (list.List.$length - 1 >> 0))) { - variadic = true; - } else { - check.invalidAST(field.Pos(), "... not permitted", new ($sliceType($emptyInterface))([])); - } - } - typ = check.typ(ftype); - if (field.Names.$length > 0) { - _ref$1 = field.Names; - _i$1 = 0; - while (_i$1 < _ref$1.$length) { - name = ((_i$1 < 0 || _i$1 >= _ref$1.$length) ? $throwRuntimeError("index out of range") : _ref$1.$array[_ref$1.$offset + _i$1]); - if (name.Name === "") { - check.invalidAST(name.Pos(), "anonymous parameter", new ($sliceType($emptyInterface))([])); - } - par = NewParam(name.Pos(), check.pkg, name.Name, typ); - check.declare(scope, name, par); - params = $append(params, par); - _i$1++; - } - named = true; + e = new embeddedType.Ptr(); $copy(e, ((_i < 0 || _i >= _ref.$length) ? $throwRuntimeError("index out of range") : _ref.$array[_ref.$offset + _i]), embeddedType); + _tuple = (_entry = prev[e.typ.$key()], _entry !== undefined ? [_entry.v, true] : [0, false]); i = _tuple[0]; found = _tuple[1]; + if (found) { + ((i < 0 || i >= list.$length) ? $throwRuntimeError("index out of range") : list.$array[list.$offset + i]).multiples = true; } else { - par$1 = NewParam(ftype.Pos(), check.pkg, "", typ); - check.recordImplicit(field, par$1); - params = $append(params, par$1); - anonymous = true; + _key$2 = e.typ; (prev || $throwRuntimeError("assignment to entry in nil map"))[_key$2.$key()] = { k: _key$2, v: n }; + $copy(((n < 0 || n >= list.$length) ? $throwRuntimeError("index out of range") : list.$array[list.$offset + n]), e, embeddedType); + n = n + (1) >> 0; } _i++; } - if (named && anonymous) { - check.invalidAST(list.Pos(), "list contains both named and anonymous parameters", new ($sliceType($emptyInterface))([])); - } - if (variadic && params.$length > 0) { - last = (x = params.$length - 1 >> 0, ((x < 0 || x >= params.$length) ? $throwRuntimeError("index out of range") : params.$array[params.$offset + x])); - last.object.typ = new Slice.Ptr(last.object.typ); - } - return [params, variadic]; - }; - Checker.prototype.collectParams = function(scope, list, variadicOk) { return this.$val.collectParams(scope, list, variadicOk); }; - Checker.Ptr.prototype.declareInSet = function(oset, pos, obj) { - var check, alt; - check = this; - alt = oset.insert(obj); - if (!($interfaceIsEqual(alt, $ifaceNil))) { - check.errorf(pos, "%s redeclared", new ($sliceType($emptyInterface))([new $String(obj.Name())])); - check.reportAltDecl(alt); - return false; - } - return true; + return $subslice(list, 0, n); }; - Checker.prototype.declareInSet = function(oset, pos, obj) { return this.$val.declareInSet(oset, pos, obj); }; - Checker.Ptr.prototype.interfaceType = function(iface, ityp, def$1, path$1) { - var check, recvTyp, mset, signatures, embedded, _ref, _i, f, x, name, pos, sig, m, _ref$1, _i$1, e, pos$1, typ, _tuple, named, u, _tuple$1, embed, _ref$2, _i$2, m$1, _ref$3, _i$3, i, m$2, expr, typ$1, _tuple$2, sig$1, old, x$1, x$2, x$3; - check = this; - if (ityp.Methods === ($ptrType(ast.FieldList)).nil) { - return; - } - recvTyp = iface; - if (!(def$1 === ($ptrType(Named)).nil)) { - recvTyp = def$1; + MissingMethod = $pkg.MissingMethod = function(V, T, static$1) { + var method = ($ptrType(Func)).nil, wrongType = false, _tuple, ityp, _ref, _i, m, _tuple$1, obj, _tmp, _tmp$1, _tmp$2, _tmp$3, _ref$1, _i$1, m$1, _tuple$2, obj$1, _tuple$3, f, _tmp$4, _tmp$5, _tmp$6, _tmp$7; + if (T.Empty()) { + return [method, wrongType]; } - mset = false; - signatures = ($sliceType(ast.Expr)).nil; - embedded = ($sliceType(ast.Expr)).nil; - _ref = ityp.Methods.List; - _i = 0; - while (_i < _ref.$length) { - f = ((_i < 0 || _i >= _ref.$length) ? $throwRuntimeError("index out of range") : _ref.$array[_ref.$offset + _i]); - if (f.Names.$length > 0) { - name = (x = f.Names, ((0 < 0 || 0 >= x.$length) ? $throwRuntimeError("index out of range") : x.$array[x.$offset + 0])); - pos = name.Pos(); - if (name.Name === "_") { - check.errorf(pos, "invalid method name _", new ($sliceType($emptyInterface))([])); - _i++; - continue; - } - sig = new Signature.Ptr(); - sig.recv = NewVar(pos, check.pkg, "", recvTyp); - m = NewFunc(pos, check.pkg, name.Name, sig); - if (check.declareInSet(new ($ptrType(objset))(function() { return mset; }, function($v) { mset = $v; }), pos, m)) { - iface.methods = $append(iface.methods, m); - iface.allMethods = $append(iface.allMethods, m); - signatures = $append(signatures, f.Type); - check.recordDef(name, m); + _tuple = $assertType(V.Underlying(), ($ptrType(Interface)), true); ityp = _tuple[0]; + if (!(ityp === ($ptrType(Interface)).nil)) { + _ref = T.allMethods; + _i = 0; + while (_i < _ref.$length) { + m = ((_i < 0 || _i >= _ref.$length) ? $throwRuntimeError("index out of range") : _ref.$array[_ref.$offset + _i]); + _tuple$1 = lookupMethod(ityp.allMethods, m.object.pkg, m.object.name); obj = _tuple$1[1]; + if (obj === ($ptrType(Func)).nil) { + if (static$1) { + _tmp = m; _tmp$1 = false; method = _tmp; wrongType = _tmp$1; + return [method, wrongType]; + } + } else if (!Identical(obj.object.Type(), m.object.typ)) { + _tmp$2 = m; _tmp$3 = true; method = _tmp$2; wrongType = _tmp$3; + return [method, wrongType]; } - } else { - embedded = $append(embedded, f.Type); + _i++; } - _i++; + return [method, wrongType]; } - _ref$1 = embedded; + _ref$1 = T.allMethods; _i$1 = 0; while (_i$1 < _ref$1.$length) { - e = ((_i$1 < 0 || _i$1 >= _ref$1.$length) ? $throwRuntimeError("index out of range") : _ref$1.$array[_ref$1.$offset + _i$1]); - pos$1 = e.Pos(); - typ = check.typExpr(e, ($ptrType(Named)).nil, path$1); - _tuple = $assertType(typ, ($ptrType(Named)), true); named = _tuple[0]; - if (named === ($ptrType(Named)).nil) { - if (!($interfaceIsEqual(typ, $pkg.Typ[0]))) { - check.invalidAST(pos$1, "%s is not named type", new ($sliceType($emptyInterface))([typ])); - } - _i$1++; - continue; - } - u = underlying(named); - _tuple$1 = $assertType(u, ($ptrType(Interface)), true); embed = _tuple$1[0]; - if (embed === ($ptrType(Interface)).nil) { - if (!($interfaceIsEqual(u, $pkg.Typ[0]))) { - check.errorf(pos$1, "%s is not an interface", new ($sliceType($emptyInterface))([named])); - } - _i$1++; - continue; + m$1 = ((_i$1 < 0 || _i$1 >= _ref$1.$length) ? $throwRuntimeError("index out of range") : _ref$1.$array[_ref$1.$offset + _i$1]); + _tuple$2 = lookupFieldOrMethod(V, false, m$1.object.pkg, m$1.object.name); obj$1 = _tuple$2[0]; + _tuple$3 = $assertType(obj$1, ($ptrType(Func)), true); f = _tuple$3[0]; + if (f === ($ptrType(Func)).nil) { + _tmp$4 = m$1; _tmp$5 = false; method = _tmp$4; wrongType = _tmp$5; + return [method, wrongType]; } - iface.embeddeds = $append(iface.embeddeds, named); - _ref$2 = embed.allMethods; - _i$2 = 0; - while (_i$2 < _ref$2.$length) { - m$1 = ((_i$2 < 0 || _i$2 >= _ref$2.$length) ? $throwRuntimeError("index out of range") : _ref$2.$array[_ref$2.$offset + _i$2]); - if (check.declareInSet(new ($ptrType(objset))(function() { return mset; }, function($v) { mset = $v; }), pos$1, m$1)) { - iface.allMethods = $append(iface.allMethods, m$1); - } - _i$2++; + if (!Identical(f.object.typ, m$1.object.typ)) { + _tmp$6 = m$1; _tmp$7 = true; method = _tmp$6; wrongType = _tmp$7; + return [method, wrongType]; } _i$1++; } - _ref$3 = iface.methods; - _i$3 = 0; - while (_i$3 < _ref$3.$length) { - i = _i$3; - m$2 = ((_i$3 < 0 || _i$3 >= _ref$3.$length) ? $throwRuntimeError("index out of range") : _ref$3.$array[_ref$3.$offset + _i$3]); - expr = ((i < 0 || i >= signatures.$length) ? $throwRuntimeError("index out of range") : signatures.$array[signatures.$offset + i]); - typ$1 = check.typ(expr); - _tuple$2 = $assertType(typ$1, ($ptrType(Signature)), true); sig$1 = _tuple$2[0]; - if (sig$1 === ($ptrType(Signature)).nil) { - if (!($interfaceIsEqual(typ$1, $pkg.Typ[0]))) { - check.invalidAST(expr.Pos(), "%s is not a method signature", new ($sliceType($emptyInterface))([typ$1])); - } - _i$3++; - continue; - } - old = $assertType(m$2.object.typ, ($ptrType(Signature))); - sig$1.recv = old.recv; - $copy(old, sig$1, Signature); - _i$3++; - } - sort.Sort((x$1 = iface.methods, $subslice(new byUniqueMethodName(x$1.$array), x$1.$offset, x$1.$offset + x$1.$length))); - sort.Sort((x$2 = iface.embeddeds, $subslice(new byUniqueTypeName(x$2.$array), x$2.$offset, x$2.$offset + x$2.$length))); - sort.Sort((x$3 = iface.allMethods, $subslice(new byUniqueMethodName(x$3.$array), x$3.$offset, x$3.$offset + x$3.$length))); - }; - Checker.prototype.interfaceType = function(iface, ityp, def$1, path$1) { return this.$val.interfaceType(iface, ityp, def$1, path$1); }; - byUniqueTypeName.prototype.Len = function() { - var a; - a = this; - return a.$length; + return [method, wrongType]; }; - $ptrType(byUniqueTypeName).prototype.Len = function() { return this.$get().Len(); }; - byUniqueTypeName.prototype.Less = function(i, j) { - var a; - a = this; - return ((i < 0 || i >= a.$length) ? $throwRuntimeError("index out of range") : a.$array[a.$offset + i]).obj.object.Id() < ((j < 0 || j >= a.$length) ? $throwRuntimeError("index out of range") : a.$array[a.$offset + j]).obj.object.Id(); + assertableTo = function(V, T) { + var method = ($ptrType(Func)).nil, wrongType = false, _tuple, ok, _tuple$1; + _tuple = $assertType(T.Underlying(), ($ptrType(Interface)), true); ok = _tuple[1]; + if (ok && true) { + return [method, wrongType]; + } + _tuple$1 = MissingMethod(T, V, false); method = _tuple$1[0]; wrongType = _tuple$1[1]; + return [method, wrongType]; }; - $ptrType(byUniqueTypeName).prototype.Less = function(i, j) { return this.$get().Less(i, j); }; - byUniqueTypeName.prototype.Swap = function(i, j) { - var a, _tmp, _tmp$1; - a = this; - _tmp = ((j < 0 || j >= a.$length) ? $throwRuntimeError("index out of range") : a.$array[a.$offset + j]); _tmp$1 = ((i < 0 || i >= a.$length) ? $throwRuntimeError("index out of range") : a.$array[a.$offset + i]); (i < 0 || i >= a.$length) ? $throwRuntimeError("index out of range") : a.$array[a.$offset + i] = _tmp; (j < 0 || j >= a.$length) ? $throwRuntimeError("index out of range") : a.$array[a.$offset + j] = _tmp$1; + deref = function(typ) { + var _tuple, p; + _tuple = $assertType(typ, ($ptrType(Pointer)), true); p = _tuple[0]; + if (!(p === ($ptrType(Pointer)).nil)) { + return [p.base, true]; + } + return [typ, false]; }; - $ptrType(byUniqueTypeName).prototype.Swap = function(i, j) { return this.$get().Swap(i, j); }; - byUniqueMethodName.prototype.Len = function() { - var a; - a = this; - return a.$length; + derefStructPtr = function(typ) { + var _tuple, p, _tuple$1, ok; + _tuple = $assertType(typ.Underlying(), ($ptrType(Pointer)), true); p = _tuple[0]; + if (!(p === ($ptrType(Pointer)).nil)) { + _tuple$1 = $assertType(p.base.Underlying(), ($ptrType(Struct)), true); ok = _tuple$1[1]; + if (ok) { + return p.base; + } + } + return typ; }; - $ptrType(byUniqueMethodName).prototype.Len = function() { return this.$get().Len(); }; - byUniqueMethodName.prototype.Less = function(i, j) { - var a; - a = this; - return ((i < 0 || i >= a.$length) ? $throwRuntimeError("index out of range") : a.$array[a.$offset + i]).object.Id() < ((j < 0 || j >= a.$length) ? $throwRuntimeError("index out of range") : a.$array[a.$offset + j]).object.Id(); + concat = function(list, i) { + var t; + t = ($sliceType($Int)).nil; + t = $appendSlice(t, list); + return $append(t, i); }; - $ptrType(byUniqueMethodName).prototype.Less = function(i, j) { return this.$get().Less(i, j); }; - byUniqueMethodName.prototype.Swap = function(i, j) { - var a, _tmp, _tmp$1; - a = this; - _tmp = ((j < 0 || j >= a.$length) ? $throwRuntimeError("index out of range") : a.$array[a.$offset + j]); _tmp$1 = ((i < 0 || i >= a.$length) ? $throwRuntimeError("index out of range") : a.$array[a.$offset + i]); (i < 0 || i >= a.$length) ? $throwRuntimeError("index out of range") : a.$array[a.$offset + i] = _tmp; (j < 0 || j >= a.$length) ? $throwRuntimeError("index out of range") : a.$array[a.$offset + j] = _tmp$1; + fieldIndex = function(fields, pkg, name) { + var _ref, _i, i, f; + if (!(name === "_")) { + _ref = fields; + _i = 0; + while (_i < _ref.$length) { + i = _i; + f = ((_i < 0 || _i >= _ref.$length) ? $throwRuntimeError("index out of range") : _ref.$array[_ref.$offset + _i]); + if (f.object.sameId(pkg, name)) { + return i; + } + _i++; + } + } + return -1; }; - $ptrType(byUniqueMethodName).prototype.Swap = function(i, j) { return this.$get().Swap(i, j); }; - Checker.Ptr.prototype.tag = function(t) { - var check, _tuple, val, err; - check = this; - if (!(t === ($ptrType(ast.BasicLit)).nil)) { - if (t.Kind === 9) { - _tuple = strconv.Unquote(t.Value); val = _tuple[0]; err = _tuple[1]; - if ($interfaceIsEqual(err, $ifaceNil)) { - return val; + lookupMethod = function(methods, pkg, name) { + var _ref, _i, i, m; + if (!(name === "_")) { + _ref = methods; + _i = 0; + while (_i < _ref.$length) { + i = _i; + m = ((_i < 0 || _i >= _ref.$length) ? $throwRuntimeError("index out of range") : _ref.$array[_ref.$offset + _i]); + if (m.object.sameId(pkg, name)) { + return [i, m]; } + _i++; } - check.invalidAST(t.Pos(), "incorrect tag syntax: %q", new ($sliceType($emptyInterface))([new $String(t.Value)])); } - return ""; + return [-1, ($ptrType(Func)).nil]; }; - Checker.prototype.tag = function(t) { return this.$val.tag(t); }; - Checker.Ptr.prototype.structType = function(styp, e, path$1) { - var check, list, fields, tags, fset, typ, tag, add, _ref, _i, f, _ref$1, _i$1, name, name$1, pos, _tuple, t, isPtr, t$1, _ref$2, u, _ref$3; - check = this; - list = e.Fields; - if (list === ($ptrType(ast.FieldList)).nil) { - return; + MethodSet.Ptr.prototype.String = function() { + var s, buf, _ref, _i, f; + s = this; + if (s.Len() === 0) { + return "MethodSet {}"; } - fields = ($sliceType(($ptrType(Var)))).nil; - tags = ($sliceType($String)).nil; - fset = false; - typ = $ifaceNil; - tag = ""; - add = (function(field, ident, anonymous, pos) { - var name, fld; - if (!(tag === "") && tags === ($sliceType($String)).nil) { - tags = ($sliceType($String)).make(fields.$length); - } - if (!(tags === ($sliceType($String)).nil)) { - tags = $append(tags, tag); - } - name = ident.Name; - fld = NewField(pos, check.pkg, name, typ, !(anonymous === ($ptrType(TypeName)).nil)); - if (name === "_" || check.declareInSet(new ($ptrType(objset))(function() { return fset; }, function($v) { fset = $v; }), pos, fld)) { - fields = $append(fields, fld); - check.recordDef(ident, fld); - } - if (!(anonymous === ($ptrType(TypeName)).nil)) { - check.recordUse(ident, anonymous); - } - }); - _ref = list.List; + buf = new bytes.Buffer.Ptr(); $copy(buf, new bytes.Buffer.Ptr(), bytes.Buffer); + fmt.Fprintln(buf, new ($sliceType($emptyInterface))([new $String("MethodSet {")])); + _ref = s.list; _i = 0; while (_i < _ref.$length) { f = ((_i < 0 || _i >= _ref.$length) ? $throwRuntimeError("index out of range") : _ref.$array[_ref.$offset + _i]); - typ = check.typExpr(f.Type, ($ptrType(Named)).nil, path$1); - tag = check.tag(f.Tag); - if (f.Names.$length > 0) { - _ref$1 = f.Names; - _i$1 = 0; - while (_i$1 < _ref$1.$length) { - name = ((_i$1 < 0 || _i$1 >= _ref$1.$length) ? $throwRuntimeError("index out of range") : _ref$1.$array[_ref$1.$offset + _i$1]); - add(f, name, ($ptrType(TypeName)).nil, name.Pos()); - _i$1++; - } - } else { - name$1 = anonymousFieldIdent(f.Type); - pos = f.Type.Pos(); - _tuple = deref(typ); t = _tuple[0]; isPtr = _tuple[1]; - _ref$2 = t; - if ($assertType(_ref$2, ($ptrType(Basic)), true)[1]) { - t$1 = _ref$2.$val; - if (t$1 === $pkg.Typ[0]) { + fmt.Fprintf(buf, "\t%s\n", new ($sliceType($emptyInterface))([f])); + _i++; + } + fmt.Fprintln(buf, new ($sliceType($emptyInterface))([new $String("}")])); + return buf.String(); + }; + MethodSet.prototype.String = function() { return this.$val.String(); }; + MethodSet.Ptr.prototype.Len = function() { + var s; + s = this; + return s.list.$length; + }; + MethodSet.prototype.Len = function() { return this.$val.Len(); }; + MethodSet.Ptr.prototype.At = function(i) { + var s, x; + s = this; + return (x = s.list, ((i < 0 || i >= x.$length) ? $throwRuntimeError("index out of range") : x.$array[x.$offset + i])); + }; + MethodSet.prototype.At = function(i) { return this.$val.At(i); }; + MethodSet.Ptr.prototype.Lookup = function(pkg, name) { + var s, key, i, x, m; + s = this; + if (s.Len() === 0) { + return ($ptrType(Selection)).nil; + } + key = Id(pkg, name); + i = sort.Search(s.list.$length, (function(i) { + var x, m; + m = (x = s.list, ((i < 0 || i >= x.$length) ? $throwRuntimeError("index out of range") : x.$array[x.$offset + i])); + return m.obj.Id() >= key; + })); + if (i < s.list.$length) { + m = (x = s.list, ((i < 0 || i >= x.$length) ? $throwRuntimeError("index out of range") : x.$array[x.$offset + i])); + if (m.obj.Id() === key) { + return m; + } + } + return ($ptrType(Selection)).nil; + }; + MethodSet.prototype.Lookup = function(pkg, name) { return this.$val.Lookup(pkg, name); }; + NewMethodSet = $pkg.NewMethodSet = function(T) { + var base, _tuple, typ, isPtr, _tuple$1, named, utyp, _tuple$2, ok, current, seen, next, fset, mset, _ref, _i, e, _entry, _key$2, t, _ref$1, _ref$2, _i$1, i, f, _tuple$3, typ$1, isPtr$1, _tuple$4, t$1, _ref$3, _i$2, _keys, _entry$1, k, m, _tuple$5, _entry$2, found, _tuple$6, _entry$3, found$1, _key$3, _ref$4, _i$3, _keys$1, _entry$4, k$1, f$1, _tuple$7, _entry$5, found$2, _key$4, list, _ref$5, _i$4, _keys$2, _entry$6, m$1; + base = false; + _tuple = deref(T); typ = _tuple[0]; isPtr = _tuple[1]; + _tuple$1 = $assertType(typ, ($ptrType(Named)), true); named = _tuple$1[0]; + if (isPtr) { + utyp = typ; + if (!(named === ($ptrType(Named)).nil)) { + utyp = named.underlying; + } + _tuple$2 = $assertType(utyp, ($ptrType(Interface)), true); ok = _tuple$2[1]; + if (ok) { + return emptyMethodSet; + } + } + current = new ($sliceType(embeddedType))([new embeddedType.Ptr(named, ($sliceType($Int)).nil, isPtr, false)]); + seen = false; + while (current.$length > 0) { + next = ($sliceType(embeddedType)).nil; + fset = false; + mset = false; + _ref = current; + _i = 0; + while (_i < _ref.$length) { + e = new embeddedType.Ptr(); $copy(e, ((_i < 0 || _i >= _ref.$length) ? $throwRuntimeError("index out of range") : _ref.$array[_ref.$offset + _i]), embeddedType); + if (!(e.typ === ($ptrType(Named)).nil)) { + if ((_entry = seen[e.typ.$key()], _entry !== undefined ? _entry.v : false)) { _i++; continue; } - if (t$1.kind === 18) { - check.errorf(pos, "anonymous field type cannot be unsafe.Pointer", new ($sliceType($emptyInterface))([])); - _i++; - continue; + if (seen === false) { + seen = new $Map(); } - add(f, name$1, $assertType($pkg.Universe.Lookup(t$1.name), ($ptrType(TypeName))), pos); - } else if ($assertType(_ref$2, ($ptrType(Named)), true)[1]) { - t$1 = _ref$2.$val; - _ref$3 = t$1.underlying; - if ($assertType(_ref$3, ($ptrType(Basic)), true)[1]) { - u = _ref$3.$val; - if (u.kind === 18) { - check.errorf(pos, "anonymous field type cannot be unsafe.Pointer", new ($sliceType($emptyInterface))([])); - _i++; - continue; + _key$2 = e.typ; (seen || $throwRuntimeError("assignment to entry in nil map"))[_key$2.$key()] = { k: _key$2, v: true }; + mset = (new methodSet(mset)).add(e.typ.methods, e.index, e.indirect, e.multiples); + typ = e.typ.underlying; + } + _ref$1 = typ; + if ($assertType(_ref$1, ($ptrType(Struct)), true)[1]) { + t = _ref$1.$val; + _ref$2 = t.fields; + _i$1 = 0; + while (_i$1 < _ref$2.$length) { + i = _i$1; + f = ((_i$1 < 0 || _i$1 >= _ref$2.$length) ? $throwRuntimeError("index out of range") : _ref$2.$array[_ref$2.$offset + _i$1]); + fset = (new fieldSet(fset)).add(f, e.multiples); + if (f.anonymous) { + _tuple$3 = deref(f.object.typ); typ$1 = _tuple$3[0]; isPtr$1 = _tuple$3[1]; + _tuple$4 = $assertType(typ$1, ($ptrType(Named)), true); t$1 = _tuple$4[0]; + if (!(t$1 === ($ptrType(Named)).nil)) { + next = $append(next, new embeddedType.Ptr(t$1, concat(e.index, i), e.indirect || isPtr$1, e.multiples)); + } } - } else if ($assertType(_ref$3, ($ptrType(Pointer)), true)[1]) { - u = _ref$3.$val; - check.errorf(pos, "anonymous field type cannot be a pointer", new ($sliceType($emptyInterface))([])); - _i++; - continue; - } else if ($assertType(_ref$3, ($ptrType(Interface)), true)[1]) { - u = _ref$3.$val; - if (isPtr) { - check.errorf(pos, "anonymous field type cannot be a pointer to an interface", new ($sliceType($emptyInterface))([])); - _i++; - continue; + _i$1++; + } + } else if ($assertType(_ref$1, ($ptrType(Interface)), true)[1]) { + t = _ref$1.$val; + mset = (new methodSet(mset)).add(t.allMethods, e.index, true, e.multiples); + } + _i++; + } + _ref$3 = mset; + _i$2 = 0; + _keys = $keys(_ref$3); + while (_i$2 < _keys.length) { + _entry$1 = _ref$3[_keys[_i$2]]; + if (_entry$1 === undefined) { + _i$2++; + continue; + } + k = _entry$1.k; + m = _entry$1.v; + _tuple$5 = (_entry$2 = base[k], _entry$2 !== undefined ? [_entry$2.v, true] : [($ptrType(Selection)).nil, false]); found = _tuple$5[1]; + if (!found) { + _tuple$6 = (_entry$3 = fset[k], _entry$3 !== undefined ? [_entry$3.v, true] : [($ptrType(Var)).nil, false]); found$1 = _tuple$6[1]; + if (found$1) { + m = ($ptrType(Selection)).nil; + } + if (base === false) { + base = new $Map(); + } + _key$3 = k; (base || $throwRuntimeError("assignment to entry in nil map"))[_key$3] = { k: _key$3, v: m }; + } + _i$2++; + } + _ref$4 = fset; + _i$3 = 0; + _keys$1 = $keys(_ref$4); + while (_i$3 < _keys$1.length) { + _entry$4 = _ref$4[_keys$1[_i$3]]; + if (_entry$4 === undefined) { + _i$3++; + continue; + } + k$1 = _entry$4.k; + f$1 = _entry$4.v; + if (f$1 === ($ptrType(Var)).nil) { + _tuple$7 = (_entry$5 = base[k$1], _entry$5 !== undefined ? [_entry$5.v, true] : [($ptrType(Selection)).nil, false]); found$2 = _tuple$7[1]; + if (!found$2) { + if (base === false) { + base = new $Map(); } + _key$4 = k$1; (base || $throwRuntimeError("assignment to entry in nil map"))[_key$4] = { k: _key$4, v: ($ptrType(Selection)).nil }; } - add(f, name$1, t$1.obj, pos); - } else { - t$1 = _ref$2; - check.invalidAST(pos, "anonymous field type %s must be named", new ($sliceType($emptyInterface))([typ])); } + _i$3++; } - _i++; + current = consolidateMultiples(next); } - styp.fields = fields; - styp.tags = tags; - }; - Checker.prototype.structType = function(styp, e, path$1) { return this.$val.structType(styp, e, path$1); }; - anonymousFieldIdent = function(e) { - var e$1, _ref; - _ref = e; - if ($assertType(_ref, ($ptrType(ast.Ident)), true)[1]) { - e$1 = _ref.$val; - return e$1; - } else if ($assertType(_ref, ($ptrType(ast.StarExpr)), true)[1]) { - e$1 = _ref.$val; - return anonymousFieldIdent(e$1.X); - } else if ($assertType(_ref, ($ptrType(ast.SelectorExpr)), true)[1]) { - e$1 = _ref.$val; - return e$1.Sel; + if ($keys(base).length === 0) { + return emptyMethodSet; } - return ($ptrType(ast.Ident)).nil; + list = ($sliceType(($ptrType(Selection)))).nil; + _ref$5 = base; + _i$4 = 0; + _keys$2 = $keys(_ref$5); + while (_i$4 < _keys$2.length) { + _entry$6 = _ref$5[_keys$2[_i$4]]; + if (_entry$6 === undefined) { + _i$4++; + continue; + } + m$1 = _entry$6.v; + if (!(m$1 === ($ptrType(Selection)).nil)) { + m$1.recv = T; + list = $append(list, m$1); + } + _i$4++; + } + sort.Sort($subslice(new byUniqueName(list.$array), list.$offset, list.$offset + list.$length)); + return new MethodSet.Ptr(list); }; - defPredeclaredTypes = function() { - var _ref, _i, t, _ref$1, _i$1, t$1, res, sig, err, typ; - _ref = $pkg.Typ; - _i = 0; - while (_i < 26) { - t = ((_i < 0 || _i >= _ref.length) ? $throwRuntimeError("index out of range") : _ref[_i]); - def(NewTypeName(0, ($ptrType(Package)).nil, t.name, t)); - _i++; + fieldSet.prototype.add = function(f, multiples) { + var s, key, _tuple, _entry, found, _key$2, _key$3; + s = this.$val !== undefined ? this.$val : this; + if (s === false) { + s = new $Map(); } - _ref$1 = aliases; - _i$1 = 0; - while (_i$1 < 2) { - t$1 = ((_i$1 < 0 || _i$1 >= _ref$1.length) ? $throwRuntimeError("index out of range") : _ref$1[_i$1]); - def(NewTypeName(0, ($ptrType(Package)).nil, t$1.name, t$1)); - _i$1++; + key = f.object.Id(); + if (!multiples) { + _tuple = (_entry = s[key], _entry !== undefined ? [_entry.v, true] : [($ptrType(Var)).nil, false]); found = _tuple[1]; + if (!found) { + _key$2 = key; (s || $throwRuntimeError("assignment to entry in nil map"))[_key$2] = { k: _key$2, v: f }; + return s; + } } - res = NewVar(0, ($ptrType(Package)).nil, "", $pkg.Typ[17]); - sig = new Signature.Ptr(($ptrType(Scope)).nil, ($ptrType(Var)).nil, ($ptrType(Tuple)).nil, NewTuple(new ($sliceType(($ptrType(Var))))([res])), false); - err = NewFunc(0, ($ptrType(Package)).nil, "Error", sig); - typ = new Named.Ptr(($ptrType(TypeName)).nil, NewInterface(new ($sliceType(($ptrType(Func))))([err]), ($sliceType(($ptrType(Named)))).nil).Complete(), ($sliceType(($ptrType(Func)))).nil); - sig.recv = NewVar(0, ($ptrType(Package)).nil, "", typ); - def(NewTypeName(0, ($ptrType(Package)).nil, "error", typ)); + _key$3 = key; (s || $throwRuntimeError("assignment to entry in nil map"))[_key$3] = { k: _key$3, v: ($ptrType(Var)).nil }; + return s; }; - defPredeclaredConsts = function() { - var _ref, _i, c, x; - _ref = predeclaredConsts; - _i = 0; - while (_i < 3) { - c = new ($structType([["name", "name", "code.google.com/p/go.tools/go/types", $String, ""], ["kind", "kind", "code.google.com/p/go.tools/go/types", BasicKind, ""], ["val", "val", "code.google.com/p/go.tools/go/types", exact.Value, ""]])).Ptr(); $copy(c, ((_i < 0 || _i >= _ref.length) ? $throwRuntimeError("index out of range") : _ref[_i]), ($structType([["name", "name", "code.google.com/p/go.tools/go/types", $String, ""], ["kind", "kind", "code.google.com/p/go.tools/go/types", BasicKind, ""], ["val", "val", "code.google.com/p/go.tools/go/types", exact.Value, ""]]))); - def(NewConst(0, ($ptrType(Package)).nil, c.name, (x = c.kind, ((x < 0 || x >= $pkg.Typ.length) ? $throwRuntimeError("index out of range") : $pkg.Typ[x])), c.val)); - _i++; + $ptrType(fieldSet).prototype.add = function(f, multiples) { return new fieldSet(this.$get()).add(f, multiples); }; + methodSet.prototype.add = function(list, index, indirect, multiples) { + var s, _ref, _i, i, f, key, _tuple, _entry, found, _key$2, _key$3; + s = this.$val !== undefined ? this.$val : this; + if (list.$length === 0) { + return s; } - }; - defPredeclaredNil = function() { - def(new Nil.Ptr(new object.Ptr(($ptrType(Scope)).nil, 0, ($ptrType(Package)).nil, "nil", $pkg.Typ[25], false))); - }; - defPredeclaredFuncs = function() { - var _ref, _i, i, id; - _ref = predeclaredFuncs; + if (s === false) { + s = new $Map(); + } + _ref = list; _i = 0; - while (_i < 20) { + while (_i < _ref.$length) { i = _i; - id = (i >> 0); - if ((id === 18) || (id === 19)) { - _i++; - continue; + f = ((_i < 0 || _i >= _ref.$length) ? $throwRuntimeError("index out of range") : _ref.$array[_ref.$offset + _i]); + key = f.object.Id(); + if (!multiples) { + _tuple = (_entry = s[key], _entry !== undefined ? [_entry.v, true] : [($ptrType(Selection)).nil, false]); found = _tuple[1]; + if (!found && (indirect || !ptrRecv(f))) { + _key$2 = key; (s || $throwRuntimeError("assignment to entry in nil map"))[_key$2] = { k: _key$2, v: new Selection.Ptr(1, $ifaceNil, f, concat(index, i), indirect) }; + _i++; + continue; + } } - def(newBuiltin(id)); + _key$3 = key; (s || $throwRuntimeError("assignment to entry in nil map"))[_key$3] = { k: _key$3, v: ($ptrType(Selection)).nil }; _i++; } + return s; }; - init = function() { - $pkg.Universe = NewScope(($ptrType(Scope)).nil, "universe"); - $pkg.Unsafe = NewPackage("unsafe", "unsafe"); - $pkg.Unsafe.complete = true; - defPredeclaredTypes(); - defPredeclaredConsts(); - defPredeclaredNil(); - defPredeclaredFuncs(); - universeIota = $assertType($pkg.Universe.Lookup("iota"), ($ptrType(Const))); - $pkg.UniverseByte = $assertType($assertType($pkg.Universe.Lookup("byte"), ($ptrType(TypeName))).object.typ, ($ptrType(Basic))); - $pkg.UniverseRune = $assertType($assertType($pkg.Universe.Lookup("rune"), ($ptrType(TypeName))).object.typ, ($ptrType(Basic))); - }; - def = function(obj) { - var name, _tuple, typ, ok, scope, obj$1, _ref; - name = obj.Name(); - if (strings.Index(name, " ") >= 0) { - return; - } - _tuple = $assertType(obj.Type(), ($ptrType(Named)), true); typ = _tuple[0]; ok = _tuple[1]; - if (ok) { - typ.obj = $assertType(obj, ($ptrType(TypeName))); - } - scope = $pkg.Universe; - if (obj.Exported()) { - scope = $pkg.Unsafe.scope; - _ref = obj; - if ($assertType(_ref, ($ptrType(TypeName)), true)[1]) { - obj$1 = _ref.$val; - obj$1.object.pkg = $pkg.Unsafe; - } else if ($assertType(_ref, ($ptrType(Builtin)), true)[1]) { - obj$1 = _ref.$val; - obj$1.object.pkg = $pkg.Unsafe; - } else { - obj$1 = _ref; - unreachable(); - } - } - if (!($interfaceIsEqual(scope.Insert(obj), $ifaceNil))) { - $panic(new $String("internal error: double declaration")); - } + $ptrType(methodSet).prototype.add = function(list, index, indirect, multiples) { return new methodSet(this.$get()).add(list, index, indirect, multiples); }; + ptrRecv = function(f) { + var _tuple, isPtr; + _tuple = deref($assertType(f.object.typ, ($ptrType(Signature))).recv.object.typ); isPtr = _tuple[1]; + return isPtr; }; - $pkg.$init = function() { - Error.methods = [["Error", "Error", "", $funcType([], [$String], false), -1]]; - ($ptrType(Error)).methods = [["Error", "Error", "", $funcType([], [$String], false), -1]]; - Error.init([["Fset", "Fset", "", ($ptrType(token.FileSet)), ""], ["Pos", "Pos", "", token.Pos, ""], ["Msg", "Msg", "", $String, ""], ["Soft", "Soft", "", $Bool, ""]]); - Importer.init([($mapType($String, ($ptrType(Package)))), $String], [($ptrType(Package)), $error], false); - ($ptrType(Config)).methods = [["Check", "Check", "", $funcType([$String, ($ptrType(token.FileSet)), ($sliceType(($ptrType(ast.File)))), ($ptrType(Info))], [($ptrType(Package)), $error], false), -1], ["alignof", "alignof", "code.google.com/p/go.tools/go/types", $funcType([Type], [$Int64], false), -1], ["offsetof", "offsetof", "code.google.com/p/go.tools/go/types", $funcType([Type, ($sliceType($Int))], [$Int64], false), -1], ["offsetsof", "offsetsof", "code.google.com/p/go.tools/go/types", $funcType([($ptrType(Struct))], [($sliceType($Int64))], false), -1], ["sizeof", "sizeof", "code.google.com/p/go.tools/go/types", $funcType([Type], [$Int64], false), -1]]; - Config.init([["IgnoreFuncBodies", "IgnoreFuncBodies", "", $Bool, ""], ["FakeImportC", "FakeImportC", "", $Bool, ""], ["Packages", "Packages", "", ($mapType($String, ($ptrType(Package)))), ""], ["Error", "Error", "", ($funcType([$error], [], false)), ""], ["Import", "Import", "", Importer, ""], ["Sizes", "Sizes", "", Sizes, ""]]); - ($ptrType(Info)).methods = [["ObjectOf", "ObjectOf", "", $funcType([($ptrType(ast.Ident))], [Object], false), -1], ["TypeOf", "TypeOf", "", $funcType([ast.Expr], [Type], false), -1]]; - Info.init([["Types", "Types", "", ($mapType(ast.Expr, TypeAndValue)), ""], ["Defs", "Defs", "", ($mapType(($ptrType(ast.Ident)), Object)), ""], ["Uses", "Uses", "", ($mapType(($ptrType(ast.Ident)), Object)), ""], ["Implicits", "Implicits", "", ($mapType(ast.Node, Object)), ""], ["Selections", "Selections", "", ($mapType(($ptrType(ast.SelectorExpr)), ($ptrType(Selection)))), ""], ["Scopes", "Scopes", "", ($mapType(ast.Node, ($ptrType(Scope)))), ""], ["InitOrder", "InitOrder", "", ($sliceType(($ptrType(Initializer)))), ""]]); - TypeAndValue.methods = [["Addressable", "Addressable", "", $funcType([], [$Bool], false), -1], ["Assignable", "Assignable", "", $funcType([], [$Bool], false), -1], ["HasOk", "HasOk", "", $funcType([], [$Bool], false), -1], ["IsBuiltin", "IsBuiltin", "", $funcType([], [$Bool], false), -1], ["IsNil", "IsNil", "", $funcType([], [$Bool], false), -1], ["IsType", "IsType", "", $funcType([], [$Bool], false), -1], ["IsValue", "IsValue", "", $funcType([], [$Bool], false), -1], ["IsVoid", "IsVoid", "", $funcType([], [$Bool], false), -1]]; - ($ptrType(TypeAndValue)).methods = [["Addressable", "Addressable", "", $funcType([], [$Bool], false), -1], ["Assignable", "Assignable", "", $funcType([], [$Bool], false), -1], ["HasOk", "HasOk", "", $funcType([], [$Bool], false), -1], ["IsBuiltin", "IsBuiltin", "", $funcType([], [$Bool], false), -1], ["IsNil", "IsNil", "", $funcType([], [$Bool], false), -1], ["IsType", "IsType", "", $funcType([], [$Bool], false), -1], ["IsValue", "IsValue", "", $funcType([], [$Bool], false), -1], ["IsVoid", "IsVoid", "", $funcType([], [$Bool], false), -1]]; - TypeAndValue.init([["mode", "mode", "code.google.com/p/go.tools/go/types", operandMode, ""], ["Type", "Type", "", Type, ""], ["Value", "Value", "", exact.Value, ""]]); - ($ptrType(Initializer)).methods = [["String", "String", "", $funcType([], [$String], false), -1]]; - Initializer.init([["Lhs", "Lhs", "", ($sliceType(($ptrType(Var)))), ""], ["Rhs", "Rhs", "", ast.Expr, ""]]); - getter.init([($ptrType(operand)), $Int], [], false); - exprInfo.init([["isLhs", "isLhs", "code.google.com/p/go.tools/go/types", $Bool, ""], ["mode", "mode", "code.google.com/p/go.tools/go/types", operandMode, ""], ["typ", "typ", "code.google.com/p/go.tools/go/types", ($ptrType(Basic)), ""], ["val", "val", "code.google.com/p/go.tools/go/types", exact.Value, ""]]); - funcInfo.init([["name", "name", "code.google.com/p/go.tools/go/types", $String, ""], ["decl", "decl", "code.google.com/p/go.tools/go/types", ($ptrType(declInfo)), ""], ["sig", "sig", "code.google.com/p/go.tools/go/types", ($ptrType(Signature)), ""], ["body", "body", "code.google.com/p/go.tools/go/types", ($ptrType(ast.BlockStmt)), ""]]); - context.init([["decl", "decl", "code.google.com/p/go.tools/go/types", ($ptrType(declInfo)), ""], ["scope", "scope", "code.google.com/p/go.tools/go/types", ($ptrType(Scope)), ""], ["iota", "iota", "code.google.com/p/go.tools/go/types", exact.Value, ""], ["sig", "sig", "code.google.com/p/go.tools/go/types", ($ptrType(Signature)), ""], ["hasLabel", "hasLabel", "code.google.com/p/go.tools/go/types", $Bool, ""], ["hasCallOrRecv", "hasCallOrRecv", "code.google.com/p/go.tools/go/types", $Bool, ""]]); - Checker.methods = [["ObjectOf", "ObjectOf", "", $funcType([($ptrType(ast.Ident))], [Object], false), 3], ["TypeOf", "TypeOf", "", $funcType([ast.Expr], [Type], false), 3]]; - ($ptrType(Checker)).methods = [["Files", "Files", "", $funcType([($sliceType(($ptrType(ast.File))))], [$error], false), -1], ["ObjectOf", "ObjectOf", "", $funcType([($ptrType(ast.Ident))], [Object], false), 3], ["TypeOf", "TypeOf", "", $funcType([ast.Expr], [Type], false), 3], ["addDeclDep", "addDeclDep", "code.google.com/p/go.tools/go/types", $funcType([Object], [], false), -1], ["addMethodDecls", "addMethodDecls", "code.google.com/p/go.tools/go/types", $funcType([($ptrType(TypeName))], [], false), -1], ["appendInPostOrder", "appendInPostOrder", "code.google.com/p/go.tools/go/types", $funcType([($ptrType(($sliceType(Object)))), Object], [], false), -1], ["argument", "argument", "code.google.com/p/go.tools/go/types", $funcType([($ptrType(Signature)), $Int, ($ptrType(operand)), $Bool], [], false), -1], ["arguments$", "arguments", "code.google.com/p/go.tools/go/types", $funcType([($ptrType(operand)), ($ptrType(ast.CallExpr)), ($ptrType(Signature)), getter, $Int], [], false), -1], ["arityMatch", "arityMatch", "code.google.com/p/go.tools/go/types", $funcType([($ptrType(ast.ValueSpec)), ($ptrType(ast.ValueSpec))], [], false), -1], ["arrayLength", "arrayLength", "code.google.com/p/go.tools/go/types", $funcType([ast.Expr], [$Int64], false), -1], ["assignVar", "assignVar", "code.google.com/p/go.tools/go/types", $funcType([ast.Expr, ($ptrType(operand))], [Type], false), -1], ["assignVars", "assignVars", "code.google.com/p/go.tools/go/types", $funcType([($sliceType(ast.Expr)), ($sliceType(ast.Expr))], [], false), -1], ["assignment", "assignment", "code.google.com/p/go.tools/go/types", $funcType([($ptrType(operand)), Type], [$Bool], false), -1], ["assocMethod", "assocMethod", "code.google.com/p/go.tools/go/types", $funcType([$String, ($ptrType(Func))], [], false), -1], ["binary", "binary", "code.google.com/p/go.tools/go/types", $funcType([($ptrType(operand)), ast.Expr, ast.Expr, token.Token], [], false), -1], ["blockBranches", "blockBranches", "code.google.com/p/go.tools/go/types", $funcType([($ptrType(Scope)), ($ptrType(block)), ($ptrType(ast.LabeledStmt)), ($sliceType(ast.Stmt))], [($sliceType(($ptrType(ast.BranchStmt))))], false), -1], ["builtin", "builtin", "code.google.com/p/go.tools/go/types", $funcType([($ptrType(operand)), ($ptrType(ast.CallExpr)), builtinId], [$Bool], false), -1], ["call", "call", "code.google.com/p/go.tools/go/types", $funcType([($ptrType(operand)), ($ptrType(ast.CallExpr))], [exprKind], false), -1], ["caseTypes", "caseTypes", "code.google.com/p/go.tools/go/types", $funcType([($ptrType(operand)), ($ptrType(Interface)), ($sliceType(ast.Expr)), ($mapType(Type, token.Pos))], [Type], false), -1], ["caseValues", "caseValues", "code.google.com/p/go.tools/go/types", $funcType([operand, ($sliceType(ast.Expr))], [], false), -1], ["closeScope", "closeScope", "code.google.com/p/go.tools/go/types", $funcType([], [], false), -1], ["collectObjects", "collectObjects", "code.google.com/p/go.tools/go/types", $funcType([], [], false), -1], ["collectParams", "collectParams", "code.google.com/p/go.tools/go/types", $funcType([($ptrType(Scope)), ($ptrType(ast.FieldList)), $Bool], [($sliceType(($ptrType(Var)))), $Bool], false), -1], ["comparison", "comparison", "code.google.com/p/go.tools/go/types", $funcType([($ptrType(operand)), ($ptrType(operand)), token.Token], [], false), -1], ["complexArg", "complexArg", "code.google.com/p/go.tools/go/types", $funcType([($ptrType(operand))], [$Bool], false), -1], ["constDecl", "constDecl", "code.google.com/p/go.tools/go/types", $funcType([($ptrType(Const)), ast.Expr, ast.Expr], [], false), -1], ["conversion", "conversion", "code.google.com/p/go.tools/go/types", $funcType([($ptrType(operand)), Type], [], false), -1], ["convertUntyped", "convertUntyped", "code.google.com/p/go.tools/go/types", $funcType([($ptrType(operand)), Type], [], false), -1], ["declStmt", "declStmt", "code.google.com/p/go.tools/go/types", $funcType([ast.Decl], [], false), -1], ["declare", "declare", "code.google.com/p/go.tools/go/types", $funcType([($ptrType(Scope)), ($ptrType(ast.Ident)), Object], [], false), -1], ["declareInSet", "declareInSet", "code.google.com/p/go.tools/go/types", $funcType([($ptrType(objset)), token.Pos, Object], [$Bool], false), -1], ["declarePkgObj", "declarePkgObj", "code.google.com/p/go.tools/go/types", $funcType([($ptrType(ast.Ident)), Object, ($ptrType(declInfo))], [], false), -1], ["delay", "delay", "code.google.com/p/go.tools/go/types", $funcType([($funcType([], [], false))], [], false), -1], ["dump", "dump", "code.google.com/p/go.tools/go/types", $funcType([$String, ($sliceType($emptyInterface))], [], true), -1], ["err", "err", "code.google.com/p/go.tools/go/types", $funcType([token.Pos, $String, $Bool], [], false), -1], ["error", "error", "code.google.com/p/go.tools/go/types", $funcType([token.Pos, $String], [], false), -1], ["errorf", "errorf", "code.google.com/p/go.tools/go/types", $funcType([token.Pos, $String, ($sliceType($emptyInterface))], [], true), -1], ["expr", "expr", "code.google.com/p/go.tools/go/types", $funcType([($ptrType(operand)), ast.Expr], [], false), -1], ["exprInternal", "exprInternal", "code.google.com/p/go.tools/go/types", $funcType([($ptrType(operand)), ast.Expr, Type], [exprKind], false), -1], ["exprOrType", "exprOrType", "code.google.com/p/go.tools/go/types", $funcType([($ptrType(operand)), ast.Expr], [], false), -1], ["exprWithHint", "exprWithHint", "code.google.com/p/go.tools/go/types", $funcType([($ptrType(operand)), ast.Expr, Type], [], false), -1], ["funcBody", "funcBody", "code.google.com/p/go.tools/go/types", $funcType([($ptrType(declInfo)), $String, ($ptrType(Signature)), ($ptrType(ast.BlockStmt))], [], false), -1], ["funcDecl", "funcDecl", "code.google.com/p/go.tools/go/types", $funcType([($ptrType(Func)), ($ptrType(declInfo))], [], false), -1], ["funcType", "funcType", "code.google.com/p/go.tools/go/types", $funcType([($ptrType(Signature)), ($ptrType(ast.FieldList)), ($ptrType(ast.FuncType))], [($ptrType(Signature))], false), -1], ["functionBodies", "functionBodies", "code.google.com/p/go.tools/go/types", $funcType([], [], false), -1], ["handleBailout", "handleBailout", "code.google.com/p/go.tools/go/types", $funcType([($ptrType($error))], [], false), -1], ["ident", "ident", "code.google.com/p/go.tools/go/types", $funcType([($ptrType(operand)), ($ptrType(ast.Ident)), ($ptrType(Named)), ($sliceType(($ptrType(TypeName))))], [], false), -1], ["index", "index", "code.google.com/p/go.tools/go/types", $funcType([ast.Expr, $Int64], [$Int64, $Bool], false), -1], ["indexedElts", "indexedElts", "code.google.com/p/go.tools/go/types", $funcType([($sliceType(ast.Expr)), Type, $Int64], [$Int64], false), -1], ["initConst", "initConst", "code.google.com/p/go.tools/go/types", $funcType([($ptrType(Const)), ($ptrType(operand))], [], false), -1], ["initFiles", "initFiles", "code.google.com/p/go.tools/go/types", $funcType([($sliceType(($ptrType(ast.File))))], [], false), -1], ["initOrder", "initOrder", "code.google.com/p/go.tools/go/types", $funcType([], [], false), -1], ["initStmt", "initStmt", "code.google.com/p/go.tools/go/types", $funcType([ast.Stmt], [], false), -1], ["initVar", "initVar", "code.google.com/p/go.tools/go/types", $funcType([($ptrType(Var)), ($ptrType(operand)), $Bool], [Type], false), -1], ["initVars", "initVars", "code.google.com/p/go.tools/go/types", $funcType([($sliceType(($ptrType(Var)))), ($sliceType(ast.Expr)), token.Pos], [], false), -1], ["interfaceFor", "interfaceFor", "code.google.com/p/go.tools/go/types", $funcType([Object], [($ptrType(ast.InterfaceType))], false), -1], ["interfaceType", "interfaceType", "code.google.com/p/go.tools/go/types", $funcType([($ptrType(Interface)), ($ptrType(ast.InterfaceType)), ($ptrType(Named)), ($sliceType(($ptrType(TypeName))))], [], false), -1], ["invalidAST", "invalidAST", "code.google.com/p/go.tools/go/types", $funcType([token.Pos, $String, ($sliceType($emptyInterface))], [], true), -1], ["invalidArg", "invalidArg", "code.google.com/p/go.tools/go/types", $funcType([token.Pos, $String, ($sliceType($emptyInterface))], [], true), -1], ["invalidOp", "invalidOp", "code.google.com/p/go.tools/go/types", $funcType([token.Pos, $String, ($sliceType($emptyInterface))], [], true), -1], ["isTerminating", "isTerminating", "code.google.com/p/go.tools/go/types", $funcType([ast.Stmt, $String], [$Bool], false), -1], ["isTerminatingList", "isTerminatingList", "code.google.com/p/go.tools/go/types", $funcType([($sliceType(ast.Stmt)), $String], [$Bool], false), -1], ["isTerminatingSwitch", "isTerminatingSwitch", "code.google.com/p/go.tools/go/types", $funcType([($ptrType(ast.BlockStmt)), $String], [$Bool], false), -1], ["labels", "labels", "code.google.com/p/go.tools/go/types", $funcType([($ptrType(ast.BlockStmt))], [], false), -1], ["later", "later", "code.google.com/p/go.tools/go/types", $funcType([$String, ($ptrType(declInfo)), ($ptrType(Signature)), ($ptrType(ast.BlockStmt))], [], false), -1], ["multipleDefaults", "multipleDefaults", "code.google.com/p/go.tools/go/types", $funcType([($sliceType(ast.Stmt))], [], false), -1], ["objDecl", "objDecl", "code.google.com/p/go.tools/go/types", $funcType([Object, ($ptrType(Named)), ($sliceType(($ptrType(TypeName))))], [], false), -1], ["op", "op", "code.google.com/p/go.tools/go/types", $funcType([opPredicates, ($ptrType(operand)), token.Token], [$Bool], false), -1], ["openScope", "openScope", "code.google.com/p/go.tools/go/types", $funcType([ast.Stmt, $String], [], false), -1], ["packageObjects", "packageObjects", "code.google.com/p/go.tools/go/types", $funcType([($sliceType(Object))], [], false), -1], ["rawExpr", "rawExpr", "code.google.com/p/go.tools/go/types", $funcType([($ptrType(operand)), ast.Expr, Type], [exprKind], false), -1], ["recordBuiltinType", "recordBuiltinType", "code.google.com/p/go.tools/go/types", $funcType([ast.Expr, ($ptrType(Signature))], [], false), -1], ["recordCommaOkTypes", "recordCommaOkTypes", "code.google.com/p/go.tools/go/types", $funcType([ast.Expr, ($arrayType(Type, 2))], [], false), -1], ["recordDef", "recordDef", "code.google.com/p/go.tools/go/types", $funcType([($ptrType(ast.Ident)), Object], [], false), -1], ["recordImplicit", "recordImplicit", "code.google.com/p/go.tools/go/types", $funcType([ast.Node, Object], [], false), -1], ["recordScope", "recordScope", "code.google.com/p/go.tools/go/types", $funcType([ast.Node, ($ptrType(Scope))], [], false), -1], ["recordSelection", "recordSelection", "code.google.com/p/go.tools/go/types", $funcType([($ptrType(ast.SelectorExpr)), SelectionKind, Type, Object, ($sliceType($Int)), $Bool], [], false), -1], ["recordTypeAndValue", "recordTypeAndValue", "code.google.com/p/go.tools/go/types", $funcType([ast.Expr, operandMode, Type, exact.Value], [], false), -1], ["recordUntyped", "recordUntyped", "code.google.com/p/go.tools/go/types", $funcType([], [], false), -1], ["recordUse", "recordUse", "code.google.com/p/go.tools/go/types", $funcType([($ptrType(ast.Ident)), Object], [], false), -1], ["rememberUntyped", "rememberUntyped", "code.google.com/p/go.tools/go/types", $funcType([ast.Expr, $Bool, operandMode, ($ptrType(Basic)), exact.Value], [], false), -1], ["reportAltDecl", "reportAltDecl", "code.google.com/p/go.tools/go/types", $funcType([Object], [], false), -1], ["reportCycle", "reportCycle", "code.google.com/p/go.tools/go/types", $funcType([($sliceType(($ptrType(objNode)))), $Int], [], false), -1], ["representable", "representable", "code.google.com/p/go.tools/go/types", $funcType([($ptrType(operand)), ($ptrType(Basic))], [], false), -1], ["resolveOrder", "resolveOrder", "code.google.com/p/go.tools/go/types", $funcType([], [($sliceType(Object))], false), -1], ["selector", "selector", "code.google.com/p/go.tools/go/types", $funcType([($ptrType(operand)), ($ptrType(ast.SelectorExpr))], [], false), -1], ["shift", "shift", "code.google.com/p/go.tools/go/types", $funcType([($ptrType(operand)), ($ptrType(operand)), token.Token], [], false), -1], ["shortVarDecl", "shortVarDecl", "code.google.com/p/go.tools/go/types", $funcType([token.Pos, ($sliceType(ast.Expr)), ($sliceType(ast.Expr))], [], false), -1], ["softErrorf", "softErrorf", "code.google.com/p/go.tools/go/types", $funcType([token.Pos, $String, ($sliceType($emptyInterface))], [], true), -1], ["sprintf", "sprintf", "code.google.com/p/go.tools/go/types", $funcType([$String, ($sliceType($emptyInterface))], [$String], true), -1], ["stmt", "stmt", "code.google.com/p/go.tools/go/types", $funcType([stmtContext, ast.Stmt], [], false), -1], ["stmtList", "stmtList", "code.google.com/p/go.tools/go/types", $funcType([stmtContext, ($sliceType(ast.Stmt))], [], false), -1], ["structType", "structType", "code.google.com/p/go.tools/go/types", $funcType([($ptrType(Struct)), ($ptrType(ast.StructType)), ($sliceType(($ptrType(TypeName))))], [], false), -1], ["suspendedCall", "suspendedCall", "code.google.com/p/go.tools/go/types", $funcType([$String, ($ptrType(ast.CallExpr))], [], false), -1], ["tag", "tag", "code.google.com/p/go.tools/go/types", $funcType([($ptrType(ast.BasicLit))], [$String], false), -1], ["trace", "trace", "code.google.com/p/go.tools/go/types", $funcType([token.Pos, $String, ($sliceType($emptyInterface))], [], true), -1], ["typ", "typ", "code.google.com/p/go.tools/go/types", $funcType([ast.Expr], [Type], false), -1], ["typExpr", "typExpr", "code.google.com/p/go.tools/go/types", $funcType([ast.Expr, ($ptrType(Named)), ($sliceType(($ptrType(TypeName))))], [Type], false), -1], ["typExprInternal", "typExprInternal", "code.google.com/p/go.tools/go/types", $funcType([ast.Expr, ($ptrType(Named)), ($sliceType(($ptrType(TypeName))))], [Type], false), -1], ["typOrNil", "typOrNil", "code.google.com/p/go.tools/go/types", $funcType([ast.Expr], [Type], false), -1], ["typeAssertion", "typeAssertion", "code.google.com/p/go.tools/go/types", $funcType([token.Pos, ($ptrType(operand)), ($ptrType(Interface)), Type], [], false), -1], ["typeDecl", "typeDecl", "code.google.com/p/go.tools/go/types", $funcType([($ptrType(TypeName)), ast.Expr, ($ptrType(Named)), ($sliceType(($ptrType(TypeName))))], [], false), -1], ["unary", "unary", "code.google.com/p/go.tools/go/types", $funcType([($ptrType(operand)), token.Token], [], false), -1], ["unusedImports", "unusedImports", "code.google.com/p/go.tools/go/types", $funcType([], [], false), -1], ["updateExprType", "updateExprType", "code.google.com/p/go.tools/go/types", $funcType([ast.Expr, Type, $Bool], [], false), -1], ["updateExprVal", "updateExprVal", "code.google.com/p/go.tools/go/types", $funcType([ast.Expr, exact.Value], [], false), -1], ["usage", "usage", "code.google.com/p/go.tools/go/types", $funcType([($ptrType(Scope))], [], false), -1], ["use", "use", "code.google.com/p/go.tools/go/types", $funcType([($sliceType(ast.Expr))], [], true), -1], ["varDecl", "varDecl", "code.google.com/p/go.tools/go/types", $funcType([($ptrType(Var)), ($sliceType(($ptrType(Var)))), ast.Expr, ast.Expr], [], false), -1]]; - Checker.init([["conf", "conf", "code.google.com/p/go.tools/go/types", ($ptrType(Config)), ""], ["fset", "fset", "code.google.com/p/go.tools/go/types", ($ptrType(token.FileSet)), ""], ["pkg", "pkg", "code.google.com/p/go.tools/go/types", ($ptrType(Package)), ""], ["Info", "", "", ($ptrType(Info)), ""], ["objMap", "objMap", "code.google.com/p/go.tools/go/types", ($mapType(Object, ($ptrType(declInfo)))), ""], ["files", "files", "code.google.com/p/go.tools/go/types", ($sliceType(($ptrType(ast.File)))), ""], ["fileScopes", "fileScopes", "code.google.com/p/go.tools/go/types", ($sliceType(($ptrType(Scope)))), ""], ["dotImports", "dotImports", "code.google.com/p/go.tools/go/types", ($sliceType(($mapType(($ptrType(Package)), token.Pos)))), ""], ["firstErr", "firstErr", "code.google.com/p/go.tools/go/types", $error, ""], ["methods", "methods", "code.google.com/p/go.tools/go/types", ($mapType($String, ($sliceType(($ptrType(Func)))))), ""], ["untyped", "untyped", "code.google.com/p/go.tools/go/types", ($mapType(ast.Expr, exprInfo)), ""], ["funcs", "funcs", "code.google.com/p/go.tools/go/types", ($sliceType(funcInfo)), ""], ["delayed", "delayed", "code.google.com/p/go.tools/go/types", ($sliceType(($funcType([], [], false)))), ""], ["context", "", "code.google.com/p/go.tools/go/types", context, ""], ["indent", "indent", "code.google.com/p/go.tools/go/types", $Int, ""]]); - bailout.init([]); - opPredicates.init(token.Token, ($funcType([Type], [$Bool], false))); - objNode.init([["obj", "obj", "code.google.com/p/go.tools/go/types", Object, ""], ["in$1", "in", "code.google.com/p/go.tools/go/types", $Int, ""], ["out", "out", "code.google.com/p/go.tools/go/types", ($sliceType(($ptrType(objNode)))), ""], ["index", "index", "code.google.com/p/go.tools/go/types", $Int, ""], ["mark", "mark", "code.google.com/p/go.tools/go/types", $Int, ""]]); - nodeQueue.methods = [["Len", "Len", "", $funcType([], [$Int], false), -1], ["Less", "Less", "", $funcType([$Int, $Int], [$Bool], false), -1], ["Swap", "Swap", "", $funcType([$Int, $Int], [], false), -1]]; - ($ptrType(nodeQueue)).methods = [["Len", "Len", "", $funcType([], [$Int], false), -1], ["Less", "Less", "", $funcType([$Int, $Int], [$Bool], false), -1], ["Pop", "Pop", "", $funcType([], [$emptyInterface], false), -1], ["Push", "Push", "", $funcType([$emptyInterface], [], false), -1], ["Swap", "Swap", "", $funcType([$Int, $Int], [], false), -1]]; - nodeQueue.init(($ptrType(objNode))); - ($ptrType(block)).methods = [["enclosingTarget", "enclosingTarget", "code.google.com/p/go.tools/go/types", $funcType([$String], [($ptrType(ast.LabeledStmt))], false), -1], ["gotoTarget", "gotoTarget", "code.google.com/p/go.tools/go/types", $funcType([$String], [($ptrType(ast.LabeledStmt))], false), -1], ["insert", "insert", "code.google.com/p/go.tools/go/types", $funcType([($ptrType(ast.LabeledStmt))], [], false), -1]]; - block.init([["parent", "parent", "code.google.com/p/go.tools/go/types", ($ptrType(block)), ""], ["lstmt", "lstmt", "code.google.com/p/go.tools/go/types", ($ptrType(ast.LabeledStmt)), ""], ["labels", "labels", "code.google.com/p/go.tools/go/types", ($mapType($String, ($ptrType(ast.LabeledStmt)))), ""]]); - embeddedType.init([["typ", "typ", "code.google.com/p/go.tools/go/types", ($ptrType(Named)), ""], ["index", "index", "code.google.com/p/go.tools/go/types", ($sliceType($Int)), ""], ["indirect", "indirect", "code.google.com/p/go.tools/go/types", $Bool, ""], ["multiples", "multiples", "code.google.com/p/go.tools/go/types", $Bool, ""]]); - ($ptrType(MethodSet)).methods = [["At", "At", "", $funcType([$Int], [($ptrType(Selection))], false), -1], ["Len", "Len", "", $funcType([], [$Int], false), -1], ["Lookup", "Lookup", "", $funcType([($ptrType(Package)), $String], [($ptrType(Selection))], false), -1], ["String", "String", "", $funcType([], [$String], false), -1]]; - MethodSet.init([["list", "list", "code.google.com/p/go.tools/go/types", ($sliceType(($ptrType(Selection)))), ""]]); - fieldSet.methods = [["add", "add", "code.google.com/p/go.tools/go/types", $funcType([($ptrType(Var)), $Bool], [fieldSet], false), -1]]; - ($ptrType(fieldSet)).methods = [["add", "add", "code.google.com/p/go.tools/go/types", $funcType([($ptrType(Var)), $Bool], [fieldSet], false), -1]]; - fieldSet.init($String, ($ptrType(Var))); - methodSet.methods = [["add", "add", "code.google.com/p/go.tools/go/types", $funcType([($sliceType(($ptrType(Func)))), ($sliceType($Int)), $Bool, $Bool], [methodSet], false), -1]]; - ($ptrType(methodSet)).methods = [["add", "add", "code.google.com/p/go.tools/go/types", $funcType([($sliceType(($ptrType(Func)))), ($sliceType($Int)), $Bool, $Bool], [methodSet], false), -1]]; - methodSet.init($String, ($ptrType(Selection))); - byUniqueName.methods = [["Len", "Len", "", $funcType([], [$Int], false), -1], ["Less", "Less", "", $funcType([$Int, $Int], [$Bool], false), -1], ["Swap", "Swap", "", $funcType([$Int, $Int], [], false), -1]]; - ($ptrType(byUniqueName)).methods = [["Len", "Len", "", $funcType([], [$Int], false), -1], ["Less", "Less", "", $funcType([$Int, $Int], [$Bool], false), -1], ["Swap", "Swap", "", $funcType([$Int, $Int], [], false), -1]]; - byUniqueName.init(($ptrType(Selection))); - Object.init([["Exported", "Exported", "", $funcType([], [$Bool], false)], ["Id", "Id", "", $funcType([], [$String], false)], ["Name", "Name", "", $funcType([], [$String], false)], ["Parent", "Parent", "", $funcType([], [($ptrType(Scope))], false)], ["Pkg", "Pkg", "", $funcType([], [($ptrType(Package))], false)], ["Pos", "Pos", "", $funcType([], [token.Pos], false)], ["String", "String", "", $funcType([], [$String], false)], ["Type", "Type", "", $funcType([], [Type], false)], ["isUsed", "isUsed", "code.google.com/p/go.tools/go/types", $funcType([], [$Bool], false)], ["sameId", "sameId", "code.google.com/p/go.tools/go/types", $funcType([($ptrType(Package)), $String], [$Bool], false)], ["setParent", "setParent", "code.google.com/p/go.tools/go/types", $funcType([($ptrType(Scope))], [], false)]]); - ($ptrType(object)).methods = [["Exported", "Exported", "", $funcType([], [$Bool], false), -1], ["Id", "Id", "", $funcType([], [$String], false), -1], ["Name", "Name", "", $funcType([], [$String], false), -1], ["Parent", "Parent", "", $funcType([], [($ptrType(Scope))], false), -1], ["Pkg", "Pkg", "", $funcType([], [($ptrType(Package))], false), -1], ["Pos", "Pos", "", $funcType([], [token.Pos], false), -1], ["String", "String", "", $funcType([], [$String], false), -1], ["Type", "Type", "", $funcType([], [Type], false), -1], ["isUsed", "isUsed", "code.google.com/p/go.tools/go/types", $funcType([], [$Bool], false), -1], ["sameId", "sameId", "code.google.com/p/go.tools/go/types", $funcType([($ptrType(Package)), $String], [$Bool], false), -1], ["setParent", "setParent", "code.google.com/p/go.tools/go/types", $funcType([($ptrType(Scope))], [], false), -1]]; - object.init([["parent", "parent", "code.google.com/p/go.tools/go/types", ($ptrType(Scope)), ""], ["pos", "pos", "code.google.com/p/go.tools/go/types", token.Pos, ""], ["pkg", "pkg", "code.google.com/p/go.tools/go/types", ($ptrType(Package)), ""], ["name", "name", "code.google.com/p/go.tools/go/types", $String, ""], ["typ", "typ", "code.google.com/p/go.tools/go/types", Type, ""], ["used", "used", "code.google.com/p/go.tools/go/types", $Bool, ""]]); - ($ptrType(PkgName)).methods = [["Exported", "Exported", "", $funcType([], [$Bool], false), 0], ["Id", "Id", "", $funcType([], [$String], false), 0], ["Imported", "Imported", "", $funcType([], [($ptrType(Package))], false), -1], ["Name", "Name", "", $funcType([], [$String], false), 0], ["Parent", "Parent", "", $funcType([], [($ptrType(Scope))], false), 0], ["Pkg", "Pkg", "", $funcType([], [($ptrType(Package))], false), 0], ["Pos", "Pos", "", $funcType([], [token.Pos], false), 0], ["String", "String", "", $funcType([], [$String], false), -1], ["Type", "Type", "", $funcType([], [Type], false), 0], ["isUsed", "isUsed", "code.google.com/p/go.tools/go/types", $funcType([], [$Bool], false), 0], ["sameId", "sameId", "code.google.com/p/go.tools/go/types", $funcType([($ptrType(Package)), $String], [$Bool], false), 0], ["setParent", "setParent", "code.google.com/p/go.tools/go/types", $funcType([($ptrType(Scope))], [], false), 0]]; - PkgName.init([["object", "", "code.google.com/p/go.tools/go/types", object, ""], ["imported", "imported", "code.google.com/p/go.tools/go/types", ($ptrType(Package)), ""]]); - ($ptrType(Const)).methods = [["Exported", "Exported", "", $funcType([], [$Bool], false), 0], ["Id", "Id", "", $funcType([], [$String], false), 0], ["Name", "Name", "", $funcType([], [$String], false), 0], ["Parent", "Parent", "", $funcType([], [($ptrType(Scope))], false), 0], ["Pkg", "Pkg", "", $funcType([], [($ptrType(Package))], false), 0], ["Pos", "Pos", "", $funcType([], [token.Pos], false), 0], ["String", "String", "", $funcType([], [$String], false), -1], ["Type", "Type", "", $funcType([], [Type], false), 0], ["Val", "Val", "", $funcType([], [exact.Value], false), -1], ["isUsed", "isUsed", "code.google.com/p/go.tools/go/types", $funcType([], [$Bool], false), 0], ["sameId", "sameId", "code.google.com/p/go.tools/go/types", $funcType([($ptrType(Package)), $String], [$Bool], false), 0], ["setParent", "setParent", "code.google.com/p/go.tools/go/types", $funcType([($ptrType(Scope))], [], false), 0]]; - Const.init([["object", "", "code.google.com/p/go.tools/go/types", object, ""], ["val", "val", "code.google.com/p/go.tools/go/types", exact.Value, ""], ["visited", "visited", "code.google.com/p/go.tools/go/types", $Bool, ""]]); - ($ptrType(TypeName)).methods = [["Exported", "Exported", "", $funcType([], [$Bool], false), 0], ["Id", "Id", "", $funcType([], [$String], false), 0], ["Name", "Name", "", $funcType([], [$String], false), 0], ["Parent", "Parent", "", $funcType([], [($ptrType(Scope))], false), 0], ["Pkg", "Pkg", "", $funcType([], [($ptrType(Package))], false), 0], ["Pos", "Pos", "", $funcType([], [token.Pos], false), 0], ["String", "String", "", $funcType([], [$String], false), -1], ["Type", "Type", "", $funcType([], [Type], false), 0], ["isUsed", "isUsed", "code.google.com/p/go.tools/go/types", $funcType([], [$Bool], false), 0], ["sameId", "sameId", "code.google.com/p/go.tools/go/types", $funcType([($ptrType(Package)), $String], [$Bool], false), 0], ["setParent", "setParent", "code.google.com/p/go.tools/go/types", $funcType([($ptrType(Scope))], [], false), 0]]; - TypeName.init([["object", "", "code.google.com/p/go.tools/go/types", object, ""]]); - ($ptrType(Var)).methods = [["Anonymous", "Anonymous", "", $funcType([], [$Bool], false), -1], ["Exported", "Exported", "", $funcType([], [$Bool], false), 0], ["Id", "Id", "", $funcType([], [$String], false), 0], ["IsField", "IsField", "", $funcType([], [$Bool], false), -1], ["Name", "Name", "", $funcType([], [$String], false), 0], ["Parent", "Parent", "", $funcType([], [($ptrType(Scope))], false), 0], ["Pkg", "Pkg", "", $funcType([], [($ptrType(Package))], false), 0], ["Pos", "Pos", "", $funcType([], [token.Pos], false), 0], ["String", "String", "", $funcType([], [$String], false), -1], ["Type", "Type", "", $funcType([], [Type], false), 0], ["isUsed", "isUsed", "code.google.com/p/go.tools/go/types", $funcType([], [$Bool], false), 0], ["sameId", "sameId", "code.google.com/p/go.tools/go/types", $funcType([($ptrType(Package)), $String], [$Bool], false), 0], ["setParent", "setParent", "code.google.com/p/go.tools/go/types", $funcType([($ptrType(Scope))], [], false), 0]]; - Var.init([["object", "", "code.google.com/p/go.tools/go/types", object, ""], ["anonymous", "anonymous", "code.google.com/p/go.tools/go/types", $Bool, ""], ["visited", "visited", "code.google.com/p/go.tools/go/types", $Bool, ""], ["isField", "isField", "code.google.com/p/go.tools/go/types", $Bool, ""]]); - ($ptrType(Func)).methods = [["Exported", "Exported", "", $funcType([], [$Bool], false), 0], ["FullName", "FullName", "", $funcType([], [$String], false), -1], ["Id", "Id", "", $funcType([], [$String], false), 0], ["Name", "Name", "", $funcType([], [$String], false), 0], ["Parent", "Parent", "", $funcType([], [($ptrType(Scope))], false), 0], ["Pkg", "Pkg", "", $funcType([], [($ptrType(Package))], false), 0], ["Pos", "Pos", "", $funcType([], [token.Pos], false), 0], ["Scope", "Scope", "", $funcType([], [($ptrType(Scope))], false), -1], ["String", "String", "", $funcType([], [$String], false), -1], ["Type", "Type", "", $funcType([], [Type], false), 0], ["isUsed", "isUsed", "code.google.com/p/go.tools/go/types", $funcType([], [$Bool], false), 0], ["sameId", "sameId", "code.google.com/p/go.tools/go/types", $funcType([($ptrType(Package)), $String], [$Bool], false), 0], ["setParent", "setParent", "code.google.com/p/go.tools/go/types", $funcType([($ptrType(Scope))], [], false), 0]]; - Func.init([["object", "", "code.google.com/p/go.tools/go/types", object, ""]]); - ($ptrType(Label)).methods = [["Exported", "Exported", "", $funcType([], [$Bool], false), 0], ["Id", "Id", "", $funcType([], [$String], false), 0], ["Name", "Name", "", $funcType([], [$String], false), 0], ["Parent", "Parent", "", $funcType([], [($ptrType(Scope))], false), 0], ["Pkg", "Pkg", "", $funcType([], [($ptrType(Package))], false), 0], ["Pos", "Pos", "", $funcType([], [token.Pos], false), 0], ["String", "String", "", $funcType([], [$String], false), -1], ["Type", "Type", "", $funcType([], [Type], false), 0], ["isUsed", "isUsed", "code.google.com/p/go.tools/go/types", $funcType([], [$Bool], false), 0], ["sameId", "sameId", "code.google.com/p/go.tools/go/types", $funcType([($ptrType(Package)), $String], [$Bool], false), 0], ["setParent", "setParent", "code.google.com/p/go.tools/go/types", $funcType([($ptrType(Scope))], [], false), 0]]; - Label.init([["object", "", "code.google.com/p/go.tools/go/types", object, ""]]); - ($ptrType(Builtin)).methods = [["Exported", "Exported", "", $funcType([], [$Bool], false), 0], ["Id", "Id", "", $funcType([], [$String], false), 0], ["Name", "Name", "", $funcType([], [$String], false), 0], ["Parent", "Parent", "", $funcType([], [($ptrType(Scope))], false), 0], ["Pkg", "Pkg", "", $funcType([], [($ptrType(Package))], false), 0], ["Pos", "Pos", "", $funcType([], [token.Pos], false), 0], ["String", "String", "", $funcType([], [$String], false), -1], ["Type", "Type", "", $funcType([], [Type], false), 0], ["isUsed", "isUsed", "code.google.com/p/go.tools/go/types", $funcType([], [$Bool], false), 0], ["sameId", "sameId", "code.google.com/p/go.tools/go/types", $funcType([($ptrType(Package)), $String], [$Bool], false), 0], ["setParent", "setParent", "code.google.com/p/go.tools/go/types", $funcType([($ptrType(Scope))], [], false), 0]]; - Builtin.init([["object", "", "code.google.com/p/go.tools/go/types", object, ""], ["id", "id", "code.google.com/p/go.tools/go/types", builtinId, ""]]); - ($ptrType(Nil)).methods = [["Exported", "Exported", "", $funcType([], [$Bool], false), 0], ["Id", "Id", "", $funcType([], [$String], false), 0], ["Name", "Name", "", $funcType([], [$String], false), 0], ["Parent", "Parent", "", $funcType([], [($ptrType(Scope))], false), 0], ["Pkg", "Pkg", "", $funcType([], [($ptrType(Package))], false), 0], ["Pos", "Pos", "", $funcType([], [token.Pos], false), 0], ["String", "String", "", $funcType([], [$String], false), -1], ["Type", "Type", "", $funcType([], [Type], false), 0], ["isUsed", "isUsed", "code.google.com/p/go.tools/go/types", $funcType([], [$Bool], false), 0], ["sameId", "sameId", "code.google.com/p/go.tools/go/types", $funcType([($ptrType(Package)), $String], [$Bool], false), 0], ["setParent", "setParent", "code.google.com/p/go.tools/go/types", $funcType([($ptrType(Scope))], [], false), 0]]; - Nil.init([["object", "", "code.google.com/p/go.tools/go/types", object, ""]]); - ($ptrType(objset)).methods = [["insert", "insert", "code.google.com/p/go.tools/go/types", $funcType([Object], [Object], false), -1]]; - objset.init($String, Object); - ($ptrType(operand)).methods = [["String", "String", "", $funcType([], [$String], false), -1], ["assignableTo", "assignableTo", "code.google.com/p/go.tools/go/types", $funcType([($ptrType(Config)), Type], [$Bool], false), -1], ["convertibleTo", "convertibleTo", "code.google.com/p/go.tools/go/types", $funcType([($ptrType(Config)), Type], [$Bool], false), -1], ["isInteger", "isInteger", "code.google.com/p/go.tools/go/types", $funcType([], [$Bool], false), -1], ["isNil", "isNil", "code.google.com/p/go.tools/go/types", $funcType([], [$Bool], false), -1], ["pos", "pos", "code.google.com/p/go.tools/go/types", $funcType([], [token.Pos], false), -1], ["setConst", "setConst", "code.google.com/p/go.tools/go/types", $funcType([token.Token, $String], [], false), -1]]; - operand.init([["mode", "mode", "code.google.com/p/go.tools/go/types", operandMode, ""], ["expr", "expr", "code.google.com/p/go.tools/go/types", ast.Expr, ""], ["typ", "typ", "code.google.com/p/go.tools/go/types", Type, ""], ["val", "val", "code.google.com/p/go.tools/go/types", exact.Value, ""], ["id", "id", "code.google.com/p/go.tools/go/types", builtinId, ""]]); - inSourceOrder.methods = [["Len", "Len", "", $funcType([], [$Int], false), -1], ["Less", "Less", "", $funcType([$Int, $Int], [$Bool], false), -1], ["Swap", "Swap", "", $funcType([$Int, $Int], [], false), -1]]; - ($ptrType(inSourceOrder)).methods = [["Len", "Len", "", $funcType([], [$Int], false), -1], ["Less", "Less", "", $funcType([$Int, $Int], [$Bool], false), -1], ["Swap", "Swap", "", $funcType([$Int, $Int], [], false), -1]]; - inSourceOrder.init(Object); - ($ptrType(Package)).methods = [["Complete", "Complete", "", $funcType([], [$Bool], false), -1], ["Imports", "Imports", "", $funcType([], [($sliceType(($ptrType(Package))))], false), -1], ["MarkComplete", "MarkComplete", "", $funcType([], [], false), -1], ["Name", "Name", "", $funcType([], [$String], false), -1], ["Path", "Path", "", $funcType([], [$String], false), -1], ["Scope", "Scope", "", $funcType([], [($ptrType(Scope))], false), -1], ["SetImports", "SetImports", "", $funcType([($sliceType(($ptrType(Package))))], [], false), -1], ["String", "String", "", $funcType([], [$String], false), -1]]; - Package.init([["path", "path", "code.google.com/p/go.tools/go/types", $String, ""], ["name", "name", "code.google.com/p/go.tools/go/types", $String, ""], ["scope", "scope", "code.google.com/p/go.tools/go/types", ($ptrType(Scope)), ""], ["complete", "complete", "code.google.com/p/go.tools/go/types", $Bool, ""], ["imports", "imports", "code.google.com/p/go.tools/go/types", ($sliceType(($ptrType(Package)))), ""], ["fake", "fake", "code.google.com/p/go.tools/go/types", $Bool, ""]]); - ($ptrType(ifacePair)).methods = [["identical", "identical", "code.google.com/p/go.tools/go/types", $funcType([($ptrType(ifacePair))], [$Bool], false), -1]]; - ifacePair.init([["x", "x", "code.google.com/p/go.tools/go/types", ($ptrType(Interface)), ""], ["y", "y", "code.google.com/p/go.tools/go/types", ($ptrType(Interface)), ""], ["prev", "prev", "code.google.com/p/go.tools/go/types", ($ptrType(ifacePair)), ""]]); - ($ptrType(declInfo)).methods = [["addDep", "addDep", "code.google.com/p/go.tools/go/types", $funcType([Object], [], false), -1], ["hasInitializer", "hasInitializer", "code.google.com/p/go.tools/go/types", $funcType([], [$Bool], false), -1]]; - declInfo.init([["file", "file", "code.google.com/p/go.tools/go/types", ($ptrType(Scope)), ""], ["lhs", "lhs", "code.google.com/p/go.tools/go/types", ($sliceType(($ptrType(Var)))), ""], ["typ", "typ", "code.google.com/p/go.tools/go/types", ast.Expr, ""], ["init", "init", "code.google.com/p/go.tools/go/types", ast.Expr, ""], ["fdecl", "fdecl", "code.google.com/p/go.tools/go/types", ($ptrType(ast.FuncDecl)), ""], ["deps", "deps", "code.google.com/p/go.tools/go/types", ($mapType(Object, $Bool)), ""], ["mark", "mark", "code.google.com/p/go.tools/go/types", $Int, ""]]); - ($ptrType(Scope)).methods = [["Child", "Child", "", $funcType([$Int], [($ptrType(Scope))], false), -1], ["Insert", "Insert", "", $funcType([Object], [Object], false), -1], ["Len", "Len", "", $funcType([], [$Int], false), -1], ["Lookup", "Lookup", "", $funcType([$String], [Object], false), -1], ["LookupParent", "LookupParent", "", $funcType([$String], [Object], false), -1], ["Names", "Names", "", $funcType([], [($sliceType($String))], false), -1], ["NumChildren", "NumChildren", "", $funcType([], [$Int], false), -1], ["Parent", "Parent", "", $funcType([], [($ptrType(Scope))], false), -1], ["String", "String", "", $funcType([], [$String], false), -1], ["WriteTo", "WriteTo", "", $funcType([io.Writer, $Int, $Bool], [], false), -1]]; - Scope.init([["parent", "parent", "code.google.com/p/go.tools/go/types", ($ptrType(Scope)), ""], ["children", "children", "code.google.com/p/go.tools/go/types", ($sliceType(($ptrType(Scope)))), ""], ["comment", "comment", "code.google.com/p/go.tools/go/types", $String, ""], ["elems", "elems", "code.google.com/p/go.tools/go/types", ($mapType($String, Object)), ""]]); - ($ptrType(Selection)).methods = [["Index", "Index", "", $funcType([], [($sliceType($Int))], false), -1], ["Indirect", "Indirect", "", $funcType([], [$Bool], false), -1], ["Kind", "Kind", "", $funcType([], [SelectionKind], false), -1], ["Obj", "Obj", "", $funcType([], [Object], false), -1], ["Recv", "Recv", "", $funcType([], [Type], false), -1], ["String", "String", "", $funcType([], [$String], false), -1], ["Type", "Type", "", $funcType([], [Type], false), -1]]; - Selection.init([["kind", "kind", "code.google.com/p/go.tools/go/types", SelectionKind, ""], ["recv", "recv", "code.google.com/p/go.tools/go/types", Type, ""], ["obj", "obj", "code.google.com/p/go.tools/go/types", Object, ""], ["index", "index", "code.google.com/p/go.tools/go/types", ($sliceType($Int)), ""], ["indirect", "indirect", "code.google.com/p/go.tools/go/types", $Bool, ""]]); - Sizes.init([["Alignof", "Alignof", "", $funcType([Type], [$Int64], false)], ["Offsetsof", "Offsetsof", "", $funcType([($sliceType(($ptrType(Var))))], [($sliceType($Int64))], false)], ["Sizeof", "Sizeof", "", $funcType([Type], [$Int64], false)]]); - ($ptrType(StdSizes)).methods = [["Alignof", "Alignof", "", $funcType([Type], [$Int64], false), -1], ["Offsetsof", "Offsetsof", "", $funcType([($sliceType(($ptrType(Var))))], [($sliceType($Int64))], false), -1], ["Sizeof", "Sizeof", "", $funcType([Type], [$Int64], false), -1]]; - StdSizes.init([["WordSize", "WordSize", "", $Int64, ""], ["MaxAlign", "MaxAlign", "", $Int64, ""]]); - Type.init([["String", "String", "", $funcType([], [$String], false)], ["Underlying", "Underlying", "", $funcType([], [Type], false)]]); - ($ptrType(Basic)).methods = [["Info", "Info", "", $funcType([], [BasicInfo], false), -1], ["Kind", "Kind", "", $funcType([], [BasicKind], false), -1], ["Name", "Name", "", $funcType([], [$String], false), -1], ["String", "String", "", $funcType([], [$String], false), -1], ["Underlying", "Underlying", "", $funcType([], [Type], false), -1]]; - Basic.init([["kind", "kind", "code.google.com/p/go.tools/go/types", BasicKind, ""], ["info", "info", "code.google.com/p/go.tools/go/types", BasicInfo, ""], ["name", "name", "code.google.com/p/go.tools/go/types", $String, ""]]); - ($ptrType(Array)).methods = [["Elem", "Elem", "", $funcType([], [Type], false), -1], ["Len", "Len", "", $funcType([], [$Int64], false), -1], ["String", "String", "", $funcType([], [$String], false), -1], ["Underlying", "Underlying", "", $funcType([], [Type], false), -1]]; - Array.init([["len", "len", "code.google.com/p/go.tools/go/types", $Int64, ""], ["elem", "elem", "code.google.com/p/go.tools/go/types", Type, ""]]); - ($ptrType(Slice)).methods = [["Elem", "Elem", "", $funcType([], [Type], false), -1], ["String", "String", "", $funcType([], [$String], false), -1], ["Underlying", "Underlying", "", $funcType([], [Type], false), -1]]; - Slice.init([["elem", "elem", "code.google.com/p/go.tools/go/types", Type, ""]]); - ($ptrType(Struct)).methods = [["Field", "Field", "", $funcType([$Int], [($ptrType(Var))], false), -1], ["NumFields", "NumFields", "", $funcType([], [$Int], false), -1], ["String", "String", "", $funcType([], [$String], false), -1], ["Tag", "Tag", "", $funcType([$Int], [$String], false), -1], ["Underlying", "Underlying", "", $funcType([], [Type], false), -1]]; - Struct.init([["fields", "fields", "code.google.com/p/go.tools/go/types", ($sliceType(($ptrType(Var)))), ""], ["tags", "tags", "code.google.com/p/go.tools/go/types", ($sliceType($String)), ""], ["offsets", "offsets", "code.google.com/p/go.tools/go/types", ($sliceType($Int64)), ""]]); - ($ptrType(Pointer)).methods = [["Elem", "Elem", "", $funcType([], [Type], false), -1], ["String", "String", "", $funcType([], [$String], false), -1], ["Underlying", "Underlying", "", $funcType([], [Type], false), -1]]; - Pointer.init([["base", "base", "code.google.com/p/go.tools/go/types", Type, ""]]); - ($ptrType(Tuple)).methods = [["At", "At", "", $funcType([$Int], [($ptrType(Var))], false), -1], ["Len", "Len", "", $funcType([], [$Int], false), -1], ["String", "String", "", $funcType([], [$String], false), -1], ["Underlying", "Underlying", "", $funcType([], [Type], false), -1]]; - Tuple.init([["vars", "vars", "code.google.com/p/go.tools/go/types", ($sliceType(($ptrType(Var)))), ""]]); - ($ptrType(Signature)).methods = [["Params", "Params", "", $funcType([], [($ptrType(Tuple))], false), -1], ["Recv", "Recv", "", $funcType([], [($ptrType(Var))], false), -1], ["Results", "Results", "", $funcType([], [($ptrType(Tuple))], false), -1], ["String", "String", "", $funcType([], [$String], false), -1], ["Underlying", "Underlying", "", $funcType([], [Type], false), -1], ["Variadic", "Variadic", "", $funcType([], [$Bool], false), -1]]; - Signature.init([["scope", "scope", "code.google.com/p/go.tools/go/types", ($ptrType(Scope)), ""], ["recv", "recv", "code.google.com/p/go.tools/go/types", ($ptrType(Var)), ""], ["params", "params", "code.google.com/p/go.tools/go/types", ($ptrType(Tuple)), ""], ["results", "results", "code.google.com/p/go.tools/go/types", ($ptrType(Tuple)), ""], ["variadic", "variadic", "code.google.com/p/go.tools/go/types", $Bool, ""]]); - ($ptrType(Interface)).methods = [["Complete", "Complete", "", $funcType([], [($ptrType(Interface))], false), -1], ["Embedded", "Embedded", "", $funcType([$Int], [($ptrType(Named))], false), -1], ["Empty", "Empty", "", $funcType([], [$Bool], false), -1], ["ExplicitMethod", "ExplicitMethod", "", $funcType([$Int], [($ptrType(Func))], false), -1], ["Method", "Method", "", $funcType([$Int], [($ptrType(Func))], false), -1], ["NumEmbeddeds", "NumEmbeddeds", "", $funcType([], [$Int], false), -1], ["NumExplicitMethods", "NumExplicitMethods", "", $funcType([], [$Int], false), -1], ["NumMethods", "NumMethods", "", $funcType([], [$Int], false), -1], ["String", "String", "", $funcType([], [$String], false), -1], ["Underlying", "Underlying", "", $funcType([], [Type], false), -1]]; - Interface.init([["methods", "methods", "code.google.com/p/go.tools/go/types", ($sliceType(($ptrType(Func)))), ""], ["embeddeds", "embeddeds", "code.google.com/p/go.tools/go/types", ($sliceType(($ptrType(Named)))), ""], ["allMethods", "allMethods", "code.google.com/p/go.tools/go/types", ($sliceType(($ptrType(Func)))), ""]]); - ($ptrType(Map)).methods = [["Elem", "Elem", "", $funcType([], [Type], false), -1], ["Key", "Key", "", $funcType([], [Type], false), -1], ["String", "String", "", $funcType([], [$String], false), -1], ["Underlying", "Underlying", "", $funcType([], [Type], false), -1]]; - Map.init([["key", "key", "code.google.com/p/go.tools/go/types", Type, ""], ["elem", "elem", "code.google.com/p/go.tools/go/types", Type, ""]]); - ($ptrType(Chan)).methods = [["Dir", "Dir", "", $funcType([], [ChanDir], false), -1], ["Elem", "Elem", "", $funcType([], [Type], false), -1], ["String", "String", "", $funcType([], [$String], false), -1], ["Underlying", "Underlying", "", $funcType([], [Type], false), -1]]; - Chan.init([["dir", "dir", "code.google.com/p/go.tools/go/types", ChanDir, ""], ["elem", "elem", "code.google.com/p/go.tools/go/types", Type, ""]]); - ($ptrType(Named)).methods = [["AddMethod", "AddMethod", "", $funcType([($ptrType(Func))], [], false), -1], ["Method", "Method", "", $funcType([$Int], [($ptrType(Func))], false), -1], ["NumMethods", "NumMethods", "", $funcType([], [$Int], false), -1], ["Obj", "Obj", "", $funcType([], [($ptrType(TypeName))], false), -1], ["SetUnderlying", "SetUnderlying", "", $funcType([Type], [], false), -1], ["String", "String", "", $funcType([], [$String], false), -1], ["Underlying", "Underlying", "", $funcType([], [Type], false), -1], ["setUnderlying", "setUnderlying", "code.google.com/p/go.tools/go/types", $funcType([Type], [], false), -1]]; - Named.init([["obj", "obj", "code.google.com/p/go.tools/go/types", ($ptrType(TypeName)), ""], ["underlying", "underlying", "code.google.com/p/go.tools/go/types", Type, ""], ["methods", "methods", "code.google.com/p/go.tools/go/types", ($sliceType(($ptrType(Func)))), ""]]); - byUniqueTypeName.methods = [["Len", "Len", "", $funcType([], [$Int], false), -1], ["Less", "Less", "", $funcType([$Int, $Int], [$Bool], false), -1], ["Swap", "Swap", "", $funcType([$Int, $Int], [], false), -1]]; - ($ptrType(byUniqueTypeName)).methods = [["Len", "Len", "", $funcType([], [$Int], false), -1], ["Less", "Less", "", $funcType([$Int, $Int], [$Bool], false), -1], ["Swap", "Swap", "", $funcType([$Int, $Int], [], false), -1]]; - byUniqueTypeName.init(($ptrType(Named))); - byUniqueMethodName.methods = [["Len", "Len", "", $funcType([], [$Int], false), -1], ["Less", "Less", "", $funcType([$Int, $Int], [$Bool], false), -1], ["Swap", "Swap", "", $funcType([$Int, $Int], [], false), -1]]; - ($ptrType(byUniqueMethodName)).methods = [["Len", "Len", "", $funcType([], [$Int], false), -1], ["Less", "Less", "", $funcType([$Int, $Int], [$Bool], false), -1], ["Swap", "Swap", "", $funcType([$Int, $Int], [], false), -1]]; - byUniqueMethodName.init(($ptrType(Func))); - $pkg.DefaultImport = $throwNilPointerError; - emptyMethodSet = new MethodSet.Ptr(); - $pkg.GcCompatibilityMode = false; - $pkg.Universe = ($ptrType(Scope)).nil; - $pkg.Unsafe = ($ptrType(Package)).nil; - universeIota = ($ptrType(Const)).nil; - $pkg.UniverseByte = ($ptrType(Basic)).nil; - $pkg.UniverseRune = ($ptrType(Basic)).nil; - operandModeString = $toNativeArray("String", ["invalid operand", "no value", "built-in", "type", "constant", "variable", "map index expression", "value", "comma, ok expression"]); - stdSizes = new StdSizes.Ptr(new $Int64(0, 8), new $Int64(0, 8)); - basicSizes = $toNativeArray("Uint8", [0, 1, 0, 1, 2, 4, 8, 0, 1, 2, 4, 8, 0, 4, 8, 8, 16]); - unaryOpPredicates = (_map = new $Map(), _key = 12, _map[_key] = { k: _key, v: isNumeric }, _key = 13, _map[_key] = { k: _key, v: isNumeric }, _key = 19, _map[_key] = { k: _key, v: isInteger }, _key = 43, _map[_key] = { k: _key, v: isBoolean }, _map); - binaryOpPredicates = (_map$1 = new $Map(), _key$1 = 12, _map$1[_key$1] = { k: _key$1, v: (function(typ) { - return isNumeric(typ) || isString(typ); - }) }, _key$1 = 13, _map$1[_key$1] = { k: _key$1, v: isNumeric }, _key$1 = 14, _map$1[_key$1] = { k: _key$1, v: isNumeric }, _key$1 = 15, _map$1[_key$1] = { k: _key$1, v: isNumeric }, _key$1 = 16, _map$1[_key$1] = { k: _key$1, v: isInteger }, _key$1 = 17, _map$1[_key$1] = { k: _key$1, v: isInteger }, _key$1 = 18, _map$1[_key$1] = { k: _key$1, v: isInteger }, _key$1 = 19, _map$1[_key$1] = { k: _key$1, v: isInteger }, _key$1 = 22, _map$1[_key$1] = { k: _key$1, v: isInteger }, _key$1 = 34, _map$1[_key$1] = { k: _key$1, v: isBoolean }, _key$1 = 35, _map$1[_key$1] = { k: _key$1, v: isBoolean }, _map$1); - $pkg.Typ = $toNativeArray("Ptr", [new Basic.Ptr(0, 0, "invalid type"), new Basic.Ptr(1, 1, "bool"), new Basic.Ptr(2, 2, "int"), new Basic.Ptr(3, 2, "int8"), new Basic.Ptr(4, 2, "int16"), new Basic.Ptr(5, 2, "int32"), new Basic.Ptr(6, 2, "int64"), new Basic.Ptr(7, 6, "uint"), new Basic.Ptr(8, 6, "uint8"), new Basic.Ptr(9, 6, "uint16"), new Basic.Ptr(10, 6, "uint32"), new Basic.Ptr(11, 6, "uint64"), new Basic.Ptr(12, 6, "uintptr"), new Basic.Ptr(13, 8, "float32"), new Basic.Ptr(14, 8, "float64"), new Basic.Ptr(15, 16, "complex64"), new Basic.Ptr(16, 16, "complex128"), new Basic.Ptr(17, 32, "string"), new Basic.Ptr(18, 0, "Pointer"), new Basic.Ptr(19, 65, "untyped bool"), new Basic.Ptr(20, 66, "untyped int"), new Basic.Ptr(21, 66, "untyped rune"), new Basic.Ptr(22, 72, "untyped float"), new Basic.Ptr(23, 80, "untyped complex"), new Basic.Ptr(24, 96, "untyped string"), new Basic.Ptr(25, 64, "untyped nil")]); - aliases = $toNativeArray("Ptr", [new Basic.Ptr(8, 6, "byte"), new Basic.Ptr(5, 2, "rune")]); - predeclaredConsts = $toNativeArray("Struct", [new ($structType([["name", "name", "code.google.com/p/go.tools/go/types", $String, ""], ["kind", "kind", "code.google.com/p/go.tools/go/types", BasicKind, ""], ["val", "val", "code.google.com/p/go.tools/go/types", exact.Value, ""]])).Ptr("true", 19, exact.MakeBool(true)), new ($structType([["name", "name", "code.google.com/p/go.tools/go/types", $String, ""], ["kind", "kind", "code.google.com/p/go.tools/go/types", BasicKind, ""], ["val", "val", "code.google.com/p/go.tools/go/types", exact.Value, ""]])).Ptr("false", 19, exact.MakeBool(false)), new ($structType([["name", "name", "code.google.com/p/go.tools/go/types", $String, ""], ["kind", "kind", "code.google.com/p/go.tools/go/types", BasicKind, ""], ["val", "val", "code.google.com/p/go.tools/go/types", exact.Value, ""]])).Ptr("iota", 20, exact.MakeInt64(new $Int64(0, 0)))]); - predeclaredFuncs = $toNativeArray("Struct", [new ($structType([["name", "name", "code.google.com/p/go.tools/go/types", $String, ""], ["nargs", "nargs", "code.google.com/p/go.tools/go/types", $Int, ""], ["variadic", "variadic", "code.google.com/p/go.tools/go/types", $Bool, ""], ["kind", "kind", "code.google.com/p/go.tools/go/types", exprKind, ""]])).Ptr("append", 1, true, 1), new ($structType([["name", "name", "code.google.com/p/go.tools/go/types", $String, ""], ["nargs", "nargs", "code.google.com/p/go.tools/go/types", $Int, ""], ["variadic", "variadic", "code.google.com/p/go.tools/go/types", $Bool, ""], ["kind", "kind", "code.google.com/p/go.tools/go/types", exprKind, ""]])).Ptr("cap", 1, false, 1), new ($structType([["name", "name", "code.google.com/p/go.tools/go/types", $String, ""], ["nargs", "nargs", "code.google.com/p/go.tools/go/types", $Int, ""], ["variadic", "variadic", "code.google.com/p/go.tools/go/types", $Bool, ""], ["kind", "kind", "code.google.com/p/go.tools/go/types", exprKind, ""]])).Ptr("close", 1, false, 2), new ($structType([["name", "name", "code.google.com/p/go.tools/go/types", $String, ""], ["nargs", "nargs", "code.google.com/p/go.tools/go/types", $Int, ""], ["variadic", "variadic", "code.google.com/p/go.tools/go/types", $Bool, ""], ["kind", "kind", "code.google.com/p/go.tools/go/types", exprKind, ""]])).Ptr("complex", 2, false, 1), new ($structType([["name", "name", "code.google.com/p/go.tools/go/types", $String, ""], ["nargs", "nargs", "code.google.com/p/go.tools/go/types", $Int, ""], ["variadic", "variadic", "code.google.com/p/go.tools/go/types", $Bool, ""], ["kind", "kind", "code.google.com/p/go.tools/go/types", exprKind, ""]])).Ptr("copy", 2, false, 2), new ($structType([["name", "name", "code.google.com/p/go.tools/go/types", $String, ""], ["nargs", "nargs", "code.google.com/p/go.tools/go/types", $Int, ""], ["variadic", "variadic", "code.google.com/p/go.tools/go/types", $Bool, ""], ["kind", "kind", "code.google.com/p/go.tools/go/types", exprKind, ""]])).Ptr("delete", 2, false, 2), new ($structType([["name", "name", "code.google.com/p/go.tools/go/types", $String, ""], ["nargs", "nargs", "code.google.com/p/go.tools/go/types", $Int, ""], ["variadic", "variadic", "code.google.com/p/go.tools/go/types", $Bool, ""], ["kind", "kind", "code.google.com/p/go.tools/go/types", exprKind, ""]])).Ptr("imag", 1, false, 1), new ($structType([["name", "name", "code.google.com/p/go.tools/go/types", $String, ""], ["nargs", "nargs", "code.google.com/p/go.tools/go/types", $Int, ""], ["variadic", "variadic", "code.google.com/p/go.tools/go/types", $Bool, ""], ["kind", "kind", "code.google.com/p/go.tools/go/types", exprKind, ""]])).Ptr("len", 1, false, 1), new ($structType([["name", "name", "code.google.com/p/go.tools/go/types", $String, ""], ["nargs", "nargs", "code.google.com/p/go.tools/go/types", $Int, ""], ["variadic", "variadic", "code.google.com/p/go.tools/go/types", $Bool, ""], ["kind", "kind", "code.google.com/p/go.tools/go/types", exprKind, ""]])).Ptr("make", 1, true, 1), new ($structType([["name", "name", "code.google.com/p/go.tools/go/types", $String, ""], ["nargs", "nargs", "code.google.com/p/go.tools/go/types", $Int, ""], ["variadic", "variadic", "code.google.com/p/go.tools/go/types", $Bool, ""], ["kind", "kind", "code.google.com/p/go.tools/go/types", exprKind, ""]])).Ptr("new", 1, false, 1), new ($structType([["name", "name", "code.google.com/p/go.tools/go/types", $String, ""], ["nargs", "nargs", "code.google.com/p/go.tools/go/types", $Int, ""], ["variadic", "variadic", "code.google.com/p/go.tools/go/types", $Bool, ""], ["kind", "kind", "code.google.com/p/go.tools/go/types", exprKind, ""]])).Ptr("panic", 1, false, 2), new ($structType([["name", "name", "code.google.com/p/go.tools/go/types", $String, ""], ["nargs", "nargs", "code.google.com/p/go.tools/go/types", $Int, ""], ["variadic", "variadic", "code.google.com/p/go.tools/go/types", $Bool, ""], ["kind", "kind", "code.google.com/p/go.tools/go/types", exprKind, ""]])).Ptr("print", 0, true, 2), new ($structType([["name", "name", "code.google.com/p/go.tools/go/types", $String, ""], ["nargs", "nargs", "code.google.com/p/go.tools/go/types", $Int, ""], ["variadic", "variadic", "code.google.com/p/go.tools/go/types", $Bool, ""], ["kind", "kind", "code.google.com/p/go.tools/go/types", exprKind, ""]])).Ptr("println", 0, true, 2), new ($structType([["name", "name", "code.google.com/p/go.tools/go/types", $String, ""], ["nargs", "nargs", "code.google.com/p/go.tools/go/types", $Int, ""], ["variadic", "variadic", "code.google.com/p/go.tools/go/types", $Bool, ""], ["kind", "kind", "code.google.com/p/go.tools/go/types", exprKind, ""]])).Ptr("real", 1, false, 1), new ($structType([["name", "name", "code.google.com/p/go.tools/go/types", $String, ""], ["nargs", "nargs", "code.google.com/p/go.tools/go/types", $Int, ""], ["variadic", "variadic", "code.google.com/p/go.tools/go/types", $Bool, ""], ["kind", "kind", "code.google.com/p/go.tools/go/types", exprKind, ""]])).Ptr("recover", 0, false, 2), new ($structType([["name", "name", "code.google.com/p/go.tools/go/types", $String, ""], ["nargs", "nargs", "code.google.com/p/go.tools/go/types", $Int, ""], ["variadic", "variadic", "code.google.com/p/go.tools/go/types", $Bool, ""], ["kind", "kind", "code.google.com/p/go.tools/go/types", exprKind, ""]])).Ptr("Alignof", 1, false, 1), new ($structType([["name", "name", "code.google.com/p/go.tools/go/types", $String, ""], ["nargs", "nargs", "code.google.com/p/go.tools/go/types", $Int, ""], ["variadic", "variadic", "code.google.com/p/go.tools/go/types", $Bool, ""], ["kind", "kind", "code.google.com/p/go.tools/go/types", exprKind, ""]])).Ptr("Offsetof", 1, false, 1), new ($structType([["name", "name", "code.google.com/p/go.tools/go/types", $String, ""], ["nargs", "nargs", "code.google.com/p/go.tools/go/types", $Int, ""], ["variadic", "variadic", "code.google.com/p/go.tools/go/types", $Bool, ""], ["kind", "kind", "code.google.com/p/go.tools/go/types", exprKind, ""]])).Ptr("Sizeof", 1, false, 1), new ($structType([["name", "name", "code.google.com/p/go.tools/go/types", $String, ""], ["nargs", "nargs", "code.google.com/p/go.tools/go/types", $Int, ""], ["variadic", "variadic", "code.google.com/p/go.tools/go/types", $Bool, ""], ["kind", "kind", "code.google.com/p/go.tools/go/types", exprKind, ""]])).Ptr("assert", 1, false, 2), new ($structType([["name", "name", "code.google.com/p/go.tools/go/types", $String, ""], ["nargs", "nargs", "code.google.com/p/go.tools/go/types", $Int, ""], ["variadic", "variadic", "code.google.com/p/go.tools/go/types", $Bool, ""], ["kind", "kind", "code.google.com/p/go.tools/go/types", exprKind, ""]])).Ptr("trace", 0, true, 2)]); - init(); + byUniqueName.prototype.Len = function() { + var a; + a = this; + return a.$length; }; - return $pkg; -})(); -$packages["regexp/syntax"] = (function() { - var $pkg = {}, unicode = $packages["unicode"], sort = $packages["sort"], strings = $packages["strings"], utf8 = $packages["unicode/utf8"], bytes = $packages["bytes"], strconv = $packages["strconv"], patchList, frag, compiler, Error, ErrorCode, Flags, parser, charGroup, ranges, Prog, InstOp, EmptyOp, Inst, Regexp, Op, anyRuneNotNL, anyRune, anyTable, code1, code2, code3, perlGroup, code4, code5, code6, code7, code8, code9, code10, code11, code12, code13, code14, code15, code16, code17, posixGroup, instOpNames, _map, _key, _map$1, _key$1, Compile, minFoldRune, cleanAlt, literalRegexp, Parse, isValidCaptureName, isCharClass, matchRune, mergeCharClass, unicodeTable, cleanClass, appendLiteral, appendRange, appendFoldedRange, appendClass, appendFoldedClass, appendNegatedClass, appendTable, appendNegatedTable, negateClass, checkUTF8, nextRune, isalnum, unhex, EmptyOpContext, IsWordChar, wordRune, bw, dumpProg, u32, dumpInst, writeRegexp, escape, simplify1; - patchList = $pkg.patchList = $newType(4, "Uint32", "syntax.patchList", "patchList", "regexp/syntax", null); - frag = $pkg.frag = $newType(0, "Struct", "syntax.frag", "frag", "regexp/syntax", function(i_, out_) { - this.$val = this; - this.i = i_ !== undefined ? i_ : 0; - this.out = out_ !== undefined ? out_ : 0; - }); - compiler = $pkg.compiler = $newType(0, "Struct", "syntax.compiler", "compiler", "regexp/syntax", function(p_) { - this.$val = this; - this.p = p_ !== undefined ? p_ : ($ptrType(Prog)).nil; - }); - Error = $pkg.Error = $newType(0, "Struct", "syntax.Error", "Error", "regexp/syntax", function(Code_, Expr_) { - this.$val = this; - this.Code = Code_ !== undefined ? Code_ : ""; - this.Expr = Expr_ !== undefined ? Expr_ : ""; - }); - ErrorCode = $pkg.ErrorCode = $newType(8, "String", "syntax.ErrorCode", "ErrorCode", "regexp/syntax", null); - Flags = $pkg.Flags = $newType(2, "Uint16", "syntax.Flags", "Flags", "regexp/syntax", null); - parser = $pkg.parser = $newType(0, "Struct", "syntax.parser", "parser", "regexp/syntax", function(flags_, stack_, free_, numCap_, wholeRegexp_, tmpClass_) { - this.$val = this; - this.flags = flags_ !== undefined ? flags_ : 0; - this.stack = stack_ !== undefined ? stack_ : ($sliceType(($ptrType(Regexp)))).nil; - this.free = free_ !== undefined ? free_ : ($ptrType(Regexp)).nil; - this.numCap = numCap_ !== undefined ? numCap_ : 0; - this.wholeRegexp = wholeRegexp_ !== undefined ? wholeRegexp_ : ""; - this.tmpClass = tmpClass_ !== undefined ? tmpClass_ : ($sliceType($Int32)).nil; - }); - charGroup = $pkg.charGroup = $newType(0, "Struct", "syntax.charGroup", "charGroup", "regexp/syntax", function(sign_, class$1_) { - this.$val = this; - this.sign = sign_ !== undefined ? sign_ : 0; - this.class$1 = class$1_ !== undefined ? class$1_ : ($sliceType($Int32)).nil; - }); - ranges = $pkg.ranges = $newType(0, "Struct", "syntax.ranges", "ranges", "regexp/syntax", function(p_) { - this.$val = this; - this.p = p_ !== undefined ? p_ : ($ptrType(($sliceType($Int32)))).nil; - }); - Prog = $pkg.Prog = $newType(0, "Struct", "syntax.Prog", "Prog", "regexp/syntax", function(Inst_, Start_, NumCap_) { - this.$val = this; - this.Inst = Inst_ !== undefined ? Inst_ : ($sliceType(Inst)).nil; - this.Start = Start_ !== undefined ? Start_ : 0; - this.NumCap = NumCap_ !== undefined ? NumCap_ : 0; - }); - InstOp = $pkg.InstOp = $newType(1, "Uint8", "syntax.InstOp", "InstOp", "regexp/syntax", null); - EmptyOp = $pkg.EmptyOp = $newType(1, "Uint8", "syntax.EmptyOp", "EmptyOp", "regexp/syntax", null); - Inst = $pkg.Inst = $newType(0, "Struct", "syntax.Inst", "Inst", "regexp/syntax", function(Op_, Out_, Arg_, Rune_) { - this.$val = this; - this.Op = Op_ !== undefined ? Op_ : 0; - this.Out = Out_ !== undefined ? Out_ : 0; - this.Arg = Arg_ !== undefined ? Arg_ : 0; - this.Rune = Rune_ !== undefined ? Rune_ : ($sliceType($Int32)).nil; - }); - Regexp = $pkg.Regexp = $newType(0, "Struct", "syntax.Regexp", "Regexp", "regexp/syntax", function(Op_, Flags_, Sub_, Sub0_, Rune_, Rune0_, Min_, Max_, Cap_, Name_) { - this.$val = this; - this.Op = Op_ !== undefined ? Op_ : 0; - this.Flags = Flags_ !== undefined ? Flags_ : 0; - this.Sub = Sub_ !== undefined ? Sub_ : ($sliceType(($ptrType(Regexp)))).nil; - this.Sub0 = Sub0_ !== undefined ? Sub0_ : ($arrayType(($ptrType(Regexp)), 1)).zero(); - this.Rune = Rune_ !== undefined ? Rune_ : ($sliceType($Int32)).nil; - this.Rune0 = Rune0_ !== undefined ? Rune0_ : ($arrayType($Int32, 2)).zero(); - this.Min = Min_ !== undefined ? Min_ : 0; - this.Max = Max_ !== undefined ? Max_ : 0; - this.Cap = Cap_ !== undefined ? Cap_ : 0; - this.Name = Name_ !== undefined ? Name_ : ""; - }); - Op = $pkg.Op = $newType(1, "Uint8", "syntax.Op", "Op", "regexp/syntax", null); - patchList.prototype.next = function(p) { - var l, x, x$1, i; - l = this.$val !== undefined ? this.$val : this; - i = (x = p.Inst, x$1 = l >>> 1 >>> 0, ((x$1 < 0 || x$1 >= x.$length) ? $throwRuntimeError("index out of range") : x.$array[x.$offset + x$1])); - if (((l & 1) >>> 0) === 0) { - return (i.Out >>> 0); - } - return (i.Arg >>> 0); + $ptrType(byUniqueName).prototype.Len = function() { return this.$get().Len(); }; + byUniqueName.prototype.Less = function(i, j) { + var a; + a = this; + return ((i < 0 || i >= a.$length) ? $throwRuntimeError("index out of range") : a.$array[a.$offset + i]).obj.Id() < ((j < 0 || j >= a.$length) ? $throwRuntimeError("index out of range") : a.$array[a.$offset + j]).obj.Id(); }; - $ptrType(patchList).prototype.next = function(p) { return new patchList(this.$get()).next(p); }; - patchList.prototype.patch = function(p, val) { - var l, x, x$1, i; - l = this.$val !== undefined ? this.$val : this; - while (!((l === 0))) { - i = (x = p.Inst, x$1 = l >>> 1 >>> 0, ((x$1 < 0 || x$1 >= x.$length) ? $throwRuntimeError("index out of range") : x.$array[x.$offset + x$1])); - if (((l & 1) >>> 0) === 0) { - l = (i.Out >>> 0); - i.Out = val; - } else { - l = (i.Arg >>> 0); - i.Arg = val; - } - } + $ptrType(byUniqueName).prototype.Less = function(i, j) { return this.$get().Less(i, j); }; + byUniqueName.prototype.Swap = function(i, j) { + var a, _tmp, _tmp$1; + a = this; + _tmp = ((j < 0 || j >= a.$length) ? $throwRuntimeError("index out of range") : a.$array[a.$offset + j]); _tmp$1 = ((i < 0 || i >= a.$length) ? $throwRuntimeError("index out of range") : a.$array[a.$offset + i]); (i < 0 || i >= a.$length) ? $throwRuntimeError("index out of range") : a.$array[a.$offset + i] = _tmp; (j < 0 || j >= a.$length) ? $throwRuntimeError("index out of range") : a.$array[a.$offset + j] = _tmp$1; }; - $ptrType(patchList).prototype.patch = function(p, val) { return new patchList(this.$get()).patch(p, val); }; - patchList.prototype.append = function(p, l2) { - var l1, last, next, x, x$1, i; - l1 = this.$val !== undefined ? this.$val : this; - if (l1 === 0) { - return l2; - } - if (l2 === 0) { - return l1; + $ptrType(byUniqueName).prototype.Swap = function(i, j) { return this.$get().Swap(i, j); }; + Id = $pkg.Id = function(pkg, name) { + var path$1; + if (ast.IsExported(name)) { + return name; } - last = l1; - while (true) { - next = (new patchList(last)).next(p); - if (next === 0) { - break; + path$1 = "_"; + if (!(pkg === ($ptrType(Package)).nil)) { + path$1 = pkg.path; + if (path$1 === "") { + path$1 = "_"; } - last = next; - } - i = (x = p.Inst, x$1 = last >>> 1 >>> 0, ((x$1 < 0 || x$1 >= x.$length) ? $throwRuntimeError("index out of range") : x.$array[x.$offset + x$1])); - if (((last & 1) >>> 0) === 0) { - i.Out = (l2 >>> 0); - } else { - i.Arg = (l2 >>> 0); } - return l1; + return path$1 + "." + name; }; - $ptrType(patchList).prototype.append = function(p, l2) { return new patchList(this.$get()).append(p, l2); }; - Compile = $pkg.Compile = function(re) { - var c, f; - c = new compiler.Ptr(); $copy(c, new compiler.Ptr(), compiler); - c.init(); - f = new frag.Ptr(); $copy(f, c.compile(re), frag); - (new patchList(f.out)).patch(c.p, c.inst(4).i); - c.p.Start = (f.i >> 0); - return [c.p, $ifaceNil]; + object.Ptr.prototype.Parent = function() { + var obj; + obj = this; + return obj.parent; }; - compiler.Ptr.prototype.init = function() { - var c; - c = this; - c.p = new Prog.Ptr(); - c.p.NumCap = 2; - c.inst(5); + object.prototype.Parent = function() { return this.$val.Parent(); }; + object.Ptr.prototype.Pos = function() { + var obj; + obj = this; + return obj.pos; }; - compiler.prototype.init = function() { return this.$val.init(); }; - compiler.Ptr.prototype.compile = function(re) { - var c, _ref, f, _ref$1, _i, j, f1, bra, x, sub, ket, x$1, x$2, x$3, f$1, _ref$2, _i$1, i, sub$1, f$2, _ref$3, _i$2, sub$2; - c = this; - _ref = re.Op; - if (_ref === 1) { - return c.fail(); - } else if (_ref === 2) { - return c.nop(); - } else if (_ref === 3) { - if (re.Rune.$length === 0) { - return c.nop(); - } - f = new frag.Ptr(); $copy(f, new frag.Ptr(), frag); - _ref$1 = re.Rune; - _i = 0; - while (_i < _ref$1.$length) { - j = _i; - f1 = new frag.Ptr(); $copy(f1, c.rune($subslice(re.Rune, j, (j + 1 >> 0)), re.Flags), frag); - if (j === 0) { - $copy(f, f1, frag); - } else { - $copy(f, c.cat($clone(f, frag), $clone(f1, frag)), frag); - } - _i++; - } - return f; - } else if (_ref === 4) { - return c.rune(re.Rune, re.Flags); - } else if (_ref === 5) { - return c.rune(anyRuneNotNL, 0); - } else if (_ref === 6) { - return c.rune(anyRune, 0); - } else if (_ref === 7) { - return c.empty(1); - } else if (_ref === 8) { - return c.empty(2); - } else if (_ref === 9) { - return c.empty(4); - } else if (_ref === 10) { - return c.empty(8); - } else if (_ref === 11) { - return c.empty(16); - } else if (_ref === 12) { - return c.empty(32); - } else if (_ref === 13) { - bra = new frag.Ptr(); $copy(bra, c.cap(((re.Cap << 1 >> 0) >>> 0)), frag); - sub = new frag.Ptr(); $copy(sub, c.compile((x = re.Sub, ((0 < 0 || 0 >= x.$length) ? $throwRuntimeError("index out of range") : x.$array[x.$offset + 0]))), frag); - ket = new frag.Ptr(); $copy(ket, c.cap((((re.Cap << 1 >> 0) | 1) >>> 0)), frag); - return c.cat($clone(c.cat($clone(bra, frag), $clone(sub, frag)), frag), $clone(ket, frag)); - } else if (_ref === 14) { - return c.star($clone(c.compile((x$1 = re.Sub, ((0 < 0 || 0 >= x$1.$length) ? $throwRuntimeError("index out of range") : x$1.$array[x$1.$offset + 0]))), frag), !((((re.Flags & 32) >>> 0) === 0))); - } else if (_ref === 15) { - return c.plus($clone(c.compile((x$2 = re.Sub, ((0 < 0 || 0 >= x$2.$length) ? $throwRuntimeError("index out of range") : x$2.$array[x$2.$offset + 0]))), frag), !((((re.Flags & 32) >>> 0) === 0))); - } else if (_ref === 16) { - return c.quest($clone(c.compile((x$3 = re.Sub, ((0 < 0 || 0 >= x$3.$length) ? $throwRuntimeError("index out of range") : x$3.$array[x$3.$offset + 0]))), frag), !((((re.Flags & 32) >>> 0) === 0))); - } else if (_ref === 18) { - if (re.Sub.$length === 0) { - return c.nop(); - } - f$1 = new frag.Ptr(); $copy(f$1, new frag.Ptr(), frag); - _ref$2 = re.Sub; - _i$1 = 0; - while (_i$1 < _ref$2.$length) { - i = _i$1; - sub$1 = ((_i$1 < 0 || _i$1 >= _ref$2.$length) ? $throwRuntimeError("index out of range") : _ref$2.$array[_ref$2.$offset + _i$1]); - if (i === 0) { - $copy(f$1, c.compile(sub$1), frag); - } else { - $copy(f$1, c.cat($clone(f$1, frag), $clone(c.compile(sub$1), frag)), frag); - } - _i$1++; - } - return f$1; - } else if (_ref === 19) { - f$2 = new frag.Ptr(); $copy(f$2, new frag.Ptr(), frag); - _ref$3 = re.Sub; - _i$2 = 0; - while (_i$2 < _ref$3.$length) { - sub$2 = ((_i$2 < 0 || _i$2 >= _ref$3.$length) ? $throwRuntimeError("index out of range") : _ref$3.$array[_ref$3.$offset + _i$2]); - $copy(f$2, c.alt($clone(f$2, frag), $clone(c.compile(sub$2), frag)), frag); - _i$2++; - } - return f$2; - } - $panic(new $String("regexp: unhandled case in compile")); + object.prototype.Pos = function() { return this.$val.Pos(); }; + object.Ptr.prototype.Pkg = function() { + var obj; + obj = this; + return obj.pkg; }; - compiler.prototype.compile = function(re) { return this.$val.compile(re); }; - compiler.Ptr.prototype.inst = function(op) { - var c, f; - c = this; - f = new frag.Ptr((c.p.Inst.$length >>> 0), 0); - c.p.Inst = $append(c.p.Inst, new Inst.Ptr(op, 0, 0, ($sliceType($Int32)).nil)); - return f; + object.prototype.Pkg = function() { return this.$val.Pkg(); }; + object.Ptr.prototype.Name = function() { + var obj; + obj = this; + return obj.name; }; - compiler.prototype.inst = function(op) { return this.$val.inst(op); }; - compiler.Ptr.prototype.nop = function() { - var c, f; - c = this; - f = new frag.Ptr(); $copy(f, c.inst(6), frag); - f.out = ((f.i << 1 >>> 0) >>> 0); - return f; + object.prototype.Name = function() { return this.$val.Name(); }; + object.Ptr.prototype.Type = function() { + var obj; + obj = this; + return obj.typ; }; - compiler.prototype.nop = function() { return this.$val.nop(); }; - compiler.Ptr.prototype.fail = function() { - var c; - c = this; - return new frag.Ptr(0, 0); + object.prototype.Type = function() { return this.$val.Type(); }; + object.Ptr.prototype.Exported = function() { + var obj; + obj = this; + return ast.IsExported(obj.name); }; - compiler.prototype.fail = function() { return this.$val.fail(); }; - compiler.Ptr.prototype.cap = function(arg) { - var c, f, x, x$1; - c = this; - f = new frag.Ptr(); $copy(f, c.inst(2), frag); - f.out = ((f.i << 1 >>> 0) >>> 0); - (x = c.p.Inst, x$1 = f.i, ((x$1 < 0 || x$1 >= x.$length) ? $throwRuntimeError("index out of range") : x.$array[x.$offset + x$1])).Arg = arg; - if (c.p.NumCap < ((arg >> 0) + 1 >> 0)) { - c.p.NumCap = (arg >> 0) + 1 >> 0; - } - return f; + object.prototype.Exported = function() { return this.$val.Exported(); }; + object.Ptr.prototype.Id = function() { + var obj; + obj = this; + return Id(obj.pkg, obj.name); }; - compiler.prototype.cap = function(arg) { return this.$val.cap(arg); }; - compiler.Ptr.prototype.cat = function(f1, f2) { - var c; - c = this; - if ((f1.i === 0) || (f2.i === 0)) { - return new frag.Ptr(0, 0); - } - (new patchList(f1.out)).patch(c.p, f2.i); - return new frag.Ptr(f1.i, f2.out); + object.prototype.Id = function() { return this.$val.Id(); }; + object.Ptr.prototype.String = function() { + var obj; + obj = this; + $panic(new $String("abstract")); }; - compiler.prototype.cat = function(f1, f2) { return this.$val.cat(f1, f2); }; - compiler.Ptr.prototype.alt = function(f1, f2) { - var c, f, x, x$1, i; - c = this; - if (f1.i === 0) { - return f2; + object.prototype.String = function() { return this.$val.String(); }; + object.Ptr.prototype.order = function() { + var obj; + obj = this; + return obj.order_; + }; + object.prototype.order = function() { return this.$val.order(); }; + object.Ptr.prototype.isUsed = function() { + var obj; + obj = this; + return obj.used; + }; + object.prototype.isUsed = function() { return this.$val.isUsed(); }; + object.Ptr.prototype.setOrder = function(order) { + var obj; + obj = this; + assert(order > 0); + obj.order_ = order; + }; + object.prototype.setOrder = function(order) { return this.$val.setOrder(order); }; + object.Ptr.prototype.setParent = function(parent) { + var obj; + obj = this; + obj.parent = parent; + }; + object.prototype.setParent = function(parent) { return this.$val.setParent(parent); }; + object.Ptr.prototype.sameId = function(pkg, name) { + var obj; + obj = this; + if (!(name === obj.name)) { + return false; } - if (f2.i === 0) { - return f1; + if (obj.Exported()) { + return true; } - f = new frag.Ptr(); $copy(f, c.inst(0), frag); - i = (x = c.p.Inst, x$1 = f.i, ((x$1 < 0 || x$1 >= x.$length) ? $throwRuntimeError("index out of range") : x.$array[x.$offset + x$1])); - i.Out = f1.i; - i.Arg = f2.i; - f.out = (new patchList(f1.out)).append(c.p, f2.out); - return f; - }; - compiler.prototype.alt = function(f1, f2) { return this.$val.alt(f1, f2); }; - compiler.Ptr.prototype.quest = function(f1, nongreedy) { - var c, f, x, x$1, i; - c = this; - f = new frag.Ptr(); $copy(f, c.inst(0), frag); - i = (x = c.p.Inst, x$1 = f.i, ((x$1 < 0 || x$1 >= x.$length) ? $throwRuntimeError("index out of range") : x.$array[x.$offset + x$1])); - if (nongreedy) { - i.Arg = f1.i; - f.out = ((f.i << 1 >>> 0) >>> 0); - } else { - i.Out = f1.i; - f.out = ((((f.i << 1 >>> 0) | 1) >>> 0) >>> 0); + if (pkg === ($ptrType(Package)).nil || obj.pkg === ($ptrType(Package)).nil) { + return pkg === obj.pkg; } - f.out = (new patchList(f.out)).append(c.p, f1.out); - return f; + return pkg.path === obj.pkg.path; }; - compiler.prototype.quest = function(f1, nongreedy) { return this.$val.quest(f1, nongreedy); }; - compiler.Ptr.prototype.star = function(f1, nongreedy) { - var c, f, x, x$1, i; - c = this; - f = new frag.Ptr(); $copy(f, c.inst(0), frag); - i = (x = c.p.Inst, x$1 = f.i, ((x$1 < 0 || x$1 >= x.$length) ? $throwRuntimeError("index out of range") : x.$array[x.$offset + x$1])); - if (nongreedy) { - i.Arg = f1.i; - f.out = ((f.i << 1 >>> 0) >>> 0); - } else { - i.Out = f1.i; - f.out = ((((f.i << 1 >>> 0) | 1) >>> 0) >>> 0); - } - (new patchList(f1.out)).patch(c.p, f.i); - return f; + object.prototype.sameId = function(pkg, name) { return this.$val.sameId(pkg, name); }; + NewPkgName = $pkg.NewPkgName = function(pos, pkg, name, imported) { + return new PkgName.Ptr(new object.Ptr(($ptrType(Scope)).nil, pos, pkg, name, $pkg.Typ[0], 0, false), imported); }; - compiler.prototype.star = function(f1, nongreedy) { return this.$val.star(f1, nongreedy); }; - compiler.Ptr.prototype.plus = function(f1, nongreedy) { - var c; - c = this; - return new frag.Ptr(f1.i, c.star($clone(f1, frag), nongreedy).out); + PkgName.Ptr.prototype.Imported = function() { + var obj; + obj = this; + return obj.imported; }; - compiler.prototype.plus = function(f1, nongreedy) { return this.$val.plus(f1, nongreedy); }; - compiler.Ptr.prototype.empty = function(op) { - var c, f, x, x$1; - c = this; - f = new frag.Ptr(); $copy(f, c.inst(3), frag); - (x = c.p.Inst, x$1 = f.i, ((x$1 < 0 || x$1 >= x.$length) ? $throwRuntimeError("index out of range") : x.$array[x.$offset + x$1])).Arg = (op >>> 0); - f.out = ((f.i << 1 >>> 0) >>> 0); - return f; + PkgName.prototype.Imported = function() { return this.$val.Imported(); }; + NewConst = $pkg.NewConst = function(pos, pkg, name, typ, val) { + return new Const.Ptr(new object.Ptr(($ptrType(Scope)).nil, pos, pkg, name, typ, 0, false), val, false); }; - compiler.prototype.empty = function(op) { return this.$val.empty(op); }; - compiler.Ptr.prototype.rune = function(r, flags) { - var c, f, x, x$1, i; - c = this; - f = new frag.Ptr(); $copy(f, c.inst(7), frag); - i = (x = c.p.Inst, x$1 = f.i, ((x$1 < 0 || x$1 >= x.$length) ? $throwRuntimeError("index out of range") : x.$array[x.$offset + x$1])); - i.Rune = r; - flags = (flags & (1)) >>> 0; - if (!((r.$length === 1)) || (unicode.SimpleFold(((0 < 0 || 0 >= r.$length) ? $throwRuntimeError("index out of range") : r.$array[r.$offset + 0])) === ((0 < 0 || 0 >= r.$length) ? $throwRuntimeError("index out of range") : r.$array[r.$offset + 0]))) { - flags = flags & ~(1); - } - i.Arg = (flags >>> 0); - f.out = ((f.i << 1 >>> 0) >>> 0); - if ((((flags & 1) >>> 0) === 0) && ((r.$length === 1) || (r.$length === 2) && (((0 < 0 || 0 >= r.$length) ? $throwRuntimeError("index out of range") : r.$array[r.$offset + 0]) === ((1 < 0 || 1 >= r.$length) ? $throwRuntimeError("index out of range") : r.$array[r.$offset + 1])))) { - i.Op = 8; - } else if ((r.$length === 2) && (((0 < 0 || 0 >= r.$length) ? $throwRuntimeError("index out of range") : r.$array[r.$offset + 0]) === 0) && (((1 < 0 || 1 >= r.$length) ? $throwRuntimeError("index out of range") : r.$array[r.$offset + 1]) === 1114111)) { - i.Op = 9; - } else if ((r.$length === 4) && (((0 < 0 || 0 >= r.$length) ? $throwRuntimeError("index out of range") : r.$array[r.$offset + 0]) === 0) && (((1 < 0 || 1 >= r.$length) ? $throwRuntimeError("index out of range") : r.$array[r.$offset + 1]) === 9) && (((2 < 0 || 2 >= r.$length) ? $throwRuntimeError("index out of range") : r.$array[r.$offset + 2]) === 11) && (((3 < 0 || 3 >= r.$length) ? $throwRuntimeError("index out of range") : r.$array[r.$offset + 3]) === 1114111)) { - i.Op = 10; + Const.Ptr.prototype.Val = function() { + var obj; + obj = this; + return obj.val; + }; + Const.prototype.Val = function() { return this.$val.Val(); }; + NewTypeName = $pkg.NewTypeName = function(pos, pkg, name, typ) { + return new TypeName.Ptr(new object.Ptr(($ptrType(Scope)).nil, pos, pkg, name, typ, 0, false)); + }; + NewVar = $pkg.NewVar = function(pos, pkg, name, typ) { + return new Var.Ptr(new object.Ptr(($ptrType(Scope)).nil, pos, pkg, name, typ, 0, false), false, false, false); + }; + NewParam = $pkg.NewParam = function(pos, pkg, name, typ) { + return new Var.Ptr(new object.Ptr(($ptrType(Scope)).nil, pos, pkg, name, typ, 0, true), false, false, false); + }; + NewField = $pkg.NewField = function(pos, pkg, name, typ, anonymous) { + return new Var.Ptr(new object.Ptr(($ptrType(Scope)).nil, pos, pkg, name, typ, 0, false), anonymous, false, true); + }; + Var.Ptr.prototype.Anonymous = function() { + var obj; + obj = this; + return obj.anonymous; + }; + Var.prototype.Anonymous = function() { return this.$val.Anonymous(); }; + Var.Ptr.prototype.IsField = function() { + var obj; + obj = this; + return obj.isField; + }; + Var.prototype.IsField = function() { return this.$val.IsField(); }; + NewFunc = $pkg.NewFunc = function(pos, pkg, name, sig) { + var typ; + typ = $ifaceNil; + if (!(sig === ($ptrType(Signature)).nil)) { + typ = sig; } - return f; + return new Func.Ptr(new object.Ptr(($ptrType(Scope)).nil, pos, pkg, name, typ, 0, false)); }; - compiler.prototype.rune = function(r, flags) { return this.$val.rune(r, flags); }; - Error.Ptr.prototype.Error = function() { - var e; - e = this; - return "error parsing regexp: " + (new ErrorCode(e.Code)).String() + ": `" + e.Expr + "`"; + Func.Ptr.prototype.FullName = function() { + var obj, buf; + obj = this; + buf = new bytes.Buffer.Ptr(); $copy(buf, new bytes.Buffer.Ptr(), bytes.Buffer); + writeFuncName(buf, ($ptrType(Package)).nil, obj); + return buf.String(); }; - Error.prototype.Error = function() { return this.$val.Error(); }; - ErrorCode.prototype.String = function() { - var e; - e = this.$val !== undefined ? this.$val : this; - return e; + Func.prototype.FullName = function() { return this.$val.FullName(); }; + Func.Ptr.prototype.Scope = function() { + var obj; + obj = this; + return $assertType(obj.object.typ, ($ptrType(Signature))).scope; }; - $ptrType(ErrorCode).prototype.String = function() { return new ErrorCode(this.$get()).String(); }; - parser.Ptr.prototype.newRegexp = function(op) { - var p, re; - p = this; - re = p.free; - if (!(re === ($ptrType(Regexp)).nil)) { - p.free = re.Sub0[0]; - $copy(re, new Regexp.Ptr(0, 0, ($sliceType(($ptrType(Regexp)))).nil, ($arrayType(($ptrType(Regexp)), 1)).zero(), ($sliceType($Int32)).nil, ($arrayType($Int32, 2)).zero(), 0, 0, 0, ""), Regexp); + Func.prototype.Scope = function() { return this.$val.Scope(); }; + NewLabel = $pkg.NewLabel = function(pos, pkg, name) { + return new Label.Ptr(new object.Ptr(($ptrType(Scope)).nil, pos, pkg, name, $pkg.Typ[0], 0, false)); + }; + newBuiltin = function(id) { + return new Builtin.Ptr(new object.Ptr(($ptrType(Scope)).nil, 0, ($ptrType(Package)).nil, ((id < 0 || id >= predeclaredFuncs.length) ? $throwRuntimeError("index out of range") : predeclaredFuncs[id]).name, $pkg.Typ[0], 0, false), id); + }; + writeObject = function(buf, this$1, obj) { + var typ, obj$1, _ref, path$1, pkg; + typ = obj.Type(); + _ref = obj; + if ($assertType(_ref, ($ptrType(PkgName)), true)[1]) { + obj$1 = _ref.$val; + fmt.Fprintf(buf, "package %s", new ($sliceType($emptyInterface))([new $String(obj$1.object.Name())])); + path$1 = obj$1.imported.path; + if (!(path$1 === "") && !(path$1 === obj$1.object.name)) { + fmt.Fprintf(buf, " (%q)", new ($sliceType($emptyInterface))([new $String(path$1)])); + } + return; + } else if ($assertType(_ref, ($ptrType(Const)), true)[1]) { + obj$1 = _ref.$val; + buf.WriteString("const"); + } else if ($assertType(_ref, ($ptrType(TypeName)), true)[1]) { + obj$1 = _ref.$val; + buf.WriteString("type"); + typ = typ.Underlying(); + } else if ($assertType(_ref, ($ptrType(Var)), true)[1]) { + obj$1 = _ref.$val; + if (obj$1.isField) { + buf.WriteString("field"); + } else { + buf.WriteString("var"); + } + } else if ($assertType(_ref, ($ptrType(Func)), true)[1]) { + obj$1 = _ref.$val; + buf.WriteString("func "); + writeFuncName(buf, this$1, obj$1); + if (!($interfaceIsEqual(typ, $ifaceNil))) { + WriteSignature(buf, this$1, $assertType(typ, ($ptrType(Signature)))); + } + return; + } else if ($assertType(_ref, ($ptrType(Label)), true)[1]) { + obj$1 = _ref.$val; + buf.WriteString("label"); + typ = $ifaceNil; + } else if ($assertType(_ref, ($ptrType(Builtin)), true)[1]) { + obj$1 = _ref.$val; + buf.WriteString("builtin"); + typ = $ifaceNil; + } else if ($assertType(_ref, ($ptrType(Nil)), true)[1]) { + obj$1 = _ref.$val; + buf.WriteString("nil"); + return; } else { - re = new Regexp.Ptr(); + obj$1 = _ref; + $panic(new $String(fmt.Sprintf("writeObject(%T)", new ($sliceType($emptyInterface))([obj$1])))); + } + buf.WriteByte(32); + pkg = obj.Pkg(); + if (!(pkg === ($ptrType(Package)).nil) && !(this$1 === pkg) && $interfaceIsEqual(pkg.scope.Lookup(obj.Name()), obj)) { + buf.WriteString(pkg.path); + buf.WriteByte(46); + } + buf.WriteString(obj.Name()); + if (!($interfaceIsEqual(typ, $ifaceNil))) { + buf.WriteByte(32); + WriteType(buf, this$1, typ); } - re.Op = op; - return re; }; - parser.prototype.newRegexp = function(op) { return this.$val.newRegexp(op); }; - parser.Ptr.prototype.reuse = function(re) { - var p; - p = this; - re.Sub0[0] = p.free; - p.free = re; + ObjectString = $pkg.ObjectString = function(this$1, obj) { + var buf; + buf = new bytes.Buffer.Ptr(); $copy(buf, new bytes.Buffer.Ptr(), bytes.Buffer); + writeObject(buf, this$1, obj); + return buf.String(); + }; + PkgName.Ptr.prototype.String = function() { + var obj; + obj = this; + return ObjectString(($ptrType(Package)).nil, obj); + }; + PkgName.prototype.String = function() { return this.$val.String(); }; + Const.Ptr.prototype.String = function() { + var obj; + obj = this; + return ObjectString(($ptrType(Package)).nil, obj); + }; + Const.prototype.String = function() { return this.$val.String(); }; + TypeName.Ptr.prototype.String = function() { + var obj; + obj = this; + return ObjectString(($ptrType(Package)).nil, obj); + }; + TypeName.prototype.String = function() { return this.$val.String(); }; + Var.Ptr.prototype.String = function() { + var obj; + obj = this; + return ObjectString(($ptrType(Package)).nil, obj); + }; + Var.prototype.String = function() { return this.$val.String(); }; + Func.Ptr.prototype.String = function() { + var obj; + obj = this; + return ObjectString(($ptrType(Package)).nil, obj); + }; + Func.prototype.String = function() { return this.$val.String(); }; + Label.Ptr.prototype.String = function() { + var obj; + obj = this; + return ObjectString(($ptrType(Package)).nil, obj); + }; + Label.prototype.String = function() { return this.$val.String(); }; + Builtin.Ptr.prototype.String = function() { + var obj; + obj = this; + return ObjectString(($ptrType(Package)).nil, obj); + }; + Builtin.prototype.String = function() { return this.$val.String(); }; + Nil.Ptr.prototype.String = function() { + var obj; + obj = this; + return ObjectString(($ptrType(Package)).nil, obj); }; - parser.prototype.reuse = function(re) { return this.$val.reuse(re); }; - parser.Ptr.prototype.push = function(re) { - var p, x, x$1, x$2, x$3, x$4, x$5, x$6, x$7, x$8, x$9, x$10, x$11, x$12, x$13, x$14, x$15, x$16, x$17; - p = this; - if ((re.Op === 4) && (re.Rune.$length === 2) && ((x = re.Rune, ((0 < 0 || 0 >= x.$length) ? $throwRuntimeError("index out of range") : x.$array[x.$offset + 0])) === (x$1 = re.Rune, ((1 < 0 || 1 >= x$1.$length) ? $throwRuntimeError("index out of range") : x$1.$array[x$1.$offset + 1])))) { - if (p.maybeConcat((x$16 = re.Rune, ((0 < 0 || 0 >= x$16.$length) ? $throwRuntimeError("index out of range") : x$16.$array[x$16.$offset + 0])), p.flags & ~1)) { - return ($ptrType(Regexp)).nil; - } - re.Op = 3; - re.Rune = $subslice(re.Rune, 0, 1); - re.Flags = p.flags & ~1; - } else if ((re.Op === 4) && (re.Rune.$length === 4) && ((x$2 = re.Rune, ((0 < 0 || 0 >= x$2.$length) ? $throwRuntimeError("index out of range") : x$2.$array[x$2.$offset + 0])) === (x$3 = re.Rune, ((1 < 0 || 1 >= x$3.$length) ? $throwRuntimeError("index out of range") : x$3.$array[x$3.$offset + 1]))) && ((x$4 = re.Rune, ((2 < 0 || 2 >= x$4.$length) ? $throwRuntimeError("index out of range") : x$4.$array[x$4.$offset + 2])) === (x$5 = re.Rune, ((3 < 0 || 3 >= x$5.$length) ? $throwRuntimeError("index out of range") : x$5.$array[x$5.$offset + 3]))) && (unicode.SimpleFold((x$6 = re.Rune, ((0 < 0 || 0 >= x$6.$length) ? $throwRuntimeError("index out of range") : x$6.$array[x$6.$offset + 0]))) === (x$7 = re.Rune, ((2 < 0 || 2 >= x$7.$length) ? $throwRuntimeError("index out of range") : x$7.$array[x$7.$offset + 2]))) && (unicode.SimpleFold((x$8 = re.Rune, ((2 < 0 || 2 >= x$8.$length) ? $throwRuntimeError("index out of range") : x$8.$array[x$8.$offset + 2]))) === (x$9 = re.Rune, ((0 < 0 || 0 >= x$9.$length) ? $throwRuntimeError("index out of range") : x$9.$array[x$9.$offset + 0]))) || (re.Op === 4) && (re.Rune.$length === 2) && (((x$10 = re.Rune, ((0 < 0 || 0 >= x$10.$length) ? $throwRuntimeError("index out of range") : x$10.$array[x$10.$offset + 0])) + 1 >> 0) === (x$11 = re.Rune, ((1 < 0 || 1 >= x$11.$length) ? $throwRuntimeError("index out of range") : x$11.$array[x$11.$offset + 1]))) && (unicode.SimpleFold((x$12 = re.Rune, ((0 < 0 || 0 >= x$12.$length) ? $throwRuntimeError("index out of range") : x$12.$array[x$12.$offset + 0]))) === (x$13 = re.Rune, ((1 < 0 || 1 >= x$13.$length) ? $throwRuntimeError("index out of range") : x$13.$array[x$13.$offset + 1]))) && (unicode.SimpleFold((x$14 = re.Rune, ((1 < 0 || 1 >= x$14.$length) ? $throwRuntimeError("index out of range") : x$14.$array[x$14.$offset + 1]))) === (x$15 = re.Rune, ((0 < 0 || 0 >= x$15.$length) ? $throwRuntimeError("index out of range") : x$15.$array[x$15.$offset + 0])))) { - if (p.maybeConcat((x$17 = re.Rune, ((0 < 0 || 0 >= x$17.$length) ? $throwRuntimeError("index out of range") : x$17.$array[x$17.$offset + 0])), (p.flags | 1) >>> 0)) { - return ($ptrType(Regexp)).nil; + Nil.prototype.String = function() { return this.$val.String(); }; + writeFuncName = function(buf, this$1, f) { + var sig, recv, _tuple, ok; + if (!($interfaceIsEqual(f.object.typ, $ifaceNil))) { + sig = $assertType(f.object.typ, ($ptrType(Signature))); + recv = sig.Recv(); + if (!(recv === ($ptrType(Var)).nil)) { + buf.WriteByte(40); + _tuple = $assertType(recv.object.Type(), ($ptrType(Interface)), true); ok = _tuple[1]; + if (ok) { + buf.WriteString("interface"); + } else { + WriteType(buf, this$1, recv.object.Type()); + } + buf.WriteByte(41); + buf.WriteByte(46); + } else if (!(f.object.pkg === ($ptrType(Package)).nil) && !(f.object.pkg === this$1)) { + buf.WriteString(f.object.pkg.path); + buf.WriteByte(46); } - re.Op = 3; - re.Rune = $subslice(re.Rune, 0, 1); - re.Flags = (p.flags | 1) >>> 0; - } else { - p.maybeConcat(-1, 0); } - p.stack = $append(p.stack, re); - return re; + buf.WriteString(f.object.name); }; - parser.prototype.push = function(re) { return this.$val.push(re); }; - parser.Ptr.prototype.maybeConcat = function(r, flags) { - var p, n, x, x$1, re1, x$2, x$3, re2, x$4; - p = this; - n = p.stack.$length; - if (n < 2) { - return false; - } - re1 = (x = p.stack, x$1 = n - 1 >> 0, ((x$1 < 0 || x$1 >= x.$length) ? $throwRuntimeError("index out of range") : x.$array[x.$offset + x$1])); - re2 = (x$2 = p.stack, x$3 = n - 2 >> 0, ((x$3 < 0 || x$3 >= x$2.$length) ? $throwRuntimeError("index out of range") : x$2.$array[x$2.$offset + x$3])); - if (!((re1.Op === 3)) || !((re2.Op === 3)) || !((((re1.Flags & 1) >>> 0) === ((re2.Flags & 1) >>> 0)))) { - return false; + $ptrType(objset).prototype.insert = function(obj) { + var s, id, _entry, alt, _key$2; + s = this; + id = obj.Id(); + alt = (_entry = (s.$get())[id], _entry !== undefined ? _entry.v : $ifaceNil); + if (!($interfaceIsEqual(alt, $ifaceNil))) { + return alt; } - re2.Rune = $appendSlice(re2.Rune, re1.Rune); - if (r >= 0) { - re1.Rune = $subslice(new ($sliceType($Int32))(re1.Rune0), 0, 1); - (x$4 = re1.Rune, (0 < 0 || 0 >= x$4.$length) ? $throwRuntimeError("index out of range") : x$4.$array[x$4.$offset + 0] = r); - re1.Flags = flags; - return true; + if (s.$get() === false) { + s.$set(new $Map()); } - p.stack = $subslice(p.stack, 0, (n - 1 >> 0)); - p.reuse(re1); - return false; + _key$2 = id; (s.$get() || $throwRuntimeError("assignment to entry in nil map"))[_key$2] = { k: _key$2, v: obj }; + return $ifaceNil; }; - parser.prototype.maybeConcat = function(r, flags) { return this.$val.maybeConcat(r, flags); }; - parser.Ptr.prototype.newLiteral = function(r, flags) { - var p, re; - p = this; - re = p.newRegexp(3); - re.Flags = flags; - if (!((((flags & 1) >>> 0) === 0))) { - r = minFoldRune(r); + operand.Ptr.prototype.pos = function() { + var x; + x = this; + if ($interfaceIsEqual(x.expr, $ifaceNil)) { + return 0; } - re.Rune0[0] = r; - re.Rune = $subslice(new ($sliceType($Int32))(re.Rune0), 0, 1); - return re; + return x.expr.Pos(); }; - parser.prototype.newLiteral = function(r, flags) { return this.$val.newLiteral(r, flags); }; - minFoldRune = function(r) { - var min, r0; - if (r < 65 || r > 66639) { - return r; - } - min = r; - r0 = r; - r = unicode.SimpleFold(r); - while (!((r === r0))) { - if (min > r) { - min = r; + operand.prototype.pos = function() { return this.$val.pos(); }; + operandString = function(this$1, x) { + var buf, expr, _ref, x$1, hasType, _ref$1, x$2, s; + buf = new bytes.Buffer.Ptr(); $copy(buf, new bytes.Buffer.Ptr(), bytes.Buffer); + expr = ""; + if (!($interfaceIsEqual(x.expr, $ifaceNil))) { + expr = ExprString(x.expr); + } else { + _ref = x.mode; + if (_ref === 2) { + expr = (x$1 = x.id, ((x$1 < 0 || x$1 >= predeclaredFuncs.length) ? $throwRuntimeError("index out of range") : predeclaredFuncs[x$1])).name; + } else if (_ref === 3) { + expr = TypeString(this$1, x.typ); + } else if (_ref === 4) { + expr = x.val.String(); } - r = unicode.SimpleFold(r); } - return min; - }; - parser.Ptr.prototype.literal = function(r) { - var p; - p = this; - p.push(p.newLiteral(r, p.flags)); - }; - parser.prototype.literal = function(r) { return this.$val.literal(r); }; - parser.Ptr.prototype.op = function(op) { - var p, re; - p = this; - re = p.newRegexp(op); - re.Flags = p.flags; - return p.push(re); - }; - parser.prototype.op = function(op) { return this.$val.op(op); }; - parser.Ptr.prototype.repeat = function(op, min, max, before, after, lastRepeat) { - var p, flags, n, x, x$1, sub, re, x$2, x$3, x$4; - p = this; - flags = p.flags; - if (!((((p.flags & 64) >>> 0) === 0))) { - if (after.length > 0 && (after.charCodeAt(0) === 63)) { - after = after.substring(1); - flags = (flags ^ (32)) << 16 >>> 16; + if (!(expr === "")) { + buf.WriteString(expr); + buf.WriteString(" ("); + } + hasType = false; + _ref$1 = x.mode; + switch (0) { default: if (_ref$1 === 0 || _ref$1 === 1 || _ref$1 === 2 || _ref$1 === 3) { + } else { + if (isUntyped(x.typ)) { + buf.WriteString($assertType(x.typ, ($ptrType(Basic))).name); + buf.WriteByte(32); + break; } - if (!(lastRepeat === "")) { - return ["", new Error.Ptr("invalid nested repetition operator", lastRepeat.substring(0, (lastRepeat.length - after.length >> 0)))]; + hasType = true; + } } + buf.WriteString((x$2 = x.mode, ((x$2 < 0 || x$2 >= operandModeString.length) ? $throwRuntimeError("index out of range") : operandModeString[x$2]))); + if (x.mode === 4) { + s = x.val.String(); + if (!(s === expr)) { + buf.WriteByte(32); + buf.WriteString(s); } } - n = p.stack.$length; - if (n === 0) { - return ["", new Error.Ptr("missing argument to repetition operator", before.substring(0, (before.length - after.length >> 0)))]; + if (hasType) { + if (!($interfaceIsEqual(x.typ, $pkg.Typ[0]))) { + buf.WriteString(" of type "); + WriteType(buf, this$1, x.typ); + } else { + buf.WriteString(" with invalid type"); + } } - sub = (x = p.stack, x$1 = n - 1 >> 0, ((x$1 < 0 || x$1 >= x.$length) ? $throwRuntimeError("index out of range") : x.$array[x.$offset + x$1])); - if (sub.Op >= 128) { - return ["", new Error.Ptr("missing argument to repetition operator", before.substring(0, (before.length - after.length >> 0)))]; + if (!(expr === "")) { + buf.WriteByte(41); } - re = p.newRegexp(op); - re.Min = min; - re.Max = max; - re.Flags = flags; - re.Sub = $subslice(new ($sliceType(($ptrType(Regexp))))(re.Sub0), 0, 1); - (x$2 = re.Sub, (0 < 0 || 0 >= x$2.$length) ? $throwRuntimeError("index out of range") : x$2.$array[x$2.$offset + 0] = sub); - (x$3 = p.stack, x$4 = n - 1 >> 0, (x$4 < 0 || x$4 >= x$3.$length) ? $throwRuntimeError("index out of range") : x$3.$array[x$3.$offset + x$4] = re); - return [after, $ifaceNil]; + return buf.String(); }; - parser.prototype.repeat = function(op, min, max, before, after, lastRepeat) { return this.$val.repeat(op, min, max, before, after, lastRepeat); }; - parser.Ptr.prototype.concat = function() { - var p, i, x, x$1, subs; - p = this; - p.maybeConcat(-1, 0); - i = p.stack.$length; - while (i > 0 && (x = p.stack, x$1 = i - 1 >> 0, ((x$1 < 0 || x$1 >= x.$length) ? $throwRuntimeError("index out of range") : x.$array[x.$offset + x$1])).Op < 128) { - i = i - (1) >> 0; - } - subs = $subslice(p.stack, i); - p.stack = $subslice(p.stack, 0, i); - if (subs.$length === 0) { - return p.push(p.newRegexp(2)); - } - return p.push(p.collapse(subs, 18)); + operand.Ptr.prototype.String = function() { + var x; + x = this; + return operandString(($ptrType(Package)).nil, x); }; - parser.prototype.concat = function() { return this.$val.concat(); }; - parser.Ptr.prototype.alternate = function() { - var p, i, x, x$1, subs, x$2; - p = this; - i = p.stack.$length; - while (i > 0 && (x = p.stack, x$1 = i - 1 >> 0, ((x$1 < 0 || x$1 >= x.$length) ? $throwRuntimeError("index out of range") : x.$array[x.$offset + x$1])).Op < 128) { - i = i - (1) >> 0; - } - subs = $subslice(p.stack, i); - p.stack = $subslice(p.stack, 0, i); - if (subs.$length > 0) { - cleanAlt((x$2 = subs.$length - 1 >> 0, ((x$2 < 0 || x$2 >= subs.$length) ? $throwRuntimeError("index out of range") : subs.$array[subs.$offset + x$2]))); + operand.prototype.String = function() { return this.$val.String(); }; + operand.Ptr.prototype.setConst = function(tok, lit) { + var x, val, kind, _ref; + x = this; + val = exact.MakeFromLiteral(lit, tok); + if ($interfaceIsEqual(val, $ifaceNil)) { + x.mode = 0; + return; } - if (subs.$length === 0) { - return p.push(p.newRegexp(1)); + kind = 0; + _ref = tok; + if (_ref === 5) { + kind = 20; + } else if (_ref === 6) { + kind = 22; + } else if (_ref === 7) { + kind = 23; + } else if (_ref === 8) { + kind = 21; + } else if (_ref === 9) { + kind = 24; } - return p.push(p.collapse(subs, 19)); + x.mode = 4; + x.typ = ((kind < 0 || kind >= $pkg.Typ.length) ? $throwRuntimeError("index out of range") : $pkg.Typ[kind]); + x.val = val; }; - parser.prototype.alternate = function() { return this.$val.alternate(); }; - cleanAlt = function(re) { - var _ref, x, x$1, x$2, x$3, x$4, x$5; - _ref = re.Op; - if (_ref === 4) { - re.Rune = cleanClass(new ($ptrType(($sliceType($Int32))))(function() { return this.$target.Rune; }, function($v) { this.$target.Rune = $v; }, re)); - if ((re.Rune.$length === 2) && ((x = re.Rune, ((0 < 0 || 0 >= x.$length) ? $throwRuntimeError("index out of range") : x.$array[x.$offset + 0])) === 0) && ((x$1 = re.Rune, ((1 < 0 || 1 >= x$1.$length) ? $throwRuntimeError("index out of range") : x$1.$array[x$1.$offset + 1])) === 1114111)) { - re.Rune = ($sliceType($Int32)).nil; - re.Op = 6; - return; - } - if ((re.Rune.$length === 4) && ((x$2 = re.Rune, ((0 < 0 || 0 >= x$2.$length) ? $throwRuntimeError("index out of range") : x$2.$array[x$2.$offset + 0])) === 0) && ((x$3 = re.Rune, ((1 < 0 || 1 >= x$3.$length) ? $throwRuntimeError("index out of range") : x$3.$array[x$3.$offset + 1])) === 9) && ((x$4 = re.Rune, ((2 < 0 || 2 >= x$4.$length) ? $throwRuntimeError("index out of range") : x$4.$array[x$4.$offset + 2])) === 11) && ((x$5 = re.Rune, ((3 < 0 || 3 >= x$5.$length) ? $throwRuntimeError("index out of range") : x$5.$array[x$5.$offset + 3])) === 1114111)) { - re.Rune = ($sliceType($Int32)).nil; - re.Op = 5; - return; - } - if ((re.Rune.$capacity - re.Rune.$length >> 0) > 100) { - re.Rune = $appendSlice($subslice(new ($sliceType($Int32))(re.Rune0), 0, 0), re.Rune); - } - } + operand.prototype.setConst = function(tok, lit) { return this.$val.setConst(tok, lit); }; + operand.Ptr.prototype.isNil = function() { + var x; + x = this; + return (x.mode === 7) && $interfaceIsEqual(x.typ, $pkg.Typ[25]); }; - parser.Ptr.prototype.collapse = function(subs, op) { - var p, re, _ref, _i, sub, old, x; - p = this; - if (subs.$length === 1) { - return ((0 < 0 || 0 >= subs.$length) ? $throwRuntimeError("index out of range") : subs.$array[subs.$offset + 0]); + operand.prototype.isNil = function() { return this.$val.isNil(); }; + operand.Ptr.prototype.assignableTo = function(conf, T) { + var x, V, Vu, Tu, _tuple, Ti, ok, _tuple$1, Vc, ok$1, _tuple$2, Tc, ok$2, t, _ref, t$1, _ref$1, _tuple$3, Vb; + x = this; + if ((x.mode === 0) || $interfaceIsEqual(T, $pkg.Typ[0])) { + return true; } - re = p.newRegexp(op); - re.Sub = $subslice(new ($sliceType(($ptrType(Regexp))))(re.Sub0), 0, 0); - _ref = subs; - _i = 0; - while (_i < _ref.$length) { - sub = ((_i < 0 || _i >= _ref.$length) ? $throwRuntimeError("index out of range") : _ref.$array[_ref.$offset + _i]); - if (sub.Op === op) { - re.Sub = $appendSlice(re.Sub, sub.Sub); - p.reuse(sub); - } else { - re.Sub = $append(re.Sub, sub); - } - _i++; + V = x.typ; + if (Identical(V, T)) { + return true; } - if (op === 19) { - re.Sub = p.factor(re.Sub, re.Flags); - if (re.Sub.$length === 1) { - old = re; - re = (x = re.Sub, ((0 < 0 || 0 >= x.$length) ? $throwRuntimeError("index out of range") : x.$array[x.$offset + 0])); - p.reuse(old); + Vu = V.Underlying(); + Tu = T.Underlying(); + _tuple = $assertType(Tu, ($ptrType(Interface)), true); Ti = _tuple[0]; ok = _tuple[1]; + if (ok) { + if (Implements(x.typ, Ti)) { + return true; } } - return re; - }; - parser.prototype.collapse = function(subs, op) { return this.$val.collapse(subs, op); }; - parser.Ptr.prototype.factor = function(sub, flags) { - var p, str, strflags, start, out, i, istr, iflags, _tuple, same, prefix, j, suffix, re, first, i$1, ifirst, prefix$1, j$1, reuse, suffix$1, re$1, i$2, max, j$2, _tmp, _tmp$1, j$3, _ref, _i, i$3, x; - p = this; - if (sub.$length < 2) { - return sub; + if (Identical(Vu, Tu) && (!isNamed(V) || !isNamed(T))) { + return true; } - str = ($sliceType($Int32)).nil; - strflags = 0; - start = 0; - out = $subslice(sub, 0, 0); - i = 0; - while (i <= sub.$length) { - istr = ($sliceType($Int32)).nil; - iflags = 0; - if (i < sub.$length) { - _tuple = p.leadingString(((i < 0 || i >= sub.$length) ? $throwRuntimeError("index out of range") : sub.$array[sub.$offset + i])); istr = _tuple[0]; iflags = _tuple[1]; - if (iflags === strflags) { - same = 0; - while (same < str.$length && same < istr.$length && (((same < 0 || same >= str.$length) ? $throwRuntimeError("index out of range") : str.$array[str.$offset + same]) === ((same < 0 || same >= istr.$length) ? $throwRuntimeError("index out of range") : istr.$array[istr.$offset + same]))) { - same = same + (1) >> 0; - } - if (same > 0) { - str = $subslice(str, 0, same); - i = i + (1) >> 0; - continue; - } - } + _tuple$1 = $assertType(Vu, ($ptrType(Chan)), true); Vc = _tuple$1[0]; ok$1 = _tuple$1[1]; + if (ok$1 && (Vc.dir === 0)) { + _tuple$2 = $assertType(Tu, ($ptrType(Chan)), true); Tc = _tuple$2[0]; ok$2 = _tuple$2[1]; + if (ok$2 && Identical(Vc.elem, Tc.elem)) { + return !isNamed(V) || !isNamed(T); } - if (i === start) { - } else if (i === (start + 1 >> 0)) { - out = $append(out, ((start < 0 || start >= sub.$length) ? $throwRuntimeError("index out of range") : sub.$array[sub.$offset + start])); - } else { - prefix = p.newRegexp(3); - prefix.Flags = strflags; - prefix.Rune = $appendSlice($subslice(prefix.Rune, 0, 0), str); - j = start; - while (j < i) { - (j < 0 || j >= sub.$length) ? $throwRuntimeError("index out of range") : sub.$array[sub.$offset + j] = p.removeLeadingString(((j < 0 || j >= sub.$length) ? $throwRuntimeError("index out of range") : sub.$array[sub.$offset + j]), str.$length); - j = j + (1) >> 0; + } + if (x.isNil()) { + _ref = Tu; + if ($assertType(_ref, ($ptrType(Basic)), true)[1]) { + t = _ref.$val; + if (t.kind === 18) { + return true; } - suffix = p.collapse($subslice(sub, start, i), 19); - re = p.newRegexp(18); - re.Sub = $append($subslice(re.Sub, 0, 0), prefix, suffix); - out = $append(out, re); + } else if ($assertType(_ref, ($ptrType(Pointer)), true)[1] || $assertType(_ref, ($ptrType(Signature)), true)[1] || $assertType(_ref, ($ptrType(Slice)), true)[1] || $assertType(_ref, ($ptrType(Map)), true)[1] || $assertType(_ref, ($ptrType(Chan)), true)[1] || $assertType(_ref, ($ptrType(Interface)), true)[1]) { + t = _ref; + return true; } - start = i; - str = istr; - strflags = iflags; - i = i + (1) >> 0; + return false; } - sub = out; - start = 0; - out = $subslice(sub, 0, 0); - first = ($ptrType(Regexp)).nil; - i$1 = 0; - while (i$1 <= sub.$length) { - ifirst = ($ptrType(Regexp)).nil; - if (i$1 < sub.$length) { - ifirst = p.leadingRegexp(((i$1 < 0 || i$1 >= sub.$length) ? $throwRuntimeError("index out of range") : sub.$array[sub.$offset + i$1])); - if (!(first === ($ptrType(Regexp)).nil) && first.Equal(ifirst)) { - i$1 = i$1 + (1) >> 0; - continue; + if (isUntyped(Vu)) { + _ref$1 = Tu; + if ($assertType(_ref$1, ($ptrType(Basic)), true)[1]) { + t$1 = _ref$1.$val; + if (x.mode === 4) { + return representableConst(x.val, conf, t$1.kind, ($ptrType(exact.Value)).nil); } - } - if (i$1 === start) { - } else if (i$1 === (start + 1 >> 0)) { - out = $append(out, ((start < 0 || start >= sub.$length) ? $throwRuntimeError("index out of range") : sub.$array[sub.$offset + start])); - } else { - prefix$1 = first; - j$1 = start; - while (j$1 < i$1) { - reuse = !((j$1 === start)); - (j$1 < 0 || j$1 >= sub.$length) ? $throwRuntimeError("index out of range") : sub.$array[sub.$offset + j$1] = p.removeLeadingRegexp(((j$1 < 0 || j$1 >= sub.$length) ? $throwRuntimeError("index out of range") : sub.$array[sub.$offset + j$1]), reuse); - j$1 = j$1 + (1) >> 0; + _tuple$3 = $assertType(Vu, ($ptrType(Basic)), true); Vb = _tuple$3[0]; + if (!(Vb === ($ptrType(Basic)).nil)) { + return (Vb.kind === 19) && isBoolean(Tu); } - suffix$1 = p.collapse($subslice(sub, start, i$1), 19); - re$1 = p.newRegexp(18); - re$1.Sub = $append($subslice(re$1.Sub, 0, 0), prefix$1, suffix$1); - out = $append(out, re$1); + } else if ($assertType(_ref$1, ($ptrType(Interface)), true)[1]) { + t$1 = _ref$1.$val; + return x.isNil() || t$1.Empty(); + } else if ($assertType(_ref$1, ($ptrType(Pointer)), true)[1] || $assertType(_ref$1, ($ptrType(Signature)), true)[1] || $assertType(_ref$1, ($ptrType(Slice)), true)[1] || $assertType(_ref$1, ($ptrType(Map)), true)[1] || $assertType(_ref$1, ($ptrType(Chan)), true)[1]) { + t$1 = _ref$1; + return x.isNil(); } - start = i$1; - first = ifirst; - i$1 = i$1 + (1) >> 0; } - sub = out; - start = 0; - out = $subslice(sub, 0, 0); - i$2 = 0; - while (i$2 <= sub.$length) { - if (i$2 < sub.$length && isCharClass(((i$2 < 0 || i$2 >= sub.$length) ? $throwRuntimeError("index out of range") : sub.$array[sub.$offset + i$2]))) { - i$2 = i$2 + (1) >> 0; + return false; + }; + operand.prototype.assignableTo = function(conf, T) { return this.$val.assignableTo(conf, T); }; + operand.Ptr.prototype.isInteger = function() { + var x; + x = this; + return (x.mode === 0) || isInteger(x.typ) || (x.mode === 4) && representableConst(x.val, ($ptrType(Config)).nil, 20, ($ptrType(exact.Value)).nil); + }; + operand.prototype.isInteger = function() { return this.$val.isInteger(); }; + Checker.Ptr.prototype.resolveOrder = function() { + var check, _tmp, _tmp$1, ifaces, others, _ref, _i, _keys, _entry, obj, ityp, _ref$1, _i$1, f, _tuple, ident, embedded, _entry$1, order, _ref$2, _i$2, obj$1; + check = this; + _tmp = ($sliceType(Object)).nil; _tmp$1 = ($sliceType(Object)).nil; ifaces = _tmp; others = _tmp$1; + _ref = check.objMap; + _i = 0; + _keys = $keys(_ref); + while (_i < _keys.length) { + _entry = _ref[_keys[_i]]; + if (_entry === undefined) { + _i++; continue; } - if (i$2 === start) { - } else if (i$2 === (start + 1 >> 0)) { - out = $append(out, ((start < 0 || start >= sub.$length) ? $throwRuntimeError("index out of range") : sub.$array[sub.$offset + start])); - } else { - max = start; - j$2 = start + 1 >> 0; - while (j$2 < i$2) { - if (((max < 0 || max >= sub.$length) ? $throwRuntimeError("index out of range") : sub.$array[sub.$offset + max]).Op < ((j$2 < 0 || j$2 >= sub.$length) ? $throwRuntimeError("index out of range") : sub.$array[sub.$offset + j$2]).Op || (((max < 0 || max >= sub.$length) ? $throwRuntimeError("index out of range") : sub.$array[sub.$offset + max]).Op === ((j$2 < 0 || j$2 >= sub.$length) ? $throwRuntimeError("index out of range") : sub.$array[sub.$offset + j$2]).Op) && ((max < 0 || max >= sub.$length) ? $throwRuntimeError("index out of range") : sub.$array[sub.$offset + max]).Rune.$length < ((j$2 < 0 || j$2 >= sub.$length) ? $throwRuntimeError("index out of range") : sub.$array[sub.$offset + j$2]).Rune.$length) { - max = j$2; + obj = _entry.k; + ityp = check.interfaceFor(obj); + if (!(ityp === ($ptrType(ast.InterfaceType)).nil)) { + ifaces = $append(ifaces, obj); + _ref$1 = ityp.Methods.List; + _i$1 = 0; + while (_i$1 < _ref$1.$length) { + f = ((_i$1 < 0 || _i$1 >= _ref$1.$length) ? $throwRuntimeError("index out of range") : _ref$1.$array[_ref$1.$offset + _i$1]); + if (f.Names.$length === 0) { + _tuple = $assertType(f.Type, ($ptrType(ast.Ident)), true); ident = _tuple[0]; + if (!(ident === ($ptrType(ast.Ident)).nil)) { + embedded = check.pkg.scope.Lookup(ident.Name); + if (!(check.interfaceFor(embedded) === ($ptrType(ast.InterfaceType)).nil)) { + (_entry$1 = check.objMap[obj.$key()], _entry$1 !== undefined ? _entry$1.v : ($ptrType(declInfo)).nil).addDep(embedded); + } + } } - j$2 = j$2 + (1) >> 0; - } - _tmp = ((max < 0 || max >= sub.$length) ? $throwRuntimeError("index out of range") : sub.$array[sub.$offset + max]); _tmp$1 = ((start < 0 || start >= sub.$length) ? $throwRuntimeError("index out of range") : sub.$array[sub.$offset + start]); (start < 0 || start >= sub.$length) ? $throwRuntimeError("index out of range") : sub.$array[sub.$offset + start] = _tmp; (max < 0 || max >= sub.$length) ? $throwRuntimeError("index out of range") : sub.$array[sub.$offset + max] = _tmp$1; - j$3 = start + 1 >> 0; - while (j$3 < i$2) { - mergeCharClass(((start < 0 || start >= sub.$length) ? $throwRuntimeError("index out of range") : sub.$array[sub.$offset + start]), ((j$3 < 0 || j$3 >= sub.$length) ? $throwRuntimeError("index out of range") : sub.$array[sub.$offset + j$3])); - p.reuse(((j$3 < 0 || j$3 >= sub.$length) ? $throwRuntimeError("index out of range") : sub.$array[sub.$offset + j$3])); - j$3 = j$3 + (1) >> 0; + _i$1++; } - cleanAlt(((start < 0 || start >= sub.$length) ? $throwRuntimeError("index out of range") : sub.$array[sub.$offset + start])); - out = $append(out, ((start < 0 || start >= sub.$length) ? $throwRuntimeError("index out of range") : sub.$array[sub.$offset + start])); - } - if (i$2 < sub.$length) { - out = $append(out, ((i$2 < 0 || i$2 >= sub.$length) ? $throwRuntimeError("index out of range") : sub.$array[sub.$offset + i$2])); + } else { + others = $append(others, obj); } - start = i$2 + 1 >> 0; - i$2 = i$2 + (1) >> 0; + _i++; + } + order = ($sliceType(Object)).nil; + sort.Sort($subslice(new inSourceOrder(ifaces.$array), ifaces.$offset, ifaces.$offset + ifaces.$length)); + _ref$2 = ifaces; + _i$2 = 0; + while (_i$2 < _ref$2.$length) { + obj$1 = ((_i$2 < 0 || _i$2 >= _ref$2.$length) ? $throwRuntimeError("index out of range") : _ref$2.$array[_ref$2.$offset + _i$2]); + check.appendInPostOrder(new ($ptrType(($sliceType(Object))))(function() { return order; }, function($v) { order = $v; }), obj$1); + _i$2++; + } + sort.Sort($subslice(new inSourceOrder(others.$array), others.$offset, others.$offset + others.$length)); + return $appendSlice(order, others); + }; + Checker.prototype.resolveOrder = function() { return this.$val.resolveOrder(); }; + Checker.Ptr.prototype.interfaceFor = function(obj) { + var check, _tuple, tname, _entry, d, _tuple$1, ityp; + check = this; + _tuple = $assertType(obj, ($ptrType(TypeName)), true); tname = _tuple[0]; + if (tname === ($ptrType(TypeName)).nil) { + return ($ptrType(ast.InterfaceType)).nil; } - sub = out; - start = 0; - out = $subslice(sub, 0, 0); - _ref = sub; + d = (_entry = check.objMap[obj.$key()], _entry !== undefined ? _entry.v : ($ptrType(declInfo)).nil); + if (d === ($ptrType(declInfo)).nil) { + check.dump("%s: %s should have been declared", new ($sliceType($emptyInterface))([new token.Pos(obj.Pos()), new $String(obj.Name())])); + unreachable(); + } + if ($interfaceIsEqual(d.typ, $ifaceNil)) { + return ($ptrType(ast.InterfaceType)).nil; + } + _tuple$1 = $assertType(d.typ, ($ptrType(ast.InterfaceType)), true); ityp = _tuple$1[0]; + return ityp; + }; + Checker.prototype.interfaceFor = function(obj) { return this.$val.interfaceFor(obj); }; + Checker.Ptr.prototype.appendInPostOrder = function(order, obj) { + var check, _entry, d, _ref, _i, obj$1; + check = this; + d = (_entry = check.objMap[obj.$key()], _entry !== undefined ? _entry.v : ($ptrType(declInfo)).nil); + if (!((d.mark === 0))) { + return; + } + d.mark = 1; + _ref = orderedSetObjects(d.deps); _i = 0; while (_i < _ref.$length) { - i$3 = _i; - if ((i$3 + 1 >> 0) < sub.$length && (((i$3 < 0 || i$3 >= sub.$length) ? $throwRuntimeError("index out of range") : sub.$array[sub.$offset + i$3]).Op === 2) && ((x = i$3 + 1 >> 0, ((x < 0 || x >= sub.$length) ? $throwRuntimeError("index out of range") : sub.$array[sub.$offset + x])).Op === 2)) { + obj$1 = ((_i < 0 || _i >= _ref.$length) ? $throwRuntimeError("index out of range") : _ref.$array[_ref.$offset + _i]); + check.appendInPostOrder(order, obj$1); + _i++; + } + order.$set($append(order.$get(), obj)); + }; + Checker.prototype.appendInPostOrder = function(order, obj) { return this.$val.appendInPostOrder(order, obj); }; + orderedSetObjects = function(set) { + var list, i, _ref, _i, _keys, _entry, obj; + list = ($sliceType(Object)).make($keys(set).length); + i = 0; + _ref = set; + _i = 0; + _keys = $keys(_ref); + while (_i < _keys.length) { + _entry = _ref[_keys[_i]]; + if (_entry === undefined) { _i++; continue; } - out = $append(out, ((i$3 < 0 || i$3 >= sub.$length) ? $throwRuntimeError("index out of range") : sub.$array[sub.$offset + i$3])); + obj = _entry.k; + (i < 0 || i >= list.$length) ? $throwRuntimeError("index out of range") : list.$array[list.$offset + i] = obj; + i = i + (1) >> 0; _i++; } - sub = out; - return sub; + sort.Sort($subslice(new inSourceOrder(list.$array), list.$offset, list.$offset + list.$length)); + return list; }; - parser.prototype.factor = function(sub, flags) { return this.$val.factor(sub, flags); }; - parser.Ptr.prototype.leadingString = function(re) { - var p, x; - p = this; - if ((re.Op === 18) && re.Sub.$length > 0) { - re = (x = re.Sub, ((0 < 0 || 0 >= x.$length) ? $throwRuntimeError("index out of range") : x.$array[x.$offset + 0])); + inSourceOrder.prototype.Len = function() { + var a; + a = this; + return a.$length; + }; + $ptrType(inSourceOrder).prototype.Len = function() { return this.$get().Len(); }; + inSourceOrder.prototype.Less = function(i, j) { + var a; + a = this; + return ((i < 0 || i >= a.$length) ? $throwRuntimeError("index out of range") : a.$array[a.$offset + i]).order() < ((j < 0 || j >= a.$length) ? $throwRuntimeError("index out of range") : a.$array[a.$offset + j]).order(); + }; + $ptrType(inSourceOrder).prototype.Less = function(i, j) { return this.$get().Less(i, j); }; + inSourceOrder.prototype.Swap = function(i, j) { + var a, _tmp, _tmp$1; + a = this; + _tmp = ((j < 0 || j >= a.$length) ? $throwRuntimeError("index out of range") : a.$array[a.$offset + j]); _tmp$1 = ((i < 0 || i >= a.$length) ? $throwRuntimeError("index out of range") : a.$array[a.$offset + i]); (i < 0 || i >= a.$length) ? $throwRuntimeError("index out of range") : a.$array[a.$offset + i] = _tmp; (j < 0 || j >= a.$length) ? $throwRuntimeError("index out of range") : a.$array[a.$offset + j] = _tmp$1; + }; + $ptrType(inSourceOrder).prototype.Swap = function(i, j) { return this.$get().Swap(i, j); }; + NewPackage = $pkg.NewPackage = function(path$1, name) { + var scope; + if (name === "_") { + $panic(new $String("invalid package name _")); } - if (!((re.Op === 3))) { - return [($sliceType($Int32)).nil, 0]; + scope = NewScope($pkg.Universe, fmt.Sprintf("package %q", new ($sliceType($emptyInterface))([new $String(path$1)]))); + return new Package.Ptr(path$1, name, scope, false, ($sliceType(($ptrType(Package)))).nil, false); + }; + Package.Ptr.prototype.Path = function() { + var pkg; + pkg = this; + return pkg.path; + }; + Package.prototype.Path = function() { return this.$val.Path(); }; + Package.Ptr.prototype.Name = function() { + var pkg; + pkg = this; + return pkg.name; + }; + Package.prototype.Name = function() { return this.$val.Name(); }; + Package.Ptr.prototype.Scope = function() { + var pkg; + pkg = this; + return pkg.scope; + }; + Package.prototype.Scope = function() { return this.$val.Scope(); }; + Package.Ptr.prototype.Complete = function() { + var pkg; + pkg = this; + return pkg.complete; + }; + Package.prototype.Complete = function() { return this.$val.Complete(); }; + Package.Ptr.prototype.MarkComplete = function() { + var pkg; + pkg = this; + pkg.complete = true; + }; + Package.prototype.MarkComplete = function() { return this.$val.MarkComplete(); }; + Package.Ptr.prototype.Imports = function() { + var pkg; + pkg = this; + return pkg.imports; + }; + Package.prototype.Imports = function() { return this.$val.Imports(); }; + Package.Ptr.prototype.SetImports = function(list) { + var pkg; + pkg = this; + pkg.imports = list; + }; + Package.prototype.SetImports = function(list) { return this.$val.SetImports(list); }; + Package.Ptr.prototype.String = function() { + var pkg; + pkg = this; + return fmt.Sprintf("package %s (%q)", new ($sliceType($emptyInterface))([new $String(pkg.name), new $String(pkg.path)])); + }; + Package.prototype.String = function() { return this.$val.String(); }; + isNamed = function(typ) { + var _tuple, ok, _tuple$1, ok$1; + _tuple = $assertType(typ, ($ptrType(Basic)), true); ok = _tuple[1]; + if (ok) { + return ok; } - return [re.Rune, (re.Flags & 1) >>> 0]; + _tuple$1 = $assertType(typ, ($ptrType(Named)), true); ok$1 = _tuple$1[1]; + return ok$1; }; - parser.prototype.leadingString = function(re) { return this.$val.leadingString(re); }; - parser.Ptr.prototype.removeLeadingString = function(re, n) { - var p, x, sub, x$1, _ref, old, x$2; - p = this; - if ((re.Op === 18) && re.Sub.$length > 0) { - sub = (x = re.Sub, ((0 < 0 || 0 >= x.$length) ? $throwRuntimeError("index out of range") : x.$array[x.$offset + 0])); - sub = p.removeLeadingString(sub, n); - (x$1 = re.Sub, (0 < 0 || 0 >= x$1.$length) ? $throwRuntimeError("index out of range") : x$1.$array[x$1.$offset + 0] = sub); - if (sub.Op === 2) { - p.reuse(sub); - _ref = re.Sub.$length; - if (_ref === 0 || _ref === 1) { - re.Op = 2; - re.Sub = ($sliceType(($ptrType(Regexp)))).nil; - } else if (_ref === 2) { - old = re; - re = (x$2 = re.Sub, ((1 < 0 || 1 >= x$2.$length) ? $throwRuntimeError("index out of range") : x$2.$array[x$2.$offset + 1])); - p.reuse(old); - } else { - $copySlice(re.Sub, $subslice(re.Sub, 1)); - re.Sub = $subslice(re.Sub, 0, (re.Sub.$length - 1 >> 0)); + isBoolean = function(typ) { + var _tuple, t, ok; + _tuple = $assertType(typ.Underlying(), ($ptrType(Basic)), true); t = _tuple[0]; ok = _tuple[1]; + return ok && !(((t.info & 1) === 0)); + }; + isInteger = function(typ) { + var _tuple, t, ok; + _tuple = $assertType(typ.Underlying(), ($ptrType(Basic)), true); t = _tuple[0]; ok = _tuple[1]; + return ok && !(((t.info & 2) === 0)); + }; + isUnsigned = function(typ) { + var _tuple, t, ok; + _tuple = $assertType(typ.Underlying(), ($ptrType(Basic)), true); t = _tuple[0]; ok = _tuple[1]; + return ok && !(((t.info & 4) === 0)); + }; + isFloat = function(typ) { + var _tuple, t, ok; + _tuple = $assertType(typ.Underlying(), ($ptrType(Basic)), true); t = _tuple[0]; ok = _tuple[1]; + return ok && !(((t.info & 8) === 0)); + }; + isComplex = function(typ) { + var _tuple, t, ok; + _tuple = $assertType(typ.Underlying(), ($ptrType(Basic)), true); t = _tuple[0]; ok = _tuple[1]; + return ok && !(((t.info & 16) === 0)); + }; + isNumeric = function(typ) { + var _tuple, t, ok; + _tuple = $assertType(typ.Underlying(), ($ptrType(Basic)), true); t = _tuple[0]; ok = _tuple[1]; + return ok && !(((t.info & 26) === 0)); + }; + isString = function(typ) { + var _tuple, t, ok; + _tuple = $assertType(typ.Underlying(), ($ptrType(Basic)), true); t = _tuple[0]; ok = _tuple[1]; + return ok && !(((t.info & 32) === 0)); + }; + isTyped = function(typ) { + var _tuple, t, ok; + _tuple = $assertType(typ.Underlying(), ($ptrType(Basic)), true); t = _tuple[0]; ok = _tuple[1]; + return !ok || ((t.info & 64) === 0); + }; + isUntyped = function(typ) { + var _tuple, t, ok; + _tuple = $assertType(typ.Underlying(), ($ptrType(Basic)), true); t = _tuple[0]; ok = _tuple[1]; + return ok && !(((t.info & 64) === 0)); + }; + isOrdered = function(typ) { + var _tuple, t, ok; + _tuple = $assertType(typ.Underlying(), ($ptrType(Basic)), true); t = _tuple[0]; ok = _tuple[1]; + return ok && !(((t.info & 42) === 0)); + }; + isConstType = function(typ) { + var _tuple, t, ok; + _tuple = $assertType(typ.Underlying(), ($ptrType(Basic)), true); t = _tuple[0]; ok = _tuple[1]; + return ok && !(((t.info & 59) === 0)); + }; + isInterface = function(typ) { + var _tuple, ok; + _tuple = $assertType(typ.Underlying(), ($ptrType(Interface)), true); ok = _tuple[1]; + return ok; + }; + Comparable = $pkg.Comparable = function(T) { + var t, _ref, _ref$1, _i, f; + _ref = T.Underlying(); + if ($assertType(_ref, ($ptrType(Basic)), true)[1]) { + t = _ref.$val; + return !((t.kind === 25)); + } else if ($assertType(_ref, ($ptrType(Pointer)), true)[1] || $assertType(_ref, ($ptrType(Interface)), true)[1] || $assertType(_ref, ($ptrType(Chan)), true)[1]) { + t = _ref; + return true; + } else if ($assertType(_ref, ($ptrType(Struct)), true)[1]) { + t = _ref.$val; + _ref$1 = t.fields; + _i = 0; + while (_i < _ref$1.$length) { + f = ((_i < 0 || _i >= _ref$1.$length) ? $throwRuntimeError("index out of range") : _ref$1.$array[_ref$1.$offset + _i]); + if (!Comparable(f.object.typ)) { + return false; } + _i++; } - return re; - } - if (re.Op === 3) { - re.Rune = $subslice(re.Rune, 0, $copySlice(re.Rune, $subslice(re.Rune, n))); - if (re.Rune.$length === 0) { - re.Op = 2; - } + return true; + } else if ($assertType(_ref, ($ptrType(Array)), true)[1]) { + t = _ref.$val; + return Comparable(t.elem); } - return re; + return false; }; - parser.prototype.removeLeadingString = function(re, n) { return this.$val.removeLeadingString(re, n); }; - parser.Ptr.prototype.leadingRegexp = function(re) { - var p, x, sub; - p = this; - if (re.Op === 2) { - return ($ptrType(Regexp)).nil; - } - if ((re.Op === 18) && re.Sub.$length > 0) { - sub = (x = re.Sub, ((0 < 0 || 0 >= x.$length) ? $throwRuntimeError("index out of range") : x.$array[x.$offset + 0])); - if (sub.Op === 2) { - return ($ptrType(Regexp)).nil; - } - return sub; + hasNil = function(typ) { + var t, _ref; + _ref = typ.Underlying(); + if ($assertType(_ref, ($ptrType(Basic)), true)[1]) { + t = _ref.$val; + return t.kind === 18; + } else if ($assertType(_ref, ($ptrType(Slice)), true)[1] || $assertType(_ref, ($ptrType(Pointer)), true)[1] || $assertType(_ref, ($ptrType(Signature)), true)[1] || $assertType(_ref, ($ptrType(Interface)), true)[1] || $assertType(_ref, ($ptrType(Map)), true)[1] || $assertType(_ref, ($ptrType(Chan)), true)[1]) { + t = _ref; + return true; } - return re; + return false; }; - parser.prototype.leadingRegexp = function(re) { return this.$val.leadingRegexp(re); }; - parser.Ptr.prototype.removeLeadingRegexp = function(re, reuse) { - var p, x, _ref, old, x$1; + Identical = $pkg.Identical = function(x, y) { + return identical(x, y, ($ptrType(ifacePair)).nil); + }; + ifacePair.Ptr.prototype.identical = function(q) { + var p; p = this; - if ((re.Op === 18) && re.Sub.$length > 0) { - if (reuse) { - p.reuse((x = re.Sub, ((0 < 0 || 0 >= x.$length) ? $throwRuntimeError("index out of range") : x.$array[x.$offset + 0]))); - } - re.Sub = $subslice(re.Sub, 0, $copySlice(re.Sub, $subslice(re.Sub, 1))); - _ref = re.Sub.$length; - if (_ref === 0) { - re.Op = 2; - re.Sub = ($sliceType(($ptrType(Regexp)))).nil; - } else if (_ref === 1) { - old = re; - re = (x$1 = re.Sub, ((0 < 0 || 0 >= x$1.$length) ? $throwRuntimeError("index out of range") : x$1.$array[x$1.$offset + 0])); - p.reuse(old); - } - return re; - } - if (reuse) { - p.reuse(re); - } - return p.newRegexp(2); + return p.x === q.x && p.y === q.y || p.x === q.y && p.y === q.x; }; - parser.prototype.removeLeadingRegexp = function(re, reuse) { return this.$val.removeLeadingRegexp(re, reuse); }; - literalRegexp = function(s, flags) { - var re, _ref, _i, _rune, c; - re = new Regexp.Ptr(3, 0, ($sliceType(($ptrType(Regexp)))).nil, ($arrayType(($ptrType(Regexp)), 1)).zero(), ($sliceType($Int32)).nil, ($arrayType($Int32, 2)).zero(), 0, 0, 0, ""); - re.Flags = flags; - re.Rune = $subslice(new ($sliceType($Int32))(re.Rune0), 0, 0); - _ref = s; - _i = 0; - while (_i < _ref.length) { - _rune = $decodeRune(_ref, _i); - c = _rune[0]; - if (re.Rune.$length >= re.Rune.$capacity) { - re.Rune = new ($sliceType($Int32))($stringToRunes(s)); - break; - } - re.Rune = $append(re.Rune, c); - _i += _rune[1]; + ifacePair.prototype.identical = function(q) { return this.$val.identical(q); }; + identical = function(x, y, p) { + var x$1, _ref, _tuple, y$1, ok, _tuple$1, y$2, ok$1, x$2, x$3, _tuple$2, y$3, ok$2, _tuple$3, y$4, ok$3, _ref$1, _i, i, f, x$4, g, _tuple$4, y$5, ok$4, _tuple$5, y$6, ok$5, _ref$2, _i$1, i$1, v, x$5, w, _tuple$6, y$7, ok$6, _tuple$7, y$8, ok$7, a, b, q, _ref$3, _i$2, i$2, f$1, g$1, _tuple$8, y$9, ok$8, _tuple$9, y$10, ok$9, _tuple$10, y$11, ok$10; + if ($interfaceIsEqual(x, y)) { + return true; } - return re; - }; - Parse = $pkg.Parse = function(s, flags) { - var err, p, err$1, c, op, lastRepeat, t, repeat, _ref, _tuple, _lhs, _tuple$1, before, _ref$1, after, _tuple$2, before$1, _tuple$3, min, max, after$1, ok, _tuple$4, _ref$2, lit, i, re, _tuple$5, r, rest, err$2, _tuple$6, r$1, rest$1, _tuple$7, _tuple$8, n, x; - if (!((((flags & 2) >>> 0) === 0))) { - err = checkUTF8(s); - if (!($interfaceIsEqual(err, $ifaceNil))) { - return [($ptrType(Regexp)).nil, err]; + _ref = x; + if ($assertType(_ref, ($ptrType(Basic)), true)[1]) { + x$1 = _ref.$val; + _tuple = $assertType(y, ($ptrType(Basic)), true); y$1 = _tuple[0]; ok = _tuple[1]; + if (ok) { + return x$1.kind === y$1.kind; } - return [literalRegexp(s, flags), $ifaceNil]; - } - p = new parser.Ptr(); $copy(p, new parser.Ptr(), parser); - err$1 = $ifaceNil; - c = 0; - op = 0; - lastRepeat = ""; - p.flags = flags; - p.wholeRegexp = s; - t = s; - while (!(t === "")) { - repeat = ""; - _ref = t.charCodeAt(0); - BigSwitch: - switch (0) { default: if (_ref === 40) { - if (!((((p.flags & 64) >>> 0) === 0)) && t.length >= 2 && (t.charCodeAt(1) === 63)) { - _tuple = p.parsePerlFlags(t); t = _tuple[0]; err$1 = _tuple[1]; - if (!($interfaceIsEqual(err$1, $ifaceNil))) { - return [($ptrType(Regexp)).nil, err$1]; + } else if ($assertType(_ref, ($ptrType(Array)), true)[1]) { + x$1 = _ref.$val; + _tuple$1 = $assertType(y, ($ptrType(Array)), true); y$2 = _tuple$1[0]; ok$1 = _tuple$1[1]; + if (ok$1) { + return (x$2 = x$1.len, x$3 = y$2.len, (x$2.$high === x$3.$high && x$2.$low === x$3.$low)) && identical(x$1.elem, y$2.elem, p); + } + } else if ($assertType(_ref, ($ptrType(Slice)), true)[1]) { + x$1 = _ref.$val; + _tuple$2 = $assertType(y, ($ptrType(Slice)), true); y$3 = _tuple$2[0]; ok$2 = _tuple$2[1]; + if (ok$2) { + return identical(x$1.elem, y$3.elem, p); + } + } else if ($assertType(_ref, ($ptrType(Struct)), true)[1]) { + x$1 = _ref.$val; + _tuple$3 = $assertType(y, ($ptrType(Struct)), true); y$4 = _tuple$3[0]; ok$3 = _tuple$3[1]; + if (ok$3) { + if (x$1.NumFields() === y$4.NumFields()) { + _ref$1 = x$1.fields; + _i = 0; + while (_i < _ref$1.$length) { + i = _i; + f = ((_i < 0 || _i >= _ref$1.$length) ? $throwRuntimeError("index out of range") : _ref$1.$array[_ref$1.$offset + _i]); + g = (x$4 = y$4.fields, ((i < 0 || i >= x$4.$length) ? $throwRuntimeError("index out of range") : x$4.$array[x$4.$offset + i])); + if (!(f.anonymous === g.anonymous) || !(x$1.Tag(i) === y$4.Tag(i)) || !f.object.sameId(g.object.pkg, g.object.name) || !identical(f.object.typ, g.object.typ, p)) { + return false; + } + _i++; } - break; - } - p.numCap = p.numCap + (1) >> 0; - p.op(128).Cap = p.numCap; - t = t.substring(1); - } else if (_ref === 124) { - err$1 = p.parseVerticalBar(); - if (!($interfaceIsEqual(err$1, $ifaceNil))) { - return [($ptrType(Regexp)).nil, err$1]; - } - t = t.substring(1); - } else if (_ref === 41) { - err$1 = p.parseRightParen(); - if (!($interfaceIsEqual(err$1, $ifaceNil))) { - return [($ptrType(Regexp)).nil, err$1]; - } - t = t.substring(1); - } else if (_ref === 94) { - if (!((((p.flags & 16) >>> 0) === 0))) { - p.op(9); - } else { - p.op(7); - } - t = t.substring(1); - } else if (_ref === 36) { - if (!((((p.flags & 16) >>> 0) === 0))) { - _lhs = p.op(10); _lhs.Flags = (_lhs.Flags | (256)) >>> 0; - } else { - p.op(8); - } - t = t.substring(1); - } else if (_ref === 46) { - if (!((((p.flags & 8) >>> 0) === 0))) { - p.op(6); - } else { - p.op(5); - } - t = t.substring(1); - } else if (_ref === 91) { - _tuple$1 = p.parseClass(t); t = _tuple$1[0]; err$1 = _tuple$1[1]; - if (!($interfaceIsEqual(err$1, $ifaceNil))) { - return [($ptrType(Regexp)).nil, err$1]; - } - } else if (_ref === 42 || _ref === 43 || _ref === 63) { - before = t; - _ref$1 = t.charCodeAt(0); - if (_ref$1 === 42) { - op = 14; - } else if (_ref$1 === 43) { - op = 15; - } else if (_ref$1 === 63) { - op = 16; - } - after = t.substring(1); - _tuple$2 = p.repeat(op, 0, 0, before, after, lastRepeat); after = _tuple$2[0]; err$1 = _tuple$2[1]; - if (!($interfaceIsEqual(err$1, $ifaceNil))) { - return [($ptrType(Regexp)).nil, err$1]; - } - repeat = before; - t = after; - } else if (_ref === 123) { - op = 17; - before$1 = t; - _tuple$3 = p.parseRepeat(t); min = _tuple$3[0]; max = _tuple$3[1]; after$1 = _tuple$3[2]; ok = _tuple$3[3]; - if (!ok) { - p.literal(123); - t = t.substring(1); - break; - } - if (min < 0 || min > 1000 || max > 1000 || max >= 0 && min > max) { - return [($ptrType(Regexp)).nil, new Error.Ptr("invalid repeat count", before$1.substring(0, (before$1.length - after$1.length >> 0)))]; - } - _tuple$4 = p.repeat(op, min, max, before$1, after$1, lastRepeat); after$1 = _tuple$4[0]; err$1 = _tuple$4[1]; - if (!($interfaceIsEqual(err$1, $ifaceNil))) { - return [($ptrType(Regexp)).nil, err$1]; + return true; } - repeat = before$1; - t = after$1; - } else if (_ref === 92) { - if (!((((p.flags & 64) >>> 0) === 0)) && t.length >= 2) { - _ref$2 = t.charCodeAt(1); - if (_ref$2 === 65) { - p.op(9); - t = t.substring(2); - break BigSwitch; - } else if (_ref$2 === 98) { - p.op(11); - t = t.substring(2); - break BigSwitch; - } else if (_ref$2 === 66) { - p.op(12); - t = t.substring(2); - break BigSwitch; - } else if (_ref$2 === 67) { - return [($ptrType(Regexp)).nil, new Error.Ptr("invalid escape sequence", t.substring(0, 2))]; - } else if (_ref$2 === 81) { - lit = ""; - i = strings.Index(t, "\\E"); - if (i < 0) { - lit = t.substring(2); - t = ""; - } else { - lit = t.substring(2, i); - t = t.substring((i + 2 >> 0)); + } + } else if ($assertType(_ref, ($ptrType(Pointer)), true)[1]) { + x$1 = _ref.$val; + _tuple$4 = $assertType(y, ($ptrType(Pointer)), true); y$5 = _tuple$4[0]; ok$4 = _tuple$4[1]; + if (ok$4) { + return identical(x$1.base, y$5.base, p); + } + } else if ($assertType(_ref, ($ptrType(Tuple)), true)[1]) { + x$1 = _ref.$val; + _tuple$5 = $assertType(y, ($ptrType(Tuple)), true); y$6 = _tuple$5[0]; ok$5 = _tuple$5[1]; + if (ok$5) { + if (x$1.Len() === y$6.Len()) { + if (!(x$1 === ($ptrType(Tuple)).nil)) { + _ref$2 = x$1.vars; + _i$1 = 0; + while (_i$1 < _ref$2.$length) { + i$1 = _i$1; + v = ((_i$1 < 0 || _i$1 >= _ref$2.$length) ? $throwRuntimeError("index out of range") : _ref$2.$array[_ref$2.$offset + _i$1]); + w = (x$5 = y$6.vars, ((i$1 < 0 || i$1 >= x$5.$length) ? $throwRuntimeError("index out of range") : x$5.$array[x$5.$offset + i$1])); + if (!identical(v.object.typ, w.object.typ, p)) { + return false; + } + _i$1++; } - p.push(literalRegexp(lit, p.flags)); - break BigSwitch; - } else if (_ref$2 === 122) { - p.op(10); - t = t.substring(2); - break BigSwitch; } + return true; } - re = p.newRegexp(4); - re.Flags = p.flags; - if (t.length >= 2 && ((t.charCodeAt(1) === 112) || (t.charCodeAt(1) === 80))) { - _tuple$5 = p.parseUnicodeClass(t, $subslice(new ($sliceType($Int32))(re.Rune0), 0, 0)); r = _tuple$5[0]; rest = _tuple$5[1]; err$2 = _tuple$5[2]; - if (!($interfaceIsEqual(err$2, $ifaceNil))) { - return [($ptrType(Regexp)).nil, err$2]; + } + } else if ($assertType(_ref, ($ptrType(Signature)), true)[1]) { + x$1 = _ref.$val; + _tuple$6 = $assertType(y, ($ptrType(Signature)), true); y$7 = _tuple$6[0]; ok$6 = _tuple$6[1]; + if (ok$6) { + return x$1.variadic === y$7.variadic && identical(x$1.params, y$7.params, p) && identical(x$1.results, y$7.results, p); + } + } else if ($assertType(_ref, ($ptrType(Interface)), true)[1]) { + x$1 = _ref.$val; + _tuple$7 = $assertType(y, ($ptrType(Interface)), true); y$8 = _tuple$7[0]; ok$7 = _tuple$7[1]; + if (ok$7) { + a = x$1.allMethods; + b = y$8.allMethods; + if (a.$length === b.$length) { + q = new ifacePair.Ptr(x$1, y$8, p); + while (!(p === ($ptrType(ifacePair)).nil)) { + if (p.identical(q)) { + return true; + } + p = p.prev; } - if (!(r === ($sliceType($Int32)).nil)) { - re.Rune = r; - t = rest; - p.push(re); - break BigSwitch; + _ref$3 = a; + _i$2 = 0; + while (_i$2 < _ref$3.$length) { + i$2 = _i$2; + f$1 = ((_i$2 < 0 || _i$2 >= _ref$3.$length) ? $throwRuntimeError("index out of range") : _ref$3.$array[_ref$3.$offset + _i$2]); + g$1 = ((i$2 < 0 || i$2 >= b.$length) ? $throwRuntimeError("index out of range") : b.$array[b.$offset + i$2]); + if (!(f$1.object.Id() === g$1.object.Id()) || !identical(f$1.object.typ, g$1.object.typ, q)) { + return false; + } + _i$2++; } + return true; } - _tuple$6 = p.parsePerlClassEscape(t, $subslice(new ($sliceType($Int32))(re.Rune0), 0, 0)); r$1 = _tuple$6[0]; rest$1 = _tuple$6[1]; - if (!(r$1 === ($sliceType($Int32)).nil)) { - re.Rune = r$1; - t = rest$1; - p.push(re); - break BigSwitch; - } - p.reuse(re); - _tuple$7 = p.parseEscape(t); c = _tuple$7[0]; t = _tuple$7[1]; err$1 = _tuple$7[2]; - if (!($interfaceIsEqual(err$1, $ifaceNil))) { - return [($ptrType(Regexp)).nil, err$1]; - } - p.literal(c); - } else { - _tuple$8 = nextRune(t); c = _tuple$8[0]; t = _tuple$8[1]; err$1 = _tuple$8[2]; - if (!($interfaceIsEqual(err$1, $ifaceNil))) { - return [($ptrType(Regexp)).nil, err$1]; - } - p.literal(c); - } } - lastRepeat = repeat; + } + } else if ($assertType(_ref, ($ptrType(Map)), true)[1]) { + x$1 = _ref.$val; + _tuple$8 = $assertType(y, ($ptrType(Map)), true); y$9 = _tuple$8[0]; ok$8 = _tuple$8[1]; + if (ok$8) { + return identical(x$1.key, y$9.key, p) && identical(x$1.elem, y$9.elem, p); + } + } else if ($assertType(_ref, ($ptrType(Chan)), true)[1]) { + x$1 = _ref.$val; + _tuple$9 = $assertType(y, ($ptrType(Chan)), true); y$10 = _tuple$9[0]; ok$9 = _tuple$9[1]; + if (ok$9) { + return (x$1.dir === y$10.dir) && identical(x$1.elem, y$10.elem, p); + } + } else if ($assertType(_ref, ($ptrType(Named)), true)[1]) { + x$1 = _ref.$val; + _tuple$10 = $assertType(y, ($ptrType(Named)), true); y$11 = _tuple$10[0]; ok$10 = _tuple$10[1]; + if (ok$10) { + return x$1.obj === y$11.obj; + } + } else { + x$1 = _ref; + unreachable(); } - p.concat(); - if (p.swapVerticalBar()) { - p.stack = $subslice(p.stack, 0, (p.stack.$length - 1 >> 0)); + return false; + }; + defaultType = function(typ) { + var _tuple, t, ok, _ref; + _tuple = $assertType(typ, ($ptrType(Basic)), true); t = _tuple[0]; ok = _tuple[1]; + if (ok) { + _ref = t.kind; + if (_ref === 19) { + return $pkg.Typ[1]; + } else if (_ref === 20) { + return $pkg.Typ[2]; + } else if (_ref === 21) { + return $pkg.UniverseRune; + } else if (_ref === 22) { + return $pkg.Typ[14]; + } else if (_ref === 23) { + return $pkg.Typ[16]; + } else if (_ref === 24) { + return $pkg.Typ[17]; + } } - p.alternate(); - n = p.stack.$length; - if (!((n === 1))) { - return [($ptrType(Regexp)).nil, new Error.Ptr("missing closing )", s)]; + return typ; + }; + declInfo.Ptr.prototype.hasInitializer = function() { + var d; + d = this; + return !($interfaceIsEqual(d.init, $ifaceNil)) || !(d.fdecl === ($ptrType(ast.FuncDecl)).nil) && !(d.fdecl.Body === ($ptrType(ast.BlockStmt)).nil); + }; + declInfo.prototype.hasInitializer = function() { return this.$val.hasInitializer(); }; + declInfo.Ptr.prototype.addDep = function(obj) { + var d, m, _key$2; + d = this; + m = d.deps; + if (m === false) { + m = new $Map(); + d.deps = m; } - return [(x = p.stack, ((0 < 0 || 0 >= x.$length) ? $throwRuntimeError("index out of range") : x.$array[x.$offset + 0])), $ifaceNil]; + _key$2 = obj; (m || $throwRuntimeError("assignment to entry in nil map"))[_key$2.$key()] = { k: _key$2, v: true }; }; - parser.Ptr.prototype.parseRepeat = function(s) { - var min = 0, max = 0, rest = "", ok = false, p, ok1, _tuple, _tuple$1; - p = this; - if (s === "" || !((s.charCodeAt(0) === 123))) { - return [min, max, rest, ok]; + declInfo.prototype.addDep = function(obj) { return this.$val.addDep(obj); }; + Checker.Ptr.prototype.arityMatch = function(s, init$1) { + var check, l, r, x, n, x$1, n$1; + check = this; + l = s.Names.$length; + r = s.Values.$length; + if (!(init$1 === ($ptrType(ast.ValueSpec)).nil)) { + r = init$1.Values.$length; } - s = s.substring(1); - ok1 = false; - _tuple = p.parseInt(s); min = _tuple[0]; s = _tuple[1]; ok1 = _tuple[2]; - if (!ok1) { - return [min, max, rest, ok]; + if (init$1 === ($ptrType(ast.ValueSpec)).nil && (r === 0)) { + if ($interfaceIsEqual(s.Type, $ifaceNil)) { + check.errorf(s.Pos(), "missing type or init expr", new ($sliceType($emptyInterface))([])); + } + } else if (l < r) { + if (l < s.Values.$length) { + n = (x = s.Values, ((l < 0 || l >= x.$length) ? $throwRuntimeError("index out of range") : x.$array[x.$offset + l])); + check.errorf(n.Pos(), "extra init expr %s", new ($sliceType($emptyInterface))([n])); + } else { + check.errorf(s.Pos(), "extra init expr at %s", new ($sliceType($emptyInterface))([new token.Pos(init$1.Pos())])); + } + } else if (l > r && (!(init$1 === ($ptrType(ast.ValueSpec)).nil) || !((r === 1)))) { + n$1 = (x$1 = s.Names, ((r < 0 || r >= x$1.$length) ? $throwRuntimeError("index out of range") : x$1.$array[x$1.$offset + r])); + check.errorf(n$1.Pos(), "missing init expr for %s", new ($sliceType($emptyInterface))([n$1])); + } + }; + Checker.prototype.arityMatch = function(s, init$1) { return this.$val.arityMatch(s, init$1); }; + validatedImportPath = function(path$1) { + var _tuple, s, err, _ref, _i, _rune, r; + _tuple = strconv.Unquote(path$1); s = _tuple[0]; err = _tuple[1]; + if (!($interfaceIsEqual(err, $ifaceNil))) { + return ["", err]; } if (s === "") { - return [min, max, rest, ok]; + return ["", fmt.Errorf("empty string", new ($sliceType($emptyInterface))([]))]; } - if (!((s.charCodeAt(0) === 44))) { - max = min; - } else { - s = s.substring(1); - if (s === "") { - return [min, max, rest, ok]; - } - if (s.charCodeAt(0) === 125) { - max = -1; - } else { - _tuple$1 = p.parseInt(s); max = _tuple$1[0]; s = _tuple$1[1]; ok1 = _tuple$1[2]; - if (!ok1) { - return [min, max, rest, ok]; - } else if (max < 0) { - min = -1; - } + _ref = s; + _i = 0; + while (_i < _ref.length) { + _rune = $decodeRune(_ref, _i); + r = _rune[0]; + if (!unicode.IsGraphic(r) || unicode.IsSpace(r) || strings.ContainsRune("!\"#$%&'()*,:;<=>?[\\]^{|}`\xEF\xBF\xBD", r)) { + return [s, fmt.Errorf("invalid character %#U", new ($sliceType($emptyInterface))([new $Int32(r)]))]; } + _i += _rune[1]; } - if (s === "" || !((s.charCodeAt(0) === 125))) { - return [min, max, rest, ok]; + return [s, $ifaceNil]; + }; + Checker.Ptr.prototype.declarePkgObj = function(ident, obj, d) { + var check, _key$2; + check = this; + assert(ident.Name === obj.Name()); + if (ident.Name === "init") { + check.errorf(ident.Pos(), "cannot declare init - must be func", new ($sliceType($emptyInterface))([])); + return; } - rest = s.substring(1); - ok = true; - return [min, max, rest, ok]; + check.declare(check.pkg.scope, ident, obj); + _key$2 = obj; (check.objMap || $throwRuntimeError("assignment to entry in nil map"))[_key$2.$key()] = { k: _key$2, v: d }; + obj.setOrder(($keys(check.objMap).length >>> 0)); }; - parser.prototype.parseRepeat = function(s) { return this.$val.parseRepeat(s); }; - parser.Ptr.prototype.parsePerlFlags = function(s) { - var rest = "", err = $ifaceNil, p, t, end, _tmp, _tmp$1, _tmp$2, _tmp$3, capture, name, _tmp$4, _tmp$5, _tmp$6, _tmp$7, re, _tmp$8, _tmp$9, c, flags, sign, sawFlag, _tuple, _tmp$10, _tmp$11, _ref, _tmp$12, _tmp$13, _tmp$14, _tmp$15; - p = this; - t = s; - if (t.length > 4 && (t.charCodeAt(2) === 80) && (t.charCodeAt(3) === 60)) { - end = strings.IndexRune(t, 62); - if (end < 0) { - err = checkUTF8(t); - if (!($interfaceIsEqual(err, $ifaceNil))) { - _tmp = ""; _tmp$1 = err; rest = _tmp; err = _tmp$1; - return [rest, err]; - } - _tmp$2 = ""; _tmp$3 = new Error.Ptr("invalid named capture", s); rest = _tmp$2; err = _tmp$3; - return [rest, err]; - } - capture = t.substring(0, (end + 1 >> 0)); - name = t.substring(4, end); - err = checkUTF8(name); - if (!($interfaceIsEqual(err, $ifaceNil))) { - _tmp$4 = ""; _tmp$5 = err; rest = _tmp$4; err = _tmp$5; - return [rest, err]; - } - if (!isValidCaptureName(name)) { - _tmp$6 = ""; _tmp$7 = new Error.Ptr("invalid named capture", capture); rest = _tmp$6; err = _tmp$7; - return [rest, err]; + Checker.prototype.declarePkgObj = function(ident, obj, d) { return this.$val.declarePkgObj(ident, obj, d); }; + Checker.Ptr.prototype.collectObjects = function() { + var check, pkg, importer, pkgImports, _ref, _i, imp, _key$2, _ref$1, _i$1, fileNo, file, x, fileScope, _ref$2, _i$2, decl, d, _ref$3, last, _ref$4, _i$3, iota, spec, s, _ref$5, imp$1, _tuple, path$1, err, err$1, _tuple$1, _entry, _key$3, name, obj, _ref$6, _i$4, _keys, _entry$1, obj$1, x$1, posSet, x$2, _key$4, _ref$7, _ref$8, _i$5, i, name$1, obj$2, init$1, x$3, d$1, lhs, d1, x$4, _ref$9, _i$6, i$1, name$2, obj$3, d$2, init$2, x$5, obj$4, name$3, obj$5, list, typ, _tuple$2, ptr, _tuple$3, base, info, _key$5, _ref$10, _i$7, scope, _ref$11, _i$8, _keys$1, _entry$2, obj$6, alt, _tuple$4, pkg$1, ok; + check = this; + pkg = check.pkg; + importer = check.conf.Import; + if (importer === $throwNilPointerError) { + if ($pkg.DefaultImport === $throwNilPointerError) { + $panic(new $String("no Config.Import or DefaultImport (missing import _ \"code.google.com/p/go.tools/go/gcimporter\"?)")); } - p.numCap = p.numCap + (1) >> 0; - re = p.op(128); - re.Cap = p.numCap; - re.Name = name; - _tmp$8 = t.substring((end + 1 >> 0)); _tmp$9 = $ifaceNil; rest = _tmp$8; err = _tmp$9; - return [rest, err]; + importer = $pkg.DefaultImport; } - c = 0; - t = t.substring(2); - flags = p.flags; - sign = 1; - sawFlag = false; - Loop: - while (!(t === "")) { - _tuple = nextRune(t); c = _tuple[0]; t = _tuple[1]; err = _tuple[2]; - if (!($interfaceIsEqual(err, $ifaceNil))) { - _tmp$10 = ""; _tmp$11 = err; rest = _tmp$10; err = _tmp$11; - return [rest, err]; - } - _ref = c; - if (_ref === 105) { - flags = (flags | (1)) >>> 0; - sawFlag = true; - } else if (_ref === 109) { - flags = flags & ~(16); - sawFlag = true; - } else if (_ref === 115) { - flags = (flags | (8)) >>> 0; - sawFlag = true; - } else if (_ref === 85) { - flags = (flags | (32)) >>> 0; - sawFlag = true; - } else if (_ref === 45) { - if (sign < 0) { - break Loop; - } - sign = -1; - flags = ~flags << 16 >>> 16; - sawFlag = false; - } else if (_ref === 58 || _ref === 41) { - if (sign < 0) { - if (!sawFlag) { - break Loop; + pkgImports = new $Map(); + _ref = pkg.imports; + _i = 0; + while (_i < _ref.$length) { + imp = ((_i < 0 || _i >= _ref.$length) ? $throwRuntimeError("index out of range") : _ref.$array[_ref.$offset + _i]); + _key$2 = imp; (pkgImports || $throwRuntimeError("assignment to entry in nil map"))[_key$2.$key()] = { k: _key$2, v: true }; + _i++; + } + _ref$1 = check.files; + _i$1 = 0; + while (_i$1 < _ref$1.$length) { + fileNo = _i$1; + file = ((_i$1 < 0 || _i$1 >= _ref$1.$length) ? $throwRuntimeError("index out of range") : _ref$1.$array[_ref$1.$offset + _i$1]); + check.recordDef(file.Name, $ifaceNil); + fileScope = (x = check.fileScopes, ((fileNo < 0 || fileNo >= x.$length) ? $throwRuntimeError("index out of range") : x.$array[x.$offset + fileNo])); + _ref$2 = file.Decls; + _i$2 = 0; + while (_i$2 < _ref$2.$length) { + decl = ((_i$2 < 0 || _i$2 >= _ref$2.$length) ? $throwRuntimeError("index out of range") : _ref$2.$array[_ref$2.$offset + _i$2]); + _ref$3 = decl; + if ($assertType(_ref$3, ($ptrType(ast.BadDecl)), true)[1]) { + d = _ref$3.$val; + } else if ($assertType(_ref$3, ($ptrType(ast.GenDecl)), true)[1]) { + d = _ref$3.$val; + last = ($ptrType(ast.ValueSpec)).nil; + _ref$4 = d.Specs; + _i$3 = 0; + while (_i$3 < _ref$4.$length) { + iota = _i$3; + spec = ((_i$3 < 0 || _i$3 >= _ref$4.$length) ? $throwRuntimeError("index out of range") : _ref$4.$array[_ref$4.$offset + _i$3]); + _ref$5 = spec; + if ($assertType(_ref$5, ($ptrType(ast.ImportSpec)), true)[1]) { + s = _ref$5.$val; + imp$1 = ($ptrType(Package)).nil; + _tuple = validatedImportPath(s.Path.Value); path$1 = _tuple[0]; err = _tuple[1]; + if (!($interfaceIsEqual(err, $ifaceNil))) { + check.errorf(s.Path.Pos(), "invalid import path (%s)", new ($sliceType($emptyInterface))([err])); + _i$3++; + continue; + } + if (path$1 === "C" && check.conf.FakeImportC) { + imp$1 = NewPackage("C", "C"); + imp$1.fake = true; + } else { + err$1 = $ifaceNil; + _tuple$1 = importer(check.conf.Packages, path$1); imp$1 = _tuple$1[0]; err$1 = _tuple$1[1]; + if (imp$1 === ($ptrType(Package)).nil && $interfaceIsEqual(err$1, $ifaceNil)) { + err$1 = errors.New("Config.Import returned nil but no error"); + } + if (!($interfaceIsEqual(err$1, $ifaceNil))) { + check.errorf(s.Path.Pos(), "could not import %s (%s)", new ($sliceType($emptyInterface))([new $String(path$1), err$1])); + _i$3++; + continue; + } + } + if (!(_entry = pkgImports[imp$1.$key()], _entry !== undefined ? _entry.v : false)) { + _key$3 = imp$1; (pkgImports || $throwRuntimeError("assignment to entry in nil map"))[_key$3.$key()] = { k: _key$3, v: true }; + if (!(imp$1 === $pkg.Unsafe)) { + pkg.imports = $append(pkg.imports, imp$1); + } + } + name = imp$1.name; + if (!(s.Name === ($ptrType(ast.Ident)).nil)) { + name = s.Name.Name; + if (name === "init") { + check.errorf(s.Name.Pos(), "cannot declare init - must be func", new ($sliceType($emptyInterface))([])); + _i$3++; + continue; + } + } + obj = NewPkgName(s.Pos(), pkg, name, imp$1); + if (!(s.Name === ($ptrType(ast.Ident)).nil)) { + check.recordDef(s.Name, obj); + } else { + check.recordImplicit(s, obj); + } + if (name === ".") { + _ref$6 = imp$1.scope.elems; + _i$4 = 0; + _keys = $keys(_ref$6); + while (_i$4 < _keys.length) { + _entry$1 = _ref$6[_keys[_i$4]]; + if (_entry$1 === undefined) { + _i$4++; + continue; + } + obj$1 = _entry$1.v; + if (obj$1.Exported()) { + check.declare(fileScope, ($ptrType(ast.Ident)).nil, obj$1); + check.recordImplicit(s, obj$1); + } + _i$4++; + } + posSet = (x$1 = check.dotImports, ((fileNo < 0 || fileNo >= x$1.$length) ? $throwRuntimeError("index out of range") : x$1.$array[x$1.$offset + fileNo])); + if (posSet === false) { + posSet = new $Map(); + (x$2 = check.dotImports, (fileNo < 0 || fileNo >= x$2.$length) ? $throwRuntimeError("index out of range") : x$2.$array[x$2.$offset + fileNo] = posSet); + } + _key$4 = imp$1; (posSet || $throwRuntimeError("assignment to entry in nil map"))[_key$4.$key()] = { k: _key$4, v: s.Pos() }; + } else { + check.declare(fileScope, ($ptrType(ast.Ident)).nil, obj); + } + } else if ($assertType(_ref$5, ($ptrType(ast.ValueSpec)), true)[1]) { + s = _ref$5.$val; + _ref$7 = d.Tok; + if (_ref$7 === 64) { + if (!($interfaceIsEqual(s.Type, $ifaceNil)) || s.Values.$length > 0) { + last = s; + } else if (last === ($ptrType(ast.ValueSpec)).nil) { + last = new ast.ValueSpec.Ptr(); + } + _ref$8 = s.Names; + _i$5 = 0; + while (_i$5 < _ref$8.$length) { + i = _i$5; + name$1 = ((_i$5 < 0 || _i$5 >= _ref$8.$length) ? $throwRuntimeError("index out of range") : _ref$8.$array[_ref$8.$offset + _i$5]); + obj$2 = NewConst(name$1.Pos(), pkg, name$1.Name, $ifaceNil, exact.MakeInt64(new $Int64(0, iota))); + init$1 = $ifaceNil; + if (i < last.Values.$length) { + init$1 = (x$3 = last.Values, ((i < 0 || i >= x$3.$length) ? $throwRuntimeError("index out of range") : x$3.$array[x$3.$offset + i])); + } + d$1 = new declInfo.Ptr(fileScope, ($sliceType(($ptrType(Var)))).nil, last.Type, init$1, ($ptrType(ast.FuncDecl)).nil, false, 0); + check.declarePkgObj(name$1, obj$2, d$1); + _i$5++; + } + check.arityMatch(s, last); + } else if (_ref$7 === 85) { + lhs = ($sliceType(($ptrType(Var)))).make(s.Names.$length); + d1 = ($ptrType(declInfo)).nil; + if (s.Values.$length === 1) { + d1 = new declInfo.Ptr(fileScope, lhs, s.Type, (x$4 = s.Values, ((0 < 0 || 0 >= x$4.$length) ? $throwRuntimeError("index out of range") : x$4.$array[x$4.$offset + 0])), ($ptrType(ast.FuncDecl)).nil, false, 0); + } + _ref$9 = s.Names; + _i$6 = 0; + while (_i$6 < _ref$9.$length) { + i$1 = _i$6; + name$2 = ((_i$6 < 0 || _i$6 >= _ref$9.$length) ? $throwRuntimeError("index out of range") : _ref$9.$array[_ref$9.$offset + _i$6]); + obj$3 = NewVar(name$2.Pos(), pkg, name$2.Name, $ifaceNil); + (i$1 < 0 || i$1 >= lhs.$length) ? $throwRuntimeError("index out of range") : lhs.$array[lhs.$offset + i$1] = obj$3; + d$2 = d1; + if (d$2 === ($ptrType(declInfo)).nil) { + init$2 = $ifaceNil; + if (i$1 < s.Values.$length) { + init$2 = (x$5 = s.Values, ((i$1 < 0 || i$1 >= x$5.$length) ? $throwRuntimeError("index out of range") : x$5.$array[x$5.$offset + i$1])); + } + d$2 = new declInfo.Ptr(fileScope, ($sliceType(($ptrType(Var)))).nil, s.Type, init$2, ($ptrType(ast.FuncDecl)).nil, false, 0); + } + check.declarePkgObj(name$2, obj$3, d$2); + _i$6++; + } + check.arityMatch(s, ($ptrType(ast.ValueSpec)).nil); + } else { + check.invalidAST(s.Pos(), "invalid token %s", new ($sliceType($emptyInterface))([new token.Token(d.Tok)])); + } + } else if ($assertType(_ref$5, ($ptrType(ast.TypeSpec)), true)[1]) { + s = _ref$5.$val; + obj$4 = NewTypeName(s.Name.Pos(), pkg, s.Name.Name, $ifaceNil); + check.declarePkgObj(s.Name, obj$4, new declInfo.Ptr(fileScope, ($sliceType(($ptrType(Var)))).nil, s.Type, $ifaceNil, ($ptrType(ast.FuncDecl)).nil, false, 0)); + } else { + s = _ref$5; + check.invalidAST(s.Pos(), "unknown ast.Spec node %T", new ($sliceType($emptyInterface))([s])); + } + _i$3++; } - flags = ~flags << 16 >>> 16; + } else if ($assertType(_ref$3, ($ptrType(ast.FuncDecl)), true)[1]) { + d = _ref$3.$val; + name$3 = d.Name.Name; + obj$5 = NewFunc(d.Name.Pos(), pkg, name$3, ($ptrType(Signature)).nil); + if (d.Recv === ($ptrType(ast.FieldList)).nil) { + if (name$3 === "init") { + obj$5.object.parent = pkg.scope; + check.recordDef(d.Name, obj$5); + if (d.Body === ($ptrType(ast.BlockStmt)).nil) { + check.softErrorf(obj$5.object.pos, "missing function body", new ($sliceType($emptyInterface))([])); + } + } else { + check.declare(pkg.scope, d.Name, obj$5); + } + } else { + check.recordDef(d.Name, obj$5); + list = d.Recv.List; + if (list.$length > 0) { + typ = ((0 < 0 || 0 >= list.$length) ? $throwRuntimeError("index out of range") : list.$array[list.$offset + 0]).Type; + _tuple$2 = $assertType(typ, ($ptrType(ast.StarExpr)), true); ptr = _tuple$2[0]; + if (!(ptr === ($ptrType(ast.StarExpr)).nil)) { + typ = ptr.X; + } + _tuple$3 = $assertType(typ, ($ptrType(ast.Ident)), true); base = _tuple$3[0]; + if (!(base === ($ptrType(ast.Ident)).nil) && !(base.Name === "_")) { + check.assocMethod(base.Name, obj$5); + } + } + } + info = new declInfo.Ptr(fileScope, ($sliceType(($ptrType(Var)))).nil, $ifaceNil, $ifaceNil, d, false, 0); + _key$5 = obj$5; (check.objMap || $throwRuntimeError("assignment to entry in nil map"))[_key$5.$key()] = { k: _key$5, v: info }; + obj$5.object.setOrder(($keys(check.objMap).length >>> 0)); + } else { + d = _ref$3; + check.invalidAST(d.Pos(), "unknown ast.Decl node %T", new ($sliceType($emptyInterface))([d])); + } + _i$2++; + } + _i$1++; + } + _ref$10 = check.fileScopes; + _i$7 = 0; + while (_i$7 < _ref$10.$length) { + scope = ((_i$7 < 0 || _i$7 >= _ref$10.$length) ? $throwRuntimeError("index out of range") : _ref$10.$array[_ref$10.$offset + _i$7]); + _ref$11 = scope.elems; + _i$8 = 0; + _keys$1 = $keys(_ref$11); + while (_i$8 < _keys$1.length) { + _entry$2 = _ref$11[_keys$1[_i$8]]; + if (_entry$2 === undefined) { + _i$8++; + continue; } - if (c === 58) { - p.op(128); + obj$6 = _entry$2.v; + alt = pkg.scope.Lookup(obj$6.Name()); + if (!($interfaceIsEqual(alt, $ifaceNil))) { + _tuple$4 = $assertType(obj$6, ($ptrType(PkgName)), true); pkg$1 = _tuple$4[0]; ok = _tuple$4[1]; + if (ok) { + check.errorf(alt.Pos(), "%s already declared through import of %s", new ($sliceType($emptyInterface))([new $String(alt.Name()), pkg$1.Imported()])); + check.reportAltDecl(pkg$1); + } else { + check.errorf(alt.Pos(), "%s already declared through dot-import of %s", new ($sliceType($emptyInterface))([new $String(alt.Name()), obj$6.Pkg()])); + check.reportAltDecl(obj$6); + } } - p.flags = flags; - _tmp$12 = t; _tmp$13 = $ifaceNil; rest = _tmp$12; err = _tmp$13; - return [rest, err]; - } else { - break Loop; + _i$8++; } + _i$7++; } - _tmp$14 = ""; _tmp$15 = new Error.Ptr("invalid or unsupported Perl syntax", s.substring(0, (s.length - t.length >> 0))); rest = _tmp$14; err = _tmp$15; - return [rest, err]; }; - parser.prototype.parsePerlFlags = function(s) { return this.$val.parsePerlFlags(s); }; - isValidCaptureName = function(name) { - var _ref, _i, _rune, c; - if (name === "") { - return false; - } - _ref = name; + Checker.prototype.collectObjects = function() { return this.$val.collectObjects(); }; + Checker.Ptr.prototype.packageObjects = function(objList) { + var check, _ref, _i, obj, _tuple, obj$1, typePath, _ref$1, _i$1, obj$2; + check = this; + _ref = objList; _i = 0; - while (_i < _ref.length) { - _rune = $decodeRune(_ref, _i); - c = _rune[0]; - if (!((c === 95)) && !isalnum(c)) { - return false; + while (_i < _ref.$length) { + obj = ((_i < 0 || _i >= _ref.$length) ? $throwRuntimeError("index out of range") : _ref.$array[_ref.$offset + _i]); + _tuple = $assertType(obj, ($ptrType(TypeName)), true); obj$1 = _tuple[0]; + if (!(obj$1 === ($ptrType(TypeName)).nil) && !($interfaceIsEqual(obj$1.object.typ, $ifaceNil))) { + check.addMethodDecls(obj$1); } - _i += _rune[1]; + _i++; } - return true; - }; - parser.Ptr.prototype.parseInt = function(s) { - var n = 0, rest = "", ok = false, p, t, i; - p = this; - if (s === "" || s.charCodeAt(0) < 48 || 57 < s.charCodeAt(0)) { - return [n, rest, ok]; + typePath = ($sliceType(($ptrType(TypeName)))).make(0, 8); + _ref$1 = objList; + _i$1 = 0; + while (_i$1 < _ref$1.$length) { + obj$2 = ((_i$1 < 0 || _i$1 >= _ref$1.$length) ? $throwRuntimeError("index out of range") : _ref$1.$array[_ref$1.$offset + _i$1]); + check.objDecl(obj$2, ($ptrType(Named)).nil, typePath); + _i$1++; } - if (s.length >= 2 && (s.charCodeAt(0) === 48) && 48 <= s.charCodeAt(1) && s.charCodeAt(1) <= 57) { - return [n, rest, ok]; + check.methods = false; + }; + Checker.prototype.packageObjects = function(objList) { return this.$val.packageObjects(objList); }; + Checker.Ptr.prototype.functionBodies = function() { + var check, _ref, _i, f; + check = this; + _ref = check.funcs; + _i = 0; + while (_i < _ref.$length) { + f = new funcInfo.Ptr(); $copy(f, ((_i < 0 || _i >= _ref.$length) ? $throwRuntimeError("index out of range") : _ref.$array[_ref.$offset + _i]), funcInfo); + check.funcBody(f.decl, f.name, f.sig, f.body); + _i++; } - t = s; - while (!(s === "") && 48 <= s.charCodeAt(0) && s.charCodeAt(0) <= 57) { - s = s.substring(1); + }; + Checker.prototype.functionBodies = function() { return this.$val.functionBodies(); }; + Checker.Ptr.prototype.unusedImports = function() { + var check, _ref, _i, i, scope, usedDotImports, _ref$1, _i$1, _keys, _entry, obj, obj$1, _ref$2, path$1, base, _key$2, _ref$3, x, _i$2, _keys$1, _entry$1, pkg, pos, _entry$2; + check = this; + if (check.conf.IgnoreFuncBodies) { + return; } - rest = s; - ok = true; - t = t.substring(0, (t.length - s.length >> 0)); - i = 0; - while (i < t.length) { - if (n >= 100000000) { - n = -1; - break; + _ref = check.fileScopes; + _i = 0; + while (_i < _ref.$length) { + i = _i; + scope = ((_i < 0 || _i >= _ref.$length) ? $throwRuntimeError("index out of range") : _ref.$array[_ref.$offset + _i]); + usedDotImports = false; + _ref$1 = scope.elems; + _i$1 = 0; + _keys = $keys(_ref$1); + while (_i$1 < _keys.length) { + _entry = _ref$1[_keys[_i$1]]; + if (_entry === undefined) { + _i$1++; + continue; + } + obj = _entry.v; + _ref$2 = obj; + if ($assertType(_ref$2, ($ptrType(PkgName)), true)[1]) { + obj$1 = _ref$2.$val; + if (!obj$1.object.used) { + path$1 = obj$1.imported.path; + base = path.Base(path$1); + if (obj$1.object.name === base) { + check.softErrorf(obj$1.object.pos, "%q imported but not used", new ($sliceType($emptyInterface))([new $String(path$1)])); + } else { + check.softErrorf(obj$1.object.pos, "%q imported but not used as %s", new ($sliceType($emptyInterface))([new $String(path$1), new $String(obj$1.object.name)])); + } + } + } else { + obj$1 = _ref$2; + if (obj$1.isUsed()) { + if (usedDotImports === false) { + usedDotImports = new $Map(); + } + _key$2 = obj$1.Pkg(); (usedDotImports || $throwRuntimeError("assignment to entry in nil map"))[_key$2.$key()] = { k: _key$2, v: true }; + } + } + _i$1++; } - n = (((((n >>> 16 << 16) * 10 >> 0) + (n << 16 >>> 16) * 10) >> 0) + (t.charCodeAt(i) >> 0) >> 0) - 48 >> 0; - i = i + (1) >> 0; - } - return [n, rest, ok]; - }; - parser.prototype.parseInt = function(s) { return this.$val.parseInt(s); }; - isCharClass = function(re) { - return (re.Op === 3) && (re.Rune.$length === 1) || (re.Op === 4) || (re.Op === 5) || (re.Op === 6); - }; - matchRune = function(re, r) { - var _ref, x, i, x$1, x$2, x$3; - _ref = re.Op; - if (_ref === 3) { - return (re.Rune.$length === 1) && ((x = re.Rune, ((0 < 0 || 0 >= x.$length) ? $throwRuntimeError("index out of range") : x.$array[x.$offset + 0])) === r); - } else if (_ref === 4) { - i = 0; - while (i < re.Rune.$length) { - if ((x$1 = re.Rune, ((i < 0 || i >= x$1.$length) ? $throwRuntimeError("index out of range") : x$1.$array[x$1.$offset + i])) <= r && r <= (x$2 = re.Rune, x$3 = i + 1 >> 0, ((x$3 < 0 || x$3 >= x$2.$length) ? $throwRuntimeError("index out of range") : x$2.$array[x$2.$offset + x$3]))) { - return true; + _ref$3 = (x = check.dotImports, ((i < 0 || i >= x.$length) ? $throwRuntimeError("index out of range") : x.$array[x.$offset + i])); + _i$2 = 0; + _keys$1 = $keys(_ref$3); + while (_i$2 < _keys$1.length) { + _entry$1 = _ref$3[_keys$1[_i$2]]; + if (_entry$1 === undefined) { + _i$2++; + continue; } - i = i + (2) >> 0; + pkg = _entry$1.k; + pos = _entry$1.v; + if (!(_entry$2 = usedDotImports[pkg.$key()], _entry$2 !== undefined ? _entry$2.v : false)) { + check.softErrorf(pos, "%q imported but not used", new ($sliceType($emptyInterface))([new $String(pkg.path)])); + } + _i$2++; } - return false; - } else if (_ref === 5) { - return !((r === 10)); - } else if (_ref === 6) { - return true; - } - return false; - }; - parser.Ptr.prototype.parseVerticalBar = function() { - var p; - p = this; - p.concat(); - if (!p.swapVerticalBar()) { - p.op(129); + _i++; } - return $ifaceNil; }; - parser.prototype.parseVerticalBar = function() { return this.$val.parseVerticalBar(); }; - mergeCharClass = function(dst, src) { - var _ref, x, x$1, x$2, x$3, x$4; - _ref = dst.Op; - switch (0) { default: if (_ref === 6) { - } else if (_ref === 5) { - if (matchRune(src, 10)) { - dst.Op = 6; + Checker.prototype.unusedImports = function() { return this.$val.unusedImports(); }; + Checker.Ptr.prototype.isTerminating = function(s, label) { + var check, s$1, _ref, _tuple, call, _tuple$1, id, obj, _tuple$2, b, _ref$1, _i, s$2, cc; + check = this; + _ref = s; + if ($assertType(_ref, ($ptrType(ast.BadStmt)), true)[1] || $assertType(_ref, ($ptrType(ast.DeclStmt)), true)[1] || $assertType(_ref, ($ptrType(ast.EmptyStmt)), true)[1] || $assertType(_ref, ($ptrType(ast.SendStmt)), true)[1] || $assertType(_ref, ($ptrType(ast.IncDecStmt)), true)[1] || $assertType(_ref, ($ptrType(ast.AssignStmt)), true)[1] || $assertType(_ref, ($ptrType(ast.GoStmt)), true)[1] || $assertType(_ref, ($ptrType(ast.DeferStmt)), true)[1] || $assertType(_ref, ($ptrType(ast.RangeStmt)), true)[1]) { + s$1 = _ref; + } else if ($assertType(_ref, ($ptrType(ast.LabeledStmt)), true)[1]) { + s$1 = _ref.$val; + return check.isTerminating(s$1.Stmt, s$1.Label.Name); + } else if ($assertType(_ref, ($ptrType(ast.ExprStmt)), true)[1]) { + s$1 = _ref.$val; + _tuple = $assertType(unparen(s$1.X), ($ptrType(ast.CallExpr)), true); call = _tuple[0]; + if (!(call === ($ptrType(ast.CallExpr)).nil)) { + _tuple$1 = $assertType(call.Fun, ($ptrType(ast.Ident)), true); id = _tuple$1[0]; + if (!(id === ($ptrType(ast.Ident)).nil)) { + obj = check.context.scope.LookupParent(id.Name); + if (!($interfaceIsEqual(obj, $ifaceNil))) { + _tuple$2 = $assertType(obj, ($ptrType(Builtin)), true); b = _tuple$2[0]; + if (!(b === ($ptrType(Builtin)).nil) && (b.id === 10)) { + return true; + } + } + } } - } else if (_ref === 4) { - if (src.Op === 3) { - dst.Rune = appendLiteral(dst.Rune, (x = src.Rune, ((0 < 0 || 0 >= x.$length) ? $throwRuntimeError("index out of range") : x.$array[x.$offset + 0])), src.Flags); - } else { - dst.Rune = appendClass(dst.Rune, src.Rune); + } else if ($assertType(_ref, ($ptrType(ast.ReturnStmt)), true)[1]) { + s$1 = _ref.$val; + return true; + } else if ($assertType(_ref, ($ptrType(ast.BranchStmt)), true)[1]) { + s$1 = _ref.$val; + if ((s$1.Tok === 73) || (s$1.Tok === 69)) { + return true; } - } else if (_ref === 3) { - if (((x$1 = src.Rune, ((0 < 0 || 0 >= x$1.$length) ? $throwRuntimeError("index out of range") : x$1.$array[x$1.$offset + 0])) === (x$2 = dst.Rune, ((0 < 0 || 0 >= x$2.$length) ? $throwRuntimeError("index out of range") : x$2.$array[x$2.$offset + 0]))) && (src.Flags === dst.Flags)) { - break; + } else if ($assertType(_ref, ($ptrType(ast.BlockStmt)), true)[1]) { + s$1 = _ref.$val; + return check.isTerminatingList(s$1.List, ""); + } else if ($assertType(_ref, ($ptrType(ast.IfStmt)), true)[1]) { + s$1 = _ref.$val; + if (!($interfaceIsEqual(s$1.Else, $ifaceNil)) && check.isTerminating(s$1.Body, "") && check.isTerminating(s$1.Else, "")) { + return true; } - dst.Op = 4; - dst.Rune = appendLiteral($subslice(dst.Rune, 0, 0), (x$3 = dst.Rune, ((0 < 0 || 0 >= x$3.$length) ? $throwRuntimeError("index out of range") : x$3.$array[x$3.$offset + 0])), dst.Flags); - dst.Rune = appendLiteral(dst.Rune, (x$4 = src.Rune, ((0 < 0 || 0 >= x$4.$length) ? $throwRuntimeError("index out of range") : x$4.$array[x$4.$offset + 0])), src.Flags); - } } - }; - parser.Ptr.prototype.swapVerticalBar = function() { - var p, n, x, x$1, x$2, x$3, x$4, x$5, x$6, x$7, re1, x$8, x$9, re3, _tmp, _tmp$1, x$10, x$11, x$12, x$13, re1$1, x$14, x$15, re2, x$16, x$17, x$18, x$19, x$20, x$21; - p = this; - n = p.stack.$length; - if (n >= 3 && ((x = p.stack, x$1 = n - 2 >> 0, ((x$1 < 0 || x$1 >= x.$length) ? $throwRuntimeError("index out of range") : x.$array[x.$offset + x$1])).Op === 129) && isCharClass((x$2 = p.stack, x$3 = n - 1 >> 0, ((x$3 < 0 || x$3 >= x$2.$length) ? $throwRuntimeError("index out of range") : x$2.$array[x$2.$offset + x$3]))) && isCharClass((x$4 = p.stack, x$5 = n - 3 >> 0, ((x$5 < 0 || x$5 >= x$4.$length) ? $throwRuntimeError("index out of range") : x$4.$array[x$4.$offset + x$5])))) { - re1 = (x$6 = p.stack, x$7 = n - 1 >> 0, ((x$7 < 0 || x$7 >= x$6.$length) ? $throwRuntimeError("index out of range") : x$6.$array[x$6.$offset + x$7])); - re3 = (x$8 = p.stack, x$9 = n - 3 >> 0, ((x$9 < 0 || x$9 >= x$8.$length) ? $throwRuntimeError("index out of range") : x$8.$array[x$8.$offset + x$9])); - if (re1.Op > re3.Op) { - _tmp = re3; _tmp$1 = re1; re1 = _tmp; re3 = _tmp$1; - (x$10 = p.stack, x$11 = n - 3 >> 0, (x$11 < 0 || x$11 >= x$10.$length) ? $throwRuntimeError("index out of range") : x$10.$array[x$10.$offset + x$11] = re3); + } else if ($assertType(_ref, ($ptrType(ast.SwitchStmt)), true)[1]) { + s$1 = _ref.$val; + return check.isTerminatingSwitch(s$1.Body, label); + } else if ($assertType(_ref, ($ptrType(ast.TypeSwitchStmt)), true)[1]) { + s$1 = _ref.$val; + return check.isTerminatingSwitch(s$1.Body, label); + } else if ($assertType(_ref, ($ptrType(ast.SelectStmt)), true)[1]) { + s$1 = _ref.$val; + _ref$1 = s$1.Body.List; + _i = 0; + while (_i < _ref$1.$length) { + s$2 = ((_i < 0 || _i >= _ref$1.$length) ? $throwRuntimeError("index out of range") : _ref$1.$array[_ref$1.$offset + _i]); + cc = $assertType(s$2, ($ptrType(ast.CommClause))); + if (!check.isTerminatingList(cc.Body, "") || hasBreakList(cc.Body, label, true)) { + return false; + } + _i++; } - mergeCharClass(re3, re1); - p.reuse(re1); - p.stack = $subslice(p.stack, 0, (n - 1 >> 0)); return true; - } - if (n >= 2) { - re1$1 = (x$12 = p.stack, x$13 = n - 1 >> 0, ((x$13 < 0 || x$13 >= x$12.$length) ? $throwRuntimeError("index out of range") : x$12.$array[x$12.$offset + x$13])); - re2 = (x$14 = p.stack, x$15 = n - 2 >> 0, ((x$15 < 0 || x$15 >= x$14.$length) ? $throwRuntimeError("index out of range") : x$14.$array[x$14.$offset + x$15])); - if (re2.Op === 129) { - if (n >= 3) { - cleanAlt((x$16 = p.stack, x$17 = n - 3 >> 0, ((x$17 < 0 || x$17 >= x$16.$length) ? $throwRuntimeError("index out of range") : x$16.$array[x$16.$offset + x$17]))); - } - (x$18 = p.stack, x$19 = n - 2 >> 0, (x$19 < 0 || x$19 >= x$18.$length) ? $throwRuntimeError("index out of range") : x$18.$array[x$18.$offset + x$19] = re1$1); - (x$20 = p.stack, x$21 = n - 1 >> 0, (x$21 < 0 || x$21 >= x$20.$length) ? $throwRuntimeError("index out of range") : x$20.$array[x$20.$offset + x$21] = re2); + } else if ($assertType(_ref, ($ptrType(ast.ForStmt)), true)[1]) { + s$1 = _ref.$val; + if ($interfaceIsEqual(s$1.Cond, $ifaceNil) && !hasBreak(s$1.Body, label, true)) { return true; } + } else { + s$1 = _ref; + unreachable(); } return false; }; - parser.prototype.swapVerticalBar = function() { return this.$val.swapVerticalBar(); }; - parser.Ptr.prototype.parseRightParen = function() { - var p, n, x, x$1, re1, x$2, x$3, re2, x$4; - p = this; - p.concat(); - if (p.swapVerticalBar()) { - p.stack = $subslice(p.stack, 0, (p.stack.$length - 1 >> 0)); - } - p.alternate(); - n = p.stack.$length; - if (n < 2) { - return new Error.Ptr("unexpected )", p.wholeRegexp); - } - re1 = (x = p.stack, x$1 = n - 1 >> 0, ((x$1 < 0 || x$1 >= x.$length) ? $throwRuntimeError("index out of range") : x.$array[x.$offset + x$1])); - re2 = (x$2 = p.stack, x$3 = n - 2 >> 0, ((x$3 < 0 || x$3 >= x$2.$length) ? $throwRuntimeError("index out of range") : x$2.$array[x$2.$offset + x$3])); - p.stack = $subslice(p.stack, 0, (n - 2 >> 0)); - if (!((re2.Op === 128))) { - return new Error.Ptr("unexpected )", p.wholeRegexp); - } - p.flags = re2.Flags; - if (re2.Cap === 0) { - p.push(re1); - } else { - re2.Op = 13; - re2.Sub = $subslice(new ($sliceType(($ptrType(Regexp))))(re2.Sub0), 0, 1); - (x$4 = re2.Sub, (0 < 0 || 0 >= x$4.$length) ? $throwRuntimeError("index out of range") : x$4.$array[x$4.$offset + 0] = re1); - p.push(re2); - } - return $ifaceNil; + Checker.prototype.isTerminating = function(s, label) { return this.$val.isTerminating(s, label); }; + Checker.Ptr.prototype.isTerminatingList = function(list, label) { + var check, n, x; + check = this; + n = list.$length; + return n > 0 && check.isTerminating((x = n - 1 >> 0, ((x < 0 || x >= list.$length) ? $throwRuntimeError("index out of range") : list.$array[list.$offset + x])), label); }; - parser.prototype.parseRightParen = function() { return this.$val.parseRightParen(); }; - parser.Ptr.prototype.parseEscape = function(s) { - var r = 0, rest = "", err = $ifaceNil, p, t, _tmp, _tmp$1, _tmp$2, _tuple, c, _tmp$3, _tmp$4, _tmp$5, _ref, i, _tmp$6, _tmp$7, _tmp$8, _tmp$9, _tmp$10, _tmp$11, _tuple$1, _tmp$12, _tmp$13, _tmp$14, nhex, _tuple$2, _tmp$15, _tmp$16, _tmp$17, v, _tmp$18, _tmp$19, _tmp$20, x, _tuple$3, _tmp$21, _tmp$22, _tmp$23, y, _tmp$24, _tmp$25, _tmp$26, _tmp$27, _tmp$28, _tmp$29, _tmp$30, _tmp$31, _tmp$32, _tmp$33, _tmp$34, _tmp$35, _tmp$36, _tmp$37, _tmp$38, _tmp$39, _tmp$40, _tmp$41, _tmp$42, _tmp$43, _tmp$44, _tmp$45, _tmp$46, _tmp$47, _tmp$48, _tmp$49, _tmp$50; - p = this; - t = s.substring(1); - if (t === "") { - _tmp = 0; _tmp$1 = ""; _tmp$2 = new Error.Ptr("trailing backslash at end of expression", ""); r = _tmp; rest = _tmp$1; err = _tmp$2; - return [r, rest, err]; - } - _tuple = nextRune(t); c = _tuple[0]; t = _tuple[1]; err = _tuple[2]; - if (!($interfaceIsEqual(err, $ifaceNil))) { - _tmp$3 = 0; _tmp$4 = ""; _tmp$5 = err; r = _tmp$3; rest = _tmp$4; err = _tmp$5; - return [r, rest, err]; - } - _ref = c; - Switch: - switch (0) { default: if (_ref === 49 || _ref === 50 || _ref === 51 || _ref === 52 || _ref === 53 || _ref === 54 || _ref === 55) { - if (t === "" || t.charCodeAt(0) < 48 || t.charCodeAt(0) > 55) { - break; - } - r = c - 48 >> 0; - i = 1; - while (i < 3) { - if (t === "" || t.charCodeAt(0) < 48 || t.charCodeAt(0) > 55) { - break; - } - r = (((((r >>> 16 << 16) * 8 >> 0) + (r << 16 >>> 16) * 8) >> 0) + (t.charCodeAt(0) >> 0) >> 0) - 48 >> 0; - t = t.substring(1); - i = i + (1) >> 0; - } - _tmp$6 = r; _tmp$7 = t; _tmp$8 = $ifaceNil; r = _tmp$6; rest = _tmp$7; err = _tmp$8; - return [r, rest, err]; - } else if (_ref === 48) { - r = c - 48 >> 0; - i = 1; - while (i < 3) { - if (t === "" || t.charCodeAt(0) < 48 || t.charCodeAt(0) > 55) { - break; - } - r = (((((r >>> 16 << 16) * 8 >> 0) + (r << 16 >>> 16) * 8) >> 0) + (t.charCodeAt(0) >> 0) >> 0) - 48 >> 0; - t = t.substring(1); - i = i + (1) >> 0; - } - _tmp$9 = r; _tmp$10 = t; _tmp$11 = $ifaceNil; r = _tmp$9; rest = _tmp$10; err = _tmp$11; - return [r, rest, err]; - } else if (_ref === 120) { - if (t === "") { - break; + Checker.prototype.isTerminatingList = function(list, label) { return this.$val.isTerminatingList(list, label); }; + Checker.Ptr.prototype.isTerminatingSwitch = function(body, label) { + var check, hasDefault, _ref, _i, s, cc; + check = this; + hasDefault = false; + _ref = body.List; + _i = 0; + while (_i < _ref.$length) { + s = ((_i < 0 || _i >= _ref.$length) ? $throwRuntimeError("index out of range") : _ref.$array[_ref.$offset + _i]); + cc = $assertType(s, ($ptrType(ast.CaseClause))); + if (cc.List === ($sliceType(ast.Expr)).nil) { + hasDefault = true; } - _tuple$1 = nextRune(t); c = _tuple$1[0]; t = _tuple$1[1]; err = _tuple$1[2]; - if (!($interfaceIsEqual(err, $ifaceNil))) { - _tmp$12 = 0; _tmp$13 = ""; _tmp$14 = err; r = _tmp$12; rest = _tmp$13; err = _tmp$14; - return [r, rest, err]; + if (!check.isTerminatingList(cc.Body, "") || hasBreakList(cc.Body, label, true)) { + return false; } - if (c === 123) { - nhex = 0; - r = 0; - while (true) { - if (t === "") { - break Switch; - } - _tuple$2 = nextRune(t); c = _tuple$2[0]; t = _tuple$2[1]; err = _tuple$2[2]; - if (!($interfaceIsEqual(err, $ifaceNil))) { - _tmp$15 = 0; _tmp$16 = ""; _tmp$17 = err; r = _tmp$15; rest = _tmp$16; err = _tmp$17; - return [r, rest, err]; - } - if (c === 125) { - break; - } - v = unhex(c); - if (v < 0) { - break Switch; - } - r = ((((r >>> 16 << 16) * 16 >> 0) + (r << 16 >>> 16) * 16) >> 0) + v >> 0; - if (r > 1114111) { - break Switch; - } - nhex = nhex + (1) >> 0; + _i++; + } + return hasDefault; + }; + Checker.prototype.isTerminatingSwitch = function(body, label) { return this.$val.isTerminatingSwitch(body, label); }; + hasBreak = function(s, label, implicit) { + var s$1, _ref; + _ref = s; + if ($assertType(_ref, ($ptrType(ast.BadStmt)), true)[1] || $assertType(_ref, ($ptrType(ast.DeclStmt)), true)[1] || $assertType(_ref, ($ptrType(ast.EmptyStmt)), true)[1] || $assertType(_ref, ($ptrType(ast.ExprStmt)), true)[1] || $assertType(_ref, ($ptrType(ast.SendStmt)), true)[1] || $assertType(_ref, ($ptrType(ast.IncDecStmt)), true)[1] || $assertType(_ref, ($ptrType(ast.AssignStmt)), true)[1] || $assertType(_ref, ($ptrType(ast.GoStmt)), true)[1] || $assertType(_ref, ($ptrType(ast.DeferStmt)), true)[1] || $assertType(_ref, ($ptrType(ast.ReturnStmt)), true)[1]) { + s$1 = _ref; + } else if ($assertType(_ref, ($ptrType(ast.LabeledStmt)), true)[1]) { + s$1 = _ref.$val; + return hasBreak(s$1.Stmt, label, implicit); + } else if ($assertType(_ref, ($ptrType(ast.BranchStmt)), true)[1]) { + s$1 = _ref.$val; + if (s$1.Tok === 61) { + if (s$1.Label === ($ptrType(ast.Ident)).nil) { + return implicit; } - if (nhex === 0) { - break Switch; + if (s$1.Label.Name === label) { + return true; } - _tmp$18 = r; _tmp$19 = t; _tmp$20 = $ifaceNil; r = _tmp$18; rest = _tmp$19; err = _tmp$20; - return [r, rest, err]; } - x = unhex(c); - _tuple$3 = nextRune(t); c = _tuple$3[0]; t = _tuple$3[1]; err = _tuple$3[2]; - if (!($interfaceIsEqual(err, $ifaceNil))) { - _tmp$21 = 0; _tmp$22 = ""; _tmp$23 = err; r = _tmp$21; rest = _tmp$22; err = _tmp$23; - return [r, rest, err]; + } else if ($assertType(_ref, ($ptrType(ast.BlockStmt)), true)[1]) { + s$1 = _ref.$val; + return hasBreakList(s$1.List, label, implicit); + } else if ($assertType(_ref, ($ptrType(ast.IfStmt)), true)[1]) { + s$1 = _ref.$val; + if (hasBreak(s$1.Body, label, implicit) || !($interfaceIsEqual(s$1.Else, $ifaceNil)) && hasBreak(s$1.Else, label, implicit)) { + return true; } - y = unhex(c); - if (x < 0 || y < 0) { - break; + } else if ($assertType(_ref, ($ptrType(ast.CaseClause)), true)[1]) { + s$1 = _ref.$val; + return hasBreakList(s$1.Body, label, implicit); + } else if ($assertType(_ref, ($ptrType(ast.SwitchStmt)), true)[1]) { + s$1 = _ref.$val; + if (!(label === "") && hasBreak(s$1.Body, label, false)) { + return true; } - _tmp$24 = ((((x >>> 16 << 16) * 16 >> 0) + (x << 16 >>> 16) * 16) >> 0) + y >> 0; _tmp$25 = t; _tmp$26 = $ifaceNil; r = _tmp$24; rest = _tmp$25; err = _tmp$26; - return [r, rest, err]; - } else if (_ref === 97) { - _tmp$27 = 7; _tmp$28 = t; _tmp$29 = err; r = _tmp$27; rest = _tmp$28; err = _tmp$29; - return [r, rest, err]; - } else if (_ref === 102) { - _tmp$30 = 12; _tmp$31 = t; _tmp$32 = err; r = _tmp$30; rest = _tmp$31; err = _tmp$32; - return [r, rest, err]; - } else if (_ref === 110) { - _tmp$33 = 10; _tmp$34 = t; _tmp$35 = err; r = _tmp$33; rest = _tmp$34; err = _tmp$35; - return [r, rest, err]; - } else if (_ref === 114) { - _tmp$36 = 13; _tmp$37 = t; _tmp$38 = err; r = _tmp$36; rest = _tmp$37; err = _tmp$38; - return [r, rest, err]; - } else if (_ref === 116) { - _tmp$39 = 9; _tmp$40 = t; _tmp$41 = err; r = _tmp$39; rest = _tmp$40; err = _tmp$41; - return [r, rest, err]; - } else if (_ref === 118) { - _tmp$42 = 11; _tmp$43 = t; _tmp$44 = err; r = _tmp$42; rest = _tmp$43; err = _tmp$44; - return [r, rest, err]; - } else { - if (c < 128 && !isalnum(c)) { - _tmp$45 = c; _tmp$46 = t; _tmp$47 = $ifaceNil; r = _tmp$45; rest = _tmp$46; err = _tmp$47; - return [r, rest, err]; + } else if ($assertType(_ref, ($ptrType(ast.TypeSwitchStmt)), true)[1]) { + s$1 = _ref.$val; + if (!(label === "") && hasBreak(s$1.Body, label, false)) { + return true; } - } } - _tmp$48 = 0; _tmp$49 = ""; _tmp$50 = new Error.Ptr("invalid escape sequence", s.substring(0, (s.length - t.length >> 0))); r = _tmp$48; rest = _tmp$49; err = _tmp$50; - return [r, rest, err]; - }; - parser.prototype.parseEscape = function(s) { return this.$val.parseEscape(s); }; - parser.Ptr.prototype.parseClassChar = function(s, wholeClass) { - var r = 0, rest = "", err = $ifaceNil, p, _tmp, _tmp$1, _tmp$2, _tuple, _tuple$1; - p = this; - if (s === "") { - _tmp = 0; _tmp$1 = ""; _tmp$2 = new Error.Ptr("missing closing ]", wholeClass); r = _tmp; rest = _tmp$1; err = _tmp$2; - return [r, rest, err]; - } - if (s.charCodeAt(0) === 92) { - _tuple = p.parseEscape(s); r = _tuple[0]; rest = _tuple[1]; err = _tuple[2]; - return [r, rest, err]; + } else if ($assertType(_ref, ($ptrType(ast.CommClause)), true)[1]) { + s$1 = _ref.$val; + return hasBreakList(s$1.Body, label, implicit); + } else if ($assertType(_ref, ($ptrType(ast.SelectStmt)), true)[1]) { + s$1 = _ref.$val; + if (!(label === "") && hasBreak(s$1.Body, label, false)) { + return true; + } + } else if ($assertType(_ref, ($ptrType(ast.ForStmt)), true)[1]) { + s$1 = _ref.$val; + if (!(label === "") && hasBreak(s$1.Body, label, false)) { + return true; + } + } else if ($assertType(_ref, ($ptrType(ast.RangeStmt)), true)[1]) { + s$1 = _ref.$val; + if (!(label === "") && hasBreak(s$1.Body, label, false)) { + return true; + } + } else { + s$1 = _ref; + unreachable(); } - _tuple$1 = nextRune(s); r = _tuple$1[0]; rest = _tuple$1[1]; err = _tuple$1[2]; - return [r, rest, err]; + return false; }; - parser.prototype.parseClassChar = function(s, wholeClass) { return this.$val.parseClassChar(s, wholeClass); }; - parser.Ptr.prototype.parsePerlClassEscape = function(s, r) { - var out = ($sliceType($Int32)).nil, rest = "", p, _entry, g, _tmp, _tmp$1; - p = this; - if ((((p.flags & 64) >>> 0) === 0) || s.length < 2 || !((s.charCodeAt(0) === 92))) { - return [out, rest]; - } - g = new charGroup.Ptr(); $copy(g, (_entry = perlGroup[s.substring(0, 2)], _entry !== undefined ? _entry.v : new charGroup.Ptr()), charGroup); - if (g.sign === 0) { - return [out, rest]; + hasBreakList = function(list, label, implicit) { + var _ref, _i, s; + _ref = list; + _i = 0; + while (_i < _ref.$length) { + s = ((_i < 0 || _i >= _ref.$length) ? $throwRuntimeError("index out of range") : _ref.$array[_ref.$offset + _i]); + if (hasBreak(s, label, implicit)) { + return true; + } + _i++; } - _tmp = p.appendGroup(r, $clone(g, charGroup)); _tmp$1 = s.substring(2); out = _tmp; rest = _tmp$1; - return [out, rest]; + return false; }; - parser.prototype.parsePerlClassEscape = function(s, r) { return this.$val.parsePerlClassEscape(s, r); }; - parser.Ptr.prototype.parseNamedClass = function(s, r) { - var out = ($sliceType($Int32)).nil, rest = "", err = $ifaceNil, p, i, _tmp, _tmp$1, name, _entry, g, _tmp$2, _tmp$3, _tmp$4, _tmp$5, _tmp$6, _tmp$7; - p = this; - if (s.length < 2 || !((s.charCodeAt(0) === 91)) || !((s.charCodeAt(1) === 58))) { - return [out, rest, err]; - } - i = strings.Index(s.substring(2), ":]"); - if (i < 0) { - return [out, rest, err]; - } - i = i + (2) >> 0; - _tmp = s.substring(0, (i + 2 >> 0)); _tmp$1 = s.substring((i + 2 >> 0)); name = _tmp; s = _tmp$1; - g = new charGroup.Ptr(); $copy(g, (_entry = posixGroup[name], _entry !== undefined ? _entry.v : new charGroup.Ptr()), charGroup); - if (g.sign === 0) { - _tmp$2 = ($sliceType($Int32)).nil; _tmp$3 = ""; _tmp$4 = new Error.Ptr("invalid character class range", name); out = _tmp$2; rest = _tmp$3; err = _tmp$4; - return [out, rest, err]; + NewScope = $pkg.NewScope = function(parent, comment) { + var s; + s = new Scope.Ptr(parent, ($sliceType(($ptrType(Scope)))).nil, comment, false); + if (!(parent === ($ptrType(Scope)).nil) && !(parent === $pkg.Universe)) { + parent.children = $append(parent.children, s); } - _tmp$5 = p.appendGroup(r, $clone(g, charGroup)); _tmp$6 = s; _tmp$7 = $ifaceNil; out = _tmp$5; rest = _tmp$6; err = _tmp$7; - return [out, rest, err]; + return s; }; - parser.prototype.parseNamedClass = function(s, r) { return this.$val.parseNamedClass(s, r); }; - parser.Ptr.prototype.appendGroup = function(r, g) { - var p, tmp; - p = this; - if (((p.flags & 1) >>> 0) === 0) { - if (g.sign < 0) { - r = appendNegatedClass(r, g.class$1); - } else { - r = appendClass(r, g.class$1); + Scope.Ptr.prototype.Parent = function() { + var s; + s = this; + return s.parent; + }; + Scope.prototype.Parent = function() { return this.$val.Parent(); }; + Scope.Ptr.prototype.Len = function() { + var s; + s = this; + return $keys(s.elems).length; + }; + Scope.prototype.Len = function() { return this.$val.Len(); }; + Scope.Ptr.prototype.Names = function() { + var s, names, i, _ref, _i, _keys, _entry, name; + s = this; + names = ($sliceType($String)).make($keys(s.elems).length); + i = 0; + _ref = s.elems; + _i = 0; + _keys = $keys(_ref); + while (_i < _keys.length) { + _entry = _ref[_keys[_i]]; + if (_entry === undefined) { + _i++; + continue; } - } else { - tmp = $subslice(p.tmpClass, 0, 0); - tmp = appendFoldedClass(tmp, g.class$1); - p.tmpClass = tmp; - tmp = cleanClass(new ($ptrType(($sliceType($Int32))))(function() { return this.$target.tmpClass; }, function($v) { this.$target.tmpClass = $v; }, p)); - if (g.sign < 0) { - r = appendNegatedClass(r, tmp); - } else { - r = appendClass(r, tmp); + name = _entry.k; + (i < 0 || i >= names.$length) ? $throwRuntimeError("index out of range") : names.$array[names.$offset + i] = name; + i = i + (1) >> 0; + _i++; + } + sort.Strings(names); + return names; + }; + Scope.prototype.Names = function() { return this.$val.Names(); }; + Scope.Ptr.prototype.NumChildren = function() { + var s; + s = this; + return s.children.$length; + }; + Scope.prototype.NumChildren = function() { return this.$val.NumChildren(); }; + Scope.Ptr.prototype.Child = function(i) { + var s, x; + s = this; + return (x = s.children, ((i < 0 || i >= x.$length) ? $throwRuntimeError("index out of range") : x.$array[x.$offset + i])); + }; + Scope.prototype.Child = function(i) { return this.$val.Child(i); }; + Scope.Ptr.prototype.Lookup = function(name) { + var s, _entry; + s = this; + return (_entry = s.elems[name], _entry !== undefined ? _entry.v : $ifaceNil); + }; + Scope.prototype.Lookup = function(name) { return this.$val.Lookup(name); }; + Scope.Ptr.prototype.LookupParent = function(name) { + var s, _entry, obj; + s = this; + while (!(s === ($ptrType(Scope)).nil)) { + obj = (_entry = s.elems[name], _entry !== undefined ? _entry.v : $ifaceNil); + if (!($interfaceIsEqual(obj, $ifaceNil))) { + return obj; } + s = s.parent; } - return r; + return $ifaceNil; }; - parser.prototype.appendGroup = function(r, g) { return this.$val.appendGroup(r, g); }; - unicodeTable = function(name) { - var _entry, t, _entry$1, _entry$2, t$1, _entry$3; - if (name === "Any") { - return [anyTable, anyTable]; + Scope.prototype.LookupParent = function(name) { return this.$val.LookupParent(name); }; + Scope.Ptr.prototype.Insert = function(obj) { + var s, name, _entry, alt, _key$2; + s = this; + name = obj.Name(); + alt = (_entry = s.elems[name], _entry !== undefined ? _entry.v : $ifaceNil); + if (!($interfaceIsEqual(alt, $ifaceNil))) { + return alt; } - t = (_entry = unicode.Categories[name], _entry !== undefined ? _entry.v : ($ptrType(unicode.RangeTable)).nil); - if (!(t === ($ptrType(unicode.RangeTable)).nil)) { - return [t, (_entry$1 = unicode.FoldCategory[name], _entry$1 !== undefined ? _entry$1.v : ($ptrType(unicode.RangeTable)).nil)]; + if (s.elems === false) { + s.elems = new $Map(); } - t$1 = (_entry$2 = unicode.Scripts[name], _entry$2 !== undefined ? _entry$2.v : ($ptrType(unicode.RangeTable)).nil); - if (!(t$1 === ($ptrType(unicode.RangeTable)).nil)) { - return [t$1, (_entry$3 = unicode.FoldScript[name], _entry$3 !== undefined ? _entry$3.v : ($ptrType(unicode.RangeTable)).nil)]; + _key$2 = name; (s.elems || $throwRuntimeError("assignment to entry in nil map"))[_key$2] = { k: _key$2, v: obj }; + if (obj.Parent() === ($ptrType(Scope)).nil) { + obj.setParent(s); } - return [($ptrType(unicode.RangeTable)).nil, ($ptrType(unicode.RangeTable)).nil]; + return $ifaceNil; }; - parser.Ptr.prototype.parseUnicodeClass = function(s, r) { - var out = ($sliceType($Int32)).nil, rest = "", err = $ifaceNil, p, sign, t, _tuple, c, _tmp, _tmp$1, seq, name, end, _tmp$2, _tmp$3, _tmp$4, _tmp$5, _tmp$6, _tuple$1, tab, fold, _tmp$7, _tmp$8, _tmp$9, tmp, _tmp$10, _tmp$11, _tmp$12; - p = this; - if ((((p.flags & 128) >>> 0) === 0) || s.length < 2 || !((s.charCodeAt(0) === 92)) || !((s.charCodeAt(1) === 112)) && !((s.charCodeAt(1) === 80))) { - return [out, rest, err]; - } - sign = 1; - if (s.charCodeAt(1) === 80) { - sign = -1; + Scope.prototype.Insert = function(obj) { return this.$val.Insert(obj); }; + Scope.Ptr.prototype.WriteTo = function(w, n, recurse) { + var s, indn, indn1, _ref, _i, name, _entry, _ref$1, _i$1, s$1; + s = this; + indn = strings.Repeat(". ", n); + fmt.Fprintf(w, "%s%s scope %p {", new ($sliceType($emptyInterface))([new $String(indn), new $String(s.comment), s])); + if ($keys(s.elems).length === 0) { + fmt.Fprintf(w, "}\n", new ($sliceType($emptyInterface))([])); + return; } - t = s.substring(2); - _tuple = nextRune(t); c = _tuple[0]; t = _tuple[1]; err = _tuple[2]; - if (!($interfaceIsEqual(err, $ifaceNil))) { - return [out, rest, err]; + fmt.Fprintln(w, new ($sliceType($emptyInterface))([])); + indn1 = indn + ". "; + _ref = s.Names(); + _i = 0; + while (_i < _ref.$length) { + name = ((_i < 0 || _i >= _ref.$length) ? $throwRuntimeError("index out of range") : _ref.$array[_ref.$offset + _i]); + fmt.Fprintf(w, "%s%s\n", new ($sliceType($emptyInterface))([new $String(indn1), (_entry = s.elems[name], _entry !== undefined ? _entry.v : $ifaceNil)])); + _i++; } - _tmp = ""; _tmp$1 = ""; seq = _tmp; name = _tmp$1; - if (!((c === 123))) { - seq = s.substring(0, (s.length - t.length >> 0)); - name = seq.substring(2); - } else { - end = strings.IndexRune(s, 125); - if (end < 0) { - err = checkUTF8(s); - if (!($interfaceIsEqual(err, $ifaceNil))) { - return [out, rest, err]; - } - _tmp$2 = ($sliceType($Int32)).nil; _tmp$3 = ""; _tmp$4 = new Error.Ptr("invalid character class range", s); out = _tmp$2; rest = _tmp$3; err = _tmp$4; - return [out, rest, err]; - } - _tmp$5 = s.substring(0, (end + 1 >> 0)); _tmp$6 = s.substring((end + 1 >> 0)); seq = _tmp$5; t = _tmp$6; - name = s.substring(3, end); - err = checkUTF8(name); - if (!($interfaceIsEqual(err, $ifaceNil))) { - return [out, rest, err]; + if (recurse) { + _ref$1 = s.children; + _i$1 = 0; + while (_i$1 < _ref$1.$length) { + s$1 = ((_i$1 < 0 || _i$1 >= _ref$1.$length) ? $throwRuntimeError("index out of range") : _ref$1.$array[_ref$1.$offset + _i$1]); + fmt.Fprintln(w, new ($sliceType($emptyInterface))([])); + s$1.WriteTo(w, n + 1 >> 0, recurse); + _i$1++; } } - if (!(name === "") && (name.charCodeAt(0) === 94)) { - sign = -sign; - name = name.substring(1); + fmt.Fprintf(w, "%s}", new ($sliceType($emptyInterface))([new $String(indn)])); + }; + Scope.prototype.WriteTo = function(w, n, recurse) { return this.$val.WriteTo(w, n, recurse); }; + Scope.Ptr.prototype.String = function() { + var s, buf; + s = this; + buf = new bytes.Buffer.Ptr(); $copy(buf, new bytes.Buffer.Ptr(), bytes.Buffer); + s.WriteTo(buf, 0, false); + return buf.String(); + }; + Scope.prototype.String = function() { return this.$val.String(); }; + Selection.Ptr.prototype.Kind = function() { + var s; + s = this; + return s.kind; + }; + Selection.prototype.Kind = function() { return this.$val.Kind(); }; + Selection.Ptr.prototype.Recv = function() { + var s; + s = this; + return s.recv; + }; + Selection.prototype.Recv = function() { return this.$val.Recv(); }; + Selection.Ptr.prototype.Obj = function() { + var s; + s = this; + return s.obj; + }; + Selection.prototype.Obj = function() { return this.$val.Obj(); }; + Selection.Ptr.prototype.Type = function() { + var s, _ref, sig, recv, sig$1, arg0, params; + s = this; + _ref = s.kind; + if (_ref === 1) { + sig = new Signature.Ptr(); $copy(sig, $assertType($assertType(s.obj, ($ptrType(Func))).object.typ, ($ptrType(Signature))), Signature); + recv = new Var.Ptr(); $copy(recv, sig.recv, Var); + recv.object.typ = s.recv; + sig.recv = recv; + return sig; + } else if (_ref === 2) { + sig$1 = new Signature.Ptr(); $copy(sig$1, $assertType($assertType(s.obj, ($ptrType(Func))).object.typ, ($ptrType(Signature))), Signature); + arg0 = new Var.Ptr(); $copy(arg0, sig$1.recv, Var); + sig$1.recv = ($ptrType(Var)).nil; + arg0.object.typ = s.recv; + params = ($sliceType(($ptrType(Var)))).nil; + if (!(sig$1.params === ($ptrType(Tuple)).nil)) { + params = sig$1.params.vars; + } + sig$1.params = NewTuple($appendSlice(new ($sliceType(($ptrType(Var))))([arg0]), params)); + return sig$1; } - _tuple$1 = unicodeTable(name); tab = _tuple$1[0]; fold = _tuple$1[1]; - if (tab === ($ptrType(unicode.RangeTable)).nil) { - _tmp$7 = ($sliceType($Int32)).nil; _tmp$8 = ""; _tmp$9 = new Error.Ptr("invalid character class range", seq); out = _tmp$7; rest = _tmp$8; err = _tmp$9; - return [out, rest, err]; + return s.obj.Type(); + }; + Selection.prototype.Type = function() { return this.$val.Type(); }; + Selection.Ptr.prototype.Index = function() { + var s; + s = this; + return s.index; + }; + Selection.prototype.Index = function() { return this.$val.Index(); }; + Selection.Ptr.prototype.Indirect = function() { + var s; + s = this; + return s.indirect; + }; + Selection.prototype.Indirect = function() { return this.$val.Indirect(); }; + Selection.Ptr.prototype.String = function() { + var s; + s = this; + return SelectionString(($ptrType(Package)).nil, s); + }; + Selection.prototype.String = function() { return this.$val.String(); }; + SelectionString = $pkg.SelectionString = function(this$1, s) { + var k, _ref, buf, T; + k = ""; + _ref = s.kind; + if (_ref === 0) { + k = "field "; + } else if (_ref === 1) { + k = "method "; + } else if (_ref === 2) { + k = "method expr "; + } else { + unreachable(); } - if ((((p.flags & 1) >>> 0) === 0) || fold === ($ptrType(unicode.RangeTable)).nil) { - if (sign > 0) { - r = appendTable(r, tab); - } else { - r = appendNegatedTable(r, tab); - } + buf = new bytes.Buffer.Ptr(); $copy(buf, new bytes.Buffer.Ptr(), bytes.Buffer); + buf.WriteString(k); + buf.WriteByte(40); + WriteType(buf, this$1, s.Recv()); + fmt.Fprintf(buf, ") %s", new ($sliceType($emptyInterface))([new $String(s.obj.Name())])); + T = s.Type(); + if (s.kind === 0) { + buf.WriteByte(32); + WriteType(buf, this$1, T); } else { - tmp = $subslice(p.tmpClass, 0, 0); - tmp = appendTable(tmp, tab); - tmp = appendTable(tmp, fold); - p.tmpClass = tmp; - tmp = cleanClass(new ($ptrType(($sliceType($Int32))))(function() { return this.$target.tmpClass; }, function($v) { this.$target.tmpClass = $v; }, p)); - if (sign > 0) { - r = appendClass(r, tmp); - } else { - r = appendNegatedClass(r, tmp); - } + WriteSignature(buf, this$1, $assertType(T, ($ptrType(Signature)))); } - _tmp$10 = r; _tmp$11 = t; _tmp$12 = $ifaceNil; out = _tmp$10; rest = _tmp$11; err = _tmp$12; - return [out, rest, err]; + return buf.String(); }; - parser.prototype.parseUnicodeClass = function(s, r) { return this.$val.parseUnicodeClass(s, r); }; - parser.Ptr.prototype.parseClass = function(s) { - var rest = "", err = $ifaceNil, p, t, re, sign, class$1, first, _tuple, size, _tmp, _tmp$1, _tuple$1, nclass, nt, err$1, _tmp$2, _tmp$3, _tmp$4, _tmp$5, _tuple$2, nclass$1, nt$1, err$2, _tmp$6, _tmp$7, _tmp$8, _tmp$9, _tuple$3, nclass$2, nt$2, _tmp$10, _tmp$11, rng, _tmp$12, _tmp$13, lo, hi, _tuple$4, _tmp$14, _tmp$15, _tuple$5, _tmp$16, _tmp$17, _tmp$18, _tmp$19, _tmp$20, _tmp$21; - p = this; - t = s.substring(1); - re = p.newRegexp(4); - re.Flags = p.flags; - re.Rune = $subslice(new ($sliceType($Int32))(re.Rune0), 0, 0); - sign = 1; - if (!(t === "") && (t.charCodeAt(0) === 94)) { - sign = -1; - t = t.substring(1); - if (((p.flags & 4) >>> 0) === 0) { - re.Rune = $append(re.Rune, 10, 10); + StdSizes.Ptr.prototype.Alignof = function(T) { + var s, t, _ref, max, _ref$1, _i, f, a, a$1, x; + s = this; + _ref = T.Underlying(); + if ($assertType(_ref, ($ptrType(Array)), true)[1]) { + t = _ref.$val; + return s.Alignof(t.elem); + } else if ($assertType(_ref, ($ptrType(Struct)), true)[1]) { + t = _ref.$val; + max = new $Int64(0, 1); + _ref$1 = t.fields; + _i = 0; + while (_i < _ref$1.$length) { + f = ((_i < 0 || _i >= _ref$1.$length) ? $throwRuntimeError("index out of range") : _ref$1.$array[_ref$1.$offset + _i]); + a = s.Alignof(f.object.typ); + if ((a.$high > max.$high || (a.$high === max.$high && a.$low > max.$low))) { + max = a; + } + _i++; } + return max; } - class$1 = re.Rune; - first = true; - while (t === "" || !((t.charCodeAt(0) === 93)) || first) { - if (!(t === "") && (t.charCodeAt(0) === 45) && (((p.flags & 64) >>> 0) === 0) && !first && ((t.length === 1) || !((t.charCodeAt(1) === 93)))) { - _tuple = utf8.DecodeRuneInString(t.substring(1)); size = _tuple[1]; - _tmp = ""; _tmp$1 = new Error.Ptr("invalid character class range", t.substring(0, (1 + size >> 0))); rest = _tmp; err = _tmp$1; - return [rest, err]; - } - first = false; - if (t.length > 2 && (t.charCodeAt(0) === 91) && (t.charCodeAt(1) === 58)) { - _tuple$1 = p.parseNamedClass(t, class$1); nclass = _tuple$1[0]; nt = _tuple$1[1]; err$1 = _tuple$1[2]; - if (!($interfaceIsEqual(err$1, $ifaceNil))) { - _tmp$2 = ""; _tmp$3 = err$1; rest = _tmp$2; err = _tmp$3; - return [rest, err]; - } - if (!(nclass === ($sliceType($Int32)).nil)) { - _tmp$4 = nclass; _tmp$5 = nt; class$1 = _tmp$4; t = _tmp$5; - continue; + a$1 = s.Sizeof(T); + if ((a$1.$high < 0 || (a$1.$high === 0 && a$1.$low < 1))) { + return new $Int64(0, 1); + } + if ((x = s.MaxAlign, (a$1.$high > x.$high || (a$1.$high === x.$high && a$1.$low > x.$low)))) { + return s.MaxAlign; + } + return a$1; + }; + StdSizes.prototype.Alignof = function(T) { return this.$val.Alignof(T); }; + StdSizes.Ptr.prototype.Offsetsof = function(fields) { + var s, offsets, o, _ref, _i, i, f, a, x; + s = this; + offsets = ($sliceType($Int64)).make(fields.$length); + o = new $Int64(0, 0); + _ref = fields; + _i = 0; + while (_i < _ref.$length) { + i = _i; + f = ((_i < 0 || _i >= _ref.$length) ? $throwRuntimeError("index out of range") : _ref.$array[_ref.$offset + _i]); + a = s.Alignof(f.object.typ); + o = align(o, a); + (i < 0 || i >= offsets.$length) ? $throwRuntimeError("index out of range") : offsets.$array[offsets.$offset + i] = o; + o = (x = s.Sizeof(f.object.typ), new $Int64(o.$high + x.$high, o.$low + x.$low)); + _i++; + } + return offsets; + }; + StdSizes.prototype.Offsetsof = function(fields) { return this.$val.Offsetsof(fields); }; + StdSizes.Ptr.prototype.Sizeof = function(T) { + var s, t, _ref, k, s$1, a, z, n, offsets, x, x$1, x$2, x$3, x$4; + s = this; + _ref = T.Underlying(); + if ($assertType(_ref, ($ptrType(Basic)), true)[1]) { + t = _ref.$val; + assert(isTyped(T)); + k = t.kind; + if ((k >> 0) < 17) { + s$1 = ((k < 0 || k >= basicSizes.length) ? $throwRuntimeError("index out of range") : basicSizes[k]); + if (s$1 > 0) { + return new $Int64(0, s$1); } } - _tuple$2 = p.parseUnicodeClass(t, class$1); nclass$1 = _tuple$2[0]; nt$1 = _tuple$2[1]; err$2 = _tuple$2[2]; - if (!($interfaceIsEqual(err$2, $ifaceNil))) { - _tmp$6 = ""; _tmp$7 = err$2; rest = _tmp$6; err = _tmp$7; - return [rest, err]; + if (k === 17) { + return $mul64(s.WordSize, new $Int64(0, 2)); } - if (!(nclass$1 === ($sliceType($Int32)).nil)) { - _tmp$8 = nclass$1; _tmp$9 = nt$1; class$1 = _tmp$8; t = _tmp$9; - continue; + } else if ($assertType(_ref, ($ptrType(Array)), true)[1]) { + t = _ref.$val; + a = s.Alignof(t.elem); + z = s.Sizeof(t.elem); + return $mul64(align(z, a), t.len); + } else if ($assertType(_ref, ($ptrType(Slice)), true)[1]) { + t = _ref.$val; + return $mul64(s.WordSize, new $Int64(0, 3)); + } else if ($assertType(_ref, ($ptrType(Struct)), true)[1]) { + t = _ref.$val; + n = t.NumFields(); + if (n === 0) { + return new $Int64(0, 0); } - _tuple$3 = p.parsePerlClassEscape(t, class$1); nclass$2 = _tuple$3[0]; nt$2 = _tuple$3[1]; - if (!(nclass$2 === ($sliceType($Int32)).nil)) { - _tmp$10 = nclass$2; _tmp$11 = nt$2; class$1 = _tmp$10; t = _tmp$11; - continue; + offsets = t.offsets; + if (t.offsets === ($sliceType($Int64)).nil) { + offsets = s.Offsetsof(t.fields); + t.offsets = offsets; } - rng = t; - _tmp$12 = 0; _tmp$13 = 0; lo = _tmp$12; hi = _tmp$13; - _tuple$4 = p.parseClassChar(t, s); lo = _tuple$4[0]; t = _tuple$4[1]; err$2 = _tuple$4[2]; - if (!($interfaceIsEqual(err$2, $ifaceNil))) { - _tmp$14 = ""; _tmp$15 = err$2; rest = _tmp$14; err = _tmp$15; - return [rest, err]; + return (x = (x$1 = n - 1 >> 0, ((x$1 < 0 || x$1 >= offsets.$length) ? $throwRuntimeError("index out of range") : offsets.$array[offsets.$offset + x$1])), x$2 = s.Sizeof((x$3 = t.fields, x$4 = n - 1 >> 0, ((x$4 < 0 || x$4 >= x$3.$length) ? $throwRuntimeError("index out of range") : x$3.$array[x$3.$offset + x$4])).object.typ), new $Int64(x.$high + x$2.$high, x.$low + x$2.$low)); + } else if ($assertType(_ref, ($ptrType(Interface)), true)[1]) { + t = _ref.$val; + return $mul64(s.WordSize, new $Int64(0, 2)); + } + return s.WordSize; + }; + StdSizes.prototype.Sizeof = function(T) { return this.$val.Sizeof(T); }; + Config.Ptr.prototype.alignof = function(T) { + var conf, s, a; + conf = this; + s = conf.Sizes; + if (!($interfaceIsEqual(s, $ifaceNil))) { + a = s.Alignof(T); + if ((a.$high > 0 || (a.$high === 0 && a.$low >= 1))) { + return a; } - hi = lo; - if (t.length >= 2 && (t.charCodeAt(0) === 45) && !((t.charCodeAt(1) === 93))) { - t = t.substring(1); - _tuple$5 = p.parseClassChar(t, s); hi = _tuple$5[0]; t = _tuple$5[1]; err$2 = _tuple$5[2]; - if (!($interfaceIsEqual(err$2, $ifaceNil))) { - _tmp$16 = ""; _tmp$17 = err$2; rest = _tmp$16; err = _tmp$17; - return [rest, err]; + $panic(new $String("Config.Sizes.Alignof returned an alignment < 1")); + } + return stdSizes.Alignof(T); + }; + Config.prototype.alignof = function(T) { return this.$val.alignof(T); }; + Config.Ptr.prototype.offsetsof = function(T) { + var conf, offsets, s, _ref, _i, o; + conf = this; + offsets = T.offsets; + if (offsets === ($sliceType($Int64)).nil && T.NumFields() > 0) { + s = conf.Sizes; + if (!($interfaceIsEqual(s, $ifaceNil))) { + offsets = s.Offsetsof(T.fields); + if (!((offsets.$length === T.NumFields()))) { + $panic(new $String("Config.Sizes.Offsetsof returned the wrong number of offsets")); } - if (hi < lo) { - rng = rng.substring(0, (rng.length - t.length >> 0)); - _tmp$18 = ""; _tmp$19 = new Error.Ptr("invalid character class range", rng); rest = _tmp$18; err = _tmp$19; - return [rest, err]; + _ref = offsets; + _i = 0; + while (_i < _ref.$length) { + o = ((_i < 0 || _i >= _ref.$length) ? $throwRuntimeError("index out of range") : _ref.$array[_ref.$offset + _i]); + if ((o.$high < 0 || (o.$high === 0 && o.$low < 0))) { + $panic(new $String("Config.Sizes.Offsetsof returned an offset < 0")); + } + _i++; } - } - if (((p.flags & 1) >>> 0) === 0) { - class$1 = appendRange(class$1, lo, hi); } else { - class$1 = appendFoldedRange(class$1, lo, hi); + offsets = stdSizes.Offsetsof(T.fields); } + T.offsets = offsets; } - t = t.substring(1); - re.Rune = class$1; - class$1 = cleanClass(new ($ptrType(($sliceType($Int32))))(function() { return this.$target.Rune; }, function($v) { this.$target.Rune = $v; }, re)); - if (sign < 0) { - class$1 = negateClass(class$1); - } - re.Rune = class$1; - p.push(re); - _tmp$20 = t; _tmp$21 = $ifaceNil; rest = _tmp$20; err = _tmp$21; - return [rest, err]; + return offsets; }; - parser.prototype.parseClass = function(s) { return this.$val.parseClass(s); }; - cleanClass = function(rp) { - var x, r, w, i, _tmp, _tmp$1, x$1, lo, hi, x$2, x$3, x$4, x$5; - sort.Sort((x = new ranges.Ptr(rp), new x.constructor.Struct(x))); - r = rp.$get(); - if (r.$length < 2) { - return r; + Config.prototype.offsetsof = function(T) { return this.$val.offsetsof(T); }; + Config.Ptr.prototype.offsetof = function(typ, index) { + var conf, o, _ref, _i, i, s, x, x$1, x$2; + conf = this; + o = new $Int64(0, 0); + _ref = index; + _i = 0; + while (_i < _ref.$length) { + i = ((_i < 0 || _i >= _ref.$length) ? $throwRuntimeError("index out of range") : _ref.$array[_ref.$offset + _i]); + s = $assertType(typ.Underlying(), ($ptrType(Struct))); + o = (x = (x$1 = conf.offsetsof(s), ((i < 0 || i >= x$1.$length) ? $throwRuntimeError("index out of range") : x$1.$array[x$1.$offset + i])), new $Int64(o.$high + x.$high, o.$low + x.$low)); + typ = (x$2 = s.fields, ((i < 0 || i >= x$2.$length) ? $throwRuntimeError("index out of range") : x$2.$array[x$2.$offset + i])).object.typ; + _i++; } - w = 2; - i = 2; - while (i < r.$length) { - _tmp = ((i < 0 || i >= r.$length) ? $throwRuntimeError("index out of range") : r.$array[r.$offset + i]); _tmp$1 = (x$1 = i + 1 >> 0, ((x$1 < 0 || x$1 >= r.$length) ? $throwRuntimeError("index out of range") : r.$array[r.$offset + x$1])); lo = _tmp; hi = _tmp$1; - if (lo <= ((x$2 = w - 1 >> 0, ((x$2 < 0 || x$2 >= r.$length) ? $throwRuntimeError("index out of range") : r.$array[r.$offset + x$2])) + 1 >> 0)) { - if (hi > (x$3 = w - 1 >> 0, ((x$3 < 0 || x$3 >= r.$length) ? $throwRuntimeError("index out of range") : r.$array[r.$offset + x$3]))) { - (x$4 = w - 1 >> 0, (x$4 < 0 || x$4 >= r.$length) ? $throwRuntimeError("index out of range") : r.$array[r.$offset + x$4] = hi); - } - i = i + (2) >> 0; - continue; + return o; + }; + Config.prototype.offsetof = function(typ, index) { return this.$val.offsetof(typ, index); }; + Config.Ptr.prototype.sizeof = function(T) { + var conf, s, z; + conf = this; + s = conf.Sizes; + if (!($interfaceIsEqual(s, $ifaceNil))) { + z = s.Sizeof(T); + if ((z.$high > 0 || (z.$high === 0 && z.$low >= 0))) { + return z; } - (w < 0 || w >= r.$length) ? $throwRuntimeError("index out of range") : r.$array[r.$offset + w] = lo; - (x$5 = w + 1 >> 0, (x$5 < 0 || x$5 >= r.$length) ? $throwRuntimeError("index out of range") : r.$array[r.$offset + x$5] = hi); - w = w + (2) >> 0; - i = i + (2) >> 0; + $panic(new $String("Config.Sizes.Sizeof returned a size < 0")); } - return $subslice(r, 0, w); + return stdSizes.Sizeof(T); }; - appendLiteral = function(r, x, flags) { - if (!((((flags & 1) >>> 0) === 0))) { - return appendFoldedRange(r, x, x); - } - return appendRange(r, x, x); + Config.prototype.sizeof = function(T) { return this.$val.sizeof(T); }; + align = function(x, a) { + var x$1, y, x$2; + y = (x$1 = new $Int64(x.$high + a.$high, x.$low + a.$low), new $Int64(x$1.$high - 0, x$1.$low - 1)); + return (x$2 = $div64(y, a, true), new $Int64(y.$high - x$2.$high, y.$low - x$2.$low)); }; - appendRange = function(r, lo, hi) { - var n, i, _tmp, x, _tmp$1, x$1, rlo, rhi, x$2, x$3; - n = r.$length; - i = 2; - while (i <= 4) { - if (n >= i) { - _tmp = (x = n - i >> 0, ((x < 0 || x >= r.$length) ? $throwRuntimeError("index out of range") : r.$array[r.$offset + x])); _tmp$1 = (x$1 = (n - i >> 0) + 1 >> 0, ((x$1 < 0 || x$1 >= r.$length) ? $throwRuntimeError("index out of range") : r.$array[r.$offset + x$1])); rlo = _tmp; rhi = _tmp$1; - if (lo <= (rhi + 1 >> 0) && rlo <= (hi + 1 >> 0)) { - if (lo < rlo) { - (x$2 = n - i >> 0, (x$2 < 0 || x$2 >= r.$length) ? $throwRuntimeError("index out of range") : r.$array[r.$offset + x$2] = lo); - } - if (hi > rhi) { - (x$3 = (n - i >> 0) + 1 >> 0, (x$3 < 0 || x$3 >= r.$length) ? $throwRuntimeError("index out of range") : r.$array[r.$offset + x$3] = hi); - } - return r; - } - } - i = i + (2) >> 0; + Checker.Ptr.prototype.funcBody = function(decl, name, sig, body) { + var $deferred = [], $err = null, check; + /* */ try { $deferFrames.push($deferred); + check = this; + $deferred.push([(function(ctxt, indent) { + $copy(check.context, ctxt, context); + check.indent = indent; + }), [$clone(check.context, context), check.indent]]); + $copy(check.context, new context.Ptr(decl, sig.scope, $ifaceNil, sig, false, false), context); + check.indent = 0; + check.stmtList(0, body.List); + if (check.context.hasLabel) { + check.labels(body); } - return $append(r, lo, hi); + if (sig.results.Len() > 0 && !check.isTerminating(body, "")) { + check.error(body.Rbrace, "missing return"); + } + check.usage(sig.scope); + /* */ } catch(err) { $err = err; } finally { $deferFrames.pop(); $callDeferred($deferred, $err); } }; - appendFoldedRange = function(r, lo, hi) { - var c, f; - if (lo <= 65 && hi >= 66639) { - return appendRange(r, lo, hi); + Checker.prototype.funcBody = function(decl, name, sig, body) { return this.$val.funcBody(decl, name, sig, body); }; + Checker.Ptr.prototype.usage = function(scope) { + var check, _ref, _i, _keys, _entry, obj, _tuple, v, _ref$1, _i$1, scope$1; + check = this; + _ref = scope.elems; + _i = 0; + _keys = $keys(_ref); + while (_i < _keys.length) { + _entry = _ref[_keys[_i]]; + if (_entry === undefined) { + _i++; + continue; + } + obj = _entry.v; + _tuple = $assertType(obj, ($ptrType(Var)), true); v = _tuple[0]; + if (!(v === ($ptrType(Var)).nil) && !v.object.used) { + check.softErrorf(v.object.pos, "%s declared but not used", new ($sliceType($emptyInterface))([new $String(v.object.name)])); + } + _i++; } - if (hi < 65 || lo > 66639) { - return appendRange(r, lo, hi); + _ref$1 = scope.children; + _i$1 = 0; + while (_i$1 < _ref$1.$length) { + scope$1 = ((_i$1 < 0 || _i$1 >= _ref$1.$length) ? $throwRuntimeError("index out of range") : _ref$1.$array[_ref$1.$offset + _i$1]); + check.usage(scope$1); + _i$1++; } - if (lo < 65) { - r = appendRange(r, lo, 64); - lo = 65; + }; + Checker.prototype.usage = function(scope) { return this.$val.usage(scope); }; + Checker.Ptr.prototype.simpleStmt = function(s) { + var check; + check = this; + if (!($interfaceIsEqual(s, $ifaceNil))) { + check.stmt(0, s); } - if (hi > 66639) { - r = appendRange(r, 66640, hi); - hi = 66639; + }; + Checker.prototype.simpleStmt = function(s) { return this.$val.simpleStmt(s); }; + Checker.Ptr.prototype.stmtList = function(ctxt, list) { + var check, ok, inner, _ref, _i, i, s, inner$1; + check = this; + ok = !((((ctxt & 4) >>> 0) === 0)); + inner = ctxt & ~4; + _ref = list; + _i = 0; + while (_i < _ref.$length) { + i = _i; + s = ((_i < 0 || _i >= _ref.$length) ? $throwRuntimeError("index out of range") : _ref.$array[_ref.$offset + _i]); + inner$1 = inner; + if (ok && ((i + 1 >> 0) === list.$length)) { + inner$1 = (inner$1 | (4)) >>> 0; + } + check.stmt(inner$1, s); + _i++; } - c = lo; - while (c <= hi) { - r = appendRange(r, c, c); - f = unicode.SimpleFold(c); - while (!((f === c))) { - r = appendRange(r, f, f); - f = unicode.SimpleFold(f); + }; + Checker.prototype.stmtList = function(ctxt, list) { return this.$val.stmtList(ctxt, list); }; + Checker.Ptr.prototype.multipleDefaults = function(list) { + var check, first, _ref, _i, s, d, c, _ref$1; + check = this; + first = $ifaceNil; + _ref = list; + _i = 0; + while (_i < _ref.$length) { + s = ((_i < 0 || _i >= _ref.$length) ? $throwRuntimeError("index out of range") : _ref.$array[_ref.$offset + _i]); + d = $ifaceNil; + _ref$1 = s; + if ($assertType(_ref$1, ($ptrType(ast.CaseClause)), true)[1]) { + c = _ref$1.$val; + if (c.List.$length === 0) { + d = s; + } + } else if ($assertType(_ref$1, ($ptrType(ast.CommClause)), true)[1]) { + c = _ref$1.$val; + if ($interfaceIsEqual(c.Comm, $ifaceNil)) { + d = s; + } + } else { + c = _ref$1; + check.invalidAST(s.Pos(), "case/communication clause expected", new ($sliceType($emptyInterface))([])); } - c = c + (1) >> 0; + if (!($interfaceIsEqual(d, $ifaceNil))) { + if (!($interfaceIsEqual(first, $ifaceNil))) { + check.errorf(d.Pos(), "multiple defaults (first at %s)", new ($sliceType($emptyInterface))([new token.Pos(first.Pos())])); + } else { + first = d; + } + } + _i++; } - return r; }; - appendClass = function(r, x) { - var i, x$1; - i = 0; - while (i < x.$length) { - r = appendRange(r, ((i < 0 || i >= x.$length) ? $throwRuntimeError("index out of range") : x.$array[x.$offset + i]), (x$1 = i + 1 >> 0, ((x$1 < 0 || x$1 >= x.$length) ? $throwRuntimeError("index out of range") : x.$array[x.$offset + x$1]))); - i = i + (2) >> 0; + Checker.prototype.multipleDefaults = function(list) { return this.$val.multipleDefaults(list); }; + Checker.Ptr.prototype.openScope = function(s, comment) { + var check, scope; + check = this; + scope = NewScope(check.context.scope, comment); + check.recordScope(s, scope); + check.context.scope = scope; + }; + Checker.prototype.openScope = function(s, comment) { return this.$val.openScope(s, comment); }; + Checker.Ptr.prototype.closeScope = function() { + var check; + check = this; + check.context.scope = check.context.scope.Parent(); + }; + Checker.prototype.closeScope = function() { return this.$val.closeScope(); }; + assignOp = function(op) { + if (23 <= op && op <= 33) { + return op + -11 >> 0; } - return r; + return 0; }; - appendFoldedClass = function(r, x) { - var i, x$1; - i = 0; - while (i < x.$length) { - r = appendFoldedRange(r, ((i < 0 || i >= x.$length) ? $throwRuntimeError("index out of range") : x.$array[x.$offset + i]), (x$1 = i + 1 >> 0, ((x$1 < 0 || x$1 >= x.$length) ? $throwRuntimeError("index out of range") : x.$array[x.$offset + x$1]))); - i = i + (2) >> 0; + Checker.Ptr.prototype.suspendedCall = function(keyword, call) { + var check, x, msg, _ref; + check = this; + x = new operand.Ptr(); $copy(x, new operand.Ptr(), operand); + msg = ""; + _ref = check.rawExpr(x, call, $ifaceNil); + if (_ref === 0) { + msg = "requires function call, not conversion"; + } else if (_ref === 1) { + msg = "discards result of"; + } else if (_ref === 2) { + return; + } else { + unreachable(); } - return r; + check.errorf(x.pos(), "%s %s %s", new ($sliceType($emptyInterface))([new $String(keyword), new $String(msg), x])); }; - appendNegatedClass = function(r, x) { - var nextLo, i, _tmp, _tmp$1, x$1, lo, hi; - nextLo = 0; - i = 0; - while (i < x.$length) { - _tmp = ((i < 0 || i >= x.$length) ? $throwRuntimeError("index out of range") : x.$array[x.$offset + i]); _tmp$1 = (x$1 = i + 1 >> 0, ((x$1 < 0 || x$1 >= x.$length) ? $throwRuntimeError("index out of range") : x.$array[x.$offset + x$1])); lo = _tmp; hi = _tmp$1; - if (nextLo <= (lo - 1 >> 0)) { - r = appendRange(r, nextLo, lo - 1 >> 0); + Checker.prototype.suspendedCall = function(keyword, call) { return this.$val.suspendedCall(keyword, call); }; + Checker.Ptr.prototype.caseValues = function(x, values) { + var check, _ref, _i, e, y; + check = this; + _ref = values; + _i = 0; + while (_i < _ref.$length) { + e = ((_i < 0 || _i >= _ref.$length) ? $throwRuntimeError("index out of range") : _ref.$array[_ref.$offset + _i]); + y = new operand.Ptr(); $copy(y, new operand.Ptr(), operand); + check.expr(y, e); + if (y.mode === 0) { + return; } - nextLo = hi + 1 >> 0; - i = i + (2) >> 0; - } - if (nextLo <= 1114111) { - r = appendRange(r, nextLo, 1114111); + check.convertUntyped(y, x.typ); + if (y.mode === 0) { + return; + } + check.convertUntyped(x, y.typ); + if (x.mode === 0) { + return; + } + check.comparison(y, x, 39); + _i++; } - return r; }; - appendTable = function(r, x) { - var _ref, _i, xr, _tmp, _tmp$1, _tmp$2, lo, hi, stride, c, _ref$1, _i$1, xr$1, _tmp$3, _tmp$4, _tmp$5, lo$1, hi$1, stride$1, c$1; - _ref = x.R16; + Checker.prototype.caseValues = function(x, values) { return this.$val.caseValues(x, values); }; + Checker.Ptr.prototype.caseTypes = function(x, xtyp, types, seen) { + var T = $ifaceNil, check, _ref, _i, e, _ref$1, _i$1, _keys, _entry, t, pos, _key$2; + check = this; + _ref = types; _i = 0; + L: while (_i < _ref.$length) { - xr = new unicode.Range16.Ptr(); $copy(xr, ((_i < 0 || _i >= _ref.$length) ? $throwRuntimeError("index out of range") : _ref.$array[_ref.$offset + _i]), unicode.Range16); - _tmp = (xr.Lo >> 0); _tmp$1 = (xr.Hi >> 0); _tmp$2 = (xr.Stride >> 0); lo = _tmp; hi = _tmp$1; stride = _tmp$2; - if (stride === 1) { - r = appendRange(r, lo, hi); + e = ((_i < 0 || _i >= _ref.$length) ? $throwRuntimeError("index out of range") : _ref.$array[_ref.$offset + _i]); + T = check.typOrNil(e); + if ($interfaceIsEqual(T, $pkg.Typ[0])) { _i++; continue; } - c = lo; - while (c <= hi) { - r = appendRange(r, c, c); - c = c + (stride) >> 0; + _ref$1 = seen; + _i$1 = 0; + _keys = $keys(_ref$1); + while (_i$1 < _keys.length) { + _entry = _ref$1[_keys[_i$1]]; + if (_entry === undefined) { + _i$1++; + continue; + } + t = _entry.k; + pos = _entry.v; + if ($interfaceIsEqual(T, $ifaceNil) && $interfaceIsEqual(t, $ifaceNil) || !($interfaceIsEqual(T, $ifaceNil)) && !($interfaceIsEqual(t, $ifaceNil)) && Identical(T, t)) { + check.error(e.Pos(), "duplicate case in type switch"); + check.errorf(pos, "\tprevious case %s", new ($sliceType($emptyInterface))([T])); + _i++; + continue L; + } + _i$1++; + } + _key$2 = T; (seen || $throwRuntimeError("assignment to entry in nil map"))[_key$2.$key()] = { k: _key$2, v: e.Pos() }; + if (!($interfaceIsEqual(T, $ifaceNil))) { + check.typeAssertion(e.Pos(), x, xtyp, T); + } + _i++; + } + return T; + }; + Checker.prototype.caseTypes = function(x, xtyp, types, seen) { return this.$val.caseTypes(x, xtyp, types, seen); }; + Checker.Ptr.prototype.stmt = function(ctxt, s) { + var $deferred = [], $err = null, check, inner, s$1, _ref, x, kind, msg, _ref$1, _tmp, _tmp$1, ch, x$1, _tuple, tch, ok, op, _ref$2, x$2, Y, _ref$3, op$1, x$3, x$4, x$5, x$6, res, x$7, _ref$4, _i, obj, alt, x$8, _ref$5, x$9, x$10, _ref$6, _i$1, i, c, _tuple$1, clause, inner$1, lhs, rhs, guard, _ref$7, _tuple$2, x$11, x$12, _tuple$3, expr, x$13, _tuple$4, xtyp, lhsVars, seen, _ref$8, _i$2, s$2, _tuple$5, clause$1, T, obj$1, used, _ref$9, _i$3, v, _ref$10, _i$4, s$3, _tuple$6, clause$2, valid, rhs$1, s$4, _ref$11, x$14, _tuple$7, x$15, x$16, _tuple$8, s$5, decl, x$17, _tmp$2, _tmp$3, key, val, typ, _ref$12, _tuple$9, typ$1, lhs$1, rhs$2, vars, _ref$13, _i$5, i$1, lhs$2, obj$2, _tuple$10, ident, name, _ref$14, _i$6, obj$3, _ref$15, _i$7, i$2, lhs$3; + /* */ try { $deferFrames.push($deferred); + check = this; + assert($interfaceIsEqual(check.context.iota, $ifaceNil)); + inner = ctxt & ~4; + _ref = s; + if ($assertType(_ref, ($ptrType(ast.BadStmt)), true)[1] || $assertType(_ref, ($ptrType(ast.EmptyStmt)), true)[1]) { + s$1 = _ref; + } else if ($assertType(_ref, ($ptrType(ast.DeclStmt)), true)[1]) { + s$1 = _ref.$val; + check.declStmt(s$1.Decl); + } else if ($assertType(_ref, ($ptrType(ast.LabeledStmt)), true)[1]) { + s$1 = _ref.$val; + check.context.hasLabel = true; + check.stmt(ctxt, s$1.Stmt); + } else if ($assertType(_ref, ($ptrType(ast.ExprStmt)), true)[1]) { + s$1 = _ref.$val; + x = new operand.Ptr(); $copy(x, new operand.Ptr(), operand); + kind = check.rawExpr(x, s$1.X, $ifaceNil); + msg = ""; + _ref$1 = x.mode; + if (_ref$1 === 2) { + msg = "must be called"; + } else if (_ref$1 === 3) { + msg = "is not an expression"; + } else { + if (kind === 2) { + return; + } + msg = "is not used"; + } + check.errorf(x.pos(), "%s %s", new ($sliceType($emptyInterface))([x, new $String(msg)])); + } else if ($assertType(_ref, ($ptrType(ast.SendStmt)), true)[1]) { + s$1 = _ref.$val; + _tmp = new operand.Ptr(); $copy(_tmp, new operand.Ptr(), operand); _tmp$1 = new operand.Ptr(); $copy(_tmp$1, new operand.Ptr(), operand); ch = new operand.Ptr(); $copy(ch, _tmp, operand); x$1 = new operand.Ptr(); $copy(x$1, _tmp$1, operand); + check.expr(ch, s$1.Chan); + check.expr(x$1, s$1.Value); + if ((ch.mode === 0) || (x$1.mode === 0)) { + return; + } + _tuple = $assertType(ch.typ.Underlying(), ($ptrType(Chan)), true); tch = _tuple[0]; ok = _tuple[1]; + if (!ok || (tch.dir === 2) || !check.assignment(x$1, tch.elem)) { + if (!((x$1.mode === 0))) { + check.invalidOp(ch.pos(), "cannot send %s to channel %s", new ($sliceType($emptyInterface))([x$1, ch])); + } + } + } else if ($assertType(_ref, ($ptrType(ast.IncDecStmt)), true)[1]) { + s$1 = _ref.$val; + op = 0; + _ref$2 = s$1.Tok; + if (_ref$2 === 37) { + op = 12; + } else if (_ref$2 === 38) { + op = 13; + } else { + check.invalidAST(s$1.TokPos, "unknown inc/dec operation %s", new ($sliceType($emptyInterface))([new token.Token(s$1.Tok)])); + return; + } + x$2 = new operand.Ptr(); $copy(x$2, new operand.Ptr(), operand); + Y = new ast.BasicLit.Ptr(s$1.X.Pos(), 5, "1"); + check.binary(x$2, s$1.X, Y, op); + if (x$2.mode === 0) { + return; + } + check.assignVar(s$1.X, x$2); + } else if ($assertType(_ref, ($ptrType(ast.AssignStmt)), true)[1]) { + s$1 = _ref.$val; + _ref$3 = s$1.Tok; + if (_ref$3 === 42 || _ref$3 === 47) { + if (s$1.Lhs.$length === 0) { + check.invalidAST(s$1.Pos(), "missing lhs in assignment", new ($sliceType($emptyInterface))([])); + return; + } + if (s$1.Tok === 47) { + check.shortVarDecl(s$1.TokPos, s$1.Lhs, s$1.Rhs); + } else { + check.assignVars(s$1.Lhs, s$1.Rhs); + } + } else { + if (!((s$1.Lhs.$length === 1)) || !((s$1.Rhs.$length === 1))) { + check.errorf(s$1.TokPos, "assignment operation %s requires single-valued expressions", new ($sliceType($emptyInterface))([new token.Token(s$1.Tok)])); + return; + } + op$1 = assignOp(s$1.Tok); + if (op$1 === 0) { + check.invalidAST(s$1.TokPos, "unknown assignment operation %s", new ($sliceType($emptyInterface))([new token.Token(s$1.Tok)])); + return; + } + x$3 = new operand.Ptr(); $copy(x$3, new operand.Ptr(), operand); + check.binary(x$3, (x$4 = s$1.Lhs, ((0 < 0 || 0 >= x$4.$length) ? $throwRuntimeError("index out of range") : x$4.$array[x$4.$offset + 0])), (x$5 = s$1.Rhs, ((0 < 0 || 0 >= x$5.$length) ? $throwRuntimeError("index out of range") : x$5.$array[x$5.$offset + 0])), op$1); + if (x$3.mode === 0) { + return; + } + check.assignVar((x$6 = s$1.Lhs, ((0 < 0 || 0 >= x$6.$length) ? $throwRuntimeError("index out of range") : x$6.$array[x$6.$offset + 0])), x$3); + } + } else if ($assertType(_ref, ($ptrType(ast.GoStmt)), true)[1]) { + s$1 = _ref.$val; + check.suspendedCall("go", s$1.Call); + } else if ($assertType(_ref, ($ptrType(ast.DeferStmt)), true)[1]) { + s$1 = _ref.$val; + check.suspendedCall("defer", s$1.Call); + } else if ($assertType(_ref, ($ptrType(ast.ReturnStmt)), true)[1]) { + s$1 = _ref.$val; + res = check.context.sig.results; + if (res.Len() > 0) { + if ((s$1.Results.$length === 0) && !((x$7 = res.vars, ((0 < 0 || 0 >= x$7.$length) ? $throwRuntimeError("index out of range") : x$7.$array[x$7.$offset + 0])).object.name === "")) { + _ref$4 = res.vars; + _i = 0; + while (_i < _ref$4.$length) { + obj = ((_i < 0 || _i >= _ref$4.$length) ? $throwRuntimeError("index out of range") : _ref$4.$array[_ref$4.$offset + _i]); + alt = check.context.scope.LookupParent(obj.object.name); + if (!($interfaceIsEqual(alt, $ifaceNil)) && !($interfaceIsEqual(alt, obj))) { + check.errorf(s$1.Pos(), "result parameter %s not in scope at return", new ($sliceType($emptyInterface))([new $String(obj.object.name)])); + check.errorf(alt.Pos(), "\tinner declaration of %s", new ($sliceType($emptyInterface))([obj])); + } + _i++; + } + } else { + check.initVars(res.vars, s$1.Results, s$1.Return); + } + } else if (s$1.Results.$length > 0) { + check.error((x$8 = s$1.Results, ((0 < 0 || 0 >= x$8.$length) ? $throwRuntimeError("index out of range") : x$8.$array[x$8.$offset + 0])).Pos(), "no result values expected"); + check.use(s$1.Results); + } + } else if ($assertType(_ref, ($ptrType(ast.BranchStmt)), true)[1]) { + s$1 = _ref.$val; + if (!(s$1.Label === ($ptrType(ast.Ident)).nil)) { + check.context.hasLabel = true; + return; + } + _ref$5 = s$1.Tok; + if (_ref$5 === 61) { + if (((ctxt & 1) >>> 0) === 0) { + check.error(s$1.Pos(), "break not in for, switch, or select statement"); + } + } else if (_ref$5 === 65) { + if (((ctxt & 2) >>> 0) === 0) { + check.error(s$1.Pos(), "continue not in for statement"); + } + } else if (_ref$5 === 69) { + if (((ctxt & 4) >>> 0) === 0) { + check.error(s$1.Pos(), "fallthrough statement out of place"); + } + } else { + check.invalidAST(s$1.Pos(), "branch statement: %s", new ($sliceType($emptyInterface))([new token.Token(s$1.Tok)])); + } + } else if ($assertType(_ref, ($ptrType(ast.BlockStmt)), true)[1]) { + s$1 = _ref.$val; + check.openScope(s$1, "block"); + $deferred.push([$methodVal(check, "closeScope"), []]); + check.stmtList(inner, s$1.List); + } else if ($assertType(_ref, ($ptrType(ast.IfStmt)), true)[1]) { + s$1 = _ref.$val; + check.openScope(s$1, "if"); + $deferred.push([$methodVal(check, "closeScope"), []]); + check.simpleStmt(s$1.Init); + x$9 = new operand.Ptr(); $copy(x$9, new operand.Ptr(), operand); + check.expr(x$9, s$1.Cond); + if (!((x$9.mode === 0)) && !isBoolean(x$9.typ)) { + check.error(s$1.Cond.Pos(), "non-boolean condition in if statement"); + } + check.stmt(inner, s$1.Body); + if (!($interfaceIsEqual(s$1.Else, $ifaceNil))) { + check.stmt(inner, s$1.Else); + } + } else if ($assertType(_ref, ($ptrType(ast.SwitchStmt)), true)[1]) { + s$1 = _ref.$val; + inner = (inner | (1)) >>> 0; + check.openScope(s$1, "switch"); + $deferred.push([$methodVal(check, "closeScope"), []]); + check.simpleStmt(s$1.Init); + x$10 = new operand.Ptr(); $copy(x$10, new operand.Ptr(), operand); + if (!($interfaceIsEqual(s$1.Tag, $ifaceNil))) { + check.expr(x$10, s$1.Tag); + } else { + x$10.mode = 4; + x$10.typ = $pkg.Typ[1]; + x$10.val = exact.MakeBool(true); + x$10.expr = new ast.Ident.Ptr(s$1.Body.Lbrace, "true", ($ptrType(ast.Object)).nil); } - _i++; - } - _ref$1 = x.R32; - _i$1 = 0; - while (_i$1 < _ref$1.$length) { - xr$1 = new unicode.Range32.Ptr(); $copy(xr$1, ((_i$1 < 0 || _i$1 >= _ref$1.$length) ? $throwRuntimeError("index out of range") : _ref$1.$array[_ref$1.$offset + _i$1]), unicode.Range32); - _tmp$3 = (xr$1.Lo >> 0); _tmp$4 = (xr$1.Hi >> 0); _tmp$5 = (xr$1.Stride >> 0); lo$1 = _tmp$3; hi$1 = _tmp$4; stride$1 = _tmp$5; - if (stride$1 === 1) { - r = appendRange(r, lo$1, hi$1); + check.multipleDefaults(s$1.Body.List); + _ref$6 = s$1.Body.List; + _i$1 = 0; + while (_i$1 < _ref$6.$length) { + i = _i$1; + c = ((_i$1 < 0 || _i$1 >= _ref$6.$length) ? $throwRuntimeError("index out of range") : _ref$6.$array[_ref$6.$offset + _i$1]); + _tuple$1 = $assertType(c, ($ptrType(ast.CaseClause)), true); clause = _tuple$1[0]; + if (clause === ($ptrType(ast.CaseClause)).nil) { + check.invalidAST(c.Pos(), "incorrect expression switch case", new ($sliceType($emptyInterface))([])); + _i$1++; + continue; + } + if (!((x$10.mode === 0))) { + check.caseValues($clone(x$10, operand), clause.List); + } + check.openScope(clause, "case"); + inner$1 = inner; + if ((i + 1 >> 0) < s$1.Body.List.$length) { + inner$1 = (inner$1 | (4)) >>> 0; + } + check.stmtList(inner$1, clause.Body); + check.closeScope(); _i$1++; - continue; } - c$1 = lo$1; - while (c$1 <= hi$1) { - r = appendRange(r, c$1, c$1); - c$1 = c$1 + (stride$1) >> 0; + } else if ($assertType(_ref, ($ptrType(ast.TypeSwitchStmt)), true)[1]) { + s$1 = _ref.$val; + inner = (inner | (1)) >>> 0; + check.openScope(s$1, "type switch"); + $deferred.push([$methodVal(check, "closeScope"), []]); + check.simpleStmt(s$1.Init); + lhs = ($ptrType(ast.Ident)).nil; + rhs = $ifaceNil; + _ref$7 = s$1.Assign; + if ($assertType(_ref$7, ($ptrType(ast.ExprStmt)), true)[1]) { + guard = _ref$7.$val; + rhs = guard.X; + } else if ($assertType(_ref$7, ($ptrType(ast.AssignStmt)), true)[1]) { + guard = _ref$7.$val; + if (!((guard.Lhs.$length === 1)) || !((guard.Tok === 47)) || !((guard.Rhs.$length === 1))) { + check.invalidAST(s$1.Pos(), "incorrect form of type switch guard", new ($sliceType($emptyInterface))([])); + return; + } + _tuple$2 = $assertType((x$11 = guard.Lhs, ((0 < 0 || 0 >= x$11.$length) ? $throwRuntimeError("index out of range") : x$11.$array[x$11.$offset + 0])), ($ptrType(ast.Ident)), true); lhs = _tuple$2[0]; + if (lhs === ($ptrType(ast.Ident)).nil) { + check.invalidAST(s$1.Pos(), "incorrect form of type switch guard", new ($sliceType($emptyInterface))([])); + return; + } + check.recordDef(lhs, $ifaceNil); + rhs = (x$12 = guard.Rhs, ((0 < 0 || 0 >= x$12.$length) ? $throwRuntimeError("index out of range") : x$12.$array[x$12.$offset + 0])); + } else { + guard = _ref$7; + check.invalidAST(s$1.Pos(), "incorrect form of type switch guard", new ($sliceType($emptyInterface))([])); + return; } - _i$1++; - } - return r; - }; - appendNegatedTable = function(r, x) { - var nextLo, _ref, _i, xr, _tmp, _tmp$1, _tmp$2, lo, hi, stride, c, _ref$1, _i$1, xr$1, _tmp$3, _tmp$4, _tmp$5, lo$1, hi$1, stride$1, c$1; - nextLo = 0; - _ref = x.R16; - _i = 0; - while (_i < _ref.$length) { - xr = new unicode.Range16.Ptr(); $copy(xr, ((_i < 0 || _i >= _ref.$length) ? $throwRuntimeError("index out of range") : _ref.$array[_ref.$offset + _i]), unicode.Range16); - _tmp = (xr.Lo >> 0); _tmp$1 = (xr.Hi >> 0); _tmp$2 = (xr.Stride >> 0); lo = _tmp; hi = _tmp$1; stride = _tmp$2; - if (stride === 1) { - if (nextLo <= (lo - 1 >> 0)) { - r = appendRange(r, nextLo, lo - 1 >> 0); + _tuple$3 = $assertType(rhs, ($ptrType(ast.TypeAssertExpr)), true); expr = _tuple$3[0]; + if (expr === ($ptrType(ast.TypeAssertExpr)).nil || !($interfaceIsEqual(expr.Type, $ifaceNil))) { + check.invalidAST(s$1.Pos(), "incorrect form of type switch guard", new ($sliceType($emptyInterface))([])); + return; + } + x$13 = new operand.Ptr(); $copy(x$13, new operand.Ptr(), operand); + check.expr(x$13, expr.X); + if (x$13.mode === 0) { + return; + } + _tuple$4 = $assertType(x$13.typ.Underlying(), ($ptrType(Interface)), true); xtyp = _tuple$4[0]; + if (xtyp === ($ptrType(Interface)).nil) { + check.errorf(x$13.pos(), "%s is not an interface", new ($sliceType($emptyInterface))([x$13])); + return; + } + check.multipleDefaults(s$1.Body.List); + lhsVars = ($sliceType(($ptrType(Var)))).nil; + seen = new $Map(); + _ref$8 = s$1.Body.List; + _i$2 = 0; + while (_i$2 < _ref$8.$length) { + s$2 = ((_i$2 < 0 || _i$2 >= _ref$8.$length) ? $throwRuntimeError("index out of range") : _ref$8.$array[_ref$8.$offset + _i$2]); + _tuple$5 = $assertType(s$2, ($ptrType(ast.CaseClause)), true); clause$1 = _tuple$5[0]; + if (clause$1 === ($ptrType(ast.CaseClause)).nil) { + check.invalidAST(s$2.Pos(), "incorrect type switch case", new ($sliceType($emptyInterface))([])); + _i$2++; + continue; } - nextLo = hi + 1 >> 0; - _i++; - continue; + T = check.caseTypes(x$13, xtyp, clause$1.List, seen); + check.openScope(clause$1, "case"); + if (!(lhs === ($ptrType(ast.Ident)).nil)) { + if (!((clause$1.List.$length === 1)) || $interfaceIsEqual(T, $ifaceNil)) { + T = x$13.typ; + } + obj$1 = NewVar(lhs.Pos(), check.pkg, lhs.Name, T); + check.declare(check.context.scope, ($ptrType(ast.Ident)).nil, obj$1); + check.recordImplicit(clause$1, obj$1); + lhsVars = $append(lhsVars, obj$1); + } + check.stmtList(inner, clause$1.Body); + check.closeScope(); + _i$2++; } - c = lo; - while (c <= hi) { - if (nextLo <= (c - 1 >> 0)) { - r = appendRange(r, nextLo, c - 1 >> 0); + if (!(lhs === ($ptrType(ast.Ident)).nil)) { + used = false; + _ref$9 = lhsVars; + _i$3 = 0; + while (_i$3 < _ref$9.$length) { + v = ((_i$3 < 0 || _i$3 >= _ref$9.$length) ? $throwRuntimeError("index out of range") : _ref$9.$array[_ref$9.$offset + _i$3]); + if (v.object.used) { + used = true; + } + v.object.used = true; + _i$3++; + } + if (!used) { + check.softErrorf(lhs.Pos(), "%s declared but not used", new ($sliceType($emptyInterface))([new $String(lhs.Name)])); } - nextLo = c + 1 >> 0; - c = c + (stride) >> 0; } - _i++; - } - _ref$1 = x.R32; - _i$1 = 0; - while (_i$1 < _ref$1.$length) { - xr$1 = new unicode.Range32.Ptr(); $copy(xr$1, ((_i$1 < 0 || _i$1 >= _ref$1.$length) ? $throwRuntimeError("index out of range") : _ref$1.$array[_ref$1.$offset + _i$1]), unicode.Range32); - _tmp$3 = (xr$1.Lo >> 0); _tmp$4 = (xr$1.Hi >> 0); _tmp$5 = (xr$1.Stride >> 0); lo$1 = _tmp$3; hi$1 = _tmp$4; stride$1 = _tmp$5; - if (stride$1 === 1) { - if (nextLo <= (lo$1 - 1 >> 0)) { - r = appendRange(r, nextLo, lo$1 - 1 >> 0); + } else if ($assertType(_ref, ($ptrType(ast.SelectStmt)), true)[1]) { + s$1 = _ref.$val; + inner = (inner | (1)) >>> 0; + check.multipleDefaults(s$1.Body.List); + _ref$10 = s$1.Body.List; + _i$4 = 0; + while (_i$4 < _ref$10.$length) { + s$3 = ((_i$4 < 0 || _i$4 >= _ref$10.$length) ? $throwRuntimeError("index out of range") : _ref$10.$array[_ref$10.$offset + _i$4]); + _tuple$6 = $assertType(s$3, ($ptrType(ast.CommClause)), true); clause$2 = _tuple$6[0]; + if (clause$2 === ($ptrType(ast.CommClause)).nil) { + _i$4++; + continue; } - nextLo = hi$1 + 1 >> 0; - _i$1++; - continue; + valid = false; + rhs$1 = $ifaceNil; + _ref$11 = clause$2.Comm; + if (_ref$11 === $ifaceNil || $assertType(_ref$11, ($ptrType(ast.SendStmt)), true)[1]) { + s$4 = _ref$11; + valid = true; + } else if ($assertType(_ref$11, ($ptrType(ast.AssignStmt)), true)[1]) { + s$4 = _ref$11.$val; + if (s$4.Rhs.$length === 1) { + rhs$1 = (x$14 = s$4.Rhs, ((0 < 0 || 0 >= x$14.$length) ? $throwRuntimeError("index out of range") : x$14.$array[x$14.$offset + 0])); + } + } else if ($assertType(_ref$11, ($ptrType(ast.ExprStmt)), true)[1]) { + s$4 = _ref$11.$val; + rhs$1 = s$4.X; + } + if (!($interfaceIsEqual(rhs$1, $ifaceNil))) { + _tuple$7 = $assertType(unparen(rhs$1), ($ptrType(ast.UnaryExpr)), true); x$15 = _tuple$7[0]; + if (!(x$15 === ($ptrType(ast.UnaryExpr)).nil) && (x$15.Op === 36)) { + valid = true; + } + } + if (!valid) { + check.error(clause$2.Comm.Pos(), "select case must be send or receive (possibly with assignment)"); + _i$4++; + continue; + } + check.openScope(s$3, "case"); + $deferred.push([$methodVal(check, "closeScope"), []]); + if (!($interfaceIsEqual(clause$2.Comm, $ifaceNil))) { + check.stmt(inner, clause$2.Comm); + } + check.stmtList(inner, clause$2.Body); + _i$4++; } - c$1 = lo$1; - while (c$1 <= hi$1) { - if (nextLo <= (c$1 - 1 >> 0)) { - r = appendRange(r, nextLo, c$1 - 1 >> 0); + } else if ($assertType(_ref, ($ptrType(ast.ForStmt)), true)[1]) { + s$1 = _ref.$val; + inner = (inner | (3)) >>> 0; + check.openScope(s$1, "for"); + $deferred.push([$methodVal(check, "closeScope"), []]); + check.simpleStmt(s$1.Init); + if (!($interfaceIsEqual(s$1.Cond, $ifaceNil))) { + x$16 = new operand.Ptr(); $copy(x$16, new operand.Ptr(), operand); + check.expr(x$16, s$1.Cond); + if (!((x$16.mode === 0)) && !isBoolean(x$16.typ)) { + check.error(s$1.Cond.Pos(), "non-boolean condition in for statement"); } - nextLo = c$1 + 1 >> 0; - c$1 = c$1 + (stride$1) >> 0; } - _i$1++; - } - if (nextLo <= 1114111) { - r = appendRange(r, nextLo, 1114111); - } - return r; - }; - negateClass = function(r) { - var nextLo, w, i, _tmp, _tmp$1, x, lo, hi, x$1; - nextLo = 0; - w = 0; - i = 0; - while (i < r.$length) { - _tmp = ((i < 0 || i >= r.$length) ? $throwRuntimeError("index out of range") : r.$array[r.$offset + i]); _tmp$1 = (x = i + 1 >> 0, ((x < 0 || x >= r.$length) ? $throwRuntimeError("index out of range") : r.$array[r.$offset + x])); lo = _tmp; hi = _tmp$1; - if (nextLo <= (lo - 1 >> 0)) { - (w < 0 || w >= r.$length) ? $throwRuntimeError("index out of range") : r.$array[r.$offset + w] = nextLo; - (x$1 = w + 1 >> 0, (x$1 < 0 || x$1 >= r.$length) ? $throwRuntimeError("index out of range") : r.$array[r.$offset + x$1] = lo - 1 >> 0); - w = w + (2) >> 0; + check.simpleStmt(s$1.Post); + _tuple$8 = $assertType(s$1.Post, ($ptrType(ast.AssignStmt)), true); s$5 = _tuple$8[0]; + if (!(s$5 === ($ptrType(ast.AssignStmt)).nil) && (s$5.Tok === 47)) { + check.softErrorf(s$5.Pos(), "cannot declare in post statement", new ($sliceType($emptyInterface))([])); + check.use(s$5.Lhs); } - nextLo = hi + 1 >> 0; - i = i + (2) >> 0; - } - r = $subslice(r, 0, w); - if (nextLo <= 1114111) { - r = $append(r, nextLo, 1114111); - } - return r; - }; - ranges.Ptr.prototype.Less = function(i, j) { - var ra, p, x, x$1, x$2, x$3; - ra = new ranges.Ptr(); $copy(ra, this, ranges); - p = ra.p.$get(); - i = (x = 2, (((i >>> 16 << 16) * x >> 0) + (i << 16 >>> 16) * x) >> 0); - j = (x$1 = 2, (((j >>> 16 << 16) * x$1 >> 0) + (j << 16 >>> 16) * x$1) >> 0); - return ((i < 0 || i >= p.$length) ? $throwRuntimeError("index out of range") : p.$array[p.$offset + i]) < ((j < 0 || j >= p.$length) ? $throwRuntimeError("index out of range") : p.$array[p.$offset + j]) || (((i < 0 || i >= p.$length) ? $throwRuntimeError("index out of range") : p.$array[p.$offset + i]) === ((j < 0 || j >= p.$length) ? $throwRuntimeError("index out of range") : p.$array[p.$offset + j])) && (x$2 = i + 1 >> 0, ((x$2 < 0 || x$2 >= p.$length) ? $throwRuntimeError("index out of range") : p.$array[p.$offset + x$2])) > (x$3 = j + 1 >> 0, ((x$3 < 0 || x$3 >= p.$length) ? $throwRuntimeError("index out of range") : p.$array[p.$offset + x$3])); - }; - ranges.prototype.Less = function(i, j) { return this.$val.Less(i, j); }; - ranges.Ptr.prototype.Len = function() { - var ra, _q; - ra = new ranges.Ptr(); $copy(ra, this, ranges); - return (_q = ra.p.$get().$length / 2, (_q === _q && _q !== 1/0 && _q !== -1/0) ? _q >> 0 : $throwRuntimeError("integer divide by zero")); - }; - ranges.prototype.Len = function() { return this.$val.Len(); }; - ranges.Ptr.prototype.Swap = function(i, j) { - var ra, p, x, x$1, _tmp, _tmp$1, x$2, _tmp$2, _tmp$3, x$3, x$4, x$5; - ra = new ranges.Ptr(); $copy(ra, this, ranges); - p = ra.p.$get(); - i = (x = 2, (((i >>> 16 << 16) * x >> 0) + (i << 16 >>> 16) * x) >> 0); - j = (x$1 = 2, (((j >>> 16 << 16) * x$1 >> 0) + (j << 16 >>> 16) * x$1) >> 0); - _tmp = ((j < 0 || j >= p.$length) ? $throwRuntimeError("index out of range") : p.$array[p.$offset + j]); _tmp$1 = (x$2 = j + 1 >> 0, ((x$2 < 0 || x$2 >= p.$length) ? $throwRuntimeError("index out of range") : p.$array[p.$offset + x$2])); _tmp$2 = ((i < 0 || i >= p.$length) ? $throwRuntimeError("index out of range") : p.$array[p.$offset + i]); _tmp$3 = (x$3 = i + 1 >> 0, ((x$3 < 0 || x$3 >= p.$length) ? $throwRuntimeError("index out of range") : p.$array[p.$offset + x$3])); (i < 0 || i >= p.$length) ? $throwRuntimeError("index out of range") : p.$array[p.$offset + i] = _tmp; (x$4 = i + 1 >> 0, (x$4 < 0 || x$4 >= p.$length) ? $throwRuntimeError("index out of range") : p.$array[p.$offset + x$4] = _tmp$1); (j < 0 || j >= p.$length) ? $throwRuntimeError("index out of range") : p.$array[p.$offset + j] = _tmp$2; (x$5 = j + 1 >> 0, (x$5 < 0 || x$5 >= p.$length) ? $throwRuntimeError("index out of range") : p.$array[p.$offset + x$5] = _tmp$3); - }; - ranges.prototype.Swap = function(i, j) { return this.$val.Swap(i, j); }; - checkUTF8 = function(s) { - var _tuple, rune, size; - while (!(s === "")) { - _tuple = utf8.DecodeRuneInString(s); rune = _tuple[0]; size = _tuple[1]; - if ((rune === 65533) && (size === 1)) { - return new Error.Ptr("invalid UTF-8", s); + check.stmt(inner, s$1.Body); + } else if ($assertType(_ref, ($ptrType(ast.RangeStmt)), true)[1]) { + s$1 = _ref.$val; + inner = (inner | (3)) >>> 0; + check.openScope(s$1, "for"); + $deferred.push([$methodVal(check, "closeScope"), []]); + decl = s$1.Tok === 47; + x$17 = new operand.Ptr(); $copy(x$17, new operand.Ptr(), operand); + check.expr(x$17, s$1.X); + if (x$17.mode === 0) { + if (!decl) { + check.stmt(inner, s$1.Body); + } + return; } - s = s.substring(size); - } - return $ifaceNil; - }; - nextRune = function(s) { - var c = 0, t = "", err = $ifaceNil, _tuple, size, _tmp, _tmp$1, _tmp$2, _tmp$3, _tmp$4, _tmp$5; - _tuple = utf8.DecodeRuneInString(s); c = _tuple[0]; size = _tuple[1]; - if ((c === 65533) && (size === 1)) { - _tmp = 0; _tmp$1 = ""; _tmp$2 = new Error.Ptr("invalid UTF-8", s); c = _tmp; t = _tmp$1; err = _tmp$2; - return [c, t, err]; - } - _tmp$3 = c; _tmp$4 = s.substring(size); _tmp$5 = $ifaceNil; c = _tmp$3; t = _tmp$4; err = _tmp$5; - return [c, t, err]; - }; - isalnum = function(c) { - return 48 <= c && c <= 57 || 65 <= c && c <= 90 || 97 <= c && c <= 122; - }; - unhex = function(c) { - if (48 <= c && c <= 57) { - return c - 48 >> 0; - } - if (97 <= c && c <= 102) { - return (c - 97 >> 0) + 10 >> 0; - } - if (65 <= c && c <= 70) { - return (c - 65 >> 0) + 10 >> 0; - } - return -1; - }; - InstOp.prototype.String = function() { - var i; - i = this.$val !== undefined ? this.$val : this; - if ((i >>> 0) >= (instOpNames.$length >>> 0)) { - return ""; - } - return ((i < 0 || i >= instOpNames.$length) ? $throwRuntimeError("index out of range") : instOpNames.$array[instOpNames.$offset + i]); - }; - $ptrType(InstOp).prototype.String = function() { return new InstOp(this.$get()).String(); }; - EmptyOpContext = $pkg.EmptyOpContext = function(r1, r2) { - var op, boundary; - op = 32; - boundary = 0; - if (IsWordChar(r1)) { - boundary = 1; - } else if (r1 === 10) { - op = (op | (1)) >>> 0; - } else if (r1 < 0) { - op = (op | (5)) >>> 0; - } - if (IsWordChar(r2)) { - boundary = (boundary ^ (1)) << 24 >>> 24; - } else if (r2 === 10) { - op = (op | (2)) >>> 0; - } else if (r2 < 0) { - op = (op | (10)) >>> 0; - } - if (!((boundary === 0))) { - op = (op ^ (48)) << 24 >>> 24; - } - return op; - }; - IsWordChar = $pkg.IsWordChar = function(r) { - return 65 <= r && r <= 90 || 97 <= r && r <= 122 || 48 <= r && r <= 57 || (r === 95); - }; - Prog.Ptr.prototype.String = function() { - var p, b; - p = this; - b = new bytes.Buffer.Ptr(); $copy(b, new bytes.Buffer.Ptr(), bytes.Buffer); - dumpProg(b, p); - return b.String(); - }; - Prog.prototype.String = function() { return this.$val.String(); }; - Prog.Ptr.prototype.skipNop = function(pc) { - var p, x, i, x$1; - p = this; - i = (x = p.Inst, ((pc < 0 || pc >= x.$length) ? $throwRuntimeError("index out of range") : x.$array[x.$offset + pc])); - while ((i.Op === 6) || (i.Op === 2)) { - pc = i.Out; - i = (x$1 = p.Inst, ((pc < 0 || pc >= x$1.$length) ? $throwRuntimeError("index out of range") : x$1.$array[x$1.$offset + pc])); - } - return [i, pc]; - }; - Prog.prototype.skipNop = function(pc) { return this.$val.skipNop(pc); }; - Inst.Ptr.prototype.op = function() { - var i, op, _ref; - i = this; - op = i.Op; - _ref = op; - if (_ref === 8 || _ref === 9 || _ref === 10) { - op = 7; - } - return op; - }; - Inst.prototype.op = function() { return this.$val.op(); }; - Prog.Ptr.prototype.Prefix = function() { - var prefix = "", complete = false, p, _tuple, i, _tmp, _tmp$1, buf, x, _tuple$1, _tmp$2, _tmp$3; - p = this; - _tuple = p.skipNop((p.Start >>> 0)); i = _tuple[0]; - if (!((i.op() === 7)) || !((i.Rune.$length === 1))) { - _tmp = ""; _tmp$1 = i.Op === 4; prefix = _tmp; complete = _tmp$1; - return [prefix, complete]; - } - buf = new bytes.Buffer.Ptr(); $copy(buf, new bytes.Buffer.Ptr(), bytes.Buffer); - while ((i.op() === 7) && (i.Rune.$length === 1) && ((((i.Arg << 16 >>> 16) & 1) >>> 0) === 0)) { - buf.WriteRune((x = i.Rune, ((0 < 0 || 0 >= x.$length) ? $throwRuntimeError("index out of range") : x.$array[x.$offset + 0]))); - _tuple$1 = p.skipNop(i.Out); i = _tuple$1[0]; - } - _tmp$2 = buf.String(); _tmp$3 = i.Op === 4; prefix = _tmp$2; complete = _tmp$3; - return [prefix, complete]; - }; - Prog.prototype.Prefix = function() { return this.$val.Prefix(); }; - Prog.Ptr.prototype.StartCond = function() { - var p, flag, pc, x, i, _ref, x$1; - p = this; - flag = 0; - pc = (p.Start >>> 0); - i = (x = p.Inst, ((pc < 0 || pc >= x.$length) ? $throwRuntimeError("index out of range") : x.$array[x.$offset + pc])); - Loop: - while (true) { - _ref = i.Op; - if (_ref === 3) { - flag = (flag | ((i.Arg << 24 >>> 24))) >>> 0; - } else if (_ref === 5) { - return 255; - } else if (_ref === 2 || _ref === 6) { - } else { - break Loop; + _tmp$2 = $ifaceNil; _tmp$3 = $ifaceNil; key = _tmp$2; val = _tmp$3; + _ref$12 = x$17.typ.Underlying(); + if ($assertType(_ref$12, ($ptrType(Basic)), true)[1]) { + typ = _ref$12.$val; + if (isString(typ)) { + key = $pkg.Typ[2]; + val = $pkg.UniverseRune; + } + } else if ($assertType(_ref$12, ($ptrType(Array)), true)[1]) { + typ = _ref$12.$val; + key = $pkg.Typ[2]; + val = typ.elem; + } else if ($assertType(_ref$12, ($ptrType(Slice)), true)[1]) { + typ = _ref$12.$val; + key = $pkg.Typ[2]; + val = typ.elem; + } else if ($assertType(_ref$12, ($ptrType(Pointer)), true)[1]) { + typ = _ref$12.$val; + _tuple$9 = $assertType(typ.base.Underlying(), ($ptrType(Array)), true); typ$1 = _tuple$9[0]; + if (!(typ$1 === ($ptrType(Array)).nil)) { + key = $pkg.Typ[2]; + val = typ$1.elem; + } + } else if ($assertType(_ref$12, ($ptrType(Map)), true)[1]) { + typ = _ref$12.$val; + key = typ.key; + val = typ.elem; + } else if ($assertType(_ref$12, ($ptrType(Chan)), true)[1]) { + typ = _ref$12.$val; + key = typ.elem; + val = $pkg.Typ[0]; + if (typ.dir === 1) { + check.errorf(x$17.pos(), "cannot range over send-only channel %s", new ($sliceType($emptyInterface))([x$17])); + } + if (!($interfaceIsEqual(s$1.Value, $ifaceNil))) { + check.errorf(s$1.Value.Pos(), "iteration over %s permits only one iteration variable", new ($sliceType($emptyInterface))([x$17])); + } } - pc = i.Out; - i = (x$1 = p.Inst, ((pc < 0 || pc >= x$1.$length) ? $throwRuntimeError("index out of range") : x$1.$array[x$1.$offset + pc])); - } - return flag; - }; - Prog.prototype.StartCond = function() { return this.$val.StartCond(); }; - Inst.Ptr.prototype.MatchRune = function(r) { - var i; - i = this; - return !((i.MatchRunePos(r) === -1)); - }; - Inst.prototype.MatchRune = function(r) { return this.$val.MatchRune(r); }; - Inst.Ptr.prototype.MatchRunePos = function(r) { - var i, rune, r0, r1, j, x, _q, lo, _q$1, hi, _q$2, m, x$1, c, x$2; - i = this; - rune = i.Rune; - if (rune.$length === 1) { - r0 = ((0 < 0 || 0 >= rune.$length) ? $throwRuntimeError("index out of range") : rune.$array[rune.$offset + 0]); - if (r === r0) { - return 0; + if ($interfaceIsEqual(key, $ifaceNil)) { + check.errorf(x$17.pos(), "cannot range over %s", new ($sliceType($emptyInterface))([x$17])); + if (!decl) { + check.stmt(inner, s$1.Body); + } + return; } - if (!(((((i.Arg << 16 >>> 16) & 1) >>> 0) === 0))) { - r1 = unicode.SimpleFold(r0); - while (!((r1 === r0))) { - if (r === r1) { - return 0; + lhs$1 = $toNativeArray("Interface", [s$1.Key, s$1.Value]); + rhs$2 = $toNativeArray("Interface", [key, val]); + if (decl) { + vars = ($sliceType(($ptrType(Var)))).nil; + _ref$13 = lhs$1; + _i$5 = 0; + while (_i$5 < 2) { + i$1 = _i$5; + lhs$2 = ((_i$5 < 0 || _i$5 >= _ref$13.length) ? $throwRuntimeError("index out of range") : _ref$13[_i$5]); + if ($interfaceIsEqual(lhs$2, $ifaceNil)) { + _i$5++; + continue; + } + obj$2 = ($ptrType(Var)).nil; + _tuple$10 = $assertType(lhs$2, ($ptrType(ast.Ident)), true); ident = _tuple$10[0]; + if (!(ident === ($ptrType(ast.Ident)).nil)) { + name = ident.Name; + obj$2 = NewVar(ident.Pos(), check.pkg, name, $ifaceNil); + check.recordDef(ident, obj$2); + if (!(name === "_")) { + vars = $append(vars, obj$2); + } + } else { + check.errorf(lhs$2.Pos(), "cannot declare %s", new ($sliceType($emptyInterface))([lhs$2])); + obj$2 = NewVar(lhs$2.Pos(), check.pkg, "_", $ifaceNil); } - r1 = unicode.SimpleFold(r1); + x$17.mode = 7; + x$17.expr = lhs$2; + x$17.typ = ((i$1 < 0 || i$1 >= rhs$2.length) ? $throwRuntimeError("index out of range") : rhs$2[i$1]); + check.initVar(obj$2, x$17, false); + _i$5++; } - } - return -1; - } - j = 0; - while (j < rune.$length && j <= 8) { - if (r < ((j < 0 || j >= rune.$length) ? $throwRuntimeError("index out of range") : rune.$array[rune.$offset + j])) { - return -1; - } - if (r <= (x = j + 1 >> 0, ((x < 0 || x >= rune.$length) ? $throwRuntimeError("index out of range") : rune.$array[rune.$offset + x]))) { - return (_q = j / 2, (_q === _q && _q !== 1/0 && _q !== -1/0) ? _q >> 0 : $throwRuntimeError("integer divide by zero")); - } - j = j + (2) >> 0; - } - lo = 0; - hi = (_q$1 = rune.$length / 2, (_q$1 === _q$1 && _q$1 !== 1/0 && _q$1 !== -1/0) ? _q$1 >> 0 : $throwRuntimeError("integer divide by zero")); - while (lo < hi) { - m = lo + (_q$2 = ((hi - lo >> 0)) / 2, (_q$2 === _q$2 && _q$2 !== 1/0 && _q$2 !== -1/0) ? _q$2 >> 0 : $throwRuntimeError("integer divide by zero")) >> 0; - c = (x$1 = (((2 >>> 16 << 16) * m >> 0) + (2 << 16 >>> 16) * m) >> 0, ((x$1 < 0 || x$1 >= rune.$length) ? $throwRuntimeError("index out of range") : rune.$array[rune.$offset + x$1])); - if (c <= r) { - if (r <= (x$2 = ((((2 >>> 16 << 16) * m >> 0) + (2 << 16 >>> 16) * m) >> 0) + 1 >> 0, ((x$2 < 0 || x$2 >= rune.$length) ? $throwRuntimeError("index out of range") : rune.$array[rune.$offset + x$2]))) { - return m; + if (vars.$length > 0) { + _ref$14 = vars; + _i$6 = 0; + while (_i$6 < _ref$14.$length) { + obj$3 = ((_i$6 < 0 || _i$6 >= _ref$14.$length) ? $throwRuntimeError("index out of range") : _ref$14.$array[_ref$14.$offset + _i$6]); + check.declare(check.context.scope, ($ptrType(ast.Ident)).nil, obj$3); + _i$6++; + } + } else { + check.error(s$1.TokPos, "no new variables on left side of :="); } - lo = m + 1 >> 0; } else { - hi = m; + _ref$15 = lhs$1; + _i$7 = 0; + while (_i$7 < 2) { + i$2 = _i$7; + lhs$3 = ((_i$7 < 0 || _i$7 >= _ref$15.length) ? $throwRuntimeError("index out of range") : _ref$15[_i$7]); + if ($interfaceIsEqual(lhs$3, $ifaceNil)) { + _i$7++; + continue; + } + x$17.mode = 7; + x$17.expr = lhs$3; + x$17.typ = ((i$2 < 0 || i$2 >= rhs$2.length) ? $throwRuntimeError("index out of range") : rhs$2[i$2]); + check.assignVar(lhs$3, x$17); + _i$7++; + } } + check.stmt(inner, s$1.Body); + } else { + s$1 = _ref; + check.error(s$1.Pos(), "invalid statement"); } - return -1; + /* */ } catch(err) { $err = err; } finally { $deferFrames.pop(); $callDeferred($deferred, $err); } }; - Inst.prototype.MatchRunePos = function(r) { return this.$val.MatchRunePos(r); }; - wordRune = function(r) { - return (r === 95) || (65 <= r && r <= 90) || (97 <= r && r <= 122) || (48 <= r && r <= 57); + Checker.prototype.stmt = function(ctxt, s) { return this.$val.stmt(ctxt, s); }; + Basic.Ptr.prototype.Kind = function() { + var b; + b = this; + return b.kind; }; - Inst.Ptr.prototype.MatchEmptyWidth = function(before, after) { - var i, _ref; - i = this; - _ref = (i.Arg << 24 >>> 24); - if (_ref === 1) { - return (before === 10) || (before === -1); - } else if (_ref === 2) { - return (after === 10) || (after === -1); - } else if (_ref === 4) { - return before === -1; - } else if (_ref === 8) { - return after === -1; - } else if (_ref === 16) { - return !(wordRune(before) === wordRune(after)); - } else if (_ref === 32) { - return wordRune(before) === wordRune(after); - } - $panic(new $String("unknown empty width arg")); + Basic.prototype.Kind = function() { return this.$val.Kind(); }; + Basic.Ptr.prototype.Info = function() { + var b; + b = this; + return b.info; }; - Inst.prototype.MatchEmptyWidth = function(before, after) { return this.$val.MatchEmptyWidth(before, after); }; - Inst.Ptr.prototype.String = function() { - var i, b; - i = this; - b = new bytes.Buffer.Ptr(); $copy(b, new bytes.Buffer.Ptr(), bytes.Buffer); - dumpInst(b, i); - return b.String(); + Basic.prototype.Info = function() { return this.$val.Info(); }; + Basic.Ptr.prototype.Name = function() { + var b; + b = this; + return b.name; }; - Inst.prototype.String = function() { return this.$val.String(); }; - bw = function(b, args) { - var _ref, _i, s; - _ref = args; - _i = 0; - while (_i < _ref.$length) { - s = ((_i < 0 || _i >= _ref.$length) ? $throwRuntimeError("index out of range") : _ref.$array[_ref.$offset + _i]); - b.WriteString(s); - _i++; - } + Basic.prototype.Name = function() { return this.$val.Name(); }; + NewArray = $pkg.NewArray = function(elem, len) { + return new Array.Ptr(len, elem); }; - dumpProg = function(b, p) { - var _ref, _i, j, x, i, pc; - _ref = p.Inst; + Array.Ptr.prototype.Len = function() { + var a; + a = this; + return a.len; + }; + Array.prototype.Len = function() { return this.$val.Len(); }; + Array.Ptr.prototype.Elem = function() { + var a; + a = this; + return a.elem; + }; + Array.prototype.Elem = function() { return this.$val.Elem(); }; + NewSlice = $pkg.NewSlice = function(elem) { + return new Slice.Ptr(elem); + }; + Slice.Ptr.prototype.Elem = function() { + var s; + s = this; + return s.elem; + }; + Slice.prototype.Elem = function() { return this.$val.Elem(); }; + NewStruct = $pkg.NewStruct = function(fields, tags) { + var fset, _ref, _i, f; + fset = false; + _ref = fields; _i = 0; while (_i < _ref.$length) { - j = _i; - i = (x = p.Inst, ((j < 0 || j >= x.$length) ? $throwRuntimeError("index out of range") : x.$array[x.$offset + j])); - pc = strconv.Itoa(j); - if (pc.length < 3) { - b.WriteString(" ".substring(pc.length)); - } - if (j === p.Start) { - pc = pc + ("*"); + f = ((_i < 0 || _i >= _ref.$length) ? $throwRuntimeError("index out of range") : _ref.$array[_ref.$offset + _i]); + if (!(f.object.name === "_") && !($interfaceIsEqual(new ($ptrType(objset))(function() { return fset; }, function($v) { fset = $v; }).insert(f), $ifaceNil))) { + $panic(new $String("multiple fields with the same name")); } - bw(b, new ($sliceType($String))([pc, "\t"])); - dumpInst(b, i); - bw(b, new ($sliceType($String))(["\n"])); _i++; } + if (tags.$length > fields.$length) { + $panic(new $String("more tags than fields")); + } + return new Struct.Ptr(fields, tags, ($sliceType($Int64)).nil); }; - u32 = function(i) { - return strconv.FormatUint(new $Uint64(0, i), 10); + Struct.Ptr.prototype.NumFields = function() { + var s; + s = this; + return s.fields.$length; }; - dumpInst = function(b, i) { - var _ref; - _ref = i.Op; - if (_ref === 0) { - bw(b, new ($sliceType($String))(["alt -> ", u32(i.Out), ", ", u32(i.Arg)])); - } else if (_ref === 1) { - bw(b, new ($sliceType($String))(["altmatch -> ", u32(i.Out), ", ", u32(i.Arg)])); - } else if (_ref === 2) { - bw(b, new ($sliceType($String))(["cap ", u32(i.Arg), " -> ", u32(i.Out)])); - } else if (_ref === 3) { - bw(b, new ($sliceType($String))(["empty ", u32(i.Arg), " -> ", u32(i.Out)])); - } else if (_ref === 4) { - bw(b, new ($sliceType($String))(["match"])); - } else if (_ref === 5) { - bw(b, new ($sliceType($String))(["fail"])); - } else if (_ref === 6) { - bw(b, new ($sliceType($String))(["nop -> ", u32(i.Out)])); - } else if (_ref === 7) { - if (i.Rune === ($sliceType($Int32)).nil) { - bw(b, new ($sliceType($String))(["rune "])); - } - bw(b, new ($sliceType($String))(["rune ", strconv.QuoteToASCII($runesToString(i.Rune))])); - if (!(((((i.Arg << 16 >>> 16) & 1) >>> 0) === 0))) { - bw(b, new ($sliceType($String))(["/i"])); - } - bw(b, new ($sliceType($String))([" -> ", u32(i.Out)])); - } else if (_ref === 8) { - bw(b, new ($sliceType($String))(["rune1 ", strconv.QuoteToASCII($runesToString(i.Rune)), " -> ", u32(i.Out)])); - } else if (_ref === 9) { - bw(b, new ($sliceType($String))(["any -> ", u32(i.Out)])); - } else if (_ref === 10) { - bw(b, new ($sliceType($String))(["anynotnl -> ", u32(i.Out)])); + Struct.prototype.NumFields = function() { return this.$val.NumFields(); }; + Struct.Ptr.prototype.Field = function(i) { + var s, x; + s = this; + return (x = s.fields, ((i < 0 || i >= x.$length) ? $throwRuntimeError("index out of range") : x.$array[x.$offset + i])); + }; + Struct.prototype.Field = function(i) { return this.$val.Field(i); }; + Struct.Ptr.prototype.Tag = function(i) { + var s, x; + s = this; + if (i < s.tags.$length) { + return (x = s.tags, ((i < 0 || i >= x.$length) ? $throwRuntimeError("index out of range") : x.$array[x.$offset + i])); } + return ""; }; - Regexp.Ptr.prototype.Equal = function(y) { - var x, _ref, _ref$1, _i, i, r, x$1, _ref$2, _i$1, i$1, sub, x$2, x$3, x$4, x$5, x$6, x$7, x$8; - x = this; - if (x === ($ptrType(Regexp)).nil || y === ($ptrType(Regexp)).nil) { - return x === y; + Struct.prototype.Tag = function(i) { return this.$val.Tag(i); }; + NewPointer = $pkg.NewPointer = function(elem) { + return new Pointer.Ptr(elem); + }; + Pointer.Ptr.prototype.Elem = function() { + var p; + p = this; + return p.base; + }; + Pointer.prototype.Elem = function() { return this.$val.Elem(); }; + NewTuple = $pkg.NewTuple = function(x) { + if (x.$length > 0) { + return new Tuple.Ptr(x); } - if (!((x.Op === y.Op))) { - return false; + return ($ptrType(Tuple)).nil; + }; + Tuple.Ptr.prototype.Len = function() { + var t; + t = this; + if (!(t === ($ptrType(Tuple)).nil)) { + return t.vars.$length; } - _ref = x.Op; - if (_ref === 10) { - if (!((((x.Flags & 256) >>> 0) === ((y.Flags & 256) >>> 0)))) { - return false; - } - } else if (_ref === 3 || _ref === 4) { - if (!((x.Rune.$length === y.Rune.$length))) { - return false; - } - _ref$1 = x.Rune; - _i = 0; - while (_i < _ref$1.$length) { - i = _i; - r = ((_i < 0 || _i >= _ref$1.$length) ? $throwRuntimeError("index out of range") : _ref$1.$array[_ref$1.$offset + _i]); - if (!((r === (x$1 = y.Rune, ((i < 0 || i >= x$1.$length) ? $throwRuntimeError("index out of range") : x$1.$array[x$1.$offset + i]))))) { - return false; - } - _i++; - } - } else if (_ref === 19 || _ref === 18) { - if (!((x.Sub.$length === y.Sub.$length))) { - return false; - } - _ref$2 = x.Sub; - _i$1 = 0; - while (_i$1 < _ref$2.$length) { - i$1 = _i$1; - sub = ((_i$1 < 0 || _i$1 >= _ref$2.$length) ? $throwRuntimeError("index out of range") : _ref$2.$array[_ref$2.$offset + _i$1]); - if (!sub.Equal((x$2 = y.Sub, ((i$1 < 0 || i$1 >= x$2.$length) ? $throwRuntimeError("index out of range") : x$2.$array[x$2.$offset + i$1])))) { - return false; - } - _i$1++; - } - } else if (_ref === 14 || _ref === 15 || _ref === 16) { - if (!((((x.Flags & 32) >>> 0) === ((y.Flags & 32) >>> 0))) || !(x$3 = x.Sub, ((0 < 0 || 0 >= x$3.$length) ? $throwRuntimeError("index out of range") : x$3.$array[x$3.$offset + 0])).Equal((x$4 = y.Sub, ((0 < 0 || 0 >= x$4.$length) ? $throwRuntimeError("index out of range") : x$4.$array[x$4.$offset + 0])))) { - return false; - } - } else if (_ref === 17) { - if (!((((x.Flags & 32) >>> 0) === ((y.Flags & 32) >>> 0))) || !((x.Min === y.Min)) || !((x.Max === y.Max)) || !(x$5 = x.Sub, ((0 < 0 || 0 >= x$5.$length) ? $throwRuntimeError("index out of range") : x$5.$array[x$5.$offset + 0])).Equal((x$6 = y.Sub, ((0 < 0 || 0 >= x$6.$length) ? $throwRuntimeError("index out of range") : x$6.$array[x$6.$offset + 0])))) { - return false; + return 0; + }; + Tuple.prototype.Len = function() { return this.$val.Len(); }; + Tuple.Ptr.prototype.At = function(i) { + var t, x; + t = this; + return (x = t.vars, ((i < 0 || i >= x.$length) ? $throwRuntimeError("index out of range") : x.$array[x.$offset + i])); + }; + Tuple.prototype.At = function(i) { return this.$val.At(i); }; + NewSignature = $pkg.NewSignature = function(scope, recv, params, results, variadic) { + var n, _tuple, ok; + if (variadic) { + n = params.Len(); + if (n === 0) { + $panic(new $String("types.NewSignature: variadic function must have at least one parameter")); } - } else if (_ref === 13) { - if (!((x.Cap === y.Cap)) || !(x.Name === y.Name) || !(x$7 = x.Sub, ((0 < 0 || 0 >= x$7.$length) ? $throwRuntimeError("index out of range") : x$7.$array[x$7.$offset + 0])).Equal((x$8 = y.Sub, ((0 < 0 || 0 >= x$8.$length) ? $throwRuntimeError("index out of range") : x$8.$array[x$8.$offset + 0])))) { - return false; + _tuple = $assertType(params.At(n - 1 >> 0).object.typ, ($ptrType(Slice)), true); ok = _tuple[1]; + if (!ok) { + $panic(new $String("types.NewSignature: variadic parameter must be of unnamed slice type")); } } - return true; + return new Signature.Ptr(scope, recv, params, results, variadic); }; - Regexp.prototype.Equal = function(y) { return this.$val.Equal(y); }; - writeRegexp = function(b, re) { - var _ref, _ref$1, _i, r, _r, x, x$1, x$2, i, _tmp, x$3, _tmp$1, x$4, x$5, lo, hi, i$1, _tmp$2, x$6, _tmp$3, x$7, x$8, lo$1, hi$1, x$9, x$10, x$11, sub, _ref$2, _ref$3, _i$1, sub$1, _ref$4, _i$2, i$2, sub$2; - _ref = re.Op; - switch (0) { default: if (_ref === 1) { - b.WriteString("[^\\x00-\\x{10FFFF}]"); - } else if (_ref === 2) { - b.WriteString("(?:)"); - } else if (_ref === 3) { - if (!((((re.Flags & 1) >>> 0) === 0))) { - b.WriteString("(?i:"); - } - _ref$1 = re.Rune; - _i = 0; - while (_i < _ref$1.$length) { - r = ((_i < 0 || _i >= _ref$1.$length) ? $throwRuntimeError("index out of range") : _ref$1.$array[_ref$1.$offset + _i]); - escape(b, r, false); - _i++; - } - if (!((((re.Flags & 1) >>> 0) === 0))) { - b.WriteString(")"); - } - } else if (_ref === 4) { - if (!(((_r = re.Rune.$length % 2, _r === _r ? _r : $throwRuntimeError("integer divide by zero")) === 0))) { - b.WriteString("[invalid char class]"); - break; - } - b.WriteRune(91); - if (re.Rune.$length === 0) { - b.WriteString("^\\x00-\\x{10FFFF}"); - } else if (((x = re.Rune, ((0 < 0 || 0 >= x.$length) ? $throwRuntimeError("index out of range") : x.$array[x.$offset + 0])) === 0) && ((x$1 = re.Rune, x$2 = re.Rune.$length - 1 >> 0, ((x$2 < 0 || x$2 >= x$1.$length) ? $throwRuntimeError("index out of range") : x$1.$array[x$1.$offset + x$2])) === 1114111)) { - b.WriteRune(94); - i = 1; - while (i < (re.Rune.$length - 1 >> 0)) { - _tmp = (x$3 = re.Rune, ((i < 0 || i >= x$3.$length) ? $throwRuntimeError("index out of range") : x$3.$array[x$3.$offset + i])) + 1 >> 0; _tmp$1 = (x$4 = re.Rune, x$5 = i + 1 >> 0, ((x$5 < 0 || x$5 >= x$4.$length) ? $throwRuntimeError("index out of range") : x$4.$array[x$4.$offset + x$5])) - 1 >> 0; lo = _tmp; hi = _tmp$1; - escape(b, lo, lo === 45); - if (!((lo === hi))) { - b.WriteRune(45); - escape(b, hi, hi === 45); - } - i = i + (2) >> 0; - } - } else { - i$1 = 0; - while (i$1 < re.Rune.$length) { - _tmp$2 = (x$6 = re.Rune, ((i$1 < 0 || i$1 >= x$6.$length) ? $throwRuntimeError("index out of range") : x$6.$array[x$6.$offset + i$1])); _tmp$3 = (x$7 = re.Rune, x$8 = i$1 + 1 >> 0, ((x$8 < 0 || x$8 >= x$7.$length) ? $throwRuntimeError("index out of range") : x$7.$array[x$7.$offset + x$8])); lo$1 = _tmp$2; hi$1 = _tmp$3; - escape(b, lo$1, lo$1 === 45); - if (!((lo$1 === hi$1))) { - b.WriteRune(45); - escape(b, hi$1, hi$1 === 45); - } - i$1 = i$1 + (2) >> 0; - } - } - b.WriteRune(93); - } else if (_ref === 5) { - b.WriteString("(?-s:.)"); - } else if (_ref === 6) { - b.WriteString("(?s:.)"); - } else if (_ref === 7) { - b.WriteRune(94); - } else if (_ref === 8) { - b.WriteRune(36); - } else if (_ref === 9) { - b.WriteString("\\A"); - } else if (_ref === 10) { - if (!((((re.Flags & 256) >>> 0) === 0))) { - b.WriteString("(?-m:$)"); - } else { - b.WriteString("\\z"); - } - } else if (_ref === 11) { - b.WriteString("\\b"); - } else if (_ref === 12) { - b.WriteString("\\B"); - } else if (_ref === 13) { - if (!(re.Name === "")) { - b.WriteString("(?P<"); - b.WriteString(re.Name); - b.WriteRune(62); - } else { - b.WriteRune(40); - } - if (!(((x$9 = re.Sub, ((0 < 0 || 0 >= x$9.$length) ? $throwRuntimeError("index out of range") : x$9.$array[x$9.$offset + 0])).Op === 2))) { - writeRegexp(b, (x$10 = re.Sub, ((0 < 0 || 0 >= x$10.$length) ? $throwRuntimeError("index out of range") : x$10.$array[x$10.$offset + 0]))); - } - b.WriteRune(41); - } else if (_ref === 14 || _ref === 15 || _ref === 16 || _ref === 17) { - sub = (x$11 = re.Sub, ((0 < 0 || 0 >= x$11.$length) ? $throwRuntimeError("index out of range") : x$11.$array[x$11.$offset + 0])); - if (sub.Op > 13 || (sub.Op === 3) && sub.Rune.$length > 1) { - b.WriteString("(?:"); - writeRegexp(b, sub); - b.WriteString(")"); - } else { - writeRegexp(b, sub); - } - _ref$2 = re.Op; - if (_ref$2 === 14) { - b.WriteRune(42); - } else if (_ref$2 === 15) { - b.WriteRune(43); - } else if (_ref$2 === 16) { - b.WriteRune(63); - } else if (_ref$2 === 17) { - b.WriteRune(123); - b.WriteString(strconv.Itoa(re.Min)); - if (!((re.Max === re.Min))) { - b.WriteRune(44); - if (re.Max >= 0) { - b.WriteString(strconv.Itoa(re.Max)); - } - } - b.WriteRune(125); - } - if (!((((re.Flags & 32) >>> 0) === 0))) { - b.WriteRune(63); - } - } else if (_ref === 18) { - _ref$3 = re.Sub; - _i$1 = 0; - while (_i$1 < _ref$3.$length) { - sub$1 = ((_i$1 < 0 || _i$1 >= _ref$3.$length) ? $throwRuntimeError("index out of range") : _ref$3.$array[_ref$3.$offset + _i$1]); - if (sub$1.Op === 19) { - b.WriteString("(?:"); - writeRegexp(b, sub$1); - b.WriteString(")"); - } else { - writeRegexp(b, sub$1); - } - _i$1++; - } - } else if (_ref === 19) { - _ref$4 = re.Sub; - _i$2 = 0; - while (_i$2 < _ref$4.$length) { - i$2 = _i$2; - sub$2 = ((_i$2 < 0 || _i$2 >= _ref$4.$length) ? $throwRuntimeError("index out of range") : _ref$4.$array[_ref$4.$offset + _i$2]); - if (i$2 > 0) { - b.WriteRune(124); - } - writeRegexp(b, sub$2); - _i$2++; - } - } else { - b.WriteString("> 0)) + ">"); - } } + Signature.Ptr.prototype.Recv = function() { + var s; + s = this; + return s.recv; }; - Regexp.Ptr.prototype.String = function() { - var re, b; - re = this; - b = new bytes.Buffer.Ptr(); $copy(b, new bytes.Buffer.Ptr(), bytes.Buffer); - writeRegexp(b, re); - return b.String(); + Signature.prototype.Recv = function() { return this.$val.Recv(); }; + Signature.Ptr.prototype.Params = function() { + var s; + s = this; + return s.params; }; - Regexp.prototype.String = function() { return this.$val.String(); }; - escape = function(b, r, force) { - var _ref, s; - if (unicode.IsPrint(r)) { - if (strings.IndexRune("\\.+*?()|[]{}^$", r) >= 0 || force) { - b.WriteRune(92); - } - b.WriteRune(r); - return; - } - _ref = r; - switch (0) { default: if (_ref === 7) { - b.WriteString("\\a"); - } else if (_ref === 12) { - b.WriteString("\\f"); - } else if (_ref === 10) { - b.WriteString("\\n"); - } else if (_ref === 13) { - b.WriteString("\\r"); - } else if (_ref === 9) { - b.WriteString("\\t"); - } else if (_ref === 11) { - b.WriteString("\\v"); - } else { - if (r < 256) { - b.WriteString("\\x"); - s = strconv.FormatInt(new $Int64(0, r), 16); - if (s.length === 1) { - b.WriteRune(48); - } - b.WriteString(s); - break; - } - b.WriteString("\\x{"); - b.WriteString(strconv.FormatInt(new $Int64(0, r), 16)); - b.WriteString("}"); - } } + Signature.prototype.Params = function() { return this.$val.Params(); }; + Signature.Ptr.prototype.Results = function() { + var s; + s = this; + return s.results; }; - Regexp.Ptr.prototype.MaxCap = function() { - var re, m, _ref, _i, sub, n; - re = this; - m = 0; - if (re.Op === 13) { - m = re.Cap; - } - _ref = re.Sub; + Signature.prototype.Results = function() { return this.$val.Results(); }; + Signature.Ptr.prototype.Variadic = function() { + var s; + s = this; + return s.variadic; + }; + Signature.prototype.Variadic = function() { return this.$val.Variadic(); }; + NewInterface = $pkg.NewInterface = function(methods, embeddeds) { + var typ, mset, _ref, _i, m; + typ = new Interface.Ptr(); + mset = false; + _ref = methods; _i = 0; while (_i < _ref.$length) { - sub = ((_i < 0 || _i >= _ref.$length) ? $throwRuntimeError("index out of range") : _ref.$array[_ref.$offset + _i]); - n = sub.MaxCap(); - if (m < n) { - m = n; + m = ((_i < 0 || _i >= _ref.$length) ? $throwRuntimeError("index out of range") : _ref.$array[_ref.$offset + _i]); + if (!($interfaceIsEqual(new ($ptrType(objset))(function() { return mset; }, function($v) { mset = $v; }).insert(m), $ifaceNil))) { + $panic(new $String("multiple methods with the same name")); } + $assertType(m.object.typ, ($ptrType(Signature))).recv = NewVar(m.object.pos, m.object.pkg, "", typ); _i++; } - return m; + sort.Sort($subslice(new byUniqueMethodName(methods.$array), methods.$offset, methods.$offset + methods.$length)); + if (embeddeds === ($sliceType(($ptrType(Named)))).nil) { + sort.Sort($subslice(new byUniqueTypeName(embeddeds.$array), embeddeds.$offset, embeddeds.$offset + embeddeds.$length)); + } + typ.methods = methods; + typ.embeddeds = embeddeds; + return typ; }; - Regexp.prototype.MaxCap = function() { return this.$val.MaxCap(); }; - Regexp.Ptr.prototype.CapNames = function() { - var re, names; - re = this; - names = ($sliceType($String)).make((re.MaxCap() + 1 >> 0)); - re.capNames(names); - return names; + Interface.Ptr.prototype.NumExplicitMethods = function() { + var t; + t = this; + return t.methods.$length; }; - Regexp.prototype.CapNames = function() { return this.$val.CapNames(); }; - Regexp.Ptr.prototype.capNames = function(names) { - var re, x, _ref, _i, sub; - re = this; - if (re.Op === 13) { - (x = re.Cap, (x < 0 || x >= names.$length) ? $throwRuntimeError("index out of range") : names.$array[names.$offset + x] = re.Name); - } - _ref = re.Sub; - _i = 0; - while (_i < _ref.$length) { - sub = ((_i < 0 || _i >= _ref.$length) ? $throwRuntimeError("index out of range") : _ref.$array[_ref.$offset + _i]); - sub.capNames(names); - _i++; - } + Interface.prototype.NumExplicitMethods = function() { return this.$val.NumExplicitMethods(); }; + Interface.Ptr.prototype.ExplicitMethod = function(i) { + var t, x; + t = this; + return (x = t.methods, ((i < 0 || i >= x.$length) ? $throwRuntimeError("index out of range") : x.$array[x.$offset + i])); }; - Regexp.prototype.capNames = function(names) { return this.$val.capNames(names); }; - Regexp.Ptr.prototype.Simplify = function() { - var re, _ref, nre, _ref$1, _i, i, sub, nsub, x, sub$1, x$1, sub$2, nre$1, i$1, prefix, i$2, suffix, i$3, nre2; - re = this; - if (re === ($ptrType(Regexp)).nil) { - return ($ptrType(Regexp)).nil; + Interface.prototype.ExplicitMethod = function(i) { return this.$val.ExplicitMethod(i); }; + Interface.Ptr.prototype.NumEmbeddeds = function() { + var t; + t = this; + return t.embeddeds.$length; + }; + Interface.prototype.NumEmbeddeds = function() { return this.$val.NumEmbeddeds(); }; + Interface.Ptr.prototype.Embedded = function(i) { + var t, x; + t = this; + return (x = t.embeddeds, ((i < 0 || i >= x.$length) ? $throwRuntimeError("index out of range") : x.$array[x.$offset + i])); + }; + Interface.prototype.Embedded = function(i) { return this.$val.Embedded(i); }; + Interface.Ptr.prototype.NumMethods = function() { + var t; + t = this; + return t.allMethods.$length; + }; + Interface.prototype.NumMethods = function() { return this.$val.NumMethods(); }; + Interface.Ptr.prototype.Method = function(i) { + var t, x; + t = this; + return (x = t.allMethods, ((i < 0 || i >= x.$length) ? $throwRuntimeError("index out of range") : x.$array[x.$offset + i])); + }; + Interface.prototype.Method = function(i) { return this.$val.Method(i); }; + Interface.Ptr.prototype.Empty = function() { + var t; + t = this; + return t.allMethods.$length === 0; + }; + Interface.prototype.Empty = function() { return this.$val.Empty(); }; + Interface.Ptr.prototype.Complete = function() { + var t, allMethods, _ref, _i, et, it, _ref$1, _i$1, tm, newm, newmtyp; + t = this; + if (!(t.allMethods === ($sliceType(($ptrType(Func)))).nil)) { + return t; } - _ref = re.Op; - if (_ref === 13 || _ref === 18 || _ref === 19) { - nre = re; - _ref$1 = re.Sub; + allMethods = ($sliceType(($ptrType(Func)))).nil; + if (t.embeddeds === ($sliceType(($ptrType(Named)))).nil) { + if (t.methods === ($sliceType(($ptrType(Func)))).nil) { + allMethods = ($sliceType(($ptrType(Func)))).make(0, 1); + } else { + allMethods = t.methods; + } + } else { + allMethods = $appendSlice(allMethods, t.methods); + _ref = t.embeddeds; _i = 0; - while (_i < _ref$1.$length) { - i = _i; - sub = ((_i < 0 || _i >= _ref$1.$length) ? $throwRuntimeError("index out of range") : _ref$1.$array[_ref$1.$offset + _i]); - nsub = sub.Simplify(); - if (nre === re && !(nsub === sub)) { - nre = new Regexp.Ptr(); - $copy(nre, re, Regexp); - nre.Rune = ($sliceType($Int32)).nil; - nre.Sub = $appendSlice($subslice(new ($sliceType(($ptrType(Regexp))))(nre.Sub0), 0, 0), $subslice(re.Sub, 0, i)); - } - if (!(nre === re)) { - nre.Sub = $append(nre.Sub, nsub); + while (_i < _ref.$length) { + et = ((_i < 0 || _i >= _ref.$length) ? $throwRuntimeError("index out of range") : _ref.$array[_ref.$offset + _i]); + it = $assertType(et.Underlying(), ($ptrType(Interface))); + it.Complete(); + _ref$1 = it.allMethods; + _i$1 = 0; + while (_i$1 < _ref$1.$length) { + tm = ((_i$1 < 0 || _i$1 >= _ref$1.$length) ? $throwRuntimeError("index out of range") : _ref$1.$array[_ref$1.$offset + _i$1]); + newm = new Func.Ptr(); $copy(newm, tm, Func); + newmtyp = new Signature.Ptr(); $copy(newmtyp, $assertType(tm.object.typ, ($ptrType(Signature))), Signature); + newm.object.typ = newmtyp; + newmtyp.recv = NewVar(newm.object.pos, newm.object.pkg, "", t); + allMethods = $append(allMethods, newm); + _i$1++; } _i++; } - return nre; - } else if (_ref === 14 || _ref === 15 || _ref === 16) { - sub$1 = (x = re.Sub, ((0 < 0 || 0 >= x.$length) ? $throwRuntimeError("index out of range") : x.$array[x.$offset + 0])).Simplify(); - return simplify1(re.Op, re.Flags, sub$1, re); - } else if (_ref === 17) { - if ((re.Min === 0) && (re.Max === 0)) { - return new Regexp.Ptr(2, 0, ($sliceType(($ptrType(Regexp)))).nil, ($arrayType(($ptrType(Regexp)), 1)).zero(), ($sliceType($Int32)).nil, ($arrayType($Int32, 2)).zero(), 0, 0, 0, ""); - } - sub$2 = (x$1 = re.Sub, ((0 < 0 || 0 >= x$1.$length) ? $throwRuntimeError("index out of range") : x$1.$array[x$1.$offset + 0])).Simplify(); - if (re.Max === -1) { - if (re.Min === 0) { - return simplify1(14, re.Flags, sub$2, ($ptrType(Regexp)).nil); - } - if (re.Min === 1) { - return simplify1(15, re.Flags, sub$2, ($ptrType(Regexp)).nil); - } - nre$1 = new Regexp.Ptr(18, 0, ($sliceType(($ptrType(Regexp)))).nil, ($arrayType(($ptrType(Regexp)), 1)).zero(), ($sliceType($Int32)).nil, ($arrayType($Int32, 2)).zero(), 0, 0, 0, ""); - nre$1.Sub = $subslice(new ($sliceType(($ptrType(Regexp))))(nre$1.Sub0), 0, 0); - i$1 = 0; - while (i$1 < (re.Min - 1 >> 0)) { - nre$1.Sub = $append(nre$1.Sub, sub$2); - i$1 = i$1 + (1) >> 0; - } - nre$1.Sub = $append(nre$1.Sub, simplify1(15, re.Flags, sub$2, ($ptrType(Regexp)).nil)); - return nre$1; - } - if ((re.Min === 1) && (re.Max === 1)) { - return sub$2; - } - prefix = ($ptrType(Regexp)).nil; - if (re.Min > 0) { - prefix = new Regexp.Ptr(18, 0, ($sliceType(($ptrType(Regexp)))).nil, ($arrayType(($ptrType(Regexp)), 1)).zero(), ($sliceType($Int32)).nil, ($arrayType($Int32, 2)).zero(), 0, 0, 0, ""); - prefix.Sub = $subslice(new ($sliceType(($ptrType(Regexp))))(prefix.Sub0), 0, 0); - i$2 = 0; - while (i$2 < re.Min) { - prefix.Sub = $append(prefix.Sub, sub$2); - i$2 = i$2 + (1) >> 0; - } - } - if (re.Max > re.Min) { - suffix = simplify1(16, re.Flags, sub$2, ($ptrType(Regexp)).nil); - i$3 = re.Min + 1 >> 0; - while (i$3 < re.Max) { - nre2 = new Regexp.Ptr(18, 0, ($sliceType(($ptrType(Regexp)))).nil, ($arrayType(($ptrType(Regexp)), 1)).zero(), ($sliceType($Int32)).nil, ($arrayType($Int32, 2)).zero(), 0, 0, 0, ""); - nre2.Sub = $append($subslice(new ($sliceType(($ptrType(Regexp))))(nre2.Sub0), 0, 0), sub$2, suffix); - suffix = simplify1(16, re.Flags, nre2, ($ptrType(Regexp)).nil); - i$3 = i$3 + (1) >> 0; - } - if (prefix === ($ptrType(Regexp)).nil) { - return suffix; - } - prefix.Sub = $append(prefix.Sub, suffix); - } - if (!(prefix === ($ptrType(Regexp)).nil)) { - return prefix; - } - return new Regexp.Ptr(1, 0, ($sliceType(($ptrType(Regexp)))).nil, ($arrayType(($ptrType(Regexp)), 1)).zero(), ($sliceType($Int32)).nil, ($arrayType($Int32, 2)).zero(), 0, 0, 0, ""); + sort.Sort($subslice(new byUniqueMethodName(allMethods.$array), allMethods.$offset, allMethods.$offset + allMethods.$length)); } - return re; + t.allMethods = allMethods; + return t; }; - Regexp.prototype.Simplify = function() { return this.$val.Simplify(); }; - simplify1 = function(op, flags, sub, re) { - var x; - if (sub.Op === 2) { - return sub; + Interface.prototype.Complete = function() { return this.$val.Complete(); }; + NewMap = $pkg.NewMap = function(key, elem) { + return new Map.Ptr(key, elem); + }; + Map.Ptr.prototype.Key = function() { + var m; + m = this; + return m.key; + }; + Map.prototype.Key = function() { return this.$val.Key(); }; + Map.Ptr.prototype.Elem = function() { + var m; + m = this; + return m.elem; + }; + Map.prototype.Elem = function() { return this.$val.Elem(); }; + NewChan = $pkg.NewChan = function(dir, elem) { + return new Chan.Ptr(dir, elem); + }; + Chan.Ptr.prototype.Dir = function() { + var c; + c = this; + return c.dir; + }; + Chan.prototype.Dir = function() { return this.$val.Dir(); }; + Chan.Ptr.prototype.Elem = function() { + var c; + c = this; + return c.elem; + }; + Chan.prototype.Elem = function() { return this.$val.Elem(); }; + NewNamed = $pkg.NewNamed = function(obj, underlying$1, methods) { + var _tuple, ok, typ; + _tuple = $assertType(underlying$1, ($ptrType(Named)), true); ok = _tuple[1]; + if (ok) { + $panic(new $String("types.NewNamed: underlying type must not be *Named")); } - if ((op === sub.Op) && (((flags & 32) >>> 0) === ((sub.Flags & 32) >>> 0))) { - return sub; + typ = new Named.Ptr(obj, underlying$1, methods); + if ($interfaceIsEqual(obj.object.typ, $ifaceNil)) { + obj.object.typ = typ; } - if (!(re === ($ptrType(Regexp)).nil) && (re.Op === op) && (((re.Flags & 32) >>> 0) === ((flags & 32) >>> 0)) && sub === (x = re.Sub, ((0 < 0 || 0 >= x.$length) ? $throwRuntimeError("index out of range") : x.$array[x.$offset + 0]))) { - return re; + return typ; + }; + Named.Ptr.prototype.Obj = function() { + var t; + t = this; + return t.obj; + }; + Named.prototype.Obj = function() { return this.$val.Obj(); }; + Named.Ptr.prototype.NumMethods = function() { + var t; + t = this; + return t.methods.$length; + }; + Named.prototype.NumMethods = function() { return this.$val.NumMethods(); }; + Named.Ptr.prototype.Method = function(i) { + var t, x; + t = this; + return (x = t.methods, ((i < 0 || i >= x.$length) ? $throwRuntimeError("index out of range") : x.$array[x.$offset + i])); + }; + Named.prototype.Method = function(i) { return this.$val.Method(i); }; + Named.Ptr.prototype.SetUnderlying = function(underlying$1) { + var t, _tuple, ok; + t = this; + if ($interfaceIsEqual(underlying$1, $ifaceNil)) { + $panic(new $String("types.Named.SetUnderlying: underlying type must not be nil")); } - re = new Regexp.Ptr(op, flags, ($sliceType(($ptrType(Regexp)))).nil, ($arrayType(($ptrType(Regexp)), 1)).zero(), ($sliceType($Int32)).nil, ($arrayType($Int32, 2)).zero(), 0, 0, 0, ""); - re.Sub = $append($subslice(new ($sliceType(($ptrType(Regexp))))(re.Sub0), 0, 0), sub); - return re; + _tuple = $assertType(underlying$1, ($ptrType(Named)), true); ok = _tuple[1]; + if (ok) { + $panic(new $String("types.Named.SetUnderlying: underlying type must not be *Named")); + } + t.underlying = underlying$1; }; - $pkg.$init = function() { - patchList.methods = [["append", "append", "regexp/syntax", $funcType([($ptrType(Prog)), patchList], [patchList], false), -1], ["next", "next", "regexp/syntax", $funcType([($ptrType(Prog))], [patchList], false), -1], ["patch", "patch", "regexp/syntax", $funcType([($ptrType(Prog)), $Uint32], [], false), -1]]; - ($ptrType(patchList)).methods = [["append", "append", "regexp/syntax", $funcType([($ptrType(Prog)), patchList], [patchList], false), -1], ["next", "next", "regexp/syntax", $funcType([($ptrType(Prog))], [patchList], false), -1], ["patch", "patch", "regexp/syntax", $funcType([($ptrType(Prog)), $Uint32], [], false), -1]]; - frag.init([["i", "i", "regexp/syntax", $Uint32, ""], ["out", "out", "regexp/syntax", patchList, ""]]); - ($ptrType(compiler)).methods = [["alt", "alt", "regexp/syntax", $funcType([frag, frag], [frag], false), -1], ["cap", "cap", "regexp/syntax", $funcType([$Uint32], [frag], false), -1], ["cat", "cat", "regexp/syntax", $funcType([frag, frag], [frag], false), -1], ["compile", "compile", "regexp/syntax", $funcType([($ptrType(Regexp))], [frag], false), -1], ["empty", "empty", "regexp/syntax", $funcType([EmptyOp], [frag], false), -1], ["fail", "fail", "regexp/syntax", $funcType([], [frag], false), -1], ["init", "init", "regexp/syntax", $funcType([], [], false), -1], ["inst", "inst", "regexp/syntax", $funcType([InstOp], [frag], false), -1], ["nop", "nop", "regexp/syntax", $funcType([], [frag], false), -1], ["plus", "plus", "regexp/syntax", $funcType([frag, $Bool], [frag], false), -1], ["quest", "quest", "regexp/syntax", $funcType([frag, $Bool], [frag], false), -1], ["rune", "rune", "regexp/syntax", $funcType([($sliceType($Int32)), Flags], [frag], false), -1], ["star", "star", "regexp/syntax", $funcType([frag, $Bool], [frag], false), -1]]; - compiler.init([["p", "p", "regexp/syntax", ($ptrType(Prog)), ""]]); - ($ptrType(Error)).methods = [["Error", "Error", "", $funcType([], [$String], false), -1]]; - Error.init([["Code", "Code", "", ErrorCode, ""], ["Expr", "Expr", "", $String, ""]]); - ErrorCode.methods = [["String", "String", "", $funcType([], [$String], false), -1]]; - ($ptrType(ErrorCode)).methods = [["String", "String", "", $funcType([], [$String], false), -1]]; - ($ptrType(parser)).methods = [["alternate", "alternate", "regexp/syntax", $funcType([], [($ptrType(Regexp))], false), -1], ["appendGroup", "appendGroup", "regexp/syntax", $funcType([($sliceType($Int32)), charGroup], [($sliceType($Int32))], false), -1], ["collapse", "collapse", "regexp/syntax", $funcType([($sliceType(($ptrType(Regexp)))), Op], [($ptrType(Regexp))], false), -1], ["concat", "concat", "regexp/syntax", $funcType([], [($ptrType(Regexp))], false), -1], ["factor", "factor", "regexp/syntax", $funcType([($sliceType(($ptrType(Regexp)))), Flags], [($sliceType(($ptrType(Regexp))))], false), -1], ["leadingRegexp", "leadingRegexp", "regexp/syntax", $funcType([($ptrType(Regexp))], [($ptrType(Regexp))], false), -1], ["leadingString", "leadingString", "regexp/syntax", $funcType([($ptrType(Regexp))], [($sliceType($Int32)), Flags], false), -1], ["literal", "literal", "regexp/syntax", $funcType([$Int32], [], false), -1], ["maybeConcat", "maybeConcat", "regexp/syntax", $funcType([$Int32, Flags], [$Bool], false), -1], ["newLiteral", "newLiteral", "regexp/syntax", $funcType([$Int32, Flags], [($ptrType(Regexp))], false), -1], ["newRegexp", "newRegexp", "regexp/syntax", $funcType([Op], [($ptrType(Regexp))], false), -1], ["op", "op", "regexp/syntax", $funcType([Op], [($ptrType(Regexp))], false), -1], ["parseClass", "parseClass", "regexp/syntax", $funcType([$String], [$String, $error], false), -1], ["parseClassChar", "parseClassChar", "regexp/syntax", $funcType([$String, $String], [$Int32, $String, $error], false), -1], ["parseEscape", "parseEscape", "regexp/syntax", $funcType([$String], [$Int32, $String, $error], false), -1], ["parseInt", "parseInt", "regexp/syntax", $funcType([$String], [$Int, $String, $Bool], false), -1], ["parseNamedClass", "parseNamedClass", "regexp/syntax", $funcType([$String, ($sliceType($Int32))], [($sliceType($Int32)), $String, $error], false), -1], ["parsePerlClassEscape", "parsePerlClassEscape", "regexp/syntax", $funcType([$String, ($sliceType($Int32))], [($sliceType($Int32)), $String], false), -1], ["parsePerlFlags", "parsePerlFlags", "regexp/syntax", $funcType([$String], [$String, $error], false), -1], ["parseRepeat", "parseRepeat", "regexp/syntax", $funcType([$String], [$Int, $Int, $String, $Bool], false), -1], ["parseRightParen", "parseRightParen", "regexp/syntax", $funcType([], [$error], false), -1], ["parseUnicodeClass", "parseUnicodeClass", "regexp/syntax", $funcType([$String, ($sliceType($Int32))], [($sliceType($Int32)), $String, $error], false), -1], ["parseVerticalBar", "parseVerticalBar", "regexp/syntax", $funcType([], [$error], false), -1], ["push", "push", "regexp/syntax", $funcType([($ptrType(Regexp))], [($ptrType(Regexp))], false), -1], ["removeLeadingRegexp", "removeLeadingRegexp", "regexp/syntax", $funcType([($ptrType(Regexp)), $Bool], [($ptrType(Regexp))], false), -1], ["removeLeadingString", "removeLeadingString", "regexp/syntax", $funcType([($ptrType(Regexp)), $Int], [($ptrType(Regexp))], false), -1], ["repeat", "repeat", "regexp/syntax", $funcType([Op, $Int, $Int, $String, $String, $String], [$String, $error], false), -1], ["reuse", "reuse", "regexp/syntax", $funcType([($ptrType(Regexp))], [], false), -1], ["swapVerticalBar", "swapVerticalBar", "regexp/syntax", $funcType([], [$Bool], false), -1]]; - parser.init([["flags", "flags", "regexp/syntax", Flags, ""], ["stack", "stack", "regexp/syntax", ($sliceType(($ptrType(Regexp)))), ""], ["free", "free", "regexp/syntax", ($ptrType(Regexp)), ""], ["numCap", "numCap", "regexp/syntax", $Int, ""], ["wholeRegexp", "wholeRegexp", "regexp/syntax", $String, ""], ["tmpClass", "tmpClass", "regexp/syntax", ($sliceType($Int32)), ""]]); - charGroup.init([["sign", "sign", "regexp/syntax", $Int, ""], ["class$1", "class", "regexp/syntax", ($sliceType($Int32)), ""]]); - ranges.methods = [["Len", "Len", "", $funcType([], [$Int], false), -1], ["Less", "Less", "", $funcType([$Int, $Int], [$Bool], false), -1], ["Swap", "Swap", "", $funcType([$Int, $Int], [], false), -1]]; - ($ptrType(ranges)).methods = [["Len", "Len", "", $funcType([], [$Int], false), -1], ["Less", "Less", "", $funcType([$Int, $Int], [$Bool], false), -1], ["Swap", "Swap", "", $funcType([$Int, $Int], [], false), -1]]; - ranges.init([["p", "p", "regexp/syntax", ($ptrType(($sliceType($Int32)))), ""]]); - ($ptrType(Prog)).methods = [["Prefix", "Prefix", "", $funcType([], [$String, $Bool], false), -1], ["StartCond", "StartCond", "", $funcType([], [EmptyOp], false), -1], ["String", "String", "", $funcType([], [$String], false), -1], ["skipNop", "skipNop", "regexp/syntax", $funcType([$Uint32], [($ptrType(Inst)), $Uint32], false), -1]]; - Prog.init([["Inst", "Inst", "", ($sliceType(Inst)), ""], ["Start", "Start", "", $Int, ""], ["NumCap", "NumCap", "", $Int, ""]]); - InstOp.methods = [["String", "String", "", $funcType([], [$String], false), -1]]; - ($ptrType(InstOp)).methods = [["String", "String", "", $funcType([], [$String], false), -1]]; - ($ptrType(Inst)).methods = [["MatchEmptyWidth", "MatchEmptyWidth", "", $funcType([$Int32, $Int32], [$Bool], false), -1], ["MatchRune", "MatchRune", "", $funcType([$Int32], [$Bool], false), -1], ["MatchRunePos", "MatchRunePos", "", $funcType([$Int32], [$Int], false), -1], ["String", "String", "", $funcType([], [$String], false), -1], ["op", "op", "regexp/syntax", $funcType([], [InstOp], false), -1]]; - Inst.init([["Op", "Op", "", InstOp, ""], ["Out", "Out", "", $Uint32, ""], ["Arg", "Arg", "", $Uint32, ""], ["Rune", "Rune", "", ($sliceType($Int32)), ""]]); - ($ptrType(Regexp)).methods = [["CapNames", "CapNames", "", $funcType([], [($sliceType($String))], false), -1], ["Equal", "Equal", "", $funcType([($ptrType(Regexp))], [$Bool], false), -1], ["MaxCap", "MaxCap", "", $funcType([], [$Int], false), -1], ["Simplify", "Simplify", "", $funcType([], [($ptrType(Regexp))], false), -1], ["String", "String", "", $funcType([], [$String], false), -1], ["capNames", "capNames", "regexp/syntax", $funcType([($sliceType($String))], [], false), -1]]; - Regexp.init([["Op", "Op", "", Op, ""], ["Flags", "Flags", "", Flags, ""], ["Sub", "Sub", "", ($sliceType(($ptrType(Regexp)))), ""], ["Sub0", "Sub0", "", ($arrayType(($ptrType(Regexp)), 1)), ""], ["Rune", "Rune", "", ($sliceType($Int32)), ""], ["Rune0", "Rune0", "", ($arrayType($Int32, 2)), ""], ["Min", "Min", "", $Int, ""], ["Max", "Max", "", $Int, ""], ["Cap", "Cap", "", $Int, ""], ["Name", "Name", "", $String, ""]]); - anyRuneNotNL = new ($sliceType($Int32))([0, 9, 11, 1114111]); - anyRune = new ($sliceType($Int32))([0, 1114111]); - anyTable = new unicode.RangeTable.Ptr(new ($sliceType(unicode.Range16))([new unicode.Range16.Ptr(0, 65535, 1)]), new ($sliceType(unicode.Range32))([new unicode.Range32.Ptr(65536, 1114111, 1)]), 0); - code1 = new ($sliceType($Int32))([48, 57]); - code2 = new ($sliceType($Int32))([9, 10, 12, 13, 32, 32]); - code3 = new ($sliceType($Int32))([48, 57, 65, 90, 95, 95, 97, 122]); - perlGroup = (_map = new $Map(), _key = "\\d", _map[_key] = { k: _key, v: new charGroup.Ptr(1, code1) }, _key = "\\D", _map[_key] = { k: _key, v: new charGroup.Ptr(-1, code1) }, _key = "\\s", _map[_key] = { k: _key, v: new charGroup.Ptr(1, code2) }, _key = "\\S", _map[_key] = { k: _key, v: new charGroup.Ptr(-1, code2) }, _key = "\\w", _map[_key] = { k: _key, v: new charGroup.Ptr(1, code3) }, _key = "\\W", _map[_key] = { k: _key, v: new charGroup.Ptr(-1, code3) }, _map); - code4 = new ($sliceType($Int32))([48, 57, 65, 90, 97, 122]); - code5 = new ($sliceType($Int32))([65, 90, 97, 122]); - code6 = new ($sliceType($Int32))([0, 127]); - code7 = new ($sliceType($Int32))([9, 9, 32, 32]); - code8 = new ($sliceType($Int32))([0, 31, 127, 127]); - code9 = new ($sliceType($Int32))([48, 57]); - code10 = new ($sliceType($Int32))([33, 126]); - code11 = new ($sliceType($Int32))([97, 122]); - code12 = new ($sliceType($Int32))([32, 126]); - code13 = new ($sliceType($Int32))([33, 47, 58, 64, 91, 96, 123, 126]); - code14 = new ($sliceType($Int32))([9, 13, 32, 32]); - code15 = new ($sliceType($Int32))([65, 90]); - code16 = new ($sliceType($Int32))([48, 57, 65, 90, 95, 95, 97, 122]); - code17 = new ($sliceType($Int32))([48, 57, 65, 70, 97, 102]); - posixGroup = (_map$1 = new $Map(), _key$1 = "[:alnum:]", _map$1[_key$1] = { k: _key$1, v: new charGroup.Ptr(1, code4) }, _key$1 = "[:^alnum:]", _map$1[_key$1] = { k: _key$1, v: new charGroup.Ptr(-1, code4) }, _key$1 = "[:alpha:]", _map$1[_key$1] = { k: _key$1, v: new charGroup.Ptr(1, code5) }, _key$1 = "[:^alpha:]", _map$1[_key$1] = { k: _key$1, v: new charGroup.Ptr(-1, code5) }, _key$1 = "[:ascii:]", _map$1[_key$1] = { k: _key$1, v: new charGroup.Ptr(1, code6) }, _key$1 = "[:^ascii:]", _map$1[_key$1] = { k: _key$1, v: new charGroup.Ptr(-1, code6) }, _key$1 = "[:blank:]", _map$1[_key$1] = { k: _key$1, v: new charGroup.Ptr(1, code7) }, _key$1 = "[:^blank:]", _map$1[_key$1] = { k: _key$1, v: new charGroup.Ptr(-1, code7) }, _key$1 = "[:cntrl:]", _map$1[_key$1] = { k: _key$1, v: new charGroup.Ptr(1, code8) }, _key$1 = "[:^cntrl:]", _map$1[_key$1] = { k: _key$1, v: new charGroup.Ptr(-1, code8) }, _key$1 = "[:digit:]", _map$1[_key$1] = { k: _key$1, v: new charGroup.Ptr(1, code9) }, _key$1 = "[:^digit:]", _map$1[_key$1] = { k: _key$1, v: new charGroup.Ptr(-1, code9) }, _key$1 = "[:graph:]", _map$1[_key$1] = { k: _key$1, v: new charGroup.Ptr(1, code10) }, _key$1 = "[:^graph:]", _map$1[_key$1] = { k: _key$1, v: new charGroup.Ptr(-1, code10) }, _key$1 = "[:lower:]", _map$1[_key$1] = { k: _key$1, v: new charGroup.Ptr(1, code11) }, _key$1 = "[:^lower:]", _map$1[_key$1] = { k: _key$1, v: new charGroup.Ptr(-1, code11) }, _key$1 = "[:print:]", _map$1[_key$1] = { k: _key$1, v: new charGroup.Ptr(1, code12) }, _key$1 = "[:^print:]", _map$1[_key$1] = { k: _key$1, v: new charGroup.Ptr(-1, code12) }, _key$1 = "[:punct:]", _map$1[_key$1] = { k: _key$1, v: new charGroup.Ptr(1, code13) }, _key$1 = "[:^punct:]", _map$1[_key$1] = { k: _key$1, v: new charGroup.Ptr(-1, code13) }, _key$1 = "[:space:]", _map$1[_key$1] = { k: _key$1, v: new charGroup.Ptr(1, code14) }, _key$1 = "[:^space:]", _map$1[_key$1] = { k: _key$1, v: new charGroup.Ptr(-1, code14) }, _key$1 = "[:upper:]", _map$1[_key$1] = { k: _key$1, v: new charGroup.Ptr(1, code15) }, _key$1 = "[:^upper:]", _map$1[_key$1] = { k: _key$1, v: new charGroup.Ptr(-1, code15) }, _key$1 = "[:word:]", _map$1[_key$1] = { k: _key$1, v: new charGroup.Ptr(1, code16) }, _key$1 = "[:^word:]", _map$1[_key$1] = { k: _key$1, v: new charGroup.Ptr(-1, code16) }, _key$1 = "[:xdigit:]", _map$1[_key$1] = { k: _key$1, v: new charGroup.Ptr(1, code17) }, _key$1 = "[:^xdigit:]", _map$1[_key$1] = { k: _key$1, v: new charGroup.Ptr(-1, code17) }, _map$1); - instOpNames = new ($sliceType($String))(["InstAlt", "InstAltMatch", "InstCapture", "InstEmptyWidth", "InstMatch", "InstFail", "InstNop", "InstRune", "InstRune1", "InstRuneAny", "InstRuneAnyNotNL"]); + Named.prototype.SetUnderlying = function(underlying$1) { return this.$val.SetUnderlying(underlying$1); }; + Named.Ptr.prototype.AddMethod = function(m) { + var t, _tuple, i; + t = this; + _tuple = lookupMethod(t.methods, m.object.pkg, m.object.name); i = _tuple[0]; + if (i < 0) { + t.methods = $append(t.methods, m); + } }; - return $pkg; -})(); -$packages["regexp"] = (function() { - var $pkg = {}, testing = $packages["testing"], io = $packages["io"], syntax = $packages["regexp/syntax"], bytes = $packages["bytes"], sort = $packages["sort"], unicode = $packages["unicode"], strconv = $packages["strconv"], strings = $packages["strings"], sync = $packages["sync"], utf8 = $packages["unicode/utf8"], queue, entry, thread, machine, onePassProg, onePassInst, queueOnePass, runeSlice, Regexp, input, inputString, inputBytes, inputReader, empty, noRune, noNext, anyRuneNotNL, anyRune, notOnePass, progMachine, onePassPrefix, onePassNext, iop, newQueue, mergeRuneSets, cleanupOnePass, onePassCopy, makeOnePass, compileOnePass, Compile, compile, MustCompile, quote, extract; - queue = $pkg.queue = $newType(0, "Struct", "regexp.queue", "queue", "regexp", function(sparse_, dense_) { - this.$val = this; - this.sparse = sparse_ !== undefined ? sparse_ : ($sliceType($Uint32)).nil; - this.dense = dense_ !== undefined ? dense_ : ($sliceType(entry)).nil; - }); - entry = $pkg.entry = $newType(0, "Struct", "regexp.entry", "entry", "regexp", function(pc_, t_) { - this.$val = this; - this.pc = pc_ !== undefined ? pc_ : 0; - this.t = t_ !== undefined ? t_ : ($ptrType(thread)).nil; - }); - thread = $pkg.thread = $newType(0, "Struct", "regexp.thread", "thread", "regexp", function(inst_, cap_) { - this.$val = this; - this.inst = inst_ !== undefined ? inst_ : ($ptrType(syntax.Inst)).nil; - this.cap = cap_ !== undefined ? cap_ : ($sliceType($Int)).nil; - }); - machine = $pkg.machine = $newType(0, "Struct", "regexp.machine", "machine", "regexp", function(re_, p_, op_, q0_, q1_, pool_, matched_, matchcap_, inputBytes_, inputString_, inputReader_) { - this.$val = this; - this.re = re_ !== undefined ? re_ : ($ptrType(Regexp)).nil; - this.p = p_ !== undefined ? p_ : ($ptrType(syntax.Prog)).nil; - this.op = op_ !== undefined ? op_ : ($ptrType(onePassProg)).nil; - this.q0 = q0_ !== undefined ? q0_ : new queue.Ptr(); - this.q1 = q1_ !== undefined ? q1_ : new queue.Ptr(); - this.pool = pool_ !== undefined ? pool_ : ($sliceType(($ptrType(thread)))).nil; - this.matched = matched_ !== undefined ? matched_ : false; - this.matchcap = matchcap_ !== undefined ? matchcap_ : ($sliceType($Int)).nil; - this.inputBytes = inputBytes_ !== undefined ? inputBytes_ : new inputBytes.Ptr(); - this.inputString = inputString_ !== undefined ? inputString_ : new inputString.Ptr(); - this.inputReader = inputReader_ !== undefined ? inputReader_ : new inputReader.Ptr(); - }); - onePassProg = $pkg.onePassProg = $newType(0, "Struct", "regexp.onePassProg", "onePassProg", "regexp", function(Inst_, Start_, NumCap_) { - this.$val = this; - this.Inst = Inst_ !== undefined ? Inst_ : ($sliceType(onePassInst)).nil; - this.Start = Start_ !== undefined ? Start_ : 0; - this.NumCap = NumCap_ !== undefined ? NumCap_ : 0; - }); - onePassInst = $pkg.onePassInst = $newType(0, "Struct", "regexp.onePassInst", "onePassInst", "regexp", function(Inst_, Next_) { - this.$val = this; - this.Inst = Inst_ !== undefined ? Inst_ : new syntax.Inst.Ptr(); - this.Next = Next_ !== undefined ? Next_ : ($sliceType($Uint32)).nil; - }); - queueOnePass = $pkg.queueOnePass = $newType(0, "Struct", "regexp.queueOnePass", "queueOnePass", "regexp", function(sparse_, dense_, size_, nextIndex_) { - this.$val = this; - this.sparse = sparse_ !== undefined ? sparse_ : ($sliceType($Uint32)).nil; - this.dense = dense_ !== undefined ? dense_ : ($sliceType($Uint32)).nil; - this.size = size_ !== undefined ? size_ : 0; - this.nextIndex = nextIndex_ !== undefined ? nextIndex_ : 0; - }); - runeSlice = $pkg.runeSlice = $newType(12, "Slice", "regexp.runeSlice", "runeSlice", "regexp", null); - Regexp = $pkg.Regexp = $newType(0, "Struct", "regexp.Regexp", "Regexp", "regexp", function(expr_, prog_, onepass_, prefix_, prefixBytes_, prefixComplete_, prefixRune_, prefixEnd_, cond_, numSubexp_, subexpNames_, longest_, mu_, machine_) { - this.$val = this; - this.expr = expr_ !== undefined ? expr_ : ""; - this.prog = prog_ !== undefined ? prog_ : ($ptrType(syntax.Prog)).nil; - this.onepass = onepass_ !== undefined ? onepass_ : ($ptrType(onePassProg)).nil; - this.prefix = prefix_ !== undefined ? prefix_ : ""; - this.prefixBytes = prefixBytes_ !== undefined ? prefixBytes_ : ($sliceType($Uint8)).nil; - this.prefixComplete = prefixComplete_ !== undefined ? prefixComplete_ : false; - this.prefixRune = prefixRune_ !== undefined ? prefixRune_ : 0; - this.prefixEnd = prefixEnd_ !== undefined ? prefixEnd_ : 0; - this.cond = cond_ !== undefined ? cond_ : 0; - this.numSubexp = numSubexp_ !== undefined ? numSubexp_ : 0; - this.subexpNames = subexpNames_ !== undefined ? subexpNames_ : ($sliceType($String)).nil; - this.longest = longest_ !== undefined ? longest_ : false; - this.mu = mu_ !== undefined ? mu_ : new sync.Mutex.Ptr(); - this.machine = machine_ !== undefined ? machine_ : ($sliceType(($ptrType(machine)))).nil; - }); - input = $pkg.input = $newType(8, "Interface", "regexp.input", "input", "regexp", null); - inputString = $pkg.inputString = $newType(0, "Struct", "regexp.inputString", "inputString", "regexp", function(str_) { - this.$val = this; - this.str = str_ !== undefined ? str_ : ""; - }); - inputBytes = $pkg.inputBytes = $newType(0, "Struct", "regexp.inputBytes", "inputBytes", "regexp", function(str_) { - this.$val = this; - this.str = str_ !== undefined ? str_ : ($sliceType($Uint8)).nil; - }); - inputReader = $pkg.inputReader = $newType(0, "Struct", "regexp.inputReader", "inputReader", "regexp", function(r_, atEOT_, pos_) { - this.$val = this; - this.r = r_ !== undefined ? r_ : $ifaceNil; - this.atEOT = atEOT_ !== undefined ? atEOT_ : false; - this.pos = pos_ !== undefined ? pos_ : 0; - }); - machine.Ptr.prototype.newInputBytes = function(b) { - var m; - m = this; - m.inputBytes.str = b; - return m.inputBytes; + Named.prototype.AddMethod = function(m) { return this.$val.AddMethod(m); }; + Basic.Ptr.prototype.Underlying = function() { + var t; + t = this; + return t; + }; + Basic.prototype.Underlying = function() { return this.$val.Underlying(); }; + Array.Ptr.prototype.Underlying = function() { + var t; + t = this; + return t; + }; + Array.prototype.Underlying = function() { return this.$val.Underlying(); }; + Slice.Ptr.prototype.Underlying = function() { + var t; + t = this; + return t; + }; + Slice.prototype.Underlying = function() { return this.$val.Underlying(); }; + Struct.Ptr.prototype.Underlying = function() { + var t; + t = this; + return t; + }; + Struct.prototype.Underlying = function() { return this.$val.Underlying(); }; + Pointer.Ptr.prototype.Underlying = function() { + var t; + t = this; + return t; + }; + Pointer.prototype.Underlying = function() { return this.$val.Underlying(); }; + Tuple.Ptr.prototype.Underlying = function() { + var t; + t = this; + return t; + }; + Tuple.prototype.Underlying = function() { return this.$val.Underlying(); }; + Signature.Ptr.prototype.Underlying = function() { + var t; + t = this; + return t; + }; + Signature.prototype.Underlying = function() { return this.$val.Underlying(); }; + Interface.Ptr.prototype.Underlying = function() { + var t; + t = this; + return t; + }; + Interface.prototype.Underlying = function() { return this.$val.Underlying(); }; + Map.Ptr.prototype.Underlying = function() { + var t; + t = this; + return t; + }; + Map.prototype.Underlying = function() { return this.$val.Underlying(); }; + Chan.Ptr.prototype.Underlying = function() { + var t; + t = this; + return t; + }; + Chan.prototype.Underlying = function() { return this.$val.Underlying(); }; + Named.Ptr.prototype.Underlying = function() { + var t; + t = this; + return t.underlying; + }; + Named.prototype.Underlying = function() { return this.$val.Underlying(); }; + Basic.Ptr.prototype.String = function() { + var t; + t = this; + return TypeString(($ptrType(Package)).nil, t); + }; + Basic.prototype.String = function() { return this.$val.String(); }; + Array.Ptr.prototype.String = function() { + var t; + t = this; + return TypeString(($ptrType(Package)).nil, t); }; - machine.prototype.newInputBytes = function(b) { return this.$val.newInputBytes(b); }; - machine.Ptr.prototype.newInputString = function(s) { - var m; - m = this; - m.inputString.str = s; - return m.inputString; + Array.prototype.String = function() { return this.$val.String(); }; + Slice.Ptr.prototype.String = function() { + var t; + t = this; + return TypeString(($ptrType(Package)).nil, t); }; - machine.prototype.newInputString = function(s) { return this.$val.newInputString(s); }; - machine.Ptr.prototype.newInputReader = function(r) { - var m; - m = this; - m.inputReader.r = r; - m.inputReader.atEOT = false; - m.inputReader.pos = 0; - return m.inputReader; + Slice.prototype.String = function() { return this.$val.String(); }; + Struct.Ptr.prototype.String = function() { + var t; + t = this; + return TypeString(($ptrType(Package)).nil, t); }; - machine.prototype.newInputReader = function(r) { return this.$val.newInputReader(r); }; - progMachine = function(p, op) { - var m, n, ncap; - m = new machine.Ptr(($ptrType(Regexp)).nil, p, op, new queue.Ptr(), new queue.Ptr(), ($sliceType(($ptrType(thread)))).nil, false, ($sliceType($Int)).nil, new inputBytes.Ptr(), new inputString.Ptr(), new inputReader.Ptr()); - n = m.p.Inst.$length; - $copy(m.q0, new queue.Ptr(($sliceType($Uint32)).make(n), ($sliceType(entry)).make(0, n)), queue); - $copy(m.q1, new queue.Ptr(($sliceType($Uint32)).make(n), ($sliceType(entry)).make(0, n)), queue); - ncap = p.NumCap; - if (ncap < 2) { - ncap = 2; - } - m.matchcap = ($sliceType($Int)).make(ncap); - return m; + Struct.prototype.String = function() { return this.$val.String(); }; + Pointer.Ptr.prototype.String = function() { + var t; + t = this; + return TypeString(($ptrType(Package)).nil, t); }; - machine.Ptr.prototype.init = function(ncap) { - var m, _ref, _i, t; - m = this; - _ref = m.pool; - _i = 0; - while (_i < _ref.$length) { - t = ((_i < 0 || _i >= _ref.$length) ? $throwRuntimeError("index out of range") : _ref.$array[_ref.$offset + _i]); - t.cap = $subslice(t.cap, 0, ncap); - _i++; - } - m.matchcap = $subslice(m.matchcap, 0, ncap); + Pointer.prototype.String = function() { return this.$val.String(); }; + Tuple.Ptr.prototype.String = function() { + var t; + t = this; + return TypeString(($ptrType(Package)).nil, t); }; - machine.prototype.init = function(ncap) { return this.$val.init(ncap); }; - machine.Ptr.prototype.alloc = function(i) { - var m, t, n, x, x$1; - m = this; - t = ($ptrType(thread)).nil; - n = m.pool.$length; - if (n > 0) { - t = (x = m.pool, x$1 = n - 1 >> 0, ((x$1 < 0 || x$1 >= x.$length) ? $throwRuntimeError("index out of range") : x.$array[x.$offset + x$1])); - m.pool = $subslice(m.pool, 0, (n - 1 >> 0)); - } else { - t = new thread.Ptr(); - t.cap = ($sliceType($Int)).make(m.matchcap.$length, m.matchcap.$capacity); - } - t.inst = i; - return t; + Tuple.prototype.String = function() { return this.$val.String(); }; + Signature.Ptr.prototype.String = function() { + var t; + t = this; + return TypeString(($ptrType(Package)).nil, t); }; - machine.prototype.alloc = function(i) { return this.$val.alloc(i); }; - machine.Ptr.prototype.match = function(i, pos) { - var m, startCond, _ref, _i, i$1, x, _tmp, _tmp$1, runq, nextq, _tmp$2, _tmp$3, r, r1, _tmp$4, _tmp$5, width, width1, _tuple, _tuple$1, flag, advance, _tuple$2, _tuple$3, x$1, _tmp$6, _tmp$7, _tuple$4, _tmp$8, _tmp$9; - m = this; - startCond = m.re.cond; - if (startCond === 255) { - return false; - } - m.matched = false; - _ref = m.matchcap; + Signature.prototype.String = function() { return this.$val.String(); }; + Interface.Ptr.prototype.String = function() { + var t; + t = this; + return TypeString(($ptrType(Package)).nil, t); + }; + Interface.prototype.String = function() { return this.$val.String(); }; + Map.Ptr.prototype.String = function() { + var t; + t = this; + return TypeString(($ptrType(Package)).nil, t); + }; + Map.prototype.String = function() { return this.$val.String(); }; + Chan.Ptr.prototype.String = function() { + var t; + t = this; + return TypeString(($ptrType(Package)).nil, t); + }; + Chan.prototype.String = function() { return this.$val.String(); }; + Named.Ptr.prototype.String = function() { + var t; + t = this; + return TypeString(($ptrType(Package)).nil, t); + }; + Named.prototype.String = function() { return this.$val.String(); }; + TypeString = $pkg.TypeString = function(this$1, typ) { + var buf; + buf = new bytes.Buffer.Ptr(); $copy(buf, new bytes.Buffer.Ptr(), bytes.Buffer); + WriteType(buf, this$1, typ); + return buf.String(); + }; + WriteType = $pkg.WriteType = function(buf, this$1, typ) { + writeType(buf, this$1, typ, ($sliceType(Type)).make(8)); + }; + writeType = function(buf, this$1, typ, visited) { + var _ref, _i, t, t$1, _ref$1, _ref$2, _ref$3, _i$1, i, f, tag, _ref$4, _i$2, i$1, m, _ref$5, _i$3, i$2, m$1, _ref$6, _i$4, i$3, typ$1, s, parens, _ref$7, _tuple, c, s$1, obj, pkg; + _ref = visited; _i = 0; while (_i < _ref.$length) { - i$1 = _i; - (x = m.matchcap, (i$1 < 0 || i$1 >= x.$length) ? $throwRuntimeError("index out of range") : x.$array[x.$offset + i$1] = -1); + t = ((_i < 0 || _i >= _ref.$length) ? $throwRuntimeError("index out of range") : _ref.$array[_ref.$offset + _i]); + if ($interfaceIsEqual(t, typ)) { + fmt.Fprintf(buf, "\xE2\x97\x8B%T", new ($sliceType($emptyInterface))([typ])); + return; + } _i++; } - _tmp = m.q0; _tmp$1 = m.q1; runq = _tmp; nextq = _tmp$1; - _tmp$2 = -1; _tmp$3 = -1; r = _tmp$2; r1 = _tmp$3; - _tmp$4 = 0; _tmp$5 = 0; width = _tmp$4; width1 = _tmp$5; - _tuple = i.step(pos); r = _tuple[0]; width = _tuple[1]; - if (!((r === -1))) { - _tuple$1 = i.step(pos + width >> 0); r1 = _tuple$1[0]; width1 = _tuple$1[1]; - } - flag = 0; - if (pos === 0) { - flag = syntax.EmptyOpContext(-1, r); - } else { - flag = i.context(pos); - } - while (true) { - if (runq.dense.$length === 0) { - if (!((((startCond & 4) >>> 0) === 0)) && !((pos === 0))) { - break; + visited = $append(visited, typ); + _ref$1 = typ; + if (_ref$1 === $ifaceNil) { + t$1 = _ref$1; + buf.WriteString(""); + } else if ($assertType(_ref$1, ($ptrType(Basic)), true)[1]) { + t$1 = _ref$1.$val; + if (t$1.kind === 18) { + buf.WriteString("unsafe."); + } + if ($pkg.GcCompatibilityMode) { + _ref$2 = t$1.kind; + if (_ref$2 === 8) { + t$1 = $pkg.Typ[8]; + } else if (_ref$2 === 5) { + t$1 = $pkg.Typ[5]; } - if (m.matched) { - break; + } + buf.WriteString(t$1.name); + } else if ($assertType(_ref$1, ($ptrType(Array)), true)[1]) { + t$1 = _ref$1.$val; + fmt.Fprintf(buf, "[%d]", new ($sliceType($emptyInterface))([t$1.len])); + writeType(buf, this$1, t$1.elem, visited); + } else if ($assertType(_ref$1, ($ptrType(Slice)), true)[1]) { + t$1 = _ref$1.$val; + buf.WriteString("[]"); + writeType(buf, this$1, t$1.elem, visited); + } else if ($assertType(_ref$1, ($ptrType(Struct)), true)[1]) { + t$1 = _ref$1.$val; + buf.WriteString("struct{"); + _ref$3 = t$1.fields; + _i$1 = 0; + while (_i$1 < _ref$3.$length) { + i = _i$1; + f = ((_i$1 < 0 || _i$1 >= _ref$3.$length) ? $throwRuntimeError("index out of range") : _ref$3.$array[_ref$3.$offset + _i$1]); + if (i > 0) { + buf.WriteString("; "); } - if (m.re.prefix.length > 0 && !((r1 === m.re.prefixRune)) && i.canCheckPrefix()) { - advance = i.index(m.re, pos); - if (advance < 0) { - break; + if (!f.anonymous) { + buf.WriteString(f.object.name); + buf.WriteByte(32); + } + writeType(buf, this$1, f.object.typ, visited); + tag = t$1.Tag(i); + if (!(tag === "")) { + fmt.Fprintf(buf, " %q", new ($sliceType($emptyInterface))([new $String(tag)])); + } + _i$1++; + } + buf.WriteByte(125); + } else if ($assertType(_ref$1, ($ptrType(Pointer)), true)[1]) { + t$1 = _ref$1.$val; + buf.WriteByte(42); + writeType(buf, this$1, t$1.base, visited); + } else if ($assertType(_ref$1, ($ptrType(Tuple)), true)[1]) { + t$1 = _ref$1.$val; + writeTuple(buf, this$1, t$1, false, visited); + } else if ($assertType(_ref$1, ($ptrType(Signature)), true)[1]) { + t$1 = _ref$1.$val; + buf.WriteString("func"); + writeSignature(buf, this$1, t$1, visited); + } else if ($assertType(_ref$1, ($ptrType(Interface)), true)[1]) { + t$1 = _ref$1.$val; + buf.WriteString("interface{"); + if ($pkg.GcCompatibilityMode) { + _ref$4 = t$1.allMethods; + _i$2 = 0; + while (_i$2 < _ref$4.$length) { + i$1 = _i$2; + m = ((_i$2 < 0 || _i$2 >= _ref$4.$length) ? $throwRuntimeError("index out of range") : _ref$4.$array[_ref$4.$offset + _i$2]); + if (i$1 > 0) { + buf.WriteString("; "); } - pos = pos + (advance) >> 0; - _tuple$2 = i.step(pos); r = _tuple$2[0]; width = _tuple$2[1]; - _tuple$3 = i.step(pos + width >> 0); r1 = _tuple$3[0]; width1 = _tuple$3[1]; + buf.WriteString(m.object.name); + writeSignature(buf, this$1, $assertType(m.object.typ, ($ptrType(Signature))), visited); + _i$2++; + } + } else { + _ref$5 = t$1.methods; + _i$3 = 0; + while (_i$3 < _ref$5.$length) { + i$2 = _i$3; + m$1 = ((_i$3 < 0 || _i$3 >= _ref$5.$length) ? $throwRuntimeError("index out of range") : _ref$5.$array[_ref$5.$offset + _i$3]); + if (i$2 > 0) { + buf.WriteString("; "); + } + buf.WriteString(m$1.object.name); + writeSignature(buf, this$1, $assertType(m$1.object.typ, ($ptrType(Signature))), visited); + _i$3++; + } + _ref$6 = t$1.embeddeds; + _i$4 = 0; + while (_i$4 < _ref$6.$length) { + i$3 = _i$4; + typ$1 = ((_i$4 < 0 || _i$4 >= _ref$6.$length) ? $throwRuntimeError("index out of range") : _ref$6.$array[_ref$6.$offset + _i$4]); + if (i$3 > 0 || t$1.methods.$length > 0) { + buf.WriteString("; "); + } + writeType(buf, this$1, typ$1, visited); + _i$4++; } } - if (!m.matched) { - if (m.matchcap.$length > 0) { - (x$1 = m.matchcap, (0 < 0 || 0 >= x$1.$length) ? $throwRuntimeError("index out of range") : x$1.$array[x$1.$offset + 0] = pos); + buf.WriteByte(125); + } else if ($assertType(_ref$1, ($ptrType(Map)), true)[1]) { + t$1 = _ref$1.$val; + buf.WriteString("map["); + writeType(buf, this$1, t$1.key, visited); + buf.WriteByte(93); + writeType(buf, this$1, t$1.elem, visited); + } else if ($assertType(_ref$1, ($ptrType(Chan)), true)[1]) { + t$1 = _ref$1.$val; + s = ""; + parens = false; + _ref$7 = t$1.dir; + if (_ref$7 === 0) { + s = "chan "; + _tuple = $assertType(t$1.elem, ($ptrType(Chan)), true); c = _tuple[0]; + if (!(c === ($ptrType(Chan)).nil) && (c.dir === 2)) { + parens = true; } - m.add(runq, (m.p.Start >>> 0), pos, m.matchcap, flag, ($ptrType(thread)).nil); + } else if (_ref$7 === 1) { + s = "chan<- "; + } else if (_ref$7 === 2) { + s = "<-chan "; + } else { + $panic(new $String("unreachable")); } - flag = syntax.EmptyOpContext(r, r1); - m.step(runq, nextq, pos, pos + width >> 0, r, flag); - if (width === 0) { - break; + buf.WriteString(s); + if (parens) { + buf.WriteByte(40); } - if ((m.matchcap.$length === 0) && m.matched) { - break; + writeType(buf, this$1, t$1.elem, visited); + if (parens) { + buf.WriteByte(41); } - pos = pos + (width) >> 0; - _tmp$6 = r1; _tmp$7 = width1; r = _tmp$6; width = _tmp$7; - if (!((r === -1))) { - _tuple$4 = i.step(pos + width >> 0); r1 = _tuple$4[0]; width1 = _tuple$4[1]; + } else if ($assertType(_ref$1, ($ptrType(Named)), true)[1]) { + t$1 = _ref$1.$val; + s$1 = ""; + obj = t$1.obj; + if (!(obj === ($ptrType(TypeName)).nil)) { + pkg = obj.object.pkg; + if (!(pkg === ($ptrType(Package)).nil) && !(pkg === this$1)) { + buf.WriteString(pkg.path); + buf.WriteByte(46); + } + s$1 = obj.object.name; } - _tmp$8 = nextq; _tmp$9 = runq; runq = _tmp$8; nextq = _tmp$9; + buf.WriteString(s$1); + } else { + t$1 = _ref$1; + buf.WriteString(t$1.String()); } - m.clear(nextq); - return m.matched; }; - machine.prototype.match = function(i, pos) { return this.$val.match(i, pos); }; - machine.Ptr.prototype.clear = function(q) { - var m, _ref, _i, d; - m = this; - _ref = q.dense; - _i = 0; - while (_i < _ref.$length) { - d = new entry.Ptr(); $copy(d, ((_i < 0 || _i >= _ref.$length) ? $throwRuntimeError("index out of range") : _ref.$array[_ref.$offset + _i]), entry); - if (!(d.t === ($ptrType(thread)).nil)) { - m.pool = $append(m.pool, d.t); + writeTuple = function(buf, this$1, tup, variadic, visited) { + var _ref, _i, i, v, typ, _tuple, s, ok, _tuple$1, t, ok$1; + buf.WriteByte(40); + if (!(tup === ($ptrType(Tuple)).nil)) { + _ref = tup.vars; + _i = 0; + while (_i < _ref.$length) { + i = _i; + v = ((_i < 0 || _i >= _ref.$length) ? $throwRuntimeError("index out of range") : _ref.$array[_ref.$offset + _i]); + if (i > 0) { + buf.WriteString(", "); + } + if (!(v.object.name === "")) { + buf.WriteString(v.object.name); + buf.WriteByte(32); + } + typ = v.object.typ; + if (variadic && (i === (tup.vars.$length - 1 >> 0))) { + _tuple = $assertType(typ, ($ptrType(Slice)), true); s = _tuple[0]; ok = _tuple[1]; + if (ok) { + buf.WriteString("..."); + typ = s.elem; + } else { + _tuple$1 = $assertType(typ.Underlying(), ($ptrType(Basic)), true); t = _tuple$1[0]; ok$1 = _tuple$1[1]; + if (!ok$1 || !((t.kind === 17))) { + $panic(new $String("internal error: string type expected")); + } + writeType(buf, this$1, typ, visited); + buf.WriteString("..."); + _i++; + continue; + } + } + writeType(buf, this$1, typ, visited); + _i++; } - _i++; } - q.dense = $subslice(q.dense, 0, 0); + buf.WriteByte(41); }; - machine.prototype.clear = function(q) { return this.$val.clear(q); }; - machine.Ptr.prototype.step = function(runq, nextq, pos, nextPos, c, nextCond) { - var m, longest, j, x, d, t, x$1, x$2, i, add, _ref, x$3, x$4, _ref$1, _i, d$1, x$5; - m = this; - longest = m.re.longest; - j = 0; - while (j < runq.dense.$length) { - d = (x = runq.dense, ((j < 0 || j >= x.$length) ? $throwRuntimeError("index out of range") : x.$array[x.$offset + j])); - t = d.t; - if (t === ($ptrType(thread)).nil) { - j = j + (1) >> 0; - continue; + WriteSignature = $pkg.WriteSignature = function(buf, this$1, sig) { + writeSignature(buf, this$1, sig, ($sliceType(Type)).make(8)); + }; + writeSignature = function(buf, this$1, sig, visited) { + var n, x, x$1; + writeTuple(buf, this$1, sig.params, sig.variadic, visited); + n = sig.results.Len(); + if (n === 0) { + return; + } + buf.WriteByte(32); + if ((n === 1) && (x = sig.results.vars, ((0 < 0 || 0 >= x.$length) ? $throwRuntimeError("index out of range") : x.$array[x.$offset + 0])).object.name === "") { + writeType(buf, this$1, (x$1 = sig.results.vars, ((0 < 0 || 0 >= x$1.$length) ? $throwRuntimeError("index out of range") : x$1.$array[x$1.$offset + 0])).object.typ, visited); + return; + } + writeTuple(buf, this$1, sig.results, false, visited); + }; + Checker.Ptr.prototype.ident = function(x, e, def$1, path$1) { + var check, obj, typ, obj$1, _ref, _ref$1, _i, i, prev, _ref$2, _i$1, obj$2; + check = this; + x.mode = 0; + x.expr = e; + obj = check.context.scope.LookupParent(e.Name); + if ($interfaceIsEqual(obj, $ifaceNil)) { + if (e.Name === "_") { + check.errorf(e.Pos(), "cannot use _ as value or type", new ($sliceType($emptyInterface))([])); + } else { + check.errorf(e.Pos(), "undeclared name: %s", new ($sliceType($emptyInterface))([new $String(e.Name)])); } - if (longest && m.matched && t.cap.$length > 0 && (x$1 = m.matchcap, ((0 < 0 || 0 >= x$1.$length) ? $throwRuntimeError("index out of range") : x$1.$array[x$1.$offset + 0])) < (x$2 = t.cap, ((0 < 0 || 0 >= x$2.$length) ? $throwRuntimeError("index out of range") : x$2.$array[x$2.$offset + 0]))) { - m.pool = $append(m.pool, t); - j = j + (1) >> 0; - continue; + return; + } + check.recordUse(e, obj); + check.objDecl(obj, def$1, path$1); + typ = obj.Type(); + assert(!($interfaceIsEqual(typ, $ifaceNil))); + _ref = obj; + if ($assertType(_ref, ($ptrType(PkgName)), true)[1]) { + obj$1 = _ref.$val; + check.errorf(e.Pos(), "use of package %s not in selector", new ($sliceType($emptyInterface))([new $String(obj$1.object.name)])); + return; + } else if ($assertType(_ref, ($ptrType(Const)), true)[1]) { + obj$1 = _ref.$val; + obj$1.object.used = true; + check.addDeclDep(obj$1); + if ($interfaceIsEqual(typ, $pkg.Typ[0])) { + return; + } + if (obj$1 === universeIota) { + if ($interfaceIsEqual(check.context.iota, $ifaceNil)) { + check.errorf(e.Pos(), "cannot use iota outside constant declaration", new ($sliceType($emptyInterface))([])); + return; + } + x.val = check.context.iota; + } else { + x.val = obj$1.val; + } + assert(!($interfaceIsEqual(x.val, $ifaceNil))); + x.mode = 4; + } else if ($assertType(_ref, ($ptrType(TypeName)), true)[1]) { + obj$1 = _ref.$val; + obj$1.object.used = true; + x.mode = 3; + _ref$1 = path$1; + _i = 0; + while (_i < _ref$1.$length) { + i = _i; + prev = ((_i < 0 || _i >= _ref$1.$length) ? $throwRuntimeError("index out of range") : _ref$1.$array[_ref$1.$offset + _i]); + if (prev === obj$1) { + check.errorf(obj$1.object.pos, "illegal cycle in declaration of %s", new ($sliceType($emptyInterface))([new $String(obj$1.object.name)])); + _ref$2 = $subslice(path$1, i); + _i$1 = 0; + while (_i$1 < _ref$2.$length) { + obj$2 = ((_i$1 < 0 || _i$1 >= _ref$2.$length) ? $throwRuntimeError("index out of range") : _ref$2.$array[_ref$2.$offset + _i$1]); + check.errorf(obj$2.object.Pos(), "\t%s refers to", new ($sliceType($emptyInterface))([new $String(obj$2.object.Name())])); + _i$1++; + } + check.errorf(obj$1.object.Pos(), "\t%s", new ($sliceType($emptyInterface))([new $String(obj$1.object.Name())])); + typ = $pkg.Typ[0]; + break; + } + _i++; + } + } else if ($assertType(_ref, ($ptrType(Var)), true)[1]) { + obj$1 = _ref.$val; + obj$1.object.used = true; + check.addDeclDep(obj$1); + if ($interfaceIsEqual(typ, $pkg.Typ[0])) { + return; + } + x.mode = 5; + } else if ($assertType(_ref, ($ptrType(Func)), true)[1]) { + obj$1 = _ref.$val; + obj$1.object.used = true; + check.addDeclDep(obj$1); + x.mode = 7; + } else if ($assertType(_ref, ($ptrType(Builtin)), true)[1]) { + obj$1 = _ref.$val; + obj$1.object.used = true; + x.id = obj$1.id; + x.mode = 2; + } else if ($assertType(_ref, ($ptrType(Nil)), true)[1]) { + obj$1 = _ref.$val; + x.mode = 7; + } else { + obj$1 = _ref; + unreachable(); + } + x.typ = typ; + }; + Checker.prototype.ident = function(x, e, def$1, path$1) { return this.$val.ident(x, e, def$1, path$1); }; + Checker.Ptr.prototype.typExpr = function(e, def$1, path$1) { + var T = $ifaceNil, $deferred = [], $err = null, check; + /* */ try { $deferFrames.push($deferred); + check = this; + T = check.typExprInternal(e, def$1, path$1); + assert(isTyped(T)); + check.recordTypeAndValue(e, 3, T, $ifaceNil); + return T; + /* */ } catch(err) { $err = err; } finally { $deferFrames.pop(); $callDeferred($deferred, $err); return T; } + }; + Checker.prototype.typExpr = function(e, def$1, path$1) { return this.$val.typExpr(e, def$1, path$1); }; + Checker.Ptr.prototype.typ = function(e) { + var check; + check = this; + return check.typExpr(e, ($ptrType(Named)).nil, ($sliceType(($ptrType(TypeName)))).nil); + }; + Checker.prototype.typ = function(e) { return this.$val.typ(e); }; + Checker.Ptr.prototype.funcType = function(sig, recvPar, ftyp) { + var check, scope, _tuple, recvList, _tuple$1, params, variadic, _tuple$2, results, recv, _ref, x, _tuple$3, t, err, _tuple$4, T, u, _ref$1; + check = this; + scope = NewScope(check.context.scope, "function"); + check.recordScope(ftyp, scope); + _tuple = check.collectParams(scope, recvPar, false); recvList = _tuple[0]; + _tuple$1 = check.collectParams(scope, ftyp.Params, true); params = _tuple$1[0]; variadic = _tuple$1[1]; + _tuple$2 = check.collectParams(scope, ftyp.Results, false); results = _tuple$2[0]; + if (!(recvPar === ($ptrType(ast.FieldList)).nil)) { + recv = ($ptrType(Var)).nil; + _ref = recvList.$length; + if (_ref === 0) { + check.error(recvPar.Pos(), "method is missing receiver"); + recv = NewParam(0, ($ptrType(Package)).nil, "", $pkg.Typ[0]); + } else if (_ref === 1) { + recv = ((0 < 0 || 0 >= recvList.$length) ? $throwRuntimeError("index out of range") : recvList.$array[recvList.$offset + 0]); + } else { + check.error((x = recvList.$length - 1 >> 0, ((x < 0 || x >= recvList.$length) ? $throwRuntimeError("index out of range") : recvList.$array[recvList.$offset + x])).object.Pos(), "method must have exactly one receiver"); + recv = ((0 < 0 || 0 >= recvList.$length) ? $throwRuntimeError("index out of range") : recvList.$array[recvList.$offset + 0]); } - i = t.inst; - add = false; - _ref = i.Op; - if (_ref === 4) { - if (t.cap.$length > 0 && (!longest || !m.matched || (x$3 = m.matchcap, ((1 < 0 || 1 >= x$3.$length) ? $throwRuntimeError("index out of range") : x$3.$array[x$3.$offset + 1])) < pos)) { - (x$4 = t.cap, (1 < 0 || 1 >= x$4.$length) ? $throwRuntimeError("index out of range") : x$4.$array[x$4.$offset + 1] = pos); - $copySlice(m.matchcap, t.cap); - } - if (!longest) { - _ref$1 = $subslice(runq.dense, (j + 1 >> 0)); - _i = 0; - while (_i < _ref$1.$length) { - d$1 = new entry.Ptr(); $copy(d$1, ((_i < 0 || _i >= _ref$1.$length) ? $throwRuntimeError("index out of range") : _ref$1.$array[_ref$1.$offset + _i]), entry); - if (!(d$1.t === ($ptrType(thread)).nil)) { - m.pool = $append(m.pool, d$1.t); + _tuple$3 = deref(recv.object.typ); t = _tuple$3[0]; + if (!($interfaceIsEqual(t, $pkg.Typ[0]))) { + err = ""; + _tuple$4 = $assertType(t, ($ptrType(Named)), true); T = _tuple$4[0]; + if (!(T === ($ptrType(Named)).nil)) { + if (!(T.obj.object.pkg === check.pkg)) { + err = "type not defined in this package"; + } else { + _ref$1 = T.underlying; + if ($assertType(_ref$1, ($ptrType(Basic)), true)[1]) { + u = _ref$1.$val; + if (u.kind === 18) { + err = "unsafe.Pointer"; + } + } else if ($assertType(_ref$1, ($ptrType(Pointer)), true)[1] || $assertType(_ref$1, ($ptrType(Interface)), true)[1]) { + u = _ref$1; + err = "pointer or interface type"; } - _i++; } - runq.dense = $subslice(runq.dense, 0, 0); + } else { + err = "basic or unnamed type"; + } + if (!(err === "")) { + check.errorf(recv.object.pos, "invalid receiver %s (%s)", new ($sliceType($emptyInterface))([recv.object.typ, new $String(err)])); } - m.matched = true; - } else if (_ref === 7) { - add = i.MatchRune(c); - } else if (_ref === 8) { - add = c === (x$5 = i.Rune, ((0 < 0 || 0 >= x$5.$length) ? $throwRuntimeError("index out of range") : x$5.$array[x$5.$offset + 0])); - } else if (_ref === 9) { - add = true; - } else if (_ref === 10) { - add = !((c === 10)); - } else { - $panic(new $String("bad inst")); - } - if (add) { - t = m.add(nextq, i.Out, nextPos, t.cap, nextCond, t); - } - if (!(t === ($ptrType(thread)).nil)) { - m.pool = $append(m.pool, t); } - j = j + (1) >> 0; + sig.recv = recv; } - runq.dense = $subslice(runq.dense, 0, 0); + sig.scope = scope; + sig.params = NewTuple(params); + sig.results = NewTuple(results); + sig.variadic = variadic; + return sig; }; - machine.prototype.step = function(runq, nextq, pos, nextPos, c, nextCond) { return this.$val.step(runq, nextq, pos, nextPos, c, nextCond); }; - machine.Ptr.prototype.add = function(q, pc, pos, cap, cond, t) { - var m, x, j, x$1, j$1, x$2, d, x$3, x$4, i, _ref, x$5, opos, x$6, x$7; - m = this; - if (pc === 0) { - return t; - } - j = (x = q.sparse, ((pc < 0 || pc >= x.$length) ? $throwRuntimeError("index out of range") : x.$array[x.$offset + pc])); - if (j < (q.dense.$length >>> 0) && ((x$1 = q.dense, ((j < 0 || j >= x$1.$length) ? $throwRuntimeError("index out of range") : x$1.$array[x$1.$offset + j])).pc === pc)) { - return t; - } - j$1 = q.dense.$length; - q.dense = $subslice(q.dense, 0, (j$1 + 1 >> 0)); - d = (x$2 = q.dense, ((j$1 < 0 || j$1 >= x$2.$length) ? $throwRuntimeError("index out of range") : x$2.$array[x$2.$offset + j$1])); - d.t = ($ptrType(thread)).nil; - d.pc = pc; - (x$3 = q.sparse, (pc < 0 || pc >= x$3.$length) ? $throwRuntimeError("index out of range") : x$3.$array[x$3.$offset + pc] = (j$1 >>> 0)); - i = (x$4 = m.p.Inst, ((pc < 0 || pc >= x$4.$length) ? $throwRuntimeError("index out of range") : x$4.$array[x$4.$offset + pc])); - _ref = i.Op; - if (_ref === 5) { - } else if (_ref === 0 || _ref === 1) { - t = m.add(q, i.Out, pos, cap, cond, t); - t = m.add(q, i.Arg, pos, cap, cond, t); - } else if (_ref === 3) { - if (((i.Arg << 24 >>> 24) & ~cond) === 0) { - t = m.add(q, i.Out, pos, cap, cond, t); - } - } else if (_ref === 6) { - t = m.add(q, i.Out, pos, cap, cond, t); - } else if (_ref === 2) { - if ((i.Arg >> 0) < cap.$length) { - opos = (x$5 = i.Arg, ((x$5 < 0 || x$5 >= cap.$length) ? $throwRuntimeError("index out of range") : cap.$array[cap.$offset + x$5])); - (x$6 = i.Arg, (x$6 < 0 || x$6 >= cap.$length) ? $throwRuntimeError("index out of range") : cap.$array[cap.$offset + x$6] = pos); - m.add(q, i.Out, pos, cap, cond, ($ptrType(thread)).nil); - (x$7 = i.Arg, (x$7 < 0 || x$7 >= cap.$length) ? $throwRuntimeError("index out of range") : cap.$array[cap.$offset + x$7] = opos); + Checker.prototype.funcType = function(sig, recvPar, ftyp) { return this.$val.funcType(sig, recvPar, ftyp); }; + Checker.Ptr.prototype.typExprInternal = function(e, def$1, path$1) { + var check, e$1, _ref, x, _ref$1, typ, x$1, _ref$2, typ$1, typ$2, typ$3, typ$4, typ$5, typ$6, typ$7, typ$8, typ$9, dir, _ref$3, typ$10; + check = this; + _ref = e; + if ($assertType(_ref, ($ptrType(ast.BadExpr)), true)[1]) { + e$1 = _ref.$val; + } else if ($assertType(_ref, ($ptrType(ast.Ident)), true)[1]) { + e$1 = _ref.$val; + x = new operand.Ptr(); $copy(x, new operand.Ptr(), operand); + check.ident(x, e$1, def$1, path$1); + _ref$1 = x.mode; + if (_ref$1 === 3) { + typ = x.typ; + def$1.setUnderlying(typ); + return typ; + } else if (_ref$1 === 0) { + } else if (_ref$1 === 1) { + check.errorf(x.pos(), "%s used as type", new ($sliceType($emptyInterface))([x])); } else { - t = m.add(q, i.Out, pos, cap, cond, t); + check.errorf(x.pos(), "%s is not a type", new ($sliceType($emptyInterface))([x])); } - } else if (_ref === 4 || _ref === 7 || _ref === 8 || _ref === 9 || _ref === 10) { - if (t === ($ptrType(thread)).nil) { - t = m.alloc(i); + } else if ($assertType(_ref, ($ptrType(ast.SelectorExpr)), true)[1]) { + e$1 = _ref.$val; + x$1 = new operand.Ptr(); $copy(x$1, new operand.Ptr(), operand); + check.selector(x$1, e$1); + _ref$2 = x$1.mode; + if (_ref$2 === 3) { + typ$1 = x$1.typ; + def$1.setUnderlying(typ$1); + return typ$1; + } else if (_ref$2 === 0) { + } else if (_ref$2 === 1) { + check.errorf(x$1.pos(), "%s used as type", new ($sliceType($emptyInterface))([x$1])); } else { - t.inst = i; - } - if (cap.$length > 0 && !($sliceIsEqual(t.cap, 0, cap, 0))) { - $copySlice(t.cap, cap); + check.errorf(x$1.pos(), "%s is not a type", new ($sliceType($emptyInterface))([x$1])); } - d.t = t; - t = ($ptrType(thread)).nil; - } else { - $panic(new $String("unhandled")); - } - return t; - }; - machine.prototype.add = function(q, pc, pos, cap, cond, t) { return this.$val.add(q, pc, pos, cap, cond, t); }; - machine.Ptr.prototype.onepass = function(i, pos) { - var m, startCond, _ref, _i, i$1, x, _tmp, _tmp$1, r, r1, _tmp$2, _tmp$3, width, width1, _tuple, _tuple$1, flag, pc, x$1, inst, _tuple$2, _tuple$3, x$2, _ref$1, x$3, x$4, x$5, x$6, x$7, _tmp$4, _tmp$5, _tuple$4; - m = this; - startCond = m.re.cond; - if (startCond === 255) { - return false; - } - m.matched = false; - _ref = m.matchcap; - _i = 0; - while (_i < _ref.$length) { - i$1 = _i; - (x = m.matchcap, (i$1 < 0 || i$1 >= x.$length) ? $throwRuntimeError("index out of range") : x.$array[x.$offset + i$1] = -1); - _i++; - } - _tmp = -1; _tmp$1 = -1; r = _tmp; r1 = _tmp$1; - _tmp$2 = 0; _tmp$3 = 0; width = _tmp$2; width1 = _tmp$3; - _tuple = i.step(pos); r = _tuple[0]; width = _tuple[1]; - if (!((r === -1))) { - _tuple$1 = i.step(pos + width >> 0); r1 = _tuple$1[0]; width1 = _tuple$1[1]; - } - flag = 0; - if (pos === 0) { - flag = syntax.EmptyOpContext(-1, r); - } else { - flag = i.context(pos); - } - pc = m.op.Start; - inst = new onePassInst.Ptr(); $copy(inst, (x$1 = m.op.Inst, ((pc < 0 || pc >= x$1.$length) ? $throwRuntimeError("index out of range") : x$1.$array[x$1.$offset + pc])), onePassInst); - if ((pos === 0) && (((inst.Inst.Arg << 24 >>> 24) & ~flag) === 0) && m.re.prefix.length > 0 && i.canCheckPrefix()) { - if (i.hasPrefix(m.re)) { - pos = pos + (m.re.prefix.length) >> 0; - _tuple$2 = i.step(pos); r = _tuple$2[0]; width = _tuple$2[1]; - _tuple$3 = i.step(pos + width >> 0); r1 = _tuple$3[0]; width1 = _tuple$3[1]; - flag = i.context(pos); - pc = (m.re.prefixEnd >> 0); + } else if ($assertType(_ref, ($ptrType(ast.ParenExpr)), true)[1]) { + e$1 = _ref.$val; + return check.typExpr(e$1.X, def$1, path$1); + } else if ($assertType(_ref, ($ptrType(ast.ArrayType)), true)[1]) { + e$1 = _ref.$val; + if (!($interfaceIsEqual(e$1.Len, $ifaceNil))) { + typ$2 = new Array.Ptr(); + def$1.setUnderlying(typ$2); + typ$2.len = check.arrayLength(e$1.Len); + typ$2.elem = check.typExpr(e$1.Elt, ($ptrType(Named)).nil, path$1); + return typ$2; } else { - return m.matched; + typ$3 = new Slice.Ptr(); + def$1.setUnderlying(typ$3); + typ$3.elem = check.typ(e$1.Elt); + return typ$3; } - } - while (true) { - $copy(inst, (x$2 = m.op.Inst, ((pc < 0 || pc >= x$2.$length) ? $throwRuntimeError("index out of range") : x$2.$array[x$2.$offset + pc])), onePassInst); - pc = (inst.Inst.Out >> 0); - _ref$1 = inst.Inst.Op; - if (_ref$1 === 4) { - m.matched = true; - if (m.matchcap.$length > 0) { - (x$3 = m.matchcap, (0 < 0 || 0 >= x$3.$length) ? $throwRuntimeError("index out of range") : x$3.$array[x$3.$offset + 0] = 0); - (x$4 = m.matchcap, (1 < 0 || 1 >= x$4.$length) ? $throwRuntimeError("index out of range") : x$4.$array[x$4.$offset + 1] = pos); - } - return m.matched; - } else if (_ref$1 === 7) { - if (!inst.Inst.MatchRune(r)) { - return m.matched; - } - } else if (_ref$1 === 8) { - if (!((r === (x$5 = inst.Inst.Rune, ((0 < 0 || 0 >= x$5.$length) ? $throwRuntimeError("index out of range") : x$5.$array[x$5.$offset + 0]))))) { - return m.matched; - } - } else if (_ref$1 === 9) { - } else if (_ref$1 === 10) { - if (r === 10) { - return m.matched; - } - } else if (_ref$1 === 0 || _ref$1 === 1) { - pc = (onePassNext(inst, r) >> 0); - continue; - } else if (_ref$1 === 5) { - return m.matched; - } else if (_ref$1 === 6) { - continue; - } else if (_ref$1 === 3) { - if (!((((inst.Inst.Arg << 24 >>> 24) & ~flag) === 0))) { - return m.matched; - } - continue; - } else if (_ref$1 === 2) { - if ((inst.Inst.Arg >> 0) < m.matchcap.$length) { - (x$6 = m.matchcap, x$7 = inst.Inst.Arg, (x$7 < 0 || x$7 >= x$6.$length) ? $throwRuntimeError("index out of range") : x$6.$array[x$6.$offset + x$7] = pos); + } else if ($assertType(_ref, ($ptrType(ast.StructType)), true)[1]) { + e$1 = _ref.$val; + typ$4 = new Struct.Ptr(); + def$1.setUnderlying(typ$4); + check.structType(typ$4, e$1, path$1); + return typ$4; + } else if ($assertType(_ref, ($ptrType(ast.StarExpr)), true)[1]) { + e$1 = _ref.$val; + typ$5 = new Pointer.Ptr(); + def$1.setUnderlying(typ$5); + typ$5.base = check.typ(e$1.X); + return typ$5; + } else if ($assertType(_ref, ($ptrType(ast.FuncType)), true)[1]) { + e$1 = _ref.$val; + typ$6 = new Signature.Ptr(); + def$1.setUnderlying(typ$6); + check.funcType(typ$6, ($ptrType(ast.FieldList)).nil, e$1); + return typ$6; + } else if ($assertType(_ref, ($ptrType(ast.InterfaceType)), true)[1]) { + e$1 = _ref.$val; + typ$7 = new Interface.Ptr(); + def$1.setUnderlying(typ$7); + check.interfaceType(typ$7, e$1, def$1, path$1); + return typ$7; + } else if ($assertType(_ref, ($ptrType(ast.MapType)), true)[1]) { + e$1 = _ref.$val; + typ$8 = new Map.Ptr(); + def$1.setUnderlying(typ$8); + typ$8.key = check.typ(e$1.Key); + typ$8.elem = check.typ(e$1.Value); + check.delay((function() { + if (!Comparable(typ$8.key)) { + check.errorf(e$1.Key.Pos(), "invalid map key type %s", new ($sliceType($emptyInterface))([typ$8.key])); } - continue; + })); + return typ$8; + } else if ($assertType(_ref, ($ptrType(ast.ChanType)), true)[1]) { + e$1 = _ref.$val; + typ$9 = new Chan.Ptr(); + def$1.setUnderlying(typ$9); + dir = 0; + _ref$3 = e$1.Dir; + if (_ref$3 === 3) { + } else if (_ref$3 === 1) { + dir = 1; + } else if (_ref$3 === 2) { + dir = 2; } else { - $panic(new $String("bad inst")); - } - if (width === 0) { - break; - } - flag = syntax.EmptyOpContext(r, r1); - pos = pos + (width) >> 0; - _tmp$4 = r1; _tmp$5 = width1; r = _tmp$4; width = _tmp$5; - if (!((r === -1))) { - _tuple$4 = i.step(pos + width >> 0); r1 = _tuple$4[0]; width1 = _tuple$4[1]; + check.invalidAST(e$1.Pos(), "unknown channel direction %d", new ($sliceType($emptyInterface))([new ast.ChanDir(e$1.Dir)])); } - } - return m.matched; - }; - machine.prototype.onepass = function(i, pos) { return this.$val.onepass(i, pos); }; - Regexp.Ptr.prototype.doExecute = function(r, b, s, pos, ncap) { - var re, m, i, cap; - re = this; - m = re.get(); - i = $ifaceNil; - if (!($interfaceIsEqual(r, $ifaceNil))) { - i = m.newInputReader(r); - } else if (!(b === ($sliceType($Uint8)).nil)) { - i = m.newInputBytes(b); + typ$9.dir = dir; + typ$9.elem = check.typ(e$1.Value); + return typ$9; } else { - i = m.newInputString(s); + e$1 = _ref; + check.errorf(e$1.Pos(), "%s is not a type", new ($sliceType($emptyInterface))([e$1])); } - if (!(m.op === notOnePass)) { - if (!m.onepass(i, pos)) { - re.put(m); - return ($sliceType($Int)).nil; + typ$10 = $pkg.Typ[0]; + def$1.setUnderlying(typ$10); + return typ$10; + }; + Checker.prototype.typExprInternal = function(e, def$1, path$1) { return this.$val.typExprInternal(e, def$1, path$1); }; + Checker.Ptr.prototype.typOrNil = function(e) { + var check, x, _ref; + check = this; + x = new operand.Ptr(); $copy(x, new operand.Ptr(), operand); + check.rawExpr(x, e, $ifaceNil); + _ref = x.mode; + if (_ref === 0) { + } else if (_ref === 1) { + check.errorf(x.pos(), "%s used as type", new ($sliceType($emptyInterface))([x])); + } else if (_ref === 3) { + return x.typ; + } else if (_ref === 7) { + if (x.isNil()) { + return $ifaceNil; } + check.errorf(x.pos(), "%s is not a type", new ($sliceType($emptyInterface))([x])); } else { - m.init(ncap); - if (!m.match(i, pos)) { - re.put(m); - return ($sliceType($Int)).nil; - } - } - if (ncap === 0) { - re.put(m); - return empty; - } - cap = ($sliceType($Int)).make(m.matchcap.$length); - $copySlice(cap, m.matchcap); - re.put(m); - return cap; - }; - Regexp.prototype.doExecute = function(r, b, s, pos, ncap) { return this.$val.doExecute(r, b, s, pos, ncap); }; - onePassPrefix = function(p) { - var prefix = "", complete = false, pc = 0, x, x$1, i, _tmp, _tmp$1, _tmp$2, x$2, x$3, _tmp$3, _tmp$4, _tmp$5, buf, x$4, _tmp$6, _tmp$7, x$5, x$6, _tmp$8, _tmp$9, _tmp$10; - i = (x = p.Inst, x$1 = p.Start, ((x$1 < 0 || x$1 >= x.$length) ? $throwRuntimeError("index out of range") : x.$array[x.$offset + x$1])); - if (!((i.Op === 3)) || (((((i.Arg << 24 >>> 24)) & 4) >>> 0) === 0)) { - _tmp = ""; _tmp$1 = i.Op === 4; _tmp$2 = (p.Start >>> 0); prefix = _tmp; complete = _tmp$1; pc = _tmp$2; - return [prefix, complete, pc]; - } - pc = i.Out; - i = (x$2 = p.Inst, ((pc < 0 || pc >= x$2.$length) ? $throwRuntimeError("index out of range") : x$2.$array[x$2.$offset + pc])); - while (i.Op === 6) { - pc = i.Out; - i = (x$3 = p.Inst, ((pc < 0 || pc >= x$3.$length) ? $throwRuntimeError("index out of range") : x$3.$array[x$3.$offset + pc])); - } - if (!((iop(i) === 7)) || !((i.Rune.$length === 1))) { - _tmp$3 = ""; _tmp$4 = i.Op === 4; _tmp$5 = (p.Start >>> 0); prefix = _tmp$3; complete = _tmp$4; pc = _tmp$5; - return [prefix, complete, pc]; - } - buf = new bytes.Buffer.Ptr(); $copy(buf, new bytes.Buffer.Ptr(), bytes.Buffer); - while ((iop(i) === 7) && (i.Rune.$length === 1) && ((((i.Arg << 16 >>> 16) & 1) >>> 0) === 0)) { - buf.WriteRune((x$4 = i.Rune, ((0 < 0 || 0 >= x$4.$length) ? $throwRuntimeError("index out of range") : x$4.$array[x$4.$offset + 0]))); - _tmp$6 = i.Out; _tmp$7 = (x$5 = p.Inst, x$6 = i.Out, ((x$6 < 0 || x$6 >= x$5.$length) ? $throwRuntimeError("index out of range") : x$5.$array[x$5.$offset + x$6])); pc = _tmp$6; i = _tmp$7; - } - _tmp$8 = buf.String(); _tmp$9 = (i.Op === 3) && !((((((i.Arg << 24 >>> 24)) & 4) >>> 0) === 0)); _tmp$10 = pc; prefix = _tmp$8; complete = _tmp$9; pc = _tmp$10; - return [prefix, complete, pc]; - }; - onePassNext = function(i, r) { - var next, x; - next = i.Inst.MatchRunePos(r); - if (next >= 0) { - return (x = i.Next, ((next < 0 || next >= x.$length) ? $throwRuntimeError("index out of range") : x.$array[x.$offset + next])); - } - if (i.Inst.Op === 1) { - return i.Inst.Out; - } - return 0; - }; - iop = function(i) { - var op, _ref; - op = i.Op; - _ref = op; - if (_ref === 8 || _ref === 9 || _ref === 10) { - op = 7; - } - return op; - }; - queueOnePass.Ptr.prototype.empty = function() { - var q; - q = this; - return q.nextIndex >= q.size; - }; - queueOnePass.prototype.empty = function() { return this.$val.empty(); }; - queueOnePass.Ptr.prototype.next = function() { - var n = 0, q, x, x$1; - q = this; - n = (x = q.dense, x$1 = q.nextIndex, ((x$1 < 0 || x$1 >= x.$length) ? $throwRuntimeError("index out of range") : x.$array[x.$offset + x$1])); - q.nextIndex = q.nextIndex + (1) >>> 0; - return n; - }; - queueOnePass.prototype.next = function() { return this.$val.next(); }; - queueOnePass.Ptr.prototype.clear = function() { - var q; - q = this; - q.size = 0; - q.nextIndex = 0; - }; - queueOnePass.prototype.clear = function() { return this.$val.clear(); }; - queueOnePass.Ptr.prototype.contains = function(u) { - var q, x, x$1, x$2, x$3; - q = this; - if (u >= (q.sparse.$length >>> 0)) { - return false; - } - return (x = q.sparse, ((u < 0 || u >= x.$length) ? $throwRuntimeError("index out of range") : x.$array[x.$offset + u])) < q.size && ((x$1 = q.dense, x$2 = (x$3 = q.sparse, ((u < 0 || u >= x$3.$length) ? $throwRuntimeError("index out of range") : x$3.$array[x$3.$offset + u])), ((x$2 < 0 || x$2 >= x$1.$length) ? $throwRuntimeError("index out of range") : x$1.$array[x$1.$offset + x$2])) === u); - }; - queueOnePass.prototype.contains = function(u) { return this.$val.contains(u); }; - queueOnePass.Ptr.prototype.insert = function(u) { - var q; - q = this; - if (!q.contains(u)) { - q.insertNew(u); - } - }; - queueOnePass.prototype.insert = function(u) { return this.$val.insert(u); }; - queueOnePass.Ptr.prototype.insertNew = function(u) { - var q, x, x$1, x$2; - q = this; - if (u >= (q.sparse.$length >>> 0)) { - return; + check.errorf(x.pos(), "%s is not a type", new ($sliceType($emptyInterface))([x])); } - (x = q.sparse, (u < 0 || u >= x.$length) ? $throwRuntimeError("index out of range") : x.$array[x.$offset + u] = q.size); - (x$1 = q.dense, x$2 = q.size, (x$2 < 0 || x$2 >= x$1.$length) ? $throwRuntimeError("index out of range") : x$1.$array[x$1.$offset + x$2] = u); - q.size = q.size + (1) >>> 0; - }; - queueOnePass.prototype.insertNew = function(u) { return this.$val.insertNew(u); }; - newQueue = function(size) { - var q = ($ptrType(queueOnePass)).nil; - q = new queueOnePass.Ptr(($sliceType($Uint32)).make(size), ($sliceType($Uint32)).make(size), 0, 0); - return q; + return $pkg.Typ[0]; }; - mergeRuneSets = function(leftRunes, rightRunes, leftPC, rightPC) { - var $deferred = [], $err = null, leftLen, rightLen, _tmp, _tmp$1, lx, rx, merged, next, ok, ix, extend, x, x$1; - /* */ try { $deferFrames.push($deferred); - leftLen = leftRunes.$get().$length; - rightLen = rightRunes.$get().$length; - if (!(((leftLen & 1) === 0)) || !(((rightLen & 1) === 0))) { - $panic(new $String("mergeRuneSets odd length []rune")); - } - _tmp = 0; _tmp$1 = 0; lx = _tmp; rx = _tmp$1; - merged = ($sliceType($Int32)).make(0); - next = ($sliceType($Uint32)).make(0); - ok = true; - $deferred.push([(function() { - if (!ok) { - merged = ($sliceType($Int32)).nil; - next = ($sliceType($Uint32)).nil; - } - }), []]); - ix = -1; - extend = (function(newLow, newArray, pc) { - var x, x$1, x$2, x$3, x$4, x$5, _lhs; - if (ix > 0 && (x = newArray.$get(), x$1 = newLow.$get(), ((x$1 < 0 || x$1 >= x.$length) ? $throwRuntimeError("index out of range") : x.$array[x.$offset + x$1])) <= ((ix < 0 || ix >= merged.$length) ? $throwRuntimeError("index out of range") : merged.$array[merged.$offset + ix])) { - return false; - } - merged = $append(merged, (x$2 = newArray.$get(), x$3 = newLow.$get(), ((x$3 < 0 || x$3 >= x$2.$length) ? $throwRuntimeError("index out of range") : x$2.$array[x$2.$offset + x$3])), (x$4 = newArray.$get(), x$5 = newLow.$get() + 1 >> 0, ((x$5 < 0 || x$5 >= x$4.$length) ? $throwRuntimeError("index out of range") : x$4.$array[x$4.$offset + x$5]))); - _lhs = newLow; _lhs.$set(_lhs.$get() + (2) >> 0); - ix = ix + (2) >> 0; - next = $append(next, pc); - return true; - }); - while (lx < leftLen || rx < rightLen) { - if (rx >= rightLen) { - ok = extend(new ($ptrType($Int))(function() { return lx; }, function($v) { lx = $v; }), leftRunes, leftPC); - } else if (lx >= leftLen) { - ok = extend(new ($ptrType($Int))(function() { return rx; }, function($v) { rx = $v; }), rightRunes, rightPC); - } else if ((x = rightRunes.$get(), ((rx < 0 || rx >= x.$length) ? $throwRuntimeError("index out of range") : x.$array[x.$offset + rx])) < (x$1 = leftRunes.$get(), ((lx < 0 || lx >= x$1.$length) ? $throwRuntimeError("index out of range") : x$1.$array[x$1.$offset + lx]))) { - ok = extend(new ($ptrType($Int))(function() { return rx; }, function($v) { rx = $v; }), rightRunes, rightPC); - } else { - ok = extend(new ($ptrType($Int))(function() { return lx; }, function($v) { lx = $v; }), leftRunes, leftPC); - } - if (!ok) { - return [noRune, noNext]; + Checker.prototype.typOrNil = function(e) { return this.$val.typOrNil(e); }; + Checker.Ptr.prototype.arrayLength = function(e) { + var check, x, _tuple, n, ok; + check = this; + x = new operand.Ptr(); $copy(x, new operand.Ptr(), operand); + check.expr(x, e); + if (!((x.mode === 4))) { + if (!((x.mode === 0))) { + check.errorf(x.pos(), "array length %s must be constant", new ($sliceType($emptyInterface))([x])); } + return new $Int64(0, 0); } - return [merged, next]; - /* */ } catch(err) { $err = err; return [($sliceType($Int32)).nil, ($sliceType($Uint32)).nil]; } finally { $deferFrames.pop(); $callDeferred($deferred, $err); } + if (!x.isInteger()) { + check.errorf(x.pos(), "array length %s must be integer", new ($sliceType($emptyInterface))([x])); + return new $Int64(0, 0); + } + _tuple = exact.Int64Val(x.val); n = _tuple[0]; ok = _tuple[1]; + if (!ok || (n.$high < 0 || (n.$high === 0 && n.$low < 0))) { + check.errorf(x.pos(), "invalid array length %s", new ($sliceType($emptyInterface))([x])); + return new $Int64(0, 0); + } + return n; }; - cleanupOnePass = function(prog, original) { - var _ref, _i, ix, instOriginal, _ref$1, x, x$1, x$2; - _ref = original.Inst; + Checker.prototype.arrayLength = function(e) { return this.$val.arrayLength(e); }; + Checker.Ptr.prototype.collectParams = function(scope, list, variadicOk) { + var params = ($sliceType(($ptrType(Var)))).nil, variadic = false, check, _tmp, _tmp$1, named, anonymous, _ref, _i, i, field, ftype, _tuple, t, typ, _ref$1, _i$1, name, par, par$1, x, last; + check = this; + if (list === ($ptrType(ast.FieldList)).nil) { + return [params, variadic]; + } + _tmp = false; _tmp$1 = false; named = _tmp; anonymous = _tmp$1; + _ref = list.List; _i = 0; while (_i < _ref.$length) { - ix = _i; - instOriginal = new syntax.Inst.Ptr(); $copy(instOriginal, ((_i < 0 || _i >= _ref.$length) ? $throwRuntimeError("index out of range") : _ref.$array[_ref.$offset + _i]), syntax.Inst); - _ref$1 = instOriginal.Op; - if (_ref$1 === 0 || _ref$1 === 1 || _ref$1 === 7) { - } else if (_ref$1 === 2 || _ref$1 === 3 || _ref$1 === 6 || _ref$1 === 4 || _ref$1 === 5) { - (x = prog.Inst, ((ix < 0 || ix >= x.$length) ? $throwRuntimeError("index out of range") : x.$array[x.$offset + ix])).Next = ($sliceType($Uint32)).nil; - } else if (_ref$1 === 8 || _ref$1 === 9 || _ref$1 === 10) { - (x$1 = prog.Inst, ((ix < 0 || ix >= x$1.$length) ? $throwRuntimeError("index out of range") : x$1.$array[x$1.$offset + ix])).Next = ($sliceType($Uint32)).nil; - $copy((x$2 = prog.Inst, ((ix < 0 || ix >= x$2.$length) ? $throwRuntimeError("index out of range") : x$2.$array[x$2.$offset + ix])), new onePassInst.Ptr(instOriginal, ($sliceType($Uint32)).nil), onePassInst); + i = _i; + field = ((_i < 0 || _i >= _ref.$length) ? $throwRuntimeError("index out of range") : _ref.$array[_ref.$offset + _i]); + ftype = field.Type; + _tuple = $assertType(ftype, ($ptrType(ast.Ellipsis)), true); t = _tuple[0]; + if (!(t === ($ptrType(ast.Ellipsis)).nil)) { + ftype = t.Elt; + if (variadicOk && (i === (list.List.$length - 1 >> 0))) { + variadic = true; + } else { + check.invalidAST(field.Pos(), "... not permitted", new ($sliceType($emptyInterface))([])); + } + } + typ = check.typ(ftype); + if (field.Names.$length > 0) { + _ref$1 = field.Names; + _i$1 = 0; + while (_i$1 < _ref$1.$length) { + name = ((_i$1 < 0 || _i$1 >= _ref$1.$length) ? $throwRuntimeError("index out of range") : _ref$1.$array[_ref$1.$offset + _i$1]); + if (name.Name === "") { + check.invalidAST(name.Pos(), "anonymous parameter", new ($sliceType($emptyInterface))([])); + } + par = NewParam(name.Pos(), check.pkg, name.Name, typ); + check.declare(scope, name, par); + params = $append(params, par); + _i$1++; + } + named = true; + } else { + par$1 = NewParam(ftype.Pos(), check.pkg, "", typ); + check.recordImplicit(field, par$1); + params = $append(params, par$1); + anonymous = true; } _i++; } + if (named && anonymous) { + check.invalidAST(list.Pos(), "list contains both named and anonymous parameters", new ($sliceType($emptyInterface))([])); + } + if (variadic && params.$length > 0) { + last = (x = params.$length - 1 >> 0, ((x < 0 || x >= params.$length) ? $throwRuntimeError("index out of range") : params.$array[params.$offset + x])); + last.object.typ = new Slice.Ptr(last.object.typ); + } + return [params, variadic]; }; - onePassCopy = function(prog) { - var p, _ref, _i, inst, _ref$1, _i$1, p_A_Alt, pc, _ref$2, x, x$1, p_A_Other, x$2, x$3, x$4, instAlt, _tmp, _tmp$1, x$5, x$6, x$7, x$8, instOther, x$9, x$10, p_B_Alt, x$11, x$12, p_B_Other, patch, _tmp$2, _tmp$3; - p = new onePassProg.Ptr(($sliceType(onePassInst)).nil, prog.Start, prog.NumCap); - _ref = prog.Inst; + Checker.prototype.collectParams = function(scope, list, variadicOk) { return this.$val.collectParams(scope, list, variadicOk); }; + Checker.Ptr.prototype.declareInSet = function(oset, pos, obj) { + var check, alt; + check = this; + alt = oset.insert(obj); + if (!($interfaceIsEqual(alt, $ifaceNil))) { + check.errorf(pos, "%s redeclared", new ($sliceType($emptyInterface))([new $String(obj.Name())])); + check.reportAltDecl(alt); + return false; + } + return true; + }; + Checker.prototype.declareInSet = function(oset, pos, obj) { return this.$val.declareInSet(oset, pos, obj); }; + Checker.Ptr.prototype.interfaceType = function(iface, ityp, def$1, path$1) { + var check, recvTyp, mset, signatures, embedded, _ref, _i, f, x, name, pos, sig, m, _ref$1, _i$1, e, pos$1, typ, _tuple, named, u, _tuple$1, embed, _ref$2, _i$2, m$1, _ref$3, _i$3, i, m$2, expr, typ$1, _tuple$2, sig$1, old, x$1, x$2, x$3; + check = this; + if (ityp.Methods === ($ptrType(ast.FieldList)).nil) { + return; + } + recvTyp = iface; + if (!(def$1 === ($ptrType(Named)).nil)) { + recvTyp = def$1; + } + mset = false; + signatures = ($sliceType(ast.Expr)).nil; + embedded = ($sliceType(ast.Expr)).nil; + _ref = ityp.Methods.List; _i = 0; while (_i < _ref.$length) { - inst = new syntax.Inst.Ptr(); $copy(inst, ((_i < 0 || _i >= _ref.$length) ? $throwRuntimeError("index out of range") : _ref.$array[_ref.$offset + _i]), syntax.Inst); - p.Inst = $append(p.Inst, new onePassInst.Ptr(inst, ($sliceType($Uint32)).nil)); + f = ((_i < 0 || _i >= _ref.$length) ? $throwRuntimeError("index out of range") : _ref.$array[_ref.$offset + _i]); + if (f.Names.$length > 0) { + name = (x = f.Names, ((0 < 0 || 0 >= x.$length) ? $throwRuntimeError("index out of range") : x.$array[x.$offset + 0])); + pos = name.Pos(); + if (name.Name === "_") { + check.errorf(pos, "invalid method name _", new ($sliceType($emptyInterface))([])); + _i++; + continue; + } + sig = new Signature.Ptr(); + sig.recv = NewVar(pos, check.pkg, "", recvTyp); + m = NewFunc(pos, check.pkg, name.Name, sig); + if (check.declareInSet(new ($ptrType(objset))(function() { return mset; }, function($v) { mset = $v; }), pos, m)) { + iface.methods = $append(iface.methods, m); + iface.allMethods = $append(iface.allMethods, m); + signatures = $append(signatures, f.Type); + check.recordDef(name, m); + } + } else { + embedded = $append(embedded, f.Type); + } _i++; } - _ref$1 = p.Inst; + _ref$1 = embedded; _i$1 = 0; while (_i$1 < _ref$1.$length) { - p_A_Alt = [undefined]; - pc = _i$1; - _ref$2 = (x = p.Inst, ((pc < 0 || pc >= x.$length) ? $throwRuntimeError("index out of range") : x.$array[x.$offset + pc])).Inst.Op; - if (_ref$2 === 0 || _ref$2 === 1) { - p_A_Other = new ($ptrType($Uint32))(function() { return this.$target.Inst.Out; }, function($v) { this.$target.Inst.Out = $v; }, (x$1 = p.Inst, ((pc < 0 || pc >= x$1.$length) ? $throwRuntimeError("index out of range") : x$1.$array[x$1.$offset + pc]))); - p_A_Alt[0] = new ($ptrType($Uint32))(function() { return this.$target.Inst.Arg; }, function($v) { this.$target.Inst.Arg = $v; }, (x$2 = p.Inst, ((pc < 0 || pc >= x$2.$length) ? $throwRuntimeError("index out of range") : x$2.$array[x$2.$offset + pc]))); - instAlt = new onePassInst.Ptr(); $copy(instAlt, (x$3 = p.Inst, x$4 = p_A_Alt[0].$get(), ((x$4 < 0 || x$4 >= x$3.$length) ? $throwRuntimeError("index out of range") : x$3.$array[x$3.$offset + x$4])), onePassInst); - if (!((instAlt.Inst.Op === 0) || (instAlt.Inst.Op === 1))) { - _tmp = p_A_Other; _tmp$1 = p_A_Alt[0]; p_A_Alt[0] = _tmp; p_A_Other = _tmp$1; - $copy(instAlt, (x$5 = p.Inst, x$6 = p_A_Alt[0].$get(), ((x$6 < 0 || x$6 >= x$5.$length) ? $throwRuntimeError("index out of range") : x$5.$array[x$5.$offset + x$6])), onePassInst); - if (!((instAlt.Inst.Op === 0) || (instAlt.Inst.Op === 1))) { - _i$1++; - continue; - } - } - instOther = new onePassInst.Ptr(); $copy(instOther, (x$7 = p.Inst, x$8 = p_A_Other.$get(), ((x$8 < 0 || x$8 >= x$7.$length) ? $throwRuntimeError("index out of range") : x$7.$array[x$7.$offset + x$8])), onePassInst); - if ((instOther.Inst.Op === 0) || (instOther.Inst.Op === 1)) { - _i$1++; - continue; - } - p_B_Alt = new ($ptrType($Uint32))(function() { return this.$target.Inst.Out; }, function($v) { this.$target.Inst.Out = $v; }, (x$9 = p.Inst, x$10 = p_A_Alt[0].$get(), ((x$10 < 0 || x$10 >= x$9.$length) ? $throwRuntimeError("index out of range") : x$9.$array[x$9.$offset + x$10]))); - p_B_Other = new ($ptrType($Uint32))(function() { return this.$target.Inst.Arg; }, function($v) { this.$target.Inst.Arg = $v; }, (x$11 = p.Inst, x$12 = p_A_Alt[0].$get(), ((x$12 < 0 || x$12 >= x$11.$length) ? $throwRuntimeError("index out of range") : x$11.$array[x$11.$offset + x$12]))); - patch = false; - if (instAlt.Inst.Out === (pc >>> 0)) { - patch = true; - } else if (instAlt.Inst.Arg === (pc >>> 0)) { - patch = true; - _tmp$2 = p_B_Other; _tmp$3 = p_B_Alt; p_B_Alt = _tmp$2; p_B_Other = _tmp$3; - } - if (patch) { - p_B_Alt.$set(p_A_Other.$get()); + e = ((_i$1 < 0 || _i$1 >= _ref$1.$length) ? $throwRuntimeError("index out of range") : _ref$1.$array[_ref$1.$offset + _i$1]); + pos$1 = e.Pos(); + typ = check.typExpr(e, ($ptrType(Named)).nil, path$1); + _tuple = $assertType(typ, ($ptrType(Named)), true); named = _tuple[0]; + if (named === ($ptrType(Named)).nil) { + if (!($interfaceIsEqual(typ, $pkg.Typ[0]))) { + check.invalidAST(pos$1, "%s is not named type", new ($sliceType($emptyInterface))([typ])); } - if (p_A_Other.$get() === p_B_Alt.$get()) { - p_A_Alt[0].$set(p_B_Other.$get()); + _i$1++; + continue; + } + u = underlying(named); + _tuple$1 = $assertType(u, ($ptrType(Interface)), true); embed = _tuple$1[0]; + if (embed === ($ptrType(Interface)).nil) { + if (!($interfaceIsEqual(u, $pkg.Typ[0]))) { + check.errorf(pos$1, "%s is not an interface", new ($sliceType($emptyInterface))([named])); } - } else { _i$1++; continue; } + iface.embeddeds = $append(iface.embeddeds, named); + _ref$2 = embed.allMethods; + _i$2 = 0; + while (_i$2 < _ref$2.$length) { + m$1 = ((_i$2 < 0 || _i$2 >= _ref$2.$length) ? $throwRuntimeError("index out of range") : _ref$2.$array[_ref$2.$offset + _i$2]); + if (check.declareInSet(new ($ptrType(objset))(function() { return mset; }, function($v) { mset = $v; }), pos$1, m$1)) { + iface.allMethods = $append(iface.allMethods, m$1); + } + _i$2++; + } _i$1++; } - return p; + _ref$3 = iface.methods; + _i$3 = 0; + while (_i$3 < _ref$3.$length) { + i = _i$3; + m$2 = ((_i$3 < 0 || _i$3 >= _ref$3.$length) ? $throwRuntimeError("index out of range") : _ref$3.$array[_ref$3.$offset + _i$3]); + expr = ((i < 0 || i >= signatures.$length) ? $throwRuntimeError("index out of range") : signatures.$array[signatures.$offset + i]); + typ$1 = check.typ(expr); + _tuple$2 = $assertType(typ$1, ($ptrType(Signature)), true); sig$1 = _tuple$2[0]; + if (sig$1 === ($ptrType(Signature)).nil) { + if (!($interfaceIsEqual(typ$1, $pkg.Typ[0]))) { + check.invalidAST(expr.Pos(), "%s is not a method signature", new ($sliceType($emptyInterface))([typ$1])); + } + _i$3++; + continue; + } + old = $assertType(m$2.object.typ, ($ptrType(Signature))); + sig$1.recv = old.recv; + $copy(old, sig$1, Signature); + _i$3++; + } + sort.Sort((x$1 = iface.methods, $subslice(new byUniqueMethodName(x$1.$array), x$1.$offset, x$1.$offset + x$1.$length))); + sort.Sort((x$2 = iface.embeddeds, $subslice(new byUniqueTypeName(x$2.$array), x$2.$offset, x$2.$offset + x$2.$length))); + sort.Sort((x$3 = iface.allMethods, $subslice(new byUniqueMethodName(x$3.$array), x$3.$offset, x$3.$offset + x$3.$length))); }; - runeSlice.prototype.Len = function() { - var p; - p = this; - return p.$length; + Checker.prototype.interfaceType = function(iface, ityp, def$1, path$1) { return this.$val.interfaceType(iface, ityp, def$1, path$1); }; + byUniqueTypeName.prototype.Len = function() { + var a; + a = this; + return a.$length; }; - $ptrType(runeSlice).prototype.Len = function() { return this.$get().Len(); }; - runeSlice.prototype.Less = function(i, j) { - var p; - p = this; - return ((i < 0 || i >= p.$length) ? $throwRuntimeError("index out of range") : p.$array[p.$offset + i]) < ((j < 0 || j >= p.$length) ? $throwRuntimeError("index out of range") : p.$array[p.$offset + j]); + $ptrType(byUniqueTypeName).prototype.Len = function() { return this.$get().Len(); }; + byUniqueTypeName.prototype.Less = function(i, j) { + var a; + a = this; + return ((i < 0 || i >= a.$length) ? $throwRuntimeError("index out of range") : a.$array[a.$offset + i]).obj.object.Id() < ((j < 0 || j >= a.$length) ? $throwRuntimeError("index out of range") : a.$array[a.$offset + j]).obj.object.Id(); }; - $ptrType(runeSlice).prototype.Less = function(i, j) { return this.$get().Less(i, j); }; - runeSlice.prototype.Swap = function(i, j) { - var p, _tmp, _tmp$1; - p = this; - _tmp = ((j < 0 || j >= p.$length) ? $throwRuntimeError("index out of range") : p.$array[p.$offset + j]); _tmp$1 = ((i < 0 || i >= p.$length) ? $throwRuntimeError("index out of range") : p.$array[p.$offset + i]); (i < 0 || i >= p.$length) ? $throwRuntimeError("index out of range") : p.$array[p.$offset + i] = _tmp; (j < 0 || j >= p.$length) ? $throwRuntimeError("index out of range") : p.$array[p.$offset + j] = _tmp$1; + $ptrType(byUniqueTypeName).prototype.Less = function(i, j) { return this.$get().Less(i, j); }; + byUniqueTypeName.prototype.Swap = function(i, j) { + var a, _tmp, _tmp$1; + a = this; + _tmp = ((j < 0 || j >= a.$length) ? $throwRuntimeError("index out of range") : a.$array[a.$offset + j]); _tmp$1 = ((i < 0 || i >= a.$length) ? $throwRuntimeError("index out of range") : a.$array[a.$offset + i]); (i < 0 || i >= a.$length) ? $throwRuntimeError("index out of range") : a.$array[a.$offset + i] = _tmp; (j < 0 || j >= a.$length) ? $throwRuntimeError("index out of range") : a.$array[a.$offset + j] = _tmp$1; }; - $ptrType(runeSlice).prototype.Swap = function(i, j) { return this.$get().Swap(i, j); }; - runeSlice.prototype.Sort = function() { - var p; - p = this; - sort.Sort(p); + $ptrType(byUniqueTypeName).prototype.Swap = function(i, j) { return this.$get().Swap(i, j); }; + byUniqueMethodName.prototype.Len = function() { + var a; + a = this; + return a.$length; }; - $ptrType(runeSlice).prototype.Sort = function() { return this.$get().Sort(); }; - makeOnePass = function(p) { - var instQueue, visitQueue, build, check, onePassRunes, m, pc, x, inst, _ref, _ref$1, _i, i, x$1; - if (p.Inst.$length >= 1000) { - return notOnePass; - } - instQueue = newQueue(p.Inst.$length); - visitQueue = newQueue(p.Inst.$length); - build = $throwNilPointerError; - check = $throwNilPointerError; - onePassRunes = ($sliceType(($sliceType($Int32)))).make(p.Inst.$length); - build = (function(pc, q) { - var x, inst, _ref; - if (q.contains(pc)) { - return; - } - inst = new onePassInst.Ptr(); $copy(inst, (x = p.Inst, ((pc < 0 || pc >= x.$length) ? $throwRuntimeError("index out of range") : x.$array[x.$offset + pc])), onePassInst); - _ref = inst.Inst.Op; - if (_ref === 0 || _ref === 1) { - q.insert(inst.Inst.Out); - build(inst.Inst.Out, q); - q.insert(inst.Inst.Arg); - } else if (_ref === 4 || _ref === 5) { - } else { - q.insert(inst.Inst.Out); - } - }); - check = (function(pc, m) { - var ok = false, x, inst, _ref, _entry, matchOut, _entry$1, matchArg, _tmp, _tmp$1, _tmp$2, _tmp$3, _key, _tuple, x$1, x$2, x$3, x$4, x$5, _entry$2, _key$1, x$6, _q, i, _entry$3, _key$2, x$7, _q$1, i$1, _key$3, _key$4, runes, x$8, r0, r1, _q$2, i$2, _key$5, runes$1, x$9, r0$1, r1$1, x$10, x$11, _q$3, i$3, _key$6, _key$7, _q$4, i$4; - ok = true; - inst = (x = p.Inst, ((pc < 0 || pc >= x.$length) ? $throwRuntimeError("index out of range") : x.$array[x.$offset + pc])); - if (visitQueue.contains(pc)) { - return ok; - } - visitQueue.insert(pc); - _ref = inst.Inst.Op; - switch (0) { default: if (_ref === 0 || _ref === 1) { - ok = check(inst.Inst.Out, m) && check(inst.Inst.Arg, m); - matchOut = (_entry = m[inst.Inst.Out], _entry !== undefined ? _entry.v : false); - matchArg = (_entry$1 = m[inst.Inst.Arg], _entry$1 !== undefined ? _entry$1.v : false); - if (matchOut && matchArg) { - ok = false; - break; - } - if (matchArg) { - _tmp = inst.Inst.Arg; _tmp$1 = inst.Inst.Out; inst.Inst.Out = _tmp; inst.Inst.Arg = _tmp$1; - _tmp$2 = matchArg; _tmp$3 = matchOut; matchOut = _tmp$2; matchArg = _tmp$3; - } - if (matchOut) { - _key = pc; (m || $throwRuntimeError("assignment to entry in nil map"))[_key] = { k: _key, v: true }; - inst.Inst.Op = 1; - } - _tuple = mergeRuneSets(new ($ptrType(($sliceType($Int32))))(function() { return (x$2 = inst.Inst.Out, ((x$2 < 0 || x$2 >= this.$target.$length) ? $throwRuntimeError("index out of range") : this.$target.$array[this.$target.$offset + x$2])); }, function($v) { (x$1 = inst.Inst.Out, (x$1 < 0 || x$1 >= this.$target.$length) ? $throwRuntimeError("index out of range") : this.$target.$array[this.$target.$offset + x$1] = $v); }, onePassRunes), new ($ptrType(($sliceType($Int32))))(function() { return (x$4 = inst.Inst.Arg, ((x$4 < 0 || x$4 >= this.$target.$length) ? $throwRuntimeError("index out of range") : this.$target.$array[this.$target.$offset + x$4])); }, function($v) { (x$3 = inst.Inst.Arg, (x$3 < 0 || x$3 >= this.$target.$length) ? $throwRuntimeError("index out of range") : this.$target.$array[this.$target.$offset + x$3] = $v); }, onePassRunes), inst.Inst.Out, inst.Inst.Arg); (pc < 0 || pc >= onePassRunes.$length) ? $throwRuntimeError("index out of range") : onePassRunes.$array[onePassRunes.$offset + pc] = _tuple[0]; inst.Next = _tuple[1]; - if (inst.Next.$length > 0 && ((x$5 = inst.Next, ((0 < 0 || 0 >= x$5.$length) ? $throwRuntimeError("index out of range") : x$5.$array[x$5.$offset + 0])) === 4294967295)) { - ok = false; - break; - } - } else if (_ref === 2 || _ref === 6) { - ok = check(inst.Inst.Out, m); - _key$1 = pc; (m || $throwRuntimeError("assignment to entry in nil map"))[_key$1] = { k: _key$1, v: (_entry$2 = m[inst.Inst.Out], _entry$2 !== undefined ? _entry$2.v : false) }; - (pc < 0 || pc >= onePassRunes.$length) ? $throwRuntimeError("index out of range") : onePassRunes.$array[onePassRunes.$offset + pc] = $appendSlice(new ($sliceType($Int32))([]), (x$6 = inst.Inst.Out, ((x$6 < 0 || x$6 >= onePassRunes.$length) ? $throwRuntimeError("index out of range") : onePassRunes.$array[onePassRunes.$offset + x$6]))); - inst.Next = new ($sliceType($Uint32))([]); - i = (_q = ((pc < 0 || pc >= onePassRunes.$length) ? $throwRuntimeError("index out of range") : onePassRunes.$array[onePassRunes.$offset + pc]).$length / 2, (_q === _q && _q !== 1/0 && _q !== -1/0) ? _q >> 0 : $throwRuntimeError("integer divide by zero")); - while (i >= 0) { - inst.Next = $append(inst.Next, inst.Inst.Out); - i = i - (1) >> 0; - } - } else if (_ref === 3) { - ok = check(inst.Inst.Out, m); - _key$2 = pc; (m || $throwRuntimeError("assignment to entry in nil map"))[_key$2] = { k: _key$2, v: (_entry$3 = m[inst.Inst.Out], _entry$3 !== undefined ? _entry$3.v : false) }; - (pc < 0 || pc >= onePassRunes.$length) ? $throwRuntimeError("index out of range") : onePassRunes.$array[onePassRunes.$offset + pc] = $appendSlice(new ($sliceType($Int32))([]), (x$7 = inst.Inst.Out, ((x$7 < 0 || x$7 >= onePassRunes.$length) ? $throwRuntimeError("index out of range") : onePassRunes.$array[onePassRunes.$offset + x$7]))); - inst.Next = new ($sliceType($Uint32))([]); - i$1 = (_q$1 = ((pc < 0 || pc >= onePassRunes.$length) ? $throwRuntimeError("index out of range") : onePassRunes.$array[onePassRunes.$offset + pc]).$length / 2, (_q$1 === _q$1 && _q$1 !== 1/0 && _q$1 !== -1/0) ? _q$1 >> 0 : $throwRuntimeError("integer divide by zero")); - while (i$1 >= 0) { - inst.Next = $append(inst.Next, inst.Inst.Out); - i$1 = i$1 - (1) >> 0; - } - } else if (_ref === 4 || _ref === 5) { - _key$3 = pc; (m || $throwRuntimeError("assignment to entry in nil map"))[_key$3] = { k: _key$3, v: inst.Inst.Op === 4 }; - break; - } else if (_ref === 7) { - ok = check(inst.Inst.Out, m); - _key$4 = pc; (m || $throwRuntimeError("assignment to entry in nil map"))[_key$4] = { k: _key$4, v: false }; - if (inst.Next.$length > 0) { - break; - } - if (inst.Inst.Rune.$length === 0) { - (pc < 0 || pc >= onePassRunes.$length) ? $throwRuntimeError("index out of range") : onePassRunes.$array[onePassRunes.$offset + pc] = new ($sliceType($Int32))([]); - inst.Next = new ($sliceType($Uint32))([inst.Inst.Out]); - break; - } - runes = ($sliceType($Int32)).make(0); - if ((inst.Inst.Rune.$length === 1) && !(((((inst.Inst.Arg << 16 >>> 16) & 1) >>> 0) === 0))) { - r0 = (x$8 = inst.Inst.Rune, ((0 < 0 || 0 >= x$8.$length) ? $throwRuntimeError("index out of range") : x$8.$array[x$8.$offset + 0])); - runes = $append(runes, r0, r0); - r1 = unicode.SimpleFold(r0); - while (!((r1 === r0))) { - runes = $append(runes, r1, r1); - r1 = unicode.SimpleFold(r1); - } - sort.Sort($subslice(new runeSlice(runes.$array), runes.$offset, runes.$offset + runes.$length)); - } else { - runes = $appendSlice(runes, inst.Inst.Rune); - } - (pc < 0 || pc >= onePassRunes.$length) ? $throwRuntimeError("index out of range") : onePassRunes.$array[onePassRunes.$offset + pc] = runes; - inst.Next = new ($sliceType($Uint32))([]); - i$2 = (_q$2 = ((pc < 0 || pc >= onePassRunes.$length) ? $throwRuntimeError("index out of range") : onePassRunes.$array[onePassRunes.$offset + pc]).$length / 2, (_q$2 === _q$2 && _q$2 !== 1/0 && _q$2 !== -1/0) ? _q$2 >> 0 : $throwRuntimeError("integer divide by zero")); - while (i$2 >= 0) { - inst.Next = $append(inst.Next, inst.Inst.Out); - i$2 = i$2 - (1) >> 0; - } - inst.Inst.Op = 7; - } else if (_ref === 8) { - ok = check(inst.Inst.Out, m); - _key$5 = pc; (m || $throwRuntimeError("assignment to entry in nil map"))[_key$5] = { k: _key$5, v: false }; - if (inst.Next.$length > 0) { - break; - } - runes$1 = new ($sliceType($Int32))([]); - if (!(((((inst.Inst.Arg << 16 >>> 16) & 1) >>> 0) === 0))) { - r0$1 = (x$9 = inst.Inst.Rune, ((0 < 0 || 0 >= x$9.$length) ? $throwRuntimeError("index out of range") : x$9.$array[x$9.$offset + 0])); - runes$1 = $append(runes$1, r0$1, r0$1); - r1$1 = unicode.SimpleFold(r0$1); - while (!((r1$1 === r0$1))) { - runes$1 = $append(runes$1, r1$1, r1$1); - r1$1 = unicode.SimpleFold(r1$1); - } - sort.Sort($subslice(new runeSlice(runes$1.$array), runes$1.$offset, runes$1.$offset + runes$1.$length)); - } else { - runes$1 = $append(runes$1, (x$10 = inst.Inst.Rune, ((0 < 0 || 0 >= x$10.$length) ? $throwRuntimeError("index out of range") : x$10.$array[x$10.$offset + 0])), (x$11 = inst.Inst.Rune, ((0 < 0 || 0 >= x$11.$length) ? $throwRuntimeError("index out of range") : x$11.$array[x$11.$offset + 0]))); - } - (pc < 0 || pc >= onePassRunes.$length) ? $throwRuntimeError("index out of range") : onePassRunes.$array[onePassRunes.$offset + pc] = runes$1; - inst.Next = new ($sliceType($Uint32))([]); - i$3 = (_q$3 = ((pc < 0 || pc >= onePassRunes.$length) ? $throwRuntimeError("index out of range") : onePassRunes.$array[onePassRunes.$offset + pc]).$length / 2, (_q$3 === _q$3 && _q$3 !== 1/0 && _q$3 !== -1/0) ? _q$3 >> 0 : $throwRuntimeError("integer divide by zero")); - while (i$3 >= 0) { - inst.Next = $append(inst.Next, inst.Inst.Out); - i$3 = i$3 - (1) >> 0; - } - inst.Inst.Op = 7; - } else if (_ref === 9) { - ok = check(inst.Inst.Out, m); - _key$6 = pc; (m || $throwRuntimeError("assignment to entry in nil map"))[_key$6] = { k: _key$6, v: false }; - if (inst.Next.$length > 0) { - break; - } - (pc < 0 || pc >= onePassRunes.$length) ? $throwRuntimeError("index out of range") : onePassRunes.$array[onePassRunes.$offset + pc] = $appendSlice(new ($sliceType($Int32))([]), anyRune); - inst.Next = new ($sliceType($Uint32))([inst.Inst.Out]); - } else if (_ref === 10) { - ok = check(inst.Inst.Out, m); - _key$7 = pc; (m || $throwRuntimeError("assignment to entry in nil map"))[_key$7] = { k: _key$7, v: false }; - if (inst.Next.$length > 0) { - break; - } - (pc < 0 || pc >= onePassRunes.$length) ? $throwRuntimeError("index out of range") : onePassRunes.$array[onePassRunes.$offset + pc] = $appendSlice(new ($sliceType($Int32))([]), anyRuneNotNL); - inst.Next = new ($sliceType($Uint32))([]); - i$4 = (_q$4 = ((pc < 0 || pc >= onePassRunes.$length) ? $throwRuntimeError("index out of range") : onePassRunes.$array[onePassRunes.$offset + pc]).$length / 2, (_q$4 === _q$4 && _q$4 !== 1/0 && _q$4 !== -1/0) ? _q$4 >> 0 : $throwRuntimeError("integer divide by zero")); - while (i$4 >= 0) { - inst.Next = $append(inst.Next, inst.Inst.Out); - i$4 = i$4 - (1) >> 0; + $ptrType(byUniqueMethodName).prototype.Len = function() { return this.$get().Len(); }; + byUniqueMethodName.prototype.Less = function(i, j) { + var a; + a = this; + return ((i < 0 || i >= a.$length) ? $throwRuntimeError("index out of range") : a.$array[a.$offset + i]).object.Id() < ((j < 0 || j >= a.$length) ? $throwRuntimeError("index out of range") : a.$array[a.$offset + j]).object.Id(); + }; + $ptrType(byUniqueMethodName).prototype.Less = function(i, j) { return this.$get().Less(i, j); }; + byUniqueMethodName.prototype.Swap = function(i, j) { + var a, _tmp, _tmp$1; + a = this; + _tmp = ((j < 0 || j >= a.$length) ? $throwRuntimeError("index out of range") : a.$array[a.$offset + j]); _tmp$1 = ((i < 0 || i >= a.$length) ? $throwRuntimeError("index out of range") : a.$array[a.$offset + i]); (i < 0 || i >= a.$length) ? $throwRuntimeError("index out of range") : a.$array[a.$offset + i] = _tmp; (j < 0 || j >= a.$length) ? $throwRuntimeError("index out of range") : a.$array[a.$offset + j] = _tmp$1; + }; + $ptrType(byUniqueMethodName).prototype.Swap = function(i, j) { return this.$get().Swap(i, j); }; + Checker.Ptr.prototype.tag = function(t) { + var check, _tuple, val, err; + check = this; + if (!(t === ($ptrType(ast.BasicLit)).nil)) { + if (t.Kind === 9) { + _tuple = strconv.Unquote(t.Value); val = _tuple[0]; err = _tuple[1]; + if ($interfaceIsEqual(err, $ifaceNil)) { + return val; } - } } - return ok; - }); - instQueue.clear(); - instQueue.insert((p.Start >>> 0)); - m = new $Map(); - while (!instQueue.empty()) { - pc = instQueue.next(); - inst = new onePassInst.Ptr(); $copy(inst, (x = p.Inst, ((pc < 0 || pc >= x.$length) ? $throwRuntimeError("index out of range") : x.$array[x.$offset + pc])), onePassInst); - visitQueue.clear(); - if (!check(pc, m)) { - p = notOnePass; - break; - } - _ref = inst.Inst.Op; - if (_ref === 0 || _ref === 1) { - instQueue.insert(inst.Inst.Out); - instQueue.insert(inst.Inst.Arg); - } else if (_ref === 2 || _ref === 3 || _ref === 6) { - instQueue.insert(inst.Inst.Out); - } else if (_ref === 4) { - } else if (_ref === 5) { - } else if (_ref === 7 || _ref === 8 || _ref === 9 || _ref === 10) { - } else { - } - } - if (!(p === notOnePass)) { - _ref$1 = p.Inst; - _i = 0; - while (_i < _ref$1.$length) { - i = _i; - (x$1 = p.Inst, ((i < 0 || i >= x$1.$length) ? $throwRuntimeError("index out of range") : x$1.$array[x$1.$offset + i])).Inst.Rune = ((i < 0 || i >= onePassRunes.$length) ? $throwRuntimeError("index out of range") : onePassRunes.$array[onePassRunes.$offset + i]); - _i++; } + check.invalidAST(t.Pos(), "incorrect tag syntax: %q", new ($sliceType($emptyInterface))([new $String(t.Value)])); } - return p; + return ""; }; - compileOnePass = function(prog) { - var p = ($ptrType(onePassProg)).nil, x, x$1, x$2, x$3, _ref, _i, inst, x$4, x$5, opOut, _ref$1, x$6, x$7; - if (prog.Start === 0) { - p = notOnePass; - return p; - } - if (!(((x = prog.Inst, x$1 = prog.Start, ((x$1 < 0 || x$1 >= x.$length) ? $throwRuntimeError("index out of range") : x.$array[x.$offset + x$1])).Op === 3)) || !((((((x$2 = prog.Inst, x$3 = prog.Start, ((x$3 < 0 || x$3 >= x$2.$length) ? $throwRuntimeError("index out of range") : x$2.$array[x$2.$offset + x$3])).Arg << 24 >>> 24) & 4) >>> 0) === 4))) { - p = notOnePass; - return p; + Checker.prototype.tag = function(t) { return this.$val.tag(t); }; + Checker.Ptr.prototype.structType = function(styp, e, path$1) { + var check, list, fields, tags, fset, typ, tag, add, _ref, _i, f, _ref$1, _i$1, name, name$1, pos, _tuple, t, isPtr, t$1, _ref$2, u, _ref$3; + check = this; + list = e.Fields; + if (list === ($ptrType(ast.FieldList)).nil) { + return; } - _ref = prog.Inst; + fields = ($sliceType(($ptrType(Var)))).nil; + tags = ($sliceType($String)).nil; + fset = false; + typ = $ifaceNil; + tag = ""; + add = (function(field, ident, anonymous, pos) { + var name, fld; + if (!(tag === "") && tags === ($sliceType($String)).nil) { + tags = ($sliceType($String)).make(fields.$length); + } + if (!(tags === ($sliceType($String)).nil)) { + tags = $append(tags, tag); + } + name = ident.Name; + fld = NewField(pos, check.pkg, name, typ, !(anonymous === ($ptrType(TypeName)).nil)); + if (name === "_" || check.declareInSet(new ($ptrType(objset))(function() { return fset; }, function($v) { fset = $v; }), pos, fld)) { + fields = $append(fields, fld); + check.recordDef(ident, fld); + } + if (!(anonymous === ($ptrType(TypeName)).nil)) { + check.recordUse(ident, anonymous); + } + }); + _ref = list.List; _i = 0; while (_i < _ref.$length) { - inst = new syntax.Inst.Ptr(); $copy(inst, ((_i < 0 || _i >= _ref.$length) ? $throwRuntimeError("index out of range") : _ref.$array[_ref.$offset + _i]), syntax.Inst); - opOut = (x$4 = prog.Inst, x$5 = inst.Out, ((x$5 < 0 || x$5 >= x$4.$length) ? $throwRuntimeError("index out of range") : x$4.$array[x$4.$offset + x$5])).Op; - _ref$1 = inst.Op; - if (_ref$1 === 0 || _ref$1 === 1) { - if ((opOut === 4) || ((x$6 = prog.Inst, x$7 = inst.Arg, ((x$7 < 0 || x$7 >= x$6.$length) ? $throwRuntimeError("index out of range") : x$6.$array[x$6.$offset + x$7])).Op === 4)) { - p = notOnePass; - return p; + f = ((_i < 0 || _i >= _ref.$length) ? $throwRuntimeError("index out of range") : _ref.$array[_ref.$offset + _i]); + typ = check.typExpr(f.Type, ($ptrType(Named)).nil, path$1); + tag = check.tag(f.Tag); + if (f.Names.$length > 0) { + _ref$1 = f.Names; + _i$1 = 0; + while (_i$1 < _ref$1.$length) { + name = ((_i$1 < 0 || _i$1 >= _ref$1.$length) ? $throwRuntimeError("index out of range") : _ref$1.$array[_ref$1.$offset + _i$1]); + add(f, name, ($ptrType(TypeName)).nil, name.Pos()); + _i$1++; } - } else if (_ref$1 === 3) { - if (opOut === 4) { - if ((((inst.Arg << 24 >>> 24) & 8) >>> 0) === 8) { + } else { + name$1 = anonymousFieldIdent(f.Type); + pos = f.Type.Pos(); + _tuple = deref(typ); t = _tuple[0]; isPtr = _tuple[1]; + _ref$2 = t; + if ($assertType(_ref$2, ($ptrType(Basic)), true)[1]) { + t$1 = _ref$2.$val; + if (t$1 === $pkg.Typ[0]) { _i++; continue; } - p = notOnePass; - return p; - } - } else { - if (opOut === 4) { - p = notOnePass; - return p; + if (t$1.kind === 18) { + check.errorf(pos, "anonymous field type cannot be unsafe.Pointer", new ($sliceType($emptyInterface))([])); + _i++; + continue; + } + add(f, name$1, $assertType($pkg.Universe.Lookup(t$1.name), ($ptrType(TypeName))), pos); + } else if ($assertType(_ref$2, ($ptrType(Named)), true)[1]) { + t$1 = _ref$2.$val; + _ref$3 = t$1.underlying; + if ($assertType(_ref$3, ($ptrType(Basic)), true)[1]) { + u = _ref$3.$val; + if (u.kind === 18) { + check.errorf(pos, "anonymous field type cannot be unsafe.Pointer", new ($sliceType($emptyInterface))([])); + _i++; + continue; + } + } else if ($assertType(_ref$3, ($ptrType(Pointer)), true)[1]) { + u = _ref$3.$val; + check.errorf(pos, "anonymous field type cannot be a pointer", new ($sliceType($emptyInterface))([])); + _i++; + continue; + } else if ($assertType(_ref$3, ($ptrType(Interface)), true)[1]) { + u = _ref$3.$val; + if (isPtr) { + check.errorf(pos, "anonymous field type cannot be a pointer to an interface", new ($sliceType($emptyInterface))([])); + _i++; + continue; + } + } + add(f, name$1, t$1.obj, pos); + } else { + t$1 = _ref$2; + check.invalidAST(pos, "anonymous field type %s must be named", new ($sliceType($emptyInterface))([typ])); } } _i++; } - p = onePassCopy(prog); - p = makeOnePass(p); - if (!(p === notOnePass)) { - cleanupOnePass(p, prog); - } - p = p; - return p; - }; - Regexp.Ptr.prototype.String = function() { - var re; - re = this; - return re.expr; - }; - Regexp.prototype.String = function() { return this.$val.String(); }; - Compile = $pkg.Compile = function(expr) { - return compile(expr, 212, false); - }; - Regexp.Ptr.prototype.Longest = function() { - var re; - re = this; - re.longest = true; + styp.fields = fields; + styp.tags = tags; }; - Regexp.prototype.Longest = function() { return this.$val.Longest(); }; - compile = function(expr, mode, longest) { - var _tuple, re, err, maxCap, capNames, _tuple$1, prog, regexp, _tuple$2, _tuple$3, _tuple$4; - _tuple = syntax.Parse(expr, mode); re = _tuple[0]; err = _tuple[1]; - if (!($interfaceIsEqual(err, $ifaceNil))) { - return [($ptrType(Regexp)).nil, err]; - } - maxCap = re.MaxCap(); - capNames = re.CapNames(); - re = re.Simplify(); - _tuple$1 = syntax.Compile(re); prog = _tuple$1[0]; err = _tuple$1[1]; - if (!($interfaceIsEqual(err, $ifaceNil))) { - return [($ptrType(Regexp)).nil, err]; + Checker.prototype.structType = function(styp, e, path$1) { return this.$val.structType(styp, e, path$1); }; + anonymousFieldIdent = function(e) { + var e$1, _ref; + _ref = e; + if ($assertType(_ref, ($ptrType(ast.Ident)), true)[1]) { + e$1 = _ref.$val; + return e$1; + } else if ($assertType(_ref, ($ptrType(ast.StarExpr)), true)[1]) { + e$1 = _ref.$val; + return anonymousFieldIdent(e$1.X); + } else if ($assertType(_ref, ($ptrType(ast.SelectorExpr)), true)[1]) { + e$1 = _ref.$val; + return e$1.Sel; } - regexp = new Regexp.Ptr(expr, prog, compileOnePass(prog), "", ($sliceType($Uint8)).nil, false, 0, 0, prog.StartCond(), maxCap, capNames, longest, new sync.Mutex.Ptr(), ($sliceType(($ptrType(machine)))).nil); - if (regexp.onepass === notOnePass) { - _tuple$2 = prog.Prefix(); regexp.prefix = _tuple$2[0]; regexp.prefixComplete = _tuple$2[1]; - } else { - _tuple$3 = onePassPrefix(prog); regexp.prefix = _tuple$3[0]; regexp.prefixComplete = _tuple$3[1]; regexp.prefixEnd = _tuple$3[2]; + return ($ptrType(ast.Ident)).nil; + }; + defPredeclaredTypes = function() { + var _ref, _i, t, _ref$1, _i$1, t$1, res, sig, err, typ; + _ref = $pkg.Typ; + _i = 0; + while (_i < 26) { + t = ((_i < 0 || _i >= _ref.length) ? $throwRuntimeError("index out of range") : _ref[_i]); + def(NewTypeName(0, ($ptrType(Package)).nil, t.name, t)); + _i++; } - if (!(regexp.prefix === "")) { - regexp.prefixBytes = new ($sliceType($Uint8))($stringToBytes(regexp.prefix)); - _tuple$4 = utf8.DecodeRuneInString(regexp.prefix); regexp.prefixRune = _tuple$4[0]; + _ref$1 = aliases; + _i$1 = 0; + while (_i$1 < 2) { + t$1 = ((_i$1 < 0 || _i$1 >= _ref$1.length) ? $throwRuntimeError("index out of range") : _ref$1[_i$1]); + def(NewTypeName(0, ($ptrType(Package)).nil, t$1.name, t$1)); + _i$1++; } - return [regexp, $ifaceNil]; + res = NewVar(0, ($ptrType(Package)).nil, "", $pkg.Typ[17]); + sig = new Signature.Ptr(($ptrType(Scope)).nil, ($ptrType(Var)).nil, ($ptrType(Tuple)).nil, NewTuple(new ($sliceType(($ptrType(Var))))([res])), false); + err = NewFunc(0, ($ptrType(Package)).nil, "Error", sig); + typ = new Named.Ptr(($ptrType(TypeName)).nil, NewInterface(new ($sliceType(($ptrType(Func))))([err]), ($sliceType(($ptrType(Named)))).nil).Complete(), ($sliceType(($ptrType(Func)))).nil); + sig.recv = NewVar(0, ($ptrType(Package)).nil, "", typ); + def(NewTypeName(0, ($ptrType(Package)).nil, "error", typ)); }; - Regexp.Ptr.prototype.get = function() { - var re, n, x, x$1, z, z$1; - re = this; - re.mu.Lock(); - n = re.machine.$length; - if (n > 0) { - z = (x = re.machine, x$1 = n - 1 >> 0, ((x$1 < 0 || x$1 >= x.$length) ? $throwRuntimeError("index out of range") : x.$array[x.$offset + x$1])); - re.machine = $subslice(re.machine, 0, (n - 1 >> 0)); - re.mu.Unlock(); - return z; + defPredeclaredConsts = function() { + var _ref, _i, c, x; + _ref = predeclaredConsts; + _i = 0; + while (_i < 3) { + c = new ($structType([["name", "name", "code.google.com/p/go.tools/go/types", $String, ""], ["kind", "kind", "code.google.com/p/go.tools/go/types", BasicKind, ""], ["val", "val", "code.google.com/p/go.tools/go/types", exact.Value, ""]])).Ptr(); $copy(c, ((_i < 0 || _i >= _ref.length) ? $throwRuntimeError("index out of range") : _ref[_i]), ($structType([["name", "name", "code.google.com/p/go.tools/go/types", $String, ""], ["kind", "kind", "code.google.com/p/go.tools/go/types", BasicKind, ""], ["val", "val", "code.google.com/p/go.tools/go/types", exact.Value, ""]]))); + def(NewConst(0, ($ptrType(Package)).nil, c.name, (x = c.kind, ((x < 0 || x >= $pkg.Typ.length) ? $throwRuntimeError("index out of range") : $pkg.Typ[x])), c.val)); + _i++; } - re.mu.Unlock(); - z$1 = progMachine(re.prog, re.onepass); - z$1.re = re; - return z$1; - }; - Regexp.prototype.get = function() { return this.$val.get(); }; - Regexp.Ptr.prototype.put = function(z) { - var re; - re = this; - re.mu.Lock(); - re.machine = $append(re.machine, z); - re.mu.Unlock(); }; - Regexp.prototype.put = function(z) { return this.$val.put(z); }; - MustCompile = $pkg.MustCompile = function(str) { - var _tuple, regexp, error; - _tuple = Compile(str); regexp = _tuple[0]; error = _tuple[1]; - if (!($interfaceIsEqual(error, $ifaceNil))) { - $panic(new $String("regexp: Compile(" + quote(str) + "): " + error.Error())); - } - return regexp; + defPredeclaredNil = function() { + def(new Nil.Ptr(new object.Ptr(($ptrType(Scope)).nil, 0, ($ptrType(Package)).nil, "nil", $pkg.Typ[25], 0, false))); }; - quote = function(s) { - if (strconv.CanBackquote(s)) { - return "`" + s + "`"; + defPredeclaredFuncs = function() { + var _ref, _i, i, id; + _ref = predeclaredFuncs; + _i = 0; + while (_i < 20) { + i = _i; + id = (i >> 0); + if ((id === 18) || (id === 19)) { + _i++; + continue; + } + def(newBuiltin(id)); + _i++; } - return strconv.Quote(s); - }; - Regexp.Ptr.prototype.NumSubexp = function() { - var re; - re = this; - return re.numSubexp; }; - Regexp.prototype.NumSubexp = function() { return this.$val.NumSubexp(); }; - Regexp.Ptr.prototype.SubexpNames = function() { - var re; - re = this; - return re.subexpNames; + init = function() { + $pkg.Universe = NewScope(($ptrType(Scope)).nil, "universe"); + $pkg.Unsafe = NewPackage("unsafe", "unsafe"); + $pkg.Unsafe.complete = true; + defPredeclaredTypes(); + defPredeclaredConsts(); + defPredeclaredNil(); + defPredeclaredFuncs(); + universeIota = $assertType($pkg.Universe.Lookup("iota"), ($ptrType(Const))); + $pkg.UniverseByte = $assertType($assertType($pkg.Universe.Lookup("byte"), ($ptrType(TypeName))).object.typ, ($ptrType(Basic))); + $pkg.UniverseRune = $assertType($assertType($pkg.Universe.Lookup("rune"), ($ptrType(TypeName))).object.typ, ($ptrType(Basic))); }; - Regexp.prototype.SubexpNames = function() { return this.$val.SubexpNames(); }; - inputString.Ptr.prototype.step = function(pos) { - var i, c; - i = this; - if (pos < i.str.length) { - c = i.str.charCodeAt(pos); - if (c < 128) { - return [(c >> 0), 1]; + def = function(obj) { + var name, _tuple, typ, ok, scope, obj$1, _ref; + name = obj.Name(); + if (strings.Index(name, " ") >= 0) { + return; + } + _tuple = $assertType(obj.Type(), ($ptrType(Named)), true); typ = _tuple[0]; ok = _tuple[1]; + if (ok) { + typ.obj = $assertType(obj, ($ptrType(TypeName))); + } + scope = $pkg.Universe; + if (obj.Exported()) { + scope = $pkg.Unsafe.scope; + _ref = obj; + if ($assertType(_ref, ($ptrType(TypeName)), true)[1]) { + obj$1 = _ref.$val; + obj$1.object.pkg = $pkg.Unsafe; + } else if ($assertType(_ref, ($ptrType(Builtin)), true)[1]) { + obj$1 = _ref.$val; + obj$1.object.pkg = $pkg.Unsafe; + } else { + obj$1 = _ref; + unreachable(); } - return utf8.DecodeRuneInString(i.str.substring(pos)); } - return [-1, 0]; + if (!($interfaceIsEqual(scope.Insert(obj), $ifaceNil))) { + $panic(new $String("internal error: double declaration")); + } }; - inputString.prototype.step = function(pos) { return this.$val.step(pos); }; - inputString.Ptr.prototype.canCheckPrefix = function() { - var i; - i = this; - return true; + $pkg.$init = function() { + Error.methods = [["Error", "Error", "", $funcType([], [$String], false), -1]]; + ($ptrType(Error)).methods = [["Error", "Error", "", $funcType([], [$String], false), -1]]; + Error.init([["Fset", "Fset", "", ($ptrType(token.FileSet)), ""], ["Pos", "Pos", "", token.Pos, ""], ["Msg", "Msg", "", $String, ""], ["Soft", "Soft", "", $Bool, ""]]); + Importer.init([($mapType($String, ($ptrType(Package)))), $String], [($ptrType(Package)), $error], false); + ($ptrType(Config)).methods = [["Check", "Check", "", $funcType([$String, ($ptrType(token.FileSet)), ($sliceType(($ptrType(ast.File)))), ($ptrType(Info))], [($ptrType(Package)), $error], false), -1], ["alignof", "alignof", "code.google.com/p/go.tools/go/types", $funcType([Type], [$Int64], false), -1], ["offsetof", "offsetof", "code.google.com/p/go.tools/go/types", $funcType([Type, ($sliceType($Int))], [$Int64], false), -1], ["offsetsof", "offsetsof", "code.google.com/p/go.tools/go/types", $funcType([($ptrType(Struct))], [($sliceType($Int64))], false), -1], ["sizeof", "sizeof", "code.google.com/p/go.tools/go/types", $funcType([Type], [$Int64], false), -1]]; + Config.init([["IgnoreFuncBodies", "IgnoreFuncBodies", "", $Bool, ""], ["FakeImportC", "FakeImportC", "", $Bool, ""], ["Packages", "Packages", "", ($mapType($String, ($ptrType(Package)))), ""], ["Error", "Error", "", ($funcType([$error], [], false)), ""], ["Import", "Import", "", Importer, ""], ["Sizes", "Sizes", "", Sizes, ""]]); + ($ptrType(Info)).methods = [["ObjectOf", "ObjectOf", "", $funcType([($ptrType(ast.Ident))], [Object], false), -1], ["TypeOf", "TypeOf", "", $funcType([ast.Expr], [Type], false), -1]]; + Info.init([["Types", "Types", "", ($mapType(ast.Expr, TypeAndValue)), ""], ["Defs", "Defs", "", ($mapType(($ptrType(ast.Ident)), Object)), ""], ["Uses", "Uses", "", ($mapType(($ptrType(ast.Ident)), Object)), ""], ["Implicits", "Implicits", "", ($mapType(ast.Node, Object)), ""], ["Selections", "Selections", "", ($mapType(($ptrType(ast.SelectorExpr)), ($ptrType(Selection)))), ""], ["Scopes", "Scopes", "", ($mapType(ast.Node, ($ptrType(Scope)))), ""], ["InitOrder", "InitOrder", "", ($sliceType(($ptrType(Initializer)))), ""]]); + TypeAndValue.methods = [["Addressable", "Addressable", "", $funcType([], [$Bool], false), -1], ["Assignable", "Assignable", "", $funcType([], [$Bool], false), -1], ["HasOk", "HasOk", "", $funcType([], [$Bool], false), -1], ["IsBuiltin", "IsBuiltin", "", $funcType([], [$Bool], false), -1], ["IsNil", "IsNil", "", $funcType([], [$Bool], false), -1], ["IsType", "IsType", "", $funcType([], [$Bool], false), -1], ["IsValue", "IsValue", "", $funcType([], [$Bool], false), -1], ["IsVoid", "IsVoid", "", $funcType([], [$Bool], false), -1]]; + ($ptrType(TypeAndValue)).methods = [["Addressable", "Addressable", "", $funcType([], [$Bool], false), -1], ["Assignable", "Assignable", "", $funcType([], [$Bool], false), -1], ["HasOk", "HasOk", "", $funcType([], [$Bool], false), -1], ["IsBuiltin", "IsBuiltin", "", $funcType([], [$Bool], false), -1], ["IsNil", "IsNil", "", $funcType([], [$Bool], false), -1], ["IsType", "IsType", "", $funcType([], [$Bool], false), -1], ["IsValue", "IsValue", "", $funcType([], [$Bool], false), -1], ["IsVoid", "IsVoid", "", $funcType([], [$Bool], false), -1]]; + TypeAndValue.init([["mode", "mode", "code.google.com/p/go.tools/go/types", operandMode, ""], ["Type", "Type", "", Type, ""], ["Value", "Value", "", exact.Value, ""]]); + ($ptrType(Initializer)).methods = [["String", "String", "", $funcType([], [$String], false), -1]]; + Initializer.init([["Lhs", "Lhs", "", ($sliceType(($ptrType(Var)))), ""], ["Rhs", "Rhs", "", ast.Expr, ""]]); + getter.init([($ptrType(operand)), $Int], [], false); + exprInfo.init([["isLhs", "isLhs", "code.google.com/p/go.tools/go/types", $Bool, ""], ["mode", "mode", "code.google.com/p/go.tools/go/types", operandMode, ""], ["typ", "typ", "code.google.com/p/go.tools/go/types", ($ptrType(Basic)), ""], ["val", "val", "code.google.com/p/go.tools/go/types", exact.Value, ""]]); + funcInfo.init([["name", "name", "code.google.com/p/go.tools/go/types", $String, ""], ["decl", "decl", "code.google.com/p/go.tools/go/types", ($ptrType(declInfo)), ""], ["sig", "sig", "code.google.com/p/go.tools/go/types", ($ptrType(Signature)), ""], ["body", "body", "code.google.com/p/go.tools/go/types", ($ptrType(ast.BlockStmt)), ""]]); + context.init([["decl", "decl", "code.google.com/p/go.tools/go/types", ($ptrType(declInfo)), ""], ["scope", "scope", "code.google.com/p/go.tools/go/types", ($ptrType(Scope)), ""], ["iota", "iota", "code.google.com/p/go.tools/go/types", exact.Value, ""], ["sig", "sig", "code.google.com/p/go.tools/go/types", ($ptrType(Signature)), ""], ["hasLabel", "hasLabel", "code.google.com/p/go.tools/go/types", $Bool, ""], ["hasCallOrRecv", "hasCallOrRecv", "code.google.com/p/go.tools/go/types", $Bool, ""]]); + Checker.methods = [["ObjectOf", "ObjectOf", "", $funcType([($ptrType(ast.Ident))], [Object], false), 3], ["TypeOf", "TypeOf", "", $funcType([ast.Expr], [Type], false), 3]]; + ($ptrType(Checker)).methods = [["Files", "Files", "", $funcType([($sliceType(($ptrType(ast.File))))], [$error], false), -1], ["ObjectOf", "ObjectOf", "", $funcType([($ptrType(ast.Ident))], [Object], false), 3], ["TypeOf", "TypeOf", "", $funcType([ast.Expr], [Type], false), 3], ["addDeclDep", "addDeclDep", "code.google.com/p/go.tools/go/types", $funcType([Object], [], false), -1], ["addMethodDecls", "addMethodDecls", "code.google.com/p/go.tools/go/types", $funcType([($ptrType(TypeName))], [], false), -1], ["appendInPostOrder", "appendInPostOrder", "code.google.com/p/go.tools/go/types", $funcType([($ptrType(($sliceType(Object)))), Object], [], false), -1], ["argument", "argument", "code.google.com/p/go.tools/go/types", $funcType([($ptrType(Signature)), $Int, ($ptrType(operand)), $Bool], [], false), -1], ["arguments$", "arguments", "code.google.com/p/go.tools/go/types", $funcType([($ptrType(operand)), ($ptrType(ast.CallExpr)), ($ptrType(Signature)), getter, $Int], [], false), -1], ["arityMatch", "arityMatch", "code.google.com/p/go.tools/go/types", $funcType([($ptrType(ast.ValueSpec)), ($ptrType(ast.ValueSpec))], [], false), -1], ["arrayLength", "arrayLength", "code.google.com/p/go.tools/go/types", $funcType([ast.Expr], [$Int64], false), -1], ["assignVar", "assignVar", "code.google.com/p/go.tools/go/types", $funcType([ast.Expr, ($ptrType(operand))], [Type], false), -1], ["assignVars", "assignVars", "code.google.com/p/go.tools/go/types", $funcType([($sliceType(ast.Expr)), ($sliceType(ast.Expr))], [], false), -1], ["assignment", "assignment", "code.google.com/p/go.tools/go/types", $funcType([($ptrType(operand)), Type], [$Bool], false), -1], ["assocMethod", "assocMethod", "code.google.com/p/go.tools/go/types", $funcType([$String, ($ptrType(Func))], [], false), -1], ["binary", "binary", "code.google.com/p/go.tools/go/types", $funcType([($ptrType(operand)), ast.Expr, ast.Expr, token.Token], [], false), -1], ["blockBranches", "blockBranches", "code.google.com/p/go.tools/go/types", $funcType([($ptrType(Scope)), ($ptrType(block)), ($ptrType(ast.LabeledStmt)), ($sliceType(ast.Stmt))], [($sliceType(($ptrType(ast.BranchStmt))))], false), -1], ["builtin", "builtin", "code.google.com/p/go.tools/go/types", $funcType([($ptrType(operand)), ($ptrType(ast.CallExpr)), builtinId], [$Bool], false), -1], ["call", "call", "code.google.com/p/go.tools/go/types", $funcType([($ptrType(operand)), ($ptrType(ast.CallExpr))], [exprKind], false), -1], ["caseTypes", "caseTypes", "code.google.com/p/go.tools/go/types", $funcType([($ptrType(operand)), ($ptrType(Interface)), ($sliceType(ast.Expr)), ($mapType(Type, token.Pos))], [Type], false), -1], ["caseValues", "caseValues", "code.google.com/p/go.tools/go/types", $funcType([operand, ($sliceType(ast.Expr))], [], false), -1], ["closeScope", "closeScope", "code.google.com/p/go.tools/go/types", $funcType([], [], false), -1], ["collectObjects", "collectObjects", "code.google.com/p/go.tools/go/types", $funcType([], [], false), -1], ["collectParams", "collectParams", "code.google.com/p/go.tools/go/types", $funcType([($ptrType(Scope)), ($ptrType(ast.FieldList)), $Bool], [($sliceType(($ptrType(Var)))), $Bool], false), -1], ["comparison", "comparison", "code.google.com/p/go.tools/go/types", $funcType([($ptrType(operand)), ($ptrType(operand)), token.Token], [], false), -1], ["complexArg", "complexArg", "code.google.com/p/go.tools/go/types", $funcType([($ptrType(operand))], [$Bool], false), -1], ["constDecl", "constDecl", "code.google.com/p/go.tools/go/types", $funcType([($ptrType(Const)), ast.Expr, ast.Expr], [], false), -1], ["conversion", "conversion", "code.google.com/p/go.tools/go/types", $funcType([($ptrType(operand)), Type], [], false), -1], ["convertUntyped", "convertUntyped", "code.google.com/p/go.tools/go/types", $funcType([($ptrType(operand)), Type], [], false), -1], ["declStmt", "declStmt", "code.google.com/p/go.tools/go/types", $funcType([ast.Decl], [], false), -1], ["declare", "declare", "code.google.com/p/go.tools/go/types", $funcType([($ptrType(Scope)), ($ptrType(ast.Ident)), Object], [], false), -1], ["declareInSet", "declareInSet", "code.google.com/p/go.tools/go/types", $funcType([($ptrType(objset)), token.Pos, Object], [$Bool], false), -1], ["declarePkgObj", "declarePkgObj", "code.google.com/p/go.tools/go/types", $funcType([($ptrType(ast.Ident)), Object, ($ptrType(declInfo))], [], false), -1], ["delay", "delay", "code.google.com/p/go.tools/go/types", $funcType([($funcType([], [], false))], [], false), -1], ["dump", "dump", "code.google.com/p/go.tools/go/types", $funcType([$String, ($sliceType($emptyInterface))], [], true), -1], ["err", "err", "code.google.com/p/go.tools/go/types", $funcType([token.Pos, $String, $Bool], [], false), -1], ["error", "error", "code.google.com/p/go.tools/go/types", $funcType([token.Pos, $String], [], false), -1], ["errorf", "errorf", "code.google.com/p/go.tools/go/types", $funcType([token.Pos, $String, ($sliceType($emptyInterface))], [], true), -1], ["expr", "expr", "code.google.com/p/go.tools/go/types", $funcType([($ptrType(operand)), ast.Expr], [], false), -1], ["exprInternal", "exprInternal", "code.google.com/p/go.tools/go/types", $funcType([($ptrType(operand)), ast.Expr, Type], [exprKind], false), -1], ["exprOrType", "exprOrType", "code.google.com/p/go.tools/go/types", $funcType([($ptrType(operand)), ast.Expr], [], false), -1], ["exprWithHint", "exprWithHint", "code.google.com/p/go.tools/go/types", $funcType([($ptrType(operand)), ast.Expr, Type], [], false), -1], ["funcBody", "funcBody", "code.google.com/p/go.tools/go/types", $funcType([($ptrType(declInfo)), $String, ($ptrType(Signature)), ($ptrType(ast.BlockStmt))], [], false), -1], ["funcDecl", "funcDecl", "code.google.com/p/go.tools/go/types", $funcType([($ptrType(Func)), ($ptrType(declInfo))], [], false), -1], ["funcType", "funcType", "code.google.com/p/go.tools/go/types", $funcType([($ptrType(Signature)), ($ptrType(ast.FieldList)), ($ptrType(ast.FuncType))], [($ptrType(Signature))], false), -1], ["functionBodies", "functionBodies", "code.google.com/p/go.tools/go/types", $funcType([], [], false), -1], ["handleBailout", "handleBailout", "code.google.com/p/go.tools/go/types", $funcType([($ptrType($error))], [], false), -1], ["ident", "ident", "code.google.com/p/go.tools/go/types", $funcType([($ptrType(operand)), ($ptrType(ast.Ident)), ($ptrType(Named)), ($sliceType(($ptrType(TypeName))))], [], false), -1], ["index", "index", "code.google.com/p/go.tools/go/types", $funcType([ast.Expr, $Int64], [$Int64, $Bool], false), -1], ["indexedElts", "indexedElts", "code.google.com/p/go.tools/go/types", $funcType([($sliceType(ast.Expr)), Type, $Int64], [$Int64], false), -1], ["initConst", "initConst", "code.google.com/p/go.tools/go/types", $funcType([($ptrType(Const)), ($ptrType(operand))], [], false), -1], ["initFiles", "initFiles", "code.google.com/p/go.tools/go/types", $funcType([($sliceType(($ptrType(ast.File))))], [], false), -1], ["initOrder", "initOrder", "code.google.com/p/go.tools/go/types", $funcType([], [], false), -1], ["initVar", "initVar", "code.google.com/p/go.tools/go/types", $funcType([($ptrType(Var)), ($ptrType(operand)), $Bool], [Type], false), -1], ["initVars", "initVars", "code.google.com/p/go.tools/go/types", $funcType([($sliceType(($ptrType(Var)))), ($sliceType(ast.Expr)), token.Pos], [], false), -1], ["interfaceFor", "interfaceFor", "code.google.com/p/go.tools/go/types", $funcType([Object], [($ptrType(ast.InterfaceType))], false), -1], ["interfaceType", "interfaceType", "code.google.com/p/go.tools/go/types", $funcType([($ptrType(Interface)), ($ptrType(ast.InterfaceType)), ($ptrType(Named)), ($sliceType(($ptrType(TypeName))))], [], false), -1], ["invalidAST", "invalidAST", "code.google.com/p/go.tools/go/types", $funcType([token.Pos, $String, ($sliceType($emptyInterface))], [], true), -1], ["invalidArg", "invalidArg", "code.google.com/p/go.tools/go/types", $funcType([token.Pos, $String, ($sliceType($emptyInterface))], [], true), -1], ["invalidOp", "invalidOp", "code.google.com/p/go.tools/go/types", $funcType([token.Pos, $String, ($sliceType($emptyInterface))], [], true), -1], ["isTerminating", "isTerminating", "code.google.com/p/go.tools/go/types", $funcType([ast.Stmt, $String], [$Bool], false), -1], ["isTerminatingList", "isTerminatingList", "code.google.com/p/go.tools/go/types", $funcType([($sliceType(ast.Stmt)), $String], [$Bool], false), -1], ["isTerminatingSwitch", "isTerminatingSwitch", "code.google.com/p/go.tools/go/types", $funcType([($ptrType(ast.BlockStmt)), $String], [$Bool], false), -1], ["labels", "labels", "code.google.com/p/go.tools/go/types", $funcType([($ptrType(ast.BlockStmt))], [], false), -1], ["later", "later", "code.google.com/p/go.tools/go/types", $funcType([$String, ($ptrType(declInfo)), ($ptrType(Signature)), ($ptrType(ast.BlockStmt))], [], false), -1], ["multipleDefaults", "multipleDefaults", "code.google.com/p/go.tools/go/types", $funcType([($sliceType(ast.Stmt))], [], false), -1], ["objDecl", "objDecl", "code.google.com/p/go.tools/go/types", $funcType([Object, ($ptrType(Named)), ($sliceType(($ptrType(TypeName))))], [], false), -1], ["op", "op", "code.google.com/p/go.tools/go/types", $funcType([opPredicates, ($ptrType(operand)), token.Token], [$Bool], false), -1], ["openScope", "openScope", "code.google.com/p/go.tools/go/types", $funcType([ast.Stmt, $String], [], false), -1], ["packageObjects", "packageObjects", "code.google.com/p/go.tools/go/types", $funcType([($sliceType(Object))], [], false), -1], ["rawExpr", "rawExpr", "code.google.com/p/go.tools/go/types", $funcType([($ptrType(operand)), ast.Expr, Type], [exprKind], false), -1], ["recordBuiltinType", "recordBuiltinType", "code.google.com/p/go.tools/go/types", $funcType([ast.Expr, ($ptrType(Signature))], [], false), -1], ["recordCommaOkTypes", "recordCommaOkTypes", "code.google.com/p/go.tools/go/types", $funcType([ast.Expr, ($arrayType(Type, 2))], [], false), -1], ["recordDef", "recordDef", "code.google.com/p/go.tools/go/types", $funcType([($ptrType(ast.Ident)), Object], [], false), -1], ["recordImplicit", "recordImplicit", "code.google.com/p/go.tools/go/types", $funcType([ast.Node, Object], [], false), -1], ["recordScope", "recordScope", "code.google.com/p/go.tools/go/types", $funcType([ast.Node, ($ptrType(Scope))], [], false), -1], ["recordSelection", "recordSelection", "code.google.com/p/go.tools/go/types", $funcType([($ptrType(ast.SelectorExpr)), SelectionKind, Type, Object, ($sliceType($Int)), $Bool], [], false), -1], ["recordTypeAndValue", "recordTypeAndValue", "code.google.com/p/go.tools/go/types", $funcType([ast.Expr, operandMode, Type, exact.Value], [], false), -1], ["recordUntyped", "recordUntyped", "code.google.com/p/go.tools/go/types", $funcType([], [], false), -1], ["recordUse", "recordUse", "code.google.com/p/go.tools/go/types", $funcType([($ptrType(ast.Ident)), Object], [], false), -1], ["rememberUntyped", "rememberUntyped", "code.google.com/p/go.tools/go/types", $funcType([ast.Expr, $Bool, operandMode, ($ptrType(Basic)), exact.Value], [], false), -1], ["reportAltDecl", "reportAltDecl", "code.google.com/p/go.tools/go/types", $funcType([Object], [], false), -1], ["reportCycle", "reportCycle", "code.google.com/p/go.tools/go/types", $funcType([($sliceType(($ptrType(objNode)))), $Int], [], false), -1], ["representable", "representable", "code.google.com/p/go.tools/go/types", $funcType([($ptrType(operand)), ($ptrType(Basic))], [], false), -1], ["resolveOrder", "resolveOrder", "code.google.com/p/go.tools/go/types", $funcType([], [($sliceType(Object))], false), -1], ["selector", "selector", "code.google.com/p/go.tools/go/types", $funcType([($ptrType(operand)), ($ptrType(ast.SelectorExpr))], [], false), -1], ["shift", "shift", "code.google.com/p/go.tools/go/types", $funcType([($ptrType(operand)), ($ptrType(operand)), token.Token], [], false), -1], ["shortVarDecl", "shortVarDecl", "code.google.com/p/go.tools/go/types", $funcType([token.Pos, ($sliceType(ast.Expr)), ($sliceType(ast.Expr))], [], false), -1], ["simpleStmt", "simpleStmt", "code.google.com/p/go.tools/go/types", $funcType([ast.Stmt], [], false), -1], ["softErrorf", "softErrorf", "code.google.com/p/go.tools/go/types", $funcType([token.Pos, $String, ($sliceType($emptyInterface))], [], true), -1], ["sprintf", "sprintf", "code.google.com/p/go.tools/go/types", $funcType([$String, ($sliceType($emptyInterface))], [$String], true), -1], ["stmt", "stmt", "code.google.com/p/go.tools/go/types", $funcType([stmtContext, ast.Stmt], [], false), -1], ["stmtList", "stmtList", "code.google.com/p/go.tools/go/types", $funcType([stmtContext, ($sliceType(ast.Stmt))], [], false), -1], ["structType", "structType", "code.google.com/p/go.tools/go/types", $funcType([($ptrType(Struct)), ($ptrType(ast.StructType)), ($sliceType(($ptrType(TypeName))))], [], false), -1], ["suspendedCall", "suspendedCall", "code.google.com/p/go.tools/go/types", $funcType([$String, ($ptrType(ast.CallExpr))], [], false), -1], ["tag", "tag", "code.google.com/p/go.tools/go/types", $funcType([($ptrType(ast.BasicLit))], [$String], false), -1], ["trace", "trace", "code.google.com/p/go.tools/go/types", $funcType([token.Pos, $String, ($sliceType($emptyInterface))], [], true), -1], ["typ", "typ", "code.google.com/p/go.tools/go/types", $funcType([ast.Expr], [Type], false), -1], ["typExpr", "typExpr", "code.google.com/p/go.tools/go/types", $funcType([ast.Expr, ($ptrType(Named)), ($sliceType(($ptrType(TypeName))))], [Type], false), -1], ["typExprInternal", "typExprInternal", "code.google.com/p/go.tools/go/types", $funcType([ast.Expr, ($ptrType(Named)), ($sliceType(($ptrType(TypeName))))], [Type], false), -1], ["typOrNil", "typOrNil", "code.google.com/p/go.tools/go/types", $funcType([ast.Expr], [Type], false), -1], ["typeAssertion", "typeAssertion", "code.google.com/p/go.tools/go/types", $funcType([token.Pos, ($ptrType(operand)), ($ptrType(Interface)), Type], [], false), -1], ["typeDecl", "typeDecl", "code.google.com/p/go.tools/go/types", $funcType([($ptrType(TypeName)), ast.Expr, ($ptrType(Named)), ($sliceType(($ptrType(TypeName))))], [], false), -1], ["unary", "unary", "code.google.com/p/go.tools/go/types", $funcType([($ptrType(operand)), token.Token], [], false), -1], ["unusedImports", "unusedImports", "code.google.com/p/go.tools/go/types", $funcType([], [], false), -1], ["updateExprType", "updateExprType", "code.google.com/p/go.tools/go/types", $funcType([ast.Expr, Type, $Bool], [], false), -1], ["updateExprVal", "updateExprVal", "code.google.com/p/go.tools/go/types", $funcType([ast.Expr, exact.Value], [], false), -1], ["usage", "usage", "code.google.com/p/go.tools/go/types", $funcType([($ptrType(Scope))], [], false), -1], ["use", "use", "code.google.com/p/go.tools/go/types", $funcType([($sliceType(ast.Expr))], [], true), -1], ["useGetter", "useGetter", "code.google.com/p/go.tools/go/types", $funcType([getter, $Int], [], false), -1], ["varDecl", "varDecl", "code.google.com/p/go.tools/go/types", $funcType([($ptrType(Var)), ($sliceType(($ptrType(Var)))), ast.Expr, ast.Expr], [], false), -1]]; + Checker.init([["conf", "conf", "code.google.com/p/go.tools/go/types", ($ptrType(Config)), ""], ["fset", "fset", "code.google.com/p/go.tools/go/types", ($ptrType(token.FileSet)), ""], ["pkg", "pkg", "code.google.com/p/go.tools/go/types", ($ptrType(Package)), ""], ["Info", "", "", ($ptrType(Info)), ""], ["objMap", "objMap", "code.google.com/p/go.tools/go/types", ($mapType(Object, ($ptrType(declInfo)))), ""], ["files", "files", "code.google.com/p/go.tools/go/types", ($sliceType(($ptrType(ast.File)))), ""], ["fileScopes", "fileScopes", "code.google.com/p/go.tools/go/types", ($sliceType(($ptrType(Scope)))), ""], ["dotImports", "dotImports", "code.google.com/p/go.tools/go/types", ($sliceType(($mapType(($ptrType(Package)), token.Pos)))), ""], ["firstErr", "firstErr", "code.google.com/p/go.tools/go/types", $error, ""], ["methods", "methods", "code.google.com/p/go.tools/go/types", ($mapType($String, ($sliceType(($ptrType(Func)))))), ""], ["untyped", "untyped", "code.google.com/p/go.tools/go/types", ($mapType(ast.Expr, exprInfo)), ""], ["funcs", "funcs", "code.google.com/p/go.tools/go/types", ($sliceType(funcInfo)), ""], ["delayed", "delayed", "code.google.com/p/go.tools/go/types", ($sliceType(($funcType([], [], false)))), ""], ["context", "", "code.google.com/p/go.tools/go/types", context, ""], ["indent", "indent", "code.google.com/p/go.tools/go/types", $Int, ""]]); + bailout.init([]); + opPredicates.init(token.Token, ($funcType([Type], [$Bool], false))); + objNode.init([["obj", "obj", "code.google.com/p/go.tools/go/types", Object, ""], ["in$1", "in", "code.google.com/p/go.tools/go/types", $Int, ""], ["out", "out", "code.google.com/p/go.tools/go/types", ($sliceType(($ptrType(objNode)))), ""], ["index", "index", "code.google.com/p/go.tools/go/types", $Int, ""], ["mark", "mark", "code.google.com/p/go.tools/go/types", $Int, ""]]); + nodeQueue.methods = [["Len", "Len", "", $funcType([], [$Int], false), -1], ["Less", "Less", "", $funcType([$Int, $Int], [$Bool], false), -1], ["Swap", "Swap", "", $funcType([$Int, $Int], [], false), -1]]; + ($ptrType(nodeQueue)).methods = [["Len", "Len", "", $funcType([], [$Int], false), -1], ["Less", "Less", "", $funcType([$Int, $Int], [$Bool], false), -1], ["Pop", "Pop", "", $funcType([], [$emptyInterface], false), -1], ["Push", "Push", "", $funcType([$emptyInterface], [], false), -1], ["Swap", "Swap", "", $funcType([$Int, $Int], [], false), -1]]; + nodeQueue.init(($ptrType(objNode))); + ($ptrType(block)).methods = [["enclosingTarget", "enclosingTarget", "code.google.com/p/go.tools/go/types", $funcType([$String], [($ptrType(ast.LabeledStmt))], false), -1], ["gotoTarget", "gotoTarget", "code.google.com/p/go.tools/go/types", $funcType([$String], [($ptrType(ast.LabeledStmt))], false), -1], ["insert", "insert", "code.google.com/p/go.tools/go/types", $funcType([($ptrType(ast.LabeledStmt))], [], false), -1]]; + block.init([["parent", "parent", "code.google.com/p/go.tools/go/types", ($ptrType(block)), ""], ["lstmt", "lstmt", "code.google.com/p/go.tools/go/types", ($ptrType(ast.LabeledStmt)), ""], ["labels", "labels", "code.google.com/p/go.tools/go/types", ($mapType($String, ($ptrType(ast.LabeledStmt)))), ""]]); + embeddedType.init([["typ", "typ", "code.google.com/p/go.tools/go/types", ($ptrType(Named)), ""], ["index", "index", "code.google.com/p/go.tools/go/types", ($sliceType($Int)), ""], ["indirect", "indirect", "code.google.com/p/go.tools/go/types", $Bool, ""], ["multiples", "multiples", "code.google.com/p/go.tools/go/types", $Bool, ""]]); + ($ptrType(MethodSet)).methods = [["At", "At", "", $funcType([$Int], [($ptrType(Selection))], false), -1], ["Len", "Len", "", $funcType([], [$Int], false), -1], ["Lookup", "Lookup", "", $funcType([($ptrType(Package)), $String], [($ptrType(Selection))], false), -1], ["String", "String", "", $funcType([], [$String], false), -1]]; + MethodSet.init([["list", "list", "code.google.com/p/go.tools/go/types", ($sliceType(($ptrType(Selection)))), ""]]); + fieldSet.methods = [["add", "add", "code.google.com/p/go.tools/go/types", $funcType([($ptrType(Var)), $Bool], [fieldSet], false), -1]]; + ($ptrType(fieldSet)).methods = [["add", "add", "code.google.com/p/go.tools/go/types", $funcType([($ptrType(Var)), $Bool], [fieldSet], false), -1]]; + fieldSet.init($String, ($ptrType(Var))); + methodSet.methods = [["add", "add", "code.google.com/p/go.tools/go/types", $funcType([($sliceType(($ptrType(Func)))), ($sliceType($Int)), $Bool, $Bool], [methodSet], false), -1]]; + ($ptrType(methodSet)).methods = [["add", "add", "code.google.com/p/go.tools/go/types", $funcType([($sliceType(($ptrType(Func)))), ($sliceType($Int)), $Bool, $Bool], [methodSet], false), -1]]; + methodSet.init($String, ($ptrType(Selection))); + byUniqueName.methods = [["Len", "Len", "", $funcType([], [$Int], false), -1], ["Less", "Less", "", $funcType([$Int, $Int], [$Bool], false), -1], ["Swap", "Swap", "", $funcType([$Int, $Int], [], false), -1]]; + ($ptrType(byUniqueName)).methods = [["Len", "Len", "", $funcType([], [$Int], false), -1], ["Less", "Less", "", $funcType([$Int, $Int], [$Bool], false), -1], ["Swap", "Swap", "", $funcType([$Int, $Int], [], false), -1]]; + byUniqueName.init(($ptrType(Selection))); + Object.init([["Exported", "Exported", "", $funcType([], [$Bool], false)], ["Id", "Id", "", $funcType([], [$String], false)], ["Name", "Name", "", $funcType([], [$String], false)], ["Parent", "Parent", "", $funcType([], [($ptrType(Scope))], false)], ["Pkg", "Pkg", "", $funcType([], [($ptrType(Package))], false)], ["Pos", "Pos", "", $funcType([], [token.Pos], false)], ["String", "String", "", $funcType([], [$String], false)], ["Type", "Type", "", $funcType([], [Type], false)], ["isUsed", "isUsed", "code.google.com/p/go.tools/go/types", $funcType([], [$Bool], false)], ["order", "order", "code.google.com/p/go.tools/go/types", $funcType([], [$Uint32], false)], ["sameId", "sameId", "code.google.com/p/go.tools/go/types", $funcType([($ptrType(Package)), $String], [$Bool], false)], ["setOrder", "setOrder", "code.google.com/p/go.tools/go/types", $funcType([$Uint32], [], false)], ["setParent", "setParent", "code.google.com/p/go.tools/go/types", $funcType([($ptrType(Scope))], [], false)]]); + ($ptrType(object)).methods = [["Exported", "Exported", "", $funcType([], [$Bool], false), -1], ["Id", "Id", "", $funcType([], [$String], false), -1], ["Name", "Name", "", $funcType([], [$String], false), -1], ["Parent", "Parent", "", $funcType([], [($ptrType(Scope))], false), -1], ["Pkg", "Pkg", "", $funcType([], [($ptrType(Package))], false), -1], ["Pos", "Pos", "", $funcType([], [token.Pos], false), -1], ["String", "String", "", $funcType([], [$String], false), -1], ["Type", "Type", "", $funcType([], [Type], false), -1], ["isUsed", "isUsed", "code.google.com/p/go.tools/go/types", $funcType([], [$Bool], false), -1], ["order", "order", "code.google.com/p/go.tools/go/types", $funcType([], [$Uint32], false), -1], ["sameId", "sameId", "code.google.com/p/go.tools/go/types", $funcType([($ptrType(Package)), $String], [$Bool], false), -1], ["setOrder", "setOrder", "code.google.com/p/go.tools/go/types", $funcType([$Uint32], [], false), -1], ["setParent", "setParent", "code.google.com/p/go.tools/go/types", $funcType([($ptrType(Scope))], [], false), -1]]; + object.init([["parent", "parent", "code.google.com/p/go.tools/go/types", ($ptrType(Scope)), ""], ["pos", "pos", "code.google.com/p/go.tools/go/types", token.Pos, ""], ["pkg", "pkg", "code.google.com/p/go.tools/go/types", ($ptrType(Package)), ""], ["name", "name", "code.google.com/p/go.tools/go/types", $String, ""], ["typ", "typ", "code.google.com/p/go.tools/go/types", Type, ""], ["order_", "order_", "code.google.com/p/go.tools/go/types", $Uint32, ""], ["used", "used", "code.google.com/p/go.tools/go/types", $Bool, ""]]); + ($ptrType(PkgName)).methods = [["Exported", "Exported", "", $funcType([], [$Bool], false), 0], ["Id", "Id", "", $funcType([], [$String], false), 0], ["Imported", "Imported", "", $funcType([], [($ptrType(Package))], false), -1], ["Name", "Name", "", $funcType([], [$String], false), 0], ["Parent", "Parent", "", $funcType([], [($ptrType(Scope))], false), 0], ["Pkg", "Pkg", "", $funcType([], [($ptrType(Package))], false), 0], ["Pos", "Pos", "", $funcType([], [token.Pos], false), 0], ["String", "String", "", $funcType([], [$String], false), -1], ["Type", "Type", "", $funcType([], [Type], false), 0], ["isUsed", "isUsed", "code.google.com/p/go.tools/go/types", $funcType([], [$Bool], false), 0], ["order", "order", "code.google.com/p/go.tools/go/types", $funcType([], [$Uint32], false), 0], ["sameId", "sameId", "code.google.com/p/go.tools/go/types", $funcType([($ptrType(Package)), $String], [$Bool], false), 0], ["setOrder", "setOrder", "code.google.com/p/go.tools/go/types", $funcType([$Uint32], [], false), 0], ["setParent", "setParent", "code.google.com/p/go.tools/go/types", $funcType([($ptrType(Scope))], [], false), 0]]; + PkgName.init([["object", "", "code.google.com/p/go.tools/go/types", object, ""], ["imported", "imported", "code.google.com/p/go.tools/go/types", ($ptrType(Package)), ""]]); + ($ptrType(Const)).methods = [["Exported", "Exported", "", $funcType([], [$Bool], false), 0], ["Id", "Id", "", $funcType([], [$String], false), 0], ["Name", "Name", "", $funcType([], [$String], false), 0], ["Parent", "Parent", "", $funcType([], [($ptrType(Scope))], false), 0], ["Pkg", "Pkg", "", $funcType([], [($ptrType(Package))], false), 0], ["Pos", "Pos", "", $funcType([], [token.Pos], false), 0], ["String", "String", "", $funcType([], [$String], false), -1], ["Type", "Type", "", $funcType([], [Type], false), 0], ["Val", "Val", "", $funcType([], [exact.Value], false), -1], ["isUsed", "isUsed", "code.google.com/p/go.tools/go/types", $funcType([], [$Bool], false), 0], ["order", "order", "code.google.com/p/go.tools/go/types", $funcType([], [$Uint32], false), 0], ["sameId", "sameId", "code.google.com/p/go.tools/go/types", $funcType([($ptrType(Package)), $String], [$Bool], false), 0], ["setOrder", "setOrder", "code.google.com/p/go.tools/go/types", $funcType([$Uint32], [], false), 0], ["setParent", "setParent", "code.google.com/p/go.tools/go/types", $funcType([($ptrType(Scope))], [], false), 0]]; + Const.init([["object", "", "code.google.com/p/go.tools/go/types", object, ""], ["val", "val", "code.google.com/p/go.tools/go/types", exact.Value, ""], ["visited", "visited", "code.google.com/p/go.tools/go/types", $Bool, ""]]); + ($ptrType(TypeName)).methods = [["Exported", "Exported", "", $funcType([], [$Bool], false), 0], ["Id", "Id", "", $funcType([], [$String], false), 0], ["Name", "Name", "", $funcType([], [$String], false), 0], ["Parent", "Parent", "", $funcType([], [($ptrType(Scope))], false), 0], ["Pkg", "Pkg", "", $funcType([], [($ptrType(Package))], false), 0], ["Pos", "Pos", "", $funcType([], [token.Pos], false), 0], ["String", "String", "", $funcType([], [$String], false), -1], ["Type", "Type", "", $funcType([], [Type], false), 0], ["isUsed", "isUsed", "code.google.com/p/go.tools/go/types", $funcType([], [$Bool], false), 0], ["order", "order", "code.google.com/p/go.tools/go/types", $funcType([], [$Uint32], false), 0], ["sameId", "sameId", "code.google.com/p/go.tools/go/types", $funcType([($ptrType(Package)), $String], [$Bool], false), 0], ["setOrder", "setOrder", "code.google.com/p/go.tools/go/types", $funcType([$Uint32], [], false), 0], ["setParent", "setParent", "code.google.com/p/go.tools/go/types", $funcType([($ptrType(Scope))], [], false), 0]]; + TypeName.init([["object", "", "code.google.com/p/go.tools/go/types", object, ""]]); + ($ptrType(Var)).methods = [["Anonymous", "Anonymous", "", $funcType([], [$Bool], false), -1], ["Exported", "Exported", "", $funcType([], [$Bool], false), 0], ["Id", "Id", "", $funcType([], [$String], false), 0], ["IsField", "IsField", "", $funcType([], [$Bool], false), -1], ["Name", "Name", "", $funcType([], [$String], false), 0], ["Parent", "Parent", "", $funcType([], [($ptrType(Scope))], false), 0], ["Pkg", "Pkg", "", $funcType([], [($ptrType(Package))], false), 0], ["Pos", "Pos", "", $funcType([], [token.Pos], false), 0], ["String", "String", "", $funcType([], [$String], false), -1], ["Type", "Type", "", $funcType([], [Type], false), 0], ["isUsed", "isUsed", "code.google.com/p/go.tools/go/types", $funcType([], [$Bool], false), 0], ["order", "order", "code.google.com/p/go.tools/go/types", $funcType([], [$Uint32], false), 0], ["sameId", "sameId", "code.google.com/p/go.tools/go/types", $funcType([($ptrType(Package)), $String], [$Bool], false), 0], ["setOrder", "setOrder", "code.google.com/p/go.tools/go/types", $funcType([$Uint32], [], false), 0], ["setParent", "setParent", "code.google.com/p/go.tools/go/types", $funcType([($ptrType(Scope))], [], false), 0]]; + Var.init([["object", "", "code.google.com/p/go.tools/go/types", object, ""], ["anonymous", "anonymous", "code.google.com/p/go.tools/go/types", $Bool, ""], ["visited", "visited", "code.google.com/p/go.tools/go/types", $Bool, ""], ["isField", "isField", "code.google.com/p/go.tools/go/types", $Bool, ""]]); + ($ptrType(Func)).methods = [["Exported", "Exported", "", $funcType([], [$Bool], false), 0], ["FullName", "FullName", "", $funcType([], [$String], false), -1], ["Id", "Id", "", $funcType([], [$String], false), 0], ["Name", "Name", "", $funcType([], [$String], false), 0], ["Parent", "Parent", "", $funcType([], [($ptrType(Scope))], false), 0], ["Pkg", "Pkg", "", $funcType([], [($ptrType(Package))], false), 0], ["Pos", "Pos", "", $funcType([], [token.Pos], false), 0], ["Scope", "Scope", "", $funcType([], [($ptrType(Scope))], false), -1], ["String", "String", "", $funcType([], [$String], false), -1], ["Type", "Type", "", $funcType([], [Type], false), 0], ["isUsed", "isUsed", "code.google.com/p/go.tools/go/types", $funcType([], [$Bool], false), 0], ["order", "order", "code.google.com/p/go.tools/go/types", $funcType([], [$Uint32], false), 0], ["sameId", "sameId", "code.google.com/p/go.tools/go/types", $funcType([($ptrType(Package)), $String], [$Bool], false), 0], ["setOrder", "setOrder", "code.google.com/p/go.tools/go/types", $funcType([$Uint32], [], false), 0], ["setParent", "setParent", "code.google.com/p/go.tools/go/types", $funcType([($ptrType(Scope))], [], false), 0]]; + Func.init([["object", "", "code.google.com/p/go.tools/go/types", object, ""]]); + ($ptrType(Label)).methods = [["Exported", "Exported", "", $funcType([], [$Bool], false), 0], ["Id", "Id", "", $funcType([], [$String], false), 0], ["Name", "Name", "", $funcType([], [$String], false), 0], ["Parent", "Parent", "", $funcType([], [($ptrType(Scope))], false), 0], ["Pkg", "Pkg", "", $funcType([], [($ptrType(Package))], false), 0], ["Pos", "Pos", "", $funcType([], [token.Pos], false), 0], ["String", "String", "", $funcType([], [$String], false), -1], ["Type", "Type", "", $funcType([], [Type], false), 0], ["isUsed", "isUsed", "code.google.com/p/go.tools/go/types", $funcType([], [$Bool], false), 0], ["order", "order", "code.google.com/p/go.tools/go/types", $funcType([], [$Uint32], false), 0], ["sameId", "sameId", "code.google.com/p/go.tools/go/types", $funcType([($ptrType(Package)), $String], [$Bool], false), 0], ["setOrder", "setOrder", "code.google.com/p/go.tools/go/types", $funcType([$Uint32], [], false), 0], ["setParent", "setParent", "code.google.com/p/go.tools/go/types", $funcType([($ptrType(Scope))], [], false), 0]]; + Label.init([["object", "", "code.google.com/p/go.tools/go/types", object, ""]]); + ($ptrType(Builtin)).methods = [["Exported", "Exported", "", $funcType([], [$Bool], false), 0], ["Id", "Id", "", $funcType([], [$String], false), 0], ["Name", "Name", "", $funcType([], [$String], false), 0], ["Parent", "Parent", "", $funcType([], [($ptrType(Scope))], false), 0], ["Pkg", "Pkg", "", $funcType([], [($ptrType(Package))], false), 0], ["Pos", "Pos", "", $funcType([], [token.Pos], false), 0], ["String", "String", "", $funcType([], [$String], false), -1], ["Type", "Type", "", $funcType([], [Type], false), 0], ["isUsed", "isUsed", "code.google.com/p/go.tools/go/types", $funcType([], [$Bool], false), 0], ["order", "order", "code.google.com/p/go.tools/go/types", $funcType([], [$Uint32], false), 0], ["sameId", "sameId", "code.google.com/p/go.tools/go/types", $funcType([($ptrType(Package)), $String], [$Bool], false), 0], ["setOrder", "setOrder", "code.google.com/p/go.tools/go/types", $funcType([$Uint32], [], false), 0], ["setParent", "setParent", "code.google.com/p/go.tools/go/types", $funcType([($ptrType(Scope))], [], false), 0]]; + Builtin.init([["object", "", "code.google.com/p/go.tools/go/types", object, ""], ["id", "id", "code.google.com/p/go.tools/go/types", builtinId, ""]]); + ($ptrType(Nil)).methods = [["Exported", "Exported", "", $funcType([], [$Bool], false), 0], ["Id", "Id", "", $funcType([], [$String], false), 0], ["Name", "Name", "", $funcType([], [$String], false), 0], ["Parent", "Parent", "", $funcType([], [($ptrType(Scope))], false), 0], ["Pkg", "Pkg", "", $funcType([], [($ptrType(Package))], false), 0], ["Pos", "Pos", "", $funcType([], [token.Pos], false), 0], ["String", "String", "", $funcType([], [$String], false), -1], ["Type", "Type", "", $funcType([], [Type], false), 0], ["isUsed", "isUsed", "code.google.com/p/go.tools/go/types", $funcType([], [$Bool], false), 0], ["order", "order", "code.google.com/p/go.tools/go/types", $funcType([], [$Uint32], false), 0], ["sameId", "sameId", "code.google.com/p/go.tools/go/types", $funcType([($ptrType(Package)), $String], [$Bool], false), 0], ["setOrder", "setOrder", "code.google.com/p/go.tools/go/types", $funcType([$Uint32], [], false), 0], ["setParent", "setParent", "code.google.com/p/go.tools/go/types", $funcType([($ptrType(Scope))], [], false), 0]]; + Nil.init([["object", "", "code.google.com/p/go.tools/go/types", object, ""]]); + ($ptrType(objset)).methods = [["insert", "insert", "code.google.com/p/go.tools/go/types", $funcType([Object], [Object], false), -1]]; + objset.init($String, Object); + ($ptrType(operand)).methods = [["String", "String", "", $funcType([], [$String], false), -1], ["assignableTo", "assignableTo", "code.google.com/p/go.tools/go/types", $funcType([($ptrType(Config)), Type], [$Bool], false), -1], ["convertibleTo", "convertibleTo", "code.google.com/p/go.tools/go/types", $funcType([($ptrType(Config)), Type], [$Bool], false), -1], ["isInteger", "isInteger", "code.google.com/p/go.tools/go/types", $funcType([], [$Bool], false), -1], ["isNil", "isNil", "code.google.com/p/go.tools/go/types", $funcType([], [$Bool], false), -1], ["pos", "pos", "code.google.com/p/go.tools/go/types", $funcType([], [token.Pos], false), -1], ["setConst", "setConst", "code.google.com/p/go.tools/go/types", $funcType([token.Token, $String], [], false), -1]]; + operand.init([["mode", "mode", "code.google.com/p/go.tools/go/types", operandMode, ""], ["expr", "expr", "code.google.com/p/go.tools/go/types", ast.Expr, ""], ["typ", "typ", "code.google.com/p/go.tools/go/types", Type, ""], ["val", "val", "code.google.com/p/go.tools/go/types", exact.Value, ""], ["id", "id", "code.google.com/p/go.tools/go/types", builtinId, ""]]); + inSourceOrder.methods = [["Len", "Len", "", $funcType([], [$Int], false), -1], ["Less", "Less", "", $funcType([$Int, $Int], [$Bool], false), -1], ["Swap", "Swap", "", $funcType([$Int, $Int], [], false), -1]]; + ($ptrType(inSourceOrder)).methods = [["Len", "Len", "", $funcType([], [$Int], false), -1], ["Less", "Less", "", $funcType([$Int, $Int], [$Bool], false), -1], ["Swap", "Swap", "", $funcType([$Int, $Int], [], false), -1]]; + inSourceOrder.init(Object); + ($ptrType(Package)).methods = [["Complete", "Complete", "", $funcType([], [$Bool], false), -1], ["Imports", "Imports", "", $funcType([], [($sliceType(($ptrType(Package))))], false), -1], ["MarkComplete", "MarkComplete", "", $funcType([], [], false), -1], ["Name", "Name", "", $funcType([], [$String], false), -1], ["Path", "Path", "", $funcType([], [$String], false), -1], ["Scope", "Scope", "", $funcType([], [($ptrType(Scope))], false), -1], ["SetImports", "SetImports", "", $funcType([($sliceType(($ptrType(Package))))], [], false), -1], ["String", "String", "", $funcType([], [$String], false), -1]]; + Package.init([["path", "path", "code.google.com/p/go.tools/go/types", $String, ""], ["name", "name", "code.google.com/p/go.tools/go/types", $String, ""], ["scope", "scope", "code.google.com/p/go.tools/go/types", ($ptrType(Scope)), ""], ["complete", "complete", "code.google.com/p/go.tools/go/types", $Bool, ""], ["imports", "imports", "code.google.com/p/go.tools/go/types", ($sliceType(($ptrType(Package)))), ""], ["fake", "fake", "code.google.com/p/go.tools/go/types", $Bool, ""]]); + ($ptrType(ifacePair)).methods = [["identical", "identical", "code.google.com/p/go.tools/go/types", $funcType([($ptrType(ifacePair))], [$Bool], false), -1]]; + ifacePair.init([["x", "x", "code.google.com/p/go.tools/go/types", ($ptrType(Interface)), ""], ["y", "y", "code.google.com/p/go.tools/go/types", ($ptrType(Interface)), ""], ["prev", "prev", "code.google.com/p/go.tools/go/types", ($ptrType(ifacePair)), ""]]); + ($ptrType(declInfo)).methods = [["addDep", "addDep", "code.google.com/p/go.tools/go/types", $funcType([Object], [], false), -1], ["hasInitializer", "hasInitializer", "code.google.com/p/go.tools/go/types", $funcType([], [$Bool], false), -1]]; + declInfo.init([["file", "file", "code.google.com/p/go.tools/go/types", ($ptrType(Scope)), ""], ["lhs", "lhs", "code.google.com/p/go.tools/go/types", ($sliceType(($ptrType(Var)))), ""], ["typ", "typ", "code.google.com/p/go.tools/go/types", ast.Expr, ""], ["init", "init", "code.google.com/p/go.tools/go/types", ast.Expr, ""], ["fdecl", "fdecl", "code.google.com/p/go.tools/go/types", ($ptrType(ast.FuncDecl)), ""], ["deps", "deps", "code.google.com/p/go.tools/go/types", ($mapType(Object, $Bool)), ""], ["mark", "mark", "code.google.com/p/go.tools/go/types", $Int, ""]]); + ($ptrType(Scope)).methods = [["Child", "Child", "", $funcType([$Int], [($ptrType(Scope))], false), -1], ["Insert", "Insert", "", $funcType([Object], [Object], false), -1], ["Len", "Len", "", $funcType([], [$Int], false), -1], ["Lookup", "Lookup", "", $funcType([$String], [Object], false), -1], ["LookupParent", "LookupParent", "", $funcType([$String], [Object], false), -1], ["Names", "Names", "", $funcType([], [($sliceType($String))], false), -1], ["NumChildren", "NumChildren", "", $funcType([], [$Int], false), -1], ["Parent", "Parent", "", $funcType([], [($ptrType(Scope))], false), -1], ["String", "String", "", $funcType([], [$String], false), -1], ["WriteTo", "WriteTo", "", $funcType([io.Writer, $Int, $Bool], [], false), -1]]; + Scope.init([["parent", "parent", "code.google.com/p/go.tools/go/types", ($ptrType(Scope)), ""], ["children", "children", "code.google.com/p/go.tools/go/types", ($sliceType(($ptrType(Scope)))), ""], ["comment", "comment", "code.google.com/p/go.tools/go/types", $String, ""], ["elems", "elems", "code.google.com/p/go.tools/go/types", ($mapType($String, Object)), ""]]); + ($ptrType(Selection)).methods = [["Index", "Index", "", $funcType([], [($sliceType($Int))], false), -1], ["Indirect", "Indirect", "", $funcType([], [$Bool], false), -1], ["Kind", "Kind", "", $funcType([], [SelectionKind], false), -1], ["Obj", "Obj", "", $funcType([], [Object], false), -1], ["Recv", "Recv", "", $funcType([], [Type], false), -1], ["String", "String", "", $funcType([], [$String], false), -1], ["Type", "Type", "", $funcType([], [Type], false), -1]]; + Selection.init([["kind", "kind", "code.google.com/p/go.tools/go/types", SelectionKind, ""], ["recv", "recv", "code.google.com/p/go.tools/go/types", Type, ""], ["obj", "obj", "code.google.com/p/go.tools/go/types", Object, ""], ["index", "index", "code.google.com/p/go.tools/go/types", ($sliceType($Int)), ""], ["indirect", "indirect", "code.google.com/p/go.tools/go/types", $Bool, ""]]); + Sizes.init([["Alignof", "Alignof", "", $funcType([Type], [$Int64], false)], ["Offsetsof", "Offsetsof", "", $funcType([($sliceType(($ptrType(Var))))], [($sliceType($Int64))], false)], ["Sizeof", "Sizeof", "", $funcType([Type], [$Int64], false)]]); + ($ptrType(StdSizes)).methods = [["Alignof", "Alignof", "", $funcType([Type], [$Int64], false), -1], ["Offsetsof", "Offsetsof", "", $funcType([($sliceType(($ptrType(Var))))], [($sliceType($Int64))], false), -1], ["Sizeof", "Sizeof", "", $funcType([Type], [$Int64], false), -1]]; + StdSizes.init([["WordSize", "WordSize", "", $Int64, ""], ["MaxAlign", "MaxAlign", "", $Int64, ""]]); + Type.init([["String", "String", "", $funcType([], [$String], false)], ["Underlying", "Underlying", "", $funcType([], [Type], false)]]); + ($ptrType(Basic)).methods = [["Info", "Info", "", $funcType([], [BasicInfo], false), -1], ["Kind", "Kind", "", $funcType([], [BasicKind], false), -1], ["Name", "Name", "", $funcType([], [$String], false), -1], ["String", "String", "", $funcType([], [$String], false), -1], ["Underlying", "Underlying", "", $funcType([], [Type], false), -1]]; + Basic.init([["kind", "kind", "code.google.com/p/go.tools/go/types", BasicKind, ""], ["info", "info", "code.google.com/p/go.tools/go/types", BasicInfo, ""], ["name", "name", "code.google.com/p/go.tools/go/types", $String, ""]]); + ($ptrType(Array)).methods = [["Elem", "Elem", "", $funcType([], [Type], false), -1], ["Len", "Len", "", $funcType([], [$Int64], false), -1], ["String", "String", "", $funcType([], [$String], false), -1], ["Underlying", "Underlying", "", $funcType([], [Type], false), -1]]; + Array.init([["len", "len", "code.google.com/p/go.tools/go/types", $Int64, ""], ["elem", "elem", "code.google.com/p/go.tools/go/types", Type, ""]]); + ($ptrType(Slice)).methods = [["Elem", "Elem", "", $funcType([], [Type], false), -1], ["String", "String", "", $funcType([], [$String], false), -1], ["Underlying", "Underlying", "", $funcType([], [Type], false), -1]]; + Slice.init([["elem", "elem", "code.google.com/p/go.tools/go/types", Type, ""]]); + ($ptrType(Struct)).methods = [["Field", "Field", "", $funcType([$Int], [($ptrType(Var))], false), -1], ["NumFields", "NumFields", "", $funcType([], [$Int], false), -1], ["String", "String", "", $funcType([], [$String], false), -1], ["Tag", "Tag", "", $funcType([$Int], [$String], false), -1], ["Underlying", "Underlying", "", $funcType([], [Type], false), -1]]; + Struct.init([["fields", "fields", "code.google.com/p/go.tools/go/types", ($sliceType(($ptrType(Var)))), ""], ["tags", "tags", "code.google.com/p/go.tools/go/types", ($sliceType($String)), ""], ["offsets", "offsets", "code.google.com/p/go.tools/go/types", ($sliceType($Int64)), ""]]); + ($ptrType(Pointer)).methods = [["Elem", "Elem", "", $funcType([], [Type], false), -1], ["String", "String", "", $funcType([], [$String], false), -1], ["Underlying", "Underlying", "", $funcType([], [Type], false), -1]]; + Pointer.init([["base", "base", "code.google.com/p/go.tools/go/types", Type, ""]]); + ($ptrType(Tuple)).methods = [["At", "At", "", $funcType([$Int], [($ptrType(Var))], false), -1], ["Len", "Len", "", $funcType([], [$Int], false), -1], ["String", "String", "", $funcType([], [$String], false), -1], ["Underlying", "Underlying", "", $funcType([], [Type], false), -1]]; + Tuple.init([["vars", "vars", "code.google.com/p/go.tools/go/types", ($sliceType(($ptrType(Var)))), ""]]); + ($ptrType(Signature)).methods = [["Params", "Params", "", $funcType([], [($ptrType(Tuple))], false), -1], ["Recv", "Recv", "", $funcType([], [($ptrType(Var))], false), -1], ["Results", "Results", "", $funcType([], [($ptrType(Tuple))], false), -1], ["String", "String", "", $funcType([], [$String], false), -1], ["Underlying", "Underlying", "", $funcType([], [Type], false), -1], ["Variadic", "Variadic", "", $funcType([], [$Bool], false), -1]]; + Signature.init([["scope", "scope", "code.google.com/p/go.tools/go/types", ($ptrType(Scope)), ""], ["recv", "recv", "code.google.com/p/go.tools/go/types", ($ptrType(Var)), ""], ["params", "params", "code.google.com/p/go.tools/go/types", ($ptrType(Tuple)), ""], ["results", "results", "code.google.com/p/go.tools/go/types", ($ptrType(Tuple)), ""], ["variadic", "variadic", "code.google.com/p/go.tools/go/types", $Bool, ""]]); + ($ptrType(Interface)).methods = [["Complete", "Complete", "", $funcType([], [($ptrType(Interface))], false), -1], ["Embedded", "Embedded", "", $funcType([$Int], [($ptrType(Named))], false), -1], ["Empty", "Empty", "", $funcType([], [$Bool], false), -1], ["ExplicitMethod", "ExplicitMethod", "", $funcType([$Int], [($ptrType(Func))], false), -1], ["Method", "Method", "", $funcType([$Int], [($ptrType(Func))], false), -1], ["NumEmbeddeds", "NumEmbeddeds", "", $funcType([], [$Int], false), -1], ["NumExplicitMethods", "NumExplicitMethods", "", $funcType([], [$Int], false), -1], ["NumMethods", "NumMethods", "", $funcType([], [$Int], false), -1], ["String", "String", "", $funcType([], [$String], false), -1], ["Underlying", "Underlying", "", $funcType([], [Type], false), -1]]; + Interface.init([["methods", "methods", "code.google.com/p/go.tools/go/types", ($sliceType(($ptrType(Func)))), ""], ["embeddeds", "embeddeds", "code.google.com/p/go.tools/go/types", ($sliceType(($ptrType(Named)))), ""], ["allMethods", "allMethods", "code.google.com/p/go.tools/go/types", ($sliceType(($ptrType(Func)))), ""]]); + ($ptrType(Map)).methods = [["Elem", "Elem", "", $funcType([], [Type], false), -1], ["Key", "Key", "", $funcType([], [Type], false), -1], ["String", "String", "", $funcType([], [$String], false), -1], ["Underlying", "Underlying", "", $funcType([], [Type], false), -1]]; + Map.init([["key", "key", "code.google.com/p/go.tools/go/types", Type, ""], ["elem", "elem", "code.google.com/p/go.tools/go/types", Type, ""]]); + ($ptrType(Chan)).methods = [["Dir", "Dir", "", $funcType([], [ChanDir], false), -1], ["Elem", "Elem", "", $funcType([], [Type], false), -1], ["String", "String", "", $funcType([], [$String], false), -1], ["Underlying", "Underlying", "", $funcType([], [Type], false), -1]]; + Chan.init([["dir", "dir", "code.google.com/p/go.tools/go/types", ChanDir, ""], ["elem", "elem", "code.google.com/p/go.tools/go/types", Type, ""]]); + ($ptrType(Named)).methods = [["AddMethod", "AddMethod", "", $funcType([($ptrType(Func))], [], false), -1], ["Method", "Method", "", $funcType([$Int], [($ptrType(Func))], false), -1], ["NumMethods", "NumMethods", "", $funcType([], [$Int], false), -1], ["Obj", "Obj", "", $funcType([], [($ptrType(TypeName))], false), -1], ["SetUnderlying", "SetUnderlying", "", $funcType([Type], [], false), -1], ["String", "String", "", $funcType([], [$String], false), -1], ["Underlying", "Underlying", "", $funcType([], [Type], false), -1], ["setUnderlying", "setUnderlying", "code.google.com/p/go.tools/go/types", $funcType([Type], [], false), -1]]; + Named.init([["obj", "obj", "code.google.com/p/go.tools/go/types", ($ptrType(TypeName)), ""], ["underlying", "underlying", "code.google.com/p/go.tools/go/types", Type, ""], ["methods", "methods", "code.google.com/p/go.tools/go/types", ($sliceType(($ptrType(Func)))), ""]]); + byUniqueTypeName.methods = [["Len", "Len", "", $funcType([], [$Int], false), -1], ["Less", "Less", "", $funcType([$Int, $Int], [$Bool], false), -1], ["Swap", "Swap", "", $funcType([$Int, $Int], [], false), -1]]; + ($ptrType(byUniqueTypeName)).methods = [["Len", "Len", "", $funcType([], [$Int], false), -1], ["Less", "Less", "", $funcType([$Int, $Int], [$Bool], false), -1], ["Swap", "Swap", "", $funcType([$Int, $Int], [], false), -1]]; + byUniqueTypeName.init(($ptrType(Named))); + byUniqueMethodName.methods = [["Len", "Len", "", $funcType([], [$Int], false), -1], ["Less", "Less", "", $funcType([$Int, $Int], [$Bool], false), -1], ["Swap", "Swap", "", $funcType([$Int, $Int], [], false), -1]]; + ($ptrType(byUniqueMethodName)).methods = [["Len", "Len", "", $funcType([], [$Int], false), -1], ["Less", "Less", "", $funcType([$Int, $Int], [$Bool], false), -1], ["Swap", "Swap", "", $funcType([$Int, $Int], [], false), -1]]; + byUniqueMethodName.init(($ptrType(Func))); + $pkg.DefaultImport = $throwNilPointerError; + emptyMethodSet = new MethodSet.Ptr(); + $pkg.GcCompatibilityMode = false; + $pkg.Universe = ($ptrType(Scope)).nil; + $pkg.Unsafe = ($ptrType(Package)).nil; + universeIota = ($ptrType(Const)).nil; + $pkg.UniverseByte = ($ptrType(Basic)).nil; + $pkg.UniverseRune = ($ptrType(Basic)).nil; + operandModeString = $toNativeArray("String", ["invalid operand", "no value", "built-in", "type", "constant", "variable", "map index expression", "value", "comma, ok expression"]); + stdSizes = new StdSizes.Ptr(new $Int64(0, 8), new $Int64(0, 8)); + basicSizes = $toNativeArray("Uint8", [0, 1, 0, 1, 2, 4, 8, 0, 1, 2, 4, 8, 0, 4, 8, 8, 16]); + unaryOpPredicates = (_map = new $Map(), _key = 12, _map[_key] = { k: _key, v: isNumeric }, _key = 13, _map[_key] = { k: _key, v: isNumeric }, _key = 19, _map[_key] = { k: _key, v: isInteger }, _key = 43, _map[_key] = { k: _key, v: isBoolean }, _map); + binaryOpPredicates = (_map$1 = new $Map(), _key$1 = 12, _map$1[_key$1] = { k: _key$1, v: (function(typ) { + return isNumeric(typ) || isString(typ); + }) }, _key$1 = 13, _map$1[_key$1] = { k: _key$1, v: isNumeric }, _key$1 = 14, _map$1[_key$1] = { k: _key$1, v: isNumeric }, _key$1 = 15, _map$1[_key$1] = { k: _key$1, v: isNumeric }, _key$1 = 16, _map$1[_key$1] = { k: _key$1, v: isInteger }, _key$1 = 17, _map$1[_key$1] = { k: _key$1, v: isInteger }, _key$1 = 18, _map$1[_key$1] = { k: _key$1, v: isInteger }, _key$1 = 19, _map$1[_key$1] = { k: _key$1, v: isInteger }, _key$1 = 22, _map$1[_key$1] = { k: _key$1, v: isInteger }, _key$1 = 34, _map$1[_key$1] = { k: _key$1, v: isBoolean }, _key$1 = 35, _map$1[_key$1] = { k: _key$1, v: isBoolean }, _map$1); + $pkg.Typ = $toNativeArray("Ptr", [new Basic.Ptr(0, 0, "invalid type"), new Basic.Ptr(1, 1, "bool"), new Basic.Ptr(2, 2, "int"), new Basic.Ptr(3, 2, "int8"), new Basic.Ptr(4, 2, "int16"), new Basic.Ptr(5, 2, "int32"), new Basic.Ptr(6, 2, "int64"), new Basic.Ptr(7, 6, "uint"), new Basic.Ptr(8, 6, "uint8"), new Basic.Ptr(9, 6, "uint16"), new Basic.Ptr(10, 6, "uint32"), new Basic.Ptr(11, 6, "uint64"), new Basic.Ptr(12, 6, "uintptr"), new Basic.Ptr(13, 8, "float32"), new Basic.Ptr(14, 8, "float64"), new Basic.Ptr(15, 16, "complex64"), new Basic.Ptr(16, 16, "complex128"), new Basic.Ptr(17, 32, "string"), new Basic.Ptr(18, 0, "Pointer"), new Basic.Ptr(19, 65, "untyped bool"), new Basic.Ptr(20, 66, "untyped int"), new Basic.Ptr(21, 66, "untyped rune"), new Basic.Ptr(22, 72, "untyped float"), new Basic.Ptr(23, 80, "untyped complex"), new Basic.Ptr(24, 96, "untyped string"), new Basic.Ptr(25, 64, "untyped nil")]); + aliases = $toNativeArray("Ptr", [new Basic.Ptr(8, 6, "byte"), new Basic.Ptr(5, 2, "rune")]); + predeclaredConsts = $toNativeArray("Struct", [new ($structType([["name", "name", "code.google.com/p/go.tools/go/types", $String, ""], ["kind", "kind", "code.google.com/p/go.tools/go/types", BasicKind, ""], ["val", "val", "code.google.com/p/go.tools/go/types", exact.Value, ""]])).Ptr("true", 19, exact.MakeBool(true)), new ($structType([["name", "name", "code.google.com/p/go.tools/go/types", $String, ""], ["kind", "kind", "code.google.com/p/go.tools/go/types", BasicKind, ""], ["val", "val", "code.google.com/p/go.tools/go/types", exact.Value, ""]])).Ptr("false", 19, exact.MakeBool(false)), new ($structType([["name", "name", "code.google.com/p/go.tools/go/types", $String, ""], ["kind", "kind", "code.google.com/p/go.tools/go/types", BasicKind, ""], ["val", "val", "code.google.com/p/go.tools/go/types", exact.Value, ""]])).Ptr("iota", 20, exact.MakeInt64(new $Int64(0, 0)))]); + predeclaredFuncs = $toNativeArray("Struct", [new ($structType([["name", "name", "code.google.com/p/go.tools/go/types", $String, ""], ["nargs", "nargs", "code.google.com/p/go.tools/go/types", $Int, ""], ["variadic", "variadic", "code.google.com/p/go.tools/go/types", $Bool, ""], ["kind", "kind", "code.google.com/p/go.tools/go/types", exprKind, ""]])).Ptr("append", 1, true, 1), new ($structType([["name", "name", "code.google.com/p/go.tools/go/types", $String, ""], ["nargs", "nargs", "code.google.com/p/go.tools/go/types", $Int, ""], ["variadic", "variadic", "code.google.com/p/go.tools/go/types", $Bool, ""], ["kind", "kind", "code.google.com/p/go.tools/go/types", exprKind, ""]])).Ptr("cap", 1, false, 1), new ($structType([["name", "name", "code.google.com/p/go.tools/go/types", $String, ""], ["nargs", "nargs", "code.google.com/p/go.tools/go/types", $Int, ""], ["variadic", "variadic", "code.google.com/p/go.tools/go/types", $Bool, ""], ["kind", "kind", "code.google.com/p/go.tools/go/types", exprKind, ""]])).Ptr("close", 1, false, 2), new ($structType([["name", "name", "code.google.com/p/go.tools/go/types", $String, ""], ["nargs", "nargs", "code.google.com/p/go.tools/go/types", $Int, ""], ["variadic", "variadic", "code.google.com/p/go.tools/go/types", $Bool, ""], ["kind", "kind", "code.google.com/p/go.tools/go/types", exprKind, ""]])).Ptr("complex", 2, false, 1), new ($structType([["name", "name", "code.google.com/p/go.tools/go/types", $String, ""], ["nargs", "nargs", "code.google.com/p/go.tools/go/types", $Int, ""], ["variadic", "variadic", "code.google.com/p/go.tools/go/types", $Bool, ""], ["kind", "kind", "code.google.com/p/go.tools/go/types", exprKind, ""]])).Ptr("copy", 2, false, 2), new ($structType([["name", "name", "code.google.com/p/go.tools/go/types", $String, ""], ["nargs", "nargs", "code.google.com/p/go.tools/go/types", $Int, ""], ["variadic", "variadic", "code.google.com/p/go.tools/go/types", $Bool, ""], ["kind", "kind", "code.google.com/p/go.tools/go/types", exprKind, ""]])).Ptr("delete", 2, false, 2), new ($structType([["name", "name", "code.google.com/p/go.tools/go/types", $String, ""], ["nargs", "nargs", "code.google.com/p/go.tools/go/types", $Int, ""], ["variadic", "variadic", "code.google.com/p/go.tools/go/types", $Bool, ""], ["kind", "kind", "code.google.com/p/go.tools/go/types", exprKind, ""]])).Ptr("imag", 1, false, 1), new ($structType([["name", "name", "code.google.com/p/go.tools/go/types", $String, ""], ["nargs", "nargs", "code.google.com/p/go.tools/go/types", $Int, ""], ["variadic", "variadic", "code.google.com/p/go.tools/go/types", $Bool, ""], ["kind", "kind", "code.google.com/p/go.tools/go/types", exprKind, ""]])).Ptr("len", 1, false, 1), new ($structType([["name", "name", "code.google.com/p/go.tools/go/types", $String, ""], ["nargs", "nargs", "code.google.com/p/go.tools/go/types", $Int, ""], ["variadic", "variadic", "code.google.com/p/go.tools/go/types", $Bool, ""], ["kind", "kind", "code.google.com/p/go.tools/go/types", exprKind, ""]])).Ptr("make", 1, true, 1), new ($structType([["name", "name", "code.google.com/p/go.tools/go/types", $String, ""], ["nargs", "nargs", "code.google.com/p/go.tools/go/types", $Int, ""], ["variadic", "variadic", "code.google.com/p/go.tools/go/types", $Bool, ""], ["kind", "kind", "code.google.com/p/go.tools/go/types", exprKind, ""]])).Ptr("new", 1, false, 1), new ($structType([["name", "name", "code.google.com/p/go.tools/go/types", $String, ""], ["nargs", "nargs", "code.google.com/p/go.tools/go/types", $Int, ""], ["variadic", "variadic", "code.google.com/p/go.tools/go/types", $Bool, ""], ["kind", "kind", "code.google.com/p/go.tools/go/types", exprKind, ""]])).Ptr("panic", 1, false, 2), new ($structType([["name", "name", "code.google.com/p/go.tools/go/types", $String, ""], ["nargs", "nargs", "code.google.com/p/go.tools/go/types", $Int, ""], ["variadic", "variadic", "code.google.com/p/go.tools/go/types", $Bool, ""], ["kind", "kind", "code.google.com/p/go.tools/go/types", exprKind, ""]])).Ptr("print", 0, true, 2), new ($structType([["name", "name", "code.google.com/p/go.tools/go/types", $String, ""], ["nargs", "nargs", "code.google.com/p/go.tools/go/types", $Int, ""], ["variadic", "variadic", "code.google.com/p/go.tools/go/types", $Bool, ""], ["kind", "kind", "code.google.com/p/go.tools/go/types", exprKind, ""]])).Ptr("println", 0, true, 2), new ($structType([["name", "name", "code.google.com/p/go.tools/go/types", $String, ""], ["nargs", "nargs", "code.google.com/p/go.tools/go/types", $Int, ""], ["variadic", "variadic", "code.google.com/p/go.tools/go/types", $Bool, ""], ["kind", "kind", "code.google.com/p/go.tools/go/types", exprKind, ""]])).Ptr("real", 1, false, 1), new ($structType([["name", "name", "code.google.com/p/go.tools/go/types", $String, ""], ["nargs", "nargs", "code.google.com/p/go.tools/go/types", $Int, ""], ["variadic", "variadic", "code.google.com/p/go.tools/go/types", $Bool, ""], ["kind", "kind", "code.google.com/p/go.tools/go/types", exprKind, ""]])).Ptr("recover", 0, false, 2), new ($structType([["name", "name", "code.google.com/p/go.tools/go/types", $String, ""], ["nargs", "nargs", "code.google.com/p/go.tools/go/types", $Int, ""], ["variadic", "variadic", "code.google.com/p/go.tools/go/types", $Bool, ""], ["kind", "kind", "code.google.com/p/go.tools/go/types", exprKind, ""]])).Ptr("Alignof", 1, false, 1), new ($structType([["name", "name", "code.google.com/p/go.tools/go/types", $String, ""], ["nargs", "nargs", "code.google.com/p/go.tools/go/types", $Int, ""], ["variadic", "variadic", "code.google.com/p/go.tools/go/types", $Bool, ""], ["kind", "kind", "code.google.com/p/go.tools/go/types", exprKind, ""]])).Ptr("Offsetof", 1, false, 1), new ($structType([["name", "name", "code.google.com/p/go.tools/go/types", $String, ""], ["nargs", "nargs", "code.google.com/p/go.tools/go/types", $Int, ""], ["variadic", "variadic", "code.google.com/p/go.tools/go/types", $Bool, ""], ["kind", "kind", "code.google.com/p/go.tools/go/types", exprKind, ""]])).Ptr("Sizeof", 1, false, 1), new ($structType([["name", "name", "code.google.com/p/go.tools/go/types", $String, ""], ["nargs", "nargs", "code.google.com/p/go.tools/go/types", $Int, ""], ["variadic", "variadic", "code.google.com/p/go.tools/go/types", $Bool, ""], ["kind", "kind", "code.google.com/p/go.tools/go/types", exprKind, ""]])).Ptr("assert", 1, false, 2), new ($structType([["name", "name", "code.google.com/p/go.tools/go/types", $String, ""], ["nargs", "nargs", "code.google.com/p/go.tools/go/types", $Int, ""], ["variadic", "variadic", "code.google.com/p/go.tools/go/types", $Bool, ""], ["kind", "kind", "code.google.com/p/go.tools/go/types", exprKind, ""]])).Ptr("trace", 0, true, 2)]); + init(); }; - inputString.prototype.canCheckPrefix = function() { return this.$val.canCheckPrefix(); }; - inputString.Ptr.prototype.hasPrefix = function(re) { - var i; - i = this; - return strings.HasPrefix(i.str, re.prefix); + return $pkg; +})(); +$packages["regexp/syntax"] = (function() { + var $pkg = {}, unicode = $packages["unicode"], sort = $packages["sort"], strings = $packages["strings"], utf8 = $packages["unicode/utf8"], bytes = $packages["bytes"], strconv = $packages["strconv"], patchList, frag, compiler, Error, ErrorCode, Flags, parser, charGroup, ranges, Prog, InstOp, EmptyOp, Inst, Regexp, Op, anyRuneNotNL, anyRune, anyTable, code1, code2, code3, perlGroup, code4, code5, code6, code7, code8, code9, code10, code11, code12, code13, code14, code15, code16, code17, posixGroup, instOpNames, _map, _key, _map$1, _key$1, Compile, minFoldRune, cleanAlt, literalRegexp, Parse, isValidCaptureName, isCharClass, matchRune, mergeCharClass, unicodeTable, cleanClass, appendLiteral, appendRange, appendFoldedRange, appendClass, appendFoldedClass, appendNegatedClass, appendTable, appendNegatedTable, negateClass, checkUTF8, nextRune, isalnum, unhex, EmptyOpContext, IsWordChar, wordRune, bw, dumpProg, u32, dumpInst, writeRegexp, escape, simplify1; + patchList = $pkg.patchList = $newType(4, "Uint32", "syntax.patchList", "patchList", "regexp/syntax", null); + frag = $pkg.frag = $newType(0, "Struct", "syntax.frag", "frag", "regexp/syntax", function(i_, out_) { + this.$val = this; + this.i = i_ !== undefined ? i_ : 0; + this.out = out_ !== undefined ? out_ : 0; + }); + compiler = $pkg.compiler = $newType(0, "Struct", "syntax.compiler", "compiler", "regexp/syntax", function(p_) { + this.$val = this; + this.p = p_ !== undefined ? p_ : ($ptrType(Prog)).nil; + }); + Error = $pkg.Error = $newType(0, "Struct", "syntax.Error", "Error", "regexp/syntax", function(Code_, Expr_) { + this.$val = this; + this.Code = Code_ !== undefined ? Code_ : ""; + this.Expr = Expr_ !== undefined ? Expr_ : ""; + }); + ErrorCode = $pkg.ErrorCode = $newType(8, "String", "syntax.ErrorCode", "ErrorCode", "regexp/syntax", null); + Flags = $pkg.Flags = $newType(2, "Uint16", "syntax.Flags", "Flags", "regexp/syntax", null); + parser = $pkg.parser = $newType(0, "Struct", "syntax.parser", "parser", "regexp/syntax", function(flags_, stack_, free_, numCap_, wholeRegexp_, tmpClass_) { + this.$val = this; + this.flags = flags_ !== undefined ? flags_ : 0; + this.stack = stack_ !== undefined ? stack_ : ($sliceType(($ptrType(Regexp)))).nil; + this.free = free_ !== undefined ? free_ : ($ptrType(Regexp)).nil; + this.numCap = numCap_ !== undefined ? numCap_ : 0; + this.wholeRegexp = wholeRegexp_ !== undefined ? wholeRegexp_ : ""; + this.tmpClass = tmpClass_ !== undefined ? tmpClass_ : ($sliceType($Int32)).nil; + }); + charGroup = $pkg.charGroup = $newType(0, "Struct", "syntax.charGroup", "charGroup", "regexp/syntax", function(sign_, class$1_) { + this.$val = this; + this.sign = sign_ !== undefined ? sign_ : 0; + this.class$1 = class$1_ !== undefined ? class$1_ : ($sliceType($Int32)).nil; + }); + ranges = $pkg.ranges = $newType(0, "Struct", "syntax.ranges", "ranges", "regexp/syntax", function(p_) { + this.$val = this; + this.p = p_ !== undefined ? p_ : ($ptrType(($sliceType($Int32)))).nil; + }); + Prog = $pkg.Prog = $newType(0, "Struct", "syntax.Prog", "Prog", "regexp/syntax", function(Inst_, Start_, NumCap_) { + this.$val = this; + this.Inst = Inst_ !== undefined ? Inst_ : ($sliceType(Inst)).nil; + this.Start = Start_ !== undefined ? Start_ : 0; + this.NumCap = NumCap_ !== undefined ? NumCap_ : 0; + }); + InstOp = $pkg.InstOp = $newType(1, "Uint8", "syntax.InstOp", "InstOp", "regexp/syntax", null); + EmptyOp = $pkg.EmptyOp = $newType(1, "Uint8", "syntax.EmptyOp", "EmptyOp", "regexp/syntax", null); + Inst = $pkg.Inst = $newType(0, "Struct", "syntax.Inst", "Inst", "regexp/syntax", function(Op_, Out_, Arg_, Rune_) { + this.$val = this; + this.Op = Op_ !== undefined ? Op_ : 0; + this.Out = Out_ !== undefined ? Out_ : 0; + this.Arg = Arg_ !== undefined ? Arg_ : 0; + this.Rune = Rune_ !== undefined ? Rune_ : ($sliceType($Int32)).nil; + }); + Regexp = $pkg.Regexp = $newType(0, "Struct", "syntax.Regexp", "Regexp", "regexp/syntax", function(Op_, Flags_, Sub_, Sub0_, Rune_, Rune0_, Min_, Max_, Cap_, Name_) { + this.$val = this; + this.Op = Op_ !== undefined ? Op_ : 0; + this.Flags = Flags_ !== undefined ? Flags_ : 0; + this.Sub = Sub_ !== undefined ? Sub_ : ($sliceType(($ptrType(Regexp)))).nil; + this.Sub0 = Sub0_ !== undefined ? Sub0_ : ($arrayType(($ptrType(Regexp)), 1)).zero(); + this.Rune = Rune_ !== undefined ? Rune_ : ($sliceType($Int32)).nil; + this.Rune0 = Rune0_ !== undefined ? Rune0_ : ($arrayType($Int32, 2)).zero(); + this.Min = Min_ !== undefined ? Min_ : 0; + this.Max = Max_ !== undefined ? Max_ : 0; + this.Cap = Cap_ !== undefined ? Cap_ : 0; + this.Name = Name_ !== undefined ? Name_ : ""; + }); + Op = $pkg.Op = $newType(1, "Uint8", "syntax.Op", "Op", "regexp/syntax", null); + patchList.prototype.next = function(p) { + var l, x, x$1, i; + l = this.$val !== undefined ? this.$val : this; + i = (x = p.Inst, x$1 = l >>> 1 >>> 0, ((x$1 < 0 || x$1 >= x.$length) ? $throwRuntimeError("index out of range") : x.$array[x.$offset + x$1])); + if (((l & 1) >>> 0) === 0) { + return (i.Out >>> 0); + } + return (i.Arg >>> 0); }; - inputString.prototype.hasPrefix = function(re) { return this.$val.hasPrefix(re); }; - inputString.Ptr.prototype.index = function(re, pos) { - var i; - i = this; - return strings.Index(i.str.substring(pos), re.prefix); + $ptrType(patchList).prototype.next = function(p) { return new patchList(this.$get()).next(p); }; + patchList.prototype.patch = function(p, val) { + var l, x, x$1, i; + l = this.$val !== undefined ? this.$val : this; + while (!((l === 0))) { + i = (x = p.Inst, x$1 = l >>> 1 >>> 0, ((x$1 < 0 || x$1 >= x.$length) ? $throwRuntimeError("index out of range") : x.$array[x.$offset + x$1])); + if (((l & 1) >>> 0) === 0) { + l = (i.Out >>> 0); + i.Out = val; + } else { + l = (i.Arg >>> 0); + i.Arg = val; + } + } }; - inputString.prototype.index = function(re, pos) { return this.$val.index(re, pos); }; - inputString.Ptr.prototype.context = function(pos) { - var i, _tmp, _tmp$1, r1, r2, _tuple, _tuple$1; - i = this; - _tmp = -1; _tmp$1 = -1; r1 = _tmp; r2 = _tmp$1; - if (pos > 0 && pos <= i.str.length) { - _tuple = utf8.DecodeLastRuneInString(i.str.substring(0, pos)); r1 = _tuple[0]; + $ptrType(patchList).prototype.patch = function(p, val) { return new patchList(this.$get()).patch(p, val); }; + patchList.prototype.append = function(p, l2) { + var l1, last, next, x, x$1, i; + l1 = this.$val !== undefined ? this.$val : this; + if (l1 === 0) { + return l2; + } + if (l2 === 0) { + return l1; + } + last = l1; + while (true) { + next = (new patchList(last)).next(p); + if (next === 0) { + break; + } + last = next; } - if (pos < i.str.length) { - _tuple$1 = utf8.DecodeRuneInString(i.str.substring(pos)); r2 = _tuple$1[0]; + i = (x = p.Inst, x$1 = last >>> 1 >>> 0, ((x$1 < 0 || x$1 >= x.$length) ? $throwRuntimeError("index out of range") : x.$array[x.$offset + x$1])); + if (((last & 1) >>> 0) === 0) { + i.Out = (l2 >>> 0); + } else { + i.Arg = (l2 >>> 0); } - return syntax.EmptyOpContext(r1, r2); + return l1; }; - inputString.prototype.context = function(pos) { return this.$val.context(pos); }; - inputBytes.Ptr.prototype.step = function(pos) { - var i, x, c; - i = this; - if (pos < i.str.$length) { - c = (x = i.str, ((pos < 0 || pos >= x.$length) ? $throwRuntimeError("index out of range") : x.$array[x.$offset + pos])); - if (c < 128) { - return [(c >> 0), 1]; + $ptrType(patchList).prototype.append = function(p, l2) { return new patchList(this.$get()).append(p, l2); }; + Compile = $pkg.Compile = function(re) { + var c, f; + c = new compiler.Ptr(); $copy(c, new compiler.Ptr(), compiler); + c.init(); + f = new frag.Ptr(); $copy(f, c.compile(re), frag); + (new patchList(f.out)).patch(c.p, c.inst(4).i); + c.p.Start = (f.i >> 0); + return [c.p, $ifaceNil]; + }; + compiler.Ptr.prototype.init = function() { + var c; + c = this; + c.p = new Prog.Ptr(); + c.p.NumCap = 2; + c.inst(5); + }; + compiler.prototype.init = function() { return this.$val.init(); }; + compiler.Ptr.prototype.compile = function(re) { + var c, _ref, f, _ref$1, _i, j, f1, bra, x, sub, ket, x$1, x$2, x$3, f$1, _ref$2, _i$1, i, sub$1, f$2, _ref$3, _i$2, sub$2; + c = this; + _ref = re.Op; + if (_ref === 1) { + return c.fail(); + } else if (_ref === 2) { + return c.nop(); + } else if (_ref === 3) { + if (re.Rune.$length === 0) { + return c.nop(); } - return utf8.DecodeRune($subslice(i.str, pos)); + f = new frag.Ptr(); $copy(f, new frag.Ptr(), frag); + _ref$1 = re.Rune; + _i = 0; + while (_i < _ref$1.$length) { + j = _i; + f1 = new frag.Ptr(); $copy(f1, c.rune($subslice(re.Rune, j, (j + 1 >> 0)), re.Flags), frag); + if (j === 0) { + $copy(f, f1, frag); + } else { + $copy(f, c.cat($clone(f, frag), $clone(f1, frag)), frag); + } + _i++; + } + return f; + } else if (_ref === 4) { + return c.rune(re.Rune, re.Flags); + } else if (_ref === 5) { + return c.rune(anyRuneNotNL, 0); + } else if (_ref === 6) { + return c.rune(anyRune, 0); + } else if (_ref === 7) { + return c.empty(1); + } else if (_ref === 8) { + return c.empty(2); + } else if (_ref === 9) { + return c.empty(4); + } else if (_ref === 10) { + return c.empty(8); + } else if (_ref === 11) { + return c.empty(16); + } else if (_ref === 12) { + return c.empty(32); + } else if (_ref === 13) { + bra = new frag.Ptr(); $copy(bra, c.cap(((re.Cap << 1 >> 0) >>> 0)), frag); + sub = new frag.Ptr(); $copy(sub, c.compile((x = re.Sub, ((0 < 0 || 0 >= x.$length) ? $throwRuntimeError("index out of range") : x.$array[x.$offset + 0]))), frag); + ket = new frag.Ptr(); $copy(ket, c.cap((((re.Cap << 1 >> 0) | 1) >>> 0)), frag); + return c.cat($clone(c.cat($clone(bra, frag), $clone(sub, frag)), frag), $clone(ket, frag)); + } else if (_ref === 14) { + return c.star($clone(c.compile((x$1 = re.Sub, ((0 < 0 || 0 >= x$1.$length) ? $throwRuntimeError("index out of range") : x$1.$array[x$1.$offset + 0]))), frag), !((((re.Flags & 32) >>> 0) === 0))); + } else if (_ref === 15) { + return c.plus($clone(c.compile((x$2 = re.Sub, ((0 < 0 || 0 >= x$2.$length) ? $throwRuntimeError("index out of range") : x$2.$array[x$2.$offset + 0]))), frag), !((((re.Flags & 32) >>> 0) === 0))); + } else if (_ref === 16) { + return c.quest($clone(c.compile((x$3 = re.Sub, ((0 < 0 || 0 >= x$3.$length) ? $throwRuntimeError("index out of range") : x$3.$array[x$3.$offset + 0]))), frag), !((((re.Flags & 32) >>> 0) === 0))); + } else if (_ref === 18) { + if (re.Sub.$length === 0) { + return c.nop(); + } + f$1 = new frag.Ptr(); $copy(f$1, new frag.Ptr(), frag); + _ref$2 = re.Sub; + _i$1 = 0; + while (_i$1 < _ref$2.$length) { + i = _i$1; + sub$1 = ((_i$1 < 0 || _i$1 >= _ref$2.$length) ? $throwRuntimeError("index out of range") : _ref$2.$array[_ref$2.$offset + _i$1]); + if (i === 0) { + $copy(f$1, c.compile(sub$1), frag); + } else { + $copy(f$1, c.cat($clone(f$1, frag), $clone(c.compile(sub$1), frag)), frag); + } + _i$1++; + } + return f$1; + } else if (_ref === 19) { + f$2 = new frag.Ptr(); $copy(f$2, new frag.Ptr(), frag); + _ref$3 = re.Sub; + _i$2 = 0; + while (_i$2 < _ref$3.$length) { + sub$2 = ((_i$2 < 0 || _i$2 >= _ref$3.$length) ? $throwRuntimeError("index out of range") : _ref$3.$array[_ref$3.$offset + _i$2]); + $copy(f$2, c.alt($clone(f$2, frag), $clone(c.compile(sub$2), frag)), frag); + _i$2++; + } + return f$2; } - return [-1, 0]; + $panic(new $String("regexp: unhandled case in compile")); }; - inputBytes.prototype.step = function(pos) { return this.$val.step(pos); }; - inputBytes.Ptr.prototype.canCheckPrefix = function() { - var i; - i = this; - return true; + compiler.prototype.compile = function(re) { return this.$val.compile(re); }; + compiler.Ptr.prototype.inst = function(op) { + var c, f; + c = this; + f = new frag.Ptr((c.p.Inst.$length >>> 0), 0); + c.p.Inst = $append(c.p.Inst, new Inst.Ptr(op, 0, 0, ($sliceType($Int32)).nil)); + return f; }; - inputBytes.prototype.canCheckPrefix = function() { return this.$val.canCheckPrefix(); }; - inputBytes.Ptr.prototype.hasPrefix = function(re) { - var i; - i = this; - return bytes.HasPrefix(i.str, re.prefixBytes); + compiler.prototype.inst = function(op) { return this.$val.inst(op); }; + compiler.Ptr.prototype.nop = function() { + var c, f; + c = this; + f = new frag.Ptr(); $copy(f, c.inst(6), frag); + f.out = ((f.i << 1 >>> 0) >>> 0); + return f; }; - inputBytes.prototype.hasPrefix = function(re) { return this.$val.hasPrefix(re); }; - inputBytes.Ptr.prototype.index = function(re, pos) { - var i; - i = this; - return bytes.Index($subslice(i.str, pos), re.prefixBytes); + compiler.prototype.nop = function() { return this.$val.nop(); }; + compiler.Ptr.prototype.fail = function() { + var c; + c = this; + return new frag.Ptr(0, 0); }; - inputBytes.prototype.index = function(re, pos) { return this.$val.index(re, pos); }; - inputBytes.Ptr.prototype.context = function(pos) { - var i, _tmp, _tmp$1, r1, r2, _tuple, _tuple$1; - i = this; - _tmp = -1; _tmp$1 = -1; r1 = _tmp; r2 = _tmp$1; - if (pos > 0 && pos <= i.str.$length) { - _tuple = utf8.DecodeLastRune($subslice(i.str, 0, pos)); r1 = _tuple[0]; + compiler.prototype.fail = function() { return this.$val.fail(); }; + compiler.Ptr.prototype.cap = function(arg) { + var c, f, x, x$1; + c = this; + f = new frag.Ptr(); $copy(f, c.inst(2), frag); + f.out = ((f.i << 1 >>> 0) >>> 0); + (x = c.p.Inst, x$1 = f.i, ((x$1 < 0 || x$1 >= x.$length) ? $throwRuntimeError("index out of range") : x.$array[x.$offset + x$1])).Arg = arg; + if (c.p.NumCap < ((arg >> 0) + 1 >> 0)) { + c.p.NumCap = (arg >> 0) + 1 >> 0; } - if (pos < i.str.$length) { - _tuple$1 = utf8.DecodeRune($subslice(i.str, pos)); r2 = _tuple$1[0]; + return f; + }; + compiler.prototype.cap = function(arg) { return this.$val.cap(arg); }; + compiler.Ptr.prototype.cat = function(f1, f2) { + var c; + c = this; + if ((f1.i === 0) || (f2.i === 0)) { + return new frag.Ptr(0, 0); } - return syntax.EmptyOpContext(r1, r2); + (new patchList(f1.out)).patch(c.p, f2.i); + return new frag.Ptr(f1.i, f2.out); }; - inputBytes.prototype.context = function(pos) { return this.$val.context(pos); }; - inputReader.Ptr.prototype.step = function(pos) { - var i, _tuple, r, w, err; - i = this; - if (!i.atEOT && !((pos === i.pos))) { - return [-1, 0]; + compiler.prototype.cat = function(f1, f2) { return this.$val.cat(f1, f2); }; + compiler.Ptr.prototype.alt = function(f1, f2) { + var c, f, x, x$1, i; + c = this; + if (f1.i === 0) { + return f2; } - _tuple = i.r.ReadRune(); r = _tuple[0]; w = _tuple[1]; err = _tuple[2]; - if (!($interfaceIsEqual(err, $ifaceNil))) { - i.atEOT = true; - return [-1, 0]; + if (f2.i === 0) { + return f1; } - i.pos = i.pos + (w) >> 0; - return [r, w]; - }; - inputReader.prototype.step = function(pos) { return this.$val.step(pos); }; - inputReader.Ptr.prototype.canCheckPrefix = function() { - var i; - i = this; - return false; - }; - inputReader.prototype.canCheckPrefix = function() { return this.$val.canCheckPrefix(); }; - inputReader.Ptr.prototype.hasPrefix = function(re) { - var i; - i = this; - return false; - }; - inputReader.prototype.hasPrefix = function(re) { return this.$val.hasPrefix(re); }; - inputReader.Ptr.prototype.index = function(re, pos) { - var i; - i = this; - return -1; - }; - inputReader.prototype.index = function(re, pos) { return this.$val.index(re, pos); }; - inputReader.Ptr.prototype.context = function(pos) { - var i; - i = this; - return 0; + f = new frag.Ptr(); $copy(f, c.inst(0), frag); + i = (x = c.p.Inst, x$1 = f.i, ((x$1 < 0 || x$1 >= x.$length) ? $throwRuntimeError("index out of range") : x.$array[x.$offset + x$1])); + i.Out = f1.i; + i.Arg = f2.i; + f.out = (new patchList(f1.out)).append(c.p, f2.out); + return f; }; - inputReader.prototype.context = function(pos) { return this.$val.context(pos); }; - Regexp.Ptr.prototype.LiteralPrefix = function() { - var prefix = "", complete = false, re, _tmp, _tmp$1; - re = this; - _tmp = re.prefix; _tmp$1 = re.prefixComplete; prefix = _tmp; complete = _tmp$1; - return [prefix, complete]; + compiler.prototype.alt = function(f1, f2) { return this.$val.alt(f1, f2); }; + compiler.Ptr.prototype.quest = function(f1, nongreedy) { + var c, f, x, x$1, i; + c = this; + f = new frag.Ptr(); $copy(f, c.inst(0), frag); + i = (x = c.p.Inst, x$1 = f.i, ((x$1 < 0 || x$1 >= x.$length) ? $throwRuntimeError("index out of range") : x.$array[x.$offset + x$1])); + if (nongreedy) { + i.Arg = f1.i; + f.out = ((f.i << 1 >>> 0) >>> 0); + } else { + i.Out = f1.i; + f.out = ((((f.i << 1 >>> 0) | 1) >>> 0) >>> 0); + } + f.out = (new patchList(f.out)).append(c.p, f1.out); + return f; }; - Regexp.prototype.LiteralPrefix = function() { return this.$val.LiteralPrefix(); }; - Regexp.Ptr.prototype.MatchReader = function(r) { - var re; - re = this; - return !(re.doExecute(r, ($sliceType($Uint8)).nil, "", 0, 0) === ($sliceType($Int)).nil); + compiler.prototype.quest = function(f1, nongreedy) { return this.$val.quest(f1, nongreedy); }; + compiler.Ptr.prototype.star = function(f1, nongreedy) { + var c, f, x, x$1, i; + c = this; + f = new frag.Ptr(); $copy(f, c.inst(0), frag); + i = (x = c.p.Inst, x$1 = f.i, ((x$1 < 0 || x$1 >= x.$length) ? $throwRuntimeError("index out of range") : x.$array[x.$offset + x$1])); + if (nongreedy) { + i.Arg = f1.i; + f.out = ((f.i << 1 >>> 0) >>> 0); + } else { + i.Out = f1.i; + f.out = ((((f.i << 1 >>> 0) | 1) >>> 0) >>> 0); + } + (new patchList(f1.out)).patch(c.p, f.i); + return f; }; - Regexp.prototype.MatchReader = function(r) { return this.$val.MatchReader(r); }; - Regexp.Ptr.prototype.MatchString = function(s) { - var re; - re = this; - return !(re.doExecute($ifaceNil, ($sliceType($Uint8)).nil, s, 0, 0) === ($sliceType($Int)).nil); + compiler.prototype.star = function(f1, nongreedy) { return this.$val.star(f1, nongreedy); }; + compiler.Ptr.prototype.plus = function(f1, nongreedy) { + var c; + c = this; + return new frag.Ptr(f1.i, c.star($clone(f1, frag), nongreedy).out); }; - Regexp.prototype.MatchString = function(s) { return this.$val.MatchString(s); }; - Regexp.Ptr.prototype.Match = function(b) { - var re; - re = this; - return !(re.doExecute($ifaceNil, b, "", 0, 0) === ($sliceType($Int)).nil); + compiler.prototype.plus = function(f1, nongreedy) { return this.$val.plus(f1, nongreedy); }; + compiler.Ptr.prototype.empty = function(op) { + var c, f, x, x$1; + c = this; + f = new frag.Ptr(); $copy(f, c.inst(3), frag); + (x = c.p.Inst, x$1 = f.i, ((x$1 < 0 || x$1 >= x.$length) ? $throwRuntimeError("index out of range") : x.$array[x.$offset + x$1])).Arg = (op >>> 0); + f.out = ((f.i << 1 >>> 0) >>> 0); + return f; }; - Regexp.prototype.Match = function(b) { return this.$val.Match(b); }; - Regexp.Ptr.prototype.ReplaceAllString = function(src, repl) { - var re, n, x, b; - re = this; - n = 2; - if (strings.Index(repl, "$") >= 0) { - n = (x = (re.numSubexp + 1 >> 0), (((2 >>> 16 << 16) * x >> 0) + (2 << 16 >>> 16) * x) >> 0); + compiler.prototype.empty = function(op) { return this.$val.empty(op); }; + compiler.Ptr.prototype.rune = function(r, flags) { + var c, f, x, x$1, i; + c = this; + f = new frag.Ptr(); $copy(f, c.inst(7), frag); + i = (x = c.p.Inst, x$1 = f.i, ((x$1 < 0 || x$1 >= x.$length) ? $throwRuntimeError("index out of range") : x.$array[x.$offset + x$1])); + i.Rune = r; + flags = (flags & (1)) >>> 0; + if (!((r.$length === 1)) || (unicode.SimpleFold(((0 < 0 || 0 >= r.$length) ? $throwRuntimeError("index out of range") : r.$array[r.$offset + 0])) === ((0 < 0 || 0 >= r.$length) ? $throwRuntimeError("index out of range") : r.$array[r.$offset + 0]))) { + flags = flags & ~(1); } - b = re.replaceAll(($sliceType($Uint8)).nil, src, n, (function(dst, match) { - return re.expand(dst, repl, ($sliceType($Uint8)).nil, src, match); - })); - return $bytesToString(b); + i.Arg = (flags >>> 0); + f.out = ((f.i << 1 >>> 0) >>> 0); + if ((((flags & 1) >>> 0) === 0) && ((r.$length === 1) || (r.$length === 2) && (((0 < 0 || 0 >= r.$length) ? $throwRuntimeError("index out of range") : r.$array[r.$offset + 0]) === ((1 < 0 || 1 >= r.$length) ? $throwRuntimeError("index out of range") : r.$array[r.$offset + 1])))) { + i.Op = 8; + } else if ((r.$length === 2) && (((0 < 0 || 0 >= r.$length) ? $throwRuntimeError("index out of range") : r.$array[r.$offset + 0]) === 0) && (((1 < 0 || 1 >= r.$length) ? $throwRuntimeError("index out of range") : r.$array[r.$offset + 1]) === 1114111)) { + i.Op = 9; + } else if ((r.$length === 4) && (((0 < 0 || 0 >= r.$length) ? $throwRuntimeError("index out of range") : r.$array[r.$offset + 0]) === 0) && (((1 < 0 || 1 >= r.$length) ? $throwRuntimeError("index out of range") : r.$array[r.$offset + 1]) === 9) && (((2 < 0 || 2 >= r.$length) ? $throwRuntimeError("index out of range") : r.$array[r.$offset + 2]) === 11) && (((3 < 0 || 3 >= r.$length) ? $throwRuntimeError("index out of range") : r.$array[r.$offset + 3]) === 1114111)) { + i.Op = 10; + } + return f; }; - Regexp.prototype.ReplaceAllString = function(src, repl) { return this.$val.ReplaceAllString(src, repl); }; - Regexp.Ptr.prototype.ReplaceAllLiteralString = function(src, repl) { - var re; - re = this; - return $bytesToString(re.replaceAll(($sliceType($Uint8)).nil, src, 2, (function(dst, match) { - return $appendSlice(dst, new ($sliceType($Uint8))($stringToBytes(repl))); - }))); + compiler.prototype.rune = function(r, flags) { return this.$val.rune(r, flags); }; + Error.Ptr.prototype.Error = function() { + var e; + e = this; + return "error parsing regexp: " + (new ErrorCode(e.Code)).String() + ": `" + e.Expr + "`"; }; - Regexp.prototype.ReplaceAllLiteralString = function(src, repl) { return this.$val.ReplaceAllLiteralString(src, repl); }; - Regexp.Ptr.prototype.ReplaceAllStringFunc = function(src, repl) { - var re, b; - re = this; - b = re.replaceAll(($sliceType($Uint8)).nil, src, 2, (function(dst, match) { - return $appendSlice(dst, new ($sliceType($Uint8))($stringToBytes(repl(src.substring(((0 < 0 || 0 >= match.$length) ? $throwRuntimeError("index out of range") : match.$array[match.$offset + 0]), ((1 < 0 || 1 >= match.$length) ? $throwRuntimeError("index out of range") : match.$array[match.$offset + 1])))))); - })); - return $bytesToString(b); + Error.prototype.Error = function() { return this.$val.Error(); }; + ErrorCode.prototype.String = function() { + var e; + e = this.$val !== undefined ? this.$val : this; + return e; }; - Regexp.prototype.ReplaceAllStringFunc = function(src, repl) { return this.$val.ReplaceAllStringFunc(src, repl); }; - Regexp.Ptr.prototype.replaceAll = function(bsrc, src, nmatch, repl) { - var re, lastMatchEnd, searchPos, buf, endPos, a, width, _tuple, _tuple$1; - re = this; - lastMatchEnd = 0; - searchPos = 0; - buf = ($sliceType($Uint8)).nil; - endPos = 0; - if (!(bsrc === ($sliceType($Uint8)).nil)) { - endPos = bsrc.$length; + $ptrType(ErrorCode).prototype.String = function() { return new ErrorCode(this.$get()).String(); }; + parser.Ptr.prototype.newRegexp = function(op) { + var p, re; + p = this; + re = p.free; + if (!(re === ($ptrType(Regexp)).nil)) { + p.free = re.Sub0[0]; + $copy(re, new Regexp.Ptr(0, 0, ($sliceType(($ptrType(Regexp)))).nil, ($arrayType(($ptrType(Regexp)), 1)).zero(), ($sliceType($Int32)).nil, ($arrayType($Int32, 2)).zero(), 0, 0, 0, ""), Regexp); } else { - endPos = src.length; + re = new Regexp.Ptr(); } - while (searchPos <= endPos) { - a = re.doExecute($ifaceNil, bsrc, src, searchPos, nmatch); - if (a.$length === 0) { - break; - } - if (!(bsrc === ($sliceType($Uint8)).nil)) { - buf = $appendSlice(buf, $subslice(bsrc, lastMatchEnd, ((0 < 0 || 0 >= a.$length) ? $throwRuntimeError("index out of range") : a.$array[a.$offset + 0]))); - } else { - buf = $appendSlice(buf, new ($sliceType($Uint8))($stringToBytes(src.substring(lastMatchEnd, ((0 < 0 || 0 >= a.$length) ? $throwRuntimeError("index out of range") : a.$array[a.$offset + 0]))))); - } - if (((1 < 0 || 1 >= a.$length) ? $throwRuntimeError("index out of range") : a.$array[a.$offset + 1]) > lastMatchEnd || (((0 < 0 || 0 >= a.$length) ? $throwRuntimeError("index out of range") : a.$array[a.$offset + 0]) === 0)) { - buf = repl(buf, a); - } - lastMatchEnd = ((1 < 0 || 1 >= a.$length) ? $throwRuntimeError("index out of range") : a.$array[a.$offset + 1]); - width = 0; - if (!(bsrc === ($sliceType($Uint8)).nil)) { - _tuple = utf8.DecodeRune($subslice(bsrc, searchPos)); width = _tuple[1]; - } else { - _tuple$1 = utf8.DecodeRuneInString(src.substring(searchPos)); width = _tuple$1[1]; + re.Op = op; + return re; + }; + parser.prototype.newRegexp = function(op) { return this.$val.newRegexp(op); }; + parser.Ptr.prototype.reuse = function(re) { + var p; + p = this; + re.Sub0[0] = p.free; + p.free = re; + }; + parser.prototype.reuse = function(re) { return this.$val.reuse(re); }; + parser.Ptr.prototype.push = function(re) { + var p, x, x$1, x$2, x$3, x$4, x$5, x$6, x$7, x$8, x$9, x$10, x$11, x$12, x$13, x$14, x$15, x$16, x$17; + p = this; + if ((re.Op === 4) && (re.Rune.$length === 2) && ((x = re.Rune, ((0 < 0 || 0 >= x.$length) ? $throwRuntimeError("index out of range") : x.$array[x.$offset + 0])) === (x$1 = re.Rune, ((1 < 0 || 1 >= x$1.$length) ? $throwRuntimeError("index out of range") : x$1.$array[x$1.$offset + 1])))) { + if (p.maybeConcat((x$16 = re.Rune, ((0 < 0 || 0 >= x$16.$length) ? $throwRuntimeError("index out of range") : x$16.$array[x$16.$offset + 0])), p.flags & ~1)) { + return ($ptrType(Regexp)).nil; } - if ((searchPos + width >> 0) > ((1 < 0 || 1 >= a.$length) ? $throwRuntimeError("index out of range") : a.$array[a.$offset + 1])) { - searchPos = searchPos + (width) >> 0; - } else if ((searchPos + 1 >> 0) > ((1 < 0 || 1 >= a.$length) ? $throwRuntimeError("index out of range") : a.$array[a.$offset + 1])) { - searchPos = searchPos + (1) >> 0; - } else { - searchPos = ((1 < 0 || 1 >= a.$length) ? $throwRuntimeError("index out of range") : a.$array[a.$offset + 1]); + re.Op = 3; + re.Rune = $subslice(re.Rune, 0, 1); + re.Flags = p.flags & ~1; + } else if ((re.Op === 4) && (re.Rune.$length === 4) && ((x$2 = re.Rune, ((0 < 0 || 0 >= x$2.$length) ? $throwRuntimeError("index out of range") : x$2.$array[x$2.$offset + 0])) === (x$3 = re.Rune, ((1 < 0 || 1 >= x$3.$length) ? $throwRuntimeError("index out of range") : x$3.$array[x$3.$offset + 1]))) && ((x$4 = re.Rune, ((2 < 0 || 2 >= x$4.$length) ? $throwRuntimeError("index out of range") : x$4.$array[x$4.$offset + 2])) === (x$5 = re.Rune, ((3 < 0 || 3 >= x$5.$length) ? $throwRuntimeError("index out of range") : x$5.$array[x$5.$offset + 3]))) && (unicode.SimpleFold((x$6 = re.Rune, ((0 < 0 || 0 >= x$6.$length) ? $throwRuntimeError("index out of range") : x$6.$array[x$6.$offset + 0]))) === (x$7 = re.Rune, ((2 < 0 || 2 >= x$7.$length) ? $throwRuntimeError("index out of range") : x$7.$array[x$7.$offset + 2]))) && (unicode.SimpleFold((x$8 = re.Rune, ((2 < 0 || 2 >= x$8.$length) ? $throwRuntimeError("index out of range") : x$8.$array[x$8.$offset + 2]))) === (x$9 = re.Rune, ((0 < 0 || 0 >= x$9.$length) ? $throwRuntimeError("index out of range") : x$9.$array[x$9.$offset + 0]))) || (re.Op === 4) && (re.Rune.$length === 2) && (((x$10 = re.Rune, ((0 < 0 || 0 >= x$10.$length) ? $throwRuntimeError("index out of range") : x$10.$array[x$10.$offset + 0])) + 1 >> 0) === (x$11 = re.Rune, ((1 < 0 || 1 >= x$11.$length) ? $throwRuntimeError("index out of range") : x$11.$array[x$11.$offset + 1]))) && (unicode.SimpleFold((x$12 = re.Rune, ((0 < 0 || 0 >= x$12.$length) ? $throwRuntimeError("index out of range") : x$12.$array[x$12.$offset + 0]))) === (x$13 = re.Rune, ((1 < 0 || 1 >= x$13.$length) ? $throwRuntimeError("index out of range") : x$13.$array[x$13.$offset + 1]))) && (unicode.SimpleFold((x$14 = re.Rune, ((1 < 0 || 1 >= x$14.$length) ? $throwRuntimeError("index out of range") : x$14.$array[x$14.$offset + 1]))) === (x$15 = re.Rune, ((0 < 0 || 0 >= x$15.$length) ? $throwRuntimeError("index out of range") : x$15.$array[x$15.$offset + 0])))) { + if (p.maybeConcat((x$17 = re.Rune, ((0 < 0 || 0 >= x$17.$length) ? $throwRuntimeError("index out of range") : x$17.$array[x$17.$offset + 0])), (p.flags | 1) >>> 0)) { + return ($ptrType(Regexp)).nil; } - } - if (!(bsrc === ($sliceType($Uint8)).nil)) { - buf = $appendSlice(buf, $subslice(bsrc, lastMatchEnd)); + re.Op = 3; + re.Rune = $subslice(re.Rune, 0, 1); + re.Flags = (p.flags | 1) >>> 0; } else { - buf = $appendSlice(buf, new ($sliceType($Uint8))($stringToBytes(src.substring(lastMatchEnd)))); + p.maybeConcat(-1, 0); } - return buf; + p.stack = $append(p.stack, re); + return re; }; - Regexp.prototype.replaceAll = function(bsrc, src, nmatch, repl) { return this.$val.replaceAll(bsrc, src, nmatch, repl); }; - Regexp.Ptr.prototype.ReplaceAll = function(src, repl) { - var re, n, x, srepl, b; - re = this; - n = 2; - if (bytes.IndexByte(repl, 36) >= 0) { - n = (x = (re.numSubexp + 1 >> 0), (((2 >>> 16 << 16) * x >> 0) + (2 << 16 >>> 16) * x) >> 0); + parser.prototype.push = function(re) { return this.$val.push(re); }; + parser.Ptr.prototype.maybeConcat = function(r, flags) { + var p, n, x, x$1, re1, x$2, x$3, re2, x$4; + p = this; + n = p.stack.$length; + if (n < 2) { + return false; } - srepl = ""; - b = re.replaceAll(src, "", n, (function(dst, match) { - if (!((srepl.length === repl.$length))) { - srepl = $bytesToString(repl); - } - return re.expand(dst, srepl, src, "", match); - })); - return b; - }; - Regexp.prototype.ReplaceAll = function(src, repl) { return this.$val.ReplaceAll(src, repl); }; - Regexp.Ptr.prototype.ReplaceAllLiteral = function(src, repl) { - var re; - re = this; - return re.replaceAll(src, "", 2, (function(dst, match) { - return $appendSlice(dst, repl); - })); - }; - Regexp.prototype.ReplaceAllLiteral = function(src, repl) { return this.$val.ReplaceAllLiteral(src, repl); }; - Regexp.Ptr.prototype.ReplaceAllFunc = function(src, repl) { - var re; - re = this; - return re.replaceAll(src, "", 2, (function(dst, match) { - return $appendSlice(dst, repl($subslice(src, ((0 < 0 || 0 >= match.$length) ? $throwRuntimeError("index out of range") : match.$array[match.$offset + 0]), ((1 < 0 || 1 >= match.$length) ? $throwRuntimeError("index out of range") : match.$array[match.$offset + 1])))); - })); - }; - Regexp.prototype.ReplaceAllFunc = function(src, repl) { return this.$val.ReplaceAllFunc(src, repl); }; - Regexp.Ptr.prototype.pad = function(a) { - var re, x, n; - re = this; - if (a === ($sliceType($Int)).nil) { - return ($sliceType($Int)).nil; + re1 = (x = p.stack, x$1 = n - 1 >> 0, ((x$1 < 0 || x$1 >= x.$length) ? $throwRuntimeError("index out of range") : x.$array[x.$offset + x$1])); + re2 = (x$2 = p.stack, x$3 = n - 2 >> 0, ((x$3 < 0 || x$3 >= x$2.$length) ? $throwRuntimeError("index out of range") : x$2.$array[x$2.$offset + x$3])); + if (!((re1.Op === 3)) || !((re2.Op === 3)) || !((((re1.Flags & 1) >>> 0) === ((re2.Flags & 1) >>> 0)))) { + return false; } - n = (x = (1 + re.numSubexp >> 0), (((x >>> 16 << 16) * 2 >> 0) + (x << 16 >>> 16) * 2) >> 0); - while (a.$length < n) { - a = $append(a, -1); + re2.Rune = $appendSlice(re2.Rune, re1.Rune); + if (r >= 0) { + re1.Rune = $subslice(new ($sliceType($Int32))(re1.Rune0), 0, 1); + (x$4 = re1.Rune, (0 < 0 || 0 >= x$4.$length) ? $throwRuntimeError("index out of range") : x$4.$array[x$4.$offset + 0] = r); + re1.Flags = flags; + return true; } - return a; + p.stack = $subslice(p.stack, 0, (n - 1 >> 0)); + p.reuse(re1); + return false; }; - Regexp.prototype.pad = function(a) { return this.$val.pad(a); }; - Regexp.Ptr.prototype.allMatches = function(s, b, n, deliver) { - var re, end, _tmp, _tmp$1, _tmp$2, pos, i, prevMatchEnd, matches, accept, width, _tuple, _tuple$1; - re = this; - end = 0; - if (b === ($sliceType($Uint8)).nil) { - end = s.length; - } else { - end = b.$length; + parser.prototype.maybeConcat = function(r, flags) { return this.$val.maybeConcat(r, flags); }; + parser.Ptr.prototype.newLiteral = function(r, flags) { + var p, re; + p = this; + re = p.newRegexp(3); + re.Flags = flags; + if (!((((flags & 1) >>> 0) === 0))) { + r = minFoldRune(r); + } + re.Rune0[0] = r; + re.Rune = $subslice(new ($sliceType($Int32))(re.Rune0), 0, 1); + return re; + }; + parser.prototype.newLiteral = function(r, flags) { return this.$val.newLiteral(r, flags); }; + minFoldRune = function(r) { + var min, r0; + if (r < 65 || r > 66639) { + return r; } - _tmp = 0; _tmp$1 = 0; _tmp$2 = -1; pos = _tmp; i = _tmp$1; prevMatchEnd = _tmp$2; - while (i < n && pos <= end) { - matches = re.doExecute($ifaceNil, b, s, pos, re.prog.NumCap); - if (matches.$length === 0) { - break; + min = r; + r0 = r; + r = unicode.SimpleFold(r); + while (!((r === r0))) { + if (min > r) { + min = r; } - accept = true; - if (((1 < 0 || 1 >= matches.$length) ? $throwRuntimeError("index out of range") : matches.$array[matches.$offset + 1]) === pos) { - if (((0 < 0 || 0 >= matches.$length) ? $throwRuntimeError("index out of range") : matches.$array[matches.$offset + 0]) === prevMatchEnd) { - accept = false; - } - width = 0; - if (b === ($sliceType($Uint8)).nil) { - _tuple = utf8.DecodeRuneInString(s.substring(pos, end)); width = _tuple[1]; - } else { - _tuple$1 = utf8.DecodeRune($subslice(b, pos, end)); width = _tuple$1[1]; - } - if (width > 0) { - pos = pos + (width) >> 0; - } else { - pos = end + 1 >> 0; - } - } else { - pos = ((1 < 0 || 1 >= matches.$length) ? $throwRuntimeError("index out of range") : matches.$array[matches.$offset + 1]); + r = unicode.SimpleFold(r); + } + return min; + }; + parser.Ptr.prototype.literal = function(r) { + var p; + p = this; + p.push(p.newLiteral(r, p.flags)); + }; + parser.prototype.literal = function(r) { return this.$val.literal(r); }; + parser.Ptr.prototype.op = function(op) { + var p, re; + p = this; + re = p.newRegexp(op); + re.Flags = p.flags; + return p.push(re); + }; + parser.prototype.op = function(op) { return this.$val.op(op); }; + parser.Ptr.prototype.repeat = function(op, min, max, before, after, lastRepeat) { + var p, flags, n, x, x$1, sub, re, x$2, x$3, x$4; + p = this; + flags = p.flags; + if (!((((p.flags & 64) >>> 0) === 0))) { + if (after.length > 0 && (after.charCodeAt(0) === 63)) { + after = after.substring(1); + flags = (flags ^ (32)) << 16 >>> 16; } - prevMatchEnd = ((1 < 0 || 1 >= matches.$length) ? $throwRuntimeError("index out of range") : matches.$array[matches.$offset + 1]); - if (accept) { - deliver(re.pad(matches)); - i = i + (1) >> 0; + if (!(lastRepeat === "")) { + return ["", new Error.Ptr("invalid nested repetition operator", lastRepeat.substring(0, (lastRepeat.length - after.length >> 0)))]; } } - }; - Regexp.prototype.allMatches = function(s, b, n, deliver) { return this.$val.allMatches(s, b, n, deliver); }; - Regexp.Ptr.prototype.Find = function(b) { - var re, a; - re = this; - a = re.doExecute($ifaceNil, b, "", 0, 2); - if (a === ($sliceType($Int)).nil) { - return ($sliceType($Uint8)).nil; + n = p.stack.$length; + if (n === 0) { + return ["", new Error.Ptr("missing argument to repetition operator", before.substring(0, (before.length - after.length >> 0)))]; } - return $subslice(b, ((0 < 0 || 0 >= a.$length) ? $throwRuntimeError("index out of range") : a.$array[a.$offset + 0]), ((1 < 0 || 1 >= a.$length) ? $throwRuntimeError("index out of range") : a.$array[a.$offset + 1])); - }; - Regexp.prototype.Find = function(b) { return this.$val.Find(b); }; - Regexp.Ptr.prototype.FindIndex = function(b) { - var loc = ($sliceType($Int)).nil, re, a; - re = this; - a = re.doExecute($ifaceNil, b, "", 0, 2); - if (a === ($sliceType($Int)).nil) { - loc = ($sliceType($Int)).nil; - return loc; + sub = (x = p.stack, x$1 = n - 1 >> 0, ((x$1 < 0 || x$1 >= x.$length) ? $throwRuntimeError("index out of range") : x.$array[x.$offset + x$1])); + if (sub.Op >= 128) { + return ["", new Error.Ptr("missing argument to repetition operator", before.substring(0, (before.length - after.length >> 0)))]; } - loc = $subslice(a, 0, 2); - return loc; + re = p.newRegexp(op); + re.Min = min; + re.Max = max; + re.Flags = flags; + re.Sub = $subslice(new ($sliceType(($ptrType(Regexp))))(re.Sub0), 0, 1); + (x$2 = re.Sub, (0 < 0 || 0 >= x$2.$length) ? $throwRuntimeError("index out of range") : x$2.$array[x$2.$offset + 0] = sub); + (x$3 = p.stack, x$4 = n - 1 >> 0, (x$4 < 0 || x$4 >= x$3.$length) ? $throwRuntimeError("index out of range") : x$3.$array[x$3.$offset + x$4] = re); + return [after, $ifaceNil]; }; - Regexp.prototype.FindIndex = function(b) { return this.$val.FindIndex(b); }; - Regexp.Ptr.prototype.FindString = function(s) { - var re, a; - re = this; - a = re.doExecute($ifaceNil, ($sliceType($Uint8)).nil, s, 0, 2); - if (a === ($sliceType($Int)).nil) { - return ""; + parser.prototype.repeat = function(op, min, max, before, after, lastRepeat) { return this.$val.repeat(op, min, max, before, after, lastRepeat); }; + parser.Ptr.prototype.concat = function() { + var p, i, x, x$1, subs; + p = this; + p.maybeConcat(-1, 0); + i = p.stack.$length; + while (i > 0 && (x = p.stack, x$1 = i - 1 >> 0, ((x$1 < 0 || x$1 >= x.$length) ? $throwRuntimeError("index out of range") : x.$array[x.$offset + x$1])).Op < 128) { + i = i - (1) >> 0; } - return s.substring(((0 < 0 || 0 >= a.$length) ? $throwRuntimeError("index out of range") : a.$array[a.$offset + 0]), ((1 < 0 || 1 >= a.$length) ? $throwRuntimeError("index out of range") : a.$array[a.$offset + 1])); + subs = $subslice(p.stack, i); + p.stack = $subslice(p.stack, 0, i); + if (subs.$length === 0) { + return p.push(p.newRegexp(2)); + } + return p.push(p.collapse(subs, 18)); }; - Regexp.prototype.FindString = function(s) { return this.$val.FindString(s); }; - Regexp.Ptr.prototype.FindStringIndex = function(s) { - var loc = ($sliceType($Int)).nil, re, a; - re = this; - a = re.doExecute($ifaceNil, ($sliceType($Uint8)).nil, s, 0, 2); - if (a === ($sliceType($Int)).nil) { - loc = ($sliceType($Int)).nil; - return loc; + parser.prototype.concat = function() { return this.$val.concat(); }; + parser.Ptr.prototype.alternate = function() { + var p, i, x, x$1, subs, x$2; + p = this; + i = p.stack.$length; + while (i > 0 && (x = p.stack, x$1 = i - 1 >> 0, ((x$1 < 0 || x$1 >= x.$length) ? $throwRuntimeError("index out of range") : x.$array[x.$offset + x$1])).Op < 128) { + i = i - (1) >> 0; } - loc = $subslice(a, 0, 2); - return loc; + subs = $subslice(p.stack, i); + p.stack = $subslice(p.stack, 0, i); + if (subs.$length > 0) { + cleanAlt((x$2 = subs.$length - 1 >> 0, ((x$2 < 0 || x$2 >= subs.$length) ? $throwRuntimeError("index out of range") : subs.$array[subs.$offset + x$2]))); + } + if (subs.$length === 0) { + return p.push(p.newRegexp(1)); + } + return p.push(p.collapse(subs, 19)); }; - Regexp.prototype.FindStringIndex = function(s) { return this.$val.FindStringIndex(s); }; - Regexp.Ptr.prototype.FindReaderIndex = function(r) { - var loc = ($sliceType($Int)).nil, re, a; - re = this; - a = re.doExecute(r, ($sliceType($Uint8)).nil, "", 0, 2); - if (a === ($sliceType($Int)).nil) { - loc = ($sliceType($Int)).nil; - return loc; + parser.prototype.alternate = function() { return this.$val.alternate(); }; + cleanAlt = function(re) { + var _ref, x, x$1, x$2, x$3, x$4, x$5; + _ref = re.Op; + if (_ref === 4) { + re.Rune = cleanClass(new ($ptrType(($sliceType($Int32))))(function() { return this.$target.Rune; }, function($v) { this.$target.Rune = $v; }, re)); + if ((re.Rune.$length === 2) && ((x = re.Rune, ((0 < 0 || 0 >= x.$length) ? $throwRuntimeError("index out of range") : x.$array[x.$offset + 0])) === 0) && ((x$1 = re.Rune, ((1 < 0 || 1 >= x$1.$length) ? $throwRuntimeError("index out of range") : x$1.$array[x$1.$offset + 1])) === 1114111)) { + re.Rune = ($sliceType($Int32)).nil; + re.Op = 6; + return; + } + if ((re.Rune.$length === 4) && ((x$2 = re.Rune, ((0 < 0 || 0 >= x$2.$length) ? $throwRuntimeError("index out of range") : x$2.$array[x$2.$offset + 0])) === 0) && ((x$3 = re.Rune, ((1 < 0 || 1 >= x$3.$length) ? $throwRuntimeError("index out of range") : x$3.$array[x$3.$offset + 1])) === 9) && ((x$4 = re.Rune, ((2 < 0 || 2 >= x$4.$length) ? $throwRuntimeError("index out of range") : x$4.$array[x$4.$offset + 2])) === 11) && ((x$5 = re.Rune, ((3 < 0 || 3 >= x$5.$length) ? $throwRuntimeError("index out of range") : x$5.$array[x$5.$offset + 3])) === 1114111)) { + re.Rune = ($sliceType($Int32)).nil; + re.Op = 5; + return; + } + if ((re.Rune.$capacity - re.Rune.$length >> 0) > 100) { + re.Rune = $appendSlice($subslice(new ($sliceType($Int32))(re.Rune0), 0, 0), re.Rune); + } } - loc = $subslice(a, 0, 2); - return loc; }; - Regexp.prototype.FindReaderIndex = function(r) { return this.$val.FindReaderIndex(r); }; - Regexp.Ptr.prototype.FindSubmatch = function(b) { - var re, a, ret, _ref, _i, i, x, x$1, x$2; - re = this; - a = re.doExecute($ifaceNil, b, "", 0, re.prog.NumCap); - if (a === ($sliceType($Int)).nil) { - return ($sliceType(($sliceType($Uint8)))).nil; + parser.Ptr.prototype.collapse = function(subs, op) { + var p, re, _ref, _i, sub, old, x; + p = this; + if (subs.$length === 1) { + return ((0 < 0 || 0 >= subs.$length) ? $throwRuntimeError("index out of range") : subs.$array[subs.$offset + 0]); } - ret = ($sliceType(($sliceType($Uint8)))).make((1 + re.numSubexp >> 0)); - _ref = ret; + re = p.newRegexp(op); + re.Sub = $subslice(new ($sliceType(($ptrType(Regexp))))(re.Sub0), 0, 0); + _ref = subs; _i = 0; while (_i < _ref.$length) { - i = _i; - if (((((2 >>> 16 << 16) * i >> 0) + (2 << 16 >>> 16) * i) >> 0) < a.$length && (x = (((2 >>> 16 << 16) * i >> 0) + (2 << 16 >>> 16) * i) >> 0, ((x < 0 || x >= a.$length) ? $throwRuntimeError("index out of range") : a.$array[a.$offset + x])) >= 0) { - (i < 0 || i >= ret.$length) ? $throwRuntimeError("index out of range") : ret.$array[ret.$offset + i] = $subslice(b, (x$1 = (((2 >>> 16 << 16) * i >> 0) + (2 << 16 >>> 16) * i) >> 0, ((x$1 < 0 || x$1 >= a.$length) ? $throwRuntimeError("index out of range") : a.$array[a.$offset + x$1])), (x$2 = ((((2 >>> 16 << 16) * i >> 0) + (2 << 16 >>> 16) * i) >> 0) + 1 >> 0, ((x$2 < 0 || x$2 >= a.$length) ? $throwRuntimeError("index out of range") : a.$array[a.$offset + x$2]))); + sub = ((_i < 0 || _i >= _ref.$length) ? $throwRuntimeError("index out of range") : _ref.$array[_ref.$offset + _i]); + if (sub.Op === op) { + re.Sub = $appendSlice(re.Sub, sub.Sub); + p.reuse(sub); + } else { + re.Sub = $append(re.Sub, sub); } _i++; } - return ret; - }; - Regexp.prototype.FindSubmatch = function(b) { return this.$val.FindSubmatch(b); }; - Regexp.Ptr.prototype.Expand = function(dst, template, src, match) { - var re; - re = this; - return re.expand(dst, $bytesToString(template), src, "", match); - }; - Regexp.prototype.Expand = function(dst, template, src, match) { return this.$val.Expand(dst, template, src, match); }; - Regexp.Ptr.prototype.ExpandString = function(dst, template, src, match) { - var re; - re = this; - return re.expand(dst, template, ($sliceType($Uint8)).nil, src, match); - }; - Regexp.prototype.ExpandString = function(dst, template, src, match) { return this.$val.ExpandString(dst, template, src, match); }; - Regexp.Ptr.prototype.expand = function(dst, template, bsrc, src, match) { - var re, i, _tuple, name, num, rest, ok, x, x$1, x$2, x$3, x$4, _ref, _i, i$1, namei, x$5, x$6, x$7, x$8, x$9; - re = this; - while (template.length > 0) { - i = strings.Index(template, "$"); - if (i < 0) { - break; - } - dst = $appendSlice(dst, new ($sliceType($Uint8))($stringToBytes(template.substring(0, i)))); - template = template.substring(i); - if (template.length > 1 && (template.charCodeAt(1) === 36)) { - dst = $append(dst, 36); - template = template.substring(2); - continue; - } - _tuple = extract(template); name = _tuple[0]; num = _tuple[1]; rest = _tuple[2]; ok = _tuple[3]; - if (!ok) { - dst = $append(dst, 36); - template = template.substring(1); - continue; - } - template = rest; - if (num >= 0) { - if ((((((2 >>> 16 << 16) * num >> 0) + (2 << 16 >>> 16) * num) >> 0) + 1 >> 0) < match.$length && (x = (((2 >>> 16 << 16) * num >> 0) + (2 << 16 >>> 16) * num) >> 0, ((x < 0 || x >= match.$length) ? $throwRuntimeError("index out of range") : match.$array[match.$offset + x])) >= 0) { - if (!(bsrc === ($sliceType($Uint8)).nil)) { - dst = $appendSlice(dst, $subslice(bsrc, (x$1 = (((2 >>> 16 << 16) * num >> 0) + (2 << 16 >>> 16) * num) >> 0, ((x$1 < 0 || x$1 >= match.$length) ? $throwRuntimeError("index out of range") : match.$array[match.$offset + x$1])), (x$2 = ((((2 >>> 16 << 16) * num >> 0) + (2 << 16 >>> 16) * num) >> 0) + 1 >> 0, ((x$2 < 0 || x$2 >= match.$length) ? $throwRuntimeError("index out of range") : match.$array[match.$offset + x$2])))); - } else { - dst = $appendSlice(dst, new ($sliceType($Uint8))($stringToBytes(src.substring((x$3 = (((2 >>> 16 << 16) * num >> 0) + (2 << 16 >>> 16) * num) >> 0, ((x$3 < 0 || x$3 >= match.$length) ? $throwRuntimeError("index out of range") : match.$array[match.$offset + x$3])), (x$4 = ((((2 >>> 16 << 16) * num >> 0) + (2 << 16 >>> 16) * num) >> 0) + 1 >> 0, ((x$4 < 0 || x$4 >= match.$length) ? $throwRuntimeError("index out of range") : match.$array[match.$offset + x$4])))))); - } - } - } else { - _ref = re.subexpNames; - _i = 0; - while (_i < _ref.$length) { - i$1 = _i; - namei = ((_i < 0 || _i >= _ref.$length) ? $throwRuntimeError("index out of range") : _ref.$array[_ref.$offset + _i]); - if (name === namei && (((((2 >>> 16 << 16) * i$1 >> 0) + (2 << 16 >>> 16) * i$1) >> 0) + 1 >> 0) < match.$length && (x$5 = (((2 >>> 16 << 16) * i$1 >> 0) + (2 << 16 >>> 16) * i$1) >> 0, ((x$5 < 0 || x$5 >= match.$length) ? $throwRuntimeError("index out of range") : match.$array[match.$offset + x$5])) >= 0) { - if (!(bsrc === ($sliceType($Uint8)).nil)) { - dst = $appendSlice(dst, $subslice(bsrc, (x$6 = (((2 >>> 16 << 16) * i$1 >> 0) + (2 << 16 >>> 16) * i$1) >> 0, ((x$6 < 0 || x$6 >= match.$length) ? $throwRuntimeError("index out of range") : match.$array[match.$offset + x$6])), (x$7 = ((((2 >>> 16 << 16) * i$1 >> 0) + (2 << 16 >>> 16) * i$1) >> 0) + 1 >> 0, ((x$7 < 0 || x$7 >= match.$length) ? $throwRuntimeError("index out of range") : match.$array[match.$offset + x$7])))); - } else { - dst = $appendSlice(dst, new ($sliceType($Uint8))($stringToBytes(src.substring((x$8 = (((2 >>> 16 << 16) * i$1 >> 0) + (2 << 16 >>> 16) * i$1) >> 0, ((x$8 < 0 || x$8 >= match.$length) ? $throwRuntimeError("index out of range") : match.$array[match.$offset + x$8])), (x$9 = ((((2 >>> 16 << 16) * i$1 >> 0) + (2 << 16 >>> 16) * i$1) >> 0) + 1 >> 0, ((x$9 < 0 || x$9 >= match.$length) ? $throwRuntimeError("index out of range") : match.$array[match.$offset + x$9])))))); - } - break; - } - _i++; - } + if (op === 19) { + re.Sub = p.factor(re.Sub, re.Flags); + if (re.Sub.$length === 1) { + old = re; + re = (x = re.Sub, ((0 < 0 || 0 >= x.$length) ? $throwRuntimeError("index out of range") : x.$array[x.$offset + 0])); + p.reuse(old); } } - dst = $appendSlice(dst, new ($sliceType($Uint8))($stringToBytes(template))); - return dst; + return re; }; - Regexp.prototype.expand = function(dst, template, bsrc, src, match) { return this.$val.expand(dst, template, bsrc, src, match); }; - extract = function(str) { - var name = "", num = 0, rest = "", ok = false, brace, i, _tuple, rune, size, i$1; - if (str.length < 2 || !((str.charCodeAt(0) === 36))) { - return [name, num, rest, ok]; - } - brace = false; - if (str.charCodeAt(1) === 123) { - brace = true; - str = str.substring(2); - } else { - str = str.substring(1); + parser.prototype.collapse = function(subs, op) { return this.$val.collapse(subs, op); }; + parser.Ptr.prototype.factor = function(sub, flags) { + var p, str, strflags, start, out, i, istr, iflags, _tuple, same, prefix, j, suffix, re, first, i$1, ifirst, prefix$1, j$1, reuse, suffix$1, re$1, i$2, max, j$2, _tmp, _tmp$1, j$3, _ref, _i, i$3, x; + p = this; + if (sub.$length < 2) { + return sub; } + str = ($sliceType($Int32)).nil; + strflags = 0; + start = 0; + out = $subslice(sub, 0, 0); i = 0; - while (i < str.length) { - _tuple = utf8.DecodeRuneInString(str.substring(i)); rune = _tuple[0]; size = _tuple[1]; - if (!unicode.IsLetter(rune) && !unicode.IsDigit(rune) && !((rune === 95))) { - break; + while (i <= sub.$length) { + istr = ($sliceType($Int32)).nil; + iflags = 0; + if (i < sub.$length) { + _tuple = p.leadingString(((i < 0 || i >= sub.$length) ? $throwRuntimeError("index out of range") : sub.$array[sub.$offset + i])); istr = _tuple[0]; iflags = _tuple[1]; + if (iflags === strflags) { + same = 0; + while (same < str.$length && same < istr.$length && (((same < 0 || same >= str.$length) ? $throwRuntimeError("index out of range") : str.$array[str.$offset + same]) === ((same < 0 || same >= istr.$length) ? $throwRuntimeError("index out of range") : istr.$array[istr.$offset + same]))) { + same = same + (1) >> 0; + } + if (same > 0) { + str = $subslice(str, 0, same); + i = i + (1) >> 0; + continue; + } + } } - i = i + (size) >> 0; - } - if (i === 0) { - return [name, num, rest, ok]; - } - name = str.substring(0, i); - if (brace) { - if (i >= str.length || !((str.charCodeAt(i) === 125))) { - return [name, num, rest, ok]; + if (i === start) { + } else if (i === (start + 1 >> 0)) { + out = $append(out, ((start < 0 || start >= sub.$length) ? $throwRuntimeError("index out of range") : sub.$array[sub.$offset + start])); + } else { + prefix = p.newRegexp(3); + prefix.Flags = strflags; + prefix.Rune = $appendSlice($subslice(prefix.Rune, 0, 0), str); + j = start; + while (j < i) { + (j < 0 || j >= sub.$length) ? $throwRuntimeError("index out of range") : sub.$array[sub.$offset + j] = p.removeLeadingString(((j < 0 || j >= sub.$length) ? $throwRuntimeError("index out of range") : sub.$array[sub.$offset + j]), str.$length); + j = j + (1) >> 0; + } + suffix = p.collapse($subslice(sub, start, i), 19); + re = p.newRegexp(18); + re.Sub = $append($subslice(re.Sub, 0, 0), prefix, suffix); + out = $append(out, re); } + start = i; + str = istr; + strflags = iflags; i = i + (1) >> 0; } - num = 0; + sub = out; + start = 0; + out = $subslice(sub, 0, 0); + first = ($ptrType(Regexp)).nil; i$1 = 0; - while (i$1 < name.length) { - if (name.charCodeAt(i$1) < 48 || 57 < name.charCodeAt(i$1) || num >= 100000000) { - num = -1; - break; + while (i$1 <= sub.$length) { + ifirst = ($ptrType(Regexp)).nil; + if (i$1 < sub.$length) { + ifirst = p.leadingRegexp(((i$1 < 0 || i$1 >= sub.$length) ? $throwRuntimeError("index out of range") : sub.$array[sub.$offset + i$1])); + if (!(first === ($ptrType(Regexp)).nil) && first.Equal(ifirst)) { + i$1 = i$1 + (1) >> 0; + continue; + } } - num = (((((num >>> 16 << 16) * 10 >> 0) + (num << 16 >>> 16) * 10) >> 0) + (name.charCodeAt(i$1) >> 0) >> 0) - 48 >> 0; + if (i$1 === start) { + } else if (i$1 === (start + 1 >> 0)) { + out = $append(out, ((start < 0 || start >= sub.$length) ? $throwRuntimeError("index out of range") : sub.$array[sub.$offset + start])); + } else { + prefix$1 = first; + j$1 = start; + while (j$1 < i$1) { + reuse = !((j$1 === start)); + (j$1 < 0 || j$1 >= sub.$length) ? $throwRuntimeError("index out of range") : sub.$array[sub.$offset + j$1] = p.removeLeadingRegexp(((j$1 < 0 || j$1 >= sub.$length) ? $throwRuntimeError("index out of range") : sub.$array[sub.$offset + j$1]), reuse); + j$1 = j$1 + (1) >> 0; + } + suffix$1 = p.collapse($subslice(sub, start, i$1), 19); + re$1 = p.newRegexp(18); + re$1.Sub = $append($subslice(re$1.Sub, 0, 0), prefix$1, suffix$1); + out = $append(out, re$1); + } + start = i$1; + first = ifirst; i$1 = i$1 + (1) >> 0; } - if ((name.charCodeAt(0) === 48) && name.length > 1) { - num = -1; - } - rest = str.substring(i); - ok = true; - return [name, num, rest, ok]; - }; - Regexp.Ptr.prototype.FindSubmatchIndex = function(b) { - var re; - re = this; - return re.pad(re.doExecute($ifaceNil, b, "", 0, re.prog.NumCap)); - }; - Regexp.prototype.FindSubmatchIndex = function(b) { return this.$val.FindSubmatchIndex(b); }; - Regexp.Ptr.prototype.FindStringSubmatch = function(s) { - var re, a, ret, _ref, _i, i, x, x$1, x$2; - re = this; - a = re.doExecute($ifaceNil, ($sliceType($Uint8)).nil, s, 0, re.prog.NumCap); - if (a === ($sliceType($Int)).nil) { - return ($sliceType($String)).nil; + sub = out; + start = 0; + out = $subslice(sub, 0, 0); + i$2 = 0; + while (i$2 <= sub.$length) { + if (i$2 < sub.$length && isCharClass(((i$2 < 0 || i$2 >= sub.$length) ? $throwRuntimeError("index out of range") : sub.$array[sub.$offset + i$2]))) { + i$2 = i$2 + (1) >> 0; + continue; + } + if (i$2 === start) { + } else if (i$2 === (start + 1 >> 0)) { + out = $append(out, ((start < 0 || start >= sub.$length) ? $throwRuntimeError("index out of range") : sub.$array[sub.$offset + start])); + } else { + max = start; + j$2 = start + 1 >> 0; + while (j$2 < i$2) { + if (((max < 0 || max >= sub.$length) ? $throwRuntimeError("index out of range") : sub.$array[sub.$offset + max]).Op < ((j$2 < 0 || j$2 >= sub.$length) ? $throwRuntimeError("index out of range") : sub.$array[sub.$offset + j$2]).Op || (((max < 0 || max >= sub.$length) ? $throwRuntimeError("index out of range") : sub.$array[sub.$offset + max]).Op === ((j$2 < 0 || j$2 >= sub.$length) ? $throwRuntimeError("index out of range") : sub.$array[sub.$offset + j$2]).Op) && ((max < 0 || max >= sub.$length) ? $throwRuntimeError("index out of range") : sub.$array[sub.$offset + max]).Rune.$length < ((j$2 < 0 || j$2 >= sub.$length) ? $throwRuntimeError("index out of range") : sub.$array[sub.$offset + j$2]).Rune.$length) { + max = j$2; + } + j$2 = j$2 + (1) >> 0; + } + _tmp = ((max < 0 || max >= sub.$length) ? $throwRuntimeError("index out of range") : sub.$array[sub.$offset + max]); _tmp$1 = ((start < 0 || start >= sub.$length) ? $throwRuntimeError("index out of range") : sub.$array[sub.$offset + start]); (start < 0 || start >= sub.$length) ? $throwRuntimeError("index out of range") : sub.$array[sub.$offset + start] = _tmp; (max < 0 || max >= sub.$length) ? $throwRuntimeError("index out of range") : sub.$array[sub.$offset + max] = _tmp$1; + j$3 = start + 1 >> 0; + while (j$3 < i$2) { + mergeCharClass(((start < 0 || start >= sub.$length) ? $throwRuntimeError("index out of range") : sub.$array[sub.$offset + start]), ((j$3 < 0 || j$3 >= sub.$length) ? $throwRuntimeError("index out of range") : sub.$array[sub.$offset + j$3])); + p.reuse(((j$3 < 0 || j$3 >= sub.$length) ? $throwRuntimeError("index out of range") : sub.$array[sub.$offset + j$3])); + j$3 = j$3 + (1) >> 0; + } + cleanAlt(((start < 0 || start >= sub.$length) ? $throwRuntimeError("index out of range") : sub.$array[sub.$offset + start])); + out = $append(out, ((start < 0 || start >= sub.$length) ? $throwRuntimeError("index out of range") : sub.$array[sub.$offset + start])); + } + if (i$2 < sub.$length) { + out = $append(out, ((i$2 < 0 || i$2 >= sub.$length) ? $throwRuntimeError("index out of range") : sub.$array[sub.$offset + i$2])); + } + start = i$2 + 1 >> 0; + i$2 = i$2 + (1) >> 0; } - ret = ($sliceType($String)).make((1 + re.numSubexp >> 0)); - _ref = ret; + sub = out; + start = 0; + out = $subslice(sub, 0, 0); + _ref = sub; _i = 0; while (_i < _ref.$length) { - i = _i; - if (((((2 >>> 16 << 16) * i >> 0) + (2 << 16 >>> 16) * i) >> 0) < a.$length && (x = (((2 >>> 16 << 16) * i >> 0) + (2 << 16 >>> 16) * i) >> 0, ((x < 0 || x >= a.$length) ? $throwRuntimeError("index out of range") : a.$array[a.$offset + x])) >= 0) { - (i < 0 || i >= ret.$length) ? $throwRuntimeError("index out of range") : ret.$array[ret.$offset + i] = s.substring((x$1 = (((2 >>> 16 << 16) * i >> 0) + (2 << 16 >>> 16) * i) >> 0, ((x$1 < 0 || x$1 >= a.$length) ? $throwRuntimeError("index out of range") : a.$array[a.$offset + x$1])), (x$2 = ((((2 >>> 16 << 16) * i >> 0) + (2 << 16 >>> 16) * i) >> 0) + 1 >> 0, ((x$2 < 0 || x$2 >= a.$length) ? $throwRuntimeError("index out of range") : a.$array[a.$offset + x$2]))); + i$3 = _i; + if ((i$3 + 1 >> 0) < sub.$length && (((i$3 < 0 || i$3 >= sub.$length) ? $throwRuntimeError("index out of range") : sub.$array[sub.$offset + i$3]).Op === 2) && ((x = i$3 + 1 >> 0, ((x < 0 || x >= sub.$length) ? $throwRuntimeError("index out of range") : sub.$array[sub.$offset + x])).Op === 2)) { + _i++; + continue; } + out = $append(out, ((i$3 < 0 || i$3 >= sub.$length) ? $throwRuntimeError("index out of range") : sub.$array[sub.$offset + i$3])); _i++; } - return ret; - }; - Regexp.prototype.FindStringSubmatch = function(s) { return this.$val.FindStringSubmatch(s); }; - Regexp.Ptr.prototype.FindStringSubmatchIndex = function(s) { - var re; - re = this; - return re.pad(re.doExecute($ifaceNil, ($sliceType($Uint8)).nil, s, 0, re.prog.NumCap)); - }; - Regexp.prototype.FindStringSubmatchIndex = function(s) { return this.$val.FindStringSubmatchIndex(s); }; - Regexp.Ptr.prototype.FindReaderSubmatchIndex = function(r) { - var re; - re = this; - return re.pad(re.doExecute(r, ($sliceType($Uint8)).nil, "", 0, re.prog.NumCap)); - }; - Regexp.prototype.FindReaderSubmatchIndex = function(r) { return this.$val.FindReaderSubmatchIndex(r); }; - Regexp.Ptr.prototype.FindAll = function(b, n) { - var re, result; - re = this; - if (n < 0) { - n = b.$length + 1 >> 0; - } - result = ($sliceType(($sliceType($Uint8)))).make(0, 10); - re.allMatches("", b, n, (function(match) { - result = $append(result, $subslice(b, ((0 < 0 || 0 >= match.$length) ? $throwRuntimeError("index out of range") : match.$array[match.$offset + 0]), ((1 < 0 || 1 >= match.$length) ? $throwRuntimeError("index out of range") : match.$array[match.$offset + 1]))); - })); - if (result.$length === 0) { - return ($sliceType(($sliceType($Uint8)))).nil; - } - return result; - }; - Regexp.prototype.FindAll = function(b, n) { return this.$val.FindAll(b, n); }; - Regexp.Ptr.prototype.FindAllIndex = function(b, n) { - var re, result; - re = this; - if (n < 0) { - n = b.$length + 1 >> 0; - } - result = ($sliceType(($sliceType($Int)))).make(0, 10); - re.allMatches("", b, n, (function(match) { - result = $append(result, $subslice(match, 0, 2)); - })); - if (result.$length === 0) { - return ($sliceType(($sliceType($Int)))).nil; - } - return result; - }; - Regexp.prototype.FindAllIndex = function(b, n) { return this.$val.FindAllIndex(b, n); }; - Regexp.Ptr.prototype.FindAllString = function(s, n) { - var re, result; - re = this; - if (n < 0) { - n = s.length + 1 >> 0; - } - result = ($sliceType($String)).make(0, 10); - re.allMatches(s, ($sliceType($Uint8)).nil, n, (function(match) { - result = $append(result, s.substring(((0 < 0 || 0 >= match.$length) ? $throwRuntimeError("index out of range") : match.$array[match.$offset + 0]), ((1 < 0 || 1 >= match.$length) ? $throwRuntimeError("index out of range") : match.$array[match.$offset + 1]))); - })); - if (result.$length === 0) { - return ($sliceType($String)).nil; - } - return result; + sub = out; + return sub; }; - Regexp.prototype.FindAllString = function(s, n) { return this.$val.FindAllString(s, n); }; - Regexp.Ptr.prototype.FindAllStringIndex = function(s, n) { - var re, result; - re = this; - if (n < 0) { - n = s.length + 1 >> 0; + parser.prototype.factor = function(sub, flags) { return this.$val.factor(sub, flags); }; + parser.Ptr.prototype.leadingString = function(re) { + var p, x; + p = this; + if ((re.Op === 18) && re.Sub.$length > 0) { + re = (x = re.Sub, ((0 < 0 || 0 >= x.$length) ? $throwRuntimeError("index out of range") : x.$array[x.$offset + 0])); } - result = ($sliceType(($sliceType($Int)))).make(0, 10); - re.allMatches(s, ($sliceType($Uint8)).nil, n, (function(match) { - result = $append(result, $subslice(match, 0, 2)); - })); - if (result.$length === 0) { - return ($sliceType(($sliceType($Int)))).nil; + if (!((re.Op === 3))) { + return [($sliceType($Int32)).nil, 0]; } - return result; + return [re.Rune, (re.Flags & 1) >>> 0]; }; - Regexp.prototype.FindAllStringIndex = function(s, n) { return this.$val.FindAllStringIndex(s, n); }; - Regexp.Ptr.prototype.FindAllSubmatch = function(b, n) { - var re, result; - re = this; - if (n < 0) { - n = b.$length + 1 >> 0; - } - result = ($sliceType(($sliceType(($sliceType($Uint8)))))).make(0, 10); - re.allMatches("", b, n, (function(match) { - var _q, slice, _ref, _i, j, x, x$1, x$2; - slice = ($sliceType(($sliceType($Uint8)))).make((_q = match.$length / 2, (_q === _q && _q !== 1/0 && _q !== -1/0) ? _q >> 0 : $throwRuntimeError("integer divide by zero"))); - _ref = slice; - _i = 0; - while (_i < _ref.$length) { - j = _i; - if ((x = (((2 >>> 16 << 16) * j >> 0) + (2 << 16 >>> 16) * j) >> 0, ((x < 0 || x >= match.$length) ? $throwRuntimeError("index out of range") : match.$array[match.$offset + x])) >= 0) { - (j < 0 || j >= slice.$length) ? $throwRuntimeError("index out of range") : slice.$array[slice.$offset + j] = $subslice(b, (x$1 = (((2 >>> 16 << 16) * j >> 0) + (2 << 16 >>> 16) * j) >> 0, ((x$1 < 0 || x$1 >= match.$length) ? $throwRuntimeError("index out of range") : match.$array[match.$offset + x$1])), (x$2 = ((((2 >>> 16 << 16) * j >> 0) + (2 << 16 >>> 16) * j) >> 0) + 1 >> 0, ((x$2 < 0 || x$2 >= match.$length) ? $throwRuntimeError("index out of range") : match.$array[match.$offset + x$2]))); + parser.prototype.leadingString = function(re) { return this.$val.leadingString(re); }; + parser.Ptr.prototype.removeLeadingString = function(re, n) { + var p, x, sub, x$1, _ref, old, x$2; + p = this; + if ((re.Op === 18) && re.Sub.$length > 0) { + sub = (x = re.Sub, ((0 < 0 || 0 >= x.$length) ? $throwRuntimeError("index out of range") : x.$array[x.$offset + 0])); + sub = p.removeLeadingString(sub, n); + (x$1 = re.Sub, (0 < 0 || 0 >= x$1.$length) ? $throwRuntimeError("index out of range") : x$1.$array[x$1.$offset + 0] = sub); + if (sub.Op === 2) { + p.reuse(sub); + _ref = re.Sub.$length; + if (_ref === 0 || _ref === 1) { + re.Op = 2; + re.Sub = ($sliceType(($ptrType(Regexp)))).nil; + } else if (_ref === 2) { + old = re; + re = (x$2 = re.Sub, ((1 < 0 || 1 >= x$2.$length) ? $throwRuntimeError("index out of range") : x$2.$array[x$2.$offset + 1])); + p.reuse(old); + } else { + $copySlice(re.Sub, $subslice(re.Sub, 1)); + re.Sub = $subslice(re.Sub, 0, (re.Sub.$length - 1 >> 0)); } - _i++; } - result = $append(result, slice); - })); - if (result.$length === 0) { - return ($sliceType(($sliceType(($sliceType($Uint8)))))).nil; + return re; } - return result; + if (re.Op === 3) { + re.Rune = $subslice(re.Rune, 0, $copySlice(re.Rune, $subslice(re.Rune, n))); + if (re.Rune.$length === 0) { + re.Op = 2; + } + } + return re; }; - Regexp.prototype.FindAllSubmatch = function(b, n) { return this.$val.FindAllSubmatch(b, n); }; - Regexp.Ptr.prototype.FindAllSubmatchIndex = function(b, n) { - var re, result; - re = this; - if (n < 0) { - n = b.$length + 1 >> 0; + parser.prototype.removeLeadingString = function(re, n) { return this.$val.removeLeadingString(re, n); }; + parser.Ptr.prototype.leadingRegexp = function(re) { + var p, x, sub; + p = this; + if (re.Op === 2) { + return ($ptrType(Regexp)).nil; } - result = ($sliceType(($sliceType($Int)))).make(0, 10); - re.allMatches("", b, n, (function(match) { - result = $append(result, match); - })); - if (result.$length === 0) { - return ($sliceType(($sliceType($Int)))).nil; + if ((re.Op === 18) && re.Sub.$length > 0) { + sub = (x = re.Sub, ((0 < 0 || 0 >= x.$length) ? $throwRuntimeError("index out of range") : x.$array[x.$offset + 0])); + if (sub.Op === 2) { + return ($ptrType(Regexp)).nil; + } + return sub; } - return result; + return re; }; - Regexp.prototype.FindAllSubmatchIndex = function(b, n) { return this.$val.FindAllSubmatchIndex(b, n); }; - Regexp.Ptr.prototype.FindAllStringSubmatch = function(s, n) { - var re, result; - re = this; - if (n < 0) { - n = s.length + 1 >> 0; + parser.prototype.leadingRegexp = function(re) { return this.$val.leadingRegexp(re); }; + parser.Ptr.prototype.removeLeadingRegexp = function(re, reuse) { + var p, x, _ref, old, x$1; + p = this; + if ((re.Op === 18) && re.Sub.$length > 0) { + if (reuse) { + p.reuse((x = re.Sub, ((0 < 0 || 0 >= x.$length) ? $throwRuntimeError("index out of range") : x.$array[x.$offset + 0]))); + } + re.Sub = $subslice(re.Sub, 0, $copySlice(re.Sub, $subslice(re.Sub, 1))); + _ref = re.Sub.$length; + if (_ref === 0) { + re.Op = 2; + re.Sub = ($sliceType(($ptrType(Regexp)))).nil; + } else if (_ref === 1) { + old = re; + re = (x$1 = re.Sub, ((0 < 0 || 0 >= x$1.$length) ? $throwRuntimeError("index out of range") : x$1.$array[x$1.$offset + 0])); + p.reuse(old); + } + return re; } - result = ($sliceType(($sliceType($String)))).make(0, 10); - re.allMatches(s, ($sliceType($Uint8)).nil, n, (function(match) { - var _q, slice, _ref, _i, j, x, x$1, x$2; - slice = ($sliceType($String)).make((_q = match.$length / 2, (_q === _q && _q !== 1/0 && _q !== -1/0) ? _q >> 0 : $throwRuntimeError("integer divide by zero"))); - _ref = slice; - _i = 0; - while (_i < _ref.$length) { - j = _i; - if ((x = (((2 >>> 16 << 16) * j >> 0) + (2 << 16 >>> 16) * j) >> 0, ((x < 0 || x >= match.$length) ? $throwRuntimeError("index out of range") : match.$array[match.$offset + x])) >= 0) { - (j < 0 || j >= slice.$length) ? $throwRuntimeError("index out of range") : slice.$array[slice.$offset + j] = s.substring((x$1 = (((2 >>> 16 << 16) * j >> 0) + (2 << 16 >>> 16) * j) >> 0, ((x$1 < 0 || x$1 >= match.$length) ? $throwRuntimeError("index out of range") : match.$array[match.$offset + x$1])), (x$2 = ((((2 >>> 16 << 16) * j >> 0) + (2 << 16 >>> 16) * j) >> 0) + 1 >> 0, ((x$2 < 0 || x$2 >= match.$length) ? $throwRuntimeError("index out of range") : match.$array[match.$offset + x$2]))); - } - _i++; + if (reuse) { + p.reuse(re); + } + return p.newRegexp(2); + }; + parser.prototype.removeLeadingRegexp = function(re, reuse) { return this.$val.removeLeadingRegexp(re, reuse); }; + literalRegexp = function(s, flags) { + var re, _ref, _i, _rune, c; + re = new Regexp.Ptr(3, 0, ($sliceType(($ptrType(Regexp)))).nil, ($arrayType(($ptrType(Regexp)), 1)).zero(), ($sliceType($Int32)).nil, ($arrayType($Int32, 2)).zero(), 0, 0, 0, ""); + re.Flags = flags; + re.Rune = $subslice(new ($sliceType($Int32))(re.Rune0), 0, 0); + _ref = s; + _i = 0; + while (_i < _ref.length) { + _rune = $decodeRune(_ref, _i); + c = _rune[0]; + if (re.Rune.$length >= re.Rune.$capacity) { + re.Rune = new ($sliceType($Int32))($stringToRunes(s)); + break; } - result = $append(result, slice); - })); - if (result.$length === 0) { - return ($sliceType(($sliceType($String)))).nil; + re.Rune = $append(re.Rune, c); + _i += _rune[1]; } - return result; + return re; }; - Regexp.prototype.FindAllStringSubmatch = function(s, n) { return this.$val.FindAllStringSubmatch(s, n); }; - Regexp.Ptr.prototype.FindAllStringSubmatchIndex = function(s, n) { - var re, result; - re = this; - if (n < 0) { - n = s.length + 1 >> 0; + Parse = $pkg.Parse = function(s, flags) { + var err, p, err$1, c, op, lastRepeat, t, repeat, _ref, _tuple, _lhs, _tuple$1, before, _ref$1, after, _tuple$2, before$1, _tuple$3, min, max, after$1, ok, _tuple$4, _ref$2, lit, i, re, _tuple$5, r, rest, err$2, _tuple$6, r$1, rest$1, _tuple$7, _tuple$8, n, x; + if (!((((flags & 2) >>> 0) === 0))) { + err = checkUTF8(s); + if (!($interfaceIsEqual(err, $ifaceNil))) { + return [($ptrType(Regexp)).nil, err]; + } + return [literalRegexp(s, flags), $ifaceNil]; } - result = ($sliceType(($sliceType($Int)))).make(0, 10); - re.allMatches(s, ($sliceType($Uint8)).nil, n, (function(match) { - result = $append(result, match); - })); - if (result.$length === 0) { - return ($sliceType(($sliceType($Int)))).nil; + p = new parser.Ptr(); $copy(p, new parser.Ptr(), parser); + err$1 = $ifaceNil; + c = 0; + op = 0; + lastRepeat = ""; + p.flags = flags; + p.wholeRegexp = s; + t = s; + while (!(t === "")) { + repeat = ""; + _ref = t.charCodeAt(0); + BigSwitch: + switch (0) { default: if (_ref === 40) { + if (!((((p.flags & 64) >>> 0) === 0)) && t.length >= 2 && (t.charCodeAt(1) === 63)) { + _tuple = p.parsePerlFlags(t); t = _tuple[0]; err$1 = _tuple[1]; + if (!($interfaceIsEqual(err$1, $ifaceNil))) { + return [($ptrType(Regexp)).nil, err$1]; + } + break; + } + p.numCap = p.numCap + (1) >> 0; + p.op(128).Cap = p.numCap; + t = t.substring(1); + } else if (_ref === 124) { + err$1 = p.parseVerticalBar(); + if (!($interfaceIsEqual(err$1, $ifaceNil))) { + return [($ptrType(Regexp)).nil, err$1]; + } + t = t.substring(1); + } else if (_ref === 41) { + err$1 = p.parseRightParen(); + if (!($interfaceIsEqual(err$1, $ifaceNil))) { + return [($ptrType(Regexp)).nil, err$1]; + } + t = t.substring(1); + } else if (_ref === 94) { + if (!((((p.flags & 16) >>> 0) === 0))) { + p.op(9); + } else { + p.op(7); + } + t = t.substring(1); + } else if (_ref === 36) { + if (!((((p.flags & 16) >>> 0) === 0))) { + _lhs = p.op(10); _lhs.Flags = (_lhs.Flags | (256)) >>> 0; + } else { + p.op(8); + } + t = t.substring(1); + } else if (_ref === 46) { + if (!((((p.flags & 8) >>> 0) === 0))) { + p.op(6); + } else { + p.op(5); + } + t = t.substring(1); + } else if (_ref === 91) { + _tuple$1 = p.parseClass(t); t = _tuple$1[0]; err$1 = _tuple$1[1]; + if (!($interfaceIsEqual(err$1, $ifaceNil))) { + return [($ptrType(Regexp)).nil, err$1]; + } + } else if (_ref === 42 || _ref === 43 || _ref === 63) { + before = t; + _ref$1 = t.charCodeAt(0); + if (_ref$1 === 42) { + op = 14; + } else if (_ref$1 === 43) { + op = 15; + } else if (_ref$1 === 63) { + op = 16; + } + after = t.substring(1); + _tuple$2 = p.repeat(op, 0, 0, before, after, lastRepeat); after = _tuple$2[0]; err$1 = _tuple$2[1]; + if (!($interfaceIsEqual(err$1, $ifaceNil))) { + return [($ptrType(Regexp)).nil, err$1]; + } + repeat = before; + t = after; + } else if (_ref === 123) { + op = 17; + before$1 = t; + _tuple$3 = p.parseRepeat(t); min = _tuple$3[0]; max = _tuple$3[1]; after$1 = _tuple$3[2]; ok = _tuple$3[3]; + if (!ok) { + p.literal(123); + t = t.substring(1); + break; + } + if (min < 0 || min > 1000 || max > 1000 || max >= 0 && min > max) { + return [($ptrType(Regexp)).nil, new Error.Ptr("invalid repeat count", before$1.substring(0, (before$1.length - after$1.length >> 0)))]; + } + _tuple$4 = p.repeat(op, min, max, before$1, after$1, lastRepeat); after$1 = _tuple$4[0]; err$1 = _tuple$4[1]; + if (!($interfaceIsEqual(err$1, $ifaceNil))) { + return [($ptrType(Regexp)).nil, err$1]; + } + repeat = before$1; + t = after$1; + } else if (_ref === 92) { + if (!((((p.flags & 64) >>> 0) === 0)) && t.length >= 2) { + _ref$2 = t.charCodeAt(1); + if (_ref$2 === 65) { + p.op(9); + t = t.substring(2); + break BigSwitch; + } else if (_ref$2 === 98) { + p.op(11); + t = t.substring(2); + break BigSwitch; + } else if (_ref$2 === 66) { + p.op(12); + t = t.substring(2); + break BigSwitch; + } else if (_ref$2 === 67) { + return [($ptrType(Regexp)).nil, new Error.Ptr("invalid escape sequence", t.substring(0, 2))]; + } else if (_ref$2 === 81) { + lit = ""; + i = strings.Index(t, "\\E"); + if (i < 0) { + lit = t.substring(2); + t = ""; + } else { + lit = t.substring(2, i); + t = t.substring((i + 2 >> 0)); + } + p.push(literalRegexp(lit, p.flags)); + break BigSwitch; + } else if (_ref$2 === 122) { + p.op(10); + t = t.substring(2); + break BigSwitch; + } + } + re = p.newRegexp(4); + re.Flags = p.flags; + if (t.length >= 2 && ((t.charCodeAt(1) === 112) || (t.charCodeAt(1) === 80))) { + _tuple$5 = p.parseUnicodeClass(t, $subslice(new ($sliceType($Int32))(re.Rune0), 0, 0)); r = _tuple$5[0]; rest = _tuple$5[1]; err$2 = _tuple$5[2]; + if (!($interfaceIsEqual(err$2, $ifaceNil))) { + return [($ptrType(Regexp)).nil, err$2]; + } + if (!(r === ($sliceType($Int32)).nil)) { + re.Rune = r; + t = rest; + p.push(re); + break BigSwitch; + } + } + _tuple$6 = p.parsePerlClassEscape(t, $subslice(new ($sliceType($Int32))(re.Rune0), 0, 0)); r$1 = _tuple$6[0]; rest$1 = _tuple$6[1]; + if (!(r$1 === ($sliceType($Int32)).nil)) { + re.Rune = r$1; + t = rest$1; + p.push(re); + break BigSwitch; + } + p.reuse(re); + _tuple$7 = p.parseEscape(t); c = _tuple$7[0]; t = _tuple$7[1]; err$1 = _tuple$7[2]; + if (!($interfaceIsEqual(err$1, $ifaceNil))) { + return [($ptrType(Regexp)).nil, err$1]; + } + p.literal(c); + } else { + _tuple$8 = nextRune(t); c = _tuple$8[0]; t = _tuple$8[1]; err$1 = _tuple$8[2]; + if (!($interfaceIsEqual(err$1, $ifaceNil))) { + return [($ptrType(Regexp)).nil, err$1]; + } + p.literal(c); + } } + lastRepeat = repeat; } - return result; + p.concat(); + if (p.swapVerticalBar()) { + p.stack = $subslice(p.stack, 0, (p.stack.$length - 1 >> 0)); + } + p.alternate(); + n = p.stack.$length; + if (!((n === 1))) { + return [($ptrType(Regexp)).nil, new Error.Ptr("missing closing )", s)]; + } + return [(x = p.stack, ((0 < 0 || 0 >= x.$length) ? $throwRuntimeError("index out of range") : x.$array[x.$offset + 0])), $ifaceNil]; }; - Regexp.prototype.FindAllStringSubmatchIndex = function(s, n) { return this.$val.FindAllStringSubmatchIndex(s, n); }; - Regexp.Ptr.prototype.Split = function(s, n) { - var re, matches, strings$1, beg, end, _ref, _i, match; - re = this; - if (n === 0) { - return ($sliceType($String)).nil; + parser.Ptr.prototype.parseRepeat = function(s) { + var min = 0, max = 0, rest = "", ok = false, p, ok1, _tuple, _tuple$1; + p = this; + if (s === "" || !((s.charCodeAt(0) === 123))) { + return [min, max, rest, ok]; } - if (re.expr.length > 0 && (s.length === 0)) { - return new ($sliceType($String))([""]); + s = s.substring(1); + ok1 = false; + _tuple = p.parseInt(s); min = _tuple[0]; s = _tuple[1]; ok1 = _tuple[2]; + if (!ok1) { + return [min, max, rest, ok]; } - matches = re.FindAllStringIndex(s, n); - strings$1 = ($sliceType($String)).make(0, matches.$length); - beg = 0; - end = 0; - _ref = matches; - _i = 0; - while (_i < _ref.$length) { - match = ((_i < 0 || _i >= _ref.$length) ? $throwRuntimeError("index out of range") : _ref.$array[_ref.$offset + _i]); - if (n > 0 && strings$1.$length >= (n - 1 >> 0)) { - break; + if (s === "") { + return [min, max, rest, ok]; + } + if (!((s.charCodeAt(0) === 44))) { + max = min; + } else { + s = s.substring(1); + if (s === "") { + return [min, max, rest, ok]; } - end = ((0 < 0 || 0 >= match.$length) ? $throwRuntimeError("index out of range") : match.$array[match.$offset + 0]); - if (!((((1 < 0 || 1 >= match.$length) ? $throwRuntimeError("index out of range") : match.$array[match.$offset + 1]) === 0))) { - strings$1 = $append(strings$1, s.substring(beg, end)); + if (s.charCodeAt(0) === 125) { + max = -1; + } else { + _tuple$1 = p.parseInt(s); max = _tuple$1[0]; s = _tuple$1[1]; ok1 = _tuple$1[2]; + if (!ok1) { + return [min, max, rest, ok]; + } else if (max < 0) { + min = -1; + } } - beg = ((1 < 0 || 1 >= match.$length) ? $throwRuntimeError("index out of range") : match.$array[match.$offset + 1]); - _i++; } - if (!((end === s.length))) { - strings$1 = $append(strings$1, s.substring(beg)); + if (s === "" || !((s.charCodeAt(0) === 125))) { + return [min, max, rest, ok]; } - return strings$1; - }; - Regexp.prototype.Split = function(s, n) { return this.$val.Split(s, n); }; - $pkg.$init = function() { - queue.init([["sparse", "sparse", "regexp", ($sliceType($Uint32)), ""], ["dense", "dense", "regexp", ($sliceType(entry)), ""]]); - entry.init([["pc", "pc", "regexp", $Uint32, ""], ["t", "t", "regexp", ($ptrType(thread)), ""]]); - thread.init([["inst", "inst", "regexp", ($ptrType(syntax.Inst)), ""], ["cap", "cap", "regexp", ($sliceType($Int)), ""]]); - ($ptrType(machine)).methods = [["add", "add", "regexp", $funcType([($ptrType(queue)), $Uint32, $Int, ($sliceType($Int)), syntax.EmptyOp, ($ptrType(thread))], [($ptrType(thread))], false), -1], ["alloc", "alloc", "regexp", $funcType([($ptrType(syntax.Inst))], [($ptrType(thread))], false), -1], ["clear", "clear", "regexp", $funcType([($ptrType(queue))], [], false), -1], ["free", "free", "regexp", $funcType([($ptrType(thread))], [], false), -1], ["init", "init", "regexp", $funcType([$Int], [], false), -1], ["match", "match", "regexp", $funcType([input, $Int], [$Bool], false), -1], ["newInputBytes", "newInputBytes", "regexp", $funcType([($sliceType($Uint8))], [input], false), -1], ["newInputReader", "newInputReader", "regexp", $funcType([io.RuneReader], [input], false), -1], ["newInputString", "newInputString", "regexp", $funcType([$String], [input], false), -1], ["onepass", "onepass", "regexp", $funcType([input, $Int], [$Bool], false), -1], ["step", "step", "regexp", $funcType([($ptrType(queue)), ($ptrType(queue)), $Int, $Int, $Int32, syntax.EmptyOp], [], false), -1]]; - machine.init([["re", "re", "regexp", ($ptrType(Regexp)), ""], ["p", "p", "regexp", ($ptrType(syntax.Prog)), ""], ["op", "op", "regexp", ($ptrType(onePassProg)), ""], ["q0", "q0", "regexp", queue, ""], ["q1", "q1", "regexp", queue, ""], ["pool", "pool", "regexp", ($sliceType(($ptrType(thread)))), ""], ["matched", "matched", "regexp", $Bool, ""], ["matchcap", "matchcap", "regexp", ($sliceType($Int)), ""], ["inputBytes", "inputBytes", "regexp", inputBytes, ""], ["inputString", "inputString", "regexp", inputString, ""], ["inputReader", "inputReader", "regexp", inputReader, ""]]); - onePassProg.init([["Inst", "Inst", "", ($sliceType(onePassInst)), ""], ["Start", "Start", "", $Int, ""], ["NumCap", "NumCap", "", $Int, ""]]); - ($ptrType(onePassInst)).methods = [["MatchEmptyWidth", "MatchEmptyWidth", "", $funcType([$Int32, $Int32], [$Bool], false), 0], ["MatchRune", "MatchRune", "", $funcType([$Int32], [$Bool], false), 0], ["MatchRunePos", "MatchRunePos", "", $funcType([$Int32], [$Int], false), 0], ["String", "String", "", $funcType([], [$String], false), 0], ["op", "op", "regexp/syntax", $funcType([], [syntax.InstOp], false), 0]]; - onePassInst.init([["Inst", "", "", syntax.Inst, ""], ["Next", "Next", "", ($sliceType($Uint32)), ""]]); - ($ptrType(queueOnePass)).methods = [["clear", "clear", "regexp", $funcType([], [], false), -1], ["contains", "contains", "regexp", $funcType([$Uint32], [$Bool], false), -1], ["empty", "empty", "regexp", $funcType([], [$Bool], false), -1], ["insert", "insert", "regexp", $funcType([$Uint32], [], false), -1], ["insertNew", "insertNew", "regexp", $funcType([$Uint32], [], false), -1], ["next", "next", "regexp", $funcType([], [$Uint32], false), -1], ["reset", "reset", "regexp", $funcType([], [], false), -1]]; - queueOnePass.init([["sparse", "sparse", "regexp", ($sliceType($Uint32)), ""], ["dense", "dense", "regexp", ($sliceType($Uint32)), ""], ["size", "size", "regexp", $Uint32, ""], ["nextIndex", "nextIndex", "regexp", $Uint32, ""]]); - runeSlice.methods = [["Len", "Len", "", $funcType([], [$Int], false), -1], ["Less", "Less", "", $funcType([$Int, $Int], [$Bool], false), -1], ["Sort", "Sort", "", $funcType([], [], false), -1], ["Swap", "Swap", "", $funcType([$Int, $Int], [], false), -1]]; - ($ptrType(runeSlice)).methods = [["Len", "Len", "", $funcType([], [$Int], false), -1], ["Less", "Less", "", $funcType([$Int, $Int], [$Bool], false), -1], ["Sort", "Sort", "", $funcType([], [], false), -1], ["Swap", "Swap", "", $funcType([$Int, $Int], [], false), -1]]; - runeSlice.init($Int32); - ($ptrType(Regexp)).methods = [["Expand", "Expand", "", $funcType([($sliceType($Uint8)), ($sliceType($Uint8)), ($sliceType($Uint8)), ($sliceType($Int))], [($sliceType($Uint8))], false), -1], ["ExpandString", "ExpandString", "", $funcType([($sliceType($Uint8)), $String, $String, ($sliceType($Int))], [($sliceType($Uint8))], false), -1], ["Find", "Find", "", $funcType([($sliceType($Uint8))], [($sliceType($Uint8))], false), -1], ["FindAll", "FindAll", "", $funcType([($sliceType($Uint8)), $Int], [($sliceType(($sliceType($Uint8))))], false), -1], ["FindAllIndex", "FindAllIndex", "", $funcType([($sliceType($Uint8)), $Int], [($sliceType(($sliceType($Int))))], false), -1], ["FindAllString", "FindAllString", "", $funcType([$String, $Int], [($sliceType($String))], false), -1], ["FindAllStringIndex", "FindAllStringIndex", "", $funcType([$String, $Int], [($sliceType(($sliceType($Int))))], false), -1], ["FindAllStringSubmatch", "FindAllStringSubmatch", "", $funcType([$String, $Int], [($sliceType(($sliceType($String))))], false), -1], ["FindAllStringSubmatchIndex", "FindAllStringSubmatchIndex", "", $funcType([$String, $Int], [($sliceType(($sliceType($Int))))], false), -1], ["FindAllSubmatch", "FindAllSubmatch", "", $funcType([($sliceType($Uint8)), $Int], [($sliceType(($sliceType(($sliceType($Uint8))))))], false), -1], ["FindAllSubmatchIndex", "FindAllSubmatchIndex", "", $funcType([($sliceType($Uint8)), $Int], [($sliceType(($sliceType($Int))))], false), -1], ["FindIndex", "FindIndex", "", $funcType([($sliceType($Uint8))], [($sliceType($Int))], false), -1], ["FindReaderIndex", "FindReaderIndex", "", $funcType([io.RuneReader], [($sliceType($Int))], false), -1], ["FindReaderSubmatchIndex", "FindReaderSubmatchIndex", "", $funcType([io.RuneReader], [($sliceType($Int))], false), -1], ["FindString", "FindString", "", $funcType([$String], [$String], false), -1], ["FindStringIndex", "FindStringIndex", "", $funcType([$String], [($sliceType($Int))], false), -1], ["FindStringSubmatch", "FindStringSubmatch", "", $funcType([$String], [($sliceType($String))], false), -1], ["FindStringSubmatchIndex", "FindStringSubmatchIndex", "", $funcType([$String], [($sliceType($Int))], false), -1], ["FindSubmatch", "FindSubmatch", "", $funcType([($sliceType($Uint8))], [($sliceType(($sliceType($Uint8))))], false), -1], ["FindSubmatchIndex", "FindSubmatchIndex", "", $funcType([($sliceType($Uint8))], [($sliceType($Int))], false), -1], ["LiteralPrefix", "LiteralPrefix", "", $funcType([], [$String, $Bool], false), -1], ["Longest", "Longest", "", $funcType([], [], false), -1], ["Match", "Match", "", $funcType([($sliceType($Uint8))], [$Bool], false), -1], ["MatchReader", "MatchReader", "", $funcType([io.RuneReader], [$Bool], false), -1], ["MatchString", "MatchString", "", $funcType([$String], [$Bool], false), -1], ["NumSubexp", "NumSubexp", "", $funcType([], [$Int], false), -1], ["ReplaceAll", "ReplaceAll", "", $funcType([($sliceType($Uint8)), ($sliceType($Uint8))], [($sliceType($Uint8))], false), -1], ["ReplaceAllFunc", "ReplaceAllFunc", "", $funcType([($sliceType($Uint8)), ($funcType([($sliceType($Uint8))], [($sliceType($Uint8))], false))], [($sliceType($Uint8))], false), -1], ["ReplaceAllLiteral", "ReplaceAllLiteral", "", $funcType([($sliceType($Uint8)), ($sliceType($Uint8))], [($sliceType($Uint8))], false), -1], ["ReplaceAllLiteralString", "ReplaceAllLiteralString", "", $funcType([$String, $String], [$String], false), -1], ["ReplaceAllString", "ReplaceAllString", "", $funcType([$String, $String], [$String], false), -1], ["ReplaceAllStringFunc", "ReplaceAllStringFunc", "", $funcType([$String, ($funcType([$String], [$String], false))], [$String], false), -1], ["Split", "Split", "", $funcType([$String, $Int], [($sliceType($String))], false), -1], ["String", "String", "", $funcType([], [$String], false), -1], ["SubexpNames", "SubexpNames", "", $funcType([], [($sliceType($String))], false), -1], ["allMatches", "allMatches", "regexp", $funcType([$String, ($sliceType($Uint8)), $Int, ($funcType([($sliceType($Int))], [], false))], [], false), -1], ["doExecute", "doExecute", "regexp", $funcType([io.RuneReader, ($sliceType($Uint8)), $String, $Int, $Int], [($sliceType($Int))], false), -1], ["expand", "expand", "regexp", $funcType([($sliceType($Uint8)), $String, ($sliceType($Uint8)), $String, ($sliceType($Int))], [($sliceType($Uint8))], false), -1], ["get", "get", "regexp", $funcType([], [($ptrType(machine))], false), -1], ["pad", "pad", "regexp", $funcType([($sliceType($Int))], [($sliceType($Int))], false), -1], ["put", "put", "regexp", $funcType([($ptrType(machine))], [], false), -1], ["replaceAll", "replaceAll", "regexp", $funcType([($sliceType($Uint8)), $String, $Int, ($funcType([($sliceType($Uint8)), ($sliceType($Int))], [($sliceType($Uint8))], false))], [($sliceType($Uint8))], false), -1]]; - Regexp.init([["expr", "expr", "regexp", $String, ""], ["prog", "prog", "regexp", ($ptrType(syntax.Prog)), ""], ["onepass", "onepass", "regexp", ($ptrType(onePassProg)), ""], ["prefix", "prefix", "regexp", $String, ""], ["prefixBytes", "prefixBytes", "regexp", ($sliceType($Uint8)), ""], ["prefixComplete", "prefixComplete", "regexp", $Bool, ""], ["prefixRune", "prefixRune", "regexp", $Int32, ""], ["prefixEnd", "prefixEnd", "regexp", $Uint32, ""], ["cond", "cond", "regexp", syntax.EmptyOp, ""], ["numSubexp", "numSubexp", "regexp", $Int, ""], ["subexpNames", "subexpNames", "regexp", ($sliceType($String)), ""], ["longest", "longest", "regexp", $Bool, ""], ["mu", "mu", "regexp", sync.Mutex, ""], ["machine", "machine", "regexp", ($sliceType(($ptrType(machine)))), ""]]); - input.init([["canCheckPrefix", "canCheckPrefix", "regexp", $funcType([], [$Bool], false)], ["context", "context", "regexp", $funcType([$Int], [syntax.EmptyOp], false)], ["hasPrefix", "hasPrefix", "regexp", $funcType([($ptrType(Regexp))], [$Bool], false)], ["index", "index", "regexp", $funcType([($ptrType(Regexp)), $Int], [$Int], false)], ["step", "step", "regexp", $funcType([$Int], [$Int32, $Int], false)]]); - ($ptrType(inputString)).methods = [["canCheckPrefix", "canCheckPrefix", "regexp", $funcType([], [$Bool], false), -1], ["context", "context", "regexp", $funcType([$Int], [syntax.EmptyOp], false), -1], ["hasPrefix", "hasPrefix", "regexp", $funcType([($ptrType(Regexp))], [$Bool], false), -1], ["index", "index", "regexp", $funcType([($ptrType(Regexp)), $Int], [$Int], false), -1], ["step", "step", "regexp", $funcType([$Int], [$Int32, $Int], false), -1]]; - inputString.init([["str", "str", "regexp", $String, ""]]); - ($ptrType(inputBytes)).methods = [["canCheckPrefix", "canCheckPrefix", "regexp", $funcType([], [$Bool], false), -1], ["context", "context", "regexp", $funcType([$Int], [syntax.EmptyOp], false), -1], ["hasPrefix", "hasPrefix", "regexp", $funcType([($ptrType(Regexp))], [$Bool], false), -1], ["index", "index", "regexp", $funcType([($ptrType(Regexp)), $Int], [$Int], false), -1], ["step", "step", "regexp", $funcType([$Int], [$Int32, $Int], false), -1]]; - inputBytes.init([["str", "str", "regexp", ($sliceType($Uint8)), ""]]); - ($ptrType(inputReader)).methods = [["canCheckPrefix", "canCheckPrefix", "regexp", $funcType([], [$Bool], false), -1], ["context", "context", "regexp", $funcType([$Int], [syntax.EmptyOp], false), -1], ["hasPrefix", "hasPrefix", "regexp", $funcType([($ptrType(Regexp))], [$Bool], false), -1], ["index", "index", "regexp", $funcType([($ptrType(Regexp)), $Int], [$Int], false), -1], ["step", "step", "regexp", $funcType([$Int], [$Int32, $Int], false), -1]]; - inputReader.init([["r", "r", "regexp", io.RuneReader, ""], ["atEOT", "atEOT", "regexp", $Bool, ""], ["pos", "pos", "regexp", $Int, ""]]); - empty = ($sliceType($Int)).make(0); - noRune = new ($sliceType($Int32))([]); - noNext = new ($sliceType($Uint32))([4294967295]); - anyRuneNotNL = new ($sliceType($Int32))([0, 9, 11, 1114111]); - anyRune = new ($sliceType($Int32))([0, 1114111]); - notOnePass = ($ptrType(onePassProg)).nil; + rest = s.substring(1); + ok = true; + return [min, max, rest, ok]; }; - return $pkg; -})(); -$packages["net/url"] = (function() { - var $pkg = {}, bytes = $packages["bytes"], errors = $packages["errors"], sort = $packages["sort"], strconv = $packages["strconv"], strings = $packages["strings"], shouldEscape, QueryEscape, escape; - shouldEscape = function(c, mode) { - var _ref, _ref$1; - if (65 <= c && c <= 90 || 97 <= c && c <= 122 || 48 <= c && c <= 57) { - return false; + parser.prototype.parseRepeat = function(s) { return this.$val.parseRepeat(s); }; + parser.Ptr.prototype.parsePerlFlags = function(s) { + var rest = "", err = $ifaceNil, p, t, end, _tmp, _tmp$1, _tmp$2, _tmp$3, capture, name, _tmp$4, _tmp$5, _tmp$6, _tmp$7, re, _tmp$8, _tmp$9, c, flags, sign, sawFlag, _tuple, _tmp$10, _tmp$11, _ref, _tmp$12, _tmp$13, _tmp$14, _tmp$15; + p = this; + t = s; + if (t.length > 4 && (t.charCodeAt(2) === 80) && (t.charCodeAt(3) === 60)) { + end = strings.IndexRune(t, 62); + if (end < 0) { + err = checkUTF8(t); + if (!($interfaceIsEqual(err, $ifaceNil))) { + _tmp = ""; _tmp$1 = err; rest = _tmp; err = _tmp$1; + return [rest, err]; + } + _tmp$2 = ""; _tmp$3 = new Error.Ptr("invalid named capture", s); rest = _tmp$2; err = _tmp$3; + return [rest, err]; + } + capture = t.substring(0, (end + 1 >> 0)); + name = t.substring(4, end); + err = checkUTF8(name); + if (!($interfaceIsEqual(err, $ifaceNil))) { + _tmp$4 = ""; _tmp$5 = err; rest = _tmp$4; err = _tmp$5; + return [rest, err]; + } + if (!isValidCaptureName(name)) { + _tmp$6 = ""; _tmp$7 = new Error.Ptr("invalid named capture", capture); rest = _tmp$6; err = _tmp$7; + return [rest, err]; + } + p.numCap = p.numCap + (1) >> 0; + re = p.op(128); + re.Cap = p.numCap; + re.Name = name; + _tmp$8 = t.substring((end + 1 >> 0)); _tmp$9 = $ifaceNil; rest = _tmp$8; err = _tmp$9; + return [rest, err]; } - _ref = c; - if (_ref === 45 || _ref === 95 || _ref === 46 || _ref === 126) { - return false; - } else if (_ref === 36 || _ref === 38 || _ref === 43 || _ref === 44 || _ref === 47 || _ref === 58 || _ref === 59 || _ref === 61 || _ref === 63 || _ref === 64) { - _ref$1 = mode; - if (_ref$1 === 1) { - return c === 63; - } else if (_ref$1 === 2) { - return (c === 64) || (c === 47) || (c === 58); - } else if (_ref$1 === 3) { - return true; - } else if (_ref$1 === 4) { - return false; + c = 0; + t = t.substring(2); + flags = p.flags; + sign = 1; + sawFlag = false; + Loop: + while (!(t === "")) { + _tuple = nextRune(t); c = _tuple[0]; t = _tuple[1]; err = _tuple[2]; + if (!($interfaceIsEqual(err, $ifaceNil))) { + _tmp$10 = ""; _tmp$11 = err; rest = _tmp$10; err = _tmp$11; + return [rest, err]; } - } - return true; - }; - QueryEscape = $pkg.QueryEscape = function(s) { - return escape(s, 3); - }; - escape = function(s, mode) { - var _tmp, _tmp$1, spaceCount, hexCount, i, c, t, j, i$1, c$1, x, x$1; - _tmp = 0; _tmp$1 = 0; spaceCount = _tmp; hexCount = _tmp$1; - i = 0; - while (i < s.length) { - c = s.charCodeAt(i); - if (shouldEscape(c, mode)) { - if ((c === 32) && (mode === 3)) { - spaceCount = spaceCount + (1) >> 0; - } else { - hexCount = hexCount + (1) >> 0; + _ref = c; + if (_ref === 105) { + flags = (flags | (1)) >>> 0; + sawFlag = true; + } else if (_ref === 109) { + flags = flags & ~(16); + sawFlag = true; + } else if (_ref === 115) { + flags = (flags | (8)) >>> 0; + sawFlag = true; + } else if (_ref === 85) { + flags = (flags | (32)) >>> 0; + sawFlag = true; + } else if (_ref === 45) { + if (sign < 0) { + break Loop; + } + sign = -1; + flags = ~flags << 16 >>> 16; + sawFlag = false; + } else if (_ref === 58 || _ref === 41) { + if (sign < 0) { + if (!sawFlag) { + break Loop; + } + flags = ~flags << 16 >>> 16; + } + if (c === 58) { + p.op(128); } + p.flags = flags; + _tmp$12 = t; _tmp$13 = $ifaceNil; rest = _tmp$12; err = _tmp$13; + return [rest, err]; + } else { + break Loop; } - i = i + (1) >> 0; } - if ((spaceCount === 0) && (hexCount === 0)) { - return s; + _tmp$14 = ""; _tmp$15 = new Error.Ptr("invalid or unsupported Perl syntax", s.substring(0, (s.length - t.length >> 0))); rest = _tmp$14; err = _tmp$15; + return [rest, err]; + }; + parser.prototype.parsePerlFlags = function(s) { return this.$val.parsePerlFlags(s); }; + isValidCaptureName = function(name) { + var _ref, _i, _rune, c; + if (name === "") { + return false; } - t = ($sliceType($Uint8)).make((s.length + ((((2 >>> 16 << 16) * hexCount >> 0) + (2 << 16 >>> 16) * hexCount) >> 0) >> 0)); - j = 0; - i$1 = 0; - while (i$1 < s.length) { - c$1 = s.charCodeAt(i$1); - if ((c$1 === 32) && (mode === 3)) { - (j < 0 || j >= t.$length) ? $throwRuntimeError("index out of range") : t.$array[t.$offset + j] = 43; - j = j + (1) >> 0; - } else if (shouldEscape(c$1, mode)) { - (j < 0 || j >= t.$length) ? $throwRuntimeError("index out of range") : t.$array[t.$offset + j] = 37; - (x = j + 1 >> 0, (x < 0 || x >= t.$length) ? $throwRuntimeError("index out of range") : t.$array[t.$offset + x] = "0123456789ABCDEF".charCodeAt((c$1 >>> 4 << 24 >>> 24))); - (x$1 = j + 2 >> 0, (x$1 < 0 || x$1 >= t.$length) ? $throwRuntimeError("index out of range") : t.$array[t.$offset + x$1] = "0123456789ABCDEF".charCodeAt(((c$1 & 15) >>> 0))); - j = j + (3) >> 0; - } else { - (j < 0 || j >= t.$length) ? $throwRuntimeError("index out of range") : t.$array[t.$offset + j] = s.charCodeAt(i$1); - j = j + (1) >> 0; + _ref = name; + _i = 0; + while (_i < _ref.length) { + _rune = $decodeRune(_ref, _i); + c = _rune[0]; + if (!((c === 95)) && !isalnum(c)) { + return false; } - i$1 = i$1 + (1) >> 0; + _i += _rune[1]; } - return $bytesToString(t); - }; - $pkg.$init = function() { - }; - return $pkg; -})(); -$packages["container/list"] = (function() { - var $pkg = {}; - $pkg.$init = function() { - }; - return $pkg; -})(); -$packages["text/template/parse"] = (function() { - var $pkg = {}, list = $packages["container/list"], fmt = $packages["fmt"], strings = $packages["strings"], unicode = $packages["unicode"], utf8 = $packages["unicode/utf8"], bytes = $packages["bytes"], strconv = $packages["strconv"], runtime = $packages["runtime"]; - $pkg.$init = function() { + return true; }; - return $pkg; -})(); -$packages["text/template"] = (function() { - var $pkg = {}, bytes = $packages["bytes"], fmt = $packages["fmt"], io = $packages["io"], reflect = $packages["reflect"], runtime = $packages["runtime"], sort = $packages["sort"], strings = $packages["strings"], parse = $packages["text/template/parse"], errors = $packages["errors"], url = $packages["net/url"], unicode = $packages["unicode"], utf8 = $packages["unicode/utf8"], ioutil = $packages["io/ioutil"], filepath = $packages["path/filepath"], errorType, fmtStringerType, builtins, builtinFuncs, errBadComparisonType, errBadComparison, errNoComparison, htmlQuot, htmlApos, htmlAmp, htmlLt, htmlGt, jsLowUni, hex, jsBackslash, jsApos, jsQuot, jsLt, jsGt, _map, _key, isTrue, canBeNil, indirect, printableValue, createValueFuncs, addValueFuncs, goodFunc, index, length, call, truth, and, or, not, basicKind, eq, ne, lt, le, gt, ge, HTMLEscape, HTMLEscapeString, HTMLEscaper, JSEscape, JSEscapeString, jsIsSpecial, JSEscaper, URLQueryEscaper, evalArgs; - isTrue = function(val) { - var truth$1 = false, ok = false, _tmp, _tmp$1, _ref, x, x$1, x$2, _tmp$2, _tmp$3; - if (!val.IsValid()) { - _tmp = false; _tmp$1 = true; truth$1 = _tmp; ok = _tmp$1; - return [truth$1, ok]; + parser.Ptr.prototype.parseInt = function(s) { + var n = 0, rest = "", ok = false, p, t, i; + p = this; + if (s === "" || s.charCodeAt(0) < 48 || 57 < s.charCodeAt(0)) { + return [n, rest, ok]; } - _ref = val.Kind(); - if (_ref === 17 || _ref === 21 || _ref === 23 || _ref === 24) { - truth$1 = val.Len() > 0; - } else if (_ref === 1) { - truth$1 = val.Bool(); - } else if (_ref === 15 || _ref === 16) { - truth$1 = !((x = val.Complex(), (x.$real === 0 && x.$imag === 0))); - } else if (_ref === 18 || _ref === 19 || _ref === 22 || _ref === 20) { - truth$1 = !val.IsNil(); - } else if (_ref === 2 || _ref === 3 || _ref === 4 || _ref === 5 || _ref === 6) { - truth$1 = !((x$1 = val.Int(), (x$1.$high === 0 && x$1.$low === 0))); - } else if (_ref === 13 || _ref === 14) { - truth$1 = !((val.Float() === 0)); - } else if (_ref === 7 || _ref === 8 || _ref === 9 || _ref === 10 || _ref === 11 || _ref === 12) { - truth$1 = !((x$2 = val.Uint(), (x$2.$high === 0 && x$2.$low === 0))); - } else if (_ref === 25) { - truth$1 = true; - } else { - return [truth$1, ok]; + if (s.length >= 2 && (s.charCodeAt(0) === 48) && 48 <= s.charCodeAt(1) && s.charCodeAt(1) <= 57) { + return [n, rest, ok]; } - _tmp$2 = truth$1; _tmp$3 = true; truth$1 = _tmp$2; ok = _tmp$3; - return [truth$1, ok]; - }; - canBeNil = function(typ) { - var _ref; - _ref = typ.Kind(); - if (_ref === 18 || _ref === 19 || _ref === 20 || _ref === 21 || _ref === 22 || _ref === 23) { - return true; + t = s; + while (!(s === "") && 48 <= s.charCodeAt(0) && s.charCodeAt(0) <= 57) { + s = s.substring(1); } - return false; - }; - indirect = function(v) { - var rv = new reflect.Value.Ptr(), isNil = false, _tmp, _tmp$1, _tmp$2, _tmp$3; - while ((v.Kind() === 22) || (v.Kind() === 20)) { - if (v.IsNil()) { - _tmp = new reflect.Value.Ptr(); $copy(_tmp, v, reflect.Value); _tmp$1 = true; $copy(rv, _tmp, reflect.Value); isNil = _tmp$1; - return [rv, isNil]; - } - if ((v.Kind() === 20) && v.NumMethod() > 0) { + rest = s; + ok = true; + t = t.substring(0, (t.length - s.length >> 0)); + i = 0; + while (i < t.length) { + if (n >= 100000000) { + n = -1; break; } - $copy(v, v.Elem(), reflect.Value); + n = (((((n >>> 16 << 16) * 10 >> 0) + (n << 16 >>> 16) * 10) >> 0) + (t.charCodeAt(i) >> 0) >> 0) - 48 >> 0; + i = i + (1) >> 0; } - _tmp$2 = new reflect.Value.Ptr(); $copy(_tmp$2, v, reflect.Value); _tmp$3 = false; $copy(rv, _tmp$2, reflect.Value); isNil = _tmp$3; - return [rv, isNil]; + return [n, rest, ok]; }; - printableValue = function(v) { - var _tuple, _ref; - if (v.Kind() === 22) { - _tuple = indirect($clone(v, reflect.Value)); $copy(v, _tuple[0], reflect.Value); - } - if (!v.IsValid()) { - return [new $String(""), true]; - } - if (!v.Type().Implements(errorType) && !v.Type().Implements(fmtStringerType)) { - if (v.CanAddr() && (reflect.PtrTo(v.Type()).Implements(errorType) || reflect.PtrTo(v.Type()).Implements(fmtStringerType))) { - $copy(v, v.Addr(), reflect.Value); - } else { - _ref = v.Kind(); - if (_ref === 18 || _ref === 19) { - return [$ifaceNil, false]; + parser.prototype.parseInt = function(s) { return this.$val.parseInt(s); }; + isCharClass = function(re) { + return (re.Op === 3) && (re.Rune.$length === 1) || (re.Op === 4) || (re.Op === 5) || (re.Op === 6); + }; + matchRune = function(re, r) { + var _ref, x, i, x$1, x$2, x$3; + _ref = re.Op; + if (_ref === 3) { + return (re.Rune.$length === 1) && ((x = re.Rune, ((0 < 0 || 0 >= x.$length) ? $throwRuntimeError("index out of range") : x.$array[x.$offset + 0])) === r); + } else if (_ref === 4) { + i = 0; + while (i < re.Rune.$length) { + if ((x$1 = re.Rune, ((i < 0 || i >= x$1.$length) ? $throwRuntimeError("index out of range") : x$1.$array[x$1.$offset + i])) <= r && r <= (x$2 = re.Rune, x$3 = i + 1 >> 0, ((x$3 < 0 || x$3 >= x$2.$length) ? $throwRuntimeError("index out of range") : x$2.$array[x$2.$offset + x$3]))) { + return true; } + i = i + (2) >> 0; } + return false; + } else if (_ref === 5) { + return !((r === 10)); + } else if (_ref === 6) { + return true; } - return [v.Interface(), true]; + return false; }; - createValueFuncs = function(funcMap) { - var m; - m = new $Map(); - addValueFuncs(m, funcMap); - return m; + parser.Ptr.prototype.parseVerticalBar = function() { + var p; + p = this; + p.concat(); + if (!p.swapVerticalBar()) { + p.op(129); + } + return $ifaceNil; }; - addValueFuncs = function(out, in$1) { - var _ref, _i, _keys, _entry, name, fn, v, _key$1; - _ref = in$1; - _i = 0; - _keys = $keys(_ref); - while (_i < _keys.length) { - _entry = _ref[_keys[_i]]; - if (_entry === undefined) { - _i++; - continue; + parser.prototype.parseVerticalBar = function() { return this.$val.parseVerticalBar(); }; + mergeCharClass = function(dst, src) { + var _ref, x, x$1, x$2, x$3, x$4; + _ref = dst.Op; + switch (0) { default: if (_ref === 6) { + } else if (_ref === 5) { + if (matchRune(src, 10)) { + dst.Op = 6; } - name = _entry.k; - fn = _entry.v; - v = new reflect.Value.Ptr(); $copy(v, reflect.ValueOf(fn), reflect.Value); - if (!((v.Kind() === 19))) { - $panic(new $String("value for " + name + " not a function")); + } else if (_ref === 4) { + if (src.Op === 3) { + dst.Rune = appendLiteral(dst.Rune, (x = src.Rune, ((0 < 0 || 0 >= x.$length) ? $throwRuntimeError("index out of range") : x.$array[x.$offset + 0])), src.Flags); + } else { + dst.Rune = appendClass(dst.Rune, src.Rune); } - if (!goodFunc(v.Type())) { - $panic(fmt.Errorf("can't install method/function %q with %d results", new ($sliceType($emptyInterface))([new $String(name), new $Int(v.Type().NumOut())]))); + } else if (_ref === 3) { + if (((x$1 = src.Rune, ((0 < 0 || 0 >= x$1.$length) ? $throwRuntimeError("index out of range") : x$1.$array[x$1.$offset + 0])) === (x$2 = dst.Rune, ((0 < 0 || 0 >= x$2.$length) ? $throwRuntimeError("index out of range") : x$2.$array[x$2.$offset + 0]))) && (src.Flags === dst.Flags)) { + break; } - _key$1 = name; (out || $throwRuntimeError("assignment to entry in nil map"))[_key$1] = { k: _key$1, v: v }; - _i++; - } + dst.Op = 4; + dst.Rune = appendLiteral($subslice(dst.Rune, 0, 0), (x$3 = dst.Rune, ((0 < 0 || 0 >= x$3.$length) ? $throwRuntimeError("index out of range") : x$3.$array[x$3.$offset + 0])), dst.Flags); + dst.Rune = appendLiteral(dst.Rune, (x$4 = src.Rune, ((0 < 0 || 0 >= x$4.$length) ? $throwRuntimeError("index out of range") : x$4.$array[x$4.$offset + 0])), src.Flags); + } } }; - goodFunc = function(typ) { - if (typ.NumOut() === 1) { - return true; - } else if ((typ.NumOut() === 2) && $interfaceIsEqual(typ.Out(1), errorType)) { + parser.Ptr.prototype.swapVerticalBar = function() { + var p, n, x, x$1, x$2, x$3, x$4, x$5, x$6, x$7, re1, x$8, x$9, re3, _tmp, _tmp$1, x$10, x$11, x$12, x$13, re1$1, x$14, x$15, re2, x$16, x$17, x$18, x$19, x$20, x$21; + p = this; + n = p.stack.$length; + if (n >= 3 && ((x = p.stack, x$1 = n - 2 >> 0, ((x$1 < 0 || x$1 >= x.$length) ? $throwRuntimeError("index out of range") : x.$array[x.$offset + x$1])).Op === 129) && isCharClass((x$2 = p.stack, x$3 = n - 1 >> 0, ((x$3 < 0 || x$3 >= x$2.$length) ? $throwRuntimeError("index out of range") : x$2.$array[x$2.$offset + x$3]))) && isCharClass((x$4 = p.stack, x$5 = n - 3 >> 0, ((x$5 < 0 || x$5 >= x$4.$length) ? $throwRuntimeError("index out of range") : x$4.$array[x$4.$offset + x$5])))) { + re1 = (x$6 = p.stack, x$7 = n - 1 >> 0, ((x$7 < 0 || x$7 >= x$6.$length) ? $throwRuntimeError("index out of range") : x$6.$array[x$6.$offset + x$7])); + re3 = (x$8 = p.stack, x$9 = n - 3 >> 0, ((x$9 < 0 || x$9 >= x$8.$length) ? $throwRuntimeError("index out of range") : x$8.$array[x$8.$offset + x$9])); + if (re1.Op > re3.Op) { + _tmp = re3; _tmp$1 = re1; re1 = _tmp; re3 = _tmp$1; + (x$10 = p.stack, x$11 = n - 3 >> 0, (x$11 < 0 || x$11 >= x$10.$length) ? $throwRuntimeError("index out of range") : x$10.$array[x$10.$offset + x$11] = re3); + } + mergeCharClass(re3, re1); + p.reuse(re1); + p.stack = $subslice(p.stack, 0, (n - 1 >> 0)); return true; } - return false; - }; - index = function(item, indices) { - var v, _ref, _i, i, index$1, isNil, _tuple, _ref$1, x, _ref$2, x$1, x$2, x$3; - v = new reflect.Value.Ptr(); $copy(v, reflect.ValueOf(item), reflect.Value); - _ref = indices; - _i = 0; - while (_i < _ref.$length) { - i = ((_i < 0 || _i >= _ref.$length) ? $throwRuntimeError("index out of range") : _ref.$array[_ref.$offset + _i]); - index$1 = new reflect.Value.Ptr(); $copy(index$1, reflect.ValueOf(i), reflect.Value); - isNil = false; - _tuple = indirect($clone(v, reflect.Value)); $copy(v, _tuple[0], reflect.Value); isNil = _tuple[1]; - if (isNil) { - return [$ifaceNil, fmt.Errorf("index of nil pointer", new ($sliceType($emptyInterface))([]))]; - } - _ref$1 = v.Kind(); - if (_ref$1 === 17 || _ref$1 === 23 || _ref$1 === 24) { - x = new $Int64(0, 0); - _ref$2 = index$1.Kind(); - if (_ref$2 === 2 || _ref$2 === 3 || _ref$2 === 4 || _ref$2 === 5 || _ref$2 === 6) { - x = index$1.Int(); - } else if (_ref$2 === 7 || _ref$2 === 8 || _ref$2 === 9 || _ref$2 === 10 || _ref$2 === 11 || _ref$2 === 12) { - x = (x$1 = index$1.Uint(), new $Int64(x$1.$high, x$1.$low)); - } else { - return [$ifaceNil, fmt.Errorf("cannot index slice/array with type %s", new ($sliceType($emptyInterface))([index$1.Type()]))]; - } - if ((x.$high < 0 || (x.$high === 0 && x.$low < 0)) || (x$2 = new $Int64(0, v.Len()), (x.$high > x$2.$high || (x.$high === x$2.$high && x.$low >= x$2.$low)))) { - return [$ifaceNil, fmt.Errorf("index out of range: %d", new ($sliceType($emptyInterface))([x]))]; - } - $copy(v, v.Index(((x.$low + ((x.$high >> 31) * 4294967296)) >> 0)), reflect.Value); - } else if (_ref$1 === 21) { - if (!index$1.IsValid()) { - $copy(index$1, reflect.Zero(v.Type().Key()), reflect.Value); - } - if (!index$1.Type().AssignableTo(v.Type().Key())) { - return [$ifaceNil, fmt.Errorf("%s is not index type for %s", new ($sliceType($emptyInterface))([index$1.Type(), v.Type()]))]; - } - x$3 = new reflect.Value.Ptr(); $copy(x$3, v.MapIndex($clone(index$1, reflect.Value)), reflect.Value); - if (x$3.IsValid()) { - $copy(v, x$3, reflect.Value); - } else { - $copy(v, reflect.Zero(v.Type().Elem()), reflect.Value); + if (n >= 2) { + re1$1 = (x$12 = p.stack, x$13 = n - 1 >> 0, ((x$13 < 0 || x$13 >= x$12.$length) ? $throwRuntimeError("index out of range") : x$12.$array[x$12.$offset + x$13])); + re2 = (x$14 = p.stack, x$15 = n - 2 >> 0, ((x$15 < 0 || x$15 >= x$14.$length) ? $throwRuntimeError("index out of range") : x$14.$array[x$14.$offset + x$15])); + if (re2.Op === 129) { + if (n >= 3) { + cleanAlt((x$16 = p.stack, x$17 = n - 3 >> 0, ((x$17 < 0 || x$17 >= x$16.$length) ? $throwRuntimeError("index out of range") : x$16.$array[x$16.$offset + x$17]))); } - } else { - return [$ifaceNil, fmt.Errorf("can't index item of type %s", new ($sliceType($emptyInterface))([v.Type()]))]; + (x$18 = p.stack, x$19 = n - 2 >> 0, (x$19 < 0 || x$19 >= x$18.$length) ? $throwRuntimeError("index out of range") : x$18.$array[x$18.$offset + x$19] = re1$1); + (x$20 = p.stack, x$21 = n - 1 >> 0, (x$21 < 0 || x$21 >= x$20.$length) ? $throwRuntimeError("index out of range") : x$20.$array[x$20.$offset + x$21] = re2); + return true; } - _i++; } - return [v.Interface(), $ifaceNil]; + return false; }; - length = function(item) { - var _tuple, v, isNil, _ref; - _tuple = indirect($clone(reflect.ValueOf(item), reflect.Value)); v = new reflect.Value.Ptr(); $copy(v, _tuple[0], reflect.Value); isNil = _tuple[1]; - if (isNil) { - return [0, fmt.Errorf("len of nil pointer", new ($sliceType($emptyInterface))([]))]; + parser.prototype.swapVerticalBar = function() { return this.$val.swapVerticalBar(); }; + parser.Ptr.prototype.parseRightParen = function() { + var p, n, x, x$1, re1, x$2, x$3, re2, x$4; + p = this; + p.concat(); + if (p.swapVerticalBar()) { + p.stack = $subslice(p.stack, 0, (p.stack.$length - 1 >> 0)); } - _ref = v.Kind(); - if (_ref === 17 || _ref === 18 || _ref === 21 || _ref === 23 || _ref === 24) { - return [v.Len(), $ifaceNil]; + p.alternate(); + n = p.stack.$length; + if (n < 2) { + return new Error.Ptr("unexpected )", p.wholeRegexp); } - return [0, fmt.Errorf("len of type %s", new ($sliceType($emptyInterface))([v.Type()]))]; + re1 = (x = p.stack, x$1 = n - 1 >> 0, ((x$1 < 0 || x$1 >= x.$length) ? $throwRuntimeError("index out of range") : x.$array[x.$offset + x$1])); + re2 = (x$2 = p.stack, x$3 = n - 2 >> 0, ((x$3 < 0 || x$3 >= x$2.$length) ? $throwRuntimeError("index out of range") : x$2.$array[x$2.$offset + x$3])); + p.stack = $subslice(p.stack, 0, (n - 2 >> 0)); + if (!((re2.Op === 128))) { + return new Error.Ptr("unexpected )", p.wholeRegexp); + } + p.flags = re2.Flags; + if (re2.Cap === 0) { + p.push(re1); + } else { + re2.Op = 13; + re2.Sub = $subslice(new ($sliceType(($ptrType(Regexp))))(re2.Sub0), 0, 1); + (x$4 = re2.Sub, (0 < 0 || 0 >= x$4.$length) ? $throwRuntimeError("index out of range") : x$4.$array[x$4.$offset + 0] = re1); + p.push(re2); + } + return $ifaceNil; }; - call = function(fn, args) { - var v, typ, numIn, dddType, argv, _ref, _i, i, arg, value, argType, result; - v = new reflect.Value.Ptr(); $copy(v, reflect.ValueOf(fn), reflect.Value); - typ = v.Type(); - if (!((typ.Kind() === 19))) { - return [$ifaceNil, fmt.Errorf("non-function of type %s", new ($sliceType($emptyInterface))([typ]))]; + parser.prototype.parseRightParen = function() { return this.$val.parseRightParen(); }; + parser.Ptr.prototype.parseEscape = function(s) { + var r = 0, rest = "", err = $ifaceNil, p, t, _tmp, _tmp$1, _tmp$2, _tuple, c, _tmp$3, _tmp$4, _tmp$5, _ref, i, _tmp$6, _tmp$7, _tmp$8, _tmp$9, _tmp$10, _tmp$11, _tuple$1, _tmp$12, _tmp$13, _tmp$14, nhex, _tuple$2, _tmp$15, _tmp$16, _tmp$17, v, _tmp$18, _tmp$19, _tmp$20, x, _tuple$3, _tmp$21, _tmp$22, _tmp$23, y, _tmp$24, _tmp$25, _tmp$26, _tmp$27, _tmp$28, _tmp$29, _tmp$30, _tmp$31, _tmp$32, _tmp$33, _tmp$34, _tmp$35, _tmp$36, _tmp$37, _tmp$38, _tmp$39, _tmp$40, _tmp$41, _tmp$42, _tmp$43, _tmp$44, _tmp$45, _tmp$46, _tmp$47, _tmp$48, _tmp$49, _tmp$50; + p = this; + t = s.substring(1); + if (t === "") { + _tmp = 0; _tmp$1 = ""; _tmp$2 = new Error.Ptr("trailing backslash at end of expression", ""); r = _tmp; rest = _tmp$1; err = _tmp$2; + return [r, rest, err]; } - if (!goodFunc(typ)) { - return [$ifaceNil, fmt.Errorf("function called with %d args; should be 1 or 2", new ($sliceType($emptyInterface))([new $Int(typ.NumOut())]))]; + _tuple = nextRune(t); c = _tuple[0]; t = _tuple[1]; err = _tuple[2]; + if (!($interfaceIsEqual(err, $ifaceNil))) { + _tmp$3 = 0; _tmp$4 = ""; _tmp$5 = err; r = _tmp$3; rest = _tmp$4; err = _tmp$5; + return [r, rest, err]; } - numIn = typ.NumIn(); - dddType = $ifaceNil; - if (typ.IsVariadic()) { - if (args.$length < (numIn - 1 >> 0)) { - return [$ifaceNil, fmt.Errorf("wrong number of args: got %d want at least %d", new ($sliceType($emptyInterface))([new $Int(args.$length), new $Int((numIn - 1 >> 0))]))]; + _ref = c; + Switch: + switch (0) { default: if (_ref === 49 || _ref === 50 || _ref === 51 || _ref === 52 || _ref === 53 || _ref === 54 || _ref === 55) { + if (t === "" || t.charCodeAt(0) < 48 || t.charCodeAt(0) > 55) { + break; } - dddType = typ.In(numIn - 1 >> 0).Elem(); - } else { - if (!((args.$length === numIn))) { - return [$ifaceNil, fmt.Errorf("wrong number of args: got %d want %d", new ($sliceType($emptyInterface))([new $Int(args.$length), new $Int(numIn)]))]; + r = c - 48 >> 0; + i = 1; + while (i < 3) { + if (t === "" || t.charCodeAt(0) < 48 || t.charCodeAt(0) > 55) { + break; + } + r = (((((r >>> 16 << 16) * 8 >> 0) + (r << 16 >>> 16) * 8) >> 0) + (t.charCodeAt(0) >> 0) >> 0) - 48 >> 0; + t = t.substring(1); + i = i + (1) >> 0; } - } - argv = ($sliceType(reflect.Value)).make(args.$length); - _ref = args; - _i = 0; - while (_i < _ref.$length) { - i = _i; - arg = ((_i < 0 || _i >= _ref.$length) ? $throwRuntimeError("index out of range") : _ref.$array[_ref.$offset + _i]); - value = new reflect.Value.Ptr(); $copy(value, reflect.ValueOf(arg), reflect.Value); - argType = $ifaceNil; - if (!typ.IsVariadic() || i < (numIn - 1 >> 0)) { - argType = typ.In(i); - } else { - argType = dddType; + _tmp$6 = r; _tmp$7 = t; _tmp$8 = $ifaceNil; r = _tmp$6; rest = _tmp$7; err = _tmp$8; + return [r, rest, err]; + } else if (_ref === 48) { + r = c - 48 >> 0; + i = 1; + while (i < 3) { + if (t === "" || t.charCodeAt(0) < 48 || t.charCodeAt(0) > 55) { + break; + } + r = (((((r >>> 16 << 16) * 8 >> 0) + (r << 16 >>> 16) * 8) >> 0) + (t.charCodeAt(0) >> 0) >> 0) - 48 >> 0; + t = t.substring(1); + i = i + (1) >> 0; } - if (!value.IsValid() && canBeNil(argType)) { - $copy(value, reflect.Zero(argType), reflect.Value); + _tmp$9 = r; _tmp$10 = t; _tmp$11 = $ifaceNil; r = _tmp$9; rest = _tmp$10; err = _tmp$11; + return [r, rest, err]; + } else if (_ref === 120) { + if (t === "") { + break; } - if (!value.Type().AssignableTo(argType)) { - return [$ifaceNil, fmt.Errorf("arg %d has type %s; should be %s", new ($sliceType($emptyInterface))([new $Int(i), value.Type(), argType]))]; + _tuple$1 = nextRune(t); c = _tuple$1[0]; t = _tuple$1[1]; err = _tuple$1[2]; + if (!($interfaceIsEqual(err, $ifaceNil))) { + _tmp$12 = 0; _tmp$13 = ""; _tmp$14 = err; r = _tmp$12; rest = _tmp$13; err = _tmp$14; + return [r, rest, err]; + } + if (c === 123) { + nhex = 0; + r = 0; + while (true) { + if (t === "") { + break Switch; + } + _tuple$2 = nextRune(t); c = _tuple$2[0]; t = _tuple$2[1]; err = _tuple$2[2]; + if (!($interfaceIsEqual(err, $ifaceNil))) { + _tmp$15 = 0; _tmp$16 = ""; _tmp$17 = err; r = _tmp$15; rest = _tmp$16; err = _tmp$17; + return [r, rest, err]; + } + if (c === 125) { + break; + } + v = unhex(c); + if (v < 0) { + break Switch; + } + r = ((((r >>> 16 << 16) * 16 >> 0) + (r << 16 >>> 16) * 16) >> 0) + v >> 0; + if (r > 1114111) { + break Switch; + } + nhex = nhex + (1) >> 0; + } + if (nhex === 0) { + break Switch; + } + _tmp$18 = r; _tmp$19 = t; _tmp$20 = $ifaceNil; r = _tmp$18; rest = _tmp$19; err = _tmp$20; + return [r, rest, err]; + } + x = unhex(c); + _tuple$3 = nextRune(t); c = _tuple$3[0]; t = _tuple$3[1]; err = _tuple$3[2]; + if (!($interfaceIsEqual(err, $ifaceNil))) { + _tmp$21 = 0; _tmp$22 = ""; _tmp$23 = err; r = _tmp$21; rest = _tmp$22; err = _tmp$23; + return [r, rest, err]; + } + y = unhex(c); + if (x < 0 || y < 0) { + break; + } + _tmp$24 = ((((x >>> 16 << 16) * 16 >> 0) + (x << 16 >>> 16) * 16) >> 0) + y >> 0; _tmp$25 = t; _tmp$26 = $ifaceNil; r = _tmp$24; rest = _tmp$25; err = _tmp$26; + return [r, rest, err]; + } else if (_ref === 97) { + _tmp$27 = 7; _tmp$28 = t; _tmp$29 = err; r = _tmp$27; rest = _tmp$28; err = _tmp$29; + return [r, rest, err]; + } else if (_ref === 102) { + _tmp$30 = 12; _tmp$31 = t; _tmp$32 = err; r = _tmp$30; rest = _tmp$31; err = _tmp$32; + return [r, rest, err]; + } else if (_ref === 110) { + _tmp$33 = 10; _tmp$34 = t; _tmp$35 = err; r = _tmp$33; rest = _tmp$34; err = _tmp$35; + return [r, rest, err]; + } else if (_ref === 114) { + _tmp$36 = 13; _tmp$37 = t; _tmp$38 = err; r = _tmp$36; rest = _tmp$37; err = _tmp$38; + return [r, rest, err]; + } else if (_ref === 116) { + _tmp$39 = 9; _tmp$40 = t; _tmp$41 = err; r = _tmp$39; rest = _tmp$40; err = _tmp$41; + return [r, rest, err]; + } else if (_ref === 118) { + _tmp$42 = 11; _tmp$43 = t; _tmp$44 = err; r = _tmp$42; rest = _tmp$43; err = _tmp$44; + return [r, rest, err]; + } else { + if (c < 128 && !isalnum(c)) { + _tmp$45 = c; _tmp$46 = t; _tmp$47 = $ifaceNil; r = _tmp$45; rest = _tmp$46; err = _tmp$47; + return [r, rest, err]; } - $copy(((i < 0 || i >= argv.$length) ? $throwRuntimeError("index out of range") : argv.$array[argv.$offset + i]), value, reflect.Value); - _i++; - } - result = v.Call(argv); - if ((result.$length === 2) && !((1 < 0 || 1 >= result.$length) ? $throwRuntimeError("index out of range") : result.$array[result.$offset + 1]).IsNil()) { - return [((0 < 0 || 0 >= result.$length) ? $throwRuntimeError("index out of range") : result.$array[result.$offset + 0]).Interface(), $assertType(((1 < 0 || 1 >= result.$length) ? $throwRuntimeError("index out of range") : result.$array[result.$offset + 1]).Interface(), $error)]; - } - return [((0 < 0 || 0 >= result.$length) ? $throwRuntimeError("index out of range") : result.$array[result.$offset + 0]).Interface(), $ifaceNil]; - }; - truth = function(a) { - var _tuple, t; - _tuple = isTrue($clone(reflect.ValueOf(a), reflect.Value)); t = _tuple[0]; - return t; + } } + _tmp$48 = 0; _tmp$49 = ""; _tmp$50 = new Error.Ptr("invalid escape sequence", s.substring(0, (s.length - t.length >> 0))); r = _tmp$48; rest = _tmp$49; err = _tmp$50; + return [r, rest, err]; }; - and = function(arg0, args) { - var _ref, _i, i; - if (!truth(arg0)) { - return arg0; + parser.prototype.parseEscape = function(s) { return this.$val.parseEscape(s); }; + parser.Ptr.prototype.parseClassChar = function(s, wholeClass) { + var r = 0, rest = "", err = $ifaceNil, p, _tmp, _tmp$1, _tmp$2, _tuple, _tuple$1; + p = this; + if (s === "") { + _tmp = 0; _tmp$1 = ""; _tmp$2 = new Error.Ptr("missing closing ]", wholeClass); r = _tmp; rest = _tmp$1; err = _tmp$2; + return [r, rest, err]; } - _ref = args; - _i = 0; - while (_i < _ref.$length) { - i = _i; - arg0 = ((i < 0 || i >= args.$length) ? $throwRuntimeError("index out of range") : args.$array[args.$offset + i]); - if (!truth(arg0)) { - break; - } - _i++; + if (s.charCodeAt(0) === 92) { + _tuple = p.parseEscape(s); r = _tuple[0]; rest = _tuple[1]; err = _tuple[2]; + return [r, rest, err]; } - return arg0; + _tuple$1 = nextRune(s); r = _tuple$1[0]; rest = _tuple$1[1]; err = _tuple$1[2]; + return [r, rest, err]; }; - or = function(arg0, args) { - var _ref, _i, i; - if (truth(arg0)) { - return arg0; + parser.prototype.parseClassChar = function(s, wholeClass) { return this.$val.parseClassChar(s, wholeClass); }; + parser.Ptr.prototype.parsePerlClassEscape = function(s, r) { + var out = ($sliceType($Int32)).nil, rest = "", p, _entry, g, _tmp, _tmp$1; + p = this; + if ((((p.flags & 64) >>> 0) === 0) || s.length < 2 || !((s.charCodeAt(0) === 92))) { + return [out, rest]; } - _ref = args; - _i = 0; - while (_i < _ref.$length) { - i = _i; - arg0 = ((i < 0 || i >= args.$length) ? $throwRuntimeError("index out of range") : args.$array[args.$offset + i]); - if (truth(arg0)) { - break; - } - _i++; + g = new charGroup.Ptr(); $copy(g, (_entry = perlGroup[s.substring(0, 2)], _entry !== undefined ? _entry.v : new charGroup.Ptr()), charGroup); + if (g.sign === 0) { + return [out, rest]; } - return arg0; - }; - not = function(arg) { - var truth$1 = false, _tuple; - _tuple = isTrue($clone(reflect.ValueOf(arg), reflect.Value)); truth$1 = _tuple[0]; - truth$1 = !truth$1; - return truth$1; + _tmp = p.appendGroup(r, $clone(g, charGroup)); _tmp$1 = s.substring(2); out = _tmp; rest = _tmp$1; + return [out, rest]; }; - basicKind = function(v) { - var _ref; - _ref = v.Kind(); - if (_ref === 1) { - return [1, $ifaceNil]; - } else if (_ref === 2 || _ref === 3 || _ref === 4 || _ref === 5 || _ref === 6) { - return [3, $ifaceNil]; - } else if (_ref === 7 || _ref === 8 || _ref === 9 || _ref === 10 || _ref === 11 || _ref === 12) { - return [7, $ifaceNil]; - } else if (_ref === 13 || _ref === 14) { - return [4, $ifaceNil]; - } else if (_ref === 15 || _ref === 16) { - return [2, $ifaceNil]; - } else if (_ref === 24) { - return [6, $ifaceNil]; + parser.prototype.parsePerlClassEscape = function(s, r) { return this.$val.parsePerlClassEscape(s, r); }; + parser.Ptr.prototype.parseNamedClass = function(s, r) { + var out = ($sliceType($Int32)).nil, rest = "", err = $ifaceNil, p, i, _tmp, _tmp$1, name, _entry, g, _tmp$2, _tmp$3, _tmp$4, _tmp$5, _tmp$6, _tmp$7; + p = this; + if (s.length < 2 || !((s.charCodeAt(0) === 91)) || !((s.charCodeAt(1) === 58))) { + return [out, rest, err]; } - return [0, errBadComparisonType]; - }; - eq = function(arg1, arg2) { - var v1, _tuple, k1, err, _ref, _i, arg, v2, _tuple$1, k2, err$1, truth$1, _ref$1, x, x$1, x$2, x$3, x$4, x$5; - v1 = new reflect.Value.Ptr(); $copy(v1, reflect.ValueOf(arg1), reflect.Value); - _tuple = basicKind($clone(v1, reflect.Value)); k1 = _tuple[0]; err = _tuple[1]; - if (!($interfaceIsEqual(err, $ifaceNil))) { - return [false, err]; + i = strings.Index(s.substring(2), ":]"); + if (i < 0) { + return [out, rest, err]; } - if (arg2.$length === 0) { - return [false, errNoComparison]; + i = i + (2) >> 0; + _tmp = s.substring(0, (i + 2 >> 0)); _tmp$1 = s.substring((i + 2 >> 0)); name = _tmp; s = _tmp$1; + g = new charGroup.Ptr(); $copy(g, (_entry = posixGroup[name], _entry !== undefined ? _entry.v : new charGroup.Ptr()), charGroup); + if (g.sign === 0) { + _tmp$2 = ($sliceType($Int32)).nil; _tmp$3 = ""; _tmp$4 = new Error.Ptr("invalid character class range", name); out = _tmp$2; rest = _tmp$3; err = _tmp$4; + return [out, rest, err]; } - _ref = arg2; - _i = 0; - while (_i < _ref.$length) { - arg = ((_i < 0 || _i >= _ref.$length) ? $throwRuntimeError("index out of range") : _ref.$array[_ref.$offset + _i]); - v2 = new reflect.Value.Ptr(); $copy(v2, reflect.ValueOf(arg), reflect.Value); - _tuple$1 = basicKind($clone(v2, reflect.Value)); k2 = _tuple$1[0]; err$1 = _tuple$1[1]; - if (!($interfaceIsEqual(err$1, $ifaceNil))) { - return [false, err$1]; - } - if (!((k1 === k2))) { - return [false, errBadComparison]; - } - truth$1 = false; - _ref$1 = k1; - if (_ref$1 === 1) { - truth$1 = v1.Bool() === v2.Bool(); - } else if (_ref$1 === 2) { - truth$1 = (x = v1.Complex(), x$1 = v2.Complex(), (x.$real === x$1.$real && x.$imag === x$1.$imag)); - } else if (_ref$1 === 4) { - truth$1 = v1.Float() === v2.Float(); - } else if (_ref$1 === 3) { - truth$1 = (x$2 = v1.Int(), x$3 = v2.Int(), (x$2.$high === x$3.$high && x$2.$low === x$3.$low)); - } else if (_ref$1 === 6) { - truth$1 = v1.String() === v2.String(); - } else if (_ref$1 === 7) { - truth$1 = (x$4 = v1.Uint(), x$5 = v2.Uint(), (x$4.$high === x$5.$high && x$4.$low === x$5.$low)); + _tmp$5 = p.appendGroup(r, $clone(g, charGroup)); _tmp$6 = s; _tmp$7 = $ifaceNil; out = _tmp$5; rest = _tmp$6; err = _tmp$7; + return [out, rest, err]; + }; + parser.prototype.parseNamedClass = function(s, r) { return this.$val.parseNamedClass(s, r); }; + parser.Ptr.prototype.appendGroup = function(r, g) { + var p, tmp; + p = this; + if (((p.flags & 1) >>> 0) === 0) { + if (g.sign < 0) { + r = appendNegatedClass(r, g.class$1); } else { - $panic(new $String("invalid kind")); + r = appendClass(r, g.class$1); } - if (truth$1) { - return [true, $ifaceNil]; + } else { + tmp = $subslice(p.tmpClass, 0, 0); + tmp = appendFoldedClass(tmp, g.class$1); + p.tmpClass = tmp; + tmp = cleanClass(new ($ptrType(($sliceType($Int32))))(function() { return this.$target.tmpClass; }, function($v) { this.$target.tmpClass = $v; }, p)); + if (g.sign < 0) { + r = appendNegatedClass(r, tmp); + } else { + r = appendClass(r, tmp); } - _i++; } - return [false, $ifaceNil]; - }; - ne = function(arg1, arg2) { - var _tuple, equal, err; - _tuple = eq(arg1, new ($sliceType($emptyInterface))([arg2])); equal = _tuple[0]; err = _tuple[1]; - return [!equal, err]; + return r; }; - lt = function(arg1, arg2) { - var v1, _tuple, k1, err, v2, _tuple$1, k2, truth$1, _ref, x, x$1, x$2, x$3; - v1 = new reflect.Value.Ptr(); $copy(v1, reflect.ValueOf(arg1), reflect.Value); - _tuple = basicKind($clone(v1, reflect.Value)); k1 = _tuple[0]; err = _tuple[1]; - if (!($interfaceIsEqual(err, $ifaceNil))) { - return [false, err]; - } - v2 = new reflect.Value.Ptr(); $copy(v2, reflect.ValueOf(arg2), reflect.Value); - _tuple$1 = basicKind($clone(v2, reflect.Value)); k2 = _tuple$1[0]; err = _tuple$1[1]; - if (!($interfaceIsEqual(err, $ifaceNil))) { - return [false, err]; + parser.prototype.appendGroup = function(r, g) { return this.$val.appendGroup(r, g); }; + unicodeTable = function(name) { + var _entry, t, _entry$1, _entry$2, t$1, _entry$3; + if (name === "Any") { + return [anyTable, anyTable]; } - if (!((k1 === k2))) { - return [false, errBadComparison]; + t = (_entry = unicode.Categories[name], _entry !== undefined ? _entry.v : ($ptrType(unicode.RangeTable)).nil); + if (!(t === ($ptrType(unicode.RangeTable)).nil)) { + return [t, (_entry$1 = unicode.FoldCategory[name], _entry$1 !== undefined ? _entry$1.v : ($ptrType(unicode.RangeTable)).nil)]; } - truth$1 = false; - _ref = k1; - if (_ref === 1 || _ref === 2) { - return [false, errBadComparisonType]; - } else if (_ref === 4) { - truth$1 = v1.Float() < v2.Float(); - } else if (_ref === 3) { - truth$1 = (x = v1.Int(), x$1 = v2.Int(), (x.$high < x$1.$high || (x.$high === x$1.$high && x.$low < x$1.$low))); - } else if (_ref === 6) { - truth$1 = v1.String() < v2.String(); - } else if (_ref === 7) { - truth$1 = (x$2 = v1.Uint(), x$3 = v2.Uint(), (x$2.$high < x$3.$high || (x$2.$high === x$3.$high && x$2.$low < x$3.$low))); - } else { - $panic(new $String("invalid kind")); + t$1 = (_entry$2 = unicode.Scripts[name], _entry$2 !== undefined ? _entry$2.v : ($ptrType(unicode.RangeTable)).nil); + if (!(t$1 === ($ptrType(unicode.RangeTable)).nil)) { + return [t$1, (_entry$3 = unicode.FoldScript[name], _entry$3 !== undefined ? _entry$3.v : ($ptrType(unicode.RangeTable)).nil)]; } - return [truth$1, $ifaceNil]; + return [($ptrType(unicode.RangeTable)).nil, ($ptrType(unicode.RangeTable)).nil]; }; - le = function(arg1, arg2) { - var _tuple, lessThan, err; - _tuple = lt(arg1, arg2); lessThan = _tuple[0]; err = _tuple[1]; - if (lessThan || !($interfaceIsEqual(err, $ifaceNil))) { - return [lessThan, err]; + parser.Ptr.prototype.parseUnicodeClass = function(s, r) { + var out = ($sliceType($Int32)).nil, rest = "", err = $ifaceNil, p, sign, t, _tuple, c, _tmp, _tmp$1, seq, name, end, _tmp$2, _tmp$3, _tmp$4, _tmp$5, _tmp$6, _tuple$1, tab, fold, _tmp$7, _tmp$8, _tmp$9, tmp, _tmp$10, _tmp$11, _tmp$12; + p = this; + if ((((p.flags & 128) >>> 0) === 0) || s.length < 2 || !((s.charCodeAt(0) === 92)) || !((s.charCodeAt(1) === 112)) && !((s.charCodeAt(1) === 80))) { + return [out, rest, err]; } - return eq(arg1, new ($sliceType($emptyInterface))([arg2])); - }; - gt = function(arg1, arg2) { - var _tuple, lessOrEqual, err; - _tuple = le(arg1, arg2); lessOrEqual = _tuple[0]; err = _tuple[1]; - if (!($interfaceIsEqual(err, $ifaceNil))) { - return [false, err]; + sign = 1; + if (s.charCodeAt(1) === 80) { + sign = -1; } - return [!lessOrEqual, $ifaceNil]; - }; - ge = function(arg1, arg2) { - var _tuple, lessThan, err; - _tuple = lt(arg1, arg2); lessThan = _tuple[0]; err = _tuple[1]; + t = s.substring(2); + _tuple = nextRune(t); c = _tuple[0]; t = _tuple[1]; err = _tuple[2]; if (!($interfaceIsEqual(err, $ifaceNil))) { - return [false, err]; + return [out, rest, err]; } - return [!lessThan, $ifaceNil]; - }; - HTMLEscape = $pkg.HTMLEscape = function(w, b) { - var last, _ref, _i, i, c, html, _ref$1; - last = 0; - _ref = b; - _i = 0; - while (_i < _ref.$length) { - i = _i; - c = ((_i < 0 || _i >= _ref.$length) ? $throwRuntimeError("index out of range") : _ref.$array[_ref.$offset + _i]); - html = ($sliceType($Uint8)).nil; - _ref$1 = c; - if (_ref$1 === 34) { - html = htmlQuot; - } else if (_ref$1 === 39) { - html = htmlApos; - } else if (_ref$1 === 38) { - html = htmlAmp; - } else if (_ref$1 === 60) { - html = htmlLt; - } else if (_ref$1 === 62) { - html = htmlGt; + _tmp = ""; _tmp$1 = ""; seq = _tmp; name = _tmp$1; + if (!((c === 123))) { + seq = s.substring(0, (s.length - t.length >> 0)); + name = seq.substring(2); + } else { + end = strings.IndexRune(s, 125); + if (end < 0) { + err = checkUTF8(s); + if (!($interfaceIsEqual(err, $ifaceNil))) { + return [out, rest, err]; + } + _tmp$2 = ($sliceType($Int32)).nil; _tmp$3 = ""; _tmp$4 = new Error.Ptr("invalid character class range", s); out = _tmp$2; rest = _tmp$3; err = _tmp$4; + return [out, rest, err]; + } + _tmp$5 = s.substring(0, (end + 1 >> 0)); _tmp$6 = s.substring((end + 1 >> 0)); seq = _tmp$5; t = _tmp$6; + name = s.substring(3, end); + err = checkUTF8(name); + if (!($interfaceIsEqual(err, $ifaceNil))) { + return [out, rest, err]; + } + } + if (!(name === "") && (name.charCodeAt(0) === 94)) { + sign = -sign; + name = name.substring(1); + } + _tuple$1 = unicodeTable(name); tab = _tuple$1[0]; fold = _tuple$1[1]; + if (tab === ($ptrType(unicode.RangeTable)).nil) { + _tmp$7 = ($sliceType($Int32)).nil; _tmp$8 = ""; _tmp$9 = new Error.Ptr("invalid character class range", seq); out = _tmp$7; rest = _tmp$8; err = _tmp$9; + return [out, rest, err]; + } + if ((((p.flags & 1) >>> 0) === 0) || fold === ($ptrType(unicode.RangeTable)).nil) { + if (sign > 0) { + r = appendTable(r, tab); } else { - _i++; - continue; + r = appendNegatedTable(r, tab); + } + } else { + tmp = $subslice(p.tmpClass, 0, 0); + tmp = appendTable(tmp, tab); + tmp = appendTable(tmp, fold); + p.tmpClass = tmp; + tmp = cleanClass(new ($ptrType(($sliceType($Int32))))(function() { return this.$target.tmpClass; }, function($v) { this.$target.tmpClass = $v; }, p)); + if (sign > 0) { + r = appendClass(r, tmp); + } else { + r = appendNegatedClass(r, tmp); } - w.Write($subslice(b, last, i)); - w.Write(html); - last = i + 1 >> 0; - _i++; } - w.Write($subslice(b, last)); + _tmp$10 = r; _tmp$11 = t; _tmp$12 = $ifaceNil; out = _tmp$10; rest = _tmp$11; err = _tmp$12; + return [out, rest, err]; }; - HTMLEscapeString = $pkg.HTMLEscapeString = function(s) { - var b; - if (strings.IndexAny(s, "'\"&<>") < 0) { - return s; + parser.prototype.parseUnicodeClass = function(s, r) { return this.$val.parseUnicodeClass(s, r); }; + parser.Ptr.prototype.parseClass = function(s) { + var rest = "", err = $ifaceNil, p, t, re, sign, class$1, first, _tuple, size, _tmp, _tmp$1, _tuple$1, nclass, nt, err$1, _tmp$2, _tmp$3, _tmp$4, _tmp$5, _tuple$2, nclass$1, nt$1, err$2, _tmp$6, _tmp$7, _tmp$8, _tmp$9, _tuple$3, nclass$2, nt$2, _tmp$10, _tmp$11, rng, _tmp$12, _tmp$13, lo, hi, _tuple$4, _tmp$14, _tmp$15, _tuple$5, _tmp$16, _tmp$17, _tmp$18, _tmp$19, _tmp$20, _tmp$21; + p = this; + t = s.substring(1); + re = p.newRegexp(4); + re.Flags = p.flags; + re.Rune = $subslice(new ($sliceType($Int32))(re.Rune0), 0, 0); + sign = 1; + if (!(t === "") && (t.charCodeAt(0) === 94)) { + sign = -1; + t = t.substring(1); + if (((p.flags & 4) >>> 0) === 0) { + re.Rune = $append(re.Rune, 10, 10); + } } - b = new bytes.Buffer.Ptr(); $copy(b, new bytes.Buffer.Ptr(), bytes.Buffer); - HTMLEscape(b, new ($sliceType($Uint8))($stringToBytes(s))); - return b.String(); - }; - HTMLEscaper = $pkg.HTMLEscaper = function(args) { - return HTMLEscapeString(evalArgs(args)); - }; - JSEscape = $pkg.JSEscape = function(w, b) { - var last, i, c, _ref, _tmp, _tmp$1, t, b$1, _tuple, r, size; - last = 0; - i = 0; - while (i < b.$length) { - c = ((i < 0 || i >= b.$length) ? $throwRuntimeError("index out of range") : b.$array[b.$offset + i]); - if (!jsIsSpecial((c >> 0))) { - i = i + (1) >> 0; + class$1 = re.Rune; + first = true; + while (t === "" || !((t.charCodeAt(0) === 93)) || first) { + if (!(t === "") && (t.charCodeAt(0) === 45) && (((p.flags & 64) >>> 0) === 0) && !first && ((t.length === 1) || !((t.charCodeAt(1) === 93)))) { + _tuple = utf8.DecodeRuneInString(t.substring(1)); size = _tuple[1]; + _tmp = ""; _tmp$1 = new Error.Ptr("invalid character class range", t.substring(0, (1 + size >> 0))); rest = _tmp; err = _tmp$1; + return [rest, err]; + } + first = false; + if (t.length > 2 && (t.charCodeAt(0) === 91) && (t.charCodeAt(1) === 58)) { + _tuple$1 = p.parseNamedClass(t, class$1); nclass = _tuple$1[0]; nt = _tuple$1[1]; err$1 = _tuple$1[2]; + if (!($interfaceIsEqual(err$1, $ifaceNil))) { + _tmp$2 = ""; _tmp$3 = err$1; rest = _tmp$2; err = _tmp$3; + return [rest, err]; + } + if (!(nclass === ($sliceType($Int32)).nil)) { + _tmp$4 = nclass; _tmp$5 = nt; class$1 = _tmp$4; t = _tmp$5; + continue; + } + } + _tuple$2 = p.parseUnicodeClass(t, class$1); nclass$1 = _tuple$2[0]; nt$1 = _tuple$2[1]; err$2 = _tuple$2[2]; + if (!($interfaceIsEqual(err$2, $ifaceNil))) { + _tmp$6 = ""; _tmp$7 = err$2; rest = _tmp$6; err = _tmp$7; + return [rest, err]; + } + if (!(nclass$1 === ($sliceType($Int32)).nil)) { + _tmp$8 = nclass$1; _tmp$9 = nt$1; class$1 = _tmp$8; t = _tmp$9; continue; } - w.Write($subslice(b, last, i)); - if (c < 128) { - _ref = c; - if (_ref === 92) { - w.Write(jsBackslash); - } else if (_ref === 39) { - w.Write(jsApos); - } else if (_ref === 34) { - w.Write(jsQuot); - } else if (_ref === 60) { - w.Write(jsLt); - } else if (_ref === 62) { - w.Write(jsGt); - } else { - w.Write(jsLowUni); - _tmp = c >>> 4 << 24 >>> 24; _tmp$1 = (c & 15) >>> 0; t = _tmp; b$1 = _tmp$1; - w.Write($subslice(hex, t, (t + 1 << 24 >>> 24))); - w.Write($subslice(hex, b$1, (b$1 + 1 << 24 >>> 24))); + _tuple$3 = p.parsePerlClassEscape(t, class$1); nclass$2 = _tuple$3[0]; nt$2 = _tuple$3[1]; + if (!(nclass$2 === ($sliceType($Int32)).nil)) { + _tmp$10 = nclass$2; _tmp$11 = nt$2; class$1 = _tmp$10; t = _tmp$11; + continue; + } + rng = t; + _tmp$12 = 0; _tmp$13 = 0; lo = _tmp$12; hi = _tmp$13; + _tuple$4 = p.parseClassChar(t, s); lo = _tuple$4[0]; t = _tuple$4[1]; err$2 = _tuple$4[2]; + if (!($interfaceIsEqual(err$2, $ifaceNil))) { + _tmp$14 = ""; _tmp$15 = err$2; rest = _tmp$14; err = _tmp$15; + return [rest, err]; + } + hi = lo; + if (t.length >= 2 && (t.charCodeAt(0) === 45) && !((t.charCodeAt(1) === 93))) { + t = t.substring(1); + _tuple$5 = p.parseClassChar(t, s); hi = _tuple$5[0]; t = _tuple$5[1]; err$2 = _tuple$5[2]; + if (!($interfaceIsEqual(err$2, $ifaceNil))) { + _tmp$16 = ""; _tmp$17 = err$2; rest = _tmp$16; err = _tmp$17; + return [rest, err]; + } + if (hi < lo) { + rng = rng.substring(0, (rng.length - t.length >> 0)); + _tmp$18 = ""; _tmp$19 = new Error.Ptr("invalid character class range", rng); rest = _tmp$18; err = _tmp$19; + return [rest, err]; } + } + if (((p.flags & 1) >>> 0) === 0) { + class$1 = appendRange(class$1, lo, hi); } else { - _tuple = utf8.DecodeRune($subslice(b, i)); r = _tuple[0]; size = _tuple[1]; - if (unicode.IsPrint(r)) { - w.Write($subslice(b, i, (i + size >> 0))); - } else { - fmt.Fprintf(w, "\\u%04X", new ($sliceType($emptyInterface))([new $Int32(r)])); + class$1 = appendFoldedRange(class$1, lo, hi); + } + } + t = t.substring(1); + re.Rune = class$1; + class$1 = cleanClass(new ($ptrType(($sliceType($Int32))))(function() { return this.$target.Rune; }, function($v) { this.$target.Rune = $v; }, re)); + if (sign < 0) { + class$1 = negateClass(class$1); + } + re.Rune = class$1; + p.push(re); + _tmp$20 = t; _tmp$21 = $ifaceNil; rest = _tmp$20; err = _tmp$21; + return [rest, err]; + }; + parser.prototype.parseClass = function(s) { return this.$val.parseClass(s); }; + cleanClass = function(rp) { + var x, r, w, i, _tmp, _tmp$1, x$1, lo, hi, x$2, x$3, x$4, x$5; + sort.Sort((x = new ranges.Ptr(rp), new x.constructor.Struct(x))); + r = rp.$get(); + if (r.$length < 2) { + return r; + } + w = 2; + i = 2; + while (i < r.$length) { + _tmp = ((i < 0 || i >= r.$length) ? $throwRuntimeError("index out of range") : r.$array[r.$offset + i]); _tmp$1 = (x$1 = i + 1 >> 0, ((x$1 < 0 || x$1 >= r.$length) ? $throwRuntimeError("index out of range") : r.$array[r.$offset + x$1])); lo = _tmp; hi = _tmp$1; + if (lo <= ((x$2 = w - 1 >> 0, ((x$2 < 0 || x$2 >= r.$length) ? $throwRuntimeError("index out of range") : r.$array[r.$offset + x$2])) + 1 >> 0)) { + if (hi > (x$3 = w - 1 >> 0, ((x$3 < 0 || x$3 >= r.$length) ? $throwRuntimeError("index out of range") : r.$array[r.$offset + x$3]))) { + (x$4 = w - 1 >> 0, (x$4 < 0 || x$4 >= r.$length) ? $throwRuntimeError("index out of range") : r.$array[r.$offset + x$4] = hi); } - i = i + ((size - 1 >> 0)) >> 0; + i = i + (2) >> 0; + continue; } - last = i + 1 >> 0; - i = i + (1) >> 0; + (w < 0 || w >= r.$length) ? $throwRuntimeError("index out of range") : r.$array[r.$offset + w] = lo; + (x$5 = w + 1 >> 0, (x$5 < 0 || x$5 >= r.$length) ? $throwRuntimeError("index out of range") : r.$array[r.$offset + x$5] = hi); + w = w + (2) >> 0; + i = i + (2) >> 0; } - w.Write($subslice(b, last)); + return $subslice(r, 0, w); }; - JSEscapeString = $pkg.JSEscapeString = function(s) { - var b; - if (strings.IndexFunc(s, jsIsSpecial) < 0) { - return s; + appendLiteral = function(r, x, flags) { + if (!((((flags & 1) >>> 0) === 0))) { + return appendFoldedRange(r, x, x); } - b = new bytes.Buffer.Ptr(); $copy(b, new bytes.Buffer.Ptr(), bytes.Buffer); - JSEscape(b, new ($sliceType($Uint8))($stringToBytes(s))); - return b.String(); + return appendRange(r, x, x); }; - jsIsSpecial = function(r) { - var _ref; - _ref = r; - if (_ref === 92 || _ref === 39 || _ref === 34 || _ref === 60 || _ref === 62) { - return true; + appendRange = function(r, lo, hi) { + var n, i, _tmp, x, _tmp$1, x$1, rlo, rhi, x$2, x$3; + n = r.$length; + i = 2; + while (i <= 4) { + if (n >= i) { + _tmp = (x = n - i >> 0, ((x < 0 || x >= r.$length) ? $throwRuntimeError("index out of range") : r.$array[r.$offset + x])); _tmp$1 = (x$1 = (n - i >> 0) + 1 >> 0, ((x$1 < 0 || x$1 >= r.$length) ? $throwRuntimeError("index out of range") : r.$array[r.$offset + x$1])); rlo = _tmp; rhi = _tmp$1; + if (lo <= (rhi + 1 >> 0) && rlo <= (hi + 1 >> 0)) { + if (lo < rlo) { + (x$2 = n - i >> 0, (x$2 < 0 || x$2 >= r.$length) ? $throwRuntimeError("index out of range") : r.$array[r.$offset + x$2] = lo); + } + if (hi > rhi) { + (x$3 = (n - i >> 0) + 1 >> 0, (x$3 < 0 || x$3 >= r.$length) ? $throwRuntimeError("index out of range") : r.$array[r.$offset + x$3] = hi); + } + return r; + } + } + i = i + (2) >> 0; } - return r < 32 || 128 <= r; - }; - JSEscaper = $pkg.JSEscaper = function(args) { - return JSEscapeString(evalArgs(args)); - }; - URLQueryEscaper = $pkg.URLQueryEscaper = function(args) { - return url.QueryEscape(evalArgs(args)); + return $append(r, lo, hi); }; - evalArgs = function(args) { - var ok, s, _tuple, _ref, _i, i, arg, _tuple$1, a, ok$1; - ok = false; - s = ""; - if (args.$length === 1) { - _tuple = $assertType(((0 < 0 || 0 >= args.$length) ? $throwRuntimeError("index out of range") : args.$array[args.$offset + 0]), $String, true); s = _tuple[0]; ok = _tuple[1]; + appendFoldedRange = function(r, lo, hi) { + var c, f; + if (lo <= 65 && hi >= 66639) { + return appendRange(r, lo, hi); } - if (!ok) { - _ref = args; - _i = 0; - while (_i < _ref.$length) { - i = _i; - arg = ((_i < 0 || _i >= _ref.$length) ? $throwRuntimeError("index out of range") : _ref.$array[_ref.$offset + _i]); - _tuple$1 = printableValue($clone(reflect.ValueOf(arg), reflect.Value)); a = _tuple$1[0]; ok$1 = _tuple$1[1]; - if (ok$1) { - (i < 0 || i >= args.$length) ? $throwRuntimeError("index out of range") : args.$array[args.$offset + i] = a; - } - _i++; + if (hi < 65 || lo > 66639) { + return appendRange(r, lo, hi); + } + if (lo < 65) { + r = appendRange(r, lo, 64); + lo = 65; + } + if (hi > 66639) { + r = appendRange(r, 66640, hi); + hi = 66639; + } + c = lo; + while (c <= hi) { + r = appendRange(r, c, c); + f = unicode.SimpleFold(c); + while (!((f === c))) { + r = appendRange(r, f, f); + f = unicode.SimpleFold(f); } - s = fmt.Sprint(args); + c = c + (1) >> 0; } - return s; + return r; }; - $pkg.$init = function() { - errorType = reflect.TypeOf(($ptrType($error)).nil).Elem(); - fmtStringerType = reflect.TypeOf(($ptrType(fmt.Stringer)).nil).Elem(); - errBadComparisonType = errors.New("invalid type for comparison"); - errBadComparison = errors.New("incompatible types for comparison"); - errNoComparison = errors.New("missing argument for comparison"); - htmlQuot = new ($sliceType($Uint8))($stringToBytes(""")); - htmlApos = new ($sliceType($Uint8))($stringToBytes("'")); - htmlAmp = new ($sliceType($Uint8))($stringToBytes("&")); - htmlLt = new ($sliceType($Uint8))($stringToBytes("<")); - htmlGt = new ($sliceType($Uint8))($stringToBytes(">")); - jsLowUni = new ($sliceType($Uint8))($stringToBytes("\\u00")); - hex = new ($sliceType($Uint8))($stringToBytes("0123456789ABCDEF")); - jsBackslash = new ($sliceType($Uint8))($stringToBytes("\\\\")); - jsApos = new ($sliceType($Uint8))($stringToBytes("\\'")); - jsQuot = new ($sliceType($Uint8))($stringToBytes("\\\"")); - jsLt = new ($sliceType($Uint8))($stringToBytes("\\x3C")); - jsGt = new ($sliceType($Uint8))($stringToBytes("\\x3E")); - builtins = (_map = new $Map(), _key = "and", _map[_key] = { k: _key, v: new ($funcType([$emptyInterface, ($sliceType($emptyInterface))], [$emptyInterface], true))(and) }, _key = "call", _map[_key] = { k: _key, v: new ($funcType([$emptyInterface, ($sliceType($emptyInterface))], [$emptyInterface, $error], true))(call) }, _key = "html", _map[_key] = { k: _key, v: new ($funcType([($sliceType($emptyInterface))], [$String], true))(HTMLEscaper) }, _key = "index", _map[_key] = { k: _key, v: new ($funcType([$emptyInterface, ($sliceType($emptyInterface))], [$emptyInterface, $error], true))(index) }, _key = "js", _map[_key] = { k: _key, v: new ($funcType([($sliceType($emptyInterface))], [$String], true))(JSEscaper) }, _key = "len", _map[_key] = { k: _key, v: new ($funcType([$emptyInterface], [$Int, $error], false))(length) }, _key = "not", _map[_key] = { k: _key, v: new ($funcType([$emptyInterface], [$Bool], false))(not) }, _key = "or", _map[_key] = { k: _key, v: new ($funcType([$emptyInterface, ($sliceType($emptyInterface))], [$emptyInterface], true))(or) }, _key = "print", _map[_key] = { k: _key, v: new ($funcType([($sliceType($emptyInterface))], [$String], true))(fmt.Sprint) }, _key = "printf", _map[_key] = { k: _key, v: new ($funcType([$String, ($sliceType($emptyInterface))], [$String], true))(fmt.Sprintf) }, _key = "println", _map[_key] = { k: _key, v: new ($funcType([($sliceType($emptyInterface))], [$String], true))(fmt.Sprintln) }, _key = "urlquery", _map[_key] = { k: _key, v: new ($funcType([($sliceType($emptyInterface))], [$String], true))(URLQueryEscaper) }, _key = "eq", _map[_key] = { k: _key, v: new ($funcType([$emptyInterface, ($sliceType($emptyInterface))], [$Bool, $error], true))(eq) }, _key = "ge", _map[_key] = { k: _key, v: new ($funcType([$emptyInterface, $emptyInterface], [$Bool, $error], false))(ge) }, _key = "gt", _map[_key] = { k: _key, v: new ($funcType([$emptyInterface, $emptyInterface], [$Bool, $error], false))(gt) }, _key = "le", _map[_key] = { k: _key, v: new ($funcType([$emptyInterface, $emptyInterface], [$Bool, $error], false))(le) }, _key = "lt", _map[_key] = { k: _key, v: new ($funcType([$emptyInterface, $emptyInterface], [$Bool, $error], false))(lt) }, _key = "ne", _map[_key] = { k: _key, v: new ($funcType([$emptyInterface, $emptyInterface], [$Bool, $error], false))(ne) }, _map); - builtinFuncs = createValueFuncs(builtins); + appendClass = function(r, x) { + var i, x$1; + i = 0; + while (i < x.$length) { + r = appendRange(r, ((i < 0 || i >= x.$length) ? $throwRuntimeError("index out of range") : x.$array[x.$offset + i]), (x$1 = i + 1 >> 0, ((x$1 < 0 || x$1 >= x.$length) ? $throwRuntimeError("index out of range") : x.$array[x.$offset + x$1]))); + i = i + (2) >> 0; + } + return r; }; - return $pkg; -})(); -$packages["go/doc"] = (function() { - var $pkg = {}, io = $packages["io"], regexp = $packages["regexp"], strings = $packages["strings"], template = $packages["text/template"], unicode = $packages["unicode"], utf8 = $packages["unicode/utf8"], ast = $packages["go/ast"], token = $packages["go/token"], path = $packages["path"], sort = $packages["sort"], strconv = $packages["strconv"], matchRx, nonAlphaNumRx, outputPrefix, noteMarker, noteMarkerRx, noteCommentRx, firstSentenceLen, clean, Synopsis; - firstSentenceLen = function(s) { - var _tmp, _tmp$1, _tmp$2, ppp, pp, p, _ref, _i, _rune, i, q, _tmp$3, _tmp$4, _tmp$5; - _tmp = 0; _tmp$1 = 0; _tmp$2 = 0; ppp = _tmp; pp = _tmp$1; p = _tmp$2; - _ref = s; - _i = 0; - while (_i < _ref.length) { - _rune = $decodeRune(_ref, _i); - i = _i; - q = _rune[0]; - if ((q === 10) || (q === 13) || (q === 9)) { - q = 32; - } - if ((q === 32) && (p === 46) && (!unicode.IsUpper(pp) || unicode.IsUpper(ppp))) { - return i; - } - if ((p === 12290) || (p === 65294)) { - return i; - } - _tmp$3 = pp; _tmp$4 = p; _tmp$5 = q; ppp = _tmp$3; pp = _tmp$4; p = _tmp$5; - _i += _rune[1]; + appendFoldedClass = function(r, x) { + var i, x$1; + i = 0; + while (i < x.$length) { + r = appendFoldedRange(r, ((i < 0 || i >= x.$length) ? $throwRuntimeError("index out of range") : x.$array[x.$offset + i]), (x$1 = i + 1 >> 0, ((x$1 < 0 || x$1 >= x.$length) ? $throwRuntimeError("index out of range") : x.$array[x.$offset + x$1]))); + i = i + (2) >> 0; } - return s.length; + return r; }; - clean = function(s, flags) { - var b, p, i, q, n; - b = ($sliceType($Uint8)).nil; - p = 32; + appendNegatedClass = function(r, x) { + var nextLo, i, _tmp, _tmp$1, x$1, lo, hi; + nextLo = 0; i = 0; - while (i < s.length) { - q = s.charCodeAt(i); - if ((((flags & 1)) === 0) && (q === 10) || (q === 13) || (q === 9)) { - q = 32; - } - if (!((q === 32)) || !((p === 32))) { - b = $append(b, q); - p = q; + while (i < x.$length) { + _tmp = ((i < 0 || i >= x.$length) ? $throwRuntimeError("index out of range") : x.$array[x.$offset + i]); _tmp$1 = (x$1 = i + 1 >> 0, ((x$1 < 0 || x$1 >= x.$length) ? $throwRuntimeError("index out of range") : x.$array[x.$offset + x$1])); lo = _tmp; hi = _tmp$1; + if (nextLo <= (lo - 1 >> 0)) { + r = appendRange(r, nextLo, lo - 1 >> 0); } - i = i + (1) >> 0; + nextLo = hi + 1 >> 0; + i = i + (2) >> 0; } - n = b.$length; - if (n > 0 && (p === 32)) { - b = $subslice(b, 0, (n - 1 >> 0)); + if (nextLo <= 1114111) { + r = appendRange(r, nextLo, 1114111); } - return $bytesToString(b); + return r; }; - Synopsis = $pkg.Synopsis = function(s) { - var _ref, _i, prefix; - s = clean(s.substring(0, firstSentenceLen(s)), 0); - _ref = $pkg.IllegalPrefixes; + appendTable = function(r, x) { + var _ref, _i, xr, _tmp, _tmp$1, _tmp$2, lo, hi, stride, c, _ref$1, _i$1, xr$1, _tmp$3, _tmp$4, _tmp$5, lo$1, hi$1, stride$1, c$1; + _ref = x.R16; _i = 0; while (_i < _ref.$length) { - prefix = ((_i < 0 || _i >= _ref.$length) ? $throwRuntimeError("index out of range") : _ref.$array[_ref.$offset + _i]); - if (strings.HasPrefix(strings.ToLower(s), prefix)) { - return ""; + xr = new unicode.Range16.Ptr(); $copy(xr, ((_i < 0 || _i >= _ref.$length) ? $throwRuntimeError("index out of range") : _ref.$array[_ref.$offset + _i]), unicode.Range16); + _tmp = (xr.Lo >> 0); _tmp$1 = (xr.Hi >> 0); _tmp$2 = (xr.Stride >> 0); lo = _tmp; hi = _tmp$1; stride = _tmp$2; + if (stride === 1) { + r = appendRange(r, lo, hi); + _i++; + continue; + } + c = lo; + while (c <= hi) { + r = appendRange(r, c, c); + c = c + (stride) >> 0; } _i++; } - return s; - }; - $pkg.$init = function() { - matchRx = regexp.MustCompile("((https?|ftp|file|gopher|mailto|news|nntp|telnet|wais|prospero)://[a-zA-Z0-9_@\\-]+([.:][a-zA-Z0-9_@\\-]+)*/?[a-zA-Z0-9_?%#~&/\\-+=()]+([:.,][a-zA-Z0-9_?%#~&/\\-+=()]+)*)|([\\pL_][\\pL_0-9]*)"); - nonAlphaNumRx = regexp.MustCompile("[^a-zA-Z0-9]"); - outputPrefix = regexp.MustCompile("(?i)^[[:space:]]*output:"); - noteMarker = "([A-Z][A-Z]+)\\(([^)]+)\\):?"; - noteMarkerRx = regexp.MustCompile("^[ \\t]*" + noteMarker); - noteCommentRx = regexp.MustCompile("^/[/*][ \\t]*" + noteMarker); - $pkg.IllegalPrefixes = new ($sliceType($String))(["copyright", "all rights", "author"]); - }; - return $pkg; -})(); -$packages["log"] = (function() { - var $pkg = {}, fmt = $packages["fmt"], io = $packages["io"], os = $packages["os"], runtime = $packages["runtime"], sync = $packages["sync"], time = $packages["time"], Logger, std, New, itoa, Panicf; - Logger = $pkg.Logger = $newType(0, "Struct", "log.Logger", "Logger", "log", function(mu_, prefix_, flag_, out_, buf_) { - this.$val = this; - this.mu = mu_ !== undefined ? mu_ : new sync.Mutex.Ptr(); - this.prefix = prefix_ !== undefined ? prefix_ : ""; - this.flag = flag_ !== undefined ? flag_ : 0; - this.out = out_ !== undefined ? out_ : $ifaceNil; - this.buf = buf_ !== undefined ? buf_ : ($sliceType($Uint8)).nil; - }); - New = $pkg.New = function(out, prefix, flag) { - return new Logger.Ptr(new sync.Mutex.Ptr(), prefix, flag, out, ($sliceType($Uint8)).nil); - }; - itoa = function(buf, i, wid) { - var u, b, bp, _r, _q; - u = (i >>> 0); - if ((u === 0) && wid <= 1) { - buf.$set($append(buf.$get(), 48)); - return; - } - b = ($arrayType($Uint8, 32)).zero(); $copy(b, ($arrayType($Uint8, 32)).zero(), ($arrayType($Uint8, 32))); - bp = 32; - while (u > 0 || wid > 0) { - bp = bp - (1) >> 0; - wid = wid - (1) >> 0; - (bp < 0 || bp >= b.length) ? $throwRuntimeError("index out of range") : b[bp] = ((_r = u % 10, _r === _r ? _r : $throwRuntimeError("integer divide by zero")) << 24 >>> 24) + 48 << 24 >>> 24; - u = (_q = u / (10), (_q === _q && _q !== 1/0 && _q !== -1/0) ? _q >>> 0 : $throwRuntimeError("integer divide by zero")); + _ref$1 = x.R32; + _i$1 = 0; + while (_i$1 < _ref$1.$length) { + xr$1 = new unicode.Range32.Ptr(); $copy(xr$1, ((_i$1 < 0 || _i$1 >= _ref$1.$length) ? $throwRuntimeError("index out of range") : _ref$1.$array[_ref$1.$offset + _i$1]), unicode.Range32); + _tmp$3 = (xr$1.Lo >> 0); _tmp$4 = (xr$1.Hi >> 0); _tmp$5 = (xr$1.Stride >> 0); lo$1 = _tmp$3; hi$1 = _tmp$4; stride$1 = _tmp$5; + if (stride$1 === 1) { + r = appendRange(r, lo$1, hi$1); + _i$1++; + continue; + } + c$1 = lo$1; + while (c$1 <= hi$1) { + r = appendRange(r, c$1, c$1); + c$1 = c$1 + (stride$1) >> 0; + } + _i$1++; } - buf.$set($appendSlice(buf.$get(), $subslice(new ($sliceType($Uint8))(b), bp))); + return r; }; - Logger.Ptr.prototype.formatHeader = function(buf, t, file, line) { - var l, _tuple, year, month, day, _tuple$1, hour, min, sec, _q, short$1, i; - l = this; - buf.$set($appendSlice(buf.$get(), new ($sliceType($Uint8))($stringToBytes(l.prefix)))); - if (!(((l.flag & 7) === 0))) { - if (!(((l.flag & 1) === 0))) { - _tuple = t.Date(); year = _tuple[0]; month = _tuple[1]; day = _tuple[2]; - itoa(buf, year, 4); - buf.$set($append(buf.$get(), 47)); - itoa(buf, (month >> 0), 2); - buf.$set($append(buf.$get(), 47)); - itoa(buf, day, 2); - buf.$set($append(buf.$get(), 32)); + appendNegatedTable = function(r, x) { + var nextLo, _ref, _i, xr, _tmp, _tmp$1, _tmp$2, lo, hi, stride, c, _ref$1, _i$1, xr$1, _tmp$3, _tmp$4, _tmp$5, lo$1, hi$1, stride$1, c$1; + nextLo = 0; + _ref = x.R16; + _i = 0; + while (_i < _ref.$length) { + xr = new unicode.Range16.Ptr(); $copy(xr, ((_i < 0 || _i >= _ref.$length) ? $throwRuntimeError("index out of range") : _ref.$array[_ref.$offset + _i]), unicode.Range16); + _tmp = (xr.Lo >> 0); _tmp$1 = (xr.Hi >> 0); _tmp$2 = (xr.Stride >> 0); lo = _tmp; hi = _tmp$1; stride = _tmp$2; + if (stride === 1) { + if (nextLo <= (lo - 1 >> 0)) { + r = appendRange(r, nextLo, lo - 1 >> 0); + } + nextLo = hi + 1 >> 0; + _i++; + continue; } - if (!(((l.flag & 6) === 0))) { - _tuple$1 = t.Clock(); hour = _tuple$1[0]; min = _tuple$1[1]; sec = _tuple$1[2]; - itoa(buf, hour, 2); - buf.$set($append(buf.$get(), 58)); - itoa(buf, min, 2); - buf.$set($append(buf.$get(), 58)); - itoa(buf, sec, 2); - if (!(((l.flag & 4) === 0))) { - buf.$set($append(buf.$get(), 46)); - itoa(buf, (_q = t.Nanosecond() / 1000, (_q === _q && _q !== 1/0 && _q !== -1/0) ? _q >> 0 : $throwRuntimeError("integer divide by zero")), 6); + c = lo; + while (c <= hi) { + if (nextLo <= (c - 1 >> 0)) { + r = appendRange(r, nextLo, c - 1 >> 0); } - buf.$set($append(buf.$get(), 32)); + nextLo = c + 1 >> 0; + c = c + (stride) >> 0; } + _i++; } - if (!(((l.flag & 24) === 0))) { - if (!(((l.flag & 16) === 0))) { - short$1 = file; - i = file.length - 1 >> 0; - while (i > 0) { - if (file.charCodeAt(i) === 47) { - short$1 = file.substring((i + 1 >> 0)); - break; - } - i = i - (1) >> 0; + _ref$1 = x.R32; + _i$1 = 0; + while (_i$1 < _ref$1.$length) { + xr$1 = new unicode.Range32.Ptr(); $copy(xr$1, ((_i$1 < 0 || _i$1 >= _ref$1.$length) ? $throwRuntimeError("index out of range") : _ref$1.$array[_ref$1.$offset + _i$1]), unicode.Range32); + _tmp$3 = (xr$1.Lo >> 0); _tmp$4 = (xr$1.Hi >> 0); _tmp$5 = (xr$1.Stride >> 0); lo$1 = _tmp$3; hi$1 = _tmp$4; stride$1 = _tmp$5; + if (stride$1 === 1) { + if (nextLo <= (lo$1 - 1 >> 0)) { + r = appendRange(r, nextLo, lo$1 - 1 >> 0); } - file = short$1; + nextLo = hi$1 + 1 >> 0; + _i$1++; + continue; } - buf.$set($appendSlice(buf.$get(), new ($sliceType($Uint8))($stringToBytes(file)))); - buf.$set($append(buf.$get(), 58)); - itoa(buf, line, -1); - buf.$set($appendSlice(buf.$get(), new ($sliceType($Uint8))($stringToBytes(": ")))); + c$1 = lo$1; + while (c$1 <= hi$1) { + if (nextLo <= (c$1 - 1 >> 0)) { + r = appendRange(r, nextLo, c$1 - 1 >> 0); + } + nextLo = c$1 + 1 >> 0; + c$1 = c$1 + (stride$1) >> 0; + } + _i$1++; + } + if (nextLo <= 1114111) { + r = appendRange(r, nextLo, 1114111); } + return r; }; - Logger.prototype.formatHeader = function(buf, t, file, line) { return this.$val.formatHeader(buf, t, file, line); }; - Logger.Ptr.prototype.Output = function(calldepth, s) { - var $deferred = [], $err = null, l, now, file, line, ok, _tuple, _tuple$1, err; - /* */ try { $deferFrames.push($deferred); - l = this; - now = new time.Time.Ptr(); $copy(now, time.Now(), time.Time); - file = ""; - line = 0; - l.mu.Lock(); - $deferred.push([$methodVal(l.mu, "Unlock"), []]); - if (!(((l.flag & 24) === 0))) { - l.mu.Unlock(); - ok = false; - _tuple = runtime.Caller(calldepth); file = _tuple[1]; line = _tuple[2]; ok = _tuple[3]; - if (!ok) { - file = "???"; - line = 0; + negateClass = function(r) { + var nextLo, w, i, _tmp, _tmp$1, x, lo, hi, x$1; + nextLo = 0; + w = 0; + i = 0; + while (i < r.$length) { + _tmp = ((i < 0 || i >= r.$length) ? $throwRuntimeError("index out of range") : r.$array[r.$offset + i]); _tmp$1 = (x = i + 1 >> 0, ((x < 0 || x >= r.$length) ? $throwRuntimeError("index out of range") : r.$array[r.$offset + x])); lo = _tmp; hi = _tmp$1; + if (nextLo <= (lo - 1 >> 0)) { + (w < 0 || w >= r.$length) ? $throwRuntimeError("index out of range") : r.$array[r.$offset + w] = nextLo; + (x$1 = w + 1 >> 0, (x$1 < 0 || x$1 >= r.$length) ? $throwRuntimeError("index out of range") : r.$array[r.$offset + x$1] = lo - 1 >> 0); + w = w + (2) >> 0; } - l.mu.Lock(); + nextLo = hi + 1 >> 0; + i = i + (2) >> 0; } - l.buf = $subslice(l.buf, 0, 0); - l.formatHeader(new ($ptrType(($sliceType($Uint8))))(function() { return this.$target.buf; }, function($v) { this.$target.buf = $v; }, l), $clone(now, time.Time), file, line); - l.buf = $appendSlice(l.buf, new ($sliceType($Uint8))($stringToBytes(s))); - if (s.length > 0 && !((s.charCodeAt((s.length - 1 >> 0)) === 10))) { - l.buf = $append(l.buf, 10); + r = $subslice(r, 0, w); + if (nextLo <= 1114111) { + r = $append(r, nextLo, 1114111); } - _tuple$1 = l.out.Write(l.buf); err = _tuple$1[1]; - return err; - /* */ } catch(err) { $err = err; return $ifaceNil; } finally { $deferFrames.pop(); $callDeferred($deferred, $err); } - }; - Logger.prototype.Output = function(calldepth, s) { return this.$val.Output(calldepth, s); }; - Logger.Ptr.prototype.Printf = function(format, v) { - var l; - l = this; - l.Output(2, fmt.Sprintf(format, v)); - }; - Logger.prototype.Printf = function(format, v) { return this.$val.Printf(format, v); }; - Logger.Ptr.prototype.Print = function(v) { - var l; - l = this; - l.Output(2, fmt.Sprint(v)); - }; - Logger.prototype.Print = function(v) { return this.$val.Print(v); }; - Logger.Ptr.prototype.Println = function(v) { - var l; - l = this; - l.Output(2, fmt.Sprintln(v)); + return r; }; - Logger.prototype.Println = function(v) { return this.$val.Println(v); }; - Logger.Ptr.prototype.Fatal = function(v) { - var l; - l = this; - l.Output(2, fmt.Sprint(v)); - os.Exit(1); + ranges.Ptr.prototype.Less = function(i, j) { + var ra, p, x, x$1, x$2, x$3; + ra = new ranges.Ptr(); $copy(ra, this, ranges); + p = ra.p.$get(); + i = (x = 2, (((i >>> 16 << 16) * x >> 0) + (i << 16 >>> 16) * x) >> 0); + j = (x$1 = 2, (((j >>> 16 << 16) * x$1 >> 0) + (j << 16 >>> 16) * x$1) >> 0); + return ((i < 0 || i >= p.$length) ? $throwRuntimeError("index out of range") : p.$array[p.$offset + i]) < ((j < 0 || j >= p.$length) ? $throwRuntimeError("index out of range") : p.$array[p.$offset + j]) || (((i < 0 || i >= p.$length) ? $throwRuntimeError("index out of range") : p.$array[p.$offset + i]) === ((j < 0 || j >= p.$length) ? $throwRuntimeError("index out of range") : p.$array[p.$offset + j])) && (x$2 = i + 1 >> 0, ((x$2 < 0 || x$2 >= p.$length) ? $throwRuntimeError("index out of range") : p.$array[p.$offset + x$2])) > (x$3 = j + 1 >> 0, ((x$3 < 0 || x$3 >= p.$length) ? $throwRuntimeError("index out of range") : p.$array[p.$offset + x$3])); }; - Logger.prototype.Fatal = function(v) { return this.$val.Fatal(v); }; - Logger.Ptr.prototype.Fatalf = function(format, v) { - var l; - l = this; - l.Output(2, fmt.Sprintf(format, v)); - os.Exit(1); + ranges.prototype.Less = function(i, j) { return this.$val.Less(i, j); }; + ranges.Ptr.prototype.Len = function() { + var ra, _q; + ra = new ranges.Ptr(); $copy(ra, this, ranges); + return (_q = ra.p.$get().$length / 2, (_q === _q && _q !== 1/0 && _q !== -1/0) ? _q >> 0 : $throwRuntimeError("integer divide by zero")); }; - Logger.prototype.Fatalf = function(format, v) { return this.$val.Fatalf(format, v); }; - Logger.Ptr.prototype.Fatalln = function(v) { - var l; - l = this; - l.Output(2, fmt.Sprintln(v)); - os.Exit(1); + ranges.prototype.Len = function() { return this.$val.Len(); }; + ranges.Ptr.prototype.Swap = function(i, j) { + var ra, p, x, x$1, _tmp, _tmp$1, x$2, _tmp$2, _tmp$3, x$3, x$4, x$5; + ra = new ranges.Ptr(); $copy(ra, this, ranges); + p = ra.p.$get(); + i = (x = 2, (((i >>> 16 << 16) * x >> 0) + (i << 16 >>> 16) * x) >> 0); + j = (x$1 = 2, (((j >>> 16 << 16) * x$1 >> 0) + (j << 16 >>> 16) * x$1) >> 0); + _tmp = ((j < 0 || j >= p.$length) ? $throwRuntimeError("index out of range") : p.$array[p.$offset + j]); _tmp$1 = (x$2 = j + 1 >> 0, ((x$2 < 0 || x$2 >= p.$length) ? $throwRuntimeError("index out of range") : p.$array[p.$offset + x$2])); _tmp$2 = ((i < 0 || i >= p.$length) ? $throwRuntimeError("index out of range") : p.$array[p.$offset + i]); _tmp$3 = (x$3 = i + 1 >> 0, ((x$3 < 0 || x$3 >= p.$length) ? $throwRuntimeError("index out of range") : p.$array[p.$offset + x$3])); (i < 0 || i >= p.$length) ? $throwRuntimeError("index out of range") : p.$array[p.$offset + i] = _tmp; (x$4 = i + 1 >> 0, (x$4 < 0 || x$4 >= p.$length) ? $throwRuntimeError("index out of range") : p.$array[p.$offset + x$4] = _tmp$1); (j < 0 || j >= p.$length) ? $throwRuntimeError("index out of range") : p.$array[p.$offset + j] = _tmp$2; (x$5 = j + 1 >> 0, (x$5 < 0 || x$5 >= p.$length) ? $throwRuntimeError("index out of range") : p.$array[p.$offset + x$5] = _tmp$3); }; - Logger.prototype.Fatalln = function(v) { return this.$val.Fatalln(v); }; - Logger.Ptr.prototype.Panic = function(v) { - var l, s; - l = this; - s = fmt.Sprint(v); - l.Output(2, s); - $panic(new $String(s)); + ranges.prototype.Swap = function(i, j) { return this.$val.Swap(i, j); }; + checkUTF8 = function(s) { + var _tuple, rune, size; + while (!(s === "")) { + _tuple = utf8.DecodeRuneInString(s); rune = _tuple[0]; size = _tuple[1]; + if ((rune === 65533) && (size === 1)) { + return new Error.Ptr("invalid UTF-8", s); + } + s = s.substring(size); + } + return $ifaceNil; }; - Logger.prototype.Panic = function(v) { return this.$val.Panic(v); }; - Logger.Ptr.prototype.Panicf = function(format, v) { - var l, s; - l = this; - s = fmt.Sprintf(format, v); - l.Output(2, s); - $panic(new $String(s)); + nextRune = function(s) { + var c = 0, t = "", err = $ifaceNil, _tuple, size, _tmp, _tmp$1, _tmp$2, _tmp$3, _tmp$4, _tmp$5; + _tuple = utf8.DecodeRuneInString(s); c = _tuple[0]; size = _tuple[1]; + if ((c === 65533) && (size === 1)) { + _tmp = 0; _tmp$1 = ""; _tmp$2 = new Error.Ptr("invalid UTF-8", s); c = _tmp; t = _tmp$1; err = _tmp$2; + return [c, t, err]; + } + _tmp$3 = c; _tmp$4 = s.substring(size); _tmp$5 = $ifaceNil; c = _tmp$3; t = _tmp$4; err = _tmp$5; + return [c, t, err]; }; - Logger.prototype.Panicf = function(format, v) { return this.$val.Panicf(format, v); }; - Logger.Ptr.prototype.Panicln = function(v) { - var l, s; - l = this; - s = fmt.Sprintln(v); - l.Output(2, s); - $panic(new $String(s)); + isalnum = function(c) { + return 48 <= c && c <= 57 || 65 <= c && c <= 90 || 97 <= c && c <= 122; }; - Logger.prototype.Panicln = function(v) { return this.$val.Panicln(v); }; - Logger.Ptr.prototype.Flags = function() { - var $deferred = [], $err = null, l; - /* */ try { $deferFrames.push($deferred); - l = this; - l.mu.Lock(); - $deferred.push([$methodVal(l.mu, "Unlock"), []]); - return l.flag; - /* */ } catch(err) { $err = err; return 0; } finally { $deferFrames.pop(); $callDeferred($deferred, $err); } + unhex = function(c) { + if (48 <= c && c <= 57) { + return c - 48 >> 0; + } + if (97 <= c && c <= 102) { + return (c - 97 >> 0) + 10 >> 0; + } + if (65 <= c && c <= 70) { + return (c - 65 >> 0) + 10 >> 0; + } + return -1; }; - Logger.prototype.Flags = function() { return this.$val.Flags(); }; - Logger.Ptr.prototype.SetFlags = function(flag) { - var $deferred = [], $err = null, l; - /* */ try { $deferFrames.push($deferred); - l = this; - l.mu.Lock(); - $deferred.push([$methodVal(l.mu, "Unlock"), []]); - l.flag = flag; - /* */ } catch(err) { $err = err; } finally { $deferFrames.pop(); $callDeferred($deferred, $err); } + InstOp.prototype.String = function() { + var i; + i = this.$val !== undefined ? this.$val : this; + if ((i >>> 0) >= (instOpNames.$length >>> 0)) { + return ""; + } + return ((i < 0 || i >= instOpNames.$length) ? $throwRuntimeError("index out of range") : instOpNames.$array[instOpNames.$offset + i]); }; - Logger.prototype.SetFlags = function(flag) { return this.$val.SetFlags(flag); }; - Logger.Ptr.prototype.Prefix = function() { - var $deferred = [], $err = null, l; - /* */ try { $deferFrames.push($deferred); - l = this; - l.mu.Lock(); - $deferred.push([$methodVal(l.mu, "Unlock"), []]); - return l.prefix; - /* */ } catch(err) { $err = err; return ""; } finally { $deferFrames.pop(); $callDeferred($deferred, $err); } + $ptrType(InstOp).prototype.String = function() { return new InstOp(this.$get()).String(); }; + EmptyOpContext = $pkg.EmptyOpContext = function(r1, r2) { + var op, boundary; + op = 32; + boundary = 0; + if (IsWordChar(r1)) { + boundary = 1; + } else if (r1 === 10) { + op = (op | (1)) >>> 0; + } else if (r1 < 0) { + op = (op | (5)) >>> 0; + } + if (IsWordChar(r2)) { + boundary = (boundary ^ (1)) << 24 >>> 24; + } else if (r2 === 10) { + op = (op | (2)) >>> 0; + } else if (r2 < 0) { + op = (op | (10)) >>> 0; + } + if (!((boundary === 0))) { + op = (op ^ (48)) << 24 >>> 24; + } + return op; }; - Logger.prototype.Prefix = function() { return this.$val.Prefix(); }; - Logger.Ptr.prototype.SetPrefix = function(prefix) { - var $deferred = [], $err = null, l; - /* */ try { $deferFrames.push($deferred); - l = this; - l.mu.Lock(); - $deferred.push([$methodVal(l.mu, "Unlock"), []]); - l.prefix = prefix; - /* */ } catch(err) { $err = err; } finally { $deferFrames.pop(); $callDeferred($deferred, $err); } + IsWordChar = $pkg.IsWordChar = function(r) { + return 65 <= r && r <= 90 || 97 <= r && r <= 122 || 48 <= r && r <= 57 || (r === 95); }; - Logger.prototype.SetPrefix = function(prefix) { return this.$val.SetPrefix(prefix); }; - Panicf = $pkg.Panicf = function(format, v) { - var s; - s = fmt.Sprintf(format, v); - std.Output(2, s); - $panic(new $String(s)); + Prog.Ptr.prototype.String = function() { + var p, b; + p = this; + b = new bytes.Buffer.Ptr(); $copy(b, new bytes.Buffer.Ptr(), bytes.Buffer); + dumpProg(b, p); + return b.String(); }; - $pkg.$init = function() { - ($ptrType(Logger)).methods = [["Fatal", "Fatal", "", $funcType([($sliceType($emptyInterface))], [], true), -1], ["Fatalf", "Fatalf", "", $funcType([$String, ($sliceType($emptyInterface))], [], true), -1], ["Fatalln", "Fatalln", "", $funcType([($sliceType($emptyInterface))], [], true), -1], ["Flags", "Flags", "", $funcType([], [$Int], false), -1], ["Output", "Output", "", $funcType([$Int, $String], [$error], false), -1], ["Panic", "Panic", "", $funcType([($sliceType($emptyInterface))], [], true), -1], ["Panicf", "Panicf", "", $funcType([$String, ($sliceType($emptyInterface))], [], true), -1], ["Panicln", "Panicln", "", $funcType([($sliceType($emptyInterface))], [], true), -1], ["Prefix", "Prefix", "", $funcType([], [$String], false), -1], ["Print", "Print", "", $funcType([($sliceType($emptyInterface))], [], true), -1], ["Printf", "Printf", "", $funcType([$String, ($sliceType($emptyInterface))], [], true), -1], ["Println", "Println", "", $funcType([($sliceType($emptyInterface))], [], true), -1], ["SetFlags", "SetFlags", "", $funcType([$Int], [], false), -1], ["SetPrefix", "SetPrefix", "", $funcType([$String], [], false), -1], ["formatHeader", "formatHeader", "log", $funcType([($ptrType(($sliceType($Uint8)))), time.Time, $String, $Int], [], false), -1]]; - Logger.init([["mu", "mu", "log", sync.Mutex, ""], ["prefix", "prefix", "log", $String, ""], ["flag", "flag", "log", $Int, ""], ["out", "out", "log", io.Writer, ""], ["buf", "buf", "log", ($sliceType($Uint8)), ""]]); - std = New(os.Stderr, "", 3); + Prog.prototype.String = function() { return this.$val.String(); }; + Prog.Ptr.prototype.skipNop = function(pc) { + var p, x, i, x$1; + p = this; + i = (x = p.Inst, ((pc < 0 || pc >= x.$length) ? $throwRuntimeError("index out of range") : x.$array[x.$offset + pc])); + while ((i.Op === 6) || (i.Op === 2)) { + pc = i.Out; + i = (x$1 = p.Inst, ((pc < 0 || pc >= x$1.$length) ? $throwRuntimeError("index out of range") : x$1.$array[x$1.$offset + pc])); + } + return [i, pc]; }; - return $pkg; -})(); -$packages["go/build"] = (function() { - var $pkg = {}, bytes = $packages["bytes"], errors = $packages["errors"], fmt = $packages["fmt"], ast = $packages["go/ast"], doc = $packages["go/doc"], parser = $packages["go/parser"], token = $packages["go/token"], io = $packages["io"], ioutil = $packages["io/ioutil"], log = $packages["log"], os = $packages["os"], path = $packages["path"], filepath = $packages["path/filepath"], runtime = $packages["runtime"], sort = $packages["sort"], strconv = $packages["strconv"], strings = $packages["strings"], unicode = $packages["unicode"], bufio = $packages["bufio"], Context, ImportMode, Package, NoGoError, importReader, cgoEnabled, slashslash, safeBytes, knownOS, knownArch, errSyntax, errNUL, _map, _key, hasSubdir, defaultContext, envOr, nameExt, cleanImports, Import, safeCgoName, splitQuoted, init, IsLocalImport, isIdent, readComments, readImports; - Context = $pkg.Context = $newType(0, "Struct", "build.Context", "Context", "go/build", function(GOARCH_, GOOS_, GOROOT_, GOPATH_, CgoEnabled_, UseAllFiles_, Compiler_, BuildTags_, ReleaseTags_, InstallSuffix_, JoinPath_, SplitPathList_, IsAbsPath_, IsDir_, HasSubdir_, ReadDir_, OpenFile_) { - this.$val = this; - this.GOARCH = GOARCH_ !== undefined ? GOARCH_ : ""; - this.GOOS = GOOS_ !== undefined ? GOOS_ : ""; - this.GOROOT = GOROOT_ !== undefined ? GOROOT_ : ""; - this.GOPATH = GOPATH_ !== undefined ? GOPATH_ : ""; - this.CgoEnabled = CgoEnabled_ !== undefined ? CgoEnabled_ : false; - this.UseAllFiles = UseAllFiles_ !== undefined ? UseAllFiles_ : false; - this.Compiler = Compiler_ !== undefined ? Compiler_ : ""; - this.BuildTags = BuildTags_ !== undefined ? BuildTags_ : ($sliceType($String)).nil; - this.ReleaseTags = ReleaseTags_ !== undefined ? ReleaseTags_ : ($sliceType($String)).nil; - this.InstallSuffix = InstallSuffix_ !== undefined ? InstallSuffix_ : ""; - this.JoinPath = JoinPath_ !== undefined ? JoinPath_ : $throwNilPointerError; - this.SplitPathList = SplitPathList_ !== undefined ? SplitPathList_ : $throwNilPointerError; - this.IsAbsPath = IsAbsPath_ !== undefined ? IsAbsPath_ : $throwNilPointerError; - this.IsDir = IsDir_ !== undefined ? IsDir_ : $throwNilPointerError; - this.HasSubdir = HasSubdir_ !== undefined ? HasSubdir_ : $throwNilPointerError; - this.ReadDir = ReadDir_ !== undefined ? ReadDir_ : $throwNilPointerError; - this.OpenFile = OpenFile_ !== undefined ? OpenFile_ : $throwNilPointerError; - }); - ImportMode = $pkg.ImportMode = $newType(4, "Uint", "build.ImportMode", "ImportMode", "go/build", null); - Package = $pkg.Package = $newType(0, "Struct", "build.Package", "Package", "go/build", function(Dir_, Name_, Doc_, ImportPath_, Root_, SrcRoot_, PkgRoot_, BinDir_, Goroot_, PkgObj_, AllTags_, ConflictDir_, GoFiles_, CgoFiles_, IgnoredGoFiles_, CFiles_, CXXFiles_, MFiles_, HFiles_, SFiles_, SwigFiles_, SwigCXXFiles_, SysoFiles_, CgoCFLAGS_, CgoCPPFLAGS_, CgoCXXFLAGS_, CgoLDFLAGS_, CgoPkgConfig_, Imports_, ImportPos_, TestGoFiles_, TestImports_, TestImportPos_, XTestGoFiles_, XTestImports_, XTestImportPos_) { - this.$val = this; - this.Dir = Dir_ !== undefined ? Dir_ : ""; - this.Name = Name_ !== undefined ? Name_ : ""; - this.Doc = Doc_ !== undefined ? Doc_ : ""; - this.ImportPath = ImportPath_ !== undefined ? ImportPath_ : ""; - this.Root = Root_ !== undefined ? Root_ : ""; - this.SrcRoot = SrcRoot_ !== undefined ? SrcRoot_ : ""; - this.PkgRoot = PkgRoot_ !== undefined ? PkgRoot_ : ""; - this.BinDir = BinDir_ !== undefined ? BinDir_ : ""; - this.Goroot = Goroot_ !== undefined ? Goroot_ : false; - this.PkgObj = PkgObj_ !== undefined ? PkgObj_ : ""; - this.AllTags = AllTags_ !== undefined ? AllTags_ : ($sliceType($String)).nil; - this.ConflictDir = ConflictDir_ !== undefined ? ConflictDir_ : ""; - this.GoFiles = GoFiles_ !== undefined ? GoFiles_ : ($sliceType($String)).nil; - this.CgoFiles = CgoFiles_ !== undefined ? CgoFiles_ : ($sliceType($String)).nil; - this.IgnoredGoFiles = IgnoredGoFiles_ !== undefined ? IgnoredGoFiles_ : ($sliceType($String)).nil; - this.CFiles = CFiles_ !== undefined ? CFiles_ : ($sliceType($String)).nil; - this.CXXFiles = CXXFiles_ !== undefined ? CXXFiles_ : ($sliceType($String)).nil; - this.MFiles = MFiles_ !== undefined ? MFiles_ : ($sliceType($String)).nil; - this.HFiles = HFiles_ !== undefined ? HFiles_ : ($sliceType($String)).nil; - this.SFiles = SFiles_ !== undefined ? SFiles_ : ($sliceType($String)).nil; - this.SwigFiles = SwigFiles_ !== undefined ? SwigFiles_ : ($sliceType($String)).nil; - this.SwigCXXFiles = SwigCXXFiles_ !== undefined ? SwigCXXFiles_ : ($sliceType($String)).nil; - this.SysoFiles = SysoFiles_ !== undefined ? SysoFiles_ : ($sliceType($String)).nil; - this.CgoCFLAGS = CgoCFLAGS_ !== undefined ? CgoCFLAGS_ : ($sliceType($String)).nil; - this.CgoCPPFLAGS = CgoCPPFLAGS_ !== undefined ? CgoCPPFLAGS_ : ($sliceType($String)).nil; - this.CgoCXXFLAGS = CgoCXXFLAGS_ !== undefined ? CgoCXXFLAGS_ : ($sliceType($String)).nil; - this.CgoLDFLAGS = CgoLDFLAGS_ !== undefined ? CgoLDFLAGS_ : ($sliceType($String)).nil; - this.CgoPkgConfig = CgoPkgConfig_ !== undefined ? CgoPkgConfig_ : ($sliceType($String)).nil; - this.Imports = Imports_ !== undefined ? Imports_ : ($sliceType($String)).nil; - this.ImportPos = ImportPos_ !== undefined ? ImportPos_ : false; - this.TestGoFiles = TestGoFiles_ !== undefined ? TestGoFiles_ : ($sliceType($String)).nil; - this.TestImports = TestImports_ !== undefined ? TestImports_ : ($sliceType($String)).nil; - this.TestImportPos = TestImportPos_ !== undefined ? TestImportPos_ : false; - this.XTestGoFiles = XTestGoFiles_ !== undefined ? XTestGoFiles_ : ($sliceType($String)).nil; - this.XTestImports = XTestImports_ !== undefined ? XTestImports_ : ($sliceType($String)).nil; - this.XTestImportPos = XTestImportPos_ !== undefined ? XTestImportPos_ : false; - }); - NoGoError = $pkg.NoGoError = $newType(0, "Struct", "build.NoGoError", "NoGoError", "go/build", function(Dir_) { - this.$val = this; - this.Dir = Dir_ !== undefined ? Dir_ : ""; - }); - importReader = $pkg.importReader = $newType(0, "Struct", "build.importReader", "importReader", "go/build", function(b_, buf_, peek_, err_, eof_, nerr_) { - this.$val = this; - this.b = b_ !== undefined ? b_ : ($ptrType(bufio.Reader)).nil; - this.buf = buf_ !== undefined ? buf_ : ($sliceType($Uint8)).nil; - this.peek = peek_ !== undefined ? peek_ : 0; - this.err = err_ !== undefined ? err_ : $ifaceNil; - this.eof = eof_ !== undefined ? eof_ : false; - this.nerr = nerr_ !== undefined ? nerr_ : 0; - }); - Context.Ptr.prototype.joinPath = function(elem) { - var ctxt, f; - ctxt = this; - f = ctxt.JoinPath; - if (!(f === $throwNilPointerError)) { - return f(elem); + Prog.prototype.skipNop = function(pc) { return this.$val.skipNop(pc); }; + Inst.Ptr.prototype.op = function() { + var i, op, _ref; + i = this; + op = i.Op; + _ref = op; + if (_ref === 8 || _ref === 9 || _ref === 10) { + op = 7; } - return filepath.Join(elem); + return op; }; - Context.prototype.joinPath = function(elem) { return this.$val.joinPath(elem); }; - Context.Ptr.prototype.splitPathList = function(s) { - var ctxt, f; - ctxt = this; - f = ctxt.SplitPathList; - if (!(f === $throwNilPointerError)) { - return f(s); + Inst.prototype.op = function() { return this.$val.op(); }; + Prog.Ptr.prototype.Prefix = function() { + var prefix = "", complete = false, p, _tuple, i, _tmp, _tmp$1, buf, x, _tuple$1, _tmp$2, _tmp$3; + p = this; + _tuple = p.skipNop((p.Start >>> 0)); i = _tuple[0]; + if (!((i.op() === 7)) || !((i.Rune.$length === 1))) { + _tmp = ""; _tmp$1 = i.Op === 4; prefix = _tmp; complete = _tmp$1; + return [prefix, complete]; } - return filepath.SplitList(s); + buf = new bytes.Buffer.Ptr(); $copy(buf, new bytes.Buffer.Ptr(), bytes.Buffer); + while ((i.op() === 7) && (i.Rune.$length === 1) && ((((i.Arg << 16 >>> 16) & 1) >>> 0) === 0)) { + buf.WriteRune((x = i.Rune, ((0 < 0 || 0 >= x.$length) ? $throwRuntimeError("index out of range") : x.$array[x.$offset + 0]))); + _tuple$1 = p.skipNop(i.Out); i = _tuple$1[0]; + } + _tmp$2 = buf.String(); _tmp$3 = i.Op === 4; prefix = _tmp$2; complete = _tmp$3; + return [prefix, complete]; }; - Context.prototype.splitPathList = function(s) { return this.$val.splitPathList(s); }; - Context.Ptr.prototype.isAbsPath = function(path$1) { - var ctxt, f; - ctxt = this; - f = ctxt.IsAbsPath; - if (!(f === $throwNilPointerError)) { - return f(path$1); + Prog.prototype.Prefix = function() { return this.$val.Prefix(); }; + Prog.Ptr.prototype.StartCond = function() { + var p, flag, pc, x, i, _ref, x$1; + p = this; + flag = 0; + pc = (p.Start >>> 0); + i = (x = p.Inst, ((pc < 0 || pc >= x.$length) ? $throwRuntimeError("index out of range") : x.$array[x.$offset + pc])); + Loop: + while (true) { + _ref = i.Op; + if (_ref === 3) { + flag = (flag | ((i.Arg << 24 >>> 24))) >>> 0; + } else if (_ref === 5) { + return 255; + } else if (_ref === 2 || _ref === 6) { + } else { + break Loop; + } + pc = i.Out; + i = (x$1 = p.Inst, ((pc < 0 || pc >= x$1.$length) ? $throwRuntimeError("index out of range") : x$1.$array[x$1.$offset + pc])); } - return filepath.IsAbs(path$1); + return flag; }; - Context.prototype.isAbsPath = function(path$1) { return this.$val.isAbsPath(path$1); }; - Context.Ptr.prototype.isDir = function(path$1) { - var ctxt, f, _tuple, fi, err; - ctxt = this; - f = ctxt.IsDir; - if (!(f === $throwNilPointerError)) { - return f(path$1); + Prog.prototype.StartCond = function() { return this.$val.StartCond(); }; + Inst.Ptr.prototype.MatchRune = function(r) { + var i; + i = this; + return !((i.MatchRunePos(r) === -1)); + }; + Inst.prototype.MatchRune = function(r) { return this.$val.MatchRune(r); }; + Inst.Ptr.prototype.MatchRunePos = function(r) { + var i, rune, r0, r1, j, x, _q, lo, _q$1, hi, _q$2, m, x$1, c, x$2; + i = this; + rune = i.Rune; + if (rune.$length === 1) { + r0 = ((0 < 0 || 0 >= rune.$length) ? $throwRuntimeError("index out of range") : rune.$array[rune.$offset + 0]); + if (r === r0) { + return 0; + } + if (!(((((i.Arg << 16 >>> 16) & 1) >>> 0) === 0))) { + r1 = unicode.SimpleFold(r0); + while (!((r1 === r0))) { + if (r === r1) { + return 0; + } + r1 = unicode.SimpleFold(r1); + } + } + return -1; } - _tuple = os.Stat(path$1); fi = _tuple[0]; err = _tuple[1]; - return $interfaceIsEqual(err, $ifaceNil) && fi.IsDir(); + j = 0; + while (j < rune.$length && j <= 8) { + if (r < ((j < 0 || j >= rune.$length) ? $throwRuntimeError("index out of range") : rune.$array[rune.$offset + j])) { + return -1; + } + if (r <= (x = j + 1 >> 0, ((x < 0 || x >= rune.$length) ? $throwRuntimeError("index out of range") : rune.$array[rune.$offset + x]))) { + return (_q = j / 2, (_q === _q && _q !== 1/0 && _q !== -1/0) ? _q >> 0 : $throwRuntimeError("integer divide by zero")); + } + j = j + (2) >> 0; + } + lo = 0; + hi = (_q$1 = rune.$length / 2, (_q$1 === _q$1 && _q$1 !== 1/0 && _q$1 !== -1/0) ? _q$1 >> 0 : $throwRuntimeError("integer divide by zero")); + while (lo < hi) { + m = lo + (_q$2 = ((hi - lo >> 0)) / 2, (_q$2 === _q$2 && _q$2 !== 1/0 && _q$2 !== -1/0) ? _q$2 >> 0 : $throwRuntimeError("integer divide by zero")) >> 0; + c = (x$1 = (((2 >>> 16 << 16) * m >> 0) + (2 << 16 >>> 16) * m) >> 0, ((x$1 < 0 || x$1 >= rune.$length) ? $throwRuntimeError("index out of range") : rune.$array[rune.$offset + x$1])); + if (c <= r) { + if (r <= (x$2 = ((((2 >>> 16 << 16) * m >> 0) + (2 << 16 >>> 16) * m) >> 0) + 1 >> 0, ((x$2 < 0 || x$2 >= rune.$length) ? $throwRuntimeError("index out of range") : rune.$array[rune.$offset + x$2]))) { + return m; + } + lo = m + 1 >> 0; + } else { + hi = m; + } + } + return -1; }; - Context.prototype.isDir = function(path$1) { return this.$val.isDir(path$1); }; - Context.Ptr.prototype.hasSubdir = function(root, dir) { - var rel = "", ok = false, ctxt, f, _tuple, _tuple$1, _tuple$2, rootSym, _tuple$3, dirSym, _tuple$4, _tuple$5, _tuple$6; - ctxt = this; - f = ctxt.HasSubdir; - if (!(f === $throwNilPointerError)) { - _tuple = f(root, dir); rel = _tuple[0]; ok = _tuple[1]; - return [rel, ok]; + Inst.prototype.MatchRunePos = function(r) { return this.$val.MatchRunePos(r); }; + wordRune = function(r) { + return (r === 95) || (65 <= r && r <= 90) || (97 <= r && r <= 122) || (48 <= r && r <= 57); + }; + Inst.Ptr.prototype.MatchEmptyWidth = function(before, after) { + var i, _ref; + i = this; + _ref = (i.Arg << 24 >>> 24); + if (_ref === 1) { + return (before === 10) || (before === -1); + } else if (_ref === 2) { + return (after === 10) || (after === -1); + } else if (_ref === 4) { + return before === -1; + } else if (_ref === 8) { + return after === -1; + } else if (_ref === 16) { + return !(wordRune(before) === wordRune(after)); + } else if (_ref === 32) { + return wordRune(before) === wordRune(after); } - _tuple$1 = hasSubdir(root, dir); rel = _tuple$1[0]; ok = _tuple$1[1]; - if (ok) { - return [rel, ok]; + $panic(new $String("unknown empty width arg")); + }; + Inst.prototype.MatchEmptyWidth = function(before, after) { return this.$val.MatchEmptyWidth(before, after); }; + Inst.Ptr.prototype.String = function() { + var i, b; + i = this; + b = new bytes.Buffer.Ptr(); $copy(b, new bytes.Buffer.Ptr(), bytes.Buffer); + dumpInst(b, i); + return b.String(); + }; + Inst.prototype.String = function() { return this.$val.String(); }; + bw = function(b, args) { + var _ref, _i, s; + _ref = args; + _i = 0; + while (_i < _ref.$length) { + s = ((_i < 0 || _i >= _ref.$length) ? $throwRuntimeError("index out of range") : _ref.$array[_ref.$offset + _i]); + b.WriteString(s); + _i++; } - _tuple$2 = filepath.EvalSymlinks(root); rootSym = _tuple$2[0]; - _tuple$3 = filepath.EvalSymlinks(dir); dirSym = _tuple$3[0]; - _tuple$4 = hasSubdir(rootSym, dir); rel = _tuple$4[0]; ok = _tuple$4[1]; - if (ok) { - return [rel, ok]; + }; + dumpProg = function(b, p) { + var _ref, _i, j, x, i, pc; + _ref = p.Inst; + _i = 0; + while (_i < _ref.$length) { + j = _i; + i = (x = p.Inst, ((j < 0 || j >= x.$length) ? $throwRuntimeError("index out of range") : x.$array[x.$offset + j])); + pc = strconv.Itoa(j); + if (pc.length < 3) { + b.WriteString(" ".substring(pc.length)); + } + if (j === p.Start) { + pc = pc + ("*"); + } + bw(b, new ($sliceType($String))([pc, "\t"])); + dumpInst(b, i); + bw(b, new ($sliceType($String))(["\n"])); + _i++; } - _tuple$5 = hasSubdir(root, dirSym); rel = _tuple$5[0]; ok = _tuple$5[1]; - if (ok) { - return [rel, ok]; + }; + u32 = function(i) { + return strconv.FormatUint(new $Uint64(0, i), 10); + }; + dumpInst = function(b, i) { + var _ref; + _ref = i.Op; + if (_ref === 0) { + bw(b, new ($sliceType($String))(["alt -> ", u32(i.Out), ", ", u32(i.Arg)])); + } else if (_ref === 1) { + bw(b, new ($sliceType($String))(["altmatch -> ", u32(i.Out), ", ", u32(i.Arg)])); + } else if (_ref === 2) { + bw(b, new ($sliceType($String))(["cap ", u32(i.Arg), " -> ", u32(i.Out)])); + } else if (_ref === 3) { + bw(b, new ($sliceType($String))(["empty ", u32(i.Arg), " -> ", u32(i.Out)])); + } else if (_ref === 4) { + bw(b, new ($sliceType($String))(["match"])); + } else if (_ref === 5) { + bw(b, new ($sliceType($String))(["fail"])); + } else if (_ref === 6) { + bw(b, new ($sliceType($String))(["nop -> ", u32(i.Out)])); + } else if (_ref === 7) { + if (i.Rune === ($sliceType($Int32)).nil) { + bw(b, new ($sliceType($String))(["rune "])); + } + bw(b, new ($sliceType($String))(["rune ", strconv.QuoteToASCII($runesToString(i.Rune))])); + if (!(((((i.Arg << 16 >>> 16) & 1) >>> 0) === 0))) { + bw(b, new ($sliceType($String))(["/i"])); + } + bw(b, new ($sliceType($String))([" -> ", u32(i.Out)])); + } else if (_ref === 8) { + bw(b, new ($sliceType($String))(["rune1 ", strconv.QuoteToASCII($runesToString(i.Rune)), " -> ", u32(i.Out)])); + } else if (_ref === 9) { + bw(b, new ($sliceType($String))(["any -> ", u32(i.Out)])); + } else if (_ref === 10) { + bw(b, new ($sliceType($String))(["anynotnl -> ", u32(i.Out)])); } - _tuple$6 = hasSubdir(rootSym, dirSym); rel = _tuple$6[0]; ok = _tuple$6[1]; - return [rel, ok]; }; - Context.prototype.hasSubdir = function(root, dir) { return this.$val.hasSubdir(root, dir); }; - hasSubdir = function(root, dir) { - var rel = "", ok = false, _tmp, _tmp$1, _tmp$2, _tmp$3; - root = filepath.Clean(root); - if (!strings.HasSuffix(root, "/")) { - root = root + ("/"); + Regexp.Ptr.prototype.Equal = function(y) { + var x, _ref, _ref$1, _i, i, r, x$1, _ref$2, _i$1, i$1, sub, x$2, x$3, x$4, x$5, x$6, x$7, x$8; + x = this; + if (x === ($ptrType(Regexp)).nil || y === ($ptrType(Regexp)).nil) { + return x === y; } - dir = filepath.Clean(dir); - if (!strings.HasPrefix(dir, root)) { - _tmp = ""; _tmp$1 = false; rel = _tmp; ok = _tmp$1; - return [rel, ok]; + if (!((x.Op === y.Op))) { + return false; } - _tmp$2 = filepath.ToSlash(dir.substring(root.length)); _tmp$3 = true; rel = _tmp$2; ok = _tmp$3; - return [rel, ok]; + _ref = x.Op; + if (_ref === 10) { + if (!((((x.Flags & 256) >>> 0) === ((y.Flags & 256) >>> 0)))) { + return false; + } + } else if (_ref === 3 || _ref === 4) { + if (!((x.Rune.$length === y.Rune.$length))) { + return false; + } + _ref$1 = x.Rune; + _i = 0; + while (_i < _ref$1.$length) { + i = _i; + r = ((_i < 0 || _i >= _ref$1.$length) ? $throwRuntimeError("index out of range") : _ref$1.$array[_ref$1.$offset + _i]); + if (!((r === (x$1 = y.Rune, ((i < 0 || i >= x$1.$length) ? $throwRuntimeError("index out of range") : x$1.$array[x$1.$offset + i]))))) { + return false; + } + _i++; + } + } else if (_ref === 19 || _ref === 18) { + if (!((x.Sub.$length === y.Sub.$length))) { + return false; + } + _ref$2 = x.Sub; + _i$1 = 0; + while (_i$1 < _ref$2.$length) { + i$1 = _i$1; + sub = ((_i$1 < 0 || _i$1 >= _ref$2.$length) ? $throwRuntimeError("index out of range") : _ref$2.$array[_ref$2.$offset + _i$1]); + if (!sub.Equal((x$2 = y.Sub, ((i$1 < 0 || i$1 >= x$2.$length) ? $throwRuntimeError("index out of range") : x$2.$array[x$2.$offset + i$1])))) { + return false; + } + _i$1++; + } + } else if (_ref === 14 || _ref === 15 || _ref === 16) { + if (!((((x.Flags & 32) >>> 0) === ((y.Flags & 32) >>> 0))) || !(x$3 = x.Sub, ((0 < 0 || 0 >= x$3.$length) ? $throwRuntimeError("index out of range") : x$3.$array[x$3.$offset + 0])).Equal((x$4 = y.Sub, ((0 < 0 || 0 >= x$4.$length) ? $throwRuntimeError("index out of range") : x$4.$array[x$4.$offset + 0])))) { + return false; + } + } else if (_ref === 17) { + if (!((((x.Flags & 32) >>> 0) === ((y.Flags & 32) >>> 0))) || !((x.Min === y.Min)) || !((x.Max === y.Max)) || !(x$5 = x.Sub, ((0 < 0 || 0 >= x$5.$length) ? $throwRuntimeError("index out of range") : x$5.$array[x$5.$offset + 0])).Equal((x$6 = y.Sub, ((0 < 0 || 0 >= x$6.$length) ? $throwRuntimeError("index out of range") : x$6.$array[x$6.$offset + 0])))) { + return false; + } + } else if (_ref === 13) { + if (!((x.Cap === y.Cap)) || !(x.Name === y.Name) || !(x$7 = x.Sub, ((0 < 0 || 0 >= x$7.$length) ? $throwRuntimeError("index out of range") : x$7.$array[x$7.$offset + 0])).Equal((x$8 = y.Sub, ((0 < 0 || 0 >= x$8.$length) ? $throwRuntimeError("index out of range") : x$8.$array[x$8.$offset + 0])))) { + return false; + } + } + return true; + }; + Regexp.prototype.Equal = function(y) { return this.$val.Equal(y); }; + writeRegexp = function(b, re) { + var _ref, _ref$1, _i, r, _r, x, x$1, x$2, i, _tmp, x$3, _tmp$1, x$4, x$5, lo, hi, i$1, _tmp$2, x$6, _tmp$3, x$7, x$8, lo$1, hi$1, x$9, x$10, x$11, sub, _ref$2, _ref$3, _i$1, sub$1, _ref$4, _i$2, i$2, sub$2; + _ref = re.Op; + switch (0) { default: if (_ref === 1) { + b.WriteString("[^\\x00-\\x{10FFFF}]"); + } else if (_ref === 2) { + b.WriteString("(?:)"); + } else if (_ref === 3) { + if (!((((re.Flags & 1) >>> 0) === 0))) { + b.WriteString("(?i:"); + } + _ref$1 = re.Rune; + _i = 0; + while (_i < _ref$1.$length) { + r = ((_i < 0 || _i >= _ref$1.$length) ? $throwRuntimeError("index out of range") : _ref$1.$array[_ref$1.$offset + _i]); + escape(b, r, false); + _i++; + } + if (!((((re.Flags & 1) >>> 0) === 0))) { + b.WriteString(")"); + } + } else if (_ref === 4) { + if (!(((_r = re.Rune.$length % 2, _r === _r ? _r : $throwRuntimeError("integer divide by zero")) === 0))) { + b.WriteString("[invalid char class]"); + break; + } + b.WriteRune(91); + if (re.Rune.$length === 0) { + b.WriteString("^\\x00-\\x{10FFFF}"); + } else if (((x = re.Rune, ((0 < 0 || 0 >= x.$length) ? $throwRuntimeError("index out of range") : x.$array[x.$offset + 0])) === 0) && ((x$1 = re.Rune, x$2 = re.Rune.$length - 1 >> 0, ((x$2 < 0 || x$2 >= x$1.$length) ? $throwRuntimeError("index out of range") : x$1.$array[x$1.$offset + x$2])) === 1114111)) { + b.WriteRune(94); + i = 1; + while (i < (re.Rune.$length - 1 >> 0)) { + _tmp = (x$3 = re.Rune, ((i < 0 || i >= x$3.$length) ? $throwRuntimeError("index out of range") : x$3.$array[x$3.$offset + i])) + 1 >> 0; _tmp$1 = (x$4 = re.Rune, x$5 = i + 1 >> 0, ((x$5 < 0 || x$5 >= x$4.$length) ? $throwRuntimeError("index out of range") : x$4.$array[x$4.$offset + x$5])) - 1 >> 0; lo = _tmp; hi = _tmp$1; + escape(b, lo, lo === 45); + if (!((lo === hi))) { + b.WriteRune(45); + escape(b, hi, hi === 45); + } + i = i + (2) >> 0; + } + } else { + i$1 = 0; + while (i$1 < re.Rune.$length) { + _tmp$2 = (x$6 = re.Rune, ((i$1 < 0 || i$1 >= x$6.$length) ? $throwRuntimeError("index out of range") : x$6.$array[x$6.$offset + i$1])); _tmp$3 = (x$7 = re.Rune, x$8 = i$1 + 1 >> 0, ((x$8 < 0 || x$8 >= x$7.$length) ? $throwRuntimeError("index out of range") : x$7.$array[x$7.$offset + x$8])); lo$1 = _tmp$2; hi$1 = _tmp$3; + escape(b, lo$1, lo$1 === 45); + if (!((lo$1 === hi$1))) { + b.WriteRune(45); + escape(b, hi$1, hi$1 === 45); + } + i$1 = i$1 + (2) >> 0; + } + } + b.WriteRune(93); + } else if (_ref === 5) { + b.WriteString("(?-s:.)"); + } else if (_ref === 6) { + b.WriteString("(?s:.)"); + } else if (_ref === 7) { + b.WriteRune(94); + } else if (_ref === 8) { + b.WriteRune(36); + } else if (_ref === 9) { + b.WriteString("\\A"); + } else if (_ref === 10) { + if (!((((re.Flags & 256) >>> 0) === 0))) { + b.WriteString("(?-m:$)"); + } else { + b.WriteString("\\z"); + } + } else if (_ref === 11) { + b.WriteString("\\b"); + } else if (_ref === 12) { + b.WriteString("\\B"); + } else if (_ref === 13) { + if (!(re.Name === "")) { + b.WriteString("(?P<"); + b.WriteString(re.Name); + b.WriteRune(62); + } else { + b.WriteRune(40); + } + if (!(((x$9 = re.Sub, ((0 < 0 || 0 >= x$9.$length) ? $throwRuntimeError("index out of range") : x$9.$array[x$9.$offset + 0])).Op === 2))) { + writeRegexp(b, (x$10 = re.Sub, ((0 < 0 || 0 >= x$10.$length) ? $throwRuntimeError("index out of range") : x$10.$array[x$10.$offset + 0]))); + } + b.WriteRune(41); + } else if (_ref === 14 || _ref === 15 || _ref === 16 || _ref === 17) { + sub = (x$11 = re.Sub, ((0 < 0 || 0 >= x$11.$length) ? $throwRuntimeError("index out of range") : x$11.$array[x$11.$offset + 0])); + if (sub.Op > 13 || (sub.Op === 3) && sub.Rune.$length > 1) { + b.WriteString("(?:"); + writeRegexp(b, sub); + b.WriteString(")"); + } else { + writeRegexp(b, sub); + } + _ref$2 = re.Op; + if (_ref$2 === 14) { + b.WriteRune(42); + } else if (_ref$2 === 15) { + b.WriteRune(43); + } else if (_ref$2 === 16) { + b.WriteRune(63); + } else if (_ref$2 === 17) { + b.WriteRune(123); + b.WriteString(strconv.Itoa(re.Min)); + if (!((re.Max === re.Min))) { + b.WriteRune(44); + if (re.Max >= 0) { + b.WriteString(strconv.Itoa(re.Max)); + } + } + b.WriteRune(125); + } + if (!((((re.Flags & 32) >>> 0) === 0))) { + b.WriteRune(63); + } + } else if (_ref === 18) { + _ref$3 = re.Sub; + _i$1 = 0; + while (_i$1 < _ref$3.$length) { + sub$1 = ((_i$1 < 0 || _i$1 >= _ref$3.$length) ? $throwRuntimeError("index out of range") : _ref$3.$array[_ref$3.$offset + _i$1]); + if (sub$1.Op === 19) { + b.WriteString("(?:"); + writeRegexp(b, sub$1); + b.WriteString(")"); + } else { + writeRegexp(b, sub$1); + } + _i$1++; + } + } else if (_ref === 19) { + _ref$4 = re.Sub; + _i$2 = 0; + while (_i$2 < _ref$4.$length) { + i$2 = _i$2; + sub$2 = ((_i$2 < 0 || _i$2 >= _ref$4.$length) ? $throwRuntimeError("index out of range") : _ref$4.$array[_ref$4.$offset + _i$2]); + if (i$2 > 0) { + b.WriteRune(124); + } + writeRegexp(b, sub$2); + _i$2++; + } + } else { + b.WriteString("> 0)) + ">"); + } } }; - Context.Ptr.prototype.readDir = function(path$1) { - var ctxt, f; - ctxt = this; - f = ctxt.ReadDir; - if (!(f === $throwNilPointerError)) { - return f(path$1); - } - return ioutil.ReadDir(path$1); + Regexp.Ptr.prototype.String = function() { + var re, b; + re = this; + b = new bytes.Buffer.Ptr(); $copy(b, new bytes.Buffer.Ptr(), bytes.Buffer); + writeRegexp(b, re); + return b.String(); }; - Context.prototype.readDir = function(path$1) { return this.$val.readDir(path$1); }; - Context.Ptr.prototype.openFile = function(path$1) { - var ctxt, fn, _tuple, f, err; - ctxt = this; - fn = ctxt.OpenFile; - if (!(fn === $throwNilPointerError)) { - return fn(path$1); - } - _tuple = os.Open(path$1); f = _tuple[0]; err = _tuple[1]; - if (!($interfaceIsEqual(err, $ifaceNil))) { - return [$ifaceNil, err]; + Regexp.prototype.String = function() { return this.$val.String(); }; + escape = function(b, r, force) { + var _ref, s; + if (unicode.IsPrint(r)) { + if (strings.IndexRune("\\.+*?()|[]{}^$", r) >= 0 || force) { + b.WriteRune(92); + } + b.WriteRune(r); + return; } - return [f, $ifaceNil]; + _ref = r; + switch (0) { default: if (_ref === 7) { + b.WriteString("\\a"); + } else if (_ref === 12) { + b.WriteString("\\f"); + } else if (_ref === 10) { + b.WriteString("\\n"); + } else if (_ref === 13) { + b.WriteString("\\r"); + } else if (_ref === 9) { + b.WriteString("\\t"); + } else if (_ref === 11) { + b.WriteString("\\v"); + } else { + if (r < 256) { + b.WriteString("\\x"); + s = strconv.FormatInt(new $Int64(0, r), 16); + if (s.length === 1) { + b.WriteRune(48); + } + b.WriteString(s); + break; + } + b.WriteString("\\x{"); + b.WriteString(strconv.FormatInt(new $Int64(0, r), 16)); + b.WriteString("}"); + } } }; - Context.prototype.openFile = function(path$1) { return this.$val.openFile(path$1); }; - Context.Ptr.prototype.isFile = function(path$1) { - var ctxt, _tuple, f, err; - ctxt = this; - _tuple = ctxt.openFile(path$1); f = _tuple[0]; err = _tuple[1]; - if (!($interfaceIsEqual(err, $ifaceNil))) { - return false; + Regexp.Ptr.prototype.MaxCap = function() { + var re, m, _ref, _i, sub, n; + re = this; + m = 0; + if (re.Op === 13) { + m = re.Cap; } - f.Close(); - return true; - }; - Context.prototype.isFile = function(path$1) { return this.$val.isFile(path$1); }; - Context.Ptr.prototype.gopath = function() { - var ctxt, all, _ref, _i, p; - ctxt = this; - all = ($sliceType($String)).nil; - _ref = ctxt.splitPathList(ctxt.GOPATH); + _ref = re.Sub; _i = 0; while (_i < _ref.$length) { - p = ((_i < 0 || _i >= _ref.$length) ? $throwRuntimeError("index out of range") : _ref.$array[_ref.$offset + _i]); - if (p === "" || p === ctxt.GOROOT) { - _i++; - continue; - } - if (strings.HasPrefix(p, "~")) { - _i++; - continue; + sub = ((_i < 0 || _i >= _ref.$length) ? $throwRuntimeError("index out of range") : _ref.$array[_ref.$offset + _i]); + n = sub.MaxCap(); + if (m < n) { + m = n; } - all = $append(all, p); _i++; } - return all; + return m; }; - Context.prototype.gopath = function() { return this.$val.gopath(); }; - Context.Ptr.prototype.SrcDirs = function() { - var ctxt, all, dir, _ref, _i, p, dir$1; - ctxt = this; - all = ($sliceType($String)).nil; - if (!(ctxt.GOROOT === "")) { - dir = ctxt.joinPath(new ($sliceType($String))([ctxt.GOROOT, "src", "pkg"])); - if (ctxt.isDir(dir)) { - all = $append(all, dir); - } + Regexp.prototype.MaxCap = function() { return this.$val.MaxCap(); }; + Regexp.Ptr.prototype.CapNames = function() { + var re, names; + re = this; + names = ($sliceType($String)).make((re.MaxCap() + 1 >> 0)); + re.capNames(names); + return names; + }; + Regexp.prototype.CapNames = function() { return this.$val.CapNames(); }; + Regexp.Ptr.prototype.capNames = function(names) { + var re, x, _ref, _i, sub; + re = this; + if (re.Op === 13) { + (x = re.Cap, (x < 0 || x >= names.$length) ? $throwRuntimeError("index out of range") : names.$array[names.$offset + x] = re.Name); } - _ref = ctxt.gopath(); + _ref = re.Sub; _i = 0; while (_i < _ref.$length) { - p = ((_i < 0 || _i >= _ref.$length) ? $throwRuntimeError("index out of range") : _ref.$array[_ref.$offset + _i]); - dir$1 = ctxt.joinPath(new ($sliceType($String))([p, "src"])); - if (ctxt.isDir(dir$1)) { - all = $append(all, dir$1); - } + sub = ((_i < 0 || _i >= _ref.$length) ? $throwRuntimeError("index out of range") : _ref.$array[_ref.$offset + _i]); + sub.capNames(names); _i++; } - return all; - }; - Context.prototype.SrcDirs = function() { return this.$val.SrcDirs(); }; - defaultContext = function() { - var c, _ref, _entry; - c = new Context.Ptr(); $copy(c, new Context.Ptr(), Context); - c.GOARCH = envOr("GOARCH", "js"); - c.GOOS = envOr("GOOS", "darwin"); - c.GOROOT = runtime.GOROOT(); - c.GOPATH = envOr("GOPATH", ""); - c.Compiler = "gc"; - c.ReleaseTags = new ($sliceType($String))(["go1.1", "go1.2", "go1.3"]); - _ref = os.Getenv("CGO_ENABLED"); - switch (0) { default: if (_ref === "1") { - c.CgoEnabled = true; - } else if (_ref === "0") { - c.CgoEnabled = false; - } else { - if ("js" === c.GOARCH && "darwin" === c.GOOS) { - c.CgoEnabled = (_entry = cgoEnabled[c.GOOS + "/" + c.GOARCH], _entry !== undefined ? _entry.v : false); - break; - } - c.CgoEnabled = false; - } } - return c; - }; - envOr = function(name, def) { - var s; - s = os.Getenv(name); - if (s === "") { - return def; - } - return s; - }; - Package.Ptr.prototype.IsCommand = function() { - var p; - p = this; - return p.Name === "main"; - }; - Package.prototype.IsCommand = function() { return this.$val.IsCommand(); }; - Context.Ptr.prototype.ImportDir = function(dir, mode) { - var ctxt; - ctxt = this; - return ctxt.Import(".", dir, mode); - }; - Context.prototype.ImportDir = function(dir, mode) { return this.$val.ImportDir(dir, mode); }; - NoGoError.Ptr.prototype.Error = function() { - var e; - e = this; - return "no buildable Go source files in " + e.Dir; - }; - NoGoError.prototype.Error = function() { return this.$val.Error(); }; - nameExt = function(name) { - var i; - i = strings.LastIndex(name, "."); - if (i < 0) { - return ""; - } - return name.substring(i); }; - Context.Ptr.prototype.Import = function(path$1, srcDir, mode) { - var $this = this, $args = arguments, $s = 0, ctxt, p, pkga, pkgerr, _ref, _tuple, dir, elem, suffix, binaryOnly, root, _tuple$1, sub, ok, all, _ref$1, _i, i, root$1, rootsrc, _tuple$2, sub$1, ok$1, dir$1, _ref$2, _i$1, earlyRoot, dir$2, tried, dir$3, isDir, _ref$3, _i$2, root$2, dir$4, isDir$1, paths, i$1, format, x, _tuple$3, dirs, err, Sfiles, firstFile, imported, testImported, xTestImported, allTags, fset, _ref$4, _i$3, d, name, ext, _tuple$4, match, data, filename, err$1, _ref$5, _tuple$5, pf, pkg, isTest, isXTest, isCgo, _ref$6, _i$4, decl, _tuple$6, d$1, ok$2, _ref$7, _i$5, dspec, _tuple$7, spec, ok$3, quoted, _tuple$8, path$2, err$2, _entry, _key$1, _entry$1, _key$2, _entry$2, _key$3, cg, err$3, _key$4, _ref$8, _i$6, _keys, _entry$3, tag, _tuple$9, _tuple$10, _tuple$11; - /* */ while (true) { switch ($s) { case 0: - ctxt = $this; - p = new Package.Ptr("", "", "", path$1, "", "", "", "", false, "", ($sliceType($String)).nil, "", ($sliceType($String)).nil, ($sliceType($String)).nil, ($sliceType($String)).nil, ($sliceType($String)).nil, ($sliceType($String)).nil, ($sliceType($String)).nil, ($sliceType($String)).nil, ($sliceType($String)).nil, ($sliceType($String)).nil, ($sliceType($String)).nil, ($sliceType($String)).nil, ($sliceType($String)).nil, ($sliceType($String)).nil, ($sliceType($String)).nil, ($sliceType($String)).nil, ($sliceType($String)).nil, ($sliceType($String)).nil, false, ($sliceType($String)).nil, ($sliceType($String)).nil, false, ($sliceType($String)).nil, ($sliceType($String)).nil, false); - if (path$1 === "") { - return [p, fmt.Errorf("import %q: invalid import path", new ($sliceType($emptyInterface))([new $String(path$1)]))]; - } - pkga = ""; - pkgerr = $ifaceNil; - _ref = ctxt.Compiler; - if (_ref === "gccgo") { - _tuple = path.Split(p.ImportPath); dir = _tuple[0]; elem = _tuple[1]; - pkga = "pkg/gccgo_" + ctxt.GOOS + "_" + ctxt.GOARCH + "/" + dir + "lib" + elem + ".a"; - } else if (_ref === "gc") { - suffix = ""; - if (!(ctxt.InstallSuffix === "")) { - suffix = "_" + ctxt.InstallSuffix; - } - pkga = "pkg/" + ctxt.GOOS + "_" + ctxt.GOARCH + suffix + "/" + p.ImportPath + ".a"; - } else { - pkgerr = fmt.Errorf("import %q: unknown compiler %q", new ($sliceType($emptyInterface))([new $String(path$1), new $String(ctxt.Compiler)])); + Regexp.prototype.capNames = function(names) { return this.$val.capNames(names); }; + Regexp.Ptr.prototype.Simplify = function() { + var re, _ref, nre, _ref$1, _i, i, sub, nsub, x, sub$1, x$1, sub$2, nre$1, i$1, prefix, i$2, suffix, i$3, nre2; + re = this; + if (re === ($ptrType(Regexp)).nil) { + return ($ptrType(Regexp)).nil; } - binaryOnly = false; - /* if (IsLocalImport(path$1)) { */ if (IsLocalImport(path$1)) {} else { $s = 2; continue; } - pkga = ""; - if (srcDir === "") { - return [p, fmt.Errorf("import %q: import relative to unknown directory", new ($sliceType($emptyInterface))([new $String(path$1)]))]; - } - if (!ctxt.isAbsPath(path$1)) { - p.Dir = ctxt.joinPath(new ($sliceType($String))([srcDir, path$1])); - } - /* if (!(ctxt.GOROOT === "")) { */ if (!(ctxt.GOROOT === "")) {} else { $s = 4; continue; } - root = ctxt.joinPath(new ($sliceType($String))([ctxt.GOROOT, "src", "pkg"])); - _tuple$1 = ctxt.hasSubdir(root, p.Dir); sub = _tuple$1[0]; ok = _tuple$1[1]; - /* if (ok) { */ if (ok) {} else { $s = 5; continue; } - p.Goroot = true; - p.ImportPath = sub; - p.Root = ctxt.GOROOT; - /* goto Found */ $s = 1; continue; - /* } */ case 5: - /* } */ case 4: - all = ctxt.gopath(); - _ref$1 = all; + _ref = re.Op; + if (_ref === 13 || _ref === 18 || _ref === 19) { + nre = re; + _ref$1 = re.Sub; _i = 0; - /* while (_i < _ref$1.$length) { */ case 6: if(!(_i < _ref$1.$length)) { $s = 7; continue; } + while (_i < _ref$1.$length) { i = _i; - root$1 = ((_i < 0 || _i >= _ref$1.$length) ? $throwRuntimeError("index out of range") : _ref$1.$array[_ref$1.$offset + _i]); - rootsrc = ctxt.joinPath(new ($sliceType($String))([root$1, "src"])); - _tuple$2 = ctxt.hasSubdir(rootsrc, p.Dir); sub$1 = _tuple$2[0]; ok$1 = _tuple$2[1]; - /* if (ok$1) { */ if (ok$1) {} else { $s = 8; continue; } - /* if (!(ctxt.GOROOT === "")) { */ if (!(ctxt.GOROOT === "")) {} else { $s = 9; continue; } - dir$1 = ctxt.joinPath(new ($sliceType($String))([ctxt.GOROOT, "src", "pkg", sub$1])); - /* if (ctxt.isDir(dir$1)) { */ if (ctxt.isDir(dir$1)) {} else { $s = 10; continue; } - p.ConflictDir = dir$1; - /* goto Found */ $s = 1; continue; - /* } */ case 10: - /* } */ case 9: - _ref$2 = $subslice(all, 0, i); - _i$1 = 0; - /* while (_i$1 < _ref$2.$length) { */ case 11: if(!(_i$1 < _ref$2.$length)) { $s = 12; continue; } - earlyRoot = ((_i$1 < 0 || _i$1 >= _ref$2.$length) ? $throwRuntimeError("index out of range") : _ref$2.$array[_ref$2.$offset + _i$1]); - dir$2 = ctxt.joinPath(new ($sliceType($String))([earlyRoot, "src", sub$1])); - /* if (ctxt.isDir(dir$2)) { */ if (ctxt.isDir(dir$2)) {} else { $s = 13; continue; } - p.ConflictDir = dir$2; - /* goto Found */ $s = 1; continue; - /* } */ case 13: - _i$1++; - /* } */ $s = 11; continue; case 12: - p.ImportPath = sub$1; - p.Root = root$1; - /* goto Found */ $s = 1; continue; - /* } */ case 8: + sub = ((_i < 0 || _i >= _ref$1.$length) ? $throwRuntimeError("index out of range") : _ref$1.$array[_ref$1.$offset + _i]); + nsub = sub.Simplify(); + if (nre === re && !(nsub === sub)) { + nre = new Regexp.Ptr(); + $copy(nre, re, Regexp); + nre.Rune = ($sliceType($Int32)).nil; + nre.Sub = $appendSlice($subslice(new ($sliceType(($ptrType(Regexp))))(nre.Sub0), 0, 0), $subslice(re.Sub, 0, i)); + } + if (!(nre === re)) { + nre.Sub = $append(nre.Sub, nsub); + } _i++; - /* } */ $s = 6; continue; case 7: - /* } else { */ $s = 3; continue; case 2: - if (strings.HasPrefix(path$1, "/")) { - return [p, fmt.Errorf("import %q: cannot import absolute path", new ($sliceType($emptyInterface))([new $String(path$1)]))]; } - tried = new ($structType([["goroot", "goroot", "go/build", $String, ""], ["gopath", "gopath", "go/build", ($sliceType($String)), ""]])).Ptr(); $copy(tried, new ($structType([["goroot", "goroot", "go/build", $String, ""], ["gopath", "gopath", "go/build", ($sliceType($String)), ""]])).Ptr(), ($structType([["goroot", "goroot", "go/build", $String, ""], ["gopath", "gopath", "go/build", ($sliceType($String)), ""]]))); - /* if (!(ctxt.GOROOT === "")) { */ if (!(ctxt.GOROOT === "")) {} else { $s = 14; continue; } - dir$3 = ctxt.joinPath(new ($sliceType($String))([ctxt.GOROOT, "src", "pkg", path$1])); - isDir = ctxt.isDir(dir$3); - binaryOnly = !isDir && !((((mode & 2) >>> 0) === 0)) && !(pkga === "") && ctxt.isFile(ctxt.joinPath(new ($sliceType($String))([ctxt.GOROOT, pkga]))); - /* if (isDir || binaryOnly) { */ if (isDir || binaryOnly) {} else { $s = 15; continue; } - p.Dir = dir$3; - p.Goroot = true; - p.Root = ctxt.GOROOT; - /* goto Found */ $s = 1; continue; - /* } */ case 15: - tried.goroot = dir$3; - /* } */ case 14: - _ref$3 = ctxt.gopath(); - _i$2 = 0; - /* while (_i$2 < _ref$3.$length) { */ case 16: if(!(_i$2 < _ref$3.$length)) { $s = 17; continue; } - root$2 = ((_i$2 < 0 || _i$2 >= _ref$3.$length) ? $throwRuntimeError("index out of range") : _ref$3.$array[_ref$3.$offset + _i$2]); - dir$4 = ctxt.joinPath(new ($sliceType($String))([root$2, "src", path$1])); - isDir$1 = ctxt.isDir(dir$4); - binaryOnly = !isDir$1 && !((((mode & 2) >>> 0) === 0)) && !(pkga === "") && ctxt.isFile(ctxt.joinPath(new ($sliceType($String))([root$2, pkga]))); - /* if (isDir$1 || binaryOnly) { */ if (isDir$1 || binaryOnly) {} else { $s = 18; continue; } - p.Dir = dir$4; - p.Root = root$2; - /* goto Found */ $s = 1; continue; - /* } */ case 18: - tried.gopath = $append(tried.gopath, dir$4); - _i$2++; - /* } */ $s = 16; continue; case 17: - paths = ($sliceType($String)).nil; - if (!(tried.goroot === "")) { - paths = $append(paths, fmt.Sprintf("\t%s (from $GOROOT)", new ($sliceType($emptyInterface))([new $String(tried.goroot)]))); - } else { - paths = $append(paths, "\t($GOROOT not set)"); + return nre; + } else if (_ref === 14 || _ref === 15 || _ref === 16) { + sub$1 = (x = re.Sub, ((0 < 0 || 0 >= x.$length) ? $throwRuntimeError("index out of range") : x.$array[x.$offset + 0])).Simplify(); + return simplify1(re.Op, re.Flags, sub$1, re); + } else if (_ref === 17) { + if ((re.Min === 0) && (re.Max === 0)) { + return new Regexp.Ptr(2, 0, ($sliceType(($ptrType(Regexp)))).nil, ($arrayType(($ptrType(Regexp)), 1)).zero(), ($sliceType($Int32)).nil, ($arrayType($Int32, 2)).zero(), 0, 0, 0, ""); } - i$1 = 0; - format = "\t%s (from $GOPATH)"; - while (i$1 < tried.gopath.$length) { - if (i$1 > 0) { - format = "\t%s"; + sub$2 = (x$1 = re.Sub, ((0 < 0 || 0 >= x$1.$length) ? $throwRuntimeError("index out of range") : x$1.$array[x$1.$offset + 0])).Simplify(); + if (re.Max === -1) { + if (re.Min === 0) { + return simplify1(14, re.Flags, sub$2, ($ptrType(Regexp)).nil); } - paths = $append(paths, fmt.Sprintf(format, new ($sliceType($emptyInterface))([new $String((x = tried.gopath, ((i$1 < 0 || i$1 >= x.$length) ? $throwRuntimeError("index out of range") : x.$array[x.$offset + i$1])))]))); - i$1 = i$1 + (1) >> 0; - } - if (i$1 === 0) { - paths = $append(paths, "\t($GOPATH not set)"); - } - return [p, fmt.Errorf("cannot find package %q in any of:\n%s", new ($sliceType($emptyInterface))([new $String(path$1), new $String(strings.Join(paths, "\n"))]))]; - /* } */ case 3: - /* Found: */ case 1: - if (!(p.Root === "")) { - if (p.Goroot) { - p.SrcRoot = ctxt.joinPath(new ($sliceType($String))([p.Root, "src", "pkg"])); - } else { - p.SrcRoot = ctxt.joinPath(new ($sliceType($String))([p.Root, "src"])); - } - p.PkgRoot = ctxt.joinPath(new ($sliceType($String))([p.Root, "pkg"])); - p.BinDir = ctxt.joinPath(new ($sliceType($String))([p.Root, "bin"])); - if (!(pkga === "")) { - p.PkgObj = ctxt.joinPath(new ($sliceType($String))([p.Root, pkga])); - } - } - if (!((((mode & 1) >>> 0) === 0))) { - return [p, pkgerr]; - } - if (binaryOnly && !(((((mode & 2) >>> 0)) === 0))) { - return [p, pkgerr]; - } - _tuple$3 = ctxt.readDir(p.Dir); dirs = _tuple$3[0]; err = _tuple$3[1]; - if (!($interfaceIsEqual(err, $ifaceNil))) { - return [p, err]; - } - Sfiles = ($sliceType($String)).nil; - firstFile = ""; - imported = new $Map(); - testImported = new $Map(); - xTestImported = new $Map(); - allTags = new $Map(); - fset = token.NewFileSet(); - _ref$4 = dirs; - _i$3 = 0; - while (_i$3 < _ref$4.$length) { - d = ((_i$3 < 0 || _i$3 >= _ref$4.$length) ? $throwRuntimeError("index out of range") : _ref$4.$array[_ref$4.$offset + _i$3]); - if (d.IsDir()) { - _i$3++; - continue; - } - name = d.Name(); - ext = nameExt(name); - _tuple$4 = ctxt.matchFile(p.Dir, name, true, allTags); match = _tuple$4[0]; data = _tuple$4[1]; filename = _tuple$4[2]; err$1 = _tuple$4[3]; - if (!($interfaceIsEqual(err$1, $ifaceNil))) { - return [p, err$1]; - } - if (!match) { - if (ext === ".go") { - p.IgnoredGoFiles = $append(p.IgnoredGoFiles, name); + if (re.Min === 1) { + return simplify1(15, re.Flags, sub$2, ($ptrType(Regexp)).nil); } - _i$3++; - continue; - } - _ref$5 = ext; - if (_ref$5 === ".c") { - p.CFiles = $append(p.CFiles, name); - _i$3++; - continue; - } else if (_ref$5 === ".cc" || _ref$5 === ".cpp" || _ref$5 === ".cxx") { - p.CXXFiles = $append(p.CXXFiles, name); - _i$3++; - continue; - } else if (_ref$5 === ".m") { - p.MFiles = $append(p.MFiles, name); - _i$3++; - continue; - } else if (_ref$5 === ".h" || _ref$5 === ".hh" || _ref$5 === ".hpp" || _ref$5 === ".hxx") { - p.HFiles = $append(p.HFiles, name); - _i$3++; - continue; - } else if (_ref$5 === ".s") { - p.SFiles = $append(p.SFiles, name); - _i$3++; - continue; - } else if (_ref$5 === ".S") { - Sfiles = $append(Sfiles, name); - _i$3++; - continue; - } else if (_ref$5 === ".swig") { - p.SwigFiles = $append(p.SwigFiles, name); - _i$3++; - continue; - } else if (_ref$5 === ".swigcxx") { - p.SwigCXXFiles = $append(p.SwigCXXFiles, name); - _i$3++; - continue; - } else if (_ref$5 === ".syso") { - p.SysoFiles = $append(p.SysoFiles, name); - _i$3++; - continue; - } - _tuple$5 = parser.ParseFile(fset, filename, data, 6); pf = _tuple$5[0]; err$1 = _tuple$5[1]; - if (!($interfaceIsEqual(err$1, $ifaceNil))) { - return [p, err$1]; - } - pkg = pf.Name.Name; - if (pkg === "documentation") { - p.IgnoredGoFiles = $append(p.IgnoredGoFiles, name); - _i$3++; - continue; - } - isTest = strings.HasSuffix(name, "_test.go"); - isXTest = false; - if (isTest && strings.HasSuffix(pkg, "_test")) { - isXTest = true; - pkg = pkg.substring(0, (pkg.length - 5 >> 0)); + nre$1 = new Regexp.Ptr(18, 0, ($sliceType(($ptrType(Regexp)))).nil, ($arrayType(($ptrType(Regexp)), 1)).zero(), ($sliceType($Int32)).nil, ($arrayType($Int32, 2)).zero(), 0, 0, 0, ""); + nre$1.Sub = $subslice(new ($sliceType(($ptrType(Regexp))))(nre$1.Sub0), 0, 0); + i$1 = 0; + while (i$1 < (re.Min - 1 >> 0)) { + nre$1.Sub = $append(nre$1.Sub, sub$2); + i$1 = i$1 + (1) >> 0; + } + nre$1.Sub = $append(nre$1.Sub, simplify1(15, re.Flags, sub$2, ($ptrType(Regexp)).nil)); + return nre$1; } - if (p.Name === "") { - p.Name = pkg; - firstFile = name; - } else if (!(pkg === p.Name)) { - return [p, fmt.Errorf("found packages %s (%s) and %s (%s) in %s", new ($sliceType($emptyInterface))([new $String(p.Name), new $String(firstFile), new $String(pkg), new $String(name), new $String(p.Dir)]))]; + if ((re.Min === 1) && (re.Max === 1)) { + return sub$2; } - if (!(pf.Doc === ($ptrType(ast.CommentGroup)).nil) && p.Doc === "") { - p.Doc = doc.Synopsis(pf.Doc.Text()); + prefix = ($ptrType(Regexp)).nil; + if (re.Min > 0) { + prefix = new Regexp.Ptr(18, 0, ($sliceType(($ptrType(Regexp)))).nil, ($arrayType(($ptrType(Regexp)), 1)).zero(), ($sliceType($Int32)).nil, ($arrayType($Int32, 2)).zero(), 0, 0, 0, ""); + prefix.Sub = $subslice(new ($sliceType(($ptrType(Regexp))))(prefix.Sub0), 0, 0); + i$2 = 0; + while (i$2 < re.Min) { + prefix.Sub = $append(prefix.Sub, sub$2); + i$2 = i$2 + (1) >> 0; + } } - isCgo = false; - _ref$6 = pf.Decls; - _i$4 = 0; - while (_i$4 < _ref$6.$length) { - decl = ((_i$4 < 0 || _i$4 >= _ref$6.$length) ? $throwRuntimeError("index out of range") : _ref$6.$array[_ref$6.$offset + _i$4]); - _tuple$6 = $assertType(decl, ($ptrType(ast.GenDecl)), true); d$1 = _tuple$6[0]; ok$2 = _tuple$6[1]; - if (!ok$2) { - _i$4++; - continue; + if (re.Max > re.Min) { + suffix = simplify1(16, re.Flags, sub$2, ($ptrType(Regexp)).nil); + i$3 = re.Min + 1 >> 0; + while (i$3 < re.Max) { + nre2 = new Regexp.Ptr(18, 0, ($sliceType(($ptrType(Regexp)))).nil, ($arrayType(($ptrType(Regexp)), 1)).zero(), ($sliceType($Int32)).nil, ($arrayType($Int32, 2)).zero(), 0, 0, 0, ""); + nre2.Sub = $append($subslice(new ($sliceType(($ptrType(Regexp))))(nre2.Sub0), 0, 0), sub$2, suffix); + suffix = simplify1(16, re.Flags, nre2, ($ptrType(Regexp)).nil); + i$3 = i$3 + (1) >> 0; } - _ref$7 = d$1.Specs; - _i$5 = 0; - while (_i$5 < _ref$7.$length) { - dspec = ((_i$5 < 0 || _i$5 >= _ref$7.$length) ? $throwRuntimeError("index out of range") : _ref$7.$array[_ref$7.$offset + _i$5]); - _tuple$7 = $assertType(dspec, ($ptrType(ast.ImportSpec)), true); spec = _tuple$7[0]; ok$3 = _tuple$7[1]; - if (!ok$3) { - _i$5++; - continue; - } - quoted = spec.Path.Value; - _tuple$8 = strconv.Unquote(quoted); path$2 = _tuple$8[0]; err$2 = _tuple$8[1]; - if (!($interfaceIsEqual(err$2, $ifaceNil))) { - log.Panicf("%s: parser returned invalid quoted string: <%s>", new ($sliceType($emptyInterface))([new $String(filename), new $String(quoted)])); - } - if (isXTest) { - _key$1 = path$2; (xTestImported || $throwRuntimeError("assignment to entry in nil map"))[_key$1] = { k: _key$1, v: $append((_entry = xTestImported[path$2], _entry !== undefined ? _entry.v : ($sliceType(token.Position)).nil), fset.Position(spec.Pos())) }; - } else if (isTest) { - _key$2 = path$2; (testImported || $throwRuntimeError("assignment to entry in nil map"))[_key$2] = { k: _key$2, v: $append((_entry$1 = testImported[path$2], _entry$1 !== undefined ? _entry$1.v : ($sliceType(token.Position)).nil), fset.Position(spec.Pos())) }; - } else { - _key$3 = path$2; (imported || $throwRuntimeError("assignment to entry in nil map"))[_key$3] = { k: _key$3, v: $append((_entry$2 = imported[path$2], _entry$2 !== undefined ? _entry$2.v : ($sliceType(token.Position)).nil), fset.Position(spec.Pos())) }; - } - if (path$2 === "C") { - if (isTest) { - return [p, fmt.Errorf("use of cgo in test %s not supported", new ($sliceType($emptyInterface))([new $String(filename)]))]; - } - cg = spec.Doc; - if (cg === ($ptrType(ast.CommentGroup)).nil && (d$1.Specs.$length === 1)) { - cg = d$1.Doc; - } - if (!(cg === ($ptrType(ast.CommentGroup)).nil)) { - err$3 = ctxt.saveCgo(filename, p, cg); - if (!($interfaceIsEqual(err$3, $ifaceNil))) { - return [p, err$3]; - } - } - isCgo = true; - } - _i$5++; + if (prefix === ($ptrType(Regexp)).nil) { + return suffix; } - _i$4++; + prefix.Sub = $append(prefix.Sub, suffix); } - if (isCgo) { - _key$4 = "cgo"; (allTags || $throwRuntimeError("assignment to entry in nil map"))[_key$4] = { k: _key$4, v: true }; - if (ctxt.CgoEnabled) { - p.CgoFiles = $append(p.CgoFiles, name); - } else { - p.IgnoredGoFiles = $append(p.IgnoredGoFiles, name); - } - } else if (isXTest) { - p.XTestGoFiles = $append(p.XTestGoFiles, name); - } else if (isTest) { - p.TestGoFiles = $append(p.TestGoFiles, name); - } else { - p.GoFiles = $append(p.GoFiles, name); + if (!(prefix === ($ptrType(Regexp)).nil)) { + return prefix; } - _i$3++; + return new Regexp.Ptr(1, 0, ($sliceType(($ptrType(Regexp)))).nil, ($arrayType(($ptrType(Regexp)), 1)).zero(), ($sliceType($Int32)).nil, ($arrayType($Int32, 2)).zero(), 0, 0, 0, ""); } - if ((((p.GoFiles.$length + p.CgoFiles.$length >> 0) + p.TestGoFiles.$length >> 0) + p.XTestGoFiles.$length >> 0) === 0) { - return [p, new NoGoError.Ptr(p.Dir)]; + return re; + }; + Regexp.prototype.Simplify = function() { return this.$val.Simplify(); }; + simplify1 = function(op, flags, sub, re) { + var x; + if (sub.Op === 2) { + return sub; } - _ref$8 = allTags; - _i$6 = 0; - _keys = $keys(_ref$8); - while (_i$6 < _keys.length) { - _entry$3 = _ref$8[_keys[_i$6]]; - if (_entry$3 === undefined) { - _i$6++; - continue; - } - tag = _entry$3.k; - p.AllTags = $append(p.AllTags, tag); - _i$6++; + if ((op === sub.Op) && (((flags & 32) >>> 0) === ((sub.Flags & 32) >>> 0))) { + return sub; } - sort.Strings(p.AllTags); - _tuple$9 = cleanImports(imported); p.Imports = _tuple$9[0]; p.ImportPos = _tuple$9[1]; - _tuple$10 = cleanImports(testImported); p.TestImports = _tuple$10[0]; p.TestImportPos = _tuple$10[1]; - _tuple$11 = cleanImports(xTestImported); p.XTestImports = _tuple$11[0]; p.XTestImportPos = _tuple$11[1]; - if (p.CgoFiles.$length > 0) { - p.SFiles = $appendSlice(p.SFiles, Sfiles); - sort.Strings(p.SFiles); + if (!(re === ($ptrType(Regexp)).nil) && (re.Op === op) && (((re.Flags & 32) >>> 0) === ((flags & 32) >>> 0)) && sub === (x = re.Sub, ((0 < 0 || 0 >= x.$length) ? $throwRuntimeError("index out of range") : x.$array[x.$offset + 0]))) { + return re; } - return [p, pkgerr]; - /* */ case -1: } return; } + re = new Regexp.Ptr(op, flags, ($sliceType(($ptrType(Regexp)))).nil, ($arrayType(($ptrType(Regexp)), 1)).zero(), ($sliceType($Int32)).nil, ($arrayType($Int32, 2)).zero(), 0, 0, 0, ""); + re.Sub = $append($subslice(new ($sliceType(($ptrType(Regexp))))(re.Sub0), 0, 0), sub); + return re; }; - Context.prototype.Import = function(path$1, srcDir, mode) { return this.$val.Import(path$1, srcDir, mode); }; - Context.Ptr.prototype.MatchFile = function(dir, name) { - var match = false, err = $ifaceNil, ctxt, _tuple; - ctxt = this; - _tuple = ctxt.matchFile(dir, name, false, false); match = _tuple[0]; err = _tuple[3]; - return [match, err]; + $pkg.$init = function() { + patchList.methods = [["append", "append", "regexp/syntax", $funcType([($ptrType(Prog)), patchList], [patchList], false), -1], ["next", "next", "regexp/syntax", $funcType([($ptrType(Prog))], [patchList], false), -1], ["patch", "patch", "regexp/syntax", $funcType([($ptrType(Prog)), $Uint32], [], false), -1]]; + ($ptrType(patchList)).methods = [["append", "append", "regexp/syntax", $funcType([($ptrType(Prog)), patchList], [patchList], false), -1], ["next", "next", "regexp/syntax", $funcType([($ptrType(Prog))], [patchList], false), -1], ["patch", "patch", "regexp/syntax", $funcType([($ptrType(Prog)), $Uint32], [], false), -1]]; + frag.init([["i", "i", "regexp/syntax", $Uint32, ""], ["out", "out", "regexp/syntax", patchList, ""]]); + ($ptrType(compiler)).methods = [["alt", "alt", "regexp/syntax", $funcType([frag, frag], [frag], false), -1], ["cap", "cap", "regexp/syntax", $funcType([$Uint32], [frag], false), -1], ["cat", "cat", "regexp/syntax", $funcType([frag, frag], [frag], false), -1], ["compile", "compile", "regexp/syntax", $funcType([($ptrType(Regexp))], [frag], false), -1], ["empty", "empty", "regexp/syntax", $funcType([EmptyOp], [frag], false), -1], ["fail", "fail", "regexp/syntax", $funcType([], [frag], false), -1], ["init", "init", "regexp/syntax", $funcType([], [], false), -1], ["inst", "inst", "regexp/syntax", $funcType([InstOp], [frag], false), -1], ["nop", "nop", "regexp/syntax", $funcType([], [frag], false), -1], ["plus", "plus", "regexp/syntax", $funcType([frag, $Bool], [frag], false), -1], ["quest", "quest", "regexp/syntax", $funcType([frag, $Bool], [frag], false), -1], ["rune", "rune", "regexp/syntax", $funcType([($sliceType($Int32)), Flags], [frag], false), -1], ["star", "star", "regexp/syntax", $funcType([frag, $Bool], [frag], false), -1]]; + compiler.init([["p", "p", "regexp/syntax", ($ptrType(Prog)), ""]]); + ($ptrType(Error)).methods = [["Error", "Error", "", $funcType([], [$String], false), -1]]; + Error.init([["Code", "Code", "", ErrorCode, ""], ["Expr", "Expr", "", $String, ""]]); + ErrorCode.methods = [["String", "String", "", $funcType([], [$String], false), -1]]; + ($ptrType(ErrorCode)).methods = [["String", "String", "", $funcType([], [$String], false), -1]]; + ($ptrType(parser)).methods = [["alternate", "alternate", "regexp/syntax", $funcType([], [($ptrType(Regexp))], false), -1], ["appendGroup", "appendGroup", "regexp/syntax", $funcType([($sliceType($Int32)), charGroup], [($sliceType($Int32))], false), -1], ["collapse", "collapse", "regexp/syntax", $funcType([($sliceType(($ptrType(Regexp)))), Op], [($ptrType(Regexp))], false), -1], ["concat", "concat", "regexp/syntax", $funcType([], [($ptrType(Regexp))], false), -1], ["factor", "factor", "regexp/syntax", $funcType([($sliceType(($ptrType(Regexp)))), Flags], [($sliceType(($ptrType(Regexp))))], false), -1], ["leadingRegexp", "leadingRegexp", "regexp/syntax", $funcType([($ptrType(Regexp))], [($ptrType(Regexp))], false), -1], ["leadingString", "leadingString", "regexp/syntax", $funcType([($ptrType(Regexp))], [($sliceType($Int32)), Flags], false), -1], ["literal", "literal", "regexp/syntax", $funcType([$Int32], [], false), -1], ["maybeConcat", "maybeConcat", "regexp/syntax", $funcType([$Int32, Flags], [$Bool], false), -1], ["newLiteral", "newLiteral", "regexp/syntax", $funcType([$Int32, Flags], [($ptrType(Regexp))], false), -1], ["newRegexp", "newRegexp", "regexp/syntax", $funcType([Op], [($ptrType(Regexp))], false), -1], ["op", "op", "regexp/syntax", $funcType([Op], [($ptrType(Regexp))], false), -1], ["parseClass", "parseClass", "regexp/syntax", $funcType([$String], [$String, $error], false), -1], ["parseClassChar", "parseClassChar", "regexp/syntax", $funcType([$String, $String], [$Int32, $String, $error], false), -1], ["parseEscape", "parseEscape", "regexp/syntax", $funcType([$String], [$Int32, $String, $error], false), -1], ["parseInt", "parseInt", "regexp/syntax", $funcType([$String], [$Int, $String, $Bool], false), -1], ["parseNamedClass", "parseNamedClass", "regexp/syntax", $funcType([$String, ($sliceType($Int32))], [($sliceType($Int32)), $String, $error], false), -1], ["parsePerlClassEscape", "parsePerlClassEscape", "regexp/syntax", $funcType([$String, ($sliceType($Int32))], [($sliceType($Int32)), $String], false), -1], ["parsePerlFlags", "parsePerlFlags", "regexp/syntax", $funcType([$String], [$String, $error], false), -1], ["parseRepeat", "parseRepeat", "regexp/syntax", $funcType([$String], [$Int, $Int, $String, $Bool], false), -1], ["parseRightParen", "parseRightParen", "regexp/syntax", $funcType([], [$error], false), -1], ["parseUnicodeClass", "parseUnicodeClass", "regexp/syntax", $funcType([$String, ($sliceType($Int32))], [($sliceType($Int32)), $String, $error], false), -1], ["parseVerticalBar", "parseVerticalBar", "regexp/syntax", $funcType([], [$error], false), -1], ["push", "push", "regexp/syntax", $funcType([($ptrType(Regexp))], [($ptrType(Regexp))], false), -1], ["removeLeadingRegexp", "removeLeadingRegexp", "regexp/syntax", $funcType([($ptrType(Regexp)), $Bool], [($ptrType(Regexp))], false), -1], ["removeLeadingString", "removeLeadingString", "regexp/syntax", $funcType([($ptrType(Regexp)), $Int], [($ptrType(Regexp))], false), -1], ["repeat", "repeat", "regexp/syntax", $funcType([Op, $Int, $Int, $String, $String, $String], [$String, $error], false), -1], ["reuse", "reuse", "regexp/syntax", $funcType([($ptrType(Regexp))], [], false), -1], ["swapVerticalBar", "swapVerticalBar", "regexp/syntax", $funcType([], [$Bool], false), -1]]; + parser.init([["flags", "flags", "regexp/syntax", Flags, ""], ["stack", "stack", "regexp/syntax", ($sliceType(($ptrType(Regexp)))), ""], ["free", "free", "regexp/syntax", ($ptrType(Regexp)), ""], ["numCap", "numCap", "regexp/syntax", $Int, ""], ["wholeRegexp", "wholeRegexp", "regexp/syntax", $String, ""], ["tmpClass", "tmpClass", "regexp/syntax", ($sliceType($Int32)), ""]]); + charGroup.init([["sign", "sign", "regexp/syntax", $Int, ""], ["class$1", "class", "regexp/syntax", ($sliceType($Int32)), ""]]); + ranges.methods = [["Len", "Len", "", $funcType([], [$Int], false), -1], ["Less", "Less", "", $funcType([$Int, $Int], [$Bool], false), -1], ["Swap", "Swap", "", $funcType([$Int, $Int], [], false), -1]]; + ($ptrType(ranges)).methods = [["Len", "Len", "", $funcType([], [$Int], false), -1], ["Less", "Less", "", $funcType([$Int, $Int], [$Bool], false), -1], ["Swap", "Swap", "", $funcType([$Int, $Int], [], false), -1]]; + ranges.init([["p", "p", "regexp/syntax", ($ptrType(($sliceType($Int32)))), ""]]); + ($ptrType(Prog)).methods = [["Prefix", "Prefix", "", $funcType([], [$String, $Bool], false), -1], ["StartCond", "StartCond", "", $funcType([], [EmptyOp], false), -1], ["String", "String", "", $funcType([], [$String], false), -1], ["skipNop", "skipNop", "regexp/syntax", $funcType([$Uint32], [($ptrType(Inst)), $Uint32], false), -1]]; + Prog.init([["Inst", "Inst", "", ($sliceType(Inst)), ""], ["Start", "Start", "", $Int, ""], ["NumCap", "NumCap", "", $Int, ""]]); + InstOp.methods = [["String", "String", "", $funcType([], [$String], false), -1]]; + ($ptrType(InstOp)).methods = [["String", "String", "", $funcType([], [$String], false), -1]]; + ($ptrType(Inst)).methods = [["MatchEmptyWidth", "MatchEmptyWidth", "", $funcType([$Int32, $Int32], [$Bool], false), -1], ["MatchRune", "MatchRune", "", $funcType([$Int32], [$Bool], false), -1], ["MatchRunePos", "MatchRunePos", "", $funcType([$Int32], [$Int], false), -1], ["String", "String", "", $funcType([], [$String], false), -1], ["op", "op", "regexp/syntax", $funcType([], [InstOp], false), -1]]; + Inst.init([["Op", "Op", "", InstOp, ""], ["Out", "Out", "", $Uint32, ""], ["Arg", "Arg", "", $Uint32, ""], ["Rune", "Rune", "", ($sliceType($Int32)), ""]]); + ($ptrType(Regexp)).methods = [["CapNames", "CapNames", "", $funcType([], [($sliceType($String))], false), -1], ["Equal", "Equal", "", $funcType([($ptrType(Regexp))], [$Bool], false), -1], ["MaxCap", "MaxCap", "", $funcType([], [$Int], false), -1], ["Simplify", "Simplify", "", $funcType([], [($ptrType(Regexp))], false), -1], ["String", "String", "", $funcType([], [$String], false), -1], ["capNames", "capNames", "regexp/syntax", $funcType([($sliceType($String))], [], false), -1]]; + Regexp.init([["Op", "Op", "", Op, ""], ["Flags", "Flags", "", Flags, ""], ["Sub", "Sub", "", ($sliceType(($ptrType(Regexp)))), ""], ["Sub0", "Sub0", "", ($arrayType(($ptrType(Regexp)), 1)), ""], ["Rune", "Rune", "", ($sliceType($Int32)), ""], ["Rune0", "Rune0", "", ($arrayType($Int32, 2)), ""], ["Min", "Min", "", $Int, ""], ["Max", "Max", "", $Int, ""], ["Cap", "Cap", "", $Int, ""], ["Name", "Name", "", $String, ""]]); + anyRuneNotNL = new ($sliceType($Int32))([0, 9, 11, 1114111]); + anyRune = new ($sliceType($Int32))([0, 1114111]); + anyTable = new unicode.RangeTable.Ptr(new ($sliceType(unicode.Range16))([new unicode.Range16.Ptr(0, 65535, 1)]), new ($sliceType(unicode.Range32))([new unicode.Range32.Ptr(65536, 1114111, 1)]), 0); + code1 = new ($sliceType($Int32))([48, 57]); + code2 = new ($sliceType($Int32))([9, 10, 12, 13, 32, 32]); + code3 = new ($sliceType($Int32))([48, 57, 65, 90, 95, 95, 97, 122]); + perlGroup = (_map = new $Map(), _key = "\\d", _map[_key] = { k: _key, v: new charGroup.Ptr(1, code1) }, _key = "\\D", _map[_key] = { k: _key, v: new charGroup.Ptr(-1, code1) }, _key = "\\s", _map[_key] = { k: _key, v: new charGroup.Ptr(1, code2) }, _key = "\\S", _map[_key] = { k: _key, v: new charGroup.Ptr(-1, code2) }, _key = "\\w", _map[_key] = { k: _key, v: new charGroup.Ptr(1, code3) }, _key = "\\W", _map[_key] = { k: _key, v: new charGroup.Ptr(-1, code3) }, _map); + code4 = new ($sliceType($Int32))([48, 57, 65, 90, 97, 122]); + code5 = new ($sliceType($Int32))([65, 90, 97, 122]); + code6 = new ($sliceType($Int32))([0, 127]); + code7 = new ($sliceType($Int32))([9, 9, 32, 32]); + code8 = new ($sliceType($Int32))([0, 31, 127, 127]); + code9 = new ($sliceType($Int32))([48, 57]); + code10 = new ($sliceType($Int32))([33, 126]); + code11 = new ($sliceType($Int32))([97, 122]); + code12 = new ($sliceType($Int32))([32, 126]); + code13 = new ($sliceType($Int32))([33, 47, 58, 64, 91, 96, 123, 126]); + code14 = new ($sliceType($Int32))([9, 13, 32, 32]); + code15 = new ($sliceType($Int32))([65, 90]); + code16 = new ($sliceType($Int32))([48, 57, 65, 90, 95, 95, 97, 122]); + code17 = new ($sliceType($Int32))([48, 57, 65, 70, 97, 102]); + posixGroup = (_map$1 = new $Map(), _key$1 = "[:alnum:]", _map$1[_key$1] = { k: _key$1, v: new charGroup.Ptr(1, code4) }, _key$1 = "[:^alnum:]", _map$1[_key$1] = { k: _key$1, v: new charGroup.Ptr(-1, code4) }, _key$1 = "[:alpha:]", _map$1[_key$1] = { k: _key$1, v: new charGroup.Ptr(1, code5) }, _key$1 = "[:^alpha:]", _map$1[_key$1] = { k: _key$1, v: new charGroup.Ptr(-1, code5) }, _key$1 = "[:ascii:]", _map$1[_key$1] = { k: _key$1, v: new charGroup.Ptr(1, code6) }, _key$1 = "[:^ascii:]", _map$1[_key$1] = { k: _key$1, v: new charGroup.Ptr(-1, code6) }, _key$1 = "[:blank:]", _map$1[_key$1] = { k: _key$1, v: new charGroup.Ptr(1, code7) }, _key$1 = "[:^blank:]", _map$1[_key$1] = { k: _key$1, v: new charGroup.Ptr(-1, code7) }, _key$1 = "[:cntrl:]", _map$1[_key$1] = { k: _key$1, v: new charGroup.Ptr(1, code8) }, _key$1 = "[:^cntrl:]", _map$1[_key$1] = { k: _key$1, v: new charGroup.Ptr(-1, code8) }, _key$1 = "[:digit:]", _map$1[_key$1] = { k: _key$1, v: new charGroup.Ptr(1, code9) }, _key$1 = "[:^digit:]", _map$1[_key$1] = { k: _key$1, v: new charGroup.Ptr(-1, code9) }, _key$1 = "[:graph:]", _map$1[_key$1] = { k: _key$1, v: new charGroup.Ptr(1, code10) }, _key$1 = "[:^graph:]", _map$1[_key$1] = { k: _key$1, v: new charGroup.Ptr(-1, code10) }, _key$1 = "[:lower:]", _map$1[_key$1] = { k: _key$1, v: new charGroup.Ptr(1, code11) }, _key$1 = "[:^lower:]", _map$1[_key$1] = { k: _key$1, v: new charGroup.Ptr(-1, code11) }, _key$1 = "[:print:]", _map$1[_key$1] = { k: _key$1, v: new charGroup.Ptr(1, code12) }, _key$1 = "[:^print:]", _map$1[_key$1] = { k: _key$1, v: new charGroup.Ptr(-1, code12) }, _key$1 = "[:punct:]", _map$1[_key$1] = { k: _key$1, v: new charGroup.Ptr(1, code13) }, _key$1 = "[:^punct:]", _map$1[_key$1] = { k: _key$1, v: new charGroup.Ptr(-1, code13) }, _key$1 = "[:space:]", _map$1[_key$1] = { k: _key$1, v: new charGroup.Ptr(1, code14) }, _key$1 = "[:^space:]", _map$1[_key$1] = { k: _key$1, v: new charGroup.Ptr(-1, code14) }, _key$1 = "[:upper:]", _map$1[_key$1] = { k: _key$1, v: new charGroup.Ptr(1, code15) }, _key$1 = "[:^upper:]", _map$1[_key$1] = { k: _key$1, v: new charGroup.Ptr(-1, code15) }, _key$1 = "[:word:]", _map$1[_key$1] = { k: _key$1, v: new charGroup.Ptr(1, code16) }, _key$1 = "[:^word:]", _map$1[_key$1] = { k: _key$1, v: new charGroup.Ptr(-1, code16) }, _key$1 = "[:xdigit:]", _map$1[_key$1] = { k: _key$1, v: new charGroup.Ptr(1, code17) }, _key$1 = "[:^xdigit:]", _map$1[_key$1] = { k: _key$1, v: new charGroup.Ptr(-1, code17) }, _map$1); + instOpNames = new ($sliceType($String))(["InstAlt", "InstAltMatch", "InstCapture", "InstEmptyWidth", "InstMatch", "InstFail", "InstNop", "InstRune", "InstRune1", "InstRuneAny", "InstRuneAnyNotNL"]); }; - Context.prototype.MatchFile = function(dir, name) { return this.$val.MatchFile(dir, name); }; - Context.Ptr.prototype.matchFile = function(dir, name, returnImports, allTags) { - var match = false, data = ($sliceType($Uint8)).nil, filename = "", err = $ifaceNil, ctxt, i, ext, _ref, _tuple, f, _tuple$1, _tuple$2; - ctxt = this; - if (strings.HasPrefix(name, "_") || strings.HasPrefix(name, ".")) { - return [match, data, filename, err]; - } - i = strings.LastIndex(name, "."); - if (i < 0) { - i = name.length; - } - ext = name.substring(i); - if (!ctxt.goodOSArchFile(name, allTags) && !ctxt.UseAllFiles) { - return [match, data, filename, err]; - } - _ref = ext; - if (_ref === ".go" || _ref === ".c" || _ref === ".cc" || _ref === ".cxx" || _ref === ".cpp" || _ref === ".m" || _ref === ".s" || _ref === ".h" || _ref === ".hh" || _ref === ".hpp" || _ref === ".hxx" || _ref === ".S" || _ref === ".swig" || _ref === ".swigcxx") { - } else if (_ref === ".syso") { - match = true; - return [match, data, filename, err]; - } else { - return [match, data, filename, err]; - } - filename = ctxt.joinPath(new ($sliceType($String))([dir, name])); - _tuple = ctxt.openFile(filename); f = _tuple[0]; err = _tuple[1]; - if (!($interfaceIsEqual(err, $ifaceNil))) { - return [match, data, filename, err]; - } - if (strings.HasSuffix(filename, ".go")) { - _tuple$1 = readImports(f, false); data = _tuple$1[0]; err = _tuple$1[1]; - } else { - _tuple$2 = readComments(f); data = _tuple$2[0]; err = _tuple$2[1]; - } - f.Close(); - if (!($interfaceIsEqual(err, $ifaceNil))) { - err = fmt.Errorf("read %s: %v", new ($sliceType($emptyInterface))([new $String(filename), err])); - return [match, data, filename, err]; - } - if (!ctxt.shouldBuild(data, allTags) && !ctxt.UseAllFiles) { - return [match, data, filename, err]; + return $pkg; +})(); +$packages["regexp"] = (function() { + var $pkg = {}, testing = $packages["testing"], io = $packages["io"], syntax = $packages["regexp/syntax"], bytes = $packages["bytes"], sort = $packages["sort"], unicode = $packages["unicode"], strconv = $packages["strconv"], strings = $packages["strings"], sync = $packages["sync"], utf8 = $packages["unicode/utf8"], queue, entry, thread, machine, onePassProg, onePassInst, queueOnePass, runeSlice, Regexp, input, inputString, inputBytes, inputReader, empty, noRune, noNext, anyRuneNotNL, anyRune, notOnePass, progMachine, onePassPrefix, onePassNext, iop, newQueue, mergeRuneSets, cleanupOnePass, onePassCopy, makeOnePass, compileOnePass, Compile, compile, MustCompile, quote, extract; + queue = $pkg.queue = $newType(0, "Struct", "regexp.queue", "queue", "regexp", function(sparse_, dense_) { + this.$val = this; + this.sparse = sparse_ !== undefined ? sparse_ : ($sliceType($Uint32)).nil; + this.dense = dense_ !== undefined ? dense_ : ($sliceType(entry)).nil; + }); + entry = $pkg.entry = $newType(0, "Struct", "regexp.entry", "entry", "regexp", function(pc_, t_) { + this.$val = this; + this.pc = pc_ !== undefined ? pc_ : 0; + this.t = t_ !== undefined ? t_ : ($ptrType(thread)).nil; + }); + thread = $pkg.thread = $newType(0, "Struct", "regexp.thread", "thread", "regexp", function(inst_, cap_) { + this.$val = this; + this.inst = inst_ !== undefined ? inst_ : ($ptrType(syntax.Inst)).nil; + this.cap = cap_ !== undefined ? cap_ : ($sliceType($Int)).nil; + }); + machine = $pkg.machine = $newType(0, "Struct", "regexp.machine", "machine", "regexp", function(re_, p_, op_, q0_, q1_, pool_, matched_, matchcap_, inputBytes_, inputString_, inputReader_) { + this.$val = this; + this.re = re_ !== undefined ? re_ : ($ptrType(Regexp)).nil; + this.p = p_ !== undefined ? p_ : ($ptrType(syntax.Prog)).nil; + this.op = op_ !== undefined ? op_ : ($ptrType(onePassProg)).nil; + this.q0 = q0_ !== undefined ? q0_ : new queue.Ptr(); + this.q1 = q1_ !== undefined ? q1_ : new queue.Ptr(); + this.pool = pool_ !== undefined ? pool_ : ($sliceType(($ptrType(thread)))).nil; + this.matched = matched_ !== undefined ? matched_ : false; + this.matchcap = matchcap_ !== undefined ? matchcap_ : ($sliceType($Int)).nil; + this.inputBytes = inputBytes_ !== undefined ? inputBytes_ : new inputBytes.Ptr(); + this.inputString = inputString_ !== undefined ? inputString_ : new inputString.Ptr(); + this.inputReader = inputReader_ !== undefined ? inputReader_ : new inputReader.Ptr(); + }); + onePassProg = $pkg.onePassProg = $newType(0, "Struct", "regexp.onePassProg", "onePassProg", "regexp", function(Inst_, Start_, NumCap_) { + this.$val = this; + this.Inst = Inst_ !== undefined ? Inst_ : ($sliceType(onePassInst)).nil; + this.Start = Start_ !== undefined ? Start_ : 0; + this.NumCap = NumCap_ !== undefined ? NumCap_ : 0; + }); + onePassInst = $pkg.onePassInst = $newType(0, "Struct", "regexp.onePassInst", "onePassInst", "regexp", function(Inst_, Next_) { + this.$val = this; + this.Inst = Inst_ !== undefined ? Inst_ : new syntax.Inst.Ptr(); + this.Next = Next_ !== undefined ? Next_ : ($sliceType($Uint32)).nil; + }); + queueOnePass = $pkg.queueOnePass = $newType(0, "Struct", "regexp.queueOnePass", "queueOnePass", "regexp", function(sparse_, dense_, size_, nextIndex_) { + this.$val = this; + this.sparse = sparse_ !== undefined ? sparse_ : ($sliceType($Uint32)).nil; + this.dense = dense_ !== undefined ? dense_ : ($sliceType($Uint32)).nil; + this.size = size_ !== undefined ? size_ : 0; + this.nextIndex = nextIndex_ !== undefined ? nextIndex_ : 0; + }); + runeSlice = $pkg.runeSlice = $newType(12, "Slice", "regexp.runeSlice", "runeSlice", "regexp", null); + Regexp = $pkg.Regexp = $newType(0, "Struct", "regexp.Regexp", "Regexp", "regexp", function(expr_, prog_, onepass_, prefix_, prefixBytes_, prefixComplete_, prefixRune_, prefixEnd_, cond_, numSubexp_, subexpNames_, longest_, mu_, machine_) { + this.$val = this; + this.expr = expr_ !== undefined ? expr_ : ""; + this.prog = prog_ !== undefined ? prog_ : ($ptrType(syntax.Prog)).nil; + this.onepass = onepass_ !== undefined ? onepass_ : ($ptrType(onePassProg)).nil; + this.prefix = prefix_ !== undefined ? prefix_ : ""; + this.prefixBytes = prefixBytes_ !== undefined ? prefixBytes_ : ($sliceType($Uint8)).nil; + this.prefixComplete = prefixComplete_ !== undefined ? prefixComplete_ : false; + this.prefixRune = prefixRune_ !== undefined ? prefixRune_ : 0; + this.prefixEnd = prefixEnd_ !== undefined ? prefixEnd_ : 0; + this.cond = cond_ !== undefined ? cond_ : 0; + this.numSubexp = numSubexp_ !== undefined ? numSubexp_ : 0; + this.subexpNames = subexpNames_ !== undefined ? subexpNames_ : ($sliceType($String)).nil; + this.longest = longest_ !== undefined ? longest_ : false; + this.mu = mu_ !== undefined ? mu_ : new sync.Mutex.Ptr(); + this.machine = machine_ !== undefined ? machine_ : ($sliceType(($ptrType(machine)))).nil; + }); + input = $pkg.input = $newType(8, "Interface", "regexp.input", "input", "regexp", null); + inputString = $pkg.inputString = $newType(0, "Struct", "regexp.inputString", "inputString", "regexp", function(str_) { + this.$val = this; + this.str = str_ !== undefined ? str_ : ""; + }); + inputBytes = $pkg.inputBytes = $newType(0, "Struct", "regexp.inputBytes", "inputBytes", "regexp", function(str_) { + this.$val = this; + this.str = str_ !== undefined ? str_ : ($sliceType($Uint8)).nil; + }); + inputReader = $pkg.inputReader = $newType(0, "Struct", "regexp.inputReader", "inputReader", "regexp", function(r_, atEOT_, pos_) { + this.$val = this; + this.r = r_ !== undefined ? r_ : $ifaceNil; + this.atEOT = atEOT_ !== undefined ? atEOT_ : false; + this.pos = pos_ !== undefined ? pos_ : 0; + }); + machine.Ptr.prototype.newInputBytes = function(b) { + var m; + m = this; + m.inputBytes.str = b; + return m.inputBytes; + }; + machine.prototype.newInputBytes = function(b) { return this.$val.newInputBytes(b); }; + machine.Ptr.prototype.newInputString = function(s) { + var m; + m = this; + m.inputString.str = s; + return m.inputString; + }; + machine.prototype.newInputString = function(s) { return this.$val.newInputString(s); }; + machine.Ptr.prototype.newInputReader = function(r) { + var m; + m = this; + m.inputReader.r = r; + m.inputReader.atEOT = false; + m.inputReader.pos = 0; + return m.inputReader; + }; + machine.prototype.newInputReader = function(r) { return this.$val.newInputReader(r); }; + progMachine = function(p, op) { + var m, n, ncap; + m = new machine.Ptr(($ptrType(Regexp)).nil, p, op, new queue.Ptr(), new queue.Ptr(), ($sliceType(($ptrType(thread)))).nil, false, ($sliceType($Int)).nil, new inputBytes.Ptr(), new inputString.Ptr(), new inputReader.Ptr()); + n = m.p.Inst.$length; + $copy(m.q0, new queue.Ptr(($sliceType($Uint32)).make(n), ($sliceType(entry)).make(0, n)), queue); + $copy(m.q1, new queue.Ptr(($sliceType($Uint32)).make(n), ($sliceType(entry)).make(0, n)), queue); + ncap = p.NumCap; + if (ncap < 2) { + ncap = 2; } - match = true; - return [match, data, filename, err]; + m.matchcap = ($sliceType($Int)).make(ncap); + return m; }; - Context.prototype.matchFile = function(dir, name, returnImports, allTags) { return this.$val.matchFile(dir, name, returnImports, allTags); }; - cleanImports = function(m) { - var all, _ref, _i, _keys, _entry, path$1; - all = ($sliceType($String)).make(0, $keys(m).length); - _ref = m; + machine.Ptr.prototype.init = function(ncap) { + var m, _ref, _i, t; + m = this; + _ref = m.pool; _i = 0; - _keys = $keys(_ref); - while (_i < _keys.length) { - _entry = _ref[_keys[_i]]; - if (_entry === undefined) { - _i++; - continue; - } - path$1 = _entry.k; - all = $append(all, path$1); + while (_i < _ref.$length) { + t = ((_i < 0 || _i >= _ref.$length) ? $throwRuntimeError("index out of range") : _ref.$array[_ref.$offset + _i]); + t.cap = $subslice(t.cap, 0, ncap); _i++; } - sort.Strings(all); - return [all, m]; - }; - Import = $pkg.Import = function(path$1, srcDir, mode) { - return $pkg.Default.Import(path$1, srcDir, mode); + m.matchcap = $subslice(m.matchcap, 0, ncap); }; - Context.Ptr.prototype.shouldBuild = function(content, allTags) { - var ctxt, end, p, line, i, _tmp, _tmp$1, allok, line$1, i$1, _tmp$2, _tmp$3, f, ok, _ref, _i, tok; - ctxt = this; - end = 0; - p = content; - while (p.$length > 0) { - line = p; - i = bytes.IndexByte(line, 10); - if (i >= 0) { - _tmp = $subslice(line, 0, i); _tmp$1 = $subslice(p, (i + 1 >> 0)); line = _tmp; p = _tmp$1; - } else { - p = $subslice(p, p.$length); - } - line = bytes.TrimSpace(line); - if (line.$length === 0) { - end = content.$length - p.$length >> 0; - continue; - } - if (!bytes.HasPrefix(line, slashslash)) { - break; - } - } - content = $subslice(content, 0, end); - p = content; - allok = true; - while (p.$length > 0) { - line$1 = p; - i$1 = bytes.IndexByte(line$1, 10); - if (i$1 >= 0) { - _tmp$2 = $subslice(line$1, 0, i$1); _tmp$3 = $subslice(p, (i$1 + 1 >> 0)); line$1 = _tmp$2; p = _tmp$3; - } else { - p = $subslice(p, p.$length); - } - line$1 = bytes.TrimSpace(line$1); - if (bytes.HasPrefix(line$1, slashslash)) { - line$1 = bytes.TrimSpace($subslice(line$1, slashslash.$length)); - if (line$1.$length > 0 && (((0 < 0 || 0 >= line$1.$length) ? $throwRuntimeError("index out of range") : line$1.$array[line$1.$offset + 0]) === 43)) { - f = strings.Fields($bytesToString(line$1)); - if (((0 < 0 || 0 >= f.$length) ? $throwRuntimeError("index out of range") : f.$array[f.$offset + 0]) === "+build") { - ok = false; - _ref = $subslice(f, 1); - _i = 0; - while (_i < _ref.$length) { - tok = ((_i < 0 || _i >= _ref.$length) ? $throwRuntimeError("index out of range") : _ref.$array[_ref.$offset + _i]); - if (ctxt.match(tok, allTags)) { - ok = true; - } - _i++; - } - if (!ok) { - allok = false; - } - } - } - } + machine.prototype.init = function(ncap) { return this.$val.init(ncap); }; + machine.Ptr.prototype.alloc = function(i) { + var m, t, n, x, x$1; + m = this; + t = ($ptrType(thread)).nil; + n = m.pool.$length; + if (n > 0) { + t = (x = m.pool, x$1 = n - 1 >> 0, ((x$1 < 0 || x$1 >= x.$length) ? $throwRuntimeError("index out of range") : x.$array[x.$offset + x$1])); + m.pool = $subslice(m.pool, 0, (n - 1 >> 0)); + } else { + t = new thread.Ptr(); + t.cap = ($sliceType($Int)).make(m.matchcap.$length, m.matchcap.$capacity); } - return allok; + t.inst = i; + return t; }; - Context.prototype.shouldBuild = function(content, allTags) { return this.$val.shouldBuild(content, allTags); }; - Context.Ptr.prototype.saveCgo = function(filename, di, cg) { - var ctxt, text, _ref, _i, line, orig, i, _tmp, _tmp$1, line$1, argstr, f, _tmp$2, _tmp$3, x, cond, verb, ok, _ref$1, _i$1, c, _tuple, args, err, _ref$2, _i$2, arg, _ref$3; - ctxt = this; - text = cg.Text(); - _ref = strings.Split(text, "\n"); + machine.prototype.alloc = function(i) { return this.$val.alloc(i); }; + machine.Ptr.prototype.match = function(i, pos) { + var m, startCond, _ref, _i, i$1, x, _tmp, _tmp$1, runq, nextq, _tmp$2, _tmp$3, r, r1, _tmp$4, _tmp$5, width, width1, _tuple, _tuple$1, flag, advance, _tuple$2, _tuple$3, x$1, _tmp$6, _tmp$7, _tuple$4, _tmp$8, _tmp$9; + m = this; + startCond = m.re.cond; + if (startCond === 255) { + return false; + } + m.matched = false; + _ref = m.matchcap; _i = 0; while (_i < _ref.$length) { - line = ((_i < 0 || _i >= _ref.$length) ? $throwRuntimeError("index out of range") : _ref.$array[_ref.$offset + _i]); - orig = line; - line = strings.TrimSpace(line); - if (line.length < 5 || !(line.substring(0, 4) === "#cgo") || (!((line.charCodeAt(4) === 32)) && !((line.charCodeAt(4) === 9)))) { - _i++; - continue; - } - line = strings.TrimSpace(line.substring(4)); - i = strings.Index(line, ":"); - if (i < 0) { - return fmt.Errorf("%s: invalid #cgo line: %s", new ($sliceType($emptyInterface))([new $String(filename), new $String(orig)])); - } - _tmp = line.substring(0, i); _tmp$1 = line.substring((i + 1 >> 0)); line$1 = _tmp; argstr = _tmp$1; - f = strings.Fields(line$1); - if (f.$length < 1) { - return fmt.Errorf("%s: invalid #cgo line: %s", new ($sliceType($emptyInterface))([new $String(filename), new $String(orig)])); - } - _tmp$2 = $subslice(f, 0, (f.$length - 1 >> 0)); _tmp$3 = (x = f.$length - 1 >> 0, ((x < 0 || x >= f.$length) ? $throwRuntimeError("index out of range") : f.$array[f.$offset + x])); cond = _tmp$2; verb = _tmp$3; - if (cond.$length > 0) { - ok = false; - _ref$1 = cond; - _i$1 = 0; - while (_i$1 < _ref$1.$length) { - c = ((_i$1 < 0 || _i$1 >= _ref$1.$length) ? $throwRuntimeError("index out of range") : _ref$1.$array[_ref$1.$offset + _i$1]); - if (ctxt.match(c, false)) { - ok = true; + i$1 = _i; + (x = m.matchcap, (i$1 < 0 || i$1 >= x.$length) ? $throwRuntimeError("index out of range") : x.$array[x.$offset + i$1] = -1); + _i++; + } + _tmp = m.q0; _tmp$1 = m.q1; runq = _tmp; nextq = _tmp$1; + _tmp$2 = -1; _tmp$3 = -1; r = _tmp$2; r1 = _tmp$3; + _tmp$4 = 0; _tmp$5 = 0; width = _tmp$4; width1 = _tmp$5; + _tuple = i.step(pos); r = _tuple[0]; width = _tuple[1]; + if (!((r === -1))) { + _tuple$1 = i.step(pos + width >> 0); r1 = _tuple$1[0]; width1 = _tuple$1[1]; + } + flag = 0; + if (pos === 0) { + flag = syntax.EmptyOpContext(-1, r); + } else { + flag = i.context(pos); + } + while (true) { + if (runq.dense.$length === 0) { + if (!((((startCond & 4) >>> 0) === 0)) && !((pos === 0))) { + break; + } + if (m.matched) { + break; + } + if (m.re.prefix.length > 0 && !((r1 === m.re.prefixRune)) && i.canCheckPrefix()) { + advance = i.index(m.re, pos); + if (advance < 0) { break; } - _i$1++; + pos = pos + (advance) >> 0; + _tuple$2 = i.step(pos); r = _tuple$2[0]; width = _tuple$2[1]; + _tuple$3 = i.step(pos + width >> 0); r1 = _tuple$3[0]; width1 = _tuple$3[1]; } - if (!ok) { - _i++; - continue; + } + if (!m.matched) { + if (m.matchcap.$length > 0) { + (x$1 = m.matchcap, (0 < 0 || 0 >= x$1.$length) ? $throwRuntimeError("index out of range") : x$1.$array[x$1.$offset + 0] = pos); } + m.add(runq, (m.p.Start >>> 0), pos, m.matchcap, flag, ($ptrType(thread)).nil); } - _tuple = splitQuoted(argstr); args = _tuple[0]; err = _tuple[1]; - if (!($interfaceIsEqual(err, $ifaceNil))) { - return fmt.Errorf("%s: invalid #cgo line: %s", new ($sliceType($emptyInterface))([new $String(filename), new $String(orig)])); + flag = syntax.EmptyOpContext(r, r1); + m.step(runq, nextq, pos, pos + width >> 0, r, flag); + if (width === 0) { + break; } - _ref$2 = args; - _i$2 = 0; - while (_i$2 < _ref$2.$length) { - arg = ((_i$2 < 0 || _i$2 >= _ref$2.$length) ? $throwRuntimeError("index out of range") : _ref$2.$array[_ref$2.$offset + _i$2]); - if (!safeCgoName(arg)) { - return fmt.Errorf("%s: malformed #cgo argument: %s", new ($sliceType($emptyInterface))([new $String(filename), new $String(arg)])); - } - _i$2++; + if ((m.matchcap.$length === 0) && m.matched) { + break; } - _ref$3 = verb; - if (_ref$3 === "CFLAGS") { - di.CgoCFLAGS = $appendSlice(di.CgoCFLAGS, args); - } else if (_ref$3 === "CPPFLAGS") { - di.CgoCPPFLAGS = $appendSlice(di.CgoCPPFLAGS, args); - } else if (_ref$3 === "CXXFLAGS") { - di.CgoCXXFLAGS = $appendSlice(di.CgoCXXFLAGS, args); - } else if (_ref$3 === "LDFLAGS") { - di.CgoLDFLAGS = $appendSlice(di.CgoLDFLAGS, args); - } else if (_ref$3 === "pkg-config") { - di.CgoPkgConfig = $appendSlice(di.CgoPkgConfig, args); - } else { - return fmt.Errorf("%s: invalid #cgo verb: %s", new ($sliceType($emptyInterface))([new $String(filename), new $String(orig)])); + pos = pos + (width) >> 0; + _tmp$6 = r1; _tmp$7 = width1; r = _tmp$6; width = _tmp$7; + if (!((r === -1))) { + _tuple$4 = i.step(pos + width >> 0); r1 = _tuple$4[0]; width1 = _tuple$4[1]; } - _i++; + _tmp$8 = nextq; _tmp$9 = runq; runq = _tmp$8; nextq = _tmp$9; } - return $ifaceNil; + m.clear(nextq); + return m.matched; }; - Context.prototype.saveCgo = function(filename, di, cg) { return this.$val.saveCgo(filename, di, cg); }; - safeCgoName = function(s) { - var i, c; - if (s === "") { - return false; - } - i = 0; - while (i < s.length) { - c = s.charCodeAt(i); - if (c < 128 && bytes.IndexByte(safeBytes, c) < 0) { - return false; + machine.prototype.match = function(i, pos) { return this.$val.match(i, pos); }; + machine.Ptr.prototype.clear = function(q) { + var m, _ref, _i, d; + m = this; + _ref = q.dense; + _i = 0; + while (_i < _ref.$length) { + d = new entry.Ptr(); $copy(d, ((_i < 0 || _i >= _ref.$length) ? $throwRuntimeError("index out of range") : _ref.$array[_ref.$offset + _i]), entry); + if (!(d.t === ($ptrType(thread)).nil)) { + m.pool = $append(m.pool, d.t); } - i = i + (1) >> 0; + _i++; } - return true; + q.dense = $subslice(q.dense, 0, 0); }; - splitQuoted = function(s) { - var r = ($sliceType($String)).nil, err = $ifaceNil, args, arg, escaped, quoted, quote, i, _ref, _i, _rune, rune, _tmp, _tmp$1; - args = ($sliceType($String)).nil; - arg = ($sliceType($Int32)).make(s.length); - escaped = false; - quoted = false; - quote = 0; - i = 0; - _ref = s; - _i = 0; - while (_i < _ref.length) { - _rune = $decodeRune(_ref, _i); - rune = _rune[0]; - if (escaped) { - escaped = false; - } else if (rune === 92) { - escaped = true; - _i += _rune[1]; - continue; - } else if (!((quote === 0))) { - if (rune === quote) { - quote = 0; - _i += _rune[1]; - continue; - } - } else if ((rune === 34) || (rune === 39)) { - quoted = true; - quote = rune; - _i += _rune[1]; - continue; - } else if (unicode.IsSpace(rune)) { - if (quoted || i > 0) { - quoted = false; - args = $append(args, $runesToString($subslice(arg, 0, i))); - i = 0; - } - _i += _rune[1]; + machine.prototype.clear = function(q) { return this.$val.clear(q); }; + machine.Ptr.prototype.step = function(runq, nextq, pos, nextPos, c, nextCond) { + var m, longest, j, x, d, t, x$1, x$2, i, add, _ref, x$3, x$4, _ref$1, _i, d$1, x$5; + m = this; + longest = m.re.longest; + j = 0; + while (j < runq.dense.$length) { + d = (x = runq.dense, ((j < 0 || j >= x.$length) ? $throwRuntimeError("index out of range") : x.$array[x.$offset + j])); + t = d.t; + if (t === ($ptrType(thread)).nil) { + j = j + (1) >> 0; continue; } - (i < 0 || i >= arg.$length) ? $throwRuntimeError("index out of range") : arg.$array[arg.$offset + i] = rune; - i = i + (1) >> 0; - _i += _rune[1]; - } - if (quoted || i > 0) { - args = $append(args, $runesToString($subslice(arg, 0, i))); - } - if (!((quote === 0))) { - err = errors.New("unclosed quote"); - } else if (escaped) { - err = errors.New("unfinished escaping"); - } - _tmp = args; _tmp$1 = err; r = _tmp; err = _tmp$1; - return [r, err]; - }; - Context.Ptr.prototype.match = function(name, allTags) { - var ctxt, _key$1, i, ok1, ok2, _key$2, _ref, _i, _rune, c, _ref$1, _i$1, tag, _ref$2, _i$2, tag$1; - ctxt = this; - if (name === "") { - if (!(allTags === false)) { - _key$1 = name; (allTags || $throwRuntimeError("assignment to entry in nil map"))[_key$1] = { k: _key$1, v: true }; + if (longest && m.matched && t.cap.$length > 0 && (x$1 = m.matchcap, ((0 < 0 || 0 >= x$1.$length) ? $throwRuntimeError("index out of range") : x$1.$array[x$1.$offset + 0])) < (x$2 = t.cap, ((0 < 0 || 0 >= x$2.$length) ? $throwRuntimeError("index out of range") : x$2.$array[x$2.$offset + 0]))) { + m.pool = $append(m.pool, t); + j = j + (1) >> 0; + continue; } - return false; - } - i = strings.Index(name, ","); - if (i >= 0) { - ok1 = ctxt.match(name.substring(0, i), allTags); - ok2 = ctxt.match(name.substring((i + 1 >> 0)), allTags); - return ok1 && ok2; - } - if (strings.HasPrefix(name, "!!")) { - return false; - } - if (strings.HasPrefix(name, "!")) { - return name.length > 1 && !ctxt.match(name.substring(1), allTags); - } - if (!(allTags === false)) { - _key$2 = name; (allTags || $throwRuntimeError("assignment to entry in nil map"))[_key$2] = { k: _key$2, v: true }; - } - _ref = name; - _i = 0; - while (_i < _ref.length) { - _rune = $decodeRune(_ref, _i); - c = _rune[0]; - if (!unicode.IsLetter(c) && !unicode.IsDigit(c) && !((c === 95)) && !((c === 46))) { - return false; + i = t.inst; + add = false; + _ref = i.Op; + if (_ref === 4) { + if (t.cap.$length > 0 && (!longest || !m.matched || (x$3 = m.matchcap, ((1 < 0 || 1 >= x$3.$length) ? $throwRuntimeError("index out of range") : x$3.$array[x$3.$offset + 1])) < pos)) { + (x$4 = t.cap, (1 < 0 || 1 >= x$4.$length) ? $throwRuntimeError("index out of range") : x$4.$array[x$4.$offset + 1] = pos); + $copySlice(m.matchcap, t.cap); + } + if (!longest) { + _ref$1 = $subslice(runq.dense, (j + 1 >> 0)); + _i = 0; + while (_i < _ref$1.$length) { + d$1 = new entry.Ptr(); $copy(d$1, ((_i < 0 || _i >= _ref$1.$length) ? $throwRuntimeError("index out of range") : _ref$1.$array[_ref$1.$offset + _i]), entry); + if (!(d$1.t === ($ptrType(thread)).nil)) { + m.pool = $append(m.pool, d$1.t); + } + _i++; + } + runq.dense = $subslice(runq.dense, 0, 0); + } + m.matched = true; + } else if (_ref === 7) { + add = i.MatchRune(c); + } else if (_ref === 8) { + add = c === (x$5 = i.Rune, ((0 < 0 || 0 >= x$5.$length) ? $throwRuntimeError("index out of range") : x$5.$array[x$5.$offset + 0])); + } else if (_ref === 9) { + add = true; + } else if (_ref === 10) { + add = !((c === 10)); + } else { + $panic(new $String("bad inst")); } - _i += _rune[1]; - } - if (ctxt.CgoEnabled && name === "cgo") { - return true; - } - if (name === ctxt.GOOS || name === ctxt.GOARCH || name === ctxt.Compiler) { - return true; - } - _ref$1 = ctxt.BuildTags; - _i$1 = 0; - while (_i$1 < _ref$1.$length) { - tag = ((_i$1 < 0 || _i$1 >= _ref$1.$length) ? $throwRuntimeError("index out of range") : _ref$1.$array[_ref$1.$offset + _i$1]); - if (tag === name) { - return true; + if (add) { + t = m.add(nextq, i.Out, nextPos, t.cap, nextCond, t); } - _i$1++; - } - _ref$2 = ctxt.ReleaseTags; - _i$2 = 0; - while (_i$2 < _ref$2.$length) { - tag$1 = ((_i$2 < 0 || _i$2 >= _ref$2.$length) ? $throwRuntimeError("index out of range") : _ref$2.$array[_ref$2.$offset + _i$2]); - if (tag$1 === name) { - return true; + if (!(t === ($ptrType(thread)).nil)) { + m.pool = $append(m.pool, t); } - _i$2++; + j = j + (1) >> 0; } - return false; + runq.dense = $subslice(runq.dense, 0, 0); }; - Context.prototype.match = function(name, allTags) { return this.$val.match(name, allTags); }; - Context.Ptr.prototype.goodOSArchFile = function(name, allTags) { - var ctxt, dot, l, n, x, n$1, x$1, _entry, x$2, _entry$1, _key$1, x$3, _key$2, x$4, x$5, x$6, x$7, _entry$2, _key$3, x$8, x$9, x$10, _entry$3, _key$4, x$11, x$12; - ctxt = this; - dot = strings.Index(name, "."); - if (!((dot === -1))) { - name = name.substring(0, dot); + machine.prototype.step = function(runq, nextq, pos, nextPos, c, nextCond) { return this.$val.step(runq, nextq, pos, nextPos, c, nextCond); }; + machine.Ptr.prototype.add = function(q, pc, pos, cap, cond, t) { + var m, x, j, x$1, j$1, x$2, d, x$3, x$4, i, _ref, x$5, opos, x$6, x$7; + m = this; + if (pc === 0) { + return t; } - l = strings.Split(name, "_"); - n = l.$length; - if (n > 0 && (x = n - 1 >> 0, ((x < 0 || x >= l.$length) ? $throwRuntimeError("index out of range") : l.$array[l.$offset + x])) === "test") { - l = $subslice(l, 0, (n - 1 >> 0)); + j = (x = q.sparse, ((pc < 0 || pc >= x.$length) ? $throwRuntimeError("index out of range") : x.$array[x.$offset + pc])); + if (j < (q.dense.$length >>> 0) && ((x$1 = q.dense, ((j < 0 || j >= x$1.$length) ? $throwRuntimeError("index out of range") : x$1.$array[x$1.$offset + j])).pc === pc)) { + return t; } - n$1 = l.$length; - if (n$1 >= 2 && (_entry = knownOS[(x$1 = n$1 - 2 >> 0, ((x$1 < 0 || x$1 >= l.$length) ? $throwRuntimeError("index out of range") : l.$array[l.$offset + x$1]))], _entry !== undefined ? _entry.v : false) && (_entry$1 = knownArch[(x$2 = n$1 - 1 >> 0, ((x$2 < 0 || x$2 >= l.$length) ? $throwRuntimeError("index out of range") : l.$array[l.$offset + x$2]))], _entry$1 !== undefined ? _entry$1.v : false)) { - if (!(allTags === false)) { - _key$1 = (x$3 = n$1 - 2 >> 0, ((x$3 < 0 || x$3 >= l.$length) ? $throwRuntimeError("index out of range") : l.$array[l.$offset + x$3])); (allTags || $throwRuntimeError("assignment to entry in nil map"))[_key$1] = { k: _key$1, v: true }; - _key$2 = (x$4 = n$1 - 1 >> 0, ((x$4 < 0 || x$4 >= l.$length) ? $throwRuntimeError("index out of range") : l.$array[l.$offset + x$4])); (allTags || $throwRuntimeError("assignment to entry in nil map"))[_key$2] = { k: _key$2, v: true }; + j$1 = q.dense.$length; + q.dense = $subslice(q.dense, 0, (j$1 + 1 >> 0)); + d = (x$2 = q.dense, ((j$1 < 0 || j$1 >= x$2.$length) ? $throwRuntimeError("index out of range") : x$2.$array[x$2.$offset + j$1])); + d.t = ($ptrType(thread)).nil; + d.pc = pc; + (x$3 = q.sparse, (pc < 0 || pc >= x$3.$length) ? $throwRuntimeError("index out of range") : x$3.$array[x$3.$offset + pc] = (j$1 >>> 0)); + i = (x$4 = m.p.Inst, ((pc < 0 || pc >= x$4.$length) ? $throwRuntimeError("index out of range") : x$4.$array[x$4.$offset + pc])); + _ref = i.Op; + if (_ref === 5) { + } else if (_ref === 0 || _ref === 1) { + t = m.add(q, i.Out, pos, cap, cond, t); + t = m.add(q, i.Arg, pos, cap, cond, t); + } else if (_ref === 3) { + if (((i.Arg << 24 >>> 24) & ~cond) === 0) { + t = m.add(q, i.Out, pos, cap, cond, t); } - return (x$5 = n$1 - 2 >> 0, ((x$5 < 0 || x$5 >= l.$length) ? $throwRuntimeError("index out of range") : l.$array[l.$offset + x$5])) === ctxt.GOOS && (x$6 = n$1 - 1 >> 0, ((x$6 < 0 || x$6 >= l.$length) ? $throwRuntimeError("index out of range") : l.$array[l.$offset + x$6])) === ctxt.GOARCH; - } - if (n$1 >= 1 && (_entry$2 = knownOS[(x$7 = n$1 - 1 >> 0, ((x$7 < 0 || x$7 >= l.$length) ? $throwRuntimeError("index out of range") : l.$array[l.$offset + x$7]))], _entry$2 !== undefined ? _entry$2.v : false)) { - if (!(allTags === false)) { - _key$3 = (x$8 = n$1 - 1 >> 0, ((x$8 < 0 || x$8 >= l.$length) ? $throwRuntimeError("index out of range") : l.$array[l.$offset + x$8])); (allTags || $throwRuntimeError("assignment to entry in nil map"))[_key$3] = { k: _key$3, v: true }; + } else if (_ref === 6) { + t = m.add(q, i.Out, pos, cap, cond, t); + } else if (_ref === 2) { + if ((i.Arg >> 0) < cap.$length) { + opos = (x$5 = i.Arg, ((x$5 < 0 || x$5 >= cap.$length) ? $throwRuntimeError("index out of range") : cap.$array[cap.$offset + x$5])); + (x$6 = i.Arg, (x$6 < 0 || x$6 >= cap.$length) ? $throwRuntimeError("index out of range") : cap.$array[cap.$offset + x$6] = pos); + m.add(q, i.Out, pos, cap, cond, ($ptrType(thread)).nil); + (x$7 = i.Arg, (x$7 < 0 || x$7 >= cap.$length) ? $throwRuntimeError("index out of range") : cap.$array[cap.$offset + x$7] = opos); + } else { + t = m.add(q, i.Out, pos, cap, cond, t); } - return (x$9 = n$1 - 1 >> 0, ((x$9 < 0 || x$9 >= l.$length) ? $throwRuntimeError("index out of range") : l.$array[l.$offset + x$9])) === ctxt.GOOS; - } - if (n$1 >= 1 && (_entry$3 = knownArch[(x$10 = n$1 - 1 >> 0, ((x$10 < 0 || x$10 >= l.$length) ? $throwRuntimeError("index out of range") : l.$array[l.$offset + x$10]))], _entry$3 !== undefined ? _entry$3.v : false)) { - if (!(allTags === false)) { - _key$4 = (x$11 = n$1 - 1 >> 0, ((x$11 < 0 || x$11 >= l.$length) ? $throwRuntimeError("index out of range") : l.$array[l.$offset + x$11])); (allTags || $throwRuntimeError("assignment to entry in nil map"))[_key$4] = { k: _key$4, v: true }; + } else if (_ref === 4 || _ref === 7 || _ref === 8 || _ref === 9 || _ref === 10) { + if (t === ($ptrType(thread)).nil) { + t = m.alloc(i); + } else { + t.inst = i; } - return (x$12 = n$1 - 1 >> 0, ((x$12 < 0 || x$12 >= l.$length) ? $throwRuntimeError("index out of range") : l.$array[l.$offset + x$12])) === ctxt.GOARCH; + if (cap.$length > 0 && !($sliceIsEqual(t.cap, 0, cap, 0))) { + $copySlice(t.cap, cap); + } + d.t = t; + t = ($ptrType(thread)).nil; + } else { + $panic(new $String("unhandled")); } - return true; + return t; }; - Context.prototype.goodOSArchFile = function(name, allTags) { return this.$val.goodOSArchFile(name, allTags); }; - init = function() { - var _ref, _i, v, _key$1, _ref$1, _i$1, v$1, _key$2; - _ref = strings.Fields("darwin dragonfly freebsd linux nacl netbsd openbsd plan9 solaris windows "); + machine.prototype.add = function(q, pc, pos, cap, cond, t) { return this.$val.add(q, pc, pos, cap, cond, t); }; + machine.Ptr.prototype.onepass = function(i, pos) { + var m, startCond, _ref, _i, i$1, x, _tmp, _tmp$1, r, r1, _tmp$2, _tmp$3, width, width1, _tuple, _tuple$1, flag, pc, x$1, inst, _tuple$2, _tuple$3, x$2, _ref$1, x$3, x$4, x$5, x$6, x$7, _tmp$4, _tmp$5, _tuple$4; + m = this; + startCond = m.re.cond; + if (startCond === 255) { + return false; + } + m.matched = false; + _ref = m.matchcap; _i = 0; while (_i < _ref.$length) { - v = ((_i < 0 || _i >= _ref.$length) ? $throwRuntimeError("index out of range") : _ref.$array[_ref.$offset + _i]); - _key$1 = v; (knownOS || $throwRuntimeError("assignment to entry in nil map"))[_key$1] = { k: _key$1, v: true }; + i$1 = _i; + (x = m.matchcap, (i$1 < 0 || i$1 >= x.$length) ? $throwRuntimeError("index out of range") : x.$array[x.$offset + i$1] = -1); _i++; } - _ref$1 = strings.Fields("386 amd64 amd64p32 arm "); - _i$1 = 0; - while (_i$1 < _ref$1.$length) { - v$1 = ((_i$1 < 0 || _i$1 >= _ref$1.$length) ? $throwRuntimeError("index out of range") : _ref$1.$array[_ref$1.$offset + _i$1]); - _key$2 = v$1; (knownArch || $throwRuntimeError("assignment to entry in nil map"))[_key$2] = { k: _key$2, v: true }; - _i$1++; - } - }; - IsLocalImport = $pkg.IsLocalImport = function(path$1) { - return path$1 === "." || path$1 === ".." || strings.HasPrefix(path$1, "./") || strings.HasPrefix(path$1, "../"); - }; - isIdent = function(c) { - return 65 <= c && c <= 90 || 97 <= c && c <= 122 || 48 <= c && c <= 57 || (c === 95) || c >= 128; - }; - importReader.Ptr.prototype.syntaxError = function() { - var r; - r = this; - if ($interfaceIsEqual(r.err, $ifaceNil)) { - r.err = errSyntax; - } - }; - importReader.prototype.syntaxError = function() { return this.$val.syntaxError(); }; - importReader.Ptr.prototype.readByte = function() { - var r, _tuple, c, err; - r = this; - _tuple = r.b.ReadByte(); c = _tuple[0]; err = _tuple[1]; - if ($interfaceIsEqual(err, $ifaceNil)) { - r.buf = $append(r.buf, c); - if (c === 0) { - err = errNUL; - } - } - if (!($interfaceIsEqual(err, $ifaceNil))) { - if ($interfaceIsEqual(err, io.EOF)) { - r.eof = true; - } else if ($interfaceIsEqual(r.err, $ifaceNil)) { - r.err = err; - } - c = 0; - } - return c; - }; - importReader.prototype.readByte = function() { return this.$val.readByte(); }; - importReader.Ptr.prototype.peekByte = function(skipSpace) { - var r, c, _ref, c1, _tmp, _tmp$1; - r = this; - if (!($interfaceIsEqual(r.err, $ifaceNil))) { - r.nerr = r.nerr + (1) >> 0; - if (r.nerr > 10000) { - $panic(new $String("go/build: import reader looping")); - } - return 0; - } - c = r.peek; - if (c === 0) { - c = r.readByte(); + _tmp = -1; _tmp$1 = -1; r = _tmp; r1 = _tmp$1; + _tmp$2 = 0; _tmp$3 = 0; width = _tmp$2; width1 = _tmp$3; + _tuple = i.step(pos); r = _tuple[0]; width = _tuple[1]; + if (!((r === -1))) { + _tuple$1 = i.step(pos + width >> 0); r1 = _tuple$1[0]; width1 = _tuple$1[1]; } - while ($interfaceIsEqual(r.err, $ifaceNil) && !r.eof) { - if (skipSpace) { - _ref = c; - if (_ref === 32 || _ref === 12 || _ref === 9 || _ref === 13 || _ref === 10 || _ref === 59) { - c = r.readByte(); - continue; - } else if (_ref === 47) { - c = r.readByte(); - if (c === 47) { - while (!((c === 10)) && $interfaceIsEqual(r.err, $ifaceNil) && !r.eof) { - c = r.readByte(); - } - } else if (c === 42) { - c1 = 0; - while ((!((c === 42)) || !((c1 === 47))) && $interfaceIsEqual(r.err, $ifaceNil)) { - if (r.eof) { - r.syntaxError(); - } - _tmp = c1; _tmp$1 = r.readByte(); c = _tmp; c1 = _tmp$1; - } - } else { - r.syntaxError(); - } - c = r.readByte(); - continue; - } - } - break; + flag = 0; + if (pos === 0) { + flag = syntax.EmptyOpContext(-1, r); + } else { + flag = i.context(pos); } - r.peek = c; - return r.peek; - }; - importReader.prototype.peekByte = function(skipSpace) { return this.$val.peekByte(skipSpace); }; - importReader.Ptr.prototype.nextByte = function(skipSpace) { - var r, c; - r = this; - c = r.peekByte(skipSpace); - r.peek = 0; - return c; - }; - importReader.prototype.nextByte = function(skipSpace) { return this.$val.nextByte(skipSpace); }; - importReader.Ptr.prototype.readKeyword = function(kw) { - var r, i; - r = this; - r.peekByte(true); - i = 0; - while (i < kw.length) { - if (!((r.nextByte(false) === kw.charCodeAt(i)))) { - r.syntaxError(); - return; + pc = m.op.Start; + inst = new onePassInst.Ptr(); $copy(inst, (x$1 = m.op.Inst, ((pc < 0 || pc >= x$1.$length) ? $throwRuntimeError("index out of range") : x$1.$array[x$1.$offset + pc])), onePassInst); + if ((pos === 0) && (((inst.Inst.Arg << 24 >>> 24) & ~flag) === 0) && m.re.prefix.length > 0 && i.canCheckPrefix()) { + if (i.hasPrefix(m.re)) { + pos = pos + (m.re.prefix.length) >> 0; + _tuple$2 = i.step(pos); r = _tuple$2[0]; width = _tuple$2[1]; + _tuple$3 = i.step(pos + width >> 0); r1 = _tuple$3[0]; width1 = _tuple$3[1]; + flag = i.context(pos); + pc = (m.re.prefixEnd >> 0); + } else { + return m.matched; } - i = i + (1) >> 0; - } - if (isIdent(r.peekByte(false))) { - r.syntaxError(); - } - }; - importReader.prototype.readKeyword = function(kw) { return this.$val.readKeyword(kw); }; - importReader.Ptr.prototype.readIdent = function() { - var r, c; - r = this; - c = r.peekByte(true); - if (!isIdent(c)) { - r.syntaxError(); - return; - } - while (isIdent(r.peekByte(false))) { - r.peek = 0; } - }; - importReader.prototype.readIdent = function() { return this.$val.readIdent(); }; - importReader.Ptr.prototype.readString = function() { - var r, _ref, c; - r = this; - _ref = r.nextByte(true); - if (_ref === 96) { - while ($interfaceIsEqual(r.err, $ifaceNil)) { - if (r.nextByte(false) === 96) { - break; + while (true) { + $copy(inst, (x$2 = m.op.Inst, ((pc < 0 || pc >= x$2.$length) ? $throwRuntimeError("index out of range") : x$2.$array[x$2.$offset + pc])), onePassInst); + pc = (inst.Inst.Out >> 0); + _ref$1 = inst.Inst.Op; + if (_ref$1 === 4) { + m.matched = true; + if (m.matchcap.$length > 0) { + (x$3 = m.matchcap, (0 < 0 || 0 >= x$3.$length) ? $throwRuntimeError("index out of range") : x$3.$array[x$3.$offset + 0] = 0); + (x$4 = m.matchcap, (1 < 0 || 1 >= x$4.$length) ? $throwRuntimeError("index out of range") : x$4.$array[x$4.$offset + 1] = pos); } - if (r.eof) { - r.syntaxError(); + return m.matched; + } else if (_ref$1 === 7) { + if (!inst.Inst.MatchRune(r)) { + return m.matched; } - } - } else if (_ref === 34) { - while ($interfaceIsEqual(r.err, $ifaceNil)) { - c = r.nextByte(false); - if (c === 34) { - break; + } else if (_ref$1 === 8) { + if (!((r === (x$5 = inst.Inst.Rune, ((0 < 0 || 0 >= x$5.$length) ? $throwRuntimeError("index out of range") : x$5.$array[x$5.$offset + 0]))))) { + return m.matched; } - if (r.eof || (c === 10)) { - r.syntaxError(); + } else if (_ref$1 === 9) { + } else if (_ref$1 === 10) { + if (r === 10) { + return m.matched; } - if (c === 92) { - r.nextByte(false); + } else if (_ref$1 === 0 || _ref$1 === 1) { + pc = (onePassNext(inst, r) >> 0); + continue; + } else if (_ref$1 === 5) { + return m.matched; + } else if (_ref$1 === 6) { + continue; + } else if (_ref$1 === 3) { + if (!((((inst.Inst.Arg << 24 >>> 24) & ~flag) === 0))) { + return m.matched; } - } - } else { - r.syntaxError(); - } - }; - importReader.prototype.readString = function() { return this.$val.readString(); }; - importReader.Ptr.prototype.readImport = function() { - var r, c; - r = this; - c = r.peekByte(true); - if (c === 46) { - r.peek = 0; - } else if (isIdent(c)) { - r.readIdent(); - } - r.readString(); - }; - importReader.prototype.readImport = function() { return this.$val.readImport(); }; - readComments = function(f) { - var r; - r = new importReader.Ptr(bufio.NewReader(f), ($sliceType($Uint8)).nil, 0, $ifaceNil, false, 0); - r.peekByte(true); - if ($interfaceIsEqual(r.err, $ifaceNil) && !r.eof) { - r.buf = $subslice(r.buf, 0, (r.buf.$length - 1 >> 0)); - } - return [r.buf, r.err]; - }; - readImports = function(f, reportSyntaxError) { - var r; - r = new importReader.Ptr(bufio.NewReader(f), ($sliceType($Uint8)).nil, 0, $ifaceNil, false, 0); - r.readKeyword("package"); - r.readIdent(); - while (r.peekByte(true) === 105) { - r.readKeyword("import"); - if (r.peekByte(true) === 40) { - r.nextByte(false); - while (!((r.peekByte(true) === 41)) && $interfaceIsEqual(r.err, $ifaceNil)) { - r.readImport(); + continue; + } else if (_ref$1 === 2) { + if ((inst.Inst.Arg >> 0) < m.matchcap.$length) { + (x$6 = m.matchcap, x$7 = inst.Inst.Arg, (x$7 < 0 || x$7 >= x$6.$length) ? $throwRuntimeError("index out of range") : x$6.$array[x$6.$offset + x$7] = pos); } - r.nextByte(false); + continue; } else { - r.readImport(); + $panic(new $String("bad inst")); } - } - if ($interfaceIsEqual(r.err, $ifaceNil) && !r.eof) { - return [$subslice(r.buf, 0, (r.buf.$length - 1 >> 0)), $ifaceNil]; - } - if ($interfaceIsEqual(r.err, errSyntax) && !reportSyntaxError) { - r.err = $ifaceNil; - while ($interfaceIsEqual(r.err, $ifaceNil) && !r.eof) { - r.readByte(); + if (width === 0) { + break; } - } - return [r.buf, r.err]; - }; - $pkg.$init = function() { - ($ptrType(Context)).methods = [["Import", "Import", "", $funcType([$String, $String, ImportMode], [($ptrType(Package)), $error], false), -1], ["ImportDir", "ImportDir", "", $funcType([$String, ImportMode], [($ptrType(Package)), $error], false), -1], ["MatchFile", "MatchFile", "", $funcType([$String, $String], [$Bool, $error], false), -1], ["SrcDirs", "SrcDirs", "", $funcType([], [($sliceType($String))], false), -1], ["goodOSArchFile", "goodOSArchFile", "go/build", $funcType([$String, ($mapType($String, $Bool))], [$Bool], false), -1], ["gopath", "gopath", "go/build", $funcType([], [($sliceType($String))], false), -1], ["hasSubdir", "hasSubdir", "go/build", $funcType([$String, $String], [$String, $Bool], false), -1], ["isAbsPath", "isAbsPath", "go/build", $funcType([$String], [$Bool], false), -1], ["isDir", "isDir", "go/build", $funcType([$String], [$Bool], false), -1], ["isFile", "isFile", "go/build", $funcType([$String], [$Bool], false), -1], ["joinPath", "joinPath", "go/build", $funcType([($sliceType($String))], [$String], true), -1], ["match", "match", "go/build", $funcType([$String, ($mapType($String, $Bool))], [$Bool], false), -1], ["matchFile", "matchFile", "go/build", $funcType([$String, $String, $Bool, ($mapType($String, $Bool))], [$Bool, ($sliceType($Uint8)), $String, $error], false), -1], ["openFile", "openFile", "go/build", $funcType([$String], [io.ReadCloser, $error], false), -1], ["readDir", "readDir", "go/build", $funcType([$String], [($sliceType(os.FileInfo)), $error], false), -1], ["saveCgo", "saveCgo", "go/build", $funcType([$String, ($ptrType(Package)), ($ptrType(ast.CommentGroup))], [$error], false), -1], ["shouldBuild", "shouldBuild", "go/build", $funcType([($sliceType($Uint8)), ($mapType($String, $Bool))], [$Bool], false), -1], ["splitPathList", "splitPathList", "go/build", $funcType([$String], [($sliceType($String))], false), -1]]; - Context.init([["GOARCH", "GOARCH", "", $String, ""], ["GOOS", "GOOS", "", $String, ""], ["GOROOT", "GOROOT", "", $String, ""], ["GOPATH", "GOPATH", "", $String, ""], ["CgoEnabled", "CgoEnabled", "", $Bool, ""], ["UseAllFiles", "UseAllFiles", "", $Bool, ""], ["Compiler", "Compiler", "", $String, ""], ["BuildTags", "BuildTags", "", ($sliceType($String)), ""], ["ReleaseTags", "ReleaseTags", "", ($sliceType($String)), ""], ["InstallSuffix", "InstallSuffix", "", $String, ""], ["JoinPath", "JoinPath", "", ($funcType([($sliceType($String))], [$String], true)), ""], ["SplitPathList", "SplitPathList", "", ($funcType([$String], [($sliceType($String))], false)), ""], ["IsAbsPath", "IsAbsPath", "", ($funcType([$String], [$Bool], false)), ""], ["IsDir", "IsDir", "", ($funcType([$String], [$Bool], false)), ""], ["HasSubdir", "HasSubdir", "", ($funcType([$String, $String], [$String, $Bool], false)), ""], ["ReadDir", "ReadDir", "", ($funcType([$String], [($sliceType(os.FileInfo)), $error], false)), ""], ["OpenFile", "OpenFile", "", ($funcType([$String], [io.ReadCloser, $error], false)), ""]]); - ($ptrType(Package)).methods = [["IsCommand", "IsCommand", "", $funcType([], [$Bool], false), -1]]; - Package.init([["Dir", "Dir", "", $String, ""], ["Name", "Name", "", $String, ""], ["Doc", "Doc", "", $String, ""], ["ImportPath", "ImportPath", "", $String, ""], ["Root", "Root", "", $String, ""], ["SrcRoot", "SrcRoot", "", $String, ""], ["PkgRoot", "PkgRoot", "", $String, ""], ["BinDir", "BinDir", "", $String, ""], ["Goroot", "Goroot", "", $Bool, ""], ["PkgObj", "PkgObj", "", $String, ""], ["AllTags", "AllTags", "", ($sliceType($String)), ""], ["ConflictDir", "ConflictDir", "", $String, ""], ["GoFiles", "GoFiles", "", ($sliceType($String)), ""], ["CgoFiles", "CgoFiles", "", ($sliceType($String)), ""], ["IgnoredGoFiles", "IgnoredGoFiles", "", ($sliceType($String)), ""], ["CFiles", "CFiles", "", ($sliceType($String)), ""], ["CXXFiles", "CXXFiles", "", ($sliceType($String)), ""], ["MFiles", "MFiles", "", ($sliceType($String)), ""], ["HFiles", "HFiles", "", ($sliceType($String)), ""], ["SFiles", "SFiles", "", ($sliceType($String)), ""], ["SwigFiles", "SwigFiles", "", ($sliceType($String)), ""], ["SwigCXXFiles", "SwigCXXFiles", "", ($sliceType($String)), ""], ["SysoFiles", "SysoFiles", "", ($sliceType($String)), ""], ["CgoCFLAGS", "CgoCFLAGS", "", ($sliceType($String)), ""], ["CgoCPPFLAGS", "CgoCPPFLAGS", "", ($sliceType($String)), ""], ["CgoCXXFLAGS", "CgoCXXFLAGS", "", ($sliceType($String)), ""], ["CgoLDFLAGS", "CgoLDFLAGS", "", ($sliceType($String)), ""], ["CgoPkgConfig", "CgoPkgConfig", "", ($sliceType($String)), ""], ["Imports", "Imports", "", ($sliceType($String)), ""], ["ImportPos", "ImportPos", "", ($mapType($String, ($sliceType(token.Position)))), ""], ["TestGoFiles", "TestGoFiles", "", ($sliceType($String)), ""], ["TestImports", "TestImports", "", ($sliceType($String)), ""], ["TestImportPos", "TestImportPos", "", ($mapType($String, ($sliceType(token.Position)))), ""], ["XTestGoFiles", "XTestGoFiles", "", ($sliceType($String)), ""], ["XTestImports", "XTestImports", "", ($sliceType($String)), ""], ["XTestImportPos", "XTestImportPos", "", ($mapType($String, ($sliceType(token.Position)))), ""]]); - ($ptrType(NoGoError)).methods = [["Error", "Error", "", $funcType([], [$String], false), -1]]; - NoGoError.init([["Dir", "Dir", "", $String, ""]]); - ($ptrType(importReader)).methods = [["nextByte", "nextByte", "go/build", $funcType([$Bool], [$Uint8], false), -1], ["peekByte", "peekByte", "go/build", $funcType([$Bool], [$Uint8], false), -1], ["readByte", "readByte", "go/build", $funcType([], [$Uint8], false), -1], ["readIdent", "readIdent", "go/build", $funcType([], [], false), -1], ["readImport", "readImport", "go/build", $funcType([], [], false), -1], ["readKeyword", "readKeyword", "go/build", $funcType([$String], [], false), -1], ["readString", "readString", "go/build", $funcType([], [], false), -1], ["syntaxError", "syntaxError", "go/build", $funcType([], [], false), -1]]; - importReader.init([["b", "b", "go/build", ($ptrType(bufio.Reader)), ""], ["buf", "buf", "go/build", ($sliceType($Uint8)), ""], ["peek", "peek", "go/build", $Uint8, ""], ["err", "err", "go/build", $error, ""], ["eof", "eof", "go/build", $Bool, ""], ["nerr", "nerr", "go/build", $Int, ""]]); - cgoEnabled = (_map = new $Map(), _key = "darwin/386", _map[_key] = { k: _key, v: true }, _key = "darwin/amd64", _map[_key] = { k: _key, v: true }, _key = "dragonfly/386", _map[_key] = { k: _key, v: true }, _key = "dragonfly/amd64", _map[_key] = { k: _key, v: true }, _key = "freebsd/386", _map[_key] = { k: _key, v: true }, _key = "freebsd/amd64", _map[_key] = { k: _key, v: true }, _key = "freebsd/arm", _map[_key] = { k: _key, v: true }, _key = "linux/386", _map[_key] = { k: _key, v: true }, _key = "linux/amd64", _map[_key] = { k: _key, v: true }, _key = "linux/arm", _map[_key] = { k: _key, v: true }, _key = "netbsd/386", _map[_key] = { k: _key, v: true }, _key = "netbsd/amd64", _map[_key] = { k: _key, v: true }, _key = "netbsd/arm", _map[_key] = { k: _key, v: true }, _key = "openbsd/386", _map[_key] = { k: _key, v: true }, _key = "openbsd/amd64", _map[_key] = { k: _key, v: true }, _key = "windows/386", _map[_key] = { k: _key, v: true }, _key = "windows/amd64", _map[_key] = { k: _key, v: true }, _map); - $pkg.Default = new Context.Ptr(); $copy($pkg.Default, defaultContext(), Context); - slashslash = new ($sliceType($Uint8))($stringToBytes("//")); - safeBytes = new ($sliceType($Uint8))($stringToBytes("+-.,/0123456789=ABCDEFGHIJKLMNOPQRSTUVWXYZ_abcdefghijklmnopqrstuvwxyz:$")); - knownOS = new $Map(); - knownArch = new $Map(); - $pkg.ToolDir = filepath.Join(new ($sliceType($String))([runtime.GOROOT(), "pkg/tool/darwin_js"])); - errSyntax = errors.New("syntax error"); - errNUL = errors.New("unexpected NUL in input"); - init(); - }; - return $pkg; -})(); -$packages["text/scanner"] = (function() { - var $pkg = {}, bytes = $packages["bytes"], fmt = $packages["fmt"], io = $packages["io"], os = $packages["os"], unicode = $packages["unicode"], utf8 = $packages["unicode/utf8"], Position, Scanner, tokenString, _map, _key, TokenString, digitVal, isDecimal; - Position = $pkg.Position = $newType(0, "Struct", "scanner.Position", "Position", "text/scanner", function(Filename_, Offset_, Line_, Column_) { - this.$val = this; - this.Filename = Filename_ !== undefined ? Filename_ : ""; - this.Offset = Offset_ !== undefined ? Offset_ : 0; - this.Line = Line_ !== undefined ? Line_ : 0; - this.Column = Column_ !== undefined ? Column_ : 0; - }); - Scanner = $pkg.Scanner = $newType(0, "Struct", "scanner.Scanner", "Scanner", "text/scanner", function(src_, srcBuf_, srcPos_, srcEnd_, srcBufOffset_, line_, column_, lastLineLen_, lastCharLen_, tokBuf_, tokPos_, tokEnd_, ch_, Error_, ErrorCount_, Mode_, Whitespace_, Position_) { - this.$val = this; - this.src = src_ !== undefined ? src_ : $ifaceNil; - this.srcBuf = srcBuf_ !== undefined ? srcBuf_ : ($arrayType($Uint8, 1025)).zero(); - this.srcPos = srcPos_ !== undefined ? srcPos_ : 0; - this.srcEnd = srcEnd_ !== undefined ? srcEnd_ : 0; - this.srcBufOffset = srcBufOffset_ !== undefined ? srcBufOffset_ : 0; - this.line = line_ !== undefined ? line_ : 0; - this.column = column_ !== undefined ? column_ : 0; - this.lastLineLen = lastLineLen_ !== undefined ? lastLineLen_ : 0; - this.lastCharLen = lastCharLen_ !== undefined ? lastCharLen_ : 0; - this.tokBuf = tokBuf_ !== undefined ? tokBuf_ : new bytes.Buffer.Ptr(); - this.tokPos = tokPos_ !== undefined ? tokPos_ : 0; - this.tokEnd = tokEnd_ !== undefined ? tokEnd_ : 0; - this.ch = ch_ !== undefined ? ch_ : 0; - this.Error = Error_ !== undefined ? Error_ : $throwNilPointerError; - this.ErrorCount = ErrorCount_ !== undefined ? ErrorCount_ : 0; - this.Mode = Mode_ !== undefined ? Mode_ : 0; - this.Whitespace = Whitespace_ !== undefined ? Whitespace_ : new $Uint64(0, 0); - this.Position = Position_ !== undefined ? Position_ : new Position.Ptr(); - }); - Position.Ptr.prototype.IsValid = function() { - var pos; - pos = this; - return pos.Line > 0; - }; - Position.prototype.IsValid = function() { return this.$val.IsValid(); }; - Position.Ptr.prototype.String = function() { - var pos, s; - pos = new Position.Ptr(); $copy(pos, this, Position); - s = pos.Filename; - if (pos.IsValid()) { - if (!(s === "")) { - s = s + (":"); + flag = syntax.EmptyOpContext(r, r1); + pos = pos + (width) >> 0; + _tmp$4 = r1; _tmp$5 = width1; r = _tmp$4; width = _tmp$5; + if (!((r === -1))) { + _tuple$4 = i.step(pos + width >> 0); r1 = _tuple$4[0]; width1 = _tuple$4[1]; } - s = s + (fmt.Sprintf("%d:%d", new ($sliceType($emptyInterface))([new $Int(pos.Line), new $Int(pos.Column)]))); - } - if (s === "") { - s = "???"; } - return s; + return m.matched; }; - Position.prototype.String = function() { return this.$val.String(); }; - TokenString = $pkg.TokenString = function(tok) { - var _tuple, _entry, s, found; - _tuple = (_entry = tokenString[tok], _entry !== undefined ? [_entry.v, true] : ["", false]); s = _tuple[0]; found = _tuple[1]; - if (found) { - return s; + machine.prototype.onepass = function(i, pos) { return this.$val.onepass(i, pos); }; + Regexp.Ptr.prototype.doExecute = function(r, b, s, pos, ncap) { + var re, m, i, cap; + re = this; + m = re.get(); + i = $ifaceNil; + if (!($interfaceIsEqual(r, $ifaceNil))) { + i = m.newInputReader(r); + } else if (!(b === ($sliceType($Uint8)).nil)) { + i = m.newInputBytes(b); + } else { + i = m.newInputString(s); } - return fmt.Sprintf("%q", new ($sliceType($emptyInterface))([new $String($encodeRune(tok))])); - }; - Scanner.Ptr.prototype.Init = function(src) { - var s; - s = this; - s.src = src; - s.srcBuf[0] = 128; - s.srcPos = 0; - s.srcEnd = 0; - s.srcBufOffset = 0; - s.line = 1; - s.column = 0; - s.lastLineLen = 0; - s.lastCharLen = 0; - s.tokPos = -1; - s.ch = -1; - s.Error = $throwNilPointerError; - s.ErrorCount = 0; - s.Mode = 1012; - s.Whitespace = new $Uint64(1, 9728); - s.Position.Line = 0; - return s; - }; - Scanner.prototype.Init = function(src) { return this.$val.Init(src); }; - Scanner.Ptr.prototype.next = function() { - var s, _tmp, x, x$1, _tmp$1, ch, width, i, _tuple, n, err, x$2, x$3, x$4, x$5, _tuple$1, _ref; - s = this; - _tmp = ((x = s.srcBuf, x$1 = s.srcPos, ((x$1 < 0 || x$1 >= x.length) ? $throwRuntimeError("index out of range") : x[x$1])) >> 0); _tmp$1 = 1; ch = _tmp; width = _tmp$1; - if (ch >= 128) { - while ((s.srcPos + 4 >> 0) > s.srcEnd && !utf8.FullRune($subslice(new ($sliceType($Uint8))(s.srcBuf), s.srcPos, s.srcEnd))) { - if (s.tokPos >= 0) { - s.tokBuf.Write($subslice(new ($sliceType($Uint8))(s.srcBuf), s.tokPos, s.srcPos)); - s.tokPos = 0; - } - $copySlice($subslice(new ($sliceType($Uint8))(s.srcBuf), 0), $subslice(new ($sliceType($Uint8))(s.srcBuf), s.srcPos, s.srcEnd)); - s.srcBufOffset = s.srcBufOffset + (s.srcPos) >> 0; - i = s.srcEnd - s.srcPos >> 0; - _tuple = s.src.Read($subslice(new ($sliceType($Uint8))(s.srcBuf), i, 1024)); n = _tuple[0]; err = _tuple[1]; - s.srcPos = 0; - s.srcEnd = i + n >> 0; - (x$2 = s.srcBuf, x$3 = s.srcEnd, (x$3 < 0 || x$3 >= x$2.length) ? $throwRuntimeError("index out of range") : x$2[x$3] = 128); - if (!($interfaceIsEqual(err, $ifaceNil))) { - if (!($interfaceIsEqual(err, io.EOF))) { - s.error(err.Error()); - } - if (s.srcEnd === 0) { - if (s.lastCharLen > 0) { - s.column = s.column + (1) >> 0; - } - s.lastCharLen = 0; - return -1; - } - break; - } + if (!(m.op === notOnePass)) { + if (!m.onepass(i, pos)) { + re.put(m); + return ($sliceType($Int)).nil; } - ch = ((x$4 = s.srcBuf, x$5 = s.srcPos, ((x$5 < 0 || x$5 >= x$4.length) ? $throwRuntimeError("index out of range") : x$4[x$5])) >> 0); - if (ch >= 128) { - _tuple$1 = utf8.DecodeRune($subslice(new ($sliceType($Uint8))(s.srcBuf), s.srcPos, s.srcEnd)); ch = _tuple$1[0]; width = _tuple$1[1]; - if ((ch === 65533) && (width === 1)) { - s.srcPos = s.srcPos + (width) >> 0; - s.lastCharLen = width; - s.column = s.column + (1) >> 0; - s.error("illegal UTF-8 encoding"); - return ch; - } + } else { + m.init(ncap); + if (!m.match(i, pos)) { + re.put(m); + return ($sliceType($Int)).nil; } } - s.srcPos = s.srcPos + (width) >> 0; - s.lastCharLen = width; - s.column = s.column + (1) >> 0; - _ref = ch; - if (_ref === 0) { - s.error("illegal character NUL"); - } else if (_ref === 10) { - s.line = s.line + (1) >> 0; - s.lastLineLen = s.column; - s.column = 0; + if (ncap === 0) { + re.put(m); + return empty; } - return ch; - }; - Scanner.prototype.next = function() { return this.$val.next(); }; - Scanner.Ptr.prototype.Next = function() { - var s, ch; - s = this; - s.tokPos = -1; - s.Position.Line = 0; - ch = s.Peek(); - s.ch = s.next(); - return ch; + cap = ($sliceType($Int)).make(m.matchcap.$length); + $copySlice(cap, m.matchcap); + re.put(m); + return cap; }; - Scanner.prototype.Next = function() { return this.$val.Next(); }; - Scanner.Ptr.prototype.Peek = function() { - var s; - s = this; - if (s.ch < 0) { - s.ch = s.next(); - if (s.ch === 65279) { - s.ch = s.next(); - } + Regexp.prototype.doExecute = function(r, b, s, pos, ncap) { return this.$val.doExecute(r, b, s, pos, ncap); }; + onePassPrefix = function(p) { + var prefix = "", complete = false, pc = 0, x, x$1, i, _tmp, _tmp$1, _tmp$2, x$2, x$3, _tmp$3, _tmp$4, _tmp$5, buf, x$4, _tmp$6, _tmp$7, x$5, x$6, _tmp$8, _tmp$9, _tmp$10; + i = (x = p.Inst, x$1 = p.Start, ((x$1 < 0 || x$1 >= x.$length) ? $throwRuntimeError("index out of range") : x.$array[x.$offset + x$1])); + if (!((i.Op === 3)) || (((((i.Arg << 24 >>> 24)) & 4) >>> 0) === 0)) { + _tmp = ""; _tmp$1 = i.Op === 4; _tmp$2 = (p.Start >>> 0); prefix = _tmp; complete = _tmp$1; pc = _tmp$2; + return [prefix, complete, pc]; } - return s.ch; - }; - Scanner.prototype.Peek = function() { return this.$val.Peek(); }; - Scanner.Ptr.prototype.error = function(msg) { - var s, pos; - s = this; - s.ErrorCount = s.ErrorCount + (1) >> 0; - if (!(s.Error === $throwNilPointerError)) { - s.Error(s, msg); - return; + pc = i.Out; + i = (x$2 = p.Inst, ((pc < 0 || pc >= x$2.$length) ? $throwRuntimeError("index out of range") : x$2.$array[x$2.$offset + pc])); + while (i.Op === 6) { + pc = i.Out; + i = (x$3 = p.Inst, ((pc < 0 || pc >= x$3.$length) ? $throwRuntimeError("index out of range") : x$3.$array[x$3.$offset + pc])); } - pos = new Position.Ptr(); $copy(pos, s.Position, Position); - if (!pos.IsValid()) { - $copy(pos, s.Pos(), Position); + if (!((iop(i) === 7)) || !((i.Rune.$length === 1))) { + _tmp$3 = ""; _tmp$4 = i.Op === 4; _tmp$5 = (p.Start >>> 0); prefix = _tmp$3; complete = _tmp$4; pc = _tmp$5; + return [prefix, complete, pc]; } - fmt.Fprintf(os.Stderr, "%s: %s\n", new ($sliceType($emptyInterface))([new pos.constructor.Struct(pos), new $String(msg)])); + buf = new bytes.Buffer.Ptr(); $copy(buf, new bytes.Buffer.Ptr(), bytes.Buffer); + while ((iop(i) === 7) && (i.Rune.$length === 1) && ((((i.Arg << 16 >>> 16) & 1) >>> 0) === 0)) { + buf.WriteRune((x$4 = i.Rune, ((0 < 0 || 0 >= x$4.$length) ? $throwRuntimeError("index out of range") : x$4.$array[x$4.$offset + 0]))); + _tmp$6 = i.Out; _tmp$7 = (x$5 = p.Inst, x$6 = i.Out, ((x$6 < 0 || x$6 >= x$5.$length) ? $throwRuntimeError("index out of range") : x$5.$array[x$5.$offset + x$6])); pc = _tmp$6; i = _tmp$7; + } + _tmp$8 = buf.String(); _tmp$9 = (i.Op === 3) && !((((((i.Arg << 24 >>> 24)) & 4) >>> 0) === 0)); _tmp$10 = pc; prefix = _tmp$8; complete = _tmp$9; pc = _tmp$10; + return [prefix, complete, pc]; }; - Scanner.prototype.error = function(msg) { return this.$val.error(msg); }; - Scanner.Ptr.prototype.scanIdentifier = function() { - var s, ch; - s = this; - ch = s.next(); - while ((ch === 95) || unicode.IsLetter(ch) || unicode.IsDigit(ch)) { - ch = s.next(); + onePassNext = function(i, r) { + var next, x; + next = i.Inst.MatchRunePos(r); + if (next >= 0) { + return (x = i.Next, ((next < 0 || next >= x.$length) ? $throwRuntimeError("index out of range") : x.$array[x.$offset + next])); } - return ch; + if (i.Inst.Op === 1) { + return i.Inst.Out; + } + return 0; }; - Scanner.prototype.scanIdentifier = function() { return this.$val.scanIdentifier(); }; - digitVal = function(ch) { - if (48 <= ch && ch <= 57) { - return ((ch - 48 >> 0) >> 0); - } else if (97 <= ch && ch <= 102) { - return (((ch - 97 >> 0) + 10 >> 0) >> 0); - } else if (65 <= ch && ch <= 70) { - return (((ch - 65 >> 0) + 10 >> 0) >> 0); + iop = function(i) { + var op, _ref; + op = i.Op; + _ref = op; + if (_ref === 8 || _ref === 9 || _ref === 10) { + op = 7; } - return 16; + return op; }; - isDecimal = function(ch) { - return 48 <= ch && ch <= 57; + queueOnePass.Ptr.prototype.empty = function() { + var q; + q = this; + return q.nextIndex >= q.size; }; - Scanner.Ptr.prototype.scanMantissa = function(ch) { - var s; - s = this; - while (isDecimal(ch)) { - ch = s.next(); - } - return ch; + queueOnePass.prototype.empty = function() { return this.$val.empty(); }; + queueOnePass.Ptr.prototype.next = function() { + var n = 0, q, x, x$1; + q = this; + n = (x = q.dense, x$1 = q.nextIndex, ((x$1 < 0 || x$1 >= x.$length) ? $throwRuntimeError("index out of range") : x.$array[x.$offset + x$1])); + q.nextIndex = q.nextIndex + (1) >>> 0; + return n; }; - Scanner.prototype.scanMantissa = function(ch) { return this.$val.scanMantissa(ch); }; - Scanner.Ptr.prototype.scanFraction = function(ch) { - var s; - s = this; - if (ch === 46) { - ch = s.scanMantissa(s.next()); - } - return ch; + queueOnePass.prototype.next = function() { return this.$val.next(); }; + queueOnePass.Ptr.prototype.clear = function() { + var q; + q = this; + q.size = 0; + q.nextIndex = 0; }; - Scanner.prototype.scanFraction = function(ch) { return this.$val.scanFraction(ch); }; - Scanner.Ptr.prototype.scanExponent = function(ch) { - var s; - s = this; - if ((ch === 101) || (ch === 69)) { - ch = s.next(); - if ((ch === 45) || (ch === 43)) { - ch = s.next(); - } - ch = s.scanMantissa(ch); + queueOnePass.prototype.clear = function() { return this.$val.clear(); }; + queueOnePass.Ptr.prototype.contains = function(u) { + var q, x, x$1, x$2, x$3; + q = this; + if (u >= (q.sparse.$length >>> 0)) { + return false; } - return ch; + return (x = q.sparse, ((u < 0 || u >= x.$length) ? $throwRuntimeError("index out of range") : x.$array[x.$offset + u])) < q.size && ((x$1 = q.dense, x$2 = (x$3 = q.sparse, ((u < 0 || u >= x$3.$length) ? $throwRuntimeError("index out of range") : x$3.$array[x$3.$offset + u])), ((x$2 < 0 || x$2 >= x$1.$length) ? $throwRuntimeError("index out of range") : x$1.$array[x$1.$offset + x$2])) === u); }; - Scanner.prototype.scanExponent = function(ch) { return this.$val.scanExponent(ch); }; - Scanner.Ptr.prototype.scanNumber = function(ch) { - var s, hasMantissa, has8or9; - s = this; - if (ch === 48) { - ch = s.next(); - if ((ch === 120) || (ch === 88)) { - ch = s.next(); - hasMantissa = false; - while (digitVal(ch) < 16) { - ch = s.next(); - hasMantissa = true; - } - if (!hasMantissa) { - s.error("illegal hexadecimal number"); - } - } else { - has8or9 = false; - while (isDecimal(ch)) { - if (ch > 55) { - has8or9 = true; - } - ch = s.next(); - } - if (!((((s.Mode & 16) >>> 0) === 0)) && ((ch === 46) || (ch === 101) || (ch === 69))) { - ch = s.scanFraction(ch); - ch = s.scanExponent(ch); - return [-4, ch]; - } - if (has8or9) { - s.error("illegal octal number"); - } - } - return [-3, ch]; - } - ch = s.scanMantissa(ch); - if (!((((s.Mode & 16) >>> 0) === 0)) && ((ch === 46) || (ch === 101) || (ch === 69))) { - ch = s.scanFraction(ch); - ch = s.scanExponent(ch); - return [-4, ch]; + queueOnePass.prototype.contains = function(u) { return this.$val.contains(u); }; + queueOnePass.Ptr.prototype.insert = function(u) { + var q; + q = this; + if (!q.contains(u)) { + q.insertNew(u); } - return [-3, ch]; }; - Scanner.prototype.scanNumber = function(ch) { return this.$val.scanNumber(ch); }; - Scanner.Ptr.prototype.scanDigits = function(ch, base, n) { - var s; - s = this; - while (n > 0 && digitVal(ch) < base) { - ch = s.next(); - n = n - (1) >> 0; - } - if (n > 0) { - s.error("illegal char escape"); + queueOnePass.prototype.insert = function(u) { return this.$val.insert(u); }; + queueOnePass.Ptr.prototype.insertNew = function(u) { + var q, x, x$1, x$2; + q = this; + if (u >= (q.sparse.$length >>> 0)) { + return; } - return ch; + (x = q.sparse, (u < 0 || u >= x.$length) ? $throwRuntimeError("index out of range") : x.$array[x.$offset + u] = q.size); + (x$1 = q.dense, x$2 = q.size, (x$2 < 0 || x$2 >= x$1.$length) ? $throwRuntimeError("index out of range") : x$1.$array[x$1.$offset + x$2] = u); + q.size = q.size + (1) >>> 0; }; - Scanner.prototype.scanDigits = function(ch, base, n) { return this.$val.scanDigits(ch, base, n); }; - Scanner.Ptr.prototype.scanEscape = function(quote) { - var s, ch, _ref; - s = this; - ch = s.next(); - _ref = ch; - if (_ref === 97 || _ref === 98 || _ref === 102 || _ref === 110 || _ref === 114 || _ref === 116 || _ref === 118 || _ref === 92 || _ref === quote) { - ch = s.next(); - } else if (_ref === 48 || _ref === 49 || _ref === 50 || _ref === 51 || _ref === 52 || _ref === 53 || _ref === 54 || _ref === 55) { - ch = s.scanDigits(ch, 8, 3); - } else if (_ref === 120) { - ch = s.scanDigits(s.next(), 16, 2); - } else if (_ref === 117) { - ch = s.scanDigits(s.next(), 16, 4); - } else if (_ref === 85) { - ch = s.scanDigits(s.next(), 16, 8); - } else { - s.error("illegal char escape"); - } - return ch; + queueOnePass.prototype.insertNew = function(u) { return this.$val.insertNew(u); }; + newQueue = function(size) { + var q = ($ptrType(queueOnePass)).nil; + q = new queueOnePass.Ptr(($sliceType($Uint32)).make(size), ($sliceType($Uint32)).make(size), 0, 0); + return q; }; - Scanner.prototype.scanEscape = function(quote) { return this.$val.scanEscape(quote); }; - Scanner.Ptr.prototype.scanString = function(quote) { - var n = 0, s, ch; - s = this; - ch = s.next(); - while (!((ch === quote))) { - if ((ch === 10) || ch < 0) { - s.error("literal not terminated"); - return n; + mergeRuneSets = function(leftRunes, rightRunes, leftPC, rightPC) { + var $deferred = [], $err = null, leftLen, rightLen, _tmp, _tmp$1, lx, rx, merged, next, ok, ix, extend, x, x$1; + /* */ try { $deferFrames.push($deferred); + leftLen = leftRunes.$get().$length; + rightLen = rightRunes.$get().$length; + if (!(((leftLen & 1) === 0)) || !(((rightLen & 1) === 0))) { + $panic(new $String("mergeRuneSets odd length []rune")); + } + _tmp = 0; _tmp$1 = 0; lx = _tmp; rx = _tmp$1; + merged = ($sliceType($Int32)).make(0); + next = ($sliceType($Uint32)).make(0); + ok = true; + $deferred.push([(function() { + if (!ok) { + merged = ($sliceType($Int32)).nil; + next = ($sliceType($Uint32)).nil; } - if (ch === 92) { - ch = s.scanEscape(quote); + }), []]); + ix = -1; + extend = (function(newLow, newArray, pc) { + var x, x$1, x$2, x$3, x$4, x$5, _lhs; + if (ix > 0 && (x = newArray.$get(), x$1 = newLow.$get(), ((x$1 < 0 || x$1 >= x.$length) ? $throwRuntimeError("index out of range") : x.$array[x.$offset + x$1])) <= ((ix < 0 || ix >= merged.$length) ? $throwRuntimeError("index out of range") : merged.$array[merged.$offset + ix])) { + return false; + } + merged = $append(merged, (x$2 = newArray.$get(), x$3 = newLow.$get(), ((x$3 < 0 || x$3 >= x$2.$length) ? $throwRuntimeError("index out of range") : x$2.$array[x$2.$offset + x$3])), (x$4 = newArray.$get(), x$5 = newLow.$get() + 1 >> 0, ((x$5 < 0 || x$5 >= x$4.$length) ? $throwRuntimeError("index out of range") : x$4.$array[x$4.$offset + x$5]))); + _lhs = newLow; _lhs.$set(_lhs.$get() + (2) >> 0); + ix = ix + (2) >> 0; + next = $append(next, pc); + return true; + }); + while (lx < leftLen || rx < rightLen) { + if (rx >= rightLen) { + ok = extend(new ($ptrType($Int))(function() { return lx; }, function($v) { lx = $v; }), leftRunes, leftPC); + } else if (lx >= leftLen) { + ok = extend(new ($ptrType($Int))(function() { return rx; }, function($v) { rx = $v; }), rightRunes, rightPC); + } else if ((x = rightRunes.$get(), ((rx < 0 || rx >= x.$length) ? $throwRuntimeError("index out of range") : x.$array[x.$offset + rx])) < (x$1 = leftRunes.$get(), ((lx < 0 || lx >= x$1.$length) ? $throwRuntimeError("index out of range") : x$1.$array[x$1.$offset + lx]))) { + ok = extend(new ($ptrType($Int))(function() { return rx; }, function($v) { rx = $v; }), rightRunes, rightPC); } else { - ch = s.next(); + ok = extend(new ($ptrType($Int))(function() { return lx; }, function($v) { lx = $v; }), leftRunes, leftPC); } - n = n + (1) >> 0; - } - return n; - }; - Scanner.prototype.scanString = function(quote) { return this.$val.scanString(quote); }; - Scanner.Ptr.prototype.scanRawString = function() { - var s, ch; - s = this; - ch = s.next(); - while (!((ch === 96))) { - if (ch < 0) { - s.error("literal not terminated"); - return; + if (!ok) { + return [noRune, noNext]; } - ch = s.next(); - } - }; - Scanner.prototype.scanRawString = function() { return this.$val.scanRawString(); }; - Scanner.Ptr.prototype.scanChar = function() { - var s; - s = this; - if (!((s.scanString(39) === 1))) { - s.error("illegal char literal"); } + return [merged, next]; + /* */ } catch(err) { $err = err; return [($sliceType($Int32)).nil, ($sliceType($Uint32)).nil]; } finally { $deferFrames.pop(); $callDeferred($deferred, $err); } }; - Scanner.prototype.scanChar = function() { return this.$val.scanChar(); }; - Scanner.Ptr.prototype.scanComment = function(ch) { - var s, ch0; - s = this; - if (ch === 47) { - ch = s.next(); - while (!((ch === 10)) && ch >= 0) { - ch = s.next(); - } - return ch; - } - ch = s.next(); - while (true) { - if (ch < 0) { - s.error("comment not terminated"); - break; - } - ch0 = ch; - ch = s.next(); - if ((ch0 === 42) && (ch === 47)) { - ch = s.next(); - break; + cleanupOnePass = function(prog, original) { + var _ref, _i, ix, instOriginal, _ref$1, x, x$1, x$2; + _ref = original.Inst; + _i = 0; + while (_i < _ref.$length) { + ix = _i; + instOriginal = new syntax.Inst.Ptr(); $copy(instOriginal, ((_i < 0 || _i >= _ref.$length) ? $throwRuntimeError("index out of range") : _ref.$array[_ref.$offset + _i]), syntax.Inst); + _ref$1 = instOriginal.Op; + if (_ref$1 === 0 || _ref$1 === 1 || _ref$1 === 7) { + } else if (_ref$1 === 2 || _ref$1 === 3 || _ref$1 === 6 || _ref$1 === 4 || _ref$1 === 5) { + (x = prog.Inst, ((ix < 0 || ix >= x.$length) ? $throwRuntimeError("index out of range") : x.$array[x.$offset + ix])).Next = ($sliceType($Uint32)).nil; + } else if (_ref$1 === 8 || _ref$1 === 9 || _ref$1 === 10) { + (x$1 = prog.Inst, ((ix < 0 || ix >= x$1.$length) ? $throwRuntimeError("index out of range") : x$1.$array[x$1.$offset + ix])).Next = ($sliceType($Uint32)).nil; + $copy((x$2 = prog.Inst, ((ix < 0 || ix >= x$2.$length) ? $throwRuntimeError("index out of range") : x$2.$array[x$2.$offset + ix])), new onePassInst.Ptr(instOriginal, ($sliceType($Uint32)).nil), onePassInst); } + _i++; } - return ch; }; - Scanner.prototype.scanComment = function(ch) { return this.$val.scanComment(ch); }; - Scanner.Ptr.prototype.Scan = function() { - var $this = this, $args = arguments, $s = 0, s, ch, x, x$1, x$2, tok, _tuple, _ref; - /* */ while (true) { switch ($s) { case 0: - s = $this; - ch = s.Peek(); - s.tokPos = -1; - s.Position.Line = 0; - /* redo: */ case 1: - /* while (!((x = (x$1 = s.Whitespace, x$2 = $shiftLeft64(new $Uint64(0, 1), (ch >>> 0)), new $Uint64(x$1.$high & x$2.$high, (x$1.$low & x$2.$low) >>> 0)), (x.$high === 0 && x.$low === 0)))) { */ case 2: if(!(!((x = (x$1 = s.Whitespace, x$2 = $shiftLeft64(new $Uint64(0, 1), (ch >>> 0)), new $Uint64(x$1.$high & x$2.$high, (x$1.$low & x$2.$low) >>> 0)), (x.$high === 0 && x.$low === 0))))) { $s = 3; continue; } - ch = s.next(); - /* } */ $s = 2; continue; case 3: - s.tokBuf.Reset(); - s.tokPos = s.srcPos - s.lastCharLen >> 0; - s.Position.Offset = s.srcBufOffset + s.tokPos >> 0; - if (s.column > 0) { - s.Position.Line = s.line; - s.Position.Column = s.column; - } else { - s.Position.Line = s.line - 1 >> 0; - s.Position.Column = s.lastLineLen; + onePassCopy = function(prog) { + var p, _ref, _i, inst, _ref$1, _i$1, p_A_Alt, pc, _ref$2, x, x$1, p_A_Other, x$2, x$3, x$4, instAlt, _tmp, _tmp$1, x$5, x$6, x$7, x$8, instOther, x$9, x$10, p_B_Alt, x$11, x$12, p_B_Other, patch, _tmp$2, _tmp$3; + p = new onePassProg.Ptr(($sliceType(onePassInst)).nil, prog.Start, prog.NumCap); + _ref = prog.Inst; + _i = 0; + while (_i < _ref.$length) { + inst = new syntax.Inst.Ptr(); $copy(inst, ((_i < 0 || _i >= _ref.$length) ? $throwRuntimeError("index out of range") : _ref.$array[_ref.$offset + _i]), syntax.Inst); + p.Inst = $append(p.Inst, new onePassInst.Ptr(inst, ($sliceType($Uint32)).nil)); + _i++; } - tok = ch; - /* if (unicode.IsLetter(ch) || (ch === 95)) { */ if (unicode.IsLetter(ch) || (ch === 95)) {} else if (isDecimal(ch)) { $s = 4; continue; } else { $s = 5; continue; } - if (!((((s.Mode & 4) >>> 0) === 0))) { - tok = -2; - ch = s.scanIdentifier(); - } else { - ch = s.next(); - } - /* } else if (isDecimal(ch)) { */ $s = 6; continue; case 4: - if (!((((s.Mode & 24) >>> 0) === 0))) { - _tuple = s.scanNumber(ch); tok = _tuple[0]; ch = _tuple[1]; - } else { - ch = s.next(); - } - /* } else { */ $s = 6; continue; case 5: - _ref = ch; - /* if (_ref === 34) { */ if (_ref === 34) {} else if (_ref === 39) { $s = 7; continue; } else if (_ref === 46) { $s = 8; continue; } else if (_ref === 47) { $s = 9; continue; } else if (_ref === 96) { $s = 10; continue; } else { $s = 11; continue; } - if (!((((s.Mode & 64) >>> 0) === 0))) { - s.scanString(34); - tok = -6; + _ref$1 = p.Inst; + _i$1 = 0; + while (_i$1 < _ref$1.$length) { + p_A_Alt = [undefined]; + pc = _i$1; + _ref$2 = (x = p.Inst, ((pc < 0 || pc >= x.$length) ? $throwRuntimeError("index out of range") : x.$array[x.$offset + pc])).Inst.Op; + if (_ref$2 === 0 || _ref$2 === 1) { + p_A_Other = new ($ptrType($Uint32))(function() { return this.$target.Inst.Out; }, function($v) { this.$target.Inst.Out = $v; }, (x$1 = p.Inst, ((pc < 0 || pc >= x$1.$length) ? $throwRuntimeError("index out of range") : x$1.$array[x$1.$offset + pc]))); + p_A_Alt[0] = new ($ptrType($Uint32))(function() { return this.$target.Inst.Arg; }, function($v) { this.$target.Inst.Arg = $v; }, (x$2 = p.Inst, ((pc < 0 || pc >= x$2.$length) ? $throwRuntimeError("index out of range") : x$2.$array[x$2.$offset + pc]))); + instAlt = new onePassInst.Ptr(); $copy(instAlt, (x$3 = p.Inst, x$4 = p_A_Alt[0].$get(), ((x$4 < 0 || x$4 >= x$3.$length) ? $throwRuntimeError("index out of range") : x$3.$array[x$3.$offset + x$4])), onePassInst); + if (!((instAlt.Inst.Op === 0) || (instAlt.Inst.Op === 1))) { + _tmp = p_A_Other; _tmp$1 = p_A_Alt[0]; p_A_Alt[0] = _tmp; p_A_Other = _tmp$1; + $copy(instAlt, (x$5 = p.Inst, x$6 = p_A_Alt[0].$get(), ((x$6 < 0 || x$6 >= x$5.$length) ? $throwRuntimeError("index out of range") : x$5.$array[x$5.$offset + x$6])), onePassInst); + if (!((instAlt.Inst.Op === 0) || (instAlt.Inst.Op === 1))) { + _i$1++; + continue; + } } - ch = s.next(); - /* } else if (_ref === 39) { */ $s = 12; continue; case 7: - if (!((((s.Mode & 32) >>> 0) === 0))) { - s.scanChar(); - tok = -5; + instOther = new onePassInst.Ptr(); $copy(instOther, (x$7 = p.Inst, x$8 = p_A_Other.$get(), ((x$8 < 0 || x$8 >= x$7.$length) ? $throwRuntimeError("index out of range") : x$7.$array[x$7.$offset + x$8])), onePassInst); + if ((instOther.Inst.Op === 0) || (instOther.Inst.Op === 1)) { + _i$1++; + continue; } - ch = s.next(); - /* } else if (_ref === 46) { */ $s = 12; continue; case 8: - ch = s.next(); - if (isDecimal(ch) && !((((s.Mode & 16) >>> 0) === 0))) { - tok = -4; - ch = s.scanMantissa(ch); - ch = s.scanExponent(ch); + p_B_Alt = new ($ptrType($Uint32))(function() { return this.$target.Inst.Out; }, function($v) { this.$target.Inst.Out = $v; }, (x$9 = p.Inst, x$10 = p_A_Alt[0].$get(), ((x$10 < 0 || x$10 >= x$9.$length) ? $throwRuntimeError("index out of range") : x$9.$array[x$9.$offset + x$10]))); + p_B_Other = new ($ptrType($Uint32))(function() { return this.$target.Inst.Arg; }, function($v) { this.$target.Inst.Arg = $v; }, (x$11 = p.Inst, x$12 = p_A_Alt[0].$get(), ((x$12 < 0 || x$12 >= x$11.$length) ? $throwRuntimeError("index out of range") : x$11.$array[x$11.$offset + x$12]))); + patch = false; + if (instAlt.Inst.Out === (pc >>> 0)) { + patch = true; + } else if (instAlt.Inst.Arg === (pc >>> 0)) { + patch = true; + _tmp$2 = p_B_Other; _tmp$3 = p_B_Alt; p_B_Alt = _tmp$2; p_B_Other = _tmp$3; } - /* } else if (_ref === 47) { */ $s = 12; continue; case 9: - ch = s.next(); - /* if (((ch === 47) || (ch === 42)) && !((((s.Mode & 256) >>> 0) === 0))) { */ if (((ch === 47) || (ch === 42)) && !((((s.Mode & 256) >>> 0) === 0))) {} else { $s = 13; continue; } - /* if (!((((s.Mode & 512) >>> 0) === 0))) { */ if (!((((s.Mode & 512) >>> 0) === 0))) {} else { $s = 14; continue; } - s.tokPos = -1; - ch = s.scanComment(ch); - /* goto redo */ $s = 1; continue; - /* } */ case 14: - ch = s.scanComment(ch); - tok = -8; - /* } */ case 13: - /* } else if (_ref === 96) { */ $s = 12; continue; case 10: - if (!((((s.Mode & 128) >>> 0) === 0))) { - s.scanRawString(); - tok = -6; + if (patch) { + p_B_Alt.$set(p_A_Other.$get()); } - ch = s.next(); - /* } else { */ $s = 12; continue; case 11: - ch = s.next(); - /* } */ case 12: - /* } */ case 6: - s.tokEnd = s.srcPos - s.lastCharLen >> 0; - s.ch = ch; - return tok; - /* */ case -1: } return; } - }; - Scanner.prototype.Scan = function() { return this.$val.Scan(); }; - Scanner.Ptr.prototype.Pos = function() { - var pos = new Position.Ptr(), s; - s = this; - pos.Filename = s.Position.Filename; - pos.Offset = (s.srcBufOffset + s.srcPos >> 0) - s.lastCharLen >> 0; - if (s.column > 0) { - pos.Line = s.line; - pos.Column = s.column; - } else if (s.lastLineLen > 0) { - pos.Line = s.line - 1 >> 0; - pos.Column = s.lastLineLen; - } else { - pos.Line = 1; - pos.Column = 1; + if (p_A_Other.$get() === p_B_Alt.$get()) { + p_A_Alt[0].$set(p_B_Other.$get()); + } + } else { + _i$1++; + continue; + } + _i$1++; } - return pos; + return p; }; - Scanner.prototype.Pos = function() { return this.$val.Pos(); }; - Scanner.Ptr.prototype.TokenText = function() { - var s; - s = this; - if (s.tokPos < 0) { - return ""; - } - if (s.tokEnd < 0) { - s.tokEnd = s.tokPos; - } - if (s.tokBuf.Len() === 0) { - return $bytesToString($subslice(new ($sliceType($Uint8))(s.srcBuf), s.tokPos, s.tokEnd)); - } - s.tokBuf.Write($subslice(new ($sliceType($Uint8))(s.srcBuf), s.tokPos, s.tokEnd)); - s.tokPos = s.tokEnd; - return s.tokBuf.String(); + runeSlice.prototype.Len = function() { + var p; + p = this; + return p.$length; }; - Scanner.prototype.TokenText = function() { return this.$val.TokenText(); }; - $pkg.$init = function() { - Position.methods = [["String", "String", "", $funcType([], [$String], false), -1]]; - ($ptrType(Position)).methods = [["IsValid", "IsValid", "", $funcType([], [$Bool], false), -1], ["String", "String", "", $funcType([], [$String], false), -1]]; - Position.init([["Filename", "Filename", "", $String, ""], ["Offset", "Offset", "", $Int, ""], ["Line", "Line", "", $Int, ""], ["Column", "Column", "", $Int, ""]]); - Scanner.methods = [["String", "String", "", $funcType([], [$String], false), 17]]; - ($ptrType(Scanner)).methods = [["Init", "Init", "", $funcType([io.Reader], [($ptrType(Scanner))], false), -1], ["IsValid", "IsValid", "", $funcType([], [$Bool], false), 17], ["Next", "Next", "", $funcType([], [$Int32], false), -1], ["Peek", "Peek", "", $funcType([], [$Int32], false), -1], ["Pos", "Pos", "", $funcType([], [Position], false), -1], ["Scan", "Scan", "", $funcType([], [$Int32], false), -1], ["String", "String", "", $funcType([], [$String], false), 17], ["TokenText", "TokenText", "", $funcType([], [$String], false), -1], ["error", "error", "text/scanner", $funcType([$String], [], false), -1], ["next", "next", "text/scanner", $funcType([], [$Int32], false), -1], ["scanChar", "scanChar", "text/scanner", $funcType([], [], false), -1], ["scanComment", "scanComment", "text/scanner", $funcType([$Int32], [$Int32], false), -1], ["scanDigits", "scanDigits", "text/scanner", $funcType([$Int32, $Int, $Int], [$Int32], false), -1], ["scanEscape", "scanEscape", "text/scanner", $funcType([$Int32], [$Int32], false), -1], ["scanExponent", "scanExponent", "text/scanner", $funcType([$Int32], [$Int32], false), -1], ["scanFraction", "scanFraction", "text/scanner", $funcType([$Int32], [$Int32], false), -1], ["scanIdentifier", "scanIdentifier", "text/scanner", $funcType([], [$Int32], false), -1], ["scanMantissa", "scanMantissa", "text/scanner", $funcType([$Int32], [$Int32], false), -1], ["scanNumber", "scanNumber", "text/scanner", $funcType([$Int32], [$Int32, $Int32], false), -1], ["scanRawString", "scanRawString", "text/scanner", $funcType([], [], false), -1], ["scanString", "scanString", "text/scanner", $funcType([$Int32], [$Int], false), -1]]; - Scanner.init([["src", "src", "text/scanner", io.Reader, ""], ["srcBuf", "srcBuf", "text/scanner", ($arrayType($Uint8, 1025)), ""], ["srcPos", "srcPos", "text/scanner", $Int, ""], ["srcEnd", "srcEnd", "text/scanner", $Int, ""], ["srcBufOffset", "srcBufOffset", "text/scanner", $Int, ""], ["line", "line", "text/scanner", $Int, ""], ["column", "column", "text/scanner", $Int, ""], ["lastLineLen", "lastLineLen", "text/scanner", $Int, ""], ["lastCharLen", "lastCharLen", "text/scanner", $Int, ""], ["tokBuf", "tokBuf", "text/scanner", bytes.Buffer, ""], ["tokPos", "tokPos", "text/scanner", $Int, ""], ["tokEnd", "tokEnd", "text/scanner", $Int, ""], ["ch", "ch", "text/scanner", $Int32, ""], ["Error", "Error", "", ($funcType([($ptrType(Scanner)), $String], [], false)), ""], ["ErrorCount", "ErrorCount", "", $Int, ""], ["Mode", "Mode", "", $Uint, ""], ["Whitespace", "Whitespace", "", $Uint64, ""], ["Position", "", "", Position, ""]]); - tokenString = (_map = new $Map(), _key = -1, _map[_key] = { k: _key, v: "EOF" }, _key = -2, _map[_key] = { k: _key, v: "Ident" }, _key = -3, _map[_key] = { k: _key, v: "Int" }, _key = -4, _map[_key] = { k: _key, v: "Float" }, _key = -5, _map[_key] = { k: _key, v: "Char" }, _key = -6, _map[_key] = { k: _key, v: "String" }, _key = -7, _map[_key] = { k: _key, v: "RawString" }, _key = -8, _map[_key] = { k: _key, v: "Comment" }, _map); + $ptrType(runeSlice).prototype.Len = function() { return this.$get().Len(); }; + runeSlice.prototype.Less = function(i, j) { + var p; + p = this; + return ((i < 0 || i >= p.$length) ? $throwRuntimeError("index out of range") : p.$array[p.$offset + i]) < ((j < 0 || j >= p.$length) ? $throwRuntimeError("index out of range") : p.$array[p.$offset + j]); }; - return $pkg; -})(); -$packages["code.google.com/p/go.tools/go/gcimporter"] = (function() { - var $pkg = {}, bufio = $packages["bufio"], errors = $packages["errors"], fmt = $packages["fmt"], io = $packages["io"], strconv = $packages["strconv"], strings = $packages["strings"], build = $packages["go/build"], token = $packages["go/token"], os = $packages["os"], filepath = $packages["path/filepath"], scanner = $packages["text/scanner"], exact = $packages["code.google.com/p/go.tools/go/exact"], types = $packages["code.google.com/p/go.tools/go/types"], parser, importError, pkgExts, readGopackHeader, FindExportData, init, FindPkg, ImportData, Import, declTypeName, deref; - parser = $pkg.parser = $newType(0, "Struct", "gcimporter.parser", "parser", "code.google.com/p/go.tools/go/gcimporter", function(scanner_, tok_, lit_, id_, imports_) { - this.$val = this; - this.scanner = scanner_ !== undefined ? scanner_ : new scanner.Scanner.Ptr(); - this.tok = tok_ !== undefined ? tok_ : 0; - this.lit = lit_ !== undefined ? lit_ : ""; - this.id = id_ !== undefined ? id_ : ""; - this.imports = imports_ !== undefined ? imports_ : false; - }); - importError = $pkg.importError = $newType(0, "Struct", "gcimporter.importError", "importError", "code.google.com/p/go.tools/go/gcimporter", function(pos_, err_) { - this.$val = this; - this.pos = pos_ !== undefined ? pos_ : new scanner.Position.Ptr(); - this.err = err_ !== undefined ? err_ : $ifaceNil; - }); - readGopackHeader = function(r) { - var name = "", size = 0, err = $ifaceNil, hdr, _tuple, s, _tuple$1, x, x$1; - hdr = ($sliceType($Uint8)).make(60); - _tuple = io.ReadFull(r, hdr); err = _tuple[1]; - if (!($interfaceIsEqual(err, $ifaceNil))) { - return [name, size, err]; - } - s = strings.TrimSpace($bytesToString($subslice($subslice(hdr, 48), 0, 10))); - _tuple$1 = strconv.Atoi(s); size = _tuple$1[0]; err = _tuple$1[1]; - if (!($interfaceIsEqual(err, $ifaceNil)) || !(((x = hdr.$length - 2 >> 0, ((x < 0 || x >= hdr.$length) ? $throwRuntimeError("index out of range") : hdr.$array[hdr.$offset + x])) === 96)) || !(((x$1 = hdr.$length - 1 >> 0, ((x$1 < 0 || x$1 >= hdr.$length) ? $throwRuntimeError("index out of range") : hdr.$array[hdr.$offset + x$1])) === 10))) { - err = errors.New("invalid archive header"); - return [name, size, err]; - } - name = strings.TrimSpace($bytesToString($subslice(hdr, 0, 16))); - return [name, size, err]; + $ptrType(runeSlice).prototype.Less = function(i, j) { return this.$get().Less(i, j); }; + runeSlice.prototype.Swap = function(i, j) { + var p, _tmp, _tmp$1; + p = this; + _tmp = ((j < 0 || j >= p.$length) ? $throwRuntimeError("index out of range") : p.$array[p.$offset + j]); _tmp$1 = ((i < 0 || i >= p.$length) ? $throwRuntimeError("index out of range") : p.$array[p.$offset + i]); (i < 0 || i >= p.$length) ? $throwRuntimeError("index out of range") : p.$array[p.$offset + i] = _tmp; (j < 0 || j >= p.$length) ? $throwRuntimeError("index out of range") : p.$array[p.$offset + j] = _tmp$1; }; - FindExportData = $pkg.FindExportData = function(r) { - var err = $ifaceNil, _tuple, line, name, size, _tuple$1, tmp, n, _tuple$2, _tuple$3, _tuple$4, _tuple$5; - _tuple = r.ReadSlice(10); line = _tuple[0]; err = _tuple[1]; - if (!($interfaceIsEqual(err, $ifaceNil))) { - return err; + $ptrType(runeSlice).prototype.Swap = function(i, j) { return this.$get().Swap(i, j); }; + runeSlice.prototype.Sort = function() { + var p; + p = this; + sort.Sort(p); + }; + $ptrType(runeSlice).prototype.Sort = function() { return this.$get().Sort(); }; + makeOnePass = function(p) { + var instQueue, visitQueue, build, check, onePassRunes, m, pc, x, inst, _ref, _ref$1, _i, i, x$1; + if (p.Inst.$length >= 1000) { + return notOnePass; } - if ($bytesToString(line) === "!\n") { - name = ""; - size = 0; - _tuple$1 = readGopackHeader(r); name = _tuple$1[0]; size = _tuple$1[1]; err = _tuple$1[2]; - if (!($interfaceIsEqual(err, $ifaceNil))) { - return err; + instQueue = newQueue(p.Inst.$length); + visitQueue = newQueue(p.Inst.$length); + build = $throwNilPointerError; + check = $throwNilPointerError; + onePassRunes = ($sliceType(($sliceType($Int32)))).make(p.Inst.$length); + build = (function(pc, q) { + var x, inst, _ref; + if (q.contains(pc)) { + return; } - if (name === "__.SYMDEF" || name === "__.GOSYMDEF") { - tmp = ($sliceType($Uint8)).make(4096); - while (size > 0) { - n = size; - if (n > 4096) { - n = 4096; + inst = new onePassInst.Ptr(); $copy(inst, (x = p.Inst, ((pc < 0 || pc >= x.$length) ? $throwRuntimeError("index out of range") : x.$array[x.$offset + pc])), onePassInst); + _ref = inst.Inst.Op; + if (_ref === 0 || _ref === 1) { + q.insert(inst.Inst.Out); + build(inst.Inst.Out, q); + q.insert(inst.Inst.Arg); + } else if (_ref === 4 || _ref === 5) { + } else { + q.insert(inst.Inst.Out); + } + }); + check = (function(pc, m) { + var ok = false, x, inst, _ref, _entry, matchOut, _entry$1, matchArg, _tmp, _tmp$1, _tmp$2, _tmp$3, _key, _tuple, x$1, x$2, x$3, x$4, x$5, _entry$2, _key$1, x$6, _q, i, _entry$3, _key$2, x$7, _q$1, i$1, _key$3, _key$4, runes, x$8, r0, r1, _q$2, i$2, _key$5, runes$1, x$9, r0$1, r1$1, x$10, x$11, _q$3, i$3, _key$6, _key$7, _q$4, i$4; + ok = true; + inst = (x = p.Inst, ((pc < 0 || pc >= x.$length) ? $throwRuntimeError("index out of range") : x.$array[x.$offset + pc])); + if (visitQueue.contains(pc)) { + return ok; + } + visitQueue.insert(pc); + _ref = inst.Inst.Op; + switch (0) { default: if (_ref === 0 || _ref === 1) { + ok = check(inst.Inst.Out, m) && check(inst.Inst.Arg, m); + matchOut = (_entry = m[inst.Inst.Out], _entry !== undefined ? _entry.v : false); + matchArg = (_entry$1 = m[inst.Inst.Arg], _entry$1 !== undefined ? _entry$1.v : false); + if (matchOut && matchArg) { + ok = false; + break; + } + if (matchArg) { + _tmp = inst.Inst.Arg; _tmp$1 = inst.Inst.Out; inst.Inst.Out = _tmp; inst.Inst.Arg = _tmp$1; + _tmp$2 = matchArg; _tmp$3 = matchOut; matchOut = _tmp$2; matchArg = _tmp$3; + } + if (matchOut) { + _key = pc; (m || $throwRuntimeError("assignment to entry in nil map"))[_key] = { k: _key, v: true }; + inst.Inst.Op = 1; + } + _tuple = mergeRuneSets(new ($ptrType(($sliceType($Int32))))(function() { return (x$2 = inst.Inst.Out, ((x$2 < 0 || x$2 >= this.$target.$length) ? $throwRuntimeError("index out of range") : this.$target.$array[this.$target.$offset + x$2])); }, function($v) { (x$1 = inst.Inst.Out, (x$1 < 0 || x$1 >= this.$target.$length) ? $throwRuntimeError("index out of range") : this.$target.$array[this.$target.$offset + x$1] = $v); }, onePassRunes), new ($ptrType(($sliceType($Int32))))(function() { return (x$4 = inst.Inst.Arg, ((x$4 < 0 || x$4 >= this.$target.$length) ? $throwRuntimeError("index out of range") : this.$target.$array[this.$target.$offset + x$4])); }, function($v) { (x$3 = inst.Inst.Arg, (x$3 < 0 || x$3 >= this.$target.$length) ? $throwRuntimeError("index out of range") : this.$target.$array[this.$target.$offset + x$3] = $v); }, onePassRunes), inst.Inst.Out, inst.Inst.Arg); (pc < 0 || pc >= onePassRunes.$length) ? $throwRuntimeError("index out of range") : onePassRunes.$array[onePassRunes.$offset + pc] = _tuple[0]; inst.Next = _tuple[1]; + if (inst.Next.$length > 0 && ((x$5 = inst.Next, ((0 < 0 || 0 >= x$5.$length) ? $throwRuntimeError("index out of range") : x$5.$array[x$5.$offset + 0])) === 4294967295)) { + ok = false; + break; + } + } else if (_ref === 2 || _ref === 6) { + ok = check(inst.Inst.Out, m); + _key$1 = pc; (m || $throwRuntimeError("assignment to entry in nil map"))[_key$1] = { k: _key$1, v: (_entry$2 = m[inst.Inst.Out], _entry$2 !== undefined ? _entry$2.v : false) }; + (pc < 0 || pc >= onePassRunes.$length) ? $throwRuntimeError("index out of range") : onePassRunes.$array[onePassRunes.$offset + pc] = $appendSlice(new ($sliceType($Int32))([]), (x$6 = inst.Inst.Out, ((x$6 < 0 || x$6 >= onePassRunes.$length) ? $throwRuntimeError("index out of range") : onePassRunes.$array[onePassRunes.$offset + x$6]))); + inst.Next = new ($sliceType($Uint32))([]); + i = (_q = ((pc < 0 || pc >= onePassRunes.$length) ? $throwRuntimeError("index out of range") : onePassRunes.$array[onePassRunes.$offset + pc]).$length / 2, (_q === _q && _q !== 1/0 && _q !== -1/0) ? _q >> 0 : $throwRuntimeError("integer divide by zero")); + while (i >= 0) { + inst.Next = $append(inst.Next, inst.Inst.Out); + i = i - (1) >> 0; + } + } else if (_ref === 3) { + ok = check(inst.Inst.Out, m); + _key$2 = pc; (m || $throwRuntimeError("assignment to entry in nil map"))[_key$2] = { k: _key$2, v: (_entry$3 = m[inst.Inst.Out], _entry$3 !== undefined ? _entry$3.v : false) }; + (pc < 0 || pc >= onePassRunes.$length) ? $throwRuntimeError("index out of range") : onePassRunes.$array[onePassRunes.$offset + pc] = $appendSlice(new ($sliceType($Int32))([]), (x$7 = inst.Inst.Out, ((x$7 < 0 || x$7 >= onePassRunes.$length) ? $throwRuntimeError("index out of range") : onePassRunes.$array[onePassRunes.$offset + x$7]))); + inst.Next = new ($sliceType($Uint32))([]); + i$1 = (_q$1 = ((pc < 0 || pc >= onePassRunes.$length) ? $throwRuntimeError("index out of range") : onePassRunes.$array[onePassRunes.$offset + pc]).$length / 2, (_q$1 === _q$1 && _q$1 !== 1/0 && _q$1 !== -1/0) ? _q$1 >> 0 : $throwRuntimeError("integer divide by zero")); + while (i$1 >= 0) { + inst.Next = $append(inst.Next, inst.Inst.Out); + i$1 = i$1 - (1) >> 0; + } + } else if (_ref === 4 || _ref === 5) { + _key$3 = pc; (m || $throwRuntimeError("assignment to entry in nil map"))[_key$3] = { k: _key$3, v: inst.Inst.Op === 4 }; + break; + } else if (_ref === 7) { + ok = check(inst.Inst.Out, m); + _key$4 = pc; (m || $throwRuntimeError("assignment to entry in nil map"))[_key$4] = { k: _key$4, v: false }; + if (inst.Next.$length > 0) { + break; + } + if (inst.Inst.Rune.$length === 0) { + (pc < 0 || pc >= onePassRunes.$length) ? $throwRuntimeError("index out of range") : onePassRunes.$array[onePassRunes.$offset + pc] = new ($sliceType($Int32))([]); + inst.Next = new ($sliceType($Uint32))([inst.Inst.Out]); + break; + } + runes = ($sliceType($Int32)).make(0); + if ((inst.Inst.Rune.$length === 1) && !(((((inst.Inst.Arg << 16 >>> 16) & 1) >>> 0) === 0))) { + r0 = (x$8 = inst.Inst.Rune, ((0 < 0 || 0 >= x$8.$length) ? $throwRuntimeError("index out of range") : x$8.$array[x$8.$offset + 0])); + runes = $append(runes, r0, r0); + r1 = unicode.SimpleFold(r0); + while (!((r1 === r0))) { + runes = $append(runes, r1, r1); + r1 = unicode.SimpleFold(r1); } - _tuple$2 = io.ReadFull(r, $subslice(tmp, 0, n)); err = _tuple$2[1]; - if (!($interfaceIsEqual(err, $ifaceNil))) { - return err; + sort.Sort($subslice(new runeSlice(runes.$array), runes.$offset, runes.$offset + runes.$length)); + } else { + runes = $appendSlice(runes, inst.Inst.Rune); + } + (pc < 0 || pc >= onePassRunes.$length) ? $throwRuntimeError("index out of range") : onePassRunes.$array[onePassRunes.$offset + pc] = runes; + inst.Next = new ($sliceType($Uint32))([]); + i$2 = (_q$2 = ((pc < 0 || pc >= onePassRunes.$length) ? $throwRuntimeError("index out of range") : onePassRunes.$array[onePassRunes.$offset + pc]).$length / 2, (_q$2 === _q$2 && _q$2 !== 1/0 && _q$2 !== -1/0) ? _q$2 >> 0 : $throwRuntimeError("integer divide by zero")); + while (i$2 >= 0) { + inst.Next = $append(inst.Next, inst.Inst.Out); + i$2 = i$2 - (1) >> 0; + } + inst.Inst.Op = 7; + } else if (_ref === 8) { + ok = check(inst.Inst.Out, m); + _key$5 = pc; (m || $throwRuntimeError("assignment to entry in nil map"))[_key$5] = { k: _key$5, v: false }; + if (inst.Next.$length > 0) { + break; + } + runes$1 = new ($sliceType($Int32))([]); + if (!(((((inst.Inst.Arg << 16 >>> 16) & 1) >>> 0) === 0))) { + r0$1 = (x$9 = inst.Inst.Rune, ((0 < 0 || 0 >= x$9.$length) ? $throwRuntimeError("index out of range") : x$9.$array[x$9.$offset + 0])); + runes$1 = $append(runes$1, r0$1, r0$1); + r1$1 = unicode.SimpleFold(r0$1); + while (!((r1$1 === r0$1))) { + runes$1 = $append(runes$1, r1$1, r1$1); + r1$1 = unicode.SimpleFold(r1$1); } - size = size - (n) >> 0; + sort.Sort($subslice(new runeSlice(runes$1.$array), runes$1.$offset, runes$1.$offset + runes$1.$length)); + } else { + runes$1 = $append(runes$1, (x$10 = inst.Inst.Rune, ((0 < 0 || 0 >= x$10.$length) ? $throwRuntimeError("index out of range") : x$10.$array[x$10.$offset + 0])), (x$11 = inst.Inst.Rune, ((0 < 0 || 0 >= x$11.$length) ? $throwRuntimeError("index out of range") : x$11.$array[x$11.$offset + 0]))); } - _tuple$3 = readGopackHeader(r); name = _tuple$3[0]; size = _tuple$3[1]; err = _tuple$3[2]; - if (!($interfaceIsEqual(err, $ifaceNil))) { - return err; + (pc < 0 || pc >= onePassRunes.$length) ? $throwRuntimeError("index out of range") : onePassRunes.$array[onePassRunes.$offset + pc] = runes$1; + inst.Next = new ($sliceType($Uint32))([]); + i$3 = (_q$3 = ((pc < 0 || pc >= onePassRunes.$length) ? $throwRuntimeError("index out of range") : onePassRunes.$array[onePassRunes.$offset + pc]).$length / 2, (_q$3 === _q$3 && _q$3 !== 1/0 && _q$3 !== -1/0) ? _q$3 >> 0 : $throwRuntimeError("integer divide by zero")); + while (i$3 >= 0) { + inst.Next = $append(inst.Next, inst.Inst.Out); + i$3 = i$3 - (1) >> 0; } + inst.Inst.Op = 7; + } else if (_ref === 9) { + ok = check(inst.Inst.Out, m); + _key$6 = pc; (m || $throwRuntimeError("assignment to entry in nil map"))[_key$6] = { k: _key$6, v: false }; + if (inst.Next.$length > 0) { + break; + } + (pc < 0 || pc >= onePassRunes.$length) ? $throwRuntimeError("index out of range") : onePassRunes.$array[onePassRunes.$offset + pc] = $appendSlice(new ($sliceType($Int32))([]), anyRune); + inst.Next = new ($sliceType($Uint32))([inst.Inst.Out]); + } else if (_ref === 10) { + ok = check(inst.Inst.Out, m); + _key$7 = pc; (m || $throwRuntimeError("assignment to entry in nil map"))[_key$7] = { k: _key$7, v: false }; + if (inst.Next.$length > 0) { + break; + } + (pc < 0 || pc >= onePassRunes.$length) ? $throwRuntimeError("index out of range") : onePassRunes.$array[onePassRunes.$offset + pc] = $appendSlice(new ($sliceType($Int32))([]), anyRuneNotNL); + inst.Next = new ($sliceType($Uint32))([]); + i$4 = (_q$4 = ((pc < 0 || pc >= onePassRunes.$length) ? $throwRuntimeError("index out of range") : onePassRunes.$array[onePassRunes.$offset + pc]).$length / 2, (_q$4 === _q$4 && _q$4 !== 1/0 && _q$4 !== -1/0) ? _q$4 >> 0 : $throwRuntimeError("integer divide by zero")); + while (i$4 >= 0) { + inst.Next = $append(inst.Next, inst.Inst.Out); + i$4 = i$4 - (1) >> 0; + } + } } + return ok; + }); + instQueue.clear(); + instQueue.insert((p.Start >>> 0)); + m = new $Map(); + while (!instQueue.empty()) { + pc = instQueue.next(); + inst = new onePassInst.Ptr(); $copy(inst, (x = p.Inst, ((pc < 0 || pc >= x.$length) ? $throwRuntimeError("index out of range") : x.$array[x.$offset + pc])), onePassInst); + visitQueue.clear(); + if (!check(pc, m)) { + p = notOnePass; + break; } - if (!(name === "__.PKGDEF")) { - err = errors.New("go archive is missing __.PKGDEF"); - return err; - } - _tuple$4 = r.ReadSlice(10); line = _tuple$4[0]; err = _tuple$4[1]; - if (!($interfaceIsEqual(err, $ifaceNil))) { - return err; + _ref = inst.Inst.Op; + if (_ref === 0 || _ref === 1) { + instQueue.insert(inst.Inst.Out); + instQueue.insert(inst.Inst.Arg); + } else if (_ref === 2 || _ref === 3 || _ref === 6) { + instQueue.insert(inst.Inst.Out); + } else if (_ref === 4) { + } else if (_ref === 5) { + } else if (_ref === 7 || _ref === 8 || _ref === 9 || _ref === 10) { + } else { } } - if (!strings.HasPrefix($bytesToString(line), "go object ")) { - err = errors.New("not a go object file"); - return err; - } - while (!((((0 < 0 || 0 >= line.$length) ? $throwRuntimeError("index out of range") : line.$array[line.$offset + 0]) === 36))) { - _tuple$5 = r.ReadSlice(10); line = _tuple$5[0]; err = _tuple$5[1]; - if (!($interfaceIsEqual(err, $ifaceNil))) { - return err; + if (!(p === notOnePass)) { + _ref$1 = p.Inst; + _i = 0; + while (_i < _ref$1.$length) { + i = _i; + (x$1 = p.Inst, ((i < 0 || i >= x$1.$length) ? $throwRuntimeError("index out of range") : x$1.$array[x$1.$offset + i])).Inst.Rune = ((i < 0 || i >= onePassRunes.$length) ? $throwRuntimeError("index out of range") : onePassRunes.$array[onePassRunes.$offset + i]); + _i++; } } - return err; - }; - init = function() { - types.DefaultImport = Import; + return p; }; - FindPkg = $pkg.FindPkg = function(path, srcDir) { - var filename = "", id = "", noext, _tuple, bp, _ref, _i, ext, _tuple$1, f, err; - if (path.length === 0) { - return [filename, id]; + compileOnePass = function(prog) { + var p = ($ptrType(onePassProg)).nil, x, x$1, x$2, x$3, _ref, _i, inst, x$4, x$5, opOut, _ref$1, x$6, x$7; + if (prog.Start === 0) { + p = notOnePass; + return p; } - id = path; - noext = ""; - if (build.IsLocalImport(path)) { - noext = filepath.Join(new ($sliceType($String))([srcDir, path])); - id = noext; - } else if (filepath.IsAbs(path)) { - noext = path; - } else { - _tuple = build.Import(path, srcDir, 3); bp = _tuple[0]; - if (bp.PkgObj === "") { - return [filename, id]; - } - noext = strings.TrimSuffix(bp.PkgObj, ".a"); + if (!(((x = prog.Inst, x$1 = prog.Start, ((x$1 < 0 || x$1 >= x.$length) ? $throwRuntimeError("index out of range") : x.$array[x.$offset + x$1])).Op === 3)) || !((((((x$2 = prog.Inst, x$3 = prog.Start, ((x$3 < 0 || x$3 >= x$2.$length) ? $throwRuntimeError("index out of range") : x$2.$array[x$2.$offset + x$3])).Arg << 24 >>> 24) & 4) >>> 0) === 4))) { + p = notOnePass; + return p; } - _ref = pkgExts; + _ref = prog.Inst; _i = 0; - while (_i < 4) { - ext = ((_i < 0 || _i >= _ref.length) ? $throwRuntimeError("index out of range") : _ref[_i]); - filename = noext + ext; - _tuple$1 = os.Stat(filename); f = _tuple$1[0]; err = _tuple$1[1]; - if ($interfaceIsEqual(err, $ifaceNil) && !f.IsDir()) { - return [filename, id]; + while (_i < _ref.$length) { + inst = new syntax.Inst.Ptr(); $copy(inst, ((_i < 0 || _i >= _ref.$length) ? $throwRuntimeError("index out of range") : _ref.$array[_ref.$offset + _i]), syntax.Inst); + opOut = (x$4 = prog.Inst, x$5 = inst.Out, ((x$5 < 0 || x$5 >= x$4.$length) ? $throwRuntimeError("index out of range") : x$4.$array[x$4.$offset + x$5])).Op; + _ref$1 = inst.Op; + if (_ref$1 === 0 || _ref$1 === 1) { + if ((opOut === 4) || ((x$6 = prog.Inst, x$7 = inst.Arg, ((x$7 < 0 || x$7 >= x$6.$length) ? $throwRuntimeError("index out of range") : x$6.$array[x$6.$offset + x$7])).Op === 4)) { + p = notOnePass; + return p; + } + } else if (_ref$1 === 3) { + if (opOut === 4) { + if ((((inst.Arg << 24 >>> 24) & 8) >>> 0) === 8) { + _i++; + continue; + } + p = notOnePass; + return p; + } + } else { + if (opOut === 4) { + p = notOnePass; + return p; + } } _i++; } - filename = ""; - return [filename, id]; + p = onePassCopy(prog); + p = makeOnePass(p); + if (!(p === notOnePass)) { + cleanupOnePass(p, prog); + } + p = p; + return p; }; - ImportData = $pkg.ImportData = function(imports, filename, id, data) { - var pkg = ($ptrType(types.Package)).nil, err = $ifaceNil, $deferred = [], $err = null, p; - /* */ try { $deferFrames.push($deferred); - $deferred.push([(function() { - var r, _ref; - _ref = $recover(); - if (_ref === $ifaceNil) { - r = _ref; - } else if ($assertType(_ref, importError, true)[1]) { - r = _ref.$val; - err = new r.constructor.Struct(r); - } else { - r = _ref; - $panic(r); - } - }), []]); - p = new parser.Ptr(); $copy(p, new parser.Ptr(), parser); - p.init(filename, id, data, imports); - pkg = p.parseExport(); - return [pkg, err]; - /* */ } catch(err) { $err = err; } finally { $deferFrames.pop(); $callDeferred($deferred, $err); return [pkg, err]; } + Regexp.Ptr.prototype.String = function() { + var re; + re = this; + return re.expr; }; - Import = $pkg.Import = function(imports, path) { - var pkg = ($ptrType(types.Package)).nil, err = $ifaceNil, $deferred = [], $err = null, _tmp, _tmp$1, srcDir, _tuple, _tuple$1, filename, id, _entry, _tuple$2, f, buf, _tuple$3; - /* */ try { $deferFrames.push($deferred); - if (path === "unsafe") { - _tmp = types.Unsafe; _tmp$1 = $ifaceNil; pkg = _tmp; err = _tmp$1; - return [pkg, err]; - } - srcDir = "."; - if (build.IsLocalImport(path)) { - _tuple = os.Getwd(); srcDir = _tuple[0]; err = _tuple[1]; - if (!($interfaceIsEqual(err, $ifaceNil))) { - return [pkg, err]; - } - } - _tuple$1 = FindPkg(path, srcDir); filename = _tuple$1[0]; id = _tuple$1[1]; - if (filename === "") { - err = fmt.Errorf("can't find import: %s", new ($sliceType($emptyInterface))([new $String(id)])); - return [pkg, err]; - } - pkg = (_entry = imports[id], _entry !== undefined ? _entry.v : ($ptrType(types.Package)).nil); - if (!(pkg === ($ptrType(types.Package)).nil) && pkg.Complete()) { - return [pkg, err]; - } - _tuple$2 = os.Open(filename); f = _tuple$2[0]; err = _tuple$2[1]; + Regexp.prototype.String = function() { return this.$val.String(); }; + Compile = $pkg.Compile = function(expr) { + return compile(expr, 212, false); + }; + Regexp.Ptr.prototype.Longest = function() { + var re; + re = this; + re.longest = true; + }; + Regexp.prototype.Longest = function() { return this.$val.Longest(); }; + compile = function(expr, mode, longest) { + var _tuple, re, err, maxCap, capNames, _tuple$1, prog, regexp, _tuple$2, _tuple$3, _tuple$4; + _tuple = syntax.Parse(expr, mode); re = _tuple[0]; err = _tuple[1]; if (!($interfaceIsEqual(err, $ifaceNil))) { - return [pkg, err]; + return [($ptrType(Regexp)).nil, err]; } - $deferred.push([(function() { - f.Close(); - if (!($interfaceIsEqual(err, $ifaceNil))) { - err = fmt.Errorf("reading export data: %s: %v", new ($sliceType($emptyInterface))([new $String(filename), err])); - } - }), []]); - buf = bufio.NewReader(f); - err = FindExportData(buf); + maxCap = re.MaxCap(); + capNames = re.CapNames(); + re = re.Simplify(); + _tuple$1 = syntax.Compile(re); prog = _tuple$1[0]; err = _tuple$1[1]; if (!($interfaceIsEqual(err, $ifaceNil))) { - return [pkg, err]; + return [($ptrType(Regexp)).nil, err]; } - _tuple$3 = ImportData(imports, filename, id, buf); pkg = _tuple$3[0]; err = _tuple$3[1]; - return [pkg, err]; - /* */ } catch(err) { $err = err; } finally { $deferFrames.pop(); $callDeferred($deferred, $err); return [pkg, err]; } - }; - parser.Ptr.prototype.init = function(filename, id, src, imports) { - var p; - p = this; - p.scanner.Init(src); - p.scanner.Error = (function(param, msg) { - p.error(new $String(msg)); - }); - p.scanner.Mode = 876; - p.scanner.Whitespace = new $Uint64(1, 512); - p.scanner.Position.Filename = filename; - p.next(); - p.id = id; - p.imports = imports; - }; - parser.prototype.init = function(filename, id, src, imports) { return this.$val.init(filename, id, src, imports); }; - parser.Ptr.prototype.next = function() { - var p, _ref; - p = this; - p.tok = p.scanner.Scan(); - _ref = p.tok; - if (_ref === -2 || _ref === -3 || _ref === -5 || _ref === -6 || _ref === 183) { - p.lit = p.scanner.TokenText(); + regexp = new Regexp.Ptr(expr, prog, compileOnePass(prog), "", ($sliceType($Uint8)).nil, false, 0, 0, prog.StartCond(), maxCap, capNames, longest, new sync.Mutex.Ptr(), ($sliceType(($ptrType(machine)))).nil); + if (regexp.onepass === notOnePass) { + _tuple$2 = prog.Prefix(); regexp.prefix = _tuple$2[0]; regexp.prefixComplete = _tuple$2[1]; } else { - p.lit = ""; + _tuple$3 = onePassPrefix(prog); regexp.prefix = _tuple$3[0]; regexp.prefixComplete = _tuple$3[1]; regexp.prefixEnd = _tuple$3[2]; } - }; - parser.prototype.next = function() { return this.$val.next(); }; - declTypeName = function(pkg, name) { - var scope, obj, obj$1; - scope = pkg.Scope(); - obj = scope.Lookup(name); - if (!($interfaceIsEqual(obj, $ifaceNil))) { - return $assertType(obj, ($ptrType(types.TypeName))); + if (!(regexp.prefix === "")) { + regexp.prefixBytes = new ($sliceType($Uint8))($stringToBytes(regexp.prefix)); + _tuple$4 = utf8.DecodeRuneInString(regexp.prefix); regexp.prefixRune = _tuple$4[0]; } - obj$1 = types.NewTypeName(0, pkg, name, $ifaceNil); - types.NewNamed(obj$1, $ifaceNil, ($sliceType(($ptrType(types.Func)))).nil); - scope.Insert(obj$1); - return obj$1; - }; - importError.Ptr.prototype.Error = function() { - var e, x; - e = new importError.Ptr(); $copy(e, this, importError); - return fmt.Sprintf("import error %s (byte offset = %d): %s", new ($sliceType($emptyInterface))([(x = e.pos, new x.constructor.Struct(x)), new $Int(e.pos.Offset), e.err])); + return [regexp, $ifaceNil]; }; - importError.prototype.Error = function() { return this.$val.Error(); }; - parser.Ptr.prototype.error = function(err) { - var p, _tuple, s, ok, x; - p = this; - _tuple = $assertType(err, $String, true); s = _tuple[0]; ok = _tuple[1]; - if (ok) { - err = errors.New(s); + Regexp.Ptr.prototype.get = function() { + var re, n, x, x$1, z, z$1; + re = this; + re.mu.Lock(); + n = re.machine.$length; + if (n > 0) { + z = (x = re.machine, x$1 = n - 1 >> 0, ((x$1 < 0 || x$1 >= x.$length) ? $throwRuntimeError("index out of range") : x.$array[x.$offset + x$1])); + re.machine = $subslice(re.machine, 0, (n - 1 >> 0)); + re.mu.Unlock(); + return z; } - $panic((x = new importError.Ptr(p.scanner.Pos(), $assertType(err, $error)), new x.constructor.Struct(x))); - }; - parser.prototype.error = function(err) { return this.$val.error(err); }; - parser.Ptr.prototype.errorf = function(format, args) { - var p; - p = this; - p.error(new $String(fmt.Sprintf(format, args))); + re.mu.Unlock(); + z$1 = progMachine(re.prog, re.onepass); + z$1.re = re; + return z$1; }; - parser.prototype.errorf = function(format, args) { return this.$val.errorf(format, args); }; - parser.Ptr.prototype.expect = function(tok) { - var p, lit; - p = this; - lit = p.lit; - if (!((p.tok === tok))) { - p.errorf("expected %s, got %s (%s)", new ($sliceType($emptyInterface))([new $String(scanner.TokenString(tok)), new $String(scanner.TokenString(p.tok)), new $String(lit)])); - } - p.next(); - return lit; + Regexp.prototype.get = function() { return this.$val.get(); }; + Regexp.Ptr.prototype.put = function(z) { + var re; + re = this; + re.mu.Lock(); + re.machine = $append(re.machine, z); + re.mu.Unlock(); }; - parser.prototype.expect = function(tok) { return this.$val.expect(tok); }; - parser.Ptr.prototype.expectSpecial = function(tok) { - var p, sep, i; - p = this; - sep = 120; - i = 0; - while (i < tok.length && (p.tok === (tok.charCodeAt(i) >> 0)) && sep > 32) { - sep = p.scanner.Peek(); - p.next(); - i = i + (1) >> 0; - } - if (i < tok.length) { - p.errorf("expected %q, got %q", new ($sliceType($emptyInterface))([new $String(tok), new $String(tok.substring(0, i))])); + Regexp.prototype.put = function(z) { return this.$val.put(z); }; + MustCompile = $pkg.MustCompile = function(str) { + var _tuple, regexp, error; + _tuple = Compile(str); regexp = _tuple[0]; error = _tuple[1]; + if (!($interfaceIsEqual(error, $ifaceNil))) { + $panic(new $String("regexp: Compile(" + quote(str) + "): " + error.Error())); } + return regexp; }; - parser.prototype.expectSpecial = function(tok) { return this.$val.expectSpecial(tok); }; - parser.Ptr.prototype.expectKeyword = function(keyword) { - var p, lit; - p = this; - lit = p.expect(-2); - if (!(lit === keyword)) { - p.errorf("expected keyword %s, got %q", new ($sliceType($emptyInterface))([new $String(keyword), new $String(lit)])); + quote = function(s) { + if (strconv.CanBackquote(s)) { + return "`" + s + "`"; } + return strconv.Quote(s); }; - parser.prototype.expectKeyword = function(keyword) { return this.$val.expectKeyword(keyword); }; - parser.Ptr.prototype.parsePackageId = function() { - var p, _tuple, id, err; - p = this; - _tuple = strconv.Unquote(p.expect(-6)); id = _tuple[0]; err = _tuple[1]; - if (!($interfaceIsEqual(err, $ifaceNil))) { - p.error(err); - } - if (id === "") { - id = p.id; - } - return id; + Regexp.Ptr.prototype.NumSubexp = function() { + var re; + re = this; + return re.numSubexp; }; - parser.prototype.parsePackageId = function() { return this.$val.parsePackageId(); }; - parser.Ptr.prototype.parsePackageName = function() { - var p; - p = this; - return p.expect(-2); + Regexp.prototype.NumSubexp = function() { return this.$val.NumSubexp(); }; + Regexp.Ptr.prototype.SubexpNames = function() { + var re; + re = this; + return re.subexpNames; }; - parser.prototype.parsePackageName = function() { return this.$val.parsePackageName(); }; - parser.Ptr.prototype.parseDotIdent = function() { - var p, ident, sep; - p = this; - ident = ""; - if (!((p.tok === -3))) { - sep = 120; - while (((p.tok === -2) || (p.tok === -3) || (p.tok === 183)) && sep > 32) { - ident = ident + (p.lit); - sep = p.scanner.Peek(); - p.next(); + Regexp.prototype.SubexpNames = function() { return this.$val.SubexpNames(); }; + inputString.Ptr.prototype.step = function(pos) { + var i, c; + i = this; + if (pos < i.str.length) { + c = i.str.charCodeAt(pos); + if (c < 128) { + return [(c >> 0), 1]; } + return utf8.DecodeRuneInString(i.str.substring(pos)); } - if (ident === "") { - p.expect(-2); - } - return ident; - }; - parser.prototype.parseDotIdent = function() { return this.$val.parseDotIdent(); }; - parser.Ptr.prototype.parseQualifiedName = function() { - var id = "", name = "", p; - p = this; - p.expect(64); - id = p.parsePackageId(); - p.expect(46); - if (p.tok === 63) { - p.next(); - } else { - name = p.parseDotIdent(); - } - return [id, name]; - }; - parser.prototype.parseQualifiedName = function() { return this.$val.parseQualifiedName(); }; - parser.Ptr.prototype.getPkg = function(id, name) { - var p, _entry, pkg, _key; - p = this; - if (id === "unsafe") { - return types.Unsafe; - } - pkg = (_entry = p.imports[id], _entry !== undefined ? _entry.v : ($ptrType(types.Package)).nil); - if (pkg === ($ptrType(types.Package)).nil && !(name === "")) { - pkg = types.NewPackage(id, name); - _key = id; (p.imports || $throwRuntimeError("assignment to entry in nil map"))[_key] = { k: _key, v: pkg }; - } - return pkg; - }; - parser.prototype.getPkg = function(id, name) { return this.$val.getPkg(id, name); }; - parser.Ptr.prototype.parseExportedName = function() { - var pkg = ($ptrType(types.Package)).nil, name = "", p, _tuple, id; - p = this; - _tuple = p.parseQualifiedName(); id = _tuple[0]; name = _tuple[1]; - pkg = p.getPkg(id, ""); - if (pkg === ($ptrType(types.Package)).nil) { - p.errorf("%s package not found", new ($sliceType($emptyInterface))([new $String(id)])); - } - return [pkg, name]; - }; - parser.prototype.parseExportedName = function() { return this.$val.parseExportedName(); }; - parser.Ptr.prototype.parseBasicType = function() { - var p, id, obj, _tuple, obj$1, ok; - p = this; - id = p.expect(-2); - obj = types.Universe.Lookup(id); - _tuple = $assertType(obj, ($ptrType(types.TypeName)), true); obj$1 = _tuple[0]; ok = _tuple[1]; - if (ok) { - return obj$1.object.Type(); - } - p.errorf("not a basic type: %s", new ($sliceType($emptyInterface))([new $String(id)])); - return $ifaceNil; - }; - parser.prototype.parseBasicType = function() { return this.$val.parseBasicType(); }; - parser.Ptr.prototype.parseArrayType = function() { - var p, lit, elem, _tuple, n, err; - p = this; - lit = p.expect(-3); - p.expect(93); - elem = p.parseType(); - _tuple = strconv.ParseInt(lit, 10, 64); n = _tuple[0]; err = _tuple[1]; - if (!($interfaceIsEqual(err, $ifaceNil))) { - p.error(err); - } - return types.NewArray(elem, n); + return [-1, 0]; }; - parser.prototype.parseArrayType = function() { return this.$val.parseArrayType(); }; - parser.Ptr.prototype.parseMapType = function() { - var p, key, elem; - p = this; - p.expectKeyword("map"); - p.expect(91); - key = p.parseType(); - p.expect(93); - elem = p.parseType(); - return types.NewMap(key, elem); + inputString.prototype.step = function(pos) { return this.$val.step(pos); }; + inputString.Ptr.prototype.canCheckPrefix = function() { + var i; + i = this; + return true; }; - parser.prototype.parseMapType = function() { return this.$val.parseMapType(); }; - parser.Ptr.prototype.parseName = function(materializePkg) { - var pkg = ($ptrType(types.Package)).nil, name = "", p, _ref, _entry, _entry$1, id, _tuple; - p = this; - _ref = p.tok; - if (_ref === -2) { - pkg = (_entry = p.imports[p.id], _entry !== undefined ? _entry.v : ($ptrType(types.Package)).nil); - name = p.lit; - p.next(); - } else if (_ref === 63) { - pkg = (_entry$1 = p.imports[p.id], _entry$1 !== undefined ? _entry$1.v : ($ptrType(types.Package)).nil); - p.next(); - } else if (_ref === 64) { - id = ""; - _tuple = p.parseQualifiedName(); id = _tuple[0]; name = _tuple[1]; - if (materializePkg) { - pkg = p.getPkg(id, ""); - if (pkg === ($ptrType(types.Package)).nil) { - pkg = types.NewPackage(id, ""); - } - } - } else { - p.error(new $String("name expected")); - } - return [pkg, name]; + inputString.prototype.canCheckPrefix = function() { return this.$val.canCheckPrefix(); }; + inputString.Ptr.prototype.hasPrefix = function(re) { + var i; + i = this; + return strings.HasPrefix(i.str, re.prefix); }; - parser.prototype.parseName = function(materializePkg) { return this.$val.parseName(materializePkg); }; - deref = function(typ) { - var _tuple, p; - _tuple = $assertType(typ, ($ptrType(types.Pointer)), true); p = _tuple[0]; - if (!(p === ($ptrType(types.Pointer)).nil)) { - return p.Elem(); - } - return typ; + inputString.prototype.hasPrefix = function(re) { return this.$val.hasPrefix(re); }; + inputString.Ptr.prototype.index = function(re, pos) { + var i; + i = this; + return strings.Index(i.str.substring(pos), re.prefix); }; - parser.Ptr.prototype.parseField = function() { - var p, _tuple, pkg, name, typ, anonymous, typ$1, _ref, tag, s, err, _tuple$1; - p = this; - _tuple = p.parseName(true); pkg = _tuple[0]; name = _tuple[1]; - typ = p.parseType(); - anonymous = false; - if (name === "") { - _ref = deref(typ); - if ($assertType(_ref, ($ptrType(types.Basic)), true)[1]) { - typ$1 = _ref.$val; - pkg = ($ptrType(types.Package)).nil; - name = typ$1.Name(); - } else if ($assertType(_ref, ($ptrType(types.Named)), true)[1]) { - typ$1 = _ref.$val; - name = typ$1.Obj().object.Name(); - } else { - typ$1 = _ref; - p.errorf("anonymous field expected", new ($sliceType($emptyInterface))([])); - } - anonymous = true; + inputString.prototype.index = function(re, pos) { return this.$val.index(re, pos); }; + inputString.Ptr.prototype.context = function(pos) { + var i, _tmp, _tmp$1, r1, r2, _tuple, _tuple$1; + i = this; + _tmp = -1; _tmp$1 = -1; r1 = _tmp; r2 = _tmp$1; + if (pos > 0 && pos <= i.str.length) { + _tuple = utf8.DecodeLastRuneInString(i.str.substring(0, pos)); r1 = _tuple[0]; } - tag = ""; - if (p.tok === -6) { - s = p.expect(-6); - err = $ifaceNil; - _tuple$1 = strconv.Unquote(s); tag = _tuple$1[0]; err = _tuple$1[1]; - if (!($interfaceIsEqual(err, $ifaceNil))) { - p.errorf("invalid struct tag %s: %s", new ($sliceType($emptyInterface))([new $String(s), err])); - } + if (pos < i.str.length) { + _tuple$1 = utf8.DecodeRuneInString(i.str.substring(pos)); r2 = _tuple$1[0]; } - return [types.NewField(0, pkg, name, typ, anonymous), tag]; + return syntax.EmptyOpContext(r1, r2); }; - parser.prototype.parseField = function() { return this.$val.parseField(); }; - parser.Ptr.prototype.parseStructType = function() { - var p, fields, tags, i, _tuple, fld, tag; - p = this; - fields = ($sliceType(($ptrType(types.Var)))).nil; - tags = ($sliceType($String)).nil; - p.expectKeyword("struct"); - p.expect(123); - i = 0; - while (!((p.tok === 125)) && !((p.tok === -1))) { - if (i > 0) { - p.expect(59); - } - _tuple = p.parseField(); fld = _tuple[0]; tag = _tuple[1]; - if (!(tag === "") && tags === ($sliceType($String)).nil) { - tags = ($sliceType($String)).make(i); - } - if (!(tags === ($sliceType($String)).nil)) { - tags = $append(tags, tag); + inputString.prototype.context = function(pos) { return this.$val.context(pos); }; + inputBytes.Ptr.prototype.step = function(pos) { + var i, x, c; + i = this; + if (pos < i.str.$length) { + c = (x = i.str, ((pos < 0 || pos >= x.$length) ? $throwRuntimeError("index out of range") : x.$array[x.$offset + pos])); + if (c < 128) { + return [(c >> 0), 1]; } - fields = $append(fields, fld); - i = i + (1) >> 0; + return utf8.DecodeRune($subslice(i.str, pos)); } - p.expect(125); - return types.NewStruct(fields, tags); + return [-1, 0]; }; - parser.prototype.parseStructType = function() { return this.$val.parseStructType(); }; - parser.Ptr.prototype.parseParameter = function() { - var par = ($ptrType(types.Var)).nil, isVariadic = false, p, _tuple, name, i, typ; - p = this; - _tuple = p.parseName(false); name = _tuple[1]; - i = strings.Index(name, "\xC2\xB7"); - if (i >= 0) { - name = name.substring(0, i); + inputBytes.prototype.step = function(pos) { return this.$val.step(pos); }; + inputBytes.Ptr.prototype.canCheckPrefix = function() { + var i; + i = this; + return true; + }; + inputBytes.prototype.canCheckPrefix = function() { return this.$val.canCheckPrefix(); }; + inputBytes.Ptr.prototype.hasPrefix = function(re) { + var i; + i = this; + return bytes.HasPrefix(i.str, re.prefixBytes); + }; + inputBytes.prototype.hasPrefix = function(re) { return this.$val.hasPrefix(re); }; + inputBytes.Ptr.prototype.index = function(re, pos) { + var i; + i = this; + return bytes.Index($subslice(i.str, pos), re.prefixBytes); + }; + inputBytes.prototype.index = function(re, pos) { return this.$val.index(re, pos); }; + inputBytes.Ptr.prototype.context = function(pos) { + var i, _tmp, _tmp$1, r1, r2, _tuple, _tuple$1; + i = this; + _tmp = -1; _tmp$1 = -1; r1 = _tmp; r2 = _tmp$1; + if (pos > 0 && pos <= i.str.$length) { + _tuple = utf8.DecodeLastRune($subslice(i.str, 0, pos)); r1 = _tuple[0]; } - if (p.tok === 46) { - p.expectSpecial("..."); - isVariadic = true; + if (pos < i.str.$length) { + _tuple$1 = utf8.DecodeRune($subslice(i.str, pos)); r2 = _tuple$1[0]; } - typ = p.parseType(); - if (isVariadic) { - typ = types.NewSlice(typ); + return syntax.EmptyOpContext(r1, r2); + }; + inputBytes.prototype.context = function(pos) { return this.$val.context(pos); }; + inputReader.Ptr.prototype.step = function(pos) { + var i, _tuple, r, w, err; + i = this; + if (!i.atEOT && !((pos === i.pos))) { + return [-1, 0]; } - if (p.tok === -6) { - p.next(); + _tuple = i.r.ReadRune(); r = _tuple[0]; w = _tuple[1]; err = _tuple[2]; + if (!($interfaceIsEqual(err, $ifaceNil))) { + i.atEOT = true; + return [-1, 0]; } - par = types.NewVar(0, ($ptrType(types.Package)).nil, name, typ); - return [par, isVariadic]; + i.pos = i.pos + (w) >> 0; + return [r, w]; }; - parser.prototype.parseParameter = function() { return this.$val.parseParameter(); }; - parser.Ptr.prototype.parseParameters = function() { - var list = ($sliceType(($ptrType(types.Var)))).nil, isVariadic = false, p, _tuple, par, variadic; - p = this; - p.expect(40); - while (!((p.tok === 41)) && !((p.tok === -1))) { - if (list.$length > 0) { - p.expect(44); - } - _tuple = p.parseParameter(); par = _tuple[0]; variadic = _tuple[1]; - list = $append(list, par); - if (variadic) { - if (isVariadic) { - p.error(new $String("... not on final argument")); - } - isVariadic = true; - } - } - p.expect(41); - return [list, isVariadic]; + inputReader.prototype.step = function(pos) { return this.$val.step(pos); }; + inputReader.Ptr.prototype.canCheckPrefix = function() { + var i; + i = this; + return false; }; - parser.prototype.parseParameters = function() { return this.$val.parseParameters(); }; - parser.Ptr.prototype.parseSignature = function(recv) { - var p, _tuple, params, isVariadic, results, variadic, _tuple$1; - p = this; - _tuple = p.parseParameters(); params = _tuple[0]; isVariadic = _tuple[1]; - results = ($sliceType(($ptrType(types.Var)))).nil; - if (p.tok === 40) { - variadic = false; - _tuple$1 = p.parseParameters(); results = _tuple$1[0]; variadic = _tuple$1[1]; - if (variadic) { - p.error(new $String("... not permitted on result type")); - } - } - return types.NewSignature(($ptrType(types.Scope)).nil, recv, types.NewTuple(params), types.NewTuple(results), isVariadic); + inputReader.prototype.canCheckPrefix = function() { return this.$val.canCheckPrefix(); }; + inputReader.Ptr.prototype.hasPrefix = function(re) { + var i; + i = this; + return false; }; - parser.prototype.parseSignature = function(recv) { return this.$val.parseSignature(recv); }; - parser.Ptr.prototype.parseInterfaceType = function() { - var p, methods, i, _tuple, pkg, name, sig; - p = this; - methods = ($sliceType(($ptrType(types.Func)))).nil; - p.expectKeyword("interface"); - p.expect(123); - i = 0; - while (!((p.tok === 125)) && !((p.tok === -1))) { - if (i > 0) { - p.expect(59); - } - _tuple = p.parseName(true); pkg = _tuple[0]; name = _tuple[1]; - sig = p.parseSignature(($ptrType(types.Var)).nil); - methods = $append(methods, types.NewFunc(0, pkg, name, sig)); - i = i + (1) >> 0; - } - p.expect(125); - return types.NewInterface(methods, ($sliceType(($ptrType(types.Named)))).nil).Complete(); + inputReader.prototype.hasPrefix = function(re) { return this.$val.hasPrefix(re); }; + inputReader.Ptr.prototype.index = function(re, pos) { + var i; + i = this; + return -1; }; - parser.prototype.parseInterfaceType = function() { return this.$val.parseInterfaceType(); }; - parser.Ptr.prototype.parseChanType = function() { - var p, dir, elem; - p = this; - dir = 0; - if (p.tok === -2) { - p.expectKeyword("chan"); - if (p.tok === 60) { - p.expectSpecial("<-"); - dir = 1; - } - } else { - p.expectSpecial("<-"); - p.expectKeyword("chan"); - dir = 2; - } - elem = p.parseType(); - return types.NewChan(dir, elem); + inputReader.prototype.index = function(re, pos) { return this.$val.index(re, pos); }; + inputReader.Ptr.prototype.context = function(pos) { + var i; + i = this; + return 0; }; - parser.prototype.parseChanType = function() { return this.$val.parseChanType(); }; - parser.Ptr.prototype.parseType = function() { - var p, _ref, _ref$1, _tuple, pkg, name, typ; - p = this; - _ref = p.tok; - if (_ref === -2) { - _ref$1 = p.lit; - if (_ref$1 === "struct") { - return p.parseStructType(); - } else if (_ref$1 === "func") { - p.next(); - return p.parseSignature(($ptrType(types.Var)).nil); - } else if (_ref$1 === "interface") { - return p.parseInterfaceType(); - } else if (_ref$1 === "map") { - return p.parseMapType(); - } else if (_ref$1 === "chan") { - return p.parseChanType(); - } else { - return p.parseBasicType(); - } - } else if (_ref === 64) { - _tuple = p.parseExportedName(); pkg = _tuple[0]; name = _tuple[1]; - return declTypeName(pkg, name).object.Type(); - } else if (_ref === 91) { - p.next(); - if (p.tok === 93) { - p.next(); - return types.NewSlice(p.parseType()); - } - return p.parseArrayType(); - } else if (_ref === 42) { - p.next(); - return types.NewPointer(p.parseType()); - } else if (_ref === 60) { - return p.parseChanType(); - } else if (_ref === 40) { - p.next(); - typ = p.parseType(); - p.expect(41); - return typ; - } - p.errorf("expected type, got %s (%q)", new ($sliceType($emptyInterface))([new $String(scanner.TokenString(p.tok)), new $String(p.lit)])); - return $ifaceNil; + inputReader.prototype.context = function(pos) { return this.$val.context(pos); }; + Regexp.Ptr.prototype.LiteralPrefix = function() { + var prefix = "", complete = false, re, _tmp, _tmp$1; + re = this; + _tmp = re.prefix; _tmp$1 = re.prefixComplete; prefix = _tmp; complete = _tmp$1; + return [prefix, complete]; }; - parser.prototype.parseType = function() { return this.$val.parseType(); }; - parser.Ptr.prototype.parseImportDecl = function() { - var p, name; - p = this; - p.expectKeyword("import"); - name = p.parsePackageName(); - p.getPkg(p.parsePackageId(), name); + Regexp.prototype.LiteralPrefix = function() { return this.$val.LiteralPrefix(); }; + Regexp.Ptr.prototype.MatchReader = function(r) { + var re; + re = this; + return !(re.doExecute(r, ($sliceType($Uint8)).nil, "", 0, 0) === ($sliceType($Int)).nil); }; - parser.prototype.parseImportDecl = function() { return this.$val.parseImportDecl(); }; - parser.Ptr.prototype.parseInt = function() { - var p, s, _ref; - p = this; - s = ""; - _ref = p.tok; - if (_ref === 45) { - s = "-"; - p.next(); - } else if (_ref === 43) { - p.next(); + Regexp.prototype.MatchReader = function(r) { return this.$val.MatchReader(r); }; + Regexp.Ptr.prototype.MatchString = function(s) { + var re; + re = this; + return !(re.doExecute($ifaceNil, ($sliceType($Uint8)).nil, s, 0, 0) === ($sliceType($Int)).nil); + }; + Regexp.prototype.MatchString = function(s) { return this.$val.MatchString(s); }; + Regexp.Ptr.prototype.Match = function(b) { + var re; + re = this; + return !(re.doExecute($ifaceNil, b, "", 0, 0) === ($sliceType($Int)).nil); + }; + Regexp.prototype.Match = function(b) { return this.$val.Match(b); }; + Regexp.Ptr.prototype.ReplaceAllString = function(src, repl) { + var re, n, x, b; + re = this; + n = 2; + if (strings.Index(repl, "$") >= 0) { + n = (x = (re.numSubexp + 1 >> 0), (((2 >>> 16 << 16) * x >> 0) + (2 << 16 >>> 16) * x) >> 0); } - return s + p.expect(-3); + b = re.replaceAll(($sliceType($Uint8)).nil, src, n, (function(dst, match) { + return re.expand(dst, repl, ($sliceType($Uint8)).nil, src, match); + })); + return $bytesToString(b); }; - parser.prototype.parseInt = function() { return this.$val.parseInt(); }; - parser.Ptr.prototype.parseNumber = function() { - var typ = ($ptrType(types.Basic)).nil, val = $ifaceNil, p, mant, _tuple, exp, err, denom; - p = this; - mant = exact.MakeFromLiteral(p.parseInt(), 5); - if ($interfaceIsEqual(mant, $ifaceNil)) { - $panic(new $String("invalid mantissa")); + Regexp.prototype.ReplaceAllString = function(src, repl) { return this.$val.ReplaceAllString(src, repl); }; + Regexp.Ptr.prototype.ReplaceAllLiteralString = function(src, repl) { + var re; + re = this; + return $bytesToString(re.replaceAll(($sliceType($Uint8)).nil, src, 2, (function(dst, match) { + return $appendSlice(dst, new ($sliceType($Uint8))($stringToBytes(repl))); + }))); + }; + Regexp.prototype.ReplaceAllLiteralString = function(src, repl) { return this.$val.ReplaceAllLiteralString(src, repl); }; + Regexp.Ptr.prototype.ReplaceAllStringFunc = function(src, repl) { + var re, b; + re = this; + b = re.replaceAll(($sliceType($Uint8)).nil, src, 2, (function(dst, match) { + return $appendSlice(dst, new ($sliceType($Uint8))($stringToBytes(repl(src.substring(((0 < 0 || 0 >= match.$length) ? $throwRuntimeError("index out of range") : match.$array[match.$offset + 0]), ((1 < 0 || 1 >= match.$length) ? $throwRuntimeError("index out of range") : match.$array[match.$offset + 1])))))); + })); + return $bytesToString(b); + }; + Regexp.prototype.ReplaceAllStringFunc = function(src, repl) { return this.$val.ReplaceAllStringFunc(src, repl); }; + Regexp.Ptr.prototype.replaceAll = function(bsrc, src, nmatch, repl) { + var re, lastMatchEnd, searchPos, buf, endPos, a, width, _tuple, _tuple$1; + re = this; + lastMatchEnd = 0; + searchPos = 0; + buf = ($sliceType($Uint8)).nil; + endPos = 0; + if (!(bsrc === ($sliceType($Uint8)).nil)) { + endPos = bsrc.$length; + } else { + endPos = src.length; } - if (p.lit === "p") { - p.next(); - _tuple = strconv.ParseInt(p.parseInt(), 10, 0); exp = _tuple[0]; err = _tuple[1]; - if (!($interfaceIsEqual(err, $ifaceNil))) { - p.error(err); + while (searchPos <= endPos) { + a = re.doExecute($ifaceNil, bsrc, src, searchPos, nmatch); + if (a.$length === 0) { + break; } - if ((exp.$high < 0 || (exp.$high === 0 && exp.$low < 0))) { - denom = exact.MakeInt64(new $Int64(0, 1)); - denom = exact.Shift(denom, 20, (new $Int64(-exp.$high, -exp.$low).$low >>> 0)); - typ = types.Typ[22]; - val = exact.BinaryOp(mant, 15, denom); - return [typ, val]; + if (!(bsrc === ($sliceType($Uint8)).nil)) { + buf = $appendSlice(buf, $subslice(bsrc, lastMatchEnd, ((0 < 0 || 0 >= a.$length) ? $throwRuntimeError("index out of range") : a.$array[a.$offset + 0]))); + } else { + buf = $appendSlice(buf, new ($sliceType($Uint8))($stringToBytes(src.substring(lastMatchEnd, ((0 < 0 || 0 >= a.$length) ? $throwRuntimeError("index out of range") : a.$array[a.$offset + 0]))))); } - if ((exp.$high > 0 || (exp.$high === 0 && exp.$low > 0))) { - mant = exact.Shift(mant, 20, (exp.$low >>> 0)); + if (((1 < 0 || 1 >= a.$length) ? $throwRuntimeError("index out of range") : a.$array[a.$offset + 1]) > lastMatchEnd || (((0 < 0 || 0 >= a.$length) ? $throwRuntimeError("index out of range") : a.$array[a.$offset + 0]) === 0)) { + buf = repl(buf, a); } - typ = types.Typ[22]; - val = mant; - return [typ, val]; - } - typ = types.Typ[20]; - val = mant; - return [typ, val]; - }; - parser.prototype.parseNumber = function() { return this.$val.parseNumber(); }; - parser.Ptr.prototype.parseConstDecl = function() { - var p, _tuple, pkg, name, typ0, typ, val, _ref, _tuple$1, _tuple$2, _tuple$3, re, _tuple$4, im; - p = this; - p.expectKeyword("const"); - _tuple = p.parseExportedName(); pkg = _tuple[0]; name = _tuple[1]; - typ0 = $ifaceNil; - if (!((p.tok === 61))) { - typ0 = p.parseType(); - } - p.expect(61); - typ = $ifaceNil; - val = $ifaceNil; - _ref = p.tok; - switch (0) { default: if (_ref === -2) { - if (!(p.lit === "true") && !(p.lit === "false")) { - p.error(new $String("expected true or false")); + lastMatchEnd = ((1 < 0 || 1 >= a.$length) ? $throwRuntimeError("index out of range") : a.$array[a.$offset + 1]); + width = 0; + if (!(bsrc === ($sliceType($Uint8)).nil)) { + _tuple = utf8.DecodeRune($subslice(bsrc, searchPos)); width = _tuple[1]; + } else { + _tuple$1 = utf8.DecodeRuneInString(src.substring(searchPos)); width = _tuple$1[1]; } - typ = types.Typ[19]; - val = exact.MakeBool(p.lit === "true"); - p.next(); - } else if (_ref === 45 || _ref === -3) { - _tuple$1 = p.parseNumber(); typ = _tuple$1[0]; val = _tuple$1[1]; - } else if (_ref === 40) { - p.next(); - if (p.tok === -5) { - p.next(); - p.expect(43); - typ = types.Typ[21]; - _tuple$2 = p.parseNumber(); val = _tuple$2[1]; - p.expect(41); - break; + if ((searchPos + width >> 0) > ((1 < 0 || 1 >= a.$length) ? $throwRuntimeError("index out of range") : a.$array[a.$offset + 1])) { + searchPos = searchPos + (width) >> 0; + } else if ((searchPos + 1 >> 0) > ((1 < 0 || 1 >= a.$length) ? $throwRuntimeError("index out of range") : a.$array[a.$offset + 1])) { + searchPos = searchPos + (1) >> 0; + } else { + searchPos = ((1 < 0 || 1 >= a.$length) ? $throwRuntimeError("index out of range") : a.$array[a.$offset + 1]); } - _tuple$3 = p.parseNumber(); re = _tuple$3[1]; - p.expect(43); - _tuple$4 = p.parseNumber(); im = _tuple$4[1]; - p.expectKeyword("i"); - p.expect(41); - typ = types.Typ[23]; - val = exact.BinaryOp(re, 12, exact.MakeImag(im)); - } else if (_ref === -5) { - typ = types.Typ[21]; - val = exact.MakeFromLiteral(p.lit, 8); - p.next(); - } else if (_ref === -6) { - typ = types.Typ[24]; - val = exact.MakeFromLiteral(p.lit, 9); - p.next(); + } + if (!(bsrc === ($sliceType($Uint8)).nil)) { + buf = $appendSlice(buf, $subslice(bsrc, lastMatchEnd)); } else { - p.errorf("expected literal got %s", new ($sliceType($emptyInterface))([new $String(scanner.TokenString(p.tok))])); - } } - if ($interfaceIsEqual(typ0, $ifaceNil)) { - typ0 = typ; + buf = $appendSlice(buf, new ($sliceType($Uint8))($stringToBytes(src.substring(lastMatchEnd)))); } - pkg.Scope().Insert(types.NewConst(0, pkg, name, typ0, val)); + return buf; }; - parser.prototype.parseConstDecl = function() { return this.$val.parseConstDecl(); }; - parser.Ptr.prototype.parseTypeDecl = function() { - var p, _tuple, pkg, name, obj, typ, name$1; - p = this; - p.expectKeyword("type"); - _tuple = p.parseExportedName(); pkg = _tuple[0]; name = _tuple[1]; - obj = declTypeName(pkg, name); - typ = p.parseType(); - name$1 = $assertType(obj.object.Type(), ($ptrType(types.Named))); - if ($interfaceIsEqual(name$1.Underlying(), $ifaceNil)) { - name$1.SetUnderlying(typ); + Regexp.prototype.replaceAll = function(bsrc, src, nmatch, repl) { return this.$val.replaceAll(bsrc, src, nmatch, repl); }; + Regexp.Ptr.prototype.ReplaceAll = function(src, repl) { + var re, n, x, srepl, b; + re = this; + n = 2; + if (bytes.IndexByte(repl, 36) >= 0) { + n = (x = (re.numSubexp + 1 >> 0), (((2 >>> 16 << 16) * x >> 0) + (2 << 16 >>> 16) * x) >> 0); } + srepl = ""; + b = re.replaceAll(src, "", n, (function(dst, match) { + if (!((srepl.length === repl.$length))) { + srepl = $bytesToString(repl); + } + return re.expand(dst, srepl, src, "", match); + })); + return b; }; - parser.prototype.parseTypeDecl = function() { return this.$val.parseTypeDecl(); }; - parser.Ptr.prototype.parseVarDecl = function() { - var p, _tuple, pkg, name, typ; - p = this; - p.expectKeyword("var"); - _tuple = p.parseExportedName(); pkg = _tuple[0]; name = _tuple[1]; - typ = p.parseType(); - pkg.Scope().Insert(types.NewVar(0, pkg, name, typ)); + Regexp.prototype.ReplaceAll = function(src, repl) { return this.$val.ReplaceAll(src, repl); }; + Regexp.Ptr.prototype.ReplaceAllLiteral = function(src, repl) { + var re; + re = this; + return re.replaceAll(src, "", 2, (function(dst, match) { + return $appendSlice(dst, repl); + })); }; - parser.prototype.parseVarDecl = function() { return this.$val.parseVarDecl(); }; - parser.Ptr.prototype.parseFunc = function(recv) { - var p, sig, i, _ref; - p = this; - sig = p.parseSignature(recv); - if (p.tok === 123) { - p.next(); - i = 1; - while (i > 0) { - _ref = p.tok; - if (_ref === 123) { - i = i + (1) >> 0; - } else if (_ref === 125) { - i = i - (1) >> 0; + Regexp.prototype.ReplaceAllLiteral = function(src, repl) { return this.$val.ReplaceAllLiteral(src, repl); }; + Regexp.Ptr.prototype.ReplaceAllFunc = function(src, repl) { + var re; + re = this; + return re.replaceAll(src, "", 2, (function(dst, match) { + return $appendSlice(dst, repl($subslice(src, ((0 < 0 || 0 >= match.$length) ? $throwRuntimeError("index out of range") : match.$array[match.$offset + 0]), ((1 < 0 || 1 >= match.$length) ? $throwRuntimeError("index out of range") : match.$array[match.$offset + 1])))); + })); + }; + Regexp.prototype.ReplaceAllFunc = function(src, repl) { return this.$val.ReplaceAllFunc(src, repl); }; + Regexp.Ptr.prototype.pad = function(a) { + var re, x, n; + re = this; + if (a === ($sliceType($Int)).nil) { + return ($sliceType($Int)).nil; + } + n = (x = (1 + re.numSubexp >> 0), (((x >>> 16 << 16) * 2 >> 0) + (x << 16 >>> 16) * 2) >> 0); + while (a.$length < n) { + a = $append(a, -1); + } + return a; + }; + Regexp.prototype.pad = function(a) { return this.$val.pad(a); }; + Regexp.Ptr.prototype.allMatches = function(s, b, n, deliver) { + var re, end, _tmp, _tmp$1, _tmp$2, pos, i, prevMatchEnd, matches, accept, width, _tuple, _tuple$1; + re = this; + end = 0; + if (b === ($sliceType($Uint8)).nil) { + end = s.length; + } else { + end = b.$length; + } + _tmp = 0; _tmp$1 = 0; _tmp$2 = -1; pos = _tmp; i = _tmp$1; prevMatchEnd = _tmp$2; + while (i < n && pos <= end) { + matches = re.doExecute($ifaceNil, b, s, pos, re.prog.NumCap); + if (matches.$length === 0) { + break; + } + accept = true; + if (((1 < 0 || 1 >= matches.$length) ? $throwRuntimeError("index out of range") : matches.$array[matches.$offset + 1]) === pos) { + if (((0 < 0 || 0 >= matches.$length) ? $throwRuntimeError("index out of range") : matches.$array[matches.$offset + 0]) === prevMatchEnd) { + accept = false; + } + width = 0; + if (b === ($sliceType($Uint8)).nil) { + _tuple = utf8.DecodeRuneInString(s.substring(pos, end)); width = _tuple[1]; + } else { + _tuple$1 = utf8.DecodeRune($subslice(b, pos, end)); width = _tuple$1[1]; } - p.next(); + if (width > 0) { + pos = pos + (width) >> 0; + } else { + pos = end + 1 >> 0; + } + } else { + pos = ((1 < 0 || 1 >= matches.$length) ? $throwRuntimeError("index out of range") : matches.$array[matches.$offset + 1]); + } + prevMatchEnd = ((1 < 0 || 1 >= matches.$length) ? $throwRuntimeError("index out of range") : matches.$array[matches.$offset + 1]); + if (accept) { + deliver(re.pad(matches)); + i = i + (1) >> 0; } } - return sig; }; - parser.prototype.parseFunc = function(recv) { return this.$val.parseFunc(recv); }; - parser.Ptr.prototype.parseMethodDecl = function() { - var p, _tuple, recv, base, _tuple$1, name, sig, pkg; - p = this; - p.expect(40); - _tuple = p.parseParameter(); recv = _tuple[0]; - p.expect(41); - base = $assertType(deref(recv.object.Type()), ($ptrType(types.Named))); - _tuple$1 = p.parseName(true); name = _tuple$1[1]; - sig = p.parseFunc(recv); - pkg = base.Obj().object.Pkg(); - base.AddMethod(types.NewFunc(0, pkg, name, sig)); + Regexp.prototype.allMatches = function(s, b, n, deliver) { return this.$val.allMatches(s, b, n, deliver); }; + Regexp.Ptr.prototype.Find = function(b) { + var re, a; + re = this; + a = re.doExecute($ifaceNil, b, "", 0, 2); + if (a === ($sliceType($Int)).nil) { + return ($sliceType($Uint8)).nil; + } + return $subslice(b, ((0 < 0 || 0 >= a.$length) ? $throwRuntimeError("index out of range") : a.$array[a.$offset + 0]), ((1 < 0 || 1 >= a.$length) ? $throwRuntimeError("index out of range") : a.$array[a.$offset + 1])); }; - parser.prototype.parseMethodDecl = function() { return this.$val.parseMethodDecl(); }; - parser.Ptr.prototype.parseFuncDecl = function() { - var p, _tuple, pkg, name, typ; - p = this; - _tuple = p.parseExportedName(); pkg = _tuple[0]; name = _tuple[1]; - typ = p.parseFunc(($ptrType(types.Var)).nil); - pkg.Scope().Insert(types.NewFunc(0, pkg, name, typ)); + Regexp.prototype.Find = function(b) { return this.$val.Find(b); }; + Regexp.Ptr.prototype.FindIndex = function(b) { + var loc = ($sliceType($Int)).nil, re, a; + re = this; + a = re.doExecute($ifaceNil, b, "", 0, 2); + if (a === ($sliceType($Int)).nil) { + loc = ($sliceType($Int)).nil; + return loc; + } + loc = $subslice(a, 0, 2); + return loc; }; - parser.prototype.parseFuncDecl = function() { return this.$val.parseFuncDecl(); }; - parser.Ptr.prototype.parseDecl = function() { - var p, _ref; - p = this; - if (p.tok === -2) { - _ref = p.lit; - if (_ref === "import") { - p.parseImportDecl(); - } else if (_ref === "const") { - p.parseConstDecl(); - } else if (_ref === "type") { - p.parseTypeDecl(); - } else if (_ref === "var") { - p.parseVarDecl(); - } else if (_ref === "func") { - p.next(); - if (p.tok === 40) { - p.parseMethodDecl(); - } else { - p.parseFuncDecl(); - } - } + Regexp.prototype.FindIndex = function(b) { return this.$val.FindIndex(b); }; + Regexp.Ptr.prototype.FindString = function(s) { + var re, a; + re = this; + a = re.doExecute($ifaceNil, ($sliceType($Uint8)).nil, s, 0, 2); + if (a === ($sliceType($Int)).nil) { + return ""; } - p.expect(10); + return s.substring(((0 < 0 || 0 >= a.$length) ? $throwRuntimeError("index out of range") : a.$array[a.$offset + 0]), ((1 < 0 || 1 >= a.$length) ? $throwRuntimeError("index out of range") : a.$array[a.$offset + 1])); }; - parser.prototype.parseDecl = function() { return this.$val.parseDecl(); }; - parser.Ptr.prototype.parseExport = function() { - var p, name, pkg, ch, n; - p = this; - p.expectKeyword("package"); - name = p.parsePackageName(); - if ((p.tok === -2) && p.lit === "safe") { - p.next(); + Regexp.prototype.FindString = function(s) { return this.$val.FindString(s); }; + Regexp.Ptr.prototype.FindStringIndex = function(s) { + var loc = ($sliceType($Int)).nil, re, a; + re = this; + a = re.doExecute($ifaceNil, ($sliceType($Uint8)).nil, s, 0, 2); + if (a === ($sliceType($Int)).nil) { + loc = ($sliceType($Int)).nil; + return loc; } - p.expect(10); - pkg = p.getPkg(p.id, name); - while (!((p.tok === 36)) && !((p.tok === -1))) { - p.parseDecl(); + loc = $subslice(a, 0, 2); + return loc; + }; + Regexp.prototype.FindStringIndex = function(s) { return this.$val.FindStringIndex(s); }; + Regexp.Ptr.prototype.FindReaderIndex = function(r) { + var loc = ($sliceType($Int)).nil, re, a; + re = this; + a = re.doExecute(r, ($sliceType($Uint8)).nil, "", 0, 2); + if (a === ($sliceType($Int)).nil) { + loc = ($sliceType($Int)).nil; + return loc; } - ch = p.scanner.Peek(); - if (!((p.tok === 36)) || !((ch === 36))) { - p.errorf("expected '$$', got %s %c", new ($sliceType($emptyInterface))([new $String(scanner.TokenString(p.tok)), new $Int32(ch)])); + loc = $subslice(a, 0, 2); + return loc; + }; + Regexp.prototype.FindReaderIndex = function(r) { return this.$val.FindReaderIndex(r); }; + Regexp.Ptr.prototype.FindSubmatch = function(b) { + var re, a, ret, _ref, _i, i, x, x$1, x$2; + re = this; + a = re.doExecute($ifaceNil, b, "", 0, re.prog.NumCap); + if (a === ($sliceType($Int)).nil) { + return ($sliceType(($sliceType($Uint8)))).nil; } - n = p.scanner.ErrorCount; - if (!((n === 0))) { - p.errorf("expected no scanner errors, got %d", new ($sliceType($emptyInterface))([new $Int(n)])); + ret = ($sliceType(($sliceType($Uint8)))).make((1 + re.numSubexp >> 0)); + _ref = ret; + _i = 0; + while (_i < _ref.$length) { + i = _i; + if (((((2 >>> 16 << 16) * i >> 0) + (2 << 16 >>> 16) * i) >> 0) < a.$length && (x = (((2 >>> 16 << 16) * i >> 0) + (2 << 16 >>> 16) * i) >> 0, ((x < 0 || x >= a.$length) ? $throwRuntimeError("index out of range") : a.$array[a.$offset + x])) >= 0) { + (i < 0 || i >= ret.$length) ? $throwRuntimeError("index out of range") : ret.$array[ret.$offset + i] = $subslice(b, (x$1 = (((2 >>> 16 << 16) * i >> 0) + (2 << 16 >>> 16) * i) >> 0, ((x$1 < 0 || x$1 >= a.$length) ? $throwRuntimeError("index out of range") : a.$array[a.$offset + x$1])), (x$2 = ((((2 >>> 16 << 16) * i >> 0) + (2 << 16 >>> 16) * i) >> 0) + 1 >> 0, ((x$2 < 0 || x$2 >= a.$length) ? $throwRuntimeError("index out of range") : a.$array[a.$offset + x$2]))); + } + _i++; } - pkg.MarkComplete(); - return pkg; + return ret; }; - parser.prototype.parseExport = function() { return this.$val.parseExport(); }; - $pkg.$init = function() { - ($ptrType(parser)).methods = [["error", "error", "code.google.com/p/go.tools/go/gcimporter", $funcType([$emptyInterface], [], false), -1], ["errorf", "errorf", "code.google.com/p/go.tools/go/gcimporter", $funcType([$String, ($sliceType($emptyInterface))], [], true), -1], ["expect", "expect", "code.google.com/p/go.tools/go/gcimporter", $funcType([$Int32], [$String], false), -1], ["expectKeyword", "expectKeyword", "code.google.com/p/go.tools/go/gcimporter", $funcType([$String], [], false), -1], ["expectSpecial", "expectSpecial", "code.google.com/p/go.tools/go/gcimporter", $funcType([$String], [], false), -1], ["getPkg", "getPkg", "code.google.com/p/go.tools/go/gcimporter", $funcType([$String, $String], [($ptrType(types.Package))], false), -1], ["init", "init", "code.google.com/p/go.tools/go/gcimporter", $funcType([$String, $String, io.Reader, ($mapType($String, ($ptrType(types.Package))))], [], false), -1], ["next", "next", "code.google.com/p/go.tools/go/gcimporter", $funcType([], [], false), -1], ["parseArrayType", "parseArrayType", "code.google.com/p/go.tools/go/gcimporter", $funcType([], [types.Type], false), -1], ["parseBasicType", "parseBasicType", "code.google.com/p/go.tools/go/gcimporter", $funcType([], [types.Type], false), -1], ["parseChanType", "parseChanType", "code.google.com/p/go.tools/go/gcimporter", $funcType([], [types.Type], false), -1], ["parseConstDecl", "parseConstDecl", "code.google.com/p/go.tools/go/gcimporter", $funcType([], [], false), -1], ["parseDecl", "parseDecl", "code.google.com/p/go.tools/go/gcimporter", $funcType([], [], false), -1], ["parseDotIdent", "parseDotIdent", "code.google.com/p/go.tools/go/gcimporter", $funcType([], [$String], false), -1], ["parseExport", "parseExport", "code.google.com/p/go.tools/go/gcimporter", $funcType([], [($ptrType(types.Package))], false), -1], ["parseExportedName", "parseExportedName", "code.google.com/p/go.tools/go/gcimporter", $funcType([], [($ptrType(types.Package)), $String], false), -1], ["parseField", "parseField", "code.google.com/p/go.tools/go/gcimporter", $funcType([], [($ptrType(types.Var)), $String], false), -1], ["parseFunc", "parseFunc", "code.google.com/p/go.tools/go/gcimporter", $funcType([($ptrType(types.Var))], [($ptrType(types.Signature))], false), -1], ["parseFuncDecl", "parseFuncDecl", "code.google.com/p/go.tools/go/gcimporter", $funcType([], [], false), -1], ["parseImportDecl", "parseImportDecl", "code.google.com/p/go.tools/go/gcimporter", $funcType([], [], false), -1], ["parseInt", "parseInt", "code.google.com/p/go.tools/go/gcimporter", $funcType([], [$String], false), -1], ["parseInterfaceType", "parseInterfaceType", "code.google.com/p/go.tools/go/gcimporter", $funcType([], [types.Type], false), -1], ["parseMapType", "parseMapType", "code.google.com/p/go.tools/go/gcimporter", $funcType([], [types.Type], false), -1], ["parseMethodDecl", "parseMethodDecl", "code.google.com/p/go.tools/go/gcimporter", $funcType([], [], false), -1], ["parseName", "parseName", "code.google.com/p/go.tools/go/gcimporter", $funcType([$Bool], [($ptrType(types.Package)), $String], false), -1], ["parseNumber", "parseNumber", "code.google.com/p/go.tools/go/gcimporter", $funcType([], [($ptrType(types.Basic)), exact.Value], false), -1], ["parsePackageId", "parsePackageId", "code.google.com/p/go.tools/go/gcimporter", $funcType([], [$String], false), -1], ["parsePackageName", "parsePackageName", "code.google.com/p/go.tools/go/gcimporter", $funcType([], [$String], false), -1], ["parseParameter", "parseParameter", "code.google.com/p/go.tools/go/gcimporter", $funcType([], [($ptrType(types.Var)), $Bool], false), -1], ["parseParameters", "parseParameters", "code.google.com/p/go.tools/go/gcimporter", $funcType([], [($sliceType(($ptrType(types.Var)))), $Bool], false), -1], ["parseQualifiedName", "parseQualifiedName", "code.google.com/p/go.tools/go/gcimporter", $funcType([], [$String, $String], false), -1], ["parseSignature", "parseSignature", "code.google.com/p/go.tools/go/gcimporter", $funcType([($ptrType(types.Var))], [($ptrType(types.Signature))], false), -1], ["parseStructType", "parseStructType", "code.google.com/p/go.tools/go/gcimporter", $funcType([], [types.Type], false), -1], ["parseType", "parseType", "code.google.com/p/go.tools/go/gcimporter", $funcType([], [types.Type], false), -1], ["parseTypeDecl", "parseTypeDecl", "code.google.com/p/go.tools/go/gcimporter", $funcType([], [], false), -1], ["parseVarDecl", "parseVarDecl", "code.google.com/p/go.tools/go/gcimporter", $funcType([], [], false), -1]]; - parser.init([["scanner", "scanner", "code.google.com/p/go.tools/go/gcimporter", scanner.Scanner, ""], ["tok", "tok", "code.google.com/p/go.tools/go/gcimporter", $Int32, ""], ["lit", "lit", "code.google.com/p/go.tools/go/gcimporter", $String, ""], ["id", "id", "code.google.com/p/go.tools/go/gcimporter", $String, ""], ["imports", "imports", "code.google.com/p/go.tools/go/gcimporter", ($mapType($String, ($ptrType(types.Package)))), ""]]); - importError.methods = [["Error", "Error", "", $funcType([], [$String], false), -1]]; - ($ptrType(importError)).methods = [["Error", "Error", "", $funcType([], [$String], false), -1]]; - importError.init([["pos", "pos", "code.google.com/p/go.tools/go/gcimporter", scanner.Position, ""], ["err", "err", "code.google.com/p/go.tools/go/gcimporter", $error, ""]]); - pkgExts = $toNativeArray("String", [".a", ".5", ".6", ".8"]); - init(); + Regexp.prototype.FindSubmatch = function(b) { return this.$val.FindSubmatch(b); }; + Regexp.Ptr.prototype.Expand = function(dst, template, src, match) { + var re; + re = this; + return re.expand(dst, $bytesToString(template), src, "", match); }; - return $pkg; -})(); -$packages["encoding/asn1"] = (function() { - var $pkg = {}, fmt = $packages["fmt"], big = $packages["math/big"], reflect = $packages["reflect"], strconv = $packages["strconv"], time = $packages["time"], strings = $packages["strings"], bytes = $packages["bytes"], errors = $packages["errors"], io = $packages["io"], utf8 = $packages["unicode/utf8"], StructuralError, SyntaxError, BitString, ObjectIdentifier, Enumerated, Flag, RawValue, RawContent, tagAndLength, fieldParameters, bigOne, bitStringType, objectIdentifierType, enumeratedType, flagType, timeType, rawValueType, rawContentsType, bigIntType, x, x$1, x$2, parseBool, parseInt64, parseInt32, parseBigInt, parseBitString, parseObjectIdentifier, parseBase128Int, parseUTCTime, parseGeneralizedTime, parsePrintableString, isPrintable, parseIA5String, parseT61String, parseUTF8String, parseTagAndLength, parseSequenceOf, invalidLength, parseField, setDefaultValue, Unmarshal, UnmarshalWithParams, parseFieldParameters, getUniversalType; - StructuralError = $pkg.StructuralError = $newType(0, "Struct", "asn1.StructuralError", "StructuralError", "encoding/asn1", function(Msg_) { - this.$val = this; - this.Msg = Msg_ !== undefined ? Msg_ : ""; - }); - SyntaxError = $pkg.SyntaxError = $newType(0, "Struct", "asn1.SyntaxError", "SyntaxError", "encoding/asn1", function(Msg_) { - this.$val = this; - this.Msg = Msg_ !== undefined ? Msg_ : ""; - }); - BitString = $pkg.BitString = $newType(0, "Struct", "asn1.BitString", "BitString", "encoding/asn1", function(Bytes_, BitLength_) { - this.$val = this; - this.Bytes = Bytes_ !== undefined ? Bytes_ : ($sliceType($Uint8)).nil; - this.BitLength = BitLength_ !== undefined ? BitLength_ : 0; - }); - ObjectIdentifier = $pkg.ObjectIdentifier = $newType(12, "Slice", "asn1.ObjectIdentifier", "ObjectIdentifier", "encoding/asn1", null); - Enumerated = $pkg.Enumerated = $newType(4, "Int", "asn1.Enumerated", "Enumerated", "encoding/asn1", null); - Flag = $pkg.Flag = $newType(1, "Bool", "asn1.Flag", "Flag", "encoding/asn1", null); - RawValue = $pkg.RawValue = $newType(0, "Struct", "asn1.RawValue", "RawValue", "encoding/asn1", function(Class_, Tag_, IsCompound_, Bytes_, FullBytes_) { - this.$val = this; - this.Class = Class_ !== undefined ? Class_ : 0; - this.Tag = Tag_ !== undefined ? Tag_ : 0; - this.IsCompound = IsCompound_ !== undefined ? IsCompound_ : false; - this.Bytes = Bytes_ !== undefined ? Bytes_ : ($sliceType($Uint8)).nil; - this.FullBytes = FullBytes_ !== undefined ? FullBytes_ : ($sliceType($Uint8)).nil; - }); - RawContent = $pkg.RawContent = $newType(12, "Slice", "asn1.RawContent", "RawContent", "encoding/asn1", null); - tagAndLength = $pkg.tagAndLength = $newType(0, "Struct", "asn1.tagAndLength", "tagAndLength", "encoding/asn1", function(class$0_, tag_, length_, isCompound_) { - this.$val = this; - this.class$0 = class$0_ !== undefined ? class$0_ : 0; - this.tag = tag_ !== undefined ? tag_ : 0; - this.length = length_ !== undefined ? length_ : 0; - this.isCompound = isCompound_ !== undefined ? isCompound_ : false; - }); - fieldParameters = $pkg.fieldParameters = $newType(0, "Struct", "asn1.fieldParameters", "fieldParameters", "encoding/asn1", function(optional_, explicit_, application_, defaultValue_, tag_, stringType_, set_, omitEmpty_) { - this.$val = this; - this.optional = optional_ !== undefined ? optional_ : false; - this.explicit = explicit_ !== undefined ? explicit_ : false; - this.application = application_ !== undefined ? application_ : false; - this.defaultValue = defaultValue_ !== undefined ? defaultValue_ : ($ptrType($Int64)).nil; - this.tag = tag_ !== undefined ? tag_ : ($ptrType($Int)).nil; - this.stringType = stringType_ !== undefined ? stringType_ : 0; - this.set = set_ !== undefined ? set_ : false; - this.omitEmpty = omitEmpty_ !== undefined ? omitEmpty_ : false; - }); - StructuralError.Ptr.prototype.Error = function() { - var e; - e = new StructuralError.Ptr(); $copy(e, this, StructuralError); - return "asn1: structure error: " + e.Msg; + Regexp.prototype.Expand = function(dst, template, src, match) { return this.$val.Expand(dst, template, src, match); }; + Regexp.Ptr.prototype.ExpandString = function(dst, template, src, match) { + var re; + re = this; + return re.expand(dst, template, ($sliceType($Uint8)).nil, src, match); }; - StructuralError.prototype.Error = function() { return this.$val.Error(); }; - SyntaxError.Ptr.prototype.Error = function() { - var e; - e = new SyntaxError.Ptr(); $copy(e, this, SyntaxError); - return "asn1: syntax error: " + e.Msg; + Regexp.prototype.ExpandString = function(dst, template, src, match) { return this.$val.ExpandString(dst, template, src, match); }; + Regexp.Ptr.prototype.expand = function(dst, template, bsrc, src, match) { + var re, i, _tuple, name, num, rest, ok, x, x$1, x$2, x$3, x$4, _ref, _i, i$1, namei, x$5, x$6, x$7, x$8, x$9; + re = this; + while (template.length > 0) { + i = strings.Index(template, "$"); + if (i < 0) { + break; + } + dst = $appendSlice(dst, new ($sliceType($Uint8))($stringToBytes(template.substring(0, i)))); + template = template.substring(i); + if (template.length > 1 && (template.charCodeAt(1) === 36)) { + dst = $append(dst, 36); + template = template.substring(2); + continue; + } + _tuple = extract(template); name = _tuple[0]; num = _tuple[1]; rest = _tuple[2]; ok = _tuple[3]; + if (!ok) { + dst = $append(dst, 36); + template = template.substring(1); + continue; + } + template = rest; + if (num >= 0) { + if ((((((2 >>> 16 << 16) * num >> 0) + (2 << 16 >>> 16) * num) >> 0) + 1 >> 0) < match.$length && (x = (((2 >>> 16 << 16) * num >> 0) + (2 << 16 >>> 16) * num) >> 0, ((x < 0 || x >= match.$length) ? $throwRuntimeError("index out of range") : match.$array[match.$offset + x])) >= 0) { + if (!(bsrc === ($sliceType($Uint8)).nil)) { + dst = $appendSlice(dst, $subslice(bsrc, (x$1 = (((2 >>> 16 << 16) * num >> 0) + (2 << 16 >>> 16) * num) >> 0, ((x$1 < 0 || x$1 >= match.$length) ? $throwRuntimeError("index out of range") : match.$array[match.$offset + x$1])), (x$2 = ((((2 >>> 16 << 16) * num >> 0) + (2 << 16 >>> 16) * num) >> 0) + 1 >> 0, ((x$2 < 0 || x$2 >= match.$length) ? $throwRuntimeError("index out of range") : match.$array[match.$offset + x$2])))); + } else { + dst = $appendSlice(dst, new ($sliceType($Uint8))($stringToBytes(src.substring((x$3 = (((2 >>> 16 << 16) * num >> 0) + (2 << 16 >>> 16) * num) >> 0, ((x$3 < 0 || x$3 >= match.$length) ? $throwRuntimeError("index out of range") : match.$array[match.$offset + x$3])), (x$4 = ((((2 >>> 16 << 16) * num >> 0) + (2 << 16 >>> 16) * num) >> 0) + 1 >> 0, ((x$4 < 0 || x$4 >= match.$length) ? $throwRuntimeError("index out of range") : match.$array[match.$offset + x$4])))))); + } + } + } else { + _ref = re.subexpNames; + _i = 0; + while (_i < _ref.$length) { + i$1 = _i; + namei = ((_i < 0 || _i >= _ref.$length) ? $throwRuntimeError("index out of range") : _ref.$array[_ref.$offset + _i]); + if (name === namei && (((((2 >>> 16 << 16) * i$1 >> 0) + (2 << 16 >>> 16) * i$1) >> 0) + 1 >> 0) < match.$length && (x$5 = (((2 >>> 16 << 16) * i$1 >> 0) + (2 << 16 >>> 16) * i$1) >> 0, ((x$5 < 0 || x$5 >= match.$length) ? $throwRuntimeError("index out of range") : match.$array[match.$offset + x$5])) >= 0) { + if (!(bsrc === ($sliceType($Uint8)).nil)) { + dst = $appendSlice(dst, $subslice(bsrc, (x$6 = (((2 >>> 16 << 16) * i$1 >> 0) + (2 << 16 >>> 16) * i$1) >> 0, ((x$6 < 0 || x$6 >= match.$length) ? $throwRuntimeError("index out of range") : match.$array[match.$offset + x$6])), (x$7 = ((((2 >>> 16 << 16) * i$1 >> 0) + (2 << 16 >>> 16) * i$1) >> 0) + 1 >> 0, ((x$7 < 0 || x$7 >= match.$length) ? $throwRuntimeError("index out of range") : match.$array[match.$offset + x$7])))); + } else { + dst = $appendSlice(dst, new ($sliceType($Uint8))($stringToBytes(src.substring((x$8 = (((2 >>> 16 << 16) * i$1 >> 0) + (2 << 16 >>> 16) * i$1) >> 0, ((x$8 < 0 || x$8 >= match.$length) ? $throwRuntimeError("index out of range") : match.$array[match.$offset + x$8])), (x$9 = ((((2 >>> 16 << 16) * i$1 >> 0) + (2 << 16 >>> 16) * i$1) >> 0) + 1 >> 0, ((x$9 < 0 || x$9 >= match.$length) ? $throwRuntimeError("index out of range") : match.$array[match.$offset + x$9])))))); + } + break; + } + _i++; + } + } + } + dst = $appendSlice(dst, new ($sliceType($Uint8))($stringToBytes(template))); + return dst; }; - SyntaxError.prototype.Error = function() { return this.$val.Error(); }; - parseBool = function(bytes$1) { - var ret = false, err = $ifaceNil, x$3, _ref, x$4; - if (!((bytes$1.$length === 1))) { - err = (x$3 = new SyntaxError.Ptr("invalid boolean"), new x$3.constructor.Struct(x$3)); - return [ret, err]; + Regexp.prototype.expand = function(dst, template, bsrc, src, match) { return this.$val.expand(dst, template, bsrc, src, match); }; + extract = function(str) { + var name = "", num = 0, rest = "", ok = false, brace, i, _tuple, rune, size, i$1; + if (str.length < 2 || !((str.charCodeAt(0) === 36))) { + return [name, num, rest, ok]; } - _ref = ((0 < 0 || 0 >= bytes$1.$length) ? $throwRuntimeError("index out of range") : bytes$1.$array[bytes$1.$offset + 0]); - if (_ref === 0) { - ret = false; - } else if (_ref === 255) { - ret = true; + brace = false; + if (str.charCodeAt(1) === 123) { + brace = true; + str = str.substring(2); } else { - err = (x$4 = new SyntaxError.Ptr("invalid boolean"), new x$4.constructor.Struct(x$4)); + str = str.substring(1); } - return [ret, err]; - }; - parseInt64 = function(bytes$1) { - var ret = new $Int64(0, 0), err = $ifaceNil, x$3, bytesRead, x$4; - if (bytes$1.$length > 8) { - err = (x$3 = new StructuralError.Ptr("integer too large"), new x$3.constructor.Struct(x$3)); - return [ret, err]; + i = 0; + while (i < str.length) { + _tuple = utf8.DecodeRuneInString(str.substring(i)); rune = _tuple[0]; size = _tuple[1]; + if (!unicode.IsLetter(rune) && !unicode.IsDigit(rune) && !((rune === 95))) { + break; + } + i = i + (size) >> 0; } - bytesRead = 0; - while (bytesRead < bytes$1.$length) { - ret = $shiftLeft64(ret, (8)); - ret = (x$4 = new $Int64(0, ((bytesRead < 0 || bytesRead >= bytes$1.$length) ? $throwRuntimeError("index out of range") : bytes$1.$array[bytes$1.$offset + bytesRead])), new $Int64(ret.$high | x$4.$high, (ret.$low | x$4.$low) >>> 0)); - bytesRead = bytesRead + (1) >> 0; + if (i === 0) { + return [name, num, rest, ok]; } - ret = $shiftLeft64(ret, ((64 - ((bytes$1.$length << 24 >>> 24) * 8 << 24 >>> 24) << 24 >>> 24))); - ret = $shiftRightInt64(ret, ((64 - ((bytes$1.$length << 24 >>> 24) * 8 << 24 >>> 24) << 24 >>> 24))); - return [ret, err]; - }; - parseInt32 = function(bytes$1) { - var _tuple, ret64, err, x$3, x$4; - _tuple = parseInt64(bytes$1); ret64 = _tuple[0]; err = _tuple[1]; - if (!($interfaceIsEqual(err, $ifaceNil))) { - return [0, err]; + name = str.substring(0, i); + if (brace) { + if (i >= str.length || !((str.charCodeAt(i) === 125))) { + return [name, num, rest, ok]; + } + i = i + (1) >> 0; } - if (!((x$3 = new $Int64(0, ((ret64.$low + ((ret64.$high >> 31) * 4294967296)) >> 0)), (ret64.$high === x$3.$high && ret64.$low === x$3.$low)))) { - return [0, (x$4 = new StructuralError.Ptr("integer too large"), new x$4.constructor.Struct(x$4))]; + num = 0; + i$1 = 0; + while (i$1 < name.length) { + if (name.charCodeAt(i$1) < 48 || 57 < name.charCodeAt(i$1) || num >= 100000000) { + num = -1; + break; + } + num = (((((num >>> 16 << 16) * 10 >> 0) + (num << 16 >>> 16) * 10) >> 0) + (name.charCodeAt(i$1) >> 0) >> 0) - 48 >> 0; + i$1 = i$1 + (1) >> 0; } - return [((ret64.$low + ((ret64.$high >> 31) * 4294967296)) >> 0), $ifaceNil]; + if ((name.charCodeAt(0) === 48) && name.length > 1) { + num = -1; + } + rest = str.substring(i); + ok = true; + return [name, num, rest, ok]; }; - parseBigInt = function(bytes$1) { - var ret, notBytes, _ref, _i, i; - ret = new big.Int.Ptr(); - if (bytes$1.$length > 0 && (((((0 < 0 || 0 >= bytes$1.$length) ? $throwRuntimeError("index out of range") : bytes$1.$array[bytes$1.$offset + 0]) & 128) >>> 0) === 128)) { - notBytes = ($sliceType($Uint8)).make(bytes$1.$length); - _ref = notBytes; - _i = 0; - while (_i < _ref.$length) { - i = _i; - (i < 0 || i >= notBytes.$length) ? $throwRuntimeError("index out of range") : notBytes.$array[notBytes.$offset + i] = ~((i < 0 || i >= bytes$1.$length) ? $throwRuntimeError("index out of range") : bytes$1.$array[bytes$1.$offset + i]) << 24 >>> 24; - _i++; + Regexp.Ptr.prototype.FindSubmatchIndex = function(b) { + var re; + re = this; + return re.pad(re.doExecute($ifaceNil, b, "", 0, re.prog.NumCap)); + }; + Regexp.prototype.FindSubmatchIndex = function(b) { return this.$val.FindSubmatchIndex(b); }; + Regexp.Ptr.prototype.FindStringSubmatch = function(s) { + var re, a, ret, _ref, _i, i, x, x$1, x$2; + re = this; + a = re.doExecute($ifaceNil, ($sliceType($Uint8)).nil, s, 0, re.prog.NumCap); + if (a === ($sliceType($Int)).nil) { + return ($sliceType($String)).nil; + } + ret = ($sliceType($String)).make((1 + re.numSubexp >> 0)); + _ref = ret; + _i = 0; + while (_i < _ref.$length) { + i = _i; + if (((((2 >>> 16 << 16) * i >> 0) + (2 << 16 >>> 16) * i) >> 0) < a.$length && (x = (((2 >>> 16 << 16) * i >> 0) + (2 << 16 >>> 16) * i) >> 0, ((x < 0 || x >= a.$length) ? $throwRuntimeError("index out of range") : a.$array[a.$offset + x])) >= 0) { + (i < 0 || i >= ret.$length) ? $throwRuntimeError("index out of range") : ret.$array[ret.$offset + i] = s.substring((x$1 = (((2 >>> 16 << 16) * i >> 0) + (2 << 16 >>> 16) * i) >> 0, ((x$1 < 0 || x$1 >= a.$length) ? $throwRuntimeError("index out of range") : a.$array[a.$offset + x$1])), (x$2 = ((((2 >>> 16 << 16) * i >> 0) + (2 << 16 >>> 16) * i) >> 0) + 1 >> 0, ((x$2 < 0 || x$2 >= a.$length) ? $throwRuntimeError("index out of range") : a.$array[a.$offset + x$2]))); } - ret.SetBytes(notBytes); - ret.Add(ret, bigOne); - ret.Neg(ret); - return ret; + _i++; } - ret.SetBytes(bytes$1); return ret; }; - BitString.Ptr.prototype.At = function(i) { - var b, _q, x$3, _r, y, y$1, x$4; - b = new BitString.Ptr(); $copy(b, this, BitString); - if (i < 0 || i >= b.BitLength) { - return 0; - } - x$3 = (_q = i / 8, (_q === _q && _q !== 1/0 && _q !== -1/0) ? _q >> 0 : $throwRuntimeError("integer divide by zero")); - y = 7 - ((_r = i % 8, _r === _r ? _r : $throwRuntimeError("integer divide by zero")) >>> 0) >>> 0; - return (((y$1 = y, y$1 < 32 ? ((x$4 = b.Bytes, ((x$3 < 0 || x$3 >= x$4.$length) ? $throwRuntimeError("index out of range") : x$4.$array[x$4.$offset + x$3])) >>> y$1) : 0) << 24 >>> 24) >> 0) & 1; + Regexp.prototype.FindStringSubmatch = function(s) { return this.$val.FindStringSubmatch(s); }; + Regexp.Ptr.prototype.FindStringSubmatchIndex = function(s) { + var re; + re = this; + return re.pad(re.doExecute($ifaceNil, ($sliceType($Uint8)).nil, s, 0, re.prog.NumCap)); }; - BitString.prototype.At = function(i) { return this.$val.At(i); }; - BitString.Ptr.prototype.RightAlign = function() { - var b, _r, shift, a, y, x$3, i, y$1, x$4, x$5, _lhs, _index, y$2, x$6; - b = new BitString.Ptr(); $copy(b, this, BitString); - shift = ((8 - ((_r = b.BitLength % 8, _r === _r ? _r : $throwRuntimeError("integer divide by zero"))) >> 0) >>> 0); - if ((shift === 8) || (b.Bytes.$length === 0)) { - return b.Bytes; + Regexp.prototype.FindStringSubmatchIndex = function(s) { return this.$val.FindStringSubmatchIndex(s); }; + Regexp.Ptr.prototype.FindReaderSubmatchIndex = function(r) { + var re; + re = this; + return re.pad(re.doExecute(r, ($sliceType($Uint8)).nil, "", 0, re.prog.NumCap)); + }; + Regexp.prototype.FindReaderSubmatchIndex = function(r) { return this.$val.FindReaderSubmatchIndex(r); }; + Regexp.Ptr.prototype.FindAll = function(b, n) { + var re, result; + re = this; + if (n < 0) { + n = b.$length + 1 >> 0; } - a = ($sliceType($Uint8)).make(b.Bytes.$length); - (0 < 0 || 0 >= a.$length) ? $throwRuntimeError("index out of range") : a.$array[a.$offset + 0] = (y = shift, y < 32 ? ((x$3 = b.Bytes, ((0 < 0 || 0 >= x$3.$length) ? $throwRuntimeError("index out of range") : x$3.$array[x$3.$offset + 0])) >>> y) : 0) << 24 >>> 24; - i = 1; - while (i < b.Bytes.$length) { - (i < 0 || i >= a.$length) ? $throwRuntimeError("index out of range") : a.$array[a.$offset + i] = (y$1 = ((8 - shift >>> 0)), y$1 < 32 ? ((x$4 = b.Bytes, x$5 = i - 1 >> 0, ((x$5 < 0 || x$5 >= x$4.$length) ? $throwRuntimeError("index out of range") : x$4.$array[x$4.$offset + x$5])) << y$1) : 0) << 24 >>> 24; - _lhs = a; _index = i; (_index < 0 || _index >= _lhs.$length) ? $throwRuntimeError("index out of range") : _lhs.$array[_lhs.$offset + _index] = (((_index < 0 || _index >= _lhs.$length) ? $throwRuntimeError("index out of range") : _lhs.$array[_lhs.$offset + _index]) | (((y$2 = shift, y$2 < 32 ? ((x$6 = b.Bytes, ((i < 0 || i >= x$6.$length) ? $throwRuntimeError("index out of range") : x$6.$array[x$6.$offset + i])) >>> y$2) : 0) << 24 >>> 24))) >>> 0; - i = i + (1) >> 0; + result = ($sliceType(($sliceType($Uint8)))).make(0, 10); + re.allMatches("", b, n, (function(match) { + result = $append(result, $subslice(b, ((0 < 0 || 0 >= match.$length) ? $throwRuntimeError("index out of range") : match.$array[match.$offset + 0]), ((1 < 0 || 1 >= match.$length) ? $throwRuntimeError("index out of range") : match.$array[match.$offset + 1]))); + })); + if (result.$length === 0) { + return ($sliceType(($sliceType($Uint8)))).nil; } - return a; + return result; }; - BitString.prototype.RightAlign = function() { return this.$val.RightAlign(); }; - parseBitString = function(bytes$1) { - var ret = new BitString.Ptr(), err = $ifaceNil, x$3, paddingBits, x$4, y, x$5, x$6; - if (bytes$1.$length === 0) { - err = (x$3 = new SyntaxError.Ptr("zero length BIT STRING"), new x$3.constructor.Struct(x$3)); - return [ret, err]; + Regexp.prototype.FindAll = function(b, n) { return this.$val.FindAll(b, n); }; + Regexp.Ptr.prototype.FindAllIndex = function(b, n) { + var re, result; + re = this; + if (n < 0) { + n = b.$length + 1 >> 0; } - paddingBits = (((0 < 0 || 0 >= bytes$1.$length) ? $throwRuntimeError("index out of range") : bytes$1.$array[bytes$1.$offset + 0]) >> 0); - if (paddingBits > 7 || (bytes$1.$length === 1) && paddingBits > 0 || !(((((x$4 = bytes$1.$length - 1 >> 0, ((x$4 < 0 || x$4 >= bytes$1.$length) ? $throwRuntimeError("index out of range") : bytes$1.$array[bytes$1.$offset + x$4])) & (((((y = ((0 < 0 || 0 >= bytes$1.$length) ? $throwRuntimeError("index out of range") : bytes$1.$array[bytes$1.$offset + 0]), y < 32 ? (1 << y) : 0) << 24 >>> 24)) - 1 << 24 >>> 24))) >>> 0) === 0))) { - err = (x$5 = new SyntaxError.Ptr("invalid padding bits in BIT STRING"), new x$5.constructor.Struct(x$5)); - return [ret, err]; + result = ($sliceType(($sliceType($Int)))).make(0, 10); + re.allMatches("", b, n, (function(match) { + result = $append(result, $subslice(match, 0, 2)); + })); + if (result.$length === 0) { + return ($sliceType(($sliceType($Int)))).nil; } - ret.BitLength = (x$6 = (bytes$1.$length - 1 >> 0), (((x$6 >>> 16 << 16) * 8 >> 0) + (x$6 << 16 >>> 16) * 8) >> 0) - paddingBits >> 0; - ret.Bytes = $subslice(bytes$1, 1); - return [ret, err]; + return result; }; - ObjectIdentifier.prototype.Equal = function(other) { - var oi, i; - oi = this; - if (!((oi.$length === other.$length))) { - return false; + Regexp.prototype.FindAllIndex = function(b, n) { return this.$val.FindAllIndex(b, n); }; + Regexp.Ptr.prototype.FindAllString = function(s, n) { + var re, result; + re = this; + if (n < 0) { + n = s.length + 1 >> 0; } - i = 0; - while (i < oi.$length) { - if (!((((i < 0 || i >= oi.$length) ? $throwRuntimeError("index out of range") : oi.$array[oi.$offset + i]) === ((i < 0 || i >= other.$length) ? $throwRuntimeError("index out of range") : other.$array[other.$offset + i])))) { - return false; - } - i = i + (1) >> 0; + result = ($sliceType($String)).make(0, 10); + re.allMatches(s, ($sliceType($Uint8)).nil, n, (function(match) { + result = $append(result, s.substring(((0 < 0 || 0 >= match.$length) ? $throwRuntimeError("index out of range") : match.$array[match.$offset + 0]), ((1 < 0 || 1 >= match.$length) ? $throwRuntimeError("index out of range") : match.$array[match.$offset + 1]))); + })); + if (result.$length === 0) { + return ($sliceType($String)).nil; } - return true; + return result; }; - $ptrType(ObjectIdentifier).prototype.Equal = function(other) { return this.$get().Equal(other); }; - ObjectIdentifier.prototype.String = function() { - var oi, s, _ref, _i, i, v; - oi = this; - s = ""; - _ref = oi; - _i = 0; - while (_i < _ref.$length) { - i = _i; - v = ((_i < 0 || _i >= _ref.$length) ? $throwRuntimeError("index out of range") : _ref.$array[_ref.$offset + _i]); - if (i > 0) { - s = s + ("."); - } - s = s + (strconv.Itoa(v)); - _i++; + Regexp.prototype.FindAllString = function(s, n) { return this.$val.FindAllString(s, n); }; + Regexp.Ptr.prototype.FindAllStringIndex = function(s, n) { + var re, result; + re = this; + if (n < 0) { + n = s.length + 1 >> 0; + } + result = ($sliceType(($sliceType($Int)))).make(0, 10); + re.allMatches(s, ($sliceType($Uint8)).nil, n, (function(match) { + result = $append(result, $subslice(match, 0, 2)); + })); + if (result.$length === 0) { + return ($sliceType(($sliceType($Int)))).nil; } - return s; + return result; }; - $ptrType(ObjectIdentifier).prototype.String = function() { return this.$get().String(); }; - parseObjectIdentifier = function(bytes$1) { - var s = ($sliceType($Int)).nil, err = $ifaceNil, x$3, _tuple, v, offset, _q, _r, i, _tuple$1; - if (bytes$1.$length === 0) { - err = (x$3 = new SyntaxError.Ptr("zero length OBJECT IDENTIFIER"), new x$3.constructor.Struct(x$3)); - return [s, err]; + Regexp.prototype.FindAllStringIndex = function(s, n) { return this.$val.FindAllStringIndex(s, n); }; + Regexp.Ptr.prototype.FindAllSubmatch = function(b, n) { + var re, result; + re = this; + if (n < 0) { + n = b.$length + 1 >> 0; } - s = ($sliceType($Int)).make((bytes$1.$length + 1 >> 0)); - _tuple = parseBase128Int(bytes$1, 0); v = _tuple[0]; offset = _tuple[1]; err = _tuple[2]; - if (!($interfaceIsEqual(err, $ifaceNil))) { - return [s, err]; + result = ($sliceType(($sliceType(($sliceType($Uint8)))))).make(0, 10); + re.allMatches("", b, n, (function(match) { + var _q, slice, _ref, _i, j, x, x$1, x$2; + slice = ($sliceType(($sliceType($Uint8)))).make((_q = match.$length / 2, (_q === _q && _q !== 1/0 && _q !== -1/0) ? _q >> 0 : $throwRuntimeError("integer divide by zero"))); + _ref = slice; + _i = 0; + while (_i < _ref.$length) { + j = _i; + if ((x = (((2 >>> 16 << 16) * j >> 0) + (2 << 16 >>> 16) * j) >> 0, ((x < 0 || x >= match.$length) ? $throwRuntimeError("index out of range") : match.$array[match.$offset + x])) >= 0) { + (j < 0 || j >= slice.$length) ? $throwRuntimeError("index out of range") : slice.$array[slice.$offset + j] = $subslice(b, (x$1 = (((2 >>> 16 << 16) * j >> 0) + (2 << 16 >>> 16) * j) >> 0, ((x$1 < 0 || x$1 >= match.$length) ? $throwRuntimeError("index out of range") : match.$array[match.$offset + x$1])), (x$2 = ((((2 >>> 16 << 16) * j >> 0) + (2 << 16 >>> 16) * j) >> 0) + 1 >> 0, ((x$2 < 0 || x$2 >= match.$length) ? $throwRuntimeError("index out of range") : match.$array[match.$offset + x$2]))); + } + _i++; + } + result = $append(result, slice); + })); + if (result.$length === 0) { + return ($sliceType(($sliceType(($sliceType($Uint8)))))).nil; } - if (v < 80) { - (0 < 0 || 0 >= s.$length) ? $throwRuntimeError("index out of range") : s.$array[s.$offset + 0] = (_q = v / 40, (_q === _q && _q !== 1/0 && _q !== -1/0) ? _q >> 0 : $throwRuntimeError("integer divide by zero")); - (1 < 0 || 1 >= s.$length) ? $throwRuntimeError("index out of range") : s.$array[s.$offset + 1] = (_r = v % 40, _r === _r ? _r : $throwRuntimeError("integer divide by zero")); - } else { - (0 < 0 || 0 >= s.$length) ? $throwRuntimeError("index out of range") : s.$array[s.$offset + 0] = 2; - (1 < 0 || 1 >= s.$length) ? $throwRuntimeError("index out of range") : s.$array[s.$offset + 1] = v - 80 >> 0; + return result; + }; + Regexp.prototype.FindAllSubmatch = function(b, n) { return this.$val.FindAllSubmatch(b, n); }; + Regexp.Ptr.prototype.FindAllSubmatchIndex = function(b, n) { + var re, result; + re = this; + if (n < 0) { + n = b.$length + 1 >> 0; } - i = 2; - while (offset < bytes$1.$length) { - _tuple$1 = parseBase128Int(bytes$1, offset); v = _tuple$1[0]; offset = _tuple$1[1]; err = _tuple$1[2]; - if (!($interfaceIsEqual(err, $ifaceNil))) { - return [s, err]; - } - (i < 0 || i >= s.$length) ? $throwRuntimeError("index out of range") : s.$array[s.$offset + i] = v; - i = i + (1) >> 0; + result = ($sliceType(($sliceType($Int)))).make(0, 10); + re.allMatches("", b, n, (function(match) { + result = $append(result, match); + })); + if (result.$length === 0) { + return ($sliceType(($sliceType($Int)))).nil; } - s = $subslice(s, 0, i); - return [s, err]; + return result; }; - parseBase128Int = function(bytes$1, initOffset) { - var ret = 0, offset = 0, err = $ifaceNil, shifted, x$3, y, b, x$4; - offset = initOffset; - shifted = 0; - while (offset < bytes$1.$length) { - if (shifted > 4) { - err = (x$3 = new StructuralError.Ptr("base 128 integer too large"), new x$3.constructor.Struct(x$3)); - return [ret, offset, err]; - } - ret = (y = (7), y < 32 ? (ret << y) : 0) >> 0; - b = ((offset < 0 || offset >= bytes$1.$length) ? $throwRuntimeError("index out of range") : bytes$1.$array[bytes$1.$offset + offset]); - ret = ret | ((((b & 127) >>> 0) >> 0)); - offset = offset + (1) >> 0; - if (((b & 128) >>> 0) === 0) { - return [ret, offset, err]; + Regexp.prototype.FindAllSubmatchIndex = function(b, n) { return this.$val.FindAllSubmatchIndex(b, n); }; + Regexp.Ptr.prototype.FindAllStringSubmatch = function(s, n) { + var re, result; + re = this; + if (n < 0) { + n = s.length + 1 >> 0; + } + result = ($sliceType(($sliceType($String)))).make(0, 10); + re.allMatches(s, ($sliceType($Uint8)).nil, n, (function(match) { + var _q, slice, _ref, _i, j, x, x$1, x$2; + slice = ($sliceType($String)).make((_q = match.$length / 2, (_q === _q && _q !== 1/0 && _q !== -1/0) ? _q >> 0 : $throwRuntimeError("integer divide by zero"))); + _ref = slice; + _i = 0; + while (_i < _ref.$length) { + j = _i; + if ((x = (((2 >>> 16 << 16) * j >> 0) + (2 << 16 >>> 16) * j) >> 0, ((x < 0 || x >= match.$length) ? $throwRuntimeError("index out of range") : match.$array[match.$offset + x])) >= 0) { + (j < 0 || j >= slice.$length) ? $throwRuntimeError("index out of range") : slice.$array[slice.$offset + j] = s.substring((x$1 = (((2 >>> 16 << 16) * j >> 0) + (2 << 16 >>> 16) * j) >> 0, ((x$1 < 0 || x$1 >= match.$length) ? $throwRuntimeError("index out of range") : match.$array[match.$offset + x$1])), (x$2 = ((((2 >>> 16 << 16) * j >> 0) + (2 << 16 >>> 16) * j) >> 0) + 1 >> 0, ((x$2 < 0 || x$2 >= match.$length) ? $throwRuntimeError("index out of range") : match.$array[match.$offset + x$2]))); + } + _i++; } - shifted = shifted + (1) >> 0; + result = $append(result, slice); + })); + if (result.$length === 0) { + return ($sliceType(($sliceType($String)))).nil; } - err = (x$4 = new SyntaxError.Ptr("truncated base 128 integer"), new x$4.constructor.Struct(x$4)); - return [ret, offset, err]; + return result; }; - parseUTCTime = function(bytes$1) { - var ret = new time.Time.Ptr(), err = $ifaceNil, s, _tuple, _tuple$1; - s = $bytesToString(bytes$1); - _tuple = time.Parse("0601021504Z0700", s); $copy(ret, _tuple[0], time.Time); err = _tuple[1]; - if (!($interfaceIsEqual(err, $ifaceNil))) { - _tuple$1 = time.Parse("060102150405Z0700", s); $copy(ret, _tuple$1[0], time.Time); err = _tuple$1[1]; + Regexp.prototype.FindAllStringSubmatch = function(s, n) { return this.$val.FindAllStringSubmatch(s, n); }; + Regexp.Ptr.prototype.FindAllStringSubmatchIndex = function(s, n) { + var re, result; + re = this; + if (n < 0) { + n = s.length + 1 >> 0; } - if ($interfaceIsEqual(err, $ifaceNil) && ret.Year() >= 2050) { - $copy(ret, ret.AddDate(-100, 0, 0), time.Time); + result = ($sliceType(($sliceType($Int)))).make(0, 10); + re.allMatches(s, ($sliceType($Uint8)).nil, n, (function(match) { + result = $append(result, match); + })); + if (result.$length === 0) { + return ($sliceType(($sliceType($Int)))).nil; } - return [ret, err]; - }; - parseGeneralizedTime = function(bytes$1) { - var ret = new time.Time.Ptr(), err = $ifaceNil, _tuple; - _tuple = time.Parse("20060102150405Z0700", $bytesToString(bytes$1)); $copy(ret, _tuple[0], time.Time); err = _tuple[1]; - return [ret, err]; + return result; }; - parsePrintableString = function(bytes$1) { - var ret = "", err = $ifaceNil, _ref, _i, b, x$3; - _ref = bytes$1; + Regexp.prototype.FindAllStringSubmatchIndex = function(s, n) { return this.$val.FindAllStringSubmatchIndex(s, n); }; + Regexp.Ptr.prototype.Split = function(s, n) { + var re, matches, strings$1, beg, end, _ref, _i, match; + re = this; + if (n === 0) { + return ($sliceType($String)).nil; + } + if (re.expr.length > 0 && (s.length === 0)) { + return new ($sliceType($String))([""]); + } + matches = re.FindAllStringIndex(s, n); + strings$1 = ($sliceType($String)).make(0, matches.$length); + beg = 0; + end = 0; + _ref = matches; _i = 0; while (_i < _ref.$length) { - b = ((_i < 0 || _i >= _ref.$length) ? $throwRuntimeError("index out of range") : _ref.$array[_ref.$offset + _i]); - if (!isPrintable(b)) { - err = (x$3 = new SyntaxError.Ptr("PrintableString contains invalid character"), new x$3.constructor.Struct(x$3)); - return [ret, err]; + match = ((_i < 0 || _i >= _ref.$length) ? $throwRuntimeError("index out of range") : _ref.$array[_ref.$offset + _i]); + if (n > 0 && strings$1.$length >= (n - 1 >> 0)) { + break; + } + end = ((0 < 0 || 0 >= match.$length) ? $throwRuntimeError("index out of range") : match.$array[match.$offset + 0]); + if (!((((1 < 0 || 1 >= match.$length) ? $throwRuntimeError("index out of range") : match.$array[match.$offset + 1]) === 0))) { + strings$1 = $append(strings$1, s.substring(beg, end)); } + beg = ((1 < 0 || 1 >= match.$length) ? $throwRuntimeError("index out of range") : match.$array[match.$offset + 1]); _i++; } - ret = $bytesToString(bytes$1); - return [ret, err]; + if (!((end === s.length))) { + strings$1 = $append(strings$1, s.substring(beg)); + } + return strings$1; }; - isPrintable = function(b) { - return 97 <= b && b <= 122 || 65 <= b && b <= 90 || 48 <= b && b <= 57 || 39 <= b && b <= 41 || 43 <= b && b <= 47 || (b === 32) || (b === 58) || (b === 61) || (b === 63) || (b === 42); + Regexp.prototype.Split = function(s, n) { return this.$val.Split(s, n); }; + $pkg.$init = function() { + queue.init([["sparse", "sparse", "regexp", ($sliceType($Uint32)), ""], ["dense", "dense", "regexp", ($sliceType(entry)), ""]]); + entry.init([["pc", "pc", "regexp", $Uint32, ""], ["t", "t", "regexp", ($ptrType(thread)), ""]]); + thread.init([["inst", "inst", "regexp", ($ptrType(syntax.Inst)), ""], ["cap", "cap", "regexp", ($sliceType($Int)), ""]]); + ($ptrType(machine)).methods = [["add", "add", "regexp", $funcType([($ptrType(queue)), $Uint32, $Int, ($sliceType($Int)), syntax.EmptyOp, ($ptrType(thread))], [($ptrType(thread))], false), -1], ["alloc", "alloc", "regexp", $funcType([($ptrType(syntax.Inst))], [($ptrType(thread))], false), -1], ["clear", "clear", "regexp", $funcType([($ptrType(queue))], [], false), -1], ["free", "free", "regexp", $funcType([($ptrType(thread))], [], false), -1], ["init", "init", "regexp", $funcType([$Int], [], false), -1], ["match", "match", "regexp", $funcType([input, $Int], [$Bool], false), -1], ["newInputBytes", "newInputBytes", "regexp", $funcType([($sliceType($Uint8))], [input], false), -1], ["newInputReader", "newInputReader", "regexp", $funcType([io.RuneReader], [input], false), -1], ["newInputString", "newInputString", "regexp", $funcType([$String], [input], false), -1], ["onepass", "onepass", "regexp", $funcType([input, $Int], [$Bool], false), -1], ["step", "step", "regexp", $funcType([($ptrType(queue)), ($ptrType(queue)), $Int, $Int, $Int32, syntax.EmptyOp], [], false), -1]]; + machine.init([["re", "re", "regexp", ($ptrType(Regexp)), ""], ["p", "p", "regexp", ($ptrType(syntax.Prog)), ""], ["op", "op", "regexp", ($ptrType(onePassProg)), ""], ["q0", "q0", "regexp", queue, ""], ["q1", "q1", "regexp", queue, ""], ["pool", "pool", "regexp", ($sliceType(($ptrType(thread)))), ""], ["matched", "matched", "regexp", $Bool, ""], ["matchcap", "matchcap", "regexp", ($sliceType($Int)), ""], ["inputBytes", "inputBytes", "regexp", inputBytes, ""], ["inputString", "inputString", "regexp", inputString, ""], ["inputReader", "inputReader", "regexp", inputReader, ""]]); + onePassProg.init([["Inst", "Inst", "", ($sliceType(onePassInst)), ""], ["Start", "Start", "", $Int, ""], ["NumCap", "NumCap", "", $Int, ""]]); + ($ptrType(onePassInst)).methods = [["MatchEmptyWidth", "MatchEmptyWidth", "", $funcType([$Int32, $Int32], [$Bool], false), 0], ["MatchRune", "MatchRune", "", $funcType([$Int32], [$Bool], false), 0], ["MatchRunePos", "MatchRunePos", "", $funcType([$Int32], [$Int], false), 0], ["String", "String", "", $funcType([], [$String], false), 0], ["op", "op", "regexp/syntax", $funcType([], [syntax.InstOp], false), 0]]; + onePassInst.init([["Inst", "", "", syntax.Inst, ""], ["Next", "Next", "", ($sliceType($Uint32)), ""]]); + ($ptrType(queueOnePass)).methods = [["clear", "clear", "regexp", $funcType([], [], false), -1], ["contains", "contains", "regexp", $funcType([$Uint32], [$Bool], false), -1], ["empty", "empty", "regexp", $funcType([], [$Bool], false), -1], ["insert", "insert", "regexp", $funcType([$Uint32], [], false), -1], ["insertNew", "insertNew", "regexp", $funcType([$Uint32], [], false), -1], ["next", "next", "regexp", $funcType([], [$Uint32], false), -1], ["reset", "reset", "regexp", $funcType([], [], false), -1]]; + queueOnePass.init([["sparse", "sparse", "regexp", ($sliceType($Uint32)), ""], ["dense", "dense", "regexp", ($sliceType($Uint32)), ""], ["size", "size", "regexp", $Uint32, ""], ["nextIndex", "nextIndex", "regexp", $Uint32, ""]]); + runeSlice.methods = [["Len", "Len", "", $funcType([], [$Int], false), -1], ["Less", "Less", "", $funcType([$Int, $Int], [$Bool], false), -1], ["Sort", "Sort", "", $funcType([], [], false), -1], ["Swap", "Swap", "", $funcType([$Int, $Int], [], false), -1]]; + ($ptrType(runeSlice)).methods = [["Len", "Len", "", $funcType([], [$Int], false), -1], ["Less", "Less", "", $funcType([$Int, $Int], [$Bool], false), -1], ["Sort", "Sort", "", $funcType([], [], false), -1], ["Swap", "Swap", "", $funcType([$Int, $Int], [], false), -1]]; + runeSlice.init($Int32); + ($ptrType(Regexp)).methods = [["Expand", "Expand", "", $funcType([($sliceType($Uint8)), ($sliceType($Uint8)), ($sliceType($Uint8)), ($sliceType($Int))], [($sliceType($Uint8))], false), -1], ["ExpandString", "ExpandString", "", $funcType([($sliceType($Uint8)), $String, $String, ($sliceType($Int))], [($sliceType($Uint8))], false), -1], ["Find", "Find", "", $funcType([($sliceType($Uint8))], [($sliceType($Uint8))], false), -1], ["FindAll", "FindAll", "", $funcType([($sliceType($Uint8)), $Int], [($sliceType(($sliceType($Uint8))))], false), -1], ["FindAllIndex", "FindAllIndex", "", $funcType([($sliceType($Uint8)), $Int], [($sliceType(($sliceType($Int))))], false), -1], ["FindAllString", "FindAllString", "", $funcType([$String, $Int], [($sliceType($String))], false), -1], ["FindAllStringIndex", "FindAllStringIndex", "", $funcType([$String, $Int], [($sliceType(($sliceType($Int))))], false), -1], ["FindAllStringSubmatch", "FindAllStringSubmatch", "", $funcType([$String, $Int], [($sliceType(($sliceType($String))))], false), -1], ["FindAllStringSubmatchIndex", "FindAllStringSubmatchIndex", "", $funcType([$String, $Int], [($sliceType(($sliceType($Int))))], false), -1], ["FindAllSubmatch", "FindAllSubmatch", "", $funcType([($sliceType($Uint8)), $Int], [($sliceType(($sliceType(($sliceType($Uint8))))))], false), -1], ["FindAllSubmatchIndex", "FindAllSubmatchIndex", "", $funcType([($sliceType($Uint8)), $Int], [($sliceType(($sliceType($Int))))], false), -1], ["FindIndex", "FindIndex", "", $funcType([($sliceType($Uint8))], [($sliceType($Int))], false), -1], ["FindReaderIndex", "FindReaderIndex", "", $funcType([io.RuneReader], [($sliceType($Int))], false), -1], ["FindReaderSubmatchIndex", "FindReaderSubmatchIndex", "", $funcType([io.RuneReader], [($sliceType($Int))], false), -1], ["FindString", "FindString", "", $funcType([$String], [$String], false), -1], ["FindStringIndex", "FindStringIndex", "", $funcType([$String], [($sliceType($Int))], false), -1], ["FindStringSubmatch", "FindStringSubmatch", "", $funcType([$String], [($sliceType($String))], false), -1], ["FindStringSubmatchIndex", "FindStringSubmatchIndex", "", $funcType([$String], [($sliceType($Int))], false), -1], ["FindSubmatch", "FindSubmatch", "", $funcType([($sliceType($Uint8))], [($sliceType(($sliceType($Uint8))))], false), -1], ["FindSubmatchIndex", "FindSubmatchIndex", "", $funcType([($sliceType($Uint8))], [($sliceType($Int))], false), -1], ["LiteralPrefix", "LiteralPrefix", "", $funcType([], [$String, $Bool], false), -1], ["Longest", "Longest", "", $funcType([], [], false), -1], ["Match", "Match", "", $funcType([($sliceType($Uint8))], [$Bool], false), -1], ["MatchReader", "MatchReader", "", $funcType([io.RuneReader], [$Bool], false), -1], ["MatchString", "MatchString", "", $funcType([$String], [$Bool], false), -1], ["NumSubexp", "NumSubexp", "", $funcType([], [$Int], false), -1], ["ReplaceAll", "ReplaceAll", "", $funcType([($sliceType($Uint8)), ($sliceType($Uint8))], [($sliceType($Uint8))], false), -1], ["ReplaceAllFunc", "ReplaceAllFunc", "", $funcType([($sliceType($Uint8)), ($funcType([($sliceType($Uint8))], [($sliceType($Uint8))], false))], [($sliceType($Uint8))], false), -1], ["ReplaceAllLiteral", "ReplaceAllLiteral", "", $funcType([($sliceType($Uint8)), ($sliceType($Uint8))], [($sliceType($Uint8))], false), -1], ["ReplaceAllLiteralString", "ReplaceAllLiteralString", "", $funcType([$String, $String], [$String], false), -1], ["ReplaceAllString", "ReplaceAllString", "", $funcType([$String, $String], [$String], false), -1], ["ReplaceAllStringFunc", "ReplaceAllStringFunc", "", $funcType([$String, ($funcType([$String], [$String], false))], [$String], false), -1], ["Split", "Split", "", $funcType([$String, $Int], [($sliceType($String))], false), -1], ["String", "String", "", $funcType([], [$String], false), -1], ["SubexpNames", "SubexpNames", "", $funcType([], [($sliceType($String))], false), -1], ["allMatches", "allMatches", "regexp", $funcType([$String, ($sliceType($Uint8)), $Int, ($funcType([($sliceType($Int))], [], false))], [], false), -1], ["doExecute", "doExecute", "regexp", $funcType([io.RuneReader, ($sliceType($Uint8)), $String, $Int, $Int], [($sliceType($Int))], false), -1], ["expand", "expand", "regexp", $funcType([($sliceType($Uint8)), $String, ($sliceType($Uint8)), $String, ($sliceType($Int))], [($sliceType($Uint8))], false), -1], ["get", "get", "regexp", $funcType([], [($ptrType(machine))], false), -1], ["pad", "pad", "regexp", $funcType([($sliceType($Int))], [($sliceType($Int))], false), -1], ["put", "put", "regexp", $funcType([($ptrType(machine))], [], false), -1], ["replaceAll", "replaceAll", "regexp", $funcType([($sliceType($Uint8)), $String, $Int, ($funcType([($sliceType($Uint8)), ($sliceType($Int))], [($sliceType($Uint8))], false))], [($sliceType($Uint8))], false), -1]]; + Regexp.init([["expr", "expr", "regexp", $String, ""], ["prog", "prog", "regexp", ($ptrType(syntax.Prog)), ""], ["onepass", "onepass", "regexp", ($ptrType(onePassProg)), ""], ["prefix", "prefix", "regexp", $String, ""], ["prefixBytes", "prefixBytes", "regexp", ($sliceType($Uint8)), ""], ["prefixComplete", "prefixComplete", "regexp", $Bool, ""], ["prefixRune", "prefixRune", "regexp", $Int32, ""], ["prefixEnd", "prefixEnd", "regexp", $Uint32, ""], ["cond", "cond", "regexp", syntax.EmptyOp, ""], ["numSubexp", "numSubexp", "regexp", $Int, ""], ["subexpNames", "subexpNames", "regexp", ($sliceType($String)), ""], ["longest", "longest", "regexp", $Bool, ""], ["mu", "mu", "regexp", sync.Mutex, ""], ["machine", "machine", "regexp", ($sliceType(($ptrType(machine)))), ""]]); + input.init([["canCheckPrefix", "canCheckPrefix", "regexp", $funcType([], [$Bool], false)], ["context", "context", "regexp", $funcType([$Int], [syntax.EmptyOp], false)], ["hasPrefix", "hasPrefix", "regexp", $funcType([($ptrType(Regexp))], [$Bool], false)], ["index", "index", "regexp", $funcType([($ptrType(Regexp)), $Int], [$Int], false)], ["step", "step", "regexp", $funcType([$Int], [$Int32, $Int], false)]]); + ($ptrType(inputString)).methods = [["canCheckPrefix", "canCheckPrefix", "regexp", $funcType([], [$Bool], false), -1], ["context", "context", "regexp", $funcType([$Int], [syntax.EmptyOp], false), -1], ["hasPrefix", "hasPrefix", "regexp", $funcType([($ptrType(Regexp))], [$Bool], false), -1], ["index", "index", "regexp", $funcType([($ptrType(Regexp)), $Int], [$Int], false), -1], ["step", "step", "regexp", $funcType([$Int], [$Int32, $Int], false), -1]]; + inputString.init([["str", "str", "regexp", $String, ""]]); + ($ptrType(inputBytes)).methods = [["canCheckPrefix", "canCheckPrefix", "regexp", $funcType([], [$Bool], false), -1], ["context", "context", "regexp", $funcType([$Int], [syntax.EmptyOp], false), -1], ["hasPrefix", "hasPrefix", "regexp", $funcType([($ptrType(Regexp))], [$Bool], false), -1], ["index", "index", "regexp", $funcType([($ptrType(Regexp)), $Int], [$Int], false), -1], ["step", "step", "regexp", $funcType([$Int], [$Int32, $Int], false), -1]]; + inputBytes.init([["str", "str", "regexp", ($sliceType($Uint8)), ""]]); + ($ptrType(inputReader)).methods = [["canCheckPrefix", "canCheckPrefix", "regexp", $funcType([], [$Bool], false), -1], ["context", "context", "regexp", $funcType([$Int], [syntax.EmptyOp], false), -1], ["hasPrefix", "hasPrefix", "regexp", $funcType([($ptrType(Regexp))], [$Bool], false), -1], ["index", "index", "regexp", $funcType([($ptrType(Regexp)), $Int], [$Int], false), -1], ["step", "step", "regexp", $funcType([$Int], [$Int32, $Int], false), -1]]; + inputReader.init([["r", "r", "regexp", io.RuneReader, ""], ["atEOT", "atEOT", "regexp", $Bool, ""], ["pos", "pos", "regexp", $Int, ""]]); + empty = ($sliceType($Int)).make(0); + noRune = new ($sliceType($Int32))([]); + noNext = new ($sliceType($Uint32))([4294967295]); + anyRuneNotNL = new ($sliceType($Int32))([0, 9, 11, 1114111]); + anyRune = new ($sliceType($Int32))([0, 1114111]); + notOnePass = ($ptrType(onePassProg)).nil; }; - parseIA5String = function(bytes$1) { - var ret = "", err = $ifaceNil, _ref, _i, b, x$3; - _ref = bytes$1; - _i = 0; - while (_i < _ref.$length) { - b = ((_i < 0 || _i >= _ref.$length) ? $throwRuntimeError("index out of range") : _ref.$array[_ref.$offset + _i]); - if (b >= 128) { - err = (x$3 = new SyntaxError.Ptr("IA5String contains invalid character"), new x$3.constructor.Struct(x$3)); - return [ret, err]; + return $pkg; +})(); +$packages["net/url"] = (function() { + var $pkg = {}, bytes = $packages["bytes"], errors = $packages["errors"], sort = $packages["sort"], strconv = $packages["strconv"], strings = $packages["strings"], shouldEscape, QueryEscape, escape; + shouldEscape = function(c, mode) { + var _ref, _ref$1; + if (65 <= c && c <= 90 || 97 <= c && c <= 122 || 48 <= c && c <= 57) { + return false; + } + _ref = c; + if (_ref === 45 || _ref === 95 || _ref === 46 || _ref === 126) { + return false; + } else if (_ref === 36 || _ref === 38 || _ref === 43 || _ref === 44 || _ref === 47 || _ref === 58 || _ref === 59 || _ref === 61 || _ref === 63 || _ref === 64) { + _ref$1 = mode; + if (_ref$1 === 1) { + return c === 63; + } else if (_ref$1 === 2) { + return (c === 64) || (c === 47) || (c === 58); + } else if (_ref$1 === 3) { + return true; + } else if (_ref$1 === 4) { + return false; } - _i++; } - ret = $bytesToString(bytes$1); - return [ret, err]; - }; - parseT61String = function(bytes$1) { - var ret = "", err = $ifaceNil, _tmp, _tmp$1; - _tmp = $bytesToString(bytes$1); _tmp$1 = $ifaceNil; ret = _tmp; err = _tmp$1; - return [ret, err]; + return true; }; - parseUTF8String = function(bytes$1) { - var ret = "", err = $ifaceNil, _tmp, _tmp$1; - _tmp = $bytesToString(bytes$1); _tmp$1 = $ifaceNil; ret = _tmp; err = _tmp$1; - return [ret, err]; + QueryEscape = $pkg.QueryEscape = function(s) { + return escape(s, 3); }; - parseTagAndLength = function(bytes$1, initOffset) { - var ret = new tagAndLength.Ptr(), offset = 0, err = $ifaceNil, b, _tuple, x$3, numBytes, x$4, i, x$5, x$6, y, x$7; - offset = initOffset; - b = ((offset < 0 || offset >= bytes$1.$length) ? $throwRuntimeError("index out of range") : bytes$1.$array[bytes$1.$offset + offset]); - offset = offset + (1) >> 0; - ret.class$0 = ((b >>> 6 << 24 >>> 24) >> 0); - ret.isCompound = ((b & 32) >>> 0) === 32; - ret.tag = (((b & 31) >>> 0) >> 0); - if (ret.tag === 31) { - _tuple = parseBase128Int(bytes$1, offset); ret.tag = _tuple[0]; offset = _tuple[1]; err = _tuple[2]; - if (!($interfaceIsEqual(err, $ifaceNil))) { - return [ret, offset, err]; + escape = function(s, mode) { + var _tmp, _tmp$1, spaceCount, hexCount, i, c, t, j, i$1, c$1, x, x$1; + _tmp = 0; _tmp$1 = 0; spaceCount = _tmp; hexCount = _tmp$1; + i = 0; + while (i < s.length) { + c = s.charCodeAt(i); + if (shouldEscape(c, mode)) { + if ((c === 32) && (mode === 3)) { + spaceCount = spaceCount + (1) >> 0; + } else { + hexCount = hexCount + (1) >> 0; + } } + i = i + (1) >> 0; } - if (offset >= bytes$1.$length) { - err = (x$3 = new SyntaxError.Ptr("truncated tag or length"), new x$3.constructor.Struct(x$3)); - return [ret, offset, err]; + if ((spaceCount === 0) && (hexCount === 0)) { + return s; } - b = ((offset < 0 || offset >= bytes$1.$length) ? $throwRuntimeError("index out of range") : bytes$1.$array[bytes$1.$offset + offset]); - offset = offset + (1) >> 0; - if (((b & 128) >>> 0) === 0) { - ret.length = (((b & 127) >>> 0) >> 0); - } else { - numBytes = (((b & 127) >>> 0) >> 0); - if (numBytes === 0) { - err = (x$4 = new SyntaxError.Ptr("indefinite length found (not DER)"), new x$4.constructor.Struct(x$4)); - return [ret, offset, err]; - } - ret.length = 0; - i = 0; - while (i < numBytes) { - if (offset >= bytes$1.$length) { - err = (x$5 = new SyntaxError.Ptr("truncated tag or length"), new x$5.constructor.Struct(x$5)); - return [ret, offset, err]; - } - b = ((offset < 0 || offset >= bytes$1.$length) ? $throwRuntimeError("index out of range") : bytes$1.$array[bytes$1.$offset + offset]); - offset = offset + (1) >> 0; - if (ret.length >= 8388608) { - err = (x$6 = new StructuralError.Ptr("length too large"), new x$6.constructor.Struct(x$6)); - return [ret, offset, err]; - } - ret.length = (y = (8), y < 32 ? (ret.length << y) : 0) >> 0; - ret.length = ret.length | ((b >> 0)); - if (ret.length === 0) { - err = (x$7 = new StructuralError.Ptr("superfluous leading zeros in length"), new x$7.constructor.Struct(x$7)); - return [ret, offset, err]; - } - i = i + (1) >> 0; + t = ($sliceType($Uint8)).make((s.length + ((((2 >>> 16 << 16) * hexCount >> 0) + (2 << 16 >>> 16) * hexCount) >> 0) >> 0)); + j = 0; + i$1 = 0; + while (i$1 < s.length) { + c$1 = s.charCodeAt(i$1); + if ((c$1 === 32) && (mode === 3)) { + (j < 0 || j >= t.$length) ? $throwRuntimeError("index out of range") : t.$array[t.$offset + j] = 43; + j = j + (1) >> 0; + } else if (shouldEscape(c$1, mode)) { + (j < 0 || j >= t.$length) ? $throwRuntimeError("index out of range") : t.$array[t.$offset + j] = 37; + (x = j + 1 >> 0, (x < 0 || x >= t.$length) ? $throwRuntimeError("index out of range") : t.$array[t.$offset + x] = "0123456789ABCDEF".charCodeAt((c$1 >>> 4 << 24 >>> 24))); + (x$1 = j + 2 >> 0, (x$1 < 0 || x$1 >= t.$length) ? $throwRuntimeError("index out of range") : t.$array[t.$offset + x$1] = "0123456789ABCDEF".charCodeAt(((c$1 & 15) >>> 0))); + j = j + (3) >> 0; + } else { + (j < 0 || j >= t.$length) ? $throwRuntimeError("index out of range") : t.$array[t.$offset + j] = s.charCodeAt(i$1); + j = j + (1) >> 0; } + i$1 = i$1 + (1) >> 0; } - return [ret, offset, err]; + return $bytesToString(t); }; - parseSequenceOf = function(bytes$1, sliceType, elemType) { - var ret = new reflect.Value.Ptr(), err = $ifaceNil, _tuple, expectedTag, compoundType, ok, x$3, numElements, offset, t, _tuple$1, _ref, x$4, x$5, params, offset$1, i, _tuple$2; - _tuple = getUniversalType(elemType); expectedTag = _tuple[0]; compoundType = _tuple[1]; ok = _tuple[2]; - if (!ok) { - err = (x$3 = new StructuralError.Ptr("unknown Go type for slice"), new x$3.constructor.Struct(x$3)); - return [ret, err]; - } - numElements = 0; - offset = 0; - while (offset < bytes$1.$length) { - t = new tagAndLength.Ptr(); $copy(t, new tagAndLength.Ptr(), tagAndLength); - _tuple$1 = parseTagAndLength(bytes$1, offset); $copy(t, _tuple$1[0], tagAndLength); offset = _tuple$1[1]; err = _tuple$1[2]; - if (!($interfaceIsEqual(err, $ifaceNil))) { - return [ret, err]; - } - _ref = t.tag; - if (_ref === 22 || _ref === 27 || _ref === 20 || _ref === 12) { - t.tag = 19; - } else if (_ref === 24 || _ref === 23) { - t.tag = 23; - } - if (!((t.class$0 === 0)) || !(t.isCompound === compoundType) || !((t.tag === expectedTag))) { - err = (x$4 = new StructuralError.Ptr("sequence tag mismatch"), new x$4.constructor.Struct(x$4)); - return [ret, err]; - } - if (invalidLength(offset, t.length, bytes$1.$length)) { - err = (x$5 = new SyntaxError.Ptr("truncated sequence"), new x$5.constructor.Struct(x$5)); - return [ret, err]; - } - offset = offset + (t.length) >> 0; - numElements = numElements + (1) >> 0; + $pkg.$init = function() { + }; + return $pkg; +})(); +$packages["container/list"] = (function() { + var $pkg = {}; + $pkg.$init = function() { + }; + return $pkg; +})(); +$packages["text/template/parse"] = (function() { + var $pkg = {}, list = $packages["container/list"], fmt = $packages["fmt"], strings = $packages["strings"], unicode = $packages["unicode"], utf8 = $packages["unicode/utf8"], bytes = $packages["bytes"], strconv = $packages["strconv"], runtime = $packages["runtime"]; + $pkg.$init = function() { + }; + return $pkg; +})(); +$packages["text/template"] = (function() { + var $pkg = {}, bytes = $packages["bytes"], fmt = $packages["fmt"], io = $packages["io"], reflect = $packages["reflect"], runtime = $packages["runtime"], sort = $packages["sort"], strings = $packages["strings"], parse = $packages["text/template/parse"], errors = $packages["errors"], url = $packages["net/url"], unicode = $packages["unicode"], utf8 = $packages["unicode/utf8"], ioutil = $packages["io/ioutil"], filepath = $packages["path/filepath"], errorType, fmtStringerType, builtins, builtinFuncs, errBadComparisonType, errBadComparison, errNoComparison, htmlQuot, htmlApos, htmlAmp, htmlLt, htmlGt, jsLowUni, hex, jsBackslash, jsApos, jsQuot, jsLt, jsGt, _map, _key, isTrue, canBeNil, indirect, printableValue, createValueFuncs, addValueFuncs, goodFunc, index, length, call, truth, and, or, not, basicKind, eq, ne, lt, le, gt, ge, HTMLEscape, HTMLEscapeString, HTMLEscaper, JSEscape, JSEscapeString, jsIsSpecial, JSEscaper, URLQueryEscaper, evalArgs; + isTrue = function(val) { + var truth$1 = false, ok = false, _tmp, _tmp$1, _ref, x, x$1, x$2, _tmp$2, _tmp$3; + if (!val.IsValid()) { + _tmp = false; _tmp$1 = true; truth$1 = _tmp; ok = _tmp$1; + return [truth$1, ok]; } - $copy(ret, reflect.MakeSlice(sliceType, numElements, numElements), reflect.Value); - params = new fieldParameters.Ptr(false, false, false, ($ptrType($Int64)).nil, ($ptrType($Int)).nil, 0, false, false); - offset$1 = 0; - i = 0; - while (i < numElements) { - _tuple$2 = parseField($clone(ret.Index(i), reflect.Value), bytes$1, offset$1, $clone(params, fieldParameters)); offset$1 = _tuple$2[0]; err = _tuple$2[1]; - if (!($interfaceIsEqual(err, $ifaceNil))) { - return [ret, err]; - } - i = i + (1) >> 0; + _ref = val.Kind(); + if (_ref === 17 || _ref === 21 || _ref === 23 || _ref === 24) { + truth$1 = val.Len() > 0; + } else if (_ref === 1) { + truth$1 = val.Bool(); + } else if (_ref === 15 || _ref === 16) { + truth$1 = !((x = val.Complex(), (x.$real === 0 && x.$imag === 0))); + } else if (_ref === 18 || _ref === 19 || _ref === 22 || _ref === 20) { + truth$1 = !val.IsNil(); + } else if (_ref === 2 || _ref === 3 || _ref === 4 || _ref === 5 || _ref === 6) { + truth$1 = !((x$1 = val.Int(), (x$1.$high === 0 && x$1.$low === 0))); + } else if (_ref === 13 || _ref === 14) { + truth$1 = !((val.Float() === 0)); + } else if (_ref === 7 || _ref === 8 || _ref === 9 || _ref === 10 || _ref === 11 || _ref === 12) { + truth$1 = !((x$2 = val.Uint(), (x$2.$high === 0 && x$2.$low === 0))); + } else if (_ref === 25) { + truth$1 = true; + } else { + return [truth$1, ok]; } - return [ret, err]; - }; - invalidLength = function(offset, length, sliceLength) { - return (offset + length >> 0) < offset || (offset + length >> 0) > sliceLength; + _tmp$2 = truth$1; _tmp$3 = true; truth$1 = _tmp$2; ok = _tmp$3; + return [truth$1, ok]; }; - parseField = function(v, bytes$1, initOffset, params) { - var offset = 0, err = $ifaceNil, fieldType, x$3, t, _tuple, x$4, result, ifaceType, t$1, _tuple$1, x$5, result$1, innerBytes, _ref, _tuple$2, _tuple$3, _tuple$4, _tuple$5, _tuple$6, _tuple$7, _tuple$8, _tuple$9, _tuple$10, universalTag, compoundType, ok1, x$6, _tuple$11, t$2, expectedClass, _tuple$12, x$7, ok, x$8, _ref$1, expectedClass$1, expectedTag, ok$1, x$9, x$10, innerBytes$1, _ref$2, _tuple$13, newSlice, err1, _tuple$14, bs, err1$1, time$1, err1$2, _tuple$15, _tuple$16, _tuple$17, parsedInt, err1$3, parsedInt$1, val, _ref$3, _tuple$18, parsedBool, err1$4, _tuple$19, parsedInt$2, err1$5, _tuple$20, parsedInt$3, err1$6, structType, bytes$2, innerOffset, i, field, _tuple$21, sliceType, _tuple$22, newSlice$1, err1$7, v$1, _ref$4, _tuple$23, _tuple$24, _tuple$25, _tuple$26, _tuple$27, x$11, x$12; - offset = initOffset; - fieldType = v.Type(); - if (offset === bytes$1.$length) { - if (!setDefaultValue($clone(v, reflect.Value), $clone(params, fieldParameters))) { - err = (x$3 = new SyntaxError.Ptr("sequence truncated"), new x$3.constructor.Struct(x$3)); - } - return [offset, err]; + canBeNil = function(typ) { + var _ref; + _ref = typ.Kind(); + if (_ref === 18 || _ref === 19 || _ref === 20 || _ref === 21 || _ref === 22 || _ref === 23) { + return true; } - if ($interfaceIsEqual(fieldType, rawValueType)) { - t = new tagAndLength.Ptr(); $copy(t, new tagAndLength.Ptr(), tagAndLength); - _tuple = parseTagAndLength(bytes$1, offset); $copy(t, _tuple[0], tagAndLength); offset = _tuple[1]; err = _tuple[2]; - if (!($interfaceIsEqual(err, $ifaceNil))) { - return [offset, err]; + return false; + }; + indirect = function(v) { + var rv = new reflect.Value.Ptr(), isNil = false, _tmp, _tmp$1, _tmp$2, _tmp$3; + while ((v.Kind() === 22) || (v.Kind() === 20)) { + if (v.IsNil()) { + _tmp = new reflect.Value.Ptr(); $copy(_tmp, v, reflect.Value); _tmp$1 = true; $copy(rv, _tmp, reflect.Value); isNil = _tmp$1; + return [rv, isNil]; } - if (invalidLength(offset, t.length, bytes$1.$length)) { - err = (x$4 = new SyntaxError.Ptr("data truncated"), new x$4.constructor.Struct(x$4)); - return [offset, err]; + if ((v.Kind() === 20) && v.NumMethod() > 0) { + break; } - result = new RawValue.Ptr(t.class$0, t.tag, t.isCompound, $subslice(bytes$1, offset, (offset + t.length >> 0)), $subslice(bytes$1, initOffset, (offset + t.length >> 0))); - offset = offset + (t.length) >> 0; - v.Set($clone(reflect.ValueOf(new result.constructor.Struct(result)), reflect.Value)); - return [offset, err]; + $copy(v, v.Elem(), reflect.Value); } - ifaceType = fieldType; - if ((ifaceType.Kind() === 20) && (ifaceType.NumMethod() === 0)) { - t$1 = new tagAndLength.Ptr(); $copy(t$1, new tagAndLength.Ptr(), tagAndLength); - _tuple$1 = parseTagAndLength(bytes$1, offset); $copy(t$1, _tuple$1[0], tagAndLength); offset = _tuple$1[1]; err = _tuple$1[2]; - if (!($interfaceIsEqual(err, $ifaceNil))) { - return [offset, err]; - } - if (invalidLength(offset, t$1.length, bytes$1.$length)) { - err = (x$5 = new SyntaxError.Ptr("data truncated"), new x$5.constructor.Struct(x$5)); - return [offset, err]; - } - result$1 = $ifaceNil; - if (!t$1.isCompound && (t$1.class$0 === 0)) { - innerBytes = $subslice(bytes$1, offset, (offset + t$1.length >> 0)); - _ref = t$1.tag; - if (_ref === 19) { - _tuple$2 = parsePrintableString(innerBytes); result$1 = new $String(_tuple$2[0]); err = _tuple$2[1]; - } else if (_ref === 22) { - _tuple$3 = parseIA5String(innerBytes); result$1 = new $String(_tuple$3[0]); err = _tuple$3[1]; - } else if (_ref === 20) { - _tuple$4 = parseT61String(innerBytes); result$1 = new $String(_tuple$4[0]); err = _tuple$4[1]; - } else if (_ref === 12) { - _tuple$5 = parseUTF8String(innerBytes); result$1 = new $String(_tuple$5[0]); err = _tuple$5[1]; - } else if (_ref === 2) { - _tuple$6 = parseInt64(innerBytes); result$1 = _tuple$6[0]; err = _tuple$6[1]; - } else if (_ref === 3) { - _tuple$7 = parseBitString(innerBytes); result$1 = new _tuple$7[0].constructor.Struct(_tuple$7[0]); err = _tuple$7[1]; - } else if (_ref === 6) { - _tuple$8 = parseObjectIdentifier(innerBytes); result$1 = _tuple$8[0]; err = _tuple$8[1]; - } else if (_ref === 23) { - _tuple$9 = parseUTCTime(innerBytes); result$1 = new _tuple$9[0].constructor.Struct(_tuple$9[0]); err = _tuple$9[1]; - } else if (_ref === 4) { - result$1 = innerBytes; - } else { + _tmp$2 = new reflect.Value.Ptr(); $copy(_tmp$2, v, reflect.Value); _tmp$3 = false; $copy(rv, _tmp$2, reflect.Value); isNil = _tmp$3; + return [rv, isNil]; + }; + printableValue = function(v) { + var _tuple, _ref; + if (v.Kind() === 22) { + _tuple = indirect($clone(v, reflect.Value)); $copy(v, _tuple[0], reflect.Value); + } + if (!v.IsValid()) { + return [new $String(""), true]; + } + if (!v.Type().Implements(errorType) && !v.Type().Implements(fmtStringerType)) { + if (v.CanAddr() && (reflect.PtrTo(v.Type()).Implements(errorType) || reflect.PtrTo(v.Type()).Implements(fmtStringerType))) { + $copy(v, v.Addr(), reflect.Value); + } else { + _ref = v.Kind(); + if (_ref === 18 || _ref === 19) { + return [$ifaceNil, false]; } } - offset = offset + (t$1.length) >> 0; - if (!($interfaceIsEqual(err, $ifaceNil))) { - return [offset, err]; + } + return [v.Interface(), true]; + }; + createValueFuncs = function(funcMap) { + var m; + m = new $Map(); + addValueFuncs(m, funcMap); + return m; + }; + addValueFuncs = function(out, in$1) { + var _ref, _i, _keys, _entry, name, fn, v, _key$1; + _ref = in$1; + _i = 0; + _keys = $keys(_ref); + while (_i < _keys.length) { + _entry = _ref[_keys[_i]]; + if (_entry === undefined) { + _i++; + continue; + } + name = _entry.k; + fn = _entry.v; + v = new reflect.Value.Ptr(); $copy(v, reflect.ValueOf(fn), reflect.Value); + if (!((v.Kind() === 19))) { + $panic(new $String("value for " + name + " not a function")); } - if (!($interfaceIsEqual(result$1, $ifaceNil))) { - v.Set($clone(reflect.ValueOf(result$1), reflect.Value)); + if (!goodFunc(v.Type())) { + $panic(fmt.Errorf("can't install method/function %q with %d results", new ($sliceType($emptyInterface))([new $String(name), new $Int(v.Type().NumOut())]))); } - return [offset, err]; - } - _tuple$10 = getUniversalType(fieldType); universalTag = _tuple$10[0]; compoundType = _tuple$10[1]; ok1 = _tuple$10[2]; - if (!ok1) { - err = (x$6 = new StructuralError.Ptr(fmt.Sprintf("unknown Go type: %v", new ($sliceType($emptyInterface))([fieldType]))), new x$6.constructor.Struct(x$6)); - return [offset, err]; + _key$1 = name; (out || $throwRuntimeError("assignment to entry in nil map"))[_key$1] = { k: _key$1, v: v }; + _i++; } - _tuple$11 = parseTagAndLength(bytes$1, offset); t$2 = new tagAndLength.Ptr(); $copy(t$2, _tuple$11[0], tagAndLength); offset = _tuple$11[1]; err = _tuple$11[2]; - if (!($interfaceIsEqual(err, $ifaceNil))) { - return [offset, err]; + }; + goodFunc = function(typ) { + if (typ.NumOut() === 1) { + return true; + } else if ((typ.NumOut() === 2) && $interfaceIsEqual(typ.Out(1), errorType)) { + return true; } - if (params.explicit) { - expectedClass = 2; - if (params.application) { - expectedClass = 1; + return false; + }; + index = function(item, indices) { + var v, _ref, _i, i, index$1, isNil, _tuple, _ref$1, x, _ref$2, x$1, x$2, x$3; + v = new reflect.Value.Ptr(); $copy(v, reflect.ValueOf(item), reflect.Value); + _ref = indices; + _i = 0; + while (_i < _ref.$length) { + i = ((_i < 0 || _i >= _ref.$length) ? $throwRuntimeError("index out of range") : _ref.$array[_ref.$offset + _i]); + index$1 = new reflect.Value.Ptr(); $copy(index$1, reflect.ValueOf(i), reflect.Value); + isNil = false; + _tuple = indirect($clone(v, reflect.Value)); $copy(v, _tuple[0], reflect.Value); isNil = _tuple[1]; + if (isNil) { + return [$ifaceNil, fmt.Errorf("index of nil pointer", new ($sliceType($emptyInterface))([]))]; } - if ((t$2.class$0 === expectedClass) && (t$2.tag === params.tag.$get()) && ((t$2.length === 0) || t$2.isCompound)) { - if (t$2.length > 0) { - _tuple$12 = parseTagAndLength(bytes$1, offset); $copy(t$2, _tuple$12[0], tagAndLength); offset = _tuple$12[1]; err = _tuple$12[2]; - if (!($interfaceIsEqual(err, $ifaceNil))) { - return [offset, err]; - } + _ref$1 = v.Kind(); + if (_ref$1 === 17 || _ref$1 === 23 || _ref$1 === 24) { + x = new $Int64(0, 0); + _ref$2 = index$1.Kind(); + if (_ref$2 === 2 || _ref$2 === 3 || _ref$2 === 4 || _ref$2 === 5 || _ref$2 === 6) { + x = index$1.Int(); + } else if (_ref$2 === 7 || _ref$2 === 8 || _ref$2 === 9 || _ref$2 === 10 || _ref$2 === 11 || _ref$2 === 12) { + x = (x$1 = index$1.Uint(), new $Int64(x$1.$high, x$1.$low)); } else { - if (!($interfaceIsEqual(fieldType, flagType))) { - err = (x$7 = new StructuralError.Ptr("zero length explicit tag was not an asn1.Flag"), new x$7.constructor.Struct(x$7)); - return [offset, err]; - } - v.SetBool(true); - return [offset, err]; + return [$ifaceNil, fmt.Errorf("cannot index slice/array with type %s", new ($sliceType($emptyInterface))([index$1.Type()]))]; } - } else { - ok = setDefaultValue($clone(v, reflect.Value), $clone(params, fieldParameters)); - if (ok) { - offset = initOffset; + if ((x.$high < 0 || (x.$high === 0 && x.$low < 0)) || (x$2 = new $Int64(0, v.Len()), (x.$high > x$2.$high || (x.$high === x$2.$high && x.$low >= x$2.$low)))) { + return [$ifaceNil, fmt.Errorf("index out of range: %d", new ($sliceType($emptyInterface))([x]))]; + } + $copy(v, v.Index(((x.$low + ((x.$high >> 31) * 4294967296)) >> 0)), reflect.Value); + } else if (_ref$1 === 21) { + if (!index$1.IsValid()) { + $copy(index$1, reflect.Zero(v.Type().Key()), reflect.Value); + } + if (!index$1.Type().AssignableTo(v.Type().Key())) { + return [$ifaceNil, fmt.Errorf("%s is not index type for %s", new ($sliceType($emptyInterface))([index$1.Type(), v.Type()]))]; + } + x$3 = new reflect.Value.Ptr(); $copy(x$3, v.MapIndex($clone(index$1, reflect.Value)), reflect.Value); + if (x$3.IsValid()) { + $copy(v, x$3, reflect.Value); } else { - err = (x$8 = new StructuralError.Ptr("explicitly tagged member didn't match"), new x$8.constructor.Struct(x$8)); + $copy(v, reflect.Zero(v.Type().Elem()), reflect.Value); } - return [offset, err]; - } - } - if (universalTag === 19) { - _ref$1 = t$2.tag; - if (_ref$1 === 22 || _ref$1 === 27 || _ref$1 === 20 || _ref$1 === 12) { - universalTag = t$2.tag; + } else { + return [$ifaceNil, fmt.Errorf("can't index item of type %s", new ($sliceType($emptyInterface))([v.Type()]))]; } + _i++; } - if ((universalTag === 23) && (t$2.tag === 24)) { - universalTag = 24; - } - if (params.set) { - universalTag = 17; - } - expectedClass$1 = 0; - expectedTag = universalTag; - if (!params.explicit && !($pointerIsEqual(params.tag, ($ptrType($Int)).nil))) { - expectedClass$1 = 2; - expectedTag = params.tag.$get(); + return [v.Interface(), $ifaceNil]; + }; + length = function(item) { + var _tuple, v, isNil, _ref; + _tuple = indirect($clone(reflect.ValueOf(item), reflect.Value)); v = new reflect.Value.Ptr(); $copy(v, _tuple[0], reflect.Value); isNil = _tuple[1]; + if (isNil) { + return [0, fmt.Errorf("len of nil pointer", new ($sliceType($emptyInterface))([]))]; } - if (!params.explicit && params.application && !($pointerIsEqual(params.tag, ($ptrType($Int)).nil))) { - expectedClass$1 = 1; - expectedTag = params.tag.$get(); + _ref = v.Kind(); + if (_ref === 17 || _ref === 18 || _ref === 21 || _ref === 23 || _ref === 24) { + return [v.Len(), $ifaceNil]; } - if (!((t$2.class$0 === expectedClass$1)) || !((t$2.tag === expectedTag)) || !(t$2.isCompound === compoundType)) { - ok$1 = setDefaultValue($clone(v, reflect.Value), $clone(params, fieldParameters)); - if (ok$1) { - offset = initOffset; - } else { - err = (x$9 = new StructuralError.Ptr(fmt.Sprintf("tags don't match (%d vs %+v) %+v %s @%d", new ($sliceType($emptyInterface))([new $Int(expectedTag), new t$2.constructor.Struct(t$2), new params.constructor.Struct(params), new $String(fieldType.Name()), new $Int(offset)]))), new x$9.constructor.Struct(x$9)); - } - return [offset, err]; + return [0, fmt.Errorf("len of type %s", new ($sliceType($emptyInterface))([v.Type()]))]; + }; + call = function(fn, args) { + var v, typ, numIn, dddType, argv, _ref, _i, i, arg, value, argType, result; + v = new reflect.Value.Ptr(); $copy(v, reflect.ValueOf(fn), reflect.Value); + typ = v.Type(); + if (!((typ.Kind() === 19))) { + return [$ifaceNil, fmt.Errorf("non-function of type %s", new ($sliceType($emptyInterface))([typ]))]; } - if (invalidLength(offset, t$2.length, bytes$1.$length)) { - err = (x$10 = new SyntaxError.Ptr("data truncated"), new x$10.constructor.Struct(x$10)); - return [offset, err]; + if (!goodFunc(typ)) { + return [$ifaceNil, fmt.Errorf("function called with %d args; should be 1 or 2", new ($sliceType($emptyInterface))([new $Int(typ.NumOut())]))]; } - innerBytes$1 = $subslice(bytes$1, offset, (offset + t$2.length >> 0)); - offset = offset + (t$2.length) >> 0; - _ref$2 = fieldType; - if ($interfaceIsEqual(_ref$2, objectIdentifierType)) { - _tuple$13 = parseObjectIdentifier(innerBytes$1); newSlice = _tuple$13[0]; err1 = _tuple$13[1]; - v.Set($clone(reflect.MakeSlice(v.Type(), newSlice.$length, newSlice.$length), reflect.Value)); - if ($interfaceIsEqual(err1, $ifaceNil)) { - reflect.Copy($clone(v, reflect.Value), $clone(reflect.ValueOf(newSlice), reflect.Value)); + numIn = typ.NumIn(); + dddType = $ifaceNil; + if (typ.IsVariadic()) { + if (args.$length < (numIn - 1 >> 0)) { + return [$ifaceNil, fmt.Errorf("wrong number of args: got %d want at least %d", new ($sliceType($emptyInterface))([new $Int(args.$length), new $Int((numIn - 1 >> 0))]))]; } - err = err1; - return [offset, err]; - } else if ($interfaceIsEqual(_ref$2, bitStringType)) { - _tuple$14 = parseBitString(innerBytes$1); bs = new BitString.Ptr(); $copy(bs, _tuple$14[0], BitString); err1$1 = _tuple$14[1]; - if ($interfaceIsEqual(err1$1, $ifaceNil)) { - v.Set($clone(reflect.ValueOf(new bs.constructor.Struct(bs)), reflect.Value)); + dddType = typ.In(numIn - 1 >> 0).Elem(); + } else { + if (!((args.$length === numIn))) { + return [$ifaceNil, fmt.Errorf("wrong number of args: got %d want %d", new ($sliceType($emptyInterface))([new $Int(args.$length), new $Int(numIn)]))]; } - err = err1$1; - return [offset, err]; - } else if ($interfaceIsEqual(_ref$2, timeType)) { - time$1 = new time.Time.Ptr(); $copy(time$1, new time.Time.Ptr(), time.Time); - err1$2 = $ifaceNil; - if (universalTag === 23) { - _tuple$15 = parseUTCTime(innerBytes$1); $copy(time$1, _tuple$15[0], time.Time); err1$2 = _tuple$15[1]; + } + argv = ($sliceType(reflect.Value)).make(args.$length); + _ref = args; + _i = 0; + while (_i < _ref.$length) { + i = _i; + arg = ((_i < 0 || _i >= _ref.$length) ? $throwRuntimeError("index out of range") : _ref.$array[_ref.$offset + _i]); + value = new reflect.Value.Ptr(); $copy(value, reflect.ValueOf(arg), reflect.Value); + argType = $ifaceNil; + if (!typ.IsVariadic() || i < (numIn - 1 >> 0)) { + argType = typ.In(i); } else { - _tuple$16 = parseGeneralizedTime(innerBytes$1); $copy(time$1, _tuple$16[0], time.Time); err1$2 = _tuple$16[1]; + argType = dddType; } - if ($interfaceIsEqual(err1$2, $ifaceNil)) { - v.Set($clone(reflect.ValueOf(new time$1.constructor.Struct(time$1)), reflect.Value)); + if (!value.IsValid() && canBeNil(argType)) { + $copy(value, reflect.Zero(argType), reflect.Value); } - err = err1$2; - return [offset, err]; - } else if ($interfaceIsEqual(_ref$2, enumeratedType)) { - _tuple$17 = parseInt32(innerBytes$1); parsedInt = _tuple$17[0]; err1$3 = _tuple$17[1]; - if ($interfaceIsEqual(err1$3, $ifaceNil)) { - v.SetInt(new $Int64(0, parsedInt)); + if (!value.Type().AssignableTo(argType)) { + return [$ifaceNil, fmt.Errorf("arg %d has type %s; should be %s", new ($sliceType($emptyInterface))([new $Int(i), value.Type(), argType]))]; } - err = err1$3; - return [offset, err]; - } else if ($interfaceIsEqual(_ref$2, flagType)) { - v.SetBool(true); - return [offset, err]; - } else if ($interfaceIsEqual(_ref$2, bigIntType)) { - parsedInt$1 = parseBigInt(innerBytes$1); - v.Set($clone(reflect.ValueOf(parsedInt$1), reflect.Value)); - return [offset, err]; + $copy(((i < 0 || i >= argv.$length) ? $throwRuntimeError("index out of range") : argv.$array[argv.$offset + i]), value, reflect.Value); + _i++; } - val = new reflect.Value.Ptr(); $copy(val, v, reflect.Value); - _ref$3 = val.Kind(); - if (_ref$3 === 1) { - _tuple$18 = parseBool(innerBytes$1); parsedBool = _tuple$18[0]; err1$4 = _tuple$18[1]; - if ($interfaceIsEqual(err1$4, $ifaceNil)) { - val.SetBool(parsedBool); - } - err = err1$4; - return [offset, err]; - } else if (_ref$3 === 2 || _ref$3 === 5 || _ref$3 === 6) { - if (val.Type().Size() === 4) { - _tuple$19 = parseInt32(innerBytes$1); parsedInt$2 = _tuple$19[0]; err1$5 = _tuple$19[1]; - if ($interfaceIsEqual(err1$5, $ifaceNil)) { - val.SetInt(new $Int64(0, parsedInt$2)); - } - err = err1$5; - } else { - _tuple$20 = parseInt64(innerBytes$1); parsedInt$3 = _tuple$20[0]; err1$6 = _tuple$20[1]; - if ($interfaceIsEqual(err1$6, $ifaceNil)) { - val.SetInt(parsedInt$3); - } - err = err1$6; - } - return [offset, err]; - } else if (_ref$3 === 25) { - structType = fieldType; - if (structType.NumField() > 0 && $interfaceIsEqual(structType.Field(0).Type, rawContentsType)) { - bytes$2 = $subslice(bytes$1, initOffset, offset); - val.Field(0).Set($clone(reflect.ValueOf($subslice(new RawContent(bytes$2.$array), bytes$2.$offset, bytes$2.$offset + bytes$2.$length)), reflect.Value)); + result = v.Call(argv); + if ((result.$length === 2) && !((1 < 0 || 1 >= result.$length) ? $throwRuntimeError("index out of range") : result.$array[result.$offset + 1]).IsNil()) { + return [((0 < 0 || 0 >= result.$length) ? $throwRuntimeError("index out of range") : result.$array[result.$offset + 0]).Interface(), $assertType(((1 < 0 || 1 >= result.$length) ? $throwRuntimeError("index out of range") : result.$array[result.$offset + 1]).Interface(), $error)]; + } + return [((0 < 0 || 0 >= result.$length) ? $throwRuntimeError("index out of range") : result.$array[result.$offset + 0]).Interface(), $ifaceNil]; + }; + truth = function(a) { + var _tuple, t; + _tuple = isTrue($clone(reflect.ValueOf(a), reflect.Value)); t = _tuple[0]; + return t; + }; + and = function(arg0, args) { + var _ref, _i, i; + if (!truth(arg0)) { + return arg0; + } + _ref = args; + _i = 0; + while (_i < _ref.$length) { + i = _i; + arg0 = ((i < 0 || i >= args.$length) ? $throwRuntimeError("index out of range") : args.$array[args.$offset + i]); + if (!truth(arg0)) { + break; } - innerOffset = 0; - i = 0; - while (i < structType.NumField()) { - field = new reflect.StructField.Ptr(); $copy(field, structType.Field(i), reflect.StructField); - if ((i === 0) && $interfaceIsEqual(field.Type, rawContentsType)) { - i = i + (1) >> 0; - continue; - } - _tuple$21 = parseField($clone(val.Field(i), reflect.Value), innerBytes$1, innerOffset, $clone(parseFieldParameters((new reflect.StructTag(field.Tag)).Get("asn1")), fieldParameters)); innerOffset = _tuple$21[0]; err = _tuple$21[1]; - if (!($interfaceIsEqual(err, $ifaceNil))) { - return [offset, err]; - } - i = i + (1) >> 0; + _i++; + } + return arg0; + }; + or = function(arg0, args) { + var _ref, _i, i; + if (truth(arg0)) { + return arg0; + } + _ref = args; + _i = 0; + while (_i < _ref.$length) { + i = _i; + arg0 = ((i < 0 || i >= args.$length) ? $throwRuntimeError("index out of range") : args.$array[args.$offset + i]); + if (truth(arg0)) { + break; } - return [offset, err]; - } else if (_ref$3 === 23) { - sliceType = fieldType; - if (sliceType.Elem().Kind() === 8) { - val.Set($clone(reflect.MakeSlice(sliceType, innerBytes$1.$length, innerBytes$1.$length), reflect.Value)); - reflect.Copy($clone(val, reflect.Value), $clone(reflect.ValueOf(innerBytes$1), reflect.Value)); - return [offset, err]; + _i++; + } + return arg0; + }; + not = function(arg) { + var truth$1 = false, _tuple; + _tuple = isTrue($clone(reflect.ValueOf(arg), reflect.Value)); truth$1 = _tuple[0]; + truth$1 = !truth$1; + return truth$1; + }; + basicKind = function(v) { + var _ref; + _ref = v.Kind(); + if (_ref === 1) { + return [1, $ifaceNil]; + } else if (_ref === 2 || _ref === 3 || _ref === 4 || _ref === 5 || _ref === 6) { + return [3, $ifaceNil]; + } else if (_ref === 7 || _ref === 8 || _ref === 9 || _ref === 10 || _ref === 11 || _ref === 12) { + return [7, $ifaceNil]; + } else if (_ref === 13 || _ref === 14) { + return [4, $ifaceNil]; + } else if (_ref === 15 || _ref === 16) { + return [2, $ifaceNil]; + } else if (_ref === 24) { + return [6, $ifaceNil]; + } + return [0, errBadComparisonType]; + }; + eq = function(arg1, arg2) { + var v1, _tuple, k1, err, _ref, _i, arg, v2, _tuple$1, k2, err$1, truth$1, _ref$1, x, x$1, x$2, x$3, x$4, x$5; + v1 = new reflect.Value.Ptr(); $copy(v1, reflect.ValueOf(arg1), reflect.Value); + _tuple = basicKind($clone(v1, reflect.Value)); k1 = _tuple[0]; err = _tuple[1]; + if (!($interfaceIsEqual(err, $ifaceNil))) { + return [false, err]; + } + if (arg2.$length === 0) { + return [false, errNoComparison]; + } + _ref = arg2; + _i = 0; + while (_i < _ref.$length) { + arg = ((_i < 0 || _i >= _ref.$length) ? $throwRuntimeError("index out of range") : _ref.$array[_ref.$offset + _i]); + v2 = new reflect.Value.Ptr(); $copy(v2, reflect.ValueOf(arg), reflect.Value); + _tuple$1 = basicKind($clone(v2, reflect.Value)); k2 = _tuple$1[0]; err$1 = _tuple$1[1]; + if (!($interfaceIsEqual(err$1, $ifaceNil))) { + return [false, err$1]; } - _tuple$22 = parseSequenceOf(innerBytes$1, sliceType, sliceType.Elem()); newSlice$1 = new reflect.Value.Ptr(); $copy(newSlice$1, _tuple$22[0], reflect.Value); err1$7 = _tuple$22[1]; - if ($interfaceIsEqual(err1$7, $ifaceNil)) { - val.Set($clone(newSlice$1, reflect.Value)); + if (!((k1 === k2))) { + return [false, errBadComparison]; } - err = err1$7; - return [offset, err]; - } else if (_ref$3 === 24) { - v$1 = ""; - _ref$4 = universalTag; - if (_ref$4 === 19) { - _tuple$23 = parsePrintableString(innerBytes$1); v$1 = _tuple$23[0]; err = _tuple$23[1]; - } else if (_ref$4 === 22) { - _tuple$24 = parseIA5String(innerBytes$1); v$1 = _tuple$24[0]; err = _tuple$24[1]; - } else if (_ref$4 === 20) { - _tuple$25 = parseT61String(innerBytes$1); v$1 = _tuple$25[0]; err = _tuple$25[1]; - } else if (_ref$4 === 12) { - _tuple$26 = parseUTF8String(innerBytes$1); v$1 = _tuple$26[0]; err = _tuple$26[1]; - } else if (_ref$4 === 27) { - _tuple$27 = parseT61String(innerBytes$1); v$1 = _tuple$27[0]; err = _tuple$27[1]; + truth$1 = false; + _ref$1 = k1; + if (_ref$1 === 1) { + truth$1 = v1.Bool() === v2.Bool(); + } else if (_ref$1 === 2) { + truth$1 = (x = v1.Complex(), x$1 = v2.Complex(), (x.$real === x$1.$real && x.$imag === x$1.$imag)); + } else if (_ref$1 === 4) { + truth$1 = v1.Float() === v2.Float(); + } else if (_ref$1 === 3) { + truth$1 = (x$2 = v1.Int(), x$3 = v2.Int(), (x$2.$high === x$3.$high && x$2.$low === x$3.$low)); + } else if (_ref$1 === 6) { + truth$1 = v1.String() === v2.String(); + } else if (_ref$1 === 7) { + truth$1 = (x$4 = v1.Uint(), x$5 = v2.Uint(), (x$4.$high === x$5.$high && x$4.$low === x$5.$low)); } else { - err = (x$11 = new SyntaxError.Ptr(fmt.Sprintf("internal error: unknown string type %d", new ($sliceType($emptyInterface))([new $Int(universalTag)]))), new x$11.constructor.Struct(x$11)); + $panic(new $String("invalid kind")); } - if ($interfaceIsEqual(err, $ifaceNil)) { - val.SetString(v$1); + if (truth$1) { + return [true, $ifaceNil]; } - return [offset, err]; + _i++; } - err = (x$12 = new StructuralError.Ptr("unsupported: " + v.Type().String()), new x$12.constructor.Struct(x$12)); - return [offset, err]; + return [false, $ifaceNil]; }; - setDefaultValue = function(v, params) { - var ok = false, val, _ref; - if (!params.optional) { - return ok; + ne = function(arg1, arg2) { + var _tuple, equal, err; + _tuple = eq(arg1, new ($sliceType($emptyInterface))([arg2])); equal = _tuple[0]; err = _tuple[1]; + return [!equal, err]; + }; + lt = function(arg1, arg2) { + var v1, _tuple, k1, err, v2, _tuple$1, k2, truth$1, _ref, x, x$1, x$2, x$3; + v1 = new reflect.Value.Ptr(); $copy(v1, reflect.ValueOf(arg1), reflect.Value); + _tuple = basicKind($clone(v1, reflect.Value)); k1 = _tuple[0]; err = _tuple[1]; + if (!($interfaceIsEqual(err, $ifaceNil))) { + return [false, err]; } - ok = true; - if ($pointerIsEqual(params.defaultValue, ($ptrType($Int64)).nil)) { - return ok; + v2 = new reflect.Value.Ptr(); $copy(v2, reflect.ValueOf(arg2), reflect.Value); + _tuple$1 = basicKind($clone(v2, reflect.Value)); k2 = _tuple$1[0]; err = _tuple$1[1]; + if (!($interfaceIsEqual(err, $ifaceNil))) { + return [false, err]; } - val = new reflect.Value.Ptr(); $copy(val, v, reflect.Value); - _ref = val.Kind(); - if (_ref === 2 || _ref === 3 || _ref === 4 || _ref === 5 || _ref === 6) { - val.SetInt(params.defaultValue.$get()); + if (!((k1 === k2))) { + return [false, errBadComparison]; } - return ok; - }; - Unmarshal = $pkg.Unmarshal = function(b, val) { - var rest = ($sliceType($Uint8)).nil, err = $ifaceNil, _tuple; - _tuple = UnmarshalWithParams(b, val, ""); rest = _tuple[0]; err = _tuple[1]; - return [rest, err]; + truth$1 = false; + _ref = k1; + if (_ref === 1 || _ref === 2) { + return [false, errBadComparisonType]; + } else if (_ref === 4) { + truth$1 = v1.Float() < v2.Float(); + } else if (_ref === 3) { + truth$1 = (x = v1.Int(), x$1 = v2.Int(), (x.$high < x$1.$high || (x.$high === x$1.$high && x.$low < x$1.$low))); + } else if (_ref === 6) { + truth$1 = v1.String() < v2.String(); + } else if (_ref === 7) { + truth$1 = (x$2 = v1.Uint(), x$3 = v2.Uint(), (x$2.$high < x$3.$high || (x$2.$high === x$3.$high && x$2.$low < x$3.$low))); + } else { + $panic(new $String("invalid kind")); + } + return [truth$1, $ifaceNil]; }; - UnmarshalWithParams = $pkg.UnmarshalWithParams = function(b, val, params) { - var rest = ($sliceType($Uint8)).nil, err = $ifaceNil, v, _tuple, offset, _tmp, _tmp$1, _tmp$2, _tmp$3; - v = new reflect.Value.Ptr(); $copy(v, reflect.ValueOf(val).Elem(), reflect.Value); - _tuple = parseField($clone(v, reflect.Value), b, 0, $clone(parseFieldParameters(params), fieldParameters)); offset = _tuple[0]; err = _tuple[1]; - if (!($interfaceIsEqual(err, $ifaceNil))) { - _tmp = ($sliceType($Uint8)).nil; _tmp$1 = err; rest = _tmp; err = _tmp$1; - return [rest, err]; + le = function(arg1, arg2) { + var _tuple, lessThan, err; + _tuple = lt(arg1, arg2); lessThan = _tuple[0]; err = _tuple[1]; + if (lessThan || !($interfaceIsEqual(err, $ifaceNil))) { + return [lessThan, err]; } - _tmp$2 = $subslice(b, offset); _tmp$3 = $ifaceNil; rest = _tmp$2; err = _tmp$3; - return [rest, err]; + return eq(arg1, new ($sliceType($emptyInterface))([arg2])); }; - parseFieldParameters = function(str) { - var ret = new fieldParameters.Ptr(), _ref, _i, part, _tuple, i, err, _tuple$1, i$1, err$1; - _ref = strings.Split(str, ","); - _i = 0; - while (_i < _ref.$length) { - part = ((_i < 0 || _i >= _ref.$length) ? $throwRuntimeError("index out of range") : _ref.$array[_ref.$offset + _i]); - if (part === "optional") { - ret.optional = true; - } else if (part === "explicit") { - ret.explicit = true; - if ($pointerIsEqual(ret.tag, ($ptrType($Int)).nil)) { - ret.tag = $newDataPointer(0, ($ptrType($Int))); - } - } else if (part === "ia5") { - ret.stringType = 22; - } else if (part === "printable") { - ret.stringType = 19; - } else if (part === "utf8") { - ret.stringType = 12; - } else if (strings.HasPrefix(part, "default:")) { - _tuple = strconv.ParseInt(part.substring(8), 10, 64); i = _tuple[0]; err = _tuple[1]; - if ($interfaceIsEqual(err, $ifaceNil)) { - ret.defaultValue = $newDataPointer(new $Int64(0, 0), ($ptrType($Int64))); - ret.defaultValue.$set(i); - } - } else if (strings.HasPrefix(part, "tag:")) { - _tuple$1 = strconv.Atoi(part.substring(4)); i$1 = _tuple$1[0]; err$1 = _tuple$1[1]; - if ($interfaceIsEqual(err$1, $ifaceNil)) { - ret.tag = $newDataPointer(0, ($ptrType($Int))); - ret.tag.$set(i$1); - } - } else if (part === "set") { - ret.set = true; - } else if (part === "application") { - ret.application = true; - if ($pointerIsEqual(ret.tag, ($ptrType($Int)).nil)) { - ret.tag = $newDataPointer(0, ($ptrType($Int))); - } - } else if (part === "omitempty") { - ret.omitEmpty = true; - } - _i++; + gt = function(arg1, arg2) { + var _tuple, lessOrEqual, err; + _tuple = le(arg1, arg2); lessOrEqual = _tuple[0]; err = _tuple[1]; + if (!($interfaceIsEqual(err, $ifaceNil))) { + return [false, err]; } - return ret; + return [!lessOrEqual, $ifaceNil]; }; - getUniversalType = function(t) { - var tagNumber = 0, isCompound = false, ok = false, _ref, _tmp, _tmp$1, _tmp$2, _tmp$3, _tmp$4, _tmp$5, _tmp$6, _tmp$7, _tmp$8, _tmp$9, _tmp$10, _tmp$11, _tmp$12, _tmp$13, _tmp$14, _ref$1, _tmp$15, _tmp$16, _tmp$17, _tmp$18, _tmp$19, _tmp$20, _tmp$21, _tmp$22, _tmp$23, _tmp$24, _tmp$25, _tmp$26, _tmp$27, _tmp$28, _tmp$29, _tmp$30, _tmp$31, _tmp$32, _tmp$33, _tmp$34, _tmp$35, _tmp$36, _tmp$37, _tmp$38; - _ref = t; - if ($interfaceIsEqual(_ref, objectIdentifierType)) { - _tmp = 6; _tmp$1 = false; _tmp$2 = true; tagNumber = _tmp; isCompound = _tmp$1; ok = _tmp$2; - return [tagNumber, isCompound, ok]; - } else if ($interfaceIsEqual(_ref, bitStringType)) { - _tmp$3 = 3; _tmp$4 = false; _tmp$5 = true; tagNumber = _tmp$3; isCompound = _tmp$4; ok = _tmp$5; - return [tagNumber, isCompound, ok]; - } else if ($interfaceIsEqual(_ref, timeType)) { - _tmp$6 = 23; _tmp$7 = false; _tmp$8 = true; tagNumber = _tmp$6; isCompound = _tmp$7; ok = _tmp$8; - return [tagNumber, isCompound, ok]; - } else if ($interfaceIsEqual(_ref, enumeratedType)) { - _tmp$9 = 10; _tmp$10 = false; _tmp$11 = true; tagNumber = _tmp$9; isCompound = _tmp$10; ok = _tmp$11; - return [tagNumber, isCompound, ok]; - } else if ($interfaceIsEqual(_ref, bigIntType)) { - _tmp$12 = 2; _tmp$13 = false; _tmp$14 = true; tagNumber = _tmp$12; isCompound = _tmp$13; ok = _tmp$14; - return [tagNumber, isCompound, ok]; + ge = function(arg1, arg2) { + var _tuple, lessThan, err; + _tuple = lt(arg1, arg2); lessThan = _tuple[0]; err = _tuple[1]; + if (!($interfaceIsEqual(err, $ifaceNil))) { + return [false, err]; } - _ref$1 = t.Kind(); - if (_ref$1 === 1) { - _tmp$15 = 1; _tmp$16 = false; _tmp$17 = true; tagNumber = _tmp$15; isCompound = _tmp$16; ok = _tmp$17; - return [tagNumber, isCompound, ok]; - } else if (_ref$1 === 2 || _ref$1 === 3 || _ref$1 === 4 || _ref$1 === 5 || _ref$1 === 6) { - _tmp$18 = 2; _tmp$19 = false; _tmp$20 = true; tagNumber = _tmp$18; isCompound = _tmp$19; ok = _tmp$20; - return [tagNumber, isCompound, ok]; - } else if (_ref$1 === 25) { - _tmp$21 = 16; _tmp$22 = true; _tmp$23 = true; tagNumber = _tmp$21; isCompound = _tmp$22; ok = _tmp$23; - return [tagNumber, isCompound, ok]; - } else if (_ref$1 === 23) { - if (t.Elem().Kind() === 8) { - _tmp$24 = 4; _tmp$25 = false; _tmp$26 = true; tagNumber = _tmp$24; isCompound = _tmp$25; ok = _tmp$26; - return [tagNumber, isCompound, ok]; - } - if (strings.HasSuffix(t.Name(), "SET")) { - _tmp$27 = 17; _tmp$28 = true; _tmp$29 = true; tagNumber = _tmp$27; isCompound = _tmp$28; ok = _tmp$29; - return [tagNumber, isCompound, ok]; + return [!lessThan, $ifaceNil]; + }; + HTMLEscape = $pkg.HTMLEscape = function(w, b) { + var last, _ref, _i, i, c, html, _ref$1; + last = 0; + _ref = b; + _i = 0; + while (_i < _ref.$length) { + i = _i; + c = ((_i < 0 || _i >= _ref.$length) ? $throwRuntimeError("index out of range") : _ref.$array[_ref.$offset + _i]); + html = ($sliceType($Uint8)).nil; + _ref$1 = c; + if (_ref$1 === 34) { + html = htmlQuot; + } else if (_ref$1 === 39) { + html = htmlApos; + } else if (_ref$1 === 38) { + html = htmlAmp; + } else if (_ref$1 === 60) { + html = htmlLt; + } else if (_ref$1 === 62) { + html = htmlGt; + } else { + _i++; + continue; } - _tmp$30 = 16; _tmp$31 = true; _tmp$32 = true; tagNumber = _tmp$30; isCompound = _tmp$31; ok = _tmp$32; - return [tagNumber, isCompound, ok]; - } else if (_ref$1 === 24) { - _tmp$33 = 19; _tmp$34 = false; _tmp$35 = true; tagNumber = _tmp$33; isCompound = _tmp$34; ok = _tmp$35; - return [tagNumber, isCompound, ok]; + w.Write($subslice(b, last, i)); + w.Write(html); + last = i + 1 >> 0; + _i++; } - _tmp$36 = 0; _tmp$37 = false; _tmp$38 = false; tagNumber = _tmp$36; isCompound = _tmp$37; ok = _tmp$38; - return [tagNumber, isCompound, ok]; + w.Write($subslice(b, last)); }; - $pkg.$init = function() { - StructuralError.methods = [["Error", "Error", "", $funcType([], [$String], false), -1]]; - ($ptrType(StructuralError)).methods = [["Error", "Error", "", $funcType([], [$String], false), -1]]; - StructuralError.init([["Msg", "Msg", "", $String, ""]]); - SyntaxError.methods = [["Error", "Error", "", $funcType([], [$String], false), -1]]; - ($ptrType(SyntaxError)).methods = [["Error", "Error", "", $funcType([], [$String], false), -1]]; - SyntaxError.init([["Msg", "Msg", "", $String, ""]]); - BitString.methods = [["At", "At", "", $funcType([$Int], [$Int], false), -1], ["RightAlign", "RightAlign", "", $funcType([], [($sliceType($Uint8))], false), -1]]; - ($ptrType(BitString)).methods = [["At", "At", "", $funcType([$Int], [$Int], false), -1], ["RightAlign", "RightAlign", "", $funcType([], [($sliceType($Uint8))], false), -1]]; - BitString.init([["Bytes", "Bytes", "", ($sliceType($Uint8)), ""], ["BitLength", "BitLength", "", $Int, ""]]); - ObjectIdentifier.methods = [["Equal", "Equal", "", $funcType([ObjectIdentifier], [$Bool], false), -1], ["String", "String", "", $funcType([], [$String], false), -1]]; - ($ptrType(ObjectIdentifier)).methods = [["Equal", "Equal", "", $funcType([ObjectIdentifier], [$Bool], false), -1], ["String", "String", "", $funcType([], [$String], false), -1]]; - ObjectIdentifier.init($Int); - RawValue.init([["Class", "Class", "", $Int, ""], ["Tag", "Tag", "", $Int, ""], ["IsCompound", "IsCompound", "", $Bool, ""], ["Bytes", "Bytes", "", ($sliceType($Uint8)), ""], ["FullBytes", "FullBytes", "", ($sliceType($Uint8)), ""]]); - RawContent.init($Uint8); - tagAndLength.init([["class$0", "class", "encoding/asn1", $Int, ""], ["tag", "tag", "encoding/asn1", $Int, ""], ["length", "length", "encoding/asn1", $Int, ""], ["isCompound", "isCompound", "encoding/asn1", $Bool, ""]]); - fieldParameters.init([["optional", "optional", "encoding/asn1", $Bool, ""], ["explicit", "explicit", "encoding/asn1", $Bool, ""], ["application", "application", "encoding/asn1", $Bool, ""], ["defaultValue", "defaultValue", "encoding/asn1", ($ptrType($Int64)), ""], ["tag", "tag", "encoding/asn1", ($ptrType($Int)), ""], ["stringType", "stringType", "encoding/asn1", $Int, ""], ["set", "set", "encoding/asn1", $Bool, ""], ["omitEmpty", "omitEmpty", "encoding/asn1", $Bool, ""]]); - bigOne = big.NewInt(new $Int64(0, 1)); - bitStringType = reflect.TypeOf((x = new BitString.Ptr(($sliceType($Uint8)).nil, 0), new x.constructor.Struct(x))); - objectIdentifierType = reflect.TypeOf(new ObjectIdentifier([])); - enumeratedType = reflect.TypeOf(new Enumerated(0)); - flagType = reflect.TypeOf(new Flag(false)); - timeType = reflect.TypeOf((x$1 = new time.Time.Ptr(new $Int64(0, 0), 0, ($ptrType(time.Location)).nil), new x$1.constructor.Struct(x$1))); - rawValueType = reflect.TypeOf((x$2 = new RawValue.Ptr(0, 0, false, ($sliceType($Uint8)).nil, ($sliceType($Uint8)).nil), new x$2.constructor.Struct(x$2))); - rawContentsType = reflect.TypeOf(RawContent.nil); - bigIntType = reflect.TypeOf(new big.Int.Ptr()); + HTMLEscapeString = $pkg.HTMLEscapeString = function(s) { + var b; + if (strings.IndexAny(s, "'\"&<>") < 0) { + return s; + } + b = new bytes.Buffer.Ptr(); $copy(b, new bytes.Buffer.Ptr(), bytes.Buffer); + HTMLEscape(b, new ($sliceType($Uint8))($stringToBytes(s))); + return b.String(); }; - return $pkg; -})(); -$packages["encoding"] = (function() { - var $pkg = {}, TextMarshaler, TextUnmarshaler; - TextMarshaler = $pkg.TextMarshaler = $newType(8, "Interface", "encoding.TextMarshaler", "TextMarshaler", "encoding", null); - TextUnmarshaler = $pkg.TextUnmarshaler = $newType(8, "Interface", "encoding.TextUnmarshaler", "TextUnmarshaler", "encoding", null); - $pkg.$init = function() { - TextMarshaler.init([["MarshalText", "MarshalText", "", $funcType([], [($sliceType($Uint8)), $error], false)]]); - TextUnmarshaler.init([["UnmarshalText", "UnmarshalText", "", $funcType([($sliceType($Uint8))], [$error], false)]]); + HTMLEscaper = $pkg.HTMLEscaper = function(args) { + return HTMLEscapeString(evalArgs(args)); }; - return $pkg; -})(); -$packages["encoding/base64"] = (function() { - var $pkg = {}, testing = $packages["testing"], bytes = $packages["bytes"], io = $packages["io"], strconv = $packages["strconv"], strings = $packages["strings"], Encoding, encoder, CorruptInputError, removeNewlinesMapper, NewEncoding, NewEncoder; - Encoding = $pkg.Encoding = $newType(0, "Struct", "base64.Encoding", "Encoding", "encoding/base64", function(encode_, decodeMap_) { - this.$val = this; - this.encode = encode_ !== undefined ? encode_ : ""; - this.decodeMap = decodeMap_ !== undefined ? decodeMap_ : ($arrayType($Uint8, 256)).zero(); - }); - encoder = $pkg.encoder = $newType(0, "Struct", "base64.encoder", "encoder", "encoding/base64", function(err_, enc_, w_, buf_, nbuf_, out_) { - this.$val = this; - this.err = err_ !== undefined ? err_ : $ifaceNil; - this.enc = enc_ !== undefined ? enc_ : ($ptrType(Encoding)).nil; - this.w = w_ !== undefined ? w_ : $ifaceNil; - this.buf = buf_ !== undefined ? buf_ : ($arrayType($Uint8, 3)).zero(); - this.nbuf = nbuf_ !== undefined ? nbuf_ : 0; - this.out = out_ !== undefined ? out_ : ($arrayType($Uint8, 1024)).zero(); - }); - CorruptInputError = $pkg.CorruptInputError = $newType(8, "Int64", "base64.CorruptInputError", "CorruptInputError", "encoding/base64", null); - NewEncoding = $pkg.NewEncoding = function(encoder$1) { - var e, i, x, i$1, x$1, x$2; - e = new Encoding.Ptr(); - e.encode = encoder$1; + JSEscape = $pkg.JSEscape = function(w, b) { + var last, i, c, _ref, _tmp, _tmp$1, t, b$1, _tuple, r, size; + last = 0; i = 0; - while (i < 256) { - (x = e.decodeMap, (i < 0 || i >= x.length) ? $throwRuntimeError("index out of range") : x[i] = 255); + while (i < b.$length) { + c = ((i < 0 || i >= b.$length) ? $throwRuntimeError("index out of range") : b.$array[b.$offset + i]); + if (!jsIsSpecial((c >> 0))) { + i = i + (1) >> 0; + continue; + } + w.Write($subslice(b, last, i)); + if (c < 128) { + _ref = c; + if (_ref === 92) { + w.Write(jsBackslash); + } else if (_ref === 39) { + w.Write(jsApos); + } else if (_ref === 34) { + w.Write(jsQuot); + } else if (_ref === 60) { + w.Write(jsLt); + } else if (_ref === 62) { + w.Write(jsGt); + } else { + w.Write(jsLowUni); + _tmp = c >>> 4 << 24 >>> 24; _tmp$1 = (c & 15) >>> 0; t = _tmp; b$1 = _tmp$1; + w.Write($subslice(hex, t, (t + 1 << 24 >>> 24))); + w.Write($subslice(hex, b$1, (b$1 + 1 << 24 >>> 24))); + } + } else { + _tuple = utf8.DecodeRune($subslice(b, i)); r = _tuple[0]; size = _tuple[1]; + if (unicode.IsPrint(r)) { + w.Write($subslice(b, i, (i + size >> 0))); + } else { + fmt.Fprintf(w, "\\u%04X", new ($sliceType($emptyInterface))([new $Int32(r)])); + } + i = i + ((size - 1 >> 0)) >> 0; + } + last = i + 1 >> 0; i = i + (1) >> 0; } - i$1 = 0; - while (i$1 < encoder$1.length) { - (x$1 = e.decodeMap, x$2 = encoder$1.charCodeAt(i$1), (x$2 < 0 || x$2 >= x$1.length) ? $throwRuntimeError("index out of range") : x$1[x$2] = (i$1 << 24 >>> 24)); - i$1 = i$1 + (1) >> 0; + w.Write($subslice(b, last)); + }; + JSEscapeString = $pkg.JSEscapeString = function(s) { + var b; + if (strings.IndexFunc(s, jsIsSpecial) < 0) { + return s; } - return e; + b = new bytes.Buffer.Ptr(); $copy(b, new bytes.Buffer.Ptr(), bytes.Buffer); + JSEscape(b, new ($sliceType($Uint8))($stringToBytes(s))); + return b.String(); }; - Encoding.Ptr.prototype.Encode = function(dst, src) { - var enc, _ref, _lhs, _index, _lhs$1, _index$1, _lhs$2, _index$2, _lhs$3, _index$3, _lhs$4, _index$4, _lhs$5, _index$5, _lhs$6, _index$6, _lhs$7, _index$7, _lhs$8, _index$8, _lhs$9, _index$9, _lhs$10, _index$10, _lhs$11, _index$11, j; - enc = this; - if (src.$length === 0) { - return; + jsIsSpecial = function(r) { + var _ref; + _ref = r; + if (_ref === 92 || _ref === 39 || _ref === 34 || _ref === 60 || _ref === 62) { + return true; } - while (src.$length > 0) { - (0 < 0 || 0 >= dst.$length) ? $throwRuntimeError("index out of range") : dst.$array[dst.$offset + 0] = 0; - (1 < 0 || 1 >= dst.$length) ? $throwRuntimeError("index out of range") : dst.$array[dst.$offset + 1] = 0; - (2 < 0 || 2 >= dst.$length) ? $throwRuntimeError("index out of range") : dst.$array[dst.$offset + 2] = 0; - (3 < 0 || 3 >= dst.$length) ? $throwRuntimeError("index out of range") : dst.$array[dst.$offset + 3] = 0; - _ref = src.$length; - if (_ref === 2) { - _lhs = dst; _index = 2; (_index < 0 || _index >= _lhs.$length) ? $throwRuntimeError("index out of range") : _lhs.$array[_lhs.$offset + _index] = (((_index < 0 || _index >= _lhs.$length) ? $throwRuntimeError("index out of range") : _lhs.$array[_lhs.$offset + _index]) | (((((((1 < 0 || 1 >= src.$length) ? $throwRuntimeError("index out of range") : src.$array[src.$offset + 1]) << 2 << 24 >>> 24)) & 63) >>> 0))) >>> 0; - _lhs$1 = dst; _index$1 = 1; (_index$1 < 0 || _index$1 >= _lhs$1.$length) ? $throwRuntimeError("index out of range") : _lhs$1.$array[_lhs$1.$offset + _index$1] = (((_index$1 < 0 || _index$1 >= _lhs$1.$length) ? $throwRuntimeError("index out of range") : _lhs$1.$array[_lhs$1.$offset + _index$1]) | ((((1 < 0 || 1 >= src.$length) ? $throwRuntimeError("index out of range") : src.$array[src.$offset + 1]) >>> 4 << 24 >>> 24))) >>> 0; - _lhs$2 = dst; _index$2 = 1; (_index$2 < 0 || _index$2 >= _lhs$2.$length) ? $throwRuntimeError("index out of range") : _lhs$2.$array[_lhs$2.$offset + _index$2] = (((_index$2 < 0 || _index$2 >= _lhs$2.$length) ? $throwRuntimeError("index out of range") : _lhs$2.$array[_lhs$2.$offset + _index$2]) | (((((((0 < 0 || 0 >= src.$length) ? $throwRuntimeError("index out of range") : src.$array[src.$offset + 0]) << 4 << 24 >>> 24)) & 63) >>> 0))) >>> 0; - _lhs$3 = dst; _index$3 = 0; (_index$3 < 0 || _index$3 >= _lhs$3.$length) ? $throwRuntimeError("index out of range") : _lhs$3.$array[_lhs$3.$offset + _index$3] = (((_index$3 < 0 || _index$3 >= _lhs$3.$length) ? $throwRuntimeError("index out of range") : _lhs$3.$array[_lhs$3.$offset + _index$3]) | ((((0 < 0 || 0 >= src.$length) ? $throwRuntimeError("index out of range") : src.$array[src.$offset + 0]) >>> 2 << 24 >>> 24))) >>> 0; - } else if (_ref === 1) { - _lhs$4 = dst; _index$4 = 1; (_index$4 < 0 || _index$4 >= _lhs$4.$length) ? $throwRuntimeError("index out of range") : _lhs$4.$array[_lhs$4.$offset + _index$4] = (((_index$4 < 0 || _index$4 >= _lhs$4.$length) ? $throwRuntimeError("index out of range") : _lhs$4.$array[_lhs$4.$offset + _index$4]) | (((((((0 < 0 || 0 >= src.$length) ? $throwRuntimeError("index out of range") : src.$array[src.$offset + 0]) << 4 << 24 >>> 24)) & 63) >>> 0))) >>> 0; - _lhs$5 = dst; _index$5 = 0; (_index$5 < 0 || _index$5 >= _lhs$5.$length) ? $throwRuntimeError("index out of range") : _lhs$5.$array[_lhs$5.$offset + _index$5] = (((_index$5 < 0 || _index$5 >= _lhs$5.$length) ? $throwRuntimeError("index out of range") : _lhs$5.$array[_lhs$5.$offset + _index$5]) | ((((0 < 0 || 0 >= src.$length) ? $throwRuntimeError("index out of range") : src.$array[src.$offset + 0]) >>> 2 << 24 >>> 24))) >>> 0; - } else { - _lhs$6 = dst; _index$6 = 3; (_index$6 < 0 || _index$6 >= _lhs$6.$length) ? $throwRuntimeError("index out of range") : _lhs$6.$array[_lhs$6.$offset + _index$6] = (((_index$6 < 0 || _index$6 >= _lhs$6.$length) ? $throwRuntimeError("index out of range") : _lhs$6.$array[_lhs$6.$offset + _index$6]) | (((((2 < 0 || 2 >= src.$length) ? $throwRuntimeError("index out of range") : src.$array[src.$offset + 2]) & 63) >>> 0))) >>> 0; - _lhs$7 = dst; _index$7 = 2; (_index$7 < 0 || _index$7 >= _lhs$7.$length) ? $throwRuntimeError("index out of range") : _lhs$7.$array[_lhs$7.$offset + _index$7] = (((_index$7 < 0 || _index$7 >= _lhs$7.$length) ? $throwRuntimeError("index out of range") : _lhs$7.$array[_lhs$7.$offset + _index$7]) | ((((2 < 0 || 2 >= src.$length) ? $throwRuntimeError("index out of range") : src.$array[src.$offset + 2]) >>> 6 << 24 >>> 24))) >>> 0; - _lhs$8 = dst; _index$8 = 2; (_index$8 < 0 || _index$8 >= _lhs$8.$length) ? $throwRuntimeError("index out of range") : _lhs$8.$array[_lhs$8.$offset + _index$8] = (((_index$8 < 0 || _index$8 >= _lhs$8.$length) ? $throwRuntimeError("index out of range") : _lhs$8.$array[_lhs$8.$offset + _index$8]) | (((((((1 < 0 || 1 >= src.$length) ? $throwRuntimeError("index out of range") : src.$array[src.$offset + 1]) << 2 << 24 >>> 24)) & 63) >>> 0))) >>> 0; - _lhs$9 = dst; _index$9 = 1; (_index$9 < 0 || _index$9 >= _lhs$9.$length) ? $throwRuntimeError("index out of range") : _lhs$9.$array[_lhs$9.$offset + _index$9] = (((_index$9 < 0 || _index$9 >= _lhs$9.$length) ? $throwRuntimeError("index out of range") : _lhs$9.$array[_lhs$9.$offset + _index$9]) | ((((1 < 0 || 1 >= src.$length) ? $throwRuntimeError("index out of range") : src.$array[src.$offset + 1]) >>> 4 << 24 >>> 24))) >>> 0; - _lhs$10 = dst; _index$10 = 1; (_index$10 < 0 || _index$10 >= _lhs$10.$length) ? $throwRuntimeError("index out of range") : _lhs$10.$array[_lhs$10.$offset + _index$10] = (((_index$10 < 0 || _index$10 >= _lhs$10.$length) ? $throwRuntimeError("index out of range") : _lhs$10.$array[_lhs$10.$offset + _index$10]) | (((((((0 < 0 || 0 >= src.$length) ? $throwRuntimeError("index out of range") : src.$array[src.$offset + 0]) << 4 << 24 >>> 24)) & 63) >>> 0))) >>> 0; - _lhs$11 = dst; _index$11 = 0; (_index$11 < 0 || _index$11 >= _lhs$11.$length) ? $throwRuntimeError("index out of range") : _lhs$11.$array[_lhs$11.$offset + _index$11] = (((_index$11 < 0 || _index$11 >= _lhs$11.$length) ? $throwRuntimeError("index out of range") : _lhs$11.$array[_lhs$11.$offset + _index$11]) | ((((0 < 0 || 0 >= src.$length) ? $throwRuntimeError("index out of range") : src.$array[src.$offset + 0]) >>> 2 << 24 >>> 24))) >>> 0; - } - j = 0; - while (j < 4) { - (j < 0 || j >= dst.$length) ? $throwRuntimeError("index out of range") : dst.$array[dst.$offset + j] = enc.encode.charCodeAt(((j < 0 || j >= dst.$length) ? $throwRuntimeError("index out of range") : dst.$array[dst.$offset + j])); - j = j + (1) >> 0; - } - if (src.$length < 3) { - (3 < 0 || 3 >= dst.$length) ? $throwRuntimeError("index out of range") : dst.$array[dst.$offset + 3] = 61; - if (src.$length < 2) { - (2 < 0 || 2 >= dst.$length) ? $throwRuntimeError("index out of range") : dst.$array[dst.$offset + 2] = 61; + return r < 32 || 128 <= r; + }; + JSEscaper = $pkg.JSEscaper = function(args) { + return JSEscapeString(evalArgs(args)); + }; + URLQueryEscaper = $pkg.URLQueryEscaper = function(args) { + return url.QueryEscape(evalArgs(args)); + }; + evalArgs = function(args) { + var ok, s, _tuple, _ref, _i, i, arg, _tuple$1, a, ok$1; + ok = false; + s = ""; + if (args.$length === 1) { + _tuple = $assertType(((0 < 0 || 0 >= args.$length) ? $throwRuntimeError("index out of range") : args.$array[args.$offset + 0]), $String, true); s = _tuple[0]; ok = _tuple[1]; + } + if (!ok) { + _ref = args; + _i = 0; + while (_i < _ref.$length) { + i = _i; + arg = ((_i < 0 || _i >= _ref.$length) ? $throwRuntimeError("index out of range") : _ref.$array[_ref.$offset + _i]); + _tuple$1 = printableValue($clone(reflect.ValueOf(arg), reflect.Value)); a = _tuple$1[0]; ok$1 = _tuple$1[1]; + if (ok$1) { + (i < 0 || i >= args.$length) ? $throwRuntimeError("index out of range") : args.$array[args.$offset + i] = a; } - break; + _i++; } - src = $subslice(src, 3); - dst = $subslice(dst, 4); + s = fmt.Sprint(args); } + return s; }; - Encoding.prototype.Encode = function(dst, src) { return this.$val.Encode(dst, src); }; - Encoding.Ptr.prototype.EncodeToString = function(src) { - var enc, buf; - enc = this; - buf = ($sliceType($Uint8)).make(enc.EncodedLen(src.$length)); - enc.Encode(buf, src); - return $bytesToString(buf); + $pkg.$init = function() { + errorType = reflect.TypeOf(($ptrType($error)).nil).Elem(); + fmtStringerType = reflect.TypeOf(($ptrType(fmt.Stringer)).nil).Elem(); + errBadComparisonType = errors.New("invalid type for comparison"); + errBadComparison = errors.New("incompatible types for comparison"); + errNoComparison = errors.New("missing argument for comparison"); + htmlQuot = new ($sliceType($Uint8))($stringToBytes(""")); + htmlApos = new ($sliceType($Uint8))($stringToBytes("'")); + htmlAmp = new ($sliceType($Uint8))($stringToBytes("&")); + htmlLt = new ($sliceType($Uint8))($stringToBytes("<")); + htmlGt = new ($sliceType($Uint8))($stringToBytes(">")); + jsLowUni = new ($sliceType($Uint8))($stringToBytes("\\u00")); + hex = new ($sliceType($Uint8))($stringToBytes("0123456789ABCDEF")); + jsBackslash = new ($sliceType($Uint8))($stringToBytes("\\\\")); + jsApos = new ($sliceType($Uint8))($stringToBytes("\\'")); + jsQuot = new ($sliceType($Uint8))($stringToBytes("\\\"")); + jsLt = new ($sliceType($Uint8))($stringToBytes("\\x3C")); + jsGt = new ($sliceType($Uint8))($stringToBytes("\\x3E")); + builtins = (_map = new $Map(), _key = "and", _map[_key] = { k: _key, v: new ($funcType([$emptyInterface, ($sliceType($emptyInterface))], [$emptyInterface], true))(and) }, _key = "call", _map[_key] = { k: _key, v: new ($funcType([$emptyInterface, ($sliceType($emptyInterface))], [$emptyInterface, $error], true))(call) }, _key = "html", _map[_key] = { k: _key, v: new ($funcType([($sliceType($emptyInterface))], [$String], true))(HTMLEscaper) }, _key = "index", _map[_key] = { k: _key, v: new ($funcType([$emptyInterface, ($sliceType($emptyInterface))], [$emptyInterface, $error], true))(index) }, _key = "js", _map[_key] = { k: _key, v: new ($funcType([($sliceType($emptyInterface))], [$String], true))(JSEscaper) }, _key = "len", _map[_key] = { k: _key, v: new ($funcType([$emptyInterface], [$Int, $error], false))(length) }, _key = "not", _map[_key] = { k: _key, v: new ($funcType([$emptyInterface], [$Bool], false))(not) }, _key = "or", _map[_key] = { k: _key, v: new ($funcType([$emptyInterface, ($sliceType($emptyInterface))], [$emptyInterface], true))(or) }, _key = "print", _map[_key] = { k: _key, v: new ($funcType([($sliceType($emptyInterface))], [$String], true))(fmt.Sprint) }, _key = "printf", _map[_key] = { k: _key, v: new ($funcType([$String, ($sliceType($emptyInterface))], [$String], true))(fmt.Sprintf) }, _key = "println", _map[_key] = { k: _key, v: new ($funcType([($sliceType($emptyInterface))], [$String], true))(fmt.Sprintln) }, _key = "urlquery", _map[_key] = { k: _key, v: new ($funcType([($sliceType($emptyInterface))], [$String], true))(URLQueryEscaper) }, _key = "eq", _map[_key] = { k: _key, v: new ($funcType([$emptyInterface, ($sliceType($emptyInterface))], [$Bool, $error], true))(eq) }, _key = "ge", _map[_key] = { k: _key, v: new ($funcType([$emptyInterface, $emptyInterface], [$Bool, $error], false))(ge) }, _key = "gt", _map[_key] = { k: _key, v: new ($funcType([$emptyInterface, $emptyInterface], [$Bool, $error], false))(gt) }, _key = "le", _map[_key] = { k: _key, v: new ($funcType([$emptyInterface, $emptyInterface], [$Bool, $error], false))(le) }, _key = "lt", _map[_key] = { k: _key, v: new ($funcType([$emptyInterface, $emptyInterface], [$Bool, $error], false))(lt) }, _key = "ne", _map[_key] = { k: _key, v: new ($funcType([$emptyInterface, $emptyInterface], [$Bool, $error], false))(ne) }, _map); + builtinFuncs = createValueFuncs(builtins); }; - Encoding.prototype.EncodeToString = function(src) { return this.$val.EncodeToString(src); }; - encoder.Ptr.prototype.Write = function(p) { - var n = 0, err = $ifaceNil, e, _tmp, _tmp$1, i, x, x$1, _tuple, _tmp$2, _tmp$3, nn, _r, _tuple$1, x$2, _q, _tmp$4, _tmp$5, i$1, x$3; - e = this; - if (!($interfaceIsEqual(e.err, $ifaceNil))) { - _tmp = 0; _tmp$1 = e.err; n = _tmp; err = _tmp$1; - return [n, err]; - } - if (e.nbuf > 0) { - i = 0; - i = 0; - while (i < p.$length && e.nbuf < 3) { - (x = e.buf, x$1 = e.nbuf, (x$1 < 0 || x$1 >= x.length) ? $throwRuntimeError("index out of range") : x[x$1] = ((i < 0 || i >= p.$length) ? $throwRuntimeError("index out of range") : p.$array[p.$offset + i])); - e.nbuf = e.nbuf + (1) >> 0; - i = i + (1) >> 0; + return $pkg; +})(); +$packages["go/doc"] = (function() { + var $pkg = {}, io = $packages["io"], regexp = $packages["regexp"], strings = $packages["strings"], template = $packages["text/template"], unicode = $packages["unicode"], utf8 = $packages["unicode/utf8"], ast = $packages["go/ast"], token = $packages["go/token"], path = $packages["path"], sort = $packages["sort"], strconv = $packages["strconv"], matchRx, nonAlphaNumRx, outputPrefix, noteMarker, noteMarkerRx, noteCommentRx, firstSentenceLen, clean, Synopsis; + firstSentenceLen = function(s) { + var _tmp, _tmp$1, _tmp$2, ppp, pp, p, _ref, _i, _rune, i, q, _tmp$3, _tmp$4, _tmp$5; + _tmp = 0; _tmp$1 = 0; _tmp$2 = 0; ppp = _tmp; pp = _tmp$1; p = _tmp$2; + _ref = s; + _i = 0; + while (_i < _ref.length) { + _rune = $decodeRune(_ref, _i); + i = _i; + q = _rune[0]; + if ((q === 10) || (q === 13) || (q === 9)) { + q = 32; } - n = n + (i) >> 0; - p = $subslice(p, i); - if (e.nbuf < 3) { - return [n, err]; + if ((q === 32) && (p === 46) && (!unicode.IsUpper(pp) || unicode.IsUpper(ppp))) { + return i; } - e.enc.Encode($subslice(new ($sliceType($Uint8))(e.out), 0), $subslice(new ($sliceType($Uint8))(e.buf), 0)); - _tuple = e.w.Write($subslice(new ($sliceType($Uint8))(e.out), 0, 4)); e.err = _tuple[1]; - if (!($interfaceIsEqual(e.err, $ifaceNil))) { - _tmp$2 = n; _tmp$3 = e.err; n = _tmp$2; err = _tmp$3; - return [n, err]; + if ((p === 12290) || (p === 65294)) { + return i; } - e.nbuf = 0; + _tmp$3 = pp; _tmp$4 = p; _tmp$5 = q; ppp = _tmp$3; pp = _tmp$4; p = _tmp$5; + _i += _rune[1]; } - while (p.$length >= 3) { - nn = 768; - if (nn > p.$length) { - nn = p.$length; - nn = nn - ((_r = nn % 3, _r === _r ? _r : $throwRuntimeError("integer divide by zero"))) >> 0; + return s.length; + }; + clean = function(s, flags) { + var b, p, i, q, n; + b = ($sliceType($Uint8)).nil; + p = 32; + i = 0; + while (i < s.length) { + q = s.charCodeAt(i); + if ((((flags & 1)) === 0) && (q === 10) || (q === 13) || (q === 9)) { + q = 32; } - e.enc.Encode($subslice(new ($sliceType($Uint8))(e.out), 0), $subslice(p, 0, nn)); - _tuple$1 = e.w.Write($subslice(new ($sliceType($Uint8))(e.out), 0, (x$2 = (_q = nn / 3, (_q === _q && _q !== 1/0 && _q !== -1/0) ? _q >> 0 : $throwRuntimeError("integer divide by zero")), (((x$2 >>> 16 << 16) * 4 >> 0) + (x$2 << 16 >>> 16) * 4) >> 0))); e.err = _tuple$1[1]; - if (!($interfaceIsEqual(e.err, $ifaceNil))) { - _tmp$4 = n; _tmp$5 = e.err; n = _tmp$4; err = _tmp$5; - return [n, err]; + if (!((q === 32)) || !((p === 32))) { + b = $append(b, q); + p = q; } - n = n + (nn) >> 0; - p = $subslice(p, nn); + i = i + (1) >> 0; } - i$1 = 0; - while (i$1 < p.$length) { - (x$3 = e.buf, (i$1 < 0 || i$1 >= x$3.length) ? $throwRuntimeError("index out of range") : x$3[i$1] = ((i$1 < 0 || i$1 >= p.$length) ? $throwRuntimeError("index out of range") : p.$array[p.$offset + i$1])); - i$1 = i$1 + (1) >> 0; + n = b.$length; + if (n > 0 && (p === 32)) { + b = $subslice(b, 0, (n - 1 >> 0)); } - e.nbuf = p.$length; - n = n + (p.$length) >> 0; - return [n, err]; + return $bytesToString(b); }; - encoder.prototype.Write = function(p) { return this.$val.Write(p); }; - encoder.Ptr.prototype.Close = function() { - var e, _tuple; - e = this; - if ($interfaceIsEqual(e.err, $ifaceNil) && e.nbuf > 0) { - e.enc.Encode($subslice(new ($sliceType($Uint8))(e.out), 0), $subslice(new ($sliceType($Uint8))(e.buf), 0, e.nbuf)); - e.nbuf = 0; - _tuple = e.w.Write($subslice(new ($sliceType($Uint8))(e.out), 0, 4)); e.err = _tuple[1]; + Synopsis = $pkg.Synopsis = function(s) { + var _ref, _i, prefix; + s = clean(s.substring(0, firstSentenceLen(s)), 0); + _ref = $pkg.IllegalPrefixes; + _i = 0; + while (_i < _ref.$length) { + prefix = ((_i < 0 || _i >= _ref.$length) ? $throwRuntimeError("index out of range") : _ref.$array[_ref.$offset + _i]); + if (strings.HasPrefix(strings.ToLower(s), prefix)) { + return ""; + } + _i++; } - return e.err; + return s; }; - encoder.prototype.Close = function() { return this.$val.Close(); }; - NewEncoder = $pkg.NewEncoder = function(enc, w) { - return new encoder.Ptr($ifaceNil, enc, w, ($arrayType($Uint8, 3)).zero(), 0, ($arrayType($Uint8, 1024)).zero()); + $pkg.$init = function() { + matchRx = regexp.MustCompile("((https?|ftp|file|gopher|mailto|news|nntp|telnet|wais|prospero)://[a-zA-Z0-9_@\\-]+([.:][a-zA-Z0-9_@\\-]+)*/?[a-zA-Z0-9_?%#~&/\\-+=()]+([:.,][a-zA-Z0-9_?%#~&/\\-+=()]+)*)|([\\pL_][\\pL_0-9]*)"); + nonAlphaNumRx = regexp.MustCompile("[^a-zA-Z0-9]"); + outputPrefix = regexp.MustCompile("(?i)^[[:space:]]*output:"); + noteMarker = "([A-Z][A-Z]+)\\(([^)]+)\\):?"; + noteMarkerRx = regexp.MustCompile("^[ \\t]*" + noteMarker); + noteCommentRx = regexp.MustCompile("^/[/*][ \\t]*" + noteMarker); + $pkg.IllegalPrefixes = new ($sliceType($String))(["copyright", "all rights", "author"]); }; - Encoding.Ptr.prototype.EncodedLen = function(n) { - var enc, x, _q; - enc = this; - return (x = (_q = ((n + 2 >> 0)) / 3, (_q === _q && _q !== 1/0 && _q !== -1/0) ? _q >> 0 : $throwRuntimeError("integer divide by zero")), (((x >>> 16 << 16) * 4 >> 0) + (x << 16 >>> 16) * 4) >> 0); + return $pkg; +})(); +$packages["log"] = (function() { + var $pkg = {}, fmt = $packages["fmt"], io = $packages["io"], os = $packages["os"], runtime = $packages["runtime"], sync = $packages["sync"], time = $packages["time"], Logger, std, New, itoa, Panicf; + Logger = $pkg.Logger = $newType(0, "Struct", "log.Logger", "Logger", "log", function(mu_, prefix_, flag_, out_, buf_) { + this.$val = this; + this.mu = mu_ !== undefined ? mu_ : new sync.Mutex.Ptr(); + this.prefix = prefix_ !== undefined ? prefix_ : ""; + this.flag = flag_ !== undefined ? flag_ : 0; + this.out = out_ !== undefined ? out_ : $ifaceNil; + this.buf = buf_ !== undefined ? buf_ : ($sliceType($Uint8)).nil; + }); + New = $pkg.New = function(out, prefix, flag) { + return new Logger.Ptr(new sync.Mutex.Ptr(), prefix, flag, out, ($sliceType($Uint8)).nil); }; - Encoding.prototype.EncodedLen = function(n) { return this.$val.EncodedLen(n); }; - CorruptInputError.prototype.Error = function() { - var e; - e = this; - return "illegal base64 data at input byte " + strconv.FormatInt(new $Int64(e.$high, e.$low), 10); + itoa = function(buf, i, wid) { + var u, b, bp, _r, _q; + u = (i >>> 0); + if ((u === 0) && wid <= 1) { + buf.$set($append(buf.$get(), 48)); + return; + } + b = ($arrayType($Uint8, 32)).zero(); $copy(b, ($arrayType($Uint8, 32)).zero(), ($arrayType($Uint8, 32))); + bp = 32; + while (u > 0 || wid > 0) { + bp = bp - (1) >> 0; + wid = wid - (1) >> 0; + (bp < 0 || bp >= b.length) ? $throwRuntimeError("index out of range") : b[bp] = ((_r = u % 10, _r === _r ? _r : $throwRuntimeError("integer divide by zero")) << 24 >>> 24) + 48 << 24 >>> 24; + u = (_q = u / (10), (_q === _q && _q !== 1/0 && _q !== -1/0) ? _q >>> 0 : $throwRuntimeError("integer divide by zero")); + } + buf.$set($appendSlice(buf.$get(), $subslice(new ($sliceType($Uint8))(b), bp))); }; - $ptrType(CorruptInputError).prototype.Error = function() { return this.$get().Error(); }; - Encoding.Ptr.prototype.decode = function(dst, src) { - var n = 0, end = false, err = $ifaceNil, enc, olen, dbuf, dlen, _ref, _i, j, _tmp, _tmp$1, _tmp$2, in$1, _ref$1, _tmp$3, _tmp$4, _tmp$5, _tmp$6, _tmp$7, _tmp$8, _tmp$9, _tmp$10, _tmp$11, _tmp$12, _tmp$13, x, _tmp$14, _tmp$15, _tmp$16, _ref$2, _tmp$17, _tmp$18, _tmp$19; - enc = this; - olen = src.$length; - while (src.$length > 0 && !end) { - dbuf = ($arrayType($Uint8, 4)).zero(); $copy(dbuf, ($arrayType($Uint8, 4)).zero(), ($arrayType($Uint8, 4))); - dlen = 4; - _ref = dbuf; - _i = 0; - while (_i < 4) { - j = _i; - if (src.$length === 0) { - _tmp = n; _tmp$1 = false; _tmp$2 = new CorruptInputError(0, ((olen - src.$length >> 0) - j >> 0)); n = _tmp; end = _tmp$1; err = _tmp$2; - return [n, end, err]; - } - in$1 = ((0 < 0 || 0 >= src.$length) ? $throwRuntimeError("index out of range") : src.$array[src.$offset + 0]); - src = $subslice(src, 1); - if (in$1 === 61) { - _ref$1 = j; - if (_ref$1 === 0 || _ref$1 === 1) { - _tmp$3 = n; _tmp$4 = false; _tmp$5 = new CorruptInputError(0, ((olen - src.$length >> 0) - 1 >> 0)); n = _tmp$3; end = _tmp$4; err = _tmp$5; - return [n, end, err]; - } else if (_ref$1 === 2) { - if (src.$length === 0) { - _tmp$6 = n; _tmp$7 = false; _tmp$8 = new CorruptInputError(0, olen); n = _tmp$6; end = _tmp$7; err = _tmp$8; - return [n, end, err]; - } - if (!((((0 < 0 || 0 >= src.$length) ? $throwRuntimeError("index out of range") : src.$array[src.$offset + 0]) === 61))) { - _tmp$9 = n; _tmp$10 = false; _tmp$11 = new CorruptInputError(0, ((olen - src.$length >> 0) - 1 >> 0)); n = _tmp$9; end = _tmp$10; err = _tmp$11; - return [n, end, err]; - } - src = $subslice(src, 1); - } - if (src.$length > 0) { - err = new CorruptInputError(0, (olen - src.$length >> 0)); - } - _tmp$12 = j; _tmp$13 = true; dlen = _tmp$12; end = _tmp$13; - break; + Logger.Ptr.prototype.formatHeader = function(buf, t, file, line) { + var l, _tuple, year, month, day, _tuple$1, hour, min, sec, _q, short$1, i; + l = this; + buf.$set($appendSlice(buf.$get(), new ($sliceType($Uint8))($stringToBytes(l.prefix)))); + if (!(((l.flag & 7) === 0))) { + if (!(((l.flag & 1) === 0))) { + _tuple = t.Date(); year = _tuple[0]; month = _tuple[1]; day = _tuple[2]; + itoa(buf, year, 4); + buf.$set($append(buf.$get(), 47)); + itoa(buf, (month >> 0), 2); + buf.$set($append(buf.$get(), 47)); + itoa(buf, day, 2); + buf.$set($append(buf.$get(), 32)); + } + if (!(((l.flag & 6) === 0))) { + _tuple$1 = t.Clock(); hour = _tuple$1[0]; min = _tuple$1[1]; sec = _tuple$1[2]; + itoa(buf, hour, 2); + buf.$set($append(buf.$get(), 58)); + itoa(buf, min, 2); + buf.$set($append(buf.$get(), 58)); + itoa(buf, sec, 2); + if (!(((l.flag & 4) === 0))) { + buf.$set($append(buf.$get(), 46)); + itoa(buf, (_q = t.Nanosecond() / 1000, (_q === _q && _q !== 1/0 && _q !== -1/0) ? _q >> 0 : $throwRuntimeError("integer divide by zero")), 6); } - (j < 0 || j >= dbuf.length) ? $throwRuntimeError("index out of range") : dbuf[j] = (x = enc.decodeMap, ((in$1 < 0 || in$1 >= x.length) ? $throwRuntimeError("index out of range") : x[in$1])); - if (((j < 0 || j >= dbuf.length) ? $throwRuntimeError("index out of range") : dbuf[j]) === 255) { - _tmp$14 = n; _tmp$15 = false; _tmp$16 = new CorruptInputError(0, ((olen - src.$length >> 0) - 1 >> 0)); n = _tmp$14; end = _tmp$15; err = _tmp$16; - return [n, end, err]; + buf.$set($append(buf.$get(), 32)); + } + } + if (!(((l.flag & 24) === 0))) { + if (!(((l.flag & 16) === 0))) { + short$1 = file; + i = file.length - 1 >> 0; + while (i > 0) { + if (file.charCodeAt(i) === 47) { + short$1 = file.substring((i + 1 >> 0)); + break; + } + i = i - (1) >> 0; } - _i++; + file = short$1; } - _ref$2 = dlen; - if (_ref$2 === 4) { - (2 < 0 || 2 >= dst.$length) ? $throwRuntimeError("index out of range") : dst.$array[dst.$offset + 2] = ((dbuf[2] << 6 << 24 >>> 24) | dbuf[3]) >>> 0; - (1 < 0 || 1 >= dst.$length) ? $throwRuntimeError("index out of range") : dst.$array[dst.$offset + 1] = ((dbuf[1] << 4 << 24 >>> 24) | (dbuf[2] >>> 2 << 24 >>> 24)) >>> 0; - (0 < 0 || 0 >= dst.$length) ? $throwRuntimeError("index out of range") : dst.$array[dst.$offset + 0] = ((dbuf[0] << 2 << 24 >>> 24) | (dbuf[1] >>> 4 << 24 >>> 24)) >>> 0; - } else if (_ref$2 === 3) { - (1 < 0 || 1 >= dst.$length) ? $throwRuntimeError("index out of range") : dst.$array[dst.$offset + 1] = ((dbuf[1] << 4 << 24 >>> 24) | (dbuf[2] >>> 2 << 24 >>> 24)) >>> 0; - (0 < 0 || 0 >= dst.$length) ? $throwRuntimeError("index out of range") : dst.$array[dst.$offset + 0] = ((dbuf[0] << 2 << 24 >>> 24) | (dbuf[1] >>> 4 << 24 >>> 24)) >>> 0; - } else if (_ref$2 === 2) { - (0 < 0 || 0 >= dst.$length) ? $throwRuntimeError("index out of range") : dst.$array[dst.$offset + 0] = ((dbuf[0] << 2 << 24 >>> 24) | (dbuf[1] >>> 4 << 24 >>> 24)) >>> 0; + buf.$set($appendSlice(buf.$get(), new ($sliceType($Uint8))($stringToBytes(file)))); + buf.$set($append(buf.$get(), 58)); + itoa(buf, line, -1); + buf.$set($appendSlice(buf.$get(), new ($sliceType($Uint8))($stringToBytes(": ")))); + } + }; + Logger.prototype.formatHeader = function(buf, t, file, line) { return this.$val.formatHeader(buf, t, file, line); }; + Logger.Ptr.prototype.Output = function(calldepth, s) { + var $deferred = [], $err = null, l, now, file, line, ok, _tuple, _tuple$1, err; + /* */ try { $deferFrames.push($deferred); + l = this; + now = new time.Time.Ptr(); $copy(now, time.Now(), time.Time); + file = ""; + line = 0; + l.mu.Lock(); + $deferred.push([$methodVal(l.mu, "Unlock"), []]); + if (!(((l.flag & 24) === 0))) { + l.mu.Unlock(); + ok = false; + _tuple = runtime.Caller(calldepth); file = _tuple[1]; line = _tuple[2]; ok = _tuple[3]; + if (!ok) { + file = "???"; + line = 0; } - dst = $subslice(dst, 3); - n = n + ((dlen - 1 >> 0)) >> 0; + l.mu.Lock(); } - _tmp$17 = n; _tmp$18 = end; _tmp$19 = err; n = _tmp$17; end = _tmp$18; err = _tmp$19; - return [n, end, err]; + l.buf = $subslice(l.buf, 0, 0); + l.formatHeader(new ($ptrType(($sliceType($Uint8))))(function() { return this.$target.buf; }, function($v) { this.$target.buf = $v; }, l), $clone(now, time.Time), file, line); + l.buf = $appendSlice(l.buf, new ($sliceType($Uint8))($stringToBytes(s))); + if (s.length > 0 && !((s.charCodeAt((s.length - 1 >> 0)) === 10))) { + l.buf = $append(l.buf, 10); + } + _tuple$1 = l.out.Write(l.buf); err = _tuple$1[1]; + return err; + /* */ } catch(err) { $err = err; return $ifaceNil; } finally { $deferFrames.pop(); $callDeferred($deferred, $err); } }; - Encoding.prototype.decode = function(dst, src) { return this.$val.decode(dst, src); }; - Encoding.Ptr.prototype.Decode = function(dst, src) { - var n = 0, err = $ifaceNil, enc, _tuple; - enc = this; - src = bytes.Map(removeNewlinesMapper, src); - _tuple = enc.decode(dst, src); n = _tuple[0]; err = _tuple[2]; - return [n, err]; + Logger.prototype.Output = function(calldepth, s) { return this.$val.Output(calldepth, s); }; + Logger.Ptr.prototype.Printf = function(format, v) { + var l; + l = this; + l.Output(2, fmt.Sprintf(format, v)); }; - Encoding.prototype.Decode = function(dst, src) { return this.$val.Decode(dst, src); }; - Encoding.Ptr.prototype.DecodeString = function(s) { - var enc, dbuf, _tuple, n, err; - enc = this; - s = strings.Map(removeNewlinesMapper, s); - dbuf = ($sliceType($Uint8)).make(enc.DecodedLen(s.length)); - _tuple = enc.Decode(dbuf, new ($sliceType($Uint8))($stringToBytes(s))); n = _tuple[0]; err = _tuple[1]; - return [$subslice(dbuf, 0, n), err]; + Logger.prototype.Printf = function(format, v) { return this.$val.Printf(format, v); }; + Logger.Ptr.prototype.Print = function(v) { + var l; + l = this; + l.Output(2, fmt.Sprint(v)); }; - Encoding.prototype.DecodeString = function(s) { return this.$val.DecodeString(s); }; - Encoding.Ptr.prototype.DecodedLen = function(n) { - var enc, x, _q; - enc = this; - return (x = (_q = n / 4, (_q === _q && _q !== 1/0 && _q !== -1/0) ? _q >> 0 : $throwRuntimeError("integer divide by zero")), (((x >>> 16 << 16) * 3 >> 0) + (x << 16 >>> 16) * 3) >> 0); + Logger.prototype.Print = function(v) { return this.$val.Print(v); }; + Logger.Ptr.prototype.Println = function(v) { + var l; + l = this; + l.Output(2, fmt.Sprintln(v)); }; - Encoding.prototype.DecodedLen = function(n) { return this.$val.DecodedLen(n); }; - $pkg.$init = function() { - ($ptrType(Encoding)).methods = [["Decode", "Decode", "", $funcType([($sliceType($Uint8)), ($sliceType($Uint8))], [$Int, $error], false), -1], ["DecodeString", "DecodeString", "", $funcType([$String], [($sliceType($Uint8)), $error], false), -1], ["DecodedLen", "DecodedLen", "", $funcType([$Int], [$Int], false), -1], ["Encode", "Encode", "", $funcType([($sliceType($Uint8)), ($sliceType($Uint8))], [], false), -1], ["EncodeToString", "EncodeToString", "", $funcType([($sliceType($Uint8))], [$String], false), -1], ["EncodedLen", "EncodedLen", "", $funcType([$Int], [$Int], false), -1], ["decode", "decode", "encoding/base64", $funcType([($sliceType($Uint8)), ($sliceType($Uint8))], [$Int, $Bool, $error], false), -1]]; - Encoding.init([["encode", "encode", "encoding/base64", $String, ""], ["decodeMap", "decodeMap", "encoding/base64", ($arrayType($Uint8, 256)), ""]]); - ($ptrType(encoder)).methods = [["Close", "Close", "", $funcType([], [$error], false), -1], ["Write", "Write", "", $funcType([($sliceType($Uint8))], [$Int, $error], false), -1]]; - encoder.init([["err", "err", "encoding/base64", $error, ""], ["enc", "enc", "encoding/base64", ($ptrType(Encoding)), ""], ["w", "w", "encoding/base64", io.Writer, ""], ["buf", "buf", "encoding/base64", ($arrayType($Uint8, 3)), ""], ["nbuf", "nbuf", "encoding/base64", $Int, ""], ["out", "out", "encoding/base64", ($arrayType($Uint8, 1024)), ""]]); - CorruptInputError.methods = [["Error", "Error", "", $funcType([], [$String], false), -1]]; - ($ptrType(CorruptInputError)).methods = [["Error", "Error", "", $funcType([], [$String], false), -1]]; - $pkg.StdEncoding = NewEncoding("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"); - $pkg.URLEncoding = NewEncoding("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_"); - removeNewlinesMapper = (function(r) { - if ((r === 13) || (r === 10)) { - return -1; - } - return r; - }); + Logger.prototype.Println = function(v) { return this.$val.Println(v); }; + Logger.Ptr.prototype.Fatal = function(v) { + var l; + l = this; + l.Output(2, fmt.Sprint(v)); + os.Exit(1); }; - return $pkg; -})(); -$packages["unicode/utf16"] = (function() { - var $pkg = {}, IsSurrogate, DecodeRune; - IsSurrogate = $pkg.IsSurrogate = function(r) { - return 55296 <= r && r < 57344; + Logger.prototype.Fatal = function(v) { return this.$val.Fatal(v); }; + Logger.Ptr.prototype.Fatalf = function(format, v) { + var l; + l = this; + l.Output(2, fmt.Sprintf(format, v)); + os.Exit(1); }; - DecodeRune = $pkg.DecodeRune = function(r1, r2) { - if (55296 <= r1 && r1 < 56320 && 56320 <= r2 && r2 < 57344) { - return ((((r1 - 55296 >> 0)) << 10 >> 0) | ((r2 - 56320 >> 0))) + 65536 >> 0; - } - return 65533; + Logger.prototype.Fatalf = function(format, v) { return this.$val.Fatalf(format, v); }; + Logger.Ptr.prototype.Fatalln = function(v) { + var l; + l = this; + l.Output(2, fmt.Sprintln(v)); + os.Exit(1); + }; + Logger.prototype.Fatalln = function(v) { return this.$val.Fatalln(v); }; + Logger.Ptr.prototype.Panic = function(v) { + var l, s; + l = this; + s = fmt.Sprint(v); + l.Output(2, s); + $panic(new $String(s)); + }; + Logger.prototype.Panic = function(v) { return this.$val.Panic(v); }; + Logger.Ptr.prototype.Panicf = function(format, v) { + var l, s; + l = this; + s = fmt.Sprintf(format, v); + l.Output(2, s); + $panic(new $String(s)); + }; + Logger.prototype.Panicf = function(format, v) { return this.$val.Panicf(format, v); }; + Logger.Ptr.prototype.Panicln = function(v) { + var l, s; + l = this; + s = fmt.Sprintln(v); + l.Output(2, s); + $panic(new $String(s)); + }; + Logger.prototype.Panicln = function(v) { return this.$val.Panicln(v); }; + Logger.Ptr.prototype.Flags = function() { + var $deferred = [], $err = null, l; + /* */ try { $deferFrames.push($deferred); + l = this; + l.mu.Lock(); + $deferred.push([$methodVal(l.mu, "Unlock"), []]); + return l.flag; + /* */ } catch(err) { $err = err; return 0; } finally { $deferFrames.pop(); $callDeferred($deferred, $err); } + }; + Logger.prototype.Flags = function() { return this.$val.Flags(); }; + Logger.Ptr.prototype.SetFlags = function(flag) { + var $deferred = [], $err = null, l; + /* */ try { $deferFrames.push($deferred); + l = this; + l.mu.Lock(); + $deferred.push([$methodVal(l.mu, "Unlock"), []]); + l.flag = flag; + /* */ } catch(err) { $err = err; } finally { $deferFrames.pop(); $callDeferred($deferred, $err); } + }; + Logger.prototype.SetFlags = function(flag) { return this.$val.SetFlags(flag); }; + Logger.Ptr.prototype.Prefix = function() { + var $deferred = [], $err = null, l; + /* */ try { $deferFrames.push($deferred); + l = this; + l.mu.Lock(); + $deferred.push([$methodVal(l.mu, "Unlock"), []]); + return l.prefix; + /* */ } catch(err) { $err = err; return ""; } finally { $deferFrames.pop(); $callDeferred($deferred, $err); } + }; + Logger.prototype.Prefix = function() { return this.$val.Prefix(); }; + Logger.Ptr.prototype.SetPrefix = function(prefix) { + var $deferred = [], $err = null, l; + /* */ try { $deferFrames.push($deferred); + l = this; + l.mu.Lock(); + $deferred.push([$methodVal(l.mu, "Unlock"), []]); + l.prefix = prefix; + /* */ } catch(err) { $err = err; } finally { $deferFrames.pop(); $callDeferred($deferred, $err); } + }; + Logger.prototype.SetPrefix = function(prefix) { return this.$val.SetPrefix(prefix); }; + Panicf = $pkg.Panicf = function(format, v) { + var s; + s = fmt.Sprintf(format, v); + std.Output(2, s); + $panic(new $String(s)); }; $pkg.$init = function() { + ($ptrType(Logger)).methods = [["Fatal", "Fatal", "", $funcType([($sliceType($emptyInterface))], [], true), -1], ["Fatalf", "Fatalf", "", $funcType([$String, ($sliceType($emptyInterface))], [], true), -1], ["Fatalln", "Fatalln", "", $funcType([($sliceType($emptyInterface))], [], true), -1], ["Flags", "Flags", "", $funcType([], [$Int], false), -1], ["Output", "Output", "", $funcType([$Int, $String], [$error], false), -1], ["Panic", "Panic", "", $funcType([($sliceType($emptyInterface))], [], true), -1], ["Panicf", "Panicf", "", $funcType([$String, ($sliceType($emptyInterface))], [], true), -1], ["Panicln", "Panicln", "", $funcType([($sliceType($emptyInterface))], [], true), -1], ["Prefix", "Prefix", "", $funcType([], [$String], false), -1], ["Print", "Print", "", $funcType([($sliceType($emptyInterface))], [], true), -1], ["Printf", "Printf", "", $funcType([$String, ($sliceType($emptyInterface))], [], true), -1], ["Println", "Println", "", $funcType([($sliceType($emptyInterface))], [], true), -1], ["SetFlags", "SetFlags", "", $funcType([$Int], [], false), -1], ["SetPrefix", "SetPrefix", "", $funcType([$String], [], false), -1], ["formatHeader", "formatHeader", "log", $funcType([($ptrType(($sliceType($Uint8)))), time.Time, $String, $Int], [], false), -1]]; + Logger.init([["mu", "mu", "log", sync.Mutex, ""], ["prefix", "prefix", "log", $String, ""], ["flag", "flag", "log", $Int, ""], ["out", "out", "log", io.Writer, ""], ["buf", "buf", "log", ($sliceType($Uint8)), ""]]); + std = New(os.Stderr, "", 3); }; return $pkg; })(); -$packages["encoding/json"] = (function() { - var $pkg = {}, bytes = $packages["bytes"], encoding = $packages["encoding"], base64 = $packages["encoding/base64"], errors = $packages["errors"], fmt = $packages["fmt"], reflect = $packages["reflect"], runtime = $packages["runtime"], strconv = $packages["strconv"], unicode = $packages["unicode"], utf16 = $packages["unicode/utf16"], utf8 = $packages["unicode/utf8"], math = $packages["math"], sort = $packages["sort"], strings = $packages["strings"], sync = $packages["sync"], io = $packages["io"], Unmarshaler, UnmarshalTypeError, InvalidUnmarshalError, Number, decodeState, Marshaler, UnsupportedTypeError, UnsupportedValueError, MarshalerError, encodeState, encoderFunc, floatEncoder, structEncoder, mapEncoder, sliceEncoder, arrayEncoder, ptrEncoder, condAddrEncoder, stringValues, field, byName, byIndex, SyntaxError, scanner, Decoder, Encoder, tagOptions, errPhase, numberType, hex, encodeStatePool, byteSliceType, encoderCache, marshalerType, textMarshalerType, float32Encoder, float64Encoder, fieldCache, getu4, unquote, unquoteBytes, Marshal, newEncodeState, isEmptyValue, valueEncoder, typeEncoder, newTypeEncoder, invalidValueEncoder, marshalerEncoder, addrMarshalerEncoder, textMarshalerEncoder, addrTextMarshalerEncoder, boolEncoder, intEncoder, uintEncoder, stringEncoder, interfaceEncoder, unsupportedTypeEncoder, newStructEncoder, newMapEncoder, encodeByteSlice, newSliceEncoder, newArrayEncoder, newPtrEncoder, newCondAddrEncoder, isValidTag, fieldByIndex, typeByIndex, fillField, typeFields, dominantField, cachedTypeFields, foldFunc, equalFoldRight, asciiEqualFold, simpleLetterEqualFold, compact, nextValue, isSpace, stateBeginValueOrEmpty, stateBeginValue, stateBeginStringOrEmpty, stateBeginString, stateEndValue, stateEndTop, stateInString, stateInStringEsc, stateInStringEscU, stateInStringEscU1, stateInStringEscU12, stateInStringEscU123, stateNeg, state1, state0, stateDot, stateDot0, stateE, stateESign, stateE0, stateT, stateTr, stateTru, stateF, stateFa, stateFal, stateFals, stateN, stateNu, stateNul, stateError, quoteChar, stateRedo, NewDecoder, nonSpace, NewEncoder, parseTag; - Unmarshaler = $pkg.Unmarshaler = $newType(8, "Interface", "json.Unmarshaler", "Unmarshaler", "encoding/json", null); - UnmarshalTypeError = $pkg.UnmarshalTypeError = $newType(0, "Struct", "json.UnmarshalTypeError", "UnmarshalTypeError", "encoding/json", function(Value_, Type_) { - this.$val = this; - this.Value = Value_ !== undefined ? Value_ : ""; - this.Type = Type_ !== undefined ? Type_ : $ifaceNil; - }); - InvalidUnmarshalError = $pkg.InvalidUnmarshalError = $newType(0, "Struct", "json.InvalidUnmarshalError", "InvalidUnmarshalError", "encoding/json", function(Type_) { - this.$val = this; - this.Type = Type_ !== undefined ? Type_ : $ifaceNil; - }); - Number = $pkg.Number = $newType(8, "String", "json.Number", "Number", "encoding/json", null); - decodeState = $pkg.decodeState = $newType(0, "Struct", "json.decodeState", "decodeState", "encoding/json", function(data_, off_, scan_, nextscan_, savedError_, tempstr_, useNumber_) { - this.$val = this; - this.data = data_ !== undefined ? data_ : ($sliceType($Uint8)).nil; - this.off = off_ !== undefined ? off_ : 0; - this.scan = scan_ !== undefined ? scan_ : new scanner.Ptr(); - this.nextscan = nextscan_ !== undefined ? nextscan_ : new scanner.Ptr(); - this.savedError = savedError_ !== undefined ? savedError_ : $ifaceNil; - this.tempstr = tempstr_ !== undefined ? tempstr_ : ""; - this.useNumber = useNumber_ !== undefined ? useNumber_ : false; - }); - Marshaler = $pkg.Marshaler = $newType(8, "Interface", "json.Marshaler", "Marshaler", "encoding/json", null); - UnsupportedTypeError = $pkg.UnsupportedTypeError = $newType(0, "Struct", "json.UnsupportedTypeError", "UnsupportedTypeError", "encoding/json", function(Type_) { - this.$val = this; - this.Type = Type_ !== undefined ? Type_ : $ifaceNil; - }); - UnsupportedValueError = $pkg.UnsupportedValueError = $newType(0, "Struct", "json.UnsupportedValueError", "UnsupportedValueError", "encoding/json", function(Value_, Str_) { - this.$val = this; - this.Value = Value_ !== undefined ? Value_ : new reflect.Value.Ptr(); - this.Str = Str_ !== undefined ? Str_ : ""; - }); - MarshalerError = $pkg.MarshalerError = $newType(0, "Struct", "json.MarshalerError", "MarshalerError", "encoding/json", function(Type_, Err_) { - this.$val = this; - this.Type = Type_ !== undefined ? Type_ : $ifaceNil; - this.Err = Err_ !== undefined ? Err_ : $ifaceNil; - }); - encodeState = $pkg.encodeState = $newType(0, "Struct", "json.encodeState", "encodeState", "encoding/json", function(Buffer_, scratch_) { - this.$val = this; - this.Buffer = Buffer_ !== undefined ? Buffer_ : new bytes.Buffer.Ptr(); - this.scratch = scratch_ !== undefined ? scratch_ : ($arrayType($Uint8, 64)).zero(); - }); - encoderFunc = $pkg.encoderFunc = $newType(4, "Func", "json.encoderFunc", "encoderFunc", "encoding/json", null); - floatEncoder = $pkg.floatEncoder = $newType(4, "Int", "json.floatEncoder", "floatEncoder", "encoding/json", null); - structEncoder = $pkg.structEncoder = $newType(0, "Struct", "json.structEncoder", "structEncoder", "encoding/json", function(fields_, fieldEncs_) { - this.$val = this; - this.fields = fields_ !== undefined ? fields_ : ($sliceType(field)).nil; - this.fieldEncs = fieldEncs_ !== undefined ? fieldEncs_ : ($sliceType(encoderFunc)).nil; - }); - mapEncoder = $pkg.mapEncoder = $newType(0, "Struct", "json.mapEncoder", "mapEncoder", "encoding/json", function(elemEnc_) { - this.$val = this; - this.elemEnc = elemEnc_ !== undefined ? elemEnc_ : $throwNilPointerError; - }); - sliceEncoder = $pkg.sliceEncoder = $newType(0, "Struct", "json.sliceEncoder", "sliceEncoder", "encoding/json", function(arrayEnc_) { - this.$val = this; - this.arrayEnc = arrayEnc_ !== undefined ? arrayEnc_ : $throwNilPointerError; - }); - arrayEncoder = $pkg.arrayEncoder = $newType(0, "Struct", "json.arrayEncoder", "arrayEncoder", "encoding/json", function(elemEnc_) { - this.$val = this; - this.elemEnc = elemEnc_ !== undefined ? elemEnc_ : $throwNilPointerError; - }); - ptrEncoder = $pkg.ptrEncoder = $newType(0, "Struct", "json.ptrEncoder", "ptrEncoder", "encoding/json", function(elemEnc_) { - this.$val = this; - this.elemEnc = elemEnc_ !== undefined ? elemEnc_ : $throwNilPointerError; - }); - condAddrEncoder = $pkg.condAddrEncoder = $newType(0, "Struct", "json.condAddrEncoder", "condAddrEncoder", "encoding/json", function(canAddrEnc_, elseEnc_) { - this.$val = this; - this.canAddrEnc = canAddrEnc_ !== undefined ? canAddrEnc_ : $throwNilPointerError; - this.elseEnc = elseEnc_ !== undefined ? elseEnc_ : $throwNilPointerError; - }); - stringValues = $pkg.stringValues = $newType(12, "Slice", "json.stringValues", "stringValues", "encoding/json", null); - field = $pkg.field = $newType(0, "Struct", "json.field", "field", "encoding/json", function(name_, nameBytes_, equalFold_, tag_, index_, typ_, omitEmpty_, quoted_) { +$packages["go/build"] = (function() { + var $pkg = {}, bytes = $packages["bytes"], errors = $packages["errors"], fmt = $packages["fmt"], ast = $packages["go/ast"], doc = $packages["go/doc"], parser = $packages["go/parser"], token = $packages["go/token"], io = $packages["io"], ioutil = $packages["io/ioutil"], log = $packages["log"], os = $packages["os"], path = $packages["path"], filepath = $packages["path/filepath"], runtime = $packages["runtime"], sort = $packages["sort"], strconv = $packages["strconv"], strings = $packages["strings"], unicode = $packages["unicode"], bufio = $packages["bufio"], Context, ImportMode, Package, NoGoError, importReader, cgoEnabled, slashslash, safeBytes, knownOS, knownArch, errSyntax, errNUL, _map, _key, hasSubdir, defaultContext, envOr, nameExt, cleanImports, Import, safeCgoName, splitQuoted, init, IsLocalImport, isIdent, readComments, readImports; + Context = $pkg.Context = $newType(0, "Struct", "build.Context", "Context", "go/build", function(GOARCH_, GOOS_, GOROOT_, GOPATH_, CgoEnabled_, UseAllFiles_, Compiler_, BuildTags_, ReleaseTags_, InstallSuffix_, JoinPath_, SplitPathList_, IsAbsPath_, IsDir_, HasSubdir_, ReadDir_, OpenFile_) { this.$val = this; - this.name = name_ !== undefined ? name_ : ""; - this.nameBytes = nameBytes_ !== undefined ? nameBytes_ : ($sliceType($Uint8)).nil; - this.equalFold = equalFold_ !== undefined ? equalFold_ : $throwNilPointerError; - this.tag = tag_ !== undefined ? tag_ : false; - this.index = index_ !== undefined ? index_ : ($sliceType($Int)).nil; - this.typ = typ_ !== undefined ? typ_ : $ifaceNil; - this.omitEmpty = omitEmpty_ !== undefined ? omitEmpty_ : false; - this.quoted = quoted_ !== undefined ? quoted_ : false; + this.GOARCH = GOARCH_ !== undefined ? GOARCH_ : ""; + this.GOOS = GOOS_ !== undefined ? GOOS_ : ""; + this.GOROOT = GOROOT_ !== undefined ? GOROOT_ : ""; + this.GOPATH = GOPATH_ !== undefined ? GOPATH_ : ""; + this.CgoEnabled = CgoEnabled_ !== undefined ? CgoEnabled_ : false; + this.UseAllFiles = UseAllFiles_ !== undefined ? UseAllFiles_ : false; + this.Compiler = Compiler_ !== undefined ? Compiler_ : ""; + this.BuildTags = BuildTags_ !== undefined ? BuildTags_ : ($sliceType($String)).nil; + this.ReleaseTags = ReleaseTags_ !== undefined ? ReleaseTags_ : ($sliceType($String)).nil; + this.InstallSuffix = InstallSuffix_ !== undefined ? InstallSuffix_ : ""; + this.JoinPath = JoinPath_ !== undefined ? JoinPath_ : $throwNilPointerError; + this.SplitPathList = SplitPathList_ !== undefined ? SplitPathList_ : $throwNilPointerError; + this.IsAbsPath = IsAbsPath_ !== undefined ? IsAbsPath_ : $throwNilPointerError; + this.IsDir = IsDir_ !== undefined ? IsDir_ : $throwNilPointerError; + this.HasSubdir = HasSubdir_ !== undefined ? HasSubdir_ : $throwNilPointerError; + this.ReadDir = ReadDir_ !== undefined ? ReadDir_ : $throwNilPointerError; + this.OpenFile = OpenFile_ !== undefined ? OpenFile_ : $throwNilPointerError; }); - byName = $pkg.byName = $newType(12, "Slice", "json.byName", "byName", "encoding/json", null); - byIndex = $pkg.byIndex = $newType(12, "Slice", "json.byIndex", "byIndex", "encoding/json", null); - SyntaxError = $pkg.SyntaxError = $newType(0, "Struct", "json.SyntaxError", "SyntaxError", "encoding/json", function(msg_, Offset_) { + ImportMode = $pkg.ImportMode = $newType(4, "Uint", "build.ImportMode", "ImportMode", "go/build", null); + Package = $pkg.Package = $newType(0, "Struct", "build.Package", "Package", "go/build", function(Dir_, Name_, Doc_, ImportPath_, Root_, SrcRoot_, PkgRoot_, BinDir_, Goroot_, PkgObj_, AllTags_, ConflictDir_, GoFiles_, CgoFiles_, IgnoredGoFiles_, CFiles_, CXXFiles_, MFiles_, HFiles_, SFiles_, SwigFiles_, SwigCXXFiles_, SysoFiles_, CgoCFLAGS_, CgoCPPFLAGS_, CgoCXXFLAGS_, CgoLDFLAGS_, CgoPkgConfig_, Imports_, ImportPos_, TestGoFiles_, TestImports_, TestImportPos_, XTestGoFiles_, XTestImports_, XTestImportPos_) { this.$val = this; - this.msg = msg_ !== undefined ? msg_ : ""; - this.Offset = Offset_ !== undefined ? Offset_ : new $Int64(0, 0); + this.Dir = Dir_ !== undefined ? Dir_ : ""; + this.Name = Name_ !== undefined ? Name_ : ""; + this.Doc = Doc_ !== undefined ? Doc_ : ""; + this.ImportPath = ImportPath_ !== undefined ? ImportPath_ : ""; + this.Root = Root_ !== undefined ? Root_ : ""; + this.SrcRoot = SrcRoot_ !== undefined ? SrcRoot_ : ""; + this.PkgRoot = PkgRoot_ !== undefined ? PkgRoot_ : ""; + this.BinDir = BinDir_ !== undefined ? BinDir_ : ""; + this.Goroot = Goroot_ !== undefined ? Goroot_ : false; + this.PkgObj = PkgObj_ !== undefined ? PkgObj_ : ""; + this.AllTags = AllTags_ !== undefined ? AllTags_ : ($sliceType($String)).nil; + this.ConflictDir = ConflictDir_ !== undefined ? ConflictDir_ : ""; + this.GoFiles = GoFiles_ !== undefined ? GoFiles_ : ($sliceType($String)).nil; + this.CgoFiles = CgoFiles_ !== undefined ? CgoFiles_ : ($sliceType($String)).nil; + this.IgnoredGoFiles = IgnoredGoFiles_ !== undefined ? IgnoredGoFiles_ : ($sliceType($String)).nil; + this.CFiles = CFiles_ !== undefined ? CFiles_ : ($sliceType($String)).nil; + this.CXXFiles = CXXFiles_ !== undefined ? CXXFiles_ : ($sliceType($String)).nil; + this.MFiles = MFiles_ !== undefined ? MFiles_ : ($sliceType($String)).nil; + this.HFiles = HFiles_ !== undefined ? HFiles_ : ($sliceType($String)).nil; + this.SFiles = SFiles_ !== undefined ? SFiles_ : ($sliceType($String)).nil; + this.SwigFiles = SwigFiles_ !== undefined ? SwigFiles_ : ($sliceType($String)).nil; + this.SwigCXXFiles = SwigCXXFiles_ !== undefined ? SwigCXXFiles_ : ($sliceType($String)).nil; + this.SysoFiles = SysoFiles_ !== undefined ? SysoFiles_ : ($sliceType($String)).nil; + this.CgoCFLAGS = CgoCFLAGS_ !== undefined ? CgoCFLAGS_ : ($sliceType($String)).nil; + this.CgoCPPFLAGS = CgoCPPFLAGS_ !== undefined ? CgoCPPFLAGS_ : ($sliceType($String)).nil; + this.CgoCXXFLAGS = CgoCXXFLAGS_ !== undefined ? CgoCXXFLAGS_ : ($sliceType($String)).nil; + this.CgoLDFLAGS = CgoLDFLAGS_ !== undefined ? CgoLDFLAGS_ : ($sliceType($String)).nil; + this.CgoPkgConfig = CgoPkgConfig_ !== undefined ? CgoPkgConfig_ : ($sliceType($String)).nil; + this.Imports = Imports_ !== undefined ? Imports_ : ($sliceType($String)).nil; + this.ImportPos = ImportPos_ !== undefined ? ImportPos_ : false; + this.TestGoFiles = TestGoFiles_ !== undefined ? TestGoFiles_ : ($sliceType($String)).nil; + this.TestImports = TestImports_ !== undefined ? TestImports_ : ($sliceType($String)).nil; + this.TestImportPos = TestImportPos_ !== undefined ? TestImportPos_ : false; + this.XTestGoFiles = XTestGoFiles_ !== undefined ? XTestGoFiles_ : ($sliceType($String)).nil; + this.XTestImports = XTestImports_ !== undefined ? XTestImports_ : ($sliceType($String)).nil; + this.XTestImportPos = XTestImportPos_ !== undefined ? XTestImportPos_ : false; }); - scanner = $pkg.scanner = $newType(0, "Struct", "json.scanner", "scanner", "encoding/json", function(step_, endTop_, parseState_, err_, redo_, redoCode_, redoState_, bytes_) { + NoGoError = $pkg.NoGoError = $newType(0, "Struct", "build.NoGoError", "NoGoError", "go/build", function(Dir_) { this.$val = this; - this.step = step_ !== undefined ? step_ : $throwNilPointerError; - this.endTop = endTop_ !== undefined ? endTop_ : false; - this.parseState = parseState_ !== undefined ? parseState_ : ($sliceType($Int)).nil; - this.err = err_ !== undefined ? err_ : $ifaceNil; - this.redo = redo_ !== undefined ? redo_ : false; - this.redoCode = redoCode_ !== undefined ? redoCode_ : 0; - this.redoState = redoState_ !== undefined ? redoState_ : $throwNilPointerError; - this.bytes = bytes_ !== undefined ? bytes_ : new $Int64(0, 0); + this.Dir = Dir_ !== undefined ? Dir_ : ""; }); - Decoder = $pkg.Decoder = $newType(0, "Struct", "json.Decoder", "Decoder", "encoding/json", function(r_, buf_, d_, scan_, err_) { + importReader = $pkg.importReader = $newType(0, "Struct", "build.importReader", "importReader", "go/build", function(b_, buf_, peek_, err_, eof_, nerr_) { this.$val = this; - this.r = r_ !== undefined ? r_ : $ifaceNil; + this.b = b_ !== undefined ? b_ : ($ptrType(bufio.Reader)).nil; this.buf = buf_ !== undefined ? buf_ : ($sliceType($Uint8)).nil; - this.d = d_ !== undefined ? d_ : new decodeState.Ptr(); - this.scan = scan_ !== undefined ? scan_ : new scanner.Ptr(); - this.err = err_ !== undefined ? err_ : $ifaceNil; - }); - Encoder = $pkg.Encoder = $newType(0, "Struct", "json.Encoder", "Encoder", "encoding/json", function(w_, e_, err_) { - this.$val = this; - this.w = w_ !== undefined ? w_ : $ifaceNil; - this.e = e_ !== undefined ? e_ : new encodeState.Ptr(); + this.peek = peek_ !== undefined ? peek_ : 0; this.err = err_ !== undefined ? err_ : $ifaceNil; + this.eof = eof_ !== undefined ? eof_ : false; + this.nerr = nerr_ !== undefined ? nerr_ : 0; }); - tagOptions = $pkg.tagOptions = $newType(8, "String", "json.tagOptions", "tagOptions", "encoding/json", null); - UnmarshalTypeError.Ptr.prototype.Error = function() { - var e; - e = this; - return "json: cannot unmarshal " + e.Value + " into Go value of type " + e.Type.String(); - }; - UnmarshalTypeError.prototype.Error = function() { return this.$val.Error(); }; - InvalidUnmarshalError.Ptr.prototype.Error = function() { - var e; - e = this; - if ($interfaceIsEqual(e.Type, $ifaceNil)) { - return "json: Unmarshal(nil)"; - } - if (!((e.Type.Kind() === 22))) { - return "json: Unmarshal(non-pointer " + e.Type.String() + ")"; + Context.Ptr.prototype.joinPath = function(elem) { + var ctxt, f; + ctxt = this; + f = ctxt.JoinPath; + if (!(f === $throwNilPointerError)) { + return f(elem); } - return "json: Unmarshal(nil " + e.Type.String() + ")"; + return filepath.Join(elem); }; - InvalidUnmarshalError.prototype.Error = function() { return this.$val.Error(); }; - decodeState.Ptr.prototype.unmarshal = function(v) { - var err = $ifaceNil, $deferred = [], $err = null, d, rv; - /* */ try { $deferFrames.push($deferred); - d = this; - $deferred.push([(function() { - var r, _tuple, ok; - r = $recover(); - if (!($interfaceIsEqual(r, $ifaceNil))) { - _tuple = $assertType(r, runtime.Error, true); ok = _tuple[1]; - if (ok) { - $panic(r); - } - err = $assertType(r, $error); - } - }), []]); - rv = new reflect.Value.Ptr(); $copy(rv, reflect.ValueOf(v), reflect.Value); - if (!((rv.Kind() === 22)) || rv.IsNil()) { - err = new InvalidUnmarshalError.Ptr(reflect.TypeOf(v)); - return err; + Context.prototype.joinPath = function(elem) { return this.$val.joinPath(elem); }; + Context.Ptr.prototype.splitPathList = function(s) { + var ctxt, f; + ctxt = this; + f = ctxt.SplitPathList; + if (!(f === $throwNilPointerError)) { + return f(s); } - d.scan.reset(); - d.value($clone(rv, reflect.Value)); - err = d.savedError; - return err; - /* */ } catch(err) { $err = err; } finally { $deferFrames.pop(); $callDeferred($deferred, $err); return err; } - }; - decodeState.prototype.unmarshal = function(v) { return this.$val.unmarshal(v); }; - Number.prototype.String = function() { - var n; - n = this.$val !== undefined ? this.$val : this; - return n; - }; - $ptrType(Number).prototype.String = function() { return new Number(this.$get()).String(); }; - Number.prototype.Float64 = function() { - var n; - n = this.$val !== undefined ? this.$val : this; - return strconv.ParseFloat(n, 64); - }; - $ptrType(Number).prototype.Float64 = function() { return new Number(this.$get()).Float64(); }; - Number.prototype.Int64 = function() { - var n; - n = this.$val !== undefined ? this.$val : this; - return strconv.ParseInt(n, 10, 64); + return filepath.SplitList(s); }; - $ptrType(Number).prototype.Int64 = function() { return new Number(this.$get()).Int64(); }; - decodeState.Ptr.prototype.init = function(data) { - var d; - d = this; - d.data = data; - d.off = 0; - d.savedError = $ifaceNil; - return d; + Context.prototype.splitPathList = function(s) { return this.$val.splitPathList(s); }; + Context.Ptr.prototype.isAbsPath = function(path$1) { + var ctxt, f; + ctxt = this; + f = ctxt.IsAbsPath; + if (!(f === $throwNilPointerError)) { + return f(path$1); + } + return filepath.IsAbs(path$1); }; - decodeState.prototype.init = function(data) { return this.$val.init(data); }; - decodeState.Ptr.prototype.error = function(err) { - var d; - d = this; - $panic(err); + Context.prototype.isAbsPath = function(path$1) { return this.$val.isAbsPath(path$1); }; + Context.Ptr.prototype.isDir = function(path$1) { + var ctxt, f, _tuple, fi, err; + ctxt = this; + f = ctxt.IsDir; + if (!(f === $throwNilPointerError)) { + return f(path$1); + } + _tuple = os.Stat(path$1); fi = _tuple[0]; err = _tuple[1]; + return $interfaceIsEqual(err, $ifaceNil) && fi.IsDir(); }; - decodeState.prototype.error = function(err) { return this.$val.error(err); }; - decodeState.Ptr.prototype.saveError = function(err) { - var d; - d = this; - if ($interfaceIsEqual(d.savedError, $ifaceNil)) { - d.savedError = err; + Context.prototype.isDir = function(path$1) { return this.$val.isDir(path$1); }; + Context.Ptr.prototype.hasSubdir = function(root, dir) { + var rel = "", ok = false, ctxt, f, _tuple, _tuple$1, _tuple$2, rootSym, _tuple$3, dirSym, _tuple$4, _tuple$5, _tuple$6; + ctxt = this; + f = ctxt.HasSubdir; + if (!(f === $throwNilPointerError)) { + _tuple = f(root, dir); rel = _tuple[0]; ok = _tuple[1]; + return [rel, ok]; + } + _tuple$1 = hasSubdir(root, dir); rel = _tuple$1[0]; ok = _tuple$1[1]; + if (ok) { + return [rel, ok]; + } + _tuple$2 = filepath.EvalSymlinks(root); rootSym = _tuple$2[0]; + _tuple$3 = filepath.EvalSymlinks(dir); dirSym = _tuple$3[0]; + _tuple$4 = hasSubdir(rootSym, dir); rel = _tuple$4[0]; ok = _tuple$4[1]; + if (ok) { + return [rel, ok]; + } + _tuple$5 = hasSubdir(root, dirSym); rel = _tuple$5[0]; ok = _tuple$5[1]; + if (ok) { + return [rel, ok]; } + _tuple$6 = hasSubdir(rootSym, dirSym); rel = _tuple$6[0]; ok = _tuple$6[1]; + return [rel, ok]; }; - decodeState.prototype.saveError = function(err) { return this.$val.saveError(err); }; - decodeState.Ptr.prototype.next = function() { - var d, x, x$1, c, _tuple, item, rest, err; - d = this; - c = (x = d.data, x$1 = d.off, ((x$1 < 0 || x$1 >= x.$length) ? $throwRuntimeError("index out of range") : x.$array[x.$offset + x$1])); - _tuple = nextValue($subslice(d.data, d.off), d.nextscan); item = _tuple[0]; rest = _tuple[1]; err = _tuple[2]; - if (!($interfaceIsEqual(err, $ifaceNil))) { - d.error(err); + Context.prototype.hasSubdir = function(root, dir) { return this.$val.hasSubdir(root, dir); }; + hasSubdir = function(root, dir) { + var rel = "", ok = false, _tmp, _tmp$1, _tmp$2, _tmp$3; + root = filepath.Clean(root); + if (!strings.HasSuffix(root, "/")) { + root = root + ("/"); } - d.off = d.data.$length - rest.$length >> 0; - if (c === 123) { - d.scan.step(d.scan, 125); - } else { - d.scan.step(d.scan, 93); + dir = filepath.Clean(dir); + if (!strings.HasPrefix(dir, root)) { + _tmp = ""; _tmp$1 = false; rel = _tmp; ok = _tmp$1; + return [rel, ok]; } - return item; + _tmp$2 = filepath.ToSlash(dir.substring(root.length)); _tmp$3 = true; rel = _tmp$2; ok = _tmp$3; + return [rel, ok]; }; - decodeState.prototype.next = function() { return this.$val.next(); }; - decodeState.Ptr.prototype.scanWhile = function(op) { - var d, newOp, x, x$1, c; - d = this; - newOp = 0; - while (true) { - if (d.off >= d.data.$length) { - newOp = d.scan.eof(); - d.off = d.data.$length + 1 >> 0; - } else { - c = ((x = d.data, x$1 = d.off, ((x$1 < 0 || x$1 >= x.$length) ? $throwRuntimeError("index out of range") : x.$array[x.$offset + x$1])) >> 0); - d.off = d.off + (1) >> 0; - newOp = d.scan.step(d.scan, c); - } - if (!((newOp === op))) { - break; - } + Context.Ptr.prototype.readDir = function(path$1) { + var ctxt, f; + ctxt = this; + f = ctxt.ReadDir; + if (!(f === $throwNilPointerError)) { + return f(path$1); } - return newOp; + return ioutil.ReadDir(path$1); }; - decodeState.prototype.scanWhile = function(op) { return this.$val.scanWhile(op); }; - decodeState.Ptr.prototype.value = function(v) { - var d, _tuple, rest, err, n, x, x$1, op, _ref; - d = this; - if (!v.IsValid()) { - _tuple = nextValue($subslice(d.data, d.off), d.nextscan); rest = _tuple[1]; err = _tuple[2]; - if (!($interfaceIsEqual(err, $ifaceNil))) { - d.error(err); - } - d.off = d.data.$length - rest.$length >> 0; - if (d.scan.redo) { - d.scan.redo = false; - d.scan.step = stateBeginValue; - } - d.scan.step(d.scan, 34); - d.scan.step(d.scan, 34); - n = d.scan.parseState.$length; - if (n > 0 && ((x = d.scan.parseState, x$1 = n - 1 >> 0, ((x$1 < 0 || x$1 >= x.$length) ? $throwRuntimeError("index out of range") : x.$array[x.$offset + x$1])) === 0)) { - d.scan.step(d.scan, 58); - d.scan.step(d.scan, 34); - d.scan.step(d.scan, 34); - d.scan.step(d.scan, 125); - } - return; + Context.prototype.readDir = function(path$1) { return this.$val.readDir(path$1); }; + Context.Ptr.prototype.openFile = function(path$1) { + var ctxt, fn, _tuple, f, err; + ctxt = this; + fn = ctxt.OpenFile; + if (!(fn === $throwNilPointerError)) { + return fn(path$1); } - op = d.scanWhile(9); - _ref = op; - if (_ref === 6) { - d.array($clone(v, reflect.Value)); - } else if (_ref === 2) { - d.object($clone(v, reflect.Value)); - } else if (_ref === 1) { - d.literal($clone(v, reflect.Value)); - } else { - d.error(errPhase); + _tuple = os.Open(path$1); f = _tuple[0]; err = _tuple[1]; + if (!($interfaceIsEqual(err, $ifaceNil))) { + return [$ifaceNil, err]; } + return [f, $ifaceNil]; }; - decodeState.prototype.value = function(v) { return this.$val.value(v); }; - decodeState.Ptr.prototype.indirect = function(v, decodingNull) { - var d, e, _tuple, u, ok, _tuple$1, u$1, ok$1; - d = this; - if (!((v.Kind() === 22)) && !(v.Type().Name() === "") && v.CanAddr()) { - $copy(v, v.Addr(), reflect.Value); + Context.prototype.openFile = function(path$1) { return this.$val.openFile(path$1); }; + Context.Ptr.prototype.isFile = function(path$1) { + var ctxt, _tuple, f, err; + ctxt = this; + _tuple = ctxt.openFile(path$1); f = _tuple[0]; err = _tuple[1]; + if (!($interfaceIsEqual(err, $ifaceNil))) { + return false; } - while (true) { - if ((v.Kind() === 20) && !v.IsNil()) { - e = new reflect.Value.Ptr(); $copy(e, v.Elem(), reflect.Value); - if ((e.Kind() === 22) && !e.IsNil() && (!decodingNull || (e.Elem().Kind() === 22))) { - $copy(v, e, reflect.Value); - continue; - } - } - if (!((v.Kind() === 22))) { - break; - } - if (!((v.Elem().Kind() === 22)) && decodingNull && v.CanSet()) { - break; - } - if (v.IsNil()) { - v.Set($clone(reflect.New(v.Type().Elem()), reflect.Value)); + f.Close(); + return true; + }; + Context.prototype.isFile = function(path$1) { return this.$val.isFile(path$1); }; + Context.Ptr.prototype.gopath = function() { + var ctxt, all, _ref, _i, p; + ctxt = this; + all = ($sliceType($String)).nil; + _ref = ctxt.splitPathList(ctxt.GOPATH); + _i = 0; + while (_i < _ref.$length) { + p = ((_i < 0 || _i >= _ref.$length) ? $throwRuntimeError("index out of range") : _ref.$array[_ref.$offset + _i]); + if (p === "" || p === ctxt.GOROOT) { + _i++; + continue; } - if (v.Type().NumMethod() > 0) { - _tuple = $assertType(v.Interface(), Unmarshaler, true); u = _tuple[0]; ok = _tuple[1]; - if (ok) { - return [u, $ifaceNil, new reflect.Value.Ptr(($ptrType(reflect.rtype)).nil, 0, 0, 0)]; - } - _tuple$1 = $assertType(v.Interface(), encoding.TextUnmarshaler, true); u$1 = _tuple$1[0]; ok$1 = _tuple$1[1]; - if (ok$1) { - return [$ifaceNil, u$1, new reflect.Value.Ptr(($ptrType(reflect.rtype)).nil, 0, 0, 0)]; - } + if (strings.HasPrefix(p, "~")) { + _i++; + continue; } - $copy(v, v.Elem(), reflect.Value); + all = $append(all, p); + _i++; } - return [$ifaceNil, $ifaceNil, v]; + return all; }; - decodeState.prototype.indirect = function(v, decodingNull) { return this.$val.indirect(v, decodingNull); }; - decodeState.Ptr.prototype.array = function(v) { - var d, _tuple, u, ut, pv, err, _ref, i, op, _q, newcap, newv, z; - d = this; - _tuple = d.indirect($clone(v, reflect.Value), false); u = _tuple[0]; ut = _tuple[1]; pv = new reflect.Value.Ptr(); $copy(pv, _tuple[2], reflect.Value); - if (!($interfaceIsEqual(u, $ifaceNil))) { - d.off = d.off - (1) >> 0; - err = u.UnmarshalJSON(d.next()); - if (!($interfaceIsEqual(err, $ifaceNil))) { - d.error(err); + Context.prototype.gopath = function() { return this.$val.gopath(); }; + Context.Ptr.prototype.SrcDirs = function() { + var ctxt, all, dir, _ref, _i, p, dir$1; + ctxt = this; + all = ($sliceType($String)).nil; + if (!(ctxt.GOROOT === "")) { + dir = ctxt.joinPath(new ($sliceType($String))([ctxt.GOROOT, "src", "pkg"])); + if (ctxt.isDir(dir)) { + all = $append(all, dir); } - return; } - if (!($interfaceIsEqual(ut, $ifaceNil))) { - d.saveError(new UnmarshalTypeError.Ptr("array", v.Type())); - d.off = d.off - (1) >> 0; - d.next(); - return; - } - $copy(v, pv, reflect.Value); - _ref = v.Kind(); - switch (0) { default: if (_ref === 20) { - if (v.NumMethod() === 0) { - v.Set($clone(reflect.ValueOf(d.arrayInterface()), reflect.Value)); - return; + _ref = ctxt.gopath(); + _i = 0; + while (_i < _ref.$length) { + p = ((_i < 0 || _i >= _ref.$length) ? $throwRuntimeError("index out of range") : _ref.$array[_ref.$offset + _i]); + dir$1 = ctxt.joinPath(new ($sliceType($String))([p, "src"])); + if (ctxt.isDir(dir$1)) { + all = $append(all, dir$1); } - d.saveError(new UnmarshalTypeError.Ptr("array", v.Type())); - d.off = d.off - (1) >> 0; - d.next(); - return; - } else if (_ref === 17) { - } else if (_ref === 23) { - break; + _i++; + } + return all; + }; + Context.prototype.SrcDirs = function() { return this.$val.SrcDirs(); }; + defaultContext = function() { + var c, _ref, _entry; + c = new Context.Ptr(); $copy(c, new Context.Ptr(), Context); + c.GOARCH = envOr("GOARCH", "js"); + c.GOOS = envOr("GOOS", "linux"); + c.GOROOT = runtime.GOROOT(); + c.GOPATH = envOr("GOPATH", ""); + c.Compiler = "gc"; + c.ReleaseTags = new ($sliceType($String))(["go1.1", "go1.2", "go1.3"]); + _ref = os.Getenv("CGO_ENABLED"); + switch (0) { default: if (_ref === "1") { + c.CgoEnabled = true; + } else if (_ref === "0") { + c.CgoEnabled = false; } else { - d.saveError(new UnmarshalTypeError.Ptr("array", v.Type())); - d.off = d.off - (1) >> 0; - d.next(); - return; - } } - i = 0; - while (true) { - op = d.scanWhile(9); - if (op === 8) { - break; - } - d.off = d.off - (1) >> 0; - d.scan.undo(op); - if (v.Kind() === 23) { - if (i >= v.Cap()) { - newcap = v.Cap() + (_q = v.Cap() / 2, (_q === _q && _q !== 1/0 && _q !== -1/0) ? _q >> 0 : $throwRuntimeError("integer divide by zero")) >> 0; - if (newcap < 4) { - newcap = 4; - } - newv = new reflect.Value.Ptr(); $copy(newv, reflect.MakeSlice(v.Type(), v.Len(), newcap), reflect.Value); - reflect.Copy($clone(newv, reflect.Value), $clone(v, reflect.Value)); - v.Set($clone(newv, reflect.Value)); - } - if (i >= v.Len()) { - v.SetLen(i + 1 >> 0); - } - } - if (i < v.Len()) { - d.value($clone(v.Index(i), reflect.Value)); - } else { - d.value(new reflect.Value.Ptr(($ptrType(reflect.rtype)).nil, 0, 0, 0)); - } - i = i + (1) >> 0; - op = d.scanWhile(9); - if (op === 8) { + if ("js" === c.GOARCH && "linux" === c.GOOS) { + c.CgoEnabled = (_entry = cgoEnabled[c.GOOS + "/" + c.GOARCH], _entry !== undefined ? _entry.v : false); break; } - if (!((op === 7))) { - d.error(errPhase); - } - } - if (i < v.Len()) { - if (v.Kind() === 17) { - z = new reflect.Value.Ptr(); $copy(z, reflect.Zero(v.Type().Elem()), reflect.Value); - while (i < v.Len()) { - v.Index(i).Set($clone(z, reflect.Value)); - i = i + (1) >> 0; - } - } else { - v.SetLen(i); - } - } - if ((i === 0) && (v.Kind() === 23)) { - v.Set($clone(reflect.MakeSlice(v.Type(), 0, 0), reflect.Value)); - } + c.CgoEnabled = false; + } } + return c; }; - decodeState.prototype.array = function(v) { return this.$val.array(v); }; - decodeState.Ptr.prototype.object = function(v) { - var d, _tuple, u, ut, pv, err, _ref, t, mapElem, op, start, item, _tuple$1, key, ok, subv, destring, elemType, f, fields, _ref$1, _i, i, ff, _ref$2, _i$1, i$1, kv; - d = this; - _tuple = d.indirect($clone(v, reflect.Value), false); u = _tuple[0]; ut = _tuple[1]; pv = new reflect.Value.Ptr(); $copy(pv, _tuple[2], reflect.Value); - if (!($interfaceIsEqual(u, $ifaceNil))) { - d.off = d.off - (1) >> 0; - err = u.UnmarshalJSON(d.next()); - if (!($interfaceIsEqual(err, $ifaceNil))) { - d.error(err); - } - return; + envOr = function(name, def) { + var s; + s = os.Getenv(name); + if (s === "") { + return def; } - if (!($interfaceIsEqual(ut, $ifaceNil))) { - d.saveError(new UnmarshalTypeError.Ptr("object", v.Type())); - d.off = d.off - (1) >> 0; - d.next(); - return; + return s; + }; + Package.Ptr.prototype.IsCommand = function() { + var p; + p = this; + return p.Name === "main"; + }; + Package.prototype.IsCommand = function() { return this.$val.IsCommand(); }; + Context.Ptr.prototype.ImportDir = function(dir, mode) { + var ctxt; + ctxt = this; + return ctxt.Import(".", dir, mode); + }; + Context.prototype.ImportDir = function(dir, mode) { return this.$val.ImportDir(dir, mode); }; + NoGoError.Ptr.prototype.Error = function() { + var e; + e = this; + return "no buildable Go source files in " + e.Dir; + }; + NoGoError.prototype.Error = function() { return this.$val.Error(); }; + nameExt = function(name) { + var i; + i = strings.LastIndex(name, "."); + if (i < 0) { + return ""; } - $copy(v, pv, reflect.Value); - if ((v.Kind() === 20) && (v.NumMethod() === 0)) { - v.Set($clone(reflect.ValueOf(new ($mapType($String, $emptyInterface))(d.objectInterface())), reflect.Value)); - return; + return name.substring(i); + }; + Context.Ptr.prototype.Import = function(path$1, srcDir, mode) { + var $this = this, $args = arguments, $s = 0, ctxt, p, pkga, pkgerr, _ref, _tuple, dir, elem, suffix, binaryOnly, root, _tuple$1, sub, ok, all, _ref$1, _i, i, root$1, rootsrc, _tuple$2, sub$1, ok$1, dir$1, _ref$2, _i$1, earlyRoot, dir$2, tried, dir$3, isDir, _ref$3, _i$2, root$2, dir$4, isDir$1, paths, i$1, format, x, _tuple$3, dirs, err, Sfiles, firstFile, imported, testImported, xTestImported, allTags, fset, _ref$4, _i$3, d, name, ext, _tuple$4, match, data, filename, err$1, _ref$5, _tuple$5, pf, pkg, isTest, isXTest, isCgo, _ref$6, _i$4, decl, _tuple$6, d$1, ok$2, _ref$7, _i$5, dspec, _tuple$7, spec, ok$3, quoted, _tuple$8, path$2, err$2, _entry, _key$1, _entry$1, _key$2, _entry$2, _key$3, cg, err$3, _key$4, _ref$8, _i$6, _keys, _entry$3, tag, _tuple$9, _tuple$10, _tuple$11; + /* */ while (true) { switch ($s) { case 0: + ctxt = $this; + p = new Package.Ptr("", "", "", path$1, "", "", "", "", false, "", ($sliceType($String)).nil, "", ($sliceType($String)).nil, ($sliceType($String)).nil, ($sliceType($String)).nil, ($sliceType($String)).nil, ($sliceType($String)).nil, ($sliceType($String)).nil, ($sliceType($String)).nil, ($sliceType($String)).nil, ($sliceType($String)).nil, ($sliceType($String)).nil, ($sliceType($String)).nil, ($sliceType($String)).nil, ($sliceType($String)).nil, ($sliceType($String)).nil, ($sliceType($String)).nil, ($sliceType($String)).nil, ($sliceType($String)).nil, false, ($sliceType($String)).nil, ($sliceType($String)).nil, false, ($sliceType($String)).nil, ($sliceType($String)).nil, false); + if (path$1 === "") { + return [p, fmt.Errorf("import %q: invalid import path", new ($sliceType($emptyInterface))([new $String(path$1)]))]; } - _ref = v.Kind(); - switch (0) { default: if (_ref === 21) { - t = v.Type(); - if (!((t.Key().Kind() === 24))) { - d.saveError(new UnmarshalTypeError.Ptr("object", v.Type())); - break; - } - if (v.IsNil()) { - v.Set($clone(reflect.MakeMap(t), reflect.Value)); + pkga = ""; + pkgerr = $ifaceNil; + _ref = ctxt.Compiler; + if (_ref === "gccgo") { + _tuple = path.Split(p.ImportPath); dir = _tuple[0]; elem = _tuple[1]; + pkga = "pkg/gccgo_" + ctxt.GOOS + "_" + ctxt.GOARCH + "/" + dir + "lib" + elem + ".a"; + } else if (_ref === "gc") { + suffix = ""; + if (!(ctxt.InstallSuffix === "")) { + suffix = "_" + ctxt.InstallSuffix; } - } else if (_ref === 25) { + pkga = "pkg/" + ctxt.GOOS + "_" + ctxt.GOARCH + suffix + "/" + p.ImportPath + ".a"; } else { - d.saveError(new UnmarshalTypeError.Ptr("object", v.Type())); - d.off = d.off - (1) >> 0; - d.next(); - return; - } } - mapElem = new reflect.Value.Ptr(); $copy(mapElem, new reflect.Value.Ptr(), reflect.Value); - while (true) { - op = d.scanWhile(9); - if (op === 5) { - break; - } - if (!((op === 1))) { - d.error(errPhase); + pkgerr = fmt.Errorf("import %q: unknown compiler %q", new ($sliceType($emptyInterface))([new $String(path$1), new $String(ctxt.Compiler)])); + } + binaryOnly = false; + /* if (IsLocalImport(path$1)) { */ if (IsLocalImport(path$1)) {} else { $s = 2; continue; } + pkga = ""; + if (srcDir === "") { + return [p, fmt.Errorf("import %q: import relative to unknown directory", new ($sliceType($emptyInterface))([new $String(path$1)]))]; } - start = d.off - 1 >> 0; - op = d.scanWhile(0); - item = $subslice(d.data, start, (d.off - 1 >> 0)); - _tuple$1 = unquoteBytes(item); key = _tuple$1[0]; ok = _tuple$1[1]; - if (!ok) { - d.error(errPhase); + if (!ctxt.isAbsPath(path$1)) { + p.Dir = ctxt.joinPath(new ($sliceType($String))([srcDir, path$1])); } - subv = new reflect.Value.Ptr(); $copy(subv, new reflect.Value.Ptr(), reflect.Value); - destring = false; - if (v.Kind() === 21) { - elemType = v.Type().Elem(); - if (!mapElem.IsValid()) { - $copy(mapElem, reflect.New(elemType).Elem(), reflect.Value); - } else { - mapElem.Set($clone(reflect.Zero(elemType), reflect.Value)); - } - $copy(subv, mapElem, reflect.Value); - } else { - f = ($ptrType(field)).nil; - fields = cachedTypeFields(v.Type()); - _ref$1 = fields; - _i = 0; - while (_i < _ref$1.$length) { - i = _i; - ff = ((i < 0 || i >= fields.$length) ? $throwRuntimeError("index out of range") : fields.$array[fields.$offset + i]); - if (bytes.Equal(ff.nameBytes, key)) { - f = ff; - break; - } - if (f === ($ptrType(field)).nil && ff.equalFold(ff.nameBytes, key)) { - f = ff; - } - _i++; - } - if (!(f === ($ptrType(field)).nil)) { - $copy(subv, v, reflect.Value); - destring = f.quoted; - _ref$2 = f.index; + /* if (!(ctxt.GOROOT === "")) { */ if (!(ctxt.GOROOT === "")) {} else { $s = 4; continue; } + root = ctxt.joinPath(new ($sliceType($String))([ctxt.GOROOT, "src", "pkg"])); + _tuple$1 = ctxt.hasSubdir(root, p.Dir); sub = _tuple$1[0]; ok = _tuple$1[1]; + /* if (ok) { */ if (ok) {} else { $s = 5; continue; } + p.Goroot = true; + p.ImportPath = sub; + p.Root = ctxt.GOROOT; + /* goto Found */ $s = 1; continue; + /* } */ case 5: + /* } */ case 4: + all = ctxt.gopath(); + _ref$1 = all; + _i = 0; + /* while (_i < _ref$1.$length) { */ case 6: if(!(_i < _ref$1.$length)) { $s = 7; continue; } + i = _i; + root$1 = ((_i < 0 || _i >= _ref$1.$length) ? $throwRuntimeError("index out of range") : _ref$1.$array[_ref$1.$offset + _i]); + rootsrc = ctxt.joinPath(new ($sliceType($String))([root$1, "src"])); + _tuple$2 = ctxt.hasSubdir(rootsrc, p.Dir); sub$1 = _tuple$2[0]; ok$1 = _tuple$2[1]; + /* if (ok$1) { */ if (ok$1) {} else { $s = 8; continue; } + /* if (!(ctxt.GOROOT === "")) { */ if (!(ctxt.GOROOT === "")) {} else { $s = 9; continue; } + dir$1 = ctxt.joinPath(new ($sliceType($String))([ctxt.GOROOT, "src", "pkg", sub$1])); + /* if (ctxt.isDir(dir$1)) { */ if (ctxt.isDir(dir$1)) {} else { $s = 10; continue; } + p.ConflictDir = dir$1; + /* goto Found */ $s = 1; continue; + /* } */ case 10: + /* } */ case 9: + _ref$2 = $subslice(all, 0, i); _i$1 = 0; - while (_i$1 < _ref$2.$length) { - i$1 = ((_i$1 < 0 || _i$1 >= _ref$2.$length) ? $throwRuntimeError("index out of range") : _ref$2.$array[_ref$2.$offset + _i$1]); - if (subv.Kind() === 22) { - if (subv.IsNil()) { - subv.Set($clone(reflect.New(subv.Type().Elem()), reflect.Value)); - } - $copy(subv, subv.Elem(), reflect.Value); - } - $copy(subv, subv.Field(i$1), reflect.Value); + /* while (_i$1 < _ref$2.$length) { */ case 11: if(!(_i$1 < _ref$2.$length)) { $s = 12; continue; } + earlyRoot = ((_i$1 < 0 || _i$1 >= _ref$2.$length) ? $throwRuntimeError("index out of range") : _ref$2.$array[_ref$2.$offset + _i$1]); + dir$2 = ctxt.joinPath(new ($sliceType($String))([earlyRoot, "src", sub$1])); + /* if (ctxt.isDir(dir$2)) { */ if (ctxt.isDir(dir$2)) {} else { $s = 13; continue; } + p.ConflictDir = dir$2; + /* goto Found */ $s = 1; continue; + /* } */ case 13: _i$1++; - } - } + /* } */ $s = 11; continue; case 12: + p.ImportPath = sub$1; + p.Root = root$1; + /* goto Found */ $s = 1; continue; + /* } */ case 8: + _i++; + /* } */ $s = 6; continue; case 7: + /* } else { */ $s = 3; continue; case 2: + if (strings.HasPrefix(path$1, "/")) { + return [p, fmt.Errorf("import %q: cannot import absolute path", new ($sliceType($emptyInterface))([new $String(path$1)]))]; + } + tried = new ($structType([["goroot", "goroot", "go/build", $String, ""], ["gopath", "gopath", "go/build", ($sliceType($String)), ""]])).Ptr(); $copy(tried, new ($structType([["goroot", "goroot", "go/build", $String, ""], ["gopath", "gopath", "go/build", ($sliceType($String)), ""]])).Ptr(), ($structType([["goroot", "goroot", "go/build", $String, ""], ["gopath", "gopath", "go/build", ($sliceType($String)), ""]]))); + /* if (!(ctxt.GOROOT === "")) { */ if (!(ctxt.GOROOT === "")) {} else { $s = 14; continue; } + dir$3 = ctxt.joinPath(new ($sliceType($String))([ctxt.GOROOT, "src", "pkg", path$1])); + isDir = ctxt.isDir(dir$3); + binaryOnly = !isDir && !((((mode & 2) >>> 0) === 0)) && !(pkga === "") && ctxt.isFile(ctxt.joinPath(new ($sliceType($String))([ctxt.GOROOT, pkga]))); + /* if (isDir || binaryOnly) { */ if (isDir || binaryOnly) {} else { $s = 15; continue; } + p.Dir = dir$3; + p.Goroot = true; + p.Root = ctxt.GOROOT; + /* goto Found */ $s = 1; continue; + /* } */ case 15: + tried.goroot = dir$3; + /* } */ case 14: + _ref$3 = ctxt.gopath(); + _i$2 = 0; + /* while (_i$2 < _ref$3.$length) { */ case 16: if(!(_i$2 < _ref$3.$length)) { $s = 17; continue; } + root$2 = ((_i$2 < 0 || _i$2 >= _ref$3.$length) ? $throwRuntimeError("index out of range") : _ref$3.$array[_ref$3.$offset + _i$2]); + dir$4 = ctxt.joinPath(new ($sliceType($String))([root$2, "src", path$1])); + isDir$1 = ctxt.isDir(dir$4); + binaryOnly = !isDir$1 && !((((mode & 2) >>> 0) === 0)) && !(pkga === "") && ctxt.isFile(ctxt.joinPath(new ($sliceType($String))([root$2, pkga]))); + /* if (isDir$1 || binaryOnly) { */ if (isDir$1 || binaryOnly) {} else { $s = 18; continue; } + p.Dir = dir$4; + p.Root = root$2; + /* goto Found */ $s = 1; continue; + /* } */ case 18: + tried.gopath = $append(tried.gopath, dir$4); + _i$2++; + /* } */ $s = 16; continue; case 17: + paths = ($sliceType($String)).nil; + if (!(tried.goroot === "")) { + paths = $append(paths, fmt.Sprintf("\t%s (from $GOROOT)", new ($sliceType($emptyInterface))([new $String(tried.goroot)]))); + } else { + paths = $append(paths, "\t($GOROOT not set)"); } - if (op === 9) { - op = d.scanWhile(9); + i$1 = 0; + format = "\t%s (from $GOPATH)"; + while (i$1 < tried.gopath.$length) { + if (i$1 > 0) { + format = "\t%s"; + } + paths = $append(paths, fmt.Sprintf(format, new ($sliceType($emptyInterface))([new $String((x = tried.gopath, ((i$1 < 0 || i$1 >= x.$length) ? $throwRuntimeError("index out of range") : x.$array[x.$offset + i$1])))]))); + i$1 = i$1 + (1) >> 0; } - if (!((op === 3))) { - d.error(errPhase); + if (i$1 === 0) { + paths = $append(paths, "\t($GOPATH not set)"); } - if (destring) { - d.value($clone(reflect.ValueOf(new ($ptrType($String))(function() { return this.$target.tempstr; }, function($v) { this.$target.tempstr = $v; }, d)), reflect.Value)); - d.literalStore(new ($sliceType($Uint8))($stringToBytes(d.tempstr)), $clone(subv, reflect.Value), true); - d.tempstr = ""; + return [p, fmt.Errorf("cannot find package %q in any of:\n%s", new ($sliceType($emptyInterface))([new $String(path$1), new $String(strings.Join(paths, "\n"))]))]; + /* } */ case 3: + /* Found: */ case 1: + if (!(p.Root === "")) { + if (p.Goroot) { + p.SrcRoot = ctxt.joinPath(new ($sliceType($String))([p.Root, "src", "pkg"])); } else { - d.value($clone(subv, reflect.Value)); - } - if (v.Kind() === 21) { - kv = new reflect.Value.Ptr(); $copy(kv, reflect.ValueOf(key).Convert(v.Type().Key()), reflect.Value); - v.SetMapIndex($clone(kv, reflect.Value), $clone(subv, reflect.Value)); - } - op = d.scanWhile(9); - if (op === 5) { - break; + p.SrcRoot = ctxt.joinPath(new ($sliceType($String))([p.Root, "src"])); } - if (!((op === 4))) { - d.error(errPhase); + p.PkgRoot = ctxt.joinPath(new ($sliceType($String))([p.Root, "pkg"])); + p.BinDir = ctxt.joinPath(new ($sliceType($String))([p.Root, "bin"])); + if (!(pkga === "")) { + p.PkgObj = ctxt.joinPath(new ($sliceType($String))([p.Root, pkga])); } } - }; - decodeState.prototype.object = function(v) { return this.$val.object(v); }; - decodeState.Ptr.prototype.literal = function(v) { - var d, start, op; - d = this; - start = d.off - 1 >> 0; - op = d.scanWhile(0); - d.off = d.off - (1) >> 0; - d.scan.undo(op); - d.literalStore($subslice(d.data, start, d.off), $clone(v, reflect.Value), false); - }; - decodeState.prototype.literal = function(v) { return this.$val.literal(v); }; - decodeState.Ptr.prototype.convertNumber = function(s) { - var d, _tuple, f, err; - d = this; - if (d.useNumber) { - return [new Number(s), $ifaceNil]; + if (!((((mode & 1) >>> 0) === 0))) { + return [p, pkgerr]; } - _tuple = strconv.ParseFloat(s, 64); f = _tuple[0]; err = _tuple[1]; - if (!($interfaceIsEqual(err, $ifaceNil))) { - return [$ifaceNil, new UnmarshalTypeError.Ptr("number " + s, reflect.TypeOf(new $Float64(0)))]; + if (binaryOnly && !(((((mode & 2) >>> 0)) === 0))) { + return [p, pkgerr]; } - return [new $Float64(f), $ifaceNil]; - }; - decodeState.prototype.convertNumber = function(s) { return this.$val.convertNumber(s); }; - decodeState.Ptr.prototype.literalStore = function(item, v, fromQuoted) { - var d, wantptr, _tuple, u, ut, pv, err, _tuple$1, s, ok, err$1, c, _ref, _ref$1, value, _ref$2, _tuple$2, s$1, ok$1, _ref$3, b, _tuple$3, n, err$2, s$2, _ref$4, _tuple$4, n$1, err$3, _tuple$5, n$2, err$4, _tuple$6, n$3, err$5, _tuple$7, n$4, err$6; - d = this; - if (item.$length === 0) { - d.saveError(fmt.Errorf("json: invalid use of ,string struct tag, trying to unmarshal %q into %v", new ($sliceType($emptyInterface))([item, v.Type()]))); - return; + _tuple$3 = ctxt.readDir(p.Dir); dirs = _tuple$3[0]; err = _tuple$3[1]; + if (!($interfaceIsEqual(err, $ifaceNil))) { + return [p, err]; } - wantptr = ((0 < 0 || 0 >= item.$length) ? $throwRuntimeError("index out of range") : item.$array[item.$offset + 0]) === 110; - _tuple = d.indirect($clone(v, reflect.Value), wantptr); u = _tuple[0]; ut = _tuple[1]; pv = new reflect.Value.Ptr(); $copy(pv, _tuple[2], reflect.Value); - if (!($interfaceIsEqual(u, $ifaceNil))) { - err = u.UnmarshalJSON(item); - if (!($interfaceIsEqual(err, $ifaceNil))) { - d.error(err); + Sfiles = ($sliceType($String)).nil; + firstFile = ""; + imported = new $Map(); + testImported = new $Map(); + xTestImported = new $Map(); + allTags = new $Map(); + fset = token.NewFileSet(); + _ref$4 = dirs; + _i$3 = 0; + while (_i$3 < _ref$4.$length) { + d = ((_i$3 < 0 || _i$3 >= _ref$4.$length) ? $throwRuntimeError("index out of range") : _ref$4.$array[_ref$4.$offset + _i$3]); + if (d.IsDir()) { + _i$3++; + continue; } - return; - } - if (!($interfaceIsEqual(ut, $ifaceNil))) { - if (!((((0 < 0 || 0 >= item.$length) ? $throwRuntimeError("index out of range") : item.$array[item.$offset + 0]) === 34))) { - if (fromQuoted) { - d.saveError(fmt.Errorf("json: invalid use of ,string struct tag, trying to unmarshal %q into %v", new ($sliceType($emptyInterface))([item, v.Type()]))); - } else { - d.saveError(new UnmarshalTypeError.Ptr("string", v.Type())); - } + name = d.Name(); + ext = nameExt(name); + _tuple$4 = ctxt.matchFile(p.Dir, name, true, allTags); match = _tuple$4[0]; data = _tuple$4[1]; filename = _tuple$4[2]; err$1 = _tuple$4[3]; + if (!($interfaceIsEqual(err$1, $ifaceNil))) { + return [p, err$1]; } - _tuple$1 = unquoteBytes(item); s = _tuple$1[0]; ok = _tuple$1[1]; - if (!ok) { - if (fromQuoted) { - d.error(fmt.Errorf("json: invalid use of ,string struct tag, trying to unmarshal %q into %v", new ($sliceType($emptyInterface))([item, v.Type()]))); - } else { - d.error(errPhase); + if (!match) { + if (ext === ".go") { + p.IgnoredGoFiles = $append(p.IgnoredGoFiles, name); } + _i$3++; + continue; } - err$1 = ut.UnmarshalText(s); + _ref$5 = ext; + if (_ref$5 === ".c") { + p.CFiles = $append(p.CFiles, name); + _i$3++; + continue; + } else if (_ref$5 === ".cc" || _ref$5 === ".cpp" || _ref$5 === ".cxx") { + p.CXXFiles = $append(p.CXXFiles, name); + _i$3++; + continue; + } else if (_ref$5 === ".m") { + p.MFiles = $append(p.MFiles, name); + _i$3++; + continue; + } else if (_ref$5 === ".h" || _ref$5 === ".hh" || _ref$5 === ".hpp" || _ref$5 === ".hxx") { + p.HFiles = $append(p.HFiles, name); + _i$3++; + continue; + } else if (_ref$5 === ".s") { + p.SFiles = $append(p.SFiles, name); + _i$3++; + continue; + } else if (_ref$5 === ".S") { + Sfiles = $append(Sfiles, name); + _i$3++; + continue; + } else if (_ref$5 === ".swig") { + p.SwigFiles = $append(p.SwigFiles, name); + _i$3++; + continue; + } else if (_ref$5 === ".swigcxx") { + p.SwigCXXFiles = $append(p.SwigCXXFiles, name); + _i$3++; + continue; + } else if (_ref$5 === ".syso") { + p.SysoFiles = $append(p.SysoFiles, name); + _i$3++; + continue; + } + _tuple$5 = parser.ParseFile(fset, filename, data, 6); pf = _tuple$5[0]; err$1 = _tuple$5[1]; if (!($interfaceIsEqual(err$1, $ifaceNil))) { - d.error(err$1); + return [p, err$1]; } - return; - } - $copy(v, pv, reflect.Value); - c = ((0 < 0 || 0 >= item.$length) ? $throwRuntimeError("index out of range") : item.$array[item.$offset + 0]); - _ref = c; - if (_ref === 110) { - _ref$1 = v.Kind(); - if (_ref$1 === 20 || _ref$1 === 22 || _ref$1 === 21 || _ref$1 === 23) { - v.Set($clone(reflect.Zero(v.Type()), reflect.Value)); + pkg = pf.Name.Name; + if (pkg === "documentation") { + p.IgnoredGoFiles = $append(p.IgnoredGoFiles, name); + _i$3++; + continue; } - } else if (_ref === 116 || _ref === 102) { - value = c === 116; - _ref$2 = v.Kind(); - if (_ref$2 === 1) { - v.SetBool(value); - } else if (_ref$2 === 20) { - if (v.NumMethod() === 0) { - v.Set($clone(reflect.ValueOf(new $Bool(value)), reflect.Value)); - } else { - d.saveError(new UnmarshalTypeError.Ptr("bool", v.Type())); - } - } else { - if (fromQuoted) { - d.saveError(fmt.Errorf("json: invalid use of ,string struct tag, trying to unmarshal %q into %v", new ($sliceType($emptyInterface))([item, v.Type()]))); - } else { - d.saveError(new UnmarshalTypeError.Ptr("bool", v.Type())); - } + isTest = strings.HasSuffix(name, "_test.go"); + isXTest = false; + if (isTest && strings.HasSuffix(pkg, "_test")) { + isXTest = true; + pkg = pkg.substring(0, (pkg.length - 5 >> 0)); } - } else if (_ref === 34) { - _tuple$2 = unquoteBytes(item); s$1 = _tuple$2[0]; ok$1 = _tuple$2[1]; - if (!ok$1) { - if (fromQuoted) { - d.error(fmt.Errorf("json: invalid use of ,string struct tag, trying to unmarshal %q into %v", new ($sliceType($emptyInterface))([item, v.Type()]))); - } else { - d.error(errPhase); - } + if (p.Name === "") { + p.Name = pkg; + firstFile = name; + } else if (!(pkg === p.Name)) { + return [p, fmt.Errorf("found packages %s (%s) and %s (%s) in %s", new ($sliceType($emptyInterface))([new $String(p.Name), new $String(firstFile), new $String(pkg), new $String(name), new $String(p.Dir)]))]; } - _ref$3 = v.Kind(); - switch (0) { default: if (_ref$3 === 23) { - if (!($interfaceIsEqual(v.Type(), byteSliceType))) { - d.saveError(new UnmarshalTypeError.Ptr("string", v.Type())); - break; + if (!(pf.Doc === ($ptrType(ast.CommentGroup)).nil) && p.Doc === "") { + p.Doc = doc.Synopsis(pf.Doc.Text()); + } + isCgo = false; + _ref$6 = pf.Decls; + _i$4 = 0; + while (_i$4 < _ref$6.$length) { + decl = ((_i$4 < 0 || _i$4 >= _ref$6.$length) ? $throwRuntimeError("index out of range") : _ref$6.$array[_ref$6.$offset + _i$4]); + _tuple$6 = $assertType(decl, ($ptrType(ast.GenDecl)), true); d$1 = _tuple$6[0]; ok$2 = _tuple$6[1]; + if (!ok$2) { + _i$4++; + continue; } - b = ($sliceType($Uint8)).make(base64.StdEncoding.DecodedLen(s$1.$length)); - _tuple$3 = base64.StdEncoding.Decode(b, s$1); n = _tuple$3[0]; err$2 = _tuple$3[1]; - if (!($interfaceIsEqual(err$2, $ifaceNil))) { - d.saveError(err$2); - break; + _ref$7 = d$1.Specs; + _i$5 = 0; + while (_i$5 < _ref$7.$length) { + dspec = ((_i$5 < 0 || _i$5 >= _ref$7.$length) ? $throwRuntimeError("index out of range") : _ref$7.$array[_ref$7.$offset + _i$5]); + _tuple$7 = $assertType(dspec, ($ptrType(ast.ImportSpec)), true); spec = _tuple$7[0]; ok$3 = _tuple$7[1]; + if (!ok$3) { + _i$5++; + continue; + } + quoted = spec.Path.Value; + _tuple$8 = strconv.Unquote(quoted); path$2 = _tuple$8[0]; err$2 = _tuple$8[1]; + if (!($interfaceIsEqual(err$2, $ifaceNil))) { + log.Panicf("%s: parser returned invalid quoted string: <%s>", new ($sliceType($emptyInterface))([new $String(filename), new $String(quoted)])); + } + if (isXTest) { + _key$1 = path$2; (xTestImported || $throwRuntimeError("assignment to entry in nil map"))[_key$1] = { k: _key$1, v: $append((_entry = xTestImported[path$2], _entry !== undefined ? _entry.v : ($sliceType(token.Position)).nil), fset.Position(spec.Pos())) }; + } else if (isTest) { + _key$2 = path$2; (testImported || $throwRuntimeError("assignment to entry in nil map"))[_key$2] = { k: _key$2, v: $append((_entry$1 = testImported[path$2], _entry$1 !== undefined ? _entry$1.v : ($sliceType(token.Position)).nil), fset.Position(spec.Pos())) }; + } else { + _key$3 = path$2; (imported || $throwRuntimeError("assignment to entry in nil map"))[_key$3] = { k: _key$3, v: $append((_entry$2 = imported[path$2], _entry$2 !== undefined ? _entry$2.v : ($sliceType(token.Position)).nil), fset.Position(spec.Pos())) }; + } + if (path$2 === "C") { + if (isTest) { + return [p, fmt.Errorf("use of cgo in test %s not supported", new ($sliceType($emptyInterface))([new $String(filename)]))]; + } + cg = spec.Doc; + if (cg === ($ptrType(ast.CommentGroup)).nil && (d$1.Specs.$length === 1)) { + cg = d$1.Doc; + } + if (!(cg === ($ptrType(ast.CommentGroup)).nil)) { + err$3 = ctxt.saveCgo(filename, p, cg); + if (!($interfaceIsEqual(err$3, $ifaceNil))) { + return [p, err$3]; + } + } + isCgo = true; + } + _i$5++; } - v.Set($clone(reflect.ValueOf($subslice(b, 0, n)), reflect.Value)); - } else if (_ref$3 === 24) { - v.SetString($bytesToString(s$1)); - } else if (_ref$3 === 20) { - if (v.NumMethod() === 0) { - v.Set($clone(reflect.ValueOf(new $String($bytesToString(s$1))), reflect.Value)); + _i$4++; + } + if (isCgo) { + _key$4 = "cgo"; (allTags || $throwRuntimeError("assignment to entry in nil map"))[_key$4] = { k: _key$4, v: true }; + if (ctxt.CgoEnabled) { + p.CgoFiles = $append(p.CgoFiles, name); } else { - d.saveError(new UnmarshalTypeError.Ptr("string", v.Type())); + p.IgnoredGoFiles = $append(p.IgnoredGoFiles, name); } + } else if (isXTest) { + p.XTestGoFiles = $append(p.XTestGoFiles, name); + } else if (isTest) { + p.TestGoFiles = $append(p.TestGoFiles, name); } else { - d.saveError(new UnmarshalTypeError.Ptr("string", v.Type())); - } } - } else { - if (!((c === 45)) && (c < 48 || c > 57)) { - if (fromQuoted) { - d.error(fmt.Errorf("json: invalid use of ,string struct tag, trying to unmarshal %q into %v", new ($sliceType($emptyInterface))([item, v.Type()]))); - } else { - d.error(errPhase); - } + p.GoFiles = $append(p.GoFiles, name); } - s$2 = $bytesToString(item); - _ref$4 = v.Kind(); - switch (0) { default: if (_ref$4 === 20) { - _tuple$4 = d.convertNumber(s$2); n$1 = _tuple$4[0]; err$3 = _tuple$4[1]; - if (!($interfaceIsEqual(err$3, $ifaceNil))) { - d.saveError(err$3); - break; - } - if (!((v.NumMethod() === 0))) { - d.saveError(new UnmarshalTypeError.Ptr("number", v.Type())); - break; - } - v.Set($clone(reflect.ValueOf(n$1), reflect.Value)); - } else if (_ref$4 === 2 || _ref$4 === 3 || _ref$4 === 4 || _ref$4 === 5 || _ref$4 === 6) { - _tuple$5 = strconv.ParseInt(s$2, 10, 64); n$2 = _tuple$5[0]; err$4 = _tuple$5[1]; - if (!($interfaceIsEqual(err$4, $ifaceNil)) || v.OverflowInt(n$2)) { - d.saveError(new UnmarshalTypeError.Ptr("number " + s$2, v.Type())); - break; - } - v.SetInt(n$2); - } else if (_ref$4 === 7 || _ref$4 === 8 || _ref$4 === 9 || _ref$4 === 10 || _ref$4 === 11 || _ref$4 === 12) { - _tuple$6 = strconv.ParseUint(s$2, 10, 64); n$3 = _tuple$6[0]; err$5 = _tuple$6[1]; - if (!($interfaceIsEqual(err$5, $ifaceNil)) || v.OverflowUint(n$3)) { - d.saveError(new UnmarshalTypeError.Ptr("number " + s$2, v.Type())); - break; - } - v.SetUint(n$3); - } else if (_ref$4 === 13 || _ref$4 === 14) { - _tuple$7 = strconv.ParseFloat(s$2, v.Type().Bits()); n$4 = _tuple$7[0]; err$6 = _tuple$7[1]; - if (!($interfaceIsEqual(err$6, $ifaceNil)) || v.OverflowFloat(n$4)) { - d.saveError(new UnmarshalTypeError.Ptr("number " + s$2, v.Type())); - break; - } - v.SetFloat(n$4); - } else { - if ((v.Kind() === 24) && $interfaceIsEqual(v.Type(), numberType)) { - v.SetString(s$2); - break; - } - if (fromQuoted) { - d.error(fmt.Errorf("json: invalid use of ,string struct tag, trying to unmarshal %q into %v", new ($sliceType($emptyInterface))([item, v.Type()]))); - } else { - d.error(new UnmarshalTypeError.Ptr("number", v.Type())); - } - } } + _i$3++; + } + if ((((p.GoFiles.$length + p.CgoFiles.$length >> 0) + p.TestGoFiles.$length >> 0) + p.XTestGoFiles.$length >> 0) === 0) { + return [p, new NoGoError.Ptr(p.Dir)]; + } + _ref$8 = allTags; + _i$6 = 0; + _keys = $keys(_ref$8); + while (_i$6 < _keys.length) { + _entry$3 = _ref$8[_keys[_i$6]]; + if (_entry$3 === undefined) { + _i$6++; + continue; + } + tag = _entry$3.k; + p.AllTags = $append(p.AllTags, tag); + _i$6++; + } + sort.Strings(p.AllTags); + _tuple$9 = cleanImports(imported); p.Imports = _tuple$9[0]; p.ImportPos = _tuple$9[1]; + _tuple$10 = cleanImports(testImported); p.TestImports = _tuple$10[0]; p.TestImportPos = _tuple$10[1]; + _tuple$11 = cleanImports(xTestImported); p.XTestImports = _tuple$11[0]; p.XTestImportPos = _tuple$11[1]; + if (p.CgoFiles.$length > 0) { + p.SFiles = $appendSlice(p.SFiles, Sfiles); + sort.Strings(p.SFiles); } + return [p, pkgerr]; + /* */ case -1: } return; } }; - decodeState.prototype.literalStore = function(item, v, fromQuoted) { return this.$val.literalStore(item, v, fromQuoted); }; - decodeState.Ptr.prototype.valueInterface = function() { - var d, _ref; - d = this; - _ref = d.scanWhile(9); - if (_ref === 6) { - return d.arrayInterface(); - } else if (_ref === 2) { - return new ($mapType($String, $emptyInterface))(d.objectInterface()); - } else if (_ref === 1) { - return d.literalInterface(); + Context.prototype.Import = function(path$1, srcDir, mode) { return this.$val.Import(path$1, srcDir, mode); }; + Context.Ptr.prototype.MatchFile = function(dir, name) { + var match = false, err = $ifaceNil, ctxt, _tuple; + ctxt = this; + _tuple = ctxt.matchFile(dir, name, false, false); match = _tuple[0]; err = _tuple[3]; + return [match, err]; + }; + Context.prototype.MatchFile = function(dir, name) { return this.$val.MatchFile(dir, name); }; + Context.Ptr.prototype.matchFile = function(dir, name, returnImports, allTags) { + var match = false, data = ($sliceType($Uint8)).nil, filename = "", err = $ifaceNil, ctxt, i, ext, _ref, _tuple, f, _tuple$1, _tuple$2; + ctxt = this; + if (strings.HasPrefix(name, "_") || strings.HasPrefix(name, ".")) { + return [match, data, filename, err]; + } + i = strings.LastIndex(name, "."); + if (i < 0) { + i = name.length; + } + ext = name.substring(i); + if (!ctxt.goodOSArchFile(name, allTags) && !ctxt.UseAllFiles) { + return [match, data, filename, err]; + } + _ref = ext; + if (_ref === ".go" || _ref === ".c" || _ref === ".cc" || _ref === ".cxx" || _ref === ".cpp" || _ref === ".m" || _ref === ".s" || _ref === ".h" || _ref === ".hh" || _ref === ".hpp" || _ref === ".hxx" || _ref === ".S" || _ref === ".swig" || _ref === ".swigcxx") { + } else if (_ref === ".syso") { + match = true; + return [match, data, filename, err]; } else { - d.error(errPhase); - $panic(new $String("unreachable")); + return [match, data, filename, err]; + } + filename = ctxt.joinPath(new ($sliceType($String))([dir, name])); + _tuple = ctxt.openFile(filename); f = _tuple[0]; err = _tuple[1]; + if (!($interfaceIsEqual(err, $ifaceNil))) { + return [match, data, filename, err]; + } + if (strings.HasSuffix(filename, ".go")) { + _tuple$1 = readImports(f, false); data = _tuple$1[0]; err = _tuple$1[1]; + } else { + _tuple$2 = readComments(f); data = _tuple$2[0]; err = _tuple$2[1]; + } + f.Close(); + if (!($interfaceIsEqual(err, $ifaceNil))) { + err = fmt.Errorf("read %s: %v", new ($sliceType($emptyInterface))([new $String(filename), err])); + return [match, data, filename, err]; + } + if (!ctxt.shouldBuild(data, allTags) && !ctxt.UseAllFiles) { + return [match, data, filename, err]; } + match = true; + return [match, data, filename, err]; }; - decodeState.prototype.valueInterface = function() { return this.$val.valueInterface(); }; - decodeState.Ptr.prototype.arrayInterface = function() { - var d, v, op; - d = this; - v = ($sliceType($emptyInterface)).make(0); - while (true) { - op = d.scanWhile(9); - if (op === 8) { - break; + Context.prototype.matchFile = function(dir, name, returnImports, allTags) { return this.$val.matchFile(dir, name, returnImports, allTags); }; + cleanImports = function(m) { + var all, _ref, _i, _keys, _entry, path$1; + all = ($sliceType($String)).make(0, $keys(m).length); + _ref = m; + _i = 0; + _keys = $keys(_ref); + while (_i < _keys.length) { + _entry = _ref[_keys[_i]]; + if (_entry === undefined) { + _i++; + continue; } - d.off = d.off - (1) >> 0; - d.scan.undo(op); - v = $append(v, d.valueInterface()); - op = d.scanWhile(9); - if (op === 8) { + path$1 = _entry.k; + all = $append(all, path$1); + _i++; + } + sort.Strings(all); + return [all, m]; + }; + Import = $pkg.Import = function(path$1, srcDir, mode) { + return $pkg.Default.Import(path$1, srcDir, mode); + }; + Context.Ptr.prototype.shouldBuild = function(content, allTags) { + var ctxt, end, p, line, i, _tmp, _tmp$1, allok, line$1, i$1, _tmp$2, _tmp$3, f, ok, _ref, _i, tok; + ctxt = this; + end = 0; + p = content; + while (p.$length > 0) { + line = p; + i = bytes.IndexByte(line, 10); + if (i >= 0) { + _tmp = $subslice(line, 0, i); _tmp$1 = $subslice(p, (i + 1 >> 0)); line = _tmp; p = _tmp$1; + } else { + p = $subslice(p, p.$length); + } + line = bytes.TrimSpace(line); + if (line.$length === 0) { + end = content.$length - p.$length >> 0; + continue; + } + if (!bytes.HasPrefix(line, slashslash)) { break; } - if (!((op === 7))) { - d.error(errPhase); + } + content = $subslice(content, 0, end); + p = content; + allok = true; + while (p.$length > 0) { + line$1 = p; + i$1 = bytes.IndexByte(line$1, 10); + if (i$1 >= 0) { + _tmp$2 = $subslice(line$1, 0, i$1); _tmp$3 = $subslice(p, (i$1 + 1 >> 0)); line$1 = _tmp$2; p = _tmp$3; + } else { + p = $subslice(p, p.$length); + } + line$1 = bytes.TrimSpace(line$1); + if (bytes.HasPrefix(line$1, slashslash)) { + line$1 = bytes.TrimSpace($subslice(line$1, slashslash.$length)); + if (line$1.$length > 0 && (((0 < 0 || 0 >= line$1.$length) ? $throwRuntimeError("index out of range") : line$1.$array[line$1.$offset + 0]) === 43)) { + f = strings.Fields($bytesToString(line$1)); + if (((0 < 0 || 0 >= f.$length) ? $throwRuntimeError("index out of range") : f.$array[f.$offset + 0]) === "+build") { + ok = false; + _ref = $subslice(f, 1); + _i = 0; + while (_i < _ref.$length) { + tok = ((_i < 0 || _i >= _ref.$length) ? $throwRuntimeError("index out of range") : _ref.$array[_ref.$offset + _i]); + if (ctxt.match(tok, allTags)) { + ok = true; + } + _i++; + } + if (!ok) { + allok = false; + } + } + } } } - return v; + return allok; }; - decodeState.prototype.arrayInterface = function() { return this.$val.arrayInterface(); }; - decodeState.Ptr.prototype.objectInterface = function() { - var d, m, op, start, item, _tuple, key, ok, _key; - d = this; - m = new $Map(); - while (true) { - op = d.scanWhile(9); - if (op === 5) { - break; + Context.prototype.shouldBuild = function(content, allTags) { return this.$val.shouldBuild(content, allTags); }; + Context.Ptr.prototype.saveCgo = function(filename, di, cg) { + var ctxt, text, _ref, _i, line, orig, i, _tmp, _tmp$1, line$1, argstr, f, _tmp$2, _tmp$3, x, cond, verb, ok, _ref$1, _i$1, c, _tuple, args, err, _ref$2, _i$2, arg, _ref$3; + ctxt = this; + text = cg.Text(); + _ref = strings.Split(text, "\n"); + _i = 0; + while (_i < _ref.$length) { + line = ((_i < 0 || _i >= _ref.$length) ? $throwRuntimeError("index out of range") : _ref.$array[_ref.$offset + _i]); + orig = line; + line = strings.TrimSpace(line); + if (line.length < 5 || !(line.substring(0, 4) === "#cgo") || (!((line.charCodeAt(4) === 32)) && !((line.charCodeAt(4) === 9)))) { + _i++; + continue; } - if (!((op === 1))) { - d.error(errPhase); + line = strings.TrimSpace(line.substring(4)); + i = strings.Index(line, ":"); + if (i < 0) { + return fmt.Errorf("%s: invalid #cgo line: %s", new ($sliceType($emptyInterface))([new $String(filename), new $String(orig)])); } - start = d.off - 1 >> 0; - op = d.scanWhile(0); - item = $subslice(d.data, start, (d.off - 1 >> 0)); - _tuple = unquote(item); key = _tuple[0]; ok = _tuple[1]; - if (!ok) { - d.error(errPhase); + _tmp = line.substring(0, i); _tmp$1 = line.substring((i + 1 >> 0)); line$1 = _tmp; argstr = _tmp$1; + f = strings.Fields(line$1); + if (f.$length < 1) { + return fmt.Errorf("%s: invalid #cgo line: %s", new ($sliceType($emptyInterface))([new $String(filename), new $String(orig)])); } - if (op === 9) { - op = d.scanWhile(9); + _tmp$2 = $subslice(f, 0, (f.$length - 1 >> 0)); _tmp$3 = (x = f.$length - 1 >> 0, ((x < 0 || x >= f.$length) ? $throwRuntimeError("index out of range") : f.$array[f.$offset + x])); cond = _tmp$2; verb = _tmp$3; + if (cond.$length > 0) { + ok = false; + _ref$1 = cond; + _i$1 = 0; + while (_i$1 < _ref$1.$length) { + c = ((_i$1 < 0 || _i$1 >= _ref$1.$length) ? $throwRuntimeError("index out of range") : _ref$1.$array[_ref$1.$offset + _i$1]); + if (ctxt.match(c, false)) { + ok = true; + break; + } + _i$1++; + } + if (!ok) { + _i++; + continue; + } } - if (!((op === 3))) { - d.error(errPhase); + _tuple = splitQuoted(argstr); args = _tuple[0]; err = _tuple[1]; + if (!($interfaceIsEqual(err, $ifaceNil))) { + return fmt.Errorf("%s: invalid #cgo line: %s", new ($sliceType($emptyInterface))([new $String(filename), new $String(orig)])); } - _key = key; (m || $throwRuntimeError("assignment to entry in nil map"))[_key] = { k: _key, v: d.valueInterface() }; - op = d.scanWhile(9); - if (op === 5) { - break; + _ref$2 = args; + _i$2 = 0; + while (_i$2 < _ref$2.$length) { + arg = ((_i$2 < 0 || _i$2 >= _ref$2.$length) ? $throwRuntimeError("index out of range") : _ref$2.$array[_ref$2.$offset + _i$2]); + if (!safeCgoName(arg)) { + return fmt.Errorf("%s: malformed #cgo argument: %s", new ($sliceType($emptyInterface))([new $String(filename), new $String(arg)])); + } + _i$2++; } - if (!((op === 4))) { - d.error(errPhase); + _ref$3 = verb; + if (_ref$3 === "CFLAGS") { + di.CgoCFLAGS = $appendSlice(di.CgoCFLAGS, args); + } else if (_ref$3 === "CPPFLAGS") { + di.CgoCPPFLAGS = $appendSlice(di.CgoCPPFLAGS, args); + } else if (_ref$3 === "CXXFLAGS") { + di.CgoCXXFLAGS = $appendSlice(di.CgoCXXFLAGS, args); + } else if (_ref$3 === "LDFLAGS") { + di.CgoLDFLAGS = $appendSlice(di.CgoLDFLAGS, args); + } else if (_ref$3 === "pkg-config") { + di.CgoPkgConfig = $appendSlice(di.CgoPkgConfig, args); + } else { + return fmt.Errorf("%s: invalid #cgo verb: %s", new ($sliceType($emptyInterface))([new $String(filename), new $String(orig)])); } + _i++; } - return m; + return $ifaceNil; }; - decodeState.prototype.objectInterface = function() { return this.$val.objectInterface(); }; - decodeState.Ptr.prototype.literalInterface = function() { - var d, start, op, item, c, _ref, _tuple, s, ok, _tuple$1, n, err; - d = this; - start = d.off - 1 >> 0; - op = d.scanWhile(0); - d.off = d.off - (1) >> 0; - d.scan.undo(op); - item = $subslice(d.data, start, d.off); - c = ((0 < 0 || 0 >= item.$length) ? $throwRuntimeError("index out of range") : item.$array[item.$offset + 0]); - _ref = c; - if (_ref === 110) { - return $ifaceNil; - } else if (_ref === 116 || _ref === 102) { - return new $Bool((c === 116)); - } else if (_ref === 34) { - _tuple = unquote(item); s = _tuple[0]; ok = _tuple[1]; - if (!ok) { - d.error(errPhase); - } - return new $String(s); - } else { - if (!((c === 45)) && (c < 48 || c > 57)) { - d.error(errPhase); - } - _tuple$1 = d.convertNumber($bytesToString(item)); n = _tuple$1[0]; err = _tuple$1[1]; - if (!($interfaceIsEqual(err, $ifaceNil))) { - d.saveError(err); + Context.prototype.saveCgo = function(filename, di, cg) { return this.$val.saveCgo(filename, di, cg); }; + safeCgoName = function(s) { + var i, c; + if (s === "") { + return false; + } + i = 0; + while (i < s.length) { + c = s.charCodeAt(i); + if (c < 128 && bytes.IndexByte(safeBytes, c) < 0) { + return false; } - return n; + i = i + (1) >> 0; } + return true; }; - decodeState.prototype.literalInterface = function() { return this.$val.literalInterface(); }; - getu4 = function(s) { - var _tuple, r, err; - if (s.$length < 6 || !((((0 < 0 || 0 >= s.$length) ? $throwRuntimeError("index out of range") : s.$array[s.$offset + 0]) === 92)) || !((((1 < 0 || 1 >= s.$length) ? $throwRuntimeError("index out of range") : s.$array[s.$offset + 1]) === 117))) { - return -1; + splitQuoted = function(s) { + var r = ($sliceType($String)).nil, err = $ifaceNil, args, arg, escaped, quoted, quote, i, _ref, _i, _rune, rune, _tmp, _tmp$1; + args = ($sliceType($String)).nil; + arg = ($sliceType($Int32)).make(s.length); + escaped = false; + quoted = false; + quote = 0; + i = 0; + _ref = s; + _i = 0; + while (_i < _ref.length) { + _rune = $decodeRune(_ref, _i); + rune = _rune[0]; + if (escaped) { + escaped = false; + } else if (rune === 92) { + escaped = true; + _i += _rune[1]; + continue; + } else if (!((quote === 0))) { + if (rune === quote) { + quote = 0; + _i += _rune[1]; + continue; + } + } else if ((rune === 34) || (rune === 39)) { + quoted = true; + quote = rune; + _i += _rune[1]; + continue; + } else if (unicode.IsSpace(rune)) { + if (quoted || i > 0) { + quoted = false; + args = $append(args, $runesToString($subslice(arg, 0, i))); + i = 0; + } + _i += _rune[1]; + continue; + } + (i < 0 || i >= arg.$length) ? $throwRuntimeError("index out of range") : arg.$array[arg.$offset + i] = rune; + i = i + (1) >> 0; + _i += _rune[1]; } - _tuple = strconv.ParseUint($bytesToString($subslice(s, 2, 6)), 16, 64); r = _tuple[0]; err = _tuple[1]; - if (!($interfaceIsEqual(err, $ifaceNil))) { - return -1; + if (quoted || i > 0) { + args = $append(args, $runesToString($subslice(arg, 0, i))); } - return (r.$low >> 0); - }; - unquote = function(s) { - var t = "", ok = false, _tuple; - _tuple = unquoteBytes(s); s = _tuple[0]; ok = _tuple[1]; - t = $bytesToString(s); - return [t, ok]; - }; - unquoteBytes = function(s) { - var t = ($sliceType($Uint8)).nil, ok = false, x, r, c, _tuple, rr, size, _tmp, _tmp$1, b, w, x$1, nb, c$1, _ref, rr$1, rr1, dec, _tuple$1, rr$2, size$1, _tmp$2, _tmp$3; - if (s.$length < 2 || !((((0 < 0 || 0 >= s.$length) ? $throwRuntimeError("index out of range") : s.$array[s.$offset + 0]) === 34)) || !(((x = s.$length - 1 >> 0, ((x < 0 || x >= s.$length) ? $throwRuntimeError("index out of range") : s.$array[s.$offset + x])) === 34))) { - return [t, ok]; + if (!((quote === 0))) { + err = errors.New("unclosed quote"); + } else if (escaped) { + err = errors.New("unfinished escaping"); } - s = $subslice(s, 1, (s.$length - 1 >> 0)); - r = 0; - while (r < s.$length) { - c = ((r < 0 || r >= s.$length) ? $throwRuntimeError("index out of range") : s.$array[s.$offset + r]); - if ((c === 92) || (c === 34) || c < 32) { - break; - } - if (c < 128) { - r = r + (1) >> 0; - continue; + _tmp = args; _tmp$1 = err; r = _tmp; err = _tmp$1; + return [r, err]; + }; + Context.Ptr.prototype.match = function(name, allTags) { + var ctxt, _key$1, i, ok1, ok2, _key$2, _ref, _i, _rune, c, _ref$1, _i$1, tag, _ref$2, _i$2, tag$1; + ctxt = this; + if (name === "") { + if (!(allTags === false)) { + _key$1 = name; (allTags || $throwRuntimeError("assignment to entry in nil map"))[_key$1] = { k: _key$1, v: true }; } - _tuple = utf8.DecodeRune($subslice(s, r)); rr = _tuple[0]; size = _tuple[1]; - if ((rr === 65533) && (size === 1)) { - break; + return false; + } + i = strings.Index(name, ","); + if (i >= 0) { + ok1 = ctxt.match(name.substring(0, i), allTags); + ok2 = ctxt.match(name.substring((i + 1 >> 0)), allTags); + return ok1 && ok2; + } + if (strings.HasPrefix(name, "!!")) { + return false; + } + if (strings.HasPrefix(name, "!")) { + return name.length > 1 && !ctxt.match(name.substring(1), allTags); + } + if (!(allTags === false)) { + _key$2 = name; (allTags || $throwRuntimeError("assignment to entry in nil map"))[_key$2] = { k: _key$2, v: true }; + } + _ref = name; + _i = 0; + while (_i < _ref.length) { + _rune = $decodeRune(_ref, _i); + c = _rune[0]; + if (!unicode.IsLetter(c) && !unicode.IsDigit(c) && !((c === 95)) && !((c === 46))) { + return false; } - r = r + (size) >> 0; + _i += _rune[1]; } - if (r === s.$length) { - _tmp = s; _tmp$1 = true; t = _tmp; ok = _tmp$1; - return [t, ok]; + if (ctxt.CgoEnabled && name === "cgo") { + return true; } - b = ($sliceType($Uint8)).make((s.$length + 8 >> 0)); - w = $copySlice(b, $subslice(s, 0, r)); - while (r < s.$length) { - if (w >= (b.$length - 8 >> 0)) { - nb = ($sliceType($Uint8)).make((x$1 = (b.$length + 4 >> 0), (((x$1 >>> 16 << 16) * 2 >> 0) + (x$1 << 16 >>> 16) * 2) >> 0)); - $copySlice(nb, $subslice(b, 0, w)); - b = nb; + if (name === ctxt.GOOS || name === ctxt.GOARCH || name === ctxt.Compiler) { + return true; + } + _ref$1 = ctxt.BuildTags; + _i$1 = 0; + while (_i$1 < _ref$1.$length) { + tag = ((_i$1 < 0 || _i$1 >= _ref$1.$length) ? $throwRuntimeError("index out of range") : _ref$1.$array[_ref$1.$offset + _i$1]); + if (tag === name) { + return true; } - c$1 = ((r < 0 || r >= s.$length) ? $throwRuntimeError("index out of range") : s.$array[s.$offset + r]); - if (c$1 === 92) { - r = r + (1) >> 0; - if (r >= s.$length) { - return [t, ok]; - } - _ref = ((r < 0 || r >= s.$length) ? $throwRuntimeError("index out of range") : s.$array[s.$offset + r]); - switch (0) { default: if (_ref === 34 || _ref === 92 || _ref === 47 || _ref === 39) { - (w < 0 || w >= b.$length) ? $throwRuntimeError("index out of range") : b.$array[b.$offset + w] = ((r < 0 || r >= s.$length) ? $throwRuntimeError("index out of range") : s.$array[s.$offset + r]); - r = r + (1) >> 0; - w = w + (1) >> 0; - } else if (_ref === 98) { - (w < 0 || w >= b.$length) ? $throwRuntimeError("index out of range") : b.$array[b.$offset + w] = 8; - r = r + (1) >> 0; - w = w + (1) >> 0; - } else if (_ref === 102) { - (w < 0 || w >= b.$length) ? $throwRuntimeError("index out of range") : b.$array[b.$offset + w] = 12; - r = r + (1) >> 0; - w = w + (1) >> 0; - } else if (_ref === 110) { - (w < 0 || w >= b.$length) ? $throwRuntimeError("index out of range") : b.$array[b.$offset + w] = 10; - r = r + (1) >> 0; - w = w + (1) >> 0; - } else if (_ref === 114) { - (w < 0 || w >= b.$length) ? $throwRuntimeError("index out of range") : b.$array[b.$offset + w] = 13; - r = r + (1) >> 0; - w = w + (1) >> 0; - } else if (_ref === 116) { - (w < 0 || w >= b.$length) ? $throwRuntimeError("index out of range") : b.$array[b.$offset + w] = 9; - r = r + (1) >> 0; - w = w + (1) >> 0; - } else if (_ref === 117) { - r = r - (1) >> 0; - rr$1 = getu4($subslice(s, r)); - if (rr$1 < 0) { - return [t, ok]; - } - r = r + (6) >> 0; - if (utf16.IsSurrogate(rr$1)) { - rr1 = getu4($subslice(s, r)); - dec = utf16.DecodeRune(rr$1, rr1); - if (!((dec === 65533))) { - r = r + (6) >> 0; - w = w + (utf8.EncodeRune($subslice(b, w), dec)) >> 0; - break; - } - rr$1 = 65533; - } - w = w + (utf8.EncodeRune($subslice(b, w), rr$1)) >> 0; - } else { - return [t, ok]; - } } - } else if (c$1 === 34 || c$1 < 32) { - return [t, ok]; - } else if (c$1 < 128) { - (w < 0 || w >= b.$length) ? $throwRuntimeError("index out of range") : b.$array[b.$offset + w] = c$1; - r = r + (1) >> 0; - w = w + (1) >> 0; - } else { - _tuple$1 = utf8.DecodeRune($subslice(s, r)); rr$2 = _tuple$1[0]; size$1 = _tuple$1[1]; - r = r + (size$1) >> 0; - w = w + (utf8.EncodeRune($subslice(b, w), rr$2)) >> 0; + _i$1++; + } + _ref$2 = ctxt.ReleaseTags; + _i$2 = 0; + while (_i$2 < _ref$2.$length) { + tag$1 = ((_i$2 < 0 || _i$2 >= _ref$2.$length) ? $throwRuntimeError("index out of range") : _ref$2.$array[_ref$2.$offset + _i$2]); + if (tag$1 === name) { + return true; } + _i$2++; } - _tmp$2 = $subslice(b, 0, w); _tmp$3 = true; t = _tmp$2; ok = _tmp$3; - return [t, ok]; + return false; }; - Marshal = $pkg.Marshal = function(v) { - var e, err; - e = new encodeState.Ptr(new bytes.Buffer.Ptr(), ($arrayType($Uint8, 64)).zero()); - err = e.marshal(v); - if (!($interfaceIsEqual(err, $ifaceNil))) { - return [($sliceType($Uint8)).nil, err]; + Context.prototype.match = function(name, allTags) { return this.$val.match(name, allTags); }; + Context.Ptr.prototype.goodOSArchFile = function(name, allTags) { + var ctxt, dot, l, n, x, n$1, x$1, _entry, x$2, _entry$1, _key$1, x$3, _key$2, x$4, x$5, x$6, x$7, _entry$2, _key$3, x$8, x$9, x$10, _entry$3, _key$4, x$11, x$12; + ctxt = this; + dot = strings.Index(name, "."); + if (!((dot === -1))) { + name = name.substring(0, dot); } - return [e.Buffer.Bytes(), $ifaceNil]; - }; - UnsupportedTypeError.Ptr.prototype.Error = function() { - var e; - e = this; - return "json: unsupported type: " + e.Type.String(); - }; - UnsupportedTypeError.prototype.Error = function() { return this.$val.Error(); }; - UnsupportedValueError.Ptr.prototype.Error = function() { - var e; - e = this; - return "json: unsupported value: " + e.Str; - }; - UnsupportedValueError.prototype.Error = function() { return this.$val.Error(); }; - MarshalerError.Ptr.prototype.Error = function() { - var e; - e = this; - return "json: error calling MarshalJSON for type " + e.Type.String() + ": " + e.Err.Error(); - }; - MarshalerError.prototype.Error = function() { return this.$val.Error(); }; - newEncodeState = function() { - var v, e; - v = encodeStatePool.Get(); - if (!($interfaceIsEqual(v, $ifaceNil))) { - e = $assertType(v, ($ptrType(encodeState))); - e.Buffer.Reset(); - return e; + l = strings.Split(name, "_"); + n = l.$length; + if (n > 0 && (x = n - 1 >> 0, ((x < 0 || x >= l.$length) ? $throwRuntimeError("index out of range") : l.$array[l.$offset + x])) === "test") { + l = $subslice(l, 0, (n - 1 >> 0)); } - return new encodeState.Ptr(); - }; - encodeState.Ptr.prototype.marshal = function(v) { - var err = $ifaceNil, $deferred = [], $err = null, e; - /* */ try { $deferFrames.push($deferred); - e = this; - $deferred.push([(function() { - var r, _tuple, ok, _tuple$1, s, ok$1; - r = $recover(); - if (!($interfaceIsEqual(r, $ifaceNil))) { - _tuple = $assertType(r, runtime.Error, true); ok = _tuple[1]; - if (ok) { - $panic(r); - } - _tuple$1 = $assertType(r, $String, true); s = _tuple$1[0]; ok$1 = _tuple$1[1]; - if (ok$1) { - $panic(new $String(s)); - } - err = $assertType(r, $error); + n$1 = l.$length; + if (n$1 >= 2 && (_entry = knownOS[(x$1 = n$1 - 2 >> 0, ((x$1 < 0 || x$1 >= l.$length) ? $throwRuntimeError("index out of range") : l.$array[l.$offset + x$1]))], _entry !== undefined ? _entry.v : false) && (_entry$1 = knownArch[(x$2 = n$1 - 1 >> 0, ((x$2 < 0 || x$2 >= l.$length) ? $throwRuntimeError("index out of range") : l.$array[l.$offset + x$2]))], _entry$1 !== undefined ? _entry$1.v : false)) { + if (!(allTags === false)) { + _key$1 = (x$3 = n$1 - 2 >> 0, ((x$3 < 0 || x$3 >= l.$length) ? $throwRuntimeError("index out of range") : l.$array[l.$offset + x$3])); (allTags || $throwRuntimeError("assignment to entry in nil map"))[_key$1] = { k: _key$1, v: true }; + _key$2 = (x$4 = n$1 - 1 >> 0, ((x$4 < 0 || x$4 >= l.$length) ? $throwRuntimeError("index out of range") : l.$array[l.$offset + x$4])); (allTags || $throwRuntimeError("assignment to entry in nil map"))[_key$2] = { k: _key$2, v: true }; } - }), []]); - e.reflectValue($clone(reflect.ValueOf(v), reflect.Value)); - err = $ifaceNil; - return err; - /* */ } catch(err) { $err = err; } finally { $deferFrames.pop(); $callDeferred($deferred, $err); return err; } - }; - encodeState.prototype.marshal = function(v) { return this.$val.marshal(v); }; - encodeState.Ptr.prototype.error = function(err) { - var e; - e = this; - $panic(err); + return (x$5 = n$1 - 2 >> 0, ((x$5 < 0 || x$5 >= l.$length) ? $throwRuntimeError("index out of range") : l.$array[l.$offset + x$5])) === ctxt.GOOS && (x$6 = n$1 - 1 >> 0, ((x$6 < 0 || x$6 >= l.$length) ? $throwRuntimeError("index out of range") : l.$array[l.$offset + x$6])) === ctxt.GOARCH; + } + if (n$1 >= 1 && (_entry$2 = knownOS[(x$7 = n$1 - 1 >> 0, ((x$7 < 0 || x$7 >= l.$length) ? $throwRuntimeError("index out of range") : l.$array[l.$offset + x$7]))], _entry$2 !== undefined ? _entry$2.v : false)) { + if (!(allTags === false)) { + _key$3 = (x$8 = n$1 - 1 >> 0, ((x$8 < 0 || x$8 >= l.$length) ? $throwRuntimeError("index out of range") : l.$array[l.$offset + x$8])); (allTags || $throwRuntimeError("assignment to entry in nil map"))[_key$3] = { k: _key$3, v: true }; + } + return (x$9 = n$1 - 1 >> 0, ((x$9 < 0 || x$9 >= l.$length) ? $throwRuntimeError("index out of range") : l.$array[l.$offset + x$9])) === ctxt.GOOS; + } + if (n$1 >= 1 && (_entry$3 = knownArch[(x$10 = n$1 - 1 >> 0, ((x$10 < 0 || x$10 >= l.$length) ? $throwRuntimeError("index out of range") : l.$array[l.$offset + x$10]))], _entry$3 !== undefined ? _entry$3.v : false)) { + if (!(allTags === false)) { + _key$4 = (x$11 = n$1 - 1 >> 0, ((x$11 < 0 || x$11 >= l.$length) ? $throwRuntimeError("index out of range") : l.$array[l.$offset + x$11])); (allTags || $throwRuntimeError("assignment to entry in nil map"))[_key$4] = { k: _key$4, v: true }; + } + return (x$12 = n$1 - 1 >> 0, ((x$12 < 0 || x$12 >= l.$length) ? $throwRuntimeError("index out of range") : l.$array[l.$offset + x$12])) === ctxt.GOARCH; + } + return true; }; - encodeState.prototype.error = function(err) { return this.$val.error(err); }; - isEmptyValue = function(v) { - var _ref, x, x$1; - _ref = v.Kind(); - if (_ref === 17 || _ref === 21 || _ref === 23 || _ref === 24) { - return v.Len() === 0; - } else if (_ref === 1) { - return !v.Bool(); - } else if (_ref === 2 || _ref === 3 || _ref === 4 || _ref === 5 || _ref === 6) { - return (x = v.Int(), (x.$high === 0 && x.$low === 0)); - } else if (_ref === 7 || _ref === 8 || _ref === 9 || _ref === 10 || _ref === 11 || _ref === 12) { - return (x$1 = v.Uint(), (x$1.$high === 0 && x$1.$low === 0)); - } else if (_ref === 13 || _ref === 14) { - return v.Float() === 0; - } else if (_ref === 20 || _ref === 22) { - return v.IsNil(); + Context.prototype.goodOSArchFile = function(name, allTags) { return this.$val.goodOSArchFile(name, allTags); }; + init = function() { + var _ref, _i, v, _key$1, _ref$1, _i$1, v$1, _key$2; + _ref = strings.Fields("darwin dragonfly freebsd linux nacl netbsd openbsd plan9 solaris windows "); + _i = 0; + while (_i < _ref.$length) { + v = ((_i < 0 || _i >= _ref.$length) ? $throwRuntimeError("index out of range") : _ref.$array[_ref.$offset + _i]); + _key$1 = v; (knownOS || $throwRuntimeError("assignment to entry in nil map"))[_key$1] = { k: _key$1, v: true }; + _i++; + } + _ref$1 = strings.Fields("386 amd64 amd64p32 arm "); + _i$1 = 0; + while (_i$1 < _ref$1.$length) { + v$1 = ((_i$1 < 0 || _i$1 >= _ref$1.$length) ? $throwRuntimeError("index out of range") : _ref$1.$array[_ref$1.$offset + _i$1]); + _key$2 = v$1; (knownArch || $throwRuntimeError("assignment to entry in nil map"))[_key$2] = { k: _key$2, v: true }; + _i$1++; } - return false; }; - encodeState.Ptr.prototype.reflectValue = function(v) { - var e; - e = this; - valueEncoder($clone(v, reflect.Value))(e, $clone(v, reflect.Value), false); + IsLocalImport = $pkg.IsLocalImport = function(path$1) { + return path$1 === "." || path$1 === ".." || strings.HasPrefix(path$1, "./") || strings.HasPrefix(path$1, "../"); + }; + isIdent = function(c) { + return 65 <= c && c <= 90 || 97 <= c && c <= 122 || 48 <= c && c <= 57 || (c === 95) || c >= 128; }; - encodeState.prototype.reflectValue = function(v) { return this.$val.reflectValue(v); }; - valueEncoder = function(v) { - if (!v.IsValid()) { - return invalidValueEncoder; + importReader.Ptr.prototype.syntaxError = function() { + var r; + r = this; + if ($interfaceIsEqual(r.err, $ifaceNil)) { + r.err = errSyntax; } - return typeEncoder(v.Type()); }; - typeEncoder = function(t) { - var _entry, f, wg, _key, _key$1; - encoderCache.RWMutex.RLock(); - f = (_entry = encoderCache.m[t.$key()], _entry !== undefined ? _entry.v : $throwNilPointerError); - encoderCache.RWMutex.RUnlock(); - if (!(f === $throwNilPointerError)) { - return f; + importReader.prototype.syntaxError = function() { return this.$val.syntaxError(); }; + importReader.Ptr.prototype.readByte = function() { + var r, _tuple, c, err; + r = this; + _tuple = r.b.ReadByte(); c = _tuple[0]; err = _tuple[1]; + if ($interfaceIsEqual(err, $ifaceNil)) { + r.buf = $append(r.buf, c); + if (c === 0) { + err = errNUL; + } } - encoderCache.RWMutex.Lock(); - if (encoderCache.m === false) { - encoderCache.m = new $Map(); + if (!($interfaceIsEqual(err, $ifaceNil))) { + if ($interfaceIsEqual(err, io.EOF)) { + r.eof = true; + } else if ($interfaceIsEqual(r.err, $ifaceNil)) { + r.err = err; + } + c = 0; } - wg = new sync.WaitGroup.Ptr(); $copy(wg, new sync.WaitGroup.Ptr(), sync.WaitGroup); - wg.Add(1); - _key = t; (encoderCache.m || $throwRuntimeError("assignment to entry in nil map"))[_key.$key()] = { k: _key, v: (function(e, v, quoted) { - wg.Wait(); - f(e, $clone(v, reflect.Value), quoted); - }) }; - encoderCache.RWMutex.Unlock(); - f = newTypeEncoder(t, true); - wg.Done(); - encoderCache.RWMutex.Lock(); - _key$1 = t; (encoderCache.m || $throwRuntimeError("assignment to entry in nil map"))[_key$1.$key()] = { k: _key$1, v: f }; - encoderCache.RWMutex.Unlock(); - return f; + return c; }; - newTypeEncoder = function(t, allowAddr) { - var _ref; - if (t.Implements(marshalerType)) { - return marshalerEncoder; - } - if (!((t.Kind() === 22)) && allowAddr) { - if (reflect.PtrTo(t).Implements(marshalerType)) { - return newCondAddrEncoder(addrMarshalerEncoder, newTypeEncoder(t, false)); + importReader.prototype.readByte = function() { return this.$val.readByte(); }; + importReader.Ptr.prototype.peekByte = function(skipSpace) { + var r, c, _ref, c1, _tmp, _tmp$1; + r = this; + if (!($interfaceIsEqual(r.err, $ifaceNil))) { + r.nerr = r.nerr + (1) >> 0; + if (r.nerr > 10000) { + $panic(new $String("go/build: import reader looping")); } + return 0; } - if (t.Implements(textMarshalerType)) { - return textMarshalerEncoder; + c = r.peek; + if (c === 0) { + c = r.readByte(); } - if (!((t.Kind() === 22)) && allowAddr) { - if (reflect.PtrTo(t).Implements(textMarshalerType)) { - return newCondAddrEncoder(addrTextMarshalerEncoder, newTypeEncoder(t, false)); + while ($interfaceIsEqual(r.err, $ifaceNil) && !r.eof) { + if (skipSpace) { + _ref = c; + if (_ref === 32 || _ref === 12 || _ref === 9 || _ref === 13 || _ref === 10 || _ref === 59) { + c = r.readByte(); + continue; + } else if (_ref === 47) { + c = r.readByte(); + if (c === 47) { + while (!((c === 10)) && $interfaceIsEqual(r.err, $ifaceNil) && !r.eof) { + c = r.readByte(); + } + } else if (c === 42) { + c1 = 0; + while ((!((c === 42)) || !((c1 === 47))) && $interfaceIsEqual(r.err, $ifaceNil)) { + if (r.eof) { + r.syntaxError(); + } + _tmp = c1; _tmp$1 = r.readByte(); c = _tmp; c1 = _tmp$1; + } + } else { + r.syntaxError(); + } + c = r.readByte(); + continue; + } } + break; } - _ref = t.Kind(); - if (_ref === 1) { - return boolEncoder; - } else if (_ref === 2 || _ref === 3 || _ref === 4 || _ref === 5 || _ref === 6) { - return intEncoder; - } else if (_ref === 7 || _ref === 8 || _ref === 9 || _ref === 10 || _ref === 11 || _ref === 12) { - return uintEncoder; - } else if (_ref === 13) { - return float32Encoder; - } else if (_ref === 14) { - return float64Encoder; - } else if (_ref === 24) { - return stringEncoder; - } else if (_ref === 20) { - return interfaceEncoder; - } else if (_ref === 25) { - return newStructEncoder(t); - } else if (_ref === 21) { - return newMapEncoder(t); - } else if (_ref === 23) { - return newSliceEncoder(t); - } else if (_ref === 17) { - return newArrayEncoder(t); - } else if (_ref === 22) { - return newPtrEncoder(t); - } else { - return unsupportedTypeEncoder; - } + r.peek = c; + return r.peek; }; - invalidValueEncoder = function(e, v, quoted) { - e.Buffer.WriteString("null"); + importReader.prototype.peekByte = function(skipSpace) { return this.$val.peekByte(skipSpace); }; + importReader.Ptr.prototype.nextByte = function(skipSpace) { + var r, c; + r = this; + c = r.peekByte(skipSpace); + r.peek = 0; + return c; }; - marshalerEncoder = function(e, v, quoted) { - var m, _tuple, b, err; - if ((v.Kind() === 22) && v.IsNil()) { - e.Buffer.WriteString("null"); - return; - } - m = $assertType(v.Interface(), Marshaler); - _tuple = m.MarshalJSON(); b = _tuple[0]; err = _tuple[1]; - if ($interfaceIsEqual(err, $ifaceNil)) { - err = compact(e.Buffer, b, true); + importReader.prototype.nextByte = function(skipSpace) { return this.$val.nextByte(skipSpace); }; + importReader.Ptr.prototype.readKeyword = function(kw) { + var r, i; + r = this; + r.peekByte(true); + i = 0; + while (i < kw.length) { + if (!((r.nextByte(false) === kw.charCodeAt(i)))) { + r.syntaxError(); + return; + } + i = i + (1) >> 0; } - if (!($interfaceIsEqual(err, $ifaceNil))) { - e.error(new MarshalerError.Ptr(v.Type(), err)); + if (isIdent(r.peekByte(false))) { + r.syntaxError(); } }; - addrMarshalerEncoder = function(e, v, quoted) { - var va, m, _tuple, b, err; - va = new reflect.Value.Ptr(); $copy(va, v.Addr(), reflect.Value); - if (va.IsNil()) { - e.Buffer.WriteString("null"); + importReader.prototype.readKeyword = function(kw) { return this.$val.readKeyword(kw); }; + importReader.Ptr.prototype.readIdent = function() { + var r, c; + r = this; + c = r.peekByte(true); + if (!isIdent(c)) { + r.syntaxError(); return; } - m = $assertType(va.Interface(), Marshaler); - _tuple = m.MarshalJSON(); b = _tuple[0]; err = _tuple[1]; - if ($interfaceIsEqual(err, $ifaceNil)) { - err = compact(e.Buffer, b, true); + while (isIdent(r.peekByte(false))) { + r.peek = 0; } - if (!($interfaceIsEqual(err, $ifaceNil))) { - e.error(new MarshalerError.Ptr(v.Type(), err)); + }; + importReader.prototype.readIdent = function() { return this.$val.readIdent(); }; + importReader.Ptr.prototype.readString = function() { + var r, _ref, c; + r = this; + _ref = r.nextByte(true); + if (_ref === 96) { + while ($interfaceIsEqual(r.err, $ifaceNil)) { + if (r.nextByte(false) === 96) { + break; + } + if (r.eof) { + r.syntaxError(); + } + } + } else if (_ref === 34) { + while ($interfaceIsEqual(r.err, $ifaceNil)) { + c = r.nextByte(false); + if (c === 34) { + break; + } + if (r.eof || (c === 10)) { + r.syntaxError(); + } + if (c === 92) { + r.nextByte(false); + } + } + } else { + r.syntaxError(); } }; - textMarshalerEncoder = function(e, v, quoted) { - var m, _tuple, b, err, _tuple$1; - if ((v.Kind() === 22) && v.IsNil()) { - e.Buffer.WriteString("null"); - return; + importReader.prototype.readString = function() { return this.$val.readString(); }; + importReader.Ptr.prototype.readImport = function() { + var r, c; + r = this; + c = r.peekByte(true); + if (c === 46) { + r.peek = 0; + } else if (isIdent(c)) { + r.readIdent(); } - m = $assertType(v.Interface(), encoding.TextMarshaler); - _tuple = m.MarshalText(); b = _tuple[0]; err = _tuple[1]; - if ($interfaceIsEqual(err, $ifaceNil)) { - _tuple$1 = e.stringBytes(b); err = _tuple$1[1]; + r.readString(); + }; + importReader.prototype.readImport = function() { return this.$val.readImport(); }; + readComments = function(f) { + var r; + r = new importReader.Ptr(bufio.NewReader(f), ($sliceType($Uint8)).nil, 0, $ifaceNil, false, 0); + r.peekByte(true); + if ($interfaceIsEqual(r.err, $ifaceNil) && !r.eof) { + r.buf = $subslice(r.buf, 0, (r.buf.$length - 1 >> 0)); } - if (!($interfaceIsEqual(err, $ifaceNil))) { - e.error(new MarshalerError.Ptr(v.Type(), err)); + return [r.buf, r.err]; + }; + readImports = function(f, reportSyntaxError) { + var r; + r = new importReader.Ptr(bufio.NewReader(f), ($sliceType($Uint8)).nil, 0, $ifaceNil, false, 0); + r.readKeyword("package"); + r.readIdent(); + while (r.peekByte(true) === 105) { + r.readKeyword("import"); + if (r.peekByte(true) === 40) { + r.nextByte(false); + while (!((r.peekByte(true) === 41)) && $interfaceIsEqual(r.err, $ifaceNil)) { + r.readImport(); + } + r.nextByte(false); + } else { + r.readImport(); + } + } + if ($interfaceIsEqual(r.err, $ifaceNil) && !r.eof) { + return [$subslice(r.buf, 0, (r.buf.$length - 1 >> 0)), $ifaceNil]; + } + if ($interfaceIsEqual(r.err, errSyntax) && !reportSyntaxError) { + r.err = $ifaceNil; + while ($interfaceIsEqual(r.err, $ifaceNil) && !r.eof) { + r.readByte(); + } } + return [r.buf, r.err]; }; - addrTextMarshalerEncoder = function(e, v, quoted) { - var va, m, _tuple, b, err, _tuple$1; - va = new reflect.Value.Ptr(); $copy(va, v.Addr(), reflect.Value); - if (va.IsNil()) { - e.Buffer.WriteString("null"); - return; + $pkg.$init = function() { + ($ptrType(Context)).methods = [["Import", "Import", "", $funcType([$String, $String, ImportMode], [($ptrType(Package)), $error], false), -1], ["ImportDir", "ImportDir", "", $funcType([$String, ImportMode], [($ptrType(Package)), $error], false), -1], ["MatchFile", "MatchFile", "", $funcType([$String, $String], [$Bool, $error], false), -1], ["SrcDirs", "SrcDirs", "", $funcType([], [($sliceType($String))], false), -1], ["goodOSArchFile", "goodOSArchFile", "go/build", $funcType([$String, ($mapType($String, $Bool))], [$Bool], false), -1], ["gopath", "gopath", "go/build", $funcType([], [($sliceType($String))], false), -1], ["hasSubdir", "hasSubdir", "go/build", $funcType([$String, $String], [$String, $Bool], false), -1], ["isAbsPath", "isAbsPath", "go/build", $funcType([$String], [$Bool], false), -1], ["isDir", "isDir", "go/build", $funcType([$String], [$Bool], false), -1], ["isFile", "isFile", "go/build", $funcType([$String], [$Bool], false), -1], ["joinPath", "joinPath", "go/build", $funcType([($sliceType($String))], [$String], true), -1], ["match", "match", "go/build", $funcType([$String, ($mapType($String, $Bool))], [$Bool], false), -1], ["matchFile", "matchFile", "go/build", $funcType([$String, $String, $Bool, ($mapType($String, $Bool))], [$Bool, ($sliceType($Uint8)), $String, $error], false), -1], ["openFile", "openFile", "go/build", $funcType([$String], [io.ReadCloser, $error], false), -1], ["readDir", "readDir", "go/build", $funcType([$String], [($sliceType(os.FileInfo)), $error], false), -1], ["saveCgo", "saveCgo", "go/build", $funcType([$String, ($ptrType(Package)), ($ptrType(ast.CommentGroup))], [$error], false), -1], ["shouldBuild", "shouldBuild", "go/build", $funcType([($sliceType($Uint8)), ($mapType($String, $Bool))], [$Bool], false), -1], ["splitPathList", "splitPathList", "go/build", $funcType([$String], [($sliceType($String))], false), -1]]; + Context.init([["GOARCH", "GOARCH", "", $String, ""], ["GOOS", "GOOS", "", $String, ""], ["GOROOT", "GOROOT", "", $String, ""], ["GOPATH", "GOPATH", "", $String, ""], ["CgoEnabled", "CgoEnabled", "", $Bool, ""], ["UseAllFiles", "UseAllFiles", "", $Bool, ""], ["Compiler", "Compiler", "", $String, ""], ["BuildTags", "BuildTags", "", ($sliceType($String)), ""], ["ReleaseTags", "ReleaseTags", "", ($sliceType($String)), ""], ["InstallSuffix", "InstallSuffix", "", $String, ""], ["JoinPath", "JoinPath", "", ($funcType([($sliceType($String))], [$String], true)), ""], ["SplitPathList", "SplitPathList", "", ($funcType([$String], [($sliceType($String))], false)), ""], ["IsAbsPath", "IsAbsPath", "", ($funcType([$String], [$Bool], false)), ""], ["IsDir", "IsDir", "", ($funcType([$String], [$Bool], false)), ""], ["HasSubdir", "HasSubdir", "", ($funcType([$String, $String], [$String, $Bool], false)), ""], ["ReadDir", "ReadDir", "", ($funcType([$String], [($sliceType(os.FileInfo)), $error], false)), ""], ["OpenFile", "OpenFile", "", ($funcType([$String], [io.ReadCloser, $error], false)), ""]]); + ($ptrType(Package)).methods = [["IsCommand", "IsCommand", "", $funcType([], [$Bool], false), -1]]; + Package.init([["Dir", "Dir", "", $String, ""], ["Name", "Name", "", $String, ""], ["Doc", "Doc", "", $String, ""], ["ImportPath", "ImportPath", "", $String, ""], ["Root", "Root", "", $String, ""], ["SrcRoot", "SrcRoot", "", $String, ""], ["PkgRoot", "PkgRoot", "", $String, ""], ["BinDir", "BinDir", "", $String, ""], ["Goroot", "Goroot", "", $Bool, ""], ["PkgObj", "PkgObj", "", $String, ""], ["AllTags", "AllTags", "", ($sliceType($String)), ""], ["ConflictDir", "ConflictDir", "", $String, ""], ["GoFiles", "GoFiles", "", ($sliceType($String)), ""], ["CgoFiles", "CgoFiles", "", ($sliceType($String)), ""], ["IgnoredGoFiles", "IgnoredGoFiles", "", ($sliceType($String)), ""], ["CFiles", "CFiles", "", ($sliceType($String)), ""], ["CXXFiles", "CXXFiles", "", ($sliceType($String)), ""], ["MFiles", "MFiles", "", ($sliceType($String)), ""], ["HFiles", "HFiles", "", ($sliceType($String)), ""], ["SFiles", "SFiles", "", ($sliceType($String)), ""], ["SwigFiles", "SwigFiles", "", ($sliceType($String)), ""], ["SwigCXXFiles", "SwigCXXFiles", "", ($sliceType($String)), ""], ["SysoFiles", "SysoFiles", "", ($sliceType($String)), ""], ["CgoCFLAGS", "CgoCFLAGS", "", ($sliceType($String)), ""], ["CgoCPPFLAGS", "CgoCPPFLAGS", "", ($sliceType($String)), ""], ["CgoCXXFLAGS", "CgoCXXFLAGS", "", ($sliceType($String)), ""], ["CgoLDFLAGS", "CgoLDFLAGS", "", ($sliceType($String)), ""], ["CgoPkgConfig", "CgoPkgConfig", "", ($sliceType($String)), ""], ["Imports", "Imports", "", ($sliceType($String)), ""], ["ImportPos", "ImportPos", "", ($mapType($String, ($sliceType(token.Position)))), ""], ["TestGoFiles", "TestGoFiles", "", ($sliceType($String)), ""], ["TestImports", "TestImports", "", ($sliceType($String)), ""], ["TestImportPos", "TestImportPos", "", ($mapType($String, ($sliceType(token.Position)))), ""], ["XTestGoFiles", "XTestGoFiles", "", ($sliceType($String)), ""], ["XTestImports", "XTestImports", "", ($sliceType($String)), ""], ["XTestImportPos", "XTestImportPos", "", ($mapType($String, ($sliceType(token.Position)))), ""]]); + ($ptrType(NoGoError)).methods = [["Error", "Error", "", $funcType([], [$String], false), -1]]; + NoGoError.init([["Dir", "Dir", "", $String, ""]]); + ($ptrType(importReader)).methods = [["nextByte", "nextByte", "go/build", $funcType([$Bool], [$Uint8], false), -1], ["peekByte", "peekByte", "go/build", $funcType([$Bool], [$Uint8], false), -1], ["readByte", "readByte", "go/build", $funcType([], [$Uint8], false), -1], ["readIdent", "readIdent", "go/build", $funcType([], [], false), -1], ["readImport", "readImport", "go/build", $funcType([], [], false), -1], ["readKeyword", "readKeyword", "go/build", $funcType([$String], [], false), -1], ["readString", "readString", "go/build", $funcType([], [], false), -1], ["syntaxError", "syntaxError", "go/build", $funcType([], [], false), -1]]; + importReader.init([["b", "b", "go/build", ($ptrType(bufio.Reader)), ""], ["buf", "buf", "go/build", ($sliceType($Uint8)), ""], ["peek", "peek", "go/build", $Uint8, ""], ["err", "err", "go/build", $error, ""], ["eof", "eof", "go/build", $Bool, ""], ["nerr", "nerr", "go/build", $Int, ""]]); + cgoEnabled = (_map = new $Map(), _key = "darwin/386", _map[_key] = { k: _key, v: true }, _key = "darwin/amd64", _map[_key] = { k: _key, v: true }, _key = "dragonfly/386", _map[_key] = { k: _key, v: true }, _key = "dragonfly/amd64", _map[_key] = { k: _key, v: true }, _key = "freebsd/386", _map[_key] = { k: _key, v: true }, _key = "freebsd/amd64", _map[_key] = { k: _key, v: true }, _key = "freebsd/arm", _map[_key] = { k: _key, v: true }, _key = "linux/386", _map[_key] = { k: _key, v: true }, _key = "linux/amd64", _map[_key] = { k: _key, v: true }, _key = "linux/arm", _map[_key] = { k: _key, v: true }, _key = "netbsd/386", _map[_key] = { k: _key, v: true }, _key = "netbsd/amd64", _map[_key] = { k: _key, v: true }, _key = "netbsd/arm", _map[_key] = { k: _key, v: true }, _key = "openbsd/386", _map[_key] = { k: _key, v: true }, _key = "openbsd/amd64", _map[_key] = { k: _key, v: true }, _key = "windows/386", _map[_key] = { k: _key, v: true }, _key = "windows/amd64", _map[_key] = { k: _key, v: true }, _map); + $pkg.Default = new Context.Ptr(); $copy($pkg.Default, defaultContext(), Context); + slashslash = new ($sliceType($Uint8))($stringToBytes("//")); + safeBytes = new ($sliceType($Uint8))($stringToBytes("+-.,/0123456789=ABCDEFGHIJKLMNOPQRSTUVWXYZ_abcdefghijklmnopqrstuvwxyz:$")); + knownOS = new $Map(); + knownArch = new $Map(); + $pkg.ToolDir = filepath.Join(new ($sliceType($String))([runtime.GOROOT(), "pkg/tool/linux_js"])); + errSyntax = errors.New("syntax error"); + errNUL = errors.New("unexpected NUL in input"); + init(); + }; + return $pkg; +})(); +$packages["text/scanner"] = (function() { + var $pkg = {}, bytes = $packages["bytes"], fmt = $packages["fmt"], io = $packages["io"], os = $packages["os"], unicode = $packages["unicode"], utf8 = $packages["unicode/utf8"], Position, Scanner, tokenString, _map, _key, TokenString, digitVal, isDecimal; + Position = $pkg.Position = $newType(0, "Struct", "scanner.Position", "Position", "text/scanner", function(Filename_, Offset_, Line_, Column_) { + this.$val = this; + this.Filename = Filename_ !== undefined ? Filename_ : ""; + this.Offset = Offset_ !== undefined ? Offset_ : 0; + this.Line = Line_ !== undefined ? Line_ : 0; + this.Column = Column_ !== undefined ? Column_ : 0; + }); + Scanner = $pkg.Scanner = $newType(0, "Struct", "scanner.Scanner", "Scanner", "text/scanner", function(src_, srcBuf_, srcPos_, srcEnd_, srcBufOffset_, line_, column_, lastLineLen_, lastCharLen_, tokBuf_, tokPos_, tokEnd_, ch_, Error_, ErrorCount_, Mode_, Whitespace_, Position_) { + this.$val = this; + this.src = src_ !== undefined ? src_ : $ifaceNil; + this.srcBuf = srcBuf_ !== undefined ? srcBuf_ : ($arrayType($Uint8, 1025)).zero(); + this.srcPos = srcPos_ !== undefined ? srcPos_ : 0; + this.srcEnd = srcEnd_ !== undefined ? srcEnd_ : 0; + this.srcBufOffset = srcBufOffset_ !== undefined ? srcBufOffset_ : 0; + this.line = line_ !== undefined ? line_ : 0; + this.column = column_ !== undefined ? column_ : 0; + this.lastLineLen = lastLineLen_ !== undefined ? lastLineLen_ : 0; + this.lastCharLen = lastCharLen_ !== undefined ? lastCharLen_ : 0; + this.tokBuf = tokBuf_ !== undefined ? tokBuf_ : new bytes.Buffer.Ptr(); + this.tokPos = tokPos_ !== undefined ? tokPos_ : 0; + this.tokEnd = tokEnd_ !== undefined ? tokEnd_ : 0; + this.ch = ch_ !== undefined ? ch_ : 0; + this.Error = Error_ !== undefined ? Error_ : $throwNilPointerError; + this.ErrorCount = ErrorCount_ !== undefined ? ErrorCount_ : 0; + this.Mode = Mode_ !== undefined ? Mode_ : 0; + this.Whitespace = Whitespace_ !== undefined ? Whitespace_ : new $Uint64(0, 0); + this.Position = Position_ !== undefined ? Position_ : new Position.Ptr(); + }); + Position.Ptr.prototype.IsValid = function() { + var pos; + pos = this; + return pos.Line > 0; + }; + Position.prototype.IsValid = function() { return this.$val.IsValid(); }; + Position.Ptr.prototype.String = function() { + var pos, s; + pos = new Position.Ptr(); $copy(pos, this, Position); + s = pos.Filename; + if (pos.IsValid()) { + if (!(s === "")) { + s = s + (":"); + } + s = s + (fmt.Sprintf("%d:%d", new ($sliceType($emptyInterface))([new $Int(pos.Line), new $Int(pos.Column)]))); } - m = $assertType(va.Interface(), encoding.TextMarshaler); - _tuple = m.MarshalText(); b = _tuple[0]; err = _tuple[1]; - if ($interfaceIsEqual(err, $ifaceNil)) { - _tuple$1 = e.stringBytes(b); err = _tuple$1[1]; + if (s === "") { + s = "???"; } - if (!($interfaceIsEqual(err, $ifaceNil))) { - e.error(new MarshalerError.Ptr(v.Type(), err)); + return s; + }; + Position.prototype.String = function() { return this.$val.String(); }; + TokenString = $pkg.TokenString = function(tok) { + var _tuple, _entry, s, found; + _tuple = (_entry = tokenString[tok], _entry !== undefined ? [_entry.v, true] : ["", false]); s = _tuple[0]; found = _tuple[1]; + if (found) { + return s; } + return fmt.Sprintf("%q", new ($sliceType($emptyInterface))([new $String($encodeRune(tok))])); }; - boolEncoder = function(e, v, quoted) { - if (quoted) { - e.Buffer.WriteByte(34); + Scanner.Ptr.prototype.Init = function(src) { + var s; + s = this; + s.src = src; + s.srcBuf[0] = 128; + s.srcPos = 0; + s.srcEnd = 0; + s.srcBufOffset = 0; + s.line = 1; + s.column = 0; + s.lastLineLen = 0; + s.lastCharLen = 0; + s.tokPos = -1; + s.ch = -1; + s.Error = $throwNilPointerError; + s.ErrorCount = 0; + s.Mode = 1012; + s.Whitespace = new $Uint64(1, 9728); + s.Position.Line = 0; + return s; + }; + Scanner.prototype.Init = function(src) { return this.$val.Init(src); }; + Scanner.Ptr.prototype.next = function() { + var s, _tmp, x, x$1, _tmp$1, ch, width, i, _tuple, n, err, x$2, x$3, x$4, x$5, _tuple$1, _ref; + s = this; + _tmp = ((x = s.srcBuf, x$1 = s.srcPos, ((x$1 < 0 || x$1 >= x.length) ? $throwRuntimeError("index out of range") : x[x$1])) >> 0); _tmp$1 = 1; ch = _tmp; width = _tmp$1; + if (ch >= 128) { + while ((s.srcPos + 4 >> 0) > s.srcEnd && !utf8.FullRune($subslice(new ($sliceType($Uint8))(s.srcBuf), s.srcPos, s.srcEnd))) { + if (s.tokPos >= 0) { + s.tokBuf.Write($subslice(new ($sliceType($Uint8))(s.srcBuf), s.tokPos, s.srcPos)); + s.tokPos = 0; + } + $copySlice($subslice(new ($sliceType($Uint8))(s.srcBuf), 0), $subslice(new ($sliceType($Uint8))(s.srcBuf), s.srcPos, s.srcEnd)); + s.srcBufOffset = s.srcBufOffset + (s.srcPos) >> 0; + i = s.srcEnd - s.srcPos >> 0; + _tuple = s.src.Read($subslice(new ($sliceType($Uint8))(s.srcBuf), i, 1024)); n = _tuple[0]; err = _tuple[1]; + s.srcPos = 0; + s.srcEnd = i + n >> 0; + (x$2 = s.srcBuf, x$3 = s.srcEnd, (x$3 < 0 || x$3 >= x$2.length) ? $throwRuntimeError("index out of range") : x$2[x$3] = 128); + if (!($interfaceIsEqual(err, $ifaceNil))) { + if (!($interfaceIsEqual(err, io.EOF))) { + s.error(err.Error()); + } + if (s.srcEnd === 0) { + if (s.lastCharLen > 0) { + s.column = s.column + (1) >> 0; + } + s.lastCharLen = 0; + return -1; + } + break; + } + } + ch = ((x$4 = s.srcBuf, x$5 = s.srcPos, ((x$5 < 0 || x$5 >= x$4.length) ? $throwRuntimeError("index out of range") : x$4[x$5])) >> 0); + if (ch >= 128) { + _tuple$1 = utf8.DecodeRune($subslice(new ($sliceType($Uint8))(s.srcBuf), s.srcPos, s.srcEnd)); ch = _tuple$1[0]; width = _tuple$1[1]; + if ((ch === 65533) && (width === 1)) { + s.srcPos = s.srcPos + (width) >> 0; + s.lastCharLen = width; + s.column = s.column + (1) >> 0; + s.error("illegal UTF-8 encoding"); + return ch; + } + } } - if (v.Bool()) { - e.Buffer.WriteString("true"); - } else { - e.Buffer.WriteString("false"); + s.srcPos = s.srcPos + (width) >> 0; + s.lastCharLen = width; + s.column = s.column + (1) >> 0; + _ref = ch; + if (_ref === 0) { + s.error("illegal character NUL"); + } else if (_ref === 10) { + s.line = s.line + (1) >> 0; + s.lastLineLen = s.column; + s.column = 0; } - if (quoted) { - e.Buffer.WriteByte(34); + return ch; + }; + Scanner.prototype.next = function() { return this.$val.next(); }; + Scanner.Ptr.prototype.Next = function() { + var s, ch; + s = this; + s.tokPos = -1; + s.Position.Line = 0; + ch = s.Peek(); + s.ch = s.next(); + return ch; + }; + Scanner.prototype.Next = function() { return this.$val.Next(); }; + Scanner.Ptr.prototype.Peek = function() { + var s; + s = this; + if (s.ch < 0) { + s.ch = s.next(); + if (s.ch === 65279) { + s.ch = s.next(); + } } + return s.ch; }; - intEncoder = function(e, v, quoted) { - var b; - b = strconv.AppendInt($subslice(new ($sliceType($Uint8))(e.scratch), 0, 0), v.Int(), 10); - if (quoted) { - e.Buffer.WriteByte(34); + Scanner.prototype.Peek = function() { return this.$val.Peek(); }; + Scanner.Ptr.prototype.error = function(msg) { + var s, pos; + s = this; + s.ErrorCount = s.ErrorCount + (1) >> 0; + if (!(s.Error === $throwNilPointerError)) { + s.Error(s, msg); + return; } - e.Buffer.Write(b); - if (quoted) { - e.Buffer.WriteByte(34); + pos = new Position.Ptr(); $copy(pos, s.Position, Position); + if (!pos.IsValid()) { + $copy(pos, s.Pos(), Position); } + fmt.Fprintf(os.Stderr, "%s: %s\n", new ($sliceType($emptyInterface))([new pos.constructor.Struct(pos), new $String(msg)])); }; - uintEncoder = function(e, v, quoted) { - var b; - b = strconv.AppendUint($subslice(new ($sliceType($Uint8))(e.scratch), 0, 0), v.Uint(), 10); - if (quoted) { - e.Buffer.WriteByte(34); + Scanner.prototype.error = function(msg) { return this.$val.error(msg); }; + Scanner.Ptr.prototype.scanIdentifier = function() { + var s, ch; + s = this; + ch = s.next(); + while ((ch === 95) || unicode.IsLetter(ch) || unicode.IsDigit(ch)) { + ch = s.next(); } - e.Buffer.Write(b); - if (quoted) { - e.Buffer.WriteByte(34); + return ch; + }; + Scanner.prototype.scanIdentifier = function() { return this.$val.scanIdentifier(); }; + digitVal = function(ch) { + if (48 <= ch && ch <= 57) { + return ((ch - 48 >> 0) >> 0); + } else if (97 <= ch && ch <= 102) { + return (((ch - 97 >> 0) + 10 >> 0) >> 0); + } else if (65 <= ch && ch <= 70) { + return (((ch - 65 >> 0) + 10 >> 0) >> 0); } + return 16; }; - floatEncoder.prototype.encode = function(e, v, quoted) { - var bits, f, b; - bits = this.$val !== undefined ? this.$val : this; - f = v.Float(); - if (math.IsInf(f, 0) || math.IsNaN(f)) { - e.error(new UnsupportedValueError.Ptr(v, strconv.FormatFloat(f, 103, -1, (bits >> 0)))); - } - b = strconv.AppendFloat($subslice(new ($sliceType($Uint8))(e.scratch), 0, 0), f, 103, -1, (bits >> 0)); - if (quoted) { - e.Buffer.WriteByte(34); + isDecimal = function(ch) { + return 48 <= ch && ch <= 57; + }; + Scanner.Ptr.prototype.scanMantissa = function(ch) { + var s; + s = this; + while (isDecimal(ch)) { + ch = s.next(); } - e.Buffer.Write(b); - if (quoted) { - e.Buffer.WriteByte(34); + return ch; + }; + Scanner.prototype.scanMantissa = function(ch) { return this.$val.scanMantissa(ch); }; + Scanner.Ptr.prototype.scanFraction = function(ch) { + var s; + s = this; + if (ch === 46) { + ch = s.scanMantissa(s.next()); } + return ch; }; - $ptrType(floatEncoder).prototype.encode = function(e, v, quoted) { return new floatEncoder(this.$get()).encode(e, v, quoted); }; - stringEncoder = function(e, v, quoted) { - var numStr, _tuple, sb, err; - if ($interfaceIsEqual(v.Type(), numberType)) { - numStr = v.String(); - if (numStr === "") { - numStr = "0"; + Scanner.prototype.scanFraction = function(ch) { return this.$val.scanFraction(ch); }; + Scanner.Ptr.prototype.scanExponent = function(ch) { + var s; + s = this; + if ((ch === 101) || (ch === 69)) { + ch = s.next(); + if ((ch === 45) || (ch === 43)) { + ch = s.next(); } - e.Buffer.WriteString(numStr); - return; + ch = s.scanMantissa(ch); } - if (quoted) { - _tuple = Marshal(new $String(v.String())); sb = _tuple[0]; err = _tuple[1]; - if (!($interfaceIsEqual(err, $ifaceNil))) { - e.error(err); + return ch; + }; + Scanner.prototype.scanExponent = function(ch) { return this.$val.scanExponent(ch); }; + Scanner.Ptr.prototype.scanNumber = function(ch) { + var s, hasMantissa, has8or9; + s = this; + if (ch === 48) { + ch = s.next(); + if ((ch === 120) || (ch === 88)) { + ch = s.next(); + hasMantissa = false; + while (digitVal(ch) < 16) { + ch = s.next(); + hasMantissa = true; + } + if (!hasMantissa) { + s.error("illegal hexadecimal number"); + } + } else { + has8or9 = false; + while (isDecimal(ch)) { + if (ch > 55) { + has8or9 = true; + } + ch = s.next(); + } + if (!((((s.Mode & 16) >>> 0) === 0)) && ((ch === 46) || (ch === 101) || (ch === 69))) { + ch = s.scanFraction(ch); + ch = s.scanExponent(ch); + return [-4, ch]; + } + if (has8or9) { + s.error("illegal octal number"); + } } - e.string($bytesToString(sb)); - } else { - e.string(v.String()); + return [-3, ch]; + } + ch = s.scanMantissa(ch); + if (!((((s.Mode & 16) >>> 0) === 0)) && ((ch === 46) || (ch === 101) || (ch === 69))) { + ch = s.scanFraction(ch); + ch = s.scanExponent(ch); + return [-4, ch]; } + return [-3, ch]; }; - interfaceEncoder = function(e, v, quoted) { - if (v.IsNil()) { - e.Buffer.WriteString("null"); - return; + Scanner.prototype.scanNumber = function(ch) { return this.$val.scanNumber(ch); }; + Scanner.Ptr.prototype.scanDigits = function(ch, base, n) { + var s; + s = this; + while (n > 0 && digitVal(ch) < base) { + ch = s.next(); + n = n - (1) >> 0; } - e.reflectValue($clone(v.Elem(), reflect.Value)); + if (n > 0) { + s.error("illegal char escape"); + } + return ch; }; - unsupportedTypeEncoder = function(e, v, quoted) { - e.error(new UnsupportedTypeError.Ptr(v.Type())); + Scanner.prototype.scanDigits = function(ch, base, n) { return this.$val.scanDigits(ch, base, n); }; + Scanner.Ptr.prototype.scanEscape = function(quote) { + var s, ch, _ref; + s = this; + ch = s.next(); + _ref = ch; + if (_ref === 97 || _ref === 98 || _ref === 102 || _ref === 110 || _ref === 114 || _ref === 116 || _ref === 118 || _ref === 92 || _ref === quote) { + ch = s.next(); + } else if (_ref === 48 || _ref === 49 || _ref === 50 || _ref === 51 || _ref === 52 || _ref === 53 || _ref === 54 || _ref === 55) { + ch = s.scanDigits(ch, 8, 3); + } else if (_ref === 120) { + ch = s.scanDigits(s.next(), 16, 2); + } else if (_ref === 117) { + ch = s.scanDigits(s.next(), 16, 4); + } else if (_ref === 85) { + ch = s.scanDigits(s.next(), 16, 8); + } else { + s.error("illegal char escape"); + } + return ch; }; - structEncoder.Ptr.prototype.encode = function(e, v, quoted) { - var se, first, _ref, _i, i, f, fv, x; - se = this; - e.Buffer.WriteByte(123); - first = true; - _ref = se.fields; - _i = 0; - while (_i < _ref.$length) { - i = _i; - f = new field.Ptr(); $copy(f, ((_i < 0 || _i >= _ref.$length) ? $throwRuntimeError("index out of range") : _ref.$array[_ref.$offset + _i]), field); - fv = new reflect.Value.Ptr(); $copy(fv, fieldByIndex($clone(v, reflect.Value), f.index), reflect.Value); - if (!fv.IsValid() || f.omitEmpty && isEmptyValue($clone(fv, reflect.Value))) { - _i++; - continue; + Scanner.prototype.scanEscape = function(quote) { return this.$val.scanEscape(quote); }; + Scanner.Ptr.prototype.scanString = function(quote) { + var n = 0, s, ch; + s = this; + ch = s.next(); + while (!((ch === quote))) { + if ((ch === 10) || ch < 0) { + s.error("literal not terminated"); + return n; } - if (first) { - first = false; + if (ch === 92) { + ch = s.scanEscape(quote); } else { - e.Buffer.WriteByte(44); + ch = s.next(); } - e.string(f.name); - e.Buffer.WriteByte(58); - (x = se.fieldEncs, ((i < 0 || i >= x.$length) ? $throwRuntimeError("index out of range") : x.$array[x.$offset + i]))(e, $clone(fv, reflect.Value), f.quoted); - _i++; + n = n + (1) >> 0; } - e.Buffer.WriteByte(125); + return n; }; - structEncoder.prototype.encode = function(e, v, quoted) { return this.$val.encode(e, v, quoted); }; - newStructEncoder = function(t) { - var fields, se, _ref, _i, i, f, x; - fields = cachedTypeFields(t); - se = new structEncoder.Ptr(fields, ($sliceType(encoderFunc)).make(fields.$length)); - _ref = fields; - _i = 0; - while (_i < _ref.$length) { - i = _i; - f = new field.Ptr(); $copy(f, ((_i < 0 || _i >= _ref.$length) ? $throwRuntimeError("index out of range") : _ref.$array[_ref.$offset + _i]), field); - (x = se.fieldEncs, (i < 0 || i >= x.$length) ? $throwRuntimeError("index out of range") : x.$array[x.$offset + i] = typeEncoder(typeByIndex(t, f.index))); - _i++; + Scanner.prototype.scanString = function(quote) { return this.$val.scanString(quote); }; + Scanner.Ptr.prototype.scanRawString = function() { + var s, ch; + s = this; + ch = s.next(); + while (!((ch === 96))) { + if (ch < 0) { + s.error("literal not terminated"); + return; + } + ch = s.next(); } - return $methodVal(se, "encode"); }; - mapEncoder.Ptr.prototype.encode = function(e, v, param) { - var me, x, sv, _ref, _i, i, k; - me = this; - if (v.IsNil()) { - e.Buffer.WriteString("null"); - return; + Scanner.prototype.scanRawString = function() { return this.$val.scanRawString(); }; + Scanner.Ptr.prototype.scanChar = function() { + var s; + s = this; + if (!((s.scanString(39) === 1))) { + s.error("illegal char literal"); } - e.Buffer.WriteByte(123); - sv = (x = v.MapKeys(), $subslice(new stringValues(x.$array), x.$offset, x.$offset + x.$length)); - sort.Sort(sv); - _ref = sv; - _i = 0; - while (_i < _ref.$length) { - i = _i; - k = new reflect.Value.Ptr(); $copy(k, ((_i < 0 || _i >= _ref.$length) ? $throwRuntimeError("index out of range") : _ref.$array[_ref.$offset + _i]), reflect.Value); - if (i > 0) { - e.Buffer.WriteByte(44); + }; + Scanner.prototype.scanChar = function() { return this.$val.scanChar(); }; + Scanner.Ptr.prototype.scanComment = function(ch) { + var s, ch0; + s = this; + if (ch === 47) { + ch = s.next(); + while (!((ch === 10)) && ch >= 0) { + ch = s.next(); } - e.string(k.String()); - e.Buffer.WriteByte(58); - me.elemEnc(e, $clone(v.MapIndex($clone(k, reflect.Value)), reflect.Value), false); - _i++; + return ch; } - e.Buffer.WriteByte(125); - }; - mapEncoder.prototype.encode = function(e, v, param) { return this.$val.encode(e, v, param); }; - newMapEncoder = function(t) { - var me; - if (!((t.Key().Kind() === 24))) { - return unsupportedTypeEncoder; + ch = s.next(); + while (true) { + if (ch < 0) { + s.error("comment not terminated"); + break; + } + ch0 = ch; + ch = s.next(); + if ((ch0 === 42) && (ch === 47)) { + ch = s.next(); + break; + } } - me = new mapEncoder.Ptr(typeEncoder(t.Elem())); - return $methodVal(me, "encode"); + return ch; }; - encodeByteSlice = function(e, v, param) { - var s, dst, enc; - if (v.IsNil()) { - e.Buffer.WriteString("null"); - return; - } - s = v.Bytes(); - e.Buffer.WriteByte(34); - if (s.$length < 1024) { - dst = ($sliceType($Uint8)).make(base64.StdEncoding.EncodedLen(s.$length)); - base64.StdEncoding.Encode(dst, s); - e.Buffer.Write(dst); + Scanner.prototype.scanComment = function(ch) { return this.$val.scanComment(ch); }; + Scanner.Ptr.prototype.Scan = function() { + var $this = this, $args = arguments, $s = 0, s, ch, x, x$1, x$2, tok, _tuple, _ref; + /* */ while (true) { switch ($s) { case 0: + s = $this; + ch = s.Peek(); + s.tokPos = -1; + s.Position.Line = 0; + /* redo: */ case 1: + /* while (!((x = (x$1 = s.Whitespace, x$2 = $shiftLeft64(new $Uint64(0, 1), (ch >>> 0)), new $Uint64(x$1.$high & x$2.$high, (x$1.$low & x$2.$low) >>> 0)), (x.$high === 0 && x.$low === 0)))) { */ case 2: if(!(!((x = (x$1 = s.Whitespace, x$2 = $shiftLeft64(new $Uint64(0, 1), (ch >>> 0)), new $Uint64(x$1.$high & x$2.$high, (x$1.$low & x$2.$low) >>> 0)), (x.$high === 0 && x.$low === 0))))) { $s = 3; continue; } + ch = s.next(); + /* } */ $s = 2; continue; case 3: + s.tokBuf.Reset(); + s.tokPos = s.srcPos - s.lastCharLen >> 0; + s.Position.Offset = s.srcBufOffset + s.tokPos >> 0; + if (s.column > 0) { + s.Position.Line = s.line; + s.Position.Column = s.column; } else { - enc = base64.NewEncoder(base64.StdEncoding, e); - enc.Write(s); - enc.Close(); + s.Position.Line = s.line - 1 >> 0; + s.Position.Column = s.lastLineLen; } - e.Buffer.WriteByte(34); + tok = ch; + /* if (unicode.IsLetter(ch) || (ch === 95)) { */ if (unicode.IsLetter(ch) || (ch === 95)) {} else if (isDecimal(ch)) { $s = 4; continue; } else { $s = 5; continue; } + if (!((((s.Mode & 4) >>> 0) === 0))) { + tok = -2; + ch = s.scanIdentifier(); + } else { + ch = s.next(); + } + /* } else if (isDecimal(ch)) { */ $s = 6; continue; case 4: + if (!((((s.Mode & 24) >>> 0) === 0))) { + _tuple = s.scanNumber(ch); tok = _tuple[0]; ch = _tuple[1]; + } else { + ch = s.next(); + } + /* } else { */ $s = 6; continue; case 5: + _ref = ch; + /* if (_ref === 34) { */ if (_ref === 34) {} else if (_ref === 39) { $s = 7; continue; } else if (_ref === 46) { $s = 8; continue; } else if (_ref === 47) { $s = 9; continue; } else if (_ref === 96) { $s = 10; continue; } else { $s = 11; continue; } + if (!((((s.Mode & 64) >>> 0) === 0))) { + s.scanString(34); + tok = -6; + } + ch = s.next(); + /* } else if (_ref === 39) { */ $s = 12; continue; case 7: + if (!((((s.Mode & 32) >>> 0) === 0))) { + s.scanChar(); + tok = -5; + } + ch = s.next(); + /* } else if (_ref === 46) { */ $s = 12; continue; case 8: + ch = s.next(); + if (isDecimal(ch) && !((((s.Mode & 16) >>> 0) === 0))) { + tok = -4; + ch = s.scanMantissa(ch); + ch = s.scanExponent(ch); + } + /* } else if (_ref === 47) { */ $s = 12; continue; case 9: + ch = s.next(); + /* if (((ch === 47) || (ch === 42)) && !((((s.Mode & 256) >>> 0) === 0))) { */ if (((ch === 47) || (ch === 42)) && !((((s.Mode & 256) >>> 0) === 0))) {} else { $s = 13; continue; } + /* if (!((((s.Mode & 512) >>> 0) === 0))) { */ if (!((((s.Mode & 512) >>> 0) === 0))) {} else { $s = 14; continue; } + s.tokPos = -1; + ch = s.scanComment(ch); + /* goto redo */ $s = 1; continue; + /* } */ case 14: + ch = s.scanComment(ch); + tok = -8; + /* } */ case 13: + /* } else if (_ref === 96) { */ $s = 12; continue; case 10: + if (!((((s.Mode & 128) >>> 0) === 0))) { + s.scanRawString(); + tok = -6; + } + ch = s.next(); + /* } else { */ $s = 12; continue; case 11: + ch = s.next(); + /* } */ case 12: + /* } */ case 6: + s.tokEnd = s.srcPos - s.lastCharLen >> 0; + s.ch = ch; + return tok; + /* */ case -1: } return; } }; - sliceEncoder.Ptr.prototype.encode = function(e, v, param) { - var se; - se = this; - if (v.IsNil()) { - e.Buffer.WriteString("null"); - return; + Scanner.prototype.Scan = function() { return this.$val.Scan(); }; + Scanner.Ptr.prototype.Pos = function() { + var pos = new Position.Ptr(), s; + s = this; + pos.Filename = s.Position.Filename; + pos.Offset = (s.srcBufOffset + s.srcPos >> 0) - s.lastCharLen >> 0; + if (s.column > 0) { + pos.Line = s.line; + pos.Column = s.column; + } else if (s.lastLineLen > 0) { + pos.Line = s.line - 1 >> 0; + pos.Column = s.lastLineLen; + } else { + pos.Line = 1; + pos.Column = 1; } - se.arrayEnc(e, $clone(v, reflect.Value), false); + return pos; }; - sliceEncoder.prototype.encode = function(e, v, param) { return this.$val.encode(e, v, param); }; - newSliceEncoder = function(t) { - var enc; - if (t.Elem().Kind() === 8) { - return encodeByteSlice; + Scanner.prototype.Pos = function() { return this.$val.Pos(); }; + Scanner.Ptr.prototype.TokenText = function() { + var s; + s = this; + if (s.tokPos < 0) { + return ""; } - enc = new sliceEncoder.Ptr(newArrayEncoder(t)); - return $methodVal(enc, "encode"); - }; - arrayEncoder.Ptr.prototype.encode = function(e, v, param) { - var ae, n, i; - ae = this; - e.Buffer.WriteByte(91); - n = v.Len(); - i = 0; - while (i < n) { - if (i > 0) { - e.Buffer.WriteByte(44); - } - ae.elemEnc(e, $clone(v.Index(i), reflect.Value), false); - i = i + (1) >> 0; + if (s.tokEnd < 0) { + s.tokEnd = s.tokPos; } - e.Buffer.WriteByte(93); + if (s.tokBuf.Len() === 0) { + return $bytesToString($subslice(new ($sliceType($Uint8))(s.srcBuf), s.tokPos, s.tokEnd)); + } + s.tokBuf.Write($subslice(new ($sliceType($Uint8))(s.srcBuf), s.tokPos, s.tokEnd)); + s.tokPos = s.tokEnd; + return s.tokBuf.String(); }; - arrayEncoder.prototype.encode = function(e, v, param) { return this.$val.encode(e, v, param); }; - newArrayEncoder = function(t) { - var enc; - enc = new arrayEncoder.Ptr(typeEncoder(t.Elem())); - return $methodVal(enc, "encode"); + Scanner.prototype.TokenText = function() { return this.$val.TokenText(); }; + $pkg.$init = function() { + Position.methods = [["String", "String", "", $funcType([], [$String], false), -1]]; + ($ptrType(Position)).methods = [["IsValid", "IsValid", "", $funcType([], [$Bool], false), -1], ["String", "String", "", $funcType([], [$String], false), -1]]; + Position.init([["Filename", "Filename", "", $String, ""], ["Offset", "Offset", "", $Int, ""], ["Line", "Line", "", $Int, ""], ["Column", "Column", "", $Int, ""]]); + Scanner.methods = [["String", "String", "", $funcType([], [$String], false), 17]]; + ($ptrType(Scanner)).methods = [["Init", "Init", "", $funcType([io.Reader], [($ptrType(Scanner))], false), -1], ["IsValid", "IsValid", "", $funcType([], [$Bool], false), 17], ["Next", "Next", "", $funcType([], [$Int32], false), -1], ["Peek", "Peek", "", $funcType([], [$Int32], false), -1], ["Pos", "Pos", "", $funcType([], [Position], false), -1], ["Scan", "Scan", "", $funcType([], [$Int32], false), -1], ["String", "String", "", $funcType([], [$String], false), 17], ["TokenText", "TokenText", "", $funcType([], [$String], false), -1], ["error", "error", "text/scanner", $funcType([$String], [], false), -1], ["next", "next", "text/scanner", $funcType([], [$Int32], false), -1], ["scanChar", "scanChar", "text/scanner", $funcType([], [], false), -1], ["scanComment", "scanComment", "text/scanner", $funcType([$Int32], [$Int32], false), -1], ["scanDigits", "scanDigits", "text/scanner", $funcType([$Int32, $Int, $Int], [$Int32], false), -1], ["scanEscape", "scanEscape", "text/scanner", $funcType([$Int32], [$Int32], false), -1], ["scanExponent", "scanExponent", "text/scanner", $funcType([$Int32], [$Int32], false), -1], ["scanFraction", "scanFraction", "text/scanner", $funcType([$Int32], [$Int32], false), -1], ["scanIdentifier", "scanIdentifier", "text/scanner", $funcType([], [$Int32], false), -1], ["scanMantissa", "scanMantissa", "text/scanner", $funcType([$Int32], [$Int32], false), -1], ["scanNumber", "scanNumber", "text/scanner", $funcType([$Int32], [$Int32, $Int32], false), -1], ["scanRawString", "scanRawString", "text/scanner", $funcType([], [], false), -1], ["scanString", "scanString", "text/scanner", $funcType([$Int32], [$Int], false), -1]]; + Scanner.init([["src", "src", "text/scanner", io.Reader, ""], ["srcBuf", "srcBuf", "text/scanner", ($arrayType($Uint8, 1025)), ""], ["srcPos", "srcPos", "text/scanner", $Int, ""], ["srcEnd", "srcEnd", "text/scanner", $Int, ""], ["srcBufOffset", "srcBufOffset", "text/scanner", $Int, ""], ["line", "line", "text/scanner", $Int, ""], ["column", "column", "text/scanner", $Int, ""], ["lastLineLen", "lastLineLen", "text/scanner", $Int, ""], ["lastCharLen", "lastCharLen", "text/scanner", $Int, ""], ["tokBuf", "tokBuf", "text/scanner", bytes.Buffer, ""], ["tokPos", "tokPos", "text/scanner", $Int, ""], ["tokEnd", "tokEnd", "text/scanner", $Int, ""], ["ch", "ch", "text/scanner", $Int32, ""], ["Error", "Error", "", ($funcType([($ptrType(Scanner)), $String], [], false)), ""], ["ErrorCount", "ErrorCount", "", $Int, ""], ["Mode", "Mode", "", $Uint, ""], ["Whitespace", "Whitespace", "", $Uint64, ""], ["Position", "", "", Position, ""]]); + tokenString = (_map = new $Map(), _key = -1, _map[_key] = { k: _key, v: "EOF" }, _key = -2, _map[_key] = { k: _key, v: "Ident" }, _key = -3, _map[_key] = { k: _key, v: "Int" }, _key = -4, _map[_key] = { k: _key, v: "Float" }, _key = -5, _map[_key] = { k: _key, v: "Char" }, _key = -6, _map[_key] = { k: _key, v: "String" }, _key = -7, _map[_key] = { k: _key, v: "RawString" }, _key = -8, _map[_key] = { k: _key, v: "Comment" }, _map); }; - ptrEncoder.Ptr.prototype.encode = function(e, v, param) { - var pe; - pe = this; - if (v.IsNil()) { - e.Buffer.WriteString("null"); - return; + return $pkg; +})(); +$packages["code.google.com/p/go.tools/go/gcimporter"] = (function() { + var $pkg = {}, bufio = $packages["bufio"], errors = $packages["errors"], fmt = $packages["fmt"], io = $packages["io"], strconv = $packages["strconv"], strings = $packages["strings"], build = $packages["go/build"], token = $packages["go/token"], os = $packages["os"], filepath = $packages["path/filepath"], scanner = $packages["text/scanner"], exact = $packages["code.google.com/p/go.tools/go/exact"], types = $packages["code.google.com/p/go.tools/go/types"], parser, importError, pkgExts, readGopackHeader, FindExportData, init, FindPkg, ImportData, Import, declTypeName, deref; + parser = $pkg.parser = $newType(0, "Struct", "gcimporter.parser", "parser", "code.google.com/p/go.tools/go/gcimporter", function(scanner_, tok_, lit_, id_, imports_) { + this.$val = this; + this.scanner = scanner_ !== undefined ? scanner_ : new scanner.Scanner.Ptr(); + this.tok = tok_ !== undefined ? tok_ : 0; + this.lit = lit_ !== undefined ? lit_ : ""; + this.id = id_ !== undefined ? id_ : ""; + this.imports = imports_ !== undefined ? imports_ : false; + }); + importError = $pkg.importError = $newType(0, "Struct", "gcimporter.importError", "importError", "code.google.com/p/go.tools/go/gcimporter", function(pos_, err_) { + this.$val = this; + this.pos = pos_ !== undefined ? pos_ : new scanner.Position.Ptr(); + this.err = err_ !== undefined ? err_ : $ifaceNil; + }); + readGopackHeader = function(r) { + var name = "", size = 0, err = $ifaceNil, hdr, _tuple, s, _tuple$1, x, x$1; + hdr = ($sliceType($Uint8)).make(60); + _tuple = io.ReadFull(r, hdr); err = _tuple[1]; + if (!($interfaceIsEqual(err, $ifaceNil))) { + return [name, size, err]; } - pe.elemEnc(e, $clone(v.Elem(), reflect.Value), false); - }; - ptrEncoder.prototype.encode = function(e, v, param) { return this.$val.encode(e, v, param); }; - newPtrEncoder = function(t) { - var enc; - enc = new ptrEncoder.Ptr(typeEncoder(t.Elem())); - return $methodVal(enc, "encode"); + s = strings.TrimSpace($bytesToString($subslice($subslice(hdr, 48), 0, 10))); + _tuple$1 = strconv.Atoi(s); size = _tuple$1[0]; err = _tuple$1[1]; + if (!($interfaceIsEqual(err, $ifaceNil)) || !(((x = hdr.$length - 2 >> 0, ((x < 0 || x >= hdr.$length) ? $throwRuntimeError("index out of range") : hdr.$array[hdr.$offset + x])) === 96)) || !(((x$1 = hdr.$length - 1 >> 0, ((x$1 < 0 || x$1 >= hdr.$length) ? $throwRuntimeError("index out of range") : hdr.$array[hdr.$offset + x$1])) === 10))) { + err = errors.New("invalid archive header"); + return [name, size, err]; + } + name = strings.TrimSpace($bytesToString($subslice(hdr, 0, 16))); + return [name, size, err]; }; - condAddrEncoder.Ptr.prototype.encode = function(e, v, quoted) { - var ce; - ce = this; - if (v.CanAddr()) { - ce.canAddrEnc(e, $clone(v, reflect.Value), quoted); - } else { - ce.elseEnc(e, $clone(v, reflect.Value), quoted); + FindExportData = $pkg.FindExportData = function(r) { + var err = $ifaceNil, _tuple, line, name, size, _tuple$1, tmp, n, _tuple$2, _tuple$3, _tuple$4, _tuple$5; + _tuple = r.ReadSlice(10); line = _tuple[0]; err = _tuple[1]; + if (!($interfaceIsEqual(err, $ifaceNil))) { + return err; + } + if ($bytesToString(line) === "!\n") { + name = ""; + size = 0; + _tuple$1 = readGopackHeader(r); name = _tuple$1[0]; size = _tuple$1[1]; err = _tuple$1[2]; + if (!($interfaceIsEqual(err, $ifaceNil))) { + return err; + } + if (name === "__.SYMDEF" || name === "__.GOSYMDEF") { + tmp = ($sliceType($Uint8)).make(4096); + while (size > 0) { + n = size; + if (n > 4096) { + n = 4096; + } + _tuple$2 = io.ReadFull(r, $subslice(tmp, 0, n)); err = _tuple$2[1]; + if (!($interfaceIsEqual(err, $ifaceNil))) { + return err; + } + size = size - (n) >> 0; + } + _tuple$3 = readGopackHeader(r); name = _tuple$3[0]; size = _tuple$3[1]; err = _tuple$3[2]; + if (!($interfaceIsEqual(err, $ifaceNil))) { + return err; + } + } + if (!(name === "__.PKGDEF")) { + err = errors.New("go archive is missing __.PKGDEF"); + return err; + } + _tuple$4 = r.ReadSlice(10); line = _tuple$4[0]; err = _tuple$4[1]; + if (!($interfaceIsEqual(err, $ifaceNil))) { + return err; + } } - }; - condAddrEncoder.prototype.encode = function(e, v, quoted) { return this.$val.encode(e, v, quoted); }; - newCondAddrEncoder = function(canAddrEnc, elseEnc) { - var enc; - enc = new condAddrEncoder.Ptr(canAddrEnc, elseEnc); - return $methodVal(enc, "encode"); - }; - isValidTag = function(s) { - var _ref, _i, _rune, c; - if (s === "") { - return false; + if (!strings.HasPrefix($bytesToString(line), "go object ")) { + err = errors.New("not a go object file"); + return err; } - _ref = s; - _i = 0; - while (_i < _ref.length) { - _rune = $decodeRune(_ref, _i); - c = _rune[0]; - if (strings.ContainsRune("!#$%&()*+-./:<=>?@[]^_{|}~ ", c)) { - } else { - if (!unicode.IsLetter(c) && !unicode.IsDigit(c)) { - return false; - } + while (!((((0 < 0 || 0 >= line.$length) ? $throwRuntimeError("index out of range") : line.$array[line.$offset + 0]) === 36))) { + _tuple$5 = r.ReadSlice(10); line = _tuple$5[0]; err = _tuple$5[1]; + if (!($interfaceIsEqual(err, $ifaceNil))) { + return err; } - _i += _rune[1]; } - return true; + return err; }; - fieldByIndex = function(v, index) { - var _ref, _i, i; - _ref = index; - _i = 0; - while (_i < _ref.$length) { - i = ((_i < 0 || _i >= _ref.$length) ? $throwRuntimeError("index out of range") : _ref.$array[_ref.$offset + _i]); - if (v.Kind() === 22) { - if (v.IsNil()) { - return new reflect.Value.Ptr(($ptrType(reflect.rtype)).nil, 0, 0, 0); - } - $copy(v, v.Elem(), reflect.Value); + init = function() { + types.DefaultImport = Import; + }; + FindPkg = $pkg.FindPkg = function(path, srcDir) { + var filename = "", id = "", noext, _tuple, bp, _ref, _i, ext, _tuple$1, f, err; + if (path.length === 0) { + return [filename, id]; + } + id = path; + noext = ""; + if (build.IsLocalImport(path)) { + noext = filepath.Join(new ($sliceType($String))([srcDir, path])); + id = noext; + } else if (filepath.IsAbs(path)) { + noext = path; + } else { + _tuple = build.Import(path, srcDir, 3); bp = _tuple[0]; + if (bp.PkgObj === "") { + return [filename, id]; } - $copy(v, v.Field(i), reflect.Value); - _i++; + noext = strings.TrimSuffix(bp.PkgObj, ".a"); } - return v; - }; - typeByIndex = function(t, index) { - var _ref, _i, i; - _ref = index; + _ref = pkgExts; _i = 0; - while (_i < _ref.$length) { - i = ((_i < 0 || _i >= _ref.$length) ? $throwRuntimeError("index out of range") : _ref.$array[_ref.$offset + _i]); - if (t.Kind() === 22) { - t = t.Elem(); + while (_i < 4) { + ext = ((_i < 0 || _i >= _ref.length) ? $throwRuntimeError("index out of range") : _ref[_i]); + filename = noext + ext; + _tuple$1 = os.Stat(filename); f = _tuple$1[0]; err = _tuple$1[1]; + if ($interfaceIsEqual(err, $ifaceNil) && !f.IsDir()) { + return [filename, id]; } - t = t.Field(i).Type; _i++; } - return t; - }; - stringValues.prototype.Len = function() { - var sv; - sv = this; - return sv.$length; - }; - $ptrType(stringValues).prototype.Len = function() { return this.$get().Len(); }; - stringValues.prototype.Swap = function(i, j) { - var sv, _tmp, _tmp$1; - sv = this; - _tmp = new reflect.Value.Ptr(); $copy(_tmp, ((j < 0 || j >= sv.$length) ? $throwRuntimeError("index out of range") : sv.$array[sv.$offset + j]), reflect.Value); _tmp$1 = new reflect.Value.Ptr(); $copy(_tmp$1, ((i < 0 || i >= sv.$length) ? $throwRuntimeError("index out of range") : sv.$array[sv.$offset + i]), reflect.Value); $copy(((i < 0 || i >= sv.$length) ? $throwRuntimeError("index out of range") : sv.$array[sv.$offset + i]), _tmp, reflect.Value); $copy(((j < 0 || j >= sv.$length) ? $throwRuntimeError("index out of range") : sv.$array[sv.$offset + j]), _tmp$1, reflect.Value); - }; - $ptrType(stringValues).prototype.Swap = function(i, j) { return this.$get().Swap(i, j); }; - stringValues.prototype.Less = function(i, j) { - var sv; - sv = this; - return sv.get(i) < sv.get(j); - }; - $ptrType(stringValues).prototype.Less = function(i, j) { return this.$get().Less(i, j); }; - stringValues.prototype.get = function(i) { - var sv; - sv = this; - return ((i < 0 || i >= sv.$length) ? $throwRuntimeError("index out of range") : sv.$array[sv.$offset + i]).String(); + filename = ""; + return [filename, id]; }; - $ptrType(stringValues).prototype.get = function(i) { return this.$get().get(i); }; - encodeState.Ptr.prototype.string = function(s) { - var e, len0, start, i, b, _ref, _tuple, c, size; - e = this; - len0 = e.Buffer.Len(); - e.Buffer.WriteByte(34); - start = 0; - i = 0; - while (i < s.length) { - b = s.charCodeAt(i); - if (b < 128) { - if (32 <= b && !((b === 92)) && !((b === 34)) && !((b === 60)) && !((b === 62)) && !((b === 38))) { - i = i + (1) >> 0; - continue; - } - if (start < i) { - e.Buffer.WriteString(s.substring(start, i)); - } - _ref = b; - if (_ref === 92 || _ref === 34) { - e.Buffer.WriteByte(92); - e.Buffer.WriteByte(b); - } else if (_ref === 10) { - e.Buffer.WriteByte(92); - e.Buffer.WriteByte(110); - } else if (_ref === 13) { - e.Buffer.WriteByte(92); - e.Buffer.WriteByte(114); - } else { - e.Buffer.WriteString("\\u00"); - e.Buffer.WriteByte(hex.charCodeAt((b >>> 4 << 24 >>> 24))); - e.Buffer.WriteByte(hex.charCodeAt(((b & 15) >>> 0))); - } - i = i + (1) >> 0; - start = i; - continue; - } - _tuple = utf8.DecodeRuneInString(s.substring(i)); c = _tuple[0]; size = _tuple[1]; - if ((c === 65533) && (size === 1)) { - if (start < i) { - e.Buffer.WriteString(s.substring(start, i)); - } - e.Buffer.WriteString("\\ufffd"); - i = i + (size) >> 0; - start = i; - continue; + ImportData = $pkg.ImportData = function(imports, filename, id, data) { + var pkg = ($ptrType(types.Package)).nil, err = $ifaceNil, $deferred = [], $err = null, p; + /* */ try { $deferFrames.push($deferred); + $deferred.push([(function() { + var r, _ref; + _ref = $recover(); + if (_ref === $ifaceNil) { + r = _ref; + } else if ($assertType(_ref, importError, true)[1]) { + r = _ref.$val; + err = new r.constructor.Struct(r); + } else { + r = _ref; + $panic(r); } - if ((c === 8232) || (c === 8233)) { - if (start < i) { - e.Buffer.WriteString(s.substring(start, i)); - } - e.Buffer.WriteString("\\u202"); - e.Buffer.WriteByte(hex.charCodeAt((c & 15))); - i = i + (size) >> 0; - start = i; - continue; + }), []]); + p = new parser.Ptr(); $copy(p, new parser.Ptr(), parser); + p.init(filename, id, data, imports); + pkg = p.parseExport(); + return [pkg, err]; + /* */ } catch(err) { $err = err; } finally { $deferFrames.pop(); $callDeferred($deferred, $err); return [pkg, err]; } + }; + Import = $pkg.Import = function(imports, path) { + var pkg = ($ptrType(types.Package)).nil, err = $ifaceNil, $deferred = [], $err = null, _tmp, _tmp$1, srcDir, _tuple, _tuple$1, filename, id, _entry, _tuple$2, f, buf, _tuple$3; + /* */ try { $deferFrames.push($deferred); + if (path === "unsafe") { + _tmp = types.Unsafe; _tmp$1 = $ifaceNil; pkg = _tmp; err = _tmp$1; + return [pkg, err]; + } + srcDir = "."; + if (build.IsLocalImport(path)) { + _tuple = os.Getwd(); srcDir = _tuple[0]; err = _tuple[1]; + if (!($interfaceIsEqual(err, $ifaceNil))) { + return [pkg, err]; } - i = i + (size) >> 0; } - if (start < s.length) { - e.Buffer.WriteString(s.substring(start)); + _tuple$1 = FindPkg(path, srcDir); filename = _tuple$1[0]; id = _tuple$1[1]; + if (filename === "") { + err = fmt.Errorf("can't find import: %s", new ($sliceType($emptyInterface))([new $String(id)])); + return [pkg, err]; } - e.Buffer.WriteByte(34); - return [e.Buffer.Len() - len0 >> 0, $ifaceNil]; - }; - encodeState.prototype.string = function(s) { return this.$val.string(s); }; - encodeState.Ptr.prototype.stringBytes = function(s) { - var e, len0, start, i, b, _ref, _tuple, c, size; - e = this; - len0 = e.Buffer.Len(); - e.Buffer.WriteByte(34); - start = 0; - i = 0; - while (i < s.$length) { - b = ((i < 0 || i >= s.$length) ? $throwRuntimeError("index out of range") : s.$array[s.$offset + i]); - if (b < 128) { - if (32 <= b && !((b === 92)) && !((b === 34)) && !((b === 60)) && !((b === 62)) && !((b === 38))) { - i = i + (1) >> 0; - continue; - } - if (start < i) { - e.Buffer.Write($subslice(s, start, i)); - } - _ref = b; - if (_ref === 92 || _ref === 34) { - e.Buffer.WriteByte(92); - e.Buffer.WriteByte(b); - } else if (_ref === 10) { - e.Buffer.WriteByte(92); - e.Buffer.WriteByte(110); - } else if (_ref === 13) { - e.Buffer.WriteByte(92); - e.Buffer.WriteByte(114); - } else { - e.Buffer.WriteString("\\u00"); - e.Buffer.WriteByte(hex.charCodeAt((b >>> 4 << 24 >>> 24))); - e.Buffer.WriteByte(hex.charCodeAt(((b & 15) >>> 0))); - } - i = i + (1) >> 0; - start = i; - continue; - } - _tuple = utf8.DecodeRune($subslice(s, i)); c = _tuple[0]; size = _tuple[1]; - if ((c === 65533) && (size === 1)) { - if (start < i) { - e.Buffer.Write($subslice(s, start, i)); - } - e.Buffer.WriteString("\\ufffd"); - i = i + (size) >> 0; - start = i; - continue; - } - if ((c === 8232) || (c === 8233)) { - if (start < i) { - e.Buffer.Write($subslice(s, start, i)); - } - e.Buffer.WriteString("\\u202"); - e.Buffer.WriteByte(hex.charCodeAt((c & 15))); - i = i + (size) >> 0; - start = i; - continue; - } - i = i + (size) >> 0; + pkg = (_entry = imports[id], _entry !== undefined ? _entry.v : ($ptrType(types.Package)).nil); + if (!(pkg === ($ptrType(types.Package)).nil) && pkg.Complete()) { + return [pkg, err]; } - if (start < s.$length) { - e.Buffer.Write($subslice(s, start)); + _tuple$2 = os.Open(filename); f = _tuple$2[0]; err = _tuple$2[1]; + if (!($interfaceIsEqual(err, $ifaceNil))) { + return [pkg, err]; } - e.Buffer.WriteByte(34); - return [e.Buffer.Len() - len0 >> 0, $ifaceNil]; - }; - encodeState.prototype.stringBytes = function(s) { return this.$val.stringBytes(s); }; - fillField = function(f) { - f.nameBytes = new ($sliceType($Uint8))($stringToBytes(f.name)); - f.equalFold = foldFunc(f.nameBytes); - return f; - }; - byName.prototype.Len = function() { - var x; - x = this; - return x.$length; + $deferred.push([(function() { + f.Close(); + if (!($interfaceIsEqual(err, $ifaceNil))) { + err = fmt.Errorf("reading export data: %s: %v", new ($sliceType($emptyInterface))([new $String(filename), err])); + } + }), []]); + buf = bufio.NewReader(f); + err = FindExportData(buf); + if (!($interfaceIsEqual(err, $ifaceNil))) { + return [pkg, err]; + } + _tuple$3 = ImportData(imports, filename, id, buf); pkg = _tuple$3[0]; err = _tuple$3[1]; + return [pkg, err]; + /* */ } catch(err) { $err = err; } finally { $deferFrames.pop(); $callDeferred($deferred, $err); return [pkg, err]; } }; - $ptrType(byName).prototype.Len = function() { return this.$get().Len(); }; - byName.prototype.Swap = function(i, j) { - var x, _tmp, _tmp$1; - x = this; - _tmp = new field.Ptr(); $copy(_tmp, ((j < 0 || j >= x.$length) ? $throwRuntimeError("index out of range") : x.$array[x.$offset + j]), field); _tmp$1 = new field.Ptr(); $copy(_tmp$1, ((i < 0 || i >= x.$length) ? $throwRuntimeError("index out of range") : x.$array[x.$offset + i]), field); $copy(((i < 0 || i >= x.$length) ? $throwRuntimeError("index out of range") : x.$array[x.$offset + i]), _tmp, field); $copy(((j < 0 || j >= x.$length) ? $throwRuntimeError("index out of range") : x.$array[x.$offset + j]), _tmp$1, field); + parser.Ptr.prototype.init = function(filename, id, src, imports) { + var p; + p = this; + p.scanner.Init(src); + p.scanner.Error = (function(param, msg) { + p.error(new $String(msg)); + }); + p.scanner.Mode = 876; + p.scanner.Whitespace = new $Uint64(1, 512); + p.scanner.Position.Filename = filename; + p.next(); + p.id = id; + p.imports = imports; }; - $ptrType(byName).prototype.Swap = function(i, j) { return this.$get().Swap(i, j); }; - byName.prototype.Less = function(i, j) { - var x; - x = this; - if (!(((i < 0 || i >= x.$length) ? $throwRuntimeError("index out of range") : x.$array[x.$offset + i]).name === ((j < 0 || j >= x.$length) ? $throwRuntimeError("index out of range") : x.$array[x.$offset + j]).name)) { - return ((i < 0 || i >= x.$length) ? $throwRuntimeError("index out of range") : x.$array[x.$offset + i]).name < ((j < 0 || j >= x.$length) ? $throwRuntimeError("index out of range") : x.$array[x.$offset + j]).name; - } - if (!((((i < 0 || i >= x.$length) ? $throwRuntimeError("index out of range") : x.$array[x.$offset + i]).index.$length === ((j < 0 || j >= x.$length) ? $throwRuntimeError("index out of range") : x.$array[x.$offset + j]).index.$length))) { - return ((i < 0 || i >= x.$length) ? $throwRuntimeError("index out of range") : x.$array[x.$offset + i]).index.$length < ((j < 0 || j >= x.$length) ? $throwRuntimeError("index out of range") : x.$array[x.$offset + j]).index.$length; + parser.prototype.init = function(filename, id, src, imports) { return this.$val.init(filename, id, src, imports); }; + parser.Ptr.prototype.next = function() { + var p, _ref; + p = this; + p.tok = p.scanner.Scan(); + _ref = p.tok; + if (_ref === -2 || _ref === -3 || _ref === -5 || _ref === -6 || _ref === 183) { + p.lit = p.scanner.TokenText(); + } else { + p.lit = ""; } - if (!(((i < 0 || i >= x.$length) ? $throwRuntimeError("index out of range") : x.$array[x.$offset + i]).tag === ((j < 0 || j >= x.$length) ? $throwRuntimeError("index out of range") : x.$array[x.$offset + j]).tag)) { - return ((i < 0 || i >= x.$length) ? $throwRuntimeError("index out of range") : x.$array[x.$offset + i]).tag; + }; + parser.prototype.next = function() { return this.$val.next(); }; + declTypeName = function(pkg, name) { + var scope, obj, obj$1; + scope = pkg.Scope(); + obj = scope.Lookup(name); + if (!($interfaceIsEqual(obj, $ifaceNil))) { + return $assertType(obj, ($ptrType(types.TypeName))); } - return $subslice(new byIndex(x.$array), x.$offset, x.$offset + x.$length).Less(i, j); + obj$1 = types.NewTypeName(0, pkg, name, $ifaceNil); + types.NewNamed(obj$1, $ifaceNil, ($sliceType(($ptrType(types.Func)))).nil); + scope.Insert(obj$1); + return obj$1; }; - $ptrType(byName).prototype.Less = function(i, j) { return this.$get().Less(i, j); }; - byIndex.prototype.Len = function() { - var x; - x = this; - return x.$length; + importError.Ptr.prototype.Error = function() { + var e, x; + e = new importError.Ptr(); $copy(e, this, importError); + return fmt.Sprintf("import error %s (byte offset = %d): %s", new ($sliceType($emptyInterface))([(x = e.pos, new x.constructor.Struct(x)), new $Int(e.pos.Offset), e.err])); }; - $ptrType(byIndex).prototype.Len = function() { return this.$get().Len(); }; - byIndex.prototype.Swap = function(i, j) { - var x, _tmp, _tmp$1; - x = this; - _tmp = new field.Ptr(); $copy(_tmp, ((j < 0 || j >= x.$length) ? $throwRuntimeError("index out of range") : x.$array[x.$offset + j]), field); _tmp$1 = new field.Ptr(); $copy(_tmp$1, ((i < 0 || i >= x.$length) ? $throwRuntimeError("index out of range") : x.$array[x.$offset + i]), field); $copy(((i < 0 || i >= x.$length) ? $throwRuntimeError("index out of range") : x.$array[x.$offset + i]), _tmp, field); $copy(((j < 0 || j >= x.$length) ? $throwRuntimeError("index out of range") : x.$array[x.$offset + j]), _tmp$1, field); + importError.prototype.Error = function() { return this.$val.Error(); }; + parser.Ptr.prototype.error = function(err) { + var p, _tuple, s, ok, x; + p = this; + _tuple = $assertType(err, $String, true); s = _tuple[0]; ok = _tuple[1]; + if (ok) { + err = errors.New(s); + } + $panic((x = new importError.Ptr(p.scanner.Pos(), $assertType(err, $error)), new x.constructor.Struct(x))); }; - $ptrType(byIndex).prototype.Swap = function(i, j) { return this.$get().Swap(i, j); }; - byIndex.prototype.Less = function(i, j) { - var x, _ref, _i, k, xik, x$1, x$2; - x = this; - _ref = ((i < 0 || i >= x.$length) ? $throwRuntimeError("index out of range") : x.$array[x.$offset + i]).index; - _i = 0; - while (_i < _ref.$length) { - k = _i; - xik = ((_i < 0 || _i >= _ref.$length) ? $throwRuntimeError("index out of range") : _ref.$array[_ref.$offset + _i]); - if (k >= ((j < 0 || j >= x.$length) ? $throwRuntimeError("index out of range") : x.$array[x.$offset + j]).index.$length) { - return false; - } - if (!((xik === (x$1 = ((j < 0 || j >= x.$length) ? $throwRuntimeError("index out of range") : x.$array[x.$offset + j]).index, ((k < 0 || k >= x$1.$length) ? $throwRuntimeError("index out of range") : x$1.$array[x$1.$offset + k]))))) { - return xik < (x$2 = ((j < 0 || j >= x.$length) ? $throwRuntimeError("index out of range") : x.$array[x.$offset + j]).index, ((k < 0 || k >= x$2.$length) ? $throwRuntimeError("index out of range") : x$2.$array[x$2.$offset + k])); - } - _i++; + parser.prototype.error = function(err) { return this.$val.error(err); }; + parser.Ptr.prototype.errorf = function(format, args) { + var p; + p = this; + p.error(new $String(fmt.Sprintf(format, args))); + }; + parser.prototype.errorf = function(format, args) { return this.$val.errorf(format, args); }; + parser.Ptr.prototype.expect = function(tok) { + var p, lit; + p = this; + lit = p.lit; + if (!((p.tok === tok))) { + p.errorf("expected %s, got %s (%s)", new ($sliceType($emptyInterface))([new $String(scanner.TokenString(tok)), new $String(scanner.TokenString(p.tok)), new $String(lit)])); } - return ((i < 0 || i >= x.$length) ? $throwRuntimeError("index out of range") : x.$array[x.$offset + i]).index.$length < ((j < 0 || j >= x.$length) ? $throwRuntimeError("index out of range") : x.$array[x.$offset + j]).index.$length; + p.next(); + return lit; }; - $ptrType(byIndex).prototype.Less = function(i, j) { return this.$get().Less(i, j); }; - typeFields = function(t) { - var current, next, count, _map, _key, nextCount, _map$1, _key$1, visited, _map$2, _key$2, fields, _tmp, _tmp$1, _tmp$2, _tmp$3, _map$3, _key$3, _ref, _i, f, _entry, _key$4, i, sf, tag, _tuple, name, opts, index, x, ft, tagged, _entry$1, x$1, _lhs, _index, _entry$2, _key$5, _entry$3, out, _tmp$4, _tmp$5, advance, i$1, fi, name$1, x$2, fj, _tuple$1, dominant, ok; - current = new ($sliceType(field))([]); - next = new ($sliceType(field))([new field.Ptr("", ($sliceType($Uint8)).nil, $throwNilPointerError, false, ($sliceType($Int)).nil, t, false, false)]); - count = (_map = new $Map(), _map); - nextCount = (_map$1 = new $Map(), _map$1); - visited = (_map$2 = new $Map(), _map$2); - fields = ($sliceType(field)).nil; - while (next.$length > 0) { - _tmp = next; _tmp$1 = $subslice(current, 0, 0); current = _tmp; next = _tmp$1; - _tmp$2 = nextCount; _tmp$3 = (_map$3 = new $Map(), _map$3); count = _tmp$2; nextCount = _tmp$3; - _ref = current; - _i = 0; - while (_i < _ref.$length) { - f = new field.Ptr(); $copy(f, ((_i < 0 || _i >= _ref.$length) ? $throwRuntimeError("index out of range") : _ref.$array[_ref.$offset + _i]), field); - if ((_entry = visited[f.typ.$key()], _entry !== undefined ? _entry.v : false)) { - _i++; - continue; - } - _key$4 = f.typ; (visited || $throwRuntimeError("assignment to entry in nil map"))[_key$4.$key()] = { k: _key$4, v: true }; - i = 0; - while (i < f.typ.NumField()) { - sf = new reflect.StructField.Ptr(); $copy(sf, f.typ.Field(i), reflect.StructField); - if (!(sf.PkgPath === "")) { - i = i + (1) >> 0; - continue; - } - tag = (new reflect.StructTag(sf.Tag)).Get("json"); - if (tag === "-") { - i = i + (1) >> 0; - continue; - } - _tuple = parseTag(tag); name = _tuple[0]; opts = _tuple[1]; - if (!isValidTag(name)) { - name = ""; - } - index = ($sliceType($Int)).make((f.index.$length + 1 >> 0)); - $copySlice(index, f.index); - (x = f.index.$length, (x < 0 || x >= index.$length) ? $throwRuntimeError("index out of range") : index.$array[index.$offset + x] = i); - ft = sf.Type; - if (ft.Name() === "" && (ft.Kind() === 22)) { - ft = ft.Elem(); - } - if (!(name === "") || !sf.Anonymous || !((ft.Kind() === 25))) { - tagged = !(name === ""); - if (name === "") { - name = sf.Name; - } - fields = $append(fields, fillField(new field.Ptr(name, ($sliceType($Uint8)).nil, $throwNilPointerError, tagged, index, ft, (new tagOptions(opts)).Contains("omitempty"), (new tagOptions(opts)).Contains("string")))); - if ((_entry$1 = count[f.typ.$key()], _entry$1 !== undefined ? _entry$1.v : 0) > 1) { - fields = $append(fields, (x$1 = fields.$length - 1 >> 0, ((x$1 < 0 || x$1 >= fields.$length) ? $throwRuntimeError("index out of range") : fields.$array[fields.$offset + x$1]))); - } - i = i + (1) >> 0; - continue; - } - _lhs = nextCount; _index = ft; _key$5 = _index; (_lhs || $throwRuntimeError("assignment to entry in nil map"))[_key$5.$key()] = { k: _key$5, v: (_entry$2 = _lhs[_index.$key()], _entry$2 !== undefined ? _entry$2.v : 0) + (1) >> 0 }; - if ((_entry$3 = nextCount[ft.$key()], _entry$3 !== undefined ? _entry$3.v : 0) === 1) { - next = $append(next, fillField(new field.Ptr(ft.Name(), ($sliceType($Uint8)).nil, $throwNilPointerError, false, index, ft, false, false))); - } - i = i + (1) >> 0; - } - _i++; - } + parser.prototype.expect = function(tok) { return this.$val.expect(tok); }; + parser.Ptr.prototype.expectSpecial = function(tok) { + var p, sep, i; + p = this; + sep = 120; + i = 0; + while (i < tok.length && (p.tok === (tok.charCodeAt(i) >> 0)) && sep > 32) { + sep = p.scanner.Peek(); + p.next(); + i = i + (1) >> 0; } - sort.Sort($subslice(new byName(fields.$array), fields.$offset, fields.$offset + fields.$length)); - out = $subslice(fields, 0, 0); - _tmp$4 = 0; _tmp$5 = 0; advance = _tmp$4; i$1 = _tmp$5; - while (i$1 < fields.$length) { - fi = new field.Ptr(); $copy(fi, ((i$1 < 0 || i$1 >= fields.$length) ? $throwRuntimeError("index out of range") : fields.$array[fields.$offset + i$1]), field); - name$1 = fi.name; - advance = 1; - while ((i$1 + advance >> 0) < fields.$length) { - fj = new field.Ptr(); $copy(fj, (x$2 = i$1 + advance >> 0, ((x$2 < 0 || x$2 >= fields.$length) ? $throwRuntimeError("index out of range") : fields.$array[fields.$offset + x$2])), field); - if (!(fj.name === name$1)) { - break; - } - advance = advance + (1) >> 0; - } - if (advance === 1) { - out = $append(out, fi); - i$1 = i$1 + (advance) >> 0; - continue; - } - _tuple$1 = dominantField($subslice(fields, i$1, (i$1 + advance >> 0))); dominant = new field.Ptr(); $copy(dominant, _tuple$1[0], field); ok = _tuple$1[1]; - if (ok) { - out = $append(out, dominant); - } - i$1 = i$1 + (advance) >> 0; + if (i < tok.length) { + p.errorf("expected %q, got %q", new ($sliceType($emptyInterface))([new $String(tok), new $String(tok.substring(0, i))])); + } + }; + parser.prototype.expectSpecial = function(tok) { return this.$val.expectSpecial(tok); }; + parser.Ptr.prototype.expectKeyword = function(keyword) { + var p, lit; + p = this; + lit = p.expect(-2); + if (!(lit === keyword)) { + p.errorf("expected keyword %s, got %q", new ($sliceType($emptyInterface))([new $String(keyword), new $String(lit)])); } - fields = out; - sort.Sort($subslice(new byIndex(fields.$array), fields.$offset, fields.$offset + fields.$length)); - return fields; }; - dominantField = function(fields) { - var length, tagged, _ref, _i, i, f; - length = ((0 < 0 || 0 >= fields.$length) ? $throwRuntimeError("index out of range") : fields.$array[fields.$offset + 0]).index.$length; - tagged = -1; - _ref = fields; - _i = 0; - while (_i < _ref.$length) { - i = _i; - f = new field.Ptr(); $copy(f, ((_i < 0 || _i >= _ref.$length) ? $throwRuntimeError("index out of range") : _ref.$array[_ref.$offset + _i]), field); - if (f.index.$length > length) { - fields = $subslice(fields, 0, i); - break; - } - if (f.tag) { - if (tagged >= 0) { - return [new field.Ptr("", ($sliceType($Uint8)).nil, $throwNilPointerError, false, ($sliceType($Int)).nil, $ifaceNil, false, false), false]; - } - tagged = i; - } - _i++; + parser.prototype.expectKeyword = function(keyword) { return this.$val.expectKeyword(keyword); }; + parser.Ptr.prototype.parsePackageId = function() { + var p, _tuple, id, err; + p = this; + _tuple = strconv.Unquote(p.expect(-6)); id = _tuple[0]; err = _tuple[1]; + if (!($interfaceIsEqual(err, $ifaceNil))) { + p.error(err); } - if (tagged >= 0) { - return [((tagged < 0 || tagged >= fields.$length) ? $throwRuntimeError("index out of range") : fields.$array[fields.$offset + tagged]), true]; + if (id === "") { + id = p.id; } - if (fields.$length > 1) { - return [new field.Ptr("", ($sliceType($Uint8)).nil, $throwNilPointerError, false, ($sliceType($Int)).nil, $ifaceNil, false, false), false]; + return id; + }; + parser.prototype.parsePackageId = function() { return this.$val.parsePackageId(); }; + parser.Ptr.prototype.parsePackageName = function() { + var p; + p = this; + return p.expect(-2); + }; + parser.prototype.parsePackageName = function() { return this.$val.parsePackageName(); }; + parser.Ptr.prototype.parseDotIdent = function() { + var p, ident, sep; + p = this; + ident = ""; + if (!((p.tok === -3))) { + sep = 120; + while (((p.tok === -2) || (p.tok === -3) || (p.tok === 183)) && sep > 32) { + ident = ident + (p.lit); + sep = p.scanner.Peek(); + p.next(); + } } - return [((0 < 0 || 0 >= fields.$length) ? $throwRuntimeError("index out of range") : fields.$array[fields.$offset + 0]), true]; + if (ident === "") { + p.expect(-2); + } + return ident; }; - cachedTypeFields = function(t) { - var _entry, f, _map, _key, _key$1; - fieldCache.RWMutex.RLock(); - f = (_entry = fieldCache.m[t.$key()], _entry !== undefined ? _entry.v : ($sliceType(field)).nil); - fieldCache.RWMutex.RUnlock(); - if (!(f === ($sliceType(field)).nil)) { - return f; + parser.prototype.parseDotIdent = function() { return this.$val.parseDotIdent(); }; + parser.Ptr.prototype.parseQualifiedName = function() { + var id = "", name = "", p; + p = this; + p.expect(64); + id = p.parsePackageId(); + p.expect(46); + if (p.tok === 63) { + p.next(); + } else { + name = p.parseDotIdent(); } - f = typeFields(t); - if (f === ($sliceType(field)).nil) { - f = new ($sliceType(field))([]); + return [id, name]; + }; + parser.prototype.parseQualifiedName = function() { return this.$val.parseQualifiedName(); }; + parser.Ptr.prototype.getPkg = function(id, name) { + var p, _entry, pkg, _key; + p = this; + if (id === "unsafe") { + return types.Unsafe; } - fieldCache.RWMutex.Lock(); - if (fieldCache.m === false) { - fieldCache.m = (_map = new $Map(), _map); + pkg = (_entry = p.imports[id], _entry !== undefined ? _entry.v : ($ptrType(types.Package)).nil); + if (pkg === ($ptrType(types.Package)).nil && !(name === "")) { + pkg = types.NewPackage(id, name); + _key = id; (p.imports || $throwRuntimeError("assignment to entry in nil map"))[_key] = { k: _key, v: pkg }; } - _key$1 = t; (fieldCache.m || $throwRuntimeError("assignment to entry in nil map"))[_key$1.$key()] = { k: _key$1, v: f }; - fieldCache.RWMutex.Unlock(); - return f; + return pkg; }; - foldFunc = function(s) { - var nonLetter, special, _ref, _i, b, upper; - nonLetter = false; - special = false; - _ref = s; - _i = 0; - while (_i < _ref.$length) { - b = ((_i < 0 || _i >= _ref.$length) ? $throwRuntimeError("index out of range") : _ref.$array[_ref.$offset + _i]); - if (b >= 128) { - return bytes.EqualFold; - } - upper = (b & 223) >>> 0; - if (upper < 65 || upper > 90) { - nonLetter = true; - } else if ((upper === 75) || (upper === 83)) { - special = true; - } - _i++; + parser.prototype.getPkg = function(id, name) { return this.$val.getPkg(id, name); }; + parser.Ptr.prototype.parseExportedName = function() { + var pkg = ($ptrType(types.Package)).nil, name = "", p, _tuple, id; + p = this; + _tuple = p.parseQualifiedName(); id = _tuple[0]; name = _tuple[1]; + pkg = p.getPkg(id, ""); + if (pkg === ($ptrType(types.Package)).nil) { + p.errorf("%s package not found", new ($sliceType($emptyInterface))([new $String(id)])); } - if (special) { - return equalFoldRight; + return [pkg, name]; + }; + parser.prototype.parseExportedName = function() { return this.$val.parseExportedName(); }; + parser.Ptr.prototype.parseBasicType = function() { + var p, id, obj, _tuple, obj$1, ok; + p = this; + id = p.expect(-2); + obj = types.Universe.Lookup(id); + _tuple = $assertType(obj, ($ptrType(types.TypeName)), true); obj$1 = _tuple[0]; ok = _tuple[1]; + if (ok) { + return obj$1.object.Type(); } - if (nonLetter) { - return asciiEqualFold; + p.errorf("not a basic type: %s", new ($sliceType($emptyInterface))([new $String(id)])); + return $ifaceNil; + }; + parser.prototype.parseBasicType = function() { return this.$val.parseBasicType(); }; + parser.Ptr.prototype.parseArrayType = function() { + var p, lit, elem, _tuple, n, err; + p = this; + lit = p.expect(-3); + p.expect(93); + elem = p.parseType(); + _tuple = strconv.ParseInt(lit, 10, 64); n = _tuple[0]; err = _tuple[1]; + if (!($interfaceIsEqual(err, $ifaceNil))) { + p.error(err); } - return simpleLetterEqualFold; + return types.NewArray(elem, n); }; - equalFoldRight = function(s, t) { - var _ref, _i, sb, tb, sbUpper, _tuple, tr, size, _ref$1; - _ref = s; - _i = 0; - while (_i < _ref.$length) { - sb = ((_i < 0 || _i >= _ref.$length) ? $throwRuntimeError("index out of range") : _ref.$array[_ref.$offset + _i]); - if (t.$length === 0) { - return false; - } - tb = ((0 < 0 || 0 >= t.$length) ? $throwRuntimeError("index out of range") : t.$array[t.$offset + 0]); - if (tb < 128) { - if (!((sb === tb))) { - sbUpper = (sb & 223) >>> 0; - if (65 <= sbUpper && sbUpper <= 90) { - if (!((sbUpper === ((tb & 223) >>> 0)))) { - return false; - } - } else { - return false; - } + parser.prototype.parseArrayType = function() { return this.$val.parseArrayType(); }; + parser.Ptr.prototype.parseMapType = function() { + var p, key, elem; + p = this; + p.expectKeyword("map"); + p.expect(91); + key = p.parseType(); + p.expect(93); + elem = p.parseType(); + return types.NewMap(key, elem); + }; + parser.prototype.parseMapType = function() { return this.$val.parseMapType(); }; + parser.Ptr.prototype.parseName = function(materializePkg) { + var pkg = ($ptrType(types.Package)).nil, name = "", p, _ref, _entry, _entry$1, id, _tuple; + p = this; + _ref = p.tok; + if (_ref === -2) { + pkg = (_entry = p.imports[p.id], _entry !== undefined ? _entry.v : ($ptrType(types.Package)).nil); + name = p.lit; + p.next(); + } else if (_ref === 63) { + pkg = (_entry$1 = p.imports[p.id], _entry$1 !== undefined ? _entry$1.v : ($ptrType(types.Package)).nil); + p.next(); + } else if (_ref === 64) { + id = ""; + _tuple = p.parseQualifiedName(); id = _tuple[0]; name = _tuple[1]; + if (materializePkg) { + pkg = p.getPkg(id, ""); + if (pkg === ($ptrType(types.Package)).nil) { + pkg = types.NewPackage(id, ""); } - t = $subslice(t, 1); - _i++; - continue; } - _tuple = utf8.DecodeRune(t); tr = _tuple[0]; size = _tuple[1]; - _ref$1 = sb; - if (_ref$1 === 115 || _ref$1 === 83) { - if (!((tr === 383))) { - return false; - } - } else if (_ref$1 === 107 || _ref$1 === 75) { - if (!((tr === 8490))) { - return false; - } + } else { + p.error(new $String("name expected")); + } + return [pkg, name]; + }; + parser.prototype.parseName = function(materializePkg) { return this.$val.parseName(materializePkg); }; + deref = function(typ) { + var _tuple, p; + _tuple = $assertType(typ, ($ptrType(types.Pointer)), true); p = _tuple[0]; + if (!(p === ($ptrType(types.Pointer)).nil)) { + return p.Elem(); + } + return typ; + }; + parser.Ptr.prototype.parseField = function() { + var p, _tuple, pkg, name, typ, anonymous, typ$1, _ref, tag, s, err, _tuple$1; + p = this; + _tuple = p.parseName(true); pkg = _tuple[0]; name = _tuple[1]; + typ = p.parseType(); + anonymous = false; + if (name === "") { + _ref = deref(typ); + if ($assertType(_ref, ($ptrType(types.Basic)), true)[1]) { + typ$1 = _ref.$val; + pkg = ($ptrType(types.Package)).nil; + name = typ$1.Name(); + } else if ($assertType(_ref, ($ptrType(types.Named)), true)[1]) { + typ$1 = _ref.$val; + name = typ$1.Obj().object.Name(); } else { - return false; + typ$1 = _ref; + p.errorf("anonymous field expected", new ($sliceType($emptyInterface))([])); } - t = $subslice(t, size); - _i++; + anonymous = true; } - if (t.$length > 0) { - return false; + tag = ""; + if (p.tok === -6) { + s = p.expect(-6); + err = $ifaceNil; + _tuple$1 = strconv.Unquote(s); tag = _tuple$1[0]; err = _tuple$1[1]; + if (!($interfaceIsEqual(err, $ifaceNil))) { + p.errorf("invalid struct tag %s: %s", new ($sliceType($emptyInterface))([new $String(s), err])); + } } - return true; + return [types.NewField(0, pkg, name, typ, anonymous), tag]; }; - asciiEqualFold = function(s, t) { - var _ref, _i, i, sb, tb; - if (!((s.$length === t.$length))) { - return false; - } - _ref = s; - _i = 0; - while (_i < _ref.$length) { - i = _i; - sb = ((_i < 0 || _i >= _ref.$length) ? $throwRuntimeError("index out of range") : _ref.$array[_ref.$offset + _i]); - tb = ((i < 0 || i >= t.$length) ? $throwRuntimeError("index out of range") : t.$array[t.$offset + i]); - if (sb === tb) { - _i++; - continue; + parser.prototype.parseField = function() { return this.$val.parseField(); }; + parser.Ptr.prototype.parseStructType = function() { + var p, fields, tags, i, _tuple, fld, tag; + p = this; + fields = ($sliceType(($ptrType(types.Var)))).nil; + tags = ($sliceType($String)).nil; + p.expectKeyword("struct"); + p.expect(123); + i = 0; + while (!((p.tok === 125)) && !((p.tok === -1))) { + if (i > 0) { + p.expect(59); } - if ((97 <= sb && sb <= 122) || (65 <= sb && sb <= 90)) { - if (!((((sb & 223) >>> 0) === ((tb & 223) >>> 0)))) { - return false; - } - } else { - return false; + _tuple = p.parseField(); fld = _tuple[0]; tag = _tuple[1]; + if (!(tag === "") && tags === ($sliceType($String)).nil) { + tags = ($sliceType($String)).make(i); } - _i++; + if (!(tags === ($sliceType($String)).nil)) { + tags = $append(tags, tag); + } + fields = $append(fields, fld); + i = i + (1) >> 0; } - return true; + p.expect(125); + return types.NewStruct(fields, tags); }; - simpleLetterEqualFold = function(s, t) { - var _ref, _i, i, b; - if (!((s.$length === t.$length))) { - return false; + parser.prototype.parseStructType = function() { return this.$val.parseStructType(); }; + parser.Ptr.prototype.parseParameter = function() { + var par = ($ptrType(types.Var)).nil, isVariadic = false, p, _tuple, name, i, typ; + p = this; + _tuple = p.parseName(false); name = _tuple[1]; + i = strings.Index(name, "\xC2\xB7"); + if (i >= 0) { + name = name.substring(0, i); } - _ref = s; - _i = 0; - while (_i < _ref.$length) { - i = _i; - b = ((_i < 0 || _i >= _ref.$length) ? $throwRuntimeError("index out of range") : _ref.$array[_ref.$offset + _i]); - if (!((((b & 223) >>> 0) === ((((i < 0 || i >= t.$length) ? $throwRuntimeError("index out of range") : t.$array[t.$offset + i]) & 223) >>> 0)))) { - return false; - } - _i++; + if (p.tok === 46) { + p.expectSpecial("..."); + isVariadic = true; } - return true; + typ = p.parseType(); + if (isVariadic) { + typ = types.NewSlice(typ); + } + if (p.tok === -6) { + p.next(); + } + par = types.NewVar(0, ($ptrType(types.Package)).nil, name, typ); + return [par, isVariadic]; }; - compact = function(dst, src, escape) { - var origLen, scan, start, _ref, _i, i, c, x, x$1, x$2, v; - origLen = dst.Len(); - scan = new scanner.Ptr(); $copy(scan, new scanner.Ptr(), scanner); - scan.reset(); - start = 0; - _ref = src; - _i = 0; - while (_i < _ref.$length) { - i = _i; - c = ((_i < 0 || _i >= _ref.$length) ? $throwRuntimeError("index out of range") : _ref.$array[_ref.$offset + _i]); - if (escape && ((c === 60) || (c === 62) || (c === 38))) { - if (start < i) { - dst.Write($subslice(src, start, i)); - } - dst.WriteString("\\u00"); - dst.WriteByte(hex.charCodeAt((c >>> 4 << 24 >>> 24))); - dst.WriteByte(hex.charCodeAt(((c & 15) >>> 0))); - start = i + 1 >> 0; - } - if ((c === 226) && (i + 2 >> 0) < src.$length && ((x = i + 1 >> 0, ((x < 0 || x >= src.$length) ? $throwRuntimeError("index out of range") : src.$array[src.$offset + x])) === 128) && (((x$1 = i + 2 >> 0, ((x$1 < 0 || x$1 >= src.$length) ? $throwRuntimeError("index out of range") : src.$array[src.$offset + x$1])) & ~1) === 168)) { - if (start < i) { - dst.Write($subslice(src, start, i)); - } - dst.WriteString("\\u202"); - dst.WriteByte(hex.charCodeAt((((x$2 = i + 2 >> 0, ((x$2 < 0 || x$2 >= src.$length) ? $throwRuntimeError("index out of range") : src.$array[src.$offset + x$2])) & 15) >>> 0))); - start = i + 3 >> 0; + parser.prototype.parseParameter = function() { return this.$val.parseParameter(); }; + parser.Ptr.prototype.parseParameters = function() { + var list = ($sliceType(($ptrType(types.Var)))).nil, isVariadic = false, p, _tuple, par, variadic; + p = this; + p.expect(40); + while (!((p.tok === 41)) && !((p.tok === -1))) { + if (list.$length > 0) { + p.expect(44); } - v = scan.step(scan, (c >> 0)); - if (v >= 9) { - if (v === 11) { - break; - } - if (start < i) { - dst.Write($subslice(src, start, i)); + _tuple = p.parseParameter(); par = _tuple[0]; variadic = _tuple[1]; + list = $append(list, par); + if (variadic) { + if (isVariadic) { + p.error(new $String("... not on final argument")); } - start = i + 1 >> 0; + isVariadic = true; } - _i++; } - if (scan.eof() === 11) { - dst.Truncate(origLen); - return scan.err; + p.expect(41); + return [list, isVariadic]; + }; + parser.prototype.parseParameters = function() { return this.$val.parseParameters(); }; + parser.Ptr.prototype.parseSignature = function(recv) { + var p, _tuple, params, isVariadic, results, variadic, _tuple$1; + p = this; + _tuple = p.parseParameters(); params = _tuple[0]; isVariadic = _tuple[1]; + results = ($sliceType(($ptrType(types.Var)))).nil; + if (p.tok === 40) { + variadic = false; + _tuple$1 = p.parseParameters(); results = _tuple$1[0]; variadic = _tuple$1[1]; + if (variadic) { + p.error(new $String("... not permitted on result type")); + } } - if (start < src.$length) { - dst.Write($subslice(src, start)); + return types.NewSignature(($ptrType(types.Scope)).nil, recv, types.NewTuple(params), types.NewTuple(results), isVariadic); + }; + parser.prototype.parseSignature = function(recv) { return this.$val.parseSignature(recv); }; + parser.Ptr.prototype.parseInterfaceType = function() { + var p, methods, i, _tuple, pkg, name, sig; + p = this; + methods = ($sliceType(($ptrType(types.Func)))).nil; + p.expectKeyword("interface"); + p.expect(123); + i = 0; + while (!((p.tok === 125)) && !((p.tok === -1))) { + if (i > 0) { + p.expect(59); + } + _tuple = p.parseName(true); pkg = _tuple[0]; name = _tuple[1]; + sig = p.parseSignature(($ptrType(types.Var)).nil); + methods = $append(methods, types.NewFunc(0, pkg, name, sig)); + i = i + (1) >> 0; } - return $ifaceNil; + p.expect(125); + return types.NewInterface(methods, ($sliceType(($ptrType(types.Named)))).nil).Complete(); }; - nextValue = function(data, scan) { - var value = ($sliceType($Uint8)).nil, rest = ($sliceType($Uint8)).nil, err = $ifaceNil, _ref, _i, i, c, v, _ref$1, _tmp, _tmp$1, _tmp$2, _tmp$3, _tmp$4, _tmp$5, _tmp$6, _tmp$7, _tmp$8, _tmp$9, _tmp$10, _tmp$11; - scan.reset(); - _ref = data; - _i = 0; - while (_i < _ref.$length) { - i = _i; - c = ((_i < 0 || _i >= _ref.$length) ? $throwRuntimeError("index out of range") : _ref.$array[_ref.$offset + _i]); - v = scan.step(scan, (c >> 0)); - if (v >= 10) { - _ref$1 = v; - if (_ref$1 === 11) { - _tmp = ($sliceType($Uint8)).nil; _tmp$1 = ($sliceType($Uint8)).nil; _tmp$2 = scan.err; value = _tmp; rest = _tmp$1; err = _tmp$2; - return [value, rest, err]; - } else if (_ref$1 === 10) { - _tmp$3 = $subslice(data, 0, i); _tmp$4 = $subslice(data, i); _tmp$5 = $ifaceNil; value = _tmp$3; rest = _tmp$4; err = _tmp$5; - return [value, rest, err]; - } + parser.prototype.parseInterfaceType = function() { return this.$val.parseInterfaceType(); }; + parser.Ptr.prototype.parseChanType = function() { + var p, dir, elem; + p = this; + dir = 0; + if (p.tok === -2) { + p.expectKeyword("chan"); + if (p.tok === 60) { + p.expectSpecial("<-"); + dir = 1; } - _i++; + } else { + p.expectSpecial("<-"); + p.expectKeyword("chan"); + dir = 2; } - if (scan.eof() === 11) { - _tmp$6 = ($sliceType($Uint8)).nil; _tmp$7 = ($sliceType($Uint8)).nil; _tmp$8 = scan.err; value = _tmp$6; rest = _tmp$7; err = _tmp$8; - return [value, rest, err]; + elem = p.parseType(); + return types.NewChan(dir, elem); + }; + parser.prototype.parseChanType = function() { return this.$val.parseChanType(); }; + parser.Ptr.prototype.parseType = function() { + var p, _ref, _ref$1, _tuple, pkg, name, typ; + p = this; + _ref = p.tok; + if (_ref === -2) { + _ref$1 = p.lit; + if (_ref$1 === "struct") { + return p.parseStructType(); + } else if (_ref$1 === "func") { + p.next(); + return p.parseSignature(($ptrType(types.Var)).nil); + } else if (_ref$1 === "interface") { + return p.parseInterfaceType(); + } else if (_ref$1 === "map") { + return p.parseMapType(); + } else if (_ref$1 === "chan") { + return p.parseChanType(); + } else { + return p.parseBasicType(); + } + } else if (_ref === 64) { + _tuple = p.parseExportedName(); pkg = _tuple[0]; name = _tuple[1]; + return declTypeName(pkg, name).object.Type(); + } else if (_ref === 91) { + p.next(); + if (p.tok === 93) { + p.next(); + return types.NewSlice(p.parseType()); + } + return p.parseArrayType(); + } else if (_ref === 42) { + p.next(); + return types.NewPointer(p.parseType()); + } else if (_ref === 60) { + return p.parseChanType(); + } else if (_ref === 40) { + p.next(); + typ = p.parseType(); + p.expect(41); + return typ; } - _tmp$9 = data; _tmp$10 = ($sliceType($Uint8)).nil; _tmp$11 = $ifaceNil; value = _tmp$9; rest = _tmp$10; err = _tmp$11; - return [value, rest, err]; + p.errorf("expected type, got %s (%q)", new ($sliceType($emptyInterface))([new $String(scanner.TokenString(p.tok)), new $String(p.lit)])); + return $ifaceNil; }; - SyntaxError.Ptr.prototype.Error = function() { - var e; - e = this; - return e.msg; + parser.prototype.parseType = function() { return this.$val.parseType(); }; + parser.Ptr.prototype.parseImportDecl = function() { + var p, name; + p = this; + p.expectKeyword("import"); + name = p.parsePackageName(); + p.getPkg(p.parsePackageId(), name); }; - SyntaxError.prototype.Error = function() { return this.$val.Error(); }; - scanner.Ptr.prototype.reset = function() { - var s; - s = this; - s.step = stateBeginValue; - s.parseState = $subslice(s.parseState, 0, 0); - s.err = $ifaceNil; - s.redo = false; - s.endTop = false; + parser.prototype.parseImportDecl = function() { return this.$val.parseImportDecl(); }; + parser.Ptr.prototype.parseInt = function() { + var p, s, _ref; + p = this; + s = ""; + _ref = p.tok; + if (_ref === 45) { + s = "-"; + p.next(); + } else if (_ref === 43) { + p.next(); + } + return s + p.expect(-3); }; - scanner.prototype.reset = function() { return this.$val.reset(); }; - scanner.Ptr.prototype.eof = function() { - var s; - s = this; - if (!($interfaceIsEqual(s.err, $ifaceNil))) { - return 11; + parser.prototype.parseInt = function() { return this.$val.parseInt(); }; + parser.Ptr.prototype.parseNumber = function() { + var typ = ($ptrType(types.Basic)).nil, val = $ifaceNil, p, mant, _tuple, exp, err, denom; + p = this; + mant = exact.MakeFromLiteral(p.parseInt(), 5); + if ($interfaceIsEqual(mant, $ifaceNil)) { + $panic(new $String("invalid mantissa")); } - if (s.endTop) { - return 10; + if (p.lit === "p") { + p.next(); + _tuple = strconv.ParseInt(p.parseInt(), 10, 0); exp = _tuple[0]; err = _tuple[1]; + if (!($interfaceIsEqual(err, $ifaceNil))) { + p.error(err); + } + if ((exp.$high < 0 || (exp.$high === 0 && exp.$low < 0))) { + denom = exact.MakeInt64(new $Int64(0, 1)); + denom = exact.Shift(denom, 20, (new $Int64(-exp.$high, -exp.$low).$low >>> 0)); + typ = types.Typ[22]; + val = exact.BinaryOp(mant, 15, denom); + return [typ, val]; + } + if ((exp.$high > 0 || (exp.$high === 0 && exp.$low > 0))) { + mant = exact.Shift(mant, 20, (exp.$low >>> 0)); + } + typ = types.Typ[22]; + val = mant; + return [typ, val]; } - s.step(s, 32); - if (s.endTop) { - return 10; + typ = types.Typ[20]; + val = mant; + return [typ, val]; + }; + parser.prototype.parseNumber = function() { return this.$val.parseNumber(); }; + parser.Ptr.prototype.parseConstDecl = function() { + var p, _tuple, pkg, name, typ0, typ, val, _ref, _tuple$1, _tuple$2, _tuple$3, re, _tuple$4, im; + p = this; + p.expectKeyword("const"); + _tuple = p.parseExportedName(); pkg = _tuple[0]; name = _tuple[1]; + typ0 = $ifaceNil; + if (!((p.tok === 61))) { + typ0 = p.parseType(); } - if ($interfaceIsEqual(s.err, $ifaceNil)) { - s.err = new SyntaxError.Ptr("unexpected end of JSON input", s.bytes); + p.expect(61); + typ = $ifaceNil; + val = $ifaceNil; + _ref = p.tok; + switch (0) { default: if (_ref === -2) { + if (!(p.lit === "true") && !(p.lit === "false")) { + p.error(new $String("expected true or false")); + } + typ = types.Typ[19]; + val = exact.MakeBool(p.lit === "true"); + p.next(); + } else if (_ref === 45 || _ref === -3) { + _tuple$1 = p.parseNumber(); typ = _tuple$1[0]; val = _tuple$1[1]; + } else if (_ref === 40) { + p.next(); + if (p.tok === -5) { + p.next(); + p.expect(43); + typ = types.Typ[21]; + _tuple$2 = p.parseNumber(); val = _tuple$2[1]; + p.expect(41); + break; + } + _tuple$3 = p.parseNumber(); re = _tuple$3[1]; + p.expect(43); + _tuple$4 = p.parseNumber(); im = _tuple$4[1]; + p.expectKeyword("i"); + p.expect(41); + typ = types.Typ[23]; + val = exact.BinaryOp(re, 12, exact.MakeImag(im)); + } else if (_ref === -5) { + typ = types.Typ[21]; + val = exact.MakeFromLiteral(p.lit, 8); + p.next(); + } else if (_ref === -6) { + typ = types.Typ[24]; + val = exact.MakeFromLiteral(p.lit, 9); + p.next(); + } else { + p.errorf("expected literal got %s", new ($sliceType($emptyInterface))([new $String(scanner.TokenString(p.tok))])); + } } + if ($interfaceIsEqual(typ0, $ifaceNil)) { + typ0 = typ; } - return 11; - }; - scanner.prototype.eof = function() { return this.$val.eof(); }; - scanner.Ptr.prototype.pushParseState = function(p) { - var s; - s = this; - s.parseState = $append(s.parseState, p); + pkg.Scope().Insert(types.NewConst(0, pkg, name, typ0, val)); }; - scanner.prototype.pushParseState = function(p) { return this.$val.pushParseState(p); }; - scanner.Ptr.prototype.popParseState = function() { - var s, n; - s = this; - n = s.parseState.$length - 1 >> 0; - s.parseState = $subslice(s.parseState, 0, n); - s.redo = false; - if (n === 0) { - s.step = stateEndTop; - s.endTop = true; - } else { - s.step = stateEndValue; + parser.prototype.parseConstDecl = function() { return this.$val.parseConstDecl(); }; + parser.Ptr.prototype.parseTypeDecl = function() { + var p, _tuple, pkg, name, obj, typ, name$1; + p = this; + p.expectKeyword("type"); + _tuple = p.parseExportedName(); pkg = _tuple[0]; name = _tuple[1]; + obj = declTypeName(pkg, name); + typ = p.parseType(); + name$1 = $assertType(obj.object.Type(), ($ptrType(types.Named))); + if ($interfaceIsEqual(name$1.Underlying(), $ifaceNil)) { + name$1.SetUnderlying(typ); } }; - scanner.prototype.popParseState = function() { return this.$val.popParseState(); }; - isSpace = function(c) { - return (c === 32) || (c === 9) || (c === 13) || (c === 10); + parser.prototype.parseTypeDecl = function() { return this.$val.parseTypeDecl(); }; + parser.Ptr.prototype.parseVarDecl = function() { + var p, _tuple, pkg, name, typ; + p = this; + p.expectKeyword("var"); + _tuple = p.parseExportedName(); pkg = _tuple[0]; name = _tuple[1]; + typ = p.parseType(); + pkg.Scope().Insert(types.NewVar(0, pkg, name, typ)); }; - stateBeginValueOrEmpty = function(s, c) { - if (c <= 32 && isSpace((c >> 0))) { - return 9; - } - if (c === 93) { - return stateEndValue(s, c); + parser.prototype.parseVarDecl = function() { return this.$val.parseVarDecl(); }; + parser.Ptr.prototype.parseFunc = function(recv) { + var p, sig, i, _ref; + p = this; + sig = p.parseSignature(recv); + if (p.tok === 123) { + p.next(); + i = 1; + while (i > 0) { + _ref = p.tok; + if (_ref === 123) { + i = i + (1) >> 0; + } else if (_ref === 125) { + i = i - (1) >> 0; + } + p.next(); + } } - return stateBeginValue(s, c); + return sig; }; - stateBeginValue = function(s, c) { - var _ref; - if (c <= 32 && isSpace((c >> 0))) { - return 9; - } - _ref = c; - if (_ref === 123) { - s.step = stateBeginStringOrEmpty; - s.pushParseState(0); - return 2; - } else if (_ref === 91) { - s.step = stateBeginValueOrEmpty; - s.pushParseState(2); - return 6; - } else if (_ref === 34) { - s.step = stateInString; - return 1; - } else if (_ref === 45) { - s.step = stateNeg; - return 1; - } else if (_ref === 48) { - s.step = state0; - return 1; - } else if (_ref === 116) { - s.step = stateT; - return 1; - } else if (_ref === 102) { - s.step = stateF; - return 1; - } else if (_ref === 110) { - s.step = stateN; - return 1; - } - if (49 <= c && c <= 57) { - s.step = state1; - return 1; + parser.prototype.parseFunc = function(recv) { return this.$val.parseFunc(recv); }; + parser.Ptr.prototype.parseMethodDecl = function() { + var p, _tuple, recv, base, _tuple$1, name, sig, pkg; + p = this; + p.expect(40); + _tuple = p.parseParameter(); recv = _tuple[0]; + p.expect(41); + base = $assertType(deref(recv.object.Type()), ($ptrType(types.Named))); + _tuple$1 = p.parseName(true); name = _tuple$1[1]; + sig = p.parseFunc(recv); + pkg = base.Obj().object.Pkg(); + base.AddMethod(types.NewFunc(0, pkg, name, sig)); + }; + parser.prototype.parseMethodDecl = function() { return this.$val.parseMethodDecl(); }; + parser.Ptr.prototype.parseFuncDecl = function() { + var p, _tuple, pkg, name, typ; + p = this; + _tuple = p.parseExportedName(); pkg = _tuple[0]; name = _tuple[1]; + typ = p.parseFunc(($ptrType(types.Var)).nil); + pkg.Scope().Insert(types.NewFunc(0, pkg, name, typ)); + }; + parser.prototype.parseFuncDecl = function() { return this.$val.parseFuncDecl(); }; + parser.Ptr.prototype.parseDecl = function() { + var p, _ref; + p = this; + if (p.tok === -2) { + _ref = p.lit; + if (_ref === "import") { + p.parseImportDecl(); + } else if (_ref === "const") { + p.parseConstDecl(); + } else if (_ref === "type") { + p.parseTypeDecl(); + } else if (_ref === "var") { + p.parseVarDecl(); + } else if (_ref === "func") { + p.next(); + if (p.tok === 40) { + p.parseMethodDecl(); + } else { + p.parseFuncDecl(); + } + } } - return s.error(c, "looking for beginning of value"); + p.expect(10); }; - stateBeginStringOrEmpty = function(s, c) { - var n, x, x$1; - if (c <= 32 && isSpace((c >> 0))) { - return 9; + parser.prototype.parseDecl = function() { return this.$val.parseDecl(); }; + parser.Ptr.prototype.parseExport = function() { + var p, name, pkg, ch, n; + p = this; + p.expectKeyword("package"); + name = p.parsePackageName(); + if ((p.tok === -2) && p.lit === "safe") { + p.next(); } - if (c === 125) { - n = s.parseState.$length; - (x = s.parseState, x$1 = n - 1 >> 0, (x$1 < 0 || x$1 >= x.$length) ? $throwRuntimeError("index out of range") : x.$array[x.$offset + x$1] = 1); - return stateEndValue(s, c); + p.expect(10); + pkg = p.getPkg(p.id, name); + while (!((p.tok === 36)) && !((p.tok === -1))) { + p.parseDecl(); } - return stateBeginString(s, c); - }; - stateBeginString = function(s, c) { - if (c <= 32 && isSpace((c >> 0))) { - return 9; + ch = p.scanner.Peek(); + if (!((p.tok === 36)) || !((ch === 36))) { + p.errorf("expected '$$', got %s %c", new ($sliceType($emptyInterface))([new $String(scanner.TokenString(p.tok)), new $Int32(ch)])); } - if (c === 34) { - s.step = stateInString; - return 1; + n = p.scanner.ErrorCount; + if (!((n === 0))) { + p.errorf("expected no scanner errors, got %d", new ($sliceType($emptyInterface))([new $Int(n)])); } - return s.error(c, "looking for beginning of object key string"); + pkg.MarkComplete(); + return pkg; }; - stateEndValue = function(s, c) { - var n, x, x$1, ps, _ref, x$2, x$3, x$4, x$5; - n = s.parseState.$length; - if (n === 0) { - s.step = stateEndTop; - s.endTop = true; - return stateEndTop(s, c); - } - if (c <= 32 && isSpace((c >> 0))) { - s.step = stateEndValue; - return 9; + parser.prototype.parseExport = function() { return this.$val.parseExport(); }; + $pkg.$init = function() { + ($ptrType(parser)).methods = [["error", "error", "code.google.com/p/go.tools/go/gcimporter", $funcType([$emptyInterface], [], false), -1], ["errorf", "errorf", "code.google.com/p/go.tools/go/gcimporter", $funcType([$String, ($sliceType($emptyInterface))], [], true), -1], ["expect", "expect", "code.google.com/p/go.tools/go/gcimporter", $funcType([$Int32], [$String], false), -1], ["expectKeyword", "expectKeyword", "code.google.com/p/go.tools/go/gcimporter", $funcType([$String], [], false), -1], ["expectSpecial", "expectSpecial", "code.google.com/p/go.tools/go/gcimporter", $funcType([$String], [], false), -1], ["getPkg", "getPkg", "code.google.com/p/go.tools/go/gcimporter", $funcType([$String, $String], [($ptrType(types.Package))], false), -1], ["init", "init", "code.google.com/p/go.tools/go/gcimporter", $funcType([$String, $String, io.Reader, ($mapType($String, ($ptrType(types.Package))))], [], false), -1], ["next", "next", "code.google.com/p/go.tools/go/gcimporter", $funcType([], [], false), -1], ["parseArrayType", "parseArrayType", "code.google.com/p/go.tools/go/gcimporter", $funcType([], [types.Type], false), -1], ["parseBasicType", "parseBasicType", "code.google.com/p/go.tools/go/gcimporter", $funcType([], [types.Type], false), -1], ["parseChanType", "parseChanType", "code.google.com/p/go.tools/go/gcimporter", $funcType([], [types.Type], false), -1], ["parseConstDecl", "parseConstDecl", "code.google.com/p/go.tools/go/gcimporter", $funcType([], [], false), -1], ["parseDecl", "parseDecl", "code.google.com/p/go.tools/go/gcimporter", $funcType([], [], false), -1], ["parseDotIdent", "parseDotIdent", "code.google.com/p/go.tools/go/gcimporter", $funcType([], [$String], false), -1], ["parseExport", "parseExport", "code.google.com/p/go.tools/go/gcimporter", $funcType([], [($ptrType(types.Package))], false), -1], ["parseExportedName", "parseExportedName", "code.google.com/p/go.tools/go/gcimporter", $funcType([], [($ptrType(types.Package)), $String], false), -1], ["parseField", "parseField", "code.google.com/p/go.tools/go/gcimporter", $funcType([], [($ptrType(types.Var)), $String], false), -1], ["parseFunc", "parseFunc", "code.google.com/p/go.tools/go/gcimporter", $funcType([($ptrType(types.Var))], [($ptrType(types.Signature))], false), -1], ["parseFuncDecl", "parseFuncDecl", "code.google.com/p/go.tools/go/gcimporter", $funcType([], [], false), -1], ["parseImportDecl", "parseImportDecl", "code.google.com/p/go.tools/go/gcimporter", $funcType([], [], false), -1], ["parseInt", "parseInt", "code.google.com/p/go.tools/go/gcimporter", $funcType([], [$String], false), -1], ["parseInterfaceType", "parseInterfaceType", "code.google.com/p/go.tools/go/gcimporter", $funcType([], [types.Type], false), -1], ["parseMapType", "parseMapType", "code.google.com/p/go.tools/go/gcimporter", $funcType([], [types.Type], false), -1], ["parseMethodDecl", "parseMethodDecl", "code.google.com/p/go.tools/go/gcimporter", $funcType([], [], false), -1], ["parseName", "parseName", "code.google.com/p/go.tools/go/gcimporter", $funcType([$Bool], [($ptrType(types.Package)), $String], false), -1], ["parseNumber", "parseNumber", "code.google.com/p/go.tools/go/gcimporter", $funcType([], [($ptrType(types.Basic)), exact.Value], false), -1], ["parsePackageId", "parsePackageId", "code.google.com/p/go.tools/go/gcimporter", $funcType([], [$String], false), -1], ["parsePackageName", "parsePackageName", "code.google.com/p/go.tools/go/gcimporter", $funcType([], [$String], false), -1], ["parseParameter", "parseParameter", "code.google.com/p/go.tools/go/gcimporter", $funcType([], [($ptrType(types.Var)), $Bool], false), -1], ["parseParameters", "parseParameters", "code.google.com/p/go.tools/go/gcimporter", $funcType([], [($sliceType(($ptrType(types.Var)))), $Bool], false), -1], ["parseQualifiedName", "parseQualifiedName", "code.google.com/p/go.tools/go/gcimporter", $funcType([], [$String, $String], false), -1], ["parseSignature", "parseSignature", "code.google.com/p/go.tools/go/gcimporter", $funcType([($ptrType(types.Var))], [($ptrType(types.Signature))], false), -1], ["parseStructType", "parseStructType", "code.google.com/p/go.tools/go/gcimporter", $funcType([], [types.Type], false), -1], ["parseType", "parseType", "code.google.com/p/go.tools/go/gcimporter", $funcType([], [types.Type], false), -1], ["parseTypeDecl", "parseTypeDecl", "code.google.com/p/go.tools/go/gcimporter", $funcType([], [], false), -1], ["parseVarDecl", "parseVarDecl", "code.google.com/p/go.tools/go/gcimporter", $funcType([], [], false), -1]]; + parser.init([["scanner", "scanner", "code.google.com/p/go.tools/go/gcimporter", scanner.Scanner, ""], ["tok", "tok", "code.google.com/p/go.tools/go/gcimporter", $Int32, ""], ["lit", "lit", "code.google.com/p/go.tools/go/gcimporter", $String, ""], ["id", "id", "code.google.com/p/go.tools/go/gcimporter", $String, ""], ["imports", "imports", "code.google.com/p/go.tools/go/gcimporter", ($mapType($String, ($ptrType(types.Package)))), ""]]); + importError.methods = [["Error", "Error", "", $funcType([], [$String], false), -1]]; + ($ptrType(importError)).methods = [["Error", "Error", "", $funcType([], [$String], false), -1]]; + importError.init([["pos", "pos", "code.google.com/p/go.tools/go/gcimporter", scanner.Position, ""], ["err", "err", "code.google.com/p/go.tools/go/gcimporter", $error, ""]]); + pkgExts = $toNativeArray("String", [".a", ".5", ".6", ".8"]); + init(); + }; + return $pkg; +})(); +$packages["encoding/asn1"] = (function() { + var $pkg = {}, fmt = $packages["fmt"], big = $packages["math/big"], reflect = $packages["reflect"], strconv = $packages["strconv"], time = $packages["time"], strings = $packages["strings"], bytes = $packages["bytes"], errors = $packages["errors"], io = $packages["io"], utf8 = $packages["unicode/utf8"], StructuralError, SyntaxError, BitString, ObjectIdentifier, Enumerated, Flag, RawValue, RawContent, tagAndLength, fieldParameters, bigOne, bitStringType, objectIdentifierType, enumeratedType, flagType, timeType, rawValueType, rawContentsType, bigIntType, x, x$1, x$2, parseBool, parseInt64, parseInt32, parseBigInt, parseBitString, parseObjectIdentifier, parseBase128Int, parseUTCTime, parseGeneralizedTime, parsePrintableString, isPrintable, parseIA5String, parseT61String, parseUTF8String, parseTagAndLength, parseSequenceOf, invalidLength, parseField, setDefaultValue, Unmarshal, UnmarshalWithParams, parseFieldParameters, getUniversalType; + StructuralError = $pkg.StructuralError = $newType(0, "Struct", "asn1.StructuralError", "StructuralError", "encoding/asn1", function(Msg_) { + this.$val = this; + this.Msg = Msg_ !== undefined ? Msg_ : ""; + }); + SyntaxError = $pkg.SyntaxError = $newType(0, "Struct", "asn1.SyntaxError", "SyntaxError", "encoding/asn1", function(Msg_) { + this.$val = this; + this.Msg = Msg_ !== undefined ? Msg_ : ""; + }); + BitString = $pkg.BitString = $newType(0, "Struct", "asn1.BitString", "BitString", "encoding/asn1", function(Bytes_, BitLength_) { + this.$val = this; + this.Bytes = Bytes_ !== undefined ? Bytes_ : ($sliceType($Uint8)).nil; + this.BitLength = BitLength_ !== undefined ? BitLength_ : 0; + }); + ObjectIdentifier = $pkg.ObjectIdentifier = $newType(12, "Slice", "asn1.ObjectIdentifier", "ObjectIdentifier", "encoding/asn1", null); + Enumerated = $pkg.Enumerated = $newType(4, "Int", "asn1.Enumerated", "Enumerated", "encoding/asn1", null); + Flag = $pkg.Flag = $newType(1, "Bool", "asn1.Flag", "Flag", "encoding/asn1", null); + RawValue = $pkg.RawValue = $newType(0, "Struct", "asn1.RawValue", "RawValue", "encoding/asn1", function(Class_, Tag_, IsCompound_, Bytes_, FullBytes_) { + this.$val = this; + this.Class = Class_ !== undefined ? Class_ : 0; + this.Tag = Tag_ !== undefined ? Tag_ : 0; + this.IsCompound = IsCompound_ !== undefined ? IsCompound_ : false; + this.Bytes = Bytes_ !== undefined ? Bytes_ : ($sliceType($Uint8)).nil; + this.FullBytes = FullBytes_ !== undefined ? FullBytes_ : ($sliceType($Uint8)).nil; + }); + RawContent = $pkg.RawContent = $newType(12, "Slice", "asn1.RawContent", "RawContent", "encoding/asn1", null); + tagAndLength = $pkg.tagAndLength = $newType(0, "Struct", "asn1.tagAndLength", "tagAndLength", "encoding/asn1", function(class$0_, tag_, length_, isCompound_) { + this.$val = this; + this.class$0 = class$0_ !== undefined ? class$0_ : 0; + this.tag = tag_ !== undefined ? tag_ : 0; + this.length = length_ !== undefined ? length_ : 0; + this.isCompound = isCompound_ !== undefined ? isCompound_ : false; + }); + fieldParameters = $pkg.fieldParameters = $newType(0, "Struct", "asn1.fieldParameters", "fieldParameters", "encoding/asn1", function(optional_, explicit_, application_, defaultValue_, tag_, stringType_, set_, omitEmpty_) { + this.$val = this; + this.optional = optional_ !== undefined ? optional_ : false; + this.explicit = explicit_ !== undefined ? explicit_ : false; + this.application = application_ !== undefined ? application_ : false; + this.defaultValue = defaultValue_ !== undefined ? defaultValue_ : ($ptrType($Int64)).nil; + this.tag = tag_ !== undefined ? tag_ : ($ptrType($Int)).nil; + this.stringType = stringType_ !== undefined ? stringType_ : 0; + this.set = set_ !== undefined ? set_ : false; + this.omitEmpty = omitEmpty_ !== undefined ? omitEmpty_ : false; + }); + StructuralError.Ptr.prototype.Error = function() { + var e; + e = new StructuralError.Ptr(); $copy(e, this, StructuralError); + return "asn1: structure error: " + e.Msg; + }; + StructuralError.prototype.Error = function() { return this.$val.Error(); }; + SyntaxError.Ptr.prototype.Error = function() { + var e; + e = new SyntaxError.Ptr(); $copy(e, this, SyntaxError); + return "asn1: syntax error: " + e.Msg; + }; + SyntaxError.prototype.Error = function() { return this.$val.Error(); }; + parseBool = function(bytes$1) { + var ret = false, err = $ifaceNil, x$3, _ref, x$4; + if (!((bytes$1.$length === 1))) { + err = (x$3 = new SyntaxError.Ptr("invalid boolean"), new x$3.constructor.Struct(x$3)); + return [ret, err]; } - ps = (x = s.parseState, x$1 = n - 1 >> 0, ((x$1 < 0 || x$1 >= x.$length) ? $throwRuntimeError("index out of range") : x.$array[x.$offset + x$1])); - _ref = ps; + _ref = ((0 < 0 || 0 >= bytes$1.$length) ? $throwRuntimeError("index out of range") : bytes$1.$array[bytes$1.$offset + 0]); if (_ref === 0) { - if (c === 58) { - (x$2 = s.parseState, x$3 = n - 1 >> 0, (x$3 < 0 || x$3 >= x$2.$length) ? $throwRuntimeError("index out of range") : x$2.$array[x$2.$offset + x$3] = 1); - s.step = stateBeginValue; - return 3; - } - return s.error(c, "after object key"); - } else if (_ref === 1) { - if (c === 44) { - (x$4 = s.parseState, x$5 = n - 1 >> 0, (x$5 < 0 || x$5 >= x$4.$length) ? $throwRuntimeError("index out of range") : x$4.$array[x$4.$offset + x$5] = 0); - s.step = stateBeginString; - return 4; - } - if (c === 125) { - s.popParseState(); - return 5; - } - return s.error(c, "after object key:value pair"); - } else if (_ref === 2) { - if (c === 44) { - s.step = stateBeginValue; - return 7; - } - if (c === 93) { - s.popParseState(); - return 8; - } - return s.error(c, "after array element"); - } - return s.error(c, ""); - }; - stateEndTop = function(s, c) { - if (!((c === 32)) && !((c === 9)) && !((c === 13)) && !((c === 10))) { - s.error(c, "after top-level value"); + ret = false; + } else if (_ref === 255) { + ret = true; + } else { + err = (x$4 = new SyntaxError.Ptr("invalid boolean"), new x$4.constructor.Struct(x$4)); } - return 10; + return [ret, err]; }; - stateInString = function(s, c) { - if (c === 34) { - s.step = stateEndValue; - return 0; - } - if (c === 92) { - s.step = stateInStringEsc; - return 0; + parseInt64 = function(bytes$1) { + var ret = new $Int64(0, 0), err = $ifaceNil, x$3, bytesRead, x$4; + if (bytes$1.$length > 8) { + err = (x$3 = new StructuralError.Ptr("integer too large"), new x$3.constructor.Struct(x$3)); + return [ret, err]; } - if (c < 32) { - return s.error(c, "in string literal"); + bytesRead = 0; + while (bytesRead < bytes$1.$length) { + ret = $shiftLeft64(ret, (8)); + ret = (x$4 = new $Int64(0, ((bytesRead < 0 || bytesRead >= bytes$1.$length) ? $throwRuntimeError("index out of range") : bytes$1.$array[bytes$1.$offset + bytesRead])), new $Int64(ret.$high | x$4.$high, (ret.$low | x$4.$low) >>> 0)); + bytesRead = bytesRead + (1) >> 0; } - return 0; + ret = $shiftLeft64(ret, ((64 - ((bytes$1.$length << 24 >>> 24) * 8 << 24 >>> 24) << 24 >>> 24))); + ret = $shiftRightInt64(ret, ((64 - ((bytes$1.$length << 24 >>> 24) * 8 << 24 >>> 24) << 24 >>> 24))); + return [ret, err]; }; - stateInStringEsc = function(s, c) { - var _ref; - _ref = c; - if (_ref === 98 || _ref === 102 || _ref === 110 || _ref === 114 || _ref === 116 || _ref === 92 || _ref === 47 || _ref === 34) { - s.step = stateInString; - return 0; + parseInt32 = function(bytes$1) { + var _tuple, ret64, err, x$3, x$4; + _tuple = parseInt64(bytes$1); ret64 = _tuple[0]; err = _tuple[1]; + if (!($interfaceIsEqual(err, $ifaceNil))) { + return [0, err]; } - if (c === 117) { - s.step = stateInStringEscU; - return 0; + if (!((x$3 = new $Int64(0, ((ret64.$low + ((ret64.$high >> 31) * 4294967296)) >> 0)), (ret64.$high === x$3.$high && ret64.$low === x$3.$low)))) { + return [0, (x$4 = new StructuralError.Ptr("integer too large"), new x$4.constructor.Struct(x$4))]; } - return s.error(c, "in string escape code"); + return [((ret64.$low + ((ret64.$high >> 31) * 4294967296)) >> 0), $ifaceNil]; }; - stateInStringEscU = function(s, c) { - if (48 <= c && c <= 57 || 97 <= c && c <= 102 || 65 <= c && c <= 70) { - s.step = stateInStringEscU1; - return 0; + parseBigInt = function(bytes$1) { + var ret, notBytes, _ref, _i, i; + ret = new big.Int.Ptr(); + if (bytes$1.$length > 0 && (((((0 < 0 || 0 >= bytes$1.$length) ? $throwRuntimeError("index out of range") : bytes$1.$array[bytes$1.$offset + 0]) & 128) >>> 0) === 128)) { + notBytes = ($sliceType($Uint8)).make(bytes$1.$length); + _ref = notBytes; + _i = 0; + while (_i < _ref.$length) { + i = _i; + (i < 0 || i >= notBytes.$length) ? $throwRuntimeError("index out of range") : notBytes.$array[notBytes.$offset + i] = ~((i < 0 || i >= bytes$1.$length) ? $throwRuntimeError("index out of range") : bytes$1.$array[bytes$1.$offset + i]) << 24 >>> 24; + _i++; + } + ret.SetBytes(notBytes); + ret.Add(ret, bigOne); + ret.Neg(ret); + return ret; } - return s.error(c, "in \\u hexadecimal character escape"); + ret.SetBytes(bytes$1); + return ret; }; - stateInStringEscU1 = function(s, c) { - if (48 <= c && c <= 57 || 97 <= c && c <= 102 || 65 <= c && c <= 70) { - s.step = stateInStringEscU12; + BitString.Ptr.prototype.At = function(i) { + var b, _q, x$3, _r, y, y$1, x$4; + b = new BitString.Ptr(); $copy(b, this, BitString); + if (i < 0 || i >= b.BitLength) { return 0; } - return s.error(c, "in \\u hexadecimal character escape"); + x$3 = (_q = i / 8, (_q === _q && _q !== 1/0 && _q !== -1/0) ? _q >> 0 : $throwRuntimeError("integer divide by zero")); + y = 7 - ((_r = i % 8, _r === _r ? _r : $throwRuntimeError("integer divide by zero")) >>> 0) >>> 0; + return (((y$1 = y, y$1 < 32 ? ((x$4 = b.Bytes, ((x$3 < 0 || x$3 >= x$4.$length) ? $throwRuntimeError("index out of range") : x$4.$array[x$4.$offset + x$3])) >>> y$1) : 0) << 24 >>> 24) >> 0) & 1; }; - stateInStringEscU12 = function(s, c) { - if (48 <= c && c <= 57 || 97 <= c && c <= 102 || 65 <= c && c <= 70) { - s.step = stateInStringEscU123; - return 0; + BitString.prototype.At = function(i) { return this.$val.At(i); }; + BitString.Ptr.prototype.RightAlign = function() { + var b, _r, shift, a, y, x$3, i, y$1, x$4, x$5, _lhs, _index, y$2, x$6; + b = new BitString.Ptr(); $copy(b, this, BitString); + shift = ((8 - ((_r = b.BitLength % 8, _r === _r ? _r : $throwRuntimeError("integer divide by zero"))) >> 0) >>> 0); + if ((shift === 8) || (b.Bytes.$length === 0)) { + return b.Bytes; } - return s.error(c, "in \\u hexadecimal character escape"); - }; - stateInStringEscU123 = function(s, c) { - if (48 <= c && c <= 57 || 97 <= c && c <= 102 || 65 <= c && c <= 70) { - s.step = stateInString; - return 0; + a = ($sliceType($Uint8)).make(b.Bytes.$length); + (0 < 0 || 0 >= a.$length) ? $throwRuntimeError("index out of range") : a.$array[a.$offset + 0] = (y = shift, y < 32 ? ((x$3 = b.Bytes, ((0 < 0 || 0 >= x$3.$length) ? $throwRuntimeError("index out of range") : x$3.$array[x$3.$offset + 0])) >>> y) : 0) << 24 >>> 24; + i = 1; + while (i < b.Bytes.$length) { + (i < 0 || i >= a.$length) ? $throwRuntimeError("index out of range") : a.$array[a.$offset + i] = (y$1 = ((8 - shift >>> 0)), y$1 < 32 ? ((x$4 = b.Bytes, x$5 = i - 1 >> 0, ((x$5 < 0 || x$5 >= x$4.$length) ? $throwRuntimeError("index out of range") : x$4.$array[x$4.$offset + x$5])) << y$1) : 0) << 24 >>> 24; + _lhs = a; _index = i; (_index < 0 || _index >= _lhs.$length) ? $throwRuntimeError("index out of range") : _lhs.$array[_lhs.$offset + _index] = (((_index < 0 || _index >= _lhs.$length) ? $throwRuntimeError("index out of range") : _lhs.$array[_lhs.$offset + _index]) | (((y$2 = shift, y$2 < 32 ? ((x$6 = b.Bytes, ((i < 0 || i >= x$6.$length) ? $throwRuntimeError("index out of range") : x$6.$array[x$6.$offset + i])) >>> y$2) : 0) << 24 >>> 24))) >>> 0; + i = i + (1) >> 0; } - return s.error(c, "in \\u hexadecimal character escape"); + return a; }; - stateNeg = function(s, c) { - if (c === 48) { - s.step = state0; - return 0; - } - if (49 <= c && c <= 57) { - s.step = state1; - return 0; + BitString.prototype.RightAlign = function() { return this.$val.RightAlign(); }; + parseBitString = function(bytes$1) { + var ret = new BitString.Ptr(), err = $ifaceNil, x$3, paddingBits, x$4, y, x$5, x$6; + if (bytes$1.$length === 0) { + err = (x$3 = new SyntaxError.Ptr("zero length BIT STRING"), new x$3.constructor.Struct(x$3)); + return [ret, err]; } - return s.error(c, "in numeric literal"); - }; - state1 = function(s, c) { - if (48 <= c && c <= 57) { - s.step = state1; - return 0; + paddingBits = (((0 < 0 || 0 >= bytes$1.$length) ? $throwRuntimeError("index out of range") : bytes$1.$array[bytes$1.$offset + 0]) >> 0); + if (paddingBits > 7 || (bytes$1.$length === 1) && paddingBits > 0 || !(((((x$4 = bytes$1.$length - 1 >> 0, ((x$4 < 0 || x$4 >= bytes$1.$length) ? $throwRuntimeError("index out of range") : bytes$1.$array[bytes$1.$offset + x$4])) & (((((y = ((0 < 0 || 0 >= bytes$1.$length) ? $throwRuntimeError("index out of range") : bytes$1.$array[bytes$1.$offset + 0]), y < 32 ? (1 << y) : 0) << 24 >>> 24)) - 1 << 24 >>> 24))) >>> 0) === 0))) { + err = (x$5 = new SyntaxError.Ptr("invalid padding bits in BIT STRING"), new x$5.constructor.Struct(x$5)); + return [ret, err]; } - return state0(s, c); + ret.BitLength = (x$6 = (bytes$1.$length - 1 >> 0), (((x$6 >>> 16 << 16) * 8 >> 0) + (x$6 << 16 >>> 16) * 8) >> 0) - paddingBits >> 0; + ret.Bytes = $subslice(bytes$1, 1); + return [ret, err]; }; - state0 = function(s, c) { - if (c === 46) { - s.step = stateDot; - return 0; + ObjectIdentifier.prototype.Equal = function(other) { + var oi, i; + oi = this; + if (!((oi.$length === other.$length))) { + return false; } - if ((c === 101) || (c === 69)) { - s.step = stateE; - return 0; + i = 0; + while (i < oi.$length) { + if (!((((i < 0 || i >= oi.$length) ? $throwRuntimeError("index out of range") : oi.$array[oi.$offset + i]) === ((i < 0 || i >= other.$length) ? $throwRuntimeError("index out of range") : other.$array[other.$offset + i])))) { + return false; + } + i = i + (1) >> 0; } - return stateEndValue(s, c); + return true; }; - stateDot = function(s, c) { - if (48 <= c && c <= 57) { - s.step = stateDot0; - return 0; + $ptrType(ObjectIdentifier).prototype.Equal = function(other) { return this.$get().Equal(other); }; + ObjectIdentifier.prototype.String = function() { + var oi, s, _ref, _i, i, v; + oi = this; + s = ""; + _ref = oi; + _i = 0; + while (_i < _ref.$length) { + i = _i; + v = ((_i < 0 || _i >= _ref.$length) ? $throwRuntimeError("index out of range") : _ref.$array[_ref.$offset + _i]); + if (i > 0) { + s = s + ("."); + } + s = s + (strconv.Itoa(v)); + _i++; } - return s.error(c, "after decimal point in numeric literal"); + return s; }; - stateDot0 = function(s, c) { - if (48 <= c && c <= 57) { - s.step = stateDot0; - return 0; + $ptrType(ObjectIdentifier).prototype.String = function() { return this.$get().String(); }; + parseObjectIdentifier = function(bytes$1) { + var s = ($sliceType($Int)).nil, err = $ifaceNil, x$3, _tuple, v, offset, _q, _r, i, _tuple$1; + if (bytes$1.$length === 0) { + err = (x$3 = new SyntaxError.Ptr("zero length OBJECT IDENTIFIER"), new x$3.constructor.Struct(x$3)); + return [s, err]; } - if ((c === 101) || (c === 69)) { - s.step = stateE; - return 0; + s = ($sliceType($Int)).make((bytes$1.$length + 1 >> 0)); + _tuple = parseBase128Int(bytes$1, 0); v = _tuple[0]; offset = _tuple[1]; err = _tuple[2]; + if (!($interfaceIsEqual(err, $ifaceNil))) { + return [s, err]; } - return stateEndValue(s, c); - }; - stateE = function(s, c) { - if (c === 43) { - s.step = stateESign; - return 0; + if (v < 80) { + (0 < 0 || 0 >= s.$length) ? $throwRuntimeError("index out of range") : s.$array[s.$offset + 0] = (_q = v / 40, (_q === _q && _q !== 1/0 && _q !== -1/0) ? _q >> 0 : $throwRuntimeError("integer divide by zero")); + (1 < 0 || 1 >= s.$length) ? $throwRuntimeError("index out of range") : s.$array[s.$offset + 1] = (_r = v % 40, _r === _r ? _r : $throwRuntimeError("integer divide by zero")); + } else { + (0 < 0 || 0 >= s.$length) ? $throwRuntimeError("index out of range") : s.$array[s.$offset + 0] = 2; + (1 < 0 || 1 >= s.$length) ? $throwRuntimeError("index out of range") : s.$array[s.$offset + 1] = v - 80 >> 0; } - if (c === 45) { - s.step = stateESign; - return 0; + i = 2; + while (offset < bytes$1.$length) { + _tuple$1 = parseBase128Int(bytes$1, offset); v = _tuple$1[0]; offset = _tuple$1[1]; err = _tuple$1[2]; + if (!($interfaceIsEqual(err, $ifaceNil))) { + return [s, err]; + } + (i < 0 || i >= s.$length) ? $throwRuntimeError("index out of range") : s.$array[s.$offset + i] = v; + i = i + (1) >> 0; } - return stateESign(s, c); + s = $subslice(s, 0, i); + return [s, err]; }; - stateESign = function(s, c) { - if (48 <= c && c <= 57) { - s.step = stateE0; - return 0; + parseBase128Int = function(bytes$1, initOffset) { + var ret = 0, offset = 0, err = $ifaceNil, shifted, x$3, y, b, x$4; + offset = initOffset; + shifted = 0; + while (offset < bytes$1.$length) { + if (shifted > 4) { + err = (x$3 = new StructuralError.Ptr("base 128 integer too large"), new x$3.constructor.Struct(x$3)); + return [ret, offset, err]; + } + ret = (y = (7), y < 32 ? (ret << y) : 0) >> 0; + b = ((offset < 0 || offset >= bytes$1.$length) ? $throwRuntimeError("index out of range") : bytes$1.$array[bytes$1.$offset + offset]); + ret = ret | ((((b & 127) >>> 0) >> 0)); + offset = offset + (1) >> 0; + if (((b & 128) >>> 0) === 0) { + return [ret, offset, err]; + } + shifted = shifted + (1) >> 0; } - return s.error(c, "in exponent of numeric literal"); + err = (x$4 = new SyntaxError.Ptr("truncated base 128 integer"), new x$4.constructor.Struct(x$4)); + return [ret, offset, err]; }; - stateE0 = function(s, c) { - if (48 <= c && c <= 57) { - s.step = stateE0; - return 0; + parseUTCTime = function(bytes$1) { + var ret = new time.Time.Ptr(), err = $ifaceNil, s, _tuple, _tuple$1; + s = $bytesToString(bytes$1); + _tuple = time.Parse("0601021504Z0700", s); $copy(ret, _tuple[0], time.Time); err = _tuple[1]; + if (!($interfaceIsEqual(err, $ifaceNil))) { + _tuple$1 = time.Parse("060102150405Z0700", s); $copy(ret, _tuple$1[0], time.Time); err = _tuple$1[1]; } - return stateEndValue(s, c); - }; - stateT = function(s, c) { - if (c === 114) { - s.step = stateTr; - return 0; + if ($interfaceIsEqual(err, $ifaceNil) && ret.Year() >= 2050) { + $copy(ret, ret.AddDate(-100, 0, 0), time.Time); } - return s.error(c, "in literal true (expecting 'r')"); + return [ret, err]; }; - stateTr = function(s, c) { - if (c === 117) { - s.step = stateTru; - return 0; - } - return s.error(c, "in literal true (expecting 'u')"); + parseGeneralizedTime = function(bytes$1) { + var ret = new time.Time.Ptr(), err = $ifaceNil, _tuple; + _tuple = time.Parse("20060102150405Z0700", $bytesToString(bytes$1)); $copy(ret, _tuple[0], time.Time); err = _tuple[1]; + return [ret, err]; }; - stateTru = function(s, c) { - if (c === 101) { - s.step = stateEndValue; - return 0; + parsePrintableString = function(bytes$1) { + var ret = "", err = $ifaceNil, _ref, _i, b, x$3; + _ref = bytes$1; + _i = 0; + while (_i < _ref.$length) { + b = ((_i < 0 || _i >= _ref.$length) ? $throwRuntimeError("index out of range") : _ref.$array[_ref.$offset + _i]); + if (!isPrintable(b)) { + err = (x$3 = new SyntaxError.Ptr("PrintableString contains invalid character"), new x$3.constructor.Struct(x$3)); + return [ret, err]; + } + _i++; } - return s.error(c, "in literal true (expecting 'e')"); + ret = $bytesToString(bytes$1); + return [ret, err]; }; - stateF = function(s, c) { - if (c === 97) { - s.step = stateFa; - return 0; - } - return s.error(c, "in literal false (expecting 'a')"); + isPrintable = function(b) { + return 97 <= b && b <= 122 || 65 <= b && b <= 90 || 48 <= b && b <= 57 || 39 <= b && b <= 41 || 43 <= b && b <= 47 || (b === 32) || (b === 58) || (b === 61) || (b === 63) || (b === 42); }; - stateFa = function(s, c) { - if (c === 108) { - s.step = stateFal; - return 0; + parseIA5String = function(bytes$1) { + var ret = "", err = $ifaceNil, _ref, _i, b, x$3; + _ref = bytes$1; + _i = 0; + while (_i < _ref.$length) { + b = ((_i < 0 || _i >= _ref.$length) ? $throwRuntimeError("index out of range") : _ref.$array[_ref.$offset + _i]); + if (b >= 128) { + err = (x$3 = new SyntaxError.Ptr("IA5String contains invalid character"), new x$3.constructor.Struct(x$3)); + return [ret, err]; + } + _i++; } - return s.error(c, "in literal false (expecting 'l')"); + ret = $bytesToString(bytes$1); + return [ret, err]; }; - stateFal = function(s, c) { - if (c === 115) { - s.step = stateFals; - return 0; - } - return s.error(c, "in literal false (expecting 's')"); + parseT61String = function(bytes$1) { + var ret = "", err = $ifaceNil, _tmp, _tmp$1; + _tmp = $bytesToString(bytes$1); _tmp$1 = $ifaceNil; ret = _tmp; err = _tmp$1; + return [ret, err]; }; - stateFals = function(s, c) { - if (c === 101) { - s.step = stateEndValue; - return 0; - } - return s.error(c, "in literal false (expecting 'e')"); + parseUTF8String = function(bytes$1) { + var ret = "", err = $ifaceNil, _tmp, _tmp$1; + _tmp = $bytesToString(bytes$1); _tmp$1 = $ifaceNil; ret = _tmp; err = _tmp$1; + return [ret, err]; }; - stateN = function(s, c) { - if (c === 117) { - s.step = stateNu; - return 0; + parseTagAndLength = function(bytes$1, initOffset) { + var ret = new tagAndLength.Ptr(), offset = 0, err = $ifaceNil, b, _tuple, x$3, numBytes, x$4, i, x$5, x$6, y, x$7; + offset = initOffset; + b = ((offset < 0 || offset >= bytes$1.$length) ? $throwRuntimeError("index out of range") : bytes$1.$array[bytes$1.$offset + offset]); + offset = offset + (1) >> 0; + ret.class$0 = ((b >>> 6 << 24 >>> 24) >> 0); + ret.isCompound = ((b & 32) >>> 0) === 32; + ret.tag = (((b & 31) >>> 0) >> 0); + if (ret.tag === 31) { + _tuple = parseBase128Int(bytes$1, offset); ret.tag = _tuple[0]; offset = _tuple[1]; err = _tuple[2]; + if (!($interfaceIsEqual(err, $ifaceNil))) { + return [ret, offset, err]; + } } - return s.error(c, "in literal null (expecting 'u')"); - }; - stateNu = function(s, c) { - if (c === 108) { - s.step = stateNul; - return 0; + if (offset >= bytes$1.$length) { + err = (x$3 = new SyntaxError.Ptr("truncated tag or length"), new x$3.constructor.Struct(x$3)); + return [ret, offset, err]; } - return s.error(c, "in literal null (expecting 'l')"); - }; - stateNul = function(s, c) { - if (c === 108) { - s.step = stateEndValue; - return 0; + b = ((offset < 0 || offset >= bytes$1.$length) ? $throwRuntimeError("index out of range") : bytes$1.$array[bytes$1.$offset + offset]); + offset = offset + (1) >> 0; + if (((b & 128) >>> 0) === 0) { + ret.length = (((b & 127) >>> 0) >> 0); + } else { + numBytes = (((b & 127) >>> 0) >> 0); + if (numBytes === 0) { + err = (x$4 = new SyntaxError.Ptr("indefinite length found (not DER)"), new x$4.constructor.Struct(x$4)); + return [ret, offset, err]; + } + ret.length = 0; + i = 0; + while (i < numBytes) { + if (offset >= bytes$1.$length) { + err = (x$5 = new SyntaxError.Ptr("truncated tag or length"), new x$5.constructor.Struct(x$5)); + return [ret, offset, err]; + } + b = ((offset < 0 || offset >= bytes$1.$length) ? $throwRuntimeError("index out of range") : bytes$1.$array[bytes$1.$offset + offset]); + offset = offset + (1) >> 0; + if (ret.length >= 8388608) { + err = (x$6 = new StructuralError.Ptr("length too large"), new x$6.constructor.Struct(x$6)); + return [ret, offset, err]; + } + ret.length = (y = (8), y < 32 ? (ret.length << y) : 0) >> 0; + ret.length = ret.length | ((b >> 0)); + if (ret.length === 0) { + err = (x$7 = new StructuralError.Ptr("superfluous leading zeros in length"), new x$7.constructor.Struct(x$7)); + return [ret, offset, err]; + } + i = i + (1) >> 0; + } } - return s.error(c, "in literal null (expecting 'l')"); + return [ret, offset, err]; }; - stateError = function(s, c) { - return 11; + parseSequenceOf = function(bytes$1, sliceType, elemType) { + var ret = new reflect.Value.Ptr(), err = $ifaceNil, _tuple, expectedTag, compoundType, ok, x$3, numElements, offset, t, _tuple$1, _ref, x$4, x$5, params, offset$1, i, _tuple$2; + _tuple = getUniversalType(elemType); expectedTag = _tuple[0]; compoundType = _tuple[1]; ok = _tuple[2]; + if (!ok) { + err = (x$3 = new StructuralError.Ptr("unknown Go type for slice"), new x$3.constructor.Struct(x$3)); + return [ret, err]; + } + numElements = 0; + offset = 0; + while (offset < bytes$1.$length) { + t = new tagAndLength.Ptr(); $copy(t, new tagAndLength.Ptr(), tagAndLength); + _tuple$1 = parseTagAndLength(bytes$1, offset); $copy(t, _tuple$1[0], tagAndLength); offset = _tuple$1[1]; err = _tuple$1[2]; + if (!($interfaceIsEqual(err, $ifaceNil))) { + return [ret, err]; + } + _ref = t.tag; + if (_ref === 22 || _ref === 27 || _ref === 20 || _ref === 12) { + t.tag = 19; + } else if (_ref === 24 || _ref === 23) { + t.tag = 23; + } + if (!((t.class$0 === 0)) || !(t.isCompound === compoundType) || !((t.tag === expectedTag))) { + err = (x$4 = new StructuralError.Ptr("sequence tag mismatch"), new x$4.constructor.Struct(x$4)); + return [ret, err]; + } + if (invalidLength(offset, t.length, bytes$1.$length)) { + err = (x$5 = new SyntaxError.Ptr("truncated sequence"), new x$5.constructor.Struct(x$5)); + return [ret, err]; + } + offset = offset + (t.length) >> 0; + numElements = numElements + (1) >> 0; + } + $copy(ret, reflect.MakeSlice(sliceType, numElements, numElements), reflect.Value); + params = new fieldParameters.Ptr(false, false, false, ($ptrType($Int64)).nil, ($ptrType($Int)).nil, 0, false, false); + offset$1 = 0; + i = 0; + while (i < numElements) { + _tuple$2 = parseField($clone(ret.Index(i), reflect.Value), bytes$1, offset$1, $clone(params, fieldParameters)); offset$1 = _tuple$2[0]; err = _tuple$2[1]; + if (!($interfaceIsEqual(err, $ifaceNil))) { + return [ret, err]; + } + i = i + (1) >> 0; + } + return [ret, err]; }; - scanner.Ptr.prototype.error = function(c, context) { - var s; - s = this; - s.step = stateError; - s.err = new SyntaxError.Ptr("invalid character " + quoteChar(c) + " " + context, s.bytes); - return 11; + invalidLength = function(offset, length, sliceLength) { + return (offset + length >> 0) < offset || (offset + length >> 0) > sliceLength; }; - scanner.prototype.error = function(c, context) { return this.$val.error(c, context); }; - quoteChar = function(c) { - var s; - if (c === 39) { - return "'\\''"; + parseField = function(v, bytes$1, initOffset, params) { + var offset = 0, err = $ifaceNil, fieldType, x$3, t, _tuple, x$4, result, ifaceType, t$1, _tuple$1, x$5, result$1, innerBytes, _ref, _tuple$2, _tuple$3, _tuple$4, _tuple$5, _tuple$6, _tuple$7, _tuple$8, _tuple$9, _tuple$10, universalTag, compoundType, ok1, x$6, _tuple$11, t$2, expectedClass, _tuple$12, x$7, ok, x$8, _ref$1, expectedClass$1, expectedTag, ok$1, x$9, x$10, innerBytes$1, _ref$2, _tuple$13, newSlice, err1, _tuple$14, bs, err1$1, time$1, err1$2, _tuple$15, _tuple$16, _tuple$17, parsedInt, err1$3, parsedInt$1, val, _ref$3, _tuple$18, parsedBool, err1$4, _tuple$19, parsedInt$2, err1$5, _tuple$20, parsedInt$3, err1$6, structType, bytes$2, innerOffset, i, field, _tuple$21, sliceType, _tuple$22, newSlice$1, err1$7, v$1, _ref$4, _tuple$23, _tuple$24, _tuple$25, _tuple$26, _tuple$27, x$11, x$12; + offset = initOffset; + fieldType = v.Type(); + if (offset === bytes$1.$length) { + if (!setDefaultValue($clone(v, reflect.Value), $clone(params, fieldParameters))) { + err = (x$3 = new SyntaxError.Ptr("sequence truncated"), new x$3.constructor.Struct(x$3)); + } + return [offset, err]; + } + if ($interfaceIsEqual(fieldType, rawValueType)) { + t = new tagAndLength.Ptr(); $copy(t, new tagAndLength.Ptr(), tagAndLength); + _tuple = parseTagAndLength(bytes$1, offset); $copy(t, _tuple[0], tagAndLength); offset = _tuple[1]; err = _tuple[2]; + if (!($interfaceIsEqual(err, $ifaceNil))) { + return [offset, err]; + } + if (invalidLength(offset, t.length, bytes$1.$length)) { + err = (x$4 = new SyntaxError.Ptr("data truncated"), new x$4.constructor.Struct(x$4)); + return [offset, err]; + } + result = new RawValue.Ptr(t.class$0, t.tag, t.isCompound, $subslice(bytes$1, offset, (offset + t.length >> 0)), $subslice(bytes$1, initOffset, (offset + t.length >> 0))); + offset = offset + (t.length) >> 0; + v.Set($clone(reflect.ValueOf(new result.constructor.Struct(result)), reflect.Value)); + return [offset, err]; + } + ifaceType = fieldType; + if ((ifaceType.Kind() === 20) && (ifaceType.NumMethod() === 0)) { + t$1 = new tagAndLength.Ptr(); $copy(t$1, new tagAndLength.Ptr(), tagAndLength); + _tuple$1 = parseTagAndLength(bytes$1, offset); $copy(t$1, _tuple$1[0], tagAndLength); offset = _tuple$1[1]; err = _tuple$1[2]; + if (!($interfaceIsEqual(err, $ifaceNil))) { + return [offset, err]; + } + if (invalidLength(offset, t$1.length, bytes$1.$length)) { + err = (x$5 = new SyntaxError.Ptr("data truncated"), new x$5.constructor.Struct(x$5)); + return [offset, err]; + } + result$1 = $ifaceNil; + if (!t$1.isCompound && (t$1.class$0 === 0)) { + innerBytes = $subslice(bytes$1, offset, (offset + t$1.length >> 0)); + _ref = t$1.tag; + if (_ref === 19) { + _tuple$2 = parsePrintableString(innerBytes); result$1 = new $String(_tuple$2[0]); err = _tuple$2[1]; + } else if (_ref === 22) { + _tuple$3 = parseIA5String(innerBytes); result$1 = new $String(_tuple$3[0]); err = _tuple$3[1]; + } else if (_ref === 20) { + _tuple$4 = parseT61String(innerBytes); result$1 = new $String(_tuple$4[0]); err = _tuple$4[1]; + } else if (_ref === 12) { + _tuple$5 = parseUTF8String(innerBytes); result$1 = new $String(_tuple$5[0]); err = _tuple$5[1]; + } else if (_ref === 2) { + _tuple$6 = parseInt64(innerBytes); result$1 = _tuple$6[0]; err = _tuple$6[1]; + } else if (_ref === 3) { + _tuple$7 = parseBitString(innerBytes); result$1 = new _tuple$7[0].constructor.Struct(_tuple$7[0]); err = _tuple$7[1]; + } else if (_ref === 6) { + _tuple$8 = parseObjectIdentifier(innerBytes); result$1 = _tuple$8[0]; err = _tuple$8[1]; + } else if (_ref === 23) { + _tuple$9 = parseUTCTime(innerBytes); result$1 = new _tuple$9[0].constructor.Struct(_tuple$9[0]); err = _tuple$9[1]; + } else if (_ref === 4) { + result$1 = innerBytes; + } else { + } + } + offset = offset + (t$1.length) >> 0; + if (!($interfaceIsEqual(err, $ifaceNil))) { + return [offset, err]; + } + if (!($interfaceIsEqual(result$1, $ifaceNil))) { + v.Set($clone(reflect.ValueOf(result$1), reflect.Value)); + } + return [offset, err]; + } + _tuple$10 = getUniversalType(fieldType); universalTag = _tuple$10[0]; compoundType = _tuple$10[1]; ok1 = _tuple$10[2]; + if (!ok1) { + err = (x$6 = new StructuralError.Ptr(fmt.Sprintf("unknown Go type: %v", new ($sliceType($emptyInterface))([fieldType]))), new x$6.constructor.Struct(x$6)); + return [offset, err]; + } + _tuple$11 = parseTagAndLength(bytes$1, offset); t$2 = new tagAndLength.Ptr(); $copy(t$2, _tuple$11[0], tagAndLength); offset = _tuple$11[1]; err = _tuple$11[2]; + if (!($interfaceIsEqual(err, $ifaceNil))) { + return [offset, err]; + } + if (params.explicit) { + expectedClass = 2; + if (params.application) { + expectedClass = 1; + } + if ((t$2.class$0 === expectedClass) && (t$2.tag === params.tag.$get()) && ((t$2.length === 0) || t$2.isCompound)) { + if (t$2.length > 0) { + _tuple$12 = parseTagAndLength(bytes$1, offset); $copy(t$2, _tuple$12[0], tagAndLength); offset = _tuple$12[1]; err = _tuple$12[2]; + if (!($interfaceIsEqual(err, $ifaceNil))) { + return [offset, err]; + } + } else { + if (!($interfaceIsEqual(fieldType, flagType))) { + err = (x$7 = new StructuralError.Ptr("zero length explicit tag was not an asn1.Flag"), new x$7.constructor.Struct(x$7)); + return [offset, err]; + } + v.SetBool(true); + return [offset, err]; + } + } else { + ok = setDefaultValue($clone(v, reflect.Value), $clone(params, fieldParameters)); + if (ok) { + offset = initOffset; + } else { + err = (x$8 = new StructuralError.Ptr("explicitly tagged member didn't match"), new x$8.constructor.Struct(x$8)); + } + return [offset, err]; + } + } + if (universalTag === 19) { + _ref$1 = t$2.tag; + if (_ref$1 === 22 || _ref$1 === 27 || _ref$1 === 20 || _ref$1 === 12) { + universalTag = t$2.tag; + } + } + if ((universalTag === 23) && (t$2.tag === 24)) { + universalTag = 24; } - if (c === 34) { - return "'\"'"; + if (params.set) { + universalTag = 17; } - s = strconv.Quote($encodeRune(c)); - return "'" + s.substring(1, (s.length - 1 >> 0)) + "'"; - }; - scanner.Ptr.prototype.undo = function(scanCode) { - var s; - s = this; - if (s.redo) { - $panic(new $String("json: invalid use of scanner")); + expectedClass$1 = 0; + expectedTag = universalTag; + if (!params.explicit && !($pointerIsEqual(params.tag, ($ptrType($Int)).nil))) { + expectedClass$1 = 2; + expectedTag = params.tag.$get(); } - s.redoCode = scanCode; - s.redoState = s.step; - s.step = stateRedo; - s.redo = true; - }; - scanner.prototype.undo = function(scanCode) { return this.$val.undo(scanCode); }; - stateRedo = function(s, c) { - s.redo = false; - s.step = s.redoState; - return s.redoCode; - }; - NewDecoder = $pkg.NewDecoder = function(r) { - return new Decoder.Ptr(r, ($sliceType($Uint8)).nil, new decodeState.Ptr(), new scanner.Ptr(), $ifaceNil); - }; - Decoder.Ptr.prototype.UseNumber = function() { - var dec; - dec = this; - dec.d.useNumber = true; - }; - Decoder.prototype.UseNumber = function() { return this.$val.UseNumber(); }; - Decoder.Ptr.prototype.Decode = function(v) { - var dec, _tuple, n, err, rest; - dec = this; - if (!($interfaceIsEqual(dec.err, $ifaceNil))) { - return dec.err; + if (!params.explicit && params.application && !($pointerIsEqual(params.tag, ($ptrType($Int)).nil))) { + expectedClass$1 = 1; + expectedTag = params.tag.$get(); } - _tuple = dec.readValue(); n = _tuple[0]; err = _tuple[1]; - if (!($interfaceIsEqual(err, $ifaceNil))) { - return err; + if (!((t$2.class$0 === expectedClass$1)) || !((t$2.tag === expectedTag)) || !(t$2.isCompound === compoundType)) { + ok$1 = setDefaultValue($clone(v, reflect.Value), $clone(params, fieldParameters)); + if (ok$1) { + offset = initOffset; + } else { + err = (x$9 = new StructuralError.Ptr(fmt.Sprintf("tags don't match (%d vs %+v) %+v %s @%d", new ($sliceType($emptyInterface))([new $Int(expectedTag), new t$2.constructor.Struct(t$2), new params.constructor.Struct(params), new $String(fieldType.Name()), new $Int(offset)]))), new x$9.constructor.Struct(x$9)); + } + return [offset, err]; } - dec.d.init($subslice(dec.buf, 0, n)); - err = dec.d.unmarshal(v); - rest = $copySlice(dec.buf, $subslice(dec.buf, n)); - dec.buf = $subslice(dec.buf, 0, rest); - return err; - }; - Decoder.prototype.Decode = function(v) { return this.$val.Decode(v); }; - Decoder.Ptr.prototype.Buffered = function() { - var dec; - dec = this; - return bytes.NewReader(dec.buf); - }; - Decoder.prototype.Buffered = function() { return this.$val.Buffered(); }; - Decoder.Ptr.prototype.readValue = function() { - var dec, scanp, err, _ref, _i, i, c, x, x$1, v, x$2, newBuf, n, _tuple; - dec = this; - dec.scan.reset(); - scanp = 0; - err = $ifaceNil; - Input: - while (true) { - _ref = $subslice(dec.buf, scanp); - _i = 0; - while (_i < _ref.$length) { - i = _i; - c = ((_i < 0 || _i >= _ref.$length) ? $throwRuntimeError("index out of range") : _ref.$array[_ref.$offset + _i]); - dec.scan.bytes = (x = dec.scan.bytes, x$1 = new $Int64(0, 1), new $Int64(x.$high + x$1.$high, x.$low + x$1.$low)); - v = dec.scan.step(dec.scan, (c >> 0)); - if (v === 10) { - scanp = scanp + (i) >> 0; - break Input; - } - if (((v === 5) || (v === 8)) && (dec.scan.step(dec.scan, 32) === 10)) { - scanp = scanp + ((i + 1 >> 0)) >> 0; - break Input; + if (invalidLength(offset, t$2.length, bytes$1.$length)) { + err = (x$10 = new SyntaxError.Ptr("data truncated"), new x$10.constructor.Struct(x$10)); + return [offset, err]; + } + innerBytes$1 = $subslice(bytes$1, offset, (offset + t$2.length >> 0)); + offset = offset + (t$2.length) >> 0; + _ref$2 = fieldType; + if ($interfaceIsEqual(_ref$2, objectIdentifierType)) { + _tuple$13 = parseObjectIdentifier(innerBytes$1); newSlice = _tuple$13[0]; err1 = _tuple$13[1]; + v.Set($clone(reflect.MakeSlice(v.Type(), newSlice.$length, newSlice.$length), reflect.Value)); + if ($interfaceIsEqual(err1, $ifaceNil)) { + reflect.Copy($clone(v, reflect.Value), $clone(reflect.ValueOf(newSlice), reflect.Value)); + } + err = err1; + return [offset, err]; + } else if ($interfaceIsEqual(_ref$2, bitStringType)) { + _tuple$14 = parseBitString(innerBytes$1); bs = new BitString.Ptr(); $copy(bs, _tuple$14[0], BitString); err1$1 = _tuple$14[1]; + if ($interfaceIsEqual(err1$1, $ifaceNil)) { + v.Set($clone(reflect.ValueOf(new bs.constructor.Struct(bs)), reflect.Value)); + } + err = err1$1; + return [offset, err]; + } else if ($interfaceIsEqual(_ref$2, timeType)) { + time$1 = new time.Time.Ptr(); $copy(time$1, new time.Time.Ptr(), time.Time); + err1$2 = $ifaceNil; + if (universalTag === 23) { + _tuple$15 = parseUTCTime(innerBytes$1); $copy(time$1, _tuple$15[0], time.Time); err1$2 = _tuple$15[1]; + } else { + _tuple$16 = parseGeneralizedTime(innerBytes$1); $copy(time$1, _tuple$16[0], time.Time); err1$2 = _tuple$16[1]; + } + if ($interfaceIsEqual(err1$2, $ifaceNil)) { + v.Set($clone(reflect.ValueOf(new time$1.constructor.Struct(time$1)), reflect.Value)); + } + err = err1$2; + return [offset, err]; + } else if ($interfaceIsEqual(_ref$2, enumeratedType)) { + _tuple$17 = parseInt32(innerBytes$1); parsedInt = _tuple$17[0]; err1$3 = _tuple$17[1]; + if ($interfaceIsEqual(err1$3, $ifaceNil)) { + v.SetInt(new $Int64(0, parsedInt)); + } + err = err1$3; + return [offset, err]; + } else if ($interfaceIsEqual(_ref$2, flagType)) { + v.SetBool(true); + return [offset, err]; + } else if ($interfaceIsEqual(_ref$2, bigIntType)) { + parsedInt$1 = parseBigInt(innerBytes$1); + v.Set($clone(reflect.ValueOf(parsedInt$1), reflect.Value)); + return [offset, err]; + } + val = new reflect.Value.Ptr(); $copy(val, v, reflect.Value); + _ref$3 = val.Kind(); + if (_ref$3 === 1) { + _tuple$18 = parseBool(innerBytes$1); parsedBool = _tuple$18[0]; err1$4 = _tuple$18[1]; + if ($interfaceIsEqual(err1$4, $ifaceNil)) { + val.SetBool(parsedBool); + } + err = err1$4; + return [offset, err]; + } else if (_ref$3 === 2 || _ref$3 === 5 || _ref$3 === 6) { + if (val.Type().Size() === 4) { + _tuple$19 = parseInt32(innerBytes$1); parsedInt$2 = _tuple$19[0]; err1$5 = _tuple$19[1]; + if ($interfaceIsEqual(err1$5, $ifaceNil)) { + val.SetInt(new $Int64(0, parsedInt$2)); } - if (v === 11) { - dec.err = dec.scan.err; - return [0, dec.scan.err]; + err = err1$5; + } else { + _tuple$20 = parseInt64(innerBytes$1); parsedInt$3 = _tuple$20[0]; err1$6 = _tuple$20[1]; + if ($interfaceIsEqual(err1$6, $ifaceNil)) { + val.SetInt(parsedInt$3); } - _i++; + err = err1$6; } - scanp = dec.buf.$length; - if (!($interfaceIsEqual(err, $ifaceNil))) { - if ($interfaceIsEqual(err, io.EOF)) { - if (dec.scan.step(dec.scan, 32) === 10) { - break Input; - } - if (nonSpace(dec.buf)) { - err = io.ErrUnexpectedEOF; - } + return [offset, err]; + } else if (_ref$3 === 25) { + structType = fieldType; + if (structType.NumField() > 0 && $interfaceIsEqual(structType.Field(0).Type, rawContentsType)) { + bytes$2 = $subslice(bytes$1, initOffset, offset); + val.Field(0).Set($clone(reflect.ValueOf($subslice(new RawContent(bytes$2.$array), bytes$2.$offset, bytes$2.$offset + bytes$2.$length)), reflect.Value)); + } + innerOffset = 0; + i = 0; + while (i < structType.NumField()) { + field = new reflect.StructField.Ptr(); $copy(field, structType.Field(i), reflect.StructField); + if ((i === 0) && $interfaceIsEqual(field.Type, rawContentsType)) { + i = i + (1) >> 0; + continue; } - dec.err = err; - return [0, err]; + _tuple$21 = parseField($clone(val.Field(i), reflect.Value), innerBytes$1, innerOffset, $clone(parseFieldParameters((new reflect.StructTag(field.Tag)).Get("asn1")), fieldParameters)); innerOffset = _tuple$21[0]; err = _tuple$21[1]; + if (!($interfaceIsEqual(err, $ifaceNil))) { + return [offset, err]; + } + i = i + (1) >> 0; } - if ((dec.buf.$capacity - dec.buf.$length >> 0) < 512) { - newBuf = ($sliceType($Uint8)).make(dec.buf.$length, ((x$2 = dec.buf.$capacity, (((2 >>> 16 << 16) * x$2 >> 0) + (2 << 16 >>> 16) * x$2) >> 0) + 512 >> 0)); - $copySlice(newBuf, dec.buf); - dec.buf = newBuf; + return [offset, err]; + } else if (_ref$3 === 23) { + sliceType = fieldType; + if (sliceType.Elem().Kind() === 8) { + val.Set($clone(reflect.MakeSlice(sliceType, innerBytes$1.$length, innerBytes$1.$length), reflect.Value)); + reflect.Copy($clone(val, reflect.Value), $clone(reflect.ValueOf(innerBytes$1), reflect.Value)); + return [offset, err]; } - n = 0; - _tuple = dec.r.Read($subslice(dec.buf, dec.buf.$length, dec.buf.$capacity)); n = _tuple[0]; err = _tuple[1]; - dec.buf = $subslice(dec.buf, 0, (dec.buf.$length + n >> 0)); - } - return [scanp, $ifaceNil]; - }; - Decoder.prototype.readValue = function() { return this.$val.readValue(); }; - nonSpace = function(b) { - var _ref, _i, c; - _ref = b; - _i = 0; - while (_i < _ref.$length) { - c = ((_i < 0 || _i >= _ref.$length) ? $throwRuntimeError("index out of range") : _ref.$array[_ref.$offset + _i]); - if (!isSpace((c >> 0))) { - return true; + _tuple$22 = parseSequenceOf(innerBytes$1, sliceType, sliceType.Elem()); newSlice$1 = new reflect.Value.Ptr(); $copy(newSlice$1, _tuple$22[0], reflect.Value); err1$7 = _tuple$22[1]; + if ($interfaceIsEqual(err1$7, $ifaceNil)) { + val.Set($clone(newSlice$1, reflect.Value)); } - _i++; + err = err1$7; + return [offset, err]; + } else if (_ref$3 === 24) { + v$1 = ""; + _ref$4 = universalTag; + if (_ref$4 === 19) { + _tuple$23 = parsePrintableString(innerBytes$1); v$1 = _tuple$23[0]; err = _tuple$23[1]; + } else if (_ref$4 === 22) { + _tuple$24 = parseIA5String(innerBytes$1); v$1 = _tuple$24[0]; err = _tuple$24[1]; + } else if (_ref$4 === 20) { + _tuple$25 = parseT61String(innerBytes$1); v$1 = _tuple$25[0]; err = _tuple$25[1]; + } else if (_ref$4 === 12) { + _tuple$26 = parseUTF8String(innerBytes$1); v$1 = _tuple$26[0]; err = _tuple$26[1]; + } else if (_ref$4 === 27) { + _tuple$27 = parseT61String(innerBytes$1); v$1 = _tuple$27[0]; err = _tuple$27[1]; + } else { + err = (x$11 = new SyntaxError.Ptr(fmt.Sprintf("internal error: unknown string type %d", new ($sliceType($emptyInterface))([new $Int(universalTag)]))), new x$11.constructor.Struct(x$11)); + } + if ($interfaceIsEqual(err, $ifaceNil)) { + val.SetString(v$1); + } + return [offset, err]; } - return false; - }; - NewEncoder = $pkg.NewEncoder = function(w) { - return new Encoder.Ptr(w, new encodeState.Ptr(), $ifaceNil); + err = (x$12 = new StructuralError.Ptr("unsupported: " + v.Type().String()), new x$12.constructor.Struct(x$12)); + return [offset, err]; }; - Encoder.Ptr.prototype.Encode = function(v) { - var enc, e, err, _tuple; - enc = this; - if (!($interfaceIsEqual(enc.err, $ifaceNil))) { - return enc.err; + setDefaultValue = function(v, params) { + var ok = false, val, _ref; + if (!params.optional) { + return ok; } - e = newEncodeState(); - err = e.marshal(v); - if (!($interfaceIsEqual(err, $ifaceNil))) { - return err; + ok = true; + if ($pointerIsEqual(params.defaultValue, ($ptrType($Int64)).nil)) { + return ok; } - e.Buffer.WriteByte(10); - _tuple = enc.w.Write(e.Buffer.Bytes()); err = _tuple[1]; + val = new reflect.Value.Ptr(); $copy(val, v, reflect.Value); + _ref = val.Kind(); + if (_ref === 2 || _ref === 3 || _ref === 4 || _ref === 5 || _ref === 6) { + val.SetInt(params.defaultValue.$get()); + } + return ok; + }; + Unmarshal = $pkg.Unmarshal = function(b, val) { + var rest = ($sliceType($Uint8)).nil, err = $ifaceNil, _tuple; + _tuple = UnmarshalWithParams(b, val, ""); rest = _tuple[0]; err = _tuple[1]; + return [rest, err]; + }; + UnmarshalWithParams = $pkg.UnmarshalWithParams = function(b, val, params) { + var rest = ($sliceType($Uint8)).nil, err = $ifaceNil, v, _tuple, offset, _tmp, _tmp$1, _tmp$2, _tmp$3; + v = new reflect.Value.Ptr(); $copy(v, reflect.ValueOf(val).Elem(), reflect.Value); + _tuple = parseField($clone(v, reflect.Value), b, 0, $clone(parseFieldParameters(params), fieldParameters)); offset = _tuple[0]; err = _tuple[1]; if (!($interfaceIsEqual(err, $ifaceNil))) { - enc.err = err; + _tmp = ($sliceType($Uint8)).nil; _tmp$1 = err; rest = _tmp; err = _tmp$1; + return [rest, err]; } - encodeStatePool.Put(e); - return err; + _tmp$2 = $subslice(b, offset); _tmp$3 = $ifaceNil; rest = _tmp$2; err = _tmp$3; + return [rest, err]; }; - Encoder.prototype.Encode = function(v) { return this.$val.Encode(v); }; - parseTag = function(tag) { - var idx; - idx = strings.Index(tag, ","); - if (!((idx === -1))) { - return [tag.substring(0, idx), tag.substring((idx + 1 >> 0))]; + parseFieldParameters = function(str) { + var ret = new fieldParameters.Ptr(), _ref, _i, part, _tuple, i, err, _tuple$1, i$1, err$1; + _ref = strings.Split(str, ","); + _i = 0; + while (_i < _ref.$length) { + part = ((_i < 0 || _i >= _ref.$length) ? $throwRuntimeError("index out of range") : _ref.$array[_ref.$offset + _i]); + if (part === "optional") { + ret.optional = true; + } else if (part === "explicit") { + ret.explicit = true; + if ($pointerIsEqual(ret.tag, ($ptrType($Int)).nil)) { + ret.tag = $newDataPointer(0, ($ptrType($Int))); + } + } else if (part === "ia5") { + ret.stringType = 22; + } else if (part === "printable") { + ret.stringType = 19; + } else if (part === "utf8") { + ret.stringType = 12; + } else if (strings.HasPrefix(part, "default:")) { + _tuple = strconv.ParseInt(part.substring(8), 10, 64); i = _tuple[0]; err = _tuple[1]; + if ($interfaceIsEqual(err, $ifaceNil)) { + ret.defaultValue = $newDataPointer(new $Int64(0, 0), ($ptrType($Int64))); + ret.defaultValue.$set(i); + } + } else if (strings.HasPrefix(part, "tag:")) { + _tuple$1 = strconv.Atoi(part.substring(4)); i$1 = _tuple$1[0]; err$1 = _tuple$1[1]; + if ($interfaceIsEqual(err$1, $ifaceNil)) { + ret.tag = $newDataPointer(0, ($ptrType($Int))); + ret.tag.$set(i$1); + } + } else if (part === "set") { + ret.set = true; + } else if (part === "application") { + ret.application = true; + if ($pointerIsEqual(ret.tag, ($ptrType($Int)).nil)) { + ret.tag = $newDataPointer(0, ($ptrType($Int))); + } + } else if (part === "omitempty") { + ret.omitEmpty = true; + } + _i++; } - return [tag, ""]; + return ret; }; - tagOptions.prototype.Contains = function(optionName) { - var o, s, next, i, _tmp, _tmp$1; - o = this.$val !== undefined ? this.$val : this; - if (o.length === 0) { - return false; + getUniversalType = function(t) { + var tagNumber = 0, isCompound = false, ok = false, _ref, _tmp, _tmp$1, _tmp$2, _tmp$3, _tmp$4, _tmp$5, _tmp$6, _tmp$7, _tmp$8, _tmp$9, _tmp$10, _tmp$11, _tmp$12, _tmp$13, _tmp$14, _ref$1, _tmp$15, _tmp$16, _tmp$17, _tmp$18, _tmp$19, _tmp$20, _tmp$21, _tmp$22, _tmp$23, _tmp$24, _tmp$25, _tmp$26, _tmp$27, _tmp$28, _tmp$29, _tmp$30, _tmp$31, _tmp$32, _tmp$33, _tmp$34, _tmp$35, _tmp$36, _tmp$37, _tmp$38; + _ref = t; + if ($interfaceIsEqual(_ref, objectIdentifierType)) { + _tmp = 6; _tmp$1 = false; _tmp$2 = true; tagNumber = _tmp; isCompound = _tmp$1; ok = _tmp$2; + return [tagNumber, isCompound, ok]; + } else if ($interfaceIsEqual(_ref, bitStringType)) { + _tmp$3 = 3; _tmp$4 = false; _tmp$5 = true; tagNumber = _tmp$3; isCompound = _tmp$4; ok = _tmp$5; + return [tagNumber, isCompound, ok]; + } else if ($interfaceIsEqual(_ref, timeType)) { + _tmp$6 = 23; _tmp$7 = false; _tmp$8 = true; tagNumber = _tmp$6; isCompound = _tmp$7; ok = _tmp$8; + return [tagNumber, isCompound, ok]; + } else if ($interfaceIsEqual(_ref, enumeratedType)) { + _tmp$9 = 10; _tmp$10 = false; _tmp$11 = true; tagNumber = _tmp$9; isCompound = _tmp$10; ok = _tmp$11; + return [tagNumber, isCompound, ok]; + } else if ($interfaceIsEqual(_ref, bigIntType)) { + _tmp$12 = 2; _tmp$13 = false; _tmp$14 = true; tagNumber = _tmp$12; isCompound = _tmp$13; ok = _tmp$14; + return [tagNumber, isCompound, ok]; } - s = o; - while (!(s === "")) { - next = ""; - i = strings.Index(s, ","); - if (i >= 0) { - _tmp = s.substring(0, i); _tmp$1 = s.substring((i + 1 >> 0)); s = _tmp; next = _tmp$1; + _ref$1 = t.Kind(); + if (_ref$1 === 1) { + _tmp$15 = 1; _tmp$16 = false; _tmp$17 = true; tagNumber = _tmp$15; isCompound = _tmp$16; ok = _tmp$17; + return [tagNumber, isCompound, ok]; + } else if (_ref$1 === 2 || _ref$1 === 3 || _ref$1 === 4 || _ref$1 === 5 || _ref$1 === 6) { + _tmp$18 = 2; _tmp$19 = false; _tmp$20 = true; tagNumber = _tmp$18; isCompound = _tmp$19; ok = _tmp$20; + return [tagNumber, isCompound, ok]; + } else if (_ref$1 === 25) { + _tmp$21 = 16; _tmp$22 = true; _tmp$23 = true; tagNumber = _tmp$21; isCompound = _tmp$22; ok = _tmp$23; + return [tagNumber, isCompound, ok]; + } else if (_ref$1 === 23) { + if (t.Elem().Kind() === 8) { + _tmp$24 = 4; _tmp$25 = false; _tmp$26 = true; tagNumber = _tmp$24; isCompound = _tmp$25; ok = _tmp$26; + return [tagNumber, isCompound, ok]; } - if (s === optionName) { - return true; + if (strings.HasSuffix(t.Name(), "SET")) { + _tmp$27 = 17; _tmp$28 = true; _tmp$29 = true; tagNumber = _tmp$27; isCompound = _tmp$28; ok = _tmp$29; + return [tagNumber, isCompound, ok]; } - s = next; + _tmp$30 = 16; _tmp$31 = true; _tmp$32 = true; tagNumber = _tmp$30; isCompound = _tmp$31; ok = _tmp$32; + return [tagNumber, isCompound, ok]; + } else if (_ref$1 === 24) { + _tmp$33 = 19; _tmp$34 = false; _tmp$35 = true; tagNumber = _tmp$33; isCompound = _tmp$34; ok = _tmp$35; + return [tagNumber, isCompound, ok]; } - return false; + _tmp$36 = 0; _tmp$37 = false; _tmp$38 = false; tagNumber = _tmp$36; isCompound = _tmp$37; ok = _tmp$38; + return [tagNumber, isCompound, ok]; }; - $ptrType(tagOptions).prototype.Contains = function(optionName) { return new tagOptions(this.$get()).Contains(optionName); }; $pkg.$init = function() { - Unmarshaler.init([["UnmarshalJSON", "UnmarshalJSON", "", $funcType([($sliceType($Uint8))], [$error], false)]]); - ($ptrType(UnmarshalTypeError)).methods = [["Error", "Error", "", $funcType([], [$String], false), -1]]; - UnmarshalTypeError.init([["Value", "Value", "", $String, ""], ["Type", "Type", "", reflect.Type, ""]]); - ($ptrType(InvalidUnmarshalError)).methods = [["Error", "Error", "", $funcType([], [$String], false), -1]]; - InvalidUnmarshalError.init([["Type", "Type", "", reflect.Type, ""]]); - Number.methods = [["Float64", "Float64", "", $funcType([], [$Float64, $error], false), -1], ["Int64", "Int64", "", $funcType([], [$Int64, $error], false), -1], ["String", "String", "", $funcType([], [$String], false), -1]]; - ($ptrType(Number)).methods = [["Float64", "Float64", "", $funcType([], [$Float64, $error], false), -1], ["Int64", "Int64", "", $funcType([], [$Int64, $error], false), -1], ["String", "String", "", $funcType([], [$String], false), -1]]; - ($ptrType(decodeState)).methods = [["array", "array", "encoding/json", $funcType([reflect.Value], [], false), -1], ["arrayInterface", "arrayInterface", "encoding/json", $funcType([], [($sliceType($emptyInterface))], false), -1], ["convertNumber", "convertNumber", "encoding/json", $funcType([$String], [$emptyInterface, $error], false), -1], ["error", "error", "encoding/json", $funcType([$error], [], false), -1], ["indirect", "indirect", "encoding/json", $funcType([reflect.Value, $Bool], [Unmarshaler, encoding.TextUnmarshaler, reflect.Value], false), -1], ["init", "init", "encoding/json", $funcType([($sliceType($Uint8))], [($ptrType(decodeState))], false), -1], ["literal", "literal", "encoding/json", $funcType([reflect.Value], [], false), -1], ["literalInterface", "literalInterface", "encoding/json", $funcType([], [$emptyInterface], false), -1], ["literalStore", "literalStore", "encoding/json", $funcType([($sliceType($Uint8)), reflect.Value, $Bool], [], false), -1], ["next", "next", "encoding/json", $funcType([], [($sliceType($Uint8))], false), -1], ["object", "object", "encoding/json", $funcType([reflect.Value], [], false), -1], ["objectInterface", "objectInterface", "encoding/json", $funcType([], [($mapType($String, $emptyInterface))], false), -1], ["saveError", "saveError", "encoding/json", $funcType([$error], [], false), -1], ["scanWhile", "scanWhile", "encoding/json", $funcType([$Int], [$Int], false), -1], ["unmarshal", "unmarshal", "encoding/json", $funcType([$emptyInterface], [$error], false), -1], ["value", "value", "encoding/json", $funcType([reflect.Value], [], false), -1], ["valueInterface", "valueInterface", "encoding/json", $funcType([], [$emptyInterface], false), -1]]; - decodeState.init([["data", "data", "encoding/json", ($sliceType($Uint8)), ""], ["off", "off", "encoding/json", $Int, ""], ["scan", "scan", "encoding/json", scanner, ""], ["nextscan", "nextscan", "encoding/json", scanner, ""], ["savedError", "savedError", "encoding/json", $error, ""], ["tempstr", "tempstr", "encoding/json", $String, ""], ["useNumber", "useNumber", "encoding/json", $Bool, ""]]); - Marshaler.init([["MarshalJSON", "MarshalJSON", "", $funcType([], [($sliceType($Uint8)), $error], false)]]); - ($ptrType(UnsupportedTypeError)).methods = [["Error", "Error", "", $funcType([], [$String], false), -1]]; - UnsupportedTypeError.init([["Type", "Type", "", reflect.Type, ""]]); - ($ptrType(UnsupportedValueError)).methods = [["Error", "Error", "", $funcType([], [$String], false), -1]]; - UnsupportedValueError.init([["Value", "Value", "", reflect.Value, ""], ["Str", "Str", "", $String, ""]]); - ($ptrType(MarshalerError)).methods = [["Error", "Error", "", $funcType([], [$String], false), -1]]; - MarshalerError.init([["Type", "Type", "", reflect.Type, ""], ["Err", "Err", "", $error, ""]]); - ($ptrType(encodeState)).methods = [["Bytes", "Bytes", "", $funcType([], [($sliceType($Uint8))], false), 0], ["Grow", "Grow", "", $funcType([$Int], [], false), 0], ["Len", "Len", "", $funcType([], [$Int], false), 0], ["Next", "Next", "", $funcType([$Int], [($sliceType($Uint8))], false), 0], ["Read", "Read", "", $funcType([($sliceType($Uint8))], [$Int, $error], false), 0], ["ReadByte", "ReadByte", "", $funcType([], [$Uint8, $error], false), 0], ["ReadBytes", "ReadBytes", "", $funcType([$Uint8], [($sliceType($Uint8)), $error], false), 0], ["ReadFrom", "ReadFrom", "", $funcType([io.Reader], [$Int64, $error], false), 0], ["ReadRune", "ReadRune", "", $funcType([], [$Int32, $Int, $error], false), 0], ["ReadString", "ReadString", "", $funcType([$Uint8], [$String, $error], false), 0], ["Reset", "Reset", "", $funcType([], [], false), 0], ["String", "String", "", $funcType([], [$String], false), 0], ["Truncate", "Truncate", "", $funcType([$Int], [], false), 0], ["UnreadByte", "UnreadByte", "", $funcType([], [$error], false), 0], ["UnreadRune", "UnreadRune", "", $funcType([], [$error], false), 0], ["Write", "Write", "", $funcType([($sliceType($Uint8))], [$Int, $error], false), 0], ["WriteByte", "WriteByte", "", $funcType([$Uint8], [$error], false), 0], ["WriteRune", "WriteRune", "", $funcType([$Int32], [$Int, $error], false), 0], ["WriteString", "WriteString", "", $funcType([$String], [$Int, $error], false), 0], ["WriteTo", "WriteTo", "", $funcType([io.Writer], [$Int64, $error], false), 0], ["grow", "grow", "bytes", $funcType([$Int], [$Int], false), 0], ["readSlice", "readSlice", "bytes", $funcType([$Uint8], [($sliceType($Uint8)), $error], false), 0], ["error", "error", "encoding/json", $funcType([$error], [], false), -1], ["marshal", "marshal", "encoding/json", $funcType([$emptyInterface], [$error], false), -1], ["reflectValue", "reflectValue", "encoding/json", $funcType([reflect.Value], [], false), -1], ["string", "string", "encoding/json", $funcType([$String], [$Int, $error], false), -1], ["stringBytes", "stringBytes", "encoding/json", $funcType([($sliceType($Uint8))], [$Int, $error], false), -1]]; - encodeState.init([["Buffer", "", "", bytes.Buffer, ""], ["scratch", "scratch", "encoding/json", ($arrayType($Uint8, 64)), ""]]); - encoderFunc.init([($ptrType(encodeState)), reflect.Value, $Bool], [], false); - floatEncoder.methods = [["encode", "encode", "encoding/json", $funcType([($ptrType(encodeState)), reflect.Value, $Bool], [], false), -1]]; - ($ptrType(floatEncoder)).methods = [["encode", "encode", "encoding/json", $funcType([($ptrType(encodeState)), reflect.Value, $Bool], [], false), -1]]; - ($ptrType(structEncoder)).methods = [["encode", "encode", "encoding/json", $funcType([($ptrType(encodeState)), reflect.Value, $Bool], [], false), -1]]; - structEncoder.init([["fields", "fields", "encoding/json", ($sliceType(field)), ""], ["fieldEncs", "fieldEncs", "encoding/json", ($sliceType(encoderFunc)), ""]]); - ($ptrType(mapEncoder)).methods = [["encode", "encode", "encoding/json", $funcType([($ptrType(encodeState)), reflect.Value, $Bool], [], false), -1]]; - mapEncoder.init([["elemEnc", "elemEnc", "encoding/json", encoderFunc, ""]]); - ($ptrType(sliceEncoder)).methods = [["encode", "encode", "encoding/json", $funcType([($ptrType(encodeState)), reflect.Value, $Bool], [], false), -1]]; - sliceEncoder.init([["arrayEnc", "arrayEnc", "encoding/json", encoderFunc, ""]]); - ($ptrType(arrayEncoder)).methods = [["encode", "encode", "encoding/json", $funcType([($ptrType(encodeState)), reflect.Value, $Bool], [], false), -1]]; - arrayEncoder.init([["elemEnc", "elemEnc", "encoding/json", encoderFunc, ""]]); - ($ptrType(ptrEncoder)).methods = [["encode", "encode", "encoding/json", $funcType([($ptrType(encodeState)), reflect.Value, $Bool], [], false), -1]]; - ptrEncoder.init([["elemEnc", "elemEnc", "encoding/json", encoderFunc, ""]]); - ($ptrType(condAddrEncoder)).methods = [["encode", "encode", "encoding/json", $funcType([($ptrType(encodeState)), reflect.Value, $Bool], [], false), -1]]; - condAddrEncoder.init([["canAddrEnc", "canAddrEnc", "encoding/json", encoderFunc, ""], ["elseEnc", "elseEnc", "encoding/json", encoderFunc, ""]]); - stringValues.methods = [["Len", "Len", "", $funcType([], [$Int], false), -1], ["Less", "Less", "", $funcType([$Int, $Int], [$Bool], false), -1], ["Swap", "Swap", "", $funcType([$Int, $Int], [], false), -1], ["get", "get", "encoding/json", $funcType([$Int], [$String], false), -1]]; - ($ptrType(stringValues)).methods = [["Len", "Len", "", $funcType([], [$Int], false), -1], ["Less", "Less", "", $funcType([$Int, $Int], [$Bool], false), -1], ["Swap", "Swap", "", $funcType([$Int, $Int], [], false), -1], ["get", "get", "encoding/json", $funcType([$Int], [$String], false), -1]]; - stringValues.init(reflect.Value); - field.init([["name", "name", "encoding/json", $String, ""], ["nameBytes", "nameBytes", "encoding/json", ($sliceType($Uint8)), ""], ["equalFold", "equalFold", "encoding/json", ($funcType([($sliceType($Uint8)), ($sliceType($Uint8))], [$Bool], false)), ""], ["tag", "tag", "encoding/json", $Bool, ""], ["index", "index", "encoding/json", ($sliceType($Int)), ""], ["typ", "typ", "encoding/json", reflect.Type, ""], ["omitEmpty", "omitEmpty", "encoding/json", $Bool, ""], ["quoted", "quoted", "encoding/json", $Bool, ""]]); - byName.methods = [["Len", "Len", "", $funcType([], [$Int], false), -1], ["Less", "Less", "", $funcType([$Int, $Int], [$Bool], false), -1], ["Swap", "Swap", "", $funcType([$Int, $Int], [], false), -1]]; - ($ptrType(byName)).methods = [["Len", "Len", "", $funcType([], [$Int], false), -1], ["Less", "Less", "", $funcType([$Int, $Int], [$Bool], false), -1], ["Swap", "Swap", "", $funcType([$Int, $Int], [], false), -1]]; - byName.init(field); - byIndex.methods = [["Len", "Len", "", $funcType([], [$Int], false), -1], ["Less", "Less", "", $funcType([$Int, $Int], [$Bool], false), -1], ["Swap", "Swap", "", $funcType([$Int, $Int], [], false), -1]]; - ($ptrType(byIndex)).methods = [["Len", "Len", "", $funcType([], [$Int], false), -1], ["Less", "Less", "", $funcType([$Int, $Int], [$Bool], false), -1], ["Swap", "Swap", "", $funcType([$Int, $Int], [], false), -1]]; - byIndex.init(field); + StructuralError.methods = [["Error", "Error", "", $funcType([], [$String], false), -1]]; + ($ptrType(StructuralError)).methods = [["Error", "Error", "", $funcType([], [$String], false), -1]]; + StructuralError.init([["Msg", "Msg", "", $String, ""]]); + SyntaxError.methods = [["Error", "Error", "", $funcType([], [$String], false), -1]]; ($ptrType(SyntaxError)).methods = [["Error", "Error", "", $funcType([], [$String], false), -1]]; - SyntaxError.init([["msg", "msg", "encoding/json", $String, ""], ["Offset", "Offset", "", $Int64, ""]]); - ($ptrType(scanner)).methods = [["eof", "eof", "encoding/json", $funcType([], [$Int], false), -1], ["error", "error", "encoding/json", $funcType([$Int, $String], [$Int], false), -1], ["popParseState", "popParseState", "encoding/json", $funcType([], [], false), -1], ["pushParseState", "pushParseState", "encoding/json", $funcType([$Int], [], false), -1], ["reset", "reset", "encoding/json", $funcType([], [], false), -1], ["undo", "undo", "encoding/json", $funcType([$Int], [], false), -1]]; - scanner.init([["step", "step", "encoding/json", ($funcType([($ptrType(scanner)), $Int], [$Int], false)), ""], ["endTop", "endTop", "encoding/json", $Bool, ""], ["parseState", "parseState", "encoding/json", ($sliceType($Int)), ""], ["err", "err", "encoding/json", $error, ""], ["redo", "redo", "encoding/json", $Bool, ""], ["redoCode", "redoCode", "encoding/json", $Int, ""], ["redoState", "redoState", "encoding/json", ($funcType([($ptrType(scanner)), $Int], [$Int], false)), ""], ["bytes", "bytes", "encoding/json", $Int64, ""]]); - ($ptrType(Decoder)).methods = [["Buffered", "Buffered", "", $funcType([], [io.Reader], false), -1], ["Decode", "Decode", "", $funcType([$emptyInterface], [$error], false), -1], ["UseNumber", "UseNumber", "", $funcType([], [], false), -1], ["readValue", "readValue", "encoding/json", $funcType([], [$Int, $error], false), -1]]; - Decoder.init([["r", "r", "encoding/json", io.Reader, ""], ["buf", "buf", "encoding/json", ($sliceType($Uint8)), ""], ["d", "d", "encoding/json", decodeState, ""], ["scan", "scan", "encoding/json", scanner, ""], ["err", "err", "encoding/json", $error, ""]]); - ($ptrType(Encoder)).methods = [["Encode", "Encode", "", $funcType([$emptyInterface], [$error], false), -1]]; - Encoder.init([["w", "w", "encoding/json", io.Writer, ""], ["e", "e", "encoding/json", encodeState, ""], ["err", "err", "encoding/json", $error, ""]]); - tagOptions.methods = [["Contains", "Contains", "", $funcType([$String], [$Bool], false), -1]]; - ($ptrType(tagOptions)).methods = [["Contains", "Contains", "", $funcType([$String], [$Bool], false), -1]]; - encodeStatePool = new sync.Pool.Ptr(); - encoderCache = new ($structType([["RWMutex", "", "", sync.RWMutex, ""], ["m", "m", "encoding/json", ($mapType(reflect.Type, encoderFunc)), ""]])).Ptr(); - fieldCache = new ($structType([["RWMutex", "", "", sync.RWMutex, ""], ["m", "m", "encoding/json", ($mapType(reflect.Type, ($sliceType(field)))), ""]])).Ptr(); - errPhase = errors.New("JSON decoder out of sync - data changing underfoot?"); - numberType = reflect.TypeOf(new Number("")); - hex = "0123456789abcdef"; - byteSliceType = reflect.TypeOf(($sliceType($Uint8)).nil); - marshalerType = reflect.TypeOf($newDataPointer($ifaceNil, ($ptrType(Marshaler)))).Elem(); - textMarshalerType = reflect.TypeOf($newDataPointer($ifaceNil, ($ptrType(encoding.TextMarshaler)))).Elem(); - float32Encoder = $methodVal((new floatEncoder(32)), "encode"); - float64Encoder = $methodVal((new floatEncoder(64)), "encode"); + SyntaxError.init([["Msg", "Msg", "", $String, ""]]); + BitString.methods = [["At", "At", "", $funcType([$Int], [$Int], false), -1], ["RightAlign", "RightAlign", "", $funcType([], [($sliceType($Uint8))], false), -1]]; + ($ptrType(BitString)).methods = [["At", "At", "", $funcType([$Int], [$Int], false), -1], ["RightAlign", "RightAlign", "", $funcType([], [($sliceType($Uint8))], false), -1]]; + BitString.init([["Bytes", "Bytes", "", ($sliceType($Uint8)), ""], ["BitLength", "BitLength", "", $Int, ""]]); + ObjectIdentifier.methods = [["Equal", "Equal", "", $funcType([ObjectIdentifier], [$Bool], false), -1], ["String", "String", "", $funcType([], [$String], false), -1]]; + ($ptrType(ObjectIdentifier)).methods = [["Equal", "Equal", "", $funcType([ObjectIdentifier], [$Bool], false), -1], ["String", "String", "", $funcType([], [$String], false), -1]]; + ObjectIdentifier.init($Int); + RawValue.init([["Class", "Class", "", $Int, ""], ["Tag", "Tag", "", $Int, ""], ["IsCompound", "IsCompound", "", $Bool, ""], ["Bytes", "Bytes", "", ($sliceType($Uint8)), ""], ["FullBytes", "FullBytes", "", ($sliceType($Uint8)), ""]]); + RawContent.init($Uint8); + tagAndLength.init([["class$0", "class", "encoding/asn1", $Int, ""], ["tag", "tag", "encoding/asn1", $Int, ""], ["length", "length", "encoding/asn1", $Int, ""], ["isCompound", "isCompound", "encoding/asn1", $Bool, ""]]); + fieldParameters.init([["optional", "optional", "encoding/asn1", $Bool, ""], ["explicit", "explicit", "encoding/asn1", $Bool, ""], ["application", "application", "encoding/asn1", $Bool, ""], ["defaultValue", "defaultValue", "encoding/asn1", ($ptrType($Int64)), ""], ["tag", "tag", "encoding/asn1", ($ptrType($Int)), ""], ["stringType", "stringType", "encoding/asn1", $Int, ""], ["set", "set", "encoding/asn1", $Bool, ""], ["omitEmpty", "omitEmpty", "encoding/asn1", $Bool, ""]]); + bigOne = big.NewInt(new $Int64(0, 1)); + bitStringType = reflect.TypeOf((x = new BitString.Ptr(($sliceType($Uint8)).nil, 0), new x.constructor.Struct(x))); + objectIdentifierType = reflect.TypeOf(new ObjectIdentifier([])); + enumeratedType = reflect.TypeOf(new Enumerated(0)); + flagType = reflect.TypeOf(new Flag(false)); + timeType = reflect.TypeOf((x$1 = new time.Time.Ptr(new $Int64(0, 0), 0, ($ptrType(time.Location)).nil), new x$1.constructor.Struct(x$1))); + rawValueType = reflect.TypeOf((x$2 = new RawValue.Ptr(0, 0, false, ($sliceType($Uint8)).nil, ($sliceType($Uint8)).nil), new x$2.constructor.Struct(x$2))); + rawContentsType = reflect.TypeOf(RawContent.nil); + bigIntType = reflect.TypeOf(new big.Int.Ptr()); }; return $pkg; })(); @@ -49974,6 +50530,9 @@ $packages["github.com/gopherjs/gopherjs/compiler"] = (function() { x$2 = _ref$10.$val; newIndex = new ast.IndexExpr.Ptr(c.newIdent("this.$target", (_entry$11 = c.p.info.Types[x$2.X.$key()], _entry$11 !== undefined ? _entry$11.v : new types.TypeAndValue.Ptr()).Type), 0, x$2.Index, 0); return c.formatExpr("new %s(function() { return %e; }, function($v) { %s }, %e)", new ($sliceType($emptyInterface))([new $String(c.typeName(exprType)), newIndex, new $String(c.translateAssign(newIndex, "$v", exprType, false)), x$2.X])); + } else if ($assertType(_ref$10, ($ptrType(ast.StarExpr)), true)[1]) { + x$2 = _ref$10.$val; + return c.translateExpr(x$2.X); } else { x$2 = _ref$10; $panic(new $String(fmt.Sprintf("Unhandled: %T\n", new ($sliceType($emptyInterface))([x$2])))); @@ -51256,7 +51815,7 @@ $packages["github.com/gopherjs/gopherjs/compiler"] = (function() { }; funcContext.prototype.formatExprInternal = function(format, a, parens) { return this.$val.formatExprInternal(format, a, parens); }; Compile = $pkg.Compile = function(importPath, files, fileSet, importContext, minify) { - var info, errList, previousErr, config, _tuple, typesPkg, err, _key, gcData, encodedFileSet, err$1, archive, _map, _key$1, c, _ref, _i, _keys, _entry, name, _key$2, importedPaths, _ref$1, _i$1, importedPkg, varName, _key$3, _ref$2, _i$2, impPath, _tuple$1, impOutput, err$2, functions, toplevelTypes, vars, _ref$3, _i$3, file, _ref$4, _i$4, _keys$1, _entry$1, k, v, _key$4, _ref$5, _i$5, decl, d, _ref$6, _entry$2, sig, recvType, _tuple$2, ptr, isPtr, _entry$3, o, _key$5, _ref$7, _ref$8, _i$6, spec, _entry$4, o$1, _ref$9, _i$7, spec$1, _ref$10, _i$8, name$1, _entry$5, o$2, done, _ref$11, _i$9, _keys$2, _entry$6, context, _ref$12, _i$10, _keys$3, _entry$7, obj, calls, _entry$8, _ref$13, _i$11, call, collectDependencies, _ref$14, _i$12, d$1, o$3, typeName, varsWithInit, _ref$15, _i$13, init$1, _ref$16, _i$14, o$4, _key$6, _ref$17, _i$15, d$2, o$5, _tuple$3, _entry$9, ok, _ref$18, _i$16, d$3, lhs, init$2, _ref$19, _i$17, i, o$6, ident, _key$7, _key$8, v$1, x, mainFunc, _ref$20, _i$18, d$4, context$1, o$7, fun, _entry$10, _entry$11, _ref$21, recvType$1, _tuple$4, ptr$1, isPointer, _tuple$5, namedRecvType, stmts, _ref$22, _i$19, dep, id, call$1, _tuple$6, depArchive, err$3, _key$9, _key$10, id$1, call$2, _key$11, _key$12, id$2, _key$13, call$3; + var info, errList, previousErr, config, _tuple, typesPkg, err, _key, gcData, encodedFileSet, err$1, archive, _map, _key$1, c, _ref, _i, _keys, _entry, name, _key$2, importedPaths, _ref$1, _i$1, importedPkg, varName, _key$3, _ref$2, _i$2, impPath, _tuple$1, impOutput, err$2, functions, toplevelTypes, vars, _ref$3, _i$3, file, _ref$4, _i$4, _keys$1, _entry$1, k, v, _key$4, _ref$5, _i$5, decl, d, _ref$6, _entry$2, sig, recvType, _tuple$2, ptr, isPtr, _entry$3, o, _key$5, _ref$7, _ref$8, _i$6, spec, _entry$4, o$1, _ref$9, _i$7, spec$1, _ref$10, _i$8, name$1, _entry$5, o$2, done, _ref$11, _i$9, _keys$2, _entry$6, context, _ref$12, _i$10, _keys$3, _entry$7, obj, calls, _entry$8, _ref$13, _i$11, call, collectDependencies, _ref$14, _i$12, d$1, o$3, typeName, varsWithInit, _ref$15, _i$13, init$1, _ref$16, _i$14, o$4, _key$6, _ref$17, _i$15, d$2, o$5, _tuple$3, _entry$9, ok, _ref$18, _i$16, lhs, d$3, init$2, _ref$19, _i$17, i, o$6, ident, _key$7, _key$8, v$1, x, mainFunc, _ref$20, _i$18, o$7, d$4, context$1, fun, _entry$10, _entry$11, _ref$21, recvType$1, _tuple$4, ptr$1, isPointer, _tuple$5, namedRecvType, stmts, _ref$22, _i$19, dep, id, call$1, _tuple$6, depArchive, err$3, _key$9, _key$10, id$1, call$2, _key$11, _key$12, id$2, _key$13, call$3; info = new types.Info.Ptr(new $Map(), new $Map(), new $Map(), new $Map(), new $Map(), false, ($sliceType(($ptrType(types.Initializer)))).nil); errList = ErrorList.nil; previousErr = $ifaceNil; @@ -51544,8 +52103,8 @@ $packages["github.com/gopherjs/gopherjs/compiler"] = (function() { _ref$18 = c.p.info.InitOrder; _i$16 = 0; while (_i$16 < _ref$18.$length) { - d$3 = [undefined]; lhs = [undefined]; + d$3 = [undefined]; init$2 = ((_i$16 < 0 || _i$16 >= _ref$18.$length) ? $throwRuntimeError("index out of range") : _ref$18.$array[_ref$18.$offset + _i$16]); lhs[0] = ($sliceType(ast.Expr)).make(init$2.Lhs.$length); _ref$19 = init$2.Lhs; @@ -51582,9 +52141,9 @@ $packages["github.com/gopherjs/gopherjs/compiler"] = (function() { _ref$20 = functions; _i$18 = 0; while (_i$18 < _ref$20.$length) { + o$7 = [undefined]; d$4 = [undefined]; context$1 = [undefined]; - o$7 = [undefined]; fun = ((_i$18 < 0 || _i$18 >= _ref$20.$length) ? $throwRuntimeError("index out of range") : _ref$20.$array[_ref$20.$offset + _i$18]); o$7[0] = $assertType((_entry$10 = c.p.info.Defs[fun.Name.$key()], _entry$10 !== undefined ? _entry$10.v : $ifaceNil), ($ptrType(types.Func))); context$1[0] = (_entry$11 = c.p.funcContexts[o$7[0].$key()], _entry$11 !== undefined ? _entry$11.v : ($ptrType(funcContext)).nil); @@ -56395,17 +56954,17 @@ $packages["go/format"] = (function() { }; return $pkg; })(); -$packages["github.com/gopherjs/gopherjs.github.io/playground"] = (function() { +$packages["/home/h8liu/projects/gojs-pg/playground"] = (function() { var $pkg = {}, bytes = $packages["bytes"], angularjs = $packages["github.com/gopherjs/go-angularjs"], compiler = $packages["github.com/gopherjs/gopherjs/compiler"], js = $packages["github.com/gopherjs/gopherjs/js"], ast = $packages["go/ast"], format = $packages["go/format"], parser = $packages["go/parser"], scanner = $packages["go/scanner"], token = $packages["go/token"], strings = $packages["strings"], time = $packages["time"], Line, output, main, setupEnvironment; - Line = $pkg.Line = $newType(4, "Map", "main.Line", "Line", "github.com/gopherjs/gopherjs.github.io/playground", null); + Line = $pkg.Line = $newType(4, "Map", "main.Line", "Line", "/home/h8liu/projects/gojs-pg/playground", null); main = function() { var app; - app = angularjs.NewModule("playground", ($sliceType($String)).nil, $throwNilPointerError); - app.NewController("PlaygroundCtrl", (function(scope) { + app = angularjs.NewModule("playground", ($sliceType($String)).nil); + app.NewController("PlaygroundCtrl", new ($funcType([($ptrType(angularjs.Scope))], [], false))((function(scope) { var packages, pkgsToLoad, importContext, fileSet, pkgsReceived, codeArea, run; - scope.Object.code = $externalize("package main\n\nimport (\n\t\"fmt\"\n\t\"github.com/gopherjs/gopherjs/js\"\n)\n\nfunc main() {\n\tfmt.Println(\"Hello, playground\")\n\tjs.Global.Call(\"alert\", \"Hello, JavaScript\")\n\tprintln(\"Hello, JS console\")\n}\n", $String); - scope.Object.showGenerated = $externalize(false, $Bool); - scope.Object.generated = $externalize("(generated code will be shown here after clicking \"Run\")", $String); + scope.Provider.Object.code = $externalize("package main\n\nimport (\n\t\"fmt\"\n\t\"github.com/gopherjs/gopherjs/js\"\n)\n\nfunc main() {\n\tfmt.Println(\"Hello, playground\")\n\tjs.Global.Call(\"alert\", \"Hello, JavaScript\")\n\tprintln(\"Hello, JS console\")\n}\n", $String); + scope.Provider.Object.showGenerated = $externalize(false, $Bool); + scope.Provider.Object.generated = $externalize("(generated code will be shown here after clicking \"Run\")", $String); packages = new $Map(); pkgsToLoad = ($sliceType($String)).nil; importContext = compiler.NewImportContext((function(path) { @@ -56430,7 +56989,7 @@ $packages["github.com/gopherjs/gopherjs.github.io/playground"] = (function() { } else if (_ref === 13) { toInsert = "\n"; start = $parseInt(codeArea.Prop("selectionStart")) >> 0; - code = $internalize(scope.Object.code, $String); + code = $internalize(scope.Provider.Object.code, $String); i = strings.LastIndex(code.substring(0, start), "\n") + 1 >> 0; while (i < start) { c = code.charCodeAt(i); @@ -56444,9 +57003,9 @@ $packages["github.com/gopherjs/gopherjs.github.io/playground"] = (function() { if (!(toInsert === "")) { start$1 = $parseInt(codeArea.Prop("selectionStart")) >> 0; end = $parseInt(codeArea.Prop("selectionEnd")) >> 0; - code$1 = $internalize(scope.Object.code, $String); + code$1 = $internalize(scope.Provider.Object.code, $String); scope.Apply((function() { - scope.Object.code = $externalize(code$1.substring(0, start$1) + toInsert + code$1.substring(end), $String); + scope.Provider.Object.code = $externalize(code$1.substring(0, start$1) + toInsert + code$1.substring(end), $String); })); codeArea.SetProp(new $String("selectionStart"), new $Int((start$1 + toInsert.length >> 0))); codeArea.SetProp(new $String("selectionEnd"), new $Int((start$1 + toInsert.length >> 0))); @@ -56457,9 +57016,9 @@ $packages["github.com/gopherjs/gopherjs.github.io/playground"] = (function() { run = (function(loadOnly) { var _tuple, file, err, _tuple$1, list, ok, _ref, _i, entry, _map, _key, _map$1, _key$1, _tuple$2, mainPkg, _key$2, _tuple$3, list$1, ok$1, output$1, _ref$1, _i$1, entry$1, _map$2, _key$3, _map$3, _key$4, allPkgs, _ref$2, _i$2, depPath, _tuple$4, dep, _ref$3, _i$3, req, path, p, mainPkgCode, _entry, jsCode; output = ($sliceType(Line)).nil; - scope.Object.output = $externalize(output, ($sliceType(Line))); + scope.Provider.Object.output = $externalize(output, ($sliceType(Line))); pkgsToLoad = ($sliceType($String)).nil; - _tuple = parser.ParseFile(fileSet, "prog.go", new ($sliceType($Uint8))($stringToBytes($internalize(scope.Object.code, $String))), 4); file = _tuple[0]; err = _tuple[1]; + _tuple = parser.ParseFile(fileSet, "prog.go", new ($sliceType($Uint8))($stringToBytes($internalize(scope.Provider.Object.code, $String))), 4); file = _tuple[0]; err = _tuple[1]; if (!($interfaceIsEqual(err, $ifaceNil))) { _tuple$1 = $assertType(err, scanner.ErrorList, true); list = _tuple$1[0]; ok = _tuple$1[1]; if (ok) { @@ -56470,10 +57029,10 @@ $packages["github.com/gopherjs/gopherjs.github.io/playground"] = (function() { output = $append(output, (_map = new $Map(), _key = "type", _map[_key] = { k: _key, v: "err" }, _key = "content", _map[_key] = { k: _key, v: entry.Error() }, _map)); _i++; } - scope.Object.output = $externalize(output, ($sliceType(Line))); + scope.Provider.Object.output = $externalize(output, ($sliceType(Line))); return; } - scope.Object.output = $externalize(new ($sliceType(Line))([(_map$1 = new $Map(), _key$1 = "type", _map$1[_key$1] = { k: _key$1, v: "err" }, _key$1 = "content", _map$1[_key$1] = { k: _key$1, v: err.Error() }, _map$1)]), ($sliceType(Line))); + scope.Provider.Object.output = $externalize(new ($sliceType(Line))([(_map$1 = new $Map(), _key$1 = "type", _map$1[_key$1] = { k: _key$1, v: "err" }, _key$1 = "content", _map$1[_key$1] = { k: _key$1, v: err.Error() }, _map$1)]), ($sliceType(Line))); return; } _tuple$2 = compiler.Compile("main", new ($sliceType(($ptrType(ast.File))))([file]), fileSet, importContext, false); mainPkg = _tuple$2[0]; err = _tuple$2[1]; @@ -56489,10 +57048,10 @@ $packages["github.com/gopherjs/gopherjs.github.io/playground"] = (function() { output$1 = $append(output$1, (_map$2 = new $Map(), _key$3 = "type", _map$2[_key$3] = { k: _key$3, v: "err" }, _key$3 = "content", _map$2[_key$3] = { k: _key$3, v: entry$1.Error() }, _map$2)); _i$1++; } - scope.Object.output = $externalize(output$1, ($sliceType(Line))); + scope.Provider.Object.output = $externalize(output$1, ($sliceType(Line))); return; } - scope.Object.output = $externalize(new ($sliceType(Line))([(_map$3 = new $Map(), _key$4 = "type", _map$3[_key$4] = { k: _key$4, v: "err" }, _key$4 = "content", _map$3[_key$4] = { k: _key$4, v: err.Error() }, _map$3)]), ($sliceType(Line))); + scope.Provider.Object.output = $externalize(new ($sliceType(Line))([(_map$3 = new $Map(), _key$4 = "type", _map$3[_key$4] = { k: _key$4, v: "err" }, _key$4 = "content", _map$3[_key$4] = { k: _key$4, v: err.Error() }, _map$3)]), ($sliceType(Line))); return; } allPkgs = ($sliceType(($ptrType(compiler.Archive)))).nil; @@ -56524,7 +57083,7 @@ $packages["github.com/gopherjs/gopherjs.github.io/playground"] = (function() { if (!((($parseInt(req[0].status) >> 0) === 200))) { scope.Apply((function(path, req) { return function() { var _map$4, _key$5; - scope.Object.output = $externalize(new ($sliceType(Line))([(_map$4 = new $Map(), _key$5 = "type", _map$4[_key$5] = { k: _key$5, v: "err" }, _key$5 = "content", _map$4[_key$5] = { k: _key$5, v: "cannot load package \"" + path[0] + "\"" }, _map$4)]), ($sliceType(Line))); + scope.Provider.Object.output = $externalize(new ($sliceType(Line))([(_map$4 = new $Map(), _key$5 = "type", _map$4[_key$5] = { k: _key$5, v: "err" }, _key$5 = "content", _map$4[_key$5] = { k: _key$5, v: "cannot load package \"" + path[0] + "\"" }, _map$4)]), ($sliceType(Line))); }; })(path, req)); return; } @@ -56533,7 +57092,7 @@ $packages["github.com/gopherjs/gopherjs.github.io/playground"] = (function() { if (!($interfaceIsEqual(err, $ifaceNil))) { scope.Apply((function(path, req) { return function() { var _map$4, _key$6; - scope.Object.output = $externalize(new ($sliceType(Line))([(_map$4 = new $Map(), _key$6 = "type", _map$4[_key$6] = { k: _key$6, v: "err" }, _key$6 = "content", _map$4[_key$6] = { k: _key$6, v: err.Error() }, _map$4)]), ($sliceType(Line))); + scope.Provider.Object.output = $externalize(new ($sliceType(Line))([(_map$4 = new $Map(), _key$6 = "type", _map$4[_key$6] = { k: _key$6, v: "err" }, _key$6 = "content", _map$4[_key$6] = { k: _key$6, v: err.Error() }, _map$4)]), ($sliceType(Line))); }; })(path, req)); return; } @@ -56552,26 +57111,26 @@ $packages["github.com/gopherjs/gopherjs.github.io/playground"] = (function() { } mainPkgCode = bytes.NewBuffer(($sliceType($Uint8)).nil); compiler.WritePkgCode((_entry = packages["main"], _entry !== undefined ? _entry.v : ($ptrType(compiler.Archive)).nil), false, new compiler.SourceMapFilter.Ptr(mainPkgCode, $throwNilPointerError, 0, 0, ($ptrType(token.FileSet)).nil)); - scope.Object.generated = $externalize(mainPkgCode.String(), $String); + scope.Provider.Object.generated = $externalize(mainPkgCode.String(), $String); jsCode = bytes.NewBuffer(($sliceType($Uint8)).nil); jsCode.WriteString("try{\n"); compiler.WriteProgramCode(allPkgs, importContext, new compiler.SourceMapFilter.Ptr(jsCode, $throwNilPointerError, 0, 0, ($ptrType(token.FileSet)).nil)); jsCode.WriteString("} catch (err) {\ngoPanicHandler(err.message);\n}\n"); $global.eval(jsCode.String()); }); - scope.Object.run = $externalize(run, ($funcType([$Bool], [], false))); + scope.Provider.Object.run = $externalize(run, ($funcType([$Bool], [], false))); run(true); - scope.Object.format = $externalize((function() { + scope.Provider.Object.format = $externalize((function() { var _tuple, out, err, _map, _key; - _tuple = format.Source(new ($sliceType($Uint8))($stringToBytes($internalize(scope.Object.code, $String)))); out = _tuple[0]; err = _tuple[1]; + _tuple = format.Source(new ($sliceType($Uint8))($stringToBytes($internalize(scope.Provider.Object.code, $String)))); out = _tuple[0]; err = _tuple[1]; if (!($interfaceIsEqual(err, $ifaceNil))) { - scope.Object.output = $externalize(new ($sliceType(Line))([(_map = new $Map(), _key = "type", _map[_key] = { k: _key, v: "err" }, _key = "content", _map[_key] = { k: _key, v: err.Error() }, _map)]), ($sliceType(Line))); + scope.Provider.Object.output = $externalize(new ($sliceType(Line))([(_map = new $Map(), _key = "type", _map[_key] = { k: _key, v: "err" }, _key = "content", _map[_key] = { k: _key, v: err.Error() }, _map)]), ($sliceType(Line))); return; } - scope.Object.code = $externalize($bytesToString(out), $String); - scope.Object.output = $externalize(new ($sliceType(Line))([]), ($sliceType(Line))); + scope.Provider.Object.code = $externalize($bytesToString(out), $String); + scope.Provider.Object.output = $externalize(new ($sliceType(Line))([]), ($sliceType(Line))); }), ($funcType([], [], false))); - })); + }))); }; setupEnvironment = function(scope) { $global.goPrintToConsole = (function(b) { @@ -56586,7 +57145,7 @@ $packages["github.com/gopherjs/gopherjs.github.io/playground"] = (function() { output = $append(output, (_map$1 = new $Map(), _key$2 = "type", _map$1[_key$2] = { k: _key$2, v: "out" }, _key$2 = "content", _map$1[_key$2] = { k: _key$2, v: ((i < 0 || i >= lines.$length) ? $throwRuntimeError("index out of range") : lines.$array[lines.$offset + i]) }, _map$1)); i = i + (1) >> 0; } - scope.Object.output = $externalize(output, ($sliceType(Line))); + scope.Provider.Object.output = $externalize(output, ($sliceType(Line))); scope.EvalAsync((function() { time.AfterFunc(new time.Duration(0, 0), (function() { var box; @@ -56598,7 +57157,7 @@ $packages["github.com/gopherjs/gopherjs.github.io/playground"] = (function() { $global.goPanicHandler = (function(msg) { var _map, _key; output = $append(output, (_map = new $Map(), _key = "type", _map[_key] = { k: _key, v: "err" }, _key = "content", _map[_key] = { k: _key, v: "panic: " + msg }, _map)); - scope.Object.output = $externalize(output, ($sliceType(Line))); + scope.Provider.Object.output = $externalize(output, ($sliceType(Line))); }); }; $pkg.$run = function($b) { @@ -56613,13 +57172,13 @@ $packages["github.com/gopherjs/gopherjs.github.io/playground"] = (function() { $packages["unicode"].$init(); $packages["unicode/utf8"].$init(); $packages["bytes"].$init(); - $packages["github.com/gopherjs/go-angularjs"].$init(); + $packages["encoding"].$init(); $packages["math"].$init(); - $packages["syscall"].$init(); + $packages["strconv"].$init(); $packages["strings"].$init(); + $packages["syscall"].$init(); $packages["time"].$init(); $packages["os"].$init(); - $packages["strconv"].$init(); $packages["reflect"].$init(); $packages["fmt"].$init(); $packages["sort"].$init(); @@ -56628,6 +57187,12 @@ $packages["github.com/gopherjs/gopherjs.github.io/playground"] = (function() { $packages["text/tabwriter"].$init(); $packages["runtime/pprof"].$init(); $r = $packages["testing"].$init(true); /* */ $s = 1; case 1: if ($r && $r.$blocking) { $r = $r(); } + $packages["encoding/base64"].$init(); + $packages["unicode/utf16"].$init(); + $packages["encoding/json"].$init(); + $packages["github.com/codegangsta/inject"].$init(); + $packages["github.com/phaikawl/options"].$init(); + $packages["github.com/gopherjs/go-angularjs"].$init(); $packages["go/token"].$init(); $packages["encoding/binary"].$init(); $packages["math/rand"].$init(); @@ -56653,10 +57218,6 @@ $packages["github.com/gopherjs/gopherjs.github.io/playground"] = (function() { $packages["text/scanner"].$init(); $packages["code.google.com/p/go.tools/go/gcimporter"].$init(); $packages["encoding/asn1"].$init(); - $packages["encoding"].$init(); - $packages["encoding/base64"].$init(); - $packages["unicode/utf16"].$init(); - $packages["encoding/json"].$init(); $packages["github.com/gopherjs/gopherjs/compiler/prelude"].$init(); $packages["github.com/gopherjs/gopherjs/gcexporter"].$init(); $packages["github.com/gopherjs/gopherjs/compiler"].$init(); @@ -56672,7 +57233,7 @@ $packages["github.com/gopherjs/gopherjs.github.io/playground"] = (function() { }; return $pkg; })(); -$go($packages["github.com/gopherjs/gopherjs.github.io/playground"].$run, [], true); +$go($packages["/home/h8liu/projects/gojs-pg/playground"].$run, [], true); })(); //# sourceMappingURL=playground.js.map