Skip to content

Commit

Permalink
updated from dagor4 repo on 2023/11/19, rev 7c0d114dca5d924ef032d22d7…
Browse files Browse the repository at this point in the history
…24c67eaea1faf30
  • Loading branch information
NicSavichev committed Nov 19, 2023
1 parent 0427e7f commit bc0780a
Show file tree
Hide file tree
Showing 1,231 changed files with 35,515 additions and 15,332 deletions.
2 changes: 1 addition & 1 deletion DagorEngine.rev.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
734cc7c4ec4235531e627319981a91c135d4319f
7c0d114dca5d924ef032d22d724c67eaea1faf30
1 change: 1 addition & 0 deletions prog/1stPartyLibs/daScript/daslib/coroutines.das
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ class private YieldFrom : AstCallMacro
//! The idea is that coroutine or generator can continuesly yield from another sub-coroutine or generator.
def override visit ( prog:ProgramPtr; mod:Module?; var call:smart_ptr<ExprCallMacro> ) : ExpressionPtr
macro_verify( call.arguments |> length==1,prog,call.at,"expecting yeild_from(iterator)" )
macro_verify( call.arguments[0]._type!=null,prog,call.at,"expecting iterator" )
macro_verify( call.arguments[0]._type.isIterator,prog,call.at,"expecting iterator" )
let iname = make_unique_private_name("_yield_from_iterator",call.at)
return <- qmacro_block <|
Expand Down
20 changes: 7 additions & 13 deletions prog/1stPartyLibs/daScript/examples/test/misc/hello_world.das
Original file line number Diff line number Diff line change
@@ -1,17 +1,11 @@
require dump_fields

[|>dump_fields]
struct Foo
a : int

struct Bar : Foo
b : int
class Foo
static a : int
def static bar ( A : auto )
a = int(A)
print("set to {a}\n")

