Esempio n. 1
0
        public static Assignment Parse(ref string input, Namespace ns)
        {
            var orgInput = input;

            var ident = Identifier.Parse(ref input);
            if (ident == null)
                return null;

            Whitespace.Parse(ref input);

            if (input[0] != '=')
                return null;
            input = input.Substring(1);

            Whitespace.Parse(ref input);

            var expr = Expression.Parse(ref input, ns);

            if (ident.Value.Contains("."))
            {
                input = orgInput;
                return null;
            }

            var id = ns.GetScope().Add(ident.Value, expr.ReturnType);
            return new Assignment(ident, expr, id);
        }
Esempio n. 2
0
        public void Process(Namespace @namespace, bool filterNamespaces = false)
        {
            TranslationUnit = @namespace.TranslationUnit;

            var collector = new RecordCollector(TranslationUnit);
            @namespace.Visit(collector);

            foreach (var record in collector.Declarations)
            {
                if (record.Value is Namespace)
                    continue;

                if (record.Value.IsDependent)
                    continue;

                if (filterNamespaces)
                {
                    var declNamespace = GetEffectiveNamespace(record.Value);

                    var isSameNamespace = declNamespace == @namespace;
                    if (declNamespace != null)
                        isSameNamespace |= declNamespace.QualifiedName == @namespace.QualifiedName;

                    if (!isSameNamespace)
                        continue;
                }

                record.Value.Visit(this);
                GenerateInclude(record);
            }
        }
Esempio n. 3
0
 public ConstantInfo(object value, ProjectState projectState)
     : base((BuiltinClassInfo)projectState.GetNamespaceFromObjects(DynamicHelpers.GetPythonType(value)))
 {
     _value = value;
     _type = DynamicHelpers.GetPythonType(value);
     _builtinInfo = ((BuiltinClassInfo)projectState.GetNamespaceFromObjects(_type)).Instance;
 }
 public Service CreateServiceAndLogin(Namespace ns = null)
 {
     var service = new Service(Config.Scheme, Config.Host, Config.Port, ns);
     var task = service.LogOnAsync(Config.Username, Config.Password);
     task.Wait();
     return service;
 }
        private static void GenerateSymbols(Namespace n, StringBuilder sb, string indent2)
        {
            foreach (Symbol s in n.Symbols)
            {
                if (s.Section <= 0) { continue; }

                string name = s.Demangled;
                if (s.Namespace.Length > 0)
                {
                    string namespacetext = string.Join("::", s.Namespace) + "::";
                    name = name.Replace(namespacetext, "");
                }
                name = name.Replace("__thiscall ", "");
                name = name.Replace("__cdecl ", "");

                // C functions
                if (s.Demangled == s.Name && s.DataType == IMAGE_SYM_DTYPE.IMAGE_SYM_DTYPE_FUNCTION)
                {
                    name = name + "()";
                }

                sb.Append(indent2);
                sb.AppendFormat("{0};\n", name);
            }
        }
Esempio n. 6
0
        public Dictionary<string, string> GenerateComponent(Namespace ns, List<Wire> wires, List<string> modules)
        {
            Dictionary<string, string> properties = new Dictionary<string, string>();
            foreach (Component component in ns.Declarations.OfType<Component>())
            {
                modules.Add(component.Name);
                ComponentType cType = ComponentType.IMPLEMENTATION;

                Dictionary<Reference, Component> dependencyMap = this.dependencyDiscoverer.GetherDependencyMap(ns, wires, component);

                List<string> dependencies = this.dependencyDiscoverer.GetherDependencies(dependencyMap);

                bool directDataAccess = this.dataAccessFinder.HasAnyDirectDataAccess(ns, wires, component);

                if (component.Services.Any())
                {
                    this.GenerateServiceImplementations(ns, modules, wires, component, dependencies, dependencyMap);
                }
                else
                {
                    if (component.Implementation != null && component.Implementation.Name.Equals("JSF"))
                    {
                        cType = ComponentType.WEB;
                        this.jSFGenerator.GenerateWebTier(ns, component, directDataAccess);
                    }
                    if (component is Composite)
                    {
                        string facadeDir = this.directoryHandler.createJavaDirectory(ns, component.Name, generatorUtil.Properties.serviceFacadePackage);
                        string facadeFile = Path.Combine(facadeDir, component.Name + "Facade.java");
                        using (StreamWriter writer = new StreamWriter(facadeFile))
                        {
                            writer.WriteLine(this.springClassGen.GenerateComponent(component));
                        }
                    }
                }
                BindingTypeHolder clientFor = new BindingTypeHolder();
                if (component.References.Any())
                {
                    clientFor = this.GenerateReferenceAccessors(ns, component, directDataAccess, dependencyMap, properties);
                }

                // generate pom.xml and spring-config.xml of Business Logic module
                this.directoryHandler.createJavaDirectory(ns, component.Name, "");
                string fileName = Path.Combine(ns.Name + "-" + component.Name, "pom.xml");
                using (StreamWriter writer = new StreamWriter(fileName))
                {
                    string s = this.springConfigGen.GenerateComponentPom(ns, component, dependencies,
                        clientFor.HasRestBinding, clientFor.HasWebServiceBinding, clientFor.HasWebSocketBinding, cType);
                    writer.WriteLine(s);
                }

                string javaDir = this.directoryHandler.createJavaDirectory(ns, component.Name, "", false);
                fileName = Path.Combine(javaDir, "spring-config.xml");
                using (StreamWriter writer = new StreamWriter(fileName))
                {
                    writer.WriteLine(this.springConfigGen.GenerateComponentSpringConfig(ns));
                }
            }
            return properties;
        }
Esempio n. 7
0
 public Dictionary<Reference, Component> GetherDependencyMap(Namespace ns, List<Wire> wires, Component component)
 {
     Dictionary<Reference, Component> dependencies = new Dictionary<Reference, Component>();
     foreach (Reference reference in component.References)
     {
         bool referenceStatisfied = false;
         foreach (Wire wire in wires)
         {
             if (wire.Source.Equals(reference))
             {
                 Component comp = wire.Target.Component;
                 Service target = wire.Target as Service;
                 if (target != null)
                 {
                     referenceStatisfied = true;
                     PutDependecy(dependencies, reference, target, comp);
                 }
             }
         }
         if (!referenceStatisfied)
         {
             foreach (Component comp in ns.Declarations.OfType<Component>())
             {
                 foreach (Service serv in comp.Services)
                 {
                     if (serv.Interface.Equals(reference.Interface))
                     {
                         PutDependecy(dependencies, reference, serv, comp);
                     }
                 }
             }
         }
     }
     return dependencies;
 }
Esempio n. 8
0
        // Generates a codedom namespace and attaches it to the compile unit (the root of the tree)
        public static void Emit(CodeCompileUnit codeCompileUnit, Namespace ns)
        {
            // Create the codedom namespace expression
            var codeNamespace = new CodeNamespace();

            // Assign the namespace name.
            codeNamespace.Name = ns.GetFullName();

            // Attach it to the root of the codedom tree.
            codeCompileUnit.Namespaces.Add(codeNamespace);

            // Create and attach the children of the namespace: classes, delegates, other namespaces, etc.
            foreach (var e in ns.ChildExpressions)
            {
                if (e is Namespace)
                    Emit(codeCompileUnit, (Namespace)e);
                if (e is Class)
                    ClassEmitter.Emit(codeNamespace, (Class)e);
                if (e is Import)
                {
                    var i = e as Import;
                    if (i.IsType) // Are we importing a class, enum, interface, struct, module?
                        codeNamespace.Imports.Add(new CodeNamespaceImport((e as Import).GetNamespace()));
                    else
                        codeNamespace.Imports.Add(new CodeNamespaceImport((e as Import).Name));
                }
                if (e is Pie.Expressions.Enum)
                    EnumEmitter.Emit(codeNamespace, e as Pie.Expressions.Enum);
                if (e is DelegateDeclaration)
                    DelegateEmitter.Emit(codeNamespace, e as DelegateDeclaration);
                if (e is Interface)
                    InterfaceEmitter.Emit(codeNamespace, e as Interface);
            }
        }
