Exemplo 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;
 }
Exemplo n.º 2
0
        private void ClassTranslator_GenerateField(Identifier id, ExpTranslator xlat, AssignExp ass)
        {
            if (id.Name == "__slots__")
            {
                // We should already have analyzed the slots in
                // the type inference phase, so we ignore __slots__.
                return;
            }
            else
            {
                var(fieldType, nmspcs) = types.TranslateTypeOf(id);
                gen.EnsureImports(nmspcs);

                GenerateField(id.Name, fieldType, ass.Src?.Accept(xlat));
            }
        }
Exemplo n.º 3
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);
 }
Exemplo n.º 4
0
 public IntrinsicTranslator(ExpTranslator expTranslator)
 {
     this.expTranslator = expTranslator;
     this.m             = expTranslator.m;
     this.translators   = new Dictionary <string, Func <Application, CodeExpression[], CodeExpression> >
     {
         { "isinstance", Translate_isinstance },
         { "int", Translate_int },
         { "list", Translate_list },
         { "set", Translate_set },
         { "dict", Translate_dict },
         { "len", Translate_len },
         { "sum", Translate_sum },
         { "filter", Translate_filter },
         { "complex", Translate_complex },
         { "float", Translate_float },
         { "sorted", Translate_sorted },
         { "str", Translate_str },
         { "enumerate", Translate_enumerate },
     };
 }
Exemplo n.º 5
0
 public MethodGenerator(
     ClassDef?classDef,
     FunctionDef f,
     string?fnName,
     List <Parameter> args,
     bool isStatic,
     bool isAsync,
     TypeReferenceTranslator types,
     CodeGenerator gen)
 {
     this.classDef = classDef;
     this.f        = f;
     this.fnName   = fnName;
     this.args     = args;
     this.isStatic = isStatic;
     this.isAsync  = isAsync;
     this.gen      = gen;
     this.gensym   = new SymbolGenerator();
     this.types    = types;
     this.xlat     = new ExpTranslator(classDef, this.types, gen, gensym);
     this.globals  = new HashSet <string>();
     this.stmtXlat = new StatementTranslator(classDef, types, gen, gensym, globals);
 }