src/InitTweak/InitTweak.cc
ast::Expr * createBitwiseAssignment (const ast::Expr * dst, const ast::Expr * src) {
		static ast::ptr<ast::FunctionDecl> assign = nullptr;
		if (!assign) {
			auto td = new ast::TypeDecl({}, "T", {}, nullptr, ast::TypeDecl::Dtype, true);
			assign = new ast::FunctionDecl({}, "?=?", {}, 
			{ new ast::ObjectDecl({}, "_dst", new ast::ReferenceType(new ast::TypeInstType("T", td))),
			  new ast::ObjectDecl({}, "_src", new ast::TypeInstType("T", td))},
			{ new ast::ObjectDecl({}, "_ret", new ast::TypeInstType("T", td))}, nullptr, {}, ast::Linkage::Intrinsic);
		}
		if (dst->result.as<ast::ReferenceType>()) {
			for (int depth = dst->result->referenceDepth(); depth > 0; depth--) {
				dst = new ast::AddressExpr(dst);
			}
		}
		else {
			dst = new ast::CastExpr(dst, new ast::ReferenceType(dst->result, {}));
		}
		if (src->result.as<ast::ReferenceType>()) {
			for (int depth = src->result->referenceDepth(); depth > 0; depth--) {
				src = new ast::AddressExpr(src);
			}
		}
		return new ast::ApplicationExpr(dst->location, ast::VariableExpr::functionPointer(dst->location, assign), {dst, src});
	}
// looks like some other such codegen uses UntypedExpr and does not create fake function. should revisit afterwards
// following passes may accidentally resolve this expression if returned as untyped...
looks like some other such codegen uses UntypedExpr and does not create fake function. should revisit afterwards
following passes may accidentally resolve this expression if returned as untyped
looks like some other such codegen uses UntypedExpr and does not create fake function . should revisit afterwards following passes may accidentally resolve this expression if returned as untyped
ast::Expr * createBitwiseAssignment (const ast::Expr * dst, const ast::Expr * src) {
		static ast::ptr<ast::FunctionDecl> assign = nullptr;
		if (!assign) {
			auto td = new ast::TypeDecl({}, "T", {}, nullptr, ast::TypeDecl::Dtype, true);
			assign = new ast::FunctionDecl({}, "?=?", {}, 
			{ new ast::ObjectDecl({}, "_dst", new ast::ReferenceType(new ast::TypeInstType("T", td))),
			  new ast::ObjectDecl({}, "_src", new ast::TypeInstType("T", td))},
			{ new ast::ObjectDecl({}, "_ret", new ast::TypeInstType("T", td))}, nullptr, {}, ast::Linkage::Intrinsic);
		}
		if (dst->result.as<ast::ReferenceType>()) {
			for (int depth = dst->result->referenceDepth(); depth > 0; depth--) {
				dst = new ast::AddressExpr(dst);
			}
		}
		else {
			dst = new ast::CastExpr(dst, new ast::ReferenceType(dst->result, {}));
		}
		if (src->result.as<ast::ReferenceType>()) {
			for (int depth = src->result->referenceDepth(); depth > 0; depth--) {
				src = new ast::AddressExpr(src);
			}
		}
		return new ast::ApplicationExpr(dst->location, ast::VariableExpr::functionPointer(dst->location, assign), {dst, src});
	}
ast :: Expr * createBitwiseAssignment ( const ast :: Expr * dst , const ast :: Expr * src ) { static ast :: ptr < ast :: FunctionDecl > assign = nullptr ; if ( ! assign ) { auto td = new ast :: TypeDecl ( { } , " " , { } , nullptr , ast :: TypeDecl :: Dtype , true ) ; assign = new ast :: FunctionDecl ( { } , " " , { } , { new ast :: ObjectDecl ( { } , " " , new ast :: ReferenceType ( new ast :: TypeInstType ( " " , td ) ) ) , new ast :: ObjectDecl ( { } , " " , new ast :: TypeInstType ( " " , td ) ) } , { new ast :: ObjectDecl ( { } , " " , new ast :: TypeInstType ( " " , td ) ) } , nullptr , { } , ast :: Linkage :: Intrinsic ) ; } if ( dst -> result . as < ast :: ReferenceType > ( ) ) { for ( int depth = dst -> result -> referenceDepth ( ) ; depth > 0 ; depth -- ) { dst = new ast :: AddressExpr ( dst ) ; } } else { dst = new ast :: CastExpr ( dst , new ast :: ReferenceType ( dst -> result , { } ) ) ; } if ( src -> result . as < ast :: ReferenceType > ( ) ) { for ( int depth = src -> result -> referenceDepth ( ) ; depth > 0 ; depth -- ) { src = new ast :: AddressExpr ( src ) ; } } return new ast :: ApplicationExpr ( dst -> location , ast :: VariableExpr :: functionPointer ( dst -> location , assign ) , { dst , src } ) ; }
looks like some other such codegen uses UntypedExpr and does not create fake function.
looks like some other such codegen uses UntypedExpr and does not create fake function .