Esempio n. 9
0
        private bool CheckDirectDataAccess(Namespace ns, List<Wire> wires, string dataModule, Reference reference, Service serv)
        {
            Component comp = serv.Component;
            bool hasDirectDataAccess = false;
            List<Binding> bindings = new List<Binding>();
            if (serv.Binding != null)
                bindings.Add(serv.Binding);
            if (reference.Binding != null)
                bindings.Add(reference.Binding);
            BindingTypeHolder binding = bindingGenerator.CheckForBindings(bindings);

            if (!binding.hasAnyBinding())
            {
                // direct access
                if (comp.Name == dataModule || dataModule == ANY && serv.Interface is Database)
                {
                    hasDirectDataAccess = true;
                }
                else
                {
                    // need to check
                    hasDirectDataAccess = HasDirectDataAccess(ns, wires, comp, dataModule);
                }
            }

            return hasDirectDataAccess;
        }
Esempio n. 10
0
        public void TestClassFullName()
        {
            Namespace n = new Namespace(null, null);
            n.Name = "foo";

            Class c = new Class(null, null);
            c.UnqualifiedName = "bar";
            Console.WriteLine(c.GetQualifiedName());
            Assert.AreEqual("foo", n.Name, "namespace name1");
            Assert.AreEqual("foo", n.GetFullName(), "namespace full name1");
            Assert.AreEqual("bar", c.UnqualifiedName, "class name1");
            Assert.AreEqual("bar", c.GetQualifiedName(), "class full name1");

            c.ParentExpression = n;
            Assert.AreEqual("foo", n.Name, "namespace name2");
            Assert.AreEqual("foo", n.GetFullName(), "namespace full name2");
            Assert.AreEqual("bar", c.UnqualifiedName, "class name2");
            Assert.AreEqual("foo.bar", c.GetQualifiedName(), "class full name2");

            c.ParentExpression = new Expression(null, null);
            Assert.AreEqual("foo", n.Name, "namespace name3");
            Assert.AreEqual("foo", n.GetFullName(), "namespace full name3");
            Assert.AreEqual("bar", c.UnqualifiedName, "class name3");
            Assert.AreEqual("bar", c.GetQualifiedName(), "class full name3");
        }
Esempio n. 11
0
        public static IExpression Parse(ref string input, Namespace ns)
        {
            var orgInput = input;

            var literal = Literal.Parse(ref input);
            if (literal != null)
                return literal;

            input = orgInput;
            var method = MethodCall.Parse(ref input, ns);
            if (method != null)
                return method;

            input = orgInput;
            var assignment = Assignment.Parse(ref input, ns);
            if (assignment != null)
            {
                assignment.ExprMode = true;
                return assignment;
            }

            input = orgInput;
            var variable = Variable.Parse(ref input, ns);
            if (variable != null)
                return variable;

            input = orgInput;
            return null;
        }
        public Service Connect(Namespace ns)
        {
            var service = new Service(Scheme.Https, this.command.Host, this.command.Port, ns);
            service.LoginAsync(this.command.Username, this.command.Password).Wait();

            return service;
        }
Esempio n. 13
0
        private static void SortDeclarations(Namespace @namespace)
        {
            @namespace.Declarations = @namespace.Declarations.OrderBy(
                declaration => declaration.DefinitionOrder).ToList();

            foreach (var childNamespace in @namespace.Namespaces)
                SortDeclarations(childNamespace);
        }
Esempio n. 14
0
        private static void SortDeclarations(Namespace @namespace)
        {
            @namespace.Classes.Sort((c, c1) =>
                                    (int)(c.DefinitionOrder - c1.DefinitionOrder));

            foreach (var childNamespace in @namespace.Namespaces)
                SortDeclarations(childNamespace);
        }
Esempio n. 15
0
        // Build a namespace expression
        public static void BuildNamespace(IronyParser parser, Root root, Expression parentExpression, ParseTreeNode currentNode)
        {
            Namespace n = new Namespace(parentExpression, currentNode.FindToken().Convert());
            n.Name = currentNode.ChildNodes[1].FindTokenAndGetText();
            parentExpression.ChildExpressions.Add(n);

            parser.ConsumeParseTree(root, n, currentNode.ChildNodes[2]);
        }
Esempio n. 16
0
        public static Variable Parse(ref string input, Namespace ns)
        {
            var ident = Identifier.Parse(ref input);
            if (ident == null)
                return null;

            return ns.GetScope().Get(ident.Value);
        }
Esempio n. 17
0
 public static Results GetLatestResults(String ipHost, Namespace nameSpace)
 {
     if (!latest_results.ContainsKey(nameSpace))
         latest_results[nameSpace] = new Dictionary<String, ResultsCounter>();
     if (!latest_results[nameSpace].ContainsKey(ipHost))
         latest_results[nameSpace].Add(ipHost, new ResultsCounter());
     return latest_results[nameSpace][ipHost].Results;
 }
Esempio n. 18
0
	static string GetNamespace (Namespace ns)
	{
		switch (ns) {
		case Namespace.System_Windows_Media: return "System.Windows.Media";
		case Namespace.System_Windows_Media_Animation: return "System.Windows.Media.Animation";
		default: throw new Exception ();
		}
	}
 public RootNamespace(Namespace parent, string name)
     : this(
         parent,
         (parent is GlobalRootNamespace
              ? new MemberName(name)
              : new MemberName(parent.MemberName, Separators.Dot, name)))
 {
     parent.AddNamespace(this);
 }
Esempio n. 20
0
        /// <summary>
        /// Create a Splunk <see cref="Service" /> and login using the settings
        /// provided in .splunkrc.
        /// </summary>
        /// <param name="ns">
        /// </param>
        /// <returns>
        /// The service created.
        /// </returns>
        public static async Task<Service> CreateService(Namespace ns = null)
        {
            var context = new MockContext(Splunk.Scheme, Splunk.Host, Splunk.Port);
            var service = new Service(context, ns);
            
            await service.LogOnAsync(Splunk.Username, Splunk.Password);

            return service;
        }
Esempio n. 21
0
        /// <summary>
        /// Initializes a new instance of the <see cref="Service"/> class.
        /// </summary>
        /// <param name="context">
        /// The context for requests by the new <see cref="Service"/>.
        /// </param>
        /// <param name="namespace">
        /// The namespace for requests by the new <see cref="Service"/>. The
        /// default value is <c>null</c> indicating that <see cref=
        /// "Namespace.Default"/> should be used.
        /// </param>
        /// <exception cref="ArgumentNullException">
        /// <see cref="context"/> is <c>null</c>.
        /// </exception>
        public Service(Context context, Namespace @namespace = null)
        {
            Contract.Requires<ArgumentNullException>(context != null, "context");

            this.context = context;
            this.@namespace = @namespace ?? Namespace.Default;
            this.receiver = new Receiver(context, this.Namespace);
            this.server = new Server(context, this.Namespace);
        }
