/// <summary>
        /// Processes the decorators of <paramref name="stmt"/>.
        /// </summary>
        /// <param name="stmt"></param>
        /// <returns>If true, the body of the statement has been
        /// translated, so don't do it again.</returns>
        public bool VisitDecorators(Statement stmt)
        {
            if (stmt.decorators == null)
            {
                return(false);
            }
            var decorators = stmt.decorators;

            if (this.properties.TryGetValue(stmt, out var propdef))
            {
                if (propdef.IsTranslated)
                {
                    return(true);
                }
                decorators.Remove(propdef.GetterDecoration !);
                decorators.Remove(propdef.SetterDecoration !);
                this.customAttrs = decorators.Select(dd => VisitDecorator(dd));
                var prop = gen.PropertyDef(
                    propdef.Name,
                    () => GeneratePropertyGetter(propdef.Getter !),
                    () => GeneratePropertySetter(propdef.Setter !));
                LocalVariableGenerator.Generate(null, prop.GetStatements, globals);
                LocalVariableGenerator.Generate(
                    new List <CodeParameterDeclarationExpression> {
                    new CodeParameterDeclarationExpression(prop.PropertyType !, "value"),
                },
Esempio n. 2
0
        public static void Generate(CodeMemberMethod method, HashSet <string> globals)
        {
            var gen = new LocalVariableGenerator(method.Parameters, method.Statements, globals);

            gen.Analyze(new List <CodeStatement>(), method.Statements);
            gen.Generate();
        }
Esempio n. 3
0
        protected override CodeMemberMethod Generate(CodeTypeReference ignore, CodeParameterDeclarationExpression[] parms)
        {
            var cons = gen.Constructor(parms, () => XlatConstructor(f.body));

            GenerateTupleParameterUnpackers(cons);
            LocalVariableGenerator.Generate(cons, globals);
            return(cons);
        }
Esempio n. 4
0
        public static void Generate(List <CodeParameterDeclarationExpression>?parameters, List <CodeStatement> statements, HashSet <string> globals)
        {
            parameters ??= new List <CodeParameterDeclarationExpression>();
            var gen = new LocalVariableGenerator(parameters, statements, globals);

            gen.Analyze(new List <CodeStatement>(), statements);
            gen.Generate();
        }
Esempio n. 5
0
        protected override CodeMemberMethod Generate(CodeTypeReference retType, CodeParameterDeclarationExpression[] parms)
        {
            var method = gen.LambdaMethod(parms, () => Xlat(f.body));

            GenerateTupleParameterUnpackers(method);
            LocalVariableGenerator.Generate(method, globals);
            return(method);
        }
Esempio n. 6
0
        protected virtual CodeMemberMethod Generate(CodeTypeReference retType, CodeParameterDeclarationExpression[] parms)
        {
            CodeMemberMethod method;

            if (isStatic)
            {
                method = gen.StaticMethod(fnName, retType, parms, () => Xlat(f.body));
            }
            else
            {
                method = gen.Method(fnName, retType, parms, () => Xlat(f.body));
            }
            method.IsAsync = isAsync;
            GenerateTupleParameterUnpackers(method);
            LocalVariableGenerator.Generate(method, globals);
            return(method);
        }