id
stringlengths
2
7
text
stringlengths
17
51.2k
title
stringclasses
1 value
c6600
if !math.IsInf(float64(x), 0) { cmp = x.rational().Cmp(y.rational()) // x is finite } else if x > 0 { cmp = -1 // x is +Inf } else { cmp = +1 // x is -Inf } return threeway(op, cmp), nil } } // All other values of different types compare unequal. switch op { case syntax.EQL: return ...
c6601
fmt.Printf("\tentry %d @ %p hash=%d key=%v value=%v\n", i, e, e.hash, e.key, e.value) fmt.Printf("\t\tnext=%p &next=%p prev=%p", e.next, &e.next, e.prevLink) if e.prevLink != nil { fmt.Printf(" *prev=%p", *e.prevLink) } fmt.Println() } } } }
c6602
on amd64 machines. return uint32(goStringHash(s, 0)) } return softHashString(s) }
c6603
h ^= uint32(s[i]) h *= 16777619 } return h }
c6604
first lookahead token expr = p.parseTest() // A following newline (e.g. "f()\n") appears outside any brackets, // on a non-blank line, and thus results in a NEWLINE token. if p.tok == NEWLINE { p.nextToken() } if p.tok != EOF { p.in.errorf(p.in.pos, "got %#v after expression, want EOF", p.tok) } p.assign...
c6605
if debug { log.Printf("nextToken: %-20s%+v\n", p.tok, p.tokval.pos) } return oldpos }
c6606
= p.parseTestNoCond() } return &LambdaExpr{ Lambda: lambda, Function: Function{ StartPos: lambda, Params: params, Body: []Stmt{&ReturnStmt{Result: body}}, }, } }
c6607
case LBRACK: x = p.parseSliceSuffix(x) case LPAREN: x = p.parseCallSuffix(x) default: return x } } }
c6608
post = append(post, stack[len(stack)-1]) stack = stack[:len(stack)-1] } return true }) return pre, post }
c6609
r <= 'Z' || unicode.SimpleFold(r) != r { return true } } return false }
c6610
} return Int{&smallint[x]} } return Int{new(big.Int).SetInt64(x)} }
c6611
Int{&smallint[x]} } return Int{new(big.Int).SetUint64(uint64(x))} }
c6612
big.Exact { return // inexact } return x, true }
c6613
big.Exact { return // inexact } return x, true }
c6614
values without allocation. f, _ := new(big.Float).SetInt(i.bigint).Float64() return Float(f) }
c6615
&& v <= math.MaxInt32 { return int(v), nil } } return 0, fmt.Errorf("%s out of range", i) }
c6616
convert float NaN to integer") } return finiteFloatToInt(x), nil } return zero, fmt.Errorf("cannot convert %s to int", x.Type()) }
c6617
nil { panic(f) // non-finite } i.Div(rat.Num(), rat.Denom()) } return Int{&i} }
c6618
"allow nested def statements") flag.BoolVar(&resolve.AllowBitwise, "bitwise", resolve.AllowBitwise, "allow bitwise operations (&, |, ^, ~, <<, and >>)") }
c6619
== nil { thread.locals = make(map[string]interface{}) } thread.locals[key] = value }
c6620
fmt.Sprintf(format, args...) return &EvalError{Msg: msg, Frame: fr} }
c6621
{ return fn.funcode.Position(fr.callpc) // position of active call } return syntax.MakePosition(&builtinFilename, 1, 0) }
c6622
e.Frame.WriteBacktrace(&buf) fmt.Fprintf(&buf, "Error: %s", e.Msg) return buf.String() }
c6623
print(fr.parent) fmt.Fprintf(out, " %s: in %s\n", fr.Position(), fr.Callable().Name()) } } print(fr) }
c6624
{ stack = append(stack, fr) } return stack }
c6625
err := resolve.File(f, isPredeclared, Universe.Has); err != nil { return f, nil, err } compiled := compile.File(f.Stmts, f.Locals, f.Globals) return f, &Program{compiled}, nil }
c6626
return nil, err } return &Program{prog}, nil }
c6627
a map and freeze it. // We return a (partial) map even in case of error. return toplevel.Globals(), err }
c6628
append(x.elems, ylist.elems...) } else { iter := y.Iterate() defer iter.Done() var z Value for iter.Next(&z) { x.elems = append(x.elems, z) } } }
c6629
return v, err } } return nil, fmt.Errorf("%s has no .%s field or method", x.Type(), name) }
c6630
{ err := x.SetField(name, y) return err } return fmt.Errorf("can't assign to .%s field of %s", name, x.Type()) }
c6631
check: nil is not a valid Skylark value. if result == nil && err == nil { return nil, fmt.Errorf("internal error: nil (not None) returned from %s", fn) } return result, err }
c6632
isUniversal) r.expr(expr) r.env.resolveLocalUses() r.resolveNonLocalUses(r.env) // globals & universals if len(r.errors) > 0 { return nil, r.errors } return r.moduleLocals, nil }
c6633
// Assign it a new local (positive) index in the current container. _, ok := r.env.bindings[id.Name] if !ok { var locals *[]*syntax.Ident if fn := r.container().function; fn != nil { locals = &fn.Locals } else { locals = &r.moduleLocals } r.env.bind(id.Name, binding{Local, len(*locals)}) *locals =...
c6634
%d", use.id.NamePos, use.id.Name, bind) } return bind // found } if env.function != nil { break } } return binding{} // not found in this function }
c6635
env.function.FreeVars = append(env.function.FreeVars, id) if debug { fmt.Printf("creating freevar %v in function at %s: %s\n", len(env.function.FreeVars), fmt.Sprint(env.function.Span()), id.Name) } } // Memoize, to avoid duplicate free vars // and redundant global (failing) lookups. env.bind(i...
c6636
0, len(d)), } for k, v := range d { s.entries = append(s.entries, entry{k, v}) } sort.Sort(s.entries) return s }
c6637
// to_{json,proto} are deprecated, appropriately; see Google issue b/36412967. switch name { case "to_json", "to_proto": return skylark.NewBuiltin(name, func(thread *skylark.Thread, fn *skylark.Builtin, args skylark.Tuple, kwargs []skylark.Tuple) (skylark.Value, error) { var buf bytes.Buffer var err error ...
c6638
if err != nil { report.Errorf("%s:%d: not a quoted regexp: %s", filename, linenum, rest) continue } rx, err := regexp.Compile(pattern) if err != nil { report.Errorf("%s:%d: %v", filename, linenum, err) continue } wantErrs[linenum] = rx if debug { fmt.Printf("\t%d\t%s\n", linenu...
c6639
match pattern %q", chunk.filename, linenum, msg, rx) } } else { chunk.report.Errorf("%s:%d: unexpected error: %v", chunk.filename, linenum, msg) } }
c6640
expected error matching %q", chunk.filename, linenum, rx) } }
c6641
p.Col = 1 } p.Col += int32(utf8.RuneCountInString(s)) return p }
c6642
return '\n' } return rune(b) } r, _ := utf8.DecodeRune(sc.rest) return r }
c6643
sc.rest[1:] } r = '\n' } if r == '\n' { sc.pos.Line++ sc.pos.Col = 1 } else { sc.pos.Col++ } return r } r, size := utf8.DecodeRune(sc.rest) sc.rest = sc.rest[size:] sc.pos.Col++ return r }
c6644
sc.rest val.raw = "" val.pos = sc.pos }
c6645
== "" { val.raw = string(sc.token[:len(sc.token)-len(sc.rest)]) } }
c6646
fmt.Fprintln(os.Stderr, evalErr.Backtrace()) } else { fmt.Fprintln(os.Stderr, err) } }
c6647
== nil { if ok { // request for package whose loading is in progress return nil, fmt.Errorf("cycle in load graph") } // Add a placeholder to indicate "load in progress". cache[module] = nil // Load it. thread := &skylark.Thread{Load: thread.Load} globals, err := skylark.ExecFile(thread, ...
c6648
Filename: prog.Toplevel.Pos.Filename(), Loads: gobIdents(prog.Loads), Names: prog.Names, Constants: prog.Constants, Functions: make([]gobFunction, len(prog.Functions)), Globals: gobIdents(prog.Globals), Toplevel: gobFunc(prog.Toplevel), } for i, f := range prog.Functions { gp.Functions[i]...
c6649
Globals: ungobIdents(gp.Globals), Functions: make([]*Funcode, len(gp.Functions)), } ungobFunc := func(gf *gobFunction) *Funcode { pos := syntax.MakePosition(&file, gf.Id.Line, gf.Id.Col) return &Funcode{ Prog: prog, Pos: pos, Name: gf.Id.Name, Code: gf.Code, pclinet...
c6650
res[i].Name = id.Name res[i].Pos = id.NamePos } return res }
c6651
expr}} return File(stmts, locals, nil).Toplevel }
c6652
> 0 { pos = syntax.Start(stmts[0]) } pcomp.prog.Toplevel = pcomp.function("<toplevel>", pos, stmts, locals, nil) return pcomp.prog }
c6653
if insn.op >= OpcodeArgMin { if insn.op == CJMP || insn.op == ITERJMP { code = addUint32(code, insn.arg, 4) // pad arg to 4 bytes } else { code = addUint32(code, insn.arg, 0) } pc = uint32(len(code)) } } if b.jmp != nil && b.jmp.index != b.index+1 { addr := b.jmp.addr if debug...
c6654
CALL_VAR, CALL_KW, CALL_VAR_KW: comment = fmt.Sprintf("%d pos, %d named", arg>>8, arg&0xff) default: // JMP, CJMP, ITERJMP, MAKETUPLE, MAKELIST, LOAD, UNPACK: // arg is just a number } var buf bytes.Buffer fmt.Fprintf(&buf, "\t%d\t%-10s\t%d", pc, op, arg) if comment != "" { fmt.Fprint(&buf, "\t; ", commen...
c6655
fcomp.block.insns = append(fcomp.block.insns, insn) fcomp.pos.Line = 0 }
c6656
arg: arg, line: fcomp.pos.Line} fcomp.block.insns = append(fcomp.block.insns, insn) fcomp.pos.Line = 0 }
c6657
// unreachable: Skylark has no arbitrary looping constructs } fcomp.block.jmp = b fcomp.block = nil }
c6658
index pcomp.prog.Names = append(pcomp.prog.Names, name) } return index }
c6659
index pcomp.prog.Constants = append(pcomp.prog.Constants, v) } return index }
c6660
pcomp.prog.Functions = append(pcomp.prog.Functions, fn) } return index }
c6661
fcomp.pcomp.constantIndex(s)) }
c6662
log.Fatalf("%s: set(%s): neither global nor local (%d)", id.NamePos, id.Name, id.Scope) } }
c6663
fcomp.setPos(id.NamePos) fcomp.emit1(GLOBAL, uint32(id.Index)) case resolve.Predeclared: fcomp.setPos(id.NamePos) fcomp.emit1(PREDECLARED, fcomp.pcomp.nameIndex(id.Name)) case resolve.Universal: fcomp.emit1(UNIVERSAL, fcomp.pcomp.nameIndex(id.Name)) default: log.Fatalf("%s: compiler.lookup(%s): scope = %...
c6664
fcomp.emit(EXCH) fcomp.setPos(lhs.Lbrack) fcomp.emit(SETINDEX) case *syntax.DotExpr: // x.f = rhs fcomp.expr(lhs.X) fcomp.emit(EXCH) fcomp.setPos(lhs.Dot) fcomp.emit1(SETFIELD, fcomp.pcomp.nameIndex(lhs.Name.Name)) default: panic(lhs) } }
c6665
'l': var elems []syntax.Expr for _, arg := range args { elems = append(elems, arg.x.(*syntax.ListExpr).List...) } return &syntax.ListExpr{List: elems} case 't': var elems []syntax.Expr for _, arg := range args { elems = append(elems, arg.x.(*syntax.TupleExpr).List...) } return &syntax.TupleExpr{...
c6666
y := fcomp.newBlock() fcomp.condjump(CJMP, t, y) fcomp.block = y fcomp.ifelse(cond.Y, t, f) return case syntax.NOT_IN: // if x not in y then goto t else goto f // => // if x in y then goto f else goto t copy := *cond copy.Op = syntax.IN fcomp.expr(&copy) fcomp.condjump(CJMP, f...
c6667
Col %d", e.Line, e.Column) if e.Token != nil { s += fmt.Sprintf(" near '%s'", e.Token.Val) } } s += "] " s += e.OrigError.Error() return s }
c6668
nil && outErr == nil { outErr = err } }() scanner := bufio.NewScanner(file) l := 0 for scanner.Scan() { l++ if l == e.Line { return scanner.Text(), true, nil } } return "", false, nil }
c6669
} if len(tokens) > 0 { p.lastToken = tokens[len(tokens)-1] } return p }
c6670
p.Consume() return t } return nil }
c6671
nil { p.Consume() return t } return nil }
c6672
return p.PeekN(0, typ, val) }
c6673
&Error{ Template: p.template, Filename: p.name, Sender: "parser", Line: line, Column: col, Token: token, OrigError: errors.New(msg), } }
c6674
return tpl.newTemplateWriterAndExecute(context, writer) }
c6675
buffer, err := tpl.newBufferAndExecute(context) if err != nil { return "", err } return buffer.String(), nil }
c6676
:= NewLocalFileSystemLoader(baseDir) if err != nil { log.Panic(err) } return fs }
c6677
{ return nil, err } return bytes.NewReader(buf), nil }
c6678
if err != nil { return nil, err } return &SandboxedFilesystemLoader{ LocalFilesystemLoader: fs, }, nil }
c6679
} _, has = set.bannedTags[name] if has { return errors.Errorf("tag '%s' is already banned", name) } set.bannedTags[name] = true return nil }
c6680
} _, has = set.bannedFilters[name] if has { return errors.Errorf("filter '%s' is already banned", name) } set.bannedFilters[name] = true return nil }
c6681
} for _, filename := range filenames { delete(set.templateCache, set.resolveFilename(nil, filename)) } }
c6682
error) { set.firstTemplateCreated = true return newTemplateString(set, []byte(tpl)) }
c6683
= true return newTemplateString(set, tpl) }
c6684
{ return nil, &Error{ Filename: filename, Sender: "fromfile", OrigError: err, } } return newTemplate(set, filename, false, buf) }
c6685
err := tpl.Execute(ctx) if err != nil { return "", err } return result, nil }
c6686
err := tpl.Execute(ctx) if err != nil { return "", err } return result, nil }
c6687
err := tpl.Execute(ctx) if err != nil { return "", err } return result, nil }
c6688
val: reflect.ValueOf(i), safe: true, } }
c6689
v.getResolvedValue().Kind() == reflect.Float64 }
c6690
== reflect.Uint8 || v.getResolvedValue().Kind() == reflect.Uint16 || v.getResolvedValue().Kind() == reflect.Uint32 || v.getResolvedValue().Kind() == reflect.Uint64 }
c6691
return len(runes) default: logf("Value.Len() not available for type: %s\n", v.getResolvedValue().Kind().String()) return 0 } }
c6692
i < len(runes) { return AsValue(string(runes[i])) } return AsValue("") default: logf("Value.Slice() not available for type: %s\n", v.getResolvedValue().Kind().String()) return AsValue([]int{}) } }
c6693
return v.val.Interface() } return nil }
c6694
return v.Integer() == other.Integer() } return v.Interface() == other.Interface() }
c6695
{ val, err := ApplyFilter(name, value, param) if err != nil { panic(err) } return val }
c6696
ctrl} mock.recorder = &MockCollectorReaderMockRecorder{mock} return mock }
c6697
"GetAllRecords", reflect.TypeOf((*MockCollectorReader)(nil).GetAllRecords)) }
c6698
:= ret[0].(map[string]*collector.UserRecord) return ret0 }
c6699
mock.recorder = &MockCollectorMockRecorder{mock} return mock }