Esempio n. 1
0
        /// <summary>
        /// Gets the string representation of a given full symbol.
        /// </summary>
        protected static string ToDebugString(FullSymbol symbol)
        {
            Contract.Requires(symbol.IsValid);
#if DEBUG
            return(FrontEndContext.DebugContext != null?symbol.ToString(FrontEndContext.DebugContext.SymbolTable) : symbol.ToString());
#else
            return(symbol.ToString());
#endif
        }
Esempio n. 2
0
        public void GetParent()
        {
            var        idt    = new SymbolTable();
            FullSymbol da     = FullSymbol.Create(idt, @"c.a");
            FullSymbol parent = da.GetParent(idt);

            XAssert.AreEqual(@"c", parent.ToString(idt));

            da     = FullSymbol.Create(idt, @"c.a.b");
            parent = da.GetParent(idt);
            XAssert.AreEqual(@"c.a", parent.ToString(idt));
        }
Esempio n. 3
0
        public void Concat()
        {
            var        idt = new SymbolTable();
            FullSymbol a1  = FullSymbol.Create(idt, @"C.A");
            SymbolAtom p1  = SymbolAtom.Create(idt.StringTable, "B");
            FullSymbol a2  = a1.Concat(idt, p1);

            XAssert.AreEqual(@"C.AB", a2.ToString(idt));
        }
Esempio n. 4
0
        public void RelocateForm2()
        {
            var        idt = new SymbolTable();
            FullSymbol d2  = FullSymbol.Create(idt, @"c.a.x");
            FullSymbol f1  = FullSymbol.Create(idt, @"C.a.b.c.d.cpp");

            XAssert.IsFalse(f1.IsWithin(idt, d2));
            FullSymbol f2 = f1.Relocate(idt, d2);

            XAssert.AreEqual(@"c.a.x.cpp", f2.ToString(idt));
        }
Esempio n. 5
0
        public void IsInitialized()
        {
            FullSymbol p = default(FullSymbol);

            XAssert.IsFalse(p.IsValid);

            var idt = new SymbolTable();

            p = FullSymbol.Create(idt, @"C.AAA.CCC");
            XAssert.AreEqual(@"C.AAA.CCC", p.ToString(idt));
            XAssert.IsTrue(p.IsValid);
        }
Esempio n. 6
0
        /// <summary>
        /// Evaluates a member using by resolving a symbol by a full name.
        /// </summary>
        /// <remarks>
        /// DScript V2 feature.
        /// </remarks>
        internal EvaluationResult EvaluateEntryByFullName(Context context, FullSymbol fullName, LineInfo location)
        {
            ResolvedEntry resolvedEntry = default(ResolvedEntry);

            if (CurrentFileModule?.TryGetResolvedEntryByFullName(fullName, out resolvedEntry) == true)
            {
                return(EvaluateResolvedSymbol(context, this, location, resolvedEntry));
            }

            // This is an assertion but not a graceful error, because resolution may fail only if something went wrong.
            string message = I($"Can't find resolved symbol by a full name '{fullName.ToString(context.FrontEndContext.SymbolTable)}'");

            Contract.Assert(false, message);

            return(EvaluationResult.Undefined);
        }
Esempio n. 7
0
        private bool TryResolveEntryByLocation(Context context, FilePosition filePosition, FullSymbol nameForDebuggingPurposes, out ResolvedEntry resolvedEntry, out FileModuleLiteral owningFileModule)
        {
            owningFileModule = default(FileModuleLiteral);
            resolvedEntry    = default(ResolvedEntry);

            if (CurrentFileModule?.TryGetResolvedEntry(context.ModuleRegistry, filePosition, out resolvedEntry, out owningFileModule) == true)
            {
                return(true);
            }

            // This is an assertion but not a graceful error, because resolution may fail only if something went wrong.
            string message =
                I($"Can't find resolved symbol '{nameForDebuggingPurposes.ToString(context.FrontEndContext.SymbolTable)}' at position '{filePosition.Position}' from source file '{filePosition.Path.ToString(context.PathTable)}'");

            Contract.Assert(false, message);
            return(false);
        }
Esempio n. 8
0
        public void Combine()
        {
            var        idt = new SymbolTable();
            FullSymbol a1  = FullSymbol.Create(idt, @"C");
            SymbolAtom p1  = SymbolAtom.Create(idt.StringTable, "A");
            FullSymbol a2  = a1.Combine(idt, p1);

            XAssert.AreEqual(@"C.A", a2.ToString(idt));

            a1 = FullSymbol.Create(idt, @"C.X");
            p1 = SymbolAtom.Create(idt.StringTable, "A");
            a2 = a1.Combine(idt, p1);
            XAssert.AreEqual(@"C.X.A", a2.ToString(idt));

            a1 = FullSymbol.Create(idt, @"C.X");
            p1 = SymbolAtom.Create(idt.StringTable, "A");
            SymbolAtom p2 = SymbolAtom.Create(idt.StringTable, "B");

            a2 = a1.Combine(idt, p1, p2);
            XAssert.AreEqual(@"C.X.A.B", a2.ToString(idt));

            a1 = FullSymbol.Create(idt, @"C.X");
            p1 = SymbolAtom.Create(idt.StringTable, "A");
            p2 = SymbolAtom.Create(idt.StringTable, "B");
            SymbolAtom p3 = SymbolAtom.Create(idt.StringTable, "C");

            a2 = a1.Combine(idt, p1, p2, p3);
            XAssert.AreEqual(@"C.X.A.B.C", a2.ToString(idt));

            a1 = FullSymbol.Create(idt, @"C");
            PartialSymbol rp = PartialSymbol.Create(idt.StringTable, @"A.B");

            a2 = a1.Combine(idt, rp);
            XAssert.AreEqual(@"C.A.B", a2.ToString(idt));

            a1 = FullSymbol.Create(idt, @"C.X");
            rp = PartialSymbol.Create(idt.StringTable, @"A.B");
            a2 = a1.Combine(idt, rp);
            XAssert.AreEqual(@"C.X.A.B", a2.ToString(idt));
        }
Esempio n. 9
0
 /// <summary>
 /// Converts a FullSymbol to a string
 /// </summary>
 /// <param name="symbolTable">SymbolTable to use to convert the FullSymbol</param>
 /// <param name="fullSymbol">FullSymbol to convert to string</param>
 /// <returns>The result of converting the provided FullSymbol to a string</returns>
 public static string FullSymbolToString(this SymbolTable symbolTable, FullSymbol fullSymbol)
 {
     return(fullSymbol.ToString(symbolTable));
 }
Esempio n. 10
0
 public XElement CreateRow(string key, FullSymbol value)
 {
     return(value.IsValid ? CreateRow(key, value.ToString(m_symbolTable)) : null);
 }
Esempio n. 11
0
 private static string CreateString(FullSymbol value, SymbolTable symbolTable)
 {
     return(value.IsValid ? value.ToString(symbolTable) : null);
 }