| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent b978482 commit f3bdb72
58 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -168,7 +168,7 @@ def isConstRedundantForCpp(typeDecl : TypeDeclPtr) { | |||
| 168 | 168 | if (Type.tBitfield) { return true; } | |
| 169 | 169 | if (Type.tBitfield8) { return true; } | |
| 170 | 170 | if (Type.tBitfield16) { return true; } | |
| 171 | - if (Type.tBitfield64) { return true; } | ||
| 171 | + if (Type.tBitfield64) { return true; } // nolint:STYLE017 (match arm chain) | ||
| 172 | 172 | if (_) { return false; } | |
| 173 | 173 | } | |
| 174 | 174 | } | |
@@ -397,7 +397,7 @@ def describeCppTypeEx(typeDecl : TypeDeclPtr; | |||
| 397 | 397 | if (typeDecl.firstType != null) { | |
| 398 | 398 | type_name = describeCppTypeEx(typeDecl.firstType, DescribeConfig(redundant_const = true, cross_platform = cfg.cross_platform), useAlias) | |
| 399 | 399 | } | |
| 400 | - let extra_comma = length(typeDecl.argTypes) != 0 ? "," : ""; | ||
| 400 | + let extra_comma = !empty(typeDecl.argTypes) ? "," : ""; | ||
| 401 | 401 | let arg_types = (each(typeDecl.argTypes) | |
| 402 | 402 | ._select(describeCppTypeEx(_, DescribeConfig(redundant_const = true, cross_platform = cfg.cross_platform), useAlias)) | |
| 403 | 403 | .to_array() | |
@@ -692,8 +692,7 @@ class public AotDebugInfoHelper { | |||
| 692 | 692 | if (si.fields == null) return ; | |
| 693 | 693 | for (fi in range(si.count)) { | |
| 694 | 694 | let fld & = unsafe(si.fields[fi]) | |
| 695 | - if (fld.annotation_arguments == null) continue; | ||
| 696 | - if (length(*fld.annotation_arguments) == 0) continue; | ||
| 695 | + if (fld.annotation_arguments == null || empty(*fld.annotation_arguments)) continue; | ||
| 697 | 696 | write(writer, " {structInfoName(si)}_field_{fi}.annotation_arguments = &{structInfoName(si)}_field_{fi}_ann;\n") | |
| 698 | 697 | } | |
| 699 | 698 | }) | |
@@ -731,7 +730,7 @@ class public AotDebugInfoHelper { | |||
| 731 | 730 | writeDim(writer, fld, suffix); | |
| 732 | 731 | writeArgTypes(writer, fld, suffix); | |
| 733 | 732 | writeArgNames(writer, fld, suffix); | |
| 734 | - let prefix = (info.module_name |> length() > 0) ? "{info.module_name}::" : ""; | ||
| 733 | + let prefix = (info.module_name |> !empty(info.module_name)) ? "{info.module_name}::" : ""; | ||
| 735 | 734 | write(*writer, "VarInfo {structInfoName(info)}_field_{fi} = \{ {describeCppVarInfo(prefix + info.name, fld,suffix)} \};\n"); | |
| 736 | 735 | if (fld.annotation_arguments != null) { | |
| 737 | 736 | if (length(*fld.annotation_arguments) > 0) { | |
@@ -996,7 +995,7 @@ class public BlockVariableCollector : AstVisitor { | |||
| 996 | 995 | def getFinalBlock() { | |
| 997 | 996 | for (i in range(length(stack))) { | |
| 998 | 997 | let blk = stack[length(stack) - i - 1]; | |
| 999 | - if (length(blk.finalList) != 0) return blk; | ||
| 998 | + if (!empty(blk.finalList)) return blk; | ||
| 1000 | 999 | if (blk.blockFlags.isClosure) return null; | |
| 1001 | 1000 | } | |
| 1002 | 1001 | return null; | |
@@ -1730,10 +1729,10 @@ class public CppAot : AstVisitor { | |||
| 1730 | 1729 | that.right._type.baseType == Type.tBool && that.right._type.isSimpleType); | |
| 1731 | 1730 | } | |
| 1732 | 1731 | def isOpPolicy2(that : ExprOp2?) { | |
| 1733 | - if (is_alpha(first_character(that.op))) return true; | ||
| 1734 | - if (that.op == "/" || that.op == "%") return true; | ||
| 1735 | - if (that.op == "<<<" || that.op == ">>>" || that.op == "<<<=" || that.op == ">>>=") return true; | ||
| 1736 | - if (that.op == "<<" || that.op == ">>" || that.op == "<<=" || that.op == ">>=") return true; | ||
| 1732 | + if (is_alpha(first_character(that.op)) | ||
| 1733 | + || that.op == "/" || that.op == "%" | ||
| 1734 | + || that.op == "<<<" || that.op == ">>>" || that.op == "<<<=" || that.op == ">>>=" | ||
| 1735 | + || that.op == "<<" || that.op == ">>" || that.op == "<<=" || that.op == ">>=") return true; | ||
| 1737 | 1736 | return that._type.isPolicyType || that.left._type.isPolicyType || that.right._type.isPolicyType; | |
| 1738 | 1737 | } | |
| 1739 | 1738 | def opPolicyBase(that : ExprOp2?) { | |
@@ -3259,7 +3258,7 @@ class public CppAot : AstVisitor { | |||
| 3259 | 3258 | } | |
| 3260 | 3259 | } | |
| 3261 | 3260 | def override canVisitExprLooksLikeCallArgument(call : ExprLooksLikeCall?; arg : ExpressionPtr; last : bool) { | |
| 3262 | - if (length(call.arguments) >= 1 && call.arguments[0] == arg && call is ExprInvoke) { | ||
| 3261 | + if (!empty(call.arguments) && call.arguments[0] == arg && call is ExprInvoke) { | ||
| 3263 | 3262 | let inv = call as ExprInvoke; | |
| 3264 | 3263 | if (inv.isInvokeMethod) return false; | |
| 3265 | 3264 | } | |
@@ -3319,24 +3318,17 @@ class public CppAot : AstVisitor { | |||
| 3319 | 3318 | if (!polType.isHandle) { | |
| 3320 | 3319 | if (polType.isVecPolicyType && argType.isVecPolicyType) return false; | |
| 3321 | 3320 | } | |
| 3322 | - if (!polType.isPolicyType) return false; | ||
| 3323 | - return true; | ||
| 3321 | + return polType.isPolicyType; | ||
| 3324 | 3322 | } | |
| 3325 | 3323 | def policyResultNeedCast(polType : TypeDeclPtr; resType : TypeDeclPtr) { | |
| 3326 | - if (resType.isVoid) return false; | ||
| 3327 | - if (!resType.isPolicyType) return false; | ||
| 3324 | + if (resType.isVoid || !resType.isPolicyType) return false; | ||
| 3328 | 3325 | return policyArgNeedCast(polType, resType); | |
| 3329 | 3326 | } | |
| 3330 | 3327 | def isPolicyBasedCall(call : ExprCall?) { | |
| 3331 | 3328 | let bif = call.func as BuiltInFunction; | |
| 3332 | - if (call.arguments |> empty() && call.func.result.baseType == Type.tHandle) { | ||
| 3333 | - // c-tor? | ||
| 3334 | - return false; | ||
| 3335 | - } elif (bif.flags.policyBased) { | ||
| 3336 | - return true; | ||
| 3337 | - } else { | ||
| 3338 | - return false; | ||
| 3339 | - } | ||
| 3329 | + // empty arg ctor returning handle is NOT policy-based | ||
| 3330 | + if (call.arguments |> empty() && call.func.result.baseType == Type.tHandle) return false; | ||
| 3331 | + return bif.flags.policyBased; | ||
| 3340 | 3332 | } | |
| 3341 | 3333 | def isPolicyBasedCallFunc(call : ExprCallFunc?) { | |
| 3342 | 3334 | if (call.func.flags.builtIn) { | |
@@ -3354,12 +3346,10 @@ class public CppAot : AstVisitor { | |||
| 3354 | 3346 | if (func.flags.callBased) { | |
| 3355 | 3347 | panic("we should not be here. call-based calls handled elsewhere"); | |
| 3356 | 3348 | } | |
| 3357 | - return length(bif.cppName) == 0; | ||
| 3349 | + return empty(bif.cppName); | ||
| 3358 | 3350 | } | |
| 3359 | - if (func.flags.noAot) return true; | ||
| 3360 | - if (func.flags.aotHybrid) return true; | ||
| 3361 | - if (func._module == program.getThisModule) return false; | ||
| 3362 | - return true; | ||
| 3351 | + if (func.flags.noAot || func.flags.aotHybrid) return true; | ||
| 3352 | + return func._module != program.getThisModule; | ||
| 3363 | 3353 | } | |
| 3364 | 3354 | def needsArgPassType(argType : TypeDeclPtr) { | |
| 3365 | 3355 | return !argType.flags.constant && !argType.isGoodBlockType; | |
@@ -3448,7 +3438,7 @@ class public CppAot : AstVisitor { | |||
| 3448 | 3438 | } | |
| 3449 | 3439 | assume mangledName = call.func |> get_mangled_name(); | |
| 3450 | 3440 | let hash = call.func.getMangledNameHash; | |
| 3451 | - if (length(call.arguments) >= 1) { | ||
| 3441 | + if (!empty(call.arguments)) { | ||
| 3452 | 3442 | write(*ss, "<"); | |
| 3453 | 3443 | for (arg in call.func.arguments) { | |
| 3454 | 3444 | write(*ss, "{describeCppType(arg._type,DescribeConfig(cross_platform=cross_platform))}"); | |
@@ -3816,8 +3806,8 @@ def collectUsedFunctions(modules : array<Module?>; totalFunctions : int; this_mo | |||
| 3816 | 3806 | fnn.reserve(totalFunctions); | |
| 3817 | 3807 | for (pm in modules) { | |
| 3818 | 3808 | pm |> for_each_module_function($(pfun) { | |
| 3819 | - if (!all_modules && pfun._module != this_module) return ; | ||
| 3820 | - if (pfun.index < 0 || !pfun.flags.used) return ; | ||
| 3809 | + if ((!all_modules && pfun._module != this_module) | ||
| 3810 | + || pfun.index < 0 || !pfun.flags.used) return ; | ||
| 3821 | 3811 | if (!is_all) { | |
| 3822 | 3812 | if (pfun.flags.builtIn || pfun.flags.noAot) return ; | |
| 3823 | 3813 | } | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -53,8 +53,7 @@ def writeStandaloneContextMethods(var prog : ProgramPtr; var logs : StringBuilde | |||
| 53 | 53 | var coll = new BlockVariableCollector(); | |
| 54 | 54 | ||
| 55 | 55 | for (fn in fnn) { | |
| 56 | - if (!fn.flags.exports) continue; | ||
| 57 | - if (fn._module != prog.getThisModule) continue; | ||
| 56 | + if (!fn.flags.exports || fn._module != prog.getThisModule) continue; | ||
| 58 | 57 | if (declare_only) { | |
| 59 | 58 | write(logs, " "); | |
| 60 | 59 | } | |
@@ -232,8 +231,8 @@ class StandaloneContextGen : CppAot { | |||
| 232 | 231 | var globals : array<Variable?>; | |
| 233 | 232 | prog.get_ptr() |> for_each_module_no_order($(pm) { | |
| 234 | 233 | pm |> for_each_global($(pvar) { | |
| 235 | - if (pvar.index < 0 || !pvar.flags.used) return ; | ||
| 236 | - if (pvar._module == prog.getThisModule) return ; | ||
| 234 | + if (pvar.index < 0 || !pvar.flags.used | ||
| 235 | + || pvar._module == prog.getThisModule) return ; | ||
| 237 | 236 | globals.push(pvar); | |
| 238 | 237 | }); | |
| 239 | 238 | }); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -48,7 +48,7 @@ def for_each_subrange(total : int; blk : block<(r : range) : void>) { | |||
| 48 | 48 | [macro_function] | |
| 49 | 49 | def generateApplyVisitStruct(stype : TypeDeclPtr; frange : range; fnname : string; at : LineInfo; var names : array<string>; hasExtraArg : bool) { | |
| 50 | 50 | assert(stype.baseType == Type.tStructure) | |
| 51 | - assert(stype.dim |> length == 0) | ||
| 51 | + assert(empty(stype.dim)) | ||
| 52 | 52 | let nfields = frange.y - frange.x | |
| 53 | 53 | var selfT = clone_type(stype) | |
| 54 | 54 | selfT.flags |= TypeDeclFlags.isExplicit | TypeDeclFlags.explicitConst | |
@@ -124,7 +124,7 @@ def generateApplyVisitStruct(stype : TypeDeclPtr; fnname : string; at : LineInfo | |||
| 124 | 124 | [macro_function] | |
| 125 | 125 | def generateApplyVisitTuple(stype : TypeDeclPtr; frange : range; fnname : string; at : LineInfo; var names : array<string>) { | |
| 126 | 126 | assert(stype.baseType == Type.tTuple) | |
| 127 | - assert(stype.dim |> length == 0) | ||
| 127 | + assert(empty(stype.dim)) | ||
| 128 | 128 | let nfields = frange.y - frange.x | |
| 129 | 129 | var selfT = clone_type(stype) | |
| 130 | 130 | selfT.flags |= TypeDeclFlags.isExplicit | TypeDeclFlags.explicitConst | |
@@ -181,7 +181,7 @@ def generateApplyVisitTuple(stype : TypeDeclPtr; fnname : string; at : LineInfo) | |||
| 181 | 181 | [macro_function] | |
| 182 | 182 | def generateApplyVisitVariant(stype : TypeDeclPtr; frange : range; fnname : string; at : LineInfo; var names : array<string>) { | |
| 183 | 183 | assert(stype.baseType == Type.tVariant) | |
| 184 | - assert(stype.dim |> length == 0) | ||
| 184 | + assert(empty(stype.dim)) | ||
| 185 | 185 | let nfields = frange.y - frange.x | |
| 186 | 186 | var selfT = clone_type(stype) | |
| 187 | 187 | selfT.flags |= TypeDeclFlags.isExplicit | TypeDeclFlags.explicitConst | |
@@ -272,7 +272,7 @@ class ApplyMacro : AstCallMacro { | |||
| 272 | 272 | macro_verify(expr.arguments |> length == 2, prog, expr.at, "expecting apply(value, block)") | |
| 273 | 273 | if (expr.arguments[0]._type != null) {// need value inferred | |
| 274 | 274 | var argT = clone_type(expr.arguments[0]._type) | |
| 275 | - macro_verify(argT.dim |> length == 0, prog, expr.at, "can't apply to dim") | ||
| 275 | + macro_verify(empty(argT.dim), prog, expr.at, "can't apply to dim") | ||
| 276 | 276 | macro_verify(argT.baseType == Type.tStructure || argT.baseType == Type.tTuple || argT.baseType == Type.tVariant, | |
| 277 | 277 | prog, expr.at, "can only apply to {describe(expr.arguments[0]._type)}") | |
| 278 | 278 | macro_verify(expr.arguments[1] is ExprMakeBlock, prog, expr.at, "expecting make block, i.e. $(..)") | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -974,7 +974,7 @@ def add_new_optimization_macro(name : string; var someClassPtr) { | |||
| 974 | 974 | def find_module(prog : smart_ptr<Program>; name : string) : Module? { | |
| 975 | 975 | var rm : Module? | |
| 976 | 976 | program_for_each_module(prog) $(mod) { | |
| 977 | - if (string(mod.name) == name) { | ||
| 977 | + if (mod.name == name) { | ||
| 978 | 978 | rm = mod | |
| 979 | 979 | } | |
| 980 | 980 | } | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -79,9 +79,7 @@ def describe_function_short(func : FunctionPtr) { | |||
| 79 | 79 | ||
| 80 | 80 | def isExpression(t : TypeDeclPtr; top : bool = true) : bool { | |
| 81 | 81 | //! Returns true if the type declaration refers to an AST expression node type. | |
| 82 | - if (t == null) { | ||
| 83 | - return false | ||
| 84 | - } elif (t.dim |> length != 0) { | ||
| 82 | + if (t == null || !empty(t.dim)) { | ||
| 85 | 83 | return false | |
| 86 | 84 | } elif (t.baseType == Type.tHandle) { | |
| 87 | 85 | if (t.annotation._module.name == "ast_core") { | |
@@ -108,11 +106,11 @@ def is_same_or_inherited(parent, child : Structure const?) { | |||
| 108 | 106 | ||
| 109 | 107 | def is_class_method(cinfo : StructurePtr; finfo : TypeDeclPtr) { | |
| 110 | 108 | //! Returns true if the function type declaration is a method of the given class structure. | |
| 111 | - if (finfo.baseType != Type.tFunction) return false | ||
| 112 | - if (finfo.dim |> length != 0) return false | ||
| 113 | - if (finfo.argTypes |> length == 0) return false | ||
| 114 | - if (finfo.argTypes[0].baseType != Type.tStructure) return false | ||
| 115 | - if (finfo.argTypes[0].dim |> length != 0) return false | ||
| 109 | + if (finfo.baseType != Type.tFunction | ||
| 110 | + || !empty(finfo.dim) | ||
| 111 | + || empty(finfo.argTypes) | ||
| 112 | + || finfo.argTypes[0].baseType != Type.tStructure | ||
| 113 | + || !empty(finfo.argTypes[0].dim)) return false | ||
| 116 | 114 | return !!is_same_or_inherited(finfo.argTypes[0].structType, cinfo) | |
| 117 | 115 | } | |
| 118 | 116 | ||
@@ -848,7 +846,7 @@ def private walk_and_convert_enumeration(data : uint8 const?; info : TypeDeclPtr | |||
| 848 | 846 | def walk_and_convert(data : uint8 const?; info : TypeDeclPtr; at : LineInfo) : Expression? { | |
| 849 | 847 | //! Recursively converts raw data to an AST expression based on type information. | |
| 850 | 848 | // print("0x{intptr(data)} {describe(info)}\n") | |
| 851 | - if (info.dim |> length != 0) { | ||
| 849 | + if (!empty(info.dim)) { | ||
| 852 | 850 | return walk_and_convert_dim(data, info, at) | |
| 853 | 851 | } elif (info.baseType == Type.tArray) { | |
| 854 | 852 | return walk_and_convert_array(data, info, at) | |
@@ -1262,7 +1260,7 @@ def private debug_expression_impl(var writer : StringBuilderWriter; expr : Expre | |||
| 1262 | 1260 | } | |
| 1263 | 1261 | if (tstr == "$::dasvector`ptr`Expression") { | |
| 1264 | 1262 | let pv = unsafe(reinterpret<dasvector`ptr`Expression?> p8) | |
| 1265 | - if (length(*pv) != 0) { | ||
| 1263 | + if (!empty(*pv)) { | ||
| 1266 | 1264 | let ts = repeat(" ", tabs + 2) | |
| 1267 | 1265 | writer |> write("\n{ts}[{name}\n") | |
| 1268 | 1266 | for (l, i in *pv, count()) { | |
@@ -1276,7 +1274,7 @@ def private debug_expression_impl(var writer : StringBuilderWriter; expr : Expre | |||
| 1276 | 1274 | } | |
| 1277 | 1275 | } elif (tstr == "$::dasvector`ptr`Variable") { | |
| 1278 | 1276 | let pv = unsafe(reinterpret<dasvector`ptr`Variable?> p8) | |
| 1279 | - if (length(*pv) != 0) { | ||
| 1277 | + if (!empty(*pv)) { | ||
| 1280 | 1278 | let ts = repeat(" ", tabs + 2) | |
| 1281 | 1279 | writer |> write("\n{ts}[{name}\n") | |
| 1282 | 1280 | for (l, i in *pv, count()) { | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -25,17 +25,21 @@ def report_to_debugger(var ctx : Context; category, name : string; value : auto( | |||
| 25 | 25 | def isExpressionType(_vinfo) { | |
| 26 | 26 | if (_vinfo.basicType != Type.tPointer || _vinfo.firstType == null) return false | |
| 27 | 27 | let vinfo = _vinfo.firstType | |
| 28 | - if (vinfo.basicType != Type.tHandle) return false | ||
| 29 | - if (vinfo.annotation._module.name != "ast_core") return false | ||
| 30 | - return !!string(vinfo.annotation.name) |> starts_with("Expr") | ||
| 28 | + if (vinfo.basicType != Type.tHandle | ||
| 29 | + || vinfo.annotation._module.name != "ast_core") return false | ||
| 30 | + var result = false | ||
| 31 | + peek(vinfo.annotation.name) $(n) { | ||
| 32 | + result = n |> starts_with("Expr") | ||
| 33 | + } | ||
| 34 | + return result | ||
| 31 | 35 | } | |
| 32 | 36 | ||
| 33 | 37 | def isModulePtrType(_vinfo; mod, what : string) { | |
| 34 | 38 | if (_vinfo.basicType != Type.tPointer || _vinfo.firstType == null) return false | |
| 35 | 39 | let vinfo = _vinfo.firstType | |
| 36 | - if (vinfo.basicType != Type.tHandle) return false | ||
| 37 | - if (vinfo.annotation._module.name != mod) return false | ||
| 38 | - return !(vinfo.annotation.name != what) | ||
| 40 | + if (vinfo.basicType != Type.tHandle | ||
| 41 | + || vinfo.annotation._module.name != mod) return false | ||
| 42 | + return vinfo.annotation.name == what | ||
| 39 | 43 | } | |
| 40 | 44 | ||
| 41 | 45 | def isAstPtrType(_vinfo; what : string) { | |
@@ -47,9 +51,9 @@ def isRttiPtrType(_vinfo; what : string) { | |||
| 47 | 51 | } | |
| 48 | 52 | ||
| 49 | 53 | def isRttiType(vinfo; what : string) { | |
| 50 | - if (vinfo.basicType != Type.tHandle) return false | ||
| 51 | - if (vinfo.annotation._module.name != "rtti_core") return false | ||
| 52 | - return !(vinfo.annotation.name != what) | ||
| 54 | + if (vinfo.basicType != Type.tHandle | ||
| 55 | + || vinfo.annotation._module.name != "rtti_core") return false | ||
| 56 | + return vinfo.annotation.name == what | ||
| 53 | 57 | } | |
| 54 | 58 | ||
| 55 | 59 | def describe_arg(var ctxid : Context; vinfo; arg : void?) : void { | |
| Back | FazBrowse Home | New Git URL |
0 commit comments