Ejemplo n.º 1
0
 public StatementTranslator(TypeReferenceTranslator types, CodeGenerator gen, SymbolGenerator gensym, HashSet <string> globals)
 {
     this.types      = types;
     this.gen        = gen;
     this.gensym     = gensym;
     this.xlat       = new ExpTranslator(types, gen, gensym);
     this.properties = new Dictionary <Statement, PropertyDefinition>();
     this.globals    = globals;
 }
Ejemplo n.º 2
0
 public MethodGenerator(
     FunctionDef f,
     string fnName,
     List <Parameter> args,
     bool isStatic,
     bool isAsync,
     TypeReferenceTranslator types,
     CodeGenerator gen)
 {
     this.f        = f;
     this.fnName   = fnName;
     this.args     = args;
     this.isStatic = isStatic;
     this.isAsync  = isAsync;
     this.gen      = gen;
     this.gensym   = new SymbolGenerator();
     this.types    = new TypeReferenceTranslator(new Dictionary <Node, DataType>());
     this.xlat     = new ExpTranslator(this.types, gen, gensym);
     this.globals  = new HashSet <string>();
     this.stmtXlat = new StatementTranslator(types, gen, gensym, globals);
 }
Ejemplo n.º 3
0
        string Xlat(string pyExp)
        {
            var rdr = new StringReader(pyExp);
            var lex = new Syntax.Lexer("foo.py", rdr);
            var par = new Syntax.Parser("foo.py", lex);
            var exp = par.test();

            Debug.Print("{0}", exp);
            var sym    = new SymbolGenerator();
            var types  = new TypeReferenceTranslator(new Dictionary <Node, DataType>());
            var xlt    = new ExpTranslator(types, new CodeGenerator(new CodeCompileUnit(), "", "test"), sym);
            var csExp  = exp.Accept(xlt);
            var pvd    = new CSharpCodeProvider();
            var writer = new StringWriter();

            pvd.GenerateCodeFromExpression(csExp, writer,
                                           new CodeGeneratorOptions
            {
            });
            return(writer.ToString());
        }
Ejemplo n.º 4
0
 public ModuleTranslator(TypeReferenceTranslator types, CodeGenerator gen) : base(types, gen, new SymbolGenerator(), new HashSet <string>())
 {
     this.gen = gen;
 }