Ejemplo n.º 1
0
        public override TypeNode VisitTypeNode(TypeNode typeNode)
        {
            if (typeNode == null)
            {
                return(null);
            }

            TypeNode savedCurrentType = this.CurrentType;

            if (savedCurrentType != null && savedCurrentType.TemplateArguments != null && savedCurrentType.TemplateArguments.Count > 0 &&
                typeNode.Template != null && (typeNode.Template.TemplateParameters == null || typeNode.Template.TemplateParameters.Count == 0))
            {
                typeNode.TemplateArguments = new TypeNodeList();
            }

            this.CurrentType            = typeNode;
            typeNode.Attributes         = this.VisitAttributeList(typeNode.Attributes);
            typeNode.SecurityAttributes = this.VisitSecurityAttributeList(typeNode.SecurityAttributes);
            Class c = typeNode as Class;

            if (c != null)
            {
                c.BaseClass = (Class)this.VisitTypeReference(c.BaseClass);
            }

            typeNode.Interfaces = this.VisitInterfaceReferenceList(typeNode.Interfaces);

            if (typeNode.ProvideTypeMembers != null && typeNode.ProvideNestedTypes != null && typeNode.ProviderHandle != null)
            {
                typeNode.members            = null;
                typeNode.ProviderHandle     = new SpecializerHandle(typeNode.ProvideNestedTypes, typeNode.ProvideTypeMembers, typeNode.ProviderHandle);
                typeNode.ProvideNestedTypes = new TypeNode.NestedTypeProvider(this.ProvideNestedTypes);
                typeNode.ProvideTypeMembers = new TypeNode.TypeMemberProvider(this.ProvideTypeMembers);

                DelegateNode delegateNode = typeNode as DelegateNode;

                if (delegateNode != null)
                {
                    if (!delegateNode.IsNormalized)
                    { //In the Normalized case Parameters are retrieved from the Invoke method, which means evaluating Members
                        delegateNode.Parameters = this.VisitParameterList(delegateNode.Parameters);
                        delegateNode.ReturnType = this.VisitTypeReference(delegateNode.ReturnType);
                    }
                }
            }
            else
            {
                typeNode.Members = this.VisitMemberList(typeNode.Members);
                DelegateNode delegateNode = typeNode as DelegateNode;

                if (delegateNode != null)
                {
                    delegateNode.Parameters = this.VisitParameterList(delegateNode.Parameters);
                    delegateNode.ReturnType = this.VisitTypeReference(delegateNode.ReturnType);
                }
            }

            this.CurrentType = savedCurrentType;
            return(typeNode);
        }
        /// <summary>
        /// Checks types for problems
        /// </summary>
        /// <param name="type"></param>
        /// <returns></returns>
        public override ProblemCollection Check(TypeNode type)
        {
#if DEBUG
            lock (_debugLock)
            {
#endif
            UniqueProblemCollection problems = new UniqueProblemCollection();

            string currentTypeNamespace = type.FullName;
            string baseNamespace        = GetNamespaceFromTypeName(currentTypeNamespace, BaseNamespaceMoniker);

            if (!string.IsNullOrEmpty(baseNamespace))
            {
                string typeName;

                //Determine the name of the type
                switch (type.NodeType)
                {
                case NodeType.DelegateNode:
                    typeName = "Delegate";
                    break;

                case NodeType.Interface:
                    typeName = "Interface";
                    break;

                default:
                    typeName = "Class";
                    break;
                }

                if (type.BaseType != null)
                {
                    CallTestObjectValue(problems, null, baseNamespace, type.BaseType, typeName + " in namespace {0} may not be based on a class from namespace {1}");
                }

                //Check implemented interfaces
                foreach (InterfaceNode interfaceType in type.Interfaces)
                {
                    CallTestObjectValue(problems, null, baseNamespace, interfaceType.FullName, typeName + " in namespace {0} may not implement an interface from namespace {1}");
                }

                if (type is DelegateNode)
                {
                    DelegateNode delegateNode = type as DelegateNode;

                    CallTestObjectValue(problems, null, baseNamespace, delegateNode.ReturnType, "Delegate in namespace {0} may not have a return type from namespace {1}");

                    foreach (Parameter parameter in delegateNode.Parameters)
                    {
                        TestObjectValue(problems, null, baseNamespace, parameter.Type, "Delegate parameter in namespace {0} may not reference namespace {1}");
                    }
                }
            }
            return(problems.Problems);

#if DEBUG
        }
#endif
        }
Ejemplo n.º 3
0
 public virtual string GetDelegateSignature(DelegateNode del)
 {
     if (del == null)
     {
         return("");
     }
     return(this.GetTypeName(del.ReturnType) + " " + this.GetSignatureString(del.FullName, del.Parameters, "(", ")", ", "));
 }
Ejemplo n.º 4
0
        protected void ProcessDelegateAddr(SimplePointsToGraph ptg, uint offset, IVariable dst, IMethodReference methodRef, IVariable instance)
        {
            var ptgID        = new PTGID(new MethodContex(this.method), (int)offset);
            var delegateNode = new DelegateNode(ptgID, methodRef, instance);

            ptg.Add(delegateNode);
            ptg.RemoveRootEdges(dst);
            ptg.PointsTo(dst, delegateNode);
        }
Ejemplo n.º 5
0
        public AstNode VisitDelegate(DelegateNode n)
        {
            if (!n.Attributes.IsNullOrEmpty())
            {
                foreach (var a in n.Attributes)
                {
                    Visit(a);
                }
            }

            Visit(n.AccessModifier);
            Append(" delegate ");
            Visit(n.ReturnType);
            Append(" ");
            Visit(n.Name);
            if (!n.GenericTypeParameters.IsNullOrEmpty())
            {
                Append("<");
                Visit(n.GenericTypeParameters[0]);
                for (var i = 1; i < n.GenericTypeParameters.Count; i++)
                {
                    Append(", ");
                    Visit(n.GenericTypeParameters[i]);
                }

                Append(">");
            }
            Append("(");
            if (!n.Parameters.IsNullOrEmpty())
            {
                Visit(n.Parameters[0]);
                for (var i = 1; i < n.Parameters.Count; i++)
                {
                    Append(", ");
                    Visit(n.Parameters[i]);
                }
            }

            Append(")");
            if (!n.GenericTypeParameters.IsNullOrEmpty() && !n.TypeConstraints.IsNullOrEmpty())
            {
                IncreaseIndent();
                AppendLineAndIndent();
                Visit(n.TypeConstraints[0]);
                foreach (var tc in n.TypeConstraints.Skip(1))
                {
                    AppendLineAndIndent();
                    Visit(tc);
                }

                DecreaseIndent();
            }

            Append(";");
            return(n);
        }
Ejemplo n.º 6
0
        public static bool IsAssumedPureDelegate(DelegateNode n)
        {
            if (WorstCase)
            {
                return(false);
            }
            bool res = false;

            res = n.GetAttribute(SystemTypes.PureAttribute) != null;
            return(res);
        }
Ejemplo n.º 7
0
 public virtual AstNode VisitDelegate(DelegateNode n)
 {
     Visit(n.Attributes);
     Visit(n.AccessModifier);
     Visit(n.ReturnType);
     Visit(n.Name);
     Visit(n.Parameters);
     Visit(n.GenericTypeParameters);
     Visit(n.TypeConstraints);
     return(n);
 }
 private ISymbolTable GetDelegatesEnvironment(DelegateNode sourceDelegateType)
 {
     ISymbolTable environment = new SymbolTable (_blockParserContext.BlacklistManager);
       foreach (Parameter parameter in sourceDelegateType.Parameters)
       {
     if (parameter.Attributes != null)
     {
       environment.MakeSafe (parameter.Name.Name, FragmentUtility.GetFragmentType (parameter.Attributes));
     }
       }
       return environment;
 }
        private ISymbolTable GetDelegatesEnvironment(DelegateNode sourceDelegateType)
        {
            ISymbolTable environment = new SymbolTable(_blockParserContext.BlacklistManager);

            foreach (Parameter parameter in sourceDelegateType.Parameters)
            {
                if (parameter.Attributes != null)
                {
                    environment.MakeSafe(parameter.Name.Name, FragmentUtility.GetFragmentType(parameter.Attributes));
                }
            }
            return(environment);
        }
Ejemplo n.º 10
0
        public override DelegateNode VisitDelegateNode(DelegateNode delegateNode)
        {
            if (delegateNode == null || delegateNode.SourceContext.SourceText == null)
            {
                return(null);
            }
            this.writer.WriteStartElement("Delegate");
            this.writer.WriteAttributeString("name", delegateNode.Name.Name);
            this.WriteSourceContext(delegateNode);

            this.writer.WriteEndElement(); // Delegate
            return(delegateNode);
        }
        private Fragment GetDelegateTypesReturnFragment(DelegateNode sourceDelegateType)
        {
            var returnFragment = Fragment.CreateEmpty();

            foreach (Member member in sourceDelegateType.Members)
            {
                if (member.Name.Name == "Invoke")
                {
                    Method invoke = (Method)member;
                    returnFragment = FragmentUtility.ReturnFragmentType(invoke);
                }
            }
            return(returnFragment);
        }
Ejemplo n.º 12
0
        private void ProvideTypeMembers(TypeNode /*!*/ typeNode, object /*!*/ handle)
        {
            SpecializerHandle sHandler         = (SpecializerHandle)handle;
            TypeNode          savedCurrentType = this.CurrentType;

            this.CurrentType = typeNode;
            sHandler.TypeMemberProvider(typeNode, sHandler.Handle);
            typeNode.Members = this.VisitMemberList(typeNode.Members);
            DelegateNode delegateNode = typeNode as DelegateNode;

            if (delegateNode != null && delegateNode.IsNormalized)
            {
                delegateNode.Parameters = this.VisitParameterList(delegateNode.Parameters);
                delegateNode.ReturnType = this.VisitTypeReference(delegateNode.ReturnType);
            }
            this.CurrentType = savedCurrentType;
        }
        protected override void HandleStatement(HandleContext context)
        {
            AssignmentStatement assignmentStatement = (AssignmentStatement)context.Statement;

            if (!CoversAssignment(assignmentStatement))
            {
                return;
            }

            Method       assignedMethod     = GetAssignedDelegateMethod(assignmentStatement);
            DelegateNode sourceDelegateType = (DelegateNode)assignmentStatement.Source.Type;
            Fragment     returnFragment     = GetDelegateTypesReturnFragment(sourceDelegateType);
            ISymbolTable environment        = GetDelegatesEnvironment(sourceDelegateType);

            IMethodGraphAnalyzer       methodParser                = new MethodGraphAnalyzer(_blockParserContext.ProblemPipe);
            IMethodGraphBuilder        methodGraphBuilder          = new MethodGraphBuilder(assignedMethod, _blockParserContext.BlacklistManager, _blockParserContext.ProblemPipe, returnFragment);
            IInitialSymbolTableBuilder parameterSymbolTableBuilder = new EmbeddedInitialSymbolTableBuilder(assignedMethod, _blockParserContext.BlacklistManager, environment);

            methodParser.Parse(methodGraphBuilder, parameterSymbolTableBuilder);
        }
Ejemplo n.º 14
0
        private static void Unlink(Job job, Agent implant)
        {
            LinkMessage linkMsg   = JsonConvert.DeserializeObject <LinkMessage>(job.Task.parameters);
            string      agentUUID = linkMsg.connection_info.agent_uuid;
            string      message;

            if (agentUUID == null || agentUUID == "")
            {
                job.SetError($"Could not unlink from {linkMsg.connection_info.host} as no agent UUID could be parsed.");
            }
            else
            {
                // In the future, we need to change DelegateNodes to a list of delegate nodes,
                // which is then filtered down for unlinking and passing messages. Current model
                // will not support multiple P2P agents from one host to another.
                if (!implant.DelegateNodes.ContainsKey(agentUUID))
                {
                    job.SetError($"No such connection to {linkMsg.connection_info.host} (Agent {linkMsg.connection_info.agent_uuid} using {linkMsg.connection_info.c2_profile.name.ToUpper()}) exists.");
                    return;
                }
                DelegateNode dg = implant.DelegateNodes[agentUUID];
                switch (linkMsg.connection_info.c2_profile.name.ToLower())
                {
                case "smbserver":
                    SMBClientProfile hLinkedAgentProfile = (SMBClientProfile)dg.NodeRelay.MessageProducer;
                    var unlinkMsg = new UnlinkMessage()
                    {
                        action = "unlink"
                    };
                    message = JsonConvert.SerializeObject(unlinkMsg);
                    hLinkedAgentProfile.Send("", message);
                    implant.RemoveDelegateNode(agentUUID);
                    job.SetComplete($"Successfully unlinked {linkMsg.connection_info.host} ({linkMsg.connection_info.c2_profile.name.ToUpper()})");
                    break;

                default:
                    job.SetError($"Unknown peer-to-peer profile \"{linkMsg.connection_info.c2_profile.name}\"");
                    break;
                }
            }
        }
Ejemplo n.º 15
0
 private DelegateNode TranslateToDelegate(CodeTypeDelegate typeDec, Identifier nameSpace, TypeNode declaringType){
   Debug.Assert(typeDec != null);
   DelegateNode d = new DelegateNode();
   d.Attributes = this.Translate(typeDec.CustomAttributes, null);
   d.DeclaringModule = this.targetModule;
   d.DeclaringType = declaringType;
   d.Name = Identifier.For(typeDec.Name);
   d.Namespace = nameSpace;
   d.Parameters = this.Translate(typeDec.Parameters);
   d.ReturnType = this.TranslateToTypeNode(typeDec.ReturnType);
   this.SetTypeFlags(d, typeDec.TypeAttributes);
   d.Flags |= TypeFlags.Sealed;
   if (declaringType != null) declaringType.Members.Add(d);
   return d;
 }
Ejemplo n.º 16
0
 public virtual DelegateNode VisitDelegateNode(DelegateNode delegateNode){
   if (delegateNode == null) return null;
   delegateNode = (DelegateNode)this.VisitTypeNode(delegateNode);
   if (delegateNode == null) return null;
   delegateNode.Parameters = this.VisitParameterList(delegateNode.Parameters);
   delegateNode.ReturnType = this.VisitTypeReference(delegateNode.ReturnType);
   return delegateNode;
 }