Esempio n. 22
0
        /// <summary>
        /// Immutable multiname object.
        /// </summary>
        /// <param name="kind">The kind of multiname</param>
        /// <param name="name">The multiname name</param>
        /// <param name="ns">Optional namespace, dependant on kind. See AVM2 spec</param>
        /// <param name="set">Optional namespace set, dependant on kind. See AVM2 spec</param>
        internal Multiname(MultinameKind kind, string name, Namespace ns, NamespaceSet set)
        {
            this.Kind = kind;
            this.Name = name;
            this.NS = ns;
            this.Set = set;

            /* Sanity checking... */

            switch (kind)
            {
                case MultinameKind.QName:
                case MultinameKind.QNameA:
                    if (ns == null)
                    {
                        throw new SWFModellerException(
                                SWFModellerError.Internal,
                                "A " + kind.ToString() + " requires a namespace");
                    }

                    break;

                case MultinameKind.RTQName:
                case MultinameKind.RTQNameA:
                    break;

                case MultinameKind.RTQNameL:
                case MultinameKind.RTQNameLA:
                    break;

                case MultinameKind.Multiname:
                case MultinameKind.MultinameA:
                    if (set == null)
                    {
                        throw new SWFModellerException(
                                SWFModellerError.Internal,
                                "A " + kind.ToString() + " requires a namespace set");
                    }

                    break;

                case MultinameKind.MultinameL:
                case MultinameKind.MultinameLA:
                    if (set == null)
                    {
                        throw new SWFModellerException(
                                SWFModellerError.Internal,
                                "A " + kind.ToString() + " requires a namespace set");
                    }

                    break;

                default:
                    break;
            }
        }
Esempio n. 23
0
 internal static SpecializedNamespace MakeSpecializedCallable(Func<CallExpression, AnalysisUnit, INamespaceSet[], NameExpression[], INamespaceSet> dlg, bool analyze, Namespace v)
 {
     SpecializedNamespace special;
     if (analyze) {
         special = new SpecializedCallable(v, dlg);
     } else {
         special = new SpecializedCallableNoAnalyze(v, dlg);
     }
     return special;
 }
Esempio n. 24
0
        public void Create_Namespace_Long()
        {
            var @namespace = new Namespace("Create.Namespace.Long");

            var expectet = Comparer.Create_Namespace_Long();
            var actual = @namespace.ToString();

            Assert.AreEqual(expectet, actual);
            Console.WriteLine(actual);
        }
Esempio n. 25
0
 protected DeclaredType FindType( Namespace ns, IDocumentationMember association )
 {
     DeclaredType dt = null;
     try
     {
         var typeName = Identifier.FromType( association.TargetType );
         dt = ns.Types.FirstOrDefault( x => x.IsIdentifiedBy( typeName ) );
     }
     catch( Exception ) { }
     return dt;
 }
Esempio n. 26
0
 public void Bind(Symbol id, Namespace nspace, ILocation<Object> location)
 {
     switch (nspace)
     {
         case Namespace.Variable:
             variables.Add(id, location);
             break;
         default:
             throw new NotImplementedException ();
     }
 }
Esempio n. 27
0
        public void Create_Using_With_Given_Namespace()
        {
            var @namespace = new Namespace("BITS.Compilers.CSharp.Test");

            var @using = new Using(@namespace);

            var expectet = Comparer.Create_Using_With_Given_Namespace();
            var actual = @using.ToString();

            Assert.AreEqual(expectet, actual);
            Console.WriteLine(actual);
        }
Esempio n. 28
0
        public static void ClearResults(String ipHost, Namespace nameSpace)
        {
            lock(result_locker)
            {
                if (!latest_results.ContainsKey(nameSpace))
                    latest_results[nameSpace] = new Dictionary<String, ResultsCounter>();
                if (!latest_results[nameSpace].ContainsKey(ipHost))
                    latest_results[nameSpace].Add(ipHost, new ResultsCounter());

                latest_results[nameSpace][ipHost].Results = null; // results.Clear();
            }
        }
Esempio n. 29
0
        public void Create_Nested_Namespaces()
        {
            var @namespace = new Namespace("Create_Nested_Namespaces")
            {
                new Namespace("Nested_Create_Nested_Namespaces"),
            };

            var expectet = Comparer.Create_Nested_Namespaces();
            var actual = @namespace.ToString();
            Assert.AreEqual(expectet, actual);
            Console.WriteLine(actual);
        }
        /// <summary>
        /// Establishes and returns a namespace.
        /// </summary>
        public Namespace CreateNamespace(string username, string appname)
        {
            //Args splunkNamespace = new Args();

            //splunkNamespace.Add("owner", username);
            //splunkNamespace.Add("app", appname);

            //Service service = this.Connect();

            Namespace splunkNamespace = new Namespace(username, appname);
            return splunkNamespace;
        }
Esempio n. 31
0
        public override AstNode Visit(ClassDefinition node)
        {
            // Check the partial flag.
            bool isPartial = (node.GetFlags() & MemberFlags.ImplFlagMask) == MemberFlags.Partial;

            // Add the parent static flag.
            if (currentContainer.IsStatic())
            {
                MemberFlags oldInstance = node.GetFlags() & MemberFlags.InstanceMask;
                if (oldInstance == MemberFlags.Static || oldInstance == MemberFlags.Instanced)
                {
                    MemberFlags flags = node.GetFlags() & ~MemberFlags.InstanceMask;
                    node.SetFlags(flags | MemberFlags.Static);
                }
                else
                {
                    Error(node, "static class member cannot be {0}.", oldInstance.ToString().ToLower());
                }
            }

            // Static classes are automatically sealed.
            if ((node.GetFlags() & MemberFlags.InstanceMask) == MemberFlags.Static)
            {
                MemberFlags flags = node.GetFlags() & ~MemberFlags.InheritanceMask;
                node.SetFlags(flags | MemberFlags.Sealed);
            }

            // Parse the generic signature.
            GenericSignature genericSign = node.GetGenericSignature();
            GenericPrototype genProto    = GenericPrototype.Empty;
            PseudoScope      protoScope  = null;

            if (genericSign != null)
            {
                // Visit the generic signature.
                genericSign.Accept(this);

                // Connect the generic prototype.
                genProto = genericSign.GetPrototype();

                // Create the placeholders scope.
                protoScope = new PseudoScope(currentScope, genProto);
                node.SetGenericScope(protoScope);
            }

            // Prevent redefinition.
            ScopeMember old = currentContainer.FindType(node.GetName(), genProto);

            if (old != null && (!isPartial || !old.IsClass()))
            {
                Error(node, "trying to redefine a class.");
            }

            // Create the structure
            Class clazz = (Class)old;

            if (clazz != null)
            {
                if (!clazz.IsPartial())
                {
                    Error(node, "incompatible partial class definitions.");
                }
            }
            else
            {
                clazz          = new Class(node.GetName(), node.GetFlags(), currentContainer);
                clazz.Position = node.GetPosition();
                clazz.SetGenericPrototype(genProto);
            }
            node.SetStructure(clazz);

            // Use the prototype scope.
            if (protoScope != null)
            {
                PushScope(protoScope);
            }

            // Register type maps.
            string     fullName = clazz.GetFullName();
            IChelaType alias;

            if (typeMaps.TryGetValue(fullName, out alias))
            {
                currentModule.RegisterTypeMap(alias, clazz);
            }

            // Register type association.
            IChelaType assoc;

            if (assocClasses.TryGetValue(fullName, out assoc))
            {
                currentModule.RegisterAssociatedClass(assoc, clazz);
            }

            // Array base class is special.
            if (fullName == "Chela.Lang.Array")
            {
                currentModule.RegisterArrayClass(clazz);
            }
            else if (fullName == "Chela.Lang.Attribute")
            {
                currentModule.RegisterAttributeClass(clazz);
            }
            else if (fullName == "Chela.Lang.ValueType")
            {
                currentModule.RegisterValueTypeClass(clazz);
            }
            else if (fullName == "Chela.Lang.Enum")
            {
                currentModule.RegisterEnumClass(clazz);
            }
            else if (fullName == "Chela.Lang.Type")
            {
                currentModule.RegisterTypeClass(clazz);
            }
            else if (fullName == "Chela.Lang.Delegate")
            {
                currentModule.RegisterDelegateClass(clazz);
            }
            else if (fullName == "Chela.Compute.StreamHolder")
            {
                currentModule.RegisterStreamHolderClass(clazz);
            }
            else if (fullName == "Chela.Compute.StreamHolder1D")
            {
                currentModule.RegisterStreamHolder1DClass(clazz);
            }
            else if (fullName == "Chela.Compute.StreamHolder2D")
            {
                currentModule.RegisterStreamHolder2DClass(clazz);
            }
            else if (fullName == "Chela.Compute.StreamHolder3D")
            {
                currentModule.RegisterStreamHolder3DClass(clazz);
            }
            else if (fullName == "Chela.Compute.UniformHolder")
            {
                currentModule.RegisterUniformHolderClass(clazz);
            }

            // Add into the current scope.
            if (currentContainer.IsNamespace())
            {
                Namespace space = (Namespace)currentContainer;
                if (old == null)
                {
                    space.AddType(clazz);
                }
            }
            else if (currentContainer.IsStructure() || currentContainer.IsInterface() || currentContainer.IsClass())
            {
                Structure parent = (Structure)currentContainer;
                if (old == null)
                {
                    parent.AddType(clazz);
                }
            }
            else
            {
                Error(node, "unexpected place for a class.");
            }

            // Push the class unsafe.
            if (clazz.IsUnsafe())
            {
                PushUnsafe();
            }

            // Update the scope.
            PushScope(clazz);

            // Visit the building children.
            VisitList(node.GetChildren());

            // Restore the scope.
            PopScope();

            // Restore the scope.
            if (protoScope != null)
            {
                PopScope();
            }

            // Pop the class unsafe.
            if (clazz.IsUnsafe())
            {
                PopUnsafe();
            }

            return(node);
        }
