#!/usr/bin/env python

#   Copyright 2015 Ufora Inc.
#
#   Licensed under the Apache License, Version 2.0 (the "License");
#   you may not use this file except in compliance with the License.
#   You may obtain a copy of the License at
#
#       http://www.apache.org/licenses/LICENSE-2.0
#
#   Unless required by applicable law or agreed to in writing, software
#   distributed under the License is distributed on an "AS IS" BASIS,
#   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
#   See the License for the specific language governing permissions and
#   limitations under the License.

"""
resetAxiomSearchFunction

Reset the FORA axiom search-function code to a default state that will build.
This is the first step in the code-gen required to generate a proper axiom search tree.
"""

import os
import ufora

uforaDir = os.path.split(os.path.abspath(ufora.__file__))[0]

emptyAxiomSearchFunctionText = """
//generated by ufora/scripts/resetAxiomSearchFunction.py
#include "AxiomSearch.hppml"
#include "../Core/ApplyArgFrame.hppml"
#include "../Judgment/JudgmentOnValue.hppml"
#include "../Primitives/Symbol.hpp"
#include "../Core/Type.hppml"
#include "../TypedFora/ABI/VectorRecord.hpp"
using TypedFora::Abi::VectorRecord;
namespace Fora {
uword_t searchJOVTree(const Fora::ApplyArgFrame& vals)
	{
	lassert(false);
	}
}
"""

emptyAxiomSearchFunctionText2 = """
//generated by ufora/scripts/rebuildAxiomSearchFunction.py
#include "AxiomSearch.hppml"
#include "../Core/ApplyArgFrame.hppml"
#include "../Judgment/JudgmentOnValue.hppml"
#include "../Primitives/Symbol.hpp"
#include "../Core/Type.hppml"
#include "../TypedFora/ABI/VectorRecord.hpp"
#include "../Judgment/JudgmentOnValueTree.hppml"
using TypedFora::Abi::VectorRecord;
namespace Fora {
Nullable<uword_t> searchJOVTree(const JudgmentOnValueTuple& vals, long curTreeId)
	{
	return null();
	}
Nullable<uword_t> searchJOVTree(const JudgmentOnValueTuple& vals)
	{
	return searchJOVTree(vals, 0);
	}
}
"""

with open(os.path.join(uforaDir, "FORA", "Axioms", "AxiomSearch.cpp"), "w") as f:
    print >> f, emptyAxiomSearchFunctionText

with open(os.path.join(uforaDir, "FORA", "Axioms", "AxiomSearch2.cpp"), "w") as f:
    print >> f, emptyAxiomSearchFunctionText2

 