Ejemplo n.º 17
0
        public static void report(Node node, int shift)
        {
            if (node == null)
            {
                indent(shift);
                Console.WriteLine("NULL ENTITY");
                return;
            }

            switch (node.NodeType)
            {
            case NodeType.AliasDefinition:
            {
                AliasDefinition alias = node as AliasDefinition;
                indent(shift);
                Console.WriteLine("using {0} = {1};", alias.Alias.Name, alias.AliasedUri.Name);
                break;
            }

            case NodeType.CompilationUnit:
            case NodeType.CompilationUnitSnippet:
            {
                CompilationUnit cu = node as CompilationUnit;

                for (int i = 0, n = cu.Nodes.Length; i < n; i++)
                {
                    report(cu.Nodes[i], 0);
                }
                break;
            }

            case NodeType.Namespace:
            {
                Namespace ns = node as Namespace;

                if (ns.UsedNamespaces != null && ns.UsedNamespaces.Length != 0)
                {
                    indent(shift);
                    Console.WriteLine("using ");
                    for (int i = 0, n = ns.UsedNamespaces.Length; i < n; i++)
                    {
                        Console.Write("{0}", ns.UsedNamespaces[i].Namespace.Name);
                        if (i < n - 1)
                        {
                            Console.Write(", ");
                        }
                    }
                    Console.WriteLine();
                }

                indent(shift);
                Console.WriteLine("namespace {0}", ns.FullNameId.Name);

                indent(shift);
                Console.WriteLine("{");

                if (ns.AliasDefinitions != null && ns.AliasDefinitions.Length != 0)
                {
                    for (int i = 0, n = ns.AliasDefinitions.Length; i < n; i++)
                    {
                        report(ns.AliasDefinitions[i], shift + ind);
                    }
                }

                if (ns.NestedNamespaces != null && ns.NestedNamespaces.Length != 0)
                {
                    for (int i = 0, n = ns.NestedNamespaces.Length; i < n; i++)
                    {
                        report(ns.NestedNamespaces[i], shift + ind);
                    }
                }

                if (ns.Types != null && ns.Types.Length != 0)
                {
                    for (int i = 0, n = ns.Types.Length; i < n; i++)
                    {
                        report(ns.Types[i], shift + ind);
                    }
                }

                indent(shift);
                Console.WriteLine("}");

                break;
            }

            case NodeType.Class:
            {
                Class cls = node as Class;

                if (cls == SystemTypes.Object)
                {
                    Console.Write(cls.Name);
                    break;
                }

                indent(shift);

                if (cls.IsAbstract)
                {
                    Console.Write("abstract ");
                }
                if (cls.IsPrivate)
                {
                    Console.Write("private ");
                }
                else if (cls.IsPublic)
                {
                    Console.Write("public ");
                }
                else
                {
                    Console.Write("internal ");                             // ??????????????
                }
                if (cls.IsSealed)
                {
                    Console.Write("sealed ");
                }

                Console.Write("class ");
                if (cls.DeclaringType != null)
                {
                    Console.Write("{0}::", cls.DeclaringType.Name.Name);
                }
                Console.Write("{0}", cls.Name != null?cls.Name.Name:"<NONAME>");

                if (cls.BaseClass != null)
                {
                    Console.Write(" : {0}", cls.BaseClass.Name.Name);
                }

                if (cls.Interfaces != null && cls.Interfaces.Length != 0)
                {
                    if (cls.BaseClass != null)
                    {
                        Console.Write(",");
                    }
                    else
                    {
                        Console.Write(" :");
                    }

                    for (int i = 0, n = cls.Interfaces.Length; i < n; i++)
                    {
                        Interface interfac = cls.Interfaces[i];
                        if (interfac != null)
                        {
                            Console.Write(" {0}", interfac.Name.Name);
                        }
                        if (i < n - 1)
                        {
                            Console.Write(",");
                        }
                    }
                }
                Console.WriteLine();

                indent(shift);
                Console.WriteLine("{");

                if (cls.Members != null && cls.Members.Length != 0)
                {
                    for (int i = 0, n = cls.Members.Length; i < n; i++)
                    {
                        Member member = cls.Members[i];

                        if (member == null)
                        {
                            indent(shift + ind);
                            Console.WriteLine("<UNRESOLVED MEMBER>");
                            continue;
                        }
                        report(member, shift + ind);
                    }
                }
                indent(shift);
                Console.WriteLine("}");

                break;
            }

            case NodeType.Struct:
            {
                Struct struc = node as Struct;

                indent(shift);

                if (struc.IsAbstract)
                {
                    Console.Write("abstract ");
                }
                if (struc.IsPrivate)
                {
                    Console.Write("private ");
                }
                else if (struc.IsPublic)
                {
                    Console.Write("public ");
                }
                else
                {
                    Console.Write("internal ");                               // ??????????????
                }
                if (struc.IsSealed)
                {
                    Console.Write("sealed ");
                }

                Console.Write("struct ");
                if (struc.DeclaringType != null)
                {
                    Console.Write("{0}::", struc.DeclaringType.Name.Name);
                }
                Console.Write("{0}", struc.Name != null?struc.Name.Name:"<NONAME>");

                if (struc.Interfaces != null && struc.Interfaces.Length != 0)
                {
                    Console.Write(" :");
                    for (int i = 0, n = struc.Interfaces.Length; i < n; i++)
                    {
                        Interface interfac = struc.Interfaces[i];
                        if (interfac != null)
                        {
                            Console.Write(" {0}", interfac.Name.Name);
                        }
                        if (i < n - 1)
                        {
                            Console.Write(",");
                        }
                    }
                }
                Console.WriteLine();

                indent(shift);
                Console.WriteLine("{");

                if (struc.Members != null && struc.Members.Length != 0)
                {
                    for (int i = 0, n = struc.Members.Length; i < n; i++)
                    {
                        Member member = struc.Members[i];

                        if (member == null)
                        {
                            indent(shift + ind);
                            Console.WriteLine("<UNRESOLVED MEMBER>");
                            continue;
                        }
                        report(member, shift + ind);
                    }
                }
                indent(shift);
                Console.WriteLine("}");
                break;
            }

            case NodeType.EnumNode:
            {
                EnumNode enume = node as EnumNode;

                indent(shift);
                if (enume.Name != null && enume.Name.Name != null)
                {
                    Console.Write("enum {0} = ", enume.Name.Name);
                }
                else
                {
                    Console.Write("enum <NONAME> = ");
                }
                Console.Write("{");

                for (int i = 0, n = enume.Members.Length; i < n; i++)
                {
                    Field enumerator = (Field)enume.Members[i];
                    Console.Write("{0}", enumerator.Name.Name);
                    if (enumerator.DefaultValue != null)
                    {
                        Console.Write(" = {0}", enumerator.DefaultValue.ToString());
                    }
                    if (i < n - 1)
                    {
                        Console.Write(", ");
                    }
                }
                Console.WriteLine("};");

                break;
            }

            case NodeType.Interface:
            {
                Interface interfac = node as Interface;

                indent(shift);

                if (interfac.IsAbstract)
                {
                    Console.Write("abstract ");
                }
                if (interfac.IsPrivate)
                {
                    Console.Write("private ");
                }
                else if (interfac.IsPublic)
                {
                    Console.Write("public ");
                }
                else
                {
                    Console.Write("internal ");                                // ???????????
                }
                Console.WriteLine("interface {0}", interfac.Name.Name);
                indent(shift);
                Console.WriteLine("{");

                if (interfac.Members != null && interfac.Members.Length != 0)
                {
                    for (int i = 0, n = interfac.Members.Length; i < n; i++)
                    {
                        Member member = interfac.Members[i];

                        if (member == null)
                        {
                            indent(shift + ind);
                            Console.WriteLine("<UNRESOLVED MEMBER>");
                            continue;
                        }
                        report(member, shift + ind);
                    }
                }
                indent(shift);
                Console.WriteLine("}");

                break;
            }

            case NodeType.Method:
            case NodeType.InstanceInitializer:
            {
                Method method = node as Method;

                indent(shift);

                if (method.IsAbstract)
                {
                    Console.Write("abstract ");
                }
                if (method.IsPublic)
                {
                    Console.Write("public ");
                }
                if (method.IsStatic)
                {
                    Console.Write("static ");
                }
                if (method.IsVirtual)
                {
                    Console.Write("virtual ");
                }
                if (method.IsPrivate)
                {
                    Console.Write("private ");
                }
                if (method.OverriddenMethod != null)
                {
                    Console.Write("override ");
                }

                if (method.ReturnType != null && method.ReturnType.Name != null)
                {
                    Console.Write("{0} ", method.ReturnType.Name.Name);
                }
                if (method.Name != null)
                {
                    if (method.ImplementedInterfaceMethods != null && method.ImplementedInterfaceMethods.Length != 0)
                    {
                        Method interf = method.ImplementedInterfaceMethods[0];
                        if (interf != null)
                        {
                            string name = interf.DeclaringType.Name.Name;
                            Console.Write("{0}.", name);
                        }
                    }
                    Console.Write("{0}", method.Name.Name);
                }
                Console.Write(" (");

                if (method.Parameters != null && method.Parameters.Length != 0)
                {
                    for (int i = 0, n = method.Parameters.Length; i < n; i++)
                    {
                        Parameter par = method.Parameters[i];
                        if (par == null)
                        {
                            continue;
                        }
                        if ((par.Flags & ParameterFlags.In) != 0)
                        {
                            Console.Write("in ");
                        }
                        if ((par.Flags & ParameterFlags.Out) != 0)
                        {
                            Console.Write("out ");
                        }

                        if (par.Type != null && par.Type.Name != null)
                        {
                            Console.Write("{0}", par.Type.Name.Name);
                        }
                        else
                        {
                            report(par.Type, 0);
                        }
                        Console.Write(" {0}", par.Name.Name);
                        if (i < n - 1)
                        {
                            Console.Write(", ");
                        }
                    }
                }
                Console.Write(" )");

                // method body
                if (method.Body != null)
                {
                    Console.WriteLine();
                    report(method.Body, shift);
                }
                else
                {
                    Console.WriteLine(";");
                }
                break;
            }

            case NodeType.DelegateNode:
            {
                DelegateNode dn = node as DelegateNode;

                indent(shift);
                Console.Write("delegate ");

                if (dn.ReturnType != null && dn.ReturnType.Name != null)
                {
                    Console.Write("{0} ", dn.ReturnType.Name.Name);
                }
                if (dn.Name != null)
                {
                    Console.Write("{0}", dn.Name.Name);
                }
                Console.Write(" (");

                if (dn.Parameters != null && dn.Parameters.Length != 0)
                {
                    for (int i = 0, n = dn.Parameters.Length; i < n; i++)
                    {
                        Parameter par = dn.Parameters[i];
                        if (par == null)
                        {
                            continue;
                        }
                        if ((par.Flags & ParameterFlags.In) != 0)
                        {
                            Console.Write("in ");
                        }
                        if ((par.Flags & ParameterFlags.Out) != 0)
                        {
                            Console.Write("out ");
                        }

                        if (par.Type != null && par.Type.Name != null)
                        {
                            Console.Write("{0}", par.Type.Name.Name);
                        }
                        else
                        {
                            report(par.Type, 0);
                        }
                        Console.Write(" {0}", par.Name.Name);
                        if (i < n - 1)
                        {
                            Console.Write(", ");
                        }
                    }
                }
                Console.WriteLine(" );");
                break;
            }

            case NodeType.StaticInitializer:
            {
                StaticInitializer si = node as StaticInitializer;

                indent(shift);

                Console.WriteLine("static {0} ( )", si.Name.Name);

                // body
                if (si.Body != null)
                {
                    report(si.Body, shift);
                }
                else
                {
                    Console.WriteLine("NO BODY");
                }
                break;
            }

            case NodeType.FieldInitializerBlock:
            {
                FieldInitializerBlock initializers = node as FieldInitializerBlock;

                indent(shift);
                if (initializers.IsStatic)
                {
                    Console.Write("static ");
                }
                Console.WriteLine("init {");
                for (int i = 0, n = initializers.Statements.Length; i < n; i++)
                {
                    report(initializers.Statements[i], shift + ind);
                }
                indent(shift);
                Console.WriteLine("}");
                break;
            }

            case NodeType.Base:
            {
                Console.Write("base");
                break;
            }

            case NodeType.Field:
            {
                Field field = node as Field;

                indent(shift);

                if (field.IsPrivate)
                {
                    Console.Write("private ");
                }
                else if (field.IsPublic)
                {
                    Console.Write("public ");
                }

                if (field.IsStatic)
                {
                    Console.Write("static ");
                }
                if (field.IsInitOnly)
                {
                    Console.Write("readonly ");
                }

                if (field.Type != null)
                {
                    if (field.Type.Name != null)
                    {
                        Console.Write("{0}", field.Type.Name.Name);
                    }
                    else
                    {
                        report(field.Type, 0);
                    }
                }
                Console.Write(" {0}", field.Name.Name);

                if (field.Initializer != null)
                {
                    Console.Write(" = ");
                    report(field.Initializer, 0);
                }
                Console.WriteLine(";");

                break;
            }

            case NodeType.VariableDeclaration:
            {
                VariableDeclaration variable = node as VariableDeclaration;

                indent(shift);
                if (variable.Type != null && variable.Type.Name != null)
                {
                    Console.Write("{0}", variable.Type.Name.Name);
                }
                else
                {
                    report(variable.Type, 0);
                }

                Console.Write(" {0}", variable.Name.Name);

                if (variable.Initializer != null)
                {
                    Console.Write(" = ");
                    report(variable.Initializer, 0);
                }
                Console.WriteLine(";");

                break;
            }

            case NodeType.LocalDeclarationsStatement:
            {
                LocalDeclarationsStatement stmt = node as LocalDeclarationsStatement;

                indent(shift);

                TypeNode type = stmt.Type;
                if (type != null && type.Name != null)
                {
                    Console.Write("{0}", type.Name.Name);
                }
                else
                {
                    report(type, 0);
                }
                Console.Write(" ");

                LocalDeclarationList list = stmt.Declarations;
                for (int i = 0, n = list.Length; i < n; i++)
                {
                    LocalDeclaration local = list[i];
                    Console.Write("{0}", local.Name.Name);
                    if (local.InitialValue != null)
                    {
                        Console.Write(" = ");
                        report(local.InitialValue, 0);
                    }
                    if (i < n - 1)
                    {
                        Console.Write(", ");
                    }
                }
                Console.WriteLine(";");
                break;
            }

            case NodeType.Property:
            {
                Property property = node as Property;

                indent(shift);

                if (property.IsPrivate)
                {
                    Console.Write("private ");
                }
                else if (property.IsPublic)
                {
                    Console.Write("public ");
                }

                if (property.IsStatic)
                {
                    Console.Write("static ");
                }

                if (property != null)
                {
                    if (property.Type != null && property.Type.Name != null)
                    {
                        Console.Write("{0} ", property.Type.Name.Name);
                    }

                    if (property.ImplementedTypes != null)
                    {
                        TypeNode typ = property.ImplementedTypes[0];
                        Console.Write("{0}.", typ.Name.Name);
                    }
                    if (property.Name != null)
                    {
                        Console.WriteLine("{0}", property.Name.Name);
                    }
                }
                indent(shift);
                Console.WriteLine("{");

                if (property.Getter != null)
                {
                    report(property.Getter, shift + ind);
                }
                if (property.Setter != null)
                {
                    report(property.Setter, shift + ind);
                }

                indent(shift);
                Console.WriteLine("}");

                break;
            }

            case NodeType.Lock:
            {
                Lock _lock = node as Lock;

                indent(shift);
                Console.Write("lock(");
                report(_lock.Guard, shift);
                Console.WriteLine(")");
                report(_lock.Body, shift + ind);
                indent(shift);
                Console.WriteLine("}");

                break;
            }

            case NodeType.Block:
            {
                Block block = node as Block;
                if (block == null || block.Statements == null)
                {
                    break;
                }
                indent(shift);
                Console.WriteLine("{");

                for (int i = 0, n = block.Statements.Length; i < n; i++)
                {
                    report(block.Statements[i], shift + ind);
                    Console.WriteLine();
                }
                indent(shift);
                Console.WriteLine("}");

                break;
            }

            case NodeType.MemberBinding:
            {
                MemberBinding mb = node as MemberBinding;
                if (mb.TargetObject != null)
                {
                    report(mb.TargetObject, 0);
                }
                else if (mb.BoundMember != null && mb.BoundMember.DeclaringType != null)
                {
                    Console.Write(mb.BoundMember.DeclaringType.Name);
                }
                Console.Write(".");
                if (mb.BoundMember.Name != null)
                {
                    Console.Write(mb.BoundMember.Name.Name);
                }
                else
                {
                    report(mb.BoundMember, 0);
                }
                break;
            }

            case NodeType.AssignmentStatement:
            {
                AssignmentStatement assignment = node as AssignmentStatement;

                indent(shift);

                report(assignment.Target, 0);
                switch (assignment.Operator)
                {
                case NodeType.Nop: Console.Write(" = "); break;

                case NodeType.Add: Console.Write(" += "); break;

                case NodeType.Add_Ovf: Console.Write(" += "); break;

                case NodeType.Add_Ovf_Un: Console.Write(" += "); break;

                case NodeType.Sub: Console.Write(" -= "); break;

                case NodeType.Sub_Ovf: Console.Write(" -= "); break;

                case NodeType.Sub_Ovf_Un: Console.Write(" -= "); break;

                case NodeType.Mul: Console.Write(" *= "); break;

                case NodeType.Mul_Ovf: Console.Write(" *= "); break;

                case NodeType.Mul_Ovf_Un: Console.Write(" *= "); break;
                }
                report(assignment.Source, 0);
                Console.Write(";");
                break;
            }

            case NodeType.ExpressionStatement:
            {
                ExpressionStatement exprStatement = node as ExpressionStatement;

                indent(shift);

                report(exprStatement.Expression, 0);
                Console.Write(";");
                break;
            }

            case NodeType.Return:
            {
                Return return_stmt = node as Return;

                indent(shift);
                Console.Write("return");
                if (return_stmt.Expression != null)
                {
                    Console.Write(" ");
                    report(return_stmt.Expression, 0);
                }
                Console.Write(";");

                break;
            }

            case NodeType.Branch:
            {
                Branch branch = node as Branch;

                indent(shift);
                Console.WriteLine("break; (???)");

                break;
            }

            case NodeType.For:
            {
                For for_stmt = node as For;

                indent(shift);
                Console.Write("for ( ");
                for (int i = 0, n = for_stmt.Initializer.Length; i < n; i++)
                {
                    report(for_stmt.Initializer[i], 0);
                }
                report(for_stmt.Condition, 0);
                Console.Write("; ");
                for (int i = 0, n = for_stmt.Incrementer.Length; i < n; i++)
                {
                    report(for_stmt.Incrementer[i], 0);
                }
                Console.WriteLine(")");

                indent(shift);
                Console.WriteLine("{");
                report(for_stmt.Body, shift + ind);
                indent(shift);
                Console.WriteLine("}");

                break;
            }

            case NodeType.While:
            {
                While while_loop = node as While;

                indent(shift);
                Console.Write("while ( ");
                report(while_loop.Condition, 0);
                Console.WriteLine(" )");

                report(while_loop.Body, shift);

                break;
            }

            case NodeType.DoWhile:
            {
                DoWhile repeat = node as DoWhile;

                indent(shift);
                Console.WriteLine("do");
                report(repeat.Body, shift);

                indent(shift);
                Console.Write("while (");
                report(repeat.Condition, 0);
                Console.WriteLine(" );");

                break;
            }

            case NodeType.If:
            {
                If if_stmt = node as If;

                indent(shift);
                Console.Write("if ( ");
                report(if_stmt.Condition, 0);
                Console.WriteLine(" )");

                report(if_stmt.TrueBlock, shift);

                if (if_stmt.FalseBlock == null ||
                    if_stmt.FalseBlock.Statements == null ||
                    if_stmt.FalseBlock.Statements.Length == 0)
                {
                    break;
                }

                indent(shift);
                Console.WriteLine("else");
                report(if_stmt.FalseBlock, shift);

                break;
            }

            case NodeType.Switch:
            {
                Switch swtch = node as Switch;

                indent(shift);
                Console.Write("switch ( ");
                report(swtch.Expression, 0);
                Console.WriteLine(" )");

                indent(shift);
                Console.WriteLine("{");

                for (int i = 0, n = swtch.Cases.Length; i < n; i++)
                {
                    indent(shift + ind);
                    if (swtch.Cases[i].Label != null)
                    {
                        Console.Write("case ");
                        report(swtch.Cases[i].Label, 0);
                        Console.WriteLine(":");
                    }
                    else
                    {
                        Console.WriteLine("default:");
                    }
                    report(swtch.Cases[i].Body, shift + ind);
                }
                indent(shift);
                Console.WriteLine("}");

                break;
            }

            case NodeType.Throw:
            {
                Throw thro = node as Throw;

                indent(shift);
                Console.Write("throw (");
                report(thro.Expression, 0);
                Console.Write(");");
                break;
            }

            case NodeType.Exit:
            {
                indent(shift);
                Console.WriteLine("exit;");
                break;
            }

            case NodeType.Continue:
            {
                indent(shift);
                Console.WriteLine("continue;");
                break;
            }

            case NodeType.Try:
            {
                Try trys = node as Try;

                indent(shift);
                Console.WriteLine("try {");
                report(trys.TryBlock, shift + ind);
                indent(shift);
                Console.WriteLine("}");
                if (trys.Catchers != null)
                {
                    for (int i = 0, n = trys.Catchers.Length; i < n; i++)
                    {
                        indent(shift);
                        if (trys.Catchers[i].Type != null)
                        {
                            Console.Write("catch ( {0} ", trys.Catchers[i].Type.FullName);
                        }
                        else
                        {
                            Console.Write("catch ( ");
                        }
                        if (trys.Catchers[i].Variable != null)
                        {
                            report(trys.Catchers[i].Variable, 0);
                        }
                        Console.WriteLine(" ) {");
                        report(trys.Catchers[i].Block, shift + ind);
                        indent(shift);
                        Console.WriteLine("}");
                    }
                }
                if (trys.Finally != null && trys.Finally.Block != null)
                {
                    indent(shift);
                    Console.WriteLine("finally");
                    report(trys.Finally.Block, shift);
                }
                break;
            }

            case NodeType.BlockExpression:
            {
                BlockExpression be = node as BlockExpression;

                Console.WriteLine("(");
                StatementList sl = be.Block.Statements;
                for (int i = 0, n = sl.Length; i < n; i++)
                {
                    report(sl[i], shift + ind);
                }
                indent(shift);
                Console.Write(")");
                break;
            }

            case NodeType.ArrayTypeExpression:
            {
                ArrayTypeExpression array = node as ArrayTypeExpression;

                indent(shift);

                if (array.ElementType != null &&
                    array.ElementType.Name != null &&
                    array.ElementType.Name.Name != null)
                {
                    Console.Write(array.ElementType.Name.Name);
                }
                else
                {
                    report(array.ElementType, 0);
                }

                Console.Write("[");
                for (int i = 0, n = array.Rank; i < n; i++)
                {
                    if (array.Sizes != null)
                    {
                        Console.Write(array.Sizes[i]);
                    }
                    if (i < n - 1)
                    {
                        Console.Write(",");
                    }
                }
                Console.Write("]");

                break;
            }

            case NodeType.Construct:
            {
                Construct construct = node as Construct;

                indent(shift);
                Console.Write("new ");
                report(construct.Constructor, 0);
                Console.Write("(");
                if (construct.Operands != null)
                {
                    for (int i = 0, n = construct.Operands.Length; i < n; i++)
                    {
                        report(construct.Operands[i], 0);
                        if (i < n - 1)
                        {
                            Console.Write(",");
                        }
                    }
                }
                Console.Write(")");
                break;
            }

            case NodeType.ConstructArray:
            {
                ConstructArray initializer = node as ConstructArray;

                Console.Write("new ");

                if (initializer.ElementType != null &&
                    initializer.ElementType.Name != null &&
                    initializer.ElementType.Name.Name != null)
                {
                    Console.Write(initializer.ElementType.Name.Name);
                }
                else
                {
                    report(initializer.ElementType, 0);
                }

                Console.Write("[");
                for (int i = 0, n = initializer.Operands.Length; i < n; i++)
                {
                    report(initializer.Operands[i], 0);
                    if (i < n - 1)
                    {
                        Console.Write(",");
                    }
                }
                Console.Write("]");

                break;
            }

            case NodeType.ConstructDelegate:
            {
                ConstructDelegate cd = node as ConstructDelegate;

                // Console.Write("new {0}({1})",cd.DelegateType.Name.Name,cd.MethodName.Name);
                Console.Write("new {0}(", cd.DelegateType.Name.Name);
                report(cd.TargetObject, 0);
                Console.Write(".{0})", cd.MethodName.Name);
                // cd.Type;
                break;
            }

            default:
            {
                if (node is ZonnonCompilation)
                {
                    ZonnonCompilation zc = node as ZonnonCompilation;
                    report(zc.CompilationUnits[0], shift);
                }
                // Expression?

                else if (node is MethodCall)
                {
                    MethodCall call = node as MethodCall;

                    report(call.Callee, 0);
                    Console.Write("(");

                    if (call.Operands != null && call.Operands.Length != 0)
                    {
                        for (int i = 0, n = call.Operands.Length; i < n; i++)
                        {
                            report(call.Operands[i], 0);
                            if (i < n - 1)
                            {
                                Console.Write(",");
                            }
                        }
                    }

                    Console.Write(")");
                }
                else if (node is Variable)
                {
                    Variable variable = node as Variable;
                    Console.Write("{0}", variable.Name.Name);
                }
                else if (node is Identifier)
                {
                    Identifier identifier = node as Identifier;
                    Console.Write("{0}", identifier.Name);
                }
                else if (node is QualifiedIdentifier)
                {
                    QualifiedIdentifier qualid = node as QualifiedIdentifier;
                    report(qualid.Qualifier, 0);
                    Console.Write(".{0}", qualid.Identifier == null?"<UNRESOLVED>":qualid.Identifier.Name);
                }
                else if (node is Literal)
                {
                    Literal literal = node as Literal;
                    if (literal.Value == null)
                    {
                        Console.Write("null");
                    }
                    else
                    {
                        if (literal.Value is string)
                        {
                            Console.Write("\"");
                        }
                        else if (literal.Value is char)
                        {
                            Console.Write("'");
                        }
                        Console.Write("{0}", literal.Value.ToString());
                        if (literal.Value is string)
                        {
                            Console.Write("\"");
                        }
                        else if (literal.Value is char)
                        {
                            Console.Write("'");
                        }
                    }
                }
                else if (node is Indexer)
                {
                    Indexer indexer = node as Indexer;
                    report(indexer.Object, 0);
                    Console.Write("[");
                    for (int i = 0, n = indexer.Operands.Length; i < n; i++)
                    {
                        report(indexer.Operands[i], 0);
                        if (i < n - 1)
                        {
                            Console.Write(",");
                        }
                    }
                    Console.Write("]");
                }
                else if (node is UnaryExpression)
                {
                    UnaryExpression unexpr = node as UnaryExpression;

                    bool add_pars = unexpr.Operand is BinaryExpression ||
                                    unexpr.Operand is UnaryExpression;

                    switch (unexpr.NodeType)
                    {
                    case NodeType.Add: Console.Write("+");  break;

                    case NodeType.Sub: Console.Write("-");  break;

                    case NodeType.Neg: Console.Write("-");  break;

                    case NodeType.Not: Console.Write("~");  break;

                    case NodeType.UnaryPlus: Console.Write("+"); break;

                    case NodeType.LogicalNot: Console.Write("!"); break;

                    case NodeType.Conv_U2: Console.Write("(UInt16)"); break;

                    case NodeType.RefAddress: Console.Write("ref "); break;

                    case NodeType.Ckfinite: Console.Write("(Ckfinite)"); break;

                    default:           Console.Write("???");  break;
                    }

                    if (add_pars)
                    {
                        Console.Write("(");
                    }
                    report(unexpr.Operand, 0);
                    if (add_pars)
                    {
                        Console.Write(")");
                    }
                }
                else if (node is BinaryExpression)
                {
                    BinaryExpression binexpr = node as BinaryExpression;

                    bool add_pars = binexpr.Operand1 is BinaryExpression ||
                                    binexpr.Operand1 is UnaryExpression;

                    if (binexpr.NodeType == NodeType.Castclass)
                    {
                        Console.Write("(");
                        report(binexpr.Operand2, 0);
                        Console.Write(")");

                        if (add_pars)
                        {
                            Console.Write("(");
                        }
                        report(binexpr.Operand1, 0);
                        if (add_pars)
                        {
                            Console.Write(")");
                        }
                        break;
                    }

                    if (add_pars)
                    {
                        Console.Write("(");
                    }
                    report(binexpr.Operand1, 0);
                    if (add_pars)
                    {
                        Console.Write(")");
                    }

                    switch (binexpr.NodeType)
                    {
                    case NodeType.Add: Console.Write(" + "); break;

                    case NodeType.Add_Ovf: Console.Write(" + "); break;

                    case NodeType.Add_Ovf_Un: Console.Write(" + "); break;

                    case NodeType.Sub: Console.Write(" - "); break;

                    case NodeType.Sub_Ovf: Console.Write(" - "); break;

                    case NodeType.Sub_Ovf_Un: Console.Write(" - "); break;

                    case NodeType.Mul: Console.Write(" * "); break;

                    case NodeType.Mul_Ovf: Console.Write(" * "); break;

                    case NodeType.Mul_Ovf_Un: Console.Write(" * "); break;

                    case NodeType.Div: Console.Write(" / "); break;

                    // case NodeType.Div : Console.Write(" DIV "); break;  // "DIV" ?????
                    case NodeType.Rem: Console.Write(" % "); break;          // "MOD" ?????

                    case NodeType.Or: Console.Write(" | "); break;

                    case NodeType.And: Console.Write(" & "); break;

                    case NodeType.Eq: Console.Write(" == "); break;

                    case NodeType.Ne: Console.Write(" != "); break;

                    case NodeType.Lt: Console.Write(" < "); break;

                    case NodeType.Le: Console.Write(" <= "); break;

                    case NodeType.Gt: Console.Write(" > "); break;

                    case NodeType.Ge: Console.Write(" >= "); break;

                    case NodeType.LogicalOr: Console.Write(" || "); break;

                    case NodeType.LogicalAnd: Console.Write(" && "); break;

                    case NodeType.Is: Console.Write(" is "); break;

                    case NodeType.Comma: Console.Write(","); break;

                    // case OPERATORS.In           : expression.NodeType = NodeType  // "IN" break;
                    // case OPERATORS.Implements   : expression.NodeType = NodeType  // "IMPLEMENTS" break;
                    default: Console.Write(" !! "); break;
                    }

                    add_pars = binexpr.Operand2 is BinaryExpression ||
                               binexpr.Operand2 is UnaryExpression;

                    if (add_pars)
                    {
                        Console.Write("(");
                    }
                    report(binexpr.Operand2, 0);
                    if (add_pars)
                    {
                        Console.Write(")");
                    }
                }
                else if (node is TernaryExpression)
                {
                    TernaryExpression ter = node as TernaryExpression;
                    if (ter.NodeType == NodeType.Conditional)
                    {
                        report(ter.Operand1, 0);
                        Console.Write(" ? ");
                        report(ter.Operand2, 0);
                        Console.Write(" : ");
                        report(ter.Operand3, 0);
                    }
                }
                else if (node is PostfixExpression)
                {
                    PostfixExpression postfixExpr = node as PostfixExpression;

                    report(postfixExpr.Expression, 0);

                    switch (postfixExpr.Operator)
                    {
                    case NodeType.Increment: Console.Write("++"); break;

                    case NodeType.Decrement: Console.Write("--"); break;

                    default: Console.Write("???"); break;
                    }
                }
                else if (node is LabeledStatement)
                {
                    LabeledStatement lbst = node as LabeledStatement;
                    indent(shift);
                    report(lbst.Label, 0);
                    Console.Write(" : ");
                    report(lbst.Statement, 0);
                }
                else if (node is Goto)
                {
                    Goto gt = node as Goto;
                    indent(shift);
                    Console.Write("goto ");
                    report(gt.TargetLabel, 0);
                }
                else
                {
                    indent(shift);
                    Console.WriteLine("No code for reporting {0}:{1}", node.UniqueKey, node.ToString());
                }
                break;
            }
            }
        }
