Beispiel #1
0
func InitPredefs() {
	Predefs = collections.NewPersistentMap()
	Predefs.Set("std:len", length)
	Predefs.Set("std:sprintf", sprintf)
	Predefs.Set("std:printf", printf)
	Predefs.Set("std:println", println)
	Predefs.Set("std:exit", exit)
	Predefs.Set("std:open", fileOpen)
	Predefs.Set("std:write", fileWrite)
	Predefs.Set("std:close", fileClose)

	logging.Debug("Built-in environment:")
	for k, _ := range Predefs.Freeze() {
		logging.Debug(" |- %s", k)
	}
}
Beispiel #2
0
Datei: vm.go Projekt: jerluc/rift
func Run(rifts []*lang.Node) {
	InitPredefs()
	env := collections.ExtendPersistentMap(Predefs)
	for _, riftNode := range rifts {
		rift := riftNode.Rift()
		if !rift.IsMain() {
			evalRift(rift, env)
		}
	}
	if main := mainRift(rifts); main != nil {
		evalRift(main, env)
	} else {
		// TODO: Serve functionality
	}
	logging.Debug("Final environment:")
	for k, v := range env.Freeze() {
		logging.Debug(" |- %s = %+v", k, v)
	}
}
Beispiel #3
0
Datei: vm.go Projekt: jerluc/rift
func evalRift(rift *lang.Rift, env collections.PersistentMap) {
	logging.Debug("Evaluating rift [%s]", rift.Name())
	for _, line := range rift.Lines() {
		evaluate(rift, env, line)
	}
}