Skip to content

Commit

Permalink
Moving giant imports list from the library to the frontend (opening t…
Browse files Browse the repository at this point in the history
…he possiblity for goinstall to work)
  • Loading branch information
bytbox committed Dec 13, 2011
1 parent 32638cc commit 2b9882b
Show file tree
Hide file tree
Showing 6 changed files with 29 additions and 16 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Expand Up @@ -5,7 +5,7 @@
_obj _obj
kakapo kakapo
packages.go packages.go
lisp/scanpkgs/scanpkgs scanpkgs/scanpkgs
*.a *.a
repl.go repl.go
*.out *.out
Expand Down
15 changes: 13 additions & 2 deletions Makefile
@@ -1,7 +1,7 @@
include ${GOROOT}/src/Make.inc include ${GOROOT}/src/Make.inc


TARG = kakapo TARG = kakapo
GOFILES = kakapo.go repl.go GOFILES = kakapo.go repl.go packages.go
PREREQ = lisp PREREQ = lisp
CLEANFILES = _go_.${O} ${TARG} lisp.a repl.go CLEANFILES = _go_.${O} ${TARG} lisp.a repl.go
TXT2GO = ./txt2go.sh TXT2GO = ./txt2go.sh
Expand All @@ -15,16 +15,27 @@ _go_.${O}: ${GOFILES} ${PREREQ}
repl.go: repl.lsp repl.go: repl.lsp
${TXT2GO} repl < repl.lsp > $@ ${TXT2GO} repl < repl.lsp > $@


packages.go: scanpkgs/scanpkgs
scanpkgs/scanpkgs > packages.go
gofmt -w packages.go

lisp: lisp:
make -Clisp make -Clisp
cp lisp/_obj/lisp.a . cp lisp/_obj/lisp.a .


scanpkgs/scanpkgs: scanpkgs/scanpkgs.${O}
${LD} -o $@ scanpkgs/scanpkgs.${O}

scanpkgs/scanpkgs.${O}: scanpkgs/main.go
${GC} -o $@ scanpkgs/main.go

clean: clean:
rm -f ${CLEANFILES} rm -f ${CLEANFILES}
rm -f scanpkgs/scanpkgs.${O} scanpkgs/scanpkgs
make -Clisp clean make -Clisp clean


fmt: fmt:
gofmt -w ${GOFILES} gofmt -w kakapo.go
make -Clisp fmt make -Clisp fmt


test: ${TARG} test: ${TARG}
Expand Down
6 changes: 6 additions & 0 deletions kakapo.go
Expand Up @@ -23,6 +23,12 @@ func main() {
return return
} }


// Expose impots
for name, pkg := range _go_imports {
ExposeImport(name, pkg)
}

// Expose globals
ExposeGlobal("-interpreter", "Kakapo") ExposeGlobal("-interpreter", "Kakapo")
ExposeGlobal("-interpreter-version", VERSION) ExposeGlobal("-interpreter-version", VERSION)


Expand Down
13 changes: 1 addition & 12 deletions lisp/Makefile
Expand Up @@ -3,21 +3,10 @@ include ${GOROOT}/src/Make.inc
TARG = lisp TARG = lisp
BUILTINGO = cons.go math.go panic.go bool.go BUILTINGO = cons.go math.go panic.go bool.go
SRCFILES = parse.go eval.go util.go builtins.go syntax.go compat.go primitives.go scope.go interpret.go ${BUILTINGO} SRCFILES = parse.go eval.go util.go builtins.go syntax.go compat.go primitives.go scope.go interpret.go ${BUILTINGO}
GOFILES = ${SRCFILES} packages.go GOFILES = ${SRCFILES}
CLEANFILES = packages.go


include ${GOROOT}/src/Make.pkg include ${GOROOT}/src/Make.pkg


packages.go: scanpkgs/scanpkgs
scanpkgs/scanpkgs > packages.go
gofmt -w packages.go

scanpkgs/scanpkgs: scanpkgs/scanpkgs.${O}
${LD} -o $@ scanpkgs/scanpkgs.${O}

scanpkgs/scanpkgs.${O}: scanpkgs/main.go
${GC} -o $@ scanpkgs/main.go

fmt: fmt:
gofmt -w ${SRCFILES} gofmt -w ${SRCFILES}


7 changes: 7 additions & 0 deletions lisp/compat.go
Expand Up @@ -5,6 +5,13 @@ import (
"reflect" "reflect"
) )


// The map of available imports
var _go_imports = map[string]map[string]interface{}{}

func ExposeImport(name string, pkg map[string]interface{}) {
_go_imports[name] = pkg
}

func builtinImport(sc *scope, ss []sexpr) sexpr { func builtinImport(sc *scope, ss []sexpr) sexpr {
if len(ss) != 1 { if len(ss) != 1 {
panic("Invalid number of arguments") panic("Invalid number of arguments")
Expand Down
2 changes: 1 addition & 1 deletion lisp/scanpkgs/main.go → scanpkgs/main.go
Expand Up @@ -33,7 +33,7 @@ type item struct {
} }


func main() { func main() {
fmt.Println("package lisp") fmt.Println("package main")


// find AR(1) // find AR(1)
findAr() findAr()
Expand Down

0 comments on commit 2b9882b

Please sign in to comment.