Exemple #1
0
 public ASTCILNode VisitLetIn(ASTLetInNode LetIn)
 {
     return(new ASTCILBlockNode(LetIn.Declarations.SelectMany(x =>
     {
         ASTCILExpressionNode expression;
         compilationUnit.TypeEnvironment.GetTypeDefinition(x.Type.Text, LetIn.SymbolTable, out var type);
         if (x.Expression != null)
         {
             expression = (ASTCILExpressionNode)x.Expression.Accept(this);
         }
         else if (x.Type.Text == Types.Bool)
         {
             expression = new ASTCILBoolConstantNode(false);
         }
         else if (x.Type.Text == Types.Int)
         {
             expression = new ASTCILIntConstantNode(0);
         }
         else if (x.Type.Text == Types.String)
         {
             expression = new ASTCILStringConstantNode("", labelIlGenerator.GenerateEmptyStringData());
         }
         else
         {
             expression = new ASTCILVoidNode();
         }
         return new ASTCILExpressionNode[]
         {
             new ASTCILAssignmentNode(x.Id, expression)
         };
     }).Append((ASTCILExpressionNode)LetIn.LetExp.Accept(this))));
 }
        public MipsProgram VisitIntConstant(ASTCILIntConstantNode IntConstant)
        {
            var result = new MipsProgram();

            result.SectionCode.Append(MipsGenerationHelper.NewScript()
                                      .LoadConstant(MipsRegisterSet.a0, IntConstant.Value));
            return(result);
        }