Esempio n. 1
0
 public string Generate(XElement xml) {
     var m = new Module {
                            Namespace = new NamespaceDeclaration(xml.Name.LocalName)
                        };
     foreach (var element in xml.Elements()) {
         generateElement(element, m.Globals);
     }
     return m.ToCodeString();
 }
        public virtual void setup() {
            string code = @"import System.Data
class X :
    def Z() as string :
        return  ''
def B() as bool :
    return false
registry['x'] = X
if B() :
    pass";
            this.cu = Compile("test",code, getPipeline() , prepareCompiler);
            Console.WriteLine(cu.Errors);
            Assert.True(cu.Errors.Count==0);
            this.srcmodule = cu.CompileUnit.Modules[0].Clone() as Module;
            Console.WriteLine(srcmodule.ToCodeString());
            this.pr = postProcess();
            if(pr.ToCodeString()!=srcmodule.ToCodeString()) {
                Console.WriteLine(pr.ToCodeString());
            }
        }
Esempio n. 3
0
		string GetStringFromModule(Module module, ConverterSettings settings)
		{
			if (settings.Errors.Count > 0) {
				Assert.Fail(settings.Errors.Count.ToString() + " errors: " + settings.Errors[0]);
			}
			if (settings.Warnings.Count > 0) {
				Assert.Fail(settings.Warnings.Count.ToString() + " warnings: " + settings.Warnings[0]);
			}
			Assert.IsNotNull(module, "Module is null");
			string str = module.ToCodeString();
			str = str.Trim().Replace("\r", "");
			for (int i = 0; i < 5; i++) {
				str = str.Replace("\n\n", "\n");
				str = str.Replace("  ", " ");
			}
			return str;
		}