示例#1
0
                    // lexinit initializes known symbols and the basic types.
                    private static void lexinit()
                    {
                        {
                            var s__prev1 = s;

                            foreach (var(_, __s) in _addr_basicTypes)
                            {
                                s = __s;
                                var etype = s.etype;
                                if (int(etype) >= len(types.Types))
                                {
                                    Fatalf("lexinit: %s bad etype", s.name);
                                }

                                var s2 = builtinpkg.Lookup(s.name);
                                var t  = types.Types[etype];
                                if (t == null)
                                {
                                    t     = types.New(etype);
                                    t.Sym = s2;
                                    if (etype != TANY && etype != TSTRING)
                                    {
                                        dowidth(t);
                                    }

                                    types.Types[etype] = t;
                                }

                                s2.Def = asTypesNode(typenod(t));
                                asNode(s2.Def).Name;

                                @new <Name>();
                            }

                            s = s__prev1;
                        }

                        {
                            var s__prev1 = s;

                            foreach (var(_, __s) in _addr_builtinFuncs)
                            {
                                s      = __s;
                                s2     = builtinpkg.Lookup(s.name);
                                s2.Def = asTypesNode(newname(s2));
                                asNode(s2.Def).SetSubOp(s.op);
                            }

                            s = s__prev1;
                        }

                        {
                            var s__prev1 = s;

                            foreach (var(_, __s) in _addr_unsafeFuncs)
                            {
                                s      = __s;
                                s2     = unsafepkg.Lookup(s.name);
                                s2.Def = asTypesNode(newname(s2));
                                asNode(s2.Def).SetSubOp(s.op);
                            }

                            s = s__prev1;
                        }

                        types.Idealstring = types.New(TSTRING);
                        types.Idealbool   = types.New(TBOOL);
                        types.Types[TANY] = types.New(TANY);

                        var s = builtinpkg.Lookup("true");

                        s.Def = asTypesNode(nodbool(true));
                        asNode(s.Def).Sym;

                        lookup("true");
                        asNode(s.Def).Name;

                        @new <Name>();
                        asNode(s.Def).Type;

                        types.Idealbool;

                        s     = builtinpkg.Lookup("false");
                        s.Def = asTypesNode(nodbool(false));
                        asNode(s.Def).Sym;

                        lookup("false");
                        asNode(s.Def).Name;

                        @new <Name>();
                        asNode(s.Def).Type;

                        types.Idealbool;

                        s                   = lookup("_");
                        s.Block             = -100L;
                        s.Def               = asTypesNode(newname(s));
                        types.Types[TBLANK] = types.New(TBLANK);
                        asNode(s.Def).Type;

                        types.Types[TBLANK];
                        nblank = asNode(s.Def);

                        s                   = builtinpkg.Lookup("_");
                        s.Block             = -100L;
                        s.Def               = asTypesNode(newname(s));
                        types.Types[TBLANK] = types.New(TBLANK);
                        asNode(s.Def).Type;

                        types.Types[TBLANK];

                        types.Types[TNIL] = types.New(TNIL);
                        s = builtinpkg.Lookup("nil");
                        Val v = default;

                        v.U   = @new <NilVal>();
                        s.Def = asTypesNode(nodlit(v));
                        asNode(s.Def).Sym;

                        s;
                        asNode(s.Def).Name;

                        @new <Name>();

                        s     = builtinpkg.Lookup("iota");
                        s.Def = asTypesNode(nod(OIOTA, null, null));
                        asNode(s.Def).Sym;

                        s;
                        asNode(s.Def).Name;

                        @new <Name>();
                    }