Пример #1
0
 public override object Clone(CloneInfo info)
 {
     if (info.BackQuote)
     {
         var clone = new SymbolNode();
         BaseClone(clone);
         clone.Name = Name;
         return(clone);
     }
     else
     {
         if (info.LocalIdentifiers.Contains(Name) || !info.StackFrame.Scope.ContainsSymbol(Name))
         {
             var clone = new SymbolNode();
             BaseClone(clone);
             clone.Name = Name;
             return(clone);
         }
         else
         {
             var clone = new SymbolSnapshotNode();
             BaseClone(clone);
             clone.staticSymbol       = new Symbol();
             clone.StaticSymbol.Value = info.StackFrame.Scope.GetSymbol(Name).Value;
             clone.Name = Name;
             return(clone);
         }
     }
 }
Пример #2
0
 public override object Clone(CloneInfo info)
 {
     if (info.BackQuote)
     {
         var clone = new SymbolNode();
         BaseClone(clone);
         clone.Name = Name;
         return clone;
     }
     else
     {
         if (info.LocalIdentifiers.Contains(Name) || !info.StackFrame.Scope.ContainsSymbol(Name))
         {
             var clone = new SymbolNode();
             BaseClone(clone);
             clone.Name = Name;
             return clone;
         }
         else
         {
             var clone = new SymbolSnapshotNode();
             BaseClone(clone);
             clone.staticSymbol = new Symbol();
             clone.StaticSymbol.Value = info.StackFrame.Scope.GetSymbol(Name).Value;
             clone.Name = Name;
             return clone;
         }
     }
 }
Пример #3
0
        private ValueNode ParseQuote(ParseInfo info, ref int index)
        {
            var node = new ConsNode();
            node.Args = new List<object>();
            var idNode = new SymbolNode();
            idNode.Name = "quote";
            idNode.CodeStartIndex = index;
            idNode.CodeLength = 1;
            SetupNode(info, idNode);
            node.Args.Add(idNode);

            node.CodeStartIndex = index;
            index++;
            object expression = ParseArg(info, ref index);

            node.Args.Add(expression);

            node.CodeLength = index - node.CodeStartIndex;
            SetupNode(info, node);

            return node;
        }
Пример #4
0
        private object ParseLiteral(ParseInfo info, ref int index)
        {
            string current = GetToken(info, ref index);

            double doubleValue;
            if (double.TryParse(current, NumberStyles.Number, CultureInfo.InvariantCulture, out doubleValue))
            {
                if (current.IndexOf(".") >= 0)
                {
                    return doubleValue;
                }
                else
                {
                    return (int) doubleValue;
                }
            }
            else
            {
                if (current.Length > 1 && current.EndsWith("b"))
                {
                    string prefix = current.Substring(0, current.Length - 1);
                    long l = 0;
                    if (long.TryParse(prefix, out l))
                    {
                        return new BigInteger(l);
                    }
                }

                var valueNode = new SymbolNode();
                SetupNode(info, valueNode);
                valueNode.Name = current;
                valueNode.CodeStartIndex = index - current.Length;
                valueNode.CodeLength = current.Length;
                return valueNode;
            }
        }