Esempio n. 32
0
        public override AstNode Visit(NamespaceDefinition node)
        {
            // Handle nested names.
            string        fullname    = node.GetName();
            StringBuilder nameBuilder = new StringBuilder();

            int numscopes = 0;

            for (int i = 0; i < fullname.Length; i++)
            {
                char c = fullname[i];
                if (c != '.')
                {
                    nameBuilder.Append(c);
                    if (i + 1 < fullname.Length)
                    {
                        continue;
                    }
                }

                // Expect full name.
                if (c == '.' && i + 1 == fullname.Length)
                {
                    Error(node, "expected complete namespace name.");
                }

                // Find an already declared namespace.
                string name = nameBuilder.ToString();
                nameBuilder.Length = 0;
                ScopeMember old = currentContainer.FindMember(name);
                if (old != null)
                {
                    if (!old.IsNamespace())
                    {
                        Error(node, "defining namespace collides with another thing.");
                    }

                    // Store a reference in the node.
                    node.SetNamespace((Namespace)old);
                }
                else
                {
                    // Cast the current scope.
                    Namespace space = (Namespace)currentContainer;

                    // Create, name and add the new namespace.
                    Namespace newNamespace = new Namespace(space);
                    newNamespace.SetName(name);
                    space.AddMember(newNamespace);

                    // Store a reference in the node.
                    node.SetNamespace(newNamespace);
                }

                // Update the scope.
                PushScope(node.GetNamespace());

                // Increase the number of scopes.
                numscopes++;
            }

            // Visit the children.
            VisitList(node.GetChildren());

            // Restore the scopes.
            for (int i = 0; i < numscopes; i++)
            {
                PopScope();
            }

            return(node);
        }
Esempio n. 33
0
 public bool VisitNamespace(Namespace @namespace)
 {
     throw new System.NotImplementedException();
 }
Esempio n. 34
0
 string GetKey(Namespace ns)
 {
     return(GetExportName(ns) + ".g");
 }
Esempio n. 35
0
 public override void Populate(TextWriter trapFile)
 {
     trapFile.types(this, Kinds.TypeKind.ARGLIST, "__arglist");
     trapFile.parent_namespace(this, Namespace.Create(Context, Context.Compilation.GlobalNamespace));
     Modifier.HasModifier(Context, trapFile, this, "public");
 }
        public void Matching_Successful()
        {
            CodeRootMap map = new CodeRootMap();

            Class     cl  = new Class(controller, "Class1");
            Namespace ns1 = new Namespace(controller);

            ns1.Name = "ArchAngel.Tests";
            ns1.AddChild(cl);
            CodeRoot root = new CodeRoot(controller);

            root.AddChild(ns1);
            map.AddCodeRoot(root, Version.User);

            cl = new Class(controller, "Class1");
            Namespace ns2 = new Namespace(controller);

            ns2.Name = "Slyce.Tests";
            ns2.AddChild(cl);
            root = new CodeRoot(controller);
            root.AddChild(ns2);
            map.AddCodeRoot(root, Version.PrevGen);

            cl = new Class(controller, "Class1");
            Namespace ns3 = new Namespace(controller);

            ns3.Name = "Slyce.Tests";
            ns3.AddChild(cl);
            root = new CodeRoot(controller);
            root.AddChild(ns3);
            map.AddCodeRoot(root, Version.NewGen);

            map.MatchConstructs(map, ns1, ns3, ns2);

            foreach (CodeRootMapNode child in map.AllNodes)
            {
                Assert.That(child.PrevGenObj, Is.Not.Null,
                            string.Format("PrevGen in {0} is null", child.GetFirstValidBaseConstruct().ShortName));
                Assert.That(child.NewGenObj, Is.Not.Null,
                            string.Format("NewGen in {0} is null", child.GetFirstValidBaseConstruct().ShortName));
                Assert.That(child.UserObj, Is.Not.Null,
                            string.Format("User in {0} is null", child.GetFirstValidBaseConstruct().ShortName));
            }

            string result = map.GetMergedCodeRoot().ToString();

            Assert.That(map.Diff(), Is.EqualTo(TypeOfDiff.UserChangeOnly));
            Assertions.StringContains(result, "class Class1", 1);
            Assertions.StringContains(result, "namespace ArchAngel.Tests", 1);
            Assertions.StringContains(result, "namespace Slyce.Tests", 0);

            int count = 0;

            foreach (CodeRootMapNode node in map.AllNodes)
            {
                if (node.IsTheSameReference(ns1))
                {
                    count++;
                }
            }
            Assert.That(count, Is.EqualTo(1));
        }
 // Token: 0x06000C5A RID: 3162 RVA: 0x00037F98 File Offset: 0x00036198
 internal static DeleteDomainRequest ConstructDeleteDomainRequest(SmtpDomain domain, Guid tenantId, Namespace ns, bool skipTenantCheck)
 {
     LocatorServiceClientAdapter.ThrowIfNull(domain, "domain");
     if (!skipTenantCheck)
     {
         LocatorServiceClientAdapter.ThrowIfEmptyGuid(tenantId, "tenantId");
     }
     LocatorServiceClientAdapter.ThrowIfInvalidNamespace(ns);
     return(new DeleteDomainRequest
     {
         TenantId = tenantId,
         Domain = new DomainQuery
         {
             DomainName = domain.Domain,
             PropertyNames = new string[]
             {
                 NamespaceUtil.NamespaceWildcard(ns)
             }
         }
     });
 }
 // Token: 0x06000C59 RID: 3161 RVA: 0x00037F8C File Offset: 0x0003618C
 internal static DeleteDomainRequest ConstructDeleteDomainRequest(SmtpDomain domain, Guid tenantId, Namespace ns)
 {
     return(LocatorServiceClientWriter.ConstructDeleteDomainRequest(domain, tenantId, ns, false));
 }
 // Token: 0x06000C58 RID: 3160 RVA: 0x00037F3C File Offset: 0x0003613C
 internal static DeleteTenantRequest ConstructDeleteTenantRequest(Guid tenantId, Namespace ns)
 {
     LocatorServiceClientAdapter.ThrowIfEmptyGuid(tenantId, "tenantId");
     LocatorServiceClientAdapter.ThrowIfInvalidNamespace(ns);
     return(new DeleteTenantRequest
     {
         Tenant = new TenantQuery
         {
             TenantId = tenantId,
             PropertyNames = new string[]
             {
                 NamespaceUtil.NamespaceWildcard(ns)
             }
         }
     });
 }
