NewLang Project
Yet another programm language
Loading...
Searching...
No Matches
newlang::Compiler Class Reference

#include <jit.h>

Public Types

enum  FunctionStep { PREPARE = 1 , OPERATION = 2 , COMPLETE = 3 }
 
typedef std::string WriteFunctionOp(CompileInfo &ci, TermPtr &op, FunctionStep step)
 

Public Member Functions

 Compiler (RuntimePtr rt)
 
virtual ~Compiler ()
 

Static Public Member Functions

static bool MakeFunctionCpp (CompileInfo &ci, std::string func_name, TermPtr &func_define, std::ostream &out)
 
static bool MakeCppFile (TermPtr list, std::ostream &out, const char *source=nullptr, Context *ctx=nullptr)
 
static std::string MakeFunctionBodyCpp (CompileInfo &ci, TermPtr ast)
 
static std::string MakeSequenceOpsCpp (CompileInfo &ci, TermPtr elem, bool top_level)
 
static std::string GetImpl (CompileInfo &ci, TermPtr term, std::string &output)
 
static std::string BeginIterators (CompileInfo &ci, TermPtr args, std::string &output, std::vector< std::string > &iters)
 
static void ReplaceSourceVariable (CompileInfo &ci, size_t count, std::string &body)
 
static void MakeCppFileFunctions (CompileInfo &ci, TermPtr elem, std::ostream &out)
 
static void MakeCppFileConstants (CompileInfo &ci, TermPtr elem, std::ostream &out)
 
static void MakeCppFileCallTerm (CompileInfo &ci, TermPtr ast, std::ostream &out, size_t deep)
 
static std::string MakeCppFileCallArgs (CompileInfo &ci, TermPtr &args, TermPtr proto)
 
static std::string MakeIteratorCallArgs_ (CompileInfo &ci, TermPtr args, std::vector< std::string > &iters)
 
static std::string MakeCppFileVariable (CompileInfo &ci, TermPtr &args, std::ostream &out)
 
static bool Execute (const char *exec, std::string *out=nullptr, int *exit_code=nullptr)
 
static bool GccMakeModule (const char *file, const char *module, const char *opts=nullptr, std::string *out=nullptr, int *exit_code=nullptr)
 
static std::string EncodeNonAsciiCharacters (const char *text)
 
static bool CompileModule (const char *filename, const char *output)
 
static ObjPtr GetIndexField (Context *ctx, ObjPtr obj, TermPtr term, bool create_field=false)
 
static bool ExecFunc (FunctionType *func, Obj *def_arg, Context *ctx, Obj &in, ObjPtr &out)
 
static bool StringTemplate (std::string &format, Context *ctx)
 
static void WriteIncludeFiles_ (std::ostream &out)
 
static void WriteDeclarationFunctions_ (CompileInfo &ci, TermPtr &func, std::ostream &out, std::vector< std::string > &func_list)
 
static std::string WriteFunctionCheckOp_ (CompileInfo &ci, TermPtr &op, const char *check_true, const char *check_false)
 
static std::string WriteFunctionBodyCLEAN_ (CompileInfo &ci, TermPtr &op, FunctionStep step=FunctionStep::OPERATION)
 
static std::string WriteFunctionBodyOTHER_ (CompileInfo &ci, TermPtr &op, FunctionStep step=FunctionStep::OPERATION)
 
static std::string WriteArgsForCall_ (CompileInfo &ci, TermPtr &func)
 
static void SelectTerms_ (TermPtr &obj, std::vector< TermPtr > &terms)
 
static bool WriteFunctionName_ (TermPtr &func, std::ostream &out, bool is_transparent=false)
 
static void ReplaceFuncArgs (TermPtr &func_define, std::string &str)
 
static std::string MakeCommentLine (std::string comment)
 
static std::string WriteSimpleBody_ (CompileInfo &ci, TermPtr &func)
 

Protected Attributes

RuntimePtr m_runtime
 

Detailed Description

Definition at line 330 of file jit.h.

Member Typedef Documentation

◆ WriteFunctionOp

typedef std::string newlang::Compiler::WriteFunctionOp(CompileInfo &ci, TermPtr &op, FunctionStep step)

Definition at line 416 of file jit.h.

Member Enumeration Documentation

◆ FunctionStep

Enumerator
PREPARE 
OPERATION 
COMPLETE 

Definition at line 410 of file jit.h.

Constructor & Destructor Documentation

◆ Compiler()

newlang::Compiler::Compiler ( RuntimePtr rt)

◆ ~Compiler()

virtual newlang::Compiler::~Compiler ( )
inlinevirtual

Definition at line 394 of file jit.h.

Member Function Documentation

◆ MakeFunctionCpp()

static bool newlang::Compiler::MakeFunctionCpp ( CompileInfo & ci,
std::string func_name,
TermPtr & func_define,
std::ostream & out )
static

◆ MakeCppFile()

static bool newlang::Compiler::MakeCppFile ( TermPtr list,
std::ostream & out,
const char * source = nullptr,
Context * ctx = nullptr )
static

◆ MakeFunctionBodyCpp()

static std::string newlang::Compiler::MakeFunctionBodyCpp ( CompileInfo & ci,
TermPtr ast )
static

