diff --git a/.gitattributes b/.gitattributes index 559365ce63d..5953177325f 100644 --- a/.gitattributes +++ b/.gitattributes @@ -52,6 +52,12 @@ java/ql/test/stubs/**/*.java linguist-generated=true java/ql/test/experimental/stubs/**/*.java linguist-generated=true +# For some languages, upgrade script testing references really old dbscheme +# files from legacy upgrades that have CRLF line endings. Since upgrade +# resolution relies on object hashes, we must suppress line ending conversion +# for those testing dbscheme files. +*/ql/lib/upgrades/initial/*.dbscheme -text + # Generated test files - these are synced from the standard JavaScript libraries using # `javascript/ql/experimental/adaptivethreatmodeling/test/update_endpoint_test_files.py`. javascript/ql/experimental/adaptivethreatmodeling/test/endpoint_large_scale/autogenerated/**/*.js linguist-generated=true -merge diff --git a/cpp/ql/lib/upgrades/initial/semmlecode.cpp.dbscheme b/cpp/ql/lib/upgrades/initial/semmlecode.cpp.dbscheme new file mode 100644 index 00000000000..454f1e15151 --- /dev/null +++ b/cpp/ql/lib/upgrades/initial/semmlecode.cpp.dbscheme @@ -0,0 +1,1111 @@ +/* + * External artifacts + */ + +externalDefects( + unique int id : @externalDefect, + varchar(900) queryPath : string ref, + int location : @location_default ref, + varchar(900) message : string ref, + float severity : float ref +); + +externalMetrics( + unique int id : @externalMetric, + varchar(900) queryPath : string ref, + int location : @location_default ref, + float value : float ref +); + +externalData( + int id : @externalDataElement, + varchar(900) path : string ref, + int column: int ref, + varchar(900) value : string ref +); + +snapshotDate(unique date snapshotDate : date ref); + +sourceLocationPrefix(varchar(900) prefix : string ref); + +/* + * Duplicate code + */ + +duplicateCode( + unique int id : @duplication, + varchar(900) relativePath : string ref, + int equivClass : int ref); + +similarCode( + unique int id : @similarity, + varchar(900) relativePath : string ref, + int equivClass : int ref); + +@duplication_or_similarity = @duplication | @similarity + +tokens( + int id : @duplication_or_similarity ref, + int offset : int ref, + int beginLine : int ref, + int beginColumn : int ref, + int endLine : int ref, + int endColumn : int ref); + +/* + * Version history + */ + +svnentries( + int id : @svnentry, + varchar(500) revision : string ref, + varchar(500) author : string ref, + date revisionDate : date ref, + int changeSize : int ref +) + +svnaffectedfiles( + int id : @svnentry ref, + int file : @file ref, + varchar(500) action : string ref +) + +svnentrymsg( + int id : @svnentry ref, + varchar(500) message : string ref +) + +svnchurn( + int commit : @svnentry ref, + int file : @file ref, + int churnedLines : int ref +) + +/* + * C++ dbscheme + */ + +@location = @location_stmt | @location_expr | @location_default ; + +locations_default(unique int id: @location_default, + int file: @file ref, + int beginLine: int ref, + int beginColumn: int ref, + int endLine: int ref, + int endColumn: int ref); + +locations_stmt(unique int id: @location_stmt, + int file: @file ref, + int beginLine: int ref, + int beginColumn: int ref, + int endLine: int ref, + int endColumn: int ref); + +locations_expr(unique int id: @location_expr, + int file: @file ref, + int beginLine: int ref, + int beginColumn: int ref, + int endLine: int ref, + int endColumn: int ref); + +@sourceline = @file | @function | @variable | @enumconstant; + +numlines(unique int element_id: @sourceline ref, + int num_lines: int ref, + int num_code: int ref, + int num_comment: int ref + ); + +diagnostics(unique int id: @diagnostic, + int severity: int ref, + varchar(900) error_tag: string ref, + varchar(900) error_message: string ref, + int location: @location_default ref); + +/* + fromSource(0) = unknown, + fromSource(1) = from source, + fromSource(2) = from library +*/ +files(unique int id: @file, + varchar(900) name: string ref, + varchar(900) simple: string ref, + varchar(900) ext: string ref, + int fromSource: int ref); + +folders(unique int id: @folder, + varchar(900) name: string ref, + varchar(900) simple: string ref); + +@container = @folder | @file + +containerparent(int parent: @container ref, + unique int child: @container ref); + +fileannotations(int id: @file ref, + int kind: int ref, + varchar(900) name: string ref, + varchar(900) value: string ref); + +inmacroexpansion(int id: @element ref, + int inv: @macroinvocation ref); + +macroinvocations(unique int id: @macroinvocation, + int macro_id: @ppd_define ref, + int location: @location_default ref); + +macroparent(unique int id: @macroinvocation ref, + int parent_id: @macroinvocation ref); + +// a macroinvocation may be part of another location +// the way to find a constant expression that uses a macro +// is thus to find a constant expression that has a location +// to which a macro invocation is bound +macrolocationbind(int id: @macroinvocation ref, + int location: @location ref); + +/* + case @function.kind of + 1 = normal + | 2 = constructor + | 3 = destructor + | 4 = conversion + | 5 = operator + | 6 = builtin // GCC built-in functions, e.g. __builtin___memcpy_chk + ; +*/ +functions(unique int id: @function, + varchar(900) name: string ref, + int kind: int ref); + +function_return_type(int id: @function ref, int return_type: @type ref); + +purefunctions(unique int id: @function ref); + + + +fun_decls(unique int id: @fun_decl, + int function: @function ref, + int type_id: @type ref, + varchar(900) name: string ref, + int location: @location_default ref); +fun_def(unique int id: @fun_decl ref); +fun_decl_specifiers(int id: @fun_decl ref, + varchar(900) name: string ref) +fun_decl_throws(int fun_decl: @fun_decl ref, + int index: int ref, + int type_id: @type ref); +/* an empty throw specification is different from none */ +fun_decl_empty_throws(unique int fun_decl: @fun_decl ref); +fun_decl_noexcept(int fun_decl: @fun_decl ref, + int constant: @expr ref); +fun_decl_empty_noexcept(int fun_decl: @fun_decl ref); +fun_decl_typedef_type(unique int fun_decl: @fun_decl ref, + int typedeftype_id: @usertype ref); + +param_decl_bind(unique int id: @var_decl ref, + int index: int ref, + int fun_decl: @fun_decl ref); + +var_decls(unique int id: @var_decl, + int variable: @variable ref, + int type_id: @type ref, + varchar(900) name: string ref, + int location: @location_default ref); +var_def(unique int id: @var_decl ref); +var_decl_specifiers(int id: @var_decl ref, + varchar(900) name: string ref) + +type_decls(unique int id: @type_decl, + int type_id: @type ref, + int location: @location_default ref); +type_def(unique int id: @type_decl ref); +type_decl_specifiers(int id: @type_decl ref, + varchar(900) name: string ref) + +namespace_decls(unique int id: @namespace_decl, + int namespace_id: @namespace ref, + int location: @location_default ref, + int bodylocation: @location_default ref); + +usings(unique int id: @using, + int element_id: @element ref, + int container: @element ref, + int location: @location_default ref); + +// each function has an ordered list of parameters +params(unique int id: @parameter, + int function: @functionorblock ref, + int index: int ref, + int type_id: @type ref); + +overrides(int new: @function ref, int old: @function ref); + +membervariables(unique int id: @membervariable, + int type_id: @type ref, + varchar(900) name: string ref); + +properties(unique int id: @property, + int type_id: @type ref, + varchar(900) name: string ref, + int getter: @function ref); + +property_setter(int prop: @property ref, int setter: @function ref); +property_synthesis(int prop: @property ref, int ivar: @membervariable ref); +property_attribute(int prop: @property ref, int attr: @attribute ref); +property_decl_location(int prop: @property ref, int loc: @location_default ref); + +globalvariables(unique int id: @globalvariable, + int type_id: @type ref, + varchar(900) name: string ref); + +localvariables(unique int id: @localvariable, + int type_id: @type ref, + varchar(900) name: string ref); + +autoderivation(unique int var: @variable ref, + int derivation_type: @type ref); + +enumconstants(unique int id: @enumconstant, + int parent: @usertype ref, + int index: int ref, + int type_id: @type ref, + varchar(900) name: string ref, + int location: @location_default ref); + +@variable = @localvariable | @globalvariable | @membervariable | @parameter; + + +/* + Built-in types are the fundamental types, i.e., integral, floating, and void. + kind(1) = error, kind(2) = unknown, kind(3) = void, kind(4) = boolean, + kind(5) = char, kind(6) = unsigned char, kind(7) = signed char + kind(8) = short, kind(9) = unsigned short, kind(10) = signed short + kind(11) = int, kind(12) = unsigned int, kind(13) = signed int, + kind(14) = long, kind(15) = unsigned long, kind(16) = signed long, + kind(17) = long long, kind(18) = unsigned long long, kind(19) = signed long long, + kind(20) = __int8, kind(21) = __int16, kind(22) = __int32, kind(23) = __int64, // Microsoft specific + kind(24) = float, kind(25) = double, kind(26) = long double, + kind(27) = _Complex float, kind(28) = _Complex double, kind(29) = _Complex long double, //C99 specific + kind(30) = _Imaginary float, kind(31) = _Imaginary double, kind(32) = _Imaginary long double, //C99 specific + kind(33) = wchar_t, // MS specific + kind(34) = decltype(nullptr), // C++11 +*/ +builtintypes(unique int id: @builtintype, + varchar(900) name: string ref, + int kind: int ref, + int size: int ref, + int sign: int ref); + +pointersize(unique int size: int ref); + +/* + Derived types are types that are directly derived from existing types and + point to, refer to, transform type data to return a new type. + + case @derivedtype.kind of + 1 = pointer + | 2 = reference + | 3 = type_with_specifiers + | 4 = array + | 5 = gnu_vector + | 6 = routineptr + | 7 = routinereference + | 8 = rvalue_reference // C++11 + | 9 = type_conforming_to_protocols // ObjC + | 10 = block + ; +*/ +derivedtypes(unique int id: @derivedtype, + varchar(900) name: string ref, + int kind: int ref, + int type_id: @type ref); + +arraysizes(unique int id: @derivedtype ref, + int num_elements: int ref, + int bytesize: int ref, + int alignment: int ref); + +typedefbase(unique int id: @usertype ref, + int type_id: @type ref); + +decltypes(unique int id: @decltype, + int expr: @expr ref, + int base_type: @type ref, + boolean parentheses_would_change_meaning: boolean ref); + +/* + case @usertype.kind of + 1 = struct + | 2 = class + | 3 = union + | 4 = enum + | 5 = typedef + | 6 = template + | 7 = template_parameter + | 8 = template_template_parameter + | 9 = proxy_class // a proxy class associated with a template parameter + | 10 = objc_class + | 11 = objc_protocol + | 12 = objc_category + ; +*/ +usertypes(unique int id: @usertype, + varchar(900) name: string ref, + int kind: int ref); + +usertypesize(unique int id: @usertype ref, + int size: int ref, + int alignment: int ref); + +usertype_final(unique int id: @usertype ref); + +is_class_template(unique int id: @usertype ref); +class_instantiation(unique int to: @usertype ref, + int from: @usertype ref); +class_template_argument(int type_id: @usertype ref, + int index: int ref, + int arg_type: @type ref); + +is_proxy_class_for(unique int id: @usertype ref, + unique int templ_param_id: @usertype ref); + +is_function_template(unique int id: @function ref); +function_instantiation(unique int to: @function ref, + int from: @function ref); +function_template_argument(int function_id: @function ref, + int index: int ref, + int arg_type: @type ref); + +/* + Fixed point types + precision(1) = short, precision(2) = default, precision(3) = long + is_unsigned(1) = unsigned is_unsigned(2) = signed + is_fract_type(1) = declared with _Fract + saturating(1) = declared with _Sat +*/ +/* TODO +fixedpointtypes(unique int id: @fixedpointtype, + int precision: int ref, + int is_unsigned: int ref, + int is_fract_type: int ref, + int saturating: int ref); +*/ + +routinetypes(unique int id: @routinetype, + int return_type: @type ref); + +routinetypeargs(int routine: @routinetype ref, + int index: int ref, + int type_id: @type ref); + +ptrtomembers(unique int id: @ptrtomember, + int type_id: @type ref, + int class_id: @type ref); + +/* + specifiers for types, functions, and variables + + "public", + "protected", + "private", + + "const", + "volatile", + "static", + + "pure", + "virtual", + "sealed", // Microsoft + "__interface", // Microsoft + "inline", + "explicit", + + "near", // near far extension + "far", // near far extension + "__ptr32", // Microsoft + "__ptr64", // Microsoft + "__sptr", // Microsoft + "__uptr", // Microsoft + "dllimport", // Microsoft + "dllexport", // Microsoft + "thread", // Microsoft + "naked", // Microsoft + "microsoft_inline", // Microsoft + "forceinline", // Microsoft + "selectany", // Microsoft + "nothrow", // Microsoft + "novtable", // Microsoft + "noreturn", // Microsoft + "noinline", // Microsoft + "noalias", // Microsoft + "restrict", // Microsoft +*/ + +/* REMOVE +typerefs(unique int id: @typeref, + int type_id: @type ref); +*/ + +specifiers(unique int id: @specifier, + unique varchar(900) str: string ref); + +typespecifiers(int type_id: @type ref, + int spec_id: @specifier ref); + +/* REMOVE +typerefspecs(int type_ref_id: @typeref ref, + int spec_id: @specifier ref); +*/ + +funspecifiers(int func_id: @function ref, + int spec_id: @specifier ref); + +varspecifiers(int var_id: @accessible ref, + int spec_id: @specifier ref); + +@specifiable = /* REMOVE @typeref |*/ @type | @function | @variable | @enumconstant | @frienddecl; + +attributes(unique int id: @attribute, + int kind: int ref, + varchar(100) name: string ref, + varchar(100) name_space: string ref, + int location: @location_default ref); + +case @attribute.kind of + 0 = @gnuattribute +| 1 = @stdattribute +| 2 = @declspec +| 3 = @msattribute +| 4 = @alignas +| 5 = @objc_propertyattribute +; + +attribute_args(unique int id: @attribute_arg, + int kind: int ref, + int attribute: @attribute ref, + int index: int ref, + int location: @location_default ref); + +case @attribute_arg.kind of + 0 = @attribute_arg_empty +| 1 = @attribute_arg_token +| 2 = @attribute_arg_constant +| 3 = @attribute_arg_type +; + +attribute_arg_value(unique int arg: @attribute_arg ref, varchar(100) value: string ref); +attribute_arg_type(unique int arg: @attribute_arg ref, int type_id: @type ref); +attribute_arg_name(unique int arg: @attribute_arg ref, varchar(100) name: string ref); + +typeattributes(int type_id: @type ref, + int spec_id: @attribute ref); + +funcattributes(int func_id: @function ref, + int spec_id: @attribute ref); + +varattributes(int var_id: @accessible ref, + int spec_id: @attribute ref); + +stmtattributes(int stmt_id: @stmt ref, + int spec_id: @attribute ref); + +@type = @builtintype | @derivedtype | @usertype /* TODO | @fixedpointtype */ | @routinetype | @ptrtomember | @decltype; + +member(int parent: @type ref, + int index: int ref, + int child: @member ref); + +enclosingfunction(unique int child: @usertype ref, + int parent: @function ref); + +derivations(unique int derivation: @derivation, + int sub: @type ref, + int index: int ref, + int super: @type ref, + int location: @location_default ref); + +derspecifiers(int der_id: @derivation ref, + int spec_id: @specifier ref); + +frienddecls(unique int id: @frienddecl, + int type_id: @type ref, + int decl_id: @declaration ref, + int location: @location_default ref); + +conforming_to_protocols(int type_id: @type ref, + int protocol: @usertype ref); + +@declaredtype = @usertype ; + +@declaration = @function | @declaredtype | @variable | @enumconstant | @frienddecl | @property; + +@member = @membervariable | @function | @declaredtype | @enumconstant | @property; + +@locatable = @diagnostic | @declaration | @ppd_include | @ppd_define | @macroinvocation /*| @funcall*/ | @xmllocatable | @attribute | @attribute_arg; + +@scope = @stmt | @function | @namedscope; +@namedscope = @namespace | @usertype; + +@element = @locatable | @file | @folder | @specifier | @type | @expr /* | @typeref */ | @namespace | @initialiser | @stmt | @derivation | @comment | @preprocdirect | @fun_decl | @var_decl | @type_decl | @namespace_decl | @using | @namequalifier | @specialnamequalifyingelement | @externalDefect | @externalMetric; + +@exprparent = @element; + +comments(unique int id: @comment, + varchar(900) contents: string ref, + int location: @location_default ref); + +commentbinding(unique int id: @comment ref, + int element: @element ref); + +exprconv(int converted: @expr ref, + unique int conversion: @expr ref); + +compgenerated(unique int id: @element ref); + + +namespaces(unique int id: @namespace, + varchar(900) name: string ref); + +namespacembrs(int parentid: @namespace ref, + unique int memberid: @namespacembr ref); + +@namespacembr = @declaration | @namespace; + +exprparents(int expr_id: @expr ref, + int child_index: int ref, + int parent_id: @exprparent ref); + +/* +case @funbindexpr.kind of + 0 = @normal_call // a normal call +| 1 = @virtual_call // a virtual call +| 2 = @adl_call // a call whose target is only found by ADL +; +*/ +iscall(unique int caller: @funbindexpr ref, int kind: int ref); + +numtemplatearguments(unique int expr_id: @expr ref, + int num: int ref); + +specialnamequalifyingelements(unique int id: @specialnamequalifyingelement, + unique varchar(900) name: string ref); + +@namequalifiableelement = @expr | @namequalifier; +@namequalifyingelement = @namespace | @specialnamequalifyingelement | @usertype; + +namequalifiers(unique int id: @namequalifier, + unique int qualifiableelement: @namequalifiableelement ref, + int qualifyingelement: @namequalifyingelement ref, + int location: @location_default ref); + +varbind(unique int expr: @varbindexpr ref, + int var: @accessible ref); + +funbind(unique int expr: @funbindexpr ref, + int fun: @function ref); + +// the second field is a string representation of the value +// the third field is the actual text in the source or the same as the second field +values(unique int id: @value, + varchar(900) str: string ref, + varchar(900) text: string ref); + +valuebind(int val: @value ref, + unique int expr: @expr ref); + +objc_string(int lit: @literal ref); + +fieldoffsets(unique int id: @variable ref, + int byteoffset: int ref, + int bitoffset: int ref); + +bitfield(unique int id: @variable ref, + int bits: int ref, + int declared_bits: int ref); + +/* REMOVE +varrefbind(int var: @variable ref, + int expr: @varref ref); +*/ + +/* REMOVE +funrefbind(int fun: @function ref, + int expr: @funref ref); +*/ + +/* TODO +memberprefix(int member: @expr ref, + int prefix: @expr ref); +*/ + +/* + kind(1) = mbrcallexpr + kind(2) = mbrptrcallexpr + kind(3) = mbrptrmbrcallexpr + kind(4) = ptrmbrptrmbrcallexpr + kind(5) = mbrreadexpr // x.y + kind(6) = mbrptrreadexpr // p->y + kind(7) = mbrptrmbrreadexpr // x.*pm + kind(8) = mbrptrmbrptrreadexpr // x->*pm + kind(9) = staticmbrreadexpr // static x.y + kind(10) = staticmbrptrreadexpr // static p->y +*/ +/* TODO +memberaccess(int member: @expr ref, + int kind: int ref); +*/ + +initialisers(unique int init: @initialiser, + int var: @accessible ref, + unique int expr: @expr ref, + int location: @location_expr ref); + +exprcontainers(int exp: @expr ref, + int container: @exprcontainer ref); + +@exprcontainer = @function | @variable | @enumconstant | @usertype; + +exprs(unique int id: @expr, + int kind: int ref, + int typeid: @type ref, + int location: @location_expr ref); + +case @expr.kind of + 1 = @errorexpr +| 2 = @address_of // & AddressOfExpr +| 3 = @reference_to // ReferenceToExpr (implicit?) +| 4 = @indirect // * PointerDereferenceExpr +| 5 = @ref_indirect // ReferenceDereferenceExpr (implicit?) +// ... +| 8 = @array_to_pointer // (???) +| 9 = @vacuous_destructor_call // VacuousDestructorCall +// ... +| 11 = @assume // Microsoft +| 12 = @parexpr +| 13 = @arithnegexpr +| 14 = @unaryplusexpr +| 15 = @complementexpr +| 16 = @notexpr +| 17 = @conjugation // GNU ~ operator +| 18 = @realpartexpr // GNU __real +| 19 = @imagpartexpr // GNU __imag +| 20 = @postincrexpr +| 21 = @postdecrexpr +| 22 = @preincrexpr +| 23 = @predecrexpr +| 24 = @conditionalexpr +| 25 = @addexpr +| 26 = @subexpr +| 27 = @mulexpr +| 28 = @divexpr +| 29 = @remexpr +| 30 = @jmulexpr // C99 mul imaginary +| 31 = @jdivexpr // C99 div imaginary +| 32 = @fjaddexpr // C99 add real + imaginary +| 33 = @jfaddexpr // C99 add imaginary + real +| 34 = @fjsubexpr // C99 sub real - imaginary +| 35 = @jfsubexpr // C99 sub imaginary - real +| 36 = @paddexpr // pointer add (pointer + int or int + pointer) +| 37 = @psubexpr // pointer sub (pointer - integer) +| 38 = @pdiffexpr // difference between two pointers +| 39 = @lshiftexpr +| 40 = @rshiftexpr +| 41 = @andexpr +| 42 = @orexpr +| 43 = @xorexpr +| 44 = @eqexpr +| 45 = @neexpr +| 46 = @gtexpr +| 47 = @ltexpr +| 48 = @geexpr +| 49 = @leexpr +| 50 = @minexpr // GNU minimum +| 51 = @maxexpr // GNU maximum +| 52 = @assignexpr +| 53 = @assignaddexpr +| 54 = @assignsubexpr +| 55 = @assignmulexpr +| 56 = @assigndivexpr +| 57 = @assignremexpr +| 58 = @assignlshiftexpr +| 59 = @assignrshiftexpr +| 60 = @assignandexpr +| 61 = @assignorexpr +| 62 = @assignxorexpr +| 63 = @assignpaddexpr // assign pointer add +| 64 = @assignpsubexpr // assign pointer sub +| 65 = @andlogicalexpr +| 66 = @orlogicalexpr +| 67 = @commaexpr +| 68 = @subscriptexpr // access to member of an array, e.g., a[5] +| 69 = @objc_subscriptexpr // ObjC custom subscripting +// ... +| 73 = @virtfunptrexpr +| 74 = @callexpr +| 75 = @msgexpr_normal // Objective C +| 76 = @msgexpr_super // Objective C +| 77 = @atselectorexpr // Objective C +| 78 = @atprotocolexpr // Objective C +| 79 = @vastartexpr +| 80 = @vaargexpr +| 81 = @vaendexpr +| 82 = @vacopyexpr +| 83 = @atencodeexpr // Objective C +| 84 = @varaccess +| 85 = @thisaccess +| 86 = @objc_box_expr // Objective C +| 87 = @new_expr +| 88 = @delete_expr +| 89 = @throw_expr +| 90 = @condition_decl // a variable declared in a condition, e.g., if(int x = y > 2) +// ... +| 92 = @type_id +| 93 = @runtime_sizeof +| 94 = @runtime_alignof +// ... +| 96 = @expr_stmt // GNU extension +| 97 = @routineexpr +| 98 = @type_operand // used to access a type in certain contexts (haven't found any examples yet....) +| 99 = @offsetofexpr // offsetof ::= type and field +| 100 = @hasassignexpr // __has_assign ::= type +| 101 = @hascopyexpr // __has_copy ::= type +| 102 = @hasnothrowassign // __has_nothrow_assign ::= type +| 103 = @hasnothrowconstr // __has_nothrow_constructor ::= type +| 104 = @hasnothrowcopy // __has_nothrow_copy ::= type +| 105 = @hastrivialassign // __has_trivial_assign ::= type +| 106 = @hastrivialconstr // __has_trivial_constructor ::= type +| 107 = @hastrivialcopy // __has_trivial_copy ::= type +| 108 = @hasuserdestr // __has_user_destructor ::= type +| 109 = @hasvirtualdestr // __has_virtual_desctructor ::= type +| 110 = @isabstractexpr // __is_abstract ::= type +| 111 = @isbaseofexpr // __is_base_of ::= type type +| 112 = @isclassexpr // __is_class ::= type +| 113 = @isconvtoexpr // __is_convertible_to ::= type type +| 114 = @isemptyexpr // __is_empty ::= type +| 115 = @isenumexpr // __is_enum ::= type +| 116 = @ispodexpr // __is_pod ::= type +| 117 = @ispolyexpr // __is_polymorphic ::= type +| 118 = @isunionexpr // __is_union ::= type +| 119 = @typescompexpr // GNU __builtin_types_compatible ::= type type +| 120 = @intaddrexpr // EDG internal builtin, used to implement offsetof +// ... +| 122 = @hastrivialdestructor // __has_trivial_destructor ::= type +| 123 = @literal +| 127 = @aggregateliteral +| 128 = @delete_array_expr +| 129 = @new_array_expr +| 130 = @objc_array_literal +| 131 = @objc_dictionary_literal +// ... +| 200 = @ctordirectinit +| 201 = @ctorvirtualinit +| 202 = @ctorfieldinit +| 203 = @ctordelegatinginit +| 204 = @dtordirectdestruct +| 205 = @dtorvirtualdestruct +| 206 = @dtorfielddestruct +// ... +| 210 = @static_cast +| 211 = @reinterpret_cast +| 212 = @const_cast +| 213 = @dynamic_cast +| 214 = @c_style_cast +| 215 = @lambdaexpr +| 216 = @param_ref +| 217 = @noopexpr +// ... +| 294 = @istriviallyconstructibleexpr +| 295 = @isdestructibleexpr +| 296 = @isnothrowdestructibleexpr +| 297 = @istriviallydestructibleexpr +| 298 = @istriviallyassignableexpr +| 299 = @isnothrowassignableexpr +| 300 = @istrivialexpr +| 301 = @isstandardlayoutexpr +| 302 = @istriviallycopyableexpr +| 303 = @isliteraltypeexpr +| 304 = @hastrivialmoveconstructorexpr +| 305 = @hastrivialmoveassignexpr +| 306 = @hasnothrowmoveassignexpr +| 307 = @isconstructibleexpr +| 308 = @isnothrowconstructibleexpr +| 309 = @hasfinalizerexpr +| 310 = @isdelegateexpr +| 311 = @isinterfaceclassexpr +| 312 = @isrefarrayexpr +| 313 = @isrefclassexpr +| 314 = @issealedexpr +| 315 = @issimplevalueclassexpr +| 316 = @isvalueclassexpr +| 317 = @isfinalexpr +| 319 = @noexceptexpr +; + +@ctorinit = @ctordirectinit | @ctorvirtualinit | @ctorfieldinit | @ctordelegatinginit; +@dtordestruct = @dtordirectdestruct | @dtorvirtualdestruct | @dtorfielddestruct; + +@msgexpr = @msgexpr_normal | @msgexpr_super; +msgexpr_selector(unique int expr: @msgexpr ref, varchar(64) selector : string ref); +msgexpr_receiver_type(unique int expr: @msgexpr_normal ref, int receiver : @type ref); +msgexpr_for_property(unique int expr: @msgexpr_normal ref); + +atselectorexpr_selector(unique int expr: @atselectorexpr ref, varchar(64) selector : string ref); + +atprotocolexpr_protocol(unique int expr: @atprotocolexpr ref, int protocol : @usertype ref); + +atencodeexpr_type(unique int expr: @atencodeexpr ref, int the_type : @type ref); + +condition_decl_bind(unique int expr: @condition_decl ref, + unique int decl: @declaration ref); + +typeid_bind(unique int expr: @type_id ref, + int type_id: @type ref); + +@runtime_sizeof_or_alignof = @runtime_sizeof | @runtime_alignof; + +sizeof_bind(unique int expr: @runtime_sizeof_or_alignof ref, + int type_id: @type ref); + +code_block(unique int block: @literal ref, + unique int routine: @function ref); + +lambdas(unique int expr: @lambdaexpr ref, + varchar(1) default_capture: string ref, + boolean has_explicit_return_type: boolean ref); + +lambda_capture(unique int id: @lambdacapture, + int lambda: @lambdaexpr ref, + int index: int ref, + boolean captured_by_reference: boolean ref, + boolean is_implicit: boolean ref, + int location: @location_default ref); + +@funbindexpr = @routineexpr | @new_expr | @delete_expr | @delete_array_expr | @ctordirectinit | @ctorvirtualinit | @ctordelegatinginit | @dtordirectdestruct | @dtorvirtualdestruct | @msgexpr; + +@varbindexpr = @varaccess | @ctorfieldinit | @dtorfielddestruct; +@addressable = @function | @variable ; +@accessible = @addressable | @enumconstant ; +@callable = @function | @variable; // only for variables with routine types + + +stmts(unique int id: @stmt, + int kind: int ref, + int location: @location_stmt ref); + +case @stmt.kind of + 1 = @stmt_expr +| 2 = @stmt_if +| 3 = @stmt_while +| 4 = @stmt_goto +| 5 = @stmt_label +| 6 = @stmt_return +| 7 = @stmt_block +| 8 = @stmt_end_test_while // do { ... } while ( ... ) +| 9 = @stmt_for +| 10 = @stmt_switch_case +| 11 = @stmt_switch +| 13 = @stmt_asm // "asm" statement or the body of an asm function +| 15 = @stmt_try_block +| 16 = @stmt_microsoft_try // Microsoft +| 17 = @stmt_decl +| 18 = @stmt_set_vla_size // C99 +| 19 = @stmt_vla_decl // C99 +| 25 = @stmt_assigned_goto // GNU +| 26 = @stmt_empty +| 27 = @stmt_continue +| 28 = @stmt_break +| 29 = @stmt_range_based_for // C++11 +| 30 = @stmt_at_autoreleasepool_block // Objective C +| 31 = @stmt_objc_for_in // Objective C +| 32 = @stmt_at_synchronized // Objective C +; + +objc_for_in(unique int loop: @stmt_objc_for_in ref, + int collection: @expr ref, + int condition: @expr ref, + int body: @stmt ref); + +@stmtparent = @stmt | @expr_stmt ; +stmtparents(unique int id: @stmt ref, + int index: int ref, + int parent: @stmtparent ref); + +ishandler(unique int block: @stmt_block ref); +isfinally(unique int block: @stmt_block ref); + +is_objc_try_stmt(unique int try: @stmt ref); +is_objc_throw(unique int throw: @throw_expr ref); + +@cfgnode = @stmt | @expr | @function | @initialiser ; +successors(int from: @cfgnode ref, + int to: @cfgnode ref); + +truecond(unique int from: @cfgnode ref, + int to: @cfgnode ref); + +falsecond(unique int from: @cfgnode ref, + int to: @cfgnode ref); + +stmtfunction(unique int stmt: @stmt ref, + int fun: @function ref); + +stmt_decl_bind(int stmt: @stmt_decl ref, + int decl: @declaration ref); + +@functionorblock = @function | @stmt_block; + +blockscope(int block: @stmt_block ref, + int enclosing: @functionorblock ref); + +@jump = @stmt_goto | @stmt_break | @stmt_continue; + +@jumporlabel = @jump | @stmt_label | @literal; + +jumpinfo(unique int id: @jumporlabel ref, + varchar(900) str: string ref, + int target: @stmt ref); + +preprocdirects(unique int id: @preprocdirect, + int kind: int ref, + int location: @location_default ref); +case @preprocdirect.kind of + 0 = @ppd_if +| 1 = @ppd_ifdef +| 2 = @ppd_ifndef +| 3 = @ppd_elif +| 4 = @ppd_else +| 5 = @ppd_endif +| 6 = @ppd_plain_include +| 7 = @ppd_define +| 8 = @ppd_undef +| 9 = @ppd_line +| 10 = @ppd_error +| 11 = @ppd_pragma +| 12 = @ppd_objc_import +| 13 = @ppd_include_next +| 18 = @ppd_warning +; + +@ppd_include = @ppd_plain_include | @ppd_objc_import | @ppd_include_next; + +@ppd_branch = @ppd_if | @ppd_ifdef | @ppd_ifndef | @ppd_elif; + +preprocpair(int begin : @ppd_branch ref, + int end : @ppd_endif ref); + +preproctrue(int branch : @ppd_branch ref); +preprocfalse(int branch : @ppd_branch ref); + +preproctext(unique int id: @preprocdirect ref, + varchar(900) head: string ref, + varchar(900) body: string ref); + +includes(unique int id: @ppd_include ref, + int included: @file ref); + +/* Definitions and uses */ + +#computed +definitionUsePair( + int var : @variable ref, + int def : @cfgnode ref, + int use : @expr ref); + +#computed +definitionReaches( + int def : @cfgnode ref, + int node : @cfgnode ref); + +#computed +useUsePair( + int v : @variable ref, + int first : @expr ref, + int second : @expr ref); + +#computed +directUseUsePair( + int v : @variable ref, + int first : @expr ref, + int second : @expr ref); + +/* Nullness information */ + +#computed +nullCheckExpr( + int e : @expr ref, + int var : @variable ref); + +#computed +validCheckExpr( + int e : @expr ref, + int var : @variable ref); + +#computed +checkedNull( + int var : @variable ref, + int node : @cfgnode ref); + +#computed +checkedValid( + int var : @variable ref, + int node : @cfgnode ref); + +/* compilation dependencies taking #include directives into account */ + +#computed +fileDepends( + int src : @file ref, + int tgt : @file ref); + +/* XML Files */ + +xmlEncoding (unique int id: @file ref, varchar(900) encoding: string ref); + +xmlDTDs (unique int id: @xmldtd, + varchar(900) root: string ref, + varchar(900) publicId: string ref, + varchar(900) systemId: string ref, + int fileid: @file ref); + +xmlElements (unique int id: @xmlelement, + varchar(900) name: string ref, + int parentid: @xmlparent ref, + int idx: int ref, + int fileid: @file ref); + +xmlAttrs (unique int id: @xmlattribute, + int elementid: @xmlelement ref, + varchar(900) name: string ref, + varchar(3600) value: string ref, + int idx: int ref, + int fileid: @file ref); + +xmlNs (int id: @xmlnamespace, + varchar(900) prefixName: string ref, + varchar(900) URI: string ref, + int fileid: @file ref); + +xmlHasNs (int elementId: @xmlnamespaceable ref, + int nsId: @xmlnamespace ref, + int fileid: @file ref); + +xmlComments (unique int id: @xmlcomment, + varchar(3600) text: string ref, + int parentid: @xmlparent ref, + int fileid: @file ref); + +xmlChars (unique int id: @xmlcharacters, + varchar(3600) text: string ref, + int parentid: @xmlparent ref, + int idx: int ref, + int isCDATA: int ref, + int fileid: @file ref); + +@xmlparent = @file | @xmlelement; +@xmlnamespaceable = @xmlelement | @xmlattribute; + +xmllocations(int xmlElement: @xmllocatable ref, + int location: @location_default ref); + +@xmllocatable = @xmlcharacters | @xmlelement | @xmlcomment | @xmlattribute | @xmldtd | @file | @xmlnamespace; diff --git a/csharp/ql/lib/upgrades/initial/semmlecode.csharp.dbscheme b/csharp/ql/lib/upgrades/initial/semmlecode.csharp.dbscheme index 34565707dfb..b1166f9a165 100644 --- a/csharp/ql/lib/upgrades/initial/semmlecode.csharp.dbscheme +++ b/csharp/ql/lib/upgrades/initial/semmlecode.csharp.dbscheme @@ -1,1707 +1,752 @@ -/* - * External artifacts - */ - -externalDefects( - unique int id: @externalDefect, - varchar(900) queryPath: string ref, - int location: @location ref, - varchar(900) message: string ref, - float severity: float ref); - -externalMetrics( - unique int id: @externalMetric, - varchar(900) queryPath: string ref, - int location: @location ref, - float value: float ref); - -externalData( - int id: @externalDataElement, - varchar(900) path: string ref, - int column: int ref, - varchar(900) value: string ref); - -snapshotDate( - unique date snapshotDate: date ref); - -sourceLocationPrefix( - varchar(900) prefix: string ref); - -/* - * Duplicate code - */ - -duplicateCode( - unique int id: @duplication, - varchar(900) relativePath: string ref, - int equivClass: int ref); - -similarCode( - unique int id: @similarity, - varchar(900) relativePath: string ref, - int equivClass: int ref); - -@duplication_or_similarity = @duplication | @similarity - -tokens( - int id: @duplication_or_similarity ref, - int offset: int ref, - int beginLine: int ref, - int beginColumn: int ref, - int endLine: int ref, - int endColumn: int ref); - -/* - * Version history - */ - -svnentries( - int id: @svnentry, - varchar(500) revision: string ref, - varchar(500) author: string ref, - date revisionDate: date ref, - int changeSize: int ref); - -svnaffectedfiles( - int id: @svnentry ref, - int file: @file ref, - varchar(500) action: string ref); - -svnentrymsg( - int id: @svnentry ref, - varchar(500) message: string ref -) - -svnchurn( - int commit: @svnentry ref, - int file: @file ref, - int addedLines: int ref, - int deletedLines: int ref); - -/* - * C# dbscheme - */ - -/** ELEMENTS **/ - -@element = @declaration | @stmt | @expr | @modifier | @attribute | @namespace_declaration - | @using_directive | @type_parameter_constraints | @external_element - | @xmllocatable | @asp_element | @namespace; - -@declaration = @callable | @generic | @assignable; - -@named_element = @namespace | @declaration; - -@declaration_with_accessors = @property | @indexer | @event; - -@assignable = @variable | @assignable_with_accessors | @event; - -@assignable_with_accessors = @property | @indexer; - -@external_element = @externalMetric | @externalDefect | @externalDataElement; - -@attributable = @assembly | @field | @parameter | @operator | @method | @constructor - | @destructor | @callable_accessor | @value_or_ref_type | @declaration_with_accessors; - -/** LOCATIONS, ASEMMBLIES, MODULES, FILES and FOLDERS **/ - -@location = @location_default | @assembly; - -locations_default( - unique int id: @location_default, - int file: @file ref, - int beginLine: int ref, - int beginColumn: int ref, - int endLine: int ref, - int endColumn: int ref); - -@sourceline = @file | @callable | @xmllocatable; - -numlines( - unique int element_id: @sourceline ref, - int num_lines: int ref, - int num_code: int ref, - int num_comment: int ref); - -assemblies( - unique int id: @assembly, - int file: @file ref, - varchar(900) fullname: string ref, - varchar(900) name: string ref, - varchar(900) version: string ref); - -/* - fromSource(0) = unknown, - fromSource(1) = from source, - fromSource(2) = from library -*/ -files( - unique int id: @file, - varchar(900) name: string ref, - varchar(900) simple: string ref, - varchar(900) ext: string ref, - int fromSource: int ref); - -folders( - unique int id: @folder, - varchar(900) name: string ref, - varchar(900) simple: string ref); - -@container = @folder | @file ; - -containerparent( - int parent: @container ref, - unique int child: @container ref); - -file_extraction_mode( - unique int file: @file ref, - int mode: int ref - /* 0 = normal, 1 = standalone extractor */ - ); - -/** NAMESPACES **/ - -@type_container = @namespace | @type; - -namespaces( - unique int id: @namespace, - varchar(900) name: string ref); - -namespace_declarations( - unique int id: @namespace_declaration, - int namespace_id: @namespace ref); - -namespace_declaration_location( - unique int id: @namespace_declaration ref, - int loc: @location ref); - -parent_namespace( - unique int child_id: @type_container ref, - int namespace_id: @namespace ref); - -@declaration_or_directive = @namespace_declaration | @type | @using_directive; - -parent_namespace_declaration( - int child_id: @declaration_or_directive ref, // cannot be unique because of partial classes - int namespace_id: @namespace_declaration ref); - -@using_directive = @using_namespace_directive | @using_static_directive; - -using_namespace_directives( - unique int id: @using_namespace_directive, - int namespace_id: @namespace ref); - -using_static_directives( - unique int id: @using_static_directive, - int type_id: @type_or_ref ref); - -using_directive_location( - unique int id: @using_directive ref, - int loc: @location ref); - -/** TYPES **/ - -types( - unique int id: @type, - int kind: int ref, - varchar(900) name: string ref); - -case @type.kind of - 1 = @bool_type -| 2 = @char_type -| 3 = @decimal_type -| 4 = @sbyte_type -| 5 = @short_type -| 6 = @int_type -| 7 = @long_type -| 8 = @byte_type -| 9 = @ushort_type -| 10 = @uint_type -| 11 = @ulong_type -| 12 = @float_type -| 13 = @double_type -| 14 = @enum_type -| 15 = @struct_type -| 17 = @class_type -| 19 = @interface_type -| 20 = @delegate_type -| 21 = @null_type -| 22 = @type_parameter -| 23 = @pointer_type -| 24 = @nullable_type -| 25 = @array_type -| 26 = @void_type -| 27 = @int_ptr_type -| 28 = @uint_ptr_type -| 29 = @dynamic_type -| 30 = @arglist_type -| 31 = @unknown_type -| 32 = @tuple_type - ; - -@simple_type = @bool_type | @char_type | @integral_type | @floating_point_type | @decimal_type; -@integral_type = @signed_integral_type | @unsigned_integral_type; -@signed_integral_type = @sbyte_type | @short_type | @int_type | @long_type; -@unsigned_integral_type = @byte_type | @ushort_type | @uint_type | @ulong_type; -@floating_point_type = @float_type | @double_type; -@value_type = @simple_type | @enum_type | @struct_type | @nullable_type | @int_ptr_type - | @uint_ptr_type | @tuple_type; -@ref_type = @class_type | @interface_type | @array_type | @delegate_type | @null_type - | @dynamic_type; -@value_or_ref_type = @value_type | @ref_type; - -typerefs( - unique int id: @typeref, - varchar(900) name: string ref); - -typeref_type( - unique int id: @typeref ref, - unique int typeId: @type ref); - -@type_or_ref = @type | @typeref; - -array_element_type( - unique int array: @array_type ref, - int dimension: int ref, - int rank: int ref, - int element: @type_or_ref ref); - -nullable_underlying_type( - unique int nullable: @nullable_type ref, - int underlying: @type_or_ref ref); - -pointer_referent_type( - unique int pointer: @pointer_type ref, - int referent: @type_or_ref ref); - -enum_underlying_type( - unique int enum_id: @enum_type ref, - int underlying_type_id: @type_or_ref ref); - -delegate_return_type( - unique int delegate_id: @delegate_type ref, - int return_type_id: @type_or_ref ref); - -extend( - unique int sub: @type ref, - int super: @type_or_ref ref); - -@interface_or_ref = @interface_type | @typeref; - -implement( - int sub: @type ref, - int super: @type_or_ref ref); - -type_location( - int id: @type ref, - int loc: @location ref); - -tuple_underlying_type( - unique int tuple: @tuple_type ref, - int struct: @struct_type ref); - -#keyset[tuple, index] -tuple_element( - int tuple: @tuple_type ref, - int index: int ref, - unique int field: @field ref); - -attributes( - unique int id: @attribute, - int type_id: @type_or_ref ref, - int target: @attributable ref); - -attribute_location( - int id: @attribute ref, - int loc: @location ref); - -@type_mention_parent = @element | @type_mention; - -type_mention( - unique int id: @type_mention, - int type_id: @type_or_ref ref, - int parent: @type_mention_parent ref); - -type_mention_location( - unique int id: @type_mention ref, - int loc: @location ref); - -/** GENERICS **/ - -@generic = @type | @method | @local_function; - -is_generic(unique int id: @generic ref); - -is_constructed(unique int id: @generic ref); - -type_parameters( - unique int id: @type_parameter ref, - int index: int ref, - int generic_id: @generic ref, - int variance: int ref /* none = 0, out = 1, in = 2 */); - -#keyset[constructed_id, index] -type_arguments( - int id: @type_or_ref ref, - int index: int ref, - int constructed_id: @generic_or_ref ref); - -@generic_or_ref = @generic | @typeref; - -constructed_generic( - unique int constructed: @generic ref, - int generic: @generic_or_ref ref); - -type_parameter_constraints( - unique int id: @type_parameter_constraints, - int param_id: @type_parameter ref); - -type_parameter_constraints_location( - int id: @type_parameter_constraints ref, - int loc: @location ref); - -general_type_parameter_constraints( - int id: @type_parameter_constraints ref, - int kind: int ref /* class = 1, struct = 2, new = 3 */); - -specific_type_parameter_constraints( - int id: @type_parameter_constraints ref, - int base_id: @type_or_ref ref); - - -/** MODIFIERS */ - -@modifiable = @modifiable_direct | @event_accessor; - -@modifiable_direct = @member | @accessor; - -modifiers( - unique int id: @modifier, - varchar(900) name: string ref); - -has_modifiers( - int id: @modifiable_direct ref, - int mod_id: @modifier ref); - -compiler_generated(unique int id: @modifiable_direct ref); - -/** MEMBERS **/ - -@member = @method | @constructor | @destructor | @field | @property | @event | @operator | @indexer | @type; - -@named_exprorstmt = @goto_stmt | @labeled_stmt | @literal_expr; - -@virtualizable = @method | @property | @indexer | @event; - -exprorstmt_name( - unique int parent_id: @named_exprorstmt ref, - varchar(900) name: string ref); - -nested_types( - unique int id: @type ref, - int declaring_type_id: @type ref, - int unbound_id: @type ref); - -properties( - unique int id: @property, - varchar(900) name: string ref, - int declaring_type_id: @type ref, - int type_id: @type_or_ref ref, - int unbound_id: @property ref); - -property_location( - int id: @property ref, - int loc: @location ref); - -indexers( - unique int id: @indexer, - varchar(900) name: string ref, - int declaring_type_id: @type ref, - int type_id: @type_or_ref ref, - int unbound_id: @indexer ref); - -indexer_location( - int id: @indexer ref, - int loc: @location ref); - -accessors( - unique int id: @accessor, - int kind: int ref, - varchar(900) name: string ref, - int declaring_member_id: @member ref, - int unbound_id: @accessor ref); - -case @accessor.kind of - 1 = @getter -| 2 = @setter - ; - -accessor_location( - int id: @accessor ref, - int loc: @location ref); - -events( - unique int id: @event, - varchar(900) name: string ref, - int declaring_type_id: @type ref, - int type_id: @type_or_ref ref, - int unbound_id: @event ref); - -event_location( - int id: @event ref, - int loc: @location ref); - -event_accessors( - unique int id: @event_accessor, - int kind: int ref, - varchar(900) name: string ref, - int declaring_event_id: @event ref, - int unbound_id: @event_accessor ref); - -case @event_accessor.kind of - 1 = @add_event_accessor -| 2 = @remove_event_accessor - ; - -event_accessor_location( - int id: @event_accessor ref, - int loc: @location ref); - -operators( - unique int id: @operator, - varchar(900) name: string ref, - varchar(900) symbol: string ref, - int declaring_type_id: @type ref, - int type_id: @type_or_ref ref, - int unbound_id: @operator ref); - -operator_location( - int id: @operator ref, - int loc: @location ref); - -constant_value( - unique int id: @variable ref, - varchar(900) value: string ref); - -/** CALLABLES **/ - -@callable = @method | @constructor | @destructor | @operator | @callable_accessor | @anonymous_function_expr | @local_function; - -@callable_accessor = @accessor | @event_accessor; - -methods( - unique int id: @method, - varchar(900) name: string ref, - int declaring_type_id: @type ref, - int type_id: @type_or_ref ref, - int unbound_id: @method ref); - -method_location( - int id: @method ref, - int loc: @location ref); - -constructors( - unique int id: @constructor, - varchar(900) name: string ref, - int declaring_type_id: @type ref, - int unbound_id: @constructor ref); - -constructor_location( - int id: @constructor ref, - int loc: @location ref); - -destructors( - unique int id: @destructor, - varchar(900) name: string ref, - int declaring_type_id: @type ref, - int unbound_id: @destructor ref); - -destructor_location( - int id: @destructor ref, - int loc: @location ref); - -overrides( - unique int id: @callable ref, - int base_id: @callable ref); - -explicitly_implements( - unique int id: @member ref, - int interface_id: @interface_or_ref ref); - -local_functions( - unique int id: @local_function, - varchar(900) name: string ref, - int return_type: @type ref, - int unbound_id: @local_function ref); - -local_function_stmts( - unique int fn: @local_function_stmt ref, - int stmt: @local_function ref); - -@ref_callable = @local_function | @method | @delegate_type; - -ref_returns(int fn: @ref_callable ref); - -ref_readonly_returns(int fn: @ref_callable ref); - -/** VARIABLES **/ - -@variable = @local_scope_variable | @field; - -@local_scope_variable = @local_variable | @parameter; - -fields( - unique int id: @field, - int kind: int ref, - varchar(900) name: string ref, - int declaring_type_id: @type ref, - int type_id: @type_or_ref ref, - int unbound_id: @field ref); - -case @field.kind of - 1 = @addressable_field -| 2 = @constant - ; - -field_location( - int id: @field ref, - int loc: @location ref); - -localvars( - unique int id: @local_variable, - int kind: int ref, - varchar(900) name: string ref, - int implicitly_typed: int ref /* 0 = no, 1 = yes */, - int type_id: @type_or_ref ref, - int parent_id: @local_var_decl_expr ref); - -case @local_variable.kind of - 1 = @addressable_local_variable -| 2 = @local_constant -| 3 = @local_variable_ref - ; - -localvar_location( - unique int id: @local_variable ref, - int loc: @location ref); - -@parameterizable = @callable | @delegate_type | @indexer; - -#keyset[name, parent_id] -#keyset[index, parent_id] -params( - unique int id: @parameter, - varchar(900) name: string ref, - int type_id: @type_or_ref ref, - int index: int ref, - int mode: int ref, /* value = 0, ref = 1, out = 2, array = 3, this = 4 */ - int parent_id: @parameterizable ref, - int unbound_id: @parameter ref); - -param_location( - int id: @parameter ref, - int loc: @location ref); - -/** STATEMENTS **/ - -@exprorstmt_parent = @control_flow_element | @top_level_exprorstmt_parent; - -statements( - unique int id: @stmt, - int kind: int ref); - -#keyset[index, parent] -stmt_parent( - unique int stmt: @stmt ref, - int index: int ref, - int parent: @control_flow_element ref); - -@top_level_stmt_parent = @callable; - -// [index, parent] is not a keyset because the same parent may be compiled multiple times -stmt_parent_top_level( - unique int stmt: @stmt ref, - int index: int ref, - int parent: @top_level_stmt_parent ref); - -case @stmt.kind of - 1 = @block_stmt -| 2 = @expr_stmt -| 3 = @if_stmt -| 4 = @switch_stmt -| 5 = @while_stmt -| 6 = @do_stmt -| 7 = @for_stmt -| 8 = @foreach_stmt -| 9 = @break_stmt -| 10 = @continue_stmt -| 11 = @goto_stmt -| 12 = @goto_case_stmt -| 13 = @goto_default_stmt -| 14 = @throw_stmt -| 15 = @return_stmt -| 16 = @yield_stmt -| 17 = @try_stmt -| 18 = @checked_stmt -| 19 = @unchecked_stmt -| 20 = @lock_stmt -| 21 = @using_stmt -| 22 = @var_decl_stmt -| 23 = @const_decl_stmt -| 24 = @empty_stmt -| 25 = @unsafe_stmt -| 26 = @fixed_stmt -| 27 = @label_stmt -| 28 = @catch -| 29 = @case -| 30 = @local_function_stmt - ; - -@labeled_stmt = @label_stmt | @case; - -@decl_stmt = @var_decl_stmt | @const_decl_stmt; - -@cond_stmt = @if_stmt | @switch_stmt; - -@loop_stmt = @while_stmt | @do_stmt | @for_stmt | @foreach_stmt; - -@jump_stmt = @break_stmt | @goto_any_stmt | @continue_stmt | @throw_stmt | @return_stmt - | @yield_stmt; - -@goto_any_stmt = @goto_default_stmt | @goto_case_stmt | @goto_stmt; - - -stmt_location( - unique int id: @stmt ref, - int loc: @location ref); - -catch_type( - unique int catch_id: @catch ref, - int type_id: @type_or_ref ref, - int kind: int ref /* explicit = 1, implicit = 2 */); - -/** EXPRESSIONS **/ - -expressions( - unique int id: @expr, - int kind: int ref, - int type_id: @type_or_ref ref); - -#keyset[index, parent] -expr_parent( - unique int expr: @expr ref, - int index: int ref, - int parent: @control_flow_element ref); - -@top_level_expr_parent = @attribute | @field | @property | @indexer | @parameter; - -@top_level_exprorstmt_parent = @top_level_expr_parent | @top_level_stmt_parent; - -// [index, parent] is not a keyset because the same parent may be compiled multiple times -expr_parent_top_level( - unique int expr: @expr ref, - int index: int ref, - int parent: @top_level_exprorstmt_parent ref); - -case @expr.kind of -/* literal */ - 1 = @bool_literal_expr -| 2 = @char_literal_expr -| 3 = @decimal_literal_expr -| 4 = @int_literal_expr -| 5 = @long_literal_expr -| 6 = @uint_literal_expr -| 7 = @ulong_literal_expr -| 8 = @float_literal_expr -| 9 = @double_literal_expr -| 10 = @string_literal_expr -| 11 = @null_literal_expr -/* primary & unary */ -| 12 = @this_access_expr -| 13 = @base_access_expr -| 14 = @local_variable_access_expr -| 15 = @parameter_access_expr -| 16 = @field_access_expr -| 17 = @property_access_expr -| 18 = @method_access_expr -| 19 = @event_access_expr -| 20 = @indexer_access_expr -| 21 = @array_access_expr -| 22 = @type_access_expr -| 23 = @typeof_expr -| 24 = @method_invocation_expr -| 25 = @delegate_invocation_expr -| 26 = @operator_invocation_expr -| 27 = @cast_expr -| 28 = @object_creation_expr -| 29 = @explicit_delegate_creation_expr -| 30 = @implicit_delegate_creation_expr -| 31 = @array_creation_expr -| 32 = @default_expr -| 33 = @plus_expr -| 34 = @minus_expr -| 35 = @bit_not_expr -| 36 = @log_not_expr -| 37 = @post_incr_expr -| 38 = @post_decr_expr -| 39 = @pre_incr_expr -| 40 = @pre_decr_expr -/* multiplicative */ -| 41 = @mul_expr -| 42 = @div_expr -| 43 = @rem_expr -/* additive */ -| 44 = @add_expr -| 45 = @sub_expr -/* shift */ -| 46 = @lshift_expr -| 47 = @rshift_expr -/* relational */ -| 48 = @lt_expr -| 49 = @gt_expr -| 50 = @le_expr -| 51 = @ge_expr -/* equality */ -| 52 = @eq_expr -| 53 = @ne_expr -/* logical */ -| 54 = @bit_and_expr -| 55 = @bit_xor_expr -| 56 = @bit_or_expr -| 57 = @log_and_expr -| 58 = @log_or_expr -/* type testing */ -| 59 = @is_expr -| 60 = @as_expr -/* null coalescing */ -| 61 = @null_coalescing_expr -/* conditional */ -| 62 = @conditional_expr -/* assignment */ -| 63 = @simple_assign_expr -| 64 = @assign_add_expr -| 65 = @assign_sub_expr -| 66 = @assign_mul_expr -| 67 = @assign_div_expr -| 68 = @assign_rem_expr -| 69 = @assign_and_expr -| 70 = @assign_xor_expr -| 71 = @assign_or_expr -| 72 = @assign_lshift_expr -| 73 = @assign_rshift_expr -/* more */ -| 74 = @object_init_expr -| 75 = @collection_init_expr -| 76 = @array_init_expr -| 77 = @checked_expr -| 78 = @unchecked_expr -| 79 = @constructor_init_expr -| 80 = @add_event_expr -| 81 = @remove_event_expr -| 82 = @par_expr -| 83 = @local_var_decl_expr -| 84 = @lambda_expr -| 85 = @anonymous_method_expr -| 86 = @namespace_expr -/* dynamic */ -| 92 = @dynamic_element_access_expr -| 93 = @dynamic_member_access_expr -/* unsafe */ -| 100 = @pointer_indirection_expr -| 101 = @address_of_expr -| 102 = @sizeof_expr -/* async */ -| 103 = @await_expr -/* C# 6.0 */ -| 104 = @nameof_expr -| 105 = @interpolated_string_expr -| 106 = @unknown_expr -/* C# 7.0 */ -| 107 = @throw_expr -| 108 = @tuple_expr -| 109 = @local_function_invocation_expr -| 110 = @ref_expr -| 111 = @discard_expr -; - -@integer_literal_expr = @int_literal_expr | @long_literal_expr | @uint_literal_expr | @ulong_literal_expr; -@real_literal_expr = @float_literal_expr | @double_literal_expr | @decimal_literal_expr; -@literal_expr = @bool_literal_expr | @char_literal_expr | @integer_literal_expr | @real_literal_expr - | @string_literal_expr | @null_literal_expr; - -@assign_expr = @simple_assign_expr | @assign_op_expr | @local_var_decl_expr; -@assign_op_expr = @assign_arith_expr | @assign_bitwise_expr | @assign_event_expr; -@assign_event_expr = @add_event_expr | @remove_event_expr; - -@assign_arith_expr = @assign_add_expr | @assign_sub_expr | @assign_mul_expr | @assign_div_expr - | @assign_rem_expr -@assign_bitwise_expr = @assign_and_expr | @assign_or_expr | @assign_xor_expr - | @assign_lshift_expr | @assign_rshift_expr; - -@member_access_expr = @field_access_expr | @property_access_expr | @indexer_access_expr | @event_access_expr - | @method_access_expr | @type_access_expr | @dynamic_member_access_expr; -@access_expr = @member_access_expr | @this_access_expr | @base_access_expr | @assignable_access_expr; -@element_access_expr = @indexer_access_expr | @array_access_expr | @dynamic_element_access_expr; - -@local_variable_access = @local_variable_access_expr | @local_var_decl_expr; -@local_scope_variable_access_expr = @parameter_access_expr | @local_variable_access; -@variable_access_expr = @local_scope_variable_access_expr | @field_access_expr; - -@assignable_access_expr = @variable_access_expr | @property_access_expr | @element_access_expr - | @event_access_expr | @dynamic_member_access_expr; - -@objectorcollection_init_expr = @object_init_expr | @collection_init_expr; - -@delegate_creation_expr = @explicit_delegate_creation_expr | @implicit_delegate_creation_expr; - -@bin_arith_op_expr = @mul_expr | @div_expr | @rem_expr | @add_expr | @sub_expr; -@incr_op_expr = @pre_incr_expr | @post_incr_expr; -@decr_op_expr = @pre_decr_expr | @post_decr_expr; -@mut_op_expr = @incr_op_expr | @decr_op_expr; -@un_arith_op_expr = @plus_expr | @minus_expr | @mut_op_expr; -@arith_op_expr = @bin_arith_op_expr | @un_arith_op_expr; - -@ternary_log_op_expr = @conditional_expr; -@bin_log_op_expr = @log_and_expr | @log_or_expr | @null_coalescing_expr; -@un_log_op_expr = @log_not_expr; -@log_expr = @un_log_op_expr | @bin_log_op_expr | @ternary_log_op_expr; - -@bin_bit_op_expr = @bit_and_expr | @bit_or_expr | @bit_xor_expr | @lshift_expr - | @rshift_expr; -@un_bit_op_expr = @bit_not_expr; -@bit_expr = @un_bit_op_expr | @bin_bit_op_expr; - -@equality_op_expr = @eq_expr | @ne_expr; -@rel_op_expr = @gt_expr | @lt_expr| @ge_expr | @le_expr; -@comp_expr = @equality_op_expr | @rel_op_expr; - -@op_expr = @assign_expr | @un_op | @bin_op | @ternary_op; - -@ternary_op = @ternary_log_op_expr; -@bin_op = @bin_arith_op_expr | @bin_log_op_expr | @bin_bit_op_expr | @comp_expr; -@un_op = @un_arith_op_expr | @un_log_op_expr | @un_bit_op_expr | @sizeof_expr - | @pointer_indirection_expr | @address_of_expr; - -@anonymous_function_expr = @lambda_expr | @anonymous_method_expr; - -@call = @method_invocation_expr | @constructor_init_expr | @operator_invocation_expr - | @delegate_invocation_expr | @object_creation_expr | @call_access_expr - | @local_function_invocation_expr; - -@call_access_expr = @property_access_expr | @event_access_expr | @indexer_access_expr; - -@late_bindable_expr = @dynamic_element_access_expr | @dynamic_member_access_expr - | @object_creation_expr | @method_invocation_expr | @operator_invocation_expr; - -@throw_element = @throw_expr | @throw_stmt; - -implicitly_typed_array_creation( - unique int id: @array_creation_expr ref); - -explicitly_sized_array_creation( - unique int id: @array_creation_expr ref); - -mutator_invocation_mode( - unique int id: @operator_invocation_expr ref, - int mode: int ref /* prefix = 1, postfix = 2*/); - -expr_compiler_generated( - unique int id: @expr ref); - -expr_value( - unique int id: @expr ref, - varchar(900) value: string ref); - -expr_call( - unique int caller_id: @expr ref, - int target_id: @callable ref); - -expr_access( - unique int accesser_id: @access_expr ref, - int target_id: @accessible ref); - -@accessible = @method | @assignable | @local_function; - -expr_location( - unique int id: @expr ref, - int loc: @location ref); - -dynamic_member_name( - unique int id: @late_bindable_expr ref, - varchar(900) name: string ref); - -@qualifiable_expr = @member_access_expr - | @method_invocation_expr - | @element_access_expr; - -conditional_access( - unique int id: @qualifiable_expr ref); - -expr_argument( - unique int id: @expr ref, - int mode: int ref); - /* mode is the same as params: value = 0, ref = 1, out = 2 */ - -expr_argument_name( - unique int id: @expr ref, - varchar(900) name: string ref); - -/** CONTROL/DATA FLOW **/ - -@control_flow_element = @stmt | @expr; - -/* XML Files */ - -xmlEncoding ( - unique int id: @file ref, - varchar(900) encoding: string ref); - -xmlDTDs( - unique int id: @xmldtd, - varchar(900) root: string ref, - varchar(900) publicId: string ref, - varchar(900) systemId: string ref, - int fileid: @file ref); - -xmlElements( - unique int id: @xmlelement, - varchar(900) name: string ref, - int parentid: @xmlparent ref, - int idx: int ref, - int fileid: @file ref); - -xmlAttrs( - unique int id: @xmlattribute, - int elementid: @xmlelement ref, - varchar(900) name: string ref, - varchar(3600) value: string ref, - int idx: int ref, - int fileid: @file ref); - -xmlNs( - int id: @xmlnamespace, - varchar(900) prefixName: string ref, - varchar(900) URI: string ref, - int fileid: @file ref); - -xmlHasNs( - int elementId: @xmlnamespaceable ref, - int nsId: @xmlnamespace ref, - int fileid: @file ref); - -xmlComments( - unique int id: @xmlcomment, - varchar(3600) text: string ref, - int parentid: @xmlparent ref, - int fileid: @file ref); - -xmlChars( - unique int id: @xmlcharacters, - varchar(3600) text: string ref, - int parentid: @xmlparent ref, - int idx: int ref, - int isCDATA: int ref, - int fileid: @file ref); - -@xmlparent = @file | @xmlelement; -@xmlnamespaceable = @xmlelement | @xmlattribute; - -xmllocations( - int xmlElement: @xmllocatable ref, - int location: @location_default ref); - -@xmllocatable = @xmlcharacters | @xmlelement | @xmlcomment | @xmlattribute | @xmldtd | @file | @xmlnamespace; - -/* Comments */ - -commentline( - unique int id: @commentline, - int kind: int ref, - varchar(800) text: string ref, - varchar(800) rawtext: string ref); - -case @commentline.kind of - 0 = @singlelinecomment -| 1 = @xmldoccomment -| 2 = @multilinecomment; - -commentline_location( - unique int id: @commentline ref, - int loc: @location ref); - -commentblock( - unique int id : @commentblock); - -commentblock_location( - unique int id: @commentblock ref, - int loc: @location ref); - -commentblock_binding( - int id: @commentblock ref, - int entity: @element ref, - int bindtype: int ref); /* 0: Parent, 1: Best, 2: Before, 3: After */ - -commentblock_child( - int id: @commentblock ref, - int commentline: @commentline ref, - int index: int ref); - -/* ASP.NET */ - -case @asp_element.kind of - 0=@asp_close_tag -| 1=@asp_code -| 2=@asp_comment -| 3=@asp_data_binding -| 4=@asp_directive -| 5=@asp_open_tag -| 6=@asp_quoted_string -| 7=@asp_text -| 8=@asp_xml_directive; - -@asp_attribute = @asp_code | @asp_data_binding | @asp_quoted_string; - -asp_elements( - unique int id: @asp_element, - int kind: int ref, - int loc: @location ref); - -asp_comment_server(unique int comment: @asp_comment ref); -asp_code_inline(unique int code: @asp_code ref); -asp_directive_attribute( - int directive: @asp_directive ref, - int index: int ref, - varchar(1000) name: string ref, - int value: @asp_quoted_string ref); -asp_directive_name( - unique int directive: @asp_directive ref, - varchar(1000) name: string ref); -asp_element_body( - unique int element: @asp_element ref, - varchar(1000) body: string ref); -asp_tag_attribute( - int tag: @asp_open_tag ref, - int index: int ref, - varchar(1000) name: string ref, - int attribute: @asp_attribute ref); -asp_tag_name( - unique int tag: @asp_open_tag ref, - varchar(1000) name: string ref); -asp_tag_isempty(int tag: @asp_open_tag ref); - -/* Common Intermediate Language - CIL */ - -case @cil_instruction.opcode of - 0 = @cil_nop -| 1 = @cil_break -| 2 = @cil_ldarg_0 -| 3 = @cil_ldarg_1 -| 4 = @cil_ldarg_2 -| 5 = @cil_ldarg_3 -| 6 = @cil_ldloc_0 -| 7 = @cil_ldloc_1 -| 8 = @cil_ldloc_2 -| 9 = @cil_ldloc_3 -| 10 = @cil_stloc_0 -| 11 = @cil_stloc_1 -| 12 = @cil_stloc_2 -| 13 = @cil_stloc_3 -| 14 = @cil_ldarg_s -| 15 = @cil_ldarga_s -| 16 = @cil_starg_s -| 17 = @cil_ldloc_s -| 18 = @cil_ldloca_s -| 19 = @cil_stloc_s -| 20 = @cil_ldnull -| 21 = @cil_ldc_i4_m1 -| 22 = @cil_ldc_i4_0 -| 23 = @cil_ldc_i4_1 -| 24 = @cil_ldc_i4_2 -| 25 = @cil_ldc_i4_3 -| 26 = @cil_ldc_i4_4 -| 27 = @cil_ldc_i4_5 -| 28 = @cil_ldc_i4_6 -| 29 = @cil_ldc_i4_7 -| 30 = @cil_ldc_i4_8 -| 31 = @cil_ldc_i4_s -| 32 = @cil_ldc_i4 -| 33 = @cil_ldc_i8 -| 34 = @cil_ldc_r4 -| 35 = @cil_ldc_r8 -| 37 = @cil_dup -| 38 = @cil_pop -| 39 = @cil_jmp -| 40 = @cil_call -| 41 = @cil_calli -| 42 = @cil_ret -| 43 = @cil_br_s -| 44 = @cil_brfalse_s -| 45 = @cil_brtrue_s -| 46 = @cil_beq_s -| 47 = @cil_bge_s -| 48 = @cil_bgt_s -| 49 = @cil_ble_s -| 50 = @cil_blt_s -| 51 = @cil_bne_un_s -| 52 = @cil_bge_un_s -| 53 = @cil_bgt_un_s -| 54 = @cil_ble_un_s -| 55 = @cil_blt_un_s -| 56 = @cil_br -| 57 = @cil_brfalse -| 58 = @cil_brtrue -| 59 = @cil_beq -| 60 = @cil_bge -| 61 = @cil_bgt -| 62 = @cil_ble -| 63 = @cil_blt -| 64 = @cil_bne_un -| 65 = @cil_bge_un -| 66 = @cil_bgt_un -| 67 = @cil_ble_un -| 68 = @cil_blt_un -| 69 = @cil_switch -| 70 = @cil_ldind_i1 -| 71 = @cil_ldind_u1 -| 72 = @cil_ldind_i2 -| 73 = @cil_ldind_u2 -| 74 = @cil_ldind_i4 -| 75 = @cil_ldind_u4 -| 76 = @cil_ldind_i8 -| 77 = @cil_ldind_i -| 78 = @cil_ldind_r4 -| 79 = @cil_ldind_r8 -| 80 = @cil_ldind_ref -| 81 = @cil_stind_ref -| 82 = @cil_stind_i1 -| 83 = @cil_stind_i2 -| 84 = @cil_stind_i4 -| 85 = @cil_stind_i8 -| 86 = @cil_stind_r4 -| 87 = @cil_stind_r8 -| 88 = @cil_add -| 89 = @cil_sub -| 90 = @cil_mul -| 91 = @cil_div -| 92 = @cil_div_un -| 93 = @cil_rem -| 94 = @cil_rem_un -| 95 = @cil_and -| 96 = @cil_or -| 97 = @cil_xor -| 98 = @cil_shl -| 99 = @cil_shr -| 100 = @cil_shr_un -| 101 = @cil_neg -| 102 = @cil_not -| 103 = @cil_conv_i1 -| 104 = @cil_conv_i2 -| 105 = @cil_conv_i4 -| 106 = @cil_conv_i8 -| 107 = @cil_conv_r4 -| 108 = @cil_conv_r8 -| 109 = @cil_conv_u4 -| 110 = @cil_conv_u8 -| 111 = @cil_callvirt -| 112 = @cil_cpobj -| 113 = @cil_ldobj -| 114 = @cil_ldstr -| 115 = @cil_newobj -| 116 = @cil_castclass -| 117 = @cil_isinst -| 118 = @cil_conv_r_un -| 121 = @cil_unbox -| 122 = @cil_throw -| 123 = @cil_ldfld -| 124 = @cil_ldflda -| 125 = @cil_stfld -| 126 = @cil_ldsfld -| 127 = @cil_ldsflda -| 128 = @cil_stsfld -| 129 = @cil_stobj -| 130 = @cil_conv_ovf_i1_un -| 131 = @cil_conv_ovf_i2_un -| 132 = @cil_conv_ovf_i4_un -| 133 = @cil_conv_ovf_i8_un -| 134 = @cil_conv_ovf_u1_un -| 135 = @cil_conv_ovf_u2_un -| 136 = @cil_conv_ovf_u4_un -| 137 = @cil_conv_ovf_u8_un -| 138 = @cil_conv_ovf_i_un -| 139 = @cil_conv_ovf_u_un -| 140 = @cil_box -| 141 = @cil_newarr -| 142 = @cil_ldlen -| 143 = @cil_ldelema -| 144 = @cil_ldelem_i1 -| 145 = @cil_ldelem_u1 -| 146 = @cil_ldelem_i2 -| 147 = @cil_ldelem_u2 -| 148 = @cil_ldelem_i4 -| 149 = @cil_ldelem_u4 -| 150 = @cil_ldelem_i8 -| 151 = @cil_ldelem_i -| 152 = @cil_ldelem_r4 -| 153 = @cil_ldelem_r8 -| 154 = @cil_ldelem_ref -| 155 = @cil_stelem_i -| 156 = @cil_stelem_i1 -| 157 = @cil_stelem_i2 -| 158 = @cil_stelem_i4 -| 159 = @cil_stelem_i8 -| 160 = @cil_stelem_r4 -| 161 = @cil_stelem_r8 -| 162 = @cil_stelem_ref -| 163 = @cil_ldelem -| 164 = @cil_stelem -| 165 = @cil_unbox_any -| 179 = @cil_conv_ovf_i1 -| 180 = @cil_conv_ovf_u1 -| 181 = @cil_conv_ovf_i2 -| 182 = @cil_conv_ovf_u2 -| 183 = @cil_conv_ovf_i4 -| 184 = @cil_conv_ovf_u4 -| 185 = @cil_conv_ovf_i8 -| 186 = @cil_conv_ovf_u8 -| 194 = @cil_refanyval -| 195 = @cil_ckinfinite -| 198 = @cil_mkrefany -| 208 = @cil_ldtoken -| 209 = @cil_conv_u2 -| 210 = @cil_conv_u1 -| 211 = @cil_conv_i -| 212 = @cil_conv_ovf_i -| 213 = @cil_conv_ovf_u -| 214 = @cil_add_ovf -| 215 = @cil_add_ovf_un -| 216 = @cil_mul_ovf -| 217 = @cil_mul_ovf_un -| 218 = @cil_sub_ovf -| 219 = @cil_sub_ovf_un -| 220 = @cil_endfinally -| 221 = @cil_leave -| 222 = @cil_leave_s -| 223 = @cil_stind_i -| 224 = @cil_conv_u -| 65024 = @cil_arglist -| 65025 = @cil_ceq -| 65026 = @cil_cgt -| 65027 = @cil_cgt_un -| 65028 = @cil_clt -| 65029 = @cil_clt_un -| 65030 = @cil_ldftn -| 65031 = @cil_ldvirtftn -| 65033 = @cil_ldarg -| 65034 = @cil_ldarga -| 65035 = @cil_starg -| 65036 = @cil_ldloc -| 65037 = @cil_ldloca -| 65038 = @cil_stloc -| 65039 = @cil_localloc -| 65041 = @cil_endfilter -| 65042 = @cil_unaligned -| 65043 = @cil_volatile -| 65044 = @cil_tail -| 65045 = @cil_initobj -| 65046 = @cil_constrained -| 65047 = @cil_cpblk -| 65048 = @cil_initblk -| 65050 = @cil_rethrow -| 65052 = @cil_sizeof -| 65053 = @cil_refanytype -| 65054 = @cil_readonly -; - -// CIL ignored instructions - -@cil_ignore = @cil_nop | @cil_break | @cil_volatile | @cil_unaligned; - -// CIL local/parameter/field access - -@cil_ldarg_any = @cil_ldarg_0 | @cil_ldarg_1 | @cil_ldarg_2 | @cil_ldarg_3 | @cil_ldarg_s | @cil_ldarga_s | @cil_ldarg | @cil_ldarga; -@cil_starg_any = @cil_starg | @cil_starg_s; - -@cil_ldloc_any = @cil_ldloc_0 | @cil_ldloc_1 | @cil_ldloc_2 | @cil_ldloc_3 | @cil_ldloc_s | @cil_ldloca_s | @cil_ldloc | @cil_ldloca; -@cil_stloc_any = @cil_stloc_0 | @cil_stloc_1 | @cil_stloc_2 | @cil_stloc_3 | @cil_stloc_s | @cil_stloc; - -@cil_ldfld_any = @cil_ldfld | @cil_ldsfld | @cil_ldsflda | @cil_ldflda; -@cil_stfld_any = @cil_stfld | @cil_stsfld; - -@cil_local_access = @cil_stloc_any | @cil_ldloc_any; -@cil_arg_access = @cil_starg_any | @cil_ldarg_any; -@cil_read_access = @cil_ldloc_any | @cil_ldarg_any | @cil_ldfld_any; -@cil_write_access = @cil_stloc_any | @cil_starg_any | @cil_stfld_any; - -@cil_stack_access = @cil_local_access | @cil_arg_access; -@cil_field_access = @cil_ldfld_any | @cil_stfld_any; - -@cil_access = @cil_read_access | @cil_write_access; - -// CIL constant/literal instructions - -@cil_ldc_i = @cil_ldc_i4_any | @cil_ldc_i8; - -@cil_ldc_i4_any = @cil_ldc_i4_m1 | @cil_ldc_i4_0 | @cil_ldc_i4_1 | @cil_ldc_i4_2 | @cil_ldc_i4_3 | - @cil_ldc_i4_4 | @cil_ldc_i4_5 | @cil_ldc_i4_6 | @cil_ldc_i4_7 | @cil_ldc_i4_8 | @cil_ldc_i4_s | @cil_ldc_i4; - -@cil_ldc_r = @cil_ldc_r4 | @cil_ldc_r8; - -@cil_literal = @cil_ldnull | @cil_ldc_i | @cil_ldc_r | @cil_ldstr; - -// Control flow - -@cil_conditional_jump = @cil_binary_jump | @cil_unary_jump; -@cil_binary_jump = @cil_beq_s | @cil_bge_s | @cil_bgt_s | @cil_ble_s | @cil_blt_s | - @cil_bne_un_s | @cil_bge_un_s | @cil_bgt_un_s | @cil_ble_un_s | @cil_blt_un_s | - @cil_beq | @cil_bge | @cil_bgt | @cil_ble | @cil_blt | - @cil_bne_un | @cil_bge_un | @cil_bgt_un | @cil_ble_un | @cil_blt_un; -@cil_unary_jump = @cil_brfalse_s | @cil_brtrue_s | @cil_brfalse | @cil_brtrue | @cil_switch; -@cil_unconditional_jump = @cil_br | @cil_br_s | @cil_leave_any; -@cil_leave_any = @cil_leave | @cil_leave_s; -@cil_jump = @cil_unconditional_jump | @cil_conditional_jump; - -// CIL call instructions - -@cil_call_any = @cil_jmp | @cil_call | @cil_calli | @cil_tail | @cil_callvirt | @cil_newobj; - -// CIL expression instructions - -@cil_expr = @cil_literal | @cil_binary_expr | @cil_unary_expr | @cil_call_any | @cil_read_access | - @cil_newarr | @cil_ldtoken | @cil_sizeof | - @cil_ldftn | @cil_ldvirtftn | @cil_localloc | @cil_mkrefany | @cil_refanytype | @cil_arglist | @cil_dup; - -@cil_unary_expr = - @cil_conversion_operation | @cil_unary_arithmetic_operation | @cil_unary_bitwise_operation| - @cil_ldlen | @cil_isinst | @cil_box | @cil_ldobj | @cil_castclass | @cil_unbox_any | - @cil_ldind | @cil_unbox; - -@cil_conversion_operation = - @cil_conv_i1 | @cil_conv_i2 | @cil_conv_i4 | @cil_conv_i8 | - @cil_conv_u1 | @cil_conv_u2 | @cil_conv_u4 | @cil_conv_u8 | - @cil_conv_ovf_i | @cil_conv_ovf_i_un | @cil_conv_ovf_i1 | @cil_conv_ovf_i1_un | - @cil_conv_ovf_i2 | @cil_conv_ovf_i2_un | @cil_conv_ovf_i4 | @cil_conv_ovf_i4_un | - @cil_conv_ovf_i8 | @cil_conv_ovf_i8_un | @cil_conv_ovf_u | @cil_conv_ovf_u_un | - @cil_conv_ovf_u1 | @cil_conv_ovf_u1_un | @cil_conv_ovf_u2 | @cil_conv_ovf_u2_un | - @cil_conv_ovf_u4 | @cil_conv_ovf_u4_un | @cil_conv_ovf_u8 | @cil_conv_ovf_u8_un | - @cil_conv_r4 | @cil_conv_r8 | @cil_conv_ovf_u2 | @cil_conv_ovf_u2_un | - @cil_conv_i | @cil_conv_u | @cil_conv_r_un; - -@cil_ldind = @cil_ldind_i | @cil_ldind_i1 | @cil_ldind_i2 | @cil_ldind_i4 | @cil_ldind_i8 | - @cil_ldind_r4 | @cil_ldind_r8 | @cil_ldind_ref | @cil_ldind_u1 | @cil_ldind_u2 | @cil_ldind_u4; - -@cil_stind = @cil_stind_i | @cil_stind_i1 | @cil_stind_i2 | @cil_stind_i4 | @cil_stind_i8 | - @cil_stind_r4 | @cil_stind_r8 | @cil_stind_ref; - -@cil_bitwise_operation = @cil_binary_bitwise_operation | @cil_unary_bitwise_operation; - -@cil_binary_bitwise_operation = @cil_and | @cil_or | @cil_xor | @cil_shr | @cil_shr | @cil_shr_un | @cil_shl; - -@cil_binary_arithmetic_operation = @cil_add | @cil_sub | @cil_mul | @cil_div | @cil_div_un | - @cil_rem | @cil_rem_un | @cil_add_ovf | @cil_add_ovf_un | @cil_mul_ovf | @cil_mul_ovf_un | - @cil_sub_ovf | @cil_sub_ovf_un; - -@cil_unary_bitwise_operation = @cil_not; - -@cil_binary_expr = @cil_binary_arithmetic_operation | @cil_binary_bitwise_operation | @cil_read_array | @cil_comparison_operation; - -@cil_unary_arithmetic_operation = @cil_neg; - -@cil_comparison_operation = @cil_cgt_un | @cil_ceq | @cil_cgt | @cil_clt | @cil_clt_un; - -// Elements that retrieve an address of something -@cil_read_ref = @cil_ldloca_s | @cil_ldarga_s | @cil_ldflda | @cil_ldsflda | @cil_ldelema; - -// CIL array instructions - -@cil_read_array = - @cil_ldelem | @cil_ldelema | @cil_ldelem_i1 | @cil_ldelem_ref | @cil_ldelem_i | - @cil_ldelem_i1 | @cil_ldelem_i2 | @cil_ldelem_i4 | @cil_ldelem_i8 | @cil_ldelem_r4 | - @cil_ldelem_r8 | @cil_ldelem_u1 | @cil_ldelem_u2 | @cil_ldelem_u4; - -@cil_write_array = @cil_stelem | @cil_stelem_ref | - @cil_stelem_i | @cil_stelem_i1 | @cil_stelem_i2 | @cil_stelem_i4 | @cil_stelem_i8 | - @cil_stelem_r4 | @cil_stelem_r8; - -@cil_throw_any = @cil_throw | @cil_rethrow; - -#keyset[impl, index] -cil_instruction( - unique int id: @cil_instruction, - int opcode: int ref, - int index: int ref, - int impl: @cil_method_implementation ref); - -cil_jump( - unique int instruction: @cil_jump ref, - int target: @cil_instruction ref); - -cil_access( - unique int instruction: @cil_instruction ref, - int target: @cil_accessible ref); - -cil_value( - unique int instruction: @cil_literal ref, - varchar(900) value: string ref); - -#keyset[instruction, index] -cil_switch( - int instruction: @cil_switch ref, - int index: int ref, - int target: @cil_instruction ref); - -cil_instruction_location( - unique int id: @cil_instruction ref, - int loc: @location ref); - -cil_type_location( - int id: @cil_type ref, - int loc: @location ref); - -cil_method_location( - int id: @cil_method ref, - int loc: @location ref); - -@cil_namespace = @namespace; - -@cil_type_container = @cil_type | @cil_namespace | @cil_method; - -case @cil_type.kind of - 0 = @cil_valueorreftype -| 1 = @cil_typeparameter -| 2 = @cil_array_type -| 3 = @cil_pointer_type -; - -cil_type( - unique int id: @cil_type, - varchar(900) name: string ref, - int kind: int ref, - int parent: @cil_type_container ref, - int sourceDecl: @cil_type ref); - -cil_pointer_type( - unique int id: @cil_pointer_type ref, - int pointee: @cil_type ref); - -cil_array_type( - unique int id: @cil_array_type ref, - int element_type: @cil_type ref, - int rank: int ref); - -cil_method( - unique int id: @cil_method, - varchar(900) name: string ref, - int parent: @cil_type ref, - int return_type: @cil_type ref); - -cil_method_source_declaration( - unique int method: @cil_method ref, - int source: @cil_method ref); - -cil_method_implementation( - unique int id: @cil_method_implementation, - int method: @cil_method ref, - int location: @assembly ref); - -cil_implements( - int id: @cil_method ref, - int decl: @cil_method ref); - -#keyset[parent, name] -cil_field( - unique int id: @cil_field, - int parent: @cil_type ref, - varchar(900) name: string ref, - int field_type: @cil_type ref); - -@cil_element = @cil_instruction | @cil_declaration | @cil_handler | @cil_attribute | @cil_namespace; -@cil_named_element = @cil_declaration | @cil_namespace; -@cil_declaration = @cil_variable | @cil_method | @cil_type | @cil_member; -@cil_accessible = @cil_declaration; -@cil_variable = @cil_field | @cil_stack_variable; -@cil_stack_variable = @cil_local_variable | @cil_parameter; -@cil_member = @cil_method | @cil_type | @cil_field | @cil_property | @cil_event; - -#keyset[method, index] -cil_parameter( - unique int id: @cil_parameter, - int method: @cil_method ref, - int index: int ref, - int param_type: @cil_type ref); - -cil_parameter_in(unique int id: @cil_parameter ref); -cil_parameter_out(unique int id: @cil_parameter ref); - -cil_setter(unique int prop: @cil_property ref, - int method: @cil_method ref); - -cil_getter(unique int prop: @cil_property ref, - int method: @cil_method ref); - -cil_adder(unique int event: @cil_event ref, - int method: @cil_method ref); - -cil_remover(unique int event: @cil_event ref, int method: @cil_method ref); - -cil_raiser(unique int event: @cil_event ref, int method: @cil_method ref); - -cil_property( - unique int id: @cil_property, - int parent: @cil_type ref, - varchar(900) name: string ref, - int property_type: @cil_type ref); - -#keyset[parent, name] -cil_event(unique int id: @cil_event, - int parent: @cil_type ref, - varchar(900) name: string ref, - int event_type: @cil_type ref); - -#keyset[impl, index] -cil_local_variable( - unique int id: @cil_local_variable, - int impl: @cil_method_implementation ref, - int index: int ref, - int var_type: @cil_type ref); - -// CIL handlers (exception handlers etc). - -case @cil_handler.kind of - 0 = @cil_catch_handler -| 1 = @cil_filter_handler -| 2 = @cil_finally_handler -| 4 = @cil_fault_handler -; - -#keyset[impl, index] -cil_handler( - unique int id: @cil_handler, - int impl: @cil_method_implementation ref, - int index: int ref, - int kind: int ref, - int try_start: @cil_instruction ref, - int try_end: @cil_instruction ref, - int handler_start: @cil_instruction ref); - -cil_handler_filter( - unique int id: @cil_handler ref, - int filter_start: @cil_instruction ref); - -cil_handler_type( - unique int id: @cil_handler ref, - int catch_type: @cil_type ref); - -@cil_controlflow_node = @cil_entry_point | @cil_instruction; - -@cil_entry_point = @cil_method_implementation | @cil_handler; - -@cil_dataflow_node = @cil_instruction | @cil_variable | @cil_method; - -cil_method_stack_size( - unique int method: @cil_method_implementation ref, - int size: int ref); - -// CIL modifiers - -cil_public(int id: @cil_member ref); -cil_private(int id: @cil_member ref); -cil_protected(int id: @cil_member ref); -cil_internal(int id: @cil_member ref); -cil_static(int id: @cil_member ref); -cil_sealed(int id: @cil_member ref); -cil_virtual(int id: @cil_method ref); -cil_abstract(int id: @cil_member ref); -cil_class(int id: @cil_type ref); -cil_interface(int id: @cil_type ref); -cil_security(int id: @cil_member ref); -cil_requiresecobject(int id: @cil_method ref); -cil_specialname(int id: @cil_method ref); -cil_newslot(int id: @cil_method ref); - -cil_base_class(unique int id: @cil_type ref, int base: @cil_type ref); -cil_base_interface(int id: @cil_type ref, int base: @cil_type ref); - -#keyset[unbound, index] -cil_type_parameter( - int unbound: @cil_member ref, - int index: int ref, - int param: @cil_typeparameter ref); - -#keyset[bound, index] -cil_type_argument( - int bound: @cil_member ref, - int index: int ref, - int t: @cil_type ref); - -// CIL type parameter constraints - -cil_typeparam_covariant(int tp: @cil_typeparameter ref); -cil_typeparam_contravariant(int tp: @cil_typeparameter ref); -cil_typeparam_class(int tp: @cil_typeparameter ref); -cil_typeparam_struct(int tp: @cil_typeparameter ref); -cil_typeparam_new(int tp: @cil_typeparameter ref); -cil_typeparam_constraint(int tp: @cil_typeparameter ref, int supertype: @cil_type ref); - -// CIL attributes - -cil_attribute( - unique int attributeid: @cil_attribute, - int element: @cil_declaration ref, - int constructor: @cil_method ref); - -#keyset[attribute_id, param] -cil_attribute_named_argument( - int attribute_id: @cil_attribute ref, - varchar(100) param: string ref, - varchar(900) value: string ref); - -#keyset[attribute_id, index] -cil_attribute_positional_argument( - int attribute_id: @cil_attribute ref, - int index: int ref, - varchar(900) value: string ref); - - -// Common .Net data model covering both C# and CIL - -// Common elements -@dotnet_element = @element | @cil_element; -@dotnet_named_element = @named_element | @cil_named_element; -@dotnet_callable = @callable | @cil_method; -@dotnet_variable = @variable | @cil_variable; -@dotnet_field = @field | @cil_field; -@dotnet_parameter = @parameter | @cil_parameter; -@dotnet_declaration = @declaration | @cil_declaration; -@dotnet_member = @member | @cil_member; -@dotnet_event = @event | @cil_event; -@dotnet_property = @property | @cil_property | @indexer; - -// Common types -@dotnet_type = @type | @cil_type; -@dotnet_call = @call | @cil_call_any; -@dotnet_throw = @throw_element | @cil_throw_any; -@dotnet_valueorreftype = @cil_valueorreftype | @value_or_ref_type | @cil_array_type | @void_type; -@dotnet_typeparameter = @type_parameter | @cil_typeparameter; -@dotnet_array_type = @array_type | @cil_array_type; -@dotnet_pointer_type = @pointer_type | @cil_pointer_type; -@dotnet_type_parameter = @type_parameter | @cil_typeparameter; -@dotnet_generic = @dotnet_valueorreftype | @dotnet_callable; - -// Attributes -@dotnet_attribute = @attribute | @cil_attribute; - -// Expressions -@dotnet_expr = @expr | @cil_expr; - -// Literals -@dotnet_literal = @literal_expr | @cil_literal; -@dotnet_string_literal = @string_literal_expr | @cil_ldstr; -@dotnet_int_literal = @integer_literal_expr | @cil_ldc_i; -@dotnet_float_literal = @float_literal_expr | @cil_ldc_r; -@dotnet_null_literal = @null_literal_expr | @cil_ldnull; - -@metadata_entity = @cil_method | @cil_type | @cil_field | @cil_property | @field | @property | - @callable | @value_or_ref_type | @void_type; - -#keyset[entity, location] -metadata_handle(int entity : @metadata_entity ref, int location: @assembly ref, int handle: int ref) +/* + * External artifacts + */ + +externalDefects( + unique int id : @externalDefect, + varchar(900) queryPath : string ref, + int location : @location ref, + varchar(900) message : string ref, + float severity : float ref +); + +externalMetrics( + unique int id : @externalMetric, + varchar(900) queryPath : string ref, + int location : @location ref, + float value : float ref +); + +externalData( + int id : @externalDataElement, + varchar(900) path : string ref, + int column: int ref, + varchar(900) value : string ref +); + +snapshotDate(unique date snapshotDate : date ref); + +sourceLocationPrefix(varchar(900) prefix : string ref); + +/* + * Duplicate code + */ + +duplicateCode( + unique int id : @duplication, + varchar(900) relativePath : string ref, + int equivClass : int ref); + +similarCode( + unique int id : @similarity, + varchar(900) relativePath : string ref, + int equivClass : int ref); + +@duplication_or_similarity = @duplication | @similarity + +tokens( + int id : @duplication_or_similarity ref, + int offset : int ref, + int beginLine : int ref, + int beginColumn : int ref, + int endLine : int ref, + int endColumn : int ref); + +/* + * Version history + */ + +svnentries( + int id : @svnentry, + varchar(500) revision : string ref, + varchar(500) author : string ref, + date revisionDate : date ref, + int changeSize : int ref +) + +svnaffectedfiles( + int id : @svnentry ref, + int file : @file ref, + varchar(500) action : string ref +) + +svnentrymsg( + int id : @svnentry ref, + varchar(500) message : string ref +) + +svnchurn( + int commit : @svnentry ref, + int file : @file ref, + int churnedLines : int ref +) + +/* + * C# dbscheme + */ + +/** ELEMENTS **/ + +@element = @container | @type | @expr | @stmt | @member | @variable | @namespace + | @modifier | @accessor | @event_accessor | @type_parameter_constraints + | @namespace_declaration | @using_directive | @attribute + | @xmllocatable | @externalMetric | @externalDefect; + +/** LOCATIONS, ASEMMBLIES, MODULES, FILES and FOLDERS **/ + +@location = @location_default | @assembly; + +locations_default(unique int id: @location_default, + int file: @file ref, + int beginLine: int ref, + int beginColumn: int ref, + int endLine: int ref, + int endColumn: int ref); + +@sourceline = @file | @callable | @xmllocatable; + +numlines(int element_id: @sourceline ref, + int num_lines: int ref, + int num_code: int ref, + int num_comment: int ref); + +assemblies(unique int id: @assembly, + int file: @file ref, + varchar(900) fullname: string ref, + varchar(900) name: string ref, + varchar(900) version: string ref); +/* + fromSource(0) = unknown, + fromSource(1) = from source, + fromSource(2) = from library +*/ +files(unique int id: @file, + varchar(900) name: string ref, + varchar(900) simple: string ref, + varchar(900) ext: string ref, + int fromSource: int ref); + +folders(unique int id: @folder, + varchar(900) name: string ref, + varchar(900) simple: string ref); + +@container = @folder | @file ; + +containerparent(int parent: @container ref, + unique int child: @container ref); + +/** NAMESPACES **/ + +@type_container = @namespace | @type; + +namespaces(unique int id: @namespace, + varchar(900) name: string ref); + +namespace_declarations(unique int id: @namespace_declaration, + int namespace_id: @namespace ref); +namespace_declaration_location(unique int id: @namespace_declaration ref, + int loc: @location ref); + +parent_namespace(unique int child_id: @type_container ref, + int namespace_id: @namespace ref); + +@declaration_or_directive = @namespace_declaration | @type | @using_directive; + +parent_namespace_declaration(int child_id: @declaration_or_directive ref, + int namespace_id: @namespace_declaration ref); + +@using_directive = @using_namespace_directive; + +using_namespace_directives(unique int id: @using_namespace_directive, + int namespace_id: @namespace ref); +using_directive_location(unique int id: @using_directive ref, + int loc: @location ref); + +/** TYPES **/ + +types(unique int id: @type, + int kind: int ref, + varchar(900) name: string ref); +case @type.kind of + 1 = @bool_type +| 2 = @char_type +| 3 = @decimal_type +| 4 = @sbyte_type +| 5 = @short_type +| 6 = @int_type +| 7 = @long_type +| 8 = @byte_type +| 9 = @ushort_type +| 10 = @uint_type +| 11 = @ulong_type +| 12 = @float_type +| 13 = @double_type +| 14 = @enum_type +| 15 = @struct_type +| 17 = @class_type +| 19 = @interface_type +| 20 = @delegate_type +| 21 = @null_type +| 22 = @type_parameter +| 23 = @pointer_type +| 24 = @nullable_type +| 25 = @array_type +| 26 = @void_type +| 27 = @int_ptr_type +| 28 = @uint_ptr_type +| 29 = @dynamic_type +| 30 = @arglist_type + ; + +array_element_type(unique int array: @array_type ref, + int dimension: int ref, + int rank: int ref, + int element: @type ref); +nullable_underlying_type(unique int nullable: @nullable_type ref, + int underlying: @type ref); +pointer_referent_type(unique int pointer: @pointer_type ref, + int referent: @type ref); +enum_underlying_type(unique int enum_id: @enum_type ref, + int underlying_type_id: @type ref); +delegate_return_type(unique int delegate_id: @delegate_type ref, + int return_type_id: @type ref); +extend(unique int sub: @type ref, + int super: @type ref); +implement(int sub: @type ref, + int super: @type ref); + +type_location(int id: @type ref, + int loc: @location ref); + +attributes(unique int id: @attribute, + int type_id: @type ref, + int target: @element ref); + +attribute_location(int id: @attribute ref, + int loc: @location ref); + +/** GENERICS **/ + +@generic = @type | @method; + +is_generic(unique int id: @generic ref); +is_constructed(unique int id: @generic ref); +type_parameters(unique int id: @type_parameter ref, + int index: int ref, + int generic_id: @generic ref); +type_arguments(int id: @type ref, + int index: int ref, + int constructed_id: @generic ref); +constructed_generic(unique int constructed: @generic ref, + int generic: @generic ref); + +type_parameter_constraints(unique int id: @type_parameter_constraints, + int param_id: @type_parameter ref); +type_parameter_constraints_location(int id: @type_parameter_constraints ref, + int loc: @location ref); +general_type_parameter_constraints(int id: @type_parameter_constraints ref, + int kind: int ref /* class = 1, struct = 2, new = 3 */); +specific_type_parameter_constraints(int id: @type_parameter_constraints ref, + int base_id: @type ref); + + +/** MODIFIERS */ + +@modifiable = @member | @accessor; + +modifiers(unique int id: @modifier, + varchar(900) name: string ref); + +has_modifiers(int id: @modifiable ref, + int mod_id: @modifier ref); + +compiler_generated(unique int id: @modifiable ref); + +/** MEMBERS **/ + +@member = @method | @constructor | @destructor | @field | @property | @event | @operator | @indexer | @type; + +@exprorstmt_parent = @expr | @stmt | @memberoraccessor | @variable | @attribute; + +@memberoraccessor = @member | @accessor | @event_accessor; + +@named_exprorstmt = @goto_stmt | @labeled_stmt | @literal_expr; + +exprorstmt_name(unique int parent_id: @named_exprorstmt ref, + varchar(900) name: string ref); + +nested_types(unique int id: @type ref, + int declaring_type_id: @type ref, + int unbound_id: @type ref); + +properties(unique int id: @property, + varchar(900) name: string ref, + int declaring_type_id: @type ref, + int type_id: @type ref, + int unbound_id: @property ref); + +property_location(int id: @property ref, + int loc: @location ref); + +indexers(unique int id: @indexer, + varchar(900) name: string ref, + int declaring_type_id: @type ref, + int type_id: @type ref, + int unbound_id: @indexer ref); + +indexer_location(int id: @indexer ref, + int loc: @location ref); + +accessors(unique int id: @accessor, + int kind: int ref, + varchar(900) name: string ref, + int declaring_member_id: @member ref, + int unbound_id: @accessor ref); +case @accessor.kind of + 1 = @getter +| 2 = @setter + ; + +accessor_location(int id: @accessor ref, + int loc: @location ref); + +events(unique int id: @event, + varchar(900) name: string ref, + int declaring_type_id: @type ref, + int type_id: @type ref, + int unbound_id: @event ref); + +event_location(int id: @event ref, + int loc: @location ref); + +event_accessors(unique int id: @event_accessor, + int kind: int ref, + varchar(900) name: string ref, + int declaring_event_id: @event ref, + int unbound_id: @event_accessor ref); +case @event_accessor.kind of + 1 = @add_event_accessor +| 2 = @remove_event_accessor + ; + +event_accessor_location(int id: @event_accessor ref, + int loc: @location ref); + +operators(unique int id: @operator, + varchar(900) name: string ref, + varchar(900) symbol: string ref, + int declaring_type_id: @type ref, + int type_id: @type ref, + int unbound_id: @operator ref); + +operator_location(int id: @operator ref, + int loc: @location ref); + +constant_value(unique int id: @variable ref, + varchar(900) value: string ref); + +/** CALLABLES **/ + +@callable = @method | @constructor | @destructor | @operator | @accessor | @event_accessor | @variable | @indexer | @anonymous_function_expr; + +methods(unique int id: @method, + varchar(900) name: string ref, + int declaring_type_id: @type ref, + int type_id: @type ref, + int unbound_id: @method ref); + +method_location(int id: @method ref, + int loc: @location ref); + +constructors(unique int id: @constructor, + varchar(900) name: string ref, + int declaring_type_id: @type ref, + int unbound_id: @constructor ref); + +constructor_location(int id: @constructor ref, + int loc: @location ref); + +destructors(unique int id: @destructor, + varchar(900) name: string ref, + int declaring_type_id: @type ref, + int unbound_id: @destructor ref); + +destructor_location(int id: @destructor ref, + int loc: @location ref); + +overrides(int id: @callable ref, + int base_id: @callable ref); + +explicitly_implements( + unique int id: @member ref, + int interface_id: @interface_type ref +); + +/** VARIABLES **/ + +@variable = @local_variable | @parameter | @field; + +fields(unique int id: @field, + int kind: int ref, + varchar(900) name: string ref, + int declaring_type_id: @type ref, + int type_id: @type ref, + int unbound_id: @field ref); +case @field.kind of + 1 = @addressable_field +| 2 = @constant + ; + +field_location(int id: @field ref, + int loc: @location ref); + +localvars(unique int id: @local_variable, + int kind: int ref, + varchar(900) name: string ref, + int implicitly_typed: int ref /* 0 = no, 1 = yes */, + int type_id: @type ref, + int parent_id: @local_var_decl_expr ref); +case @local_variable.kind of + 1 = @addressable_local_variable +| 2 = @local_constant + ; + +localvar_location(unique int id: @local_variable ref, + int loc: @location ref); + +@parameterizable = @callable | @delegate_type; + +params(unique int id: @parameter, + varchar(900) name: string ref, + int type_id: @type ref, + int index: int ref, + int mode: int ref, /* value = 0, ref = 1, out = 2, array = 3, this = 4 */ + int parent_id: @parameterizable ref, + int unbound_id: @parameter ref); + +param_location(int id: @parameter ref, + int loc: @location ref); + +/** STATEMENTS **/ + +statements(unique int id: @stmt, + int kind: int ref, + int index: int ref, + int parent: @exprorstmt_parent ref); +case @stmt.kind of + 1 = @block_stmt +| 2 = @expr_stmt +| 3 = @if_stmt +| 4 = @switch_stmt +| 5 = @while_stmt +| 6 = @do_stmt +| 7 = @for_stmt +| 8 = @foreach_stmt +| 9 = @break_stmt +| 10 = @continue_stmt +| 11 = @goto_stmt +| 12 = @goto_case_stmt +| 13 = @goto_default_stmt +| 14 = @throw_stmt +| 15 = @return_stmt +| 16 = @yield_stmt +| 17 = @try_stmt +| 18 = @checked_stmt +| 19 = @unchecked_stmt +| 20 = @lock_stmt +| 21 = @using_stmt +| 22 = @var_decl_stmt +| 23 = @const_decl_stmt +| 24 = @empty_stmt +| 25 = @unsafe_stmt +| 26 = @fixed_stmt +| 27 = @label_stmt +| 28 = @catch +| 29 = @case + ; + +@labeled_stmt = @label_stmt | @case; + +@decl_stmt = @var_decl_stmt | @const_decl_stmt; + +stmt_location(unique int id: @stmt ref, + int loc: @location ref); + +catch_type(unique int catch_id: @catch ref, + int type_id: @type ref, + int kind: int ref /* explicit = 1, implicit = 2 */); + +/** EXPRESSIONS **/ + +expressions(unique int id: @expr, + int kind: int ref, + int type_id: @type ref, + int index: int ref, + int parent: @exprorstmt_parent ref); +case @expr.kind of +/* literal */ + 1 = @bool_literal_expr +| 2 = @char_literal_expr +| 3 = @decimal_literal_expr +| 4 = @int_literal_expr +| 5 = @long_literal_expr +| 6 = @uint_literal_expr +| 7 = @ulong_literal_expr +| 8 = @float_literal_expr +| 9 = @double_literal_expr +| 10 = @string_literal_expr +| 11 = @null_literal_expr +/* primary & unary */ +| 12 = @this_access_expr +| 13 = @base_access_expr +| 14 = @local_variable_access_expr +| 15 = @parameter_access_expr +| 16 = @field_access_expr +| 17 = @property_access_expr +| 18 = @method_access_expr +| 19 = @event_access_expr +| 20 = @indexer_access_expr +| 21 = @array_access_expr +| 22 = @type_access_expr +| 23 = @typeof_expr +| 24 = @method_invocation_expr +| 25 = @delegate_invocation_expr +| 26 = @operator_invocation_expr +| 27 = @cast_expr +| 28 = @object_creation_expr +| 29 = @explicit_delegate_creation_expr +| 30 = @implicit_delegate_creation_expr +| 31 = @array_creation_expr +| 32 = @default_expr +| 33 = @plus_expr +| 34 = @minus_expr +| 35 = @bit_not_expr +| 36 = @log_not_expr +| 37 = @post_incr_expr +| 38 = @post_decr_expr +| 39 = @pre_incr_expr +| 40 = @pre_decr_expr +/* multiplicative */ +| 41 = @mul_expr +| 42 = @div_expr +| 43 = @rem_expr +/* additive */ +| 44 = @add_expr +| 45 = @sub_expr +/* shift */ +| 46 = @lshift_expr +| 47 = @rshift_expr +/* relational */ +| 48 = @lt_expr +| 49 = @gt_expr +| 50 = @le_expr +| 51 = @ge_expr +/* equality */ +| 52 = @eq_expr +| 53 = @ne_expr +/* logical */ +| 54 = @bit_and_expr +| 55 = @bit_xor_expr +| 56 = @bit_or_expr +| 57 = @log_and_expr +| 58 = @log_or_expr +/* type testing */ +| 59 = @is_expr +| 60 = @as_expr +/* null coalescing */ +| 61 = @null_coalescing_expr +/* conditional */ +| 62 = @conditional_expr +/* assignment */ +| 63 = @simple_assign_expr +| 64 = @assign_add_expr +| 65 = @assign_sub_expr +| 66 = @assign_mul_expr +| 67 = @assign_div_expr +| 68 = @assign_rem_expr +| 69 = @assign_and_expr +| 70 = @assign_xor_expr +| 71 = @assign_or_expr +| 72 = @assign_lshift_expr +| 73 = @assign_rshift_expr +/* more */ +| 74 = @object_init_expr +| 75 = @collection_init_expr +| 76 = @array_init_expr +| 77 = @checked_expr +| 78 = @unchecked_expr +| 79 = @constructor_init_expr +| 80 = @add_event_expr +| 81 = @remove_event_expr +| 82 = @par_expr +| 83 = @local_var_decl_expr +| 84 = @lambda_expr +| 85 = @anonymous_method_expr +| 86 = @namespace_expr +/* dynamic */ +| 87 = @dynamic_conversion_expr +| 88 = @dynamic_unary_conversion_expr +| 89 = @dynamic_invocation_expr +| 90 = @dynamic_event_compound_assign_expr +| 91 = @dynamic_constructor_binder_expr +| 92 = @dynamic_index_binder_expr +| 93 = @dynamic_member_binder_expr +/* unsafe */ +| 100 = @pointer_indirection_expr +| 101 = @address_of_expr +| 102 = @sizeof_expr +/* async */ +| 103 = @await_expr + ; + +@integer_literal_expr = @int_literal_expr | @long_literal_expr | @uint_literal_expr | @ulong_literal_expr; +@real_literal_expr = @float_literal_expr | @double_literal_expr | @decimal_literal_expr; +@literal_expr = @bool_literal_expr | @char_literal_expr | @integer_literal_expr | @real_literal_expr + | @string_literal_expr | @null_literal_expr; + +@assign_expr = @simple_assign_expr | @assign_op_expr | @local_var_decl_expr; +@assign_op_expr = @assign_add_expr | @assign_sub_expr | @assign_mul_expr | @assign_div_expr + | @assign_rem_expr | @assign_and_expr | @assign_or_expr | @assign_xor_expr + | @assign_lshift_expr | @assign_rshift_expr; + +@member_access_expr = @field_access_expr | @property_access_expr | @method_access_expr + | @event_access_expr | @indexer_access_expr | @type_access_expr; +@access_expr = @member_access_expr | @local_variable_access_expr | @parameter_access_expr; + +@objectorcollection_init_expr = @object_init_expr | @collection_init_expr; + +@delegate_creation_expr = @explicit_delegate_creation_expr | @implicit_delegate_creation_expr; + +@anonymous_function_expr = @lambda_expr | @anonymous_method_expr; + +@call = @method_invocation_expr | @constructor_init_expr | @operator_invocation_expr + | @delegate_invocation_expr | @object_creation_expr; + +@dynamic_expr = @dynamic_conversion_expr | @dynamic_unary_conversion_expr | @dynamic_invocation_expr + | @dynamic_event_compound_assign_expr | @dynamic_constructor_binder_expr | @dynamic_index_binder_expr + | @dynamic_member_binder_expr; + +object_creation_mode(unique int id: @object_creation_expr ref, + int mode: int ref /* normal = 1, default value type = 2, type parameter = 3*/); + +implicitly_typed_array_creation(unique int id: @array_creation_expr ref); + +explicitly_sized_array_creation(unique int id: @array_creation_expr ref); + +mutator_invocation_mode(unique int id: @operator_invocation_expr ref, + int mode: int ref /* prefix = 1, postfix = 2*/); + +expr_compiler_generated(unique int id: @expr ref); + +expr_value(int id: @expr ref, + varchar(900) value: string ref); + +expr_call(unique int caller_id: @expr ref, + int target_id: @callable ref); + +expr_access(unique int accesser_id: @access_expr ref, + int target_id: @accessible ref); +@accessible = @method | @field | @property | @indexer | @event | @variable; + +expr_location(unique int id: @expr ref, + int loc: @location ref); + +dynamic_member_name(unique int id: @dynamic_expr ref, + varchar(900) name: string ref); + +/** CONTROL-FLOW **/ + +@cfg_node = @stmt | @expr | @callable; +@loop = @while_stmt | @do_stmt | @for_stmt | @foreach_stmt; +@breakable = @loop | @switch_stmt; + +successors(int from: @cfg_node ref, + int to: @cfg_node ref); + +truecond(int from: @cfg_node ref, + int to: @cfg_node ref); + +falsecond(int from: @cfg_node ref, + int to: @cfg_node ref); + +breaks(int scope: @breakable ref, + int stmt: @break_stmt ref); + +break_target(int scope: @breakable ref, + int next: @cfg_node ref); + +continues(int scope: @loop ref, + int stmt: @continue_stmt ref); + +continue_target(int scope: @loop ref, + int next: @cfg_node ref); + +goto(int from: @cfg_node ref, + int to: @labeled_stmt ref); + +/* a jump from inside to outside of a try-finally statement + executes the finally block "on the way", thus a jump + can take place in several steps: */ + +jump_step(int origin: @cfg_node ref, + int from: @cfg_node ref, + int to: @cfg_node ref); + +last_finally_node(int try: @try_stmt ref, + int node: @cfg_node ref); + +jump_if_true(int node: @cfg_node ref); + +jump_if_false(int node: @cfg_node ref); + +/* XML Files */ + +xmlEncoding (unique int id: @file ref, varchar(900) encoding: string ref); + +xmlDTDs (unique int id: @xmldtd, + varchar(900) root: string ref, + varchar(900) publicId: string ref, + varchar(900) systemId: string ref, + int fileid: @file ref); + +xmlElements (unique int id: @xmlelement, + varchar(900) name: string ref, + int parentid: @xmlparent ref, + int idx: int ref, + int fileid: @file ref); + +xmlAttrs (unique int id: @xmlattribute, + int elementid: @xmlelement ref, + varchar(900) name: string ref, + varchar(3600) value: string ref, + int idx: int ref, + int fileid: @file ref); + +xmlNs (int id: @xmlnamespace, + varchar(900) prefixName: string ref, + varchar(900) URI: string ref, + int fileid: @file ref); + +xmlHasNs (int elementId: @xmlnamespaceable ref, + int nsId: @xmlnamespace ref, + int fileid: @file ref); + +xmlComments (unique int id: @xmlcomment, + varchar(3600) text: string ref, + int parentid: @xmlparent ref, + int fileid: @file ref); + +xmlChars (unique int id: @xmlcharacters, + varchar(3600) text: string ref, + int parentid: @xmlparent ref, + int idx: int ref, + int isCDATA: int ref, + int fileid: @file ref); + +@xmlparent = @file | @xmlelement; +@xmlnamespaceable = @xmlelement | @xmlattribute; + +xmllocations(int xmlElement: @xmllocatable ref, + int location: @location_default ref); + +@xmllocatable = @xmlcharacters | @xmlelement | @xmlcomment | @xmlattribute | @xmldtd | @file | @xmlnamespace; diff --git a/java/ql/lib/upgrades/initial/semmlecode.dbscheme b/java/ql/lib/upgrades/initial/semmlecode.dbscheme new file mode 100644 index 00000000000..57bb881e645 --- /dev/null +++ b/java/ql/lib/upgrades/initial/semmlecode.dbscheme @@ -0,0 +1,648 @@ +/* + * External artifacts + */ + +externalDefects( + unique int id : @externalDefect, + varchar(900) queryPath : string ref, + int location : @location ref, + varchar(900) message : string ref, + float severity : float ref +); + +externalMetrics( + unique int id : @externalMetric, + varchar(900) queryPath : string ref, + int location : @location ref, + float value : float ref +); + +externalData( + int id : @externalDataElement, + varchar(900) path : string ref, + int column: int ref, + varchar(900) value : string ref +); + +snapshotDate(unique date snapshotDate : date ref); + +sourceLocationPrefix(varchar(900) prefix : string ref); + +/* + * Duplicate code + */ + +duplicateCode( + unique int id : @duplication, + varchar(900) relativePath : string ref, + int equivClass : int ref); + +similarCode( + unique int id : @similarity, + varchar(900) relativePath : string ref, + int equivClass : int ref); + +@duplication_or_similarity = @duplication | @similarity + +tokens( + int id : @duplication_or_similarity ref, + int offset : int ref, + int beginLine : int ref, + int beginColumn : int ref, + int endLine : int ref, + int endColumn : int ref); + +/* + * Version history + */ + +svnentries( + int id : @svnentry, + varchar(500) revision : string ref, + varchar(500) author : string ref, + date revisionDate : date ref, + int changeSize : int ref +) + +svnaffectedfiles( + int id : @svnentry ref, + int file : @file ref, + varchar(500) action : string ref +) + +svnentrymsg( + int id : @svnentry ref, + varchar(500) message : string ref +) + +svnchurn( + int commit : @svnentry ref, + int file : @file ref, + int churnedLines : int ref +) + +/* + * Java dbscheme + */ + +@location = @location_default ; + +locations_default(unique int id: @location_default, + int file: @file ref, + int beginLine: int ref, + int beginColumn: int ref, + int endLine: int ref, + int endColumn: int ref + ); + +hasLocation(int locatableid: @locatable ref, int id: @location ref); + +@sourceline = @locatable ; + +numlines(int element_id: @sourceline ref, + int num_lines: int ref, + int num_code: int ref, + int num_comment: int ref + ); + +/* + fromSource(0) = unknown, + fromSource(1) = from source, + fromSource(2) = from library +*/ +files(unique int id: @file, + varchar(900) name: string ref, + varchar(900) simple: string ref, + varchar(900) ext: string ref, + int fromSource: int ref); + +folders(unique int id: @folder, + varchar(900) name: string ref, + varchar(900) simple: string ref); + +@container = @folder | @file + +containerparent(int parent: @container ref, + unique int child: @container ref); + +cupackage (unique int id: @file ref, int packageid: @package ref); + +/* Java */ + +packages (unique int id: @package, + varchar(900) nodeName: string ref); + +primitives (unique int id: @primitive, + varchar(20) nodeName: string ref); + +modifiers (unique int id: @modifier, + varchar(20) nodeName: string ref); + +classes (unique int id: @class, + varchar(900) nodeName: string ref, + int parentid: @package ref, + int sourceid: @class ref); + +interfaces (unique int id: @interface, + varchar(900) nodeName: string ref, + int parentid: @package ref, + int sourceid: @interface ref); + +fielddecls (unique int id: @fielddecl, + int parentid: @reftype ref); + +fieldDeclaredIn (int fieldId: @field ref, + int fieldDeclId: @fielddecl ref, + int pos: int ref); + +fields (unique int id: @field, + varchar(900) nodeName: string ref, + int typeid: @type ref, + int parentid: @reftype ref, + int sourceid: @field ref); + +constrs (unique int id: @constructor, + varchar(900) nodeName: string ref, + varchar(900) signature: string ref, + int typeid: @type ref, + int parentid: @reftype ref, + int sourceid: @constructor ref); + +methods (unique int id: @method, + varchar(900) nodeName: string ref, + varchar(900) signature: string ref, + int typeid: @type ref, + int parentid: @reftype ref, + int sourceid: @method ref); + +params (int id: @param, + varchar(900) nodeName: string ref, + int typeid: @type ref, + int pos: int ref, + int parentid: @callable ref, + int sourceid: @param ref); + +exceptions (unique int id: @exception, + int typeid: @type ref, + int parentid: @callable ref); + +isAnnotType (int interfaceid: @interface ref); + +isAnnotElem (int methodid: @method ref); + +// annotValue(annot, id2, value) holds iff +// annot is an application of an annotation @A(v1=n1,...,vk=nk)] +// && id2=vi, value=ni for some i +annotValue (int parentid: @annotation ref, + int id2: @method ref, + unique int value: @expr ref); // unique because source/bytecode expressions are disjoint + +isEnumType (int classid: @class ref); + +isEnumConst (int fieldid: @field ref); + +typeVars (unique int id: @typevariable, + varchar(900) nodeName: string ref, + int pos: int ref, + int kind: int ref, // unused, but kept for backwards compatibility + int parentid: @typeormethod ref); + +wildcards (unique int id: @wildcard, + varchar(900) nodeName: string ref, + int kind: int ref); + +typeBounds (unique int id: @typebound, + int typeid: @reftype ref, // reftype because there are no primitive bounds + int pos: int ref, + int parentid: @boundedtype ref); + +typeArgs (int argumentid: @reftype ref, + int pos: int ref, + int parentid: @typeormethod ref); + +isParameterized(int memberid: @member ref); + +isRaw (int memberid: @member ref); + +erasure (unique int memberid: @member ref, + int erasureid: @member ref); + +isAnonymClass (int classid: @class ref, + int parent: @classinstancexpr ref); + +isLocalClass (int classid: @class ref, + int parent: @localclassdeclstmt ref); + +isDefConstr (int constructorid: @constructor ref); + +arrays (unique int id: @array, + varchar(900) nodeName: string ref, + int elementtypeid: @type ref, + int dimension: int ref, + int componenttypeid: @type ref); + +enclInReftype (unique int child: @reftype ref, + int parent: @reftype ref); + +// id1 extends id2 +extendsReftype (int id1: @reftype ref, + int id2: @classorinterface ref); + +implInterface (int id1: @classorarray ref, + int id2: @interface ref); + +hasModifier (int id1: @modifiable ref, + int id2: @modifier ref); + +readsField (unique int id: @readsFieldExpr, + int id1: @callable ref, + int id2: @field ref); + +writesField (unique int id: @writesFieldExpr, + int id1: @callable ref, + int id2: @field ref); + +callsMethod (unique int id: @makesMethodCallExpr, + int id1: @callable ref, + int id2: @method ref, + int kind: int ref); + +callsConstr (unique int id: @makesConstructorCallExpr, + int id1: @callable ref, + int id2: @constructor ref, + int kind: int ref); + +imports (unique int id: @import, + int holder: @typeorpackage ref, + varchar(900) name: string ref, + int kind: int ref); + +stmts (unique int id: @stmt, + int kind: int ref, + int parent: @stmtparent ref, + int idx: int ref, + int bodydecl: @callable ref); + +@stmtparent = @callable | @stmt; + +succs(int fromSuccessor: @stmt ref, + int toSuccessor: @stmtparent ref); + +case @stmt.kind of + 0 = @block +| 1 = @ifstmt +| 2 = @forstmt +| 3 = @enhancedforstmt +| 4 = @whilestmt +| 5 = @dostmt +| 6 = @trystmt +| 7 = @switchstmt +| 8 = @synchronizedstmt +| 9 = @returnstmt +| 10 = @throwstmt +| 11 = @breakstmt +| 12 = @continuestmt +| 13 = @emptystmt +| 14 = @exprstmt +| 15 = @labeledstmt +| 16 = @assertstmt +| 17 = @localvariabledeclstmt +| 18 = @localclassdeclstmt +| 19 = @constructorinvocationstmt +| 20 = @superconstructorinvocationstmt +| 21 = @case +| 22 = @catchclause; + +exprs( + unique int id: @expr, + int kind: int ref, + int typeid: @type ref, + int parent: @element ref, // to deal with annotations inside annotations + int idx: int ref +); + +callableEnclosingExpr( + unique int id: @expr ref, + int callable_id: @callable ref +); + +statementEnclosingExpr( + unique int id: @expr ref, + int statement_id: @stmt ref +); + +case @expr.kind of + 1 = @arrayaccess +| 2 = @arraycreationexpr +| 3 = @arrayinit +| 4 = @assignexpr +| 5 = @assignaddexpr +| 6 = @assignsubexpr +| 7 = @assignmulexpr +| 8 = @assigndivexpr +| 9 = @assignremexpr +| 10 = @assignandexpr +| 11 = @assignorexpr +| 12 = @assignxorexpr +| 13 = @assignlshiftexpr +| 14 = @assignrshiftexpr +| 15 = @assignurshiftexpr +| 16 = @booleanliteral +| 17 = @integerliteral +| 18 = @longliteral +| 19 = @floatingpointliteral +| 20 = @doubleliteral +| 21 = @characterliteral +| 22 = @stringliteral +| 23 = @nullliteral +| 24 = @mulexpr +| 25 = @divexpr +| 26 = @remexpr +| 27 = @addexpr +| 28 = @subexpr +| 29 = @lshiftexpr +| 30 = @rshiftexpr +| 31 = @urshiftexpr +| 32 = @andbitexpr +| 33 = @orbitexpr +| 34 = @xorbitexpr +| 35 = @andlogicalexpr +| 36 = @orlogicalexpr +| 37 = @ltexpr +| 38 = @gtexpr +| 39 = @leexpr +| 40 = @geexpr +| 41 = @eqexpr +| 42 = @neexpr +| 43 = @postincexpr +| 44 = @postdecexpr +| 45 = @preincexpr +| 46 = @predecexpr +| 47 = @minusexpr +| 48 = @plusexpr +| 49 = @bitnotexpr +| 50 = @lognotexpr +| 51 = @castexpr +| 52 = @classinstancexpr +| 53 = @conditionalexpr +| 54 = @parexpr +| 55 = @instanceofexpr +| 56 = @localvariabledeclexpr +| 57 = @typeliteral +| 58 = @thisaccess +| 59 = @superaccess +| 60 = @varaccess +| 61 = @methodaccess +| 62 = @typeaccess +| 63 = @arraytypeaccess +| 64 = @packageaccess +| 65 = @wildcardtypeaccess +| 66 = @annotation +| 67 = @uniontypeaccess; + + +@assignment = @assignexpr + | @assignop; + +@unaryassignment = @postincexpr + | @postdecexpr + | @preincexpr + | @predecexpr; + +@assignop = @assignaddexpr + | @assignsubexpr + | @assignmulexpr + | @assigndivexpr + | @assignremexpr + | @assignandexpr + | @assignorexpr + | @assignxorexpr + | @assignlshiftexpr + | @assignrshiftexpr + | @assignurshiftexpr; + +@literal = @booleanliteral + | @integerliteral + | @longliteral + | @floatingpointliteral + | @doubleliteral + | @characterliteral + | @stringliteral + | @nullliteral; + +@binaryexpr = @mulexpr + | @divexpr + | @remexpr + | @addexpr + | @subexpr + | @lshiftexpr + | @rshiftexpr + | @urshiftexpr + | @andbitexpr + | @orbitexpr + | @xorbitexpr + | @andlogicalexpr + | @orlogicalexpr + | @ltexpr + | @gtexpr + | @leexpr + | @geexpr + | @eqexpr + | @neexpr; + +@unaryexpr = @postincexpr + | @postdecexpr + | @preincexpr + | @predecexpr + | @minusexpr + | @plusexpr + | @bitnotexpr + | @lognotexpr; + +@caller = @classinstancexpr + | @methodaccess + | @constructorinvocationstmt + | @superconstructorinvocationstmt; + +@abscaller = @caller | @callExpr ; + +callableBinding (unique int callerid: @caller ref, + int callee: @callable ref); + +@exprparent = @stmt | @expr | @callable | @field | @fielddecl | @class | @interface; + +variableBinding (unique int expr: @varaccess ref, + int variable: @variable ref); + +@variable = @localvar | @param | @field; +@localorparam = @localvar | @param; + +localvars (unique int id: @localvar, + varchar(900) nodeName: string ref, + int typeid: @type ref, + int parentid: @localvariabledeclexpr ref); + +@namedexprorstmt = + @breakstmt + | @continuestmt + | @labeledstmt + | @literal; + +namestrings (varchar(900) name: string ref, + unique int parent: @namedexprorstmt ref); + +javadoc (unique int id: @javadoc); + +isNormalComment(int commentid : @javadoc ref); + +hasJavadoc (int documentableid: @member ref, + int javadocid: @javadoc ref); + +javadocTag (unique int id: @javadocTag, + varchar(900) name: string ref, + int parentid: @javadocParent ref, + int idx: int ref); + +javadocText (unique int id: @javadocText, + varchar(900) text: string ref, + int parentid: @javadocParent ref, + int idx: int ref); + +@typeorpackage = @type | @package; + +@child = @typeorpackage | @typeormethod | @callable; + +@modifiable_or_locatable = @modifiable | @locatable_element; + +@named_element = @commentable | @modifier_named; + +@typeormethod = @type | @method; +@classorinterface = @interface | @class; +@boundedtype = @typevariable | @wildcard; +@reftype = @classorinterface | @array | @boundedtype; +@classorarray = @class | @array; +@type = @primitive | @reftype; +@callable = @method | @constructor; +@element = @file | @package | @primitive | @class | @interface | @method | @constructor | @modifier | @param | @exception | @field | + @annotation | @boundedtype | @array | @localvar | @expr | @stmt | @import | @fielddecl; + +@modifiable = @member_modifiable| @param | @localvar ; + +@commentable = @package | @modifiable | @locatable_element ; + +@package_member = @file | @param | @member ; + +@member_modifiable = @class | @interface | @method | @constructor | @field ; + +@expression = @callExpr | @fieldAccessExpr; +@fieldAccessExpr = @readsFieldExpr | @writesFieldExpr; +@callExpr = @makesMethodCallExpr | @makesConstructorCallExpr; + +@member = @method | @constructor | @field | @reftype ; + +@locatable = @file | @class | @interface | @fielddecl | @field | @constructor | @method | @param | @exception + | @boundedtype | @typebound | @array + | @readsFieldExpr | @writesFieldExpr | @makesMethodCallExpr | @makesConstructorCallExpr + | @import | @stmt | @expr | @localvar | @javadoc | @javadocTag | @javadocText + | @xmllocatable | @externalDefect | @externalMetric; + +@locatable_element = @file | @class | @interface | @field | @param | @exception | @callable + +@named = @param | @member | @package | @typeormethod | @file; + +@modifier_named = @modifier | @modifiable | @named; + +@javadocParent = @javadoc | @javadocTag; +@javadocElement = @javadocTag | @javadocText; + +/* XML Files */ + +xmlEncoding (unique int id: @file ref, varchar(900) encoding: string ref); + +xmlDTDs (unique int id: @xmldtd, + varchar(900) root: string ref, + varchar(900) publicId: string ref, + varchar(900) systemId: string ref, + int fileid: @file ref); + +xmlElements (unique int id: @xmlelement, + varchar(900) name: string ref, + int parentid: @xmlparent ref, + int idx: int ref, + int fileid: @file ref); + +xmlAttrs (unique int id: @xmlattribute, + int elementid: @xmlelement ref, + varchar(900) name: string ref, + varchar(3600) value: string ref, + int idx: int ref, + int fileid: @file ref); + +xmlNs (int id: @xmlnamespace, + varchar(900) prefixName: string ref, + varchar(900) URI: string ref, + int fileid: @file ref); + +xmlHasNs (int elementId: @xmlnamespaceable ref, + int nsId: @xmlnamespace ref, + int fileid: @file ref); + +xmlComments (unique int id: @xmlcomment, + varchar(3600) text: string ref, + int parentid: @xmlparent ref, + int fileid: @file ref); + +xmlChars (unique int id: @xmlcharacters, + varchar(3600) text: string ref, + int parentid: @xmlparent ref, + int idx: int ref, + int isCDATA: int ref, + int fileid: @file ref); + +@xmlparent = @file | @xmlelement; +@xmlnamespaceable = @xmlelement | @xmlattribute; + +xmllocations(int xmlElement: @xmllocatable ref, + int location: @location_default ref); + +@xmllocatable = @xmlcharacters | @xmlelement | @xmlcomment | @xmlattribute | @xmldtd | @file | @xmlnamespace; + +@top = @element | @locatable | @folder; + +/* *** Well-Founded Orders *** */ + +/* The type hierarchy order */ +order:typeOrder(3); + +key:extendsReftype.order(id1, id2, typeOrder); +key:implInterface.order(id1, id2, typeOrder); + +/* The AST parent-child order */ + +order:astChildOrder(4); + +key:classes.order(id, parentid, astChildOrder); // Transitive +key:interfaces.order(id, parentid, astChildOrder); // Transitive +key:fields.order(id, parentid, astChildOrder); +key:methods.order(id, parentid, astChildOrder); +key:constrs.order(id, parentid, astChildOrder); +key:params.order(id, parentid, astChildOrder); +key:exceptions.order(id, parentid, astChildOrder); +key:typeVars.order(id, parentid, astChildOrder); +key:typeBounds.order(id, parentid, astChildOrder); +key:stmts.order(id,parent,astChildOrder); +key:stmts.order(id,bodydecl,astChildOrder); +key:exprs.order(id,parent,astChildOrder); +key:localvars.order(id,parentid,astChildOrder); + +/* Calls and field accesses */ + +key:readsField.order(id, id1, astChildOrder); +key:writesField.order(id, id1, astChildOrder); +key:callsMethod.order(id, id1, astChildOrder); +key:callsConstr.order(id, id1, astChildOrder); + +/* Binary Relations */ + +key:enclInReftype.order(child, parent, astChildOrder); + diff --git a/javascript/ql/lib/upgrades/initial/semmlecode.javascript.dbscheme b/javascript/ql/lib/upgrades/initial/semmlecode.javascript.dbscheme new file mode 100644 index 00000000000..75fcf6336d7 --- /dev/null +++ b/javascript/ql/lib/upgrades/initial/semmlecode.javascript.dbscheme @@ -0,0 +1,477 @@ +/*** Standard fragments ***/ + +/** Files and folders **/ + +@location = @location_default; + +locations_default(unique int id: @location_default, + int file: @file ref, + int beginLine: int ref, + int beginColumn: int ref, + int endLine: int ref, + int endColumn: int ref + ); + +@sourceline = @toplevel; + +numlines(int element_id: @sourceline ref, + int num_lines: int ref, + int num_code: int ref, + int num_comment: int ref + ); + + +/* + fromSource(0) = unknown, + fromSource(1) = from source, + fromSource(2) = from library +*/ +files(unique int id: @file, + varchar(900) name: string ref, + varchar(900) simple: string ref, + varchar(900) ext: string ref, + int fromSource: int ref); + +folders(unique int id: @folder, + varchar(900) name: string ref, + varchar(900) simple: string ref); + + +@container = @folder | @file ; + + +containerparent(int parent: @container ref, + unique int child: @container ref); + +/** Duplicate code **/ + +duplicateCode( + unique int id : @duplication, + varchar(900) relativePath : string ref, + int equivClass : int ref); + +similarCode( + unique int id : @similarity, + varchar(900) relativePath : string ref, + int equivClass : int ref); + +@duplication_or_similarity = @duplication | @similarity; + +tokens( + int id : @duplication_or_similarity ref, + int offset : int ref, + int beginLine : int ref, + int beginColumn : int ref, + int endLine : int ref, + int endColumn : int ref); + +/** External data **/ + +externalDefects( + unique int id : @externalDefect, + varchar(900) queryPath : string ref, + int location : @location ref, + varchar(900) message : string ref, + float severity : float ref +); + +externalMetrics( + unique int id : @externalMetric, + varchar(900) queryPath : string ref, + int location : @location ref, + float value : float ref +); + +externalData( + int id : @externalDataElement, + varchar(900) path : string ref, + int column: int ref, + varchar(900) value : string ref +); + +snapshotDate(unique date snapshotDate : date ref); + +sourceLocationPrefix(varchar(900) prefix : string ref); + +/** Version control data **/ + +svnentries( + int id : @svnentry, + varchar(500) revision : string ref, + varchar(500) author : string ref, + date revisionDate : date ref, + int changeSize : int ref +); + +svnaffectedfiles( + int id : @svnentry ref, + int file : @file ref, + varchar(500) action : string ref +); + +svnentrymsg( + int id : @svnentry ref, + varchar(500) message : string ref +); + +svnchurn( + int commit : @svnentry ref, + int file : @file ref, + int churnedLines : int ref +); + + +/*** JavaScript-specific part ***/ + +// top-level code fragments +toplevels (unique int id: @toplevel, + int kind: int ref); + +case @toplevel.kind of + 0 = @script +| 1 = @inline_script +| 2 = @event_handler +| 3 = @javascript_url; + +// statements +stmts (unique int id: @stmt, + int kind: int ref, + int parent: @stmtparent ref, + int idx: int ref, + varchar(900) tostring: string ref); + +stmtContainers (int stmt: @stmt ref, + int container: @stmt_container ref); + +semicolonInserted (int stmt: @stmt ref); + +jumpTargets (int jump: @stmt ref, + int target: @stmt ref); + +@stmtparent = @stmt | @toplevel | @functionexpr; +@stmt_container = @toplevel | @functiondecl; + +case @stmt.kind of + 0 = @emptystmt +| 1 = @blockstmt +| 2 = @exprstmt +| 3 = @ifstmt +| 4 = @labeledstmt +| 5 = @breakstmt +| 6 = @continuestmt +| 7 = @withstmt +| 8 = @switchstmt +| 9 = @returnstmt +| 10 = @throwstmt +| 11 = @trystmt +| 12 = @whilestmt +| 13 = @dowhilestmt +| 14 = @forstmt +| 15 = @forinstmt +| 16 = @debuggerstmt +| 17 = @functiondeclstmt +| 18 = @vardeclstmt +| 19 = @case +| 20 = @catchclause +; + +// expressions +exprs (unique int id: @expr, + int kind: int ref, + int parent: @exprparent ref, + int idx: int ref, + varchar(900) tostring: string ref); + +literals (varchar(900) value: string ref, + varchar(900) raw: string ref, + unique int expr: @expr ref); + +enclosingStmt (int expr: @expr ref, + int stmt: @stmt ref); + +arraySize (int ae: @arrayexpr ref, + int sz: int ref); + +@exprparent = @expr | @stmt | @property | @vardeclarator; + +case @expr.kind of + 0 = @identifier +| 1 = @nullliteral +| 2 = @booleanliteral +| 3 = @numberliteral +| 4 = @stringliteral +| 5 = @regexpliteral +| 6 = @thisexpr +| 7 = @arrayexpr +| 8 = @objexpr +| 9 = @functionexpr +| 10 = @seqexpr +| 11 = @conditionalexpr +| 12 = @newexpr +| 13 = @callexpr +| 14 = @dotexpr +| 15 = @indexexpr +| 16 = @negexpr +| 17 = @plusexpr +| 18 = @lognotexpr +| 19 = @bitnotexpr +| 20 = @typeofexpr +| 21 = @voidexpr +| 22 = @deleteexpr +| 23 = @eqexpr +| 24 = @neqexpr +| 25 = @eqqexpr +| 26 = @neqqexpr +| 27 = @ltexpr +| 28 = @leexpr +| 29 = @gtexpr +| 30 = @geexpr +| 31 = @lshiftexpr +| 32 = @rshiftexpr +| 33 = @urshiftexpr +| 34 = @addexpr +| 35 = @subexpr +| 36 = @mulexpr +| 37 = @divexpr +| 38 = @modexpr +| 39 = @bitorexpr +| 40 = @xorexpr +| 41 = @bitandexpr +| 42 = @inexpr +| 43 = @instanceofexpr +| 44 = @logandexpr +| 45 = @logorexpr +| 47 = @assignexpr +| 48 = @assignaddexpr +| 49 = @assignsubexpr +| 50 = @assignmulexpr +| 51 = @assigndivexpr +| 52 = @assignmodexpr +| 53 = @assignlshiftexpr +| 54 = @assignrshiftexpr +| 55 = @assignurshiftexpr +| 56 = @assignorexpr +| 57 = @assignxorexpr +| 58 = @assignandexpr +| 59 = @preincexpr +| 60 = @postincexpr +| 61 = @predecexpr +| 62 = @postdecexpr +| 63 = @parexpr +; + +@literal = @nullliteral | @booleanliteral | @numberliteral | @stringliteral | @regexpliteral; + +@propaccess = @dotexpr | @indexexpr; + +@invokeexpr = @newexpr | @callexpr; + +@unaryexpr = @negexpr | @plusexpr | @lognotexpr | @bitnotexpr | @typeofexpr | @voidexpr | @deleteexpr; + +@equalitytest = @eqexpr | @neqexpr | @eqqexpr | @neqqexpr; + +@comparison = @equalitytest | @ltexpr | @leexpr | @gtexpr | @geexpr; + +@binaryexpr = @comparison | @lshiftexpr | @rshiftexpr | @urshiftexpr | @addexpr | @subexpr | @mulexpr | @divexpr | @modexpr | @bitorexpr | @xorexpr | @bitandexpr | @inexpr | @instanceofexpr | @logandexpr | @logorexpr; + +@assignment = @assignexpr | @assignaddexpr | @assignsubexpr | @assignmulexpr | @assigndivexpr | @assignmodexpr | @assignlshiftexpr | @assignrshiftexpr | @assignurshiftexpr | @assignorexpr | @assignxorexpr | @assignandexpr; + +@updateexpr = @preincexpr | @postincexpr | @predecexpr | @postdecexpr; + +// scopes +scopes (unique int id: @scope, + int kind: int ref); + +case @scope.kind of + 0 = @globalscope +| 1 = @functionscope +| 2 = @catchscope +| 3 = @modulescope; + +@scopenode = @functiondecl | @catchclause | @script; + +scopenodes (int node: @scopenode ref, + int scope: @scope ref); + +scopenesting (int inner: @scope ref, + int outer: @scope ref); + +// functions +@functiondecl = @functiondeclstmt | @functionexpr; + +@parameterized = @functiondecl | @catchclause; + +params (unique int id: @param, + int variable: @variable ref, + varchar(900) name: string ref, + int pos: int ref, + int parent: @parameterized ref); + +// variables +variables (unique int id: @variable, + varchar(900) name: string ref, + int scope: @scope ref); + +isArgumentsObject (int id: @variable ref); + +vardecls (unique int id: @vardeclarator, + int variable: @variable ref, + int parent: @stmt ref, + int pos: int ref, + varchar(900) tostring: string ref); + +// function declaration statements and named function expressions implicitly +// declare variables; this table links the function declaration with its variable +functionvars (int func: @functiondecl ref, + int var: @variable ref); + +bind (int id: @identifier ref, + int decl: @variable ref); + +@vardeclaration = @param | @vardeclarator | @functiondecl; + +// properties in object literals +properties (unique int id: @property, + int parent: @objexpr ref, + int index: int ref, + int kind: int ref, // 0 - normal, 1 - getter, 2 - setter + varchar(900) tostring: string ref); + +// comments +comments (unique int id: @comment, + int kind: int ref, + int toplevel: @toplevel ref, + varchar(900) text: string ref, + varchar(900) tostring: string ref); + +case @comment.kind of + 0 = @slashslashcomment +| 1 = @slashstarcomment +| 2 = @doccomment +| 3 = @htmlcommentstart +| 4 = @htmlcommentend; + +@htmlcomment = @htmlcommentstart | @htmlcommentend; +@linecomment = @slashslashcomment | @htmlcomment; +@blockcomment = @slashstarcomment | @doccomment; + +// source lines +lines (unique int id: @line, + int toplevel: @toplevel ref, + varchar(900) text: string ref, + varchar(2) terminator: string ref); + +// errors +errors (unique int id: @error, + int kind: int ref, + int toplevel: @toplevel ref, + varchar(900) message: string ref); + +case @error.kind of + 0 = @parseerror; + +// regular expressions +regexpterm (unique int id: @regexpterm, + int kind: int ref, + int parent: @regexpparent ref, + int idx: int ref, + varchar(900) tostring: string ref); + +@regexpparent = @regexpterm | @regexpliteral; + +case @regexpterm.kind of + 0 = @regexp_alt +| 1 = @regexp_seq +| 2 = @regexp_caret +| 3 = @regexp_dollar +| 4 = @regexp_wordboundary +| 5 = @regexp_nonwordboundary +| 6 = @regexp_positive_lookahead +| 7 = @regexp_negative_lookahead +| 8 = @regexp_star +| 9 = @regexp_plus +| 10 = @regexp_opt +| 11 = @regexp_range +| 12 = @regexp_dot +| 13 = @regexp_group +| 14 = @regexp_normal_char +| 15 = @regexp_hex_escape +| 16 = @regexp_unicode_escape +| 17 = @regexp_dec_escape +| 18 = @regexp_oct_escape +| 19 = @regexp_ctrl_escape +| 20 = @regexp_char_class_escape +| 21 = @regexp_id_escape +| 22 = @regexp_backref +| 23 = @regexp_char_class +| 24 = @regexp_char_range; + +regexpParseErrors (unique int id: @regexp_parse_error, + int kind: int ref, + int regexp: @regexpterm ref); + +case @regexp_parse_error.kind of + 0 = @regexp_parse_error_unexpected_eos +| 1 = @regexp_parse_error_unexpected_char +| 2 = @regexp_parse_error_expected_digit +| 3 = @regexp_parse_error_expected_hex_digit +| 4 = @regexp_parse_error_expected_control_letter +| 5 = @regexp_parse_error_expected_closing_paren +| 6 = @regexp_parse_error_expected_closing_brace +| 7 = @regexp_parse_error_expected_eos +| 8 = @regexp_parse_error_octal_escape +| 9 = @regexp_parse_error_invalid_backref; + +@regexp_quantifier = @regexp_star | @regexp_plus | @regexp_opt | @regexp_range; +@regexp_escape = @regexp_char_escape | @regexp_char_class_escape; +@regexp_char_escape = @regexp_hex_escape | @regexp_unicode_escape | @regexp_dec_escape | @regexp_oct_escape | @regexp_ctrl_escape | @regexp_id_escape; +@regexp_constant = @regexp_normal_char | @regexp_char_escape; + +isGreedy (int id: @regexp_quantifier ref); +rangeQuantifierLowerBound (int id: @regexp_range ref, int lo: int ref); +rangeQuantifierUpperBound (int id: @regexp_range ref, int hi: int ref); +isCapture (int id: @regexp_group ref, int number: int ref); +isInverted (int id: @regexp_char_class ref); +regexpConstValue (int id: @regexp_constant ref, varchar(1) value: string ref); +charClassEscape (int id: @regexp_char_class_escape ref, varchar(1) value: string ref); +backref (int id: @regexp_backref ref, int value: int ref); + +// tokens +tokeninfo (unique int id: @token, + int kind: int ref, + int toplevel: @toplevel ref, + int idx: int ref, + varchar(900) value: string ref); + +case @token.kind of + 0 = @token_eof +| 1 = @token_null_literal +| 2 = @token_boolean_literal +| 3 = @token_numeric_literal +| 4 = @token_string_literal +| 5 = @token_regular_expression +| 6 = @token_identifier +| 7 = @token_keyword +| 8 = @token_punctuator; + +// locations +@locatable = @file + | @toplevel | @stmt | @expr | @property | @vardeclaration + | @comment + | @line + | @error | @regexp_parse_error + | @regexpterm + | @token; + +hasLocation (int locatable: @locatable ref, + int location: @location ref); + +// Closure externs +external_global (unique int id: @external_global, varchar(900) name: string ref); +external_member (unique int id: @external_member, varchar(900) name: string ref, int parent: @external_entity ref); + +external_function (unique int id: @external_function, int decl: @external_decl ref); +external_object (unique int id: @external_object, int decl: @external_decl ref); + +@external_decl = @external_global | @external_member; +@external_entity = @external_function | @external_object; diff --git a/python/ql/lib/upgrades/initial/semmlecode.python.dbscheme b/python/ql/lib/upgrades/initial/semmlecode.python.dbscheme new file mode 100644 index 00000000000..3f9d0d3de95 --- /dev/null +++ b/python/ql/lib/upgrades/initial/semmlecode.python.dbscheme @@ -0,0 +1,837 @@ +/* + * This dbscheme is auto-generated by 'semmle/dbscheme_gen.py'. + * WARNING: Any modifications to this file will be lost. + * Relations can be changed by modifying master.py or + * by adding rules to dbscheme.template + */ + +/* + * External artifacts + */ + +externalDefects( + unique int id : @externalDefect, + varchar(900) queryPath : string ref, + int location : @location ref, + varchar(900) message : string ref, + float severity : float ref +); + +externalMetrics( + unique int id : @externalMetric, + varchar(900) queryPath : string ref, + int location : @location ref, + float value : float ref +); + +externalData( + int id : @externalDataElement, + varchar(900) queryPath : string ref, + int column: int ref, + varchar(900) data : string ref +); + +snapshotDate(unique date snapshotDate : date ref); + +sourceLocationPrefix(varchar(900) prefix : string ref); + + +/* + * Duplicate code + */ + +duplicateCode( + unique int id : @duplication, + varchar(900) relativePath : string ref, + int equivClass : int ref); + +similarCode( + unique int id : @similarity, + varchar(900) relativePath : string ref, + int equivClass : int ref); + +@duplication_or_similarity = @duplication | @similarity + +tokens( + int id : @duplication_or_similarity ref, + int offset : int ref, + int beginLine : int ref, + int beginColumn : int ref, + int endLine : int ref, + int endColumn : int ref); + +/* + * Line metrics + */ +py_codelines(int id : @py_scope ref, + int count : int ref); + +py_commentlines(int id : @py_scope ref, + int count : int ref); + +py_docstringlines(int id : @py_scope ref, + int count : int ref); + +py_alllines(int id : @py_scope ref, + int count : int ref); + +/* + * Version history + */ + +svnentries( + int id : @svnentry, + varchar(500) revision : string ref, + varchar(500) author : string ref, + date revisionDate : date ref, + int changeSize : int ref +) + +svnaffectedfiles( + int id : @svnentry ref, + int file : @file ref, + varchar(500) action : string ref +) + +svnentrymsg( + int id : @svnentry ref, + varchar(500) message : string ref +) + +svnchurn( + int commit : @svnentry ref, + int file : @file ref, + int churnedLines : int ref +) + +/**************************** + Python dbscheme +****************************/ + +/* + fromSource(0) = unknown, + fromSource(1) = from source, + fromSource(2) = from library +*/ +files(unique int id: @file, + varchar(900) name: string ref, + varchar(900) simple: string ref, + varchar(900) ext: string ref, + int fromSource: int ref); + +folders(unique int id: @folder, + varchar(900) name: string ref, + varchar(900) simple: string ref); + +@container = @folder | @file; + +containerparent(int parent: @container ref, + unique int child: @container ref); + +@sourceline = @file | @py_Module; + +numlines(int element_id: @sourceline ref, + int num_lines: int ref, + int num_code: int ref, + int num_comment: int ref + ); + +@location = @location_ast | @location_default ; + +locations_default(unique int id: @location_default, + int file: @file ref, + int beginLine: int ref, + int beginColumn: int ref, + int endLine: int ref, + int endColumn: int ref); + +locations_ast(unique int id: @location_ast, + int module: @py_Module ref, + int beginLine: int ref, + int beginColumn: int ref, + int endLine: int ref, + int endColumn: int ref); + +py_module_path(int module: @py_Module ref, int file: @file ref); + +variable(unique int id : @py_variable, + int scope : @py_scope ref, + varchar(1) name : string ref); + +py_line_lengths(unique int id : @py_line, + int file: @py_Module ref, + int line : int ref, + int length : int ref); + +/* AUTO GENERATED PART STARTS HERE */ + + +/* Assert.location = 0, location */ +/* Assert.test = 1, expr */ +/* Assert.msg = 2, expr */ + +/* Assign.location = 0, location */ +/* Assign.value = 1, expr */ +/* Assign.targets = 2, expr_list */ + +/* Attribute.location = 0, location */ +/* Attribute.value = 1, expr */ +/* Attribute.attr = 2, str */ +/* Attribute.ctx = 3, expr_context */ + +/* AugAssign.location = 0, location */ +/* AugAssign.operation = 1, BinOp */ + +/* BinaryExpr.location = 0, location */ +/* BinaryExpr.left = 1, expr */ +/* BinaryExpr.op = 2, operator */ +/* BinaryExpr.right = 3, expr */ +/* BinaryExpr = AugAssign */ + +/* BoolExpr.location = 0, location */ +/* BoolExpr.op = 1, boolop */ +/* BoolExpr.values = 2, expr_list */ + +/* Break.location = 0, location */ + +/* Bytes.location = 0, location */ +/* Bytes.s = 1, bytes */ + +/* Call.location = 0, location */ +/* Call.func = 1, expr */ +/* Call.args = 2, expr_list */ +/* Call.keywords = 3, keyword_list */ +/* Call.starargs = 4, expr */ +/* Call.kwargs = 5, expr */ + +/* Class.name = 0, str */ +/* Class.body = 1, stmt_list */ +/* Class = ClassExpr */ + +/* ClassExpr.location = 0, location */ +/* ClassExpr.name = 1, str */ +/* ClassExpr.bases = 2, expr_list */ +/* ClassExpr.keywords = 3, keyword_list */ +/* ClassExpr.starargs = 4, expr */ +/* ClassExpr.kwargs = 5, expr */ +/* ClassExpr.inner_scope = 6, Class */ + +/* Compare.location = 0, location */ +/* Compare.left = 1, expr */ +/* Compare.ops = 2, cmpop_list */ +/* Compare.comparators = 3, expr_list */ + +/* Continue.location = 0, location */ + +/* Delete.location = 0, location */ +/* Delete.targets = 1, expr_list */ + +/* Dict.location = 0, location */ +/* Dict.keys = 1, expr_list */ +/* Dict.values = 2, expr_list */ + +/* DictComp.location = 0, location */ +/* DictComp.function = 1, Function */ +/* DictComp.iterable = 2, expr */ + +/* Ellipsis.location = 0, location */ + +/* ExceptStmt.location = 0, location */ +/* ExceptStmt.type = 1, expr */ +/* ExceptStmt.name = 2, expr */ +/* ExceptStmt.body = 3, stmt_list */ + +/* Exec.location = 0, location */ +/* Exec.body = 1, expr */ +/* Exec.globals = 2, expr */ +/* Exec.locals = 3, expr */ + +/* ExprStmt.location = 0, location */ +/* ExprStmt.value = 1, expr */ + +/* For.location = 0, location */ +/* For.target = 1, expr */ +/* For.iter = 2, expr */ +/* For.body = 3, stmt_list */ +/* For.orelse = 4, stmt_list */ + +/* Function.name = 0, str */ +/* Function.args = 1, parameter_list */ +/* Function.vararg = 2, expr */ +/* Function.kwonlyargs = 3, str_list */ +/* Function.kwarg = 4, expr */ +/* Function.body = 5, stmt_list */ +/* Function = FunctionParent */ + +/* FunctionExpr.location = 0, location */ +/* FunctionExpr.name = 1, str */ +/* FunctionExpr.args = 2, arguments */ +/* FunctionExpr.returns = 3, expr */ +/* FunctionExpr.inner_scope = 4, Function */ + +/* GeneratorExp.location = 0, location */ +/* GeneratorExp.function = 1, Function */ +/* GeneratorExp.iterable = 2, expr */ + +/* Global.location = 0, location */ +/* Global.names = 1, str_list */ + +/* If.location = 0, location */ +/* If.test = 1, expr */ +/* If.body = 2, stmt_list */ +/* If.orelse = 3, stmt_list */ + +/* IfExp.location = 0, location */ +/* IfExp.test = 1, expr */ +/* IfExp.body = 2, expr */ +/* IfExp.orelse = 3, expr */ + +/* Import.location = 0, location */ +/* Import.names = 1, alias_list */ + +/* ImportExpr.location = 0, location */ +/* ImportExpr.level = 1, int */ +/* ImportExpr.name = 2, str */ +/* ImportExpr.top = 3, bool */ + +/* ImportStar.location = 0, location */ +/* ImportStar.module = 1, expr */ + +/* ImportMember.location = 0, location */ +/* ImportMember.module = 1, expr */ +/* ImportMember.name = 2, str */ + +/* Lambda.location = 0, location */ +/* Lambda.args = 1, arguments */ +/* Lambda.inner_scope = 2, Function */ + +/* List.location = 0, location */ +/* List.elts = 1, expr_list */ +/* List.ctx = 2, expr_context */ + +/* ListComp.location = 0, location */ +/* ListComp.function = 1, Function */ +/* ListComp.iterable = 2, expr */ +/* ListComp.generators = 3, comprehension_list */ +/* ListComp.elt = 4, expr */ + +/* Module.name = 0, str */ +/* Module.hash = 1, str */ +/* Module.body = 2, stmt_list */ +/* Module.kind = 3, str */ + +/* Name.location = 0, location */ +/* Name.variable = 1, variable */ +/* Name.ctx = 2, expr_context */ +/* Name = ParameterList */ + +/* Nonlocal.location = 0, location */ +/* Nonlocal.names = 1, str_list */ + +/* Num.location = 0, location */ +/* Num.n = 1, number */ +/* Num.text = 2, number */ + +/* Pass.location = 0, location */ + +/* Print.location = 0, location */ +/* Print.dest = 1, expr */ +/* Print.values = 2, expr_list */ +/* Print.nl = 3, bool */ + +/* Raise.location = 0, location */ +/* Raise.exc = 1, expr */ +/* Raise.cause = 2, expr */ +/* Raise.type = 3, expr */ +/* Raise.inst = 4, expr */ +/* Raise.tback = 5, expr */ + +/* Repr.location = 0, location */ +/* Repr.value = 1, expr */ + +/* Return.location = 0, location */ +/* Return.value = 1, expr */ + +/* Set.location = 0, location */ +/* Set.elts = 1, expr_list */ + +/* SetComp.location = 0, location */ +/* SetComp.function = 1, Function */ +/* SetComp.iterable = 2, expr */ + +/* Slice.location = 0, location */ +/* Slice.start = 1, expr */ +/* Slice.stop = 2, expr */ +/* Slice.step = 3, expr */ + +/* Starred.location = 0, location */ +/* Starred.value = 1, expr */ +/* Starred.ctx = 2, expr_context */ + +/* Str.location = 0, location */ +/* Str.s = 1, str */ + +/* Subscript.location = 0, location */ +/* Subscript.value = 1, expr */ +/* Subscript.index = 2, expr */ +/* Subscript.ctx = 3, expr_context */ + +/* Try.location = 0, location */ +/* Try.body = 1, stmt_list */ +/* Try.orelse = 2, stmt_list */ +/* Try.handlers = 3, stmt_list */ +/* Try.finalbody = 4, stmt_list */ + +/* Tuple.location = 0, location */ +/* Tuple.elts = 1, expr_list */ +/* Tuple.ctx = 2, expr_context */ +/* Tuple = ParameterList */ + +/* UnaryExpr.location = 0, location */ +/* UnaryExpr.op = 1, unaryop */ +/* UnaryExpr.operand = 2, expr */ + +/* While.location = 0, location */ +/* While.test = 1, expr */ +/* While.body = 2, stmt_list */ +/* While.orelse = 3, stmt_list */ + +/* With.location = 0, location */ +/* With.context_expr = 1, expr */ +/* With.optional_vars = 2, expr */ +/* With.body = 3, stmt_list */ + +/* Yield.location = 0, location */ +/* Yield.value = 1, expr */ + +/* YieldFrom.location = 0, location */ +/* YieldFrom.value = 1, expr */ + +/* Alias.value = 0, expr */ +/* Alias.asname = 1, expr */ +/* Alias = AliasList */ +/* AliasList = Import */ + +/* Arguments.kw_defaults = 0, expr_list */ +/* Arguments.defaults = 1, expr_list */ +/* Arguments.annotations = 2, expr_list */ +/* Arguments.varargannotation = 3, expr */ +/* Arguments.kwargannotation = 4, expr */ +/* Arguments = ArgumentsParent */ +/* boolean = BoolParent */ +/* Boolop = BoolExpr */ +/* string = Bytes */ +/* Cmpop = CmpopList */ +/* CmpopList = Compare */ + +/* Comprehension.iter = 0, expr */ +/* Comprehension.target = 1, expr */ +/* Comprehension.ifs = 2, expr_list */ +/* Comprehension = ComprehensionList */ +/* ComprehensionList = ListComp */ + +/* Expr.location = 0, location */ +/* Expr = ExprParent */ +/* ExprContext = ExprContextParent */ +/* ExprList = ExprListParent */ +/* int = ImportExpr */ + +/* Keyword.arg = 0, str */ +/* Keyword.value = 1, expr */ +/* Keyword = KeywordList */ +/* KeywordList = KeywordListParent */ +/* Location = ExprOrStmt */ +/* string = Num */ +/* Operator = BinaryExpr */ +/* ParameterList = Function */ + +/* Stmt.location = 0, location */ +/* Stmt = StmtList */ +/* StmtList = StmtListParent */ +/* string = StrParent */ +/* StringList = StrListParent */ +/* Unaryop = UnaryExpr */ +/* Variable = Name */ +py_Classes(unique int id : @py_Class, + unique int parent : @py_ClassExpr ref); + +py_Functions(unique int id : @py_Function, + int parent : @py_Function_parent ref, + int idx : int ref); + +py_Modules(unique int id : @py_Module); + +py_aliases(unique int id : @py_alias, + int parent : @py_alias_list ref, + int idx : int ref); + +py_alias_lists(unique int id : @py_alias_list, + unique int parent : @py_Import ref); + +py_arguments(unique int id : @py_arguments, + int parent : @py_arguments_parent ref, + int idx : int ref); + +py_bools(boolean id : boolean ref, + unique int parent : @py_bool_parent ref); + +py_boolops(unique int id : @py_boolop, + int kind: int ref, + unique int parent : @py_BoolExpr ref); + +py_bytes(varchar(1) id : string ref, + unique int parent : @py_Bytes ref); + +py_cmpops(unique int id : @py_cmpop, + int kind: int ref, + int parent : @py_cmpop_list ref, + int idx : int ref); + +py_cmpop_lists(unique int id : @py_cmpop_list, + unique int parent : @py_Compare ref); + +py_comprehensions(unique int id : @py_comprehension, + int parent : @py_comprehension_list ref, + int idx : int ref); + +py_comprehension_lists(unique int id : @py_comprehension_list, + unique int parent : @py_ListComp ref); + +py_exprs(unique int id : @py_expr, + int kind: int ref, + int parent : @py_expr_parent ref, + int idx : int ref); + +py_expr_contexts(unique int id : @py_expr_context, + int kind: int ref, + int parent : @py_expr_context_parent ref, + int idx : int ref); + +py_expr_lists(unique int id : @py_expr_list, + int parent : @py_expr_list_parent ref, + int idx : int ref); + +py_ints(int id : int ref, + unique int parent : @py_ImportExpr ref); + +py_keywords(unique int id : @py_keyword, + int parent : @py_keyword_list ref, + int idx : int ref); + +py_keyword_lists(unique int id : @py_keyword_list, + unique int parent : @py_keyword_list_parent ref); + +py_locations(unique int id : @location ref, + unique int parent : @py_expr_or_stmt ref); + +py_numbers(varchar(1) id : string ref, + int parent : @py_Num ref, + int idx : int ref); + +py_operators(unique int id : @py_operator, + int kind: int ref, + unique int parent : @py_BinaryExpr ref); + +py_parameter_lists(unique int id : @py_parameter_list, + unique int parent : @py_Function ref); + +py_stmts(unique int id : @py_stmt, + int kind: int ref, + int parent : @py_stmt_list ref, + int idx : int ref); + +py_stmt_lists(unique int id : @py_stmt_list, + int parent : @py_stmt_list_parent ref, + int idx : int ref); + +py_strs(varchar(1) id : string ref, + int parent : @py_str_parent ref, + int idx : int ref); + +py_str_lists(unique int id : @py_str_list, + int parent : @py_str_list_parent ref, + int idx : int ref); + +py_unaryops(unique int id : @py_unaryop, + int kind: int ref, + unique int parent : @py_UnaryExpr ref); + +py_variables(int id : @py_variable ref, + unique int parent : @py_Name ref); + +@py_Function_parent = @py_DictComp | @py_FunctionExpr | @py_GeneratorExp | @py_Lambda | @py_ListComp | @py_SetComp; + +@py_arguments_parent = @py_FunctionExpr | @py_Lambda; + +@py_ast_node = @py_Class | @py_Function | @py_Module | @py_expr | @py_stmt; + +@py_bool_parent = @py_ImportExpr | @py_Print; + +case @py_boolop.kind of + 0 = @py_And +| 1 = @py_Or; + +case @py_cmpop.kind of + 0 = @py_Eq +| 1 = @py_Gt +| 2 = @py_GtE +| 3 = @py_In +| 4 = @py_Is +| 5 = @py_IsNot +| 6 = @py_Lt +| 7 = @py_LtE +| 8 = @py_NotEq +| 9 = @py_NotIn; + +case @py_expr.kind of + 0 = @py_Attribute +| 1 = @py_BinaryExpr +| 2 = @py_BoolExpr +| 3 = @py_Bytes +| 4 = @py_Call +| 5 = @py_ClassExpr +| 6 = @py_Compare +| 7 = @py_Dict +| 8 = @py_DictComp +| 9 = @py_Ellipsis +| 10 = @py_FunctionExpr +| 11 = @py_GeneratorExp +| 12 = @py_IfExp +| 13 = @py_ImportExpr +| 14 = @py_ImportMember +| 15 = @py_Lambda +| 16 = @py_List +| 17 = @py_ListComp +| 18 = @py_Name +| 19 = @py_Num +| 20 = @py_Repr +| 21 = @py_Set +| 22 = @py_SetComp +| 23 = @py_Slice +| 24 = @py_Starred +| 25 = @py_Str +| 26 = @py_Subscript +| 27 = @py_Tuple +| 28 = @py_UnaryExpr +| 29 = @py_Yield +| 30 = @py_YieldFrom; + +case @py_expr_context.kind of + 0 = @py_AugLoad +| 1 = @py_AugStore +| 2 = @py_Del +| 3 = @py_Load +| 4 = @py_Param +| 5 = @py_Store; + +@py_expr_context_parent = @py_Attribute | @py_List | @py_Name | @py_Starred | @py_Subscript | @py_Tuple; + +@py_expr_list_parent = @py_Assign | @py_BoolExpr | @py_Call | @py_ClassExpr | @py_Compare | @py_Delete | @py_Dict | @py_List | @py_Print | @py_Set | @py_Tuple | @py_arguments | @py_comprehension; + +@py_expr_or_stmt = @py_expr | @py_stmt; + +@py_expr_parent = @py_Assert | @py_Assign | @py_Attribute | @py_AugAssign | @py_BinaryExpr | @py_Call | @py_ClassExpr | @py_Compare | @py_DictComp | @py_ExceptStmt | @py_Exec | @py_Expr_stmt | @py_For | @py_Function | @py_FunctionExpr | @py_GeneratorExp | @py_If | @py_IfExp | @py_ImportMember | @py_ImportStar | @py_ListComp | @py_Print | @py_Raise | @py_Repr | @py_Return | @py_SetComp | @py_Slice | @py_Starred | @py_Subscript | @py_UnaryExpr | @py_While | @py_With | @py_Yield | @py_YieldFrom | @py_alias | @py_arguments | @py_comprehension | @py_expr_list | @py_keyword | @py_parameter_list; + +@py_keyword_list_parent = @py_Call | @py_ClassExpr; + +case @py_operator.kind of + 0 = @py_Add +| 1 = @py_BitAnd +| 2 = @py_BitOr +| 3 = @py_BitXor +| 4 = @py_Div +| 5 = @py_FloorDiv +| 6 = @py_LShift +| 7 = @py_Mod +| 8 = @py_Mult +| 9 = @py_Pow +| 10 = @py_RShift +| 11 = @py_Sub; + +@py_parameter = @py_Name | @py_Tuple; + +@py_scope = @py_Class | @py_Function | @py_Module; + +case @py_stmt.kind of + 0 = @py_Assert +| 1 = @py_Assign +| 2 = @py_AugAssign +| 3 = @py_Break +| 4 = @py_Continue +| 5 = @py_Delete +| 6 = @py_ExceptStmt +| 7 = @py_Exec +| 8 = @py_Expr_stmt +| 9 = @py_For +| 10 = @py_Global +| 11 = @py_If +| 12 = @py_Import +| 13 = @py_ImportStar +| 14 = @py_Nonlocal +| 15 = @py_Pass +| 16 = @py_Print +| 17 = @py_Raise +| 18 = @py_Return +| 19 = @py_Try +| 20 = @py_While +| 21 = @py_With; + +@py_stmt_list_parent = @py_Class | @py_ExceptStmt | @py_For | @py_Function | @py_If | @py_Module | @py_Try | @py_While | @py_With; + +@py_str_list_parent = @py_Function | @py_Global | @py_Nonlocal; + +@py_str_parent = @py_Attribute | @py_Class | @py_ClassExpr | @py_Function | @py_FunctionExpr | @py_ImportExpr | @py_ImportMember | @py_Module | @py_Str | @py_keyword | @py_str_list; + +case @py_unaryop.kind of + 0 = @py_Invert +| 1 = @py_Not +| 2 = @py_UAdd +| 3 = @py_USub; + + +/* + * End of auto-generated part + */ + + + +/* Map relative names to absolute names for imports */ +py_absolute_names(int module : @py_Module ref, + varchar(1) relname : string ref, + varchar(1) absname : string ref); + +py_exports(int id : @py_Module ref, + varchar(1) name : string ref); + +/* Successor information */ +py_successors(int predecessor : @py_flow_node ref, + int successor : @py_flow_node ref); + +py_true_successors(int predecessor : @py_flow_node ref, + int successor : @py_flow_node ref); + +py_exception_successors(int predecessor : @py_flow_node ref, + int successor : @py_flow_node ref); + +py_false_successors(int predecessor : @py_flow_node ref, + int successor : @py_flow_node ref); + +py_flow_bb_node(unique int flownode : @py_flow_node, + int realnode : @py_ast_node ref, + int basicblock : @py_flow_node ref, + int index : int ref); + +py_scope_flow(int flow : @py_flow_node ref, + int scope : @py_scope ref, + int kind : int ref); + +py_idoms(unique int node : @py_flow_node ref, + int immediate_dominator : @py_flow_node ref); + +py_ssa_phi(int phi : @py_ssa_var ref, + int arg: @py_ssa_var ref); + +py_ssa_var(unique int id : @py_ssa_var, + int var : @py_variable ref); + +py_ssa_use(int node: @py_flow_node ref, + int var : @py_ssa_var ref); + +py_ssa_defn(unique int id : @py_ssa_var ref, + int node: @py_flow_node ref); + +@py_base_var = @py_variable | @py_ssa_var; + +py_scopes(unique int node : @py_expr_or_stmt ref, + int scope : @py_scope ref); + +py_scope_location(unique int id : @location ref, + unique int scope : @py_scope ref); + +py_flags(unique varchar(1) name : string ref, + varchar(1) value : string ref); + +py_syntax_error(unique int id : @location ref, + varchar(1) message : string ref); + +py_comments(unique int id : @py_comment, + varchar(1) text : string ref, + unique int location : @location ref); + +/* Type information support */ + +py_cobjects(unique int obj : @py_cobject, + int typeof : @py_cobject ref); + +py_cmembers(int object : @py_cobject ref, + varchar(1) name : string ref, + int member : @py_cobject ref); + +py_citems(int object : @py_cobject ref, + int index : int ref, + int member : @py_cobject ref); + +py_cobjectnames(unique int obj : @py_cobject ref, + varchar(1) name : string ref); + +py_special_objects(unique int obj : @py_cobject ref, + unique varchar(1) name : string ref); + +py_decorated_object(int object : @py_object ref, + int level: int ref); + +@py_object = @py_cobject | @py_flow_node; + +@py_source_element = @py_ast_node | @container; + +/* XML Files */ + +xmlEncoding (unique int id: @file ref, varchar(900) encoding: string ref); + +xmlDTDs (unique int id: @xmldtd, + varchar(900) root: string ref, + varchar(900) publicId: string ref, + varchar(900) systemId: string ref, + int fileid: @file ref); + +xmlElements (unique int id: @xmlelement, + varchar(900) name: string ref, + int parentid: @xmlparent ref, + int idx: int ref, + int fileid: @file ref); + +xmlAttrs (unique int id: @xmlattribute, + int elementid: @xmlelement ref, + varchar(900) name: string ref, + varchar(3600) value: string ref, + int idx: int ref, + int fileid: @file ref); + +xmlNs (int id: @xmlnamespace, + varchar(900) prefixName: string ref, + varchar(900) URI: string ref, + int fileid: @file ref); + +xmlHasNs (int elementId: @xmlnamespaceable ref, + int nsId: @xmlnamespace ref, + int fileid: @file ref); + +xmlComments (unique int id: @xmlcomment, + varchar(3600) text: string ref, + int parentid: @xmlparent ref, + int fileid: @file ref); + +xmlChars (unique int id: @xmlcharacters, + varchar(3600) text: string ref, + int parentid: @xmlparent ref, + int idx: int ref, + int isCDATA: int ref, + int fileid: @file ref); + +@xmlparent = @file | @xmlelement; +@xmlnamespaceable = @xmlelement | @xmlattribute; + +xmllocations(int xmlElement: @xmllocatable ref, + int location: @location_default ref); + +@xmllocatable = @xmlcharacters | @xmlelement | @xmlcomment | @xmlattribute | @xmldtd | @file | @xmlnamespace;