Esempio n. 40
0
        /// <summary>
        /// Sorts article meta data
        /// </summary>
        /// <param name="articleText">The wiki text of the article.</param>
        /// <param name="articleTitle">Title of the article</param>
        /// <param name="fixOptionalWhitespace">Whether to request optional excess whitespace to be fixed</param>
        /// <returns>The updated article text</returns>
        internal string Sort(string articleText, string articleTitle, bool fixOptionalWhitespace)
        {
            if (Namespace.Determine(articleTitle) == Namespace.Template)         // Don't sort on templates
            {
                return(articleText);
            }

            // short pages monitor check for en-wiki: keep at very end of article if present
            // See [[Template:Long comment/doc]]
            string shortPagesMonitor = "";

            if (Variables.LangCode.Equals("en"))
            {
                Match spm = WikiRegexes.ShortPagesMonitor.Match(articleText);

                if (spm.Success)
                {
                    articleText       = WikiRegexes.ShortPagesMonitor.Replace(articleText, "").TrimEnd();
                    shortPagesMonitor = spm.Value.TrimEnd();
                }
            }

            articleText = CommentedOutEnInterwiki.Replace(articleText, "");

            string personData = Tools.Newline(RemovePersonData(ref articleText));
            string disambig   = Tools.Newline(RemoveDisambig(ref articleText));
            string categories = Tools.Newline(RemoveCats(ref articleText, articleTitle));
            string interwikis = Tools.Newline(Interwikis(ref articleText));

            if (Namespace.IsMainSpace(articleTitle))
            {
                // maintenance templates above infoboxes etc., zeroth section only
                if (Variables.LangCode.Equals("en"))
                {
                    string zerothSection = WikiRegexes.ZerothSection.Match(articleText).Value;
                    string restOfArticle = articleText.Substring(zerothSection.Length);
                    articleText = MoveMaintenanceTags(zerothSection) + restOfArticle;
                }

                // Dablinks above orphan tags per [[WP:LAYOUT]]
                articleText = MoveDablinks(articleText);

                if (Variables.LangCode.Equals("en"))
                {
                    articleText = MovePortalTemplates(articleText);
                    articleText = MoveTemplateToSeeAlsoSection(articleText, WikiRegexes.WikipediaBooks);
                    articleText = MoveSisterlinks(articleText);
                    articleText = MoveTemplateToReferencesSection(articleText, WikiRegexes.Ibid);
                    articleText = MoveExternalLinks(articleText);
                    articleText = MoveSeeAlso(articleText);
                }
            }
            // two newlines here per https://en.wikipedia.org/w/index.php?title=Wikipedia_talk:AutoWikiBrowser&oldid=243224092#Blank_lines_before_stubs
            // https://en.wikipedia.org/wiki/Wikipedia_talk:AutoWikiBrowser/Bugs/Archive_11#Two_empty_lines_before_stub-templates
            // ru, sl, ar, arz wikis use only one newline
            string strStub = "";

            // Category: can use {{Verylargestub}}/{{popstub}} which is not a stub template, don't do stub sorting
            if (!Namespace.Determine(articleTitle).Equals(Namespace.Category))
            {
                strStub = Tools.Newline(RemoveStubs(ref articleText), (Variables.LangCode.Equals("ru") || Variables.LangCode.Equals("sl") || Variables.LangCode.Equals("ar") || Variables.LangCode.Equals("arz")) ? 1 : 2);
            }

            // filter out excess white space and remove "----" from end of article
            articleText  = Parsers.RemoveWhiteSpace(articleText, fixOptionalWhitespace) + "\r\n";
            articleText += disambig;

            switch (Variables.LangCode)
            {
            case "de":
            case "sl":
                articleText += strStub + categories + personData;

                // https://en.wikipedia.org/wiki/Wikipedia_talk:AutoWikiBrowser#Removal_of_blank_lines
                // on de wiki a blank line is desired between persondata and interwikis
                if (Variables.LangCode.Equals("de") && personData.Length > 0 && interwikis.Length > 0)
                {
                    articleText += "\r\n";
                }
                break;

            case "ar":
            case "arz":
            case "cs":
            case "el":
            case "pl":
            case "ru":
            case "simple":
                articleText += personData + strStub + categories;
                break;

            case "it":
                if (Variables.Project == ProjectEnum.wikiquote)
                {
                    articleText += personData + strStub + categories;
                }
                else
                {
                    articleText += personData + categories + strStub;
                }
                break;

            default:
                articleText += personData + categories + strStub;
                break;
            }
            articleText = (articleText + interwikis);

            // Only trim start on Category namespace, restore any saved short page monitor text
            return((Namespace.Determine(articleTitle) == Namespace.Category ?  articleText.Trim() : articleText.TrimEnd()) + shortPagesMonitor);
        }
Esempio n. 41
0
 protected override IEnumerable <object> EnumerateReferences(Namespace record)
 {
     yield return(record.Identifier);
 }
Esempio n. 42
0
 public NamedArgument(string name, Global globalEnvironment, Namespace targetNamespace = null)
 {
     this.name              = name;
     this.targetNamespace   = targetNamespace;
     this.globalEnvironment = globalEnvironment;
 }
Esempio n. 43
0
 public abstract void setNamespace(Namespace newValue);
        public void Matching_Successful()
        {
            Class cl = new Class(controller, "Class1");

            cl.IsPartial = true;
            cl.GenericTypes.Add("T");
            Class            c2    = new Class(controller, "Class2"); // Extra class in user
            AttributeSection attrs = new AttributeSection(controller);
            Attribute        attr  = new Attribute(controller);

            attr.PositionalArguments.Add("true");
            attr.Name = "Serializable";
            attrs.AddAttribute(attr);
            cl.AddAttributeSection(attrs);
            Namespace ns = new Namespace(controller);

            ns.Name = "ArchAngel.Tests";
            ns.AddChild(cl);
            ns.AddChild(c2);
            CodeRoot root = new CodeRoot(controller);

            root.AddChild(ns);

            CodeRootMap map = new CodeRootMap();

            map.AddCodeRoot(root, Version.User);

            cl           = new Class(controller, "Class1");
            cl.IsPartial = true;
            cl.GenericTypes.Add("T");
            attrs = new AttributeSection(controller);
            attr  = new Attribute(controller);
            attr.PositionalArguments.Add("true");
            attr.Name = "Serializable";
            attrs.AddAttribute(attr);
            cl.AddAttributeSection(attrs);

            // Create another class to match to the user one.
            Class c3 = new Class(controller, "Class3");

            ns      = new Namespace(controller);
            ns.Name = "ArchAngel.Tests";
            ns.AddChild(cl);
            ns.AddChild(c3);
            root = new CodeRoot(controller);
            root.AddChild(ns);

            map.AddCodeRoot(root, Version.PrevGen);
            map.AddCodeRoot(root, Version.NewGen);

            map.MatchConstructs(map.GetExactNode(ns), c2, c3, c3);

            string result = map.GetMergedCodeRoot().ToString();

            Assert.That(map.Diff(), Is.EqualTo(TypeOfDiff.UserChangeOnly));
            Assertions.StringContains(result, "class Class1");
            Assertions.StringContains(result, "[Serializable(true)]");
            Assertions.StringContains(result, "namespace ArchAngel.Tests");
            Assertions.StringContains(result, "Class2");
            Assertions.StringContains(result, "Class3", 0);

            int count = 0;

            foreach (CodeRootMapNode node in map.AllNodes)
            {
                if (node.IsTheSameReference(c2))
                {
                    count++;
                }
            }
            Assert.That(count, Is.EqualTo(1));
        }
