Skip to content

Commit bb225be

Browse files
authored
GSoC'25 Week 3 Blog Post By Safwan Sayeed (#242)
1 parent 79ced7f commit bb225be

File tree

1 file changed

+97
-0
lines changed

1 file changed

+97
-0
lines changed
Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
---
2+
title: "GSoC '25 Week 3 Update by Safwan Sayeed"
3+
excerpt: "AST to IR Compilation Logic and Pseudocode Implementation"
4+
category: "DEVELOPER NEWS"
5+
date: "2025-06-22"
6+
slug: "2025-06-22-gsoc-25-sa-fw-an-week3"
7+
author: "@/constants/MarkdownFiles/authors/safwan-sayeed.md"
8+
tags: "gsoc25,sugarlabs,week3,sa-fw-an"
9+
image: "assets/Images/GSOC.png"
10+
---
11+
12+
<!-- markdownlint-disable -->
13+
14+
# Week 3 Progress Report by Safwan Sayeed
15+
16+
**Project:** Music Blocks 4 Program Engine
17+
**Mentors:** [Anindya Kundu](https://github.com/meganindya/), [Sumit Srivastava](https://github.com/sum2it)
18+
**Assisting Mentors:** [Devin Ullibari](https://github.com/pikurasa/), [Walter Bender](https://github.com/walterbender)
19+
**Reporting Period:** 2025-06-16 - 2025-06-22
20+
21+
---
22+
23+
## A Blog-style Retrospective
24+
25+
This week marked a significant milestone in our Music Blocks program engine development as we transitioned from the foundational memory architecture to the core compilation logic. The focus shifted to implementing the AST-to-IR (Intermediate Representation) translation layer - the crucial bridge between our abstract syntax tree representation and executable code.
26+
27+
The challenge was designing a static compilation system that converts AST nodes into a linear sequence of IR instructions, following the three-address code format. Working with complex expression hierarchies and statement blocks required careful consideration of instruction ordering and variable management.
28+
29+
Our mentors provided invaluable guidance on maintaining the static nature of the compilation process, emphasizing that we're translating program structure rather than executing runtime calculations. This distinction was crucial for keeping our implementation focused and efficient.
30+
31+
---
32+
33+
## Goals for This Week
34+
35+
- Complete the AST-to-IR compilation logic technical specification with detailed pseudocode patterns.
36+
- Implement evaluate() methods for all expression classes returning instruction lists.
37+
- Develop pseudocode for simple statements following the established IR generation patterns.
38+
- Design the instruction chaining mechanism for complex nested expressions.
39+
40+
---
41+
42+
## This Week's Highlights
43+
44+
1. **IR Compilation Logic Specification**
45+
- Expanded the tech spec with comprehensive AST-to-IR translation documentation covering expression and statement compilation patterns.
46+
- Detailed instruction list generation requirements and variable management strategies.
47+
- Link: [IR Compilation Logic](https://docs.google.com/document/d/1_MCCgl-RqiEQH0UQ4EX-2O6G4iRxgHAY1rZpw3QPXT0/edit?tab=t.i655udul8zuq)
48+
49+
2. **AST-to-IR Pseudocode Implementation**
50+
- Implemented evaluate() methods for all expression classes (Literal, Binary/Unary Operators, Arrays, Dictionaries, etc.)
51+
- Developed instruction list generation patterns following three-address code format
52+
- Created symbol table integration using sym_query, sym_declare, and sym_assign operations
53+
- Link: [Tech Spec Document - AST to IR Methods](https://docs.google.com/document/d/1_MCCgl-RqiEQH0UQ4EX-2O6G4iRxgHAY1rZpw3QPXT0/edit?tab=t.87123fra3s4#heading=h.gqjcwrtkdgvq)
54+
55+
3. **Simple Statements Compilation Logic**
56+
- Implemented pseudocode for VariableDeclarationStatement, VariableAssignmentStatement, FunctionCallStatement, and JumpStatement
57+
- Established parameter passing patterns for evaluate() methods ensuring proper instruction dependency chains
58+
59+
---
60+
61+
## Challenges & Solutions
62+
63+
- **Understanding Static vs Runtime Compilation:**
64+
Initially confused about whether we were performing runtime calculations or static code translation.
65+
*Solution:* Mentors clarified that this is purely static AST-to-IR conversion with no runtime execution, helping focus the implementation approach.
66+
67+
68+
---
69+
70+
## Key Learnings
71+
72+
- Mastered the distinction between static compilation and runtime execution in compiler design.
73+
- Gained deep understanding of three-address code generation and instruction dependency management.
74+
- Enhanced skills in designing clean pseudocode patterns that can be translated to actual implementation.
75+
- Learned the importance of maintaining consistent parameter passing patterns across class hierarchies.
76+
77+
---
78+
79+
## Next Week's Roadmap
80+
81+
- Implement pseudocode for compound statements.
82+
- Design basic block generation logic for control flow structures.
83+
---
84+
85+
## Resources & References
86+
87+
- **Tech Spec:** [IR Compilation Logic](https://docs.google.com/document/d/1_MCCgl-RqiEQH0UQ4EX-2O6G4iRxgHAY1rZpw3QPXT0/edit?tab=t.i655udul8zuq)
88+
- **Tech Spec:** [AST to IR Methods](https://docs.google.com/document/d/1_MCCgl-RqiEQH0UQ4EX-2O6G4iRxgHAY1rZpw3QPXT0/edit?tab=t.87123fra3s4#heading=h.gqjcwrtkdgvq)
89+
- **Repository:** [musicblocks-v4](https://github.com/sugarlabs/musicblocks-v4)
90+
91+
---
92+
93+
## Acknowledgments
94+
95+
Special thanks to my mentors Anindya, Sumit, Devin, and Walter for their crucial guidance on compiler design principles and static compilation concepts. Their clarification on the AST-to-IR translation approach and emphasis on maintaining clean instruction generation patterns was essential for this week's successful progress.
96+
97+
---

0 commit comments

Comments
 (0)