Ejemplo n.º 18
0
 public virtual string GetDelegateSignature(DelegateNode del) {
   if (this.ErrorHandler == null) return "";
   return this.ErrorHandler.GetDelegateSignature(del);
 }
Ejemplo n.º 19
0
 public override void VisitNestedDelegate(DelegateNode node)
 {
     visitor.VisitNestedDelegate((INestedDelegateWithSymbols)node);
 }
Ejemplo n.º 20
0
 public virtual Method ChooseMethodMatchingDelegate(MemberList members, DelegateNode dt, TypeNodeList typeArguments){
   if (members == null) return null;
   TypeNode drt = dt.ReturnType;
   ParameterList paramList = dt.Parameters;
   int numPars = paramList == null ? 0 : paramList.Count;
   MemberList eligibleMethods = new MemberList();
   for (int i = 0, n = members.Count; i < n; i++){
     Method m = members[i] as Method;
     if (m == null) continue;
     if (m.Parameters == null || m.Parameters.Count != numPars) continue;
     if (typeArguments != null){
       if (m.TemplateParameters == null || m.TemplateParameters.Count == 0) continue;
       m = m.GetTemplateInstance(this.currentType, typeArguments);
     }
     if (numPars > 0 && m.TemplateParameters != null && m.TemplateParameters.Count > 0){
       Method mti = this.InferMethodTemplateArgumentsAndReturnTemplateInstance(m, dt.Parameters);
       if (mti != null) m = mti;
     }
     if (this.NotEligible(m)) continue;
     if (!m.ParametersMatchStructurallyIncludingOutFlag(paramList, true)) continue;
     if (m.ReturnType == null || !(m.ReturnType.IsStructurallyEquivalentTo(drt) || 
       (!m.ReturnType.IsValueType && this.GetTypeView(m.ReturnType).IsAssignableTo(drt)))) continue;
     eligibleMethods.Add(m);
   }
   if (eligibleMethods.Count == 0) return null;
   if (eligibleMethods.Count == 1) return (Method)eligibleMethods[0];
   ExpressionList dummyArgs = new ExpressionList(dt.Parameters.Count);
   for (int i = 0, n = dt.Parameters.Count; i < n; i++) {
     Parameter par = dt.Parameters[i];
     if (par == null || par.Type == null) continue;
     dummyArgs.Add(new Expression(NodeType.Nop, par.Type));
   }
   return (Method)this.ResolveOverload(eligibleMethods, dummyArgs);
 }
Ejemplo n.º 21
0
 public override DelegateNode VisitDelegateNode(DelegateNode delegateNode){
   if (delegateNode == null) return null;
   this.VisitResolvedTypeReference(delegateNode.ReturnType, delegateNode.ReturnTypeExpression);
   return base.VisitDelegateNode(delegateNode);
 }
Ejemplo n.º 22
0
        private TypeNode/*!*/ ConstructCorrectTypeNodeSubclass(int i, Identifier/*!*/ namesp, int firstInterfaceIndex, int lastInterfaceIndex,
          TypeFlags flags, InterfaceList interfaces, int baseTypeCodedIndex, bool isSystemEnum)
        {
            TypeNode result;
            TypeNode.TypeAttributeProvider attributeProvider = new TypeNode.TypeAttributeProvider(this.GetTypeAttributes);
            TypeNode.NestedTypeProvider nestedTypeProvider = new TypeNode.NestedTypeProvider(this.GetNestedTypes);
            TypeNode.TypeMemberProvider memberProvider = new TypeNode.TypeMemberProvider(this.GetTypeMembers);
            bool isTemplateParameter = false;

            if ((flags & TypeFlags.Interface) != 0)
            {
                if (isTemplateParameter)
                    result = new TypeParameter(interfaces, nestedTypeProvider, attributeProvider, memberProvider, i);
                else
                    result = new Interface(interfaces, nestedTypeProvider, attributeProvider, memberProvider, i);
            }
            else if (isTemplateParameter)
            {
                result = new ClassParameter(nestedTypeProvider, attributeProvider, memberProvider, i);
            }
            else
            {
                result = null;
                TypeNode baseClass = this.GetTypeIfNotGenericInstance(baseTypeCodedIndex);
                if (baseClass != null)
                {
                    if (baseClass == CoreSystemTypes.MulticastDelegate) //TODO: handle single cast delegates
                        result = new DelegateNode(nestedTypeProvider, attributeProvider, memberProvider, i);
                    else if (baseClass == CoreSystemTypes.Enum)
                        result = new EnumNode(nestedTypeProvider, attributeProvider, memberProvider, i);
                    else if (baseClass == CoreSystemTypes.ValueType &&
                      !(isSystemEnum && (flags & TypeFlags.Sealed) == 0))
                    {
                        result = new Struct(nestedTypeProvider, attributeProvider, memberProvider, i);
                    }
                }

                if(result == null)
                    result = new Class(nestedTypeProvider, attributeProvider, memberProvider, i);
            }

            result.Flags = flags;
            result.Interfaces = interfaces;
            return result;
        }
Ejemplo n.º 23
0
 public override DelegateNode VisitDelegateNode(DelegateNode delegateNode){
   delegateNode = base.VisitDelegateNode (delegateNode);
   if (delegateNode == null) return null;
   MemberList mems = delegateNode.GetMembersNamed(StandardIds.Invoke);
   Method invoke = mems == null ? null : mems.Count != 1 ? null : mems[0] as Method;
   mems = delegateNode.GetMembersNamed(StandardIds.EndInvoke);
   Method endInvoke = mems == null ? null : mems.Count != 1 ? null : mems[0] as Method;
   AttributeList returnAttributes = this.ExtractAttributes(delegateNode.Attributes, AttributeTargets.ReturnValue);
   if (invoke != null) {
     invoke.ReturnAttributes = returnAttributes;
   }
   if (endInvoke != null)
   {
     invoke.ReturnAttributes = returnAttributes;
   }
   return delegateNode;
 }
