Пример #1
0
 public void Push(StackEntry entry)
 {
     if (entry.Type.Code == StackTypeCode.Void)
     {
         _writer.Ident(Ident).WriteLine($"{entry.Expression};");
     }
     else
     {
         //var id = $"_v{_paramIndex++}";
         //_writer.Ident(Ident).WriteLine($"auto {id} = {entry.Expression};");
         //_stackValues.Push(new StackEntry { Type = entry.Type, Expression = id });
         _stackValues.Push(entry);
     }
 }
Пример #2
0
        public void Compute()
        {
            var entry = _stackValues.Peek();

            if (!entry.Computed)
            {
                _stackValues.Pop();
                var id = $"_v{_paramIndex++}";
                _writer.Ident(Ident).WriteLine($"auto {id} = {entry.Expression};");
                var newEntry = new StackEntry {
                    Type = entry.Type, Expression = id, Computed = true
                };
                _stackValues.Push(newEntry);
            }
        }