コード例 #1
0
ファイル: CustomResolver.cs プロジェクト: SealedSun/prx
 /// <summary>
 ///     Applies the encapsulated custom resolver to the supplied AST node.
 /// </summary>
 /// <param name = "t">The compiler target for which to resolve the node.</param>
 /// <param name = "unresolved">The unresolved AST node.</param>
 /// <returns>Null if no solution has been found. A compatible AST node otherwise.</returns>
 public AstExpr Resolve(CompilerTarget t, AstUnresolved unresolved)
 {
     if (IsManaged)
     {
         return _managed(t, unresolved);
     }
     else if (IsInterpreted)
     {
         var presult = _interpreted.IndirectCall
             (
                 t.Loader, new[]
                     {
                         t.Loader.CreateNativePValue(t),
                         t.Loader.CreateNativePValue(unresolved)
                     });
         if (presult.Type is ObjectPType)
             return (AstExpr) presult.Value;
         else
             return null;
     }
     else
     {
         throw new InvalidOperationException(
             "Invalid custom resolver. No implementation provided.");
     }
 }
コード例 #2
0
ファイル: AstUnresolved.cs プロジェクト: SealedSun/prx
 public override AstGetSet GetCopy()
 {
     var copy = new AstUnresolved(File, Line, Column, _id);
     CopyBaseMembers(copy);
     return copy;
 }
コード例 #3
0
ファイル: Compiler.Parser.cs プロジェクト: SealedSun/prx
        public void GetCopyOfAstUnknown()
        {
            var unr = new AstUnresolved("file", 1, 2, "the_id");
            unr.Arguments.Add(new AstNull("file2",2,3));
            unr.Arguments.RightAppend(new AstNull("file3",3,4));
            unr.Arguments.ReleaseRightAppend();
            unr.Call = PCall.Set;

            var copy = unr.GetCopy();
            Assert.AreEqual(2, unr.Arguments.Count);
            Assert.IsInstanceOf(typeof(AstNull), copy.Arguments[0]);
            Assert.AreEqual("file3",copy.Arguments[1].File);
            Assert.AreEqual(PCall.Set,unr.Call);
            Assert.AreNotSame(unr,copy);
        }