MCPcopy Create free account
hub / github.com/GaijinEntertainment/daScript / addConstant

Function addConstant

include/daScript/ast/ast_handle.h:846–858  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

844
845 template <typename TT>
846 void addConstant ( Module & mod, const string & name, const TT & value ) {
847 VariablePtr pVar = new Variable();
848 pVar->name = name;
849 pVar->type = new TypeDecl((Type)ToBasicType<TT>::type);
850 pVar->type->constant = true;
851 pVar->init = Program::makeConst(LineInfo(),pVar->type,cast<TT>::from(value));
852 pVar->init->type = new TypeDecl(*pVar->type);
853 pVar->init->constexpression = true;
854 pVar->initStackSize = sizeof(Prologue);
855 if ( !mod.addVariable(pVar) ) {
856 DAS_FATAL_ERROR("addVariable(%s) failed in module %s\n", name.c_str(), mod.name.c_str());
857 }
858 }
859 __forceinline void addConstant ( Module & mod, const string & name, const string & value ) {
860 VariablePtr pVar = new Variable();
861 pVar->name = name;

Callers 5

Module_UnitTestMethod · 0.85
Module_MathMethod · 0.85
addRuntimeMethod · 0.85
Module_MathTypesMethod · 0.85
Module_Tutorial03Method · 0.85

Calls 4

stringClass · 0.85
LineInfoClass · 0.50
addVariableMethod · 0.45
c_strMethod · 0.45

Tested by 1

Module_UnitTestMethod · 0.68