Esempio n. 45
0
 public override int GetHashCode()
 {
     unchecked
     {
         return(((Name != null ? Name.GetHashCode() : 0) * 397) ^ (Namespace != null ? Namespace.GetHashCode() : 0));
     }
 }
Esempio n. 46
0
 internal static extern object Findpropstrict(Namespace ns, string name);
Esempio n. 47
0
 internal static extern object Construct(object receiver, Namespace ns, string name);
Esempio n. 48
0
 internal static extern object GetProperty(object obj, Namespace ns, string name);
Esempio n. 49
0
        public INamespace LoadPackageFromFiles(IDictionary <Uri, string> resolveMappings)
        {
            var files = options.InputFiles;

            if (files == null || files.Count() == 0)
            {
                return(null);
            }

            var packages = new List <INamespace>();

            repository = new ModelRepository(EcoreInterop.Repository);

            if (resolveMappings != null)
            {
                repository.Locators.Add(new FileMapLocator(resolveMappings));
            }

            foreach (var ecoreFile in files)
            {
                if (Path.GetExtension(ecoreFile) == ".ecore")
                {
#if DEBUG
                    var model     = repository.Resolve(ecoreFile);
                    var ePackages = model.RootElements.OfType <EPackage>();
                    foreach (var ePackage in ePackages)
                    {
                        packages.Add(EcoreInterop.Transform2Meta(ePackage, AddMissingPackage));
                    }
#else
                    try
                    {
                        var ePackages = repository.Resolve(ecoreFile).RootElements.OfType <EPackage>();
                        foreach (var ePackage in ePackages)
                        {
                            packages.Add(EcoreInterop.Transform2Meta(ePackage, AddMissingPackage));
                        }
                    }
                    catch (Exception ex)
                    {
                        Console.WriteLine("An error occurred reading the Ecore file. The error message was: " + ex.Message);
                        Environment.ExitCode = 1;
                    }
#endif
                }
                else if (Path.GetExtension(ecoreFile) == ".nmf" || Path.GetExtension(ecoreFile) == ".nmeta")
                {
#if DEBUG
                    packages.AddRange(repository.Resolve(ecoreFile).RootElements.OfType <INamespace>());
#else
                    try
                    {
                        packages.AddRange(repository.Resolve(ecoreFile).RootElements.OfType <INamespace>());
                    }
                    catch (Exception ex)
                    {
                        Console.WriteLine("An error occurred reading the NMeta file. The error message was: " + ex.Message);
                        Environment.ExitCode = 1;
                    }
#endif
                }
            }

            if (packages.Count == 0)
            {
                throw new InvalidOperationException("No package could be found.");
            }
            else if (packages.Count == 1)
            {
                return(packages.First());
            }
            else
            {
                var package = new Namespace()
                {
                    Name = options.OverallNamespace
                };
                package.ChildNamespaces.AddRange(packages);
                return(package);
            }
        }
Esempio n. 50
0
 internal static extern void SetProperty(object obj, Namespace ns, string name, object value);
Esempio n. 51
0
        public override AstNode Visit(DelegateDefinition node)
        {
            // Parse the generic signature.
            GenericSignature genericSign = node.GetGenericSignature();
            GenericPrototype genProto    = GenericPrototype.Empty;
            PseudoScope      protoScope  = null;

            if (genericSign != null)
            {
                // Visit the generic signature.
                genericSign.Accept(this);

                // Connect the generic prototype.
                genProto = genericSign.GetPrototype();

                // Create the placeholders scope.
                protoScope = new PseudoScope(currentScope, genProto);
                node.SetGenericScope(protoScope);
            }

            // Prevent redefinition.
            ScopeMember old = currentContainer.FindType(node.GetName(), GenericPrototype.Empty);

            if (old != null)
            {
                Error(node, "trying to redefine a delegate.");
            }

            // Create the structure
            MemberFlags flags = node.GetFlags();
            // TODO: Check the flags.
            Class building = new Class(node.GetName(), flags, currentContainer);

            building.SetGenericPrototype(genProto);
            building.Position = node.GetPosition();
            node.SetStructure(building);

            // Add into the current scope.
            if (currentContainer.IsNamespace())
            {
                Namespace space = (Namespace)currentContainer;
                space.AddType(building);
            }
            else if (currentContainer.IsStructure() || currentContainer.IsInterface() || currentContainer.IsClass())
            {
                Structure parent = (Structure)currentContainer;
                parent.AddType(building);
            }
            else
            {
                Error(node, "unexpected place for a delegate.");
            }

            // Register the compute binding delegate.
            if (building.GetFullName() == "Chela.Compute.ComputeBinding")
            {
                currentModule.RegisterComputeBindingDelegate(building);
            }

            return(node);
        }
Esempio n. 52
0
 public override bool VisitNamespace(Namespace @namespace)
 {
     throw new NotImplementedException();
 }
Esempio n. 53
0
        public override AstNode Visit(InterfaceDefinition node)
        {
            // Parse the generic signature.
            GenericSignature genericSign = node.GetGenericSignature();
            GenericPrototype genProto    = GenericPrototype.Empty;
            PseudoScope      protoScope  = null;

            if (genericSign != null)
            {
                // Visit the generic signature.
                genericSign.Accept(this);

                // Connect the generic prototype.
                genProto = genericSign.GetPrototype();

                // Create the placeholders scope.
                protoScope = new PseudoScope(currentScope, genProto);
                node.SetGenericScope(protoScope);
            }

            // Prevent redefinition.
            ScopeMember old = currentContainer.FindType(node.GetName(), genProto);

            if (old != null)
            {
                Error(node, "trying to redefine a class.");
            }

            // Create the structure
            Interface iface = new Interface(node.GetName(), node.GetFlags(), currentContainer);

            iface.SetGenericPrototype(genProto);
            node.SetStructure(iface);
            iface.Position = node.GetPosition();

            // Register type maps.
            string     fullName = iface.GetFullName();
            IChelaType alias;

            if (typeMaps.TryGetValue(fullName, out alias))
            {
                currentModule.RegisterTypeMap(alias, ReferenceType.Create(iface));
            }

            // Register some important interfaces.
            if (fullName == "Chela.Lang.NumberConstraint")
            {
                currentModule.RegisterNumberConstraint(iface);
            }
            else if (fullName == "Chela.Lang.IntegerConstraint")
            {
                currentModule.RegisterIntegerConstraint(iface);
            }
            else if (fullName == "Chela.Lang.FloatingPointConstraint")
            {
                currentModule.RegisterFloatingPointConstraint(iface);
            }
            else if (fullName == "Chela.Collections.IEnumerable")
            {
                currentModule.RegisterEnumerableIface(iface);
            }
            else if (fullName == "Chela.Collections.IEnumerator")
            {
                currentModule.RegisterEnumeratorIface(iface);
            }
            else if (fullName.StartsWith("Chela.Collections.Generic.IEnumerable<"))
            {
                currentModule.RegisterEnumerableGIface(iface);
            }
            else if (fullName.StartsWith("Chela.Collections.Generic.IEnumerator<"))
            {
                currentModule.RegisterEnumeratorGIface(iface);
            }

            // Use the prototype scope.
            if (protoScope != null)
            {
                PushScope(protoScope);
            }

            // Add into the current scope.
            if (currentContainer.IsNamespace())
            {
                Namespace space = (Namespace)currentContainer;
                space.AddType(iface);
            }
            else if (currentContainer.IsStructure() || currentContainer.IsInterface() || currentContainer.IsClass())
            {
                Structure parent = (Structure)currentContainer;
                parent.AddType(iface);
            }
            else
            {
                Error(node, "unexpected place for a class.");
            }

            // Push the interface unsafe.
            if (iface.IsUnsafe())
            {
                PushUnsafe();
            }

            // Update the scope.
            PushScope(iface);

            // Visit the building children.
            VisitList(node.GetChildren());

            // Restore the scope.
            PopScope();

            // Restore the generic scope.
            if (protoScope != null)
            {
                PopScope();
            }

            // Pop the interface unsafe.
            if (iface.IsUnsafe())
            {
                PopUnsafe();
            }

            return(node);
        }