Ejemplo n.º 24
0
        protected override SelectorNode CreateBehaviour()
        {
            //Create melee attack nodes

            //Create ground slam nodes
            CooldownNode   groundSlamCooldownNode       = new CooldownNode(this, GroundSlamCooldownTime);
            AnimatorNode   groundSlamStartAnimationNode = new AnimatorNode(this, m_AnimatorRef, "IsGroundSlamStarting", ref m_GroundSlamStartLink);
            GroundSlamNode groundSlamNode = new GroundSlamNode(this, FallingRockPrefab, PunchHitBox.transform);

            //TODO: COMMENT THIS SECTION AND ADD STRING
            PlaySoundNode slamSFX = new PlaySoundNode(this, "GolemGroundSlamImpact");
            AnimatorNode  groundSlamRecoveryAnimationNode = new AnimatorNode(this, m_AnimatorRef, "IsGroundSlamRecovering", ref m_GroundSlamRecoveryLink);

            ToggleParticleSystemNode toggleGroundSlamPartclesNode = new ToggleParticleSystemNode(this, SlamParticleSystem);

            //Create ground slam sequence
            SequenceNode groundSlamSequence = new SequenceNode(this, "GroundSlamSequence", groundSlamCooldownNode, groundSlamStartAnimationNode, groundSlamNode, toggleGroundSlamPartclesNode, slamSFX, groundSlamRecoveryAnimationNode);

            //Create punch nodes
            CheckDistanceToTargetNode punchDistanceNode = new CheckDistanceToTargetNode(this, 5.0f);

            ToggleMeleeColliderNode togglePunchNode = new ToggleMeleeColliderNode(this, PunchHitBox, 15);

            LookAtTargetNode lookAtTargetNode   = new LookAtTargetNode(this);
            AnimatorNode     punchAnimationNode = new AnimatorNode(this, m_AnimatorRef, "IsPunching", ref m_PunchLink);
            //TODO: COMMENT THIS SECTION AND ADD STRING
            PlaySoundNode punchSFX = new PlaySoundNode(this, "GolemPunchImpact");
            //Create punch sequence
            SequenceNode punchSequence = new SequenceNode(this, "PunchSequence", punchDistanceNode, togglePunchNode, lookAtTargetNode, punchSFX, punchAnimationNode, togglePunchNode);

            //Create melee attack selector in order: GroundSlam, Punch
            SelectorNode meleeAttackSelector = new SelectorNode(this, "MeleeAttackSelector");

            meleeAttackSelector.AddChildren(groundSlamSequence, punchSequence);

            //Create ranged attack nodes

            //Create rock throw nodes
            CooldownNode rockThrowCooldownNode       = new CooldownNode(this, 10.0f);
            AnimatorNode rockThrowStartAnimationNode = new AnimatorNode(this, m_AnimatorRef, "IsRockThrowStarting", ref m_RockThrowStartLink);
            //TODO: COMMENT THIS SECTION AND ADD STRING
            PlaySoundNode rockThrowSFX = new PlaySoundNode(this, "GolemRockThrow");

            DelegateNode.Delegate setRockMeshFunc     = SetRockMesh;
            DelegateNode          setRockMeshTrueNode = new DelegateNode(this, setRockMeshFunc, true);

            AnimatorNode  rockThrowingAnimationNode      = new AnimatorNode(this, m_AnimatorRef, "IsRockThrowing", ref m_RockThrowingLink);
            DelegateNode  setRockMeshFalseNode           = new DelegateNode(this, setRockMeshFunc, false);
            RockThrowNode rockThrowNode                  = new RockThrowNode(this, RockThrowPrefab, FireLocation, RockThrowDamage);
            AnimatorNode  rockThrowRecoveryAnimationNode = new AnimatorNode(this, m_AnimatorRef, "IsRockThrowRecovering", ref m_RockThrowRecoveryLink);

            //Create rock throw sequence
            SequenceNode rockThrowSequence = new SequenceNode(this, "RockThrowSequence", rockThrowCooldownNode,
                                                              rockThrowStartAnimationNode,
                                                              setRockMeshTrueNode,
                                                              rockThrowingAnimationNode,
                                                              setRockMeshFalseNode,
                                                              rockThrowNode,
                                                              rockThrowSFX,
                                                              rockThrowRecoveryAnimationNode
                                                              );

            //Create ground spike nodes
            CooldownNode     groundSpikesCooldownNode       = new CooldownNode(this, 10.0f);
            AnimatorNode     groundSpikesStartAnimationNode = new AnimatorNode(this, m_AnimatorRef, "IsGroundSpikeStarting", ref m_GroundSpikesStartLink);
            GroundSpikesNode groundSpikesNode = new GroundSpikesNode(this, SpikePrefab, SpikesMovementTime);
            AnimatorNode     groundSpikesRecoveryAnimationNode = new AnimatorNode(this, m_AnimatorRef, "IsGroundSpikesRecovering", ref m_GroundSpikesRecoveryLink);

            //Create ground spike sequence
            SequenceNode groundSpikesSequence = new SequenceNode(this, "GroundSpikesSequence", groundSpikesCooldownNode, groundSpikesStartAnimationNode, groundSpikesNode, groundSpikesRecoveryAnimationNode);

            //Create ranged attack selector in order: RockThrow, GroundSpikes
            SelectorNode rangedAttackSelector = new SelectorNode(this, "RangedAttackSelector");

            rangedAttackSelector.AddChildren(rockThrowSequence, groundSpikesSequence);

            //Create targeting nodes
            TargetingAfflicted         targetingAfflictedNode     = new TargetingAfflicted(this, 8, Status.Stun);
            TargetingDistanceNode      targetingDistanceNode      = new TargetingDistanceNode(this, 1);
            TargetingHighHealthNode    targetingHighHealthNode    = new TargetingHighHealthNode(this, 1);
            TargetingHighestDamageNode targetingHighestDamageNode = new TargetingHighestDamageNode(this, 1);
            TargetingCharacterType     targetingCharacterType     = new TargetingCharacterType(this, 1, WeaponType.RANGED);
            CalculateTargetNode        calculateTargetNode        = new CalculateTargetNode(this);

            //Create the targeting sequence and attach nodes
            SequenceNode targetingSequence = new SequenceNode(this, "TargetingSequence");

            targetingSequence.AddChildren(targetingAfflictedNode,
                                          targetingDistanceNode,
                                          targetingHighHealthNode,
                                          targetingHighestDamageNode,
                                          targetingCharacterType,
                                          calculateTargetNode);

            //Create approach node
            ApproachNode approachNode = new ApproachNode(this);

            //Create Abilities/Melee/Ranged/Approach Selector
            SelectorNode actionSelector = new SelectorNode(this, "ActionSelector");

            actionSelector.AddChildren(meleeAttackSelector, rangedAttackSelector, approachNode);

            //Create Target->Action sequence
            SequenceNode getTargetAndUseAbilitySequence = new SequenceNode(this, "GetTargetAndUseAbilitySequence");

            getTargetAndUseAbilitySequence.AddChildren(targetingSequence, actionSelector);

            //Create the utility selector with the previous sequence and approach node
            SelectorNode utilitySelector = new SelectorNode(this, "UtilitySelector");

            utilitySelector.AddChildren(getTargetAndUseAbilitySequence);

            return(utilitySelector);
        }
Ejemplo n.º 25
0
    public override DelegateNode VisitDelegateNode(DelegateNode delegateNode)
    {

      return base.VisitDelegateNode(delegateNode);
    }
Ejemplo n.º 26
0
        protected override SelectorNode CreateBehaviour()
        {
            //Create the reposition nodes
            SafetyCheckNode safetyCheckNode = new SafetyCheckNode(this);

            DelegateNode.Delegate invincibleFunc        = SetInvincible;
            DelegateNode          setInvincibleTrueNode = new DelegateNode(this, invincibleFunc, true);

            AnimatorNode jumpAnimationNode = new AnimatorNode(this, m_AnimatorRef, "IsInannaJumping", ref m_JumpLink);

            LerpNode lerpUpwardsNode = new LerpNode(this, Vector3.up, JumpToMaxTime, JumpHeight, JumpSpeed);

            //Grab all tower points in the map
            GameObject[] towerPointGameObjects = GameObject.FindGameObjectsWithTag("TowerPoint");
            Transform[]  towerPointTransforms  = new Transform[towerPointGameObjects.Length];

            for (int i = 0; i < towerPointTransforms.Length; i++)
            {
                towerPointTransforms[i] = towerPointGameObjects[i].transform;
            }

            InannaMoveTowerNode moveTowerNode          = new InannaMoveTowerNode(this, towerPointTransforms);
            LerpNode            lerpDownwardsNode      = new LerpNode(this, Vector3.down, JumpToMaxTime, JumpHeight, JumpSpeed);
            AnimatorNode        landAnimationNode      = new AnimatorNode(this, m_AnimatorRef, "IsInannaLanding", ref m_LandingLink);
            PlaySoundNode       InnanaJumpSoundNode    = new PlaySoundNode(this, "WingFlap");
            DelegateNode        setInvincibleFalseNode = new DelegateNode(this, invincibleFunc, false);

            //Create reposition sequence

            SequenceNode repositionSequence = new SequenceNode(this, "RepositionSequence", safetyCheckNode, setInvincibleTrueNode, jumpAnimationNode, InnanaJumpSoundNode, lerpUpwardsNode, moveTowerNode, lerpDownwardsNode, InnanaJumpSoundNode, landAnimationNode, setInvincibleFalseNode);

            //Create arrow rain nodes
            PlaySoundNode             ArrowRainSound        = new PlaySoundNode(this, "ArrowRain", 8.0f);
            RainOfArrowsCooldownNode  arrowRainCooldownNode = new RainOfArrowsCooldownNode(this, RainOfArrowsCooldown, RainOfArrowsDiameter);
            RainOfArrowsTargetingNode arrowRainTargetNode   = new RainOfArrowsTargetingNode(this, RainOfArrowsDiameter);
            AnimatorNode           arrowRainAnimationNode   = new AnimatorNode(this, m_AnimatorRef, "IsFiringRainOfArrows", ref m_ArrowRainShotLink);
            RainOfArrowsAttackNode arrowRainAttackNode      = new RainOfArrowsAttackNode(this, m_CircularAOEPrefab.GetComponent <CircularAOE>(), RainOfArrowsWaitTime);

            //Create arrow rain sequence
            SequenceNode arrowRainSequence = new SequenceNode(this, "RainOfArrowsSequence", arrowRainCooldownNode, arrowRainTargetNode, arrowRainAnimationNode, arrowRainAttackNode, ArrowRainSound);

            //Create snipe shot nodes
            PlaySoundNode   HeavyShotSound     = new PlaySoundNode(this, "HeavyShot");
            SnipeDelayNode  snipeDelayNode     = new SnipeDelayNode(this, m_Ereshkigal.transform, m_LineRenderer, m_Ereshkigal.EreshkigalSafeSpace, HitScanBuildUp);
            AnimatorNode    snipeAnimationNode = new AnimatorNode(this, m_AnimatorRef, "IsSniping", ref m_SnipeShotLink);
            HitScanShotNode hitScanShotNode    = new HitScanShotNode(this, ShootLocation.transform, m_HitScanShot, HitscanShotDamage, HitScanShotDelay);

            //Create snipe sequence
            SequenceNode snipeSequence = new SequenceNode(this, "SnipeSequence", snipeDelayNode, snipeAnimationNode, hitScanShotNode, HeavyShotSound);

            //Create arrow shot targeting nodes
            TargetingDistanceFromLocationGreaterThenNode targetingDistanceNode = new TargetingDistanceFromLocationGreaterThenNode(this, m_Ereshkigal.transform, m_Ereshkigal.EreshkigalSafeSpace * 0.5f, 2);
            TargetingLowHealthNode     targetingLowestHPNode      = new TargetingLowHealthNode(this, 2);
            TargetingHighestDamageNode targetingHighestDamageNode = new TargetingHighestDamageNode(this, 1);
            TargetingSightNode         targetingSightNode         = new TargetingSightNode(this, 1, true);
            CalculateTargetNode        calculateTargetNode        = new CalculateTargetNode(this);

            //Create arrow shot targeting sequence
            SequenceNode targetingSequence = new SequenceNode(this, "ArrowTargetingSequence", targetingDistanceNode, targetingLowestHPNode, targetingHighestDamageNode, targetingSightNode, calculateTargetNode);

            //Create other arrow shot nodes
            PlaySoundNode       ArrowShotSoundNode      = new PlaySoundNode(this, "ArrowFire");
            CooldownNode        arrowShotCooldownNode   = new CooldownNode(this, ArrowShotRate);
            AnimatorNode        arrowShotAnimationNode  = new AnimatorNode(this, m_AnimatorRef, "IsFiringArrowShot", ref m_RegularShotLink);
            ShootProjectileNode arrowShotProjectileNode = new ShootProjectileNode(this, ArrowShotDamage, ArrowProjectilePrefab, ShootLocation, "InannaArrowPool", 5);

            //Create arrow shot sequence
            SequenceNode arrowShotSequence = new SequenceNode(this, "ArrowShotSequence", targetingSequence, arrowShotCooldownNode, arrowShotAnimationNode, ArrowShotSoundNode, arrowShotProjectileNode);

            //Create utility selector
            SelectorNode utilitySelector = new SelectorNode(this, "InannaUtilitySelector", repositionSequence, arrowRainSequence, snipeSequence, arrowShotSequence);

            return(utilitySelector);
        }
Ejemplo n.º 27
0
 public override DelegateNode VisitDelegateNode(DelegateNode delegateNode)
 {
     throw new ApplicationException("unimplemented");
 }
Ejemplo n.º 28
0
    public override DelegateNode VisitDelegateNode(DelegateNode delegateNode){
      DelegateNode dn = this.VisitTypeNode(delegateNode) as DelegateNode;
      return dn;

    }
Ejemplo n.º 29
0
 public virtual void VisitDelegateNode(DelegateNode delegateNode)
 {
   if (delegateNode == null) return;
   this.VisitTypeNode(delegateNode);
   this.VisitParameterList(delegateNode.Parameters);
   this.VisitTypeReference(delegateNode.ReturnType);
 }
Ejemplo n.º 30
0
    public virtual DelegateNode VisitDelegateNode(DelegateNode delegateNode, DelegateNode changes, DelegateNode deletions, DelegateNode insertions){
      this.UpdateSourceContext(delegateNode, changes);
      if (delegateNode == null) return changes;
      if (changes != null){
        if (deletions == null || insertions == null)
          Debug.Assert(false);
        else{
          delegateNode.Attributes = this.VisitAttributeList(delegateNode.Attributes, changes.Attributes, deletions.Attributes, insertions.Attributes);
#if !NoXml
          delegateNode.Documentation = changes.Documentation;
#endif
          delegateNode.Flags = changes.Flags;
          delegateNode.Parameters = this.VisitParameterList(delegateNode.Parameters, changes.Parameters, deletions.Parameters, insertions.Parameters);
          delegateNode.ReturnType = this.VisitTypeReference(delegateNode.ReturnType, changes.ReturnType);
          delegateNode.SecurityAttributes = this.VisitSecurityAttributeList(delegateNode.SecurityAttributes, changes.SecurityAttributes, deletions.SecurityAttributes, insertions.SecurityAttributes);
          delegateNode.TemplateParameters = this.VisitTypeReferenceList(delegateNode.TemplateParameters, changes.TemplateParameters, deletions.TemplateParameters, insertions.TemplateParameters);
        }
      }else if (deletions != null)
        return null;
      return delegateNode;
    }
 private Fragment GetDelegateTypesReturnFragment(DelegateNode sourceDelegateType)
 {
     var returnFragment = Fragment.CreateEmpty();
       foreach (Member member in sourceDelegateType.Members)
       {
     if (member.Name.Name == "Invoke")
     {
       Method invoke = (Method) member;
       returnFragment = FragmentUtility.ReturnFragmentType (invoke);
     }
       }
       return returnFragment;
 }
Ejemplo n.º 32
0
        private static void Link(Job job, Agent implant)
        {
            LinkMessage        linkMsg     = JsonConvert.DeserializeObject <LinkMessage>(job.Task.parameters);
            ConnectionInfo     connInfo    = linkMsg.connection_info;
            C2ProfileInfo      profileInfo = connInfo.c2_profile;
            C2Profile          profile;
            bool               outbound;
            ApolloTaskResponse response;


            switch (profileInfo.name.ToLower())
            {
            case "smbserver":
                string pipeName = profileInfo.parameters["PIPE_NAME".ToLower()];
                string hostName = connInfo.host;
                try
                {
                    profile = new SMBClientProfile(pipeName, hostName, implant.Profile.cryptor);
                }
                catch (Exception ex)
                {
                    job.SetError(String.Format("Failed to link to {0} over named pipe \"{1}\". Reason: {2}", hostName, pipeName, ex.Message));
                    break;
                }
                SMBRelay relay = new SMBRelay((SMBClientProfile)profile, implant.Profile, job.Task.id);
                outbound = true;
                string newAgentGUIDMsg = Guid.NewGuid().ToString();
                Thread t = new Thread(() => relay.BeginRelay(newAgentGUIDMsg));
                t.Start();
                string       tempLinkedUUID = (string)MessageInbox.Inbox.GetMessage(newAgentGUIDMsg);
                DelegateNode delegateNode   = new DelegateNode()
                {
                    // AgentUUID = tempLinkedUUID,
                    NodeRelay = relay,
                    // TemporaryUUID = true,
                    OutboundConnect   = outbound,
                    OriginatingTaskID = job.Task.id,
                    AgentComputerName = hostName,
                    ProfileInfo       = profileInfo
                };
                EdgeNode en = new EdgeNode()
                {
                    source      = implant.uuid,
                    destination = tempLinkedUUID,
                    direction   = 1,   // from source to dest
                    metadata    = "",
                    action      = "add",
                    c2_profile  = profileInfo.name
                };
                if (tempLinkedUUID.StartsWith("staging-"))
                {
                    tempLinkedUUID             = tempLinkedUUID.Replace("staging-", "");
                    delegateNode.AgentUUID     = tempLinkedUUID;
                    delegateNode.TemporaryUUID = true;
                    //string linkedUUID = relay.InitializeRelay();
                    implant.AddDelegateNode(tempLinkedUUID, delegateNode);
                    string realUUID = (string)MessageInbox.Inbox.GetMessage(newAgentGUIDMsg);
                    //Thread t = new Thread(() => relay.BeginRelay(newAgentGUIDMsg));
                    //t.Start();

                    implant.RemoveDelegateNode(tempLinkedUUID);
                    delegateNode.AgentUUID     = realUUID;
                    delegateNode.TemporaryUUID = false;
                    implant.AddDelegateNode(realUUID, delegateNode);
                    en.destination = realUUID;
                }
                else
                {
                    // this is a real uuid already staged
                    delegateNode.AgentUUID     = tempLinkedUUID;
                    delegateNode.TemporaryUUID = false;
                    implant.AddDelegateNode(tempLinkedUUID, delegateNode);
                }

                response = new ApolloTaskResponse(job.Task, $"Established link to {hostName}", new EdgeNode[] { en });
                //implant.TryPostResponse(response);
                //implant.Profile.Send(JsonConvert.SerializeObject(new EdgeNodeMessage()
                //{
                //    edges = new EdgeNode[] { en }
                //}));
                job.SetComplete(response);
                //relay.BeginRelay();
                break;

            default:
                job.SetError("Unsupported code path in LinkManager.");
                break;
            }
        }
