Ejemplo n.º 1
0
func translateFnStatement(node *ast.FnNode) core.ScDefn {
	params := []core.Name{}
	for _, param := range node.Params {
		params = append(params, core.Name(param))
	}
	return core.ScDefn{core.Name(node.Name), params, translateExpr(node.Body)}
}
Ejemplo n.º 2
0
func createNameArityCodeMapping(gmh core.GmHeap, gmg core.GmGlobals) []NameArityCodeMapping {
	globalMapping := []NameArityCodeMapping{}
	for _, obj := range gmg {
		globalMapping = append(globalMapping, createEntry(gmh, obj.Name, obj.Addr))
	}
	globalMapping = append(globalMapping, NameArityCodeMapping{core.Name("connet"), Obj{Arity(0), core.GmCode{}}})
	globalMapping = append(globalMapping, NameArityCodeMapping{core.Name("send"), Obj{Arity(1), core.GmCode{}}})
	return globalMapping
}
Ejemplo n.º 3
0
func translateFnExpr(node *ast.FnExprNode) core.CoreExpr {
	params := []core.Name{}
	for _, param := range node.Params {
		params = append(params, core.Name(param))
	}
	return core.ELam{params, translateExpr(node.Body)}
}
Ejemplo n.º 4
0
func translateNode(node interface{}) core.ScDefn {
	switch n := node.(type) {
	/*
		case *ast.LetNode:
			return translateLet(n)
		case *ast.FnExprNode:
			return translateFnExpr(n)
	*/
	case *ast.FnNode:
		return translateFnStatement(n)

	case *ast.CommentNode:
		return core.ScDefn{core.Name("comment"), []core.Name{}, core.ENum{true, false, false, 0, 0, 0, "0"}}

	default:
		return translateFnStatement(n.(*ast.FnNode))
		// return translateExpr(n)
	}
}
Ejemplo n.º 5
0
func translateDefnNode(node *ast.DefnNode) core.Defn {
	expr := translateExpr(node.Expr)
	return core.Defn{core.Name(node.Var), expr}
}