Пример #1
0
            private Computation ConvertNode(AST.VariableDeclaration node, ILabel after)
            {
                var result = this.labelFactory.WithLabel(
                    writeLabel =>
                {
                    var nodeValue = node.Value ?? new AST.IntegerLiteral(node.InputRange, 0);
                    var value     = this.GenerateExpression(nodeValue, writeLabel);
                    var write     = this.readWriteGenerator.GenerateWrite(
                        this.function,
                        node.IntermediateVariable,
                        value.Result);
                    return(new Tree(write, new UnconditionalJump(after)), value);
                });

                return(new Computation(result.Start));
            }
Пример #2
0
 /// <summary>
 /// Creates a new variable instnace
 /// </summary>
 /// <param name="source">The source item</param>
 public Variable(AST.VariableDeclaration source)
 {
     Source = source ?? throw new ArgumentNullException(nameof(source));
 }
Пример #3
0
 private ILocation ReserveLocation(Function function, IReadOnlyDictionary <AST.VariableDeclaration, HashSet <AST.FunctionDeclaration> > variableUsages, AST.VariableDeclaration variable)
 {
     if (variableUsages[variable].Count > 1)
     {
         return(function.ReserveClosureLocation(variable.Identifier, variable.VariableType));
     }
     else if (variable.VariableType.IsHeapType())
     {
         return(function.ReserveStackFrameLocation(variable.VariableType));
     }
     else
     {
         return(new VirtualRegister());
     }
 }