Exemplo n.º 1
0
        public override string CodeForm(TAC.Machine vm, int recursionLimit = -1)
        {
            if (recursionLimit == 0)
            {
                return("{...}");
            }
            if (recursionLimit > 0 && recursionLimit < 3 && vm != null)
            {
                string shortName = vm.FindShortName(this);
                if (shortName != null)
                {
                    return(shortName);
                }
            }
            var strs = new string[map.Count];
            int i    = 0;

            foreach (KeyValuePair <Value, Value> kv in map)
            {
                int nextRecurLimit = recursionLimit - 1;
                if (kv.Key == ValString.magicIsA)
                {
                    nextRecurLimit = 1;
                }
                strs[i++] = string.Format("{0}: {1}", kv.Key.CodeForm(vm, nextRecurLimit),
                                          kv.Value == null ? "null" : kv.Value.CodeForm(vm, nextRecurLimit));
            }
            return("{" + String.Join(", ", strs) + "}");
        }
Exemplo n.º 2
0
        public override string CodeForm(TAC.Machine vm, int recursionLimit = -1)
        {
            if (recursionLimit == 0)
            {
                return("[...]");
            }
            if (recursionLimit > 0 && recursionLimit < 3 && vm != null)
            {
                string shortName = vm.FindShortName(this);
                if (shortName != null)
                {
                    return(shortName);
                }
            }
            var strs = new string[values.Count];

            for (var i = 0; i < values.Count; i++)
            {
                if (values[i] == null)
                {
                    strs[i] = "null";
                }
                else
                {
                    strs[i] = values[i].CodeForm(vm, recursionLimit - 1);
                }
            }
            return("[" + string.Join(", ", strs) + "]");
        }