Exemple #1
0
        public string Transpile(CompilerContext context)
        {
            var code = new StringBuilder();

            if (IsVariableCreation)
            {
                code.AppendLine(
                    $"{TypeConverter.WhileToCSharp(CompilerScope.GetVariableType(VariableName))} {VariableName};");
            }
            code.AppendLine($"{VariableName} = {Value.Transpile(context)};");
            return(code.ToString());
        }
Exemple #2
0
        public Emit <Func <int> > EmitByteCode(CompilerContext context, Emit <Func <int> > emiter)
        {
            Local local = null;

            if (IsVariableCreation)
            {
                local = emiter.DeclareLocal(TypeConverter.WhileToType(CompilerScope.GetVariableType(VariableName)), VariableName);
            }
            else
            {
                local = emiter.Locals[VariableName];
            }
            Value.EmitByteCode(context, emiter);
            emiter.StoreLocal(local);
            return(emiter);
        }