[export]
def main
var a = Foo()
print("a = {a}\n")
var b = Bar()
print("b = {b}\n")
Foo`bar(13.1)


options log
5 changes: 5 additions & 0 deletions prog/1stPartyLibs/daScript/include/daScript/ast/ast.h
Original file line number Diff line number Diff line change
Expand Up @@ -1308,6 +1308,7 @@ namespace das
bool aot_module = false; // this is how AOT tool knows module is module, and not an entry point
bool completion = false; // this code is being compiled for 'completion' mode
bool export_all = false; // when user compiles, export all (public?) functions
bool serialize_main_module = true; // if false, then we recompile main module each time
// error reporting
int32_t always_report_candidates_threshold = 6; // always report candidates if there are less than this number
// memory
Expand Down Expand Up @@ -1540,6 +1541,8 @@ namespace das
// this one collectes dependencies and compiles with modules
ProgramPtr compileDaScript ( const string & fileName, const FileAccessPtr & access,
TextWriter & logs, ModuleGroup & libGroup, CodeOfPolicies policies = CodeOfPolicies() );
ProgramPtr compileDaScriptSerialize ( const string & fileName, const FileAccessPtr & access,
TextWriter & logs, ModuleGroup & libGroup, CodeOfPolicies policies = CodeOfPolicies() );

// collect script prerequisits
bool getPrerequisits ( const string & fileName,
Expand Down Expand Up @@ -1591,6 +1594,8 @@ namespace das
bool g_resolve_annotations = true;
TextWriter * g_compilerLog = nullptr;
int64_t macroTimeTicks = 0;
AstSerializer * serializer_read = nullptr;
AstSerializer * serializer_write = nullptr;
DebugAgentInstance g_threadLocalDebugAgent;
static DAS_THREAD_LOCAL daScriptEnvironment * bound;
static DAS_THREAD_LOCAL daScriptEnvironment * owned;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,11 @@ namespace das {
Module * thisModule = nullptr;
Module * astModule = nullptr;
bool writing = false;
bool failed = false;
size_t readOffset = 0;
vector<uint8_t> buffer;
vector<uint8_t> metadata;
bool seenNewModule = false;
// file info clean up
vector<FileInfo*> deleteUponFinish; // these pointers are for builtins (which we don't serialize) and need to be cleaned manually
das_hash_set<FileInfo*> doNotDelete;
Expand Down Expand Up @@ -53,7 +56,7 @@ namespace das {
// fieldRefs tuple contains: fieldptr, module, structname, fieldname
vector<tuple<const Structure::FieldDeclaration **, Module *, string, string>> fieldRefs;
// tracking for shared modules
das_hash_set<Module *> writingReadyModules;
das_hash_set<Module *> writingReadyModules;
void tag ( const char * name );
void read ( void * data, size_t size );
void write ( const void * data, size_t size );
Expand Down Expand Up @@ -113,6 +116,8 @@ namespace das {
// Top-level
AstSerializer & operator << ( Module & module );

void serializeProgram ( ProgramPtr program, ModuleGroup & libGroup );

template<typename T>
void serializeSmartPtr( smart_ptr<T> & obj, das_hash_map<uint64_t, smart_ptr<T>> & objMap );

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ namespace das {
__forceinline bool isGoodVariantType() const;
__forceinline bool isVoid() const;
__forceinline bool isRef() const;
__forceinline bool isAnyType() const;
bool isRefType() const;
bool isRefOrPointer() const { return isRef() || isPointer(); }
bool canWrite() const;
Expand Down Expand Up @@ -614,7 +615,7 @@ namespace das {
auto tt = typeFactory<TT>::make(ctx);
if (tt->isRefType()) {
tt->ref = false;
} else if (!tt->isRef()) {
} else if (!tt->isRef() && !tt->isAnyType()) {
// note:
// C++ does not differentiate between void foo ( Foo ); and void foo ( const Foo );
// DAS differenciates for pointers
Expand Down Expand Up @@ -787,4 +788,8 @@ namespace das {
__forceinline bool TypeDecl::isConst() const {
return constant;
}

__forceinline bool TypeDecl::isAnyType() const {
return baseType==Type::anyArgument;
}
}
28 changes: 11 additions & 17 deletions prog/1stPartyLibs/daScript/include/daScript/misc/platform.h
Original file line number Diff line number Diff line change
Expand Up @@ -211,12 +211,12 @@ __forceinline uint32_t rotr_c(uint32_t a, uint32_t b) {
void os_debug_break();

#ifndef DAS_FATAL_LOG
#define DAS_FATAL_LOG printf
#define DAS_FATAL_LOG(...) do { printf(__VA_ARGS__); fflush(stdout); } while(0)
#endif

#ifndef DAS_FATAL_ERROR
#define DAS_FATAL_ERROR(...) { \
printf(__VA_ARGS__); \
DAS_FATAL_LOG(__VA_ARGS__); \
assert(0 && "fatal error"); \
exit(-1); \
}
Expand All @@ -228,8 +228,7 @@ void os_debug_break();
#else
#define DAS_ASSERT(cond) { \
if ( !(cond) ) { \
printf("assertion failed: %s, %s:%d\n", #cond, __FILE__, __LINE__); \
fflush(stdout); \
DAS_FATAL_LOG("assertion failed: %s, %s:%d\n", #cond, __FILE__, __LINE__); \
os_debug_break(); \
} \
}
Expand All @@ -242,9 +241,8 @@ void os_debug_break();
#else
#define DAS_ASSERTF(cond,...) { \
if ( !(cond) ) { \
printf("assertion failed: %s, %s:%d\n", #cond, __FILE__, __LINE__); \
printf(__VA_ARGS__); \
fflush(stdout); \
DAS_FATAL_LOG("assertion failed: %s, %s:%d\n", #cond, __FILE__, __LINE__); \
DAS_FATAL_LOG(__VA_ARGS__); \
os_debug_break(); \
} \
}
Expand All @@ -256,16 +254,14 @@ void os_debug_break();
#ifdef NDEBUG
#define DAS_VERIFY(cond) { \
if ( !(cond) ) { \
printf("verify failed: %s, %s:%d\n", #cond, __FILE__, __LINE__); \
fflush(stdout); \
DAS_FATAL_LOG("verify failed: %s, %s:%d\n", #cond, __FILE__, __LINE__); \
exit(-1); \
} \
}
#else
#define DAS_VERIFY(cond) { \
if ( !(cond) ) { \
printf("verify failed: %s, %s:%d\n", #cond, __FILE__, __LINE__); \
fflush(stdout); \
DAS_FATAL_LOG("verify failed: %s, %s:%d\n", #cond, __FILE__, __LINE__); \
os_debug_break(); \
} \
}
Expand All @@ -276,18 +272,16 @@ void os_debug_break();
#ifdef NDEBUG
#define DAS_VERIFYF(cond,...) { \
if ( !(cond) ) { \
printf("verify failed: %s, %s:%d\n", #cond, __FILE__, __LINE__); \
printf(__VA_ARGS__); \
fflush(stdout); \
DAS_FATAL_LOG("verify failed: %s, %s:%d\n", #cond, __FILE__, __LINE__); \
DAS_FATAL_LOG(__VA_ARGS__); \
exit(-1); \
} \
}
#else
#define DAS_VERIFYF(cond,...) { \
if ( !(cond) ) { \
printf("verify failed: %s, %s:%d\n", #cond, __FILE__, __LINE__); \
printf(__VA_ARGS__); \
fflush(stdout); \
DAS_FATAL_LOG("verify failed: %s, %s:%d\n", #cond, __FILE__, __LINE__); \
DAS_FATAL_LOG(__VA_ARGS__); \
os_debug_break(); \
} \
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,7 @@ namespace das
virtual bool invalidateFileInfo ( const string & fileName );
virtual string getIncludeFileName ( const string & fileName, const string & incFileName ) const;
void freeSourceData();
virtual int64_t getFileMtime ( const string & fileName ) const;
FileInfoPtr letGoOfFileInfo ( const string & fileName );
virtual ModuleInfo getModuleInfo ( const string & req, const string & from ) const;
virtual bool isModuleAllowed ( const string &, const string & ) const { return true; };
Expand Down
12 changes: 5 additions & 7 deletions prog/1stPartyLibs/daScript/src/ast/ast.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2680,14 +2680,12 @@ namespace das {
Module * Program::addModule ( const string & name ) {
if ( auto lm = library.findModule(name) ) {
return lm;
} else {
if ( auto pm = Module::require(name) ) {
library.addModule(pm);
return pm;
} else {
return nullptr;
}
}
if ( auto pm = Module::require(name) ) {
library.addModule(pm);
return pm;
}
return nullptr;
}

bool Program::addAlias ( const TypeDeclPtr & at ) {
Expand Down
5 changes: 5 additions & 0 deletions prog/1stPartyLibs/daScript/src/ast/ast_const_folding.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -627,6 +627,11 @@ namespace das {
bool noSideEffects = true;
for ( auto & src : expr->sources ) {
noSideEffects &= src->noSideEffects;
if ( !noSideEffects ) break;
if ( src->type->isIterator() ) {
noSideEffects = false;
break;
}
}
if ( noSideEffects ) {
reportFolding();
Expand Down
28 changes: 14 additions & 14 deletions prog/1stPartyLibs/daScript/src/ast/ast_infer_type.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4701,7 +4701,7 @@ namespace das {
virtual ExpressionPtr visit ( ExprField * expr ) override {
if ( !expr->value->type || expr->value->type->isAliasOrExpr() ) return Visitor::visit(expr); // failed to infer
if ( expr->underClone ) { // we wait for the 'right' type to be infered
if ( !expr->underClone->right->type || expr->underClone->right->type->isAliasOrExpr() ) {
if ( !expr->underClone->right->type || expr->underClone->right->type->isAutoOrAlias() ) {
error("under clone field type not infered yet", "", "",
expr->at, CompilationError::cant_get_field);
return Visitor::visit(expr);
Expand Down Expand Up @@ -4998,19 +4998,6 @@ namespace das {
return Visitor::visit(expr);
}
}
// with
if ( auto eW = hasMatchingWith(expr->name) ) {
reportAstChanged();
return make_smart<ExprField>(expr->at, forceAt(eW->with->clone(),expr->at), expr->name);
}
// static class method accessing static variables
if ( func && func->isStaticClassMethod && func->classParent->hasStaticMembers ) {
auto staticVarName = func->classParent->name + "`" + expr->name;
if ( func->classParent->module->findVariable(staticVarName) ) {
reportAstChanged();
return make_smart<ExprVar>(expr->at, staticVarName);
}
}
// block arguments
for ( auto it = blocks.rbegin(); it!=blocks.rend(); ++it ) {
ExprBlock * block = *it;
Expand Down Expand Up @@ -5050,6 +5037,19 @@ namespace das {
argumentIndex ++;
}
}
// with
if ( auto eW = hasMatchingWith(expr->name) ) {
reportAstChanged();
return make_smart<ExprField>(expr->at, forceAt(eW->with->clone(),expr->at), expr->name);
}
// static class method accessing static variables
if ( func && func->isStaticClassMethod && func->classParent->hasStaticMembers ) {
auto staticVarName = func->classParent->name + "`" + expr->name;
if ( func->classParent->module->findVariable(staticVarName) ) {
reportAstChanged();
return make_smart<ExprVar>(expr->at, staticVarName);
}
}
// global
auto vars = findMatchingVar(expr->name, false);
if ( vars.size()==1 ) {
Expand Down
Loading

0 comments on commit bc0780a

Please sign in to comment.