Пример #1
0
 public virtual object Visit(CompilationUnit compilationUnit, object data)
 {
     if (compilationUnit == null)
     {
         return(data);
     }
     return(compilationUnit.AcceptChildren(this, data));
 }
Пример #2
0
        public override object VisitCompilationUnit(CompilationUnit compilationUnit, object data)
        {
            Contract.Requires(compilationUnit != null);

            // Visit children (E.g. TypeDcelarion objects)
            compilationUnit.AcceptChildren(this, data);

            return(null);
        }
        public override object Visit(CompilationUnit compilationUnit, object data)
        {
            if (compilationUnit == null)
            {
                throw new ArgumentNullException("compilationUnit");
            }
            CodeNamespace globalNamespace = new CodeNamespace("Global");

            //namespaces.Add(globalNamespace);
            namespaceDeclarations.Push(globalNamespace);
            compilationUnit.AcceptChildren(this, data);
            codeCompileUnit.Namespaces.Add(globalNamespace);
            return(globalNamespace);
        }
Пример #4
0
 public object VisitCompilationUnit(CompilationUnit compilationUnit, object data)
 {
     module             = new B.Module();
     module.LexicalInfo = new B.LexicalInfo(fileName, 1, 1);
     compilationUnit.AcceptChildren(this, data);
     if (entryPointMethod != null)
     {
         bool allMembersAreStatic = true;
         foreach (B.TypeMember member in entryPointMethod.DeclaringType.Members)
         {
             allMembersAreStatic &= member.IsStatic;
         }
         if (allMembersAreStatic)
         {
             entryPointMethod.DeclaringType.Attributes.Add(MakeAttribute(("module")));
         }
         else
         {
             lastLexicalInfo = entryPointMethod.LexicalInfo;
             B.Expression expr = MakeReferenceExpression(entryPointMethod.DeclaringType.Name + ".Main");
             B.MethodInvocationExpression mie = new B.MethodInvocationExpression(lastLexicalInfo, expr);
             if (entryPointMethod.Parameters.Count > 0)
             {
                 mie.Arguments.Add(MakeReferenceExpression("argv"));
             }
             B.SimpleTypeReference ret = entryPointMethod.ReturnType as B.SimpleTypeReference;
             if (ret.Name == "void" || ret.Name == "System.Void")
             {
                 module.Globals.Add(new B.ExpressionStatement(mie));
             }
             else
             {
                 module.Globals.Add(new B.ReturnStatement(lastLexicalInfo, mie, null));
             }
         }
     }
     B.Module tmp = module;
     module = null;
     return(tmp);
 }
Пример #5
0
		public virtual object VisitCompilationUnit(CompilationUnit compilationUnit, object data) {
			Debug.Assert((compilationUnit != null));
			return compilationUnit.AcceptChildren(this, data);
		}
Пример #6
0
		public override object VisitCompilationUnit(CompilationUnit compilationUnit, object data)
		{
			if (compilationUnit == null) {
				throw new ArgumentNullException("compilationUnit");
			}
			CodeNamespace globalNamespace = new CodeNamespace("Global");
			//namespaces.Add(globalNamespace);
			namespaceDeclarations.Push(globalNamespace);
			compilationUnit.AcceptChildren(this, data);
			codeCompileUnit.Namespaces.Add(globalNamespace);
			return globalNamespace;
		}