◆ MakeSequenceOpsCpp()

static std::string newlang::Compiler::MakeSequenceOpsCpp ( CompileInfo & ci,
TermPtr elem,
bool top_level )
static

◆ GetImpl()

static std::string newlang::Compiler::GetImpl ( CompileInfo & ci,
TermPtr term,
std::string & output )
static

◆ BeginIterators()

static std::string newlang::Compiler::BeginIterators ( CompileInfo & ci,
TermPtr args,
std::string & output,
std::vector< std::string > & iters )
static

◆ ReplaceSourceVariable()

static void newlang::Compiler::ReplaceSourceVariable ( CompileInfo & ci,
size_t count,
std::string & body )
static

◆ MakeCppFileFunctions()

static void newlang::Compiler::MakeCppFileFunctions ( CompileInfo & ci,
TermPtr elem,
std::ostream & out )
static

◆ MakeCppFileConstants()

static void newlang::Compiler::MakeCppFileConstants ( CompileInfo & ci,
TermPtr elem,
std::ostream & out )
static

◆ MakeCppFileCallTerm()

static void newlang::Compiler::MakeCppFileCallTerm ( CompileInfo & ci,
TermPtr ast,
std::ostream & out,
size_t deep )
static

◆ MakeCppFileCallArgs()

static std::string newlang::Compiler::MakeCppFileCallArgs ( CompileInfo & ci,
TermPtr & args,
TermPtr proto )
static

◆ MakeIteratorCallArgs_()

static std::string newlang::Compiler::MakeIteratorCallArgs_ ( CompileInfo & ci,
TermPtr args,
std::vector< std::string > & iters )
static

◆ MakeCppFileVariable()

static std::string newlang::Compiler::MakeCppFileVariable ( CompileInfo & ci,
TermPtr & args,
std::ostream & out )
static

◆ Execute()

static bool newlang::Compiler::Execute ( const char * exec,
std::string * out = nullptr,
int * exit_code = nullptr )
static

◆ GccMakeModule()

static bool newlang::Compiler::GccMakeModule ( const char * file,
const char * module,
const char * opts = nullptr,
std::string * out = nullptr,
int * exit_code = nullptr )
static

◆ EncodeNonAsciiCharacters()

static std::string newlang::Compiler::EncodeNonAsciiCharacters ( const char * text)
static

◆ CompileModule()

static bool newlang::Compiler::CompileModule ( const char * filename,
const char * output )
static

◆ GetIndexField()

static ObjPtr newlang::Compiler::GetIndexField ( Context * ctx,
ObjPtr obj,
TermPtr term,
bool create_field = false )
static

◆ ExecFunc()

static bool newlang::Compiler::ExecFunc ( FunctionType * func,
Obj * def_arg,
Context * ctx,
Obj & in,
ObjPtr & out )
static

◆ StringTemplate()

static bool newlang::Compiler::StringTemplate ( std::string & format,
Context * ctx )
static

◆ WriteIncludeFiles_()

static void newlang::Compiler::WriteIncludeFiles_ ( std::ostream & out)
inlinestatic

Definition at line 398 of file jit.h.

References NEWLANG_NS.

◆ WriteDeclarationFunctions_()

static void newlang::Compiler::WriteDeclarationFunctions_ ( CompileInfo & ci,
TermPtr & func,
std::ostream & out,
std::vector< std::string > & func_list )
static

◆ WriteFunctionCheckOp_()

static std::string newlang::Compiler::WriteFunctionCheckOp_ ( CompileInfo & ci,
TermPtr & op,
const char * check_true,
const char * check_false )
static

◆ WriteFunctionBodyCLEAN_()

static std::string newlang::Compiler::WriteFunctionBodyCLEAN_ ( CompileInfo & ci,
TermPtr & op,
FunctionStep step = FunctionStep::OPERATION )
inlinestatic

◆ WriteFunctionBodyOTHER_()

static std::string newlang::Compiler::WriteFunctionBodyOTHER_ ( CompileInfo & ci,
TermPtr & op,
FunctionStep step = FunctionStep::OPERATION )
inlinestatic

◆ WriteArgsForCall_()

static std::string newlang::Compiler::WriteArgsForCall_ ( CompileInfo & ci,
TermPtr & func )
static

Referenced by WriteFunctionBodyOTHER_().

◆ SelectTerms_()

static void newlang::Compiler::SelectTerms_ ( TermPtr & obj,
std::vector< TermPtr > & terms )
static

◆ WriteFunctionName_()

static bool newlang::Compiler::WriteFunctionName_ ( TermPtr & func,
std::ostream & out,
bool is_transparent = false )
static

◆ ReplaceFuncArgs()

static void newlang::Compiler::ReplaceFuncArgs ( TermPtr & func_define,
std::string & str )
static

◆ MakeCommentLine()

static std::string newlang::Compiler::MakeCommentLine ( std::string comment)
static

◆ WriteSimpleBody_()

static std::string newlang::Compiler::WriteSimpleBody_ ( CompileInfo & ci,
TermPtr & func )
static

Member Data Documentation

◆ m_runtime

RuntimePtr newlang::Compiler::m_runtime
protected

Definition at line 513 of file jit.h.


The documentation for this class was generated from the following file: