sapphire/tools/generateASTNode.sh

51 lines
661 B
Bash
Executable File

#!/usr/bin/env sh
cd "$(dirname $0)"/../src/AST
if [ "$1" == "" ]; then
exit 1
fi
if [ -f $1.cpp ]; then
exit 0
fi
if [ -f $1.h ]; then
exit 0
fi
touch $1.cpp
touch $1.h
cat << EOF > $1.h
#pragma once
#include "ExprNode.h"
class $1 final : public ExprNode
{
public:
$1();
~$1();
llvm::Value* codegen(IRBuilder* generator) override;
};
EOF
cat << EOF > $1.cpp
#include "$1.h"
$1::$1()
: ExprNode()
{
}
$1::~$1()
{
}
llvm::Value* $1::codegen(IRBuilder* generator)
{
return llvm::ConstantInt::getSigned(llvm::IntegerType::getInt32Ty(generator->getBuilder()->getContext()),
0);
}
EOF