babygo

babygo👶 is a small Go compiler made from scratch, which can compile itself. It's going to be the smallest and simplest go compiler in the world.

MIT License

Stars
294
babygo - More robust struct field's offset calculation Latest Release

Published by DQNEO about 1 year ago

What's Changed

Full Changelog: https://github.com/DQNEO/babygo/compare/v0.4.0...v0.4.1

babygo - Redesign types of the type

Published by DQNEO about 1 year ago

babygo - Support interface method call

Published by DQNEO about 1 year ago

  • Support interface method call
  • Add io.Writer interface type
  • Support error.Error() method
  • Add babygo build -x option for verbose log
  • Rename dtype labels to itab (interface table)
  • Handle implicit conversion to interface more smartly
  • Support hex digits number literals
babygo - Support separate compilation and cache build

Published by DQNEO about 1 year ago

  • Support separate compilation
  • Compiled package objects are stored into a .dcl.go file as forward declarations so that a later compilation can reuse them.
  • Introduce subcommand system
  • Features of babygo are now split into subcommands such as build , list, and compile.
  • Made os/exec to execute any linux commands by fork-and-exec mechanism
babygo - Separate the main package into several internal ones

Published by DQNEO about 1 year ago

  • Now the compiler's main code is separated into internal/ packages
  • Code generation codegen is not depend on ast any more, but on semantic analyzer (sema) and intermediate representation (ir) objects.
  • Move a lot of logic from code generator to semantic analyzer
  • Adopted DWARF2 debug info https://sourceware.org/binutils/docs/as.html#Loc
  • Adopted token.Pos and fileset position mechanism
  • Removed pre compiler. It is now generated automatically in test.
babygo - Output separate assembly files per package

Published by DQNEO about 3 years ago

babygo - main.go and precompiler.go became same

Published by DQNEO over 3 years ago

$ diff -U 0 pre/precompiler.go main.go
--- pre/precompiler.go	2021-03-09 09:31:23.000000000 +0900
+++ main.go	2021-03-09 09:30:50.000000000 +0900
@@ -8,3 +8,2 @@
-	"go/ast"
-	"go/parser"
-	"go/token"
+	"github.com/DQNEO/babygo/lib/ast"
+	"github.com/DQNEO/babygo/lib/token"
@@ -20 +19 @@
-const ProgName string = "pre"
+const ProgName string = "babygo"
@@ -4399,7 +4397,0 @@
-
-// tweak to reduce diff with main.go
-const parserImportsOnly = parser.ImportsOnly
-
-func parserParseFile(fset *token.FileSet, filename string, src interface{}, mode parser.Mode) (*ast.File, error) {
-	return parser.ParseFile(fset, filename, src, mode)
-}
babygo - Achieved self hosting

Published by DQNEO about 4 years ago

Babygo officially supports self-hosting 🎉

make test-self-host
Package Rankings
Top 5.45% on Proxy.golang.org