Esempio n. 54
0
        public static Expression Create(ExpressionNodeInfo info)
        {
            var symbolInfo = info.Context.GetSymbolInfo(info.Node);

            var target = symbolInfo.Symbol;

            if (target is null &&
                symbolInfo.CandidateReason == CandidateReason.OverloadResolutionFailure &&
                info.Node.Parent.IsKind(SyntaxKind.SuppressNullableWarningExpression))
            {
                target = symbolInfo.CandidateSymbols.FirstOrDefault();
            }

            if (target is null && symbolInfo.CandidateReason == CandidateReason.OverloadResolutionFailure)
            {
                // The expression is probably a cast
                target = info.Context.GetSymbolInfo((CSharpSyntaxNode)info.Node.Parent !).Symbol;
            }

            if (target is null && (symbolInfo.CandidateReason == CandidateReason.Ambiguous || symbolInfo.CandidateReason == CandidateReason.MemberGroup))
            {
                // Pick one at random - they probably resolve to the same ID
                target = symbolInfo.CandidateSymbols.First();
            }

            if (target is null)
            {
                if (IsInsideIfDirective(info.Node))
                {
                    return(DefineSymbol.Create(info));
                }

                info.Context.ModelError(info.Node, "Failed to resolve name");
                return(new Unknown(info));
            }

            // There is a very strange bug in Microsoft.CodeAnalysis whereby
            // target.Kind throws System.InvalidOperationException for Discard symbols.
            // So, short-circuit that test here.
            // Ideally this would be another case in the switch statement below.
            if (target is IDiscardSymbol)
            {
                return(new Discard(info));
            }

            switch (target.Kind)
            {
            case SymbolKind.TypeParameter:
            case SymbolKind.NamedType:
            case SymbolKind.DynamicType:
                return(TypeAccess.Create(info));

            case SymbolKind.Property:
            case SymbolKind.Field:
            case SymbolKind.Event:
            case SymbolKind.Method:
                return(Access.Create(info, target, true, info.Context.CreateEntity(target)));

            case SymbolKind.Local:
            case SymbolKind.RangeVariable:
                return(Access.Create(info, target, false, LocalVariable.Create(info.Context, target)));

            case SymbolKind.Parameter:
                return(Access.Create(info, target, false, Parameter.Create(info.Context, (IParameterSymbol)target)));

            case SymbolKind.Namespace:
                return(Access.Create(info, target, false, Namespace.Create(info.Context, (INamespaceSymbol)target)));

            default:
                throw new InternalError(info.Node, $"Unhandled identifier kind '{target.Kind}'");
            }
        }
Esempio n. 55
0
        public override AstNode Visit(StructDefinition node)
        {
            // Parse the generic signature.
            GenericSignature genericSign = node.GetGenericSignature();
            GenericPrototype genProto    = GenericPrototype.Empty;
            PseudoScope      protoScope  = null;

            if (genericSign != null)
            {
                // Visit the generic signature.
                genericSign.Accept(this);

                // Connect the generic prototype.
                genProto = genericSign.GetPrototype();

                // Create the placeholders scope.
                protoScope = new PseudoScope(currentScope, genProto);
                node.SetGenericScope(protoScope);
            }

            // Prevent redefinition.
            ScopeMember old = currentContainer.FindType(node.GetName(), genProto);

            if (old != null)
            {
                Error(node, "trying to redefine a struct.");
            }

            // Create the structure
            Structure building = new Structure(node.GetName(), node.GetFlags(), currentContainer);

            building.SetGenericPrototype(genProto);
            node.SetStructure(building);
            building.Position = node.GetPosition();

            // Use the prototype scope.
            if (protoScope != null)
            {
                PushScope(protoScope);
            }

            // Register type association.
            string     fullName = building.GetFullName();
            IChelaType assoc;

            if (assocClasses.TryGetValue(fullName, out assoc))
            {
                currentModule.RegisterAssociatedClass(assoc, building);
            }

            // Add into the current scope.
            if (currentContainer.IsNamespace())
            {
                Namespace space = (Namespace)currentContainer;
                space.AddType(building);
            }
            else if (currentContainer.IsStructure() || currentContainer.IsInterface() || currentContainer.IsClass())
            {
                Structure parent = (Structure)currentContainer;
                parent.AddType(building);
            }
            else
            {
                Error(node, "unexpected place for a structure.");
            }

            // Push the building unsafe.
            if (building.IsUnsafe())
            {
                PushUnsafe();
            }

            // Update the scope.
            PushScope(building);

            // Visit the building children.
            VisitList(node.GetChildren());

            // Restore the scope.
            PopScope();

            // Pop the building unsafe.
            if (building.IsUnsafe())
            {
                PopUnsafe();
            }

            // Restore the prototype scope.
            if (protoScope != null)
            {
                PopScope();
            }

            return(node);
        }
Esempio n. 56
0
        public static Namespace Parse(string path, string config, string generator)
        {
            if (File.Exists(Path.Combine(Path.GetDirectoryName(path), config)))
            {
                parserConfig = readParserConfig(Path.Combine(Path.GetDirectoryName(path), config));
            }
            else if (File.Exists(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, $"config.{generator}.json")))
            {
                parserConfig = readParserConfig(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, $"config.{generator}.json"));
            }
            else if (File.Exists(config))
            {
                parserConfig = readParserConfig(config);
            }

            var grammar = new ObjectGrammar();

            Console.Clear();
            //var language = new LanguageData(grammar);
            var parser = new Parser(grammar);

            var text = File.ReadAllText(path);

            var parseTree = parser.Parse(text);

            if (parseTree.Status == ParseTreeStatus.Error)
            {
                var sb = new StringBuilder();
                foreach (var msg in parseTree.ParserMessages)
                {
                    sb.AppendLine($"{msg.Message} at location: {msg.Location.ToUiString()}");
                }
                throw new DataParserException($"Parsing failed:\n\n{sb.ToString()}");
            }
            else
            {
                //printAst(parseTree, grammar.dispTree);
                //Console.ReadLine();
                //return;
                var objectList   = new List <DataModel.Object>();
                var externalList = new List <TypeDeclaration>();
                foreach (var node in parseTree.Root.ChildNodes)
                {
                    if (node.ChildNodes[0].Term.Name == "object")
                    {
                        objectList.Add(parseObjectNode(node.ChildNodes[0]));
                    }
                    else
                    {
                        externalList.Add(parseExternal(node.ChildNodes[0]));
                    }
                }
                var global = new Namespace(objectList, Path.GetFileNameWithoutExtension(path), externalList);

                if (!parserConfig.Untyped)
                {
                    if (!validate(global, externalList))
                    {
                        throw new DataParserException("Validation failed!");
                    }
                }

                return(global);
            }
        }