Ejemplo n.º 33
0
 public virtual void FillInImplicitType(AnonymousNestedFunction anonFunc, DelegateNode delegateNode) {
   if (anonFunc == null || delegateNode == null) return;
   ParameterList afParams = anonFunc.Parameters;
   ParameterList delParams = delegateNode.Parameters;
   if (afParams == null || delParams == null || afParams.Count != delParams.Count) return;
   for (int i = 0, n = afParams.Count; i < n; i++) {
     Parameter p = afParams[i];
     if (p == null || p.Type != null) continue;
     Parameter q = delParams[i];
     if (q != null) p.Type = q.Type;
   }
 }
Ejemplo n.º 34
0
    private static void ClearStatics(){
      AttributeUsageAttribute = null;
      ConditionalAttribute = null;
      DefaultMemberAttribute = null;
      InternalsVisibleToAttribute = null;
      ObsoleteAttribute = null;

      GenericICollection = null;
      GenericIEnumerable = null;
      GenericIList = null;
      ICloneable = null;
      ICollection = null;
      IEnumerable = null;
      IList = null;
#if !MinimalReader
      //Special attributes    
      AllowPartiallyTrustedCallersAttribute = null;
      AssemblyCompanyAttribute = null;
      AssemblyConfigurationAttribute = null;
      AssemblyCopyrightAttribute = null;
      AssemblyCultureAttribute = null;
      AssemblyDelaySignAttribute = null;
      AssemblyDescriptionAttribute = null;
      AssemblyFileVersionAttribute = null;
      AssemblyFlagsAttribute = null;
      AssemblyInformationalVersionAttribute = null;
      AssemblyKeyFileAttribute = null;
      AssemblyKeyNameAttribute = null;
      AssemblyProductAttribute = null;
      AssemblyTitleAttribute = null;
      AssemblyTrademarkAttribute = null;
      AssemblyVersionAttribute = null;
      ClassInterfaceAttribute = null;
      CLSCompliantAttribute = null;
      ComImportAttribute = null;
      ComRegisterFunctionAttribute = null;
      ComSourceInterfacesAttribute = null;
      ComUnregisterFunctionAttribute = null;
      ComVisibleAttribute = null;
      DebuggableAttribute = null;
      DebuggerHiddenAttribute = null;
      DebuggerStepThroughAttribute = null;
      DebuggingModes = null;
      DllImportAttribute = null;
      FieldOffsetAttribute = null;
      FlagsAttribute = null;
      GuidAttribute = null;
      ImportedFromTypeLibAttribute = null;
      InAttribute = null;
      IndexerNameAttribute = null;
      InterfaceTypeAttribute = null;
      MethodImplAttribute = null;
      NonSerializedAttribute = null;
      OptionalAttribute = null;
      OutAttribute = null;
      ParamArrayAttribute = null;
      RuntimeCompatibilityAttribute = null;
      SatelliteContractVersionAttribute = null;
      SerializableAttribute = null;
      SecurityAttribute = null;
      SecurityCriticalAttribute = null;
      SecurityTransparentAttribute = null;
      SecurityTreatAsSafeAttribute = null;
      STAThreadAttribute = null;
      StructLayoutAttribute = null;
      SuppressMessageAttribute = null;
      SuppressUnmanagedCodeSecurityAttribute = null;
      SecurityAction = null;

      //Classes need for System.TypeCode
      DBNull = null;
      DateTime = null;
      TimeSpan = null;

      //Classes and interfaces used by the Framework
      Activator = null;
      AppDomain = null;
      ApplicationException = null;
      ArgumentException = null;
      ArgumentNullException = null;
      ArgumentOutOfRangeException = null;
      ArrayList = null;
      AsyncCallback = null;
      Assembly = null;
      CodeAccessPermission = null;
      CollectionBase = null;
      CultureInfo = null;
      DictionaryBase = null;
      DictionaryEntry = null;
      DuplicateWaitObjectException = null;
      Environment = null;
      EventArgs = null;
      ExecutionEngineException = null;
      GenericArraySegment = null;
  #if !WHIDBEYwithGenerics
      GenericArrayToIEnumerableAdapter = null;
  #endif
      GenericDictionary = null;
      GenericIComparable = null;
      GenericIComparer = null;
      GenericIDictionary = null;
      GenericIEnumerator = null;
      GenericKeyValuePair = null;
      GenericList = null;
      GenericNullable = null;
      GenericQueue = null;
      GenericSortedDictionary = null;
      GenericStack = null;
      GC = null;
      Guid = null;
      __HandleProtector = null;
      HandleRef = null;
      Hashtable = null;
      IASyncResult = null;
      IComparable = null;
      IDictionary = null;
      IComparer = null;
      IDisposable = null;
      IEnumerator = null;
      IFormatProvider = null;
      IHashCodeProvider = null;
      IMembershipCondition = null;
      IndexOutOfRangeException = null;
      InvalidCastException = null;
      InvalidOperationException = null;
      IPermission = null;
      ISerializable = null;
      IStackWalk = null;
      Marshal = null;
      MarshalByRefObject = null;
      MemberInfo = null;
      NativeOverlapped = null;
      Monitor = null;
      NotSupportedException = null;
      NullReferenceException = null;
      OutOfMemoryException = null;
      ParameterInfo = null;
      Queue = null;
      ReadOnlyCollectionBase = null;
      ResourceManager = null;
      ResourceSet = null;
      SerializationInfo = null;
      Stack = null;
      StackOverflowException = null;
      Stream = null;
      StreamingContext = null;
      StringBuilder = null;
      StringComparer = null;
      StringComparison = null;
      SystemException = null;
      Thread = null;
      WindowsImpersonationContext = null;
#endif
#if ExtendedRuntime
      AnonymousAttribute = null;
      AnonymityEnum = null;
      ComposerAttribute = null;
      CustomVisitorAttribute = null;
      TemplateAttribute = null;
      TemplateInstanceAttribute = null;
      UnmanagedStructTemplateParameterAttribute = null;
      TemplateParameterFlagsAttribute = null;
      GenericBoxed = null;
      GenericIEnumerableToGenericIListAdapter = null;
      GenericInvariant = null;
      GenericNonEmptyIEnumerable = null;
      GenericNonNull = null;
      GenericStreamUtility = null;
      GenericUnboxer = null;
      ElementTypeAttribute = null;
      IDbTransactable = null;
      IAggregate = null;
      IAggregateGroup = null;
      StreamNotSingletonException = null;
      SqlHint = null;
      SqlFunctions = null;
      XmlAttributeAttributeClass = null;
      XmlChoiceIdentifierAttributeClass = null;
      XmlElementAttributeClass = null;
      XmlIgnoreAttributeClass = null;
      XmlTypeAttributeClass = null;
      INullable = null;
      SqlBinary = null;
      SqlBoolean = null;
      SqlByte = null;
      SqlDateTime = null;
      SqlDecimal = null;
      SqlDouble = null;
      SqlGuid = null;
      SqlInt16 = null;
      SqlInt32 = null;
      SqlInt64 = null;
      SqlMoney = null;
      SqlSingle = null;
      SqlString = null;
      IDbConnection = null;
      IDbTransaction = null;
      IsolationLevel = null;

      //OrdinaryExceptions
      NoChoiceException = null;
      IllegalUpcastException = null;
      //NonNull  
      Range = null;
      //Invariants
      InitGuardSetsDelegate = null;
      CheckInvariantDelegate = null;
      ObjectInvariantException = null;
      ThreadConditionDelegate = null;
      GuardThreadStart = null;
      Guard = null;
      ContractMarkers = null;
      //IReduction = null;
      AssertHelpers = null;
      ThreadStart = null;
      //CheckedExceptions
      ICheckedException = null;
      CheckedException = null;

      // Contracts
      UnreachableException = null;
      ContractException = null;
      NullTypeException = null;
      AssertException = null;
      AssumeException = null;
      InvalidContractException = null;
      RequiresException = null;
      EnsuresException = null;
      ModifiesException = null;
      ThrowsException = null;
      DoesException = null;
      InvariantException = null;
      ContractMarkerException = null;
      PreAllocatedExceptions = null;

      AdditiveAttribute = null;
      InsideAttribute = null;
      SpecPublicAttribute = null;
      SpecProtectedAttribute = null;
      SpecInternalAttribute = null;
      PureAttribute = null;
      OwnedAttribute = null;
      RepAttribute = null;
      PeerAttribute = null;
      CapturedAttribute = null;
      LockProtectedAttribute = null;
      RequiresLockProtectedAttribute = null;
      ImmutableAttribute = null;
      RequiresImmutableAttribute = null;
      RequiresCanWriteAttribute = null;
      StateIndependentAttribute = null;
      ConfinedAttribute = null;
      ModelfieldContractAttribute = null;
      ModelfieldAttribute = null;
      SatisfiesAttribute = null;
      ModelfieldException = null;

        /* Diego's Attributes for Purity Analysis and Write effects */
      OnceAttribute = null;
      WriteConfinedAttribute = null;
      WriteAttribute = null;
      ReadAttribute = null;
      GlobalReadAttribute = null;
      GlobalWriteAttribute = null;
      GlobalAccessAttribute = null;
      FreshAttribute = null;
      EscapesAttribute = null;
        /* */

      ModelAttribute = null;
      RequiresAttribute = null;
      EnsuresAttribute = null;
      ModifiesAttribute = null;
      HasWitnessAttribute = null;
      WitnessAttribute = null;
      InferredReturnValueAttribute = null;
      ThrowsAttribute = null;
      DoesAttribute = null;
      InvariantAttribute = null;
      NoDefaultActivityAttribute = null;
      NoDefaultContractAttribute = null;
      ReaderAttribute = null;
      ShadowsAssemblyAttribute = null;
      VerifyAttribute = null;
      DependentAttribute = null;
      ElementsRepAttribute = null;
      ElementsPeerAttribute = null;
      ElementAttribute = null;
      ElementCollectionAttribute = null;
      RecursionTerminationAttribute = null;
      NoReferenceComparisonAttribute = null;
      ResultNotNewlyAllocatedAttribute = null;
      noHeapAllocationAttribute = null;
#endif
    }
Ejemplo n.º 35
0
 public override DelegateNode VisitDelegateNode(DelegateNode delegateNode) {
   delegateNode = base.VisitDelegateNode(delegateNode);
   if (delegateNode == null) return null;
   if (this.IsLessAccessible(delegateNode.ReturnType, delegateNode)) {
     this.HandleError(delegateNode.Name, Error.ReturnTypeLessAccessibleThanDelegate,
       this.GetTypeName(delegateNode.ReturnType), this.GetTypeName(delegateNode));
     this.HandleRelatedError(delegateNode.ReturnType);
   }
   this.CheckParameterTypeAccessibility(delegateNode.Parameters, delegateNode);
   return delegateNode;
 }
Ejemplo n.º 36
0
 internal static TypeNode/*!*/ GetDummyTypeNode(AssemblyNode declaringAssembly, string/*!*/ nspace, string/*!*/ name, ElementType typeCode) {
   TypeNode result = null;
   switch (typeCode) {
     case ElementType.Object:
     case ElementType.String:
     case ElementType.Class:
       if (name.Length > 1 && name[0] == 'I' && char.IsUpper(name[1]))
         result = new Interface();
       else if (name == "MulticastDelegate" || name == "Delegate")
         result = new Class();
       else if (name.EndsWith("Callback") || name.EndsWith("Delegate") || name == "ThreadStart" || name == "FrameGuardGetter" || name == "GuardThreadStart")
         result = new DelegateNode();
       else
         result = new Class();
       break;
     default:
       if (name == "CciMemberKind")
         result = new EnumNode();
       else
         result = new Struct();
       break;
   }
   result.Name = Identifier.For(name);
   result.Namespace = Identifier.For(nspace);
   result.DeclaringModule = declaringAssembly;
   return result;
 }
Ejemplo n.º 37
0
 public override DelegateNode VisitDelegateNode(DelegateNode delegateNode){
   return this.VisitTypeNode(delegateNode) as DelegateNode;
 }
Ejemplo n.º 38
0
 public virtual DelegateNode VisitDelegateNode(DelegateNode delegateNode1, DelegateNode delegateNode2)
 {
     if (delegateNode1 == null) return null;
     if (delegateNode2 == null)
     {
         delegateNode1 = (DelegateNode)this.VisitTypeNode(delegateNode1, null);
         if (delegateNode1 == null) return null;
         delegateNode1.Parameters = this.VisitParameterList(delegateNode1.Parameters, null);
         delegateNode1.ReturnType = this.VisitTypeReference(delegateNode1.ReturnType, null);
     }
     else
     {
         delegateNode1 = (DelegateNode)this.VisitTypeNode(delegateNode1, delegateNode2);
         if (delegateNode1 == null) return null;
         delegateNode1.Parameters = this.VisitParameterList(delegateNode1.Parameters, delegateNode2.Parameters);
         delegateNode1.ReturnType = this.VisitTypeReference(delegateNode1.ReturnType, delegateNode2.ReturnType);
     }
     return delegateNode1;
 }
Ejemplo n.º 39
0
        private void BeforeExpand(TreeNode parentNode, CodeDelegate codeDelegate)
        {
            DelegateNode dn = new DelegateNode(codeDelegate, this);

            parentNode.Nodes.Add(dn);
        }
Ejemplo n.º 40
0
 public virtual Expression CoerceToDelegate(Expression source, TypeNode sourceType, DelegateNode targetType, bool explicitCoercion, TypeViewer typeViewer){
   if (source == null || sourceType == null || targetType == null) return null;
   if (!(sourceType is DelegateNode || sourceType is FunctionType)) return null;
   DelegateNode sourceDType = sourceType as DelegateNode;
   MemberList invokeMembers = TypeViewer.GetTypeView(typeViewer, sourceType).GetMembersNamed(StandardIds.Invoke);
   for (int i = 0, n = invokeMembers.Count; i < n; i++){
     Method invoke = invokeMembers[i] as Method;
     if (invoke == null) continue;
     //TODO: if signature is not the same, but can be coerced, emit an adapter function
     if (invoke.ReturnType != targetType.ReturnType) continue;
     if (!invoke.ParametersMatch(targetType.Parameters)) continue;
     InstanceInitializer dcons = TypeViewer.GetTypeView(typeViewer, targetType).GetConstructor(SystemTypes.Object, SystemTypes.IntPtr);
     if (dcons == null) return null;
     MemberBinding memb = new MemberBinding(source, invoke);
     memb.Type = null; 
     Expression ldftn = new UnaryExpression(memb, NodeType.Ldftn);
     ldftn.Type = SystemTypes.IntPtr;
     ExpressionList arguments = new ExpressionList(2);
     arguments.Add(source);
     arguments.Add(ldftn);
     Construct cons = new Construct(new MemberBinding(null, dcons), arguments, targetType);
     cons.SourceContext = source.SourceContext;
     return cons;
   }
   return null;
 }
