Esempio n. 1
0
 /// <summary>
 /// The main parser method.
 /// </summary>
 /// <param name="root">The root of the M object hierarchy.</param>
 public override void Parse(DynamicObjectNode root)
 {
     // A global scope instance is needed for namespace search, so we use the global namespace.
     using (new NameContextScope(ModelContext<SoaModel>.Current.Model.GlobalNamespace))
     {
         this.Process(root);
     }
 }
Esempio n. 2
0
 public SoaObject GetObject(DynamicObjectNode node)
 {
     try
     {
         return objects[node.GetNode()];
     }
     catch (KeyNotFoundException exception)
     {
         throw new SoaLanguageException("The node had not been processed yet", exception);
     }
 }
Esempio n. 3
0
 public void AddObject(DynamicObjectNode node, SoaObject @object)
 {
     try
     {
         objects.Add(node.GetNode(), @object);
         @object.AddMetaInfo(new NodeInfo(node));
     }
     catch (ArgumentException exception)
     {
         throw new SoaLanguageException("The node had been already processed", exception);
     }
 }
Esempio n. 4
0
 public virtual object Process(DynamicObjectNode node)
 {
     if (node == null) return null;
     System.Type type = this.TargetInstance.GetType();
     string methodName = string.Format(this.MethodNamePattern, node.GetBrand());
     System.Reflection.MethodInfo method = type.GetMethod(methodName, BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
     if (method != null)
     {
         return method.Invoke(this.TargetInstance, new object[] { (object)node });
     }
     else
     {
         return this.ProcessChildren(node);
     }
 }
Esempio n. 5
0
 public virtual object ProcessChildren(DynamicObjectNode node)
 {
     List<object> result = new List<object>();
     foreach (var item in node.GetNode().Edges)
     {
         DynamicObjectNode dynamicNode = DynamicObjectNode.NodeToObject(node.GetParser(), item.Node) as DynamicObjectNode;
         if (dynamicNode != null)
         {
             object itemResult = this.Process(dynamicNode);
             if (itemResult != null)
             {
                 result.Add(itemResult);
             }
         }
     }
     if (result.Count > 0) return result;
     else return null;
 }
Esempio n. 6
0
 /// <summary>
 /// The main parser method.
 /// </summary>
 /// <param name="root">The root of the M object hierarchy.</param>
 public abstract void Parse(DynamicObjectNode root);
Esempio n. 7
0
 public SourceLocationInfo(DynamicObjectNode node, SoaLanguageContext context)
     : this(node, context.FileName)
 {
 }
Esempio n. 8
0
 public SourceLocationInfo(DynamicObjectNode node, string file = null)
     : this(node.GetSourceSpan(), file)
 {
 }
Esempio n. 9
0
 public NodeInfo(DynamicObjectNode node)
 {
     Node = node;
 }