Exemplo n.º 1
0
        public MethodTree Walk()
        {
            var method = new MethodTree();

            for (int i = 0; i < node.ChildCount; i++)
            {
                ITree child = node.GetChild(i);

                if (child.IsStatement())
                {
                    method.Add(new StatementTranslator(child).Walk());
                }
                else if (child.IsTypeDeclaration())
                {
                    //TODO: Special Case!
                    new TypeDeclarationTranslator(child).Walk();
                }
                else if (child.IsVarDeclaration())
                {
                    List<VarDeclarationNode> decls = new VarDeclarationTranslator(child).Walk();

                    foreach (VarDeclarationNode decl in decls)
                    {
                        method.Add(decl);
                    }
                }
                else
                {
                    throw new NotImplementedException();
                }
            }

            return method;
        }
        public List<Field> Walk(Class c)
        {
            List<VarDeclarationNode> varDeclarations = new VarDeclarationTranslator(node).Walk();

            // TODO: Field initialization

            return varDeclarations.Select(declaration =>
                                          new Field
                                              {
                                                  Name = declaration.Name,
                                                  DeclaringType = c,
                                                  ReturnType = declaration.Type,
                                                  Modifiers = declaration.Modifiers
                                              }).ToList();
        }