Ejemplo n.º 41
0
    public virtual Differences VisitDelegateNode(DelegateNode delegateNode1, DelegateNode delegateNode2){
      Differences differences = new Differences(delegateNode1, delegateNode2);
      if (delegateNode1 == null || delegateNode2 == null){
        if (delegateNode1 != delegateNode2) differences.NumberOfDifferences++; else differences.NumberOfSimilarities++;
        return differences;
      }
      DelegateNode changes = (DelegateNode)delegateNode2.Clone();
      DelegateNode deletions = (DelegateNode)delegateNode2.Clone();
      DelegateNode insertions = (DelegateNode)delegateNode2.Clone();

      AttributeList attrChanges, attrDeletions, attrInsertions;
      Differences diff = this.VisitAttributeList(delegateNode1.Attributes, delegateNode2.Attributes, out attrChanges, out attrDeletions, out attrInsertions);
      if (diff == null){Debug.Assert(false); return differences;}
      changes.Attributes = attrChanges;
      deletions.Attributes = attrDeletions;
      insertions.Attributes = attrInsertions;
      differences.NumberOfDifferences += diff.NumberOfDifferences;
      differences.NumberOfSimilarities += diff.NumberOfSimilarities;

      if (delegateNode1.Flags == delegateNode2.Flags) differences.NumberOfSimilarities++; else differences.NumberOfDifferences++;

      ParameterList parChanges, parDeletions, parInsertions;
      diff = this.VisitParameterList(delegateNode1.Parameters, delegateNode2.Parameters, out parChanges, out parDeletions, out parInsertions);
      if (diff == null){Debug.Assert(false); return differences;}
      changes.Parameters = parChanges;
      deletions.Parameters = parDeletions;
      insertions.Parameters = parInsertions;
      differences.NumberOfDifferences += diff.NumberOfDifferences;
      differences.NumberOfSimilarities += diff.NumberOfSimilarities;

      diff = this.VisitTypeNode(delegateNode1.ReturnType, delegateNode2.ReturnType);
      if (diff == null){Debug.Assert(false); return differences;}
      changes.ReturnType = diff.Changes as TypeNode;
      deletions.ReturnType = diff.Deletions as TypeNode;
      insertions.ReturnType = diff.Insertions as TypeNode;
      //Debug.Assert(diff.Changes == changes.ReturnType && diff.Deletions == deletions.ReturnType && diff.Insertions == insertions.ReturnType);
      differences.NumberOfDifferences += diff.NumberOfDifferences;
      differences.NumberOfSimilarities += diff.NumberOfSimilarities;

      SecurityAttributeList secChanges, secDeletions, secInsertions;
      diff = this.VisitSecurityAttributeList(delegateNode1.SecurityAttributes, delegateNode2.SecurityAttributes, out secChanges, out secDeletions, out secInsertions);
      if (diff == null){Debug.Assert(false); return differences;}
      changes.SecurityAttributes = secChanges;
      deletions.SecurityAttributes = secDeletions;
      insertions.SecurityAttributes = secInsertions;
      differences.NumberOfDifferences += diff.NumberOfDifferences;
      differences.NumberOfSimilarities += diff.NumberOfSimilarities;

      TypeNodeList typeChanges, typeDeletions, typeInsertions;
      diff = this.VisitTypeNodeList(delegateNode1.TemplateParameters, delegateNode2.TemplateParameters, out typeChanges, out typeDeletions, out typeInsertions);
      if (diff == null){Debug.Assert(false); return differences;}
      changes.TemplateParameters = typeChanges;
      deletions.TemplateParameters = typeDeletions;
      insertions.TemplateParameters = typeInsertions;
      differences.NumberOfDifferences += diff.NumberOfDifferences;
      differences.NumberOfSimilarities += diff.NumberOfSimilarities;

      if (differences.NumberOfDifferences == 0){
        differences.Changes = null;
        differences.Deletions = null;
        differences.Insertions = null;
      }else{
        differences.Changes = changes;
        differences.Deletions = deletions;
        differences.Insertions = insertions;
      }
      return differences;
    }
Ejemplo n.º 42
0
 public override DelegateNode VisitDelegateNode(DelegateNode delegateNode)
 {
   throw new ApplicationException("unimplemented");
 }
 public static bool IsAssumedPureDelegate(DelegateNode n) {
   if (WorstCase)
     return false;
   bool res = false;
   res = n.GetAttribute(SystemTypes.PureAttribute) != null;
   return res;
   }
Ejemplo n.º 44
0
        protected override SelectorNode CreateBehaviour()
        {
            //create the dig nodes
            CanDigNode               canDigNode         = new CanDigNode(this);
            HealthLessThanNode       healthCheckNode    = new HealthLessThanNode(this, 0.6f);
            AnimatorNode             digAnimationNode   = new AnimatorNode(this, m_AnimatorRef, "IsDigging", ref m_DigAnimationLink);
            ToggleParticleSystemNode toggleParticleNode = new ToggleParticleSystemNode(this, DigParticleSystem);

            DelegateNode.Delegate toggleTriggerFunc = SetColliderTrigger;
            DelegateNode          toggleTriggerNode = new DelegateNode(this, toggleTriggerFunc, true);

            DelegateNode.Delegate toggleColliderFunc = ToggleCollider;
            DelegateNode          toggleColliderNode = new DelegateNode(this, toggleColliderFunc);

            ToggleNavMeshAgentNode toggleAgentNode = new ToggleNavMeshAgentNode(this);
            DelayNode delayNode = new DelayNode(this, 2.0f);
            //TODO: COMMENT THIS SECTION AND ADD STRING
            PlaySoundNode digSFX       = new PlaySoundNode(this, "NergDig");
            LerpNode      lerpDownNode = new LerpNode(this, Vector3.down, 1.0f, 2.0f, 10.0f);

            DelegateNode.Delegate rotateFunc = RotateVertical;
            DelegateNode          rotateNode = new DelegateNode(this, rotateFunc);

            TeleportToTargetOffsetNode teleportNode     = new TeleportToTargetOffsetNode(this, new Vector3(0.0f, -5.0f, 0.0f));
            LerpToTargetNode           lerpToTargetNode = new LerpToTargetNode(this, 0.5f, 1.0f, 10.0f);
            AnimatorNode        biteAnimationNode       = new AnimatorNode(this, m_AnimatorRef, "IsBiting", ref m_BiteAnimationLink);
            RunUntillTargetNull targetNullNode          = new RunUntillTargetNull(this);

            //create the dig sequence
            SequenceNode digSequence = new SequenceNode(this, "DigSequence",
                                                        healthCheckNode,
                                                        canDigNode,
                                                        toggleParticleNode,
                                                        toggleTriggerNode,
                                                        toggleColliderNode,
                                                        toggleAgentNode,
                                                        delayNode,
                                                        digSFX,
                                                        lerpDownNode,
                                                        toggleParticleNode,
                                                        rotateNode,
                                                        teleportNode,
                                                        toggleColliderNode,
                                                        toggleParticleNode,
                                                        lerpToTargetNode,
                                                        digSFX,
                                                        delayNode,
                                                        toggleParticleNode,
                                                        targetNullNode
                                                        );

            //create the targeting nodes
            TargetingSightNode     sightNode  = new TargetingSightNode(this, 1);
            TargetingLowHealthNode lowHealth  = new TargetingLowHealthNode(this, 3);
            CalculateTargetNode    calcTarget = new CalculateTargetNode(this);

            //assign the targeting sequence
            SequenceNode targetingSequ = new SequenceNode(this, "TargetingSequence", sightNode, lowHealth, calcTarget);

            //create the spit nodes
            CooldownNode spitCooldownNode = new CooldownNode(this, 1.0f);
            //AnimatorNode spitAnimationNode = new AnimatorNode(this, m_AnimatorRef, "IsSpitting", ref m_SpitAnimationLink);
            ShootProjectileNode projectileNode = new ShootProjectileNode(this, 1, ProjectilePrefab, ProjectileSpawnLoc, "MasterNergProjectile", 10);
            //SFX for the sound of the nerg spitting
            PlaySoundNode spitSound = new PlaySoundNode(this, "NergSpit");


            //create the movement nodes
            CooldownNode movementCooldownNode = new CooldownNode(this, 3.0f);
            //BackAwayNode backAwayNode = new BackAwayNode(this, false, 1.0f);
            SideStepNode             sideStepNode        = new SideStepNode(this, false, 2.0f);
            PredictiveAvoidanceNode  predictMovementNode = new PredictiveAvoidanceNode(this, false, true, 2.0f, 5.0f);
            MovementOptionRandomNode movementNodes       = new MovementOptionRandomNode(this, sideStepNode, predictMovementNode);

            //SFX for the sound of the nerg moving backward
            //TODO: COMMENT THIS SECTION AND ADD STRING
            //PlaySoundNode crawlingSFX = new PlaySoundNode(this,);

            //create the spit sequence
            SequenceNode spitSequence = new SequenceNode(this, "SpitSequence", spitCooldownNode, projectileNode, spitSound, movementCooldownNode, movementNodes /*, crawlingSFX*/);

            //assign the attack selector
            SelectorNode attackSelector = new SelectorNode(this, "AttackSelector", digSequence, spitSequence);

            //create the attack sequence
            SequenceNode attackSequence = new SequenceNode(this, "AttackTargetSequence", targetingSequ, attackSelector);

            //create utility selector
            SelectorNode utilitySelector = new SelectorNode(this, "UtilitySelector", attackSequence);

            return(utilitySelector);
        }
Ejemplo n.º 45
0
 public virtual string GetDelegateSignature(DelegateNode del){
   if (del == null) return "";
   return this.GetTypeName(del.ReturnType)+" "+this.GetSignatureString(del.FullName, del.Parameters, "(", ")", ", ");
 }
Ejemplo n.º 46
0
        private void EmitDelegateShim(StatementList setupInteropStatements, AssemblyNode inputAssembly, DelegateNode type)
        {
            //  For each referential use in an imported or exported method signature of a delegate type definition D such as:
            //      delegate R D<T, U>(A1 a1, A2 a2)
            //  declare:
            //      class D_Shim_<unique id><T, U> {
            //          private UniversalDelegate u;
            //          public D_Shim_<unique id>(UniversalDelegate u) { this.u = u; }
            //          public R Invoke(A1 a1, A2 a2) {
            //              return (R)u(new object[] {a1, a2});
            //          }
            //      }
            //  and append to <Module>::SetupInterop():
            //      InteropContextManager.Data.RegisterDelegateShim(typeof(D_Shim_<unique id>))

            var shim = new Class
                (inputAssembly,
                 null,
                 new AttributeList(0),
                 TypeFlags.Public | TypeFlags.Class,
                 Identifier.For(""),
                 Identifier.For(ShimFullName(type.FullName)),
                 (Class)env.ObjectType,
                 new InterfaceList(),
                 new MemberList());

            TransferTypeParameters(type, shim);

            var uField = new Field
                (shim,
                 new AttributeList(0),
                 FieldFlags.Private,
                 Identifier.For("u"),
                 env.UniversalDelegateType,
                 null);
            uField.Flags |= FieldFlags.Private;
            shim.Members.Add(uField);

            var ctorParam = new Parameter(Identifier.For("u"), env.UniversalDelegateType);
            var ctorBlock = new Block
                (new StatementList
                     (new ExpressionStatement
                          (new MethodCall
                               (new MemberBinding(ThisExpression(shim), env.ObjectType.GetConstructor()),
                                new ExpressionList())),
                      new AssignmentStatement
                          (new MemberBinding(ThisExpression(shim), uField),
                           new ParameterBinding(ctorParam, ctorParam.SourceContext)),
                      new Return()));
            var ctor = new InstanceInitializer(shim, new AttributeList(0), new ParameterList(ctorParam), ctorBlock);
            ctor.Flags |= MethodFlags.Public | MethodFlags.SpecialName | MethodFlags.RTSpecialName;
            TagAsCompilerGenerated(ctor);
            shim.Members.Add(ctor);

            var invokeParams = CopyParameters(type.Parameters);
            var args = new ExpressionList();
            foreach (var p in invokeParams)
                args.Add(BoxExpression(new ParameterBinding(p, p.SourceContext), env.ObjectType));
            var argsAsObjectArray = ArrayExpression(args, env.ObjectType);
            var callExpr = new MethodCall
                                        (new MemberBinding
                                             (new MemberBinding(ThisExpression(shim), uField),
                                              env.UniversalDelegate_InvokeMethod),
                                         new ExpressionList(argsAsObjectArray));
            var statements = new StatementList();
            if (type.ReturnType == env.VoidType)
            {
                statements.Add(new ExpressionStatement(callExpr));
                statements.Add(new ExpressionStatement(new UnaryExpression(null, NodeType.Pop)));
                statements.Add(new Return());
            }
            else
            {
                statements.Add(new Return(CastExpression(callExpr, type.ReturnType)));
            }
            var invoke = new Method
                (shim, new AttributeList(0), Identifier.For("Invoke"), invokeParams, type.ReturnType, new Block(statements));
            invoke.Flags |= MethodFlags.Public;
            invoke.CallingConvention |= CallingConventionFlags.HasThis;
            TagAsCompilerGenerated(invoke);
            shim.Members.Add(invoke);

            TagAsCompilerGenerated(shim);
            TagAsInteropGenerated(shim);
            TagAsIgnore(shim);

            inputAssembly.Types.Add(shim);
            shim.DeclaringModule = inputAssembly;

            env.Log(new InteropInfoMessage(RewriterMsgContext.Type(type), "Created shim type: " + shim.FullName));
            setupInteropStatements.Add
                (new ExpressionStatement
                     (new MethodCall
                          (new MemberBinding
                               (DatabaseExpression(), env.InteropDatabase_RegisterDelegateShimMethod),
                           new ExpressionList(TypeOfExpression(shim)))));
        }
Ejemplo n.º 47
0
 public override DelegateNode VisitDelegateNode(DelegateNode delegateNode)
 {
     return(this.VisitTypeNode(delegateNode) as DelegateNode);
 }