Esempio n. 57
0
        //Need to process this at the page level for the framework data
        //to process the presentation XML
        public void LoadRDFSearchResults()
        {
            XmlDocument xml           = new XmlDocument();
            Namespace   rdfnamespaces = new Namespace();

            Utilities.DataIO data = new Utilities.DataIO();

            string searchtype  = string.Empty;
            string lname       = string.Empty;
            string fname       = string.Empty;
            string institution = string.Empty;
            string department  = string.Empty;
            string division    = string.Empty;

            string searchfor            = string.Empty;
            string classgroupuri        = string.Empty;
            string classuri             = string.Empty;
            string perpage              = string.Empty;
            string offset               = string.Empty;
            string sortby               = string.Empty;
            string sortdirection        = string.Empty;
            string searchrequest        = string.Empty;
            string otherfilters         = string.Empty;
            string institutionallexcept = string.Empty;
            string departmentallexcept  = string.Empty;
            string divisionallexcept    = string.Empty;
            string exactphrase          = string.Empty;
            string nodeuri              = string.Empty;
            string nodeid               = string.Empty;


            if (this.SearchType.IsNullOrEmpty() == false)
            {
                searchtype = this.SearchType;
            }

            //else if (Request.Form["searchtype"] != null)
            //{
            //    searchtype = Request.Form["searchtype"];
            //}

            if (Request.QueryString["searchfor"].IsNullOrEmpty() == false)
            {
                searchfor = Request.QueryString["searchfor"];
            }

            if (Request.Form["txtSearchFor"].IsNullOrEmpty() == false)
            {
                searchfor = Request.Form["txtSearchFor"];
            }

            if (Request.QueryString["lname"].IsNullOrEmpty() == false)
            {
                lname = Request.QueryString["lname"];
            }

            if (Request.QueryString["institution"].IsNullOrEmpty() == false)
            {
                institution = Request.QueryString["institution"];
            }

            if (Request.QueryString["department"].IsNullOrEmpty() == false)
            {
                department = Request.QueryString["department"];
            }

            if (Request.QueryString["division"].IsNullOrEmpty() == false)
            {
                division = Request.QueryString["division"];
            }

            if (Request.QueryString["fname"].IsNullOrEmpty() == false)
            {
                fname = Request.QueryString["fname"];
            }

            if (Request.QueryString["classgroupuri"].IsNullOrEmpty() == false)
            {
                classgroupuri = HttpUtility.UrlDecode(Request.QueryString["classgroupuri"]);
            }
            else
            {
                classgroupuri = HttpUtility.UrlDecode(Request.Form["classgroupuri"]);
            }

            if (classgroupuri != null)
            {
                if (classgroupuri.Contains("!"))
                {
                    classgroupuri = classgroupuri.Replace('!', '#');
                }
            }

            if (Request.QueryString["classuri"].IsNullOrEmpty() == false)
            {
                classuri = HttpUtility.UrlDecode(Request.QueryString["classuri"]);
            }
            else
            {
                classuri = HttpUtility.UrlDecode(Request.Form["classuri"]);
            }

            if (classuri != null)
            {
                if (classuri.Contains("!"))
                {
                    classuri = classuri.Replace('!', '#');
                }
            }
            else
            {
                classuri = "";
            }

            if (Request.QueryString["perpage"].IsNullOrEmpty() == false)
            {
                perpage = Request.QueryString["perpage"];
            }
            else
            {
                perpage = Request.Form["perpage"];
            }

            //if (perpage == string.Empty || perpage == null)
            //{
            //    perpage = Request.QueryString["perpage"];
            //}

            if (perpage.IsNullOrEmpty())
            {
                perpage = "15";
            }

            if (Request.QueryString["offset"].IsNullOrEmpty() == false)
            {
                offset = Request.QueryString["offset"];
            }
            else
            {
                offset = Request.Form["offset"];
            }

            if (offset.IsNullOrEmpty())
            {
                offset = "0";
            }

            //if (offset == null)
            //    offset = "0";

            if (Request.QueryString["sortby"].IsNullOrEmpty() == false)
            {
                sortby = Request.QueryString["sortby"];
            }

            if (Request.QueryString["sortdirection"].IsNullOrEmpty() == false)
            {
                sortdirection = Request.QueryString["sortdirection"];
            }

            if (Request.QueryString["searchrequest"].IsNullOrEmpty() == false)
            {
                searchrequest = Request.QueryString["searchrequest"];
            }
            else if (masterpage.SearchRequest.IsNullOrEmpty() == false)
            {
                searchrequest = masterpage.SearchRequest;
            }

            if (Request.QueryString["otherfilters"].IsNullOrEmpty() == false)
            {
                otherfilters = Request.QueryString["otherfilters"];
            }

            if (Request.QueryString["institutionallexcept"].IsNullOrEmpty() == false)
            {
                institutionallexcept = Request.QueryString["institutionallexcept"];
            }

            if (Request.QueryString["departmentallexcept"].IsNullOrEmpty() == false)
            {
                departmentallexcept = Request.QueryString["departmentallexcept"];
            }

            if (Request.QueryString["divisionallexcept"].IsNullOrEmpty() == false)
            {
                divisionallexcept = Request.QueryString["divisionallexcept"];
            }

            if (Request.QueryString["exactphrase"].IsNullOrEmpty() == false)
            {
                exactphrase = Request.QueryString["exactphrase"];
            }

            if (Request.QueryString["nodeuri"].IsNullOrEmpty() == false)
            {
                nodeuri = Request.QueryString["nodeuri"];
                nodeid  = nodeuri.Substring(nodeuri.LastIndexOf("/") + 1);
            }

            switch (searchtype.ToLower())
            {
            case "everything":

                if (searchrequest != string.Empty)
                {
                    xml.LoadXml(data.DecryptRequest(searchrequest));
                }
                else
                {
                    xml = data.SearchRequest(searchfor, exactphrase, classgroupuri, classuri, perpage, offset);
                }

                break;

            default:                    //Person is the default
                if (searchrequest != string.Empty)
                {
                    xml.LoadXml(data.DecryptRequest(searchrequest));
                }
                else
                {
                    xml = data.SearchRequest(searchfor, exactphrase, fname, lname, institution, institutionallexcept, department, departmentallexcept, division, divisionallexcept, classuri, perpage, offset, sortby, sortdirection, otherfilters, "", ref searchrequest);
                }
                break;
            }


            if (nodeuri != string.Empty && nodeid != string.Empty)
            {
                masterpage.RDFData = data.WhySearch(xml, nodeuri, Convert.ToInt64(nodeid));
            }
            else
            {
                masterpage.RDFData = data.Search(xml, false);
            }

            Framework.Utilities.DebugLogging.Log(masterpage.RDFData.OuterXml);
            masterpage.RDFNamespaces = rdfnamespaces.LoadNamespaces(masterpage.RDFData);
            masterpage.SearchRequest = searchrequest;
        }
Esempio n. 58
0
 public object HideDataUsingAlgorithm()
 {
     return(Namespace.hideDataUsingAlgorithm());    // call the code you want to benchmark here
 }
Esempio n. 59
0
 protected override Expression <Func <Namespace, bool> > FindExisting(Namespace record)
 => existing => existing.IdentifierId == record.IdentifierId;
Esempio n. 60
0
 public override bool Check(ArticleInfo article)
 {
     return(Namespaces.Contains(Namespace.Determine(article.Title)));
 }