Ejemplo n.º 48
0
    public static void Initialize(bool doNotLockFile, bool getDebugInfo){
      if (SystemTypes.Initialized){
        SystemTypes.Clear();
        CoreSystemTypes.Initialize(doNotLockFile, getDebugInfo);
#if ExtendedRuntime
        ExtendedRuntimeTypes.Initialize(doNotLockFile, getDebugInfo);
#endif
      }else if (!CoreSystemTypes.Initialized){
        CoreSystemTypes.Initialize(doNotLockFile, getDebugInfo);
#if ExtendedRuntime
        ExtendedRuntimeTypes.Clear();
        ExtendedRuntimeTypes.Initialize(doNotLockFile, getDebugInfo);
#endif
      }

      if (TargetPlatform.TargetVersion == null){
        TargetPlatform.TargetVersion = SystemAssembly.Version;
        if (TargetPlatform.TargetVersion == null)
          TargetPlatform.TargetVersion = typeof(object).Module.Assembly.GetName().Version;
      }
      //TODO: throw an exception when the result is null
#if ExtendedRuntime
#if !NoData && !ROTOR
      SystemDataAssembly = SystemTypes.GetSystemDataAssembly(doNotLockFile, getDebugInfo);
#endif
#if !NoXml && !NoRuntimeXml
      SystemXmlAssembly = SystemTypes.GetSystemXmlAssembly(doNotLockFile, getDebugInfo);
#endif
#endif
      AttributeUsageAttribute = (Class)GetTypeNodeFor("System", "AttributeUsageAttribute", ElementType.Class);
      ConditionalAttribute = (Class)GetTypeNodeFor("System.Diagnostics", "ConditionalAttribute", ElementType.Class);
      DefaultMemberAttribute = (Class)GetTypeNodeFor("System.Reflection", "DefaultMemberAttribute", ElementType.Class);
      InternalsVisibleToAttribute = (Class)GetTypeNodeFor("System.Runtime.CompilerServices", "InternalsVisibleToAttribute", ElementType.Class);
      ObsoleteAttribute = (Class)GetTypeNodeFor("System", "ObsoleteAttribute", ElementType.Class);

      GenericICollection = (Interface)GetGenericRuntimeTypeNodeFor("System.Collections.Generic", "ICollection", 1, ElementType.Class);
      GenericIEnumerable = (Interface)GetGenericRuntimeTypeNodeFor("System.Collections.Generic", "IEnumerable", 1, ElementType.Class);
      GenericIList = (Interface)GetGenericRuntimeTypeNodeFor("System.Collections.Generic", "IList", 1, ElementType.Class);
      ICloneable = (Interface)GetTypeNodeFor("System", "ICloneable", ElementType.Class);
      ICollection = (Interface)GetTypeNodeFor("System.Collections", "ICollection", ElementType.Class);
      IEnumerable = (Interface)GetTypeNodeFor("System.Collections", "IEnumerable", ElementType.Class);
      IList = (Interface)GetTypeNodeFor("System.Collections", "IList", ElementType.Class);

#if !MinimalReader
      AllowPartiallyTrustedCallersAttribute = (Class)GetTypeNodeFor("System.Security", "AllowPartiallyTrustedCallersAttribute", ElementType.Class);
      AssemblyCompanyAttribute = (Class)GetTypeNodeFor("System.Reflection", "AssemblyCompanyAttribute", ElementType.Class);
      AssemblyConfigurationAttribute = (Class)GetTypeNodeFor("System.Reflection", "AssemblyConfigurationAttribute", ElementType.Class);
      AssemblyCopyrightAttribute = (Class)GetTypeNodeFor("System.Reflection", "AssemblyCopyrightAttribute", ElementType.Class);
      AssemblyCultureAttribute = (Class)GetTypeNodeFor("System.Reflection", "AssemblyCultureAttribute", ElementType.Class);
      AssemblyDelaySignAttribute = (Class)GetTypeNodeFor("System.Reflection", "AssemblyDelaySignAttribute", ElementType.Class);
      AssemblyDescriptionAttribute = (Class)GetTypeNodeFor("System.Reflection", "AssemblyDescriptionAttribute", ElementType.Class);
      AssemblyFileVersionAttribute = (Class)GetTypeNodeFor("System.Reflection", "AssemblyFileVersionAttribute", ElementType.Class);
      AssemblyFlagsAttribute = (Class)GetTypeNodeFor("System.Reflection", "AssemblyFlagsAttribute", ElementType.Class);
      AssemblyInformationalVersionAttribute = (Class)GetTypeNodeFor("System.Reflection", "AssemblyInformationalVersionAttribute", ElementType.Class);
      AssemblyKeyFileAttribute = (Class)GetTypeNodeFor("System.Reflection", "AssemblyKeyFileAttribute", ElementType.Class);
      AssemblyKeyNameAttribute = (Class)GetTypeNodeFor("System.Reflection", "AssemblyKeyNameAttribute", ElementType.Class); 
      AssemblyProductAttribute = (Class)GetTypeNodeFor("System.Reflection", "AssemblyProductAttribute", ElementType.Class);
      AssemblyTitleAttribute = (Class)GetTypeNodeFor("System.Reflection", "AssemblyTitleAttribute", ElementType.Class);
      AssemblyTrademarkAttribute = (Class)GetTypeNodeFor("System.Reflection", "AssemblyTrademarkAttribute", ElementType.Class);
      AssemblyVersionAttribute = (Class)GetTypeNodeFor("System.Reflection", "AssemblyVersionAttribute", ElementType.Class);
      ClassInterfaceAttribute = (Class)GetTypeNodeFor("System.Runtime.InteropServices", "ClassInterfaceAttribute", ElementType.Class);
      CLSCompliantAttribute = (Class)GetTypeNodeFor("System", "CLSCompliantAttribute", ElementType.Class);
      ComImportAttribute = (Class)GetTypeNodeFor("System.Runtime.InteropServices", "ComImportAttribute", ElementType.Class);
      ComRegisterFunctionAttribute = (Class)GetTypeNodeFor("System.Runtime.InteropServices", "ComRegisterFunctionAttribute", ElementType.Class);
      ComSourceInterfacesAttribute = (Class)GetTypeNodeFor("System.Runtime.InteropServices", "ComSourceInterfacesAttribute", ElementType.Class);
      ComUnregisterFunctionAttribute = (Class)GetTypeNodeFor("System.Runtime.InteropServices", "ComUnregisterFunctionAttribute", ElementType.Class);
      ComVisibleAttribute = (Class)GetTypeNodeFor("System.Runtime.InteropServices", "ComVisibleAttribute", ElementType.Class);      
      DebuggableAttribute = (Class)GetTypeNodeFor("System.Diagnostics", "DebuggableAttribute", ElementType.Class);
      DebuggerHiddenAttribute = (Class)GetTypeNodeFor("System.Diagnostics", "DebuggerHiddenAttribute", ElementType.Class);
      DebuggerStepThroughAttribute = (Class)GetTypeNodeFor("System.Diagnostics", "DebuggerStepThroughAttribute", ElementType.Class);
      DebuggingModes = DebuggableAttribute == null ? null : DebuggableAttribute.GetNestedType(Identifier.For("DebuggingModes")) as EnumNode;
      DllImportAttribute = (Class)GetTypeNodeFor("System.Runtime.InteropServices", "DllImportAttribute", ElementType.Class);
      FieldOffsetAttribute = (Class)GetTypeNodeFor("System.Runtime.InteropServices", "FieldOffsetAttribute", ElementType.Class);
      FlagsAttribute = (Class)GetTypeNodeFor("System", "FlagsAttribute", ElementType.Class);
      Guid = (Struct)GetTypeNodeFor("System", "Guid", ElementType.ValueType);
      GuidAttribute = (Class)GetTypeNodeFor("System.Runtime.InteropServices", "GuidAttribute", ElementType.Class);
      ImportedFromTypeLibAttribute = (Class)GetTypeNodeFor("System.Runtime.InteropServices", "ImportedFromTypeLibAttribute", ElementType.Class);
      InAttribute = (Class)GetTypeNodeFor("System.Runtime.InteropServices", "InAttribute", ElementType.Class);
      IndexerNameAttribute = (Class)GetTypeNodeFor("System.Runtime.CompilerServices", "IndexerNameAttribute", ElementType.Class);
      InterfaceTypeAttribute = (Class)GetTypeNodeFor("System.Runtime.InteropServices", "InterfaceTypeAttribute", ElementType.Class);
      MethodImplAttribute = (Class)GetTypeNodeFor("System.Runtime.CompilerServices", "MethodImplAttribute", ElementType.Class);
      NonSerializedAttribute = (Class)GetTypeNodeFor("System", "NonSerializedAttribute", ElementType.Class);      
      OptionalAttribute = (Class)GetTypeNodeFor("System.Runtime.InteropServices", "OptionalAttribute", ElementType.Class);
      OutAttribute = (Class)GetTypeNodeFor("System.Runtime.InteropServices", "OutAttribute", ElementType.Class);
      ParamArrayAttribute = (Class)GetTypeNodeFor("System", "ParamArrayAttribute", ElementType.Class);
      RuntimeCompatibilityAttribute = (Class)GetTypeNodeFor("System.Runtime.CompilerServices", "RuntimeCompatibilityAttribute", ElementType.Class);
      SatelliteContractVersionAttribute = (Class)GetTypeNodeFor("System.Resources", "SatelliteContractVersionAttribute", ElementType.Class);
      SerializableAttribute = (Class)GetTypeNodeFor("System", "SerializableAttribute", ElementType.Class);
      SecurityAttribute = (Class)GetTypeNodeFor("System.Security.Permissions", "SecurityAttribute", ElementType.Class);
      SecurityCriticalAttribute = (Class)GetTypeNodeFor("System.Security", "SecurityCriticalAttribute", ElementType.Class);
      SecurityTransparentAttribute = (Class)GetTypeNodeFor("System.Security", "SecurityTransparentAttribute", ElementType.Class);
      SecurityTreatAsSafeAttribute = (Class)GetTypeNodeFor("System.Security", "SecurityTreatAsSafeAttribute", ElementType.Class);
      STAThreadAttribute = (Class)GetTypeNodeFor("System", "STAThreadAttribute", ElementType.Class);
      StructLayoutAttribute = (Class)GetTypeNodeFor("System.Runtime.InteropServices", "StructLayoutAttribute", ElementType.Class);
      SuppressMessageAttribute = (Class)GetTypeNodeFor("System.Diagnostics.CodeAnalysis", "SuppressMessageAttribute", ElementType.Class);     
      SuppressUnmanagedCodeSecurityAttribute = (Class)GetTypeNodeFor("System.Security", "SuppressUnmanagedCodeSecurityAttribute", ElementType.Class);
      SecurityAction = GetTypeNodeFor("System.Security.Permissions", "SecurityAction", ElementType.ValueType) as EnumNode;
      DBNull = (Class)GetTypeNodeFor("System", "DBNull", ElementType.Class);
      DateTime = (Struct)GetTypeNodeFor("System", "DateTime", ElementType.ValueType);
      TimeSpan = (Struct)GetTypeNodeFor("System", "TimeSpan", ElementType.ValueType);
      Activator = (Class)GetTypeNodeFor("System", "Activator", ElementType.Class);
      AppDomain = (Class)GetTypeNodeFor("System", "AppDomain", ElementType.Class);
      ApplicationException = (Class)GetTypeNodeFor("System", "ApplicationException", ElementType.Class);
      ArgumentException = (Class)GetTypeNodeFor("System", "ArgumentException", ElementType.Class);
      ArgumentNullException = (Class)GetTypeNodeFor("System", "ArgumentNullException", ElementType.Class);
      ArgumentOutOfRangeException = (Class)GetTypeNodeFor("System", "ArgumentOutOfRangeException", ElementType.Class);
      ArrayList = (Class)GetTypeNodeFor("System.Collections", "ArrayList", ElementType.Class);
      AsyncCallback = (DelegateNode)GetTypeNodeFor("System", "AsyncCallback", ElementType.Class);
      Assembly = (Class)GetTypeNodeFor("System.Reflection", "Assembly", ElementType.Class);
      CodeAccessPermission = (Class)GetTypeNodeFor("System.Security", "CodeAccessPermission", ElementType.Class);
      CollectionBase = (Class)GetTypeNodeFor("System.Collections", "CollectionBase", ElementType.Class);
      CultureInfo = (Class)GetTypeNodeFor("System.Globalization", "CultureInfo", ElementType.Class);
      DictionaryBase = (Class)GetTypeNodeFor("System.Collections", "DictionaryBase", ElementType.Class);
      DictionaryEntry = (Struct)GetTypeNodeFor("System.Collections", "DictionaryEntry", ElementType.ValueType);
      DuplicateWaitObjectException = (Class)GetTypeNodeFor("System", "DuplicateWaitObjectException", ElementType.Class);
      Environment = (Class)GetTypeNodeFor("System", "Environment", ElementType.Class);
      EventArgs = (Class)GetTypeNodeFor("System", "EventArgs", ElementType.Class);
      ExecutionEngineException = (Class)GetTypeNodeFor("System", "ExecutionEngineException", ElementType.Class);
      GenericArraySegment = (Struct)GetGenericRuntimeTypeNodeFor("System", "ArraySegment", 1, ElementType.ValueType);
      GenericDictionary = (Class)GetGenericRuntimeTypeNodeFor("System.Collections.Generic", "Dictionary", 2, ElementType.Class);
      GenericIComparable = (Interface)GetGenericRuntimeTypeNodeFor("System.Collections.Generic", "IComparable", 1, ElementType.Class);
      GenericIComparer = (Interface)GetGenericRuntimeTypeNodeFor("System.Collections.Generic", "IComparer", 1, ElementType.Class);
      GenericIDictionary = (Interface)GetGenericRuntimeTypeNodeFor("System.Collections.Generic", "IDictionary", 2, ElementType.Class);
      GenericIEnumerator = (Interface)GetGenericRuntimeTypeNodeFor("System.Collections.Generic", "IEnumerator", 1, ElementType.Class);
      GenericKeyValuePair = (Struct)GetGenericRuntimeTypeNodeFor("System.Collections.Generic", "KeyValuePair", 2, ElementType.ValueType);
      GenericList = (Class)GetGenericRuntimeTypeNodeFor("System.Collections.Generic", "List", 1, ElementType.Class);
      GenericNullable = (Struct)GetGenericRuntimeTypeNodeFor("System", "Nullable", 1, ElementType.ValueType);
      GenericQueue = (Class)GetGenericRuntimeTypeNodeFor("System.Collections.Generic", "Queue", 1, ElementType.Class);
      GenericSortedDictionary = (Class)GetGenericRuntimeTypeNodeFor("System.Collections.Generic", "SortedDictionary", 2, ElementType.Class);
      GenericStack = (Class)GetGenericRuntimeTypeNodeFor("System.Collections.Generic", "Stack", 1, ElementType.Class);
      GC = (Class)GetTypeNodeFor("System", "GC", ElementType.Class);
      __HandleProtector = (Class)GetTypeNodeFor("System.Threading", "__HandleProtector", ElementType.Class);
      HandleRef = (Struct)GetTypeNodeFor("System.Runtime.InteropServices", "HandleRef", ElementType.ValueType);
      Hashtable = (Class)GetTypeNodeFor("System.Collections", "Hashtable", ElementType.Class);
      IASyncResult = (Interface)GetTypeNodeFor("System", "IAsyncResult", ElementType.Class);
      IComparable = (Interface)GetTypeNodeFor("System", "IComparable", ElementType.Class);
      IComparer = (Interface)GetTypeNodeFor("System.Collections", "IComparer", ElementType.Class);
      IDictionary = (Interface)GetTypeNodeFor("System.Collections", "IDictionary", ElementType.Class);
      IDisposable = (Interface)GetTypeNodeFor("System", "IDisposable", ElementType.Class);
      IEnumerator = (Interface)GetTypeNodeFor("System.Collections", "IEnumerator", ElementType.Class);
      IFormatProvider = (Interface)GetTypeNodeFor("System", "IFormatProvider", ElementType.Class);
      IHashCodeProvider = (Interface)GetTypeNodeFor("System.Collections", "IHashCodeProvider", ElementType.Class);
      IMembershipCondition = (Interface)GetTypeNodeFor("System.Security.Policy", "IMembershipCondition", ElementType.Class);
      IndexOutOfRangeException = (Class)GetTypeNodeFor("System", "IndexOutOfRangeException", ElementType.Class);
      InvalidCastException = (Class)GetTypeNodeFor("System", "InvalidCastException", ElementType.Class);
      InvalidOperationException = (Class)GetTypeNodeFor("System", "InvalidOperationException", ElementType.Class);
      IPermission = (Interface)GetTypeNodeFor("System.Security", "IPermission", ElementType.Class);
      ISerializable = (Interface)GetTypeNodeFor("System.Runtime.Serialization", "ISerializable", ElementType.Class);
      IStackWalk = (Interface)GetTypeNodeFor("System.Security", "IStackWalk", ElementType.Class);
      Marshal = (Class)GetTypeNodeFor("System.Runtime.InteropServices", "Marshal", ElementType.Class);
      MarshalByRefObject = (Class)GetTypeNodeFor("System", "MarshalByRefObject", ElementType.Class);
      MemberInfo = (Class)GetTypeNodeFor("System.Reflection", "MemberInfo", ElementType.Class);
      Monitor = (Class)GetTypeNodeFor("System.Threading", "Monitor", ElementType.Class);
      NativeOverlapped = (Struct)GetTypeNodeFor("System.Threading", "NativeOverlapped", ElementType.ValueType);
      NotSupportedException = (Class)GetTypeNodeFor("System", "NotSupportedException", ElementType.Class);
      NullReferenceException = (Class)GetTypeNodeFor("System", "NullReferenceException", ElementType.Class);
      OutOfMemoryException = (Class)GetTypeNodeFor("System", "OutOfMemoryException", ElementType.Class);
      ParameterInfo = (Class)GetTypeNodeFor("System.Reflection", "ParameterInfo", ElementType.Class);
      Queue = (Class)GetTypeNodeFor("System.Collections", "Queue", ElementType.Class);
      ReadOnlyCollectionBase = (Class)GetTypeNodeFor("System.Collections", "ReadOnlyCollectionBase", ElementType.Class);
      ResourceManager = (Class)GetTypeNodeFor("System.Resources", "ResourceManager", ElementType.Class);
      ResourceSet = (Class)GetTypeNodeFor("System.Resources", "ResourceSet", ElementType.Class);
      SerializationInfo = (Class)GetTypeNodeFor("System.Runtime.Serialization", "SerializationInfo", ElementType.Class);
      Stack = (Class)GetTypeNodeFor("System.Collections", "Stack", ElementType.Class);
      StackOverflowException = (Class)GetTypeNodeFor("System", "StackOverflowException", ElementType.Class);
      Stream = (Class)GetTypeNodeFor("System.IO", "Stream", ElementType.Class);
      StreamingContext = (Struct)GetTypeNodeFor("System.Runtime.Serialization", "StreamingContext", ElementType.ValueType);
      StringBuilder = (Class)GetTypeNodeFor("System.Text", "StringBuilder", ElementType.Class);
      StringComparer = (Class)GetTypeNodeFor("System", "StringComparer", ElementType.Class);
      StringComparison =  GetTypeNodeFor("System", "StringComparison", ElementType.ValueType) as EnumNode;
      SystemException = (Class)GetTypeNodeFor("System", "SystemException", ElementType.Class);
      Thread = (Class)GetTypeNodeFor("System.Threading", "Thread", ElementType.Class);
      WindowsImpersonationContext = (Class)GetTypeNodeFor("System.Security.Principal", "WindowsImpersonationContext", ElementType.Class);
#endif      
#if ExtendedRuntime
#if !NoXml && !NoRuntimeXml
      XmlAttributeAttributeClass = (Class)GetXmlTypeNodeFor("System.Xml.Serialization", "XmlAttributeAttribute", ElementType.Class);
      XmlChoiceIdentifierAttributeClass = (Class)GetXmlTypeNodeFor("System.Xml.Serialization", "XmlChoiceIdentifierAttribute", ElementType.Class);
      XmlElementAttributeClass = (Class)GetXmlTypeNodeFor("System.Xml.Serialization", "XmlElementAttribute", ElementType.Class);
      XmlIgnoreAttributeClass = (Class)GetXmlTypeNodeFor("System.Xml.Serialization", "XmlIgnoreAttribute", ElementType.Class);
      XmlTypeAttributeClass = (Class)GetXmlTypeNodeFor("System.Xml.Serialization", "XmlTypeAttribute", ElementType.Class);
#endif

#if !NoData
      INullable = (Interface) GetDataTypeNodeFor("System.Data.SqlTypes", "INullable", ElementType.Class);
      SqlBinary = (Struct)GetDataTypeNodeFor("System.Data.SqlTypes", "SqlBinary", ElementType.ValueType);
      SqlBoolean = (Struct)GetDataTypeNodeFor("System.Data.SqlTypes", "SqlBoolean", ElementType.ValueType);
      SqlByte = (Struct)GetDataTypeNodeFor("System.Data.SqlTypes", "SqlByte", ElementType.ValueType);
      SqlDateTime = (Struct)GetDataTypeNodeFor("System.Data.SqlTypes", "SqlDateTime", ElementType.ValueType);
      SqlDecimal = (Struct)GetDataTypeNodeFor("System.Data.SqlTypes", "SqlDecimal", ElementType.ValueType);
      SqlDouble = (Struct)GetDataTypeNodeFor("System.Data.SqlTypes", "SqlDouble", ElementType.ValueType);
      SqlGuid = (Struct)GetDataTypeNodeFor("System.Data.SqlTypes", "SqlGuid", ElementType.ValueType);
      SqlInt16 = (Struct)GetDataTypeNodeFor("System.Data.SqlTypes", "SqlInt16", ElementType.ValueType);
      SqlInt32 = (Struct)GetDataTypeNodeFor("System.Data.SqlTypes", "SqlInt32", ElementType.ValueType);
      SqlInt64 = (Struct)GetDataTypeNodeFor("System.Data.SqlTypes", "SqlInt64", ElementType.ValueType);
      SqlMoney = (Struct)GetDataTypeNodeFor("System.Data.SqlTypes", "SqlMoney", ElementType.ValueType);
      SqlSingle = (Struct)GetDataTypeNodeFor("System.Data.SqlTypes", "SqlSingle", ElementType.ValueType);
      SqlString = (Struct)GetDataTypeNodeFor("System.Data.SqlTypes", "SqlString", ElementType.ValueType);
      IDbConnection = (Interface)GetDataTypeNodeFor("System.Data", "IDbConnection", ElementType.Class);
      IDbTransaction = (Interface)GetDataTypeNodeFor("System.Data", "IDbTransaction", ElementType.Class);
      IsolationLevel = GetDataTypeNodeFor("System.Data", "IsolationLevel", ElementType.ValueType) as EnumNode;
#endif
#if CCINamespace
      const string CciNs = "Microsoft.Cci";
      const string ContractsNs = "Microsoft.Contracts";
      const string CompilerGuardsNs = "Microsoft.Contracts";
#else
      const string CciNs = "System.Compiler";
      const string ContractsNs = "Microsoft.Contracts";
      const string CompilerGuardsNs = "Microsoft.Contracts";
#endif
      const string GuardsNs = "Microsoft.Contracts";
      AnonymousAttribute = (Class)GetCompilerRuntimeTypeNodeFor(CciNs, "AnonymousAttribute", ElementType.Class);
      AnonymityEnum = GetCompilerRuntimeTypeNodeFor(CciNs, "Anonymity", ElementType.ValueType);
      ComposerAttribute = (Class)GetCompilerRuntimeTypeNodeFor(CciNs, "ComposerAttribute", ElementType.Class);
      CustomVisitorAttribute = (Class)GetCompilerRuntimeTypeNodeFor(CciNs, "CustomVisitorAttribute", ElementType.Class);
      TemplateAttribute = (Class)GetCompilerRuntimeTypeNodeFor(CciNs, "TemplateAttribute", ElementType.Class);
      TemplateInstanceAttribute = (Class)GetCompilerRuntimeTypeNodeFor(CciNs, "TemplateInstanceAttribute", ElementType.Class);
      UnmanagedStructTemplateParameterAttribute = (Class)GetCompilerRuntimeTypeNodeFor(CciNs, "UnmanagedStructTemplateParameterAttribute", ElementType.Class);
      TemplateParameterFlagsAttribute = (Class)GetCompilerRuntimeTypeNodeFor(CciNs, "TemplateParameterFlagsAttribute", ElementType.Class);
#if !WHIDBEYwithGenerics
      GenericArrayToIEnumerableAdapter = (Class)GetCompilerRuntimeTypeNodeFor("StructuralTypes", "ArrayToIEnumerableAdapter", 1, ElementType.Class);
#endif
      GenericBoxed = (Struct)GetCompilerRuntimeTypeNodeFor("StructuralTypes", "Boxed", 1, ElementType.ValueType);
      GenericIEnumerableToGenericIListAdapter = (Class)GetCompilerRuntimeTypeNodeFor("StructuralTypes", "GenericIEnumerableToGenericIListAdapter", 1, ElementType.Class);
      GenericInvariant = (Struct)GetCompilerRuntimeTypeNodeFor("StructuralTypes", "Invariant", 1, ElementType.ValueType);
      GenericNonEmptyIEnumerable = (Struct)GetCompilerRuntimeTypeNodeFor("StructuralTypes", "NonEmptyIEnumerable", 1, ElementType.ValueType);
      GenericNonNull = (Struct)GetCompilerRuntimeTypeNodeFor("StructuralTypes", "NonNull", 1, ElementType.ValueType);
      GenericStreamUtility = (Class)GetCompilerRuntimeTypeNodeFor("StructuralTypes", "StreamUtility", 1, ElementType.Class);
      GenericUnboxer = (Class)GetCompilerRuntimeTypeNodeFor("StructuralTypes", "Unboxer", 1, ElementType.Class);
      ElementTypeAttribute = (Class)GetCompilerRuntimeTypeNodeFor(CciNs, "ElementTypeAttribute", ElementType.Class);
      IDbTransactable = (Interface)GetCompilerRuntimeTypeNodeFor("System.Data", "IDbTransactable", ElementType.Class);
      IAggregate = (Interface)GetCompilerRuntimeTypeNodeFor("System.Query", "IAggregate", ElementType.Class);
      IAggregateGroup = (Interface)GetCompilerRuntimeTypeNodeFor("System.Query", "IAggregateGroup", ElementType.Class);
      StreamNotSingletonException = (Class)GetCompilerRuntimeTypeNodeFor("System.Query", "StreamNotSingletonException", ElementType.Class);
      SqlHint = GetCompilerRuntimeTypeNodeFor("System.Query", "SqlHint", ElementType.ValueType) as EnumNode;
      SqlFunctions = (Class)GetCompilerRuntimeTypeNodeFor("System.Query", "SqlFunctions", ElementType.Class);

      #region Contracts
      Range = (Class)GetCompilerRuntimeTypeNodeFor(ContractsNs, "Range", ElementType.Class);
      //Ordinary Exceptions
      NoChoiceException = (Class)GetCompilerRuntimeTypeNodeFor(ContractsNs, "NoChoiceException", ElementType.Class);
      IllegalUpcastException = (Class)GetCompilerRuntimeTypeNodeFor(ContractsNs, "IllegalUpcastException", ElementType.Class);
      CciMemberKind = (EnumNode)GetCompilerRuntimeTypeNodeFor(CciNs, "CciMemberKind", ElementType.ValueType);
      CciMemberKindAttribute = (Class)GetCompilerRuntimeTypeNodeFor(CciNs, "CciMemberKindAttribute", ElementType.Class);
      //Checked Exceptions
      ICheckedException = (Interface)GetCompilerRuntimeTypeNodeFor(ContractsNs, "ICheckedException", ElementType.Class);
      CheckedException = (Class)GetCompilerRuntimeTypeNodeFor(ContractsNs, "CheckedException", ElementType.Class);
      ContractMarkers = (Class)GetCompilerRuntimeTypeNodeFor(ContractsNs, "ContractMarkers", ElementType.Class);
      //Invariant
      InitGuardSetsDelegate = (DelegateNode) GetCompilerRuntimeTypeNodeFor(GuardsNs, "InitGuardSetsDelegate", ElementType.Class);
      CheckInvariantDelegate = (DelegateNode) GetCompilerRuntimeTypeNodeFor(GuardsNs, "CheckInvariantDelegate", ElementType.Class);
      FrameGuardGetter = (DelegateNode) GetCompilerRuntimeTypeNodeFor(GuardsNs, "FrameGuardGetter", ElementType.Class);
      ObjectInvariantException = (Class)GetCompilerRuntimeTypeNodeFor("Microsoft.Contracts", "ObjectInvariantException", ElementType.Class);
      ThreadConditionDelegate = (DelegateNode) GetCompilerRuntimeTypeNodeFor(GuardsNs, "ThreadConditionDelegate", ElementType.Class);
      GuardThreadStart = (DelegateNode) GetCompilerRuntimeTypeNodeFor(GuardsNs, "GuardThreadStart", ElementType.Class);
      Guard = (Class) GetCompilerRuntimeTypeNodeFor(GuardsNs, "Guard", ElementType.Class);
      ThreadStart = (DelegateNode) GetTypeNodeFor("System.Threading", "ThreadStart", ElementType.Class);
      AssertHelpers = (Class)GetCompilerRuntimeTypeNodeFor(ContractsNs, "AssertHelpers", ElementType.Class);
      #region Exceptions
      UnreachableException = (Class)GetCompilerRuntimeTypeNodeFor(ContractsNs, "UnreachableException", ElementType.Class);
      ContractException = (Class)GetCompilerRuntimeTypeNodeFor(ContractsNs, "ContractException", ElementType.Class);
      NullTypeException = (Class)GetCompilerRuntimeTypeNodeFor(ContractsNs, "NullTypeException", ElementType.Class);
      AssertException = (Class)GetCompilerRuntimeTypeNodeFor(ContractsNs, "AssertException", ElementType.Class);
      AssumeException = (Class)GetCompilerRuntimeTypeNodeFor(ContractsNs, "AssumeException", ElementType.Class);
      InvalidContractException = (Class)GetCompilerRuntimeTypeNodeFor(ContractsNs, "InvalidContractException", ElementType.Class);
      RequiresException = (Class)GetCompilerRuntimeTypeNodeFor(ContractsNs, "RequiresException", ElementType.Class);
      EnsuresException = (Class)GetCompilerRuntimeTypeNodeFor(ContractsNs, "EnsuresException", ElementType.Class);
      ModifiesException = (Class)GetCompilerRuntimeTypeNodeFor(ContractsNs, "ModifiesException", ElementType.Class);
      ThrowsException = (Class)GetCompilerRuntimeTypeNodeFor(ContractsNs, "ThrowsException", ElementType.Class);
      DoesException = (Class)GetCompilerRuntimeTypeNodeFor(ContractsNs, "DoesException", ElementType.Class);
      InvariantException = (Class)GetCompilerRuntimeTypeNodeFor(ContractsNs, "InvariantException", ElementType.Class);
      ContractMarkerException = (Class)GetCompilerRuntimeTypeNodeFor(ContractsNs, "ContractMarkerException", ElementType.Class);
      PreAllocatedExceptions = (Class)GetCompilerRuntimeTypeNodeFor(ContractsNs, "PreAllocatedExceptions", ElementType.Class);
      #endregion
      #region Attributes
      AdditiveAttribute = (Class)GetCompilerRuntimeTypeNodeFor(ContractsNs, "AdditiveAttribute", ElementType.Class);
      InsideAttribute = (Class)GetCompilerRuntimeTypeNodeFor(ContractsNs, "InsideAttribute", ElementType.Class);
      PureAttribute = (Class)GetCompilerRuntimeTypeNodeFor(ContractsNs, "PureAttribute", ElementType.Class);
      ConfinedAttribute = (Class)GetCompilerRuntimeTypeNodeFor(CompilerGuardsNs, "ConfinedAttribute", ElementType.Class);

      #region modelfield attributes and exceptions
      ModelfieldContractAttribute = (Class)GetCompilerRuntimeTypeNodeFor(ContractsNs, "ModelfieldContractAttribute", ElementType.Class);
      ModelfieldAttribute = (Class)GetCompilerRuntimeTypeNodeFor(ContractsNs, "ModelfieldAttribute", ElementType.Class);
      SatisfiesAttribute = (Class)GetCompilerRuntimeTypeNodeFor(ContractsNs, "SatisfiesAttribute", ElementType.Class);
      ModelfieldException = (Class)GetCompilerRuntimeTypeNodeFor("Microsoft.Contracts", "ModelfieldException", ElementType.Class);
      #endregion

      /* Diego's Attributes for Purity and WriteEffects */
        OnceAttribute = (Class)GetCompilerRuntimeTypeNodeFor(CompilerGuardsNs, "OnceAttribute", ElementType.Class);
        WriteConfinedAttribute = (Class)GetCompilerRuntimeTypeNodeFor(CompilerGuardsNs, "WriteConfinedAttribute", ElementType.Class);
        WriteAttribute = (Class)GetCompilerRuntimeTypeNodeFor(CompilerGuardsNs, "WriteAttribute", ElementType.Class);
        ReadAttribute = (Class)GetCompilerRuntimeTypeNodeFor(CompilerGuardsNs, "ReadAttribute", ElementType.Class);
        GlobalReadAttribute = (Class)GetCompilerRuntimeTypeNodeFor(CompilerGuardsNs, "GlobalReadAttribute", ElementType.Class);
        GlobalWriteAttribute = (Class)GetCompilerRuntimeTypeNodeFor(CompilerGuardsNs, "GlobalWriteAttribute", ElementType.Class);
        GlobalAccessAttribute = (Class)GetCompilerRuntimeTypeNodeFor(CompilerGuardsNs, "GlobalAccessAttribute", ElementType.Class);
        FreshAttribute = (Class)GetCompilerRuntimeTypeNodeFor(CompilerGuardsNs, "FreshAttribute", ElementType.Class);
        EscapesAttribute = (Class)GetCompilerRuntimeTypeNodeFor(CompilerGuardsNs, "EscapesAttribute", ElementType.Class);
        /*  */

      StateIndependentAttribute = (Class)GetCompilerRuntimeTypeNodeFor(ContractsNs, "StateIndependentAttribute", ElementType.Class);
      SpecPublicAttribute = (Class)GetCompilerRuntimeTypeNodeFor(ContractsNs, "SpecPublicAttribute", ElementType.Class);
      SpecProtectedAttribute = (Class)GetCompilerRuntimeTypeNodeFor(ContractsNs, "SpecProtectedAttribute", ElementType.Class);
      SpecInternalAttribute = (Class)GetCompilerRuntimeTypeNodeFor(ContractsNs, "SpecInternalAttribute", ElementType.Class);

      OwnedAttribute = (Class)GetCompilerRuntimeTypeNodeFor(CompilerGuardsNs, "OwnedAttribute", ElementType.Class);
      RepAttribute = (Class)GetCompilerRuntimeTypeNodeFor(CompilerGuardsNs, "RepAttribute", ElementType.Class);
      PeerAttribute = (Class)GetCompilerRuntimeTypeNodeFor(CompilerGuardsNs, "PeerAttribute", ElementType.Class);
      CapturedAttribute = (Class)GetCompilerRuntimeTypeNodeFor(CompilerGuardsNs, "CapturedAttribute", ElementType.Class);
      LockProtectedAttribute = (Class)GetCompilerRuntimeTypeNodeFor(CompilerGuardsNs, "LockProtectedAttribute", ElementType.Class);
      RequiresLockProtectedAttribute = (Class)GetCompilerRuntimeTypeNodeFor(CompilerGuardsNs, "RequiresLockProtectedAttribute", ElementType.Class);
      ImmutableAttribute = (Class)GetCompilerRuntimeTypeNodeFor(CompilerGuardsNs, "ImmutableAttribute", ElementType.Class);
      RequiresImmutableAttribute = (Class)GetCompilerRuntimeTypeNodeFor(CompilerGuardsNs, "RequiresImmutableAttribute", ElementType.Class);
      RequiresCanWriteAttribute = (Class)GetCompilerRuntimeTypeNodeFor(CompilerGuardsNs, "RequiresCanWriteAttribute", ElementType.Class);

      ModelAttribute = (Class)GetCompilerRuntimeTypeNodeFor(ContractsNs, "ModelAttribute", ElementType.Class);
      RequiresAttribute = (Class)GetCompilerRuntimeTypeNodeFor(ContractsNs, "RequiresAttribute", ElementType.Class);
      EnsuresAttribute = (Class)GetCompilerRuntimeTypeNodeFor(ContractsNs, "EnsuresAttribute", ElementType.Class);
      ModifiesAttribute = (Class)GetCompilerRuntimeTypeNodeFor(ContractsNs, "ModifiesAttribute", ElementType.Class);
      HasWitnessAttribute = (Class)GetCompilerRuntimeTypeNodeFor(ContractsNs, "HasWitnessAttribute", ElementType.Class);
      WitnessAttribute = (Class)GetCompilerRuntimeTypeNodeFor(ContractsNs, "WitnessAttribute", ElementType.Class);
      InferredReturnValueAttribute = (Class)GetCompilerRuntimeTypeNodeFor(ContractsNs, "InferredReturnValueAttribute", ElementType.Class);
      ThrowsAttribute = (Class)GetCompilerRuntimeTypeNodeFor(ContractsNs, "ThrowsAttribute", ElementType.Class);
      DoesAttribute = (Class)GetCompilerRuntimeTypeNodeFor(ContractsNs, "DoesAttribute", ElementType.Class);
      InvariantAttribute = (Class)GetCompilerRuntimeTypeNodeFor(ContractsNs, "InvariantAttribute", ElementType.Class);
      NoDefaultActivityAttribute = (Class)GetCompilerRuntimeTypeNodeFor(CompilerGuardsNs, "NoDefaultActivityAttribute", ElementType.Class);
      NoDefaultContractAttribute = (Class)GetCompilerRuntimeTypeNodeFor(CompilerGuardsNs, "NoDefaultContractAttribute", ElementType.Class);
      ReaderAttribute = (Class)GetCompilerRuntimeTypeNodeFor(CompilerGuardsNs, "ReaderAttribute", ElementType.Class);

      ShadowsAssemblyAttribute = (Class)GetCompilerRuntimeTypeNodeFor(ContractsNs, "ShadowsAssemblyAttribute", ElementType.Class);
      VerifyAttribute = (Class)GetCompilerRuntimeTypeNodeFor(ContractsNs, "VerifyAttribute", ElementType.Class);
      DependentAttribute = (Class)GetCompilerRuntimeTypeNodeFor(ContractsNs, "DependentAttribute", ElementType.Class);
      ElementsRepAttribute = (Class)GetCompilerRuntimeTypeNodeFor(ContractsNs, "ElementsRepAttribute", ElementType.Class);
      ElementsPeerAttribute = (Class)GetCompilerRuntimeTypeNodeFor(ContractsNs, "ElementsPeerAttribute", ElementType.Class);
      ElementAttribute = (Class)GetCompilerRuntimeTypeNodeFor(ContractsNs, "ElementAttribute", ElementType.Class);
      ElementCollectionAttribute = (Class)GetCompilerRuntimeTypeNodeFor(ContractsNs, "ElementCollectionAttribute", ElementType.Class);
      RecursionTerminationAttribute = (Class)GetCompilerRuntimeTypeNodeFor(ContractsNs, "RecursionTerminationAttribute", ElementType.Class);
      NoReferenceComparisonAttribute = (Class)GetCompilerRuntimeTypeNodeFor(ContractsNs, "NoReferenceComparisonAttribute", ElementType.Class);
      ResultNotNewlyAllocatedAttribute = (Class)GetCompilerRuntimeTypeNodeFor(ContractsNs, "ResultNotNewlyAllocatedAttribute", ElementType.Class);
#endregion
      #endregion
#endif
      SystemTypes.Initialized = true;
      object dummy = TargetPlatform.AssemblyReferenceFor; //Force selection of target platform
      if (dummy == null) return;
    }