hexsha
stringlengths
40
40
size
int64
22
2.4M
ext
stringclasses
5 values
lang
stringclasses
1 value
max_stars_repo_path
stringlengths
3
260
max_stars_repo_name
stringlengths
5
109
max_stars_repo_head_hexsha
stringlengths
40
78
max_stars_repo_licenses
listlengths
1
9
max_stars_count
float64
1
191k
max_stars_repo_stars_event_min_datetime
stringlengths
24
24
max_stars_repo_stars_event_max_datetime
stringlengths
24
24
max_issues_repo_path
stringlengths
3
260
max_issues_repo_name
stringlengths
5
109
max_issues_repo_head_hexsha
stringlengths
40
78
max_issues_repo_licenses
listlengths
1
9
max_issues_count
float64
1
67k
max_issues_repo_issues_event_min_datetime
stringlengths
24
24
max_issues_repo_issues_event_max_datetime
stringlengths
24
24
max_forks_repo_path
stringlengths
3
260
max_forks_repo_name
stringlengths
5
109
max_forks_repo_head_hexsha
stringlengths
40
78
max_forks_repo_licenses
listlengths
1
9
max_forks_count
float64
1
105k
max_forks_repo_forks_event_min_datetime
stringlengths
24
24
max_forks_repo_forks_event_max_datetime
stringlengths
24
24
content
stringlengths
22
2.4M
avg_line_length
float64
5
169k
max_line_length
int64
5
786k
alphanum_fraction
float64
0.06
0.95
matches
listlengths
1
11
ef2ea5d3eac6487ff414f81deafd0aa38fa6662d
447,096
c
C
compiler/bootstrap/libec/bootstrap/type.c
Acidburn0zzz/ecere-sdk
6eb4d438465e75a2459a07d6724d0ca2296304ce
[ "BSD-3-Clause" ]
null
null
null
compiler/bootstrap/libec/bootstrap/type.c
Acidburn0zzz/ecere-sdk
6eb4d438465e75a2459a07d6724d0ca2296304ce
[ "BSD-3-Clause" ]
null
null
null
compiler/bootstrap/libec/bootstrap/type.c
Acidburn0zzz/ecere-sdk
6eb4d438465e75a2459a07d6724d0ca2296304ce
[ "BSD-3-Clause" ]
null
null
null
/* Code generated from eC source file: type.ec */ #if defined(__GNUC__) typedef long long int64; typedef unsigned long long uint64; #ifndef _WIN32 #define __declspec(x) #endif #elif defined(__TINYC__) #include <stdarg.h> #define __builtin_va_list va_list #define __builtin_va_start va_start #define __builtin_va_end va_end #ifdef _WIN32 #define strcasecmp stricmp #define strncasecmp strnicmp #define __declspec(x) __attribute__((x)) #else #define __declspec(x) #endif typedef long long int64; typedef unsigned long long uint64; #else typedef __int64 int64; typedef unsigned __int64 uint64; #endif #ifdef __BIG_ENDIAN__ #define __ENDIAN_PAD(x) (8 - (x)) #else #define __ENDIAN_PAD(x) 0 #endif #include <stdint.h> #include <sys/types.h> extern void * __ecereNameSpace__ecere__com__eSystem_New(unsigned int size); extern void * __ecereNameSpace__ecere__com__eSystem_New0(unsigned int size); extern void * __ecereNameSpace__ecere__com__eSystem_Renew(void * memory, unsigned int size); extern void * __ecereNameSpace__ecere__com__eSystem_Renew0(void * memory, unsigned int size); extern void __ecereNameSpace__ecere__com__eSystem_Delete(void * memory); extern struct __ecereNameSpace__ecere__com__Class * __ecereClass___ecereNameSpace__ecere__sys__BTNode; struct __ecereNameSpace__ecere__sys__BTNode; extern struct __ecereNameSpace__ecere__com__Class * __ecereClass___ecereNameSpace__ecere__sys__BinaryTree; struct __ecereNameSpace__ecere__sys__BinaryTree { struct __ecereNameSpace__ecere__sys__BTNode * root; int count; int (* CompareKey)(struct __ecereNameSpace__ecere__sys__BinaryTree * tree, uintptr_t a, uintptr_t b); void (* FreeKey)(void * key); } __attribute__ ((gcc_struct)); extern struct __ecereNameSpace__ecere__com__Class * __ecereClass___ecereNameSpace__ecere__sys__OldList; struct __ecereNameSpace__ecere__sys__OldList { void * first; void * last; int count; unsigned int offset; unsigned int circ; } __attribute__ ((gcc_struct)); extern struct __ecereNameSpace__ecere__com__Class * __ecereClass___ecereNameSpace__ecere__com__Method; struct __ecereNameSpace__ecere__com__Method { char * name; struct __ecereNameSpace__ecere__com__Method * parent; struct __ecereNameSpace__ecere__com__Method * left; struct __ecereNameSpace__ecere__com__Method * right; int depth; int (* function)(); int vid; int type; struct __ecereNameSpace__ecere__com__Class * _class; void * symbol; char * dataTypeString; struct Type * dataType; int memberAccess; } __attribute__ ((gcc_struct)); extern struct __ecereNameSpace__ecere__com__Class * __ecereClass___ecereNameSpace__ecere__com__Property; struct __ecereNameSpace__ecere__com__Property { struct __ecereNameSpace__ecere__com__Property * prev; struct __ecereNameSpace__ecere__com__Property * next; char * name; unsigned int isProperty; int memberAccess; int id; struct __ecereNameSpace__ecere__com__Class * _class; char * dataTypeString; struct __ecereNameSpace__ecere__com__Class * dataTypeClass; struct Type * dataType; void (* Set)(void * , int); int (* Get)(void * ); unsigned int (* IsSet)(void * ); void * data; void * symbol; int vid; unsigned int conversion; unsigned int watcherOffset; char * category; unsigned int compiled; unsigned int selfWatchable; unsigned int isWatchable; } __attribute__ ((gcc_struct)); extern struct __ecereNameSpace__ecere__com__Class * __ecereClass_CodePosition; struct CodePosition { int line; int charPos; int pos; int included; } __attribute__ ((gcc_struct)); extern struct __ecereNameSpace__ecere__com__Class * __ecereClass_Location; struct Location { struct CodePosition start; struct CodePosition end; } __attribute__ ((gcc_struct)); extern struct __ecereNameSpace__ecere__com__Class * __ecereClass_Attrib; struct Attrib { struct Location loc; int type; struct __ecereNameSpace__ecere__sys__OldList * attribs; } __attribute__ ((gcc_struct)); extern struct __ecereNameSpace__ecere__com__Class * __ecereClass_ExtDecl; struct ExtDecl; extern struct __ecereNameSpace__ecere__com__Class * __ecereClass_ClassDefinition; struct ClassDefinition; extern struct __ecereNameSpace__ecere__com__Class * __ecereClass_Context; struct Context { struct Context * parent; struct __ecereNameSpace__ecere__sys__BinaryTree types; struct __ecereNameSpace__ecere__sys__BinaryTree classes; struct __ecereNameSpace__ecere__sys__BinaryTree symbols; struct __ecereNameSpace__ecere__sys__BinaryTree structSymbols; int nextID; int simpleID; struct __ecereNameSpace__ecere__sys__BinaryTree templateTypes; struct ClassDefinition * classDef; unsigned int templateTypesOnly; unsigned int hasNameSpace; } __attribute__ ((gcc_struct)); extern struct __ecereNameSpace__ecere__com__Class * __ecereClass_Instantiation; struct Instantiation { struct Instantiation * prev; struct Instantiation * next; struct Location loc; struct Specifier * _class; struct Expression * exp; struct __ecereNameSpace__ecere__sys__OldList * members; struct Symbol * symbol; unsigned int fullSet; unsigned int isConstant; unsigned char * data; struct Location nameLoc; struct Location insideLoc; unsigned int built; } __attribute__ ((gcc_struct)); extern struct __ecereNameSpace__ecere__com__Class * __ecereClass_Declaration; struct Declaration { struct Declaration * prev; struct Declaration * next; struct Location loc; int type; union { struct { struct __ecereNameSpace__ecere__sys__OldList * specifiers; struct __ecereNameSpace__ecere__sys__OldList * declarators; } __attribute__ ((gcc_struct)); struct Instantiation * inst; struct { struct Identifier * id; struct Expression * exp; } __attribute__ ((gcc_struct)); } __attribute__ ((gcc_struct)); struct Specifier * extStorage; struct Symbol * symbol; int declMode; } __attribute__ ((gcc_struct)); extern struct __ecereNameSpace__ecere__com__Class * __ecereClass_Statement; struct Statement { struct Statement * prev; struct Statement * next; struct Location loc; int type; union { struct __ecereNameSpace__ecere__sys__OldList * expressions; struct { struct Identifier * id; struct Statement * stmt; } __attribute__ ((gcc_struct)) labeled; struct { struct Expression * exp; struct Statement * stmt; } __attribute__ ((gcc_struct)) caseStmt; struct { struct __ecereNameSpace__ecere__sys__OldList * declarations; struct __ecereNameSpace__ecere__sys__OldList * statements; struct Context * context; unsigned int isSwitch; } __attribute__ ((gcc_struct)) compound; struct { struct __ecereNameSpace__ecere__sys__OldList * exp; struct Statement * stmt; struct Statement * elseStmt; } __attribute__ ((gcc_struct)) ifStmt; struct { struct __ecereNameSpace__ecere__sys__OldList * exp; struct Statement * stmt; } __attribute__ ((gcc_struct)) switchStmt; struct { struct __ecereNameSpace__ecere__sys__OldList * exp; struct Statement * stmt; } __attribute__ ((gcc_struct)) whileStmt; struct { struct __ecereNameSpace__ecere__sys__OldList * exp; struct Statement * stmt; } __attribute__ ((gcc_struct)) doWhile; struct { struct Statement * init; struct Statement * check; struct __ecereNameSpace__ecere__sys__OldList * increment; struct Statement * stmt; } __attribute__ ((gcc_struct)) forStmt; struct { struct Identifier * id; } __attribute__ ((gcc_struct)) gotoStmt; struct { struct Specifier * spec; char * statements; struct __ecereNameSpace__ecere__sys__OldList * inputFields; struct __ecereNameSpace__ecere__sys__OldList * outputFields; struct __ecereNameSpace__ecere__sys__OldList * clobberedFields; } __attribute__ ((gcc_struct)) asmStmt; struct { struct Expression * watcher; struct Expression * object; struct __ecereNameSpace__ecere__sys__OldList * watches; } __attribute__ ((gcc_struct)) _watch; struct { struct Identifier * id; struct __ecereNameSpace__ecere__sys__OldList * exp; struct __ecereNameSpace__ecere__sys__OldList * filter; struct Statement * stmt; } __attribute__ ((gcc_struct)) forEachStmt; struct Declaration * decl; } __attribute__ ((gcc_struct)); } __attribute__ ((gcc_struct)); extern struct __ecereNameSpace__ecere__com__Class * __ecereClass_TypeName; struct TypeName { struct TypeName * prev; struct TypeName * next; struct Location loc; struct __ecereNameSpace__ecere__sys__OldList * qualifiers; struct Declarator * declarator; int classObjectType; struct Expression * bitCount; } __attribute__ ((gcc_struct)); extern struct __ecereNameSpace__ecere__com__Class * __ecereClass_Initializer; struct Initializer { struct Initializer * prev; struct Initializer * next; struct Location loc; int type; union { struct Expression * exp; struct __ecereNameSpace__ecere__sys__OldList * list; } __attribute__ ((gcc_struct)); unsigned int isConstant; } __attribute__ ((gcc_struct)); extern struct __ecereNameSpace__ecere__com__Class * __ecereClass___ecereNameSpace__ecere__com__DataValue; struct __ecereNameSpace__ecere__com__DataValue { union { char c; unsigned char uc; short s; unsigned short us; int i; unsigned int ui; void * p; float f; double d; long long i64; uint64 ui64; } __attribute__ ((gcc_struct)); } __attribute__ ((gcc_struct)); extern struct __ecereNameSpace__ecere__com__Class * __ecereClass_Expression; struct Expression { struct Expression * prev; struct Expression * next; struct Location loc; int type; union { struct { char * constant; struct Identifier * identifier; } __attribute__ ((gcc_struct)); struct Statement * compound; struct Instantiation * instance; struct { char * string; unsigned int intlString; } __attribute__ ((gcc_struct)); struct __ecereNameSpace__ecere__sys__OldList * list; struct { struct __ecereNameSpace__ecere__sys__OldList * specifiers; struct Declarator * decl; } __attribute__ ((gcc_struct)) _classExp; struct { struct Identifier * id; } __attribute__ ((gcc_struct)) classData; struct { struct Expression * exp; struct __ecereNameSpace__ecere__sys__OldList * arguments; struct Location argLoc; } __attribute__ ((gcc_struct)) call; struct { struct Expression * exp; struct __ecereNameSpace__ecere__sys__OldList * index; } __attribute__ ((gcc_struct)) index; struct { struct Expression * exp; struct Identifier * member; int memberType; unsigned int thisPtr; } __attribute__ ((gcc_struct)) member; struct { int op; struct Expression * exp1; struct Expression * exp2; } __attribute__ ((gcc_struct)) op; struct TypeName * typeName; struct Specifier * _class; struct { struct TypeName * typeName; struct Expression * exp; } __attribute__ ((gcc_struct)) cast; struct { struct Expression * cond; struct __ecereNameSpace__ecere__sys__OldList * exp; struct Expression * elseExp; } __attribute__ ((gcc_struct)) cond; struct { struct TypeName * typeName; struct Expression * size; } __attribute__ ((gcc_struct)) _new; struct { struct TypeName * typeName; struct Expression * size; struct Expression * exp; } __attribute__ ((gcc_struct)) _renew; struct { char * table; struct Identifier * id; } __attribute__ ((gcc_struct)) db; struct { struct Expression * ds; struct Expression * name; } __attribute__ ((gcc_struct)) dbopen; struct { struct TypeName * typeName; struct Initializer * initializer; } __attribute__ ((gcc_struct)) initializer; struct { struct Expression * exp; struct TypeName * typeName; } __attribute__ ((gcc_struct)) vaArg; } __attribute__ ((gcc_struct)); unsigned int debugValue; struct __ecereNameSpace__ecere__com__DataValue val; uint64 address; unsigned int hasAddress; struct Type * expType; struct Type * destType; unsigned int usage; int tempCount; unsigned int byReference; unsigned int isConstant; unsigned int addedThis; unsigned int needCast; unsigned int thisPtr; } __attribute__ ((gcc_struct)); extern struct __ecereNameSpace__ecere__com__Class * __ecereClass_TemplateDatatype; struct TemplateDatatype { struct __ecereNameSpace__ecere__sys__OldList * specifiers; struct Declarator * decl; } __attribute__ ((gcc_struct)); extern struct __ecereNameSpace__ecere__com__Class * __ecereClass_TemplateArgument; struct TemplateArgument { struct TemplateArgument * prev; struct TemplateArgument * next; struct Location loc; struct Identifier * name; int type; union { struct Expression * expression; struct Identifier * identifier; struct TemplateDatatype * templateDatatype; } __attribute__ ((gcc_struct)); } __attribute__ ((gcc_struct)); extern struct __ecereNameSpace__ecere__com__Class * __ecereClass_TemplateParameter; struct TemplateParameter; extern struct __ecereNameSpace__ecere__com__Class * __ecereClass_Specifier; struct Specifier { struct Specifier * prev; struct Specifier * next; struct Location loc; int type; union { int specifier; struct { struct ExtDecl * extDecl; char * name; struct Symbol * symbol; struct __ecereNameSpace__ecere__sys__OldList * templateArgs; } __attribute__ ((gcc_struct)); struct { struct Identifier * id; struct __ecereNameSpace__ecere__sys__OldList * list; struct __ecereNameSpace__ecere__sys__OldList * baseSpecs; struct __ecereNameSpace__ecere__sys__OldList * definitions; unsigned int addNameSpace; struct Context * ctx; struct ExtDecl * extDeclStruct; } __attribute__ ((gcc_struct)); struct Expression * expression; struct Specifier * _class; struct TemplateParameter * templateParameter; } __attribute__ ((gcc_struct)); } __attribute__ ((gcc_struct)); extern struct __ecereNameSpace__ecere__com__Class * __ecereClass_Identifier; struct Identifier { struct Identifier * prev; struct Identifier * next; struct Location loc; struct Symbol * classSym; struct Specifier * _class; char * string; struct Identifier * badID; } __attribute__ ((gcc_struct)); extern struct __ecereNameSpace__ecere__com__Class * __ecereClass_Pointer; struct Pointer; extern struct __ecereNameSpace__ecere__com__Class * __ecereClass_Declarator; struct Declarator { struct Declarator * prev; struct Declarator * next; struct Location loc; int type; struct Symbol * symbol; struct Declarator * declarator; union { struct Identifier * identifier; struct { struct Expression * exp; struct Expression * posExp; struct Attrib * attrib; } __attribute__ ((gcc_struct)) structDecl; struct { struct Expression * exp; struct Specifier * enumClass; } __attribute__ ((gcc_struct)) array; struct { struct __ecereNameSpace__ecere__sys__OldList * parameters; } __attribute__ ((gcc_struct)) function; struct { struct Pointer * pointer; } __attribute__ ((gcc_struct)) pointer; struct { struct ExtDecl * extended; } __attribute__ ((gcc_struct)) extended; } __attribute__ ((gcc_struct)); } __attribute__ ((gcc_struct)); extern struct __ecereNameSpace__ecere__com__Class * __ecereClass_FunctionDefinition; struct FunctionDefinition; extern struct __ecereNameSpace__ecere__com__Class * __ecereClass_DBTableDef; struct DBTableDef; extern struct __ecereNameSpace__ecere__com__Class * __ecereClass_External; struct External; extern struct __ecereNameSpace__ecere__com__Class * __ecereClass_ModuleImport; struct ModuleImport; extern struct __ecereNameSpace__ecere__com__Class * __ecereClass_ClassImport; struct ClassImport; extern struct __ecereNameSpace__ecere__com__Class * __ecereClass_Symbol; struct Symbol; extern struct __ecereNameSpace__ecere__com__Class * __ecereClass_Type; struct Type; extern struct __ecereNameSpace__ecere__com__Class * __ecereClass___ecereNameSpace__ecere__com__Class; struct __ecereNameSpace__ecere__com__Class { struct __ecereNameSpace__ecere__com__Class * prev; struct __ecereNameSpace__ecere__com__Class * next; char * name; int offset; int structSize; int (* * _vTbl)(); int vTblSize; int (* Constructor)(struct __ecereNameSpace__ecere__com__Instance *); void (* Destructor)(struct __ecereNameSpace__ecere__com__Instance *); int offsetClass; int sizeClass; struct __ecereNameSpace__ecere__com__Class * base; struct __ecereNameSpace__ecere__sys__BinaryTree methods; struct __ecereNameSpace__ecere__sys__BinaryTree members; struct __ecereNameSpace__ecere__sys__BinaryTree prop; struct __ecereNameSpace__ecere__sys__OldList membersAndProperties; struct __ecereNameSpace__ecere__sys__BinaryTree classProperties; struct __ecereNameSpace__ecere__sys__OldList derivatives; int memberID; int startMemberID; int type; struct __ecereNameSpace__ecere__com__Instance * module; struct __ecereNameSpace__ecere__com__NameSpace * nameSpace; char * dataTypeString; struct Type * dataType; int typeSize; int defaultAlignment; void (* Initialize)(); int memberOffset; struct __ecereNameSpace__ecere__sys__OldList selfWatchers; char * designerClass; unsigned int noExpansion; char * defaultProperty; unsigned int comRedefinition; int count; unsigned int isRemote; unsigned int internalDecl; void * data; unsigned int computeSize; int structAlignment; int destructionWatchOffset; unsigned int fixed; struct __ecereNameSpace__ecere__sys__OldList delayedCPValues; int inheritanceAccess; char * fullName; void * symbol; struct __ecereNameSpace__ecere__sys__OldList conversions; struct __ecereNameSpace__ecere__sys__OldList templateParams; struct __ecereNameSpace__ecere__com__ClassTemplateArgument * templateArgs; struct __ecereNameSpace__ecere__com__Class * templateClass; struct __ecereNameSpace__ecere__sys__OldList templatized; int numParams; unsigned int isInstanceClass; unsigned int byValueSystemClass; } __attribute__ ((gcc_struct)); extern long long __ecereNameSpace__ecere__com__eClass_GetProperty(struct __ecereNameSpace__ecere__com__Class * _class, char * name); extern void __ecereNameSpace__ecere__com__eInstance_FireSelfWatchers(struct __ecereNameSpace__ecere__com__Instance * instance, struct __ecereNameSpace__ecere__com__Property * _property); extern struct __ecereNameSpace__ecere__com__Class * __ecereClass___ecereNameSpace__ecere__com__Instance; struct __ecereNameSpace__ecere__com__Instance { int (* * _vTbl)(); struct __ecereNameSpace__ecere__com__Class * _class; int _refCount; } __attribute__ ((gcc_struct)); extern struct __ecereNameSpace__ecere__com__Class * __ecereClass___ecereNameSpace__ecere__com__DataMember; struct __ecereNameSpace__ecere__com__DataMember { struct __ecereNameSpace__ecere__com__DataMember * prev; struct __ecereNameSpace__ecere__com__DataMember * next; char * name; unsigned int isProperty; int memberAccess; int id; struct __ecereNameSpace__ecere__com__Class * _class; char * dataTypeString; struct __ecereNameSpace__ecere__com__Class * dataTypeClass; struct Type * dataType; int type; int offset; int memberID; struct __ecereNameSpace__ecere__sys__OldList members; struct __ecereNameSpace__ecere__sys__BinaryTree membersAlpha; int memberOffset; int structAlignment; } __attribute__ ((gcc_struct)); extern struct __ecereNameSpace__ecere__com__Class * __ecereClass___ecereNameSpace__ecere__com__SerialBuffer; struct __ecereNameSpace__ecere__com__SerialBuffer { unsigned char * _buffer; unsigned int count; unsigned int _size; unsigned int pos; } __attribute__ ((gcc_struct)); extern struct __ecereNameSpace__ecere__com__Class * __ecereClass___ecereNameSpace__ecere__com__ClassTemplateArgument; struct __ecereNameSpace__ecere__com__ClassTemplateArgument { union { struct { char * dataTypeString; struct __ecereNameSpace__ecere__com__Class * dataTypeClass; } __attribute__ ((gcc_struct)); struct __ecereNameSpace__ecere__com__DataValue expression; struct { char * memberString; union { struct __ecereNameSpace__ecere__com__DataMember * member; struct __ecereNameSpace__ecere__com__Property * prop; struct __ecereNameSpace__ecere__com__Method * method; } __attribute__ ((gcc_struct)); } __attribute__ ((gcc_struct)); } __attribute__ ((gcc_struct)); } __attribute__ ((gcc_struct)); enum yytokentype { IDENTIFIER = 258, CONSTANT = 259, STRING_LITERAL = 260, SIZEOF = 261, PTR_OP = 262, INC_OP = 263, DEC_OP = 264, LEFT_OP = 265, RIGHT_OP = 266, LE_OP = 267, GE_OP = 268, EQ_OP = 269, NE_OP = 270, AND_OP = 271, OR_OP = 272, MUL_ASSIGN = 273, DIV_ASSIGN = 274, MOD_ASSIGN = 275, ADD_ASSIGN = 276, SUB_ASSIGN = 277, LEFT_ASSIGN = 278, RIGHT_ASSIGN = 279, AND_ASSIGN = 280, XOR_ASSIGN = 281, OR_ASSIGN = 282, TYPE_NAME = 283, TYPEDEF = 284, EXTERN = 285, STATIC = 286, AUTO = 287, REGISTER = 288, CHAR = 289, SHORT = 290, INT = 291, UINT = 292, INT64 = 293, LONG = 294, SIGNED = 295, UNSIGNED = 296, FLOAT = 297, DOUBLE = 298, CONST = 299, VOLATILE = 300, VOID = 301, VALIST = 302, STRUCT = 303, UNION = 304, ENUM = 305, ELLIPSIS = 306, CASE = 307, DEFAULT = 308, IF = 309, SWITCH = 310, WHILE = 311, DO = 312, FOR = 313, GOTO = 314, CONTINUE = 315, BREAK = 316, RETURN = 317, IFX = 318, ELSE = 319, CLASS = 320, THISCLASS = 321, CLASS_NAME = 322, PROPERTY = 323, SETPROP = 324, GETPROP = 325, NEWOP = 326, RENEW = 327, DELETE = 328, EXT_DECL = 329, EXT_STORAGE = 330, IMPORT = 331, DEFINE = 332, VIRTUAL = 333, ATTRIB = 334, PUBLIC = 335, PRIVATE = 336, TYPED_OBJECT = 337, ANY_OBJECT = 338, _INCREF = 339, EXTENSION = 340, ASM = 341, TYPEOF = 342, WATCH = 343, STOPWATCHING = 344, FIREWATCHERS = 345, WATCHABLE = 346, CLASS_DESIGNER = 347, CLASS_NO_EXPANSION = 348, CLASS_FIXED = 349, ISPROPSET = 350, CLASS_DEFAULT_PROPERTY = 351, PROPERTY_CATEGORY = 352, CLASS_DATA = 353, CLASS_PROPERTY = 354, SUBCLASS = 355, NAMESPACE = 356, NEW0OP = 357, RENEW0 = 358, VAARG = 359, DBTABLE = 360, DBFIELD = 361, DBINDEX = 362, DATABASE_OPEN = 363, ALIGNOF = 364, ATTRIB_DEP = 365, __ATTRIB = 366, BOOL = 367, _BOOL = 368, _COMPLEX = 369, _IMAGINARY = 370, RESTRICT = 371, THREAD = 372 }; typedef union YYSTYPE { int specifierType; int i; int declMode; struct Identifier * id; struct Expression * exp; struct Specifier * specifier; struct __ecereNameSpace__ecere__sys__OldList * list; struct Enumerator * enumerator; struct Declarator * declarator; struct Pointer * pointer; struct Initializer * initializer; struct InitDeclarator * initDeclarator; struct TypeName * typeName; struct Declaration * declaration; struct Statement * stmt; struct FunctionDefinition * function; struct External * external; struct Context * context; struct AsmField * asmField; struct Attrib * attrib; struct ExtDecl * extDecl; struct Attribute * attribute; struct Instantiation * instance; struct MembersInit * membersInit; struct MemberInit * memberInit; struct ClassFunction * classFunction; struct ClassDefinition * _class; struct ClassDef * classDef; struct PropertyDef * prop; char * string; struct Symbol * symbol; struct PropertyWatch * propertyWatch; struct TemplateParameter * templateParameter; struct TemplateArgument * templateArgument; struct TemplateDatatype * templateDatatype; struct DBTableEntry * dbtableEntry; struct DBIndexItem * dbindexItem; struct DBTableDef * dbtableDef; } __attribute__ ((gcc_struct)) YYSTYPE; extern struct __ecereNameSpace__ecere__com__Class * __ecereClass_Enumerator; struct Enumerator; extern struct __ecereNameSpace__ecere__com__Class * __ecereClass_InitDeclarator; struct InitDeclarator { struct InitDeclarator * prev; struct InitDeclarator * next; struct Location loc; struct Declarator * declarator; struct Initializer * initializer; } __attribute__ ((gcc_struct)); extern struct __ecereNameSpace__ecere__com__Class * __ecereClass_AsmField; struct AsmField; extern struct __ecereNameSpace__ecere__com__Class * __ecereClass_Attribute; struct Attribute { struct Attribute * prev; struct Attribute * next; struct Location loc; char * attr; struct Expression * exp; } __attribute__ ((gcc_struct)); extern struct __ecereNameSpace__ecere__com__Class * __ecereClass_ClassFunction; struct ClassFunction { struct ClassFunction * prev; struct ClassFunction * next; struct Location loc; struct __ecereNameSpace__ecere__sys__OldList * specifiers; struct Declarator * declarator; struct __ecereNameSpace__ecere__sys__OldList * declarations; struct Statement * body; struct __ecereNameSpace__ecere__com__Class * _class; struct __ecereNameSpace__ecere__sys__OldList attached; int declMode; struct Type * type; struct Symbol * propSet; unsigned int isVirtual; unsigned int isConstructor; unsigned int isDestructor; unsigned int dontMangle; int id; int idCode; } __attribute__ ((gcc_struct)); extern struct __ecereNameSpace__ecere__com__Class * __ecereClass_MembersInit; struct MembersInit { struct MembersInit * prev; struct MembersInit * next; struct Location loc; int type; union { struct __ecereNameSpace__ecere__sys__OldList * dataMembers; struct ClassFunction * function; } __attribute__ ((gcc_struct)); } __attribute__ ((gcc_struct)); extern struct __ecereNameSpace__ecere__com__Class * __ecereClass_MemberInit; struct MemberInit { struct MemberInit * prev; struct MemberInit * next; struct Location loc; struct Location realLoc; struct __ecereNameSpace__ecere__sys__OldList * identifiers; struct Initializer * initializer; unsigned int used; unsigned int variable; unsigned int takeOutExp; } __attribute__ ((gcc_struct)); extern struct __ecereNameSpace__ecere__com__Class * __ecereClass_PropertyDef; struct PropertyDef { struct PropertyDef * prev; struct PropertyDef * next; struct Location loc; struct __ecereNameSpace__ecere__sys__OldList * specifiers; struct Declarator * declarator; struct Identifier * id; struct Statement * getStmt; struct Statement * setStmt; struct Statement * issetStmt; struct Symbol * symbol; struct Expression * category; struct { unsigned int conversion : 1; unsigned int isWatchable : 1; unsigned int isDBProp : 1; } __attribute__ ((gcc_struct)); } __attribute__ ((gcc_struct)); extern struct __ecereNameSpace__ecere__com__Class * __ecereClass_PropertyWatch; struct PropertyWatch; extern struct __ecereNameSpace__ecere__com__Class * __ecereClass_ClassDef; struct ClassDef { struct ClassDef * prev; struct ClassDef * next; struct Location loc; int type; union { struct Declaration * decl; struct ClassFunction * function; struct __ecereNameSpace__ecere__sys__OldList * defProperties; struct PropertyDef * propertyDef; struct PropertyWatch * propertyWatch; char * designer; struct Identifier * defaultProperty; struct { struct Identifier * id; struct Initializer * initializer; } __attribute__ ((gcc_struct)); } __attribute__ ((gcc_struct)); int memberAccess; void * object; } __attribute__ ((gcc_struct)); extern struct __ecereNameSpace__ecere__com__Class * __ecereClass_DBTableEntry; struct DBTableEntry; extern struct __ecereNameSpace__ecere__com__Class * __ecereClass_DBIndexItem; struct DBIndexItem; extern YYSTYPE yylval; extern struct Location yylloc; struct TypeName * parsedType; extern unsigned int parseTypeError; extern struct __ecereNameSpace__ecere__com__Instance * fileInput; extern char * yytext; int yylex(); int yyerror(); typedef unsigned char yytype_uint8; typedef signed char yytype_int8; typedef unsigned short int yytype_uint16; typedef short int yytype_int16; void * malloc(size_t size); void free(void *); union yyalloc { yytype_int16 yyss_alloc; YYSTYPE yyvs_alloc; struct Location yyls_alloc; } __attribute__ ((gcc_struct)); static const yytype_uint8 yytranslate[] = { (unsigned char)0, (unsigned char)2, (unsigned char)2, (unsigned char)2, (unsigned char)2, (unsigned char)2, (unsigned char)2, (unsigned char)2, (unsigned char)2, (unsigned char)2, (unsigned char)2, (unsigned char)2, (unsigned char)2, (unsigned char)2, (unsigned char)2, (unsigned char)2, (unsigned char)2, (unsigned char)2, (unsigned char)2, (unsigned char)2, (unsigned char)2, (unsigned char)2, (unsigned char)2, (unsigned char)2, (unsigned char)2, (unsigned char)2, (unsigned char)2, (unsigned char)2, (unsigned char)2, (unsigned char)2, (unsigned char)2, (unsigned char)2, (unsigned char)2, (unsigned char)132, (unsigned char)2, (unsigned char)2, (unsigned char)124, (unsigned char)134, (unsigned char)129, (unsigned char)2, (unsigned char)121, (unsigned char)122, (unsigned char)118, (unsigned char)130, (unsigned char)128, (unsigned char)131, (unsigned char)125, (unsigned char)133, (unsigned char)2, (unsigned char)2, (unsigned char)2, (unsigned char)2, (unsigned char)2, (unsigned char)2, (unsigned char)2, (unsigned char)2, (unsigned char)2, (unsigned char)2, (unsigned char)138, (unsigned char)140, (unsigned char)119, (unsigned char)139, (unsigned char)120, (unsigned char)137, (unsigned char)2, (unsigned char)2, (unsigned char)2, (unsigned char)2, (unsigned char)2, (unsigned char)2, (unsigned char)2, (unsigned char)2, (unsigned char)2, (unsigned char)2, (unsigned char)2, (unsigned char)2, (unsigned char)2, (unsigned char)2, (unsigned char)2, (unsigned char)2, (unsigned char)2, (unsigned char)2, (unsigned char)2, (unsigned char)2, (unsigned char)2, (unsigned char)2, (unsigned char)2, (unsigned char)2, (unsigned char)2, (unsigned char)2, (unsigned char)2, (unsigned char)126, (unsigned char)2, (unsigned char)127, (unsigned char)135, (unsigned char)2, (unsigned char)2, (unsigned char)2, (unsigned char)2, (unsigned char)2, (unsigned char)2, (unsigned char)2, (unsigned char)2, (unsigned char)2, (unsigned char)2, (unsigned char)2, (unsigned char)2, (unsigned char)2, (unsigned char)2, (unsigned char)2, (unsigned char)2, (unsigned char)2, (unsigned char)2, (unsigned char)2, (unsigned char)2, (unsigned char)2, (unsigned char)2, (unsigned char)2, (unsigned char)2, (unsigned char)2, (unsigned char)2, (unsigned char)2, (unsigned char)2, (unsigned char)141, (unsigned char)136, (unsigned char)142, (unsigned char)123, (unsigned char)2, (unsigned char)2, (unsigned char)2, (unsigned char)2, (unsigned char)2, (unsigned char)2, (unsigned char)2, (unsigned char)2, (unsigned char)2, (unsigned char)2, (unsigned char)2, (unsigned char)2, (unsigned char)2, (unsigned char)2, (unsigned char)2, (unsigned char)2, (unsigned char)2, (unsigned char)2, (unsigned char)2, (unsigned char)2, (unsigned char)2, (unsigned char)2, (unsigned char)2, (unsigned char)2, (unsigned char)2, (unsigned char)2, (unsigned char)2, (unsigned char)2, (unsigned char)2, (unsigned char)2, (unsigned char)2, (unsigned char)2, (unsigned char)2, (unsigned char)2, (unsigned char)2, (unsigned char)2, (unsigned char)2, (unsigned char)2, (unsigned char)2, (unsigned char)2, (unsigned char)2, (unsigned char)2, (unsigned char)2, (unsigned char)2, (unsigned char)2, (unsigned char)2, (unsigned char)2, (unsigned char)2, (unsigned char)2, (unsigned char)2, (unsigned char)2, (unsigned char)2, (unsigned char)2, (unsigned char)2, (unsigned char)2, (unsigned char)2, (unsigned char)2, (unsigned char)2, (unsigned char)2, (unsigned char)2, (unsigned char)2, (unsigned char)2, (unsigned char)2, (unsigned char)2, (unsigned char)2, (unsigned char)2, (unsigned char)2, (unsigned char)2, (unsigned char)2, (unsigned char)2, (unsigned char)2, (unsigned char)2, (unsigned char)2, (unsigned char)2, (unsigned char)2, (unsigned char)2, (unsigned char)2, (unsigned char)2, (unsigned char)2, (unsigned char)2, (unsigned char)2, (unsigned char)2, (unsigned char)2, (unsigned char)2, (unsigned char)2, (unsigned char)2, (unsigned char)2, (unsigned char)2, (unsigned char)2, (unsigned char)2, (unsigned char)2, (unsigned char)2, (unsigned char)2, (unsigned char)2, (unsigned char)2, (unsigned char)2, (unsigned char)2, (unsigned char)2, (unsigned char)2, (unsigned char)2, (unsigned char)2, (unsigned char)2, (unsigned char)2, (unsigned char)2, (unsigned char)2, (unsigned char)2, (unsigned char)2, (unsigned char)2, (unsigned char)2, (unsigned char)2, (unsigned char)2, (unsigned char)2, (unsigned char)2, (unsigned char)2, (unsigned char)2, (unsigned char)2, (unsigned char)2, (unsigned char)2, (unsigned char)2, (unsigned char)2, (unsigned char)2, (unsigned char)2, (unsigned char)2, (unsigned char)2, (unsigned char)2, (unsigned char)2, (unsigned char)2, (unsigned char)2, (unsigned char)2, (unsigned char)1, (unsigned char)2, (unsigned char)3, (unsigned char)4, (unsigned char)5, (unsigned char)6, (unsigned char)7, (unsigned char)8, (unsigned char)9, (unsigned char)10, (unsigned char)11, (unsigned char)12, (unsigned char)13, (unsigned char)14, (unsigned char)15, (unsigned char)16, (unsigned char)17, (unsigned char)18, (unsigned char)19, (unsigned char)20, (unsigned char)21, (unsigned char)22, (unsigned char)23, (unsigned char)24, (unsigned char)25, (unsigned char)26, (unsigned char)27, (unsigned char)28, (unsigned char)29, (unsigned char)30, (unsigned char)31, (unsigned char)32, (unsigned char)33, (unsigned char)34, (unsigned char)35, (unsigned char)36, (unsigned char)37, (unsigned char)38, (unsigned char)39, (unsigned char)40, (unsigned char)41, (unsigned char)42, (unsigned char)43, (unsigned char)44, (unsigned char)45, (unsigned char)46, (unsigned char)47, (unsigned char)48, (unsigned char)49, (unsigned char)50, (unsigned char)51, (unsigned char)52, (unsigned char)53, (unsigned char)54, (unsigned char)55, (unsigned char)56, (unsigned char)57, (unsigned char)58, (unsigned char)59, (unsigned char)60, (unsigned char)61, (unsigned char)62, (unsigned char)63, (unsigned char)64, (unsigned char)65, (unsigned char)66, (unsigned char)67, (unsigned char)68, (unsigned char)69, (unsigned char)70, (unsigned char)71, (unsigned char)72, (unsigned char)73, (unsigned char)74, (unsigned char)75, (unsigned char)76, (unsigned char)77, (unsigned char)78, (unsigned char)79, (unsigned char)80, (unsigned char)81, (unsigned char)82, (unsigned char)83, (unsigned char)84, (unsigned char)85, (unsigned char)86, (unsigned char)87, (unsigned char)88, (unsigned char)89, (unsigned char)90, (unsigned char)91, (unsigned char)92, (unsigned char)93, (unsigned char)94, (unsigned char)95, (unsigned char)96, (unsigned char)97, (unsigned char)98, (unsigned char)99, (unsigned char)100, (unsigned char)101, (unsigned char)102, (unsigned char)103, (unsigned char)104, (unsigned char)105, (unsigned char)106, (unsigned char)107, (unsigned char)108, (unsigned char)109, (unsigned char)110, (unsigned char)111, (unsigned char)112, (unsigned char)113, (unsigned char)114, (unsigned char)115, (unsigned char)116, (unsigned char)117 }; static const yytype_uint16 yyprhs[] = { (unsigned short)0, (unsigned short)0, (unsigned short)3, (unsigned short)6, (unsigned short)9, (unsigned short)12, (unsigned short)14, (unsigned short)17, (unsigned short)19, (unsigned short)21, (unsigned short)26, (unsigned short)31, (unsigned short)34, (unsigned short)36, (unsigned short)40, (unsigned short)45, (unsigned short)49, (unsigned short)52, (unsigned short)54, (unsigned short)56, (unsigned short)60, (unsigned short)62, (unsigned short)64, (unsigned short)66, (unsigned short)68, (unsigned short)71, (unsigned short)76, (unsigned short)79, (unsigned short)86, (unsigned short)92, (unsigned short)99, (unsigned short)105, (unsigned short)113, (unsigned short)120, (unsigned short)128, (unsigned short)135, (unsigned short)137, (unsigned short)139, (unsigned short)144, (unsigned short)148, (unsigned short)153, (unsigned short)157, (unsigned short)160, (unsigned short)164, (unsigned short)167, (unsigned short)170, (unsigned short)172, (unsigned short)174, (unsigned short)176, (unsigned short)180, (unsigned short)184, (unsigned short)187, (unsigned short)190, (unsigned short)193, (unsigned short)196, (unsigned short)201, (unsigned short)204, (unsigned short)209, (unsigned short)211, (unsigned short)213, (unsigned short)215, (unsigned short)217, (unsigned short)219, (unsigned short)221, (unsigned short)223, (unsigned short)225, (unsigned short)227, (unsigned short)229, (unsigned short)234, (unsigned short)236, (unsigned short)240, (unsigned short)244, (unsigned short)248, (unsigned short)250, (unsigned short)254, (unsigned short)258, (unsigned short)260, (unsigned short)264, (unsigned short)268, (unsigned short)271, (unsigned short)273, (unsigned short)276, (unsigned short)280, (unsigned short)284, (unsigned short)288, (unsigned short)290, (unsigned short)294, (unsigned short)298, (unsigned short)300, (unsigned short)304, (unsigned short)306, (unsigned short)310, (unsigned short)312, (unsigned short)316, (unsigned short)318, (unsigned short)322, (unsigned short)324, (unsigned short)328, (unsigned short)330, (unsigned short)336, (unsigned short)338, (unsigned short)342, (unsigned short)346, (unsigned short)348, (unsigned short)350, (unsigned short)352, (unsigned short)354, (unsigned short)356, (unsigned short)358, (unsigned short)360, (unsigned short)362, (unsigned short)364, (unsigned short)366, (unsigned short)368, (unsigned short)370, (unsigned short)374, (unsigned short)376, (unsigned short)379, (unsigned short)383, (unsigned short)386, (unsigned short)392, (unsigned short)394, (unsigned short)397, (unsigned short)399, (unsigned short)402, (unsigned short)404, (unsigned short)407, (unsigned short)409, (unsigned short)412, (unsigned short)414, (unsigned short)417, (unsigned short)419, (unsigned short)422, (unsigned short)424, (unsigned short)427, (unsigned short)429, (unsigned short)432, (unsigned short)434, (unsigned short)437, (unsigned short)439, (unsigned short)442, (unsigned short)444, (unsigned short)447, (unsigned short)449, (unsigned short)452, (unsigned short)454, (unsigned short)457, (unsigned short)459, (unsigned short)462, (unsigned short)464, (unsigned short)467, (unsigned short)469, (unsigned short)472, (unsigned short)474, (unsigned short)477, (unsigned short)479, (unsigned short)482, (unsigned short)484, (unsigned short)487, (unsigned short)489, (unsigned short)492, (unsigned short)494, (unsigned short)496, (unsigned short)498, (unsigned short)501, (unsigned short)503, (unsigned short)506, (unsigned short)508, (unsigned short)511, (unsigned short)513, (unsigned short)516, (unsigned short)521, (unsigned short)527, (unsigned short)529, (unsigned short)532, (unsigned short)534, (unsigned short)537, (unsigned short)539, (unsigned short)542, (unsigned short)544, (unsigned short)547, (unsigned short)549, (unsigned short)552, (unsigned short)554, (unsigned short)557, (unsigned short)562, (unsigned short)568, (unsigned short)570, (unsigned short)574, (unsigned short)576, (unsigned short)580, (unsigned short)582, (unsigned short)584, (unsigned short)586, (unsigned short)588, (unsigned short)590, (unsigned short)592, (unsigned short)594, (unsigned short)596, (unsigned short)598, (unsigned short)600, (unsigned short)602, (unsigned short)604, (unsigned short)606, (unsigned short)608, (unsigned short)610, (unsigned short)612, (unsigned short)614, (unsigned short)616, (unsigned short)621, (unsigned short)623, (unsigned short)626, (unsigned short)630, (unsigned short)637, (unsigned short)643, (unsigned short)645, (unsigned short)647, (unsigned short)649, (unsigned short)651, (unsigned short)653, (unsigned short)655, (unsigned short)657, (unsigned short)659, (unsigned short)661, (unsigned short)663, (unsigned short)665, (unsigned short)667, (unsigned short)669, (unsigned short)671, (unsigned short)673, (unsigned short)675, (unsigned short)677, (unsigned short)679, (unsigned short)681, (unsigned short)683, (unsigned short)685, (unsigned short)687, (unsigned short)692, (unsigned short)697, (unsigned short)702, (unsigned short)704, (unsigned short)706, (unsigned short)708, (unsigned short)710, (unsigned short)712, (unsigned short)714, (unsigned short)716, (unsigned short)718, (unsigned short)720, (unsigned short)722, (unsigned short)724, (unsigned short)726, (unsigned short)728, (unsigned short)730, (unsigned short)732, (unsigned short)734, (unsigned short)736, (unsigned short)738, (unsigned short)740, (unsigned short)742, (unsigned short)744, (unsigned short)749, (unsigned short)754, (unsigned short)759, (unsigned short)761, (unsigned short)767, (unsigned short)772, (unsigned short)777, (unsigned short)781, (unsigned short)787, (unsigned short)794, (unsigned short)800, (unsigned short)806, (unsigned short)811, (unsigned short)818, (unsigned short)821, (unsigned short)824, (unsigned short)828, (unsigned short)832, (unsigned short)834, (unsigned short)837, (unsigned short)839, (unsigned short)842, (unsigned short)844, (unsigned short)846, (unsigned short)848, (unsigned short)852, (unsigned short)856, (unsigned short)860, (unsigned short)864, (unsigned short)866, (unsigned short)870, (unsigned short)872, (unsigned short)874, (unsigned short)876, (unsigned short)879, (unsigned short)883, (unsigned short)885, (unsigned short)889, (unsigned short)899, (unsigned short)909, (unsigned short)917, (unsigned short)925, (unsigned short)931, (unsigned short)942, (unsigned short)953, (unsigned short)962, (unsigned short)971, (unsigned short)978, (unsigned short)987, (unsigned short)996, (unsigned short)1003, (unsigned short)1010, (unsigned short)1015, (unsigned short)1025, (unsigned short)1035, (unsigned short)1043, (unsigned short)1051, (unsigned short)1057, (unsigned short)1061, (unsigned short)1064, (unsigned short)1067, (unsigned short)1070, (unsigned short)1072, (unsigned short)1075, (unsigned short)1077, (unsigned short)1079, (unsigned short)1081, (unsigned short)1085, (unsigned short)1087, (unsigned short)1090, (unsigned short)1093, (unsigned short)1097, (unsigned short)1103, (unsigned short)1106, (unsigned short)1109, (unsigned short)1114, (unsigned short)1120, (unsigned short)1128, (unsigned short)1136, (unsigned short)1142, (unsigned short)1144, (unsigned short)1148, (unsigned short)1150, (unsigned short)1154, (unsigned short)1158, (unsigned short)1161, (unsigned short)1165, (unsigned short)1169, (unsigned short)1173, (unsigned short)1178, (unsigned short)1183, (unsigned short)1186, (unsigned short)1190, (unsigned short)1194, (unsigned short)1199, (unsigned short)1203, (unsigned short)1206, (unsigned short)1210, (unsigned short)1214, (unsigned short)1219, (unsigned short)1221, (unsigned short)1223, (unsigned short)1226, (unsigned short)1229, (unsigned short)1232, (unsigned short)1236, (unsigned short)1238, (unsigned short)1240, (unsigned short)1243, (unsigned short)1246, (unsigned short)1249, (unsigned short)1253, (unsigned short)1255, (unsigned short)1258, (unsigned short)1262, (unsigned short)1265, (unsigned short)1267, (unsigned short)1271, (unsigned short)1276, (unsigned short)1280, (unsigned short)1285, (unsigned short)1287, (unsigned short)1290, (unsigned short)1293, (unsigned short)1297, (unsigned short)1301, (unsigned short)1304, (unsigned short)1308, (unsigned short)1312, (unsigned short)1315, (unsigned short)1317, (unsigned short)1319, (unsigned short)1322, (unsigned short)1325, (unsigned short)1327, (unsigned short)1330, (unsigned short)1333, (unsigned short)1337, (unsigned short)1341, (unsigned short)1343, (unsigned short)1346, (unsigned short)1348, (unsigned short)1351, (unsigned short)1354, (unsigned short)1358, (unsigned short)1360, (unsigned short)1364, (unsigned short)1366, (unsigned short)1370, (unsigned short)1373, (unsigned short)1376, (unsigned short)1379, (unsigned short)1383, (unsigned short)1385, (unsigned short)1387, (unsigned short)1389, (unsigned short)1393, (unsigned short)1395, (unsigned short)1398, (unsigned short)1400, (unsigned short)1403, (unsigned short)1405, (unsigned short)1409, (unsigned short)1414, (unsigned short)1416, (unsigned short)1418, (unsigned short)1420, (unsigned short)1424, (unsigned short)1426, (unsigned short)1428, (unsigned short)1430, (unsigned short)1432, (unsigned short)1434, (unsigned short)1436, (unsigned short)1440, (unsigned short)1445, (unsigned short)1449, (unsigned short)1451, (unsigned short)1454, (unsigned short)1456, (unsigned short)1459, (unsigned short)1462, (unsigned short)1464, (unsigned short)1466, (unsigned short)1469, (unsigned short)1471, (unsigned short)1474, (unsigned short)1478, (unsigned short)1480, (unsigned short)1483, (unsigned short)1489, (unsigned short)1497, (unsigned short)1503, (unsigned short)1509, (unsigned short)1517, (unsigned short)1524, (unsigned short)1532, (unsigned short)1537, (unsigned short)1543, (unsigned short)1548, (unsigned short)1552, (unsigned short)1555, (unsigned short)1558, (unsigned short)1561, (unsigned short)1565, (unsigned short)1567, (unsigned short)1573, (unsigned short)1578, (unsigned short)1584, (unsigned short)1589, (unsigned short)1594, (unsigned short)1598, (unsigned short)1603, (unsigned short)1607, (unsigned short)1611, (unsigned short)1614, (unsigned short)1617, (unsigned short)1620, (unsigned short)1623, (unsigned short)1626, (unsigned short)1629, (unsigned short)1632, (unsigned short)1635, (unsigned short)1638, (unsigned short)1642, (unsigned short)1644, (unsigned short)1646, (unsigned short)1650, (unsigned short)1653, (unsigned short)1655, (unsigned short)1657, (unsigned short)1660, (unsigned short)1663, (unsigned short)1665, (unsigned short)1668, (unsigned short)1670, (unsigned short)1672, (unsigned short)1675, (unsigned short)1677 }; static const yytype_int16 yyrhs[] = { (short)265, (short)0, (short)(-1), (short)153, (short)118, (short)(-1), (short)153, (short)119, (short)(-1), (short)153, (short)1, (short)(-1), (short)148, (short)(-1), (short)153, (short)153, (short)(-1), (short)28, (short)(-1), (short)147, (short)(-1), (short)147, (short)119, (short)206, (short)120, (short)(-1), (short)147, (short)119, (short)206, (short)11, (short)(-1), (short)183, (short)225, (short)(-1), (short)225, (short)(-1), (short)183, (short)121, (short)122, (short)(-1), (short)123, (short)183, (short)121, (short)122, (short)(-1), (short)78, (short)183, (short)225, (short)(-1), (short)78, (short)225, (short)(-1), (short)3, (short)(-1), (short)155, (short)(-1), (short)121, (short)177, (short)122, (short)(-1), (short)153, (short)(-1), (short)255, (short)(-1), (short)4, (short)(-1), (short)252, (short)(-1), (short)124, (short)252, (short)(-1), (short)124, (short)252, (short)125, (short)252, (short)(-1), (short)121, (short)122, (short)(-1), (short)71, (short)183, (short)222, (short)126, (short)178, (short)127, (short)(-1), (short)71, (short)183, (short)126, (short)178, (short)127, (short)(-1), (short)102, (short)183, (short)222, (short)126, (short)178, (short)127, (short)(-1), (short)102, (short)183, (short)126, (short)178, (short)127, (short)(-1), (short)72, (short)178, (short)186, (short)222, (short)126, (short)178, (short)127, (short)(-1), (short)72, (short)178, (short)186, (short)126, (short)178, (short)127, (short)(-1), (short)103, (short)178, (short)186, (short)222, (short)126, (short)178, (short)127, (short)(-1), (short)103, (short)178, (short)186, (short)126, (short)178, (short)127, (short)(-1), (short)1, (short)(-1), (short)154, (short)(-1), (short)156, (short)126, (short)177, (short)127, (short)(-1), (short)156, (short)121, (short)122, (short)(-1), (short)156, (short)121, (short)158, (short)122, (short)(-1), (short)156, (short)125, (short)153, (short)(-1), (short)156, (short)153, (short)(-1), (short)156, (short)7, (short)153, (short)(-1), (short)156, (short)8, (short)(-1), (short)156, (short)9, (short)(-1), (short)256, (short)(-1), (short)175, (short)(-1), (short)157, (short)(-1), (short)158, (short)128, (short)175, (short)(-1), (short)158, (short)128, (short)157, (short)(-1), (short)8, (short)160, (short)(-1), (short)9, (short)160, (short)(-1), (short)161, (short)162, (short)(-1), (short)6, (short)160, (short)(-1), (short)6, (short)121, (short)237, (short)122, (short)(-1), (short)109, (short)160, (short)(-1), (short)109, (short)121, (short)237, (short)122, (short)(-1), (short)159, (short)(-1), (short)156, (short)(-1), (short)129, (short)(-1), (short)118, (short)(-1), (short)130, (short)(-1), (short)131, (short)(-1), (short)123, (short)(-1), (short)132, (short)(-1), (short)73, (short)(-1), (short)160, (short)(-1), (short)121, (short)236, (short)122, (short)162, (short)(-1), (short)162, (short)(-1), (short)163, (short)118, (short)162, (short)(-1), (short)163, (short)133, (short)162, (short)(-1), (short)163, (short)134, (short)162, (short)(-1), (short)163, (short)(-1), (short)164, (short)130, (short)163, (short)(-1), (short)164, (short)131, (short)163, (short)(-1), (short)164, (short)(-1), (short)165, (short)10, (short)164, (short)(-1), (short)165, (short)11, (short)164, (short)(-1), (short)167, (short)119, (short)(-1), (short)165, (short)(-1), (short)166, (short)165, (short)(-1), (short)167, (short)120, (short)165, (short)(-1), (short)167, (short)12, (short)165, (short)(-1), (short)167, (short)13, (short)165, (short)(-1), (short)167, (short)(-1), (short)168, (short)14, (short)167, (short)(-1), (short)168, (short)15, (short)167, (short)(-1), (short)168, (short)(-1), (short)169, (short)129, (short)168, (short)(-1), (short)169, (short)(-1), (short)170, (short)135, (short)169, (short)(-1), (short)170, (short)(-1), (short)171, (short)136, (short)170, (short)(-1), (short)171, (short)(-1), (short)172, (short)16, (short)171, (short)(-1), (short)172, (short)(-1), (short)173, (short)17, (short)172, (short)(-1), (short)173, (short)(-1), (short)173, (short)137, (short)177, (short)138, (short)174, (short)(-1), (short)174, (short)(-1), (short)160, (short)176, (short)175, (short)(-1), (short)160, (short)176, (short)157, (short)(-1), (short)139, (short)(-1), (short)18, (short)(-1), (short)19, (short)(-1), (short)20, (short)(-1), (short)21, (short)(-1), (short)22, (short)(-1), (short)23, (short)(-1), (short)24, (short)(-1), (short)25, (short)(-1), (short)26, (short)(-1), (short)27, (short)(-1), (short)175, (short)(-1), (short)177, (short)128, (short)175, (short)(-1), (short)174, (short)(-1), (short)182, (short)140, (short)(-1), (short)182, (short)187, (short)140, (short)(-1), (short)253, (short)140, (short)(-1), (short)77, (short)153, (short)139, (short)178, (short)140, (short)(-1), (short)197, (short)(-1), (short)180, (short)197, (short)(-1), (short)198, (short)(-1), (short)180, (short)198, (short)(-1), (short)216, (short)(-1), (short)180, (short)216, (short)(-1), (short)200, (short)(-1), (short)180, (short)200, (short)(-1), (short)197, (short)(-1), (short)181, (short)197, (short)(-1), (short)198, (short)(-1), (short)181, (short)198, (short)(-1), (short)144, (short)(-1), (short)181, (short)144, (short)(-1), (short)216, (short)(-1), (short)181, (short)216, (short)(-1), (short)200, (short)(-1), (short)181, (short)200, (short)(-1), (short)189, (short)(-1), (short)182, (short)189, (short)(-1), (short)197, (short)(-1), (short)182, (short)197, (short)(-1), (short)198, (short)(-1), (short)182, (short)198, (short)(-1), (short)216, (short)(-1), (short)182, (short)216, (short)(-1), (short)200, (short)(-1), (short)182, (short)200, (short)(-1), (short)189, (short)(-1), (short)183, (short)189, (short)(-1), (short)197, (short)(-1), (short)183, (short)197, (short)(-1), (short)198, (short)(-1), (short)183, (short)198, (short)(-1), (short)144, (short)(-1), (short)183, (short)144, (short)(-1), (short)200, (short)(-1), (short)183, (short)200, (short)(-1), (short)216, (short)(-1), (short)183, (short)216, (short)(-1), (short)183, (short)(-1), (short)145, (short)(-1), (short)189, (short)(-1), (short)185, (short)189, (short)(-1), (short)197, (short)(-1), (short)185, (short)197, (short)(-1), (short)199, (short)(-1), (short)185, (short)199, (short)(-1), (short)153, (short)(-1), (short)185, (short)153, (short)(-1), (short)153, (short)119, (short)206, (short)120, (short)(-1), (short)185, (short)153, (short)119, (short)206, (short)120, (short)(-1), (short)189, (short)(-1), (short)186, (short)189, (short)(-1), (short)197, (short)(-1), (short)186, (short)197, (short)(-1), (short)199, (short)(-1), (short)186, (short)199, (short)(-1), (short)200, (short)(-1), (short)186, (short)200, (short)(-1), (short)216, (short)(-1), (short)186, (short)216, (short)(-1), (short)153, (short)(-1), (short)186, (short)153, (short)(-1), (short)153, (short)119, (short)206, (short)120, (short)(-1), (short)186, (short)153, (short)119, (short)206, (short)120, (short)(-1), (short)188, (short)(-1), (short)187, (short)128, (short)188, (short)(-1), (short)223, (short)(-1), (short)223, (short)139, (short)238, (short)(-1), (short)29, (short)(-1), (short)30, (short)(-1), (short)31, (short)(-1), (short)32, (short)(-1), (short)33, (short)(-1), (short)117, (short)(-1), (short)74, (short)(-1), (short)75, (short)(-1), (short)195, (short)(-1), (short)79, (short)(-1), (short)110, (short)(-1), (short)111, (short)(-1), (short)3, (short)(-1), (short)28, (short)(-1), (short)75, (short)(-1), (short)74, (short)(-1), (short)44, (short)(-1), (short)192, (short)(-1), (short)192, (short)121, (short)177, (short)122, (short)(-1), (short)193, (short)(-1), (short)194, (short)193, (short)(-1), (short)194, (short)128, (short)193, (short)(-1), (short)191, (short)121, (short)121, (short)194, (short)122, (short)122, (short)(-1), (short)191, (short)121, (short)121, (short)122, (short)122, (short)(-1), (short)190, (short)(-1), (short)44, (short)(-1), (short)45, (short)(-1), (short)196, (short)(-1), (short)46, (short)(-1), (short)34, (short)(-1), (short)35, (short)(-1), (short)36, (short)(-1), (short)37, (short)(-1), (short)38, (short)(-1), (short)47, (short)(-1), (short)39, (short)(-1), (short)42, (short)(-1), (short)43, (short)(-1), (short)40, (short)(-1), (short)41, (short)(-1), (short)85, (short)(-1), (short)113, (short)(-1), (short)112, (short)(-1), (short)201, (short)(-1), (short)215, (short)(-1), (short)146, (short)(-1), (short)87, (short)121, (short)175, (short)122, (short)(-1), (short)100, (short)121, (short)146, (short)122, (short)(-1), (short)100, (short)121, (short)153, (short)122, (short)(-1), (short)66, (short)(-1), (short)82, (short)(-1), (short)83, (short)(-1), (short)46, (short)(-1), (short)34, (short)(-1), (short)35, (short)(-1), (short)36, (short)(-1), (short)37, (short)(-1), (short)38, (short)(-1), (short)47, (short)(-1), (short)39, (short)(-1), (short)42, (short)(-1), (short)43, (short)(-1), (short)40, (short)(-1), (short)41, (short)(-1), (short)85, (short)(-1), (short)113, (short)(-1), (short)112, (short)(-1), (short)201, (short)(-1), (short)215, (short)(-1), (short)148, (short)(-1), (short)87, (short)121, (short)175, (short)122, (short)(-1), (short)100, (short)121, (short)146, (short)122, (short)(-1), (short)100, (short)121, (short)153, (short)122, (short)(-1), (short)66, (short)(-1), (short)207, (short)153, (short)141, (short)208, (short)142, (short)(-1), (short)207, (short)141, (short)208, (short)142, (short)(-1), (short)207, (short)153, (short)141, (short)142, (short)(-1), (short)207, (short)141, (short)142, (short)(-1), (short)207, (short)147, (short)141, (short)208, (short)142, (short)(-1), (short)207, (short)190, (short)153, (short)141, (short)208, (short)142, (short)(-1), (short)207, (short)190, (short)141, (short)208, (short)142, (short)(-1), (short)207, (short)190, (short)153, (short)141, (short)142, (short)(-1), (short)207, (short)190, (short)141, (short)142, (short)(-1), (short)207, (short)190, (short)148, (short)141, (short)208, (short)142, (short)(-1), (short)207, (short)153, (short)(-1), (short)207, (short)148, (short)(-1), (short)207, (short)190, (short)153, (short)(-1), (short)207, (short)190, (short)148, (short)(-1), (short)183, (short)(-1), (short)183, (short)221, (short)(-1), (short)183, (short)(-1), (short)183, (short)221, (short)(-1), (short)165, (short)(-1), (short)204, (short)(-1), (short)203, (short)(-1), (short)153, (short)139, (short)204, (short)(-1), (short)153, (short)139, (short)203, (short)(-1), (short)202, (short)139, (short)204, (short)(-1), (short)202, (short)139, (short)203, (short)(-1), (short)205, (short)(-1), (short)206, (short)128, (short)205, (short)(-1), (short)48, (short)(-1), (short)49, (short)(-1), (short)212, (short)(-1), (short)208, (short)212, (short)(-1), (short)156, (short)139, (short)239, (short)(-1), (short)209, (short)(-1), (short)210, (short)128, (short)209, (short)(-1), (short)68, (short)185, (short)153, (short)141, (short)69, (short)247, (short)70, (short)247, (short)142, (short)(-1), (short)68, (short)185, (short)153, (short)141, (short)70, (short)247, (short)69, (short)247, (short)142, (short)(-1), (short)68, (short)185, (short)153, (short)141, (short)69, (short)247, (short)142, (short)(-1), (short)68, (short)185, (short)153, (short)141, (short)70, (short)247, (short)142, (short)(-1), (short)68, (short)185, (short)153, (short)141, (short)142, (short)(-1), (short)68, (short)185, (short)221, (short)153, (short)141, (short)69, (short)247, (short)70, (short)247, (short)142, (short)(-1), (short)68, (short)185, (short)221, (short)153, (short)141, (short)70, (short)247, (short)69, (short)247, (short)142, (short)(-1), (short)68, (short)185, (short)221, (short)153, (short)141, (short)69, (short)247, (short)142, (short)(-1), (short)68, (short)185, (short)221, (short)153, (short)141, (short)70, (short)247, (short)142, (short)(-1), (short)68, (short)185, (short)221, (short)153, (short)141, (short)142, (short)(-1), (short)68, (short)185, (short)141, (short)69, (short)247, (short)70, (short)247, (short)142, (short)(-1), (short)68, (short)185, (short)141, (short)70, (short)247, (short)69, (short)247, (short)142, (short)(-1), (short)68, (short)185, (short)141, (short)69, (short)247, (short)142, (short)(-1), (short)68, (short)185, (short)141, (short)70, (short)247, (short)142, (short)(-1), (short)68, (short)185, (short)141, (short)142, (short)(-1), (short)68, (short)185, (short)221, (short)141, (short)69, (short)247, (short)70, (short)247, (short)142, (short)(-1), (short)68, (short)185, (short)221, (short)141, (short)70, (short)247, (short)69, (short)247, (short)142, (short)(-1), (short)68, (short)185, (short)221, (short)141, (short)69, (short)247, (short)142, (short)(-1), (short)68, (short)185, (short)221, (short)141, (short)70, (short)247, (short)142, (short)(-1), (short)68, (short)185, (short)221, (short)141, (short)142, (short)(-1), (short)183, (short)213, (short)140, (short)(-1), (short)183, (short)140, (short)(-1), (short)255, (short)140, (short)(-1), (short)254, (short)140, (short)(-1), (short)257, (short)(-1), (short)210, (short)140, (short)(-1), (short)211, (short)(-1), (short)140, (short)(-1), (short)214, (short)(-1), (short)213, (short)128, (short)214, (short)(-1), (short)229, (short)(-1), (short)229, (short)195, (short)(-1), (short)138, (short)178, (short)(-1), (short)229, (short)138, (short)178, (short)(-1), (short)229, (short)138, (short)178, (short)138, (short)178, (short)(-1), (short)50, (short)153, (short)(-1), (short)50, (short)148, (short)(-1), (short)50, (short)141, (short)217, (short)142, (short)(-1), (short)50, (short)153, (short)141, (short)217, (short)142, (short)(-1), (short)50, (short)153, (short)141, (short)217, (short)140, (short)208, (short)142, (short)(-1), (short)50, (short)148, (short)141, (short)217, (short)140, (short)208, (short)142, (short)(-1), (short)50, (short)148, (short)141, (short)217, (short)142, (short)(-1), (short)218, (short)(-1), (short)217, (short)128, (short)218, (short)(-1), (short)153, (short)(-1), (short)153, (short)139, (short)178, (short)(-1), (short)121, (short)221, (short)122, (short)(-1), (short)126, (short)127, (short)(-1), (short)126, (short)178, (short)127, (short)(-1), (short)126, (short)146, (short)127, (short)(-1), (short)219, (short)126, (short)127, (short)(-1), (short)219, (short)126, (short)178, (short)127, (short)(-1), (short)219, (short)126, (short)146, (short)127, (short)(-1), (short)121, (short)122, (short)(-1), (short)121, (short)232, (short)122, (short)(-1), (short)219, (short)121, (short)122, (short)(-1), (short)219, (short)121, (short)232, (short)122, (short)(-1), (short)121, (short)222, (short)122, (short)(-1), (short)121, (short)122, (short)(-1), (short)121, (short)232, (short)122, (short)(-1), (short)220, (short)121, (short)122, (short)(-1), (short)220, (short)121, (short)232, (short)122, (short)(-1), (short)231, (short)(-1), (short)219, (short)(-1), (short)231, (short)219, (short)(-1), (short)190, (short)231, (short)(-1), (short)190, (short)219, (short)(-1), (short)190, (short)231, (short)219, (short)(-1), (short)231, (short)(-1), (short)220, (short)(-1), (short)231, (short)220, (short)(-1), (short)190, (short)231, (short)(-1), (short)190, (short)220, (short)(-1), (short)190, (short)231, (short)220, (short)(-1), (short)228, (short)(-1), (short)231, (short)228, (short)(-1), (short)190, (short)231, (short)228, (short)(-1), (short)223, (short)190, (short)(-1), (short)153, (short)(-1), (short)121, (short)223, (short)122, (short)(-1), (short)224, (short)126, (short)178, (short)127, (short)(-1), (short)224, (short)126, (short)127, (short)(-1), (short)224, (short)126, (short)146, (short)127, (short)(-1), (short)227, (short)(-1), (short)231, (short)227, (short)(-1), (short)190, (short)227, (short)(-1), (short)190, (short)231, (short)227, (short)(-1), (short)231, (short)190, (short)227, (short)(-1), (short)224, (short)121, (short)(-1), (short)226, (short)232, (short)122, (short)(-1), (short)226, (short)235, (short)122, (short)(-1), (short)226, (short)122, (short)(-1), (short)227, (short)(-1), (short)224, (short)(-1), (short)190, (short)227, (short)(-1), (short)190, (short)224, (short)(-1), (short)224, (short)(-1), (short)231, (short)224, (short)(-1), (short)190, (short)224, (short)(-1), (short)190, (short)231, (short)224, (short)(-1), (short)231, (short)190, (short)224, (short)(-1), (short)197, (short)(-1), (short)230, (short)197, (short)(-1), (short)118, (short)(-1), (short)118, (short)230, (short)(-1), (short)118, (short)231, (short)(-1), (short)118, (short)230, (short)231, (short)(-1), (short)233, (short)(-1), (short)233, (short)128, (short)51, (short)(-1), (short)234, (short)(-1), (short)233, (short)128, (short)234, (short)(-1), (short)183, (short)223, (short)(-1), (short)183, (short)221, (short)(-1), (short)183, (short)129, (short)(-1), (short)183, (short)129, (short)223, (short)(-1), (short)184, (short)(-1), (short)65, (short)(-1), (short)153, (short)(-1), (short)235, (short)128, (short)153, (short)(-1), (short)180, (short)(-1), (short)180, (short)221, (short)(-1), (short)181, (short)(-1), (short)181, (short)221, (short)(-1), (short)175, (short)(-1), (short)141, (short)240, (short)142, (short)(-1), (short)141, (short)240, (short)128, (short)142, (short)(-1), (short)174, (short)(-1), (short)157, (short)(-1), (short)238, (short)(-1), (short)240, (short)128, (short)238, (short)(-1), (short)242, (short)(-1), (short)247, (short)(-1), (short)248, (short)(-1), (short)249, (short)(-1), (short)250, (short)(-1), (short)251, (short)(-1), (short)153, (short)138, (short)241, (short)(-1), (short)52, (short)178, (short)138, (short)241, (short)(-1), (short)53, (short)138, (short)241, (short)(-1), (short)179, (short)(-1), (short)243, (short)179, (short)(-1), (short)241, (short)(-1), (short)244, (short)241, (short)(-1), (short)244, (short)179, (short)(-1), (short)244, (short)(-1), (short)243, (short)(-1), (short)243, (short)244, (short)(-1), (short)141, (short)(-1), (short)141, (short)142, (short)(-1), (short)246, (short)245, (short)142, (short)(-1), (short)140, (short)(-1), (short)177, (short)140, (short)(-1), (short)54, (short)121, (short)177, (short)122, (short)241, (short)(-1), (short)54, (short)121, (short)177, (short)122, (short)241, (short)64, (short)241, (short)(-1), (short)55, (short)121, (short)177, (short)122, (short)241, (short)(-1), (short)56, (short)121, (short)177, (short)122, (short)241, (short)(-1), (short)57, (short)241, (short)56, (short)121, (short)177, (short)122, (short)140, (short)(-1), (short)58, (short)121, (short)248, (short)248, (short)122, (short)241, (short)(-1), (short)58, (short)121, (short)248, (short)248, (short)177, (short)122, (short)241, (short)(-1), (short)56, (short)121, (short)122, (short)241, (short)(-1), (short)58, (short)121, (short)248, (short)122, (short)241, (short)(-1), (short)58, (short)121, (short)122, (short)241, (short)(-1), (short)59, (short)153, (short)140, (short)(-1), (short)60, (short)140, (short)(-1), (short)61, (short)140, (short)(-1), (short)62, (short)140, (short)(-1), (short)62, (short)177, (short)140, (short)(-1), (short)5, (short)(-1), (short)182, (short)153, (short)141, (short)264, (short)142, (short)(-1), (short)182, (short)153, (short)141, (short)142, (short)(-1), (short)183, (short)153, (short)141, (short)264, (short)142, (short)(-1), (short)183, (short)153, (short)141, (short)142, (short)(-1), (short)146, (short)141, (short)264, (short)142, (short)(-1), (short)146, (short)141, (short)142, (short)(-1), (short)153, (short)141, (short)264, (short)142, (short)(-1), (short)153, (short)141, (short)142, (short)(-1), (short)141, (short)264, (short)142, (short)(-1), (short)141, (short)142, (short)(-1), (short)149, (short)247, (short)(-1), (short)152, (short)247, (short)(-1), (short)152, (short)140, (short)(-1), (short)150, (short)247, (short)(-1), (short)151, (short)247, (short)(-1), (short)182, (short)225, (short)(-1), (short)182, (short)229, (short)(-1), (short)258, (short)247, (short)(-1), (short)156, (short)139, (short)239, (short)(-1), (short)239, (short)(-1), (short)260, (short)(-1), (short)261, (short)128, (short)260, (short)(-1), (short)261, (short)140, (short)(-1), (short)262, (short)(-1), (short)259, (short)(-1), (short)263, (short)262, (short)(-1), (short)263, (short)259, (short)(-1), (short)140, (short)(-1), (short)263, (short)140, (short)(-1), (short)263, (short)(-1), (short)261, (short)(-1), (short)263, (short)261, (short)(-1), (short)234, (short)(-1), (short)234, (short)138, (short)178, (short)(-1) }; static const yytype_uint16 yyrline[] = { (unsigned short)0, (unsigned short)228, (unsigned short)228, (unsigned short)246, (unsigned short)280, (unsigned short)330, (unsigned short)331, (unsigned short)358, (unsigned short)362, (unsigned short)363, (unsigned short)364, (unsigned short)381, (unsigned short)383, (unsigned short)388, (unsigned short)393, (unsigned short)398, (unsigned short)400, (unsigned short)405, (unsigned short)410, (unsigned short)411, (unsigned short)416, (unsigned short)418, (unsigned short)420, (unsigned short)422, (unsigned short)424, (unsigned short)425, (unsigned short)426, (unsigned short)429, (unsigned short)430, (unsigned short)431, (unsigned short)432, (unsigned short)433, (unsigned short)434, (unsigned short)435, (unsigned short)436, (unsigned short)437, (unsigned short)441, (unsigned short)442, (unsigned short)443, (unsigned short)444, (unsigned short)445, (unsigned short)446, (unsigned short)459, (unsigned short)460, (unsigned short)461, (unsigned short)465, (unsigned short)494, (unsigned short)495, (unsigned short)496, (unsigned short)497, (unsigned short)501, (unsigned short)502, (unsigned short)503, (unsigned short)505, (unsigned short)506, (unsigned short)508, (unsigned short)509, (unsigned short)513, (unsigned short)514, (unsigned short)523, (unsigned short)524, (unsigned short)525, (unsigned short)526, (unsigned short)527, (unsigned short)528, (unsigned short)529, (unsigned short)533, (unsigned short)534, (unsigned short)538, (unsigned short)539, (unsigned short)540, (unsigned short)541, (unsigned short)545, (unsigned short)546, (unsigned short)547, (unsigned short)551, (unsigned short)552, (unsigned short)553, (unsigned short)557, (unsigned short)565, (unsigned short)566, (unsigned short)567, (unsigned short)568, (unsigned short)569, (unsigned short)573, (unsigned short)574, (unsigned short)575, (unsigned short)579, (unsigned short)580, (unsigned short)584, (unsigned short)585, (unsigned short)589, (unsigned short)590, (unsigned short)594, (unsigned short)595, (unsigned short)599, (unsigned short)600, (unsigned short)604, (unsigned short)605, (unsigned short)609, (unsigned short)610, (unsigned short)611, (unsigned short)615, (unsigned short)616, (unsigned short)617, (unsigned short)618, (unsigned short)619, (unsigned short)620, (unsigned short)621, (unsigned short)622, (unsigned short)623, (unsigned short)624, (unsigned short)625, (unsigned short)629, (unsigned short)630, (unsigned short)634, (unsigned short)638, (unsigned short)639, (unsigned short)640, (unsigned short)641, (unsigned short)645, (unsigned short)646, (unsigned short)647, (unsigned short)648, (unsigned short)649, (unsigned short)650, (unsigned short)651, (unsigned short)652, (unsigned short)656, (unsigned short)657, (unsigned short)658, (unsigned short)659, (unsigned short)660, (unsigned short)661, (unsigned short)662, (unsigned short)663, (unsigned short)664, (unsigned short)665, (unsigned short)669, (unsigned short)670, (unsigned short)671, (unsigned short)672, (unsigned short)673, (unsigned short)674, (unsigned short)675, (unsigned short)676, (unsigned short)677, (unsigned short)678, (unsigned short)682, (unsigned short)683, (unsigned short)684, (unsigned short)685, (unsigned short)686, (unsigned short)687, (unsigned short)688, (unsigned short)689, (unsigned short)690, (unsigned short)691, (unsigned short)692, (unsigned short)693, (unsigned short)697, (unsigned short)698, (unsigned short)702, (unsigned short)703, (unsigned short)704, (unsigned short)705, (unsigned short)706, (unsigned short)707, (unsigned short)708, (unsigned short)709, (unsigned short)710, (unsigned short)728, (unsigned short)745, (unsigned short)746, (unsigned short)747, (unsigned short)748, (unsigned short)749, (unsigned short)750, (unsigned short)751, (unsigned short)752, (unsigned short)753, (unsigned short)754, (unsigned short)755, (unsigned short)756, (unsigned short)757, (unsigned short)775, (unsigned short)792, (unsigned short)793, (unsigned short)797, (unsigned short)798, (unsigned short)802, (unsigned short)803, (unsigned short)804, (unsigned short)805, (unsigned short)806, (unsigned short)807, (unsigned short)811, (unsigned short)812, (unsigned short)813, (unsigned short)817, (unsigned short)818, (unsigned short)819, (unsigned short)824, (unsigned short)825, (unsigned short)826, (unsigned short)827, (unsigned short)828, (unsigned short)832, (unsigned short)833, (unsigned short)837, (unsigned short)838, (unsigned short)839, (unsigned short)843, (unsigned short)844, (unsigned short)848, (unsigned short)852, (unsigned short)853, (unsigned short)854, (unsigned short)859, (unsigned short)860, (unsigned short)861, (unsigned short)862, (unsigned short)863, (unsigned short)864, (unsigned short)865, (unsigned short)866, (unsigned short)867, (unsigned short)868, (unsigned short)869, (unsigned short)870, (unsigned short)871, (unsigned short)872, (unsigned short)873, (unsigned short)874, (unsigned short)875, (unsigned short)876, (unsigned short)877, (unsigned short)878, (unsigned short)879, (unsigned short)880, (unsigned short)881, (unsigned short)882, (unsigned short)886, (unsigned short)887, (unsigned short)888, (unsigned short)889, (unsigned short)890, (unsigned short)891, (unsigned short)892, (unsigned short)893, (unsigned short)894, (unsigned short)895, (unsigned short)896, (unsigned short)897, (unsigned short)898, (unsigned short)899, (unsigned short)900, (unsigned short)901, (unsigned short)902, (unsigned short)903, (unsigned short)904, (unsigned short)905, (unsigned short)906, (unsigned short)907, (unsigned short)912, (unsigned short)913, (unsigned short)914, (unsigned short)915, (unsigned short)916, (unsigned short)919, (unsigned short)920, (unsigned short)921, (unsigned short)922, (unsigned short)923, (unsigned short)928, (unsigned short)929, (unsigned short)932, (unsigned short)934, (unsigned short)939, (unsigned short)940, (unsigned short)945, (unsigned short)946, (unsigned short)957, (unsigned short)961, (unsigned short)963, (unsigned short)964, (unsigned short)966, (unsigned short)967, (unsigned short)991, (unsigned short)1006, (unsigned short)1007, (unsigned short)1011, (unsigned short)1012, (unsigned short)1016, (unsigned short)1017, (unsigned short)1021, (unsigned short)1025, (unsigned short)1026, (unsigned short)1030, (unsigned short)1032, (unsigned short)1034, (unsigned short)1036, (unsigned short)1038, (unsigned short)1041, (unsigned short)1043, (unsigned short)1045, (unsigned short)1047, (unsigned short)1049, (unsigned short)1052, (unsigned short)1054, (unsigned short)1056, (unsigned short)1058, (unsigned short)1060, (unsigned short)1063, (unsigned short)1065, (unsigned short)1067, (unsigned short)1069, (unsigned short)1071, (unsigned short)1076, (unsigned short)1077, (unsigned short)1078, (unsigned short)1079, (unsigned short)1080, (unsigned short)1081, (unsigned short)1082, (unsigned short)1083, (unsigned short)1087, (unsigned short)1089, (unsigned short)1094, (unsigned short)1096, (unsigned short)1098, (unsigned short)1100, (unsigned short)1102, (unsigned short)1107, (unsigned short)1108, (unsigned short)1112, (unsigned short)1114, (unsigned short)1115, (unsigned short)1116, (unsigned short)1117, (unsigned short)1121, (unsigned short)1123, (unsigned short)1128, (unsigned short)1130, (unsigned short)1136, (unsigned short)1138, (unsigned short)1140, (unsigned short)1142, (unsigned short)1144, (unsigned short)1146, (unsigned short)1148, (unsigned short)1150, (unsigned short)1152, (unsigned short)1154, (unsigned short)1156, (unsigned short)1161, (unsigned short)1163, (unsigned short)1165, (unsigned short)1167, (unsigned short)1169, (unsigned short)1174, (unsigned short)1175, (unsigned short)1176, (unsigned short)1177, (unsigned short)1178, (unsigned short)1179, (unsigned short)1183, (unsigned short)1184, (unsigned short)1185, (unsigned short)1186, (unsigned short)1187, (unsigned short)1188, (unsigned short)1234, (unsigned short)1235, (unsigned short)1237, (unsigned short)1239, (unsigned short)1244, (unsigned short)1246, (unsigned short)1248, (unsigned short)1250, (unsigned short)1252, (unsigned short)1257, (unsigned short)1258, (unsigned short)1261, (unsigned short)1263, (unsigned short)1265, (unsigned short)1271, (unsigned short)1275, (unsigned short)1277, (unsigned short)1279, (unsigned short)1284, (unsigned short)1285, (unsigned short)1286, (unsigned short)1288, (unsigned short)1293, (unsigned short)1294, (unsigned short)1295, (unsigned short)1296, (unsigned short)1297, (unsigned short)1301, (unsigned short)1302, (unsigned short)1306, (unsigned short)1307, (unsigned short)1308, (unsigned short)1309, (unsigned short)1313, (unsigned short)1314, (unsigned short)1318, (unsigned short)1319, (unsigned short)1323, (unsigned short)1324, (unsigned short)1325, (unsigned short)1326, (unsigned short)1327, (unsigned short)1338, (unsigned short)1363, (unsigned short)1364, (unsigned short)1368, (unsigned short)1369, (unsigned short)1373, (unsigned short)1374, (unsigned short)1378, (unsigned short)1380, (unsigned short)1382, (unsigned short)1398, (unsigned short)1400, (unsigned short)1422, (unsigned short)1424, (unsigned short)1429, (unsigned short)1430, (unsigned short)1431, (unsigned short)1432, (unsigned short)1433, (unsigned short)1434, (unsigned short)1438, (unsigned short)1440, (unsigned short)1442, (unsigned short)1447, (unsigned short)1448, (unsigned short)1452, (unsigned short)1453, (unsigned short)1456, (unsigned short)1460, (unsigned short)1461, (unsigned short)1462, (unsigned short)1466, (unsigned short)1470, (unsigned short)1478, (unsigned short)1483, (unsigned short)1484, (unsigned short)1488, (unsigned short)1489, (unsigned short)1490, (unsigned short)1494, (unsigned short)1495, (unsigned short)1496, (unsigned short)1497, (unsigned short)1499, (unsigned short)1500, (unsigned short)1501, (unsigned short)1505, (unsigned short)1506, (unsigned short)1507, (unsigned short)1508, (unsigned short)1509, (unsigned short)1513, (unsigned short)1517, (unsigned short)1519, (unsigned short)1524, (unsigned short)1526, (unsigned short)1551, (unsigned short)1553, (unsigned short)1555, (unsigned short)1557, (unsigned short)1562, (unsigned short)1564, (unsigned short)1568, (unsigned short)1570, (unsigned short)1572, (unsigned short)1574, (unsigned short)1576, (unsigned short)1582, (unsigned short)1584, (unsigned short)1589, (unsigned short)1594, (unsigned short)1595, (unsigned short)1599, (unsigned short)1601, (unsigned short)1606, (unsigned short)1611, (unsigned short)1612, (unsigned short)1613, (unsigned short)1614, (unsigned short)1615, (unsigned short)1616, (unsigned short)1620, (unsigned short)1621, (unsigned short)1622, (unsigned short)1626, (unsigned short)1627 }; static const char * const yytname[] = { "$end", "error", "$undefined", "IDENTIFIER", "CONSTANT", "STRING_LITERAL", "SIZEOF", "PTR_OP", "INC_OP", "DEC_OP", "LEFT_OP", "RIGHT_OP", "LE_OP", "GE_OP", "EQ_OP", "NE_OP", "AND_OP", "OR_OP", "MUL_ASSIGN", "DIV_ASSIGN", "MOD_ASSIGN", "ADD_ASSIGN", "SUB_ASSIGN", "LEFT_ASSIGN", "RIGHT_ASSIGN", "AND_ASSIGN", "XOR_ASSIGN", "OR_ASSIGN", "TYPE_NAME", "TYPEDEF", "EXTERN", "STATIC", "AUTO", "REGISTER", "CHAR", "SHORT", "INT", "UINT", "INT64", "LONG", "SIGNED", "UNSIGNED", "FLOAT", "DOUBLE", "CONST", "VOLATILE", "VOID", "VALIST", "STRUCT", "UNION", "ENUM", "ELLIPSIS", "CASE", "DEFAULT", "IF", "SWITCH", "WHILE", "DO", "FOR", "GOTO", "CONTINUE", "BREAK", "RETURN", "IFX", "ELSE", "CLASS", "THISCLASS", "CLASS_NAME", "PROPERTY", "SETPROP", "GETPROP", "NEWOP", "RENEW", "DELETE", "EXT_DECL", "EXT_STORAGE", "IMPORT", "DEFINE", "VIRTUAL", "ATTRIB", "PUBLIC", "PRIVATE", "TYPED_OBJECT", "ANY_OBJECT", "_INCREF", "EXTENSION", "ASM", "TYPEOF", "WATCH", "STOPWATCHING", "FIREWATCHERS", "WATCHABLE", "CLASS_DESIGNER", "CLASS_NO_EXPANSION", "CLASS_FIXED", "ISPROPSET", "CLASS_DEFAULT_PROPERTY", "PROPERTY_CATEGORY", "CLASS_DATA", "CLASS_PROPERTY", "SUBCLASS", "NAMESPACE", "NEW0OP", "RENEW0", "VAARG", "DBTABLE", "DBFIELD", "DBINDEX", "DATABASE_OPEN", "ALIGNOF", "ATTRIB_DEP", "__ATTRIB", "BOOL", "_BOOL", "_COMPLEX", "_IMAGINARY", "RESTRICT", "THREAD", "'*'", "'<'", "'>'", "'('", "')'", "'~'", "'$'", "'.'", "'['", "']'", "','", "'&'", "'+'", "'-'", "'!'", "'/'", "'%'", "'^'", "'|'", "'?'", "':'", "'='", "';'", "'{'", "'}'", "$accept", "guess_type", "real_guess_type", "type", "base_strict_type", "strict_type", "class_function_definition_start", "constructor_function_definition_start", "destructor_function_definition_start", "virtual_class_function_definition_start", "identifier", "primary_expression", "simple_primary_expression", "postfix_expression", "anon_instantiation_expression", "argument_expression_list", "common_unary_expression", "unary_expression", "unary_operator", "cast_expression", "multiplicative_expression", "additive_expression", "shift_expression", "relational_expression_smaller_than", "relational_expression", "equality_expression", "and_expression", "exclusive_or_expression", "inclusive_or_expression", "logical_and_expression", "logical_or_expression", "conditional_expression", "assignment_expression", "assignment_operator", "expression", "constant_expression", "declaration", "specifier_qualifier_list", "guess_specifier_qualifier_list", "declaration_specifiers", "guess_declaration_specifiers", "real_guess_declaration_specifiers", "property_specifiers", "renew_specifiers", "init_declarator_list", "init_declarator", "storage_class_specifier", "ext_decl", "_attrib", "attribute_word", "attribute", "attribs_list", "attrib", "ext_storage", "type_qualifier", "type_specifier", "strict_type_specifier", "struct_or_union_specifier_compound", "struct_or_union_specifier_nocompound", "template_datatype", "template_type_argument", "template_expression_argument", "template_argument", "template_arguments_list", "struct_or_union", "struct_declaration_list", "default_property", "default_property_list", "property", "struct_declaration", "struct_declarator_list", "struct_declarator", "enum_specifier_nocompound", "enum_specifier_compound", "enumerator_list", "enumerator", "direct_abstract_declarator", "direct_abstract_declarator_noarray", "abstract_declarator", "abstract_declarator_noarray", "declarator", "direct_declarator_nofunction", "declarator_function", "direct_declarator_function_start", "direct_declarator_function", "direct_declarator", "declarator_nofunction", "type_qualifier_list", "pointer", "parameter_type_list", "parameter_list", "parameter_declaration", "identifier_list", "type_name", "guess_type_name", "initializer", "initializer_condition", "initializer_list", "statement", "labeled_statement", "declaration_list", "statement_list", "compound_inside", "compound_start", "compound_statement", "expression_statement", "selection_statement", "iteration_statement", "jump_statement", "string_literal", "instantiation_named", "guess_instantiation_named", "instantiation_unnamed", "instantiation_anon", "class_function_definition", "instance_class_function_definition_start", "instance_class_function_definition", "data_member_initialization", "data_member_initialization_list", "data_member_initialization_list_coloned", "members_initialization_list_coloned", "members_initialization_list", "type_unit", 0 }; static const yytype_uint16 yyr1[] = { (unsigned short)0, (unsigned short)143, (unsigned short)144, (unsigned short)144, (unsigned short)145, (unsigned short)146, (unsigned short)146, (unsigned short)147, (unsigned short)148, (unsigned short)148, (unsigned short)148, (unsigned short)149, (unsigned short)149, (unsigned short)150, (unsigned short)151, (unsigned short)152, (unsigned short)152, (unsigned short)153, (unsigned short)154, (unsigned short)154, (unsigned short)155, (unsigned short)155, (unsigned short)155, (unsigned short)155, (unsigned short)155, (unsigned short)155, (unsigned short)155, (unsigned short)155, (unsigned short)155, (unsigned short)155, (unsigned short)155, (unsigned short)155, (unsigned short)155, (unsigned short)155, (unsigned short)155, (unsigned short)155, (unsigned short)156, (unsigned short)156, (unsigned short)156, (unsigned short)156, (unsigned short)156, (unsigned short)156, (unsigned short)156, (unsigned short)156, (unsigned short)156, (unsigned short)157, (unsigned short)158, (unsigned short)158, (unsigned short)158, (unsigned short)158, (unsigned short)159, (unsigned short)159, (unsigned short)159, (unsigned short)159, (unsigned short)159, (unsigned short)159, (unsigned short)159, (unsigned short)160, (unsigned short)160, (unsigned short)161, (unsigned short)161, (unsigned short)161, (unsigned short)161, (unsigned short)161, (unsigned short)161, (unsigned short)161, (unsigned short)162, (unsigned short)162, (unsigned short)163, (unsigned short)163, (unsigned short)163, (unsigned short)163, (unsigned short)164, (unsigned short)164, (unsigned short)164, (unsigned short)165, (unsigned short)165, (unsigned short)165, (unsigned short)166, (unsigned short)167, (unsigned short)167, (unsigned short)167, (unsigned short)167, (unsigned short)167, (unsigned short)168, (unsigned short)168, (unsigned short)168, (unsigned short)169, (unsigned short)169, (unsigned short)170, (unsigned short)170, (unsigned short)171, (unsigned short)171, (unsigned short)172, (unsigned short)172, (unsigned short)173, (unsigned short)173, (unsigned short)174, (unsigned short)174, (unsigned short)175, (unsigned short)175, (unsigned short)175, (unsigned short)176, (unsigned short)176, (unsigned short)176, (unsigned short)176, (unsigned short)176, (unsigned short)176, (unsigned short)176, (unsigned short)176, (unsigned short)176, (unsigned short)176, (unsigned short)176, (unsigned short)177, (unsigned short)177, (unsigned short)178, (unsigned short)179, (unsigned short)179, (unsigned short)179, (unsigned short)179, (unsigned short)180, (unsigned short)180, (unsigned short)180, (unsigned short)180, (unsigned short)180, (unsigned short)180, (unsigned short)180, (unsigned short)180, (unsigned short)181, (unsigned short)181, (unsigned short)181, (unsigned short)181, (unsigned short)181, (unsigned short)181, (unsigned short)181, (unsigned short)181, (unsigned short)181, (unsigned short)181, (unsigned short)182, (unsigned short)182, (unsigned short)182, (unsigned short)182, (unsigned short)182, (unsigned short)182, (unsigned short)182, (unsigned short)182, (unsigned short)182, (unsigned short)182, (unsigned short)183, (unsigned short)183, (unsigned short)183, (unsigned short)183, (unsigned short)183, (unsigned short)183, (unsigned short)183, (unsigned short)183, (unsigned short)183, (unsigned short)183, (unsigned short)183, (unsigned short)183, (unsigned short)184, (unsigned short)184, (unsigned short)185, (unsigned short)185, (unsigned short)185, (unsigned short)185, (unsigned short)185, (unsigned short)185, (unsigned short)185, (unsigned short)185, (unsigned short)185, (unsigned short)185, (unsigned short)186, (unsigned short)186, (unsigned short)186, (unsigned short)186, (unsigned short)186, (unsigned short)186, (unsigned short)186, (unsigned short)186, (unsigned short)186, (unsigned short)186, (unsigned short)186, (unsigned short)186, (unsigned short)186, (unsigned short)186, (unsigned short)187, (unsigned short)187, (unsigned short)188, (unsigned short)188, (unsigned short)189, (unsigned short)189, (unsigned short)189, (unsigned short)189, (unsigned short)189, (unsigned short)189, (unsigned short)190, (unsigned short)190, (unsigned short)190, (unsigned short)191, (unsigned short)191, (unsigned short)191, (unsigned short)192, (unsigned short)192, (unsigned short)192, (unsigned short)192, (unsigned short)192, (unsigned short)193, (unsigned short)193, (unsigned short)194, (unsigned short)194, (unsigned short)194, (unsigned short)195, (unsigned short)195, (unsigned short)196, (unsigned short)197, (unsigned short)197, (unsigned short)197, (unsigned short)198, (unsigned short)198, (unsigned short)198, (unsigned short)198, (unsigned short)198, (unsigned short)198, (unsigned short)198, (unsigned short)198, (unsigned short)198, (unsigned short)198, (unsigned short)198, (unsigned short)198, (unsigned short)198, (unsigned short)198, (unsigned short)198, (unsigned short)198, (unsigned short)198, (unsigned short)198, (unsigned short)198, (unsigned short)198, (unsigned short)198, (unsigned short)198, (unsigned short)198, (unsigned short)198, (unsigned short)199, (unsigned short)199, (unsigned short)199, (unsigned short)199, (unsigned short)199, (unsigned short)199, (unsigned short)199, (unsigned short)199, (unsigned short)199, (unsigned short)199, (unsigned short)199, (unsigned short)199, (unsigned short)199, (unsigned short)199, (unsigned short)199, (unsigned short)199, (unsigned short)199, (unsigned short)199, (unsigned short)199, (unsigned short)199, (unsigned short)199, (unsigned short)199, (unsigned short)200, (unsigned short)200, (unsigned short)200, (unsigned short)200, (unsigned short)200, (unsigned short)200, (unsigned short)200, (unsigned short)200, (unsigned short)200, (unsigned short)200, (unsigned short)201, (unsigned short)201, (unsigned short)201, (unsigned short)201, (unsigned short)202, (unsigned short)202, (unsigned short)203, (unsigned short)203, (unsigned short)204, (unsigned short)205, (unsigned short)205, (unsigned short)205, (unsigned short)205, (unsigned short)205, (unsigned short)205, (unsigned short)206, (unsigned short)206, (unsigned short)207, (unsigned short)207, (unsigned short)208, (unsigned short)208, (unsigned short)209, (unsigned short)210, (unsigned short)210, (unsigned short)211, (unsigned short)211, (unsigned short)211, (unsigned short)211, (unsigned short)211, (unsigned short)211, (unsigned short)211, (unsigned short)211, (unsigned short)211, (unsigned short)211, (unsigned short)211, (unsigned short)211, (unsigned short)211, (unsigned short)211, (unsigned short)211, (unsigned short)211, (unsigned short)211, (unsigned short)211, (unsigned short)211, (unsigned short)211, (unsigned short)212, (unsigned short)212, (unsigned short)212, (unsigned short)212, (unsigned short)212, (unsigned short)212, (unsigned short)212, (unsigned short)212, (unsigned short)213, (unsigned short)213, (unsigned short)214, (unsigned short)214, (unsigned short)214, (unsigned short)214, (unsigned short)214, (unsigned short)215, (unsigned short)215, (unsigned short)216, (unsigned short)216, (unsigned short)216, (unsigned short)216, (unsigned short)216, (unsigned short)217, (unsigned short)217, (unsigned short)218, (unsigned short)218, (unsigned short)219, (unsigned short)219, (unsigned short)219, (unsigned short)219, (unsigned short)219, (unsigned short)219, (unsigned short)219, (unsigned short)219, (unsigned short)219, (unsigned short)219, (unsigned short)219, (unsigned short)220, (unsigned short)220, (unsigned short)220, (unsigned short)220, (unsigned short)220, (unsigned short)221, (unsigned short)221, (unsigned short)221, (unsigned short)221, (unsigned short)221, (unsigned short)221, (unsigned short)222, (unsigned short)222, (unsigned short)222, (unsigned short)222, (unsigned short)222, (unsigned short)222, (unsigned short)223, (unsigned short)223, (unsigned short)223, (unsigned short)223, (unsigned short)224, (unsigned short)224, (unsigned short)224, (unsigned short)224, (unsigned short)224, (unsigned short)225, (unsigned short)225, (unsigned short)225, (unsigned short)225, (unsigned short)225, (unsigned short)226, (unsigned short)227, (unsigned short)227, (unsigned short)227, (unsigned short)228, (unsigned short)228, (unsigned short)228, (unsigned short)228, (unsigned short)229, (unsigned short)229, (unsigned short)229, (unsigned short)229, (unsigned short)229, (unsigned short)230, (unsigned short)230, (unsigned short)231, (unsigned short)231, (unsigned short)231, (unsigned short)231, (unsigned short)232, (unsigned short)232, (unsigned short)233, (unsigned short)233, (unsigned short)234, (unsigned short)234, (unsigned short)234, (unsigned short)234, (unsigned short)234, (unsigned short)234, (unsigned short)235, (unsigned short)235, (unsigned short)236, (unsigned short)236, (unsigned short)237, (unsigned short)237, (unsigned short)238, (unsigned short)238, (unsigned short)238, (unsigned short)239, (unsigned short)239, (unsigned short)240, (unsigned short)240, (unsigned short)241, (unsigned short)241, (unsigned short)241, (unsigned short)241, (unsigned short)241, (unsigned short)241, (unsigned short)242, (unsigned short)242, (unsigned short)242, (unsigned short)243, (unsigned short)243, (unsigned short)244, (unsigned short)244, (unsigned short)244, (unsigned short)245, (unsigned short)245, (unsigned short)245, (unsigned short)246, (unsigned short)247, (unsigned short)247, (unsigned short)248, (unsigned short)248, (unsigned short)249, (unsigned short)249, (unsigned short)249, (unsigned short)250, (unsigned short)250, (unsigned short)250, (unsigned short)250, (unsigned short)250, (unsigned short)250, (unsigned short)250, (unsigned short)251, (unsigned short)251, (unsigned short)251, (unsigned short)251, (unsigned short)251, (unsigned short)252, (unsigned short)253, (unsigned short)253, (unsigned short)254, (unsigned short)254, (unsigned short)255, (unsigned short)255, (unsigned short)255, (unsigned short)255, (unsigned short)256, (unsigned short)256, (unsigned short)257, (unsigned short)257, (unsigned short)257, (unsigned short)257, (unsigned short)257, (unsigned short)258, (unsigned short)258, (unsigned short)259, (unsigned short)260, (unsigned short)260, (unsigned short)261, (unsigned short)261, (unsigned short)262, (unsigned short)263, (unsigned short)263, (unsigned short)263, (unsigned short)263, (unsigned short)263, (unsigned short)263, (unsigned short)264, (unsigned short)264, (unsigned short)264, (unsigned short)265, (unsigned short)265 }; static const yytype_uint8 yyr2[] = { (unsigned char)0, (unsigned char)2, (unsigned char)2, (unsigned char)2, (unsigned char)2, (unsigned char)1, (unsigned char)2, (unsigned char)1, (unsigned char)1, (unsigned char)4, (unsigned char)4, (unsigned char)2, (unsigned char)1, (unsigned char)3, (unsigned char)4, (unsigned char)3, (unsigned char)2, (unsigned char)1, (unsigned char)1, (unsigned char)3, (unsigned char)1, (unsigned char)1, (unsigned char)1, (unsigned char)1, (unsigned char)2, (unsigned char)4, (unsigned char)2, (unsigned char)6, (unsigned char)5, (unsigned char)6, (unsigned char)5, (unsigned char)7, (unsigned char)6, (unsigned char)7, (unsigned char)6, (unsigned char)1, (unsigned char)1, (unsigned char)4, (unsigned char)3, (unsigned char)4, (unsigned char)3, (unsigned char)2, (unsigned char)3, (unsigned char)2, (unsigned char)2, (unsigned char)1, (unsigned char)1, (unsigned char)1, (unsigned char)3, (unsigned char)3, (unsigned char)2, (unsigned char)2, (unsigned char)2, (unsigned char)2, (unsigned char)4, (unsigned char)2, (unsigned char)4, (unsigned char)1, (unsigned char)1, (unsigned char)1, (unsigned char)1, (unsigned char)1, (unsigned char)1, (unsigned char)1, (unsigned char)1, (unsigned char)1, (unsigned char)1, (unsigned char)4, (unsigned char)1, (unsigned char)3, (unsigned char)3, (unsigned char)3, (unsigned char)1, (unsigned char)3, (unsigned char)3, (unsigned char)1, (unsigned char)3, (unsigned char)3, (unsigned char)2, (unsigned char)1, (unsigned char)2, (unsigned char)3, (unsigned char)3, (unsigned char)3, (unsigned char)1, (unsigned char)3, (unsigned char)3, (unsigned char)1, (unsigned char)3, (unsigned char)1, (unsigned char)3, (unsigned char)1, (unsigned char)3, (unsigned char)1, (unsigned char)3, (unsigned char)1, (unsigned char)3, (unsigned char)1, (unsigned char)5, (unsigned char)1, (unsigned char)3, (unsigned char)3, (unsigned char)1, (unsigned char)1, (unsigned char)1, (unsigned char)1, (unsigned char)1, (unsigned char)1, (unsigned char)1, (unsigned char)1, (unsigned char)1, (unsigned char)1, (unsigned char)1, (unsigned char)1, (unsigned char)3, (unsigned char)1, (unsigned char)2, (unsigned char)3, (unsigned char)2, (unsigned char)5, (unsigned char)1, (unsigned char)2, (unsigned char)1, (unsigned char)2, (unsigned char)1, (unsigned char)2, (unsigned char)1, (unsigned char)2, (unsigned char)1, (unsigned char)2, (unsigned char)1, (unsigned char)2, (unsigned char)1, (unsigned char)2, (unsigned char)1, (unsigned char)2, (unsigned char)1, (unsigned char)2, (unsigned char)1, (unsigned char)2, (unsigned char)1, (unsigned char)2, (unsigned char)1, (unsigned char)2, (unsigned char)1, (unsigned char)2, (unsigned char)1, (unsigned char)2, (unsigned char)1, (unsigned char)2, (unsigned char)1, (unsigned char)2, (unsigned char)1, (unsigned char)2, (unsigned char)1, (unsigned char)2, (unsigned char)1, (unsigned char)2, (unsigned char)1, (unsigned char)2, (unsigned char)1, (unsigned char)1, (unsigned char)1, (unsigned char)2, (unsigned char)1, (unsigned char)2, (unsigned char)1, (unsigned char)2, (unsigned char)1, (unsigned char)2, (unsigned char)4, (unsigned char)5, (unsigned char)1, (unsigned char)2, (unsigned char)1, (unsigned char)2, (unsigned char)1, (unsigned char)2, (unsigned char)1, (unsigned char)2, (unsigned char)1, (unsigned char)2, (unsigned char)1, (unsigned char)2, (unsigned char)4, (unsigned char)5, (unsigned char)1, (unsigned char)3, (unsigned char)1, (unsigned char)3, (unsigned char)1, (unsigned char)1, (unsigned char)1, (unsigned char)1, (unsigned char)1, (unsigned char)1, (unsigned char)1, (unsigned char)1, (unsigned char)1, (unsigned char)1, (unsigned char)1, (unsigned char)1, (unsigned char)1, (unsigned char)1, (unsigned char)1, (unsigned char)1, (unsigned char)1, (unsigned char)1, (unsigned char)4, (unsigned char)1, (unsigned char)2, (unsigned char)3, (unsigned char)6, (unsigned char)5, (unsigned char)1, (unsigned char)1, (unsigned char)1, (unsigned char)1, (unsigned char)1, (unsigned char)1, (unsigned char)1, (unsigned char)1, (unsigned char)1, (unsigned char)1, (unsigned char)1, (unsigned char)1, (unsigned char)1, (unsigned char)1, (unsigned char)1, (unsigned char)1, (unsigned char)1, (unsigned char)1, (unsigned char)1, (unsigned char)1, (unsigned char)1, (unsigned char)1, (unsigned char)4, (unsigned char)4, (unsigned char)4, (unsigned char)1, (unsigned char)1, (unsigned char)1, (unsigned char)1, (unsigned char)1, (unsigned char)1, (unsigned char)1, (unsigned char)1, (unsigned char)1, (unsigned char)1, (unsigned char)1, (unsigned char)1, (unsigned char)1, (unsigned char)1, (unsigned char)1, (unsigned char)1, (unsigned char)1, (unsigned char)1, (unsigned char)1, (unsigned char)1, (unsigned char)1, (unsigned char)4, (unsigned char)4, (unsigned char)4, (unsigned char)1, (unsigned char)5, (unsigned char)4, (unsigned char)4, (unsigned char)3, (unsigned char)5, (unsigned char)6, (unsigned char)5, (unsigned char)5, (unsigned char)4, (unsigned char)6, (unsigned char)2, (unsigned char)2, (unsigned char)3, (unsigned char)3, (unsigned char)1, (unsigned char)2, (unsigned char)1, (unsigned char)2, (unsigned char)1, (unsigned char)1, (unsigned char)1, (unsigned char)3, (unsigned char)3, (unsigned char)3, (unsigned char)3, (unsigned char)1, (unsigned char)3, (unsigned char)1, (unsigned char)1, (unsigned char)1, (unsigned char)2, (unsigned char)3, (unsigned char)1, (unsigned char)3, (unsigned char)9, (unsigned char)9, (unsigned char)7, (unsigned char)7, (unsigned char)5, (unsigned char)10, (unsigned char)10, (unsigned char)8, (unsigned char)8, (unsigned char)6, (unsigned char)8, (unsigned char)8, (unsigned char)6, (unsigned char)6, (unsigned char)4, (unsigned char)9, (unsigned char)9, (unsigned char)7, (unsigned char)7, (unsigned char)5, (unsigned char)3, (unsigned char)2, (unsigned char)2, (unsigned char)2, (unsigned char)1, (unsigned char)2, (unsigned char)1, (unsigned char)1, (unsigned char)1, (unsigned char)3, (unsigned char)1, (unsigned char)2, (unsigned char)2, (unsigned char)3, (unsigned char)5, (unsigned char)2, (unsigned char)2, (unsigned char)4, (unsigned char)5, (unsigned char)7, (unsigned char)7, (unsigned char)5, (unsigned char)1, (unsigned char)3, (unsigned char)1, (unsigned char)3, (unsigned char)3, (unsigned char)2, (unsigned char)3, (unsigned char)3, (unsigned char)3, (unsigned char)4, (unsigned char)4, (unsigned char)2, (unsigned char)3, (unsigned char)3, (unsigned char)4, (unsigned char)3, (unsigned char)2, (unsigned char)3, (unsigned char)3, (unsigned char)4, (unsigned char)1, (unsigned char)1, (unsigned char)2, (unsigned char)2, (unsigned char)2, (unsigned char)3, (unsigned char)1, (unsigned char)1, (unsigned char)2, (unsigned char)2, (unsigned char)2, (unsigned char)3, (unsigned char)1, (unsigned char)2, (unsigned char)3, (unsigned char)2, (unsigned char)1, (unsigned char)3, (unsigned char)4, (unsigned char)3, (unsigned char)4, (unsigned char)1, (unsigned char)2, (unsigned char)2, (unsigned char)3, (unsigned char)3, (unsigned char)2, (unsigned char)3, (unsigned char)3, (unsigned char)2, (unsigned char)1, (unsigned char)1, (unsigned char)2, (unsigned char)2, (unsigned char)1, (unsigned char)2, (unsigned char)2, (unsigned char)3, (unsigned char)3, (unsigned char)1, (unsigned char)2, (unsigned char)1, (unsigned char)2, (unsigned char)2, (unsigned char)3, (unsigned char)1, (unsigned char)3, (unsigned char)1, (unsigned char)3, (unsigned char)2, (unsigned char)2, (unsigned char)2, (unsigned char)3, (unsigned char)1, (unsigned char)1, (unsigned char)1, (unsigned char)3, (unsigned char)1, (unsigned char)2, (unsigned char)1, (unsigned char)2, (unsigned char)1, (unsigned char)3, (unsigned char)4, (unsigned char)1, (unsigned char)1, (unsigned char)1, (unsigned char)3, (unsigned char)1, (unsigned char)1, (unsigned char)1, (unsigned char)1, (unsigned char)1, (unsigned char)1, (unsigned char)3, (unsigned char)4, (unsigned char)3, (unsigned char)1, (unsigned char)2, (unsigned char)1, (unsigned char)2, (unsigned char)2, (unsigned char)1, (unsigned char)1, (unsigned char)2, (unsigned char)1, (unsigned char)2, (unsigned char)3, (unsigned char)1, (unsigned char)2, (unsigned char)5, (unsigned char)7, (unsigned char)5, (unsigned char)5, (unsigned char)7, (unsigned char)6, (unsigned char)7, (unsigned char)4, (unsigned char)5, (unsigned char)4, (unsigned char)3, (unsigned char)2, (unsigned char)2, (unsigned char)2, (unsigned char)3, (unsigned char)1, (unsigned char)5, (unsigned char)4, (unsigned char)5, (unsigned char)4, (unsigned char)4, (unsigned char)3, (unsigned char)4, (unsigned char)3, (unsigned char)3, (unsigned char)2, (unsigned char)2, (unsigned char)2, (unsigned char)2, (unsigned char)2, (unsigned char)2, (unsigned char)2, (unsigned char)2, (unsigned char)2, (unsigned char)3, (unsigned char)1, (unsigned char)1, (unsigned char)3, (unsigned char)2, (unsigned char)1, (unsigned char)1, (unsigned char)2, (unsigned char)2, (unsigned char)1, (unsigned char)2, (unsigned char)1, (unsigned char)1, (unsigned char)2, (unsigned char)1, (unsigned char)3 }; static const yytype_uint16 yydefact[] = { (unsigned short)0, (unsigned short)17, (unsigned short)7, (unsigned short)190, (unsigned short)191, (unsigned short)192, (unsigned short)193, (unsigned short)194, (unsigned short)219, (unsigned short)220, (unsigned short)221, (unsigned short)222, (unsigned short)223, (unsigned short)225, (unsigned short)228, (unsigned short)229, (unsigned short)226, (unsigned short)227, (unsigned short)215, (unsigned short)216, (unsigned short)218, (unsigned short)224, (unsigned short)291, (unsigned short)292, (unsigned short)0, (unsigned short)414, (unsigned short)239, (unsigned short)196, (unsigned short)197, (unsigned short)199, (unsigned short)240, (unsigned short)241, (unsigned short)230, (unsigned short)0, (unsigned short)0, (unsigned short)200, (unsigned short)201, (unsigned short)232, (unsigned short)231, (unsigned short)195, (unsigned short)154, (unsigned short)161, (unsigned short)235, (unsigned short)8, (unsigned short)5, (unsigned short)0, (unsigned short)160, (unsigned short)413, (unsigned short)148, (unsigned short)214, (unsigned short)0, (unsigned short)198, (unsigned short)217, (unsigned short)150, (unsigned short)152, (unsigned short)156, (unsigned short)233, (unsigned short)0, (unsigned short)234, (unsigned short)158, (unsigned short)498, (unsigned short)0, (unsigned short)0, (unsigned short)334, (unsigned short)333, (unsigned short)0, (unsigned short)0, (unsigned short)0, (unsigned short)4, (unsigned short)2, (unsigned short)3, (unsigned short)6, (unsigned short)401, (unsigned short)0, (unsigned short)0, (unsigned short)411, (unsigned short)155, (unsigned short)376, (unsigned short)149, (unsigned short)214, (unsigned short)151, (unsigned short)153, (unsigned short)157, (unsigned short)159, (unsigned short)361, (unsigned short)410, (unsigned short)409, (unsigned short)391, (unsigned short)0, (unsigned short)390, (unsigned short)372, (unsigned short)360, (unsigned short)0, (unsigned short)0, (unsigned short)8, (unsigned short)275, (unsigned short)274, (unsigned short)0, (unsigned short)0, (unsigned short)1, (unsigned short)342, (unsigned short)0, (unsigned short)340, (unsigned short)0, (unsigned short)0, (unsigned short)35, (unsigned short)22, (unsigned short)465, (unsigned short)0, (unsigned short)0, (unsigned short)0, (unsigned short)0, (unsigned short)0, (unsigned short)65, (unsigned short)0, (unsigned short)0, (unsigned short)0, (unsigned short)60, (unsigned short)0, (unsigned short)63, (unsigned short)0, (unsigned short)59, (unsigned short)61, (unsigned short)62, (unsigned short)64, (unsigned short)0, (unsigned short)20, (unsigned short)36, (unsigned short)18, (unsigned short)58, (unsigned short)57, (unsigned short)66, (unsigned short)0, (unsigned short)68, (unsigned short)72, (unsigned short)75, (unsigned short)79, (unsigned short)0, (unsigned short)84, (unsigned short)87, (unsigned short)89, (unsigned short)91, (unsigned short)93, (unsigned short)95, (unsigned short)97, (unsigned short)99, (unsigned short)0, (unsigned short)23, (unsigned short)21, (unsigned short)0, (unsigned short)0, (unsigned short)235, (unsigned short)20, (unsigned short)66, (unsigned short)282, (unsigned short)280, (unsigned short)0, (unsigned short)284, (unsigned short)283, (unsigned short)289, (unsigned short)0, (unsigned short)399, (unsigned short)402, (unsigned short)403, (unsigned short)351, (unsigned short)0, (unsigned short)0, (unsigned short)0, (unsigned short)0, (unsigned short)405, (unsigned short)407, (unsigned short)345, (unsigned short)0, (unsigned short)115, (unsigned short)0, (unsigned short)0, (unsigned short)376, (unsigned short)0, (unsigned short)412, (unsigned short)0, (unsigned short)364, (unsigned short)393, (unsigned short)392, (unsigned short)363, (unsigned short)0, (unsigned short)0, (unsigned short)375, (unsigned short)386, (unsigned short)0, (unsigned short)389, (unsigned short)0, (unsigned short)0, (unsigned short)0, (unsigned short)0, (unsigned short)362, (unsigned short)373, (unsigned short)0, (unsigned short)0, (unsigned short)0, (unsigned short)0, (unsigned short)0, (unsigned short)325, (unsigned short)267, (unsigned short)0, (unsigned short)0, (unsigned short)0, (unsigned short)0, (unsigned short)20, (unsigned short)0, (unsigned short)0, (unsigned short)214, (unsigned short)0, (unsigned short)296, (unsigned short)0, (unsigned short)324, (unsigned short)293, (unsigned short)0, (unsigned short)12, (unsigned short)381, (unsigned short)0, (unsigned short)0, (unsigned short)21, (unsigned short)322, (unsigned short)0, (unsigned short)0, (unsigned short)0, (unsigned short)277, (unsigned short)276, (unsigned short)499, (unsigned short)0, (unsigned short)0, (unsigned short)335, (unsigned short)0, (unsigned short)0, (unsigned short)0, (unsigned short)53, (unsigned short)0, (unsigned short)50, (unsigned short)51, (unsigned short)0, (unsigned short)0, (unsigned short)0, (unsigned short)0, (unsigned short)0, (unsigned short)0, (unsigned short)55, (unsigned short)26, (unsigned short)113, (unsigned short)0, (unsigned short)417, (unsigned short)120, (unsigned short)122, (unsigned short)126, (unsigned short)124, (unsigned short)0, (unsigned short)24, (unsigned short)0, (unsigned short)0, (unsigned short)0, (unsigned short)43, (unsigned short)44, (unsigned short)0, (unsigned short)0, (unsigned short)0, (unsigned short)41, (unsigned short)103, (unsigned short)104, (unsigned short)105, (unsigned short)106, (unsigned short)107, (unsigned short)108, (unsigned short)109, (unsigned short)110, (unsigned short)111, (unsigned short)112, (unsigned short)102, (unsigned short)0, (unsigned short)52, (unsigned short)0, (unsigned short)0, (unsigned short)0, (unsigned short)0, (unsigned short)0, (unsigned short)0, (unsigned short)0, (unsigned short)80, (unsigned short)0, (unsigned short)0, (unsigned short)78, (unsigned short)0, (unsigned short)0, (unsigned short)0, (unsigned short)0, (unsigned short)0, (unsigned short)0, (unsigned short)0, (unsigned short)0, (unsigned short)0, (unsigned short)236, (unsigned short)237, (unsigned short)238, (unsigned short)0, (unsigned short)0, (unsigned short)214, (unsigned short)281, (unsigned short)360, (unsigned short)0, (unsigned short)10, (unsigned short)9, (unsigned short)0, (unsigned short)400, (unsigned short)404, (unsigned short)344, (unsigned short)377, (unsigned short)352, (unsigned short)0, (unsigned short)347, (unsigned short)346, (unsigned short)0, (unsigned short)365, (unsigned short)374, (unsigned short)353, (unsigned short)0, (unsigned short)348, (unsigned short)0, (unsigned short)0, (unsigned short)379, (unsigned short)0, (unsigned short)0, (unsigned short)387, (unsigned short)388, (unsigned short)0, (unsigned short)202, (unsigned short)203, (unsigned short)206, (unsigned short)205, (unsigned short)204, (unsigned short)0, (unsigned short)207, (unsigned short)209, (unsigned short)0, (unsigned short)243, (unsigned short)244, (unsigned short)245, (unsigned short)246, (unsigned short)247, (unsigned short)249, (unsigned short)252, (unsigned short)253, (unsigned short)250, (unsigned short)251, (unsigned short)242, (unsigned short)248, (unsigned short)0, (unsigned short)263, (unsigned short)254, (unsigned short)0, (unsigned short)0, (unsigned short)256, (unsigned short)255, (unsigned short)259, (unsigned short)168, (unsigned short)0, (unsigned short)162, (unsigned short)164, (unsigned short)166, (unsigned short)257, (unsigned short)0, (unsigned short)258, (unsigned short)0, (unsigned short)16, (unsigned short)60, (unsigned short)0, (unsigned short)20, (unsigned short)0, (unsigned short)445, (unsigned short)0, (unsigned short)476, (unsigned short)479, (unsigned short)480, (unsigned short)478, (unsigned short)477, (unsigned short)0, (unsigned short)0, (unsigned short)0, (unsigned short)319, (unsigned short)376, (unsigned short)214, (unsigned short)0, (unsigned short)326, (unsigned short)394, (unsigned short)11, (unsigned short)328, (unsigned short)0, (unsigned short)383, (unsigned short)0, (unsigned short)265, (unsigned short)294, (unsigned short)0, (unsigned short)323, (unsigned short)0, (unsigned short)382, (unsigned short)321, (unsigned short)320, (unsigned short)0, (unsigned short)266, (unsigned short)0, (unsigned short)272, (unsigned short)0, (unsigned short)0, (unsigned short)0, (unsigned short)343, (unsigned short)341, (unsigned short)0, (unsigned short)339, (unsigned short)0, (unsigned short)336, (unsigned short)132, (unsigned short)20, (unsigned short)419, (unsigned short)128, (unsigned short)130, (unsigned short)136, (unsigned short)134, (unsigned short)0, (unsigned short)0, (unsigned short)0, (unsigned short)214, (unsigned short)367, (unsigned short)0, (unsigned short)366, (unsigned short)182, (unsigned short)0, (unsigned short)172, (unsigned short)174, (unsigned short)176, (unsigned short)178, (unsigned short)180, (unsigned short)0, (unsigned short)0, (unsigned short)0, (unsigned short)0, (unsigned short)19, (unsigned short)0, (unsigned short)0, (unsigned short)121, (unsigned short)123, (unsigned short)127, (unsigned short)125, (unsigned short)418, (unsigned short)0, (unsigned short)0, (unsigned short)493, (unsigned short)0, (unsigned short)471, (unsigned short)58, (unsigned short)425, (unsigned short)424, (unsigned short)0, (unsigned short)138, (unsigned short)140, (unsigned short)142, (unsigned short)146, (unsigned short)144, (unsigned short)485, (unsigned short)45, (unsigned short)0, (unsigned short)490, (unsigned short)486, (unsigned short)496, (unsigned short)489, (unsigned short)0, (unsigned short)0, (unsigned short)473, (unsigned short)0, (unsigned short)42, (unsigned short)38, (unsigned short)47, (unsigned short)0, (unsigned short)46, (unsigned short)40, (unsigned short)0, (unsigned short)101, (unsigned short)100, (unsigned short)69, (unsigned short)70, (unsigned short)71, (unsigned short)73, (unsigned short)74, (unsigned short)76, (unsigned short)77, (unsigned short)82, (unsigned short)83, (unsigned short)81, (unsigned short)85, (unsigned short)86, (unsigned short)88, (unsigned short)90, (unsigned short)92, (unsigned short)94, (unsigned short)96, (unsigned short)0, (unsigned short)280, (unsigned short)286, (unsigned short)285, (unsigned short)363, (unsigned short)288, (unsigned short)287, (unsigned short)290, (unsigned short)406, (unsigned short)408, (unsigned short)354, (unsigned short)350, (unsigned short)349, (unsigned short)380, (unsigned short)378, (unsigned short)416, (unsigned short)213, (unsigned short)0, (unsigned short)0, (unsigned short)0, (unsigned short)210, (unsigned short)334, (unsigned short)333, (unsigned short)0, (unsigned short)0, (unsigned short)0, (unsigned short)0, (unsigned short)169, (unsigned short)163, (unsigned short)165, (unsigned short)167, (unsigned short)0, (unsigned short)274, (unsigned short)0, (unsigned short)15, (unsigned short)214, (unsigned short)0, (unsigned short)446, (unsigned short)0, (unsigned short)0, (unsigned short)0, (unsigned short)0, (unsigned short)0, (unsigned short)0, (unsigned short)0, (unsigned short)0, (unsigned short)0, (unsigned short)0, (unsigned short)0, (unsigned short)0, (unsigned short)448, (unsigned short)20, (unsigned short)0, (unsigned short)437, (unsigned short)0, (unsigned short)439, (unsigned short)428, (unsigned short)0, (unsigned short)0, (unsigned short)0, (unsigned short)429, (unsigned short)430, (unsigned short)431, (unsigned short)432, (unsigned short)433, (unsigned short)0, (unsigned short)295, (unsigned short)13, (unsigned short)330, (unsigned short)0, (unsigned short)396, (unsigned short)0, (unsigned short)0, (unsigned short)318, (unsigned short)0, (unsigned short)329, (unsigned short)0, (unsigned short)395, (unsigned short)384, (unsigned short)297, (unsigned short)385, (unsigned short)268, (unsigned short)264, (unsigned short)270, (unsigned short)0, (unsigned short)271, (unsigned short)0, (unsigned short)0, (unsigned short)0, (unsigned short)133, (unsigned short)129, (unsigned short)131, (unsigned short)137, (unsigned short)135, (unsigned short)420, (unsigned short)54, (unsigned short)356, (unsigned short)0, (unsigned short)0, (unsigned short)0, (unsigned short)370, (unsigned short)369, (unsigned short)0, (unsigned short)0, (unsigned short)368, (unsigned short)0, (unsigned short)0, (unsigned short)183, (unsigned short)173, (unsigned short)175, (unsigned short)177, (unsigned short)179, (unsigned short)181, (unsigned short)0, (unsigned short)0, (unsigned short)0, (unsigned short)0, (unsigned short)0, (unsigned short)56, (unsigned short)114, (unsigned short)67, (unsigned short)25, (unsigned short)475, (unsigned short)0, (unsigned short)0, (unsigned short)376, (unsigned short)139, (unsigned short)141, (unsigned short)143, (unsigned short)147, (unsigned short)145, (unsigned short)481, (unsigned short)482, (unsigned short)483, (unsigned short)0, (unsigned short)488, (unsigned short)494, (unsigned short)492, (unsigned short)497, (unsigned short)491, (unsigned short)470, (unsigned short)472, (unsigned short)39, (unsigned short)0, (unsigned short)37, (unsigned short)0, (unsigned short)281, (unsigned short)0, (unsigned short)212, (unsigned short)211, (unsigned short)0, (unsigned short)0, (unsigned short)0, (unsigned short)0, (unsigned short)0, (unsigned short)0, (unsigned short)312, (unsigned short)0, (unsigned short)0, (unsigned short)0, (unsigned short)0, (unsigned short)277, (unsigned short)276, (unsigned short)14, (unsigned short)0, (unsigned short)0, (unsigned short)0, (unsigned short)0, (unsigned short)0, (unsigned short)0, (unsigned short)0, (unsigned short)0, (unsigned short)461, (unsigned short)462, (unsigned short)463, (unsigned short)0, (unsigned short)0, (unsigned short)0, (unsigned short)449, (unsigned short)116, (unsigned short)376, (unsigned short)0, (unsigned short)186, (unsigned short)188, (unsigned short)438, (unsigned short)0, (unsigned short)441, (unsigned short)440, (unsigned short)447, (unsigned short)118, (unsigned short)469, (unsigned short)0, (unsigned short)397, (unsigned short)0, (unsigned short)327, (unsigned short)394, (unsigned short)0, (unsigned short)331, (unsigned short)398, (unsigned short)273, (unsigned short)269, (unsigned short)338, (unsigned short)337, (unsigned short)355, (unsigned short)357, (unsigned short)28, (unsigned short)371, (unsigned short)358, (unsigned short)0, (unsigned short)0, (unsigned short)0, (unsigned short)0, (unsigned short)0, (unsigned short)0, (unsigned short)30, (unsigned short)0, (unsigned short)0, (unsigned short)0, (unsigned short)474, (unsigned short)484, (unsigned short)487, (unsigned short)49, (unsigned short)48, (unsigned short)98, (unsigned short)208, (unsigned short)260, (unsigned short)261, (unsigned short)262, (unsigned short)170, (unsigned short)0, (unsigned short)0, (unsigned short)0, (unsigned short)0, (unsigned short)0, (unsigned short)302, (unsigned short)0, (unsigned short)0, (unsigned short)317, (unsigned short)0, (unsigned short)0, (unsigned short)436, (unsigned short)0, (unsigned short)0, (unsigned short)0, (unsigned short)0, (unsigned short)0, (unsigned short)0, (unsigned short)0, (unsigned short)460, (unsigned short)464, (unsigned short)0, (unsigned short)434, (unsigned short)0, (unsigned short)0, (unsigned short)117, (unsigned short)0, (unsigned short)468, (unsigned short)396, (unsigned short)0, (unsigned short)0, (unsigned short)395, (unsigned short)0, (unsigned short)359, (unsigned short)27, (unsigned short)184, (unsigned short)32, (unsigned short)0, (unsigned short)0, (unsigned short)29, (unsigned short)34, (unsigned short)0, (unsigned short)0, (unsigned short)310, (unsigned short)0, (unsigned short)311, (unsigned short)171, (unsigned short)0, (unsigned short)0, (unsigned short)0, (unsigned short)0, (unsigned short)0, (unsigned short)0, (unsigned short)307, (unsigned short)435, (unsigned short)0, (unsigned short)0, (unsigned short)457, (unsigned short)0, (unsigned short)0, (unsigned short)459, (unsigned short)0, (unsigned short)0, (unsigned short)0, (unsigned short)467, (unsigned short)0, (unsigned short)187, (unsigned short)0, (unsigned short)421, (unsigned short)189, (unsigned short)397, (unsigned short)398, (unsigned short)332, (unsigned short)185, (unsigned short)31, (unsigned short)33, (unsigned short)0, (unsigned short)0, (unsigned short)0, (unsigned short)300, (unsigned short)0, (unsigned short)301, (unsigned short)0, (unsigned short)315, (unsigned short)0, (unsigned short)316, (unsigned short)0, (unsigned short)0, (unsigned short)450, (unsigned short)452, (unsigned short)453, (unsigned short)0, (unsigned short)458, (unsigned short)0, (unsigned short)0, (unsigned short)119, (unsigned short)466, (unsigned short)426, (unsigned short)0, (unsigned short)308, (unsigned short)309, (unsigned short)0, (unsigned short)0, (unsigned short)0, (unsigned short)0, (unsigned short)0, (unsigned short)305, (unsigned short)0, (unsigned short)306, (unsigned short)0, (unsigned short)0, (unsigned short)455, (unsigned short)0, (unsigned short)0, (unsigned short)422, (unsigned short)298, (unsigned short)299, (unsigned short)313, (unsigned short)314, (unsigned short)0, (unsigned short)0, (unsigned short)451, (unsigned short)454, (unsigned short)456, (unsigned short)423, (unsigned short)427, (unsigned short)303, (unsigned short)304 }; static const yytype_int16 yydefgoto[] = { (short)(-1), (short)40, (short)41, (short)125, (short)43, (short)44, (short)203, (short)204, (short)205, (short)206, (short)126, (short)127, (short)128, (short)129, (short)456, (short)478, (short)130, (short)153, (short)132, (short)133, (short)134, (short)135, (short)136, (short)137, (short)138, (short)139, (short)140, (short)141, (short)142, (short)143, (short)144, (short)145, (short)247, (short)276, (short)553, (short)174, (short)687, (short)249, (short)419, (short)458, (short)209, (short)47, (short)362, (short)432, (short)682, (short)683, (short)48, (short)49, (short)50, (short)338, (short)339, (short)340, (short)51, (short)52, (short)53, (short)54, (short)435, (short)55, (short)56, (short)156, (short)157, (short)158, (short)159, (short)160, (short)57, (short)211, (short)212, (short)213, (short)214, (short)215, (short)388, (short)389, (short)58, (short)59, (short)101, (short)102, (short)84, (short)428, (short)166, (short)429, (short)167, (short)216, (short)217, (short)88, (short)218, (short)90, (short)392, (short)162, (short)219, (short)168, (short)169, (short)170, (short)192, (short)254, (short)424, (short)799, (short)464, (short)828, (short)556, (short)557, (short)558, (short)559, (short)560, (short)376, (short)561, (short)562, (short)563, (short)564, (short)565, (short)147, (short)566, (short)220, (short)148, (short)465, (short)222, (short)466, (short)467, (short)468, (short)469, (short)470, (short)471, (short)472, (short)61 }; static const yytype_int16 yypact[] = { (short)8594, (short)(-750), (short)(-750), (short)(-750), (short)(-750), (short)(-750), (short)(-750), (short)(-750), (short)(-750), (short)(-750), (short)(-750), (short)(-750), (short)(-750), (short)(-750), (short)(-750), (short)(-750), (short)(-750), (short)(-750), (short)(-750), (short)(-750), (short)(-750), (short)(-750), (short)(-750), (short)(-750), (short)31, (short)(-750), (short)(-750), (short)(-750), (short)(-750), (short)(-750), (short)(-750), (short)(-750), (short)(-750), (short)(-90), (short)(-58), (short)(-750), (short)(-750), (short)(-750), (short)(-750), (short)(-750), (short)(-750), (short)(-750), (short)(-750), (short)(-39), (short)(-750), (short)134, (short)7047, (short)(-750), (short)(-750), (short)(-750), (short)9, (short)(-750), (short)(-750), (short)(-750), (short)(-750), (short)(-750), (short)(-750), (short)565, (short)(-750), (short)(-750), (short)(-4), (short)123, (short)79, (short)35, (short)60, (short)6798, (short)57, (short)6077, (short)(-750), (short)(-750), (short)(-750), (short)(-750), (short)917, (short)7149, (short)6482, (short)784, (short)(-750), (short)160, (short)(-750), (short)15, (short)(-750), (short)(-750), (short)(-750), (short)(-750), (short)182, (short)(-750), (short)907, (short)191, (short)8031, (short)(-750), (short)(-750), (short)402, (short)149, (short)3428, (short)(-55), (short)(-750), (short)169, (short)37, (short)6798, (short)(-750), (short)151, (short)(-50), (short)(-750), (short)79, (short)79, (short)(-750), (short)(-750), (short)(-750), (short)6831, (short)6909, (short)6909, (short)8684, (short)6798, (short)(-750), (short)8684, (short)6798, (short)6942, (short)(-750), (short)6209, (short)(-750), (short)316, (short)(-750), (short)(-750), (short)(-750), (short)(-750), (short)204, (short)47, (short)(-750), (short)(-750), (short)486, (short)(-750), (short)1024, (short)6798, (short)(-750), (short)(-16), (short)86, (short)411, (short)6798, (short)251, (short)515, (short)228, (short)39, (short)225, (short)348, (short)2, (short)(-750), (short)266, (short)(-750), (short)(-750), (short)270, (short)32, (short)204, (short)25, (short)(-750), (short)411, (short)5958, (short)268, (short)(-750), (short)(-750), (short)(-750), (short)33, (short)(-750), (short)917, (short)(-750), (short)(-750), (short)817, (short)323, (short)695, (short)326, (short)368, (short)(-750), (short)(-750), (short)(-28), (short)(-750), (short)373, (short)784, (short)(-750), (short)215, (short)907, (short)705, (short)182, (short)191, (short)(-750), (short)402, (short)8126, (short)6515, (short)(-750), (short)(-750), (short)6593, (short)(-750), (short)341, (short)385, (short)(-33), (short)24, (short)182, (short)(-750), (short)324, (short)8774, (short)8316, (short)6428, (short)8684, (short)(-750), (short)(-750), (short)379, (short)379, (short)379, (short)413, (short)30, (short)340, (short)5732, (short)215, (short)3552, (short)(-750), (short)(-56), (short)(-750), (short)(-750), (short)191, (short)(-750), (short)(-750), (short)705, (short)369, (short)398, (short)(-750), (short)5374, (short)3676, (short)3800, (short)404, (short)410, (short)(-750), (short)6798, (short)79, (short)(-750), (short)237, (short)274, (short)6209, (short)(-750), (short)6626, (short)(-750), (short)(-750), (short)160, (short)7347, (short)8864, (short)7446, (short)8864, (short)6209, (short)(-750), (short)(-750), (short)(-750), (short)210, (short)7837, (short)(-750), (short)(-750), (short)(-750), (short)(-750), (short)442, (short)446, (short)2586, (short)2728, (short)79, (short)(-750), (short)(-750), (short)5166, (short)79, (short)6798, (short)(-750), (short)(-750), (short)(-750), (short)(-750), (short)(-750), (short)(-750), (short)(-750), (short)(-750), (short)(-750), (short)(-750), (short)(-750), (short)(-750), (short)5207, (short)(-750), (short)6798, (short)6798, (short)6798, (short)6798, (short)6798, (short)6798, (short)6798, (short)411, (short)6798, (short)6798, (short)(-750), (short)6798, (short)6798, (short)6798, (short)6798, (short)6798, (short)6798, (short)6798, (short)6798, (short)6798, (short)(-750), (short)(-750), (short)(-750), (short)6077, (short)7248, (short)321, (short)437, (short)365, (short)6077, (short)(-750), (short)(-750), (short)6077, (short)(-750), (short)(-750), (short)(-750), (short)(-750), (short)(-750), (short)8504, (short)(-750), (short)(-750), (short)705, (short)182, (short)(-750), (short)(-750), (short)456, (short)(-750), (short)109, (short)459, (short)(-750), (short)170, (short)467, (short)(-750), (short)(-750), (short)79, (short)(-750), (short)(-750), (short)(-750), (short)(-750), (short)(-750), (short)461, (short)477, (short)(-750), (short)487, (short)(-750), (short)(-750), (short)(-750), (short)(-750), (short)(-750), (short)(-750), (short)(-750), (short)(-750), (short)(-750), (short)(-750), (short)(-750), (short)(-750), (short)57, (short)(-750), (short)(-750), (short)483, (short)484, (short)(-750), (short)(-750), (short)(-750), (short)480, (short)5616, (short)(-750), (short)(-750), (short)(-750), (short)(-750), (short)858, (short)(-750), (short)8316, (short)(-750), (short)917, (short)6341, (short)219, (short)8410, (short)466, (short)4990, (short)(-750), (short)(-750), (short)(-750), (short)(-750), (short)(-750), (short)5207, (short)867, (short)6798, (short)(-750), (short)148, (short)215, (short)197, (short)(-750), (short)191, (short)(-750), (short)203, (short)705, (short)(-750), (short)24, (short)(-750), (short)(-750), (short)700, (short)(-750), (short)24, (short)(-750), (short)(-750), (short)(-750), (short)3924, (short)(-750), (short)4048, (short)(-750), (short)4172, (short)5374, (short)4296, (short)(-750), (short)(-750), (short)5374, (short)(-750), (short)5374, (short)(-750), (short)(-750), (short)30, (short)7837, (short)(-750), (short)(-750), (short)(-750), (short)(-750), (short)491, (short)7936, (short)6798, (short)136, (short)493, (short)498, (short)507, (short)500, (short)7644, (short)(-750), (short)(-750), (short)(-750), (short)(-750), (short)(-750), (short)6798, (short)503, (short)7743, (short)508, (short)(-750), (short)6798, (short)79, (short)(-750), (short)(-750), (short)(-750), (short)(-750), (short)(-750), (short)6798, (short)316, (short)(-750), (short)2870, (short)(-750), (short)593, (short)(-750), (short)(-750), (short)8316, (short)(-750), (short)(-750), (short)(-750), (short)(-750), (short)(-750), (short)(-750), (short)(-750), (short)379, (short)(-750), (short)(-750), (short)289, (short)(-750), (short)3012, (short)489, (short)(-750), (short)490, (short)(-750), (short)(-750), (short)(-750), (short)253, (short)(-750), (short)(-750), (short)429, (short)(-750), (short)(-750), (short)(-750), (short)(-750), (short)(-750), (short)(-16), (short)(-16), (short)86, (short)86, (short)411, (short)411, (short)411, (short)251, (short)251, (short)515, (short)228, (short)39, (short)225, (short)348, (short)(-22), (short)7545, (short)(-750), (short)(-750), (short)365, (short)(-750), (short)(-750), (short)(-750), (short)(-750), (short)(-750), (short)(-750), (short)(-750), (short)(-750), (short)(-750), (short)(-750), (short)(-750), (short)(-750), (short)6798, (short)516, (short)505, (short)(-750), (short)(-750), (short)(-750), (short)6798, (short)57, (short)6077, (short)(-17), (short)(-51), (short)(-750), (short)(-750), (short)(-750), (short)48, (short)(-750), (short)57, (short)(-750), (short)215, (short)520, (short)(-750), (short)6798, (short)510, (short)524, (short)525, (short)529, (short)5131, (short)530, (short)79, (short)512, (short)514, (short)5503, (short)79, (short)(-750), (short)97, (short)298, (short)(-750), (short)5845, (short)(-750), (short)(-750), (short)2160, (short)2302, (short)513, (short)(-750), (short)(-750), (short)(-750), (short)(-750), (short)(-750), (short)517, (short)(-750), (short)(-750), (short)(-750), (short)3154, (short)191, (short)24, (short)733, (short)(-750), (short)6798, (short)(-750), (short)24, (short)191, (short)(-750), (short)(-750), (short)(-750), (short)(-750), (short)(-750), (short)(-750), (short)4420, (short)(-750), (short)4544, (short)4668, (short)4792, (short)(-750), (short)(-750), (short)(-750), (short)(-750), (short)(-750), (short)(-750), (short)(-750), (short)(-750), (short)534, (short)537, (short)533, (short)493, (short)507, (short)8221, (short)6798, (short)493, (short)6077, (short)6798, (short)542, (short)(-750), (short)(-750), (short)(-750), (short)(-750), (short)(-750), (short)536, (short)538, (short)6798, (short)6798, (short)541, (short)(-750), (short)(-750), (short)(-750), (short)(-750), (short)(-750), (short)521, (short)5207, (short)79, (short)(-750), (short)(-750), (short)(-750), (short)(-750), (short)(-750), (short)(-750), (short)(-750), (short)(-750), (short)5207, (short)(-750), (short)(-750), (short)(-750), (short)289, (short)(-750), (short)(-750), (short)(-750), (short)(-750), (short)5207, (short)(-750), (short)6798, (short)(-750), (short)269, (short)(-750), (short)(-750), (short)546, (short)547, (short)36, (short)179, (short)379, (short)379, (short)(-750), (short)6077, (short)217, (short)285, (short)532, (short)(-750), (short)(-750), (short)(-750), (short)544, (short)5131, (short)6798, (short)6798, (short)6666, (short)614, (short)2022, (short)531, (short)(-750), (short)(-750), (short)(-750), (short)334, (short)535, (short)5131, (short)(-750), (short)(-750), (short)53, (short)343, (short)(-750), (short)806, (short)(-750), (short)2444, (short)(-750), (short)(-750), (short)(-750), (short)(-750), (short)(-750), (short)545, (short)191, (short)215, (short)(-750), (short)553, (short)705, (short)551, (short)191, (short)(-750), (short)(-750), (short)(-750), (short)(-750), (short)(-750), (short)(-750), (short)(-750), (short)493, (short)(-750), (short)558, (short)556, (short)262, (short)557, (short)6077, (short)6798, (short)(-750), (short)563, (short)566, (short)6798, (short)(-750), (short)(-750), (short)(-750), (short)(-750), (short)(-750), (short)(-750), (short)(-750), (short)(-750), (short)(-750), (short)(-750), (short)(-750), (short)(-23), (short)(-11), (short)292, (short)379, (short)379, (short)(-750), (short)379, (short)379, (short)(-750), (short)364, (short)5131, (short)(-750), (short)345, (short)383, (short)5131, (short)399, (short)574, (short)5131, (short)5430, (short)(-750), (short)(-750), (short)6798, (short)(-750), (short)3296, (short)784, (short)(-750), (short)5242, (short)(-750), (short)553, (short)24, (short)24, (short)553, (short)6798, (short)(-750), (short)(-750), (short)(-750), (short)(-750), (short)350, (short)569, (short)(-750), (short)(-750), (short)572, (short)379, (short)(-750), (short)379, (short)(-750), (short)(-750), (short)(-15), (short)5, (short)45, (short)18, (short)379, (short)379, (short)(-750), (short)(-750), (short)5131, (short)5131, (short)(-750), (short)5131, (short)6798, (short)(-750), (short)5131, (short)6758, (short)560, (short)(-750), (short)578, (short)(-750), (short)5242, (short)(-750), (short)(-750), (short)553, (short)553, (short)(-750), (short)(-750), (short)(-750), (short)(-750), (short)579, (short)580, (short)379, (short)(-750), (short)379, (short)(-750), (short)379, (short)(-750), (short)379, (short)(-750), (short)158, (short)63, (short)638, (short)(-750), (short)(-750), (short)419, (short)(-750), (short)5131, (short)420, (short)(-750), (short)(-750), (short)(-750), (short)(-18), (short)(-750), (short)(-750), (short)581, (short)582, (short)585, (short)587, (short)379, (short)(-750), (short)379, (short)(-750), (short)5131, (short)594, (short)(-750), (short)5131, (short)4848, (short)(-750), (short)(-750), (short)(-750), (short)(-750), (short)(-750), (short)591, (short)597, (short)(-750), (short)(-750), (short)(-750), (short)(-750), (short)(-750), (short)(-750), (short)(-750) }; static const yytype_int16 yypgoto[] = { (short)(-750), (short)82, (short)(-750), (short)664, (short)678, (short)400, (short)(-750), (short)(-750), (short)(-750), (short)(-750), (short)0, (short)(-750), (short)(-750), (short)1498, (short)(-255), (short)(-750), (short)(-750), (short)167, (short)(-750), (short)(-110), (short)288, (short)283, (short)(-41), (short)(-750), (short)284, (short)450, (short)448, (short)451, (short)454, (short)447, (short)(-750), (short)1349, (short)(-49), (short)(-750), (short)(-77), (short)1396, (short)(-366), (short)(-750), (short)(-750), (short)(-363), (short)449, (short)(-750), (short)(-750), (short)518, (short)(-750), (short)(-8), (short)1389, (short)930, (short)(-750), (short)(-750), (short)(-329), (short)(-750), (short)374, (short)(-750), (short)1038, (short)1434, (short)(-148), (short)1286, (short)(-160), (short)(-750), (short)186, (short)218, (short)464, (short)(-425), (short)(-182), (short)(-154), (short)358, (short)(-750), (short)(-750), (short)(-135), (short)(-750), (short)192, (short)(-136), (short)1313, (short)478, (short)559, (short)(-74), (short)(-398), (short)(-34), (short)(-219), (short)(-45), (short)305, (short)(-184), (short)(-750), (short)(-37), (short)(-71), (short)310, (short)(-750), (short)1065, (short)(-86), (short)(-750), (short)4, (short)(-750), (short)(-750), (short)539, (short)(-749), (short)(-374), (short)(-750), (short)760, (short)(-750), (short)(-750), (short)223, (short)(-750), (short)(-750), (short)431, (short)(-628), (short)(-750), (short)(-750), (short)(-750), (short)(-117), (short)(-750), (short)(-750), (short)212, (short)(-750), (short)(-750), (short)(-750), (short)306, (short)141, (short)319, (short)322, (short)(-750), (short)(-250), (short)(-750) }; static const yytype_int16 yytable[] = { (short)45, (short)86, (short)191, (short)255, (short)60, (short)180, (short)477, (short)474, (short)567, (short)89, (short)554, (short)521, (short)85, (short)555, (short)370, (short)367, (short)146, (short)194, (short)1, (short)296, (short)195, (short)482, (short)277, (short)439, (short)64, (short)391, (short)154, (short)1, (short)1, (short)601, (short)178, (short)65, (short)605, (short)1, (short)1, (short)1, (short)89, (short)366, (short)89, (short)1, (short)1, (short)248, (short)182, (short)748, (short)307, (short)71, (short)77, (short)772, (short)827, (short)365, (short)1, (short)1, (short)655, (short)656, (short)89, (short)808, (short)1, (short)96, (short)774, (short)2, (short)1, (short)368, (short)100, (short)66, (short)67, (short)2, (short)150, (short)152, (short)658, (short)404, (short)406, (short)408, (short)398, (short)165, (short)810, (short)176, (short)397, (short)71, (short)230, (short)176, (short)67, (short)366, (short)1, (short)366, (short)399, (short)2, (short)223, (short)814, (short)190, (short)330, (short)659, (short)176, (short)231, (short)207, (short)855, (short)331, (short)285, (short)227, (short)322, (short)316, (short)1, (short)654, (short)278, (short)100, (short)100, (short)368, (short)443, (short)368, (short)195, (short)319, (short)843, (short)239, (short)320, (short)256, (short)239, (short)812, (short)646, (short)279, (short)280, (short)773, (short)792, (short)304, (short)248, (short)99, (short)844, (short)657, (short)71, (short)809, (short)76, (short)264, (short)92, (short)775, (short)837, (short)72, (short)98, (short)68, (short)73, (short)1, (short)89, (short)297, (short)182, (short)74, (short)89, (short)69, (short)70, (short)175, (short)89, (short)811, (short)69, (short)70, (short)71, (short)1, (short)71, (short)308, (short)300, (short)239, (short)182, (short)248, (short)728, (short)248, (short)815, (short)309, (short)89, (short)1, (short)301, (short)71, (short)257, (short)248, (short)484, (short)485, (short)486, (short)257, (short)62, (short)394, (short)293, (short)176, (short)103, (short)176, (short)225, (short)176, (short)367, (short)711, (short)401, (short)176, (short)45, (short)535, (short)481, (short)813, (short)257, (short)660, (short)71, (short)650, (short)685, (short)176, (short)753, (short)555, (short)555, (short)361, (short)77, (short)373, (short)239, (short)104, (short)366, (short)624, (short)707, (short)838, (short)598, (short)71, (short)264, (short)386, (short)176, (short)207, (short)479, (short)614, (short)531, (short)449, (short)281, (short)282, (short)1, (short)176, (short)501, (short)618, (short)1, (short)207, (short)207, (short)207, (short)368, (short)483, (short)835, (short)180, (short)100, (short)194, (short)131, (short)732, (short)418, (short)678, (short)512, (short)76, (short)257, (short)71, (short)239, (short)431, (short)239, (short)431, (short)418, (short)491, (short)492, (short)320, (short)493, (short)444, (short)256, (short)720, (short)69, (short)70, (short)72, (short)585, (short)587, (short)425, (short)475, (short)588, (short)154, (short)589, (short)480, (short)286, (short)287, (short)154, (short)69, (short)70, (short)154, (short)397, (short)196, (short)397, (short)366, (short)397, (short)632, (short)235, (short)237, (short)238, (short)69, (short)70, (short)366, (short)89, (short)29, (short)245, (short)611, (short)131, (short)733, (short)734, (short)767, (short)570, (short)229, (short)76, (short)611, (short)(-376), (short)(-376), (short)248, (short)368, (short)514, (short)(-376), (short)729, (short)836, (short)418, (short)45, (short)184, (short)368, (short)221, (short)418, (short)309, (short)185, (short)152, (short)224, (short)256, (short)187, (short)35, (short)36, (short)45, (short)417, (short)188, (short)176, (short)510, (short)692, (short)107, (short)76, (short)555, (short)76, (short)573, (short)417, (short)332, (short)532, (short)(-376), (short)(-376), (short)516, (short)442, (short)72, (short)622, (short)89, (short)175, (short)574, (short)443, (short)599, (short)621, (short)575, (short)68, (short)1, (short)1, (short)256, (short)89, (short)258, (short)259, (short)260, (short)394, (short)87, (short)333, (short)523, (short)736, (short)737, (short)401, (short)292, (short)579, (short)735, (short)257, (short)294, (short)528, (short)581, (short)295, (short)230, (short)131, (short)533, (short)334, (short)77, (short)288, (short)289, (short)373, (short)71, (short)239, (short)643, (short)552, (short)413, (short)87, (short)414, (short)87, (short)644, (short)765, (short)176, (short)181, (short)595, (short)71, (short)176, (short)298, (short)722, (short)309, (short)725, (short)299, (short)176, (short)620, (short)176, (short)87, (short)443, (short)335, (short)336, (short)176, (short)131, (short)230, (short)131, (short)207, (short)1, (short)207, (short)306, (short)207, (short)207, (short)207, (short)131, (short)776, (short)207, (short)415, (short)207, (short)416, (short)635, (short)71, (short)239, (short)309, (short)283, (short)284, (short)221, (short)63, (short)45, (short)443, (short)738, (short)131, (short)636, (short)131, (short)319, (short)608, (short)781, (short)782, (short)221, (short)221, (short)221, (short)679, (short)72, (short)608, (short)648, (short)302, (short)131, (short)71, (short)312, (short)337, (short)74, (short)314, (short)46, (short)397, (short)76, (short)397, (short)397, (short)397, (short)264, (short)76, (short)95, (short)626, (short)69, (short)70, (short)261, (short)443, (short)(-415), (short)131, (short)262, (short)263, (short)785, (short)647, (short)(-415), (short)803, (short)754, (short)676, (short)443, (short)750, (short)651, (short)27, (short)28, (short)309, (short)382, (short)87, (short)29, (short)181, (short)755, (short)87, (short)154, (short)302, (short)503, (short)87, (short)1, (short)332, (short)74, (short)506, (short)258, (short)259, (short)260, (short)315, (short)226, (short)181, (short)182, (short)317, (short)590, (short)239, (short)795, (short)87, (short)786, (short)783, (short)329, (short)332, (short)402, (short)684, (short)443, (short)35, (short)36, (short)390, (short)333, (short)155, (short)709, (short)89, (short)504, (short)375, (short)788, (short)46, (short)73, (short)507, (short)653, (short)152, (short)443, (short)74, (short)290, (short)291, (short)334, (short)661, (short)333, (short)663, (short)579, (short)176, (short)46, (short)403, (short)131, (short)581, (short)840, (short)842, (short)131, (short)552, (short)409, (short)672, (short)443, (short)443, (short)334, (short)677, (short)410, (short)71, (short)380, (short)375, (short)681, (short)645, (short)443, (short)552, (short)552, (short)240, (short)335, (short)336, (short)242, (short)450, (short)154, (short)489, (short)490, (short)1, (short)487, (short)488, (short)451, (short)176, (short)176, (short)494, (short)495, (short)(-279), (short)176, (short)511, (short)335, (short)336, (short)232, (short)233, (short)517, (short)76, (short)207, (short)513, (short)207, (short)207, (short)207, (short)742, (short)743, (short)745, (short)2, (short)515, (short)723, (short)1, (short)360, (short)518, (short)526, (short)258, (short)259, (short)260, (short)45, (short)524, (short)525, (short)152, (short)261, (short)538, (short)519, (short)131, (short)262, (short)263, (short)596, (short)603, (short)520, (short)221, (short)154, (short)221, (short)606, (short)221, (short)221, (short)221, (short)87, (short)604, (short)221, (short)71, (short)221, (short)425, (short)616, (short)619, (short)641, (short)642, (short)46, (short)377, (short)378, (short)379, (short)381, (short)649, (short)27, (short)28, (short)360, (short)664, (short)360, (short)29, (short)667, (short)668, (short)369, (short)666, (short)374, (short)669, (short)671, (short)673, (short)71, (short)674, (short)689, (short)704, (short)690, (short)152, (short)705, (short)706, (short)713, (short)714, (short)719, (short)42, (short)715, (short)552, (short)718, (short)726, (short)727, (short)746, (short)749, (short)154, (short)739, (short)751, (short)35, (short)36, (short)87, (short)552, (short)188, (short)763, (short)71, (short)740, (short)764, (short)766, (short)131, (short)552, (short)757, (short)87, (short)762, (short)769, (short)131, (short)571, (short)770, (short)176, (short)789, (short)804, (short)176, (short)578, (short)805, (short)825, (short)105, (short)839, (short)1, (short)106, (short)107, (short)93, (short)798, (short)1, (short)684, (short)42, (short)131, (short)821, (short)152, (short)261, (short)824, (short)131, (short)89, (short)262, (short)263, (short)826, (short)829, (short)830, (short)845, (short)846, (short)131, (short)131, (short)847, (short)2, (short)848, (short)149, (short)151, (short)625, (short)856, (short)852, (short)94, (short)1, (short)42, (short)172, (short)857, (short)552, (short)497, (short)496, (short)500, (short)552, (short)498, (short)796, (short)552, (short)798, (short)499, (short)502, (short)46, (short)42, (short)522, (short)176, (short)502, (short)580, (short)151, (short)155, (short)176, (short)176, (short)440, (short)360, (short)390, (short)46, (short)695, (short)576, (short)95, (short)633, (short)27, (short)28, (short)111, (short)112, (short)508, (short)29, (short)42, (short)721, (short)638, (short)42, (short)27, (short)28, (short)686, (short)151, (short)441, (short)29, (short)552, (short)552, (short)1, (short)552, (short)412, (short)639, (short)552, (short)0, (short)640, (short)798, (short)0, (short)0, (short)221, (short)0, (short)221, (short)221, (short)221, (short)114, (short)115, (short)0, (short)35, (short)36, (short)27, (short)28, (short)0, (short)0, (short)131, (short)29, (short)0, (short)0, (short)35, (short)36, (short)313, (short)68, (short)42, (short)1, (short)236, (short)0, (short)552, (short)120, (short)0, (short)175, (short)0, (short)0, (short)0, (short)0, (short)0, (short)360, (short)131, (short)131, (short)131, (short)131, (short)0, (short)131, (short)552, (short)360, (short)181, (short)552, (short)35, (short)36, (short)131, (short)0, (short)0, (short)42, (short)324, (short)0, (short)72, (short)327, (short)131, (short)175, (short)0, (short)0, (short)0, (short)27, (short)28, (short)87, (short)1, (short)42, (short)29, (short)42, (short)0, (short)0, (short)0, (short)0, (short)0, (short)1, (short)384, (short)0, (short)42, (short)46, (short)151, (short)0, (short)693, (short)696, (short)0, (short)27, (short)28, (short)699, (short)0, (short)0, (short)29, (short)2, (short)151, (short)151, (short)151, (short)0, (short)(-376), (short)(-376), (short)0, (short)35, (short)36, (short)(-376), (short)634, (short)151, (short)0, (short)0, (short)0, (short)72, (short)0, (short)42, (short)175, (short)42, (short)131, (short)151, (short)0, (short)0, (short)131, (short)0, (short)42, (short)131, (short)131, (short)35, (short)36, (short)0, (short)0, (short)151, (short)151, (short)0, (short)131, (short)0, (short)0, (short)0, (short)(-376), (short)(-376), (short)0, (short)0, (short)0, (short)27, (short)28, (short)662, (short)69, (short)70, (short)29, (short)(-376), (short)(-376), (short)0, (short)27, (short)28, (short)(-376), (short)0, (short)756, (short)29, (short)0, (short)0, (short)0, (short)0, (short)0, (short)131, (short)131, (short)0, (short)131, (short)131, (short)0, (short)131, (short)131, (short)0, (short)18, (short)19, (short)0, (short)131, (short)151, (short)42, (short)0, (short)35, (short)36, (short)151, (short)0, (short)0, (short)151, (short)0, (short)155, (short)79, (short)35, (short)36, (short)42, (short)0, (short)27, (short)28, (short)0, (short)0, (short)72, (short)29, (short)97, (short)175, (short)568, (short)131, (short)27, (short)28, (short)0, (short)0, (short)0, (short)29, (short)0, (short)0, (short)758, (short)0, (short)0, (short)761, (short)79, (short)0, (short)177, (short)131, (short)0, (short)0, (short)131, (short)131, (short)0, (short)0, (short)0, (short)0, (short)0, (short)186, (short)35, (short)36, (short)0, (short)0, (short)193, (short)0, (short)210, (short)0, (short)0, (short)0, (short)35, (short)36, (short)0, (short)0, (short)0, (short)0, (short)42, (short)0, (short)72, (short)151, (short)0, (short)42, (short)0, (short)151, (short)0, (short)265, (short)266, (short)267, (short)268, (short)269, (short)270, (short)271, (short)272, (short)273, (short)274, (short)46, (short)0, (short)0, (short)155, (short)0, (short)0, (short)0, (short)87, (short)0, (short)0, (short)0, (short)0, (short)800, (short)801, (short)0, (short)0, (short)151, (short)0, (short)151, (short)0, (short)151, (short)151, (short)151, (short)0, (short)0, (short)151, (short)0, (short)151, (short)0, (short)0, (short)0, (short)42, (short)80, (short)303, (short)730, (short)731, (short)0, (short)42, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)186, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)177, (short)0, (short)155, (short)186, (short)193, (short)161, (short)91, (short)0, (short)193, (short)0, (short)0, (short)0, (short)151, (short)0, (short)0, (short)0, (short)0, (short)42, (short)0, (short)0, (short)0, (short)0, (short)0, (short)210, (short)177, (short)0, (short)0, (short)0, (short)0, (short)0, (short)151, (short)0, (short)163, (short)91, (short)387, (short)179, (short)210, (short)0, (short)0, (short)183, (short)0, (short)0, (short)0, (short)0, (short)400, (short)0, (short)0, (short)0, (short)210, (short)210, (short)210, (short)250, (short)0, (short)0, (short)0, (short)0, (short)0, (short)155, (short)275, (short)777, (short)778, (short)42, (short)779, (short)780, (short)0, (short)427, (short)0, (short)427, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)303, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)652, (short)151, (short)0, (short)0, (short)80, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)310, (short)0, (short)0, (short)806, (short)0, (short)807, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)816, (short)817, (short)0, (short)0, (short)0, (short)0, (short)0, (short)42, (short)305, (short)0, (short)151, (short)151, (short)0, (short)0, (short)0, (short)311, (short)0, (short)0, (short)0, (short)0, (short)303, (short)0, (short)151, (short)364, (short)0, (short)0, (short)0, (short)831, (short)179, (short)832, (short)318, (short)833, (short)0, (short)834, (short)0, (short)80, (short)193, (short)151, (short)0, (short)151, (short)151, (short)151, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)179, (short)0, (short)849, (short)42, (short)850, (short)0, (short)151, (short)0, (short)420, (short)0, (short)393, (short)395, (short)0, (short)0, (short)80, (short)434, (short)80, (short)434, (short)420, (short)0, (short)0, (short)0, (short)0, (short)445, (short)0, (short)0, (short)0, (short)0, (short)303, (short)0, (short)460, (short)460, (short)0, (short)534, (short)0, (short)210, (short)0, (short)0, (short)536, (short)0, (short)670, (short)430, (short)0, (short)430, (short)0, (short)0, (short)0, (short)0, (short)0, (short)177, (short)305, (short)0, (short)0, (short)0, (short)0, (short)688, (short)0, (short)0, (short)151, (short)577, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)82, (short)0, (short)210, (short)0, (short)210, (short)0, (short)210, (short)210, (short)210, (short)0, (short)0, (short)210, (short)0, (short)210, (short)0, (short)0, (short)0, (short)303, (short)151, (short)0, (short)0, (short)0, (short)0, (short)427, (short)0, (short)0, (short)0, (short)83, (short)0, (short)0, (short)427, (short)0, (short)0, (short)0, (short)0, (short)305, (short)505, (short)0, (short)427, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)151, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)387, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)530, (short)0, (short)0, (short)0, (short)252, (short)0, (short)0, (short)80, (short)0, (short)161, (short)250, (short)0, (short)80, (short)0, (short)460, (short)0, (short)0, (short)151, (short)0, (short)0, (short)0, (short)0, (short)0, (short)173, (short)0, (short)0, (short)741, (short)305, (short)0, (short)0, (short)0, (short)253, (short)303, (short)0, (short)0, (short)78, (short)163, (short)179, (short)752, (short)0, (short)0, (short)82, (short)0, (short)0, (short)0, (short)0, (short)688, (short)173, (short)179, (short)0, (short)0, (short)0, (short)572, (short)0, (short)0, (short)0, (short)0, (short)591, (short)0, (short)0, (short)0, (short)173, (short)0, (short)0, (short)173, (short)0, (short)0, (short)0, (short)83, (short)0, (short)610, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)610, (short)0, (short)81, (short)0, (short)0, (short)0, (short)305, (short)536, (short)0, (short)0, (short)0, (short)0, (short)430, (short)460, (short)602, (short)0, (short)228, (short)82, (short)628, (short)430, (short)0, (short)0, (short)784, (short)0, (short)0, (short)694, (short)787, (short)430, (short)0, (short)790, (short)241, (short)460, (short)0, (short)243, (short)0, (short)0, (short)0, (short)210, (short)0, (short)210, (short)210, (short)210, (short)422, (short)0, (short)83, (short)393, (short)0, (short)0, (short)82, (short)436, (short)82, (short)436, (short)422, (short)0, (short)0, (short)0, (short)173, (short)447, (short)0, (short)173, (short)0, (short)0, (short)80, (short)0, (short)462, (short)462, (short)78, (short)818, (short)819, (short)423, (short)820, (short)0, (short)0, (short)822, (short)251, (short)83, (short)437, (short)83, (short)437, (short)423, (short)0, (short)0, (short)0, (short)0, (short)448, (short)0, (short)0, (short)0, (short)0, (short)305, (short)0, (short)463, (short)463, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)173, (short)0, (short)0, (short)325, (short)0, (short)841, (short)328, (short)0, (short)363, (short)0, (short)0, (short)81, (short)0, (short)208, (short)0, (short)628, (short)0, (short)0, (short)460, (short)460, (short)78, (short)851, (short)0, (short)318, (short)853, (short)0, (short)0, (short)457, (short)457, (short)0, (short)460, (short)0, (short)0, (short)0, (short)0, (short)0, (short)186, (short)0, (short)0, (short)0, (short)0, (short)0, (short)179, (short)0, (short)0, (short)0, (short)0, (short)411, (short)0, (short)760, (short)0, (short)78, (short)433, (short)78, (short)433, (short)0, (short)0, (short)0, (short)0, (short)0, (short)697, (short)0, (short)0, (short)0, (short)0, (short)81, (short)0, (short)459, (short)459, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)82, (short)0, (short)0, (short)252, (short)0, (short)82, (short)0, (short)462, (short)0, (short)0, (short)0, (short)0, (short)0, (short)421, (short)0, (short)0, (short)0, (short)0, (short)0, (short)81, (short)0, (short)81, (short)0, (short)421, (short)0, (short)0, (short)0, (short)83, (short)446, (short)177, (short)253, (short)0, (short)83, (short)0, (short)463, (short)461, (short)461, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)593, (short)0, (short)0, (short)0, (short)208, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)612, (short)0, (short)0, (short)208, (short)208, (short)208, (short)460, (short)0, (short)612, (short)0, (short)0, (short)0, (short)0, (short)457, (short)594, (short)173, (short)0, (short)0, (short)0, (short)0, (short)0, (short)462, (short)0, (short)0, (short)0, (short)0, (short)630, (short)613, (short)0, (short)0, (short)0, (short)0, (short)0, (short)529, (short)0, (short)613, (short)455, (short)455, (short)0, (short)462, (short)78, (short)759, (short)0, (short)0, (short)0, (short)78, (short)0, (short)459, (short)463, (short)0, (short)0, (short)0, (short)0, (short)631, (short)0, (short)0, (short)0, (short)173, (short)0, (short)0, (short)0, (short)0, (short)569, (short)0, (short)0, (short)0, (short)463, (short)0, (short)0, (short)173, (short)82, (short)0, (short)0, (short)460, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)457, (short)81, (short)0, (short)0, (short)251, (short)0, (short)81, (short)0, (short)461, (short)0, (short)0, (short)0, (short)0, (short)83, (short)0, (short)0, (short)0, (short)179, (short)457, (short)609, (short)600, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)609, (short)0, (short)0, (short)0, (short)0, (short)615, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)630, (short)459, (short)0, (short)462, (short)462, (short)0, (short)627, (short)0, (short)0, (short)0, (short)0, (short)0, (short)592, (short)0, (short)0, (short)462, (short)0, (short)0, (short)0, (short)459, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)631, (short)0, (short)0, (short)463, (short)463, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)463, (short)0, (short)0, (short)0, (short)461, (short)173, (short)0, (short)0, (short)78, (short)629, (short)0, (short)0, (short)0, (short)208, (short)0, (short)0, (short)0, (short)0, (short)0, (short)208, (short)0, (short)208, (short)461, (short)208, (short)208, (short)208, (short)0, (short)0, (short)208, (short)0, (short)208, (short)0, (short)0, (short)0, (short)0, (short)0, (short)457, (short)0, (short)0, (short)0, (short)0, (short)173, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)665, (short)81, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)627, (short)0, (short)0, (short)459, (short)459, (short)0, (short)0, (short)455, (short)0, (short)173, (short)0, (short)0, (short)173, (short)0, (short)0, (short)459, (short)0, (short)0, (short)0, (short)0, (short)0, (short)173, (short)173, (short)0, (short)0, (short)455, (short)0, (short)698, (short)462, (short)0, (short)457, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)457, (short)0, (short)0, (short)0, (short)0, (short)629, (short)0, (short)0, (short)461, (short)461, (short)0, (short)724, (short)0, (short)0, (short)0, (short)463, (short)710, (short)0, (short)0, (short)712, (short)461, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)716, (short)717, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)105, (short)0, (short)1, (short)106, (short)107, (short)108, (short)0, (short)109, (short)110, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)462, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)2, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)173, (short)0, (short)0, (short)463, (short)173, (short)455, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)459, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)208, (short)0, (short)208, (short)208, (short)208, (short)0, (short)0, (short)0, (short)0, (short)0, (short)111, (short)112, (short)113, (short)0, (short)0, (short)0, (short)0, (short)173, (short)0, (short)457, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)768, (short)173, (short)0, (short)0, (short)771, (short)0, (short)0, (short)0, (short)0, (short)0, (short)461, (short)0, (short)0, (short)0, (short)114, (short)115, (short)0, (short)0, (short)0, (short)0, (short)0, (short)116, (short)0, (short)455, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)117, (short)0, (short)459, (short)118, (short)747, (short)119, (short)120, (short)793, (short)0, (short)0, (short)0, (short)121, (short)122, (short)123, (short)124, (short)0, (short)0, (short)0, (short)802, (short)0, (short)0, (short)105, (short)551, (short)1, (short)106, (short)107, (short)108, (short)0, (short)109, (short)110, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)461, (short)2, (short)3, (short)4, (short)5, (short)6, (short)7, (short)8, (short)9, (short)10, (short)11, (short)12, (short)13, (short)14, (short)15, (short)16, (short)17, (short)18, (short)19, (short)20, (short)21, (short)22, (short)23, (short)24, (short)0, (short)539, (short)540, (short)541, (short)542, (short)543, (short)544, (short)545, (short)546, (short)547, (short)548, (short)549, (short)0, (short)0, (short)0, (short)26, (short)0, (short)0, (short)0, (short)0, (short)111, (short)112, (short)113, (short)27, (short)28, (short)0, (short)550, (short)0, (short)29, (short)0, (short)0, (short)30, (short)31, (short)0, (short)32, (short)0, (short)33, (short)0, (short)0, (short)0, (short)455, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)34, (short)0, (short)114, (short)115, (short)0, (short)0, (short)0, (short)0, (short)0, (short)116, (short)35, (short)36, (short)37, (short)38, (short)0, (short)0, (short)0, (short)39, (short)117, (short)0, (short)0, (short)118, (short)0, (short)119, (short)120, (short)0, (short)0, (short)0, (short)0, (short)121, (short)122, (short)123, (short)124, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)551, (short)375, (short)(-443), (short)105, (short)0, (short)1, (short)106, (short)107, (short)108, (short)0, (short)109, (short)110, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)2, (short)3, (short)4, (short)5, (short)6, (short)7, (short)8, (short)9, (short)10, (short)11, (short)12, (short)13, (short)14, (short)15, (short)16, (short)17, (short)18, (short)19, (short)20, (short)21, (short)22, (short)23, (short)24, (short)0, (short)539, (short)540, (short)541, (short)542, (short)543, (short)544, (short)545, (short)546, (short)547, (short)548, (short)549, (short)0, (short)0, (short)0, (short)26, (short)0, (short)0, (short)0, (short)0, (short)111, (short)112, (short)113, (short)27, (short)28, (short)0, (short)550, (short)0, (short)29, (short)0, (short)0, (short)30, (short)31, (short)0, (short)32, (short)0, (short)33, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)34, (short)0, (short)114, (short)115, (short)0, (short)0, (short)0, (short)0, (short)0, (short)116, (short)35, (short)36, (short)37, (short)38, (short)0, (short)0, (short)0, (short)39, (short)117, (short)0, (short)0, (short)118, (short)0, (short)119, (short)120, (short)0, (short)0, (short)0, (short)0, (short)121, (short)122, (short)123, (short)124, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)551, (short)375, (short)(-442), (short)105, (short)0, (short)1, (short)106, (short)107, (short)108, (short)0, (short)109, (short)110, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)2, (short)3, (short)4, (short)5, (short)6, (short)7, (short)8, (short)9, (short)10, (short)11, (short)12, (short)13, (short)14, (short)15, (short)16, (short)17, (short)18, (short)19, (short)20, (short)21, (short)22, (short)23, (short)24, (short)0, (short)539, (short)540, (short)541, (short)542, (short)543, (short)544, (short)545, (short)546, (short)547, (short)548, (short)549, (short)0, (short)0, (short)0, (short)26, (short)0, (short)0, (short)0, (short)0, (short)111, (short)112, (short)113, (short)27, (short)28, (short)0, (short)550, (short)0, (short)29, (short)0, (short)0, (short)30, (short)31, (short)0, (short)32, (short)0, (short)33, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)34, (short)0, (short)114, (short)115, (short)0, (short)0, (short)0, (short)0, (short)0, (short)116, (short)35, (short)36, (short)37, (short)38, (short)0, (short)0, (short)0, (short)39, (short)117, (short)0, (short)0, (short)118, (short)0, (short)119, (short)120, (short)0, (short)0, (short)0, (short)0, (short)121, (short)122, (short)123, (short)124, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)551, (short)375, (short)(-444), (short)105, (short)0, (short)1, (short)106, (short)107, (short)108, (short)0, (short)109, (short)110, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)2, (short)3, (short)4, (short)5, (short)6, (short)7, (short)8, (short)9, (short)10, (short)11, (short)12, (short)13, (short)14, (short)15, (short)16, (short)17, (short)18, (short)19, (short)20, (short)21, (short)22, (short)23, (short)24, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)26, (short)0, (short)0, (short)0, (short)0, (short)111, (short)112, (short)113, (short)27, (short)28, (short)0, (short)0, (short)0, (short)29, (short)0, (short)0, (short)30, (short)31, (short)0, (short)32, (short)0, (short)33, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)34, (short)0, (short)114, (short)115, (short)0, (short)0, (short)0, (short)0, (short)0, (short)116, (short)35, (short)36, (short)37, (short)38, (short)0, (short)0, (short)0, (short)39, (short)117, (short)0, (short)0, (short)118, (short)0, (short)119, (short)120, (short)0, (short)0, (short)0, (short)0, (short)121, (short)122, (short)123, (short)124, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)452, (short)453, (short)454, (short)105, (short)0, (short)1, (short)106, (short)107, (short)108, (short)0, (short)109, (short)110, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)2, (short)3, (short)4, (short)5, (short)6, (short)7, (short)8, (short)9, (short)10, (short)11, (short)12, (short)13, (short)14, (short)15, (short)16, (short)17, (short)18, (short)19, (short)20, (short)21, (short)22, (short)23, (short)24, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)26, (short)0, (short)0, (short)0, (short)0, (short)111, (short)112, (short)113, (short)27, (short)28, (short)0, (short)0, (short)0, (short)29, (short)0, (short)0, (short)30, (short)31, (short)0, (short)32, (short)0, (short)33, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)34, (short)0, (short)114, (short)115, (short)0, (short)0, (short)0, (short)0, (short)0, (short)116, (short)35, (short)36, (short)37, (short)38, (short)0, (short)0, (short)0, (short)39, (short)117, (short)0, (short)0, (short)118, (short)0, (short)119, (short)120, (short)0, (short)0, (short)0, (short)0, (short)121, (short)122, (short)123, (short)124, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)452, (short)453, (short)473, (short)105, (short)0, (short)1, (short)106, (short)107, (short)108, (short)0, (short)109, (short)110, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)2, (short)3, (short)4, (short)5, (short)6, (short)7, (short)8, (short)9, (short)10, (short)11, (short)12, (short)13, (short)14, (short)15, (short)16, (short)17, (short)18, (short)19, (short)20, (short)21, (short)22, (short)23, (short)24, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)26, (short)0, (short)0, (short)0, (short)0, (short)111, (short)112, (short)113, (short)27, (short)28, (short)0, (short)0, (short)0, (short)29, (short)0, (short)0, (short)30, (short)31, (short)0, (short)32, (short)0, (short)33, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)34, (short)0, (short)114, (short)115, (short)0, (short)0, (short)0, (short)0, (short)0, (short)116, (short)35, (short)36, (short)37, (short)38, (short)0, (short)0, (short)0, (short)39, (short)117, (short)0, (short)0, (short)118, (short)0, (short)119, (short)120, (short)0, (short)0, (short)0, (short)0, (short)121, (short)122, (short)123, (short)124, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)452, (short)453, (short)623, (short)105, (short)0, (short)1, (short)106, (short)107, (short)108, (short)0, (short)109, (short)110, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)2, (short)3, (short)4, (short)5, (short)6, (short)7, (short)8, (short)9, (short)10, (short)11, (short)12, (short)13, (short)14, (short)15, (short)16, (short)17, (short)18, (short)19, (short)20, (short)21, (short)22, (short)23, (short)24, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)26, (short)0, (short)0, (short)0, (short)0, (short)111, (short)112, (short)113, (short)27, (short)28, (short)0, (short)0, (short)0, (short)29, (short)0, (short)0, (short)30, (short)31, (short)0, (short)32, (short)0, (short)33, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)34, (short)0, (short)114, (short)115, (short)0, (short)0, (short)0, (short)0, (short)0, (short)116, (short)35, (short)36, (short)37, (short)38, (short)0, (short)0, (short)0, (short)39, (short)117, (short)0, (short)0, (short)118, (short)0, (short)119, (short)120, (short)0, (short)0, (short)0, (short)0, (short)121, (short)122, (short)123, (short)124, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)637, (short)453, (short)(-495), (short)105, (short)0, (short)1, (short)106, (short)107, (short)108, (short)0, (short)109, (short)110, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)2, (short)3, (short)4, (short)5, (short)6, (short)7, (short)8, (short)9, (short)10, (short)11, (short)12, (short)13, (short)14, (short)15, (short)16, (short)17, (short)18, (short)19, (short)20, (short)21, (short)22, (short)23, (short)24, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)26, (short)0, (short)0, (short)0, (short)0, (short)111, (short)112, (short)113, (short)27, (short)28, (short)0, (short)0, (short)0, (short)29, (short)0, (short)0, (short)30, (short)31, (short)0, (short)32, (short)0, (short)33, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)34, (short)0, (short)114, (short)115, (short)0, (short)0, (short)0, (short)0, (short)0, (short)116, (short)35, (short)36, (short)37, (short)38, (short)0, (short)0, (short)0, (short)39, (short)117, (short)0, (short)0, (short)118, (short)0, (short)119, (short)120, (short)0, (short)0, (short)0, (short)0, (short)121, (short)122, (short)123, (short)124, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)452, (short)453, (short)691, (short)105, (short)0, (short)1, (short)106, (short)107, (short)108, (short)0, (short)109, (short)110, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)2, (short)3, (short)4, (short)5, (short)6, (short)7, (short)8, (short)9, (short)10, (short)11, (short)12, (short)13, (short)14, (short)15, (short)16, (short)17, (short)18, (short)19, (short)20, (short)21, (short)22, (short)23, (short)24, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)26, (short)0, (short)0, (short)0, (short)0, (short)111, (short)112, (short)113, (short)27, (short)28, (short)0, (short)0, (short)0, (short)29, (short)0, (short)0, (short)30, (short)31, (short)0, (short)32, (short)0, (short)33, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)34, (short)0, (short)114, (short)115, (short)0, (short)0, (short)0, (short)0, (short)0, (short)116, (short)35, (short)36, (short)37, (short)38, (short)0, (short)0, (short)0, (short)39, (short)117, (short)0, (short)0, (short)118, (short)0, (short)119, (short)120, (short)0, (short)0, (short)0, (short)0, (short)121, (short)122, (short)123, (short)124, (short)105, (short)0, (short)1, (short)106, (short)107, (short)0, (short)0, (short)452, (short)453, (short)794, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)2, (short)3, (short)4, (short)5, (short)6, (short)7, (short)8, (short)9, (short)10, (short)11, (short)12, (short)13, (short)14, (short)15, (short)16, (short)17, (short)18, (short)19, (short)20, (short)21, (short)22, (short)23, (short)24, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)26, (short)0, (short)197, (short)0, (short)0, (short)111, (short)112, (short)0, (short)27, (short)28, (short)0, (short)0, (short)198, (short)29, (short)0, (short)0, (short)30, (short)31, (short)0, (short)32, (short)0, (short)33, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)34, (short)0, (short)114, (short)115, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)35, (short)36, (short)37, (short)38, (short)0, (short)0, (short)0, (short)39, (short)72, (short)0, (short)0, (short)199, (short)0, (short)200, (short)120, (short)105, (short)0, (short)1, (short)106, (short)107, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)201, (short)0, (short)202, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)2, (short)3, (short)4, (short)5, (short)6, (short)7, (short)8, (short)9, (short)10, (short)11, (short)12, (short)13, (short)14, (short)15, (short)16, (short)17, (short)18, (short)19, (short)20, (short)21, (short)22, (short)23, (short)24, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)26, (short)0, (short)197, (short)0, (short)0, (short)111, (short)112, (short)0, (short)27, (short)28, (short)0, (short)0, (short)198, (short)29, (short)0, (short)0, (short)30, (short)31, (short)0, (short)32, (short)0, (short)33, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)34, (short)0, (short)114, (short)115, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)35, (short)36, (short)37, (short)38, (short)0, (short)0, (short)0, (short)39, (short)72, (short)0, (short)0, (short)199, (short)0, (short)200, (short)120, (short)105, (short)0, (short)1, (short)106, (short)107, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)201, (short)0, (short)396, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)2, (short)3, (short)4, (short)5, (short)6, (short)7, (short)8, (short)9, (short)10, (short)11, (short)12, (short)13, (short)14, (short)15, (short)16, (short)17, (short)18, (short)19, (short)20, (short)21, (short)22, (short)23, (short)24, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)26, (short)0, (short)197, (short)0, (short)0, (short)111, (short)112, (short)0, (short)27, (short)28, (short)0, (short)0, (short)198, (short)29, (short)0, (short)0, (short)30, (short)31, (short)0, (short)32, (short)0, (short)33, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)34, (short)0, (short)114, (short)115, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)35, (short)36, (short)37, (short)38, (short)0, (short)0, (short)0, (short)39, (short)72, (short)0, (short)0, (short)199, (short)0, (short)200, (short)120, (short)105, (short)0, (short)1, (short)106, (short)107, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)201, (short)0, (short)405, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)2, (short)3, (short)4, (short)5, (short)6, (short)7, (short)8, (short)9, (short)10, (short)11, (short)12, (short)13, (short)14, (short)15, (short)16, (short)17, (short)18, (short)19, (short)20, (short)21, (short)22, (short)23, (short)24, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)26, (short)0, (short)197, (short)0, (short)0, (short)111, (short)112, (short)0, (short)27, (short)28, (short)0, (short)0, (short)198, (short)29, (short)0, (short)0, (short)30, (short)31, (short)0, (short)32, (short)0, (short)33, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)34, (short)0, (short)114, (short)115, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)35, (short)36, (short)37, (short)38, (short)0, (short)0, (short)0, (short)39, (short)72, (short)0, (short)0, (short)199, (short)0, (short)200, (short)120, (short)105, (short)0, (short)1, (short)106, (short)107, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)201, (short)0, (short)407, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)2, (short)3, (short)4, (short)5, (short)6, (short)7, (short)8, (short)9, (short)10, (short)11, (short)12, (short)13, (short)14, (short)15, (short)16, (short)17, (short)18, (short)19, (short)20, (short)21, (short)22, (short)23, (short)24, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)26, (short)0, (short)197, (short)0, (short)0, (short)111, (short)112, (short)0, (short)27, (short)28, (short)0, (short)0, (short)198, (short)29, (short)0, (short)0, (short)30, (short)31, (short)0, (short)32, (short)0, (short)33, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)34, (short)0, (short)114, (short)115, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)35, (short)36, (short)37, (short)38, (short)0, (short)0, (short)0, (short)39, (short)72, (short)0, (short)0, (short)199, (short)0, (short)200, (short)120, (short)105, (short)0, (short)1, (short)106, (short)107, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)201, (short)0, (short)582, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)2, (short)3, (short)4, (short)5, (short)6, (short)7, (short)8, (short)9, (short)10, (short)11, (short)12, (short)13, (short)14, (short)15, (short)16, (short)17, (short)18, (short)19, (short)20, (short)21, (short)22, (short)23, (short)24, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)26, (short)0, (short)197, (short)0, (short)0, (short)111, (short)112, (short)0, (short)27, (short)28, (short)0, (short)0, (short)198, (short)29, (short)0, (short)0, (short)30, (short)31, (short)0, (short)32, (short)0, (short)33, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)34, (short)0, (short)114, (short)115, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)35, (short)36, (short)37, (short)38, (short)0, (short)0, (short)0, (short)39, (short)72, (short)0, (short)0, (short)199, (short)0, (short)200, (short)120, (short)105, (short)0, (short)1, (short)106, (short)107, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)201, (short)0, (short)583, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)2, (short)3, (short)4, (short)5, (short)6, (short)7, (short)8, (short)9, (short)10, (short)11, (short)12, (short)13, (short)14, (short)15, (short)16, (short)17, (short)18, (short)19, (short)20, (short)21, (short)22, (short)23, (short)24, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)26, (short)0, (short)197, (short)0, (short)0, (short)111, (short)112, (short)0, (short)27, (short)28, (short)0, (short)0, (short)198, (short)29, (short)0, (short)0, (short)30, (short)31, (short)0, (short)32, (short)0, (short)33, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)34, (short)0, (short)114, (short)115, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)35, (short)36, (short)37, (short)38, (short)0, (short)0, (short)0, (short)39, (short)72, (short)0, (short)0, (short)199, (short)0, (short)200, (short)120, (short)105, (short)0, (short)1, (short)106, (short)107, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)201, (short)0, (short)584, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)2, (short)3, (short)4, (short)5, (short)6, (short)7, (short)8, (short)9, (short)10, (short)11, (short)12, (short)13, (short)14, (short)15, (short)16, (short)17, (short)18, (short)19, (short)20, (short)21, (short)22, (short)23, (short)24, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)26, (short)0, (short)197, (short)0, (short)0, (short)111, (short)112, (short)0, (short)27, (short)28, (short)0, (short)0, (short)198, (short)29, (short)0, (short)0, (short)30, (short)31, (short)0, (short)32, (short)0, (short)33, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)34, (short)0, (short)114, (short)115, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)35, (short)36, (short)37, (short)38, (short)0, (short)0, (short)0, (short)39, (short)72, (short)0, (short)0, (short)199, (short)0, (short)200, (short)120, (short)105, (short)0, (short)1, (short)106, (short)107, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)201, (short)0, (short)586, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)2, (short)3, (short)4, (short)5, (short)6, (short)7, (short)8, (short)9, (short)10, (short)11, (short)12, (short)13, (short)14, (short)15, (short)16, (short)17, (short)18, (short)19, (short)20, (short)21, (short)22, (short)23, (short)24, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)26, (short)0, (short)197, (short)0, (short)0, (short)111, (short)112, (short)0, (short)27, (short)28, (short)0, (short)0, (short)198, (short)29, (short)0, (short)0, (short)30, (short)31, (short)0, (short)32, (short)0, (short)33, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)34, (short)0, (short)114, (short)115, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)35, (short)36, (short)37, (short)38, (short)0, (short)0, (short)0, (short)39, (short)72, (short)0, (short)0, (short)199, (short)0, (short)200, (short)120, (short)105, (short)0, (short)1, (short)106, (short)107, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)201, (short)0, (short)700, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)2, (short)3, (short)4, (short)5, (short)6, (short)7, (short)8, (short)9, (short)10, (short)11, (short)12, (short)13, (short)14, (short)15, (short)16, (short)17, (short)18, (short)19, (short)20, (short)21, (short)22, (short)23, (short)24, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)26, (short)0, (short)197, (short)0, (short)0, (short)111, (short)112, (short)0, (short)27, (short)28, (short)0, (short)0, (short)198, (short)29, (short)0, (short)0, (short)30, (short)31, (short)0, (short)32, (short)0, (short)33, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)34, (short)0, (short)114, (short)115, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)35, (short)36, (short)37, (short)38, (short)0, (short)0, (short)0, (short)39, (short)72, (short)0, (short)0, (short)199, (short)0, (short)200, (short)120, (short)105, (short)0, (short)1, (short)106, (short)107, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)201, (short)0, (short)701, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)2, (short)3, (short)4, (short)5, (short)6, (short)7, (short)8, (short)9, (short)10, (short)11, (short)12, (short)13, (short)14, (short)15, (short)16, (short)17, (short)18, (short)19, (short)20, (short)21, (short)22, (short)23, (short)24, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)26, (short)0, (short)197, (short)0, (short)0, (short)111, (short)112, (short)0, (short)27, (short)28, (short)0, (short)0, (short)198, (short)29, (short)0, (short)0, (short)30, (short)31, (short)0, (short)32, (short)0, (short)33, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)34, (short)0, (short)114, (short)115, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)35, (short)36, (short)37, (short)38, (short)0, (short)0, (short)0, (short)39, (short)72, (short)0, (short)0, (short)199, (short)0, (short)200, (short)120, (short)105, (short)0, (short)1, (short)106, (short)107, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)201, (short)0, (short)702, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)2, (short)3, (short)4, (short)5, (short)6, (short)7, (short)8, (short)9, (short)10, (short)11, (short)12, (short)13, (short)14, (short)15, (short)16, (short)17, (short)18, (short)19, (short)20, (short)21, (short)22, (short)23, (short)24, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)105, (short)0, (short)1, (short)106, (short)107, (short)108, (short)0, (short)109, (short)110, (short)26, (short)0, (short)197, (short)0, (short)0, (short)111, (short)112, (short)0, (short)27, (short)28, (short)0, (short)0, (short)198, (short)29, (short)0, (short)0, (short)30, (short)31, (short)2, (short)32, (short)0, (short)33, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)34, (short)0, (short)114, (short)115, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)35, (short)36, (short)37, (short)38, (short)0, (short)0, (short)0, (short)39, (short)72, (short)0, (short)0, (short)199, (short)0, (short)200, (short)120, (short)0, (short)0, (short)111, (short)112, (short)113, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)201, (short)0, (short)703, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)114, (short)115, (short)0, (short)0, (short)0, (short)0, (short)0, (short)116, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)117, (short)0, (short)0, (short)118, (short)0, (short)119, (short)120, (short)0, (short)0, (short)0, (short)0, (short)121, (short)122, (short)123, (short)124, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)797, (short)854, (short)105, (short)0, (short)1, (short)106, (short)107, (short)108, (short)0, (short)109, (short)110, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)2, (short)3, (short)4, (short)5, (short)6, (short)7, (short)8, (short)9, (short)10, (short)11, (short)12, (short)13, (short)14, (short)15, (short)16, (short)17, (short)18, (short)19, (short)20, (short)21, (short)22, (short)23, (short)24, (short)0, (short)539, (short)540, (short)541, (short)542, (short)543, (short)544, (short)545, (short)546, (short)547, (short)548, (short)549, (short)0, (short)0, (short)0, (short)26, (short)0, (short)0, (short)0, (short)0, (short)111, (short)112, (short)113, (short)27, (short)28, (short)0, (short)550, (short)0, (short)29, (short)0, (short)0, (short)30, (short)31, (short)0, (short)32, (short)0, (short)33, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)34, (short)0, (short)114, (short)115, (short)0, (short)0, (short)0, (short)0, (short)0, (short)116, (short)35, (short)36, (short)37, (short)38, (short)0, (short)0, (short)0, (short)39, (short)117, (short)0, (short)0, (short)118, (short)0, (short)119, (short)120, (short)0, (short)0, (short)0, (short)0, (short)121, (short)122, (short)123, (short)124, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)551, (short)375, (short)105, (short)0, (short)1, (short)106, (short)107, (short)108, (short)0, (short)109, (short)110, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)2, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)105, (short)0, (short)1, (short)106, (short)107, (short)108, (short)0, (short)109, (short)110, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)539, (short)540, (short)541, (short)542, (short)543, (short)544, (short)545, (short)546, (short)547, (short)548, (short)549, (short)2, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)111, (short)112, (short)113, (short)0, (short)0, (short)0, (short)105, (short)0, (short)1, (short)106, (short)107, (short)108, (short)0, (short)109, (short)110, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)114, (short)115, (short)2, (short)0, (short)111, (short)112, (short)113, (short)116, (short)0, (short)0, (short)105, (short)0, (short)1, (short)106, (short)107, (short)108, (short)117, (short)109, (short)110, (short)118, (short)0, (short)119, (short)120, (short)0, (short)0, (short)0, (short)0, (short)121, (short)122, (short)123, (short)124, (short)0, (short)0, (short)0, (short)0, (short)114, (short)115, (short)2, (short)551, (short)375, (short)0, (short)0, (short)116, (short)0, (short)0, (short)111, (short)112, (short)113, (short)0, (short)0, (short)0, (short)117, (short)0, (short)0, (short)118, (short)476, (short)119, (short)120, (short)0, (short)0, (short)0, (short)0, (short)121, (short)122, (short)123, (short)124, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)453, (short)0, (short)114, (short)115, (short)0, (short)0, (short)111, (short)112, (short)113, (short)116, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)117, (short)0, (short)0, (short)118, (short)0, (short)119, (short)120, (short)0, (short)0, (short)0, (short)0, (short)121, (short)122, (short)123, (short)124, (short)0, (short)0, (short)0, (short)0, (short)114, (short)115, (short)0, (short)0, (short)453, (short)0, (short)0, (short)116, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)117, (short)0, (short)0, (short)118, (short)0, (short)119, (short)120, (short)0, (short)0, (short)0, (short)0, (short)121, (short)122, (short)123, (short)124, (short)105, (short)0, (short)1, (short)106, (short)107, (short)0, (short)0, (short)0, (short)797, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)2, (short)3, (short)4, (short)5, (short)6, (short)7, (short)8, (short)9, (short)10, (short)11, (short)12, (short)13, (short)14, (short)15, (short)16, (short)17, (short)18, (short)19, (short)20, (short)21, (short)22, (short)23, (short)24, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)105, (short)0, (short)1, (short)106, (short)107, (short)108, (short)0, (short)109, (short)110, (short)26, (short)0, (short)197, (short)0, (short)0, (short)111, (short)112, (short)0, (short)27, (short)28, (short)0, (short)0, (short)198, (short)29, (short)0, (short)0, (short)30, (short)31, (short)2, (short)32, (short)0, (short)33, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)34, (short)0, (short)114, (short)115, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)35, (short)36, (short)37, (short)38, (short)0, (short)0, (short)0, (short)39, (short)72, (short)0, (short)0, (short)199, (short)0, (short)200, (short)120, (short)0, (short)0, (short)111, (short)112, (short)113, (short)105, (short)0, (short)1, (short)106, (short)107, (short)108, (short)0, (short)109, (short)110, (short)0, (short)201, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)2, (short)114, (short)115, (short)0, (short)0, (short)0, (short)0, (short)0, (short)116, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)117, (short)0, (short)0, (short)118, (short)791, (short)119, (short)120, (short)0, (short)0, (short)0, (short)0, (short)121, (short)122, (short)123, (short)124, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)551, (short)0, (short)0, (short)0, (short)111, (short)112, (short)113, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)114, (short)115, (short)0, (short)0, (short)0, (short)0, (short)0, (short)116, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)1, (short)0, (short)117, (short)0, (short)0, (short)118, (short)0, (short)119, (short)120, (short)0, (short)0, (short)0, (short)0, (short)121, (short)122, (short)123, (short)124, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)675, (short)2, (short)3, (short)4, (short)5, (short)6, (short)7, (short)341, (short)342, (short)343, (short)344, (short)345, (short)346, (short)347, (short)348, (short)349, (short)350, (short)18, (short)19, (short)351, (short)352, (short)22, (short)23, (short)353, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)354, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)27, (short)28, (short)0, (short)0, (short)0, (short)29, (short)0, (short)0, (short)0, (short)0, (short)0, (short)355, (short)0, (short)356, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)357, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)35, (short)36, (short)358, (short)359, (short)0, (short)0, (short)0, (short)39, (short)72, (short)1, (short)0, (short)302, (short)0, (short)0, (short)0, (short)0, (short)74, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)527, (short)0, (short)0, (short)2, (short)3, (short)4, (short)5, (short)6, (short)7, (short)8, (short)9, (short)10, (short)11, (short)12, (short)13, (short)14, (short)15, (short)16, (short)17, (short)18, (short)19, (short)20, (short)21, (short)22, (short)23, (short)24, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)26, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)27, (short)28, (short)0, (short)0, (short)0, (short)29, (short)0, (short)0, (short)30, (short)31, (short)0, (short)32, (short)0, (short)33, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)34, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)35, (short)36, (short)37, (short)38, (short)0, (short)0, (short)1, (short)39, (short)72, (short)0, (short)0, (short)383, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)384, (short)0, (short)385, (short)2, (short)3, (short)4, (short)5, (short)6, (short)7, (short)8, (short)9, (short)10, (short)11, (short)12, (short)13, (short)14, (short)15, (short)16, (short)17, (short)18, (short)19, (short)20, (short)21, (short)22, (short)23, (short)24, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)26, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)27, (short)28, (short)0, (short)0, (short)0, (short)29, (short)0, (short)0, (short)30, (short)31, (short)0, (short)32, (short)0, (short)33, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)34, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)35, (short)36, (short)37, (short)38, (short)0, (short)0, (short)1, (short)39, (short)72, (short)0, (short)0, (short)175, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)680, (short)2, (short)3, (short)4, (short)5, (short)6, (short)7, (short)8, (short)9, (short)10, (short)11, (short)12, (short)13, (short)14, (short)15, (short)16, (short)17, (short)18, (short)19, (short)20, (short)21, (short)22, (short)23, (short)24, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)26, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)27, (short)28, (short)0, (short)0, (short)0, (short)29, (short)0, (short)0, (short)30, (short)31, (short)0, (short)32, (short)0, (short)33, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)34, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)35, (short)36, (short)37, (short)38, (short)0, (short)0, (short)0, (short)39, (short)72, (short)0, (short)105, (short)302, (short)1, (short)106, (short)107, (short)108, (short)74, (short)109, (short)110, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)(-278), (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)2, (short)3, (short)4, (short)5, (short)6, (short)7, (short)8, (short)9, (short)10, (short)11, (short)12, (short)13, (short)14, (short)15, (short)16, (short)17, (short)18, (short)19, (short)20, (short)21, (short)22, (short)23, (short)24, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)26, (short)0, (short)0, (short)0, (short)0, (short)111, (short)112, (short)113, (short)27, (short)28, (short)0, (short)0, (short)0, (short)29, (short)0, (short)0, (short)30, (short)31, (short)0, (short)32, (short)0, (short)33, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)34, (short)0, (short)114, (short)115, (short)0, (short)0, (short)0, (short)0, (short)0, (short)116, (short)35, (short)36, (short)37, (short)38, (short)0, (short)0, (short)0, (short)39, (short)117, (short)0, (short)0, (short)118, (short)0, (short)119, (short)120, (short)0, (short)0, (short)0, (short)0, (short)121, (short)122, (short)123, (short)124, (short)105, (short)0, (short)1, (short)106, (short)107, (short)108, (short)0, (short)109, (short)110, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)2, (short)0, (short)0, (short)0, (short)0, (short)0, (short)8, (short)9, (short)10, (short)11, (short)12, (short)13, (short)14, (short)15, (short)16, (short)17, (short)18, (short)19, (short)20, (short)21, (short)22, (short)23, (short)24, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)26, (short)0, (short)0, (short)0, (short)0, (short)111, (short)112, (short)113, (short)27, (short)28, (short)0, (short)0, (short)0, (short)29, (short)0, (short)0, (short)30, (short)31, (short)0, (short)32, (short)0, (short)33, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)34, (short)0, (short)114, (short)115, (short)0, (short)0, (short)0, (short)0, (short)0, (short)116, (short)35, (short)36, (short)37, (short)38, (short)0, (short)0, (short)0, (short)0, (short)117, (short)0, (short)0, (short)118, (short)246, (short)119, (short)120, (short)0, (short)0, (short)0, (short)0, (short)121, (short)122, (short)123, (short)124, (short)105, (short)0, (short)1, (short)106, (short)107, (short)108, (short)0, (short)109, (short)110, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)2, (short)0, (short)0, (short)0, (short)0, (short)0, (short)8, (short)9, (short)10, (short)11, (short)12, (short)13, (short)14, (short)15, (short)16, (short)17, (short)18, (short)19, (short)20, (short)21, (short)22, (short)23, (short)24, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)26, (short)0, (short)0, (short)0, (short)0, (short)111, (short)112, (short)113, (short)27, (short)28, (short)0, (short)0, (short)0, (short)29, (short)0, (short)0, (short)30, (short)31, (short)0, (short)32, (short)0, (short)33, (short)105, (short)0, (short)1, (short)106, (short)107, (short)108, (short)0, (short)109, (short)110, (short)0, (short)0, (short)0, (short)34, (short)0, (short)114, (short)115, (short)0, (short)0, (short)0, (short)0, (short)0, (short)116, (short)35, (short)36, (short)37, (short)38, (short)0, (short)2, (short)0, (short)0, (short)371, (short)0, (short)0, (short)372, (short)246, (short)119, (short)120, (short)0, (short)0, (short)0, (short)0, (short)121, (short)122, (short)123, (short)124, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)105, (short)0, (short)1, (short)106, (short)107, (short)108, (short)0, (short)109, (short)110, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)111, (short)112, (short)113, (short)27, (short)28, (short)0, (short)0, (short)0, (short)29, (short)0, (short)0, (short)2, (short)0, (short)0, (short)0, (short)0, (short)0, (short)105, (short)0, (short)1, (short)106, (short)107, (short)108, (short)0, (short)109, (short)110, (short)0, (short)0, (short)0, (short)0, (short)0, (short)114, (short)115, (short)0, (short)0, (short)0, (short)0, (short)0, (short)116, (short)35, (short)36, (short)0, (short)0, (short)0, (short)2, (short)0, (short)0, (short)371, (short)0, (short)0, (short)372, (short)246, (short)119, (short)120, (short)111, (short)112, (short)113, (short)0, (short)121, (short)122, (short)123, (short)124, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)114, (short)115, (short)111, (short)112, (short)113, (short)0, (short)0, (short)116, (short)0, (short)0, (short)105, (short)0, (short)1, (short)106, (short)107, (short)108, (short)117, (short)109, (short)110, (short)118, (short)0, (short)119, (short)120, (short)0, (short)0, (short)171, (short)0, (short)121, (short)122, (short)123, (short)124, (short)0, (short)0, (short)114, (short)115, (short)0, (short)0, (short)2, (short)0, (short)0, (short)116, (short)0, (short)0, (short)105, (short)0, (short)1, (short)106, (short)107, (short)108, (short)117, (short)109, (short)110, (short)118, (short)0, (short)119, (short)120, (short)0, (short)0, (short)323, (short)0, (short)121, (short)122, (short)123, (short)124, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)2, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)111, (short)112, (short)113, (short)105, (short)0, (short)1, (short)106, (short)107, (short)108, (short)0, (short)109, (short)110, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)2, (short)114, (short)115, (short)111, (short)112, (short)113, (short)0, (short)0, (short)116, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)117, (short)0, (short)0, (short)118, (short)0, (short)119, (short)120, (short)0, (short)0, (short)326, (short)0, (short)121, (short)122, (short)123, (short)124, (short)0, (short)0, (short)114, (short)115, (short)0, (short)0, (short)0, (short)0, (short)0, (short)116, (short)0, (short)111, (short)112, (short)113, (short)0, (short)0, (short)0, (short)0, (short)117, (short)0, (short)0, (short)118, (short)246, (short)119, (short)120, (short)0, (short)0, (short)0, (short)0, (short)121, (short)122, (short)123, (short)124, (short)105, (short)0, (short)1, (short)106, (short)107, (short)108, (short)0, (short)109, (short)110, (short)114, (short)115, (short)0, (short)0, (short)0, (short)0, (short)0, (short)116, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)117, (short)0, (short)2, (short)118, (short)744, (short)119, (short)120, (short)0, (short)0, (short)0, (short)0, (short)121, (short)122, (short)123, (short)124, (short)105, (short)0, (short)1, (short)106, (short)107, (short)108, (short)0, (short)109, (short)110, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)2, (short)0, (short)0, (short)111, (short)112, (short)113, (short)105, (short)0, (short)1, (short)106, (short)107, (short)108, (short)0, (short)109, (short)110, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)2, (short)114, (short)115, (short)0, (short)0, (short)0, (short)0, (short)0, (short)116, (short)0, (short)111, (short)112, (short)113, (short)0, (short)0, (short)0, (short)0, (short)117, (short)0, (short)0, (short)118, (short)823, (short)119, (short)120, (short)0, (short)0, (short)0, (short)0, (short)121, (short)122, (short)123, (short)124, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)114, (short)115, (short)111, (short)112, (short)113, (short)0, (short)0, (short)116, (short)0, (short)0, (short)105, (short)0, (short)1, (short)106, (short)107, (short)108, (short)117, (short)109, (short)110, (short)118, (short)0, (short)119, (short)120, (short)0, (short)0, (short)0, (short)0, (short)121, (short)122, (short)123, (short)124, (short)0, (short)0, (short)114, (short)115, (short)0, (short)0, (short)2, (short)0, (short)0, (short)116, (short)0, (short)0, (short)105, (short)0, (short)1, (short)106, (short)107, (short)108, (short)117, (short)109, (short)110, (short)234, (short)0, (short)119, (short)120, (short)0, (short)0, (short)0, (short)0, (short)121, (short)122, (short)123, (short)124, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)2, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)111, (short)112, (short)113, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)114, (short)115, (short)111, (short)112, (short)113, (short)0, (short)0, (short)116, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)117, (short)0, (short)0, (short)236, (short)0, (short)119, (short)120, (short)0, (short)0, (short)0, (short)0, (short)121, (short)122, (short)123, (short)124, (short)0, (short)0, (short)114, (short)115, (short)0, (short)0, (short)0, (short)0, (short)1, (short)116, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)117, (short)0, (short)0, (short)244, (short)0, (short)119, (short)120, (short)0, (short)0, (short)0, (short)0, (short)121, (short)122, (short)123, (short)124, (short)2, (short)3, (short)4, (short)5, (short)6, (short)7, (short)8, (short)9, (short)10, (short)11, (short)12, (short)13, (short)14, (short)15, (short)16, (short)17, (short)18, (short)19, (short)20, (short)21, (short)22, (short)23, (short)24, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)26, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)27, (short)28, (short)0, (short)0, (short)0, (short)29, (short)0, (short)0, (short)30, (short)31, (short)0, (short)32, (short)0, (short)33, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)34, (short)0, (short)0, (short)0, (short)0, (short)1, (short)0, (short)0, (short)0, (short)0, (short)35, (short)36, (short)37, (short)38, (short)0, (short)0, (short)0, (short)39, (short)72, (short)0, (short)0, (short)73, (short)0, (short)0, (short)0, (short)0, (short)74, (short)0, (short)0, (short)75, (short)2, (short)3, (short)4, (short)5, (short)6, (short)7, (short)8, (short)9, (short)10, (short)11, (short)12, (short)13, (short)14, (short)15, (short)16, (short)17, (short)18, (short)19, (short)20, (short)21, (short)22, (short)23, (short)24, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)25, (short)26, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)27, (short)28, (short)0, (short)0, (short)0, (short)29, (short)0, (short)0, (short)30, (short)31, (short)0, (short)32, (short)0, (short)33, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)34, (short)0, (short)1, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)35, (short)36, (short)37, (short)38, (short)0, (short)0, (short)0, (short)39, (short)72, (short)0, (short)0, (short)73, (short)164, (short)0, (short)0, (short)0, (short)74, (short)2, (short)3, (short)4, (short)5, (short)6, (short)7, (short)8, (short)9, (short)10, (short)11, (short)12, (short)13, (short)14, (short)15, (short)16, (short)17, (short)18, (short)19, (short)20, (short)21, (short)22, (short)23, (short)24, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)25, (short)26, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)27, (short)28, (short)0, (short)0, (short)0, (short)29, (short)0, (short)0, (short)30, (short)31, (short)0, (short)32, (short)0, (short)33, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)34, (short)0, (short)1, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)35, (short)36, (short)37, (short)38, (short)0, (short)0, (short)0, (short)39, (short)72, (short)0, (short)0, (short)302, (short)164, (short)0, (short)0, (short)0, (short)74, (short)2, (short)3, (short)4, (short)5, (short)6, (short)7, (short)8, (short)9, (short)10, (short)11, (short)12, (short)13, (short)14, (short)15, (short)16, (short)17, (short)18, (short)19, (short)20, (short)21, (short)22, (short)23, (short)24, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)26, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)27, (short)28, (short)0, (short)0, (short)0, (short)29, (short)0, (short)0, (short)30, (short)31, (short)0, (short)32, (short)0, (short)33, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)34, (short)0, (short)1, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)35, (short)36, (short)37, (short)38, (short)0, (short)0, (short)0, (short)39, (short)72, (short)0, (short)0, (short)425, (short)0, (short)0, (short)0, (short)0, (short)426, (short)2, (short)3, (short)4, (short)5, (short)6, (short)7, (short)8, (short)9, (short)10, (short)11, (short)12, (short)13, (short)14, (short)15, (short)16, (short)17, (short)18, (short)19, (short)20, (short)21, (short)22, (short)23, (short)24, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)26, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)27, (short)28, (short)0, (short)0, (short)0, (short)29, (short)0, (short)0, (short)30, (short)31, (short)0, (short)32, (short)0, (short)33, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)34, (short)0, (short)1, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)35, (short)36, (short)37, (short)38, (short)0, (short)0, (short)0, (short)39, (short)72, (short)0, (short)0, (short)425, (short)0, (short)0, (short)0, (short)0, (short)438, (short)2, (short)3, (short)4, (short)5, (short)6, (short)7, (short)8, (short)9, (short)10, (short)11, (short)12, (short)13, (short)14, (short)15, (short)16, (short)17, (short)18, (short)19, (short)20, (short)21, (short)22, (short)23, (short)24, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)26, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)27, (short)28, (short)0, (short)0, (short)0, (short)29, (short)0, (short)0, (short)30, (short)31, (short)0, (short)32, (short)0, (short)33, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)34, (short)0, (short)1, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)35, (short)36, (short)37, (short)38, (short)0, (short)0, (short)0, (short)39, (short)72, (short)0, (short)0, (short)302, (short)0, (short)0, (short)0, (short)0, (short)74, (short)2, (short)3, (short)4, (short)5, (short)6, (short)7, (short)341, (short)342, (short)343, (short)344, (short)345, (short)346, (short)347, (short)348, (short)349, (short)350, (short)18, (short)19, (short)351, (short)352, (short)22, (short)23, (short)24, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)354, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)27, (short)28, (short)0, (short)0, (short)0, (short)29, (short)0, (short)0, (short)0, (short)0, (short)0, (short)355, (short)0, (short)356, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)357, (short)0, (short)1, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)35, (short)36, (short)358, (short)359, (short)0, (short)0, (short)0, (short)39, (short)72, (short)0, (short)0, (short)425, (short)0, (short)0, (short)0, (short)0, (short)607, (short)2, (short)3, (short)4, (short)5, (short)6, (short)7, (short)341, (short)342, (short)343, (short)344, (short)345, (short)346, (short)347, (short)348, (short)349, (short)350, (short)18, (short)19, (short)351, (short)352, (short)22, (short)23, (short)24, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)354, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)27, (short)28, (short)0, (short)0, (short)0, (short)29, (short)0, (short)0, (short)0, (short)0, (short)0, (short)355, (short)0, (short)356, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)1, (short)0, (short)0, (short)357, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)35, (short)36, (short)358, (short)359, (short)0, (short)0, (short)0, (short)39, (short)72, (short)0, (short)0, (short)425, (short)2, (short)0, (short)0, (short)0, (short)617, (short)0, (short)8, (short)9, (short)10, (short)11, (short)12, (short)13, (short)14, (short)15, (short)16, (short)17, (short)18, (short)19, (short)20, (short)21, (short)22, (short)23, (short)24, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)26, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)27, (short)28, (short)0, (short)0, (short)0, (short)29, (short)0, (short)0, (short)30, (short)31, (short)0, (short)32, (short)0, (short)33, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)34, (short)0, (short)1, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)35, (short)36, (short)37, (short)38, (short)0, (short)0, (short)0, (short)0, (short)72, (short)0, (short)0, (short)302, (short)0, (short)0, (short)0, (short)0, (short)74, (short)2, (short)3, (short)4, (short)5, (short)6, (short)7, (short)8, (short)9, (short)10, (short)11, (short)12, (short)13, (short)14, (short)15, (short)16, (short)17, (short)18, (short)19, (short)20, (short)21, (short)22, (short)23, (short)24, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)25, (short)26, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)27, (short)28, (short)0, (short)0, (short)0, (short)29, (short)0, (short)0, (short)30, (short)31, (short)0, (short)32, (short)0, (short)33, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)1, (short)0, (short)34, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)35, (short)36, (short)37, (short)38, (short)0, (short)0, (short)0, (short)39, (short)72, (short)0, (short)0, (short)425, (short)597, (short)2, (short)3, (short)4, (short)5, (short)6, (short)7, (short)8, (short)9, (short)10, (short)11, (short)12, (short)13, (short)14, (short)15, (short)16, (short)17, (short)18, (short)19, (short)20, (short)21, (short)22, (short)23, (short)24, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)25, (short)26, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)27, (short)28, (short)0, (short)0, (short)0, (short)29, (short)0, (short)0, (short)30, (short)31, (short)0, (short)32, (short)0, (short)33, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)1, (short)0, (short)34, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)35, (short)36, (short)37, (short)38, (short)0, (short)0, (short)0, (short)39, (short)0, (short)0, (short)0, (short)0, (short)189, (short)2, (short)3, (short)4, (short)5, (short)6, (short)7, (short)8, (short)9, (short)10, (short)11, (short)12, (short)13, (short)14, (short)15, (short)16, (short)17, (short)18, (short)19, (short)20, (short)21, (short)22, (short)23, (short)24, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)25, (short)26, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)27, (short)28, (short)0, (short)0, (short)0, (short)29, (short)0, (short)0, (short)30, (short)31, (short)0, (short)32, (short)0, (short)33, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)1, (short)0, (short)34, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)35, (short)36, (short)37, (short)38, (short)0, (short)0, (short)0, (short)39, (short)0, (short)0, (short)0, (short)0, (short)321, (short)2, (short)3, (short)4, (short)5, (short)6, (short)7, (short)8, (short)9, (short)10, (short)11, (short)12, (short)13, (short)14, (short)15, (short)16, (short)17, (short)18, (short)19, (short)20, (short)21, (short)22, (short)23, (short)24, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)25, (short)26, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)27, (short)28, (short)0, (short)0, (short)0, (short)29, (short)0, (short)0, (short)30, (short)31, (short)0, (short)32, (short)0, (short)33, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)1, (short)0, (short)34, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)35, (short)36, (short)37, (short)38, (short)0, (short)0, (short)0, (short)39, (short)0, (short)0, (short)0, (short)0, (short)708, (short)2, (short)3, (short)4, (short)5, (short)6, (short)7, (short)8, (short)9, (short)10, (short)11, (short)12, (short)13, (short)14, (short)15, (short)16, (short)17, (short)18, (short)19, (short)20, (short)21, (short)22, (short)23, (short)24, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)26, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)27, (short)28, (short)0, (short)0, (short)0, (short)29, (short)0, (short)0, (short)30, (short)31, (short)0, (short)32, (short)0, (short)33, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)1, (short)0, (short)0, (short)34, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)35, (short)36, (short)37, (short)38, (short)0, (short)0, (short)0, (short)39, (short)72, (short)0, (short)0, (short)175, (short)2, (short)3, (short)4, (short)5, (short)6, (short)7, (short)8, (short)9, (short)10, (short)11, (short)12, (short)13, (short)14, (short)15, (short)16, (short)17, (short)18, (short)19, (short)20, (short)21, (short)22, (short)23, (short)24, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)26, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)27, (short)28, (short)0, (short)0, (short)0, (short)29, (short)0, (short)0, (short)30, (short)31, (short)0, (short)32, (short)0, (short)33, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)1, (short)0, (short)0, (short)34, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)35, (short)36, (short)37, (short)38, (short)0, (short)0, (short)0, (short)39, (short)0, (short)0, (short)0, (short)537, (short)2, (short)3, (short)4, (short)5, (short)6, (short)7, (short)8, (short)9, (short)10, (short)11, (short)12, (short)13, (short)14, (short)15, (short)16, (short)17, (short)18, (short)19, (short)20, (short)21, (short)22, (short)23, (short)24, (short)509, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)25, (short)26, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)27, (short)28, (short)0, (short)0, (short)0, (short)29, (short)0, (short)0, (short)30, (short)31, (short)0, (short)32, (short)0, (short)33, (short)0, (short)0, (short)0, (short)0, (short)0, (short)1, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)34, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)35, (short)36, (short)37, (short)38, (short)0, (short)0, (short)0, (short)39, (short)2, (short)3, (short)4, (short)5, (short)6, (short)7, (short)8, (short)9, (short)10, (short)11, (short)12, (short)13, (short)14, (short)15, (short)16, (short)17, (short)18, (short)19, (short)20, (short)21, (short)22, (short)23, (short)24, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)25, (short)26, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)27, (short)28, (short)0, (short)0, (short)0, (short)29, (short)0, (short)0, (short)30, (short)31, (short)0, (short)32, (short)0, (short)33, (short)0, (short)0, (short)0, (short)0, (short)0, (short)1, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)34, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)35, (short)36, (short)37, (short)38, (short)0, (short)0, (short)0, (short)39, (short)2, (short)3, (short)4, (short)5, (short)6, (short)7, (short)8, (short)9, (short)10, (short)11, (short)12, (short)13, (short)14, (short)15, (short)16, (short)17, (short)18, (short)19, (short)20, (short)21, (short)22, (short)23, (short)24, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)26, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)27, (short)28, (short)0, (short)0, (short)0, (short)29, (short)0, (short)0, (short)30, (short)31, (short)0, (short)32, (short)0, (short)33, (short)0, (short)0, (short)0, (short)0, (short)0, (short)1, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)34, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)35, (short)36, (short)37, (short)38, (short)0, (short)0, (short)0, (short)39, (short)2, (short)3, (short)4, (short)5, (short)6, (short)7, (short)341, (short)342, (short)343, (short)344, (short)345, (short)346, (short)347, (short)348, (short)349, (short)350, (short)18, (short)19, (short)351, (short)352, (short)22, (short)23, (short)353, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)354, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)27, (short)28, (short)0, (short)0, (short)0, (short)29, (short)0, (short)0, (short)0, (short)0, (short)0, (short)355, (short)0, (short)356, (short)0, (short)0, (short)0, (short)0, (short)0, (short)1, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)357, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)35, (short)36, (short)358, (short)359, (short)0, (short)0, (short)0, (short)39, (short)2, (short)3, (short)4, (short)5, (short)6, (short)7, (short)341, (short)342, (short)343, (short)344, (short)345, (short)346, (short)347, (short)348, (short)349, (short)350, (short)18, (short)19, (short)351, (short)352, (short)22, (short)23, (short)24, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)354, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)27, (short)28, (short)0, (short)0, (short)0, (short)29, (short)0, (short)0, (short)0, (short)0, (short)0, (short)355, (short)0, (short)356, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)357, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)35, (short)36, (short)358, (short)359, (short)0, (short)0, (short)0, (short)39 }; static const yytype_int16 yycheck[] = { (short)0, (short)46, (short)88, (short)120, (short)0, (short)79, (short)261, (short)257, (short)382, (short)46, (short)376, (short)340, (short)46, (short)376, (short)198, (short)197, (short)65, (short)91, (short)3, (short)17, (short)91, (short)276, (short)132, (short)242, (short)24, (short)209, (short)67, (short)3, (short)3, (short)427, (short)75, (short)121, (short)430, (short)3, (short)3, (short)3, (short)73, (short)197, (short)75, (short)3, (short)3, (short)118, (short)79, (short)671, (short)11, (short)45, (short)46, (short)70, (short)797, (short)197, (short)3, (short)3, (short)69, (short)70, (short)91, (short)70, (short)3, (short)57, (short)69, (short)28, (short)3, (short)197, (short)62, (short)121, (short)119, (short)28, (short)66, (short)67, (short)119, (short)223, (short)224, (short)225, (short)128, (short)73, (short)69, (short)75, (short)211, (short)77, (short)128, (short)79, (short)119, (short)241, (short)3, (short)243, (short)140, (short)28, (short)141, (short)69, (short)88, (short)122, (short)141, (short)91, (short)142, (short)93, (short)843, (short)128, (short)137, (short)97, (short)184, (short)127, (short)3, (short)526, (short)118, (short)103, (short)104, (short)241, (short)128, (short)243, (short)179, (short)183, (short)128, (short)111, (short)183, (short)141, (short)114, (short)70, (short)138, (short)133, (short)134, (short)142, (short)748, (short)155, (short)199, (short)0, (short)142, (short)142, (short)126, (short)142, (short)46, (short)129, (short)121, (short)142, (short)69, (short)118, (short)138, (short)1, (short)121, (short)3, (short)175, (short)137, (short)177, (short)126, (short)179, (short)118, (short)119, (short)121, (short)183, (short)142, (short)118, (short)119, (short)150, (short)3, (short)152, (short)120, (short)122, (short)155, (short)193, (short)234, (short)122, (short)236, (short)142, (short)128, (short)199, (short)3, (short)139, (short)165, (short)141, (short)244, (short)278, (short)279, (short)280, (short)141, (short)141, (short)210, (short)135, (short)175, (short)141, (short)177, (short)141, (short)179, (short)362, (short)606, (short)219, (short)183, (short)184, (short)369, (short)263, (short)142, (short)141, (short)141, (short)190, (short)520, (short)558, (short)193, (short)141, (short)558, (short)559, (short)197, (short)198, (short)199, (short)200, (short)141, (short)362, (short)453, (short)602, (short)142, (short)425, (short)207, (short)208, (short)209, (short)210, (short)211, (short)261, (short)432, (short)362, (short)249, (short)130, (short)131, (short)3, (short)219, (short)297, (short)440, (short)3, (short)223, (short)224, (short)225, (short)362, (short)276, (short)70, (short)303, (short)230, (short)305, (short)65, (short)658, (short)234, (short)138, (short)127, (short)155, (short)141, (short)239, (short)240, (short)241, (short)242, (short)243, (short)244, (short)286, (short)287, (short)318, (short)289, (short)249, (short)141, (short)625, (short)118, (short)119, (short)118, (short)409, (short)410, (short)121, (short)258, (short)413, (short)301, (short)415, (short)262, (short)12, (short)13, (short)306, (short)118, (short)119, (short)309, (short)404, (short)121, (short)406, (short)432, (short)408, (short)458, (short)108, (short)109, (short)110, (short)118, (short)119, (short)440, (short)318, (short)79, (short)116, (short)432, (short)118, (short)69, (short)70, (short)713, (short)141, (short)139, (short)209, (short)440, (short)74, (short)75, (short)372, (short)432, (short)127, (short)79, (short)120, (short)142, (short)301, (short)302, (short)121, (short)440, (short)93, (short)306, (short)128, (short)126, (short)309, (short)141, (short)141, (short)121, (short)110, (short)111, (short)315, (short)234, (short)126, (short)318, (short)315, (short)570, (short)5, (short)240, (short)686, (short)242, (short)128, (short)244, (short)3, (short)362, (short)110, (short)111, (short)331, (short)122, (short)118, (short)451, (short)372, (short)121, (short)140, (short)128, (short)425, (short)450, (short)138, (short)1, (short)3, (short)3, (short)141, (short)383, (short)7, (short)8, (short)9, (short)387, (short)46, (short)28, (short)353, (short)69, (short)70, (short)393, (short)129, (short)395, (short)142, (short)141, (short)136, (short)362, (short)400, (short)16, (short)128, (short)199, (short)367, (short)44, (short)369, (short)119, (short)120, (short)372, (short)373, (short)374, (short)122, (short)376, (short)140, (short)73, (short)142, (short)75, (short)128, (short)120, (short)383, (short)79, (short)419, (short)386, (short)387, (short)122, (short)644, (short)128, (short)122, (short)122, (short)393, (short)443, (short)395, (short)91, (short)128, (short)74, (short)75, (short)400, (short)234, (short)128, (short)236, (short)404, (short)3, (short)406, (short)139, (short)408, (short)409, (short)410, (short)244, (short)120, (short)413, (short)140, (short)415, (short)142, (short)128, (short)418, (short)419, (short)128, (short)10, (short)11, (short)211, (short)24, (short)425, (short)128, (short)142, (short)261, (short)140, (short)263, (short)505, (short)432, (short)69, (short)70, (short)223, (short)224, (short)225, (short)140, (short)118, (short)440, (short)518, (short)121, (short)276, (short)444, (short)122, (short)122, (short)126, (short)122, (short)0, (short)585, (short)369, (short)587, (short)588, (short)589, (short)455, (short)374, (short)57, (short)458, (short)118, (short)119, (short)121, (short)128, (short)122, (short)297, (short)125, (short)126, (short)122, (short)502, (short)128, (short)120, (short)128, (short)549, (short)128, (short)140, (short)524, (short)74, (short)75, (short)128, (short)139, (short)175, (short)79, (short)177, (short)140, (short)179, (short)526, (short)121, (short)301, (short)183, (short)3, (short)3, (short)126, (short)306, (short)7, (short)8, (short)9, (short)128, (short)97, (short)193, (short)536, (short)127, (short)419, (short)502, (short)753, (short)199, (short)122, (short)142, (short)122, (short)3, (short)140, (short)555, (short)128, (short)110, (short)111, (short)209, (short)28, (short)67, (short)603, (short)555, (short)301, (short)141, (short)122, (short)73, (short)121, (short)306, (short)525, (short)526, (short)128, (short)126, (short)14, (short)15, (short)44, (short)532, (short)28, (short)534, (short)572, (short)536, (short)88, (short)140, (short)372, (short)577, (short)122, (short)122, (short)376, (short)544, (short)141, (short)546, (short)128, (short)128, (short)44, (short)550, (short)141, (short)552, (short)140, (short)141, (short)555, (short)127, (short)128, (short)558, (short)559, (short)111, (short)74, (short)75, (short)114, (short)122, (short)606, (short)283, (short)284, (short)3, (short)281, (short)282, (short)125, (short)572, (short)573, (short)290, (short)291, (short)139, (short)577, (short)122, (short)74, (short)75, (short)103, (short)104, (short)122, (short)502, (short)585, (short)127, (short)587, (short)588, (short)589, (short)667, (short)668, (short)669, (short)28, (short)127, (short)644, (short)3, (short)197, (short)121, (short)119, (short)7, (short)8, (short)9, (short)603, (short)121, (short)121, (short)606, (short)121, (short)142, (short)122, (short)443, (short)125, (short)126, (short)122, (short)121, (short)128, (short)404, (short)658, (short)406, (short)119, (short)408, (short)409, (short)410, (short)318, (short)126, (short)413, (short)626, (short)415, (short)121, (short)126, (short)122, (short)142, (short)142, (short)184, (short)203, (short)204, (short)205, (short)206, (short)122, (short)74, (short)75, (short)241, (short)122, (short)243, (short)79, (short)121, (short)121, (short)198, (short)138, (short)200, (short)121, (short)121, (short)140, (short)653, (short)140, (short)142, (short)122, (short)140, (short)658, (short)122, (short)127, (short)119, (short)126, (short)142, (short)0, (short)127, (short)666, (short)126, (short)122, (short)122, (short)56, (short)140, (short)713, (short)141, (short)139, (short)110, (short)111, (short)372, (short)678, (short)126, (short)122, (short)681, (short)138, (short)127, (short)127, (short)518, (short)686, (short)142, (short)383, (short)138, (short)127, (short)524, (short)387, (short)127, (short)694, (short)121, (short)127, (short)697, (short)393, (short)127, (short)140, (short)1, (short)64, (short)3, (short)4, (short)5, (short)141, (short)756, (short)3, (short)754, (short)46, (short)544, (short)789, (short)713, (short)121, (short)792, (short)549, (short)754, (short)125, (short)126, (short)142, (short)142, (short)142, (short)142, (short)142, (short)558, (short)559, (short)142, (short)28, (short)142, (short)66, (short)67, (short)139, (short)142, (short)140, (short)57, (short)3, (short)73, (short)74, (short)142, (short)740, (short)293, (short)292, (short)296, (short)744, (short)294, (short)754, (short)747, (short)797, (short)295, (short)301, (short)302, (short)88, (short)353, (short)754, (short)306, (short)398, (short)93, (short)309, (short)759, (short)760, (short)243, (short)362, (short)458, (short)315, (short)573, (short)392, (short)367, (short)458, (short)74, (short)75, (short)71, (short)72, (short)309, (short)79, (short)111, (short)635, (short)471, (short)114, (short)74, (short)75, (short)558, (short)118, (short)244, (short)79, (short)785, (short)786, (short)3, (short)788, (short)230, (short)471, (short)791, (short)(-1), (short)471, (short)843, (short)(-1), (short)(-1), (short)585, (short)(-1), (short)587, (short)588, (short)589, (short)102, (short)103, (short)(-1), (short)110, (short)111, (short)74, (short)75, (short)(-1), (short)(-1), (short)644, (short)79, (short)(-1), (short)(-1), (short)110, (short)111, (short)122, (short)1, (short)155, (short)3, (short)121, (short)(-1), (short)823, (short)124, (short)(-1), (short)121, (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)432, (short)666, (short)667, (short)668, (short)669, (short)(-1), (short)671, (short)839, (short)440, (short)536, (short)842, (short)110, (short)111, (short)678, (short)(-1), (short)(-1), (short)184, (short)185, (short)(-1), (short)118, (short)188, (short)686, (short)121, (short)(-1), (short)(-1), (short)(-1), (short)74, (short)75, (short)555, (short)3, (short)198, (short)79, (short)200, (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)3, (short)138, (short)(-1), (short)209, (short)425, (short)211, (short)(-1), (short)572, (short)573, (short)(-1), (short)74, (short)75, (short)577, (short)(-1), (short)(-1), (short)79, (short)28, (short)223, (short)224, (short)225, (short)(-1), (short)74, (short)75, (short)(-1), (short)110, (short)111, (short)79, (short)466, (short)234, (short)(-1), (short)(-1), (short)(-1), (short)118, (short)(-1), (short)240, (short)121, (short)242, (short)740, (short)244, (short)(-1), (short)(-1), (short)744, (short)(-1), (short)249, (short)747, (short)748, (short)110, (short)111, (short)(-1), (short)(-1), (short)256, (short)257, (short)(-1), (short)756, (short)(-1), (short)(-1), (short)(-1), (short)110, (short)111, (short)(-1), (short)(-1), (short)(-1), (short)74, (short)75, (short)534, (short)118, (short)119, (short)79, (short)121, (short)122, (short)(-1), (short)74, (short)75, (short)126, (short)(-1), (short)139, (short)79, (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)785, (short)786, (short)(-1), (short)788, (short)789, (short)(-1), (short)791, (short)792, (short)(-1), (short)44, (short)45, (short)(-1), (short)797, (short)301, (short)302, (short)(-1), (short)110, (short)111, (short)306, (short)(-1), (short)(-1), (short)309, (short)(-1), (short)526, (short)46, (short)110, (short)111, (short)315, (short)(-1), (short)74, (short)75, (short)(-1), (short)(-1), (short)118, (short)79, (short)57, (short)121, (short)122, (short)823, (short)74, (short)75, (short)(-1), (short)(-1), (short)(-1), (short)79, (short)(-1), (short)(-1), (short)694, (short)(-1), (short)(-1), (short)697, (short)73, (short)(-1), (short)75, (short)839, (short)(-1), (short)(-1), (short)842, (short)843, (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)86, (short)110, (short)111, (short)(-1), (short)(-1), (short)91, (short)(-1), (short)93, (short)(-1), (short)(-1), (short)(-1), (short)110, (short)111, (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)369, (short)(-1), (short)118, (short)372, (short)(-1), (short)374, (short)(-1), (short)376, (short)(-1), (short)18, (short)19, (short)20, (short)21, (short)22, (short)23, (short)24, (short)25, (short)26, (short)27, (short)603, (short)(-1), (short)(-1), (short)606, (short)(-1), (short)(-1), (short)(-1), (short)754, (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)759, (short)760, (short)(-1), (short)(-1), (short)404, (short)(-1), (short)406, (short)(-1), (short)408, (short)409, (short)410, (short)(-1), (short)(-1), (short)413, (short)(-1), (short)415, (short)(-1), (short)(-1), (short)(-1), (short)419, (short)46, (short)155, (short)655, (short)656, (short)(-1), (short)425, (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)167, (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)175, (short)(-1), (short)658, (short)178, (short)179, (short)72, (short)46, (short)(-1), (short)183, (short)(-1), (short)(-1), (short)(-1), (short)453, (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)458, (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)198, (short)199, (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)471, (short)(-1), (short)72, (short)73, (short)209, (short)75, (short)211, (short)(-1), (short)(-1), (short)79, (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)219, (short)(-1), (short)(-1), (short)(-1), (short)223, (short)224, (short)225, (short)118, (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)713, (short)139, (short)733, (short)734, (short)502, (short)736, (short)737, (short)(-1), (short)240, (short)(-1), (short)242, (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)249, (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)525, (short)526, (short)(-1), (short)(-1), (short)155, (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)162, (short)(-1), (short)(-1), (short)772, (short)(-1), (short)774, (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)781, (short)782, (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)555, (short)155, (short)(-1), (short)558, (short)559, (short)(-1), (short)(-1), (short)(-1), (short)162, (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)302, (short)(-1), (short)570, (short)197, (short)(-1), (short)(-1), (short)(-1), (short)808, (short)175, (short)810, (short)177, (short)812, (short)(-1), (short)814, (short)(-1), (short)209, (short)318, (short)585, (short)(-1), (short)587, (short)588, (short)589, (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)199, (short)(-1), (short)835, (short)603, (short)837, (short)(-1), (short)606, (short)(-1), (short)234, (short)(-1), (short)209, (short)210, (short)(-1), (short)(-1), (short)240, (short)241, (short)242, (short)243, (short)244, (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)249, (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)362, (short)(-1), (short)256, (short)257, (short)(-1), (short)367, (short)(-1), (short)369, (short)(-1), (short)(-1), (short)372, (short)(-1), (short)544, (short)240, (short)(-1), (short)242, (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)383, (short)249, (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)559, (short)(-1), (short)(-1), (short)658, (short)393, (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)46, (short)(-1), (short)404, (short)(-1), (short)406, (short)(-1), (short)408, (short)409, (short)410, (short)(-1), (short)(-1), (short)413, (short)(-1), (short)415, (short)(-1), (short)(-1), (short)(-1), (short)419, (short)686, (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)425, (short)(-1), (short)(-1), (short)(-1), (short)46, (short)(-1), (short)(-1), (short)432, (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)302, (short)303, (short)(-1), (short)440, (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)713, (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)458, (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)362, (short)(-1), (short)(-1), (short)(-1), (short)118, (short)(-1), (short)(-1), (short)369, (short)(-1), (short)371, (short)372, (short)(-1), (short)374, (short)(-1), (short)376, (short)(-1), (short)(-1), (short)753, (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)74, (short)(-1), (short)(-1), (short)666, (short)362, (short)(-1), (short)(-1), (short)(-1), (short)118, (short)502, (short)(-1), (short)(-1), (short)46, (short)371, (short)372, (short)678, (short)(-1), (short)(-1), (short)155, (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)686, (short)98, (short)383, (short)(-1), (short)(-1), (short)(-1), (short)387, (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)419, (short)(-1), (short)(-1), (short)(-1), (short)112, (short)(-1), (short)(-1), (short)115, (short)(-1), (short)(-1), (short)(-1), (short)155, (short)(-1), (short)432, (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)440, (short)(-1), (short)46, (short)(-1), (short)(-1), (short)(-1), (short)419, (short)555, (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)425, (short)453, (short)427, (short)(-1), (short)98, (short)209, (short)458, (short)432, (short)(-1), (short)(-1), (short)740, (short)(-1), (short)(-1), (short)573, (short)744, (short)440, (short)(-1), (short)747, (short)112, (short)471, (short)(-1), (short)115, (short)(-1), (short)(-1), (short)(-1), (short)585, (short)(-1), (short)587, (short)588, (short)589, (short)234, (short)(-1), (short)209, (short)458, (short)(-1), (short)(-1), (short)240, (short)241, (short)242, (short)243, (short)244, (short)(-1), (short)(-1), (short)(-1), (short)185, (short)249, (short)(-1), (short)188, (short)(-1), (short)(-1), (short)502, (short)(-1), (short)256, (short)257, (short)155, (short)785, (short)786, (short)234, (short)788, (short)(-1), (short)(-1), (short)791, (short)118, (short)240, (short)241, (short)242, (short)243, (short)244, (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)249, (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)502, (short)(-1), (short)256, (short)257, (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)229, (short)(-1), (short)(-1), (short)185, (short)(-1), (short)823, (short)188, (short)(-1), (short)197, (short)(-1), (short)(-1), (short)155, (short)(-1), (short)93, (short)(-1), (short)555, (short)(-1), (short)(-1), (short)558, (short)559, (short)209, (short)839, (short)(-1), (short)536, (short)842, (short)(-1), (short)(-1), (short)256, (short)257, (short)(-1), (short)570, (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)684, (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)555, (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)229, (short)(-1), (short)697, (short)(-1), (short)240, (short)241, (short)242, (short)243, (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)573, (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)209, (short)(-1), (short)256, (short)257, (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)369, (short)(-1), (short)(-1), (short)372, (short)(-1), (short)374, (short)(-1), (short)376, (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)234, (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)240, (short)(-1), (short)242, (short)(-1), (short)244, (short)(-1), (short)(-1), (short)(-1), (short)369, (short)249, (short)754, (short)372, (short)(-1), (short)374, (short)(-1), (short)376, (short)256, (short)257, (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)419, (short)(-1), (short)(-1), (short)(-1), (short)211, (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)432, (short)(-1), (short)(-1), (short)223, (short)224, (short)225, (short)686, (short)(-1), (short)440, (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)382, (short)419, (short)384, (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)453, (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)458, (short)432, (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)362, (short)(-1), (short)440, (short)256, (short)257, (short)(-1), (short)471, (short)369, (short)694, (short)(-1), (short)(-1), (short)(-1), (short)374, (short)(-1), (short)376, (short)453, (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)458, (short)(-1), (short)(-1), (short)(-1), (short)426, (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)384, (short)(-1), (short)(-1), (short)(-1), (short)471, (short)(-1), (short)(-1), (short)438, (short)502, (short)(-1), (short)(-1), (short)753, (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)453, (short)369, (short)(-1), (short)(-1), (short)372, (short)(-1), (short)374, (short)(-1), (short)376, (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)502, (short)(-1), (short)(-1), (short)(-1), (short)754, (short)471, (short)432, (short)426, (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)440, (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)438, (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)555, (short)453, (short)(-1), (short)558, (short)559, (short)(-1), (short)458, (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)419, (short)(-1), (short)(-1), (short)570, (short)(-1), (short)(-1), (short)(-1), (short)471, (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)555, (short)(-1), (short)(-1), (short)558, (short)559, (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)570, (short)(-1), (short)(-1), (short)(-1), (short)453, (short)539, (short)(-1), (short)(-1), (short)502, (short)458, (short)(-1), (short)(-1), (short)(-1), (short)398, (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)404, (short)(-1), (short)406, (short)471, (short)408, (short)409, (short)410, (short)(-1), (short)(-1), (short)413, (short)(-1), (short)415, (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)570, (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)575, (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)539, (short)502, (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)555, (short)(-1), (short)(-1), (short)558, (short)559, (short)(-1), (short)(-1), (short)453, (short)(-1), (short)604, (short)(-1), (short)(-1), (short)607, (short)(-1), (short)(-1), (short)570, (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)616, (short)617, (short)(-1), (short)(-1), (short)471, (short)(-1), (short)575, (short)686, (short)(-1), (short)625, (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)635, (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)555, (short)(-1), (short)(-1), (short)558, (short)559, (short)(-1), (short)646, (short)(-1), (short)(-1), (short)(-1), (short)686, (short)604, (short)(-1), (short)(-1), (short)607, (short)570, (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)616, (short)617, (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)1, (short)(-1), (short)3, (short)4, (short)5, (short)6, (short)(-1), (short)8, (short)9, (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)753, (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)28, (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)714, (short)(-1), (short)(-1), (short)753, (short)718, (short)570, (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)686, (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)585, (short)(-1), (short)587, (short)588, (short)589, (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)71, (short)72, (short)73, (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)751, (short)(-1), (short)753, (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)714, (short)762, (short)(-1), (short)(-1), (short)718, (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)686, (short)(-1), (short)(-1), (short)(-1), (short)102, (short)103, (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)109, (short)(-1), (short)635, (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)118, (short)(-1), (short)753, (short)121, (short)122, (short)123, (short)124, (short)751, (short)(-1), (short)(-1), (short)(-1), (short)129, (short)130, (short)131, (short)132, (short)(-1), (short)(-1), (short)(-1), (short)762, (short)(-1), (short)(-1), (short)1, (short)140, (short)3, (short)4, (short)5, (short)6, (short)(-1), (short)8, (short)9, (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)753, (short)28, (short)29, (short)30, (short)31, (short)32, (short)33, (short)34, (short)35, (short)36, (short)37, (short)38, (short)39, (short)40, (short)41, (short)42, (short)43, (short)44, (short)45, (short)46, (short)47, (short)48, (short)49, (short)50, (short)(-1), (short)52, (short)53, (short)54, (short)55, (short)56, (short)57, (short)58, (short)59, (short)60, (short)61, (short)62, (short)(-1), (short)(-1), (short)(-1), (short)66, (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)71, (short)72, (short)73, (short)74, (short)75, (short)(-1), (short)77, (short)(-1), (short)79, (short)(-1), (short)(-1), (short)82, (short)83, (short)(-1), (short)85, (short)(-1), (short)87, (short)(-1), (short)(-1), (short)(-1), (short)753, (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)100, (short)(-1), (short)102, (short)103, (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)109, (short)110, (short)111, (short)112, (short)113, (short)(-1), (short)(-1), (short)(-1), (short)117, (short)118, (short)(-1), (short)(-1), (short)121, (short)(-1), (short)123, (short)124, (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)129, (short)130, (short)131, (short)132, (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)140, (short)141, (short)142, (short)1, (short)(-1), (short)3, (short)4, (short)5, (short)6, (short)(-1), (short)8, (short)9, (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)28, (short)29, (short)30, (short)31, (short)32, (short)33, (short)34, (short)35, (short)36, (short)37, (short)38, (short)39, (short)40, (short)41, (short)42, (short)43, (short)44, (short)45, (short)46, (short)47, (short)48, (short)49, (short)50, (short)(-1), (short)52, (short)53, (short)54, (short)55, (short)56, (short)57, (short)58, (short)59, (short)60, (short)61, (short)62, (short)(-1), (short)(-1), (short)(-1), (short)66, (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)71, (short)72, (short)73, (short)74, (short)75, (short)(-1), (short)77, (short)(-1), (short)79, (short)(-1), (short)(-1), (short)82, (short)83, (short)(-1), (short)85, (short)(-1), (short)87, (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)100, (short)(-1), (short)102, (short)103, (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)109, (short)110, (short)111, (short)112, (short)113, (short)(-1), (short)(-1), (short)(-1), (short)117, (short)118, (short)(-1), (short)(-1), (short)121, (short)(-1), (short)123, (short)124, (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)129, (short)130, (short)131, (short)132, (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)140, (short)141, (short)142, (short)1, (short)(-1), (short)3, (short)4, (short)5, (short)6, (short)(-1), (short)8, (short)9, (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)28, (short)29, (short)30, (short)31, (short)32, (short)33, (short)34, (short)35, (short)36, (short)37, (short)38, (short)39, (short)40, (short)41, (short)42, (short)43, (short)44, (short)45, (short)46, (short)47, (short)48, (short)49, (short)50, (short)(-1), (short)52, (short)53, (short)54, (short)55, (short)56, (short)57, (short)58, (short)59, (short)60, (short)61, (short)62, (short)(-1), (short)(-1), (short)(-1), (short)66, (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)71, (short)72, (short)73, (short)74, (short)75, (short)(-1), (short)77, (short)(-1), (short)79, (short)(-1), (short)(-1), (short)82, (short)83, (short)(-1), (short)85, (short)(-1), (short)87, (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)100, (short)(-1), (short)102, (short)103, (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)109, (short)110, (short)111, (short)112, (short)113, (short)(-1), (short)(-1), (short)(-1), (short)117, (short)118, (short)(-1), (short)(-1), (short)121, (short)(-1), (short)123, (short)124, (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)129, (short)130, (short)131, (short)132, (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)140, (short)141, (short)142, (short)1, (short)(-1), (short)3, (short)4, (short)5, (short)6, (short)(-1), (short)8, (short)9, (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)28, (short)29, (short)30, (short)31, (short)32, (short)33, (short)34, (short)35, (short)36, (short)37, (short)38, (short)39, (short)40, (short)41, (short)42, (short)43, (short)44, (short)45, (short)46, (short)47, (short)48, (short)49, (short)50, (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)66, (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)71, (short)72, (short)73, (short)74, (short)75, (short)(-1), (short)(-1), (short)(-1), (short)79, (short)(-1), (short)(-1), (short)82, (short)83, (short)(-1), (short)85, (short)(-1), (short)87, (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)100, (short)(-1), (short)102, (short)103, (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)109, (short)110, (short)111, (short)112, (short)113, (short)(-1), (short)(-1), (short)(-1), (short)117, (short)118, (short)(-1), (short)(-1), (short)121, (short)(-1), (short)123, (short)124, (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)129, (short)130, (short)131, (short)132, (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)140, (short)141, (short)142, (short)1, (short)(-1), (short)3, (short)4, (short)5, (short)6, (short)(-1), (short)8, (short)9, (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)28, (short)29, (short)30, (short)31, (short)32, (short)33, (short)34, (short)35, (short)36, (short)37, (short)38, (short)39, (short)40, (short)41, (short)42, (short)43, (short)44, (short)45, (short)46, (short)47, (short)48, (short)49, (short)50, (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)66, (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)71, (short)72, (short)73, (short)74, (short)75, (short)(-1), (short)(-1), (short)(-1), (short)79, (short)(-1), (short)(-1), (short)82, (short)83, (short)(-1), (short)85, (short)(-1), (short)87, (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)100, (short)(-1), (short)102, (short)103, (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)109, (short)110, (short)111, (short)112, (short)113, (short)(-1), (short)(-1), (short)(-1), (short)117, (short)118, (short)(-1), (short)(-1), (short)121, (short)(-1), (short)123, (short)124, (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)129, (short)130, (short)131, (short)132, (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)140, (short)141, (short)142, (short)1, (short)(-1), (short)3, (short)4, (short)5, (short)6, (short)(-1), (short)8, (short)9, (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)28, (short)29, (short)30, (short)31, (short)32, (short)33, (short)34, (short)35, (short)36, (short)37, (short)38, (short)39, (short)40, (short)41, (short)42, (short)43, (short)44, (short)45, (short)46, (short)47, (short)48, (short)49, (short)50, (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)66, (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)71, (short)72, (short)73, (short)74, (short)75, (short)(-1), (short)(-1), (short)(-1), (short)79, (short)(-1), (short)(-1), (short)82, (short)83, (short)(-1), (short)85, (short)(-1), (short)87, (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)100, (short)(-1), (short)102, (short)103, (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)109, (short)110, (short)111, (short)112, (short)113, (short)(-1), (short)(-1), (short)(-1), (short)117, (short)118, (short)(-1), (short)(-1), (short)121, (short)(-1), (short)123, (short)124, (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)129, (short)130, (short)131, (short)132, (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)140, (short)141, (short)142, (short)1, (short)(-1), (short)3, (short)4, (short)5, (short)6, (short)(-1), (short)8, (short)9, (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)28, (short)29, (short)30, (short)31, (short)32, (short)33, (short)34, (short)35, (short)36, (short)37, (short)38, (short)39, (short)40, (short)41, (short)42, (short)43, (short)44, (short)45, (short)46, (short)47, (short)48, (short)49, (short)50, (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)66, (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)71, (short)72, (short)73, (short)74, (short)75, (short)(-1), (short)(-1), (short)(-1), (short)79, (short)(-1), (short)(-1), (short)82, (short)83, (short)(-1), (short)85, (short)(-1), (short)87, (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)100, (short)(-1), (short)102, (short)103, (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)109, (short)110, (short)111, (short)112, (short)113, (short)(-1), (short)(-1), (short)(-1), (short)117, (short)118, (short)(-1), (short)(-1), (short)121, (short)(-1), (short)123, (short)124, (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)129, (short)130, (short)131, (short)132, (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)140, (short)141, (short)142, (short)1, (short)(-1), (short)3, (short)4, (short)5, (short)6, (short)(-1), (short)8, (short)9, (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)28, (short)29, (short)30, (short)31, (short)32, (short)33, (short)34, (short)35, (short)36, (short)37, (short)38, (short)39, (short)40, (short)41, (short)42, (short)43, (short)44, (short)45, (short)46, (short)47, (short)48, (short)49, (short)50, (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)66, (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)71, (short)72, (short)73, (short)74, (short)75, (short)(-1), (short)(-1), (short)(-1), (short)79, (short)(-1), (short)(-1), (short)82, (short)83, (short)(-1), (short)85, (short)(-1), (short)87, (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)100, (short)(-1), (short)102, (short)103, (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)109, (short)110, (short)111, (short)112, (short)113, (short)(-1), (short)(-1), (short)(-1), (short)117, (short)118, (short)(-1), (short)(-1), (short)121, (short)(-1), (short)123, (short)124, (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)129, (short)130, (short)131, (short)132, (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)140, (short)141, (short)142, (short)1, (short)(-1), (short)3, (short)4, (short)5, (short)6, (short)(-1), (short)8, (short)9, (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)28, (short)29, (short)30, (short)31, (short)32, (short)33, (short)34, (short)35, (short)36, (short)37, (short)38, (short)39, (short)40, (short)41, (short)42, (short)43, (short)44, (short)45, (short)46, (short)47, (short)48, (short)49, (short)50, (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)66, (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)71, (short)72, (short)73, (short)74, (short)75, (short)(-1), (short)(-1), (short)(-1), (short)79, (short)(-1), (short)(-1), (short)82, (short)83, (short)(-1), (short)85, (short)(-1), (short)87, (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)100, (short)(-1), (short)102, (short)103, (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)109, (short)110, (short)111, (short)112, (short)113, (short)(-1), (short)(-1), (short)(-1), (short)117, (short)118, (short)(-1), (short)(-1), (short)121, (short)(-1), (short)123, (short)124, (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)129, (short)130, (short)131, (short)132, (short)1, (short)(-1), (short)3, (short)4, (short)5, (short)(-1), (short)(-1), (short)140, (short)141, (short)142, (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)28, (short)29, (short)30, (short)31, (short)32, (short)33, (short)34, (short)35, (short)36, (short)37, (short)38, (short)39, (short)40, (short)41, (short)42, (short)43, (short)44, (short)45, (short)46, (short)47, (short)48, (short)49, (short)50, (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)66, (short)(-1), (short)68, (short)(-1), (short)(-1), (short)71, (short)72, (short)(-1), (short)74, (short)75, (short)(-1), (short)(-1), (short)78, (short)79, (short)(-1), (short)(-1), (short)82, (short)83, (short)(-1), (short)85, (short)(-1), (short)87, (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)100, (short)(-1), (short)102, (short)103, (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)110, (short)111, (short)112, (short)113, (short)(-1), (short)(-1), (short)(-1), (short)117, (short)118, (short)(-1), (short)(-1), (short)121, (short)(-1), (short)123, (short)124, (short)1, (short)(-1), (short)3, (short)4, (short)5, (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)140, (short)(-1), (short)142, (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)28, (short)29, (short)30, (short)31, (short)32, (short)33, (short)34, (short)35, (short)36, (short)37, (short)38, (short)39, (short)40, (short)41, (short)42, (short)43, (short)44, (short)45, (short)46, (short)47, (short)48, (short)49, (short)50, (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)66, (short)(-1), (short)68, (short)(-1), (short)(-1), (short)71, (short)72, (short)(-1), (short)74, (short)75, (short)(-1), (short)(-1), (short)78, (short)79, (short)(-1), (short)(-1), (short)82, (short)83, (short)(-1), (short)85, (short)(-1), (short)87, (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)100, (short)(-1), (short)102, (short)103, (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)110, (short)111, (short)112, (short)113, (short)(-1), (short)(-1), (short)(-1), (short)117, (short)118, (short)(-1), (short)(-1), (short)121, (short)(-1), (short)123, (short)124, (short)1, (short)(-1), (short)3, (short)4, (short)5, (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)140, (short)(-1), (short)142, (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)28, (short)29, (short)30, (short)31, (short)32, (short)33, (short)34, (short)35, (short)36, (short)37, (short)38, (short)39, (short)40, (short)41, (short)42, (short)43, (short)44, (short)45, (short)46, (short)47, (short)48, (short)49, (short)50, (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)66, (short)(-1), (short)68, (short)(-1), (short)(-1), (short)71, (short)72, (short)(-1), (short)74, (short)75, (short)(-1), (short)(-1), (short)78, (short)79, (short)(-1), (short)(-1), (short)82, (short)83, (short)(-1), (short)85, (short)(-1), (short)87, (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)100, (short)(-1), (short)102, (short)103, (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)110, (short)111, (short)112, (short)113, (short)(-1), (short)(-1), (short)(-1), (short)117, (short)118, (short)(-1), (short)(-1), (short)121, (short)(-1), (short)123, (short)124, (short)1, (short)(-1), (short)3, (short)4, (short)5, (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)140, (short)(-1), (short)142, (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)28, (short)29, (short)30, (short)31, (short)32, (short)33, (short)34, (short)35, (short)36, (short)37, (short)38, (short)39, (short)40, (short)41, (short)42, (short)43, (short)44, (short)45, (short)46, (short)47, (short)48, (short)49, (short)50, (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)66, (short)(-1), (short)68, (short)(-1), (short)(-1), (short)71, (short)72, (short)(-1), (short)74, (short)75, (short)(-1), (short)(-1), (short)78, (short)79, (short)(-1), (short)(-1), (short)82, (short)83, (short)(-1), (short)85, (short)(-1), (short)87, (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)100, (short)(-1), (short)102, (short)103, (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)110, (short)111, (short)112, (short)113, (short)(-1), (short)(-1), (short)(-1), (short)117, (short)118, (short)(-1), (short)(-1), (short)121, (short)(-1), (short)123, (short)124, (short)1, (short)(-1), (short)3, (short)4, (short)5, (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)140, (short)(-1), (short)142, (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)28, (short)29, (short)30, (short)31, (short)32, (short)33, (short)34, (short)35, (short)36, (short)37, (short)38, (short)39, (short)40, (short)41, (short)42, (short)43, (short)44, (short)45, (short)46, (short)47, (short)48, (short)49, (short)50, (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)66, (short)(-1), (short)68, (short)(-1), (short)(-1), (short)71, (short)72, (short)(-1), (short)74, (short)75, (short)(-1), (short)(-1), (short)78, (short)79, (short)(-1), (short)(-1), (short)82, (short)83, (short)(-1), (short)85, (short)(-1), (short)87, (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)100, (short)(-1), (short)102, (short)103, (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)110, (short)111, (short)112, (short)113, (short)(-1), (short)(-1), (short)(-1), (short)117, (short)118, (short)(-1), (short)(-1), (short)121, (short)(-1), (short)123, (short)124, (short)1, (short)(-1), (short)3, (short)4, (short)5, (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)140, (short)(-1), (short)142, (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)28, (short)29, (short)30, (short)31, (short)32, (short)33, (short)34, (short)35, (short)36, (short)37, (short)38, (short)39, (short)40, (short)41, (short)42, (short)43, (short)44, (short)45, (short)46, (short)47, (short)48, (short)49, (short)50, (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)66, (short)(-1), (short)68, (short)(-1), (short)(-1), (short)71, (short)72, (short)(-1), (short)74, (short)75, (short)(-1), (short)(-1), (short)78, (short)79, (short)(-1), (short)(-1), (short)82, (short)83, (short)(-1), (short)85, (short)(-1), (short)87, (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)100, (short)(-1), (short)102, (short)103, (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)110, (short)111, (short)112, (short)113, (short)(-1), (short)(-1), (short)(-1), (short)117, (short)118, (short)(-1), (short)(-1), (short)121, (short)(-1), (short)123, (short)124, (short)1, (short)(-1), (short)3, (short)4, (short)5, (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)140, (short)(-1), (short)142, (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)28, (short)29, (short)30, (short)31, (short)32, (short)33, (short)34, (short)35, (short)36, (short)37, (short)38, (short)39, (short)40, (short)41, (short)42, (short)43, (short)44, (short)45, (short)46, (short)47, (short)48, (short)49, (short)50, (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)66, (short)(-1), (short)68, (short)(-1), (short)(-1), (short)71, (short)72, (short)(-1), (short)74, (short)75, (short)(-1), (short)(-1), (short)78, (short)79, (short)(-1), (short)(-1), (short)82, (short)83, (short)(-1), (short)85, (short)(-1), (short)87, (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)100, (short)(-1), (short)102, (short)103, (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)110, (short)111, (short)112, (short)113, (short)(-1), (short)(-1), (short)(-1), (short)117, (short)118, (short)(-1), (short)(-1), (short)121, (short)(-1), (short)123, (short)124, (short)1, (short)(-1), (short)3, (short)4, (short)5, (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)140, (short)(-1), (short)142, (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)28, (short)29, (short)30, (short)31, (short)32, (short)33, (short)34, (short)35, (short)36, (short)37, (short)38, (short)39, (short)40, (short)41, (short)42, (short)43, (short)44, (short)45, (short)46, (short)47, (short)48, (short)49, (short)50, (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)66, (short)(-1), (short)68, (short)(-1), (short)(-1), (short)71, (short)72, (short)(-1), (short)74, (short)75, (short)(-1), (short)(-1), (short)78, (short)79, (short)(-1), (short)(-1), (short)82, (short)83, (short)(-1), (short)85, (short)(-1), (short)87, (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)100, (short)(-1), (short)102, (short)103, (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)110, (short)111, (short)112, (short)113, (short)(-1), (short)(-1), (short)(-1), (short)117, (short)118, (short)(-1), (short)(-1), (short)121, (short)(-1), (short)123, (short)124, (short)1, (short)(-1), (short)3, (short)4, (short)5, (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)140, (short)(-1), (short)142, (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)28, (short)29, (short)30, (short)31, (short)32, (short)33, (short)34, (short)35, (short)36, (short)37, (short)38, (short)39, (short)40, (short)41, (short)42, (short)43, (short)44, (short)45, (short)46, (short)47, (short)48, (short)49, (short)50, (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)66, (short)(-1), (short)68, (short)(-1), (short)(-1), (short)71, (short)72, (short)(-1), (short)74, (short)75, (short)(-1), (short)(-1), (short)78, (short)79, (short)(-1), (short)(-1), (short)82, (short)83, (short)(-1), (short)85, (short)(-1), (short)87, (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)100, (short)(-1), (short)102, (short)103, (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)110, (short)111, (short)112, (short)113, (short)(-1), (short)(-1), (short)(-1), (short)117, (short)118, (short)(-1), (short)(-1), (short)121, (short)(-1), (short)123, (short)124, (short)1, (short)(-1), (short)3, (short)4, (short)5, (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)140, (short)(-1), (short)142, (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)28, (short)29, (short)30, (short)31, (short)32, (short)33, (short)34, (short)35, (short)36, (short)37, (short)38, (short)39, (short)40, (short)41, (short)42, (short)43, (short)44, (short)45, (short)46, (short)47, (short)48, (short)49, (short)50, (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)66, (short)(-1), (short)68, (short)(-1), (short)(-1), (short)71, (short)72, (short)(-1), (short)74, (short)75, (short)(-1), (short)(-1), (short)78, (short)79, (short)(-1), (short)(-1), (short)82, (short)83, (short)(-1), (short)85, (short)(-1), (short)87, (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)100, (short)(-1), (short)102, (short)103, (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)110, (short)111, (short)112, (short)113, (short)(-1), (short)(-1), (short)(-1), (short)117, (short)118, (short)(-1), (short)(-1), (short)121, (short)(-1), (short)123, (short)124, (short)1, (short)(-1), (short)3, (short)4, (short)5, (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)140, (short)(-1), (short)142, (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)28, (short)29, (short)30, (short)31, (short)32, (short)33, (short)34, (short)35, (short)36, (short)37, (short)38, (short)39, (short)40, (short)41, (short)42, (short)43, (short)44, (short)45, (short)46, (short)47, (short)48, (short)49, (short)50, (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)66, (short)(-1), (short)68, (short)(-1), (short)(-1), (short)71, (short)72, (short)(-1), (short)74, (short)75, (short)(-1), (short)(-1), (short)78, (short)79, (short)(-1), (short)(-1), (short)82, (short)83, (short)(-1), (short)85, (short)(-1), (short)87, (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)100, (short)(-1), (short)102, (short)103, (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)110, (short)111, (short)112, (short)113, (short)(-1), (short)(-1), (short)(-1), (short)117, (short)118, (short)(-1), (short)(-1), (short)121, (short)(-1), (short)123, (short)124, (short)1, (short)(-1), (short)3, (short)4, (short)5, (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)140, (short)(-1), (short)142, (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)28, (short)29, (short)30, (short)31, (short)32, (short)33, (short)34, (short)35, (short)36, (short)37, (short)38, (short)39, (short)40, (short)41, (short)42, (short)43, (short)44, (short)45, (short)46, (short)47, (short)48, (short)49, (short)50, (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)1, (short)(-1), (short)3, (short)4, (short)5, (short)6, (short)(-1), (short)8, (short)9, (short)66, (short)(-1), (short)68, (short)(-1), (short)(-1), (short)71, (short)72, (short)(-1), (short)74, (short)75, (short)(-1), (short)(-1), (short)78, (short)79, (short)(-1), (short)(-1), (short)82, (short)83, (short)28, (short)85, (short)(-1), (short)87, (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)100, (short)(-1), (short)102, (short)103, (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)110, (short)111, (short)112, (short)113, (short)(-1), (short)(-1), (short)(-1), (short)117, (short)118, (short)(-1), (short)(-1), (short)121, (short)(-1), (short)123, (short)124, (short)(-1), (short)(-1), (short)71, (short)72, (short)73, (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)140, (short)(-1), (short)142, (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)102, (short)103, (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)109, (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)118, (short)(-1), (short)(-1), (short)121, (short)(-1), (short)123, (short)124, (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)129, (short)130, (short)131, (short)132, (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)141, (short)142, (short)1, (short)(-1), (short)3, (short)4, (short)5, (short)6, (short)(-1), (short)8, (short)9, (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)28, (short)29, (short)30, (short)31, (short)32, (short)33, (short)34, (short)35, (short)36, (short)37, (short)38, (short)39, (short)40, (short)41, (short)42, (short)43, (short)44, (short)45, (short)46, (short)47, (short)48, (short)49, (short)50, (short)(-1), (short)52, (short)53, (short)54, (short)55, (short)56, (short)57, (short)58, (short)59, (short)60, (short)61, (short)62, (short)(-1), (short)(-1), (short)(-1), (short)66, (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)71, (short)72, (short)73, (short)74, (short)75, (short)(-1), (short)77, (short)(-1), (short)79, (short)(-1), (short)(-1), (short)82, (short)83, (short)(-1), (short)85, (short)(-1), (short)87, (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)100, (short)(-1), (short)102, (short)103, (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)109, (short)110, (short)111, (short)112, (short)113, (short)(-1), (short)(-1), (short)(-1), (short)117, (short)118, (short)(-1), (short)(-1), (short)121, (short)(-1), (short)123, (short)124, (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)129, (short)130, (short)131, (short)132, (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)140, (short)141, (short)1, (short)(-1), (short)3, (short)4, (short)5, (short)6, (short)(-1), (short)8, (short)9, (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)28, (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)1, (short)(-1), (short)3, (short)4, (short)5, (short)6, (short)(-1), (short)8, (short)9, (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)52, (short)53, (short)54, (short)55, (short)56, (short)57, (short)58, (short)59, (short)60, (short)61, (short)62, (short)28, (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)71, (short)72, (short)73, (short)(-1), (short)(-1), (short)(-1), (short)1, (short)(-1), (short)3, (short)4, (short)5, (short)6, (short)(-1), (short)8, (short)9, (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)102, (short)103, (short)28, (short)(-1), (short)71, (short)72, (short)73, (short)109, (short)(-1), (short)(-1), (short)1, (short)(-1), (short)3, (short)4, (short)5, (short)6, (short)118, (short)8, (short)9, (short)121, (short)(-1), (short)123, (short)124, (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)129, (short)130, (short)131, (short)132, (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)102, (short)103, (short)28, (short)140, (short)141, (short)(-1), (short)(-1), (short)109, (short)(-1), (short)(-1), (short)71, (short)72, (short)73, (short)(-1), (short)(-1), (short)(-1), (short)118, (short)(-1), (short)(-1), (short)121, (short)122, (short)123, (short)124, (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)129, (short)130, (short)131, (short)132, (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)141, (short)(-1), (short)102, (short)103, (short)(-1), (short)(-1), (short)71, (short)72, (short)73, (short)109, (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)118, (short)(-1), (short)(-1), (short)121, (short)(-1), (short)123, (short)124, (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)129, (short)130, (short)131, (short)132, (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)102, (short)103, (short)(-1), (short)(-1), (short)141, (short)(-1), (short)(-1), (short)109, (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)118, (short)(-1), (short)(-1), (short)121, (short)(-1), (short)123, (short)124, (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)129, (short)130, (short)131, (short)132, (short)1, (short)(-1), (short)3, (short)4, (short)5, (short)(-1), (short)(-1), (short)(-1), (short)141, (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)28, (short)29, (short)30, (short)31, (short)32, (short)33, (short)34, (short)35, (short)36, (short)37, (short)38, (short)39, (short)40, (short)41, (short)42, (short)43, (short)44, (short)45, (short)46, (short)47, (short)48, (short)49, (short)50, (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)1, (short)(-1), (short)3, (short)4, (short)5, (short)6, (short)(-1), (short)8, (short)9, (short)66, (short)(-1), (short)68, (short)(-1), (short)(-1), (short)71, (short)72, (short)(-1), (short)74, (short)75, (short)(-1), (short)(-1), (short)78, (short)79, (short)(-1), (short)(-1), (short)82, (short)83, (short)28, (short)85, (short)(-1), (short)87, (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)100, (short)(-1), (short)102, (short)103, (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)110, (short)111, (short)112, (short)113, (short)(-1), (short)(-1), (short)(-1), (short)117, (short)118, (short)(-1), (short)(-1), (short)121, (short)(-1), (short)123, (short)124, (short)(-1), (short)(-1), (short)71, (short)72, (short)73, (short)1, (short)(-1), (short)3, (short)4, (short)5, (short)6, (short)(-1), (short)8, (short)9, (short)(-1), (short)140, (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)28, (short)102, (short)103, (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)109, (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)118, (short)(-1), (short)(-1), (short)121, (short)122, (short)123, (short)124, (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)129, (short)130, (short)131, (short)132, (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)140, (short)(-1), (short)(-1), (short)(-1), (short)71, (short)72, (short)73, (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)102, (short)103, (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)109, (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)3, (short)(-1), (short)118, (short)(-1), (short)(-1), (short)121, (short)(-1), (short)123, (short)124, (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)129, (short)130, (short)131, (short)132, (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)140, (short)28, (short)29, (short)30, (short)31, (short)32, (short)33, (short)34, (short)35, (short)36, (short)37, (short)38, (short)39, (short)40, (short)41, (short)42, (short)43, (short)44, (short)45, (short)46, (short)47, (short)48, (short)49, (short)50, (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)66, (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)74, (short)75, (short)(-1), (short)(-1), (short)(-1), (short)79, (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)85, (short)(-1), (short)87, (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)100, (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)110, (short)111, (short)112, (short)113, (short)(-1), (short)(-1), (short)(-1), (short)117, (short)118, (short)3, (short)(-1), (short)121, (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)126, (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)141, (short)(-1), (short)(-1), (short)28, (short)29, (short)30, (short)31, (short)32, (short)33, (short)34, (short)35, (short)36, (short)37, (short)38, (short)39, (short)40, (short)41, (short)42, (short)43, (short)44, (short)45, (short)46, (short)47, (short)48, (short)49, (short)50, (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)66, (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)74, (short)75, (short)(-1), (short)(-1), (short)(-1), (short)79, (short)(-1), (short)(-1), (short)82, (short)83, (short)(-1), (short)85, (short)(-1), (short)87, (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)100, (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)110, (short)111, (short)112, (short)113, (short)(-1), (short)(-1), (short)3, (short)117, (short)118, (short)(-1), (short)(-1), (short)121, (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)138, (short)(-1), (short)140, (short)28, (short)29, (short)30, (short)31, (short)32, (short)33, (short)34, (short)35, (short)36, (short)37, (short)38, (short)39, (short)40, (short)41, (short)42, (short)43, (short)44, (short)45, (short)46, (short)47, (short)48, (short)49, (short)50, (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)66, (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)74, (short)75, (short)(-1), (short)(-1), (short)(-1), (short)79, (short)(-1), (short)(-1), (short)82, (short)83, (short)(-1), (short)85, (short)(-1), (short)87, (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)100, (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)110, (short)111, (short)112, (short)113, (short)(-1), (short)(-1), (short)3, (short)117, (short)118, (short)(-1), (short)(-1), (short)121, (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)140, (short)28, (short)29, (short)30, (short)31, (short)32, (short)33, (short)34, (short)35, (short)36, (short)37, (short)38, (short)39, (short)40, (short)41, (short)42, (short)43, (short)44, (short)45, (short)46, (short)47, (short)48, (short)49, (short)50, (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)66, (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)74, (short)75, (short)(-1), (short)(-1), (short)(-1), (short)79, (short)(-1), (short)(-1), (short)82, (short)83, (short)(-1), (short)85, (short)(-1), (short)87, (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)100, (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)110, (short)111, (short)112, (short)113, (short)(-1), (short)(-1), (short)(-1), (short)117, (short)118, (short)(-1), (short)1, (short)121, (short)3, (short)4, (short)5, (short)6, (short)126, (short)8, (short)9, (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)139, (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)28, (short)29, (short)30, (short)31, (short)32, (short)33, (short)34, (short)35, (short)36, (short)37, (short)38, (short)39, (short)40, (short)41, (short)42, (short)43, (short)44, (short)45, (short)46, (short)47, (short)48, (short)49, (short)50, (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)66, (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)71, (short)72, (short)73, (short)74, (short)75, (short)(-1), (short)(-1), (short)(-1), (short)79, (short)(-1), (short)(-1), (short)82, (short)83, (short)(-1), (short)85, (short)(-1), (short)87, (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)100, (short)(-1), (short)102, (short)103, (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)109, (short)110, (short)111, (short)112, (short)113, (short)(-1), (short)(-1), (short)(-1), (short)117, (short)118, (short)(-1), (short)(-1), (short)121, (short)(-1), (short)123, (short)124, (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)129, (short)130, (short)131, (short)132, (short)1, (short)(-1), (short)3, (short)4, (short)5, (short)6, (short)(-1), (short)8, (short)9, (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)28, (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)34, (short)35, (short)36, (short)37, (short)38, (short)39, (short)40, (short)41, (short)42, (short)43, (short)44, (short)45, (short)46, (short)47, (short)48, (short)49, (short)50, (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)66, (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)71, (short)72, (short)73, (short)74, (short)75, (short)(-1), (short)(-1), (short)(-1), (short)79, (short)(-1), (short)(-1), (short)82, (short)83, (short)(-1), (short)85, (short)(-1), (short)87, (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)100, (short)(-1), (short)102, (short)103, (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)109, (short)110, (short)111, (short)112, (short)113, (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)118, (short)(-1), (short)(-1), (short)121, (short)122, (short)123, (short)124, (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)129, (short)130, (short)131, (short)132, (short)1, (short)(-1), (short)3, (short)4, (short)5, (short)6, (short)(-1), (short)8, (short)9, (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)28, (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)34, (short)35, (short)36, (short)37, (short)38, (short)39, (short)40, (short)41, (short)42, (short)43, (short)44, (short)45, (short)46, (short)47, (short)48, (short)49, (short)50, (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)66, (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)71, (short)72, (short)73, (short)74, (short)75, (short)(-1), (short)(-1), (short)(-1), (short)79, (short)(-1), (short)(-1), (short)82, (short)83, (short)(-1), (short)85, (short)(-1), (short)87, (short)1, (short)(-1), (short)3, (short)4, (short)5, (short)6, (short)(-1), (short)8, (short)9, (short)(-1), (short)(-1), (short)(-1), (short)100, (short)(-1), (short)102, (short)103, (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)109, (short)110, (short)111, (short)112, (short)113, (short)(-1), (short)28, (short)(-1), (short)(-1), (short)118, (short)(-1), (short)(-1), (short)121, (short)122, (short)123, (short)124, (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)129, (short)130, (short)131, (short)132, (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)1, (short)(-1), (short)3, (short)4, (short)5, (short)6, (short)(-1), (short)8, (short)9, (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)71, (short)72, (short)73, (short)74, (short)75, (short)(-1), (short)(-1), (short)(-1), (short)79, (short)(-1), (short)(-1), (short)28, (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)1, (short)(-1), (short)3, (short)4, (short)5, (short)6, (short)(-1), (short)8, (short)9, (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)102, (short)103, (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)109, (short)110, (short)111, (short)(-1), (short)(-1), (short)(-1), (short)28, (short)(-1), (short)(-1), (short)118, (short)(-1), (short)(-1), (short)121, (short)122, (short)123, (short)124, (short)71, (short)72, (short)73, (short)(-1), (short)129, (short)130, (short)131, (short)132, (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)102, (short)103, (short)71, (short)72, (short)73, (short)(-1), (short)(-1), (short)109, (short)(-1), (short)(-1), (short)1, (short)(-1), (short)3, (short)4, (short)5, (short)6, (short)118, (short)8, (short)9, (short)121, (short)(-1), (short)123, (short)124, (short)(-1), (short)(-1), (short)127, (short)(-1), (short)129, (short)130, (short)131, (short)132, (short)(-1), (short)(-1), (short)102, (short)103, (short)(-1), (short)(-1), (short)28, (short)(-1), (short)(-1), (short)109, (short)(-1), (short)(-1), (short)1, (short)(-1), (short)3, (short)4, (short)5, (short)6, (short)118, (short)8, (short)9, (short)121, (short)(-1), (short)123, (short)124, (short)(-1), (short)(-1), (short)127, (short)(-1), (short)129, (short)130, (short)131, (short)132, (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)28, (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)71, (short)72, (short)73, (short)1, (short)(-1), (short)3, (short)4, (short)5, (short)6, (short)(-1), (short)8, (short)9, (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)28, (short)102, (short)103, (short)71, (short)72, (short)73, (short)(-1), (short)(-1), (short)109, (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)118, (short)(-1), (short)(-1), (short)121, (short)(-1), (short)123, (short)124, (short)(-1), (short)(-1), (short)127, (short)(-1), (short)129, (short)130, (short)131, (short)132, (short)(-1), (short)(-1), (short)102, (short)103, (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)109, (short)(-1), (short)71, (short)72, (short)73, (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)118, (short)(-1), (short)(-1), (short)121, (short)122, (short)123, (short)124, (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)129, (short)130, (short)131, (short)132, (short)1, (short)(-1), (short)3, (short)4, (short)5, (short)6, (short)(-1), (short)8, (short)9, (short)102, (short)103, (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)109, (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)118, (short)(-1), (short)28, (short)121, (short)122, (short)123, (short)124, (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)129, (short)130, (short)131, (short)132, (short)1, (short)(-1), (short)3, (short)4, (short)5, (short)6, (short)(-1), (short)8, (short)9, (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)28, (short)(-1), (short)(-1), (short)71, (short)72, (short)73, (short)1, (short)(-1), (short)3, (short)4, (short)5, (short)6, (short)(-1), (short)8, (short)9, (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)28, (short)102, (short)103, (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)109, (short)(-1), (short)71, (short)72, (short)73, (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)118, (short)(-1), (short)(-1), (short)121, (short)122, (short)123, (short)124, (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)129, (short)130, (short)131, (short)132, (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)102, (short)103, (short)71, (short)72, (short)73, (short)(-1), (short)(-1), (short)109, (short)(-1), (short)(-1), (short)1, (short)(-1), (short)3, (short)4, (short)5, (short)6, (short)118, (short)8, (short)9, (short)121, (short)(-1), (short)123, (short)124, (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)129, (short)130, (short)131, (short)132, (short)(-1), (short)(-1), (short)102, (short)103, (short)(-1), (short)(-1), (short)28, (short)(-1), (short)(-1), (short)109, (short)(-1), (short)(-1), (short)1, (short)(-1), (short)3, (short)4, (short)5, (short)6, (short)118, (short)8, (short)9, (short)121, (short)(-1), (short)123, (short)124, (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)129, (short)130, (short)131, (short)132, (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)28, (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)71, (short)72, (short)73, (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)102, (short)103, (short)71, (short)72, (short)73, (short)(-1), (short)(-1), (short)109, (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)118, (short)(-1), (short)(-1), (short)121, (short)(-1), (short)123, (short)124, (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)129, (short)130, (short)131, (short)132, (short)(-1), (short)(-1), (short)102, (short)103, (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)3, (short)109, (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)118, (short)(-1), (short)(-1), (short)121, (short)(-1), (short)123, (short)124, (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)129, (short)130, (short)131, (short)132, (short)28, (short)29, (short)30, (short)31, (short)32, (short)33, (short)34, (short)35, (short)36, (short)37, (short)38, (short)39, (short)40, (short)41, (short)42, (short)43, (short)44, (short)45, (short)46, (short)47, (short)48, (short)49, (short)50, (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)66, (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)74, (short)75, (short)(-1), (short)(-1), (short)(-1), (short)79, (short)(-1), (short)(-1), (short)82, (short)83, (short)(-1), (short)85, (short)(-1), (short)87, (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)100, (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)3, (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)110, (short)111, (short)112, (short)113, (short)(-1), (short)(-1), (short)(-1), (short)117, (short)118, (short)(-1), (short)(-1), (short)121, (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)126, (short)(-1), (short)(-1), (short)129, (short)28, (short)29, (short)30, (short)31, (short)32, (short)33, (short)34, (short)35, (short)36, (short)37, (short)38, (short)39, (short)40, (short)41, (short)42, (short)43, (short)44, (short)45, (short)46, (short)47, (short)48, (short)49, (short)50, (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)65, (short)66, (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)74, (short)75, (short)(-1), (short)(-1), (short)(-1), (short)79, (short)(-1), (short)(-1), (short)82, (short)83, (short)(-1), (short)85, (short)(-1), (short)87, (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)100, (short)(-1), (short)3, (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)110, (short)111, (short)112, (short)113, (short)(-1), (short)(-1), (short)(-1), (short)117, (short)118, (short)(-1), (short)(-1), (short)121, (short)122, (short)(-1), (short)(-1), (short)(-1), (short)126, (short)28, (short)29, (short)30, (short)31, (short)32, (short)33, (short)34, (short)35, (short)36, (short)37, (short)38, (short)39, (short)40, (short)41, (short)42, (short)43, (short)44, (short)45, (short)46, (short)47, (short)48, (short)49, (short)50, (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)65, (short)66, (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)74, (short)75, (short)(-1), (short)(-1), (short)(-1), (short)79, (short)(-1), (short)(-1), (short)82, (short)83, (short)(-1), (short)85, (short)(-1), (short)87, (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)100, (short)(-1), (short)3, (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)110, (short)111, (short)112, (short)113, (short)(-1), (short)(-1), (short)(-1), (short)117, (short)118, (short)(-1), (short)(-1), (short)121, (short)122, (short)(-1), (short)(-1), (short)(-1), (short)126, (short)28, (short)29, (short)30, (short)31, (short)32, (short)33, (short)34, (short)35, (short)36, (short)37, (short)38, (short)39, (short)40, (short)41, (short)42, (short)43, (short)44, (short)45, (short)46, (short)47, (short)48, (short)49, (short)50, (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)66, (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)74, (short)75, (short)(-1), (short)(-1), (short)(-1), (short)79, (short)(-1), (short)(-1), (short)82, (short)83, (short)(-1), (short)85, (short)(-1), (short)87, (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)100, (short)(-1), (short)3, (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)110, (short)111, (short)112, (short)113, (short)(-1), (short)(-1), (short)(-1), (short)117, (short)118, (short)(-1), (short)(-1), (short)121, (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)126, (short)28, (short)29, (short)30, (short)31, (short)32, (short)33, (short)34, (short)35, (short)36, (short)37, (short)38, (short)39, (short)40, (short)41, (short)42, (short)43, (short)44, (short)45, (short)46, (short)47, (short)48, (short)49, (short)50, (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)66, (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)74, (short)75, (short)(-1), (short)(-1), (short)(-1), (short)79, (short)(-1), (short)(-1), (short)82, (short)83, (short)(-1), (short)85, (short)(-1), (short)87, (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)100, (short)(-1), (short)3, (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)110, (short)111, (short)112, (short)113, (short)(-1), (short)(-1), (short)(-1), (short)117, (short)118, (short)(-1), (short)(-1), (short)121, (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)126, (short)28, (short)29, (short)30, (short)31, (short)32, (short)33, (short)34, (short)35, (short)36, (short)37, (short)38, (short)39, (short)40, (short)41, (short)42, (short)43, (short)44, (short)45, (short)46, (short)47, (short)48, (short)49, (short)50, (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)66, (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)74, (short)75, (short)(-1), (short)(-1), (short)(-1), (short)79, (short)(-1), (short)(-1), (short)82, (short)83, (short)(-1), (short)85, (short)(-1), (short)87, (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)100, (short)(-1), (short)3, (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)110, (short)111, (short)112, (short)113, (short)(-1), (short)(-1), (short)(-1), (short)117, (short)118, (short)(-1), (short)(-1), (short)121, (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)126, (short)28, (short)29, (short)30, (short)31, (short)32, (short)33, (short)34, (short)35, (short)36, (short)37, (short)38, (short)39, (short)40, (short)41, (short)42, (short)43, (short)44, (short)45, (short)46, (short)47, (short)48, (short)49, (short)50, (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)66, (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)74, (short)75, (short)(-1), (short)(-1), (short)(-1), (short)79, (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)85, (short)(-1), (short)87, (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)100, (short)(-1), (short)3, (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)110, (short)111, (short)112, (short)113, (short)(-1), (short)(-1), (short)(-1), (short)117, (short)118, (short)(-1), (short)(-1), (short)121, (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)126, (short)28, (short)29, (short)30, (short)31, (short)32, (short)33, (short)34, (short)35, (short)36, (short)37, (short)38, (short)39, (short)40, (short)41, (short)42, (short)43, (short)44, (short)45, (short)46, (short)47, (short)48, (short)49, (short)50, (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)66, (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)74, (short)75, (short)(-1), (short)(-1), (short)(-1), (short)79, (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)85, (short)(-1), (short)87, (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)3, (short)(-1), (short)(-1), (short)100, (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)110, (short)111, (short)112, (short)113, (short)(-1), (short)(-1), (short)(-1), (short)117, (short)118, (short)(-1), (short)(-1), (short)121, (short)28, (short)(-1), (short)(-1), (short)(-1), (short)126, (short)(-1), (short)34, (short)35, (short)36, (short)37, (short)38, (short)39, (short)40, (short)41, (short)42, (short)43, (short)44, (short)45, (short)46, (short)47, (short)48, (short)49, (short)50, (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)66, (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)74, (short)75, (short)(-1), (short)(-1), (short)(-1), (short)79, (short)(-1), (short)(-1), (short)82, (short)83, (short)(-1), (short)85, (short)(-1), (short)87, (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)100, (short)(-1), (short)3, (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)110, (short)111, (short)112, (short)113, (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)118, (short)(-1), (short)(-1), (short)121, (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)126, (short)28, (short)29, (short)30, (short)31, (short)32, (short)33, (short)34, (short)35, (short)36, (short)37, (short)38, (short)39, (short)40, (short)41, (short)42, (short)43, (short)44, (short)45, (short)46, (short)47, (short)48, (short)49, (short)50, (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)65, (short)66, (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)74, (short)75, (short)(-1), (short)(-1), (short)(-1), (short)79, (short)(-1), (short)(-1), (short)82, (short)83, (short)(-1), (short)85, (short)(-1), (short)87, (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)3, (short)(-1), (short)100, (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)110, (short)111, (short)112, (short)113, (short)(-1), (short)(-1), (short)(-1), (short)117, (short)118, (short)(-1), (short)(-1), (short)121, (short)122, (short)28, (short)29, (short)30, (short)31, (short)32, (short)33, (short)34, (short)35, (short)36, (short)37, (short)38, (short)39, (short)40, (short)41, (short)42, (short)43, (short)44, (short)45, (short)46, (short)47, (short)48, (short)49, (short)50, (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)65, (short)66, (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)74, (short)75, (short)(-1), (short)(-1), (short)(-1), (short)79, (short)(-1), (short)(-1), (short)82, (short)83, (short)(-1), (short)85, (short)(-1), (short)87, (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)3, (short)(-1), (short)100, (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)110, (short)111, (short)112, (short)113, (short)(-1), (short)(-1), (short)(-1), (short)117, (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)122, (short)28, (short)29, (short)30, (short)31, (short)32, (short)33, (short)34, (short)35, (short)36, (short)37, (short)38, (short)39, (short)40, (short)41, (short)42, (short)43, (short)44, (short)45, (short)46, (short)47, (short)48, (short)49, (short)50, (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)65, (short)66, (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)74, (short)75, (short)(-1), (short)(-1), (short)(-1), (short)79, (short)(-1), (short)(-1), (short)82, (short)83, (short)(-1), (short)85, (short)(-1), (short)87, (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)3, (short)(-1), (short)100, (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)110, (short)111, (short)112, (short)113, (short)(-1), (short)(-1), (short)(-1), (short)117, (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)122, (short)28, (short)29, (short)30, (short)31, (short)32, (short)33, (short)34, (short)35, (short)36, (short)37, (short)38, (short)39, (short)40, (short)41, (short)42, (short)43, (short)44, (short)45, (short)46, (short)47, (short)48, (short)49, (short)50, (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)65, (short)66, (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)74, (short)75, (short)(-1), (short)(-1), (short)(-1), (short)79, (short)(-1), (short)(-1), (short)82, (short)83, (short)(-1), (short)85, (short)(-1), (short)87, (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)3, (short)(-1), (short)100, (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)110, (short)111, (short)112, (short)113, (short)(-1), (short)(-1), (short)(-1), (short)117, (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)122, (short)28, (short)29, (short)30, (short)31, (short)32, (short)33, (short)34, (short)35, (short)36, (short)37, (short)38, (short)39, (short)40, (short)41, (short)42, (short)43, (short)44, (short)45, (short)46, (short)47, (short)48, (short)49, (short)50, (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)66, (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)74, (short)75, (short)(-1), (short)(-1), (short)(-1), (short)79, (short)(-1), (short)(-1), (short)82, (short)83, (short)(-1), (short)85, (short)(-1), (short)87, (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)3, (short)(-1), (short)(-1), (short)100, (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)110, (short)111, (short)112, (short)113, (short)(-1), (short)(-1), (short)(-1), (short)117, (short)118, (short)(-1), (short)(-1), (short)121, (short)28, (short)29, (short)30, (short)31, (short)32, (short)33, (short)34, (short)35, (short)36, (short)37, (short)38, (short)39, (short)40, (short)41, (short)42, (short)43, (short)44, (short)45, (short)46, (short)47, (short)48, (short)49, (short)50, (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)66, (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)74, (short)75, (short)(-1), (short)(-1), (short)(-1), (short)79, (short)(-1), (short)(-1), (short)82, (short)83, (short)(-1), (short)85, (short)(-1), (short)87, (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)3, (short)(-1), (short)(-1), (short)100, (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)110, (short)111, (short)112, (short)113, (short)(-1), (short)(-1), (short)(-1), (short)117, (short)(-1), (short)(-1), (short)(-1), (short)121, (short)28, (short)29, (short)30, (short)31, (short)32, (short)33, (short)34, (short)35, (short)36, (short)37, (short)38, (short)39, (short)40, (short)41, (short)42, (short)43, (short)44, (short)45, (short)46, (short)47, (short)48, (short)49, (short)50, (short)51, (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)65, (short)66, (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)74, (short)75, (short)(-1), (short)(-1), (short)(-1), (short)79, (short)(-1), (short)(-1), (short)82, (short)83, (short)(-1), (short)85, (short)(-1), (short)87, (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)3, (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)100, (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)110, (short)111, (short)112, (short)113, (short)(-1), (short)(-1), (short)(-1), (short)117, (short)28, (short)29, (short)30, (short)31, (short)32, (short)33, (short)34, (short)35, (short)36, (short)37, (short)38, (short)39, (short)40, (short)41, (short)42, (short)43, (short)44, (short)45, (short)46, (short)47, (short)48, (short)49, (short)50, (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)65, (short)66, (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)74, (short)75, (short)(-1), (short)(-1), (short)(-1), (short)79, (short)(-1), (short)(-1), (short)82, (short)83, (short)(-1), (short)85, (short)(-1), (short)87, (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)3, (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)100, (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)110, (short)111, (short)112, (short)113, (short)(-1), (short)(-1), (short)(-1), (short)117, (short)28, (short)29, (short)30, (short)31, (short)32, (short)33, (short)34, (short)35, (short)36, (short)37, (short)38, (short)39, (short)40, (short)41, (short)42, (short)43, (short)44, (short)45, (short)46, (short)47, (short)48, (short)49, (short)50, (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)66, (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)74, (short)75, (short)(-1), (short)(-1), (short)(-1), (short)79, (short)(-1), (short)(-1), (short)82, (short)83, (short)(-1), (short)85, (short)(-1), (short)87, (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)3, (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)100, (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)110, (short)111, (short)112, (short)113, (short)(-1), (short)(-1), (short)(-1), (short)117, (short)28, (short)29, (short)30, (short)31, (short)32, (short)33, (short)34, (short)35, (short)36, (short)37, (short)38, (short)39, (short)40, (short)41, (short)42, (short)43, (short)44, (short)45, (short)46, (short)47, (short)48, (short)49, (short)50, (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)66, (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)74, (short)75, (short)(-1), (short)(-1), (short)(-1), (short)79, (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)85, (short)(-1), (short)87, (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)3, (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)100, (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)110, (short)111, (short)112, (short)113, (short)(-1), (short)(-1), (short)(-1), (short)117, (short)28, (short)29, (short)30, (short)31, (short)32, (short)33, (short)34, (short)35, (short)36, (short)37, (short)38, (short)39, (short)40, (short)41, (short)42, (short)43, (short)44, (short)45, (short)46, (short)47, (short)48, (short)49, (short)50, (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)66, (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)74, (short)75, (short)(-1), (short)(-1), (short)(-1), (short)79, (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)85, (short)(-1), (short)87, (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)100, (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)110, (short)111, (short)112, (short)113, (short)(-1), (short)(-1), (short)(-1), (short)117 }; static const yytype_uint16 yystos[] = { (unsigned short)0, (unsigned short)3, (unsigned short)28, (unsigned short)29, (unsigned short)30, (unsigned short)31, (unsigned short)32, (unsigned short)33, (unsigned short)34, (unsigned short)35, (unsigned short)36, (unsigned short)37, (unsigned short)38, (unsigned short)39, (unsigned short)40, (unsigned short)41, (unsigned short)42, (unsigned short)43, (unsigned short)44, (unsigned short)45, (unsigned short)46, (unsigned short)47, (unsigned short)48, (unsigned short)49, (unsigned short)50, (unsigned short)65, (unsigned short)66, (unsigned short)74, (unsigned short)75, (unsigned short)79, (unsigned short)82, (unsigned short)83, (unsigned short)85, (unsigned short)87, (unsigned short)100, (unsigned short)110, (unsigned short)111, (unsigned short)112, (unsigned short)113, (unsigned short)117, (unsigned short)144, (unsigned short)145, (unsigned short)146, (unsigned short)147, (unsigned short)148, (unsigned short)153, (unsigned short)183, (unsigned short)184, (unsigned short)189, (unsigned short)190, (unsigned short)191, (unsigned short)195, (unsigned short)196, (unsigned short)197, (unsigned short)198, (unsigned short)200, (unsigned short)201, (unsigned short)207, (unsigned short)215, (unsigned short)216, (unsigned short)234, (unsigned short)265, (unsigned short)141, (unsigned short)148, (unsigned short)153, (unsigned short)121, (unsigned short)121, (unsigned short)119, (unsigned short)1, (unsigned short)118, (unsigned short)119, (unsigned short)153, (unsigned short)118, (unsigned short)121, (unsigned short)126, (unsigned short)129, (unsigned short)144, (unsigned short)153, (unsigned short)189, (unsigned short)190, (unsigned short)197, (unsigned short)198, (unsigned short)200, (unsigned short)216, (unsigned short)219, (unsigned short)221, (unsigned short)223, (unsigned short)224, (unsigned short)226, (unsigned short)227, (unsigned short)228, (unsigned short)231, (unsigned short)121, (unsigned short)141, (unsigned short)147, (unsigned short)148, (unsigned short)153, (unsigned short)190, (unsigned short)138, (unsigned short)0, (unsigned short)153, (unsigned short)217, (unsigned short)218, (unsigned short)141, (unsigned short)141, (unsigned short)1, (unsigned short)4, (unsigned short)5, (unsigned short)6, (unsigned short)8, (unsigned short)9, (unsigned short)71, (unsigned short)72, (unsigned short)73, (unsigned short)102, (unsigned short)103, (unsigned short)109, (unsigned short)118, (unsigned short)121, (unsigned short)123, (unsigned short)124, (unsigned short)129, (unsigned short)130, (unsigned short)131, (unsigned short)132, (unsigned short)146, (unsigned short)153, (unsigned short)154, (unsigned short)155, (unsigned short)156, (unsigned short)159, (unsigned short)160, (unsigned short)161, (unsigned short)162, (unsigned short)163, (unsigned short)164, (unsigned short)165, (unsigned short)166, (unsigned short)167, (unsigned short)168, (unsigned short)169, (unsigned short)170, (unsigned short)171, (unsigned short)172, (unsigned short)173, (unsigned short)174, (unsigned short)175, (unsigned short)252, (unsigned short)255, (unsigned short)146, (unsigned short)153, (unsigned short)146, (unsigned short)153, (unsigned short)160, (unsigned short)165, (unsigned short)183, (unsigned short)202, (unsigned short)203, (unsigned short)204, (unsigned short)205, (unsigned short)206, (unsigned short)197, (unsigned short)230, (unsigned short)231, (unsigned short)122, (unsigned short)153, (unsigned short)221, (unsigned short)223, (unsigned short)232, (unsigned short)233, (unsigned short)234, (unsigned short)127, (unsigned short)146, (unsigned short)174, (unsigned short)178, (unsigned short)121, (unsigned short)153, (unsigned short)190, (unsigned short)223, (unsigned short)231, (unsigned short)219, (unsigned short)224, (unsigned short)227, (unsigned short)231, (unsigned short)121, (unsigned short)126, (unsigned short)190, (unsigned short)121, (unsigned short)126, (unsigned short)122, (unsigned short)153, (unsigned short)232, (unsigned short)235, (unsigned short)190, (unsigned short)219, (unsigned short)228, (unsigned short)121, (unsigned short)68, (unsigned short)78, (unsigned short)121, (unsigned short)123, (unsigned short)140, (unsigned short)142, (unsigned short)149, (unsigned short)150, (unsigned short)151, (unsigned short)152, (unsigned short)153, (unsigned short)156, (unsigned short)183, (unsigned short)190, (unsigned short)208, (unsigned short)209, (unsigned short)210, (unsigned short)211, (unsigned short)212, (unsigned short)224, (unsigned short)225, (unsigned short)227, (unsigned short)231, (unsigned short)254, (unsigned short)255, (unsigned short)257, (unsigned short)141, (unsigned short)141, (unsigned short)141, (unsigned short)148, (unsigned short)153, (unsigned short)178, (unsigned short)139, (unsigned short)128, (unsigned short)142, (unsigned short)217, (unsigned short)217, (unsigned short)121, (unsigned short)160, (unsigned short)121, (unsigned short)160, (unsigned short)160, (unsigned short)153, (unsigned short)183, (unsigned short)178, (unsigned short)183, (unsigned short)178, (unsigned short)121, (unsigned short)160, (unsigned short)122, (unsigned short)175, (unsigned short)177, (unsigned short)180, (unsigned short)197, (unsigned short)198, (unsigned short)200, (unsigned short)216, (unsigned short)236, (unsigned short)252, (unsigned short)141, (unsigned short)141, (unsigned short)7, (unsigned short)8, (unsigned short)9, (unsigned short)121, (unsigned short)125, (unsigned short)126, (unsigned short)153, (unsigned short)18, (unsigned short)19, (unsigned short)20, (unsigned short)21, (unsigned short)22, (unsigned short)23, (unsigned short)24, (unsigned short)25, (unsigned short)26, (unsigned short)27, (unsigned short)139, (unsigned short)176, (unsigned short)162, (unsigned short)118, (unsigned short)133, (unsigned short)134, (unsigned short)130, (unsigned short)131, (unsigned short)10, (unsigned short)11, (unsigned short)165, (unsigned short)12, (unsigned short)13, (unsigned short)119, (unsigned short)120, (unsigned short)14, (unsigned short)15, (unsigned short)129, (unsigned short)135, (unsigned short)136, (unsigned short)16, (unsigned short)17, (unsigned short)137, (unsigned short)122, (unsigned short)122, (unsigned short)122, (unsigned short)139, (unsigned short)121, (unsigned short)190, (unsigned short)221, (unsigned short)231, (unsigned short)139, (unsigned short)11, (unsigned short)120, (unsigned short)128, (unsigned short)197, (unsigned short)231, (unsigned short)122, (unsigned short)122, (unsigned short)122, (unsigned short)128, (unsigned short)127, (unsigned short)127, (unsigned short)231, (unsigned short)219, (unsigned short)228, (unsigned short)122, (unsigned short)232, (unsigned short)127, (unsigned short)146, (unsigned short)178, (unsigned short)127, (unsigned short)146, (unsigned short)178, (unsigned short)122, (unsigned short)122, (unsigned short)128, (unsigned short)3, (unsigned short)28, (unsigned short)44, (unsigned short)74, (unsigned short)75, (unsigned short)122, (unsigned short)192, (unsigned short)193, (unsigned short)194, (unsigned short)34, (unsigned short)35, (unsigned short)36, (unsigned short)37, (unsigned short)38, (unsigned short)39, (unsigned short)40, (unsigned short)41, (unsigned short)42, (unsigned short)43, (unsigned short)46, (unsigned short)47, (unsigned short)50, (unsigned short)66, (unsigned short)85, (unsigned short)87, (unsigned short)100, (unsigned short)112, (unsigned short)113, (unsigned short)148, (unsigned short)153, (unsigned short)185, (unsigned short)189, (unsigned short)197, (unsigned short)199, (unsigned short)201, (unsigned short)207, (unsigned short)215, (unsigned short)183, (unsigned short)225, (unsigned short)118, (unsigned short)121, (unsigned short)153, (unsigned short)183, (unsigned short)141, (unsigned short)246, (unsigned short)247, (unsigned short)247, (unsigned short)247, (unsigned short)140, (unsigned short)247, (unsigned short)139, (unsigned short)121, (unsigned short)138, (unsigned short)140, (unsigned short)153, (unsigned short)190, (unsigned short)213, (unsigned short)214, (unsigned short)224, (unsigned short)225, (unsigned short)229, (unsigned short)231, (unsigned short)227, (unsigned short)231, (unsigned short)142, (unsigned short)212, (unsigned short)128, (unsigned short)140, (unsigned short)190, (unsigned short)227, (unsigned short)140, (unsigned short)140, (unsigned short)208, (unsigned short)142, (unsigned short)208, (unsigned short)142, (unsigned short)208, (unsigned short)141, (unsigned short)141, (unsigned short)178, (unsigned short)218, (unsigned short)140, (unsigned short)142, (unsigned short)140, (unsigned short)142, (unsigned short)144, (unsigned short)153, (unsigned short)181, (unsigned short)197, (unsigned short)198, (unsigned short)200, (unsigned short)216, (unsigned short)237, (unsigned short)121, (unsigned short)126, (unsigned short)190, (unsigned short)220, (unsigned short)222, (unsigned short)231, (unsigned short)153, (unsigned short)186, (unsigned short)189, (unsigned short)197, (unsigned short)199, (unsigned short)200, (unsigned short)216, (unsigned short)126, (unsigned short)222, (unsigned short)186, (unsigned short)237, (unsigned short)122, (unsigned short)128, (unsigned short)153, (unsigned short)197, (unsigned short)198, (unsigned short)200, (unsigned short)216, (unsigned short)221, (unsigned short)122, (unsigned short)125, (unsigned short)140, (unsigned short)141, (unsigned short)142, (unsigned short)156, (unsigned short)157, (unsigned short)174, (unsigned short)182, (unsigned short)189, (unsigned short)197, (unsigned short)198, (unsigned short)200, (unsigned short)216, (unsigned short)239, (unsigned short)256, (unsigned short)258, (unsigned short)259, (unsigned short)260, (unsigned short)261, (unsigned short)262, (unsigned short)263, (unsigned short)264, (unsigned short)142, (unsigned short)264, (unsigned short)153, (unsigned short)122, (unsigned short)157, (unsigned short)158, (unsigned short)175, (unsigned short)153, (unsigned short)177, (unsigned short)157, (unsigned short)175, (unsigned short)162, (unsigned short)162, (unsigned short)162, (unsigned short)163, (unsigned short)163, (unsigned short)164, (unsigned short)164, (unsigned short)165, (unsigned short)165, (unsigned short)165, (unsigned short)167, (unsigned short)167, (unsigned short)168, (unsigned short)169, (unsigned short)170, (unsigned short)171, (unsigned short)172, (unsigned short)177, (unsigned short)183, (unsigned short)203, (unsigned short)204, (unsigned short)231, (unsigned short)203, (unsigned short)204, (unsigned short)205, (unsigned short)51, (unsigned short)234, (unsigned short)122, (unsigned short)127, (unsigned short)127, (unsigned short)127, (unsigned short)127, (unsigned short)153, (unsigned short)122, (unsigned short)121, (unsigned short)122, (unsigned short)128, (unsigned short)193, (unsigned short)148, (unsigned short)153, (unsigned short)121, (unsigned short)121, (unsigned short)119, (unsigned short)141, (unsigned short)153, (unsigned short)189, (unsigned short)197, (unsigned short)199, (unsigned short)221, (unsigned short)153, (unsigned short)190, (unsigned short)225, (unsigned short)190, (unsigned short)121, (unsigned short)142, (unsigned short)52, (unsigned short)53, (unsigned short)54, (unsigned short)55, (unsigned short)56, (unsigned short)57, (unsigned short)58, (unsigned short)59, (unsigned short)60, (unsigned short)61, (unsigned short)62, (unsigned short)77, (unsigned short)140, (unsigned short)153, (unsigned short)177, (unsigned short)179, (unsigned short)182, (unsigned short)241, (unsigned short)242, (unsigned short)243, (unsigned short)244, (unsigned short)245, (unsigned short)247, (unsigned short)248, (unsigned short)249, (unsigned short)250, (unsigned short)251, (unsigned short)253, (unsigned short)239, (unsigned short)122, (unsigned short)178, (unsigned short)141, (unsigned short)224, (unsigned short)231, (unsigned short)128, (unsigned short)140, (unsigned short)138, (unsigned short)195, (unsigned short)190, (unsigned short)224, (unsigned short)227, (unsigned short)209, (unsigned short)227, (unsigned short)142, (unsigned short)142, (unsigned short)142, (unsigned short)208, (unsigned short)142, (unsigned short)208, (unsigned short)208, (unsigned short)208, (unsigned short)144, (unsigned short)197, (unsigned short)198, (unsigned short)200, (unsigned short)216, (unsigned short)221, (unsigned short)122, (unsigned short)122, (unsigned short)222, (unsigned short)232, (unsigned short)178, (unsigned short)220, (unsigned short)231, (unsigned short)121, (unsigned short)126, (unsigned short)220, (unsigned short)119, (unsigned short)126, (unsigned short)153, (unsigned short)189, (unsigned short)197, (unsigned short)199, (unsigned short)200, (unsigned short)216, (unsigned short)222, (unsigned short)178, (unsigned short)126, (unsigned short)126, (unsigned short)222, (unsigned short)122, (unsigned short)175, (unsigned short)162, (unsigned short)252, (unsigned short)142, (unsigned short)264, (unsigned short)139, (unsigned short)153, (unsigned short)189, (unsigned short)197, (unsigned short)198, (unsigned short)200, (unsigned short)216, (unsigned short)225, (unsigned short)229, (unsigned short)247, (unsigned short)128, (unsigned short)140, (unsigned short)140, (unsigned short)259, (unsigned short)261, (unsigned short)262, (unsigned short)142, (unsigned short)142, (unsigned short)122, (unsigned short)128, (unsigned short)127, (unsigned short)138, (unsigned short)221, (unsigned short)177, (unsigned short)122, (unsigned short)193, (unsigned short)175, (unsigned short)146, (unsigned short)153, (unsigned short)206, (unsigned short)69, (unsigned short)70, (unsigned short)142, (unsigned short)119, (unsigned short)141, (unsigned short)141, (unsigned short)153, (unsigned short)148, (unsigned short)153, (unsigned short)122, (unsigned short)178, (unsigned short)138, (unsigned short)121, (unsigned short)121, (unsigned short)121, (unsigned short)241, (unsigned short)121, (unsigned short)153, (unsigned short)140, (unsigned short)140, (unsigned short)140, (unsigned short)177, (unsigned short)153, (unsigned short)138, (unsigned short)140, (unsigned short)140, (unsigned short)153, (unsigned short)187, (unsigned short)188, (unsigned short)223, (unsigned short)179, (unsigned short)244, (unsigned short)179, (unsigned short)241, (unsigned short)142, (unsigned short)140, (unsigned short)142, (unsigned short)264, (unsigned short)224, (unsigned short)190, (unsigned short)214, (unsigned short)224, (unsigned short)231, (unsigned short)178, (unsigned short)224, (unsigned short)142, (unsigned short)142, (unsigned short)142, (unsigned short)142, (unsigned short)122, (unsigned short)122, (unsigned short)127, (unsigned short)220, (unsigned short)122, (unsigned short)232, (unsigned short)178, (unsigned short)206, (unsigned short)178, (unsigned short)119, (unsigned short)126, (unsigned short)127, (unsigned short)178, (unsigned short)178, (unsigned short)126, (unsigned short)142, (unsigned short)239, (unsigned short)260, (unsigned short)157, (unsigned short)175, (unsigned short)174, (unsigned short)122, (unsigned short)122, (unsigned short)122, (unsigned short)122, (unsigned short)120, (unsigned short)247, (unsigned short)247, (unsigned short)206, (unsigned short)69, (unsigned short)70, (unsigned short)142, (unsigned short)69, (unsigned short)70, (unsigned short)142, (unsigned short)141, (unsigned short)138, (unsigned short)241, (unsigned short)177, (unsigned short)177, (unsigned short)122, (unsigned short)177, (unsigned short)56, (unsigned short)122, (unsigned short)248, (unsigned short)140, (unsigned short)140, (unsigned short)139, (unsigned short)241, (unsigned short)141, (unsigned short)128, (unsigned short)140, (unsigned short)139, (unsigned short)142, (unsigned short)224, (unsigned short)231, (unsigned short)190, (unsigned short)224, (unsigned short)138, (unsigned short)122, (unsigned short)127, (unsigned short)120, (unsigned short)127, (unsigned short)206, (unsigned short)178, (unsigned short)127, (unsigned short)127, (unsigned short)178, (unsigned short)70, (unsigned short)142, (unsigned short)69, (unsigned short)142, (unsigned short)120, (unsigned short)247, (unsigned short)247, (unsigned short)247, (unsigned short)247, (unsigned short)69, (unsigned short)70, (unsigned short)142, (unsigned short)241, (unsigned short)122, (unsigned short)122, (unsigned short)241, (unsigned short)122, (unsigned short)121, (unsigned short)241, (unsigned short)122, (unsigned short)248, (unsigned short)178, (unsigned short)142, (unsigned short)264, (unsigned short)188, (unsigned short)141, (unsigned short)175, (unsigned short)238, (unsigned short)224, (unsigned short)224, (unsigned short)178, (unsigned short)120, (unsigned short)127, (unsigned short)127, (unsigned short)247, (unsigned short)247, (unsigned short)70, (unsigned short)142, (unsigned short)69, (unsigned short)142, (unsigned short)70, (unsigned short)142, (unsigned short)69, (unsigned short)142, (unsigned short)247, (unsigned short)247, (unsigned short)241, (unsigned short)241, (unsigned short)241, (unsigned short)177, (unsigned short)241, (unsigned short)122, (unsigned short)177, (unsigned short)140, (unsigned short)142, (unsigned short)238, (unsigned short)240, (unsigned short)142, (unsigned short)142, (unsigned short)247, (unsigned short)247, (unsigned short)247, (unsigned short)247, (unsigned short)70, (unsigned short)142, (unsigned short)69, (unsigned short)142, (unsigned short)64, (unsigned short)122, (unsigned short)241, (unsigned short)122, (unsigned short)128, (unsigned short)142, (unsigned short)142, (unsigned short)142, (unsigned short)142, (unsigned short)142, (unsigned short)247, (unsigned short)247, (unsigned short)241, (unsigned short)140, (unsigned short)241, (unsigned short)142, (unsigned short)238, (unsigned short)142, (unsigned short)142 }; void exit(int status); void * calloc(size_t nmemb, size_t size); void free(void * ptr); void * realloc(void * ptr, size_t size); long int strtol(const char * nptr, char ** endptr, int base); long long int strtoll(const char * nptr, char ** endptr, int base); unsigned long long int strtoull(const char * nptr, char ** endptr, int base); typedef __builtin_va_list va_list; typedef void FILE; FILE * bsl_stdin(void); FILE * bsl_stdout(void); FILE * bsl_stderr(void); char * fgets(char * s, int size, FILE * stream); FILE * fopen(const char * path, const char * mode); int fclose(FILE * fp); int fflush(FILE * stream); int fgetc(FILE * stream); int fprintf(FILE * stream, const char * format, ...); int fputc(int c, FILE * stream); size_t fread(void * ptr, size_t size, size_t nmemb, FILE * stream); size_t fwrite(const void * ptr, size_t size, size_t nmemb, FILE * stream); int vsnprintf(char *, size_t, const char *, ...); int snprintf(char * str, size_t, const char * format, ...); int fseek(FILE * stream, long offset, int whence); long ftell(FILE * stream); int feof(FILE * stream); int ferror(FILE * stream); int fileno(FILE * stream); static void yy_symbol_value_print(FILE * yyoutput, int yytype, YYSTYPE const * const yyvaluep, struct Location const * const yylocationp) { if(!yyvaluep) return ; ((void)(yylocationp)); ((void)(yyoutput)); switch(yytype) { default: break; } } static void yy_symbol_print(FILE * yyoutput, int yytype, YYSTYPE const * const yyvaluep, struct Location const * const yylocationp) { if(yytype < 143) fprintf(yyoutput, "token %s (", yytname[yytype]); else fprintf(yyoutput, "nterm %s (", yytname[yytype]); ((void)0); fprintf(yyoutput, ": "); yy_symbol_value_print(yyoutput, yytype, yyvaluep, yylocationp); fprintf(yyoutput, ")"); } static void yy_stack_print(yytype_int16 * yybottom, yytype_int16 * yytop) { fprintf((bsl_stderr()), "Stack now"); for(; yybottom <= yytop; yybottom++) { int yybot = *yybottom; fprintf((bsl_stderr()), " %d", yybot); } fprintf((bsl_stderr()), "\n"); } static void yy_reduce_print(YYSTYPE * yyvsp, struct Location * yylsp, int yyrule) { int yynrhs = yyr2[yyrule]; int yyi; unsigned long int yylno = yyrline[yyrule]; fprintf((bsl_stderr()), "Reducing stack by rule %d (line %lu):\n", yyrule - 1, yylno); for(yyi = 0; yyi < yynrhs; yyi++) { fprintf((bsl_stderr()), " $%d = ", yyi + 1); yy_symbol_print((bsl_stderr()), yyrhs[yyprhs[yyrule] + yyi], &(yyvsp[(yyi + 1) - (yynrhs)]), &(yylsp[(yyi + 1) - (yynrhs)])); fprintf((bsl_stderr()), "\n"); } } int type_yydebug; extern void FreeSpecifier(struct Specifier * spec); extern void FreeClassFunction(struct ClassFunction * func); extern void FreeIdentifier(struct Identifier * id); extern void FreeExpression(struct Expression * exp); extern void FreeList(struct __ecereNameSpace__ecere__sys__OldList * list, void (* FreeFunction)(void * )); extern void FreeDeclaration(struct Declaration * decl); extern void FreeInitDeclarator(struct InitDeclarator * decl); extern void FreeExtDecl(struct ExtDecl * extDecl); extern void FreeAttribute(struct Attribute * attr); extern void FreeAttrib(struct Attrib * attr); extern void FreeTemplateDataType(struct TemplateDatatype * type); extern void FreeTemplateArgument(struct TemplateArgument * arg); extern void FreeClassDef(struct ClassDef * def); extern void FreeMemberInit(struct MemberInit * init); extern void FreeProperty(struct PropertyDef * def); extern void FreeDeclarator(struct Declarator * decl); extern void FreeEnumerator(struct Enumerator * enumerator); extern void FreePointer(struct Pointer * pointer); extern void FreeTypeName(struct TypeName * typeName); extern void FreeInitializer(struct Initializer * initializer); extern void FreeStatement(struct Statement * stmt); extern void PopContext(struct Context * ctx); extern void FreeContext(struct Context * context); extern void FreeInstance(struct Instantiation * inst); extern void FreeMembersInit(struct MembersInit * init); static void yydestruct(const char * yymsg, int yytype, YYSTYPE * yyvaluep, struct Location * yylocationp) { ((void)(yyvaluep)); ((void)(yylocationp)); if(!yymsg) yymsg = "Deleting"; do { if(type_yydebug) { fprintf((bsl_stderr()), "%s ", yymsg); yy_symbol_print((bsl_stderr()), yytype, yyvaluep, yylocationp); fprintf((bsl_stderr()), "\n"); } }while((0)); switch(yytype) { case 144: { FreeSpecifier((*yyvaluep).specifier); } ; break; case 146: { FreeSpecifier((*yyvaluep).specifier); } ; break; case 147: { FreeSpecifier((*yyvaluep).specifier); } ; break; case 148: { FreeSpecifier((*yyvaluep).specifier); } ; break; case 149: { FreeClassFunction((*yyvaluep).classFunction); } ; break; case 150: { FreeClassFunction((*yyvaluep).classFunction); } ; break; case 151: { FreeClassFunction((*yyvaluep).classFunction); } ; break; case 152: { FreeClassFunction((*yyvaluep).classFunction); } ; break; case 153: { FreeIdentifier((*yyvaluep).id); } ; break; case 154: { FreeExpression((*yyvaluep).exp); } ; break; case 156: { FreeExpression((*yyvaluep).exp); } ; break; case 158: { FreeList((*yyvaluep).list, FreeExpression); } ; break; case 160: { FreeExpression((*yyvaluep).exp); } ; break; case 162: { FreeExpression((*yyvaluep).exp); } ; break; case 163: { FreeExpression((*yyvaluep).exp); } ; break; case 164: { FreeExpression((*yyvaluep).exp); } ; break; case 165: { FreeExpression((*yyvaluep).exp); } ; break; case 167: { FreeExpression((*yyvaluep).exp); } ; break; case 168: { FreeExpression((*yyvaluep).exp); } ; break; case 169: { FreeExpression((*yyvaluep).exp); } ; break; case 170: { FreeExpression((*yyvaluep).exp); } ; break; case 171: { FreeExpression((*yyvaluep).exp); } ; break; case 172: { FreeExpression((*yyvaluep).exp); } ; break; case 173: { FreeExpression((*yyvaluep).exp); } ; break; case 174: { FreeExpression((*yyvaluep).exp); } ; break; case 175: { FreeExpression((*yyvaluep).exp); } ; break; case 177: { FreeList((*yyvaluep).list, FreeExpression); } ; break; case 178: { FreeExpression((*yyvaluep).exp); } ; break; case 179: { FreeDeclaration((*yyvaluep).declaration); } ; break; case 180: { FreeList((*yyvaluep).list, FreeSpecifier); } ; break; case 181: { FreeList((*yyvaluep).list, FreeSpecifier); } ; break; case 182: { FreeList((*yyvaluep).list, FreeSpecifier); } ; break; case 183: { FreeList((*yyvaluep).list, FreeSpecifier); } ; break; case 187: { FreeList((*yyvaluep).list, FreeInitDeclarator); } ; break; case 188: { FreeInitDeclarator((*yyvaluep).initDeclarator); } ; break; case 189: { FreeSpecifier((*yyvaluep).specifier); } ; break; case 190: { FreeExtDecl((*yyvaluep).extDecl); } ; break; case 192: { (__ecereNameSpace__ecere__com__eSystem_Delete((*yyvaluep).string), (*yyvaluep).string = 0); } ; break; case 193: { FreeAttribute((*yyvaluep).attribute); } ; break; case 194: { FreeList((*yyvaluep).list, FreeAttribute); } ; break; case 195: { FreeAttrib((*yyvaluep).attrib); } ; break; case 196: { FreeSpecifier((*yyvaluep).specifier); } ; break; case 197: { FreeSpecifier((*yyvaluep).specifier); } ; break; case 198: { FreeSpecifier((*yyvaluep).specifier); } ; break; case 199: { FreeSpecifier((*yyvaluep).specifier); } ; break; case 200: { FreeSpecifier((*yyvaluep).specifier); } ; break; case 201: { FreeSpecifier((*yyvaluep).specifier); } ; break; case 202: { FreeTemplateDataType((*yyvaluep).templateDatatype); } ; break; case 203: { FreeTemplateArgument((*yyvaluep).templateArgument); } ; break; case 204: { FreeTemplateArgument((*yyvaluep).templateArgument); } ; break; case 205: { FreeTemplateArgument((*yyvaluep).templateArgument); } ; break; case 208: { FreeList((*yyvaluep).list, FreeClassDef); } ; break; case 209: { FreeMemberInit((*yyvaluep).memberInit); } ; break; case 210: { FreeList((*yyvaluep).list, FreeMemberInit); } ; break; case 211: { FreeProperty((*yyvaluep).prop); } ; break; case 212: { FreeClassDef((*yyvaluep).classDef); } ; break; case 213: { FreeList((*yyvaluep).list, FreeDeclarator); } ; break; case 214: { FreeDeclarator((*yyvaluep).declarator); } ; break; case 215: { FreeSpecifier((*yyvaluep).specifier); } ; break; case 216: { FreeSpecifier((*yyvaluep).specifier); } ; break; case 217: { FreeList((*yyvaluep).list, FreeEnumerator); } ; break; case 218: { FreeEnumerator((*yyvaluep).enumerator); } ; break; case 219: { FreeDeclarator((*yyvaluep).declarator); } ; break; case 220: { FreeDeclarator((*yyvaluep).declarator); } ; break; case 221: { FreeDeclarator((*yyvaluep).declarator); } ; break; case 222: { FreeDeclarator((*yyvaluep).declarator); } ; break; case 223: { FreeDeclarator((*yyvaluep).declarator); } ; break; case 224: { FreeDeclarator((*yyvaluep).declarator); } ; break; case 225: { FreeDeclarator((*yyvaluep).declarator); } ; break; case 226: { FreeDeclarator((*yyvaluep).declarator); } ; break; case 227: { FreeDeclarator((*yyvaluep).declarator); } ; break; case 228: { FreeDeclarator((*yyvaluep).declarator); } ; break; case 229: { FreeDeclarator((*yyvaluep).declarator); } ; break; case 230: { FreeList((*yyvaluep).list, FreeSpecifier); } ; break; case 231: { FreePointer((*yyvaluep).pointer); } ; break; case 232: { FreeList((*yyvaluep).list, FreeTypeName); } ; break; case 233: { FreeList((*yyvaluep).list, FreeTypeName); } ; break; case 234: { FreeTypeName((*yyvaluep).typeName); } ; break; case 235: { FreeList((*yyvaluep).list, FreeTypeName); } ; break; case 236: { FreeTypeName((*yyvaluep).typeName); } ; break; case 237: { FreeTypeName((*yyvaluep).typeName); } ; break; case 238: { FreeInitializer((*yyvaluep).initializer); } ; break; case 239: { FreeInitializer((*yyvaluep).initializer); } ; break; case 240: { FreeList((*yyvaluep).list, FreeInitializer); } ; break; case 241: { FreeStatement((*yyvaluep).stmt); } ; break; case 242: { FreeStatement((*yyvaluep).stmt); } ; break; case 243: { FreeList((*yyvaluep).list, FreeDeclaration); } ; break; case 244: { FreeList((*yyvaluep).list, FreeStatement); } ; break; case 245: { FreeStatement((*yyvaluep).stmt); } ; break; case 246: { PopContext((*yyvaluep).context); FreeContext((*yyvaluep).context); (((*yyvaluep).context ? (__ecereClass_Context->Destructor ? __ecereClass_Context->Destructor((*yyvaluep).context) : 0, __ecereNameSpace__ecere__com__eSystem_Delete((*yyvaluep).context)) : 0), (*yyvaluep).context = 0); } ; break; case 247: { FreeStatement((*yyvaluep).stmt); } ; break; case 248: { FreeStatement((*yyvaluep).stmt); } ; break; case 249: { FreeStatement((*yyvaluep).stmt); } ; break; case 250: { FreeStatement((*yyvaluep).stmt); } ; break; case 251: { FreeStatement((*yyvaluep).stmt); } ; break; case 252: { (__ecereNameSpace__ecere__com__eSystem_Delete((*yyvaluep).string), (*yyvaluep).string = 0); } ; break; case 253: { FreeInstance((*yyvaluep).instance); } ; break; case 255: { FreeInstance((*yyvaluep).instance); } ; break; case 257: { FreeClassFunction((*yyvaluep).classFunction); } ; break; case 258: { FreeClassFunction((*yyvaluep).classFunction); } ; break; case 259: { FreeClassFunction((*yyvaluep).classFunction); } ; break; case 260: { FreeMemberInit((*yyvaluep).memberInit); } ; break; case 261: { FreeList((*yyvaluep).list, FreeMemberInit); } ; break; case 262: { FreeList((*yyvaluep).list, FreeMemberInit); } ; break; case 263: { FreeList((*yyvaluep).list, FreeMembersInit); } ; break; case 264: { FreeList((*yyvaluep).list, FreeMembersInit); } ; break; default: break; } } int type_yyparse(void); int type_yychar; YYSTYPE type_yylval; struct Location type_yylloc; int type_yynerrs; extern struct Symbol * DeclClass(int symbolID, char * name); extern void resetScannerPos(struct CodePosition * pos); extern char * strcpy(char * , const char * ); extern char * strcat(char * , const char * ); extern struct Symbol * _DeclClass(int symbolID, char * name); extern struct Specifier * MkSpecifierName(char * name); extern void SetClassTemplateArgs(struct Specifier * spec, struct __ecereNameSpace__ecere__sys__OldList * templateArgs); extern struct ClassFunction * MkClassFunction(struct __ecereNameSpace__ecere__sys__OldList * specifiers, struct Specifier * _class, struct Declarator * decl, struct __ecereNameSpace__ecere__sys__OldList * declList); extern struct Context * globalContext; extern struct Identifier * MkIdentifier(char * string); extern struct Expression * MkExpBrackets(struct __ecereNameSpace__ecere__sys__OldList * expressions); extern struct Expression * MkExpIdentifier(struct Identifier * id); extern struct Expression * MkExpInstance(struct Instantiation * inst); extern struct Expression * MkExpConstant(char * string); extern struct Expression * MkExpString(char * string); extern struct Expression * MkExpIntlString(char * string, char * context); extern struct Expression * MkExpDummy(void); extern struct __ecereNameSpace__ecere__sys__OldList * MkListOne(void * item); extern struct Expression * MkExpNew(struct TypeName * type, struct Expression * size); extern struct TypeName * MkTypeName(struct __ecereNameSpace__ecere__sys__OldList * qualifiers, struct Declarator * declarator); extern struct Expression * MkExpNew0(struct TypeName * type, struct Expression * size); extern struct Expression * MkExpRenew(struct Expression * memExp, struct TypeName * type, struct Expression * size); extern struct Expression * MkExpRenew0(struct Expression * memExp, struct TypeName * type, struct Expression * size); extern struct Expression * MkExpIndex(struct Expression * expression, struct __ecereNameSpace__ecere__sys__OldList * index); extern struct Expression * MkExpCall(struct Expression * expression, struct __ecereNameSpace__ecere__sys__OldList * arguments); extern struct __ecereNameSpace__ecere__sys__OldList * MkList(void); extern struct Expression * MkExpMember(struct Expression * expression, struct Identifier * member); extern size_t strlen(const char * ); extern struct Expression * MkExpPointer(struct Expression * expression, struct Identifier * member); extern struct Expression * MkExpOp(struct Expression * exp1, int op, struct Expression * exp2); extern void ListAdd(struct __ecereNameSpace__ecere__sys__OldList * list, void * item); extern struct Expression * MkExpTypeSize(struct TypeName * typeName); extern struct Expression * MkExpTypeAlign(struct TypeName * typeName); extern struct Expression * MkExpCast(struct TypeName * typeName, struct Expression * expression); extern unsigned int skipErrors; extern struct Expression * MkExpCondition(struct Expression * cond, struct __ecereNameSpace__ecere__sys__OldList * expressions, struct Expression * elseExp); extern struct Declaration * MkDeclaration(struct __ecereNameSpace__ecere__sys__OldList * specifiers, struct __ecereNameSpace__ecere__sys__OldList * initDeclarators); extern struct Declaration * MkDeclarationInst(struct Instantiation * inst); extern struct Declaration * MkDeclarationDefine(struct Identifier * id, struct Expression * exp); extern struct Specifier * MkSpecifierNameArgs(char * name, struct __ecereNameSpace__ecere__sys__OldList * templateArgs); extern struct InitDeclarator * MkInitDeclarator(struct Declarator * declarator, struct Initializer * initializer); extern struct Specifier * MkSpecifier(int specifier); extern struct ExtDecl * MkExtDeclString(char * s); extern char * __ecereNameSpace__ecere__sys__CopyString(char * string); extern struct ExtDecl * MkExtDeclAttrib(struct Attrib * attr); extern struct Attribute * MkAttribute(char * attr, struct Expression * exp); extern struct Attrib * MkAttrib(int type, struct __ecereNameSpace__ecere__sys__OldList * attribs); extern struct Specifier * MkSpecifierExtended(struct ExtDecl * extDecl); extern struct Specifier * MkSpecifierTypeOf(struct Expression * expression); extern struct Specifier * MkSpecifierSubClass(struct Specifier * _class); extern struct Specifier * MkStructOrUnion(int type, struct Identifier * id, struct __ecereNameSpace__ecere__sys__OldList * definitions); extern int declMode; extern struct TemplateDatatype * MkTemplateDatatype(struct __ecereNameSpace__ecere__sys__OldList * specifiers, struct Declarator * decl); extern struct TemplateArgument * MkTemplateTypeArgument(struct TemplateDatatype * tplDatatype); extern struct TemplateArgument * MkTemplateExpressionArgument(struct Expression * expr); extern struct MemberInit * MkMemberInitExp(struct Expression * idExp, struct Initializer * initializer); extern struct PropertyDef * MkProperty(struct __ecereNameSpace__ecere__sys__OldList * specs, struct Declarator * decl, struct Identifier * id, struct Statement * setStmt, struct Statement * getStmt); extern struct ClassDef * MkClassDefDeclaration(struct Declaration * decl); extern struct Declaration * MkStructDeclaration(struct __ecereNameSpace__ecere__sys__OldList * specifiers, struct __ecereNameSpace__ecere__sys__OldList * declarators, struct Specifier * extStorage); extern struct Declaration * MkDeclarationClassInst(struct Instantiation * inst); extern struct ClassDef * MkClassDefFunction(struct ClassFunction * function); extern struct ClassDef * MkClassDefDefaultProperty(struct __ecereNameSpace__ecere__sys__OldList * defProperties); extern struct ClassDef * MkClassDefProperty(struct PropertyDef * propertyDef); extern struct Declarator * MkStructDeclarator(struct Declarator * declarator, struct Expression * exp); extern struct Specifier * MkEnum(struct Identifier * id, struct __ecereNameSpace__ecere__sys__OldList * list); extern struct Enumerator * MkEnumerator(struct Identifier * id, struct Expression * exp); extern struct Declarator * MkDeclaratorBrackets(struct Declarator * declarator); extern struct Declarator * MkDeclaratorArray(struct Declarator * declarator, struct Expression * exp); extern struct Declarator * MkDeclaratorEnumArray(struct Declarator * declarator, struct Specifier * _class); extern struct Declarator * MkDeclaratorFunction(struct Declarator * declarator, struct __ecereNameSpace__ecere__sys__OldList * parameters); extern struct Declarator * MkDeclaratorPointer(struct Pointer * pointer, struct Declarator * declarator); extern struct Declarator * MkDeclaratorExtended(struct ExtDecl * extended, struct Declarator * declarator); extern struct Declarator * MkDeclaratorExtendedEnd(struct ExtDecl * extended, struct Declarator * declarator); extern struct Declarator * MkDeclaratorIdentifier(struct Identifier * id); extern struct Pointer * MkPointer(struct __ecereNameSpace__ecere__sys__OldList * qualifiers, struct Pointer * pointer); extern struct Initializer * MkInitializerAssignment(struct Expression * exp); extern struct Initializer * MkInitializerList(struct __ecereNameSpace__ecere__sys__OldList * list); extern struct Statement * MkLabeledStmt(struct Identifier * id, struct Statement * statement); extern struct Statement * MkCaseStmt(struct Expression * exp, struct Statement * statement); extern struct Statement * MkBadDeclStmt(struct Declaration * decl); extern struct Statement * MkCompoundStmt(struct __ecereNameSpace__ecere__sys__OldList * declarations, struct __ecereNameSpace__ecere__sys__OldList * statements); extern struct Context * PushContext(void); extern struct Statement * MkExpressionStmt(struct __ecereNameSpace__ecere__sys__OldList * expressions); extern struct Statement * MkIfStmt(struct __ecereNameSpace__ecere__sys__OldList * exp, struct Statement * statement, struct Statement * elseStmt); extern struct Statement * MkSwitchStmt(struct __ecereNameSpace__ecere__sys__OldList * exp, struct Statement * statement); extern struct Statement * MkWhileStmt(struct __ecereNameSpace__ecere__sys__OldList * exp, struct Statement * statement); extern struct Statement * MkDoWhileStmt(struct Statement * statement, struct __ecereNameSpace__ecere__sys__OldList * exp); extern struct Statement * MkForStmt(struct Statement * init, struct Statement * check, struct __ecereNameSpace__ecere__sys__OldList * inc, struct Statement * statement); extern struct Statement * MkGotoStmt(struct Identifier * id); extern struct Statement * MkContinueStmt(void); extern struct Statement * MkBreakStmt(void); extern struct Statement * MkReturnStmt(struct __ecereNameSpace__ecere__sys__OldList * exp); extern struct Instantiation * MkInstantiationNamed(struct __ecereNameSpace__ecere__sys__OldList * specs, struct Expression * exp, struct __ecereNameSpace__ecere__sys__OldList * members); extern struct Instantiation * MkInstantiation(struct Specifier * _class, struct Expression * exp, struct __ecereNameSpace__ecere__sys__OldList * members); extern void ProcessClassFunctionBody(struct ClassFunction * func, struct Statement * body); extern struct MemberInit * MkMemberInit(struct __ecereNameSpace__ecere__sys__OldList * ids, struct Initializer * initializer); extern struct MembersInit * MkMembersInitList(struct __ecereNameSpace__ecere__sys__OldList * dataMembers); extern struct MembersInit * MkMembersInitMethod(struct ClassFunction * function); int __ecereVMethodID___ecereNameSpace__ecere__sys__File_Seek; extern struct __ecereNameSpace__ecere__com__Class * __ecereClass___ecereNameSpace__ecere__sys__File; int type_yyparse(void) { int yystate; int yyerrstatus; yytype_int16 yyssa[200]; yytype_int16 * yyss; yytype_int16 * yyssp; YYSTYPE yyvsa[200]; YYSTYPE * yyvs; YYSTYPE * yyvsp; struct Location yylsa[200]; struct Location * yyls; struct Location * yylsp; struct Location yyerror_range[2]; unsigned int yystacksize; int yyn; int yyresult; int yytoken; YYSTYPE yyval; struct Location yyloc; int yylen = 0; yytoken = 0; yyss = yyssa; yyvs = yyvsa; yyls = yylsa; yystacksize = 200; do { if(type_yydebug) fprintf((bsl_stderr()), "Starting parse\n"); }while((0)); yystate = 0; yyerrstatus = 0; type_yynerrs = 0; type_yychar = (-2); yyssp = yyss; yyvsp = yyvs; yylsp = yyls; goto yysetstate; yynewstate: yyssp++; yysetstate: *yyssp = yystate; if(yyss + yystacksize - 1 <= yyssp) { unsigned int yysize = yyssp - yyss + 1; if(10000 <= yystacksize) goto yyexhaustedlab; yystacksize *= 2; if(10000 < yystacksize) yystacksize = 10000; { yytype_int16 * yyss1 = yyss; union yyalloc * yyptr = (union yyalloc *)malloc(((yystacksize) * (sizeof(yytype_int16) + sizeof(YYSTYPE) + sizeof(struct Location)) + 2 * (sizeof(union yyalloc) - 1))); if(!yyptr) goto yyexhaustedlab; do { unsigned int yynewbytes; __builtin_memcpy(&(*yyptr).yyss_alloc, yyss, (yysize) * sizeof (*(yyss))); yyss = &(*yyptr).yyss_alloc; yynewbytes = yystacksize * sizeof (*yyss) + (sizeof(union yyalloc) - 1); yyptr += yynewbytes / sizeof (*yyptr); }while((0)); do { unsigned int yynewbytes; __builtin_memcpy(&(*yyptr).yyvs_alloc, yyvs, (yysize) * sizeof (*(yyvs))); yyvs = &(*yyptr).yyvs_alloc; yynewbytes = yystacksize * sizeof (*yyvs) + (sizeof(union yyalloc) - 1); yyptr += yynewbytes / sizeof (*yyptr); }while((0)); do { unsigned int yynewbytes; __builtin_memcpy(&(*yyptr).yyls_alloc, yyls, (yysize) * sizeof (*(yyls))); yyls = &(*yyptr).yyls_alloc; yynewbytes = yystacksize * sizeof (*yyls) + (sizeof(union yyalloc) - 1); yyptr += yynewbytes / sizeof (*yyptr); }while((0)); if(yyss1 != yyssa) free(yyss1); } yyssp = yyss + yysize - 1; yyvsp = yyvs + yysize - 1; yylsp = yyls + yysize - 1; do { if(type_yydebug) fprintf((bsl_stderr()), "Stack size increased to %lu\n", yystacksize); }while((0)); if(yyss + yystacksize - 1 <= yyssp) goto yyabortlab; } do { if(type_yydebug) fprintf((bsl_stderr()), "Entering state %d\n", yystate); }while((0)); if(yystate == 99) goto yyacceptlab; goto yybackup; yybackup: yyn = yypact[yystate]; if(yyn == -750) goto yydefault; if(type_yychar == (-2)) { do { if(type_yydebug) fprintf((bsl_stderr()), "Reading a token: "); }while((0)); type_yychar = yylex(); } if(type_yychar <= 0) { type_yychar = yytoken = 0; do { if(type_yydebug) fprintf((bsl_stderr()), "Now at end of input.\n"); }while((0)); } else { yytoken = ((unsigned int)(type_yychar) <= 372 ? yytranslate[type_yychar] : 2); do { if(type_yydebug) { fprintf((bsl_stderr()), "%s ", "Next token is"); yy_symbol_print((bsl_stderr()), yytoken, &type_yylval, &type_yylloc); fprintf((bsl_stderr()), "\n"); } }while((0)); } yyn += yytoken; if(yyn < 0 || 8981 < yyn || yycheck[yyn] != yytoken) goto yydefault; yyn = yytable[yyn]; if(yyn <= 0) { if(yyn == 0 || yyn == -496) goto yyerrlab; yyn = -yyn; goto yyreduce; } if(yyerrstatus) yyerrstatus--; do { if(type_yydebug) { fprintf((bsl_stderr()), "%s ", "Shifting"); yy_symbol_print((bsl_stderr()), yytoken, &type_yylval, &type_yylloc); fprintf((bsl_stderr()), "\n"); } }while((0)); type_yychar = (-2); yystate = yyn; *++yyvsp = type_yylval; *++yylsp = type_yylloc; goto yynewstate; yydefault: yyn = yydefact[yystate]; if(yyn == 0) goto yyerrlab; goto yyreduce; yyreduce: yylen = yyr2[yyn]; yyval = yyvsp[1 - yylen]; (yyloc.start = ((yylsp - yylen))[1].start); (yyloc.end = ((yylsp - yylen))[yylen].end); ; do { if(type_yydebug) yy_reduce_print(yyvsp, yylsp, yyn); }while((0)); switch(yyn) { case 2: { yyval.specifier = (((void *)0)); DeclClass(0, yyvsp[(1) - (2)].id->string); ((unsigned int (*)(struct __ecereNameSpace__ecere__com__Instance *, int pos, int mode))__extension__ ({ struct __ecereNameSpace__ecere__com__Instance * __internal_ClassInst = fileInput; __internal_ClassInst ? __internal_ClassInst->_vTbl : __ecereClass___ecereNameSpace__ecere__sys__File->_vTbl; })[__ecereVMethodID___ecereNameSpace__ecere__sys__File_Seek])(fileInput, (yylsp[(1) - (2)]).start.pos, 0); resetScannerPos(&(yylsp[(1) - (2)]).start); (type_yychar = (-2)); FreeIdentifier(yyvsp[(1) - (2)].id); (yyvsp -= (1), yyssp -= (1), yylsp -= (1)); yystate = *yyssp; do { if(type_yydebug) yy_stack_print((yyss), (yyssp)); }while((0)); (yyvsp -= (1), yyssp -= (1), yylsp -= (1)); yystate = *yyssp; do { if(type_yydebug) yy_stack_print((yyss), (yyssp)); }while((0)); goto yysetstate; ; } break; case 3: { yyval.specifier = (((void *)0)); if(yyvsp[(1) - (2)].id->_class) { char name[1024]; strcpy(name, yyvsp[(1) - (2)].id->_class->name ? yyvsp[(1) - (2)].id->_class->name : ""); strcat(name, "::"); strcat(name, yyvsp[(1) - (2)].id->string); _DeclClass(0, name); } else _DeclClass(0, yyvsp[(1) - (2)].id->string); FreeIdentifier(yyvsp[(1) - (2)].id); ((unsigned int (*)(struct __ecereNameSpace__ecere__com__Instance *, int pos, int mode))__extension__ ({ struct __ecereNameSpace__ecere__com__Instance * __internal_ClassInst = fileInput; __internal_ClassInst ? __internal_ClassInst->_vTbl : __ecereClass___ecereNameSpace__ecere__sys__File->_vTbl; })[__ecereVMethodID___ecereNameSpace__ecere__sys__File_Seek])(fileInput, (yylsp[(1) - (2)]).start.pos, 0); resetScannerPos(&(yylsp[(1) - (2)]).start); (type_yychar = (-2)); (yyvsp -= (1), yyssp -= (1), yylsp -= (1)); yystate = *yyssp; do { if(type_yydebug) yy_stack_print((yyss), (yyssp)); }while((0)); (yyvsp -= (1), yyssp -= (1), yylsp -= (1)); yystate = *yyssp; do { if(type_yydebug) yy_stack_print((yyss), (yyssp)); }while((0)); goto yysetstate; ; } break; case 4: { DeclClass(0, yyvsp[(1) - (2)].id->string); ((unsigned int (*)(struct __ecereNameSpace__ecere__com__Instance *, int pos, int mode))__extension__ ({ struct __ecereNameSpace__ecere__com__Instance * __internal_ClassInst = fileInput; __internal_ClassInst ? __internal_ClassInst->_vTbl : __ecereClass___ecereNameSpace__ecere__sys__File->_vTbl; })[__ecereVMethodID___ecereNameSpace__ecere__sys__File_Seek])(fileInput, (yylsp[(1) - (2)]).start.pos, 0); parseTypeError = (unsigned int)0; resetScannerPos(&(yylsp[(1) - (2)]).start); (type_yychar = (-2)); FreeIdentifier(yyvsp[(1) - (2)].id); (yyvsp -= (1), yyssp -= (1), yylsp -= (1)); yystate = *yyssp; do { if(type_yydebug) yy_stack_print((yyss), (yyssp)); }while((0)); (yyvsp -= (1), yyssp -= (1), yylsp -= (1)); yystate = *yyssp; do { if(type_yydebug) yy_stack_print((yyss), (yyssp)); }while((0)); goto yysetstate; ; } break; case 5: { yyval.specifier = yyvsp[(1) - (1)].specifier; ; } break; case 6: { DeclClass(0, yyvsp[(1) - (2)].id->string); ((unsigned int (*)(struct __ecereNameSpace__ecere__com__Instance *, int pos, int mode))__extension__ ({ struct __ecereNameSpace__ecere__com__Instance * __internal_ClassInst = fileInput; __internal_ClassInst ? __internal_ClassInst->_vTbl : __ecereClass___ecereNameSpace__ecere__sys__File->_vTbl; })[__ecereVMethodID___ecereNameSpace__ecere__sys__File_Seek])(fileInput, (yylsp[(1) - (2)]).start.pos, 0); resetScannerPos(&(yylsp[(1) - (2)]).start); (type_yychar = (-2)); FreeIdentifier(yyvsp[(1) - (2)].id); FreeIdentifier(yyvsp[(2) - (2)].id); (yyvsp -= (1), yyssp -= (1), yylsp -= (1)); yystate = *yyssp; do { if(type_yydebug) yy_stack_print((yyss), (yyssp)); }while((0)); (yyvsp -= (1), yyssp -= (1), yylsp -= (1)); yystate = *yyssp; do { if(type_yydebug) yy_stack_print((yyss), (yyssp)); }while((0)); goto yysetstate; ; } break; case 7: { yyval.specifier = MkSpecifierName(yytext); ; } break; case 9: { yyval.specifier = yyvsp[(1) - (4)].specifier; SetClassTemplateArgs(yyval.specifier, yyvsp[(3) - (4)].list); yyval.specifier->loc = (yyloc); ; } break; case 10: { yyval.specifier = yyvsp[(1) - (4)].specifier; SetClassTemplateArgs(yyval.specifier, yyvsp[(3) - (4)].list); yyval.specifier->loc = (yyloc); (yylsp[(4) - (4)]).end.pos--; ((unsigned int (*)(struct __ecereNameSpace__ecere__com__Instance *, int pos, int mode))__extension__ ({ struct __ecereNameSpace__ecere__com__Instance * __internal_ClassInst = fileInput; __internal_ClassInst ? __internal_ClassInst->_vTbl : __ecereClass___ecereNameSpace__ecere__sys__File->_vTbl; })[__ecereVMethodID___ecereNameSpace__ecere__sys__File_Seek])(fileInput, (yylsp[(4) - (4)]).end.pos, 0); resetScannerPos(&(yylsp[(4) - (4)]).end); (type_yychar = (-2)); ; } break; case 11: { yyval.classFunction = MkClassFunction(yyvsp[(1) - (2)].list, (((void *)0)), yyvsp[(2) - (2)].declarator, (((void *)0))); yyval.classFunction->loc = (yyloc); yyval.classFunction->id = ++globalContext->nextID; ; } break; case 12: { yyval.classFunction = MkClassFunction((((void *)0)), (((void *)0)), yyvsp[(1) - (1)].declarator, (((void *)0))); yyval.classFunction->loc = (yyloc); yyval.classFunction->id = ++globalContext->nextID; ; } break; case 13: { yyval.classFunction = MkClassFunction((((void *)0)), (((void *)0)), (((void *)0)), (((void *)0))); yyval.classFunction->isConstructor = 0x1; yyval.classFunction->loc = (yyloc); yyval.classFunction->id = ++globalContext->nextID; FreeList(yyvsp[(1) - (3)].list, FreeSpecifier); ; } break; case 14: { yyval.classFunction = MkClassFunction((((void *)0)), (((void *)0)), (((void *)0)), (((void *)0))); yyval.classFunction->isDestructor = 0x1; yyval.classFunction->loc = (yyloc); yyval.classFunction->id = ++globalContext->nextID; FreeList(yyvsp[(2) - (4)].list, FreeSpecifier); ; } break; case 15: { yyval.classFunction = MkClassFunction(yyvsp[(2) - (3)].list, (((void *)0)), yyvsp[(3) - (3)].declarator, (((void *)0))); yyval.classFunction->isVirtual = 0x1; yyval.classFunction->loc = (yyloc); yyval.classFunction->id = ++globalContext->nextID; ; } break; case 16: { yyval.classFunction = MkClassFunction((((void *)0)), (((void *)0)), yyvsp[(2) - (2)].declarator, (((void *)0))); yyval.classFunction->isVirtual = 0x1; yyval.classFunction->loc = (yyloc); yyval.classFunction->id = ++globalContext->nextID; ; } break; case 17: { yyval.id = MkIdentifier(yytext); yyval.id->loc = (yylsp[(1) - (1)]); ; } break; case 19: { yyval.exp = MkExpBrackets(yyvsp[(2) - (3)].list); yyval.exp->loc = (yyloc); ; } break; case 20: { yyval.exp = MkExpIdentifier(yyvsp[(1) - (1)].id); yyval.exp->loc = (yyloc); ; } break; case 21: { yyval.exp = MkExpInstance(yyvsp[(1) - (1)].instance); yyval.exp->loc = (yyloc); ; } break; case 22: { yyval.exp = MkExpConstant(yytext); yyval.exp->loc = (yyloc); ; } break; case 23: { yyval.exp = MkExpString(yyvsp[(1) - (1)].string); (__ecereNameSpace__ecere__com__eSystem_Delete(yyvsp[(1) - (1)].string), yyvsp[(1) - (1)].string = 0); yyval.exp->loc = (yyloc); ; } break; case 24: { yyval.exp = MkExpIntlString(yyvsp[(2) - (2)].string, (((void *)0))); (__ecereNameSpace__ecere__com__eSystem_Delete(yyvsp[(2) - (2)].string), yyvsp[(2) - (2)].string = 0); yyval.exp->loc = (yyloc); ; } break; case 25: { yyval.exp = MkExpIntlString(yyvsp[(4) - (4)].string, yyvsp[(2) - (4)].string); (__ecereNameSpace__ecere__com__eSystem_Delete(yyvsp[(2) - (4)].string), yyvsp[(2) - (4)].string = 0); (__ecereNameSpace__ecere__com__eSystem_Delete(yyvsp[(4) - (4)].string), yyvsp[(4) - (4)].string = 0); yyval.exp->loc = (yyloc); ; } break; case 26: { struct Expression * exp = MkExpDummy(); exp->loc.start = (yylsp[(1) - (2)]).end; exp->loc.end = (yylsp[(2) - (2)]).start; yyval.exp = MkExpBrackets(MkListOne(exp)); yyval.exp->loc = (yyloc); yyerror(); ; } break; case 27: { yyval.exp = MkExpNew(MkTypeName(yyvsp[(2) - (6)].list, yyvsp[(3) - (6)].declarator), yyvsp[(5) - (6)].exp); yyval.exp->loc = (yyloc); ; } break; case 28: { yyval.exp = MkExpNew(MkTypeName(yyvsp[(2) - (5)].list, (((void *)0))), yyvsp[(4) - (5)].exp); yyval.exp->loc = (yyloc); ; } break; case 29: { yyval.exp = MkExpNew0(MkTypeName(yyvsp[(2) - (6)].list, yyvsp[(3) - (6)].declarator), yyvsp[(5) - (6)].exp); yyval.exp->loc = (yyloc); ; } break; case 30: { yyval.exp = MkExpNew0(MkTypeName(yyvsp[(2) - (5)].list, (((void *)0))), yyvsp[(4) - (5)].exp); yyval.exp->loc = (yyloc); ; } break; case 31: { yyval.exp = MkExpRenew(yyvsp[(2) - (7)].exp, MkTypeName(yyvsp[(3) - (7)].list, yyvsp[(4) - (7)].declarator), yyvsp[(6) - (7)].exp); yyval.exp->loc = (yyloc); ; } break; case 32: { yyval.exp = MkExpRenew(yyvsp[(2) - (6)].exp, MkTypeName(yyvsp[(3) - (6)].list, (((void *)0))), yyvsp[(5) - (6)].exp); yyval.exp->loc = (yyloc); ; } break; case 33: { yyval.exp = MkExpRenew0(yyvsp[(2) - (7)].exp, MkTypeName(yyvsp[(3) - (7)].list, yyvsp[(4) - (7)].declarator), yyvsp[(6) - (7)].exp); yyval.exp->loc = (yyloc); ; } break; case 34: { yyval.exp = MkExpRenew0(yyvsp[(2) - (6)].exp, MkTypeName(yyvsp[(3) - (6)].list, (((void *)0))), yyvsp[(5) - (6)].exp); yyval.exp->loc = (yyloc); ; } break; case 35: { yyval.exp = MkExpDummy(); ; } break; case 37: { yyval.exp = MkExpIndex(yyvsp[(1) - (4)].exp, yyvsp[(3) - (4)].list); yyval.exp->loc = (yyloc); ; } break; case 38: { yyval.exp = MkExpCall(yyvsp[(1) - (3)].exp, MkList()); yyval.exp->call.argLoc.start = (yylsp[(2) - (3)]).start; yyval.exp->call.argLoc.end = (yylsp[(3) - (3)]).end; yyval.exp->loc = (yyloc); ; } break; case 39: { yyval.exp = MkExpCall(yyvsp[(1) - (4)].exp, yyvsp[(3) - (4)].list); yyval.exp->call.argLoc.start = (yylsp[(2) - (4)]).start; yyval.exp->call.argLoc.end = (yylsp[(4) - (4)]).end; yyval.exp->loc = (yyloc); ; } break; case 40: { yyval.exp = MkExpMember(yyvsp[(1) - (3)].exp, yyvsp[(3) - (3)].id); yyval.exp->loc = (yyloc); ; } break; case 41: { char * constant = yyvsp[(1) - (2)].exp->type == 2 ? yyvsp[(1) - (2)].exp->constant : (((void *)0)); int len = constant ? strlen(constant) : 0; if(constant && constant[len - 1] == '.') { constant[len - 1] = (char)0; yyval.exp = MkExpMember(yyvsp[(1) - (2)].exp, yyvsp[(2) - (2)].id); yyval.exp->loc = (yyloc); } else yyerror(); ; } break; case 42: { yyval.exp = MkExpPointer(yyvsp[(1) - (3)].exp, yyvsp[(3) - (3)].id); yyval.exp->loc = (yyloc); ; } break; case 43: { yyval.exp = MkExpOp(yyvsp[(1) - (2)].exp, INC_OP, (((void *)0))); yyval.exp->loc = (yyloc); ; } break; case 44: { yyval.exp = MkExpOp(yyvsp[(1) - (2)].exp, DEC_OP, (((void *)0))); yyval.exp->loc = (yyloc); ; } break; case 45: { yyval.exp = MkExpInstance(yyvsp[(1) - (1)].instance); yyval.exp->loc = (yyloc); ; } break; case 46: { yyval.list = MkList(); ListAdd(yyval.list, yyvsp[(1) - (1)].exp); ; } break; case 47: { yyval.list = MkList(); ListAdd(yyval.list, yyvsp[(1) - (1)].exp); ; } break; case 48: { yyval.list = yyvsp[(1) - (3)].list; ListAdd(yyvsp[(1) - (3)].list, yyvsp[(3) - (3)].exp); ; } break; case 49: { yyval.list = yyvsp[(1) - (3)].list; ListAdd(yyvsp[(1) - (3)].list, yyvsp[(3) - (3)].exp); ; } break; case 50: { yyval.exp = MkExpOp((((void *)0)), INC_OP, yyvsp[(2) - (2)].exp); yyval.exp->loc = (yyloc); ; } break; case 51: { yyval.exp = MkExpOp((((void *)0)), DEC_OP, yyvsp[(2) - (2)].exp); yyval.exp->loc = (yyloc); ; } break; case 52: { yyval.exp = MkExpOp((((void *)0)), yyvsp[(1) - (2)].i, yyvsp[(2) - (2)].exp); yyval.exp->loc = (yyloc); ; } break; case 53: { yyval.exp = MkExpOp((((void *)0)), SIZEOF, yyvsp[(2) - (2)].exp); yyval.exp->loc = (yyloc); ; } break; case 54: { yyval.exp = MkExpTypeSize(yyvsp[(3) - (4)].typeName); yyval.exp->loc = (yyloc); ; } break; case 55: { yyval.exp = MkExpOp((((void *)0)), ALIGNOF, yyvsp[(2) - (2)].exp); yyval.exp->loc = (yyloc); ; } break; case 56: { yyval.exp = MkExpTypeAlign(yyvsp[(3) - (4)].typeName); yyval.exp->loc = (yyloc); ; } break; case 59: { yyval.i = '&'; ; } break; case 60: { yyval.i = '*'; ; } break; case 61: { yyval.i = '+'; ; } break; case 62: { yyval.i = '-'; ; } break; case 63: { yyval.i = '~'; ; } break; case 64: { yyval.i = '!'; ; } break; case 65: { yyval.i = DELETE; ; } break; case 67: { yyval.exp = MkExpCast(yyvsp[(2) - (4)].typeName, yyvsp[(4) - (4)].exp); yyval.exp->loc = (yyloc); ; } break; case 69: { yyval.exp = MkExpOp(yyvsp[(1) - (3)].exp, '*', yyvsp[(3) - (3)].exp); yyval.exp->loc = (yyloc); ; } break; case 70: { yyval.exp = MkExpOp(yyvsp[(1) - (3)].exp, '/', yyvsp[(3) - (3)].exp); yyval.exp->loc = (yyloc); ; } break; case 71: { yyval.exp = MkExpOp(yyvsp[(1) - (3)].exp, '%', yyvsp[(3) - (3)].exp); yyval.exp->loc = (yyloc); ; } break; case 73: { yyval.exp = MkExpOp(yyvsp[(1) - (3)].exp, '+', yyvsp[(3) - (3)].exp); yyval.exp->loc = (yyloc); ; } break; case 74: { yyval.exp = MkExpOp(yyvsp[(1) - (3)].exp, '-', yyvsp[(3) - (3)].exp); yyval.exp->loc = (yyloc); ; } break; case 76: { yyval.exp = MkExpOp(yyvsp[(1) - (3)].exp, LEFT_OP, yyvsp[(3) - (3)].exp); yyval.exp->loc = (yyloc); ; } break; case 77: { yyval.exp = MkExpOp(yyvsp[(1) - (3)].exp, RIGHT_OP, yyvsp[(3) - (3)].exp); yyval.exp->loc = (yyloc); ; } break; case 78: { yyval.exp = yyvsp[(1) - (2)].exp; skipErrors = 0x1; ; } break; case 80: { skipErrors = 0x0; yyval.exp = MkExpOp(yyvsp[(1) - (2)].exp, '<', yyvsp[(2) - (2)].exp); yyval.exp->loc = (yyloc); ; } break; case 81: { yyval.exp = MkExpOp(yyvsp[(1) - (3)].exp, '>', yyvsp[(3) - (3)].exp); yyval.exp->loc = (yyloc); ; } break; case 82: { yyval.exp = MkExpOp(yyvsp[(1) - (3)].exp, LE_OP, yyvsp[(3) - (3)].exp); yyval.exp->loc = (yyloc); ; } break; case 83: { yyval.exp = MkExpOp(yyvsp[(1) - (3)].exp, GE_OP, yyvsp[(3) - (3)].exp); yyval.exp->loc = (yyloc); ; } break; case 85: { yyval.exp = MkExpOp(yyvsp[(1) - (3)].exp, EQ_OP, yyvsp[(3) - (3)].exp); yyval.exp->loc = (yyloc); ; } break; case 86: { yyval.exp = MkExpOp(yyvsp[(1) - (3)].exp, NE_OP, yyvsp[(3) - (3)].exp); yyval.exp->loc = (yyloc); ; } break; case 88: { yyval.exp = MkExpOp(yyvsp[(1) - (3)].exp, '&', yyvsp[(3) - (3)].exp); yyval.exp->loc = (yyloc); ; } break; case 90: { yyval.exp = MkExpOp(yyvsp[(1) - (3)].exp, '^', yyvsp[(3) - (3)].exp); yyval.exp->loc = (yyloc); ; } break; case 92: { yyval.exp = MkExpOp(yyvsp[(1) - (3)].exp, '|', yyvsp[(3) - (3)].exp); yyval.exp->loc = (yyloc); ; } break; case 94: { yyval.exp = MkExpOp(yyvsp[(1) - (3)].exp, AND_OP, yyvsp[(3) - (3)].exp); yyval.exp->loc = (yyloc); ; } break; case 96: { yyval.exp = MkExpOp(yyvsp[(1) - (3)].exp, OR_OP, yyvsp[(3) - (3)].exp); yyval.exp->loc = (yyloc); ; } break; case 98: { yyval.exp = MkExpCondition(yyvsp[(1) - (5)].exp, yyvsp[(3) - (5)].list, yyvsp[(5) - (5)].exp); yyval.exp->loc = (yyloc); ; } break; case 100: { yyval.exp = MkExpOp(yyvsp[(1) - (3)].exp, yyvsp[(2) - (3)].i, yyvsp[(3) - (3)].exp); yyval.exp->loc = (yyloc); ; } break; case 101: { yyval.exp = MkExpOp(yyvsp[(1) - (3)].exp, yyvsp[(2) - (3)].i, yyvsp[(3) - (3)].exp); yyval.exp->loc = (yyloc); ; } break; case 102: { yyval.i = '='; ; } break; case 103: { yyval.i = MUL_ASSIGN; ; } break; case 104: { yyval.i = DIV_ASSIGN; ; } break; case 105: { yyval.i = MOD_ASSIGN; ; } break; case 106: { yyval.i = ADD_ASSIGN; ; } break; case 107: { yyval.i = SUB_ASSIGN; ; } break; case 108: { yyval.i = LEFT_ASSIGN; ; } break; case 109: { yyval.i = RIGHT_ASSIGN; ; } break; case 110: { yyval.i = AND_ASSIGN; ; } break; case 111: { yyval.i = XOR_ASSIGN; ; } break; case 112: { yyval.i = OR_ASSIGN; ; } break; case 113: { yyval.list = MkList(); ListAdd(yyval.list, yyvsp[(1) - (1)].exp); ; } break; case 114: { yyval.list = yyvsp[(1) - (3)].list; ListAdd(yyvsp[(1) - (3)].list, yyvsp[(3) - (3)].exp); ; } break; case 116: { yyval.declaration = MkDeclaration(yyvsp[(1) - (2)].list, (((void *)0))); yyval.declaration->loc = (yyloc); ; } break; case 117: { yyval.declaration = MkDeclaration(yyvsp[(1) - (3)].list, yyvsp[(2) - (3)].list); yyval.declaration->loc = (yyloc); ; } break; case 118: { yyval.declaration = MkDeclarationInst(yyvsp[(1) - (2)].instance); yyval.declaration->loc = (yyloc); ; } break; case 119: { yyval.declaration = MkDeclarationDefine(yyvsp[(2) - (5)].id, yyvsp[(4) - (5)].exp); yyval.declaration->loc = (yyloc); ; } break; case 120: { yyval.list = MkList(); ListAdd(yyval.list, yyvsp[(1) - (1)].specifier); ; } break; case 121: { yyval.list = yyvsp[(1) - (2)].list; ListAdd(yyvsp[(1) - (2)].list, yyvsp[(2) - (2)].specifier); ; } break; case 122: { yyval.list = MkList(); ListAdd(yyval.list, yyvsp[(1) - (1)].specifier); ; } break; case 123: { yyval.list = yyvsp[(1) - (2)].list; ListAdd(yyvsp[(1) - (2)].list, yyvsp[(2) - (2)].specifier); ; } break; case 124: { yyval.list = MkList(); ListAdd(yyval.list, yyvsp[(1) - (1)].specifier); ; } break; case 125: { yyval.list = yyvsp[(1) - (2)].list; ListAdd(yyvsp[(1) - (2)].list, yyvsp[(2) - (2)].specifier); ; } break; case 126: { yyval.list = MkList(); ListAdd(yyval.list, yyvsp[(1) - (1)].specifier); ; } break; case 127: { yyval.list = yyvsp[(1) - (2)].list; ListAdd(yyvsp[(1) - (2)].list, yyvsp[(2) - (2)].specifier); ; } break; case 128: { yyval.list = MkList(); ListAdd(yyval.list, yyvsp[(1) - (1)].specifier); ; } break; case 129: { yyval.list = yyvsp[(1) - (2)].list; ListAdd(yyvsp[(1) - (2)].list, yyvsp[(2) - (2)].specifier); ; } break; case 130: { yyval.list = MkList(); ListAdd(yyval.list, yyvsp[(1) - (1)].specifier); ; } break; case 131: { yyval.list = yyvsp[(1) - (2)].list; ListAdd(yyvsp[(1) - (2)].list, yyvsp[(2) - (2)].specifier); ; } break; case 132: { yyval.list = MkList(); ListAdd(yyval.list, yyvsp[(1) - (1)].specifier); ; } break; case 133: { yyval.list = yyvsp[(1) - (2)].list; ListAdd(yyvsp[(1) - (2)].list, yyvsp[(2) - (2)].specifier); ; } break; case 134: { yyval.list = MkList(); ListAdd(yyval.list, yyvsp[(1) - (1)].specifier); ; } break; case 135: { yyval.list = yyvsp[(1) - (2)].list; ListAdd(yyvsp[(1) - (2)].list, yyvsp[(2) - (2)].specifier); ; } break; case 136: { yyval.list = MkList(); ListAdd(yyval.list, yyvsp[(1) - (1)].specifier); ; } break; case 137: { yyval.list = yyvsp[(1) - (2)].list; ListAdd(yyvsp[(1) - (2)].list, yyvsp[(2) - (2)].specifier); ; } break; case 138: { yyval.list = MkList(); ListAdd(yyval.list, yyvsp[(1) - (1)].specifier); ; } break; case 139: { yyval.list = yyvsp[(1) - (2)].list; ListAdd(yyvsp[(1) - (2)].list, yyvsp[(2) - (2)].specifier); ; } break; case 140: { yyval.list = MkList(); ListAdd(yyval.list, yyvsp[(1) - (1)].specifier); ; } break; case 141: { yyval.list = yyvsp[(1) - (2)].list; ListAdd(yyvsp[(1) - (2)].list, yyvsp[(2) - (2)].specifier); ; } break; case 142: { yyval.list = MkList(); ListAdd(yyval.list, yyvsp[(1) - (1)].specifier); ; } break; case 143: { yyval.list = yyvsp[(1) - (2)].list; ListAdd(yyvsp[(1) - (2)].list, yyvsp[(2) - (2)].specifier); ; } break; case 144: { yyval.list = MkList(); ListAdd(yyval.list, yyvsp[(1) - (1)].specifier); ; } break; case 145: { yyval.list = yyvsp[(1) - (2)].list; ListAdd(yyvsp[(1) - (2)].list, yyvsp[(2) - (2)].specifier); ; } break; case 146: { yyval.list = MkList(); ListAdd(yyval.list, yyvsp[(1) - (1)].specifier); ; } break; case 147: { yyval.list = yyvsp[(1) - (2)].list; ListAdd(yyvsp[(1) - (2)].list, yyvsp[(2) - (2)].specifier); ; } break; case 148: { yyval.list = MkList(); ListAdd(yyval.list, yyvsp[(1) - (1)].specifier); ; } break; case 149: { yyval.list = yyvsp[(1) - (2)].list; ListAdd(yyvsp[(1) - (2)].list, yyvsp[(2) - (2)].specifier); ; } break; case 150: { yyval.list = MkList(); ListAdd(yyval.list, yyvsp[(1) - (1)].specifier); ; } break; case 151: { yyval.list = yyvsp[(1) - (2)].list; ListAdd(yyvsp[(1) - (2)].list, yyvsp[(2) - (2)].specifier); ; } break; case 152: { yyval.list = MkList(); ListAdd(yyval.list, yyvsp[(1) - (1)].specifier); ; } break; case 153: { yyval.list = yyvsp[(1) - (2)].list; ListAdd(yyvsp[(1) - (2)].list, yyvsp[(2) - (2)].specifier); ; } break; case 154: { yyval.list = MkList(); ListAdd(yyval.list, yyvsp[(1) - (1)].specifier); ; } break; case 155: { yyval.list = yyvsp[(1) - (2)].list; ListAdd(yyvsp[(1) - (2)].list, yyvsp[(2) - (2)].specifier); ; } break; case 156: { yyval.list = MkList(); ListAdd(yyval.list, yyvsp[(1) - (1)].specifier); ; } break; case 157: { yyval.list = yyvsp[(1) - (2)].list; ListAdd(yyvsp[(1) - (2)].list, yyvsp[(2) - (2)].specifier); ; } break; case 158: { yyval.list = MkList(); ListAdd(yyval.list, yyvsp[(1) - (1)].specifier); ; } break; case 159: { yyval.list = yyvsp[(1) - (2)].list; ListAdd(yyvsp[(1) - (2)].list, yyvsp[(2) - (2)].specifier); ; } break; case 160: { yyval.list = yyvsp[(1) - (1)].list; ; } break; case 161: { yyval.list = MkList(); ListAdd(yyval.list, yyvsp[(1) - (1)].specifier); ; } break; case 162: { yyval.list = MkList(); ListAdd(yyval.list, yyvsp[(1) - (1)].specifier); ; } break; case 163: { yyval.list = yyvsp[(1) - (2)].list; ListAdd(yyvsp[(1) - (2)].list, yyvsp[(2) - (2)].specifier); ; } break; case 164: { yyval.list = MkList(); ListAdd(yyval.list, yyvsp[(1) - (1)].specifier); ; } break; case 165: { yyval.list = yyvsp[(1) - (2)].list; ListAdd(yyvsp[(1) - (2)].list, yyvsp[(2) - (2)].specifier); ; } break; case 166: { yyval.list = MkList(); ListAdd(yyval.list, yyvsp[(1) - (1)].specifier); ; } break; case 167: { yyval.list = yyvsp[(1) - (2)].list; ListAdd(yyvsp[(1) - (2)].list, yyvsp[(2) - (2)].specifier); ; } break; case 168: { yyval.list = MkList(); ListAdd(yyval.list, MkSpecifierName(yyvsp[(1) - (1)].id->string)); FreeIdentifier(yyvsp[(1) - (1)].id); ; } break; case 169: { ListAdd(yyvsp[(1) - (2)].list, MkSpecifierName(yyvsp[(2) - (2)].id->string)); FreeIdentifier(yyvsp[(2) - (2)].id); ; } break; case 170: { if(yyvsp[(1) - (4)].id->_class) { char name[1024]; strcpy(name, yyvsp[(1) - (4)].id->_class->name ? yyvsp[(1) - (4)].id->_class->name : ""); strcat(name, "::"); strcat(name, yyvsp[(1) - (4)].id->string); _DeclClass(0, name); } else _DeclClass(0, yyvsp[(1) - (4)].id->string); yyval.list = MkList(); ListAdd(yyval.list, MkSpecifierNameArgs(yyvsp[(1) - (4)].id->string, yyvsp[(3) - (4)].list)); FreeIdentifier(yyvsp[(1) - (4)].id); ; } break; case 171: { if(yyvsp[(2) - (5)].id->_class && !yyvsp[(2) - (5)].id->_class->name) { char name[1024]; strcpy(name, "::"); strcat(name, yyvsp[(2) - (5)].id->string); _DeclClass(0, name); } else _DeclClass(0, yyvsp[(2) - (5)].id->string); ListAdd(yyvsp[(1) - (5)].list, MkSpecifierNameArgs(yyvsp[(2) - (5)].id->string, yyvsp[(4) - (5)].list)); FreeIdentifier(yyvsp[(2) - (5)].id); ; } break; case 172: { yyval.list = MkList(); ListAdd(yyval.list, yyvsp[(1) - (1)].specifier); ; } break; case 173: { yyval.list = yyvsp[(1) - (2)].list; ListAdd(yyvsp[(1) - (2)].list, yyvsp[(2) - (2)].specifier); ; } break; case 174: { yyval.list = MkList(); ListAdd(yyval.list, yyvsp[(1) - (1)].specifier); ; } break; case 175: { yyval.list = yyvsp[(1) - (2)].list; ListAdd(yyvsp[(1) - (2)].list, yyvsp[(2) - (2)].specifier); ; } break; case 176: { yyval.list = MkList(); ListAdd(yyval.list, yyvsp[(1) - (1)].specifier); ; } break; case 177: { yyval.list = yyvsp[(1) - (2)].list; ListAdd(yyvsp[(1) - (2)].list, yyvsp[(2) - (2)].specifier); ; } break; case 178: { yyval.list = MkList(); ListAdd(yyval.list, yyvsp[(1) - (1)].specifier); ; } break; case 179: { yyval.list = yyvsp[(1) - (2)].list; ListAdd(yyvsp[(1) - (2)].list, yyvsp[(2) - (2)].specifier); ; } break; case 180: { yyval.list = MkList(); ListAdd(yyval.list, yyvsp[(1) - (1)].specifier); ; } break; case 181: { yyval.list = yyvsp[(1) - (2)].list; ListAdd(yyvsp[(1) - (2)].list, yyvsp[(2) - (2)].specifier); ; } break; case 182: { yyval.list = MkList(); ListAdd(yyval.list, MkSpecifierName(yyvsp[(1) - (1)].id->string)); FreeIdentifier(yyvsp[(1) - (1)].id); ; } break; case 183: { yyval.list = yyvsp[(1) - (2)].list; ListAdd(yyvsp[(1) - (2)].list, MkSpecifierName(yyvsp[(2) - (2)].id->string)); FreeIdentifier(yyvsp[(2) - (2)].id); } break; case 184: { if(yyvsp[(1) - (4)].id->_class) { char name[1024]; strcpy(name, yyvsp[(1) - (4)].id->_class->name ? yyvsp[(1) - (4)].id->_class->name : ""); strcat(name, "::"); strcat(name, yyvsp[(1) - (4)].id->string); _DeclClass(0, name); } else _DeclClass(0, yyvsp[(1) - (4)].id->string); yyval.list = MkList(); ListAdd(yyval.list, MkSpecifierNameArgs(yyvsp[(1) - (4)].id->string, yyvsp[(3) - (4)].list)); FreeIdentifier(yyvsp[(1) - (4)].id); ; } break; case 185: { if(yyvsp[(2) - (5)].id->_class && !yyvsp[(2) - (5)].id->_class->name) { char name[1024]; strcpy(name, "::"); strcat(name, yyvsp[(2) - (5)].id->string); _DeclClass(0, name); } else _DeclClass(0, yyvsp[(2) - (5)].id->string); ListAdd(yyvsp[(1) - (5)].list, MkSpecifierNameArgs(yyvsp[(2) - (5)].id->string, yyvsp[(4) - (5)].list)); FreeIdentifier(yyvsp[(2) - (5)].id); ; } break; case 186: { yyval.list = MkList(); ListAdd(yyval.list, yyvsp[(1) - (1)].initDeclarator); ; } break; case 187: { yyval.list = yyvsp[(1) - (3)].list; ListAdd(yyvsp[(1) - (3)].list, yyvsp[(3) - (3)].initDeclarator); ; } break; case 188: { yyval.initDeclarator = MkInitDeclarator(yyvsp[(1) - (1)].declarator, (((void *)0))); yyval.initDeclarator->loc = (yyloc); ; } break; case 189: { yyval.initDeclarator = MkInitDeclarator(yyvsp[(1) - (3)].declarator, yyvsp[(3) - (3)].initializer); yyval.initDeclarator->loc = (yyloc); yyval.initDeclarator->initializer->loc.start = (yylsp[(2) - (3)]).end; ; } break; case 190: { yyval.specifier = MkSpecifier(TYPEDEF); ; } break; case 191: { yyval.specifier = MkSpecifier(EXTERN); ; } break; case 192: { yyval.specifier = MkSpecifier(STATIC); ; } break; case 193: { yyval.specifier = MkSpecifier(AUTO); ; } break; case 194: { yyval.specifier = MkSpecifier(REGISTER); ; } break; case 195: { yyval.specifier = MkSpecifier(THREAD); ; } break; case 196: { yyval.extDecl = MkExtDeclString(__ecereNameSpace__ecere__sys__CopyString(yytext)); ; } break; case 197: { yyval.extDecl = MkExtDeclString(__ecereNameSpace__ecere__sys__CopyString(yytext)); ; } break; case 198: { yyval.extDecl = MkExtDeclAttrib(yyvsp[(1) - (1)].attrib); ; } break; case 199: { yyval.i = ATTRIB; ; } break; case 200: { yyval.i = ATTRIB_DEP; ; } break; case 201: { yyval.i = __ATTRIB; ; } break; case 202: { yyval.string = __ecereNameSpace__ecere__sys__CopyString(yytext); ; } break; case 203: { yyval.string = __ecereNameSpace__ecere__sys__CopyString(yytext); ; } break; case 204: { yyval.string = __ecereNameSpace__ecere__sys__CopyString(yytext); ; } break; case 205: { yyval.string = __ecereNameSpace__ecere__sys__CopyString(yytext); ; } break; case 206: { yyval.string = __ecereNameSpace__ecere__sys__CopyString(yytext); ; } break; case 207: { yyval.attribute = MkAttribute(yyvsp[(1) - (1)].string, (((void *)0))); yyval.attribute->loc = (yyloc); ; } break; case 208: { yyval.attribute = MkAttribute(yyvsp[(1) - (4)].string, MkExpBrackets(yyvsp[(3) - (4)].list)); yyval.attribute->loc = (yyloc); ; } break; case 209: { yyval.list = MkListOne(yyvsp[(1) - (1)].attribute); ; } break; case 210: { ListAdd(yyvsp[(1) - (2)].list, yyvsp[(2) - (2)].attribute); yyval.list = yyvsp[(1) - (2)].list; ; } break; case 211: { ListAdd(yyvsp[(1) - (3)].list, yyvsp[(3) - (3)].attribute); yyval.list = yyvsp[(1) - (3)].list; ; } break; case 212: { yyval.attrib = MkAttrib(yyvsp[(1) - (6)].i, yyvsp[(4) - (6)].list); yyval.attrib->loc = (yyloc); ; } break; case 213: { yyval.attrib = MkAttrib(yyvsp[(1) - (5)].i, (((void *)0))); yyval.attrib->loc = (yyloc); ; } break; case 214: { yyval.specifier = MkSpecifierExtended(yyvsp[(1) - (1)].extDecl); ; } break; case 215: { yyval.specifier = MkSpecifier(CONST); ; } break; case 216: { yyval.specifier = MkSpecifier(VOLATILE); ; } break; case 217: { yyval.specifier = yyvsp[(1) - (1)].specifier; ; } break; case 218: { yyval.specifier = MkSpecifier(VOID); ; } break; case 219: { yyval.specifier = MkSpecifier(CHAR); ; } break; case 220: { yyval.specifier = MkSpecifier(SHORT); ; } break; case 221: { yyval.specifier = MkSpecifier(INT); ; } break; case 222: { yyval.specifier = MkSpecifier(UINT); ; } break; case 223: { yyval.specifier = MkSpecifier(INT64); ; } break; case 224: { yyval.specifier = MkSpecifier(VALIST); ; } break; case 225: { yyval.specifier = MkSpecifier(LONG); ; } break; case 226: { yyval.specifier = MkSpecifier(FLOAT); ; } break; case 227: { yyval.specifier = MkSpecifier(DOUBLE); ; } break; case 228: { yyval.specifier = MkSpecifier(SIGNED); ; } break; case 229: { yyval.specifier = MkSpecifier(UNSIGNED); ; } break; case 230: { yyval.specifier = MkSpecifier(EXTENSION); ; } break; case 231: { yyval.specifier = MkSpecifier(_BOOL); ; } break; case 232: { yyval.specifier = MkSpecifier(BOOL); ; } break; case 236: { yyval.specifier = MkSpecifierTypeOf(yyvsp[(3) - (4)].exp); ; } break; case 237: { yyval.specifier = MkSpecifierSubClass(yyvsp[(3) - (4)].specifier); ; } break; case 238: { _DeclClass(0, yyvsp[(3) - (4)].id->string); yyval.specifier = MkSpecifierSubClass(MkSpecifierName(yyvsp[(3) - (4)].id->string)); FreeIdentifier(yyvsp[(3) - (4)].id); ; } break; case 239: { yyval.specifier = MkSpecifier(THISCLASS); ; } break; case 240: { yyval.specifier = MkSpecifier(TYPED_OBJECT); ; } break; case 241: { yyval.specifier = MkSpecifier(ANY_OBJECT); ; } break; case 242: { yyval.specifier = MkSpecifier(VOID); ; } break; case 243: { yyval.specifier = MkSpecifier(CHAR); ; } break; case 244: { yyval.specifier = MkSpecifier(SHORT); ; } break; case 245: { yyval.specifier = MkSpecifier(INT); ; } break; case 246: { yyval.specifier = MkSpecifier(UINT); ; } break; case 247: { yyval.specifier = MkSpecifier(INT64); ; } break; case 248: { yyval.specifier = MkSpecifier(VALIST); ; } break; case 249: { yyval.specifier = MkSpecifier(LONG); ; } break; case 250: { yyval.specifier = MkSpecifier(FLOAT); ; } break; case 251: { yyval.specifier = MkSpecifier(DOUBLE); ; } break; case 252: { yyval.specifier = MkSpecifier(SIGNED); ; } break; case 253: { yyval.specifier = MkSpecifier(UNSIGNED); ; } break; case 254: { yyval.specifier = MkSpecifier(EXTENSION); ; } break; case 255: { yyval.specifier = MkSpecifier(_BOOL); ; } break; case 256: { yyval.specifier = MkSpecifier(BOOL); ; } break; case 260: { yyval.specifier = MkSpecifierTypeOf(yyvsp[(3) - (4)].exp); ; } break; case 261: { yyval.specifier = MkSpecifierSubClass(yyvsp[(3) - (4)].specifier); ; } break; case 262: { _DeclClass(0, yyvsp[(3) - (4)].id->string); yyval.specifier = MkSpecifierSubClass(MkSpecifierName(yyvsp[(3) - (4)].id->string)); FreeIdentifier(yyvsp[(3) - (4)].id); ; } break; case 263: { yyval.specifier = MkSpecifier(THISCLASS); ; } break; case 264: { yyval.specifier = MkStructOrUnion(yyvsp[(1) - (5)].specifierType, yyvsp[(2) - (5)].id, yyvsp[(4) - (5)].list); if(declMode) DeclClass(globalContext->nextID++, yyvsp[(2) - (5)].id->string); ; } break; case 265: { yyval.specifier = MkStructOrUnion(yyvsp[(1) - (4)].specifierType, (((void *)0)), yyvsp[(3) - (4)].list); ; } break; case 266: { yyval.specifier = MkStructOrUnion(yyvsp[(1) - (4)].specifierType, yyvsp[(2) - (4)].id, (((void *)0))); if(declMode) DeclClass(globalContext->nextID++, yyvsp[(2) - (4)].id->string); ; } break; case 267: { yyval.specifier = MkStructOrUnion(yyvsp[(1) - (3)].specifierType, (((void *)0)), (((void *)0))); ; } break; case 268: { yyval.specifier = MkStructOrUnion(yyvsp[(1) - (5)].specifierType, MkIdentifier(yyvsp[(2) - (5)].specifier->name), yyvsp[(4) - (5)].list); if(declMode) DeclClass(globalContext->nextID++, yyvsp[(2) - (5)].specifier->name); FreeSpecifier(yyvsp[(2) - (5)].specifier); ; } break; case 269: { yyval.specifier = MkStructOrUnion(yyvsp[(1) - (6)].specifierType, yyvsp[(3) - (6)].id, yyvsp[(5) - (6)].list); yyval.specifier->extDeclStruct = yyvsp[(2) - (6)].extDecl; if(declMode) DeclClass(globalContext->nextID++, yyvsp[(3) - (6)].id->string); ; } break; case 270: { yyval.specifier = MkStructOrUnion(yyvsp[(1) - (5)].specifierType, (((void *)0)), yyvsp[(4) - (5)].list); yyval.specifier->extDeclStruct = yyvsp[(2) - (5)].extDecl; ; } break; case 271: { yyval.specifier = MkStructOrUnion(yyvsp[(1) - (5)].specifierType, yyvsp[(3) - (5)].id, (((void *)0))); yyval.specifier->extDeclStruct = yyvsp[(2) - (5)].extDecl; if(declMode) DeclClass(globalContext->nextID++, yyvsp[(3) - (5)].id->string); ; } break; case 272: { yyval.specifier = MkStructOrUnion(yyvsp[(1) - (4)].specifierType, (((void *)0)), (((void *)0))); yyval.specifier->extDeclStruct = yyvsp[(2) - (4)].extDecl; ; } break; case 273: { yyval.specifier = MkStructOrUnion(yyvsp[(1) - (6)].specifierType, MkIdentifier(yyvsp[(3) - (6)].specifier->name), yyvsp[(5) - (6)].list); yyval.specifier->extDeclStruct = yyvsp[(2) - (6)].extDecl; if(declMode) DeclClass(globalContext->nextID++, yyvsp[(3) - (6)].specifier->name); FreeSpecifier(yyvsp[(3) - (6)].specifier); ; } break; case 274: { yyval.specifier = MkStructOrUnion(yyvsp[(1) - (2)].specifierType, yyvsp[(2) - (2)].id, (((void *)0))); if(declMode) DeclClass(0, yyvsp[(2) - (2)].id->string); ; } break; case 275: { yyval.specifier = MkStructOrUnion(yyvsp[(1) - (2)].specifierType, MkIdentifier(yyvsp[(2) - (2)].specifier->name), (((void *)0))); if(declMode) DeclClass(0, yyvsp[(2) - (2)].specifier->name); FreeSpecifier(yyvsp[(2) - (2)].specifier); ; } break; case 276: { yyval.specifier = MkStructOrUnion(yyvsp[(1) - (3)].specifierType, yyvsp[(3) - (3)].id, (((void *)0))); yyval.specifier->extDeclStruct = yyvsp[(2) - (3)].extDecl; if(declMode) DeclClass(0, yyvsp[(3) - (3)].id->string); ; } break; case 277: { yyval.specifier = MkStructOrUnion(yyvsp[(1) - (3)].specifierType, MkIdentifier(yyvsp[(3) - (3)].specifier->name), (((void *)0))); yyval.specifier->extDeclStruct = yyvsp[(2) - (3)].extDecl; if(declMode) DeclClass(0, yyvsp[(3) - (3)].specifier->name); FreeSpecifier(yyvsp[(3) - (3)].specifier); ; } break; case 278: { yyval.templateDatatype = MkTemplateDatatype(yyvsp[(1) - (1)].list, (((void *)0))); ; } break; case 279: { yyval.templateDatatype = MkTemplateDatatype(yyvsp[(1) - (2)].list, yyvsp[(2) - (2)].declarator); ; } break; case 280: { yyval.templateArgument = MkTemplateTypeArgument(MkTemplateDatatype(yyvsp[(1) - (1)].list, (((void *)0)))); ; } break; case 281: { yyval.templateArgument = MkTemplateTypeArgument(MkTemplateDatatype(yyvsp[(1) - (2)].list, yyvsp[(2) - (2)].declarator)); ; } break; case 282: { yyval.templateArgument = MkTemplateExpressionArgument(yyvsp[(1) - (1)].exp); ; } break; case 285: { yyval.templateArgument = yyvsp[(3) - (3)].templateArgument; yyval.templateArgument->name = yyvsp[(1) - (3)].id; yyval.templateArgument->loc = (yyloc); ; } break; case 286: { yyval.templateArgument = yyvsp[(3) - (3)].templateArgument; yyval.templateArgument->name = yyvsp[(1) - (3)].id; yyval.templateArgument->loc = (yyloc); ; } break; case 287: { yyval.templateArgument = yyvsp[(3) - (3)].templateArgument; if(yyvsp[(1) - (3)].templateDatatype->specifiers && (*yyvsp[(1) - (3)].templateDatatype->specifiers).first) { struct Specifier * spec = (*yyvsp[(1) - (3)].templateDatatype->specifiers).first; if(spec->type == 1) yyval.templateArgument->name = MkIdentifier(spec->name); } FreeTemplateDataType(yyvsp[(1) - (3)].templateDatatype); yyval.templateArgument->loc = (yyloc); ; } break; case 288: { yyval.templateArgument = yyvsp[(3) - (3)].templateArgument; if(yyvsp[(1) - (3)].templateDatatype->specifiers && (*yyvsp[(1) - (3)].templateDatatype->specifiers).first) { struct Specifier * spec = (*yyvsp[(1) - (3)].templateDatatype->specifiers).first; if(spec->type == 1) yyval.templateArgument->name = MkIdentifier(spec->name); } FreeTemplateDataType(yyvsp[(1) - (3)].templateDatatype); yyval.templateArgument->loc = (yyloc); ; } break; case 289: { yyval.list = MkList(); ListAdd(yyval.list, yyvsp[(1) - (1)].templateArgument); ; } break; case 290: { ListAdd(yyvsp[(1) - (3)].list, yyvsp[(3) - (3)].templateArgument); ; } break; case 291: { yyval.specifierType = 3; ; } break; case 292: { yyval.specifierType = 4; ; } break; case 293: { yyval.list = MkList(); ListAdd(yyval.list, yyvsp[(1) - (1)].classDef); ; } break; case 294: { yyval.list = yyvsp[(1) - (2)].list; ListAdd(yyvsp[(1) - (2)].list, yyvsp[(2) - (2)].classDef); ; } break; case 295: { yyval.memberInit = MkMemberInitExp(yyvsp[(1) - (3)].exp, yyvsp[(3) - (3)].initializer); yyval.memberInit->loc = (yyloc); yyval.memberInit->realLoc = (yyloc); ; } break; case 296: { yyval.list = MkList(); ListAdd(yyval.list, yyvsp[(1) - (1)].memberInit); ((struct MemberInit *)(*yyval.list).last)->loc = (yyloc); ; } break; case 297: { ((struct MemberInit *)(*yyvsp[(1) - (3)].list).last)->loc.end = (yylsp[(3) - (3)]).start; ListAdd(yyvsp[(1) - (3)].list, yyvsp[(3) - (3)].memberInit); yyval.list = yyvsp[(1) - (3)].list; ; } break; case 298: { yyval.prop = MkProperty(yyvsp[(2) - (9)].list, (((void *)0)), yyvsp[(3) - (9)].id, yyvsp[(6) - (9)].stmt, yyvsp[(8) - (9)].stmt); yyval.prop->loc = (yyloc); ; } break; case 299: { yyval.prop = MkProperty(yyvsp[(2) - (9)].list, (((void *)0)), yyvsp[(3) - (9)].id, yyvsp[(8) - (9)].stmt, yyvsp[(6) - (9)].stmt); yyval.prop->loc = (yyloc); ; } break; case 300: { yyval.prop = MkProperty(yyvsp[(2) - (7)].list, (((void *)0)), yyvsp[(3) - (7)].id, yyvsp[(6) - (7)].stmt, (((void *)0))); yyval.prop->loc = (yyloc); ; } break; case 301: { yyval.prop = MkProperty(yyvsp[(2) - (7)].list, (((void *)0)), yyvsp[(3) - (7)].id, (((void *)0)), yyvsp[(6) - (7)].stmt); yyval.prop->loc = (yyloc); ; } break; case 302: { yyval.prop = MkProperty(yyvsp[(2) - (5)].list, (((void *)0)), yyvsp[(3) - (5)].id, (((void *)0)), (((void *)0))); yyval.prop->loc = (yyloc); ; } break; case 303: { yyval.prop = MkProperty(yyvsp[(2) - (10)].list, yyvsp[(3) - (10)].declarator, yyvsp[(4) - (10)].id, yyvsp[(7) - (10)].stmt, yyvsp[(9) - (10)].stmt); yyval.prop->loc = (yyloc); ; } break; case 304: { yyval.prop = MkProperty(yyvsp[(2) - (10)].list, yyvsp[(3) - (10)].declarator, yyvsp[(4) - (10)].id, yyvsp[(9) - (10)].stmt, yyvsp[(7) - (10)].stmt); yyval.prop->loc = (yyloc); ; } break; case 305: { yyval.prop = MkProperty(yyvsp[(2) - (8)].list, yyvsp[(3) - (8)].declarator, yyvsp[(4) - (8)].id, yyvsp[(7) - (8)].stmt, (((void *)0))); yyval.prop->loc = (yyloc); ; } break; case 306: { yyval.prop = MkProperty(yyvsp[(2) - (8)].list, yyvsp[(3) - (8)].declarator, yyvsp[(4) - (8)].id, (((void *)0)), yyvsp[(7) - (8)].stmt); yyval.prop->loc = (yyloc); ; } break; case 307: { yyval.prop = MkProperty(yyvsp[(2) - (6)].list, yyvsp[(3) - (6)].declarator, yyvsp[(4) - (6)].id, (((void *)0)), (((void *)0))); yyval.prop->loc = (yyloc); ; } break; case 308: { yyval.prop = MkProperty(yyvsp[(2) - (8)].list, (((void *)0)), (((void *)0)), yyvsp[(5) - (8)].stmt, yyvsp[(7) - (8)].stmt); yyval.prop->loc = (yyloc); ; } break; case 309: { yyval.prop = MkProperty(yyvsp[(2) - (8)].list, (((void *)0)), (((void *)0)), yyvsp[(7) - (8)].stmt, yyvsp[(5) - (8)].stmt); yyval.prop->loc = (yyloc); ; } break; case 310: { yyval.prop = MkProperty(yyvsp[(2) - (6)].list, (((void *)0)), (((void *)0)), yyvsp[(5) - (6)].stmt, (((void *)0))); yyval.prop->loc = (yyloc); ; } break; case 311: { yyval.prop = MkProperty(yyvsp[(2) - (6)].list, (((void *)0)), (((void *)0)), (((void *)0)), yyvsp[(5) - (6)].stmt); yyval.prop->loc = (yyloc); ; } break; case 312: { yyval.prop = MkProperty(yyvsp[(2) - (4)].list, (((void *)0)), (((void *)0)), (((void *)0)), (((void *)0))); yyval.prop->loc = (yyloc); ; } break; case 313: { yyval.prop = MkProperty(yyvsp[(2) - (9)].list, yyvsp[(3) - (9)].declarator, (((void *)0)), yyvsp[(6) - (9)].stmt, yyvsp[(8) - (9)].stmt); yyval.prop->loc = (yyloc); ; } break; case 314: { yyval.prop = MkProperty(yyvsp[(2) - (9)].list, yyvsp[(3) - (9)].declarator, (((void *)0)), yyvsp[(8) - (9)].stmt, yyvsp[(6) - (9)].stmt); yyval.prop->loc = (yyloc); ; } break; case 315: { yyval.prop = MkProperty(yyvsp[(2) - (7)].list, yyvsp[(3) - (7)].declarator, (((void *)0)), yyvsp[(6) - (7)].stmt, (((void *)0))); yyval.prop->loc = (yyloc); ; } break; case 316: { yyval.prop = MkProperty(yyvsp[(2) - (7)].list, yyvsp[(3) - (7)].declarator, (((void *)0)), (((void *)0)), yyvsp[(6) - (7)].stmt); yyval.prop->loc = (yyloc); ; } break; case 317: { yyval.prop = MkProperty(yyvsp[(2) - (5)].list, yyvsp[(3) - (5)].declarator, (((void *)0)), (((void *)0)), (((void *)0))); yyval.prop->loc = (yyloc); ; } break; case 318: { yyval.classDef = MkClassDefDeclaration(MkStructDeclaration(yyvsp[(1) - (3)].list, yyvsp[(2) - (3)].list, (((void *)0)))); yyval.classDef->decl->loc = (yyloc); yyval.classDef->loc = (yyloc); ; } break; case 319: { yyval.classDef = MkClassDefDeclaration(MkStructDeclaration(yyvsp[(1) - (2)].list, (((void *)0)), (((void *)0)))); yyval.classDef->decl->loc = (yyloc); yyval.classDef->loc = (yyloc); ; } break; case 320: { yyval.classDef = MkClassDefDeclaration(MkDeclarationClassInst(yyvsp[(1) - (2)].instance)); yyval.classDef->loc = (yyloc); yyval.classDef->decl->loc = (yyloc); ; } break; case 321: { yyval.classDef = MkClassDefDeclaration(MkDeclarationClassInst(yyvsp[(1) - (2)].instance)); yyval.classDef->loc = (yyloc); yyval.classDef->decl->loc = (yyloc); ; } break; case 322: { yyval.classDef = MkClassDefFunction(yyvsp[(1) - (1)].classFunction); yyval.classDef->loc = (yyloc); ; } break; case 323: { yyval.classDef = MkClassDefDefaultProperty(yyvsp[(1) - (2)].list); if((*yyvsp[(1) - (2)].list).last) ((struct MemberInit *)(*yyvsp[(1) - (2)].list).last)->loc.end = (yylsp[(2) - (2)]).start; yyval.classDef->loc = (yyloc); ; } break; case 324: { yyval.classDef = MkClassDefProperty(yyvsp[(1) - (1)].prop); yyval.classDef->loc = (yyloc); globalContext->nextID++; ; } break; case 325: { yyval.classDef = (((void *)0)); ; } break; case 326: { yyval.list = MkList(); ListAdd(yyval.list, yyvsp[(1) - (1)].declarator); ; } break; case 327: { yyval.list = yyvsp[(1) - (3)].list; ListAdd(yyvsp[(1) - (3)].list, yyvsp[(3) - (3)].declarator); ; } break; case 328: { yyval.declarator = MkStructDeclarator(yyvsp[(1) - (1)].declarator, (((void *)0))); yyval.declarator->loc = (yyloc); ; } break; case 329: { yyval.declarator = MkStructDeclarator(yyvsp[(1) - (2)].declarator, (((void *)0))); yyval.declarator->structDecl.attrib = yyvsp[(2) - (2)].attrib; yyval.declarator->loc = (yyloc); ; } break; case 330: { yyval.declarator = MkStructDeclarator((((void *)0)), yyvsp[(2) - (2)].exp); yyval.declarator->loc = (yyloc); ; } break; case 331: { yyval.declarator = MkStructDeclarator(yyvsp[(1) - (3)].declarator, yyvsp[(3) - (3)].exp); yyval.declarator->loc = (yyloc); ; } break; case 332: { yyval.declarator = MkStructDeclarator(yyvsp[(1) - (5)].declarator, yyvsp[(3) - (5)].exp); yyval.declarator->structDecl.posExp = yyvsp[(5) - (5)].exp; yyval.declarator->loc = (yyloc); ; } break; case 333: { yyval.specifier = MkEnum(yyvsp[(2) - (2)].id, (((void *)0))); if(declMode) DeclClass(0, yyvsp[(2) - (2)].id->string); ; } break; case 334: { yyval.specifier = MkEnum(MkIdentifier(yyvsp[(2) - (2)].specifier->name), (((void *)0))); if(declMode) DeclClass(0, yyvsp[(2) - (2)].specifier->name); FreeSpecifier(yyvsp[(2) - (2)].specifier); ; } break; case 335: { yyval.specifier = MkEnum((((void *)0)), yyvsp[(3) - (4)].list); ; } break; case 336: { yyval.specifier = MkEnum(yyvsp[(2) - (5)].id, yyvsp[(4) - (5)].list); if(declMode) DeclClass(globalContext->nextID++, yyvsp[(2) - (5)].id->string); ; } break; case 337: { yyval.specifier = MkEnum(yyvsp[(2) - (7)].id, yyvsp[(4) - (7)].list); yyval.specifier->definitions = yyvsp[(6) - (7)].list; if(declMode) DeclClass(globalContext->nextID++, yyvsp[(2) - (7)].id->string); ; } break; case 338: { yyval.specifier = MkEnum(MkIdentifier(yyvsp[(2) - (7)].specifier->name), yyvsp[(4) - (7)].list); yyval.specifier->definitions = yyvsp[(6) - (7)].list; if(declMode) DeclClass(globalContext->nextID++, yyvsp[(2) - (7)].specifier->name); FreeSpecifier(yyvsp[(2) - (7)].specifier); ; } break; case 339: { yyval.specifier = MkEnum(MkIdentifier(yyvsp[(2) - (5)].specifier->name), yyvsp[(4) - (5)].list); if(declMode) DeclClass(globalContext->nextID++, yyvsp[(2) - (5)].specifier->name); FreeSpecifier(yyvsp[(2) - (5)].specifier); ; } break; case 340: { yyval.list = MkList(); ListAdd(yyval.list, yyvsp[(1) - (1)].enumerator); ; } break; case 341: { yyval.list = yyvsp[(1) - (3)].list; ListAdd(yyvsp[(1) - (3)].list, yyvsp[(3) - (3)].enumerator); ; } break; case 342: { yyval.enumerator = MkEnumerator(yyvsp[(1) - (1)].id, (((void *)0))); ; } break; case 343: { yyval.enumerator = MkEnumerator(yyvsp[(1) - (3)].id, yyvsp[(3) - (3)].exp); ; } break; case 344: { yyval.declarator = MkDeclaratorBrackets(yyvsp[(2) - (3)].declarator); ; } break; case 345: { yyval.declarator = MkDeclaratorArray((((void *)0)), (((void *)0))); ; } break; case 346: { yyval.declarator = MkDeclaratorArray((((void *)0)), yyvsp[(2) - (3)].exp); ; } break; case 347: { yyval.declarator = MkDeclaratorEnumArray((((void *)0)), yyvsp[(2) - (3)].specifier); ; } break; case 348: { yyval.declarator = MkDeclaratorArray(yyvsp[(1) - (3)].declarator, (((void *)0))); ; } break; case 349: { yyval.declarator = MkDeclaratorArray(yyvsp[(1) - (4)].declarator, yyvsp[(3) - (4)].exp); ; } break; case 350: { yyval.declarator = MkDeclaratorEnumArray(yyvsp[(1) - (4)].declarator, yyvsp[(3) - (4)].specifier); ; } break; case 351: { yyval.declarator = MkDeclaratorFunction((((void *)0)), (((void *)0))); ; } break; case 352: { yyval.declarator = MkDeclaratorFunction((((void *)0)), yyvsp[(2) - (3)].list); ; } break; case 353: { yyval.declarator = MkDeclaratorFunction(yyvsp[(1) - (3)].declarator, (((void *)0))); ; } break; case 354: { yyval.declarator = MkDeclaratorFunction(yyvsp[(1) - (4)].declarator, yyvsp[(3) - (4)].list); ; } break; case 355: { yyval.declarator = MkDeclaratorBrackets(yyvsp[(2) - (3)].declarator); ; } break; case 356: { yyval.declarator = MkDeclaratorFunction((((void *)0)), (((void *)0))); ; } break; case 357: { yyval.declarator = MkDeclaratorFunction((((void *)0)), yyvsp[(2) - (3)].list); ; } break; case 358: { yyval.declarator = MkDeclaratorFunction(yyvsp[(1) - (3)].declarator, (((void *)0))); ; } break; case 359: { yyval.declarator = MkDeclaratorFunction(yyvsp[(1) - (4)].declarator, yyvsp[(3) - (4)].list); ; } break; case 360: { yyval.declarator = MkDeclaratorPointer(yyvsp[(1) - (1)].pointer, (((void *)0))); ; } break; case 362: { yyval.declarator = MkDeclaratorPointer(yyvsp[(1) - (2)].pointer, yyvsp[(2) - (2)].declarator); ; } break; case 363: { yyval.declarator = MkDeclaratorExtended(yyvsp[(1) - (2)].extDecl, MkDeclaratorPointer(yyvsp[(2) - (2)].pointer, (((void *)0)))); ; } break; case 364: { yyval.declarator = MkDeclaratorExtended(yyvsp[(1) - (2)].extDecl, yyvsp[(2) - (2)].declarator); ; } break; case 365: { yyval.declarator = MkDeclaratorExtended(yyvsp[(1) - (3)].extDecl, MkDeclaratorPointer(yyvsp[(2) - (3)].pointer, yyvsp[(3) - (3)].declarator)); ; } break; case 366: { yyval.declarator = MkDeclaratorPointer(yyvsp[(1) - (1)].pointer, (((void *)0))); ; } break; case 368: { yyval.declarator = MkDeclaratorPointer(yyvsp[(1) - (2)].pointer, yyvsp[(2) - (2)].declarator); ; } break; case 369: { yyval.declarator = MkDeclaratorExtended(yyvsp[(1) - (2)].extDecl, MkDeclaratorPointer(yyvsp[(2) - (2)].pointer, (((void *)0)))); ; } break; case 370: { yyval.declarator = MkDeclaratorExtended(yyvsp[(1) - (2)].extDecl, yyvsp[(2) - (2)].declarator); ; } break; case 371: { yyval.declarator = MkDeclaratorExtended(yyvsp[(1) - (3)].extDecl, MkDeclaratorPointer(yyvsp[(2) - (3)].pointer, yyvsp[(3) - (3)].declarator)); ; } break; case 373: { yyval.declarator = MkDeclaratorPointer(yyvsp[(1) - (2)].pointer, yyvsp[(2) - (2)].declarator); ; } break; case 374: { yyval.declarator = MkDeclaratorExtended(yyvsp[(1) - (3)].extDecl, MkDeclaratorPointer(yyvsp[(2) - (3)].pointer, yyvsp[(3) - (3)].declarator)); ; } break; case 375: { yyval.declarator = MkDeclaratorExtendedEnd(yyvsp[(2) - (2)].extDecl, yyvsp[(1) - (2)].declarator); ; } break; case 376: { yyval.declarator = MkDeclaratorIdentifier(yyvsp[(1) - (1)].id); ; } break; case 377: { yyval.declarator = MkDeclaratorBrackets(yyvsp[(2) - (3)].declarator); ; } break; case 378: { yyval.declarator = MkDeclaratorArray(yyvsp[(1) - (4)].declarator, yyvsp[(3) - (4)].exp); ; } break; case 379: { yyval.declarator = MkDeclaratorArray(yyvsp[(1) - (3)].declarator, (((void *)0))); ; } break; case 380: { yyval.declarator = MkDeclaratorEnumArray(yyvsp[(1) - (4)].declarator, yyvsp[(3) - (4)].specifier); ; } break; case 382: { yyval.declarator = MkDeclaratorPointer(yyvsp[(1) - (2)].pointer, yyvsp[(2) - (2)].declarator); ; } break; case 383: { yyval.declarator = MkDeclaratorExtended(yyvsp[(1) - (2)].extDecl, yyvsp[(2) - (2)].declarator); ; } break; case 384: { yyval.declarator = MkDeclaratorExtended(yyvsp[(1) - (3)].extDecl, MkDeclaratorPointer(yyvsp[(2) - (3)].pointer, yyvsp[(3) - (3)].declarator)); ; } break; case 385: { yyval.declarator = MkDeclaratorPointer(yyvsp[(1) - (3)].pointer, MkDeclaratorExtended(yyvsp[(2) - (3)].extDecl, yyvsp[(3) - (3)].declarator)); ; } break; case 387: { yyval.declarator = MkDeclaratorFunction(yyvsp[(1) - (3)].declarator, yyvsp[(2) - (3)].list); ; } break; case 388: { yyval.declarator = MkDeclaratorFunction(yyvsp[(1) - (3)].declarator, yyvsp[(2) - (3)].list); ; } break; case 389: { yyval.declarator = MkDeclaratorFunction(yyvsp[(1) - (2)].declarator, (((void *)0))); ; } break; case 392: { yyval.declarator = MkDeclaratorExtended(yyvsp[(1) - (2)].extDecl, yyvsp[(2) - (2)].declarator); ; } break; case 393: { yyval.declarator = MkDeclaratorExtended(yyvsp[(1) - (2)].extDecl, yyvsp[(2) - (2)].declarator); ; } break; case 395: { yyval.declarator = MkDeclaratorPointer(yyvsp[(1) - (2)].pointer, yyvsp[(2) - (2)].declarator); ; } break; case 396: { yyval.declarator = MkDeclaratorExtended(yyvsp[(1) - (2)].extDecl, yyvsp[(2) - (2)].declarator); ; } break; case 397: { yyval.declarator = MkDeclaratorExtended(yyvsp[(1) - (3)].extDecl, MkDeclaratorPointer(yyvsp[(2) - (3)].pointer, yyvsp[(3) - (3)].declarator)); ; } break; case 398: { yyval.declarator = MkDeclaratorPointer(yyvsp[(1) - (3)].pointer, MkDeclaratorExtended(yyvsp[(2) - (3)].extDecl, yyvsp[(3) - (3)].declarator)); ; } break; case 399: { yyval.list = MkList(); ListAdd(yyval.list, yyvsp[(1) - (1)].specifier); ; } break; case 400: { yyval.list = yyvsp[(1) - (2)].list; ListAdd(yyvsp[(1) - (2)].list, yyvsp[(2) - (2)].specifier); ; } break; case 401: { yyval.pointer = MkPointer((((void *)0)), (((void *)0))); ; } break; case 402: { yyval.pointer = MkPointer(yyvsp[(2) - (2)].list, (((void *)0))); ; } break; case 403: { yyval.pointer = MkPointer((((void *)0)), yyvsp[(2) - (2)].pointer); ; } break; case 404: { yyval.pointer = MkPointer(yyvsp[(2) - (3)].list, yyvsp[(3) - (3)].pointer); ; } break; case 406: { yyval.list = yyvsp[(1) - (3)].list; ListAdd(yyvsp[(1) - (3)].list, MkTypeName((((void *)0)), (((void *)0)))); ; } break; case 407: { yyval.list = MkList(); ListAdd(yyval.list, yyvsp[(1) - (1)].typeName); ; } break; case 408: { yyval.list = yyvsp[(1) - (3)].list; ListAdd(yyvsp[(1) - (3)].list, yyvsp[(3) - (3)].typeName); ; } break; case 409: { yyval.typeName = MkTypeName(yyvsp[(1) - (2)].list, yyvsp[(2) - (2)].declarator); ; } break; case 410: { yyval.typeName = MkTypeName(yyvsp[(1) - (2)].list, yyvsp[(2) - (2)].declarator); ; } break; case 411: { yyval.typeName = MkTypeName(yyvsp[(1) - (2)].list, MkDeclaratorPointer(MkPointer((((void *)0)), (((void *)0))), (((void *)0)))); ; } break; case 412: { yyval.typeName = MkTypeName(yyvsp[(1) - (3)].list, MkDeclaratorPointer(MkPointer((((void *)0)), (((void *)0))), yyvsp[(3) - (3)].declarator)); ; } break; case 413: { yyval.typeName = MkTypeName(yyvsp[(1) - (1)].list, (((void *)0))); ; } break; case 414: { yyval.typeName = MkTypeName(MkListOne(MkSpecifier(CLASS)), (((void *)0))); ; } break; case 415: { yyval.list = MkList(); ListAdd(yyval.list, MkTypeName((((void *)0)), MkDeclaratorIdentifier(yyvsp[(1) - (1)].id))); ; } break; case 416: { yyval.list = yyvsp[(1) - (3)].list; ListAdd(yyvsp[(1) - (3)].list, MkTypeName((((void *)0)), MkDeclaratorIdentifier(yyvsp[(3) - (3)].id))); ; } break; case 417: { yyval.typeName = MkTypeName(yyvsp[(1) - (1)].list, (((void *)0))); ; } break; case 418: { yyval.typeName = MkTypeName(yyvsp[(1) - (2)].list, yyvsp[(2) - (2)].declarator); ; } break; case 419: { yyval.typeName = MkTypeName(yyvsp[(1) - (1)].list, (((void *)0))); ; } break; case 420: { yyval.typeName = MkTypeName(yyvsp[(1) - (2)].list, yyvsp[(2) - (2)].declarator); ; } break; case 421: { yyval.initializer = MkInitializerAssignment(yyvsp[(1) - (1)].exp); yyval.initializer->loc = (yyloc); ; } break; case 422: { yyval.initializer = MkInitializerList(yyvsp[(2) - (3)].list); yyval.initializer->loc = (yyloc); ; } break; case 423: { yyval.initializer = MkInitializerList(yyvsp[(2) - (4)].list); yyval.initializer->loc = (yyloc); { struct Expression * exp = MkExpDummy(); struct Initializer * init = MkInitializerAssignment(exp); init->loc = (yylsp[(3) - (4)]); exp->loc = (yylsp[(3) - (4)]); ListAdd(yyvsp[(2) - (4)].list, init); } ; } break; case 424: { yyval.initializer = MkInitializerAssignment(yyvsp[(1) - (1)].exp); yyval.initializer->loc = (yyloc); ; } break; case 425: { yyval.initializer = MkInitializerAssignment(yyvsp[(1) - (1)].exp); yyval.initializer->loc = (yyloc); ; } break; case 426: { yyval.list = MkList(); ListAdd(yyval.list, yyvsp[(1) - (1)].initializer); ; } break; case 427: { yyval.list = yyvsp[(1) - (3)].list; ListAdd(yyvsp[(1) - (3)].list, yyvsp[(3) - (3)].initializer); ; } break; case 434: { yyval.stmt = MkLabeledStmt(yyvsp[(1) - (3)].id, yyvsp[(3) - (3)].stmt); yyval.stmt->loc = (yyloc); ; } break; case 435: { yyval.stmt = MkCaseStmt(yyvsp[(2) - (4)].exp, yyvsp[(4) - (4)].stmt); yyval.stmt->loc = (yyloc); yyvsp[(2) - (4)].exp->loc.start = (yylsp[(1) - (4)]).end; ; } break; case 436: { yyval.stmt = MkCaseStmt((((void *)0)), yyvsp[(3) - (3)].stmt); yyval.stmt->loc = (yyloc); ; } break; case 437: { yyval.list = MkList(); ListAdd(yyval.list, yyvsp[(1) - (1)].declaration); ; } break; case 438: { yyval.list = yyvsp[(1) - (2)].list; ListAdd(yyvsp[(1) - (2)].list, yyvsp[(2) - (2)].declaration); ; } break; case 439: { yyval.list = MkList(); ListAdd(yyval.list, yyvsp[(1) - (1)].stmt); ; } break; case 440: { yyval.list = yyvsp[(1) - (2)].list; ListAdd(yyvsp[(1) - (2)].list, yyvsp[(2) - (2)].stmt); ; } break; case 441: { struct Statement * stmt = MkBadDeclStmt(yyvsp[(2) - (2)].declaration); stmt->loc = (yylsp[(2) - (2)]); ListAdd(yyvsp[(1) - (2)].list, stmt); yyval.list = yyvsp[(1) - (2)].list; ; } break; case 442: { yyval.stmt = MkCompoundStmt((((void *)0)), yyvsp[(1) - (1)].list); ; } break; case 443: { yyval.stmt = MkCompoundStmt(yyvsp[(1) - (1)].list, (((void *)0))); ; } break; case 444: { yyval.stmt = MkCompoundStmt(yyvsp[(1) - (2)].list, yyvsp[(2) - (2)].list); ; } break; case 445: { yyval.context = PushContext(); ; } break; case 446: { yyval.stmt = MkCompoundStmt((((void *)0)), (((void *)0))); yyval.stmt->compound.context = PushContext(); PopContext(yyval.stmt->compound.context); yyval.stmt->loc = (yyloc); ; } break; case 447: { yyval.stmt = yyvsp[(2) - (3)].stmt; yyval.stmt->compound.context = yyvsp[(1) - (3)].context; PopContext(yyvsp[(1) - (3)].context); yyval.stmt->loc = (yyloc); ; } break; case 448: { yyval.stmt = MkExpressionStmt((((void *)0))); yyval.stmt->loc = (yyloc); ; } break; case 449: { yyval.stmt = MkExpressionStmt(yyvsp[(1) - (2)].list); yyval.stmt->loc = (yyloc); ; } break; case 450: { yyval.stmt = MkIfStmt(yyvsp[(3) - (5)].list, yyvsp[(5) - (5)].stmt, (((void *)0))); yyval.stmt->loc = (yyloc); ; } break; case 451: { yyval.stmt = MkIfStmt(yyvsp[(3) - (7)].list, yyvsp[(5) - (7)].stmt, yyvsp[(7) - (7)].stmt); yyval.stmt->loc = (yyloc); ; } break; case 452: { yyval.stmt = MkSwitchStmt(yyvsp[(3) - (5)].list, yyvsp[(5) - (5)].stmt); yyval.stmt->loc = (yyloc); ; } break; case 453: { yyval.stmt = MkWhileStmt(yyvsp[(3) - (5)].list, yyvsp[(5) - (5)].stmt); yyval.stmt->loc = (yyloc); ; } break; case 454: { yyval.stmt = MkDoWhileStmt(yyvsp[(2) - (7)].stmt, yyvsp[(5) - (7)].list); yyval.stmt->loc = (yyloc); ; } break; case 455: { yyval.stmt = MkForStmt(yyvsp[(3) - (6)].stmt, yyvsp[(4) - (6)].stmt, (((void *)0)), yyvsp[(6) - (6)].stmt); yyval.stmt->loc = (yyloc); ; } break; case 456: { yyval.stmt = MkForStmt(yyvsp[(3) - (7)].stmt, yyvsp[(4) - (7)].stmt, yyvsp[(5) - (7)].list, yyvsp[(7) - (7)].stmt); yyval.stmt->loc = (yyloc); ; } break; case 457: { yyval.stmt = MkWhileStmt((((void *)0)), yyvsp[(4) - (4)].stmt); yyval.stmt->loc = (yyloc); ; } break; case 458: { yyval.stmt = MkForStmt(yyvsp[(3) - (5)].stmt, (((void *)0)), (((void *)0)), yyvsp[(5) - (5)].stmt); yyval.stmt->loc = (yyloc); ; } break; case 459: { yyval.stmt = MkForStmt((((void *)0)), (((void *)0)), (((void *)0)), yyvsp[(4) - (4)].stmt); yyval.stmt->loc = (yyloc); ; } break; case 460: { yyval.stmt = MkGotoStmt(yyvsp[(2) - (3)].id); yyval.stmt->loc = (yyloc); ; } break; case 461: { yyval.stmt = MkContinueStmt(); yyval.stmt->loc = (yyloc); ; } break; case 462: { yyval.stmt = MkBreakStmt(); yyval.stmt->loc = (yyloc); ; } break; case 463: { struct Expression * exp = MkExpDummy(); yyval.stmt = MkReturnStmt(MkListOne(exp)); yyval.stmt->loc = (yyloc); exp->loc = (yylsp[(2) - (2)]); ; } break; case 464: { yyval.stmt = MkReturnStmt(yyvsp[(2) - (3)].list); yyval.stmt->loc = (yyloc); ; } break; case 465: { yyval.string = __ecereNameSpace__ecere__sys__CopyString(yytext); ; } break; case 466: { yyval.instance = MkInstantiationNamed(yyvsp[(1) - (5)].list, MkExpIdentifier(yyvsp[(2) - (5)].id), yyvsp[(4) - (5)].list); yyval.instance->loc = (yyloc); yyval.instance->nameLoc = (yylsp[(2) - (5)]); yyval.instance->insideLoc.start = (yylsp[(3) - (5)]).end; yyval.instance->insideLoc.end = (yylsp[(5) - (5)]).start; ; } break; case 467: { yyval.instance = MkInstantiationNamed(yyvsp[(1) - (4)].list, MkExpIdentifier(yyvsp[(2) - (4)].id), MkList()); yyval.instance->loc = (yyloc); yyval.instance->nameLoc = (yylsp[(2) - (4)]); yyval.instance->insideLoc.start = (yylsp[(3) - (4)]).end; yyval.instance->insideLoc.end = (yylsp[(4) - (4)]).start; ; } break; case 468: { yyval.instance = MkInstantiationNamed(yyvsp[(1) - (5)].list, MkExpIdentifier(yyvsp[(2) - (5)].id), yyvsp[(4) - (5)].list); yyval.instance->loc = (yyloc); yyval.instance->nameLoc = (yylsp[(2) - (5)]); yyval.instance->insideLoc.start = (yylsp[(3) - (5)]).end; yyval.instance->insideLoc.end = (yylsp[(5) - (5)]).start; ; } break; case 469: { yyval.instance = MkInstantiationNamed(yyvsp[(1) - (4)].list, MkExpIdentifier(yyvsp[(2) - (4)].id), MkList()); yyval.instance->loc = (yyloc); yyval.instance->nameLoc = (yylsp[(2) - (4)]); yyval.instance->insideLoc.start = (yylsp[(3) - (4)]).end; yyval.instance->insideLoc.end = (yylsp[(4) - (4)]).start; ; } break; case 470: { yyval.instance = MkInstantiation(yyvsp[(1) - (4)].specifier, (((void *)0)), yyvsp[(3) - (4)].list); yyval.instance->loc = (yyloc); yyval.instance->insideLoc.start = (yylsp[(2) - (4)]).end; yyval.instance->insideLoc.end = (yylsp[(4) - (4)]).start; ; } break; case 471: { yyval.instance = MkInstantiation(yyvsp[(1) - (3)].specifier, (((void *)0)), MkList()); yyval.instance->loc = (yyloc); yyval.instance->insideLoc.start = (yylsp[(2) - (3)]).end; yyval.instance->insideLoc.end = (yylsp[(3) - (3)]).start; ; } break; case 472: { struct Location tmpLoc = type_yylloc; type_yylloc = (yylsp[(1) - (4)]); type_yylloc = tmpLoc; yyval.instance = MkInstantiation(MkSpecifierName(yyvsp[(1) - (4)].id->string), (((void *)0)), yyvsp[(3) - (4)].list); yyval.instance->loc = (yyloc); yyval.instance->insideLoc.start = (yylsp[(2) - (4)]).end; yyval.instance->insideLoc.end = (yylsp[(4) - (4)]).start; FreeIdentifier(yyvsp[(1) - (4)].id); ; } break; case 473: { struct Location tmpLoc = type_yylloc; type_yylloc = (yylsp[(1) - (3)]); type_yylloc = tmpLoc; yyval.instance = MkInstantiation(MkSpecifierName(yyvsp[(1) - (3)].id->string), (((void *)0)), MkList()); yyval.instance->loc = (yyloc); yyval.instance->insideLoc.start = (yylsp[(2) - (3)]).end; yyval.instance->insideLoc.end = (yylsp[(3) - (3)]).start; FreeIdentifier(yyvsp[(1) - (3)].id); ; } break; case 474: { yyval.instance = MkInstantiation((((void *)0)), (((void *)0)), yyvsp[(2) - (3)].list); yyval.instance->loc = (yyloc); yyval.instance->insideLoc.start = (yylsp[(1) - (3)]).end; yyval.instance->insideLoc.end = (yylsp[(3) - (3)]).start; ; } break; case 475: { yyval.instance = MkInstantiation((((void *)0)), (((void *)0)), MkList()); yyval.instance->loc = (yyloc); yyval.instance->insideLoc.start = (yylsp[(1) - (2)]).end; yyval.instance->insideLoc.end = (yylsp[(2) - (2)]).start; ; } break; case 476: { ProcessClassFunctionBody(yyvsp[(1) - (2)].classFunction, yyvsp[(2) - (2)].stmt); yyval.classFunction->loc = (yyloc); ; } break; case 477: { ProcessClassFunctionBody(yyvsp[(1) - (2)].classFunction, yyvsp[(2) - (2)].stmt); yyval.classFunction->loc = (yyloc); ; } break; case 478: { ProcessClassFunctionBody(yyvsp[(1) - (2)].classFunction, (((void *)0))); yyval.classFunction->loc = (yyloc); ; } break; case 479: { ProcessClassFunctionBody(yyvsp[(1) - (2)].classFunction, yyvsp[(2) - (2)].stmt); yyval.classFunction->loc = (yyloc); ; } break; case 480: { ProcessClassFunctionBody(yyvsp[(1) - (2)].classFunction, yyvsp[(2) - (2)].stmt); yyval.classFunction->loc = (yyloc); ; } break; case 481: { yyval.classFunction = MkClassFunction(yyvsp[(1) - (2)].list, (((void *)0)), yyvsp[(2) - (2)].declarator, (((void *)0))); yyval.classFunction->loc = (yyloc); yyval.classFunction->id = ++globalContext->nextID; ; } break; case 482: { yyval.classFunction = MkClassFunction(yyvsp[(1) - (2)].list, (((void *)0)), yyvsp[(2) - (2)].declarator, (((void *)0))); yyval.classFunction->loc = (yyloc); yyval.classFunction->id = ++globalContext->nextID; ; } break; case 483: { ProcessClassFunctionBody(yyvsp[(1) - (2)].classFunction, yyvsp[(2) - (2)].stmt); yyval.classFunction->loc = (yyloc); ; } break; case 484: { yyval.memberInit = MkMemberInitExp(yyvsp[(1) - (3)].exp, yyvsp[(3) - (3)].initializer); yyval.memberInit->loc = (yyloc); yyval.memberInit->realLoc = (yyloc); yyval.memberInit->initializer->loc.start = (yylsp[(2) - (3)]).end; ; } break; case 485: { yyval.memberInit = MkMemberInit((((void *)0)), yyvsp[(1) - (1)].initializer); yyval.memberInit->loc = (yyloc); yyval.memberInit->realLoc = (yyloc); ; } break; case 486: { yyval.list = MkList(); ListAdd(yyval.list, yyvsp[(1) - (1)].memberInit); ; } break; case 487: { ((struct MemberInit *)(*yyvsp[(1) - (3)].list).last)->loc.end = (yylsp[(3) - (3)]).start; ListAdd(yyvsp[(1) - (3)].list, yyvsp[(3) - (3)].memberInit); yyval.list = yyvsp[(1) - (3)].list; ; } break; case 488: { if((*yyvsp[(1) - (2)].list).last) ((struct MemberInit *)(*yyvsp[(1) - (2)].list).last)->loc.end = (yylsp[(2) - (2)]).end; yyval.list = yyvsp[(1) - (2)].list; ; } break; case 489: { struct MembersInit * members = MkMembersInitList(yyvsp[(1) - (1)].list); yyval.list = MkList(); ListAdd(yyval.list, members); members->loc = (yylsp[(1) - (1)]); ; } break; case 490: { yyval.list = MkList(); ListAdd(yyval.list, MkMembersInitMethod(yyvsp[(1) - (1)].classFunction)); ((struct MembersInit *)(*yyval.list).last)->loc = (yylsp[(1) - (1)]); ; } break; case 491: { struct MembersInit * members = MkMembersInitList(yyvsp[(2) - (2)].list); ListAdd(yyval.list, members); members->loc = (yylsp[(2) - (2)]); yyval.list = yyvsp[(1) - (2)].list; ; } break; case 492: { ListAdd(yyval.list, MkMembersInitMethod(yyvsp[(2) - (2)].classFunction)); ((struct MembersInit *)(*yyval.list).last)->loc = (yylsp[(2) - (2)]); yyval.list = yyvsp[(1) - (2)].list; ; } break; case 493: { struct MembersInit * members = MkMembersInitList(MkList()); yyval.list = MkList(); ListAdd(yyval.list, members); members->loc = (yylsp[(1) - (1)]); ; } break; case 494: { struct MembersInit * members = MkMembersInitList(MkList()); ListAdd(yyval.list, members); members->loc = (yylsp[(2) - (2)]); yyval.list = yyvsp[(1) - (2)].list; ; } break; case 496: { yyval.list = MkList(); ListAdd(yyval.list, MkMembersInitList(yyvsp[(1) - (1)].list)); ((struct MembersInit *)(*yyval.list).last)->loc = (yylsp[(1) - (1)]); ; } break; case 497: { ListAdd(yyvsp[(1) - (2)].list, MkMembersInitList(yyvsp[(2) - (2)].list)); ((struct MembersInit *)(*yyval.list).last)->loc = (yylsp[(2) - (2)]); ; } break; case 498: { parsedType = yyvsp[(1) - (1)].typeName; ; } break; case 499: { parsedType = yyvsp[(1) - (3)].typeName; parsedType->bitCount = yyvsp[(3) - (3)].exp; ; } break; default: break; } do { if(type_yydebug) { fprintf((bsl_stderr()), "%s ", "-> $$ ="); yy_symbol_print((bsl_stderr()), yyr1[yyn], &yyval, &yyloc); fprintf((bsl_stderr()), "\n"); } }while((0)); (yyvsp -= (yylen), yyssp -= (yylen), yylsp -= (yylen)); yylen = 0; do { if(type_yydebug) yy_stack_print((yyss), (yyssp)); }while((0)); *++yyvsp = yyval; *++yylsp = yyloc; yyn = yyr1[yyn]; yystate = yypgoto[yyn - 143] + *yyssp; if(0 <= yystate && yystate <= 8981 && yycheck[yystate] == *yyssp) yystate = yytable[yystate]; else yystate = yydefgoto[yyn - 143]; goto yynewstate; yyerrlab: if(!yyerrstatus) { ++type_yynerrs; yyerror("syntax error"); } yyerror_range[0] = type_yylloc; if(yyerrstatus == 3) { if(type_yychar <= 0) { if(type_yychar == 0) goto yyabortlab; } else { yydestruct("Error: discarding", yytoken, &type_yylval, &type_yylloc); type_yychar = (-2); } } goto yyerrlab1; yyerrorlab: if(0) goto yyerrorlab; yyerror_range[0] = yylsp[1 - yylen]; (yyvsp -= (yylen), yyssp -= (yylen), yylsp -= (yylen)); yylen = 0; do { if(type_yydebug) yy_stack_print((yyss), (yyssp)); }while((0)); yystate = *yyssp; goto yyerrlab1; yyerrlab1: yyerrstatus = 3; for(; ; ) { yyn = yypact[yystate]; if(yyn != -750) { yyn += 1; if(0 <= yyn && yyn <= 8981 && yycheck[yyn] == (short)1) { yyn = yytable[yyn]; if(0 < yyn) break; } } if(yyssp == yyss) goto yyabortlab; yyerror_range[0] = *yylsp; yydestruct("Error: popping", yystos[yystate], yyvsp, yylsp); (yyvsp -= (1), yyssp -= (1), yylsp -= (1)); yystate = *yyssp; do { if(type_yydebug) yy_stack_print((yyss), (yyssp)); }while((0)); } *++yyvsp = type_yylval; yyerror_range[1] = type_yylloc; (yyloc.start = ((yyerror_range - 1))[1].start); (yyloc.end = ((yyerror_range - 1))[2].end); ; *++yylsp = yyloc; do { if(type_yydebug) { fprintf((bsl_stderr()), "%s ", "Shifting"); yy_symbol_print((bsl_stderr()), yystos[yyn], yyvsp, yylsp); fprintf((bsl_stderr()), "\n"); } }while((0)); yystate = yyn; goto yynewstate; yyacceptlab: yyresult = 0; goto yyreturn; yyabortlab: yyresult = 1; goto yyreturn; yyexhaustedlab: yyerror("memory exhausted"); yyresult = 2; yyreturn: if(type_yychar != (-2)) yydestruct("Cleanup: discarding lookahead", yytoken, &type_yylval, &type_yylloc); (yyvsp -= (yylen), yyssp -= (yylen), yylsp -= (yylen)); do { if(type_yydebug) yy_stack_print((yyss), (yyssp)); }while((0)); while(yyssp != yyss) { yydestruct("Cleanup: popping", yystos[*yyssp], yyvsp, yylsp); (yyvsp -= (1), yyssp -= (1), yylsp -= (1)); } if(yyss != yyssa) free(yyss); return (yyresult); } void __ecereRegisterModule_type(struct __ecereNameSpace__ecere__com__Instance * module) { struct __ecereNameSpace__ecere__com__Class * class; } void __ecereUnregisterModule_type(struct __ecereNameSpace__ecere__com__Instance * module) { }
77.688271
109,872
0.645119
[ "object" ]
ef34147493f9a537e7be9494d6f0fc730c622ce7
73,538
h
C
NN/DLnet.h
freegraphics/cpputils
3f990d4765a50c7428bd6a4929a83ff49d3567bd
[ "MIT" ]
null
null
null
NN/DLnet.h
freegraphics/cpputils
3f990d4765a50c7428bd6a4929a83ff49d3567bd
[ "MIT" ]
null
null
null
NN/DLnet.h
freegraphics/cpputils
3f990d4765a50c7428bd6a4929a83ff49d3567bd
[ "MIT" ]
null
null
null
#if !defined(__DLNET_H__259ADFCB_316B_4832_B14E_2928FCCBC10B__) #define __DLNET_H__259ADFCB_316B_4832_B14E_2928FCCBC10B__ #pragma once #include "resource.h" #include <math.h> #include <vector> #include <list> #include <map> #include <Images/MemoryDC.h> #include "utils.h" #include <utils/tracealloc.h> #include <utils/binfile.h> #if !defined(real) #define real double #endif struct Vol { size_t sx,sy,depth; typedef std::vector<real> WT; WT w,dw; Vol(size_t _sx = 0,size_t _sy = 0,size_t _depth = 0,bool _bRandInit = true,real _c = 0) :sx(0),sy(0),depth(0) { alloc(_sx,_sy,_depth,_bRandInit,_c); } ~Vol() { if(!w.empty()) w.clear(); if(!dw.empty()) dw.clear(); } void alloc(size_t _sx,size_t _sy,size_t _depth,bool _bRandInit,real _c = 0,const Vol* _vol = NULL) { sx = _sx;sy = _sy; depth = _depth; size_t n = sx*sy*depth; w.resize(n); dw.resize(n); if(_bRandInit) { real scale = sqrt((real)1.0/((real)sx*(real)sy*(real)depth)); size_t i=0; gauss_rand randn; real measure = min_value<real>(scale*(real)3.0,(real)0.2); for(i=0;i<n;i++) {w[i] = clamp<real>(randn((real)0.0,scale),-measure,measure);} } else if(_vol==NULL) { size_t i=0; for(i=0;i<n;i++) {w[i] = _c;} } else if(_vol!=NULL) { size_t i=0; for(i=0;i<n;i++) {w[i] = _vol->w[i];} for(i=0;i<n;i++) {dw[i] = _vol->dw[i];} } } void clear() { if(!w.empty()) w.clear(); if(!dw.empty()) dw.clear(); sx = 0; sy = 0; depth = 0; } void alloc_copy(const Vol& _vol) { alloc(_vol.sx,_vol.sy,_vol.depth,false,(real)0,&_vol); } void copy_w(const Vol& _vol) { VERIFY_EXIT(w.size()==_vol.w.size()); size_t i=0; for(i=0;i<w.size();i++) {w[i] = _vol.w[i];} } void copy_w_mask(const Vol& _vol,size_t _min_idx,size_t _max_idx) { VERIFY_EXIT(w.size()==_vol.w.size()); size_t i=0; for(i=_min_idx;i<w.size() && i<_max_idx;i++) {w[i] = _vol.w[i];} } void copy_w_clamp(const Vol& _vol) { VERIFY_EXIT(w.size()==_vol.w.size()); size_t i=0; for(i=0;i<w.size();i++) {w[i] = clamp(_vol.w[i],(real)-0.5,(real)0.5);} } void copy_dw(const Vol& _vol) { VERIFY_EXIT(dw.size()==_vol.dw.size()); size_t i=0; for(i=0;i<dw.size();i++) {dw[i] = _vol.dw[i];} } void copy_dw_mask(const Vol& _vol,size_t _min_idx,size_t _max_idx) { VERIFY_EXIT(dw.size()==_vol.dw.size()); size_t i=0; for(i=0;i<dw.size();i++) { if(i>=_min_idx && i<_max_idx) dw[i] = _vol.dw[i]; else dw[i] = (real)0.0; } } void copy_w(const Vol& _vol,size_t _offs1,size_t _offs2,size_t _sz) { VERIFY_EXIT(w.size()>=_offs1+_sz); VERIFY_EXIT(_vol.w.size()>=_offs2+_sz); size_t i=0; for(i=0;i<_sz;i++) {w[i+_offs1] = _vol.w[i+_offs2];} } void copy_dw(const Vol& _vol,size_t _offs1,size_t _offs2,size_t _sz) { VERIFY_EXIT(dw.size()>=_offs1+_sz); VERIFY_EXIT(_vol.dw.size()>=_offs2+_sz); size_t i=0; for(i=0;i<_sz;i++) {dw[i+_offs1] = _vol.dw[i+_offs2];} } void add_dw(const Vol& _vol) { VERIFY_EXIT(dw.size()==_vol.dw.size()); size_t i=0; for(i=0;i<dw.size();i++) {dw[i] += _vol.dw[i];} } void add_w(const Vol& _vol) { VERIFY_EXIT(w.size()==_vol.w.size()); size_t i=0; for(i=0;i<w.size();i++) {w[i] += _vol.w[i];} } void mull_w(real _k) { size_t i=0; for(i=0;i<w.size();i++) {w[i] *= _k;} } void mull_dw(real _k) { size_t i=0; for(i=0;i<dw.size();i++) {dw[i] *= _k;} } void norm_w() { size_t i=0; for(i=0;i<w.size();i++) { real maxv = w[i]; real minv = w[i]; maxv = max(maxv,(real)0.5); minv = fabs(min(minv,(real)-0.5)); real delta = 2*max(maxv,minv); w[i] = w[i]/delta; } //for(i=1;i<w.size();i++) //{ // if(maxv<w[i]) maxv = w[i]; // if(minv>w[i]) minv = w[i]; //} //minv = min(minv,-0.5); //maxv = max(maxv,0.5); //if(minv==0.5 && maxv==0.5) return; //real delta = 2*max(fabs(minv),fabs(maxv)); //for(i=0;i<w.size();i++) //{ // w[i] = w[i]/delta; //} } void add_dw(const Vol& _vol,size_t _offs1,size_t _offs2,size_t _sz) { VERIFY_EXIT(dw.size()>=_offs1+_sz); VERIFY_EXIT(_vol.dw.size()>=_offs2+_sz); size_t i=0; for(i=0;i<dw.size();i++) {dw[i+_offs1] += _vol.dw[i+_offs2];} } void copy(const Vol& _vol) { VERIFY_EXIT(w.size()==_vol.w.size()); size_t i=0; for(i=0;i<w.size();i++) {w[i] = _vol.w[i];} for(i=0;i<w.size();i++) {dw[i] = _vol.dw[i];} } real get(size_t _x,size_t _y,size_t _depth) const { size_t idx = ((sx*_y)+_x)*depth + _depth; return w[idx]; } void set(size_t _x,size_t _y,size_t _depth,real _v) { size_t idx = ((sx*_y)+_x)*depth + _depth; w[idx] = _v; } void add(size_t _x,size_t _y,size_t _depth,real _v) { size_t idx = ((sx*_y)+_x)*depth + _depth; w[idx] += _v; } real get_grad(size_t _x,size_t _y,size_t _depth) const { size_t idx = ((sx*_y)+_x)*depth + _depth; return dw[idx]; } void set_grad(size_t _x,size_t _y,size_t _depth,real _v) { size_t idx = ((sx*_y)+_x)*depth + _depth; dw[idx] = _v; }; void add_grad(size_t _x,size_t _y,size_t _depth,real _v) { size_t idx = ((sx*_y)+_x)*depth + _depth; dw[idx] += _v; } void zero_dw() { size_t i=0; for(i=0;i<dw.size();i++) { dw[i] = (real)0;} } // var<Vol> cloneAndZero() const // { // var<Vol> v; // v = new Vol(sx,sy,depth,false,0); // return v; // } // // var<Vol> clone() const // { // var<Vol> v; // v = new Vol(sx,sy,depth,false,0); // size_t i=0; // for(i=0;i<w.size();i++) // { // v->w[i] = w[i]; // v->dw[i] = dw[i]; // } // return v; // } void add_from(const Vol& _v) { size_t i=0; for(i=0;i<w.size();i++) { w[i] += _v.w[i]; } } void add_from_scaled(const Vol& _v,real _a) { size_t i=0; for(i=0;i<w.size();i++) { w[i] += _v.w[i]*_a; } } void set_const(real _v) { size_t i=0; for(i=0;i<w.size();i++) { w[i] = _v; } } void regression(const Vol& _y) { VERIFY_EXIT(_y.w.size()==dw.size() && _y.w.size()==w.size()); size_t i=0; for(i=0;i<w.size();i++) { dw[i] = w[i] - _y.w[i]; } } };//struct Vol inline void img_to_vol(IN MemoryDC& _img,OUT Vol& _imgx,IN bool _bconvert2grayscale = false) { _imgx.alloc(_img.getWidth(),_img.getHeight(),_bconvert2grayscale?1:4,false); long x,y; for(y=0;y<_img.getHeight();y++) for(x=0;x<_img.getWidth();x++) { BYTE r = 0,g = 0,b = 0,a = 0; _img.GetRGBA(x,y,r,g,b,a); if(!_bconvert2grayscale) { _imgx.set(x,y,0,r/(real)256.0-(real)0.5); _imgx.set(x,y,1,g/(real)256.0-(real)0.5); _imgx.set(x,y,2,b/(real)256.0-(real)0.5); _imgx.set(x,y,3,a/(real)256.0-(real)0.5); } else { _imgx.set(x,y,0,(real)RGBtoGray(r,g,b,a)/(real)256.0-(real)0.5); } } } enum LayerTypeEn { layertype_null = 0 ,layertype_input ,layertype_fc ,layertype_relu ,layertype_sigmoid ,layertype_regression ,layertype_conv ,layertype_pool ,layertype_softmax ,layertype_maxout ,layertype_dropout ,layertype_lrn ,layertype_quadtransform ,layertype_tanh ,layertype_hidden_input ,layertype_hidden_regression ,layertype_functional }; struct Layer; struct LayerOpts { LayerTypeEn type; LayerTypeEn activation; size_t num_neurons; real l1_decay_mul; real l2_decay_mul; size_t in_sx,in_sy,in_depth; size_t out_sx,out_sy,out_depth; size_t extra_sx,extra_sy,extra_depth; size_t extra_offs; real bias_pref; bool b_bias_pref; size_t sx,sy; size_t filters; size_t stride; long pad; size_t num_inputs; size_t group_size; real drop_prob; bool b_drop_prob; real k; long n; real alpha; real beta; size_t num_classes; bool tensor; Layer* original; size_t identity; size_t start_drop; size_t stop_drop; size_t start_regression; size_t stop_regression; LayerOpts() :type(layertype_null) ,activation(layertype_null) ,num_neurons(0) ,l1_decay_mul(0) ,l2_decay_mul(0) ,in_sx(0),in_sy(0),in_depth(0) ,out_sx(0),out_sy(0),out_depth(0) ,extra_sx(0),extra_sy(0),extra_depth(0) ,extra_offs(0) ,bias_pref((real)0.1) ,b_bias_pref(false) ,sx(0),sy(0) ,filters(0) ,stride(0) ,pad(0) ,num_inputs(0) ,group_size(0) ,drop_prob((real)0.5) ,k(0) ,n(0) ,alpha(0) ,beta(0) ,num_classes(0) ,tensor(false) ,b_drop_prob(false) ,original(NULL) ,identity(0) ,start_drop(0) ,stop_drop(0) ,start_regression(0) ,stop_regression(0) { } void set_bias_pref(real _bias_pref) { b_bias_pref = true; bias_pref = _bias_pref; } void set_drop_params(real _drop_prob,size_t _start_drop,size_t _stop_drop) { b_drop_prob = true; drop_prob = _drop_prob; start_drop = _start_drop; stop_drop = _stop_drop; } }; struct ParamsAndGrads { Vol::WT* params; Vol::WT* grads; real l1_decay_mul; real l2_decay_mul; ParamsAndGrads( Vol::WT* _params = NULL ,Vol::WT* _grads = NULL ,real _l1_decay_mul = (real)0.0 ,real _l2_decay_mul = (real)0.0 ) :params(_params) ,grads(_grads) ,l1_decay_mul(_l1_decay_mul) ,l2_decay_mul(_l2_decay_mul) { } }; typedef std::vector<ParamsAndGrads> ParamsAndGradsVec; struct Layer { size_t out_sx; size_t out_sy; size_t out_depth; size_t num_inputs; Vol* in_act; Vol out_act; bool stop_learning; bool start_learning; size_t identity; LayerTypeEn layer_type; // Layer() // :out_sx(0) // ,out_sy(0) // ,out_depth(0) // ,num_inputs(0) // ,layer_type(layertype_null) // ,in_act(NULL) // ,stop_learning(false) // ,start_learning(false) // ,identity(0) // { // } Layer(const LayerOpts& _opt) :out_sx(0) ,out_sy(0) ,out_depth(0) ,num_inputs(0) ,layer_type(layertype_null) ,in_act(NULL) ,stop_learning(false) ,start_learning(false) ,identity(_opt.identity) { } virtual ~Layer() { out_act.clear(); } Layer(const Layer& _layer) :in_act(NULL) ,identity(_layer.identity) { out_sx = _layer.out_sx; out_sy = _layer.out_sy; out_depth = _layer.out_depth; num_inputs = _layer.num_inputs; layer_type = _layer.layer_type; } Vol& get_input() {return out_act;} Vol& get_result() {return out_act;} virtual void initialize(const LayerOpts& _opt) = 0; virtual void forward(bool _is_training) {}; virtual void backward(bool _blearn) {} virtual real backward(const Vol& _y,bool _blearn) {return 0;}; virtual void getParamsAndGrads(ParamsAndGradsVec& _response) {_response.clear();} virtual void setParamsAndGrads(ParamsAndGradsVec& _response) {} virtual Layer* clone() const = 0; virtual void set_input(Vol* _input) {}; }; /* // This file contains all layers that do dot products with input, // but usually in a different connectivity pattern and weight sharing // schemes: // - FullyConn is fully connected dot products // - ConvLayer does convolutions (so weight sharing spatially) // putting them together in one file because they are very similar var ConvLayer = function(opt) { var opt = opt || {}; // required this.out_depth = opt.filters; this.sx = opt.sx; // filter size. Should be odd if possible, it's cleaner. this.in_depth = opt.in_depth; this.in_sx = opt.in_sx; this.in_sy = opt.in_sy; // optional this.sy = typeof opt.sy !== 'undefined' ? opt.sy : this.sx; this.stride = typeof opt.stride !== 'undefined' ? opt.stride : 1; // stride at which we apply filters to input volume this.pad = typeof opt.pad !== 'undefined' ? opt.pad : 0; // amount of 0 padding to add around borders of input volume this.l1_decay_mul = typeof opt.l1_decay_mul !== 'undefined' ? opt.l1_decay_mul : 0.0; this.l2_decay_mul = typeof opt.l2_decay_mul !== 'undefined' ? opt.l2_decay_mul : 1.0; // computed // note we are doing floor, so if the strided convolution of the filter doesnt fit into the input // volume exactly, the output volume will be trimmed and not contain the (incomplete) computed // final application. this.out_sx = Math.floor((this.in_sx + this.pad * 2 - this.sx) / this.stride + 1); this.out_sy = Math.floor((this.in_sy + this.pad * 2 - this.sy) / this.stride + 1); this.layer_type = 'conv'; // initializations this.filters = []; for(var i=0;i<this.out_depth;i++) { this.filters.push(new Vol(this.sx, this.sy, this.in_depth)); } this.biases = new Vol(1, 1, this.out_depth, 0.1); } */ struct ConvLayer : public Layer { size_t sx,sy,stride; size_t in_depth,in_sx,in_sy; long pad; real l1_decay_mul,l2_decay_mul; std::vector<Vol> filters; std::vector<Vol> biases; static void init(LayerOpts& _opt) { _opt.stride = 1; _opt.l1_decay_mul = (real)0.0; _opt.l2_decay_mul = (real)1.0; } virtual Layer* clone() const { return trace_alloc(new ConvLayer(*this)); } ConvLayer(const LayerOpts& _opt) :Layer(_opt) ,sx(0) ,sy(0) ,stride(0) ,pad(0) ,in_depth(0) ,in_sx(0) ,in_sy(0) ,l1_decay_mul(0) ,l2_decay_mul(0) { initialize(_opt); } virtual void initialize(const LayerOpts& _opt) { out_depth = _opt.filters; sx = _opt.sx; sy = _opt.sy; in_depth = _opt.in_depth; in_sx = _opt.in_sx; in_sy = _opt.in_sy; stride = _opt.stride; pad = _opt.pad; l1_decay_mul = _opt.l1_decay_mul; l2_decay_mul = _opt.l2_decay_mul; out_sx = (in_sx + pad*2 - sx)/stride + 1; out_sy = (in_sy + pad*2 - sy)/stride + 1; layer_type = layertype_conv; filters.resize(out_depth); size_t i=0; for(i=0;i<out_depth;i++) filters[i].alloc(sx,sy,in_depth,true); biases.resize(1); biases[0].alloc(1,1,out_depth,false,(real)0.1); out_act.alloc(out_sx,out_sy,out_depth,false,(real)0.0); } ConvLayer(const ConvLayer& _cl) :Layer(_cl) { sx = _cl.sx; sy = _cl.sy; stride = _cl.stride; pad = _cl.pad; in_depth = _cl.in_depth; in_sx = _cl.in_sx; in_sy = _cl.in_sy; l1_decay_mul = _cl.l1_decay_mul; l2_decay_mul = _cl.l2_decay_mul; filters.resize(out_depth); size_t i=0; for(i=0;i<out_depth;i++) filters[i].alloc_copy(_cl.filters[i]); biases.resize(1); biases[0].alloc_copy(_cl.biases[0]); out_act.alloc_copy(_cl.out_act); } /*ConvLayer.prototype = { forward: function(V, is_training) { this.in_act = V; var A = new Vol(this.out_sx, this.out_sy, this.out_depth, 0.0); for(var d=0;d<this.out_depth;d++) { var f = this.filters[d]; var x = -this.pad; var y = -this.pad; for(var ax=0; ax<this.out_sx; x+=this.stride,ax++) { y = -this.pad; for(var ay=0; ay<this.out_sy; y+=this.stride,ay++) { // convolve centered at this particular location // could be bit more efficient, going for correctness first var a = 0.0; for(var fx=0;fx<f.sx;fx++) { for(var fy=0;fy<f.sy;fy++) { for(var fd=0;fd<f.depth;fd++) { var oy = y+fy; // coordinates in the original input array coordinates var ox = x+fx; if(oy>=0 && oy<V.sy && ox>=0 && ox<V.sx) { //a += f.get(fx, fy, fd) * V.get(ox, oy, fd); // avoid function call overhead for efficiency, compromise modularity :( a += f.w[((f.sx * fy)+fx)*f.depth+fd] * V.w[((V.sx * oy)+ox)*V.depth+fd]; } } } } a += this.biases.w[d]; A.set(ax, ay, d, a); } } } this.out_act = A; return this.out_act; },*/ void forward(bool _is_training) { Vol& V = *in_act; Vol& A = out_act; size_t d=0; for(d=0;d<out_depth;d++) { Vol& f = filters[d]; long x = -pad; long y = -pad; long ax=0; for(ax=0;ax<(long)out_sx;x+=(long)stride,ax++) { y = -pad; long ay = 0; for(ay=0;ay<(long)out_sy;y+=(long)stride,ay++) { real a = 0; long fx=0,fy=0,fd=0; for(fy=0;fy<(long)f.sy;fy++) for(fx=0;fx<(long)f.sx;fx++) for(fd=0;fd<(long)f.depth;fd++) { long oy = y + fy; long ox = x + fx; if(oy>=0 && oy<(long)V.sy && ox>=0 && ox<(long)V.sx) { // a += f->get(fx, fy, fd) * _V->get(ox, oy, fd); a += f.w[(((long)f.sx*fy)+fx)*(long)f.depth + fd] * V.w[(((long)V.sx * oy)+ox)*(long)V.depth+fd] ; } } a += biases[0].w[d]; A.set(ax,ay,d,a); } } } } /*backward: function() { // compute gradient wrt weights, biases and input data var V = this.in_act; V.dw = global.zeros(V.w.length); // zero out gradient wrt bottom data, we're about to fill it for(var d=0;d<this.out_depth;d++) { var f = this.filters[d]; var x = -this.pad; var y = -this.pad; for(var ax=0; ax<this.out_sx; x+=this.stride,ax++) { y = -this.pad; for(var ay=0; ay<this.out_sy; y+=this.stride,ay++) { // convolve and add up the gradients. // could be more efficient, going for correctness first var chain_grad = this.out_act.get_grad(ax,ay,d); // gradient from above, from chain rule for(var fx=0;fx<f.sx;fx++) { for(var fy=0;fy<f.sy;fy++) { for(var fd=0;fd<f.depth;fd++) { var oy = y+fy; var ox = x+fx; if(oy>=0 && oy<V.sy && ox>=0 && ox<V.sx) { // forward prop calculated: a += f.get(fx, fy, fd) * V.get(ox, oy, fd); //f.add_grad(fx, fy, fd, V.get(ox, oy, fd) * chain_grad); //V.add_grad(ox, oy, fd, f.get(fx, fy, fd) * chain_grad); // avoid function call overhead and use Vols directly for efficiency var ix1 = ((V.sx * oy)+ox)*V.depth+fd; var ix2 = ((f.sx * fy)+fx)*f.depth+fd; f.dw[ix2] += V.w[ix1]*chain_grad; V.dw[ix1] += f.w[ix2]*chain_grad; } } } } this.biases.dw[d] += chain_grad; } } } },*/ void backward(bool _blearn) { Vol& V = *in_act; V.zero_dw(); size_t d=0; for(d=0;d<out_depth;d++) { Vol& f = filters[d]; long x = -pad; long y = -pad; long ax=0,ay=0,fx=0,fy=0,fd=0; for(ax=0;ax<(long)out_sx;x+=(long)stride,ax++) { y = -pad; for(ay=0;ay<(long)out_sy;y+=(long)stride,ay++) { real chain_grad = out_act.get_grad(ax,ay,d); for(fy=0;fy<(long)f.sy;fy++) for(fx=0;fx<(long)f.sx;fx++) for(fd=0;fd<(long)f.depth;fd++) { long oy = y + fy; long ox = x + fx; if(oy>=0 && oy<(long)V.sy && ox>=0 && ox<(long)V.sx) { long ix1 = (((long)V.sx*oy) + ox)*(long)V.depth + fd; long ix2 = (((long)f.sx*fy) + fx)*(long)f.depth + fd; if(_blearn) f.dw[ix2] += V.w[ix1]*chain_grad; V.dw[ix1] += f.w[ix2]*chain_grad; } } if(_blearn) biases[0].dw[d] += chain_grad; } } } } /*getParamsAndGrads: function() { var response = []; for(var i=0;i<this.out_depth;i++) { response.push({params: this.filters[i].w, grads: this.filters[i].dw, l2_decay_mul: this.l2_decay_mul, l1_decay_mul: this.l1_decay_mul}); } response.push({params: this.biases.w, grads: this.biases.dw, l1_decay_mul: 0.0, l2_decay_mul: 0.0}); return response; },*/ void getParamsAndGrads(ParamsAndGradsVec& _response) { _response.clear(); _response.reserve(out_depth+1); size_t i=0; for(i=0;i<out_depth;i++) { _response.push_back(ParamsAndGrads(&(filters[i].w),&(filters[i].dw),l1_decay_mul,l2_decay_mul)); } _response.push_back(ParamsAndGrads(&(biases[0].w),&(biases[0].dw),0,0)); } virtual void setParamsAndGrads(ParamsAndGradsVec& _response) { size_t i=0,j=0; for(i=0;i<out_depth;i++) { VERIFY_DO(_response[i].params->size()==filters[i].w.size(),continue); for(j=0;j<filters[i].w.size();j++) { filters[i].w[j] = (*_response[i].params)[j]; } } VERIFY_EXIT(_response[i].params->size()==biases[0].w.size()); for(j=0;j<_response[i].params->size();j++) biases[0].w[j] = (*_response[i].params)[j]; } };//struct ConvLayer struct FullyConnLayer : public Layer { real l1_decay_mul; real l2_decay_mul; real bias; std::vector<Vol> filters; std::vector<Vol> biases; virtual Layer* clone() const { FullyConnLayer* layer = trace_alloc(new FullyConnLayer(*this)); return layer; } static void init(LayerOpts& _opt) { _opt.l1_decay_mul = (real)0.0; _opt.l2_decay_mul = (real)1.0; _opt.bias_pref = (real)0.1; } FullyConnLayer(const LayerOpts& _opt) :Layer(_opt) ,l1_decay_mul(0) ,l2_decay_mul(0) ,bias(0) { initialize(_opt); } virtual void initialize(const LayerOpts& _opt) { out_depth = _opt.num_neurons; l1_decay_mul = _opt.l1_decay_mul; l2_decay_mul = _opt.l2_decay_mul; num_inputs = _opt.in_sx*_opt.in_sy*_opt.in_depth; out_sx = 1; out_sy = 1; layer_type = layertype_fc; bias = _opt.b_bias_pref?_opt.bias_pref:(real)0.1; size_t i=0; filters.resize(out_depth); for(i=0;i<out_depth;i++) filters[i].alloc(1,1,num_inputs,true); biases.resize(1); biases[0].alloc(1,1,out_depth,false,bias); out_act.alloc(1,1,out_depth,false,(real)0.0); } FullyConnLayer(const FullyConnLayer& _fc) :Layer(_fc) { l2_decay_mul = _fc.l2_decay_mul; l1_decay_mul = _fc.l1_decay_mul; size_t i=0; filters.resize(out_depth); for(i=0;i<out_depth;i++) filters[i].alloc_copy(_fc.filters[i]); biases.resize(1); biases[0].alloc_copy(_fc.biases[0]); out_act.alloc_copy(_fc.out_act); } void forward(bool _is_training) { Vol& V = *in_act; Vol& A = out_act; const Vol::WT& Vw = V.w; size_t i = 0; for(i=0;i<out_depth;i++) { real a = 0.0; Vol::WT& wi = filters[i].w; size_t d=0; for(d=0;d<num_inputs;d++) { a += Vw[d]*wi[d]; } a += biases.front().w[i]; A.w[i] = a; } } void backward(bool _blearn) { Vol& V = *in_act; V.zero_dw(); size_t i=0; for(i=0;i<out_depth;i++) { Vol& tfi = filters[i]; real chain_grad = out_act.dw[i]; size_t d=0; for(d=0;d<num_inputs;d++) { V.dw[d] += tfi.w[d]*chain_grad; if(_blearn) tfi.dw[d] += V.w[d]*chain_grad; } if(_blearn) biases[0].dw[i] += chain_grad; } } /*void backward_temp() { Vol& V = *in_act; size_t d=0,i=0; for(d=0;d<num_inputs;d++) { real Vdwd = 0; real Vwd = V.w[d]; for(i=0;i<out_depth;i++) { Vol& tfi = filters[i]; real chain_grad = out_act.dw[i]; Vdwd += tfi.w[d]*chain_grad; tfi.dw[d] += Vwd*chain_grad; } V.dw[d] = Vdwd; } }*/ void getParamsAndGrads(ParamsAndGradsVec& _response) { _response.clear(); _response.reserve(out_depth+1); size_t i=0; for(i=0;i<out_depth;i++) { _response.push_back(ParamsAndGrads(&(filters[i].w),&(filters[i].dw),l1_decay_mul,l2_decay_mul)); } _response.push_back(ParamsAndGrads(&(biases[0].w),&(biases[0].dw),0,0)); } virtual void setParamsAndGrads(ParamsAndGradsVec& _response) { size_t i=0,j=0; for(i=0;i<out_depth;i++) { VERIFY_DO(_response[i].params->size()==filters[i].w.size(),continue); for(j=0;j<filters[i].w.size();j++) { filters[i].w[j] = (*_response[i].params)[j]; } } VERIFY_EXIT(_response[i].params->size()==biases[0].w.size()); for(j=0;j<_response[i].params->size();j++) biases[0].w[j] = (*_response[i].params)[j]; } }; /*var PoolLayer = function(opt) { var opt = opt || {}; // required this.sx = opt.sx; // filter size this.in_depth = opt.in_depth; this.in_sx = opt.in_sx; this.in_sy = opt.in_sy; // optional this.sy = typeof opt.sy !== 'undefined' ? opt.sy : this.sx; this.stride = typeof opt.stride !== 'undefined' ? opt.stride : 2; this.pad = typeof opt.pad !== 'undefined' ? opt.pad : 0; // amount of 0 padding to add around borders of input volume // computed this.out_depth = this.in_depth; this.out_sx = Math.floor((this.in_sx + this.pad * 2 - this.sx) / this.stride + 1); this.out_sy = Math.floor((this.in_sy + this.pad * 2 - this.sy) / this.stride + 1); this.layer_type = 'pool'; // store switches for x,y coordinates for where the max comes from, for each output neuron this.switchx = global.zeros(this.out_sx*this.out_sy*this.out_depth); this.switchy = global.zeros(this.out_sx*this.out_sy*this.out_depth); }*/ struct PoolLayer : public Layer { size_t in_sx,in_sy,in_depth; size_t sx,sy; long stride,pad; std::vector<long> switchx,switchy; static void init(LayerOpts& _opt) { _opt.stride = 2; } virtual Layer* clone() const { return trace_alloc(new PoolLayer(*this)); } PoolLayer(const LayerOpts& _opt) :Layer(_opt) ,sx(0),sy(0) ,stride(0),pad(0) ,in_sx(0),in_sy(0),in_depth(0) { initialize(_opt); } virtual void initialize(const LayerOpts& _opt) { sx = _opt.sx; sy = _opt.sy; in_depth = _opt.in_depth; in_sx = _opt.in_sx; in_sy = _opt.in_sy; stride = _opt.stride; pad = _opt.pad; out_depth = in_depth; out_sx = (in_sx + pad*2 - sx)/stride + 1; out_sy = (in_sy + pad*2 - sy)/stride + 1; layer_type = layertype_pool; switchx.resize(out_sx*out_sy*out_depth); switchy.resize(out_sx*out_sy*out_depth); out_act.alloc(out_sx,out_sy,out_depth,false,(real)0.0); } PoolLayer(const PoolLayer& _pl) :Layer(_pl) { sx = _pl.sx; sy = _pl.sy; stride = _pl.stride; pad = _pl.pad; in_sx = _pl.in_sx; in_sy = _pl.in_sy; in_depth = _pl.in_depth; switchx.resize(out_sx*out_sy*out_depth); switchy.resize(out_sx*out_sy*out_depth); out_act.alloc_copy(_pl.out_act); } /*forward: function(V, is_training) { this.in_act = V; var A = new Vol(this.out_sx, this.out_sy, this.out_depth, 0.0); var n=0; // a counter for switches for(var d=0;d<this.out_depth;d++) { var x = -this.pad; var y = -this.pad; for(var ax=0; ax<this.out_sx; x+=this.stride,ax++) { y = -this.pad; for(var ay=0; ay<this.out_sy; y+=this.stride,ay++) { // convolve centered at this particular location var a = -99999; // hopefully small enough ;\ var winx=-1,winy=-1; for(var fx=0;fx<this.sx;fx++) { for(var fy=0;fy<this.sy;fy++) { var oy = y+fy; var ox = x+fx; if(oy>=0 && oy<V.sy && ox>=0 && ox<V.sx) { var v = V.get(ox, oy, d); // perform max pooling and store pointers to where // the max came from. This will speed up backprop // and can help make nice visualizations in future if(v > a) { a = v; winx=ox; winy=oy;} } } } this.switchx[n] = winx; this.switchy[n] = winy; n++; A.set(ax, ay, d, a); } } } this.out_act = A; return this.out_act; },*/ virtual void forward(bool _is_training) { Vol& V = *in_act; Vol& A = out_act; size_t n=0,d=0; long ax=0,ay=0,fx=0,fy=0; for(d=0,n=0;d<out_depth;d++) { long x = -pad; long y = -pad; for(ax=0;ax<(long)out_sx;x+=stride,ax++) { y = -pad; for(ay=0;ay<(long)out_sy;y+=stride,ay++) { real a = -99999; long winx=-1,winy=-1; for(fy=0;fy<(long)sy;fy++) for(fx=0;fx<(long)sx;fx++) { long oy = y + fy; long ox = x + fx; if(oy>=0 && oy<(long)V.sy && ox>=0 && ox<(long)V.sx) { real v = V.get(ox,oy,d); if(v>a){a=v;winx=ox,winy=oy;} } } switchx[n] = winx; switchy[n] = winy; n++; A.set(ax,ay,d,a); } } } } /*backward: function() { // pooling layers have no parameters, so simply compute // gradient wrt data here var V = this.in_act; V.dw = global.zeros(V.w.length); // zero out gradient wrt data var A = this.out_act; // computed in forward pass var n = 0; for(var d=0;d<this.out_depth;d++) { var x = -this.pad; var y = -this.pad; for(var ax=0; ax<this.out_sx; x+=this.stride,ax++) { y = -this.pad; for(var ay=0; ay<this.out_sy; y+=this.stride,ay++) { var chain_grad = this.out_act.get_grad(ax,ay,d); V.add_grad(this.switchx[n], this.switchy[n], d, chain_grad); n++; } } } },*/ virtual void backward(bool _blearn) { Vol& V = *in_act; V.zero_dw(); Vol& A = out_act; size_t n=0; long d=0,ax=0,ay=0; for(n=0,d=0;d<(long)out_depth;d++) { long x = -pad; long y = -pad; for(ay=0;ay<(long)out_sy;y+=stride,ay++) { x = -pad; for(ax=0;ax<(long)out_sx;x+=stride,ax++) { real chain_grad = out_act.get_grad(ax,ay,d); V.add_grad(switchx[n],switchy[n],d,chain_grad); n++; } } } } };//struct PoolLayer struct InputLayer : public Layer { size_t extra_sx,extra_sy,extra_depth; static void init(LayerOpts& _opt) { } InputLayer(const LayerOpts& _opt) :Layer(_opt) ,extra_sx(0),extra_sy(0),extra_depth(0) { initialize(_opt); } virtual void initialize(const LayerOpts& _opt) { out_sx = _opt.out_sx!=0?_opt.out_sx:_opt.in_sx; out_sy = _opt.out_sy!=0?_opt.out_sy:_opt.in_sy; out_depth = _opt.out_depth!=0?_opt.out_depth:_opt.in_depth; extra_sx = _opt.extra_sx; extra_sy = _opt.extra_sy; extra_depth = _opt.extra_depth; layer_type = layertype_input; out_act.alloc(out_sx+extra_sx,out_sy+extra_sy,out_depth+extra_depth,false); } InputLayer(const InputLayer& _layer) :Layer(_layer) ,extra_sx(_layer.extra_sx) ,extra_sy(_layer.extra_sy) ,extra_depth(_layer.extra_depth) { out_act.alloc_copy(_layer.out_act); } virtual Layer* clone() const { InputLayer* layer = trace_alloc(new InputLayer(*this)); return layer; } }; /* // This is a classifier, with N discrete classes from 0 to N-1 // it gets a stream of N incoming numbers and computes the softmax // function (exponentiate and normalize to sum to 1 as probabilities should) var SoftmaxLayer = function(opt) { var opt = opt || {}; // computed this.num_inputs = opt.in_sx * opt.in_sy * opt.in_depth; this.out_depth = this.num_inputs; this.out_sx = 1; this.out_sy = 1; this.layer_type = 'softmax'; }*/ struct SoftmaxLayer : public Layer { Vol::WT es; static void init(LayerOpts& _opt) { } virtual Layer* clone() const { return trace_alloc(new SoftmaxLayer(*this)); } SoftmaxLayer(const LayerOpts& _opt) :Layer(_opt) { initialize(_opt); } virtual void initialize(const LayerOpts& _opt) { num_inputs = _opt.in_sx*_opt.in_sy*_opt.in_depth; out_depth = num_inputs; out_sx = 1; out_sy = 1; layer_type = layertype_softmax; out_act.alloc(out_sx,out_sy,out_depth,false,(real)0.0); } SoftmaxLayer(const SoftmaxLayer& _sl) :Layer(_sl) { out_act.alloc_copy(_sl.out_act); } /*SoftmaxLayer.prototype = { forward: function(V, is_training) { this.in_act = V; var A = new Vol(1, 1, this.out_depth, 0.0); // compute max activation var as = V.w; var amax = V.w[0]; for(var i=1;i<this.out_depth;i++) { if(as[i] > amax) amax = as[i]; } // compute exponentials (carefully to not blow up) var es = global.zeros(this.out_depth); var esum = 0.0; for(var i=0;i<this.out_depth;i++) { var e = Math.exp(as[i] - amax); esum += e; es[i] = e; } // normalize and output to sum to one for(var i=0;i<this.out_depth;i++) { es[i] /= esum; A.w[i] = es[i]; } this.es = es; // save these for backprop this.out_act = A; return this.out_act; },*/ virtual void forward(bool _is_training) { Vol& V = *in_act; Vol& A = out_act; const Vol::WT& as = V.w; real amax = V.w[0]; size_t i=0; for(i=0;i<out_depth;i++) { if(as[i]>amax) amax = as[i]; } es.resize(out_depth); real esum = 0.0; for(i=0;i<out_depth;i++) { real e = exp(as[i]-amax); esum += e; es[i] = e; } for(i=0;i<out_depth;i++) { es[i] /= esum; A.w[i] = es[i]; } } /*backward: function(y) { // compute and accumulate gradient wrt weights and bias of this layer var x = this.in_act; x.dw = global.zeros(x.w.length); // zero out the gradient of input Vol for(var i=0;i<this.out_depth;i++) { var indicator = i === y ? 1.0 : 0.0; var mul = -(indicator - this.es[i]); x.dw[i] = mul; } // loss is the class negative log likelihood return -Math.log(this.es[y]); },*/ virtual real backward(const Vol& _y,bool _blearn) { Vol& x = *in_act; x.zero_dw(); size_t i=0; size_t y = 0; for(i=0;i<out_depth;i++) { if(_y.w[i]>0.0) y=i; real mul = -(_y.w[i]+(real)0.5 - es[i]); x.dw[i] = mul; } return -log(es[y]); } };//struct SoftmaxLayer struct RegressionLayer : public Layer { bool outter_dw; size_t start_regression; size_t stop_regression; static void init(LayerOpts& _opt) { _opt.start_regression = 0; _opt.stop_regression = 0; } RegressionLayer(const LayerOpts& _opt) :Layer(_opt) ,outter_dw(false) ,start_regression(0) ,stop_regression(0) { initialize(_opt); } virtual void initialize(const LayerOpts& _opt) { num_inputs = _opt.in_sx*_opt.in_sy*_opt.in_depth; out_depth = num_inputs; out_sx = 1; out_sy = 1; layer_type = layertype_regression; outter_dw = false; start_regression = _opt.start_regression; stop_regression = _opt.stop_regression!=0?_opt.stop_regression:out_depth; out_act.alloc(out_sx,out_sy,out_depth,false,0.0); } RegressionLayer(const RegressionLayer& _layer) :Layer(_layer) ,outter_dw(_layer.outter_dw) { out_act.alloc_copy(_layer.out_act); } virtual void forward(bool _is_training) { out_act.copy_w(*in_act); } virtual real backward(const Vol& _y,bool _blearn) { Vol& x = *in_act; if(!outter_dw) { real loss = 0; x.zero_dw(); size_t i=0; for(i=start_regression;i<stop_regression;i++) { real dy = (x.w[i] - _y.w[i]); x.dw[i] = dy; loss += 2*dy*dy; } return loss; } else { x.copy_dw(out_act); return 0; } } virtual Layer* clone() const { RegressionLayer* layer = trace_alloc(new RegressionLayer(*this)); return layer; } }; struct ReluLayer : public Layer { static void init(LayerOpts& _opt) { } ReluLayer(const LayerOpts& _opt) :Layer(_opt) { initialize(_opt); } virtual void initialize(const LayerOpts& _opt) { out_sx = _opt.in_sx; out_sy = _opt.in_sy; out_depth = _opt.in_depth; layer_type = layertype_relu; out_act.alloc(out_sx,out_sy,out_depth,false,(real)0.0); } ReluLayer(const ReluLayer& _layer) :Layer(_layer) { out_act.alloc_copy(_layer.out_act); } virtual void forward(bool _is_training) { Vol& _V = *in_act; Vol& V2 = out_act; V2.copy(_V); Vol::WT& V2w = V2.w; size_t i=0; for(i=0;i<V2w.size();i++) { if(V2w[i]<0) V2w[i] = 0; } } virtual void backward(bool _blearn) { Vol& V = *in_act; Vol& V2 = out_act; V.zero_dw(); size_t i=0,N = V.w.size(); for(i=0;i<N;i++) { if(V2.w[i]<=0) V.dw[i] = 0; else V.dw[i] = V2.dw[i]; } } virtual Layer* clone() const { ReluLayer* layer = trace_alloc(new ReluLayer(*this)); return layer; } }; struct HiddenInput : public Layer { size_t extra_offs; size_t extra_size; Vol* input; static void init(LayerOpts& _opt) { } HiddenInput(const LayerOpts& _opt) :Layer(_opt) ,input(NULL) ,extra_offs(0) ,extra_size(0) { initialize(_opt); } virtual void initialize(const LayerOpts& _opt) { extra_offs = _opt.extra_offs; extra_size = max(1,_opt.extra_sx)*max(1,_opt.extra_sy)*max(1,_opt.extra_depth); out_sx = _opt.in_sx + _opt.extra_sx; out_sy = _opt.in_sy + _opt.extra_sy; out_depth = _opt.in_depth + _opt.extra_depth; layer_type = layertype_hidden_input; out_act.alloc(out_sx,out_sy,out_depth,false,(real)0.0); } virtual void set_input(Vol* _input) { input = _input; } HiddenInput(const HiddenInput& _layer) :Layer(_layer) ,input(NULL) ,extra_offs(_layer.extra_offs) ,extra_size(_layer.extra_size) { out_act.alloc_copy(_layer.out_act); } virtual void forward(bool _is_training) { Vol& V = *in_act; Vol& V2 = out_act; size_t i=0; for(i=0;i<V.w.size();i++) { V2.w[i] = V.w[i]; } size_t j=0; for(j=0;j<extra_size;j++,i++) { V2.w[i] = input->w[extra_offs+j]; } } virtual void backward(bool _blearn) { Vol& V = *in_act; Vol& V2 = out_act; V.zero_dw(); size_t i=0,N = V.w.size(); for(i=0;i<N;i++) { V.dw[i] = V2.dw[i]; } } virtual Layer* clone() const { HiddenInput* layer = trace_alloc(new HiddenInput(*this)); return layer; } };//struct HiddenInput struct HiddenRegression : public Layer { size_t extra_offs; size_t extra_size; Vol* input; Vol loss; static void init(LayerOpts& _opt) { } HiddenRegression(const LayerOpts& _opt) :Layer(_opt) ,input(NULL) ,extra_offs(0) ,extra_size(0) { initialize(_opt); } virtual void initialize(const LayerOpts& _opt) { extra_offs = _opt.extra_offs; extra_size = max(1,_opt.extra_sx)*max(1,_opt.extra_sy)*max(1,_opt.extra_depth); out_sx = _opt.in_sx; out_sy = _opt.in_sy; out_depth = _opt.in_depth; layer_type = layertype_hidden_regression; out_act.alloc(out_sx,out_sy,out_depth,false,(real)0.0); loss.alloc(max(1,_opt.extra_sx),max(1,_opt.extra_sy),max(1,_opt.extra_depth),false,(real)0.0); } virtual void set_input(Vol* _vol) { input = _vol; } HiddenRegression(const HiddenRegression& _layer) :Layer(_layer) ,input(NULL) ,extra_offs(_layer.extra_offs) ,extra_size(_layer.extra_size) { out_act.alloc_copy(_layer.out_act); loss.alloc_copy(_layer.loss); } virtual void forward(bool _is_training) { Vol& V = *in_act; Vol& V2 = out_act; size_t i=0; for(i=0;i<V.w.size()-extra_size;i++) { V2.w[i] = V.w[i]; } size_t j=0; for(j=0;j<extra_size;j++,i++) { V2.w[i] = input->w[extra_offs+j]; } } virtual void backward(bool _blearn) { Vol& V = *in_act; Vol& V2 = out_act; V.zero_dw(); size_t i=0,N = V.w.size(),j=0; for(i=0;i<N-extra_size;i++) { V.dw[i] = V2.dw[i]; } for(j=0;j<extra_size;j++,i++) { real dy = (V.w[i] - input->w[extra_offs+j]); loss.w[j] = dy; V.dw[i] = dy; } } virtual Layer* clone() const { HiddenRegression* layer = trace_alloc(new HiddenRegression(*this)); return layer; } };//struct HiddenInput struct SigmoidLayer : public Layer { static void init(LayerOpts& _opt) { } SigmoidLayer(const LayerOpts& _opt) :Layer(_opt) { initialize(_opt); } virtual void initialize(const LayerOpts& _opt) { out_sx = _opt.in_sx; out_sy = _opt.in_sy; out_depth = _opt.in_depth; layer_type = layertype_sigmoid; out_act.alloc(out_sx,out_sy,out_depth,false,(real)0.0); } SigmoidLayer(const SigmoidLayer& _layer) :Layer(_layer) { out_act.alloc_copy(_layer.out_act); } virtual void forward(bool _is_training) { Vol& _V = *in_act; Vol& V2 = out_act; size_t N = _V.w.size(); Vol::WT& V2w = V2.w; const Vol::WT& Vw = _V.w; size_t i=0; for(i=0;i<N;i++) { V2w[i] = (real)1.0/((real)1.0 + exp(-Vw[i])); } } virtual void backward(bool _blearn) { Vol& V = *in_act; Vol& V2 = out_act; size_t N = V.w.size(); V.zero_dw(); size_t i=0; for(i=0;i<N;i++) { real v2wi = V2.w[i]; V.dw[i] = v2wi*((real)1.0 - v2wi)*V2.dw[i]; } } virtual Layer* clone() const { SigmoidLayer* layer = trace_alloc(new SigmoidLayer(*this)); return layer; } }; /* // Implements Maxout nonlinearity that computes // x -> max(x) // where x is a vector of size group_size. Ideally of course, // the input size should be exactly divisible by group_size var MaxoutLayer = function(opt) { var opt = opt || {}; // required this.group_size = typeof opt.group_size !== 'undefined' ? opt.group_size : 2; // computed this.out_sx = opt.in_sx; this.out_sy = opt.in_sy; this.out_depth = Math.floor(opt.in_depth / this.group_size); this.layer_type = 'maxout'; this.switches = global.zeros(this.out_sx*this.out_sy*this.out_depth); // useful for backprop } */ struct MaxoutLayer : public Layer { size_t group_size; std::vector<long> switches; static void init(LayerOpts& _opt) { _opt.group_size = 2; } MaxoutLayer(const LayerOpts& _opt) :Layer(_opt) ,group_size(0) { initialize(_opt); } virtual void initialize(const LayerOpts& _opt) { group_size = _opt.group_size; out_sx = _opt.in_sx; out_sy = _opt.in_sy; out_depth = _opt.in_depth/group_size; layer_type = layertype_maxout; switches.resize(out_sx*out_sy*out_depth); out_act.alloc(out_sx,out_sy,out_depth,false,(real)0.0); } virtual Layer* clone() const { return trace_alloc(new MaxoutLayer(*this)); } MaxoutLayer(const MaxoutLayer& _ml) :Layer(_ml) { group_size = _ml.group_size; switches.resize(out_sx*out_sy*out_depth); out_act.alloc_copy(_ml.out_act); } /*MaxoutLayer.prototype = { forward: function(V, is_training) { this.in_act = V; var N = this.out_depth; var V2 = new Vol(this.out_sx, this.out_sy, this.out_depth, 0.0); // optimization branch. If we're operating on 1D arrays we dont have // to worry about keeping track of x,y,d coordinates inside // input volumes. In convnets we do :( if(this.out_sx === 1 && this.out_sy === 1) { for(var i=0;i<N;i++) { var ix = i * this.group_size; // base index offset var a = V.w[ix]; var ai = 0; for(var j=1;j<this.group_size;j++) { var a2 = V.w[ix+j]; if(a2 > a) { a = a2; ai = j; } } V2.w[i] = a; this.switches[i] = ix + ai; } } else { var n=0; // counter for switches for(var x=0;x<V.sx;x++) { for(var y=0;y<V.sy;y++) { for(var i=0;i<N;i++) { var ix = i * this.group_size; var a = V.get(x, y, ix); var ai = 0; for(var j=1;j<this.group_size;j++) { var a2 = V.get(x, y, ix+j); if(a2 > a) { a = a2; ai = j; } } V2.set(x,y,i,a); this.switches[n] = ix + ai; n++; } } } } this.out_act = V2; return this.out_act; },*/ virtual void forward(bool _is_training) { Vol& V = *in_act; size_t N = out_depth; Vol& V2 = out_act; if(out_sx==1 && out_sy==1) { size_t i=0; for(i=0;i<N;i++) { size_t ix = i*group_size; real a = V.w[ix]; size_t ai = 0; size_t j=0; for(j=0;j<group_size && ix+j<N;j++) { real a2 = V.w[ix+j]; if(a2>a) { a = a2; ai = j; } } V2.w[i] = a; switches[i] = ix+ai; } } else { size_t n=0; size_t x=0,y=0,i=0; for(y=0;y<V.sy;y++) for(x=0;x<V.sx;x++) for(i=0;i<N;i++) { size_t ix = i*group_size; real a = V.get(x,y,ix); size_t ai = 0; size_t j=0; for(j=0;j<group_size && ix+j<N;j++) { real a2 = V.get(x,y,ix+j); if(a2>a) { a = a2; ai = j; } } V2.set(x,y,i,a); switches[n] = ix + ai; n++; } } } /*backward: function() { var V = this.in_act; // we need to set dw of this var V2 = this.out_act; var N = this.out_depth; V.dw = global.zeros(V.w.length); // zero out gradient wrt data // pass the gradient through the appropriate switch if(this.out_sx === 1 && this.out_sy === 1) { for(var i=0;i<N;i++) { var chain_grad = V2.dw[i]; V.dw[this.switches[i]] = chain_grad; } } else { // bleh okay, lets do this the hard way var n=0; // counter for switches for(var x=0;x<V2.sx;x++) { for(var y=0;y<V2.sy;y++) { for(var i=0;i<N;i++) { var chain_grad = V2.get_grad(x,y,i); V.set_grad(x,y,this.switches[n],chain_grad); n++; } } } } },*/ virtual void backward(bool _blearn) { Vol& V = *in_act; Vol& V2 = out_act; size_t N = out_depth; V.zero_dw(); if(out_sx==1 && out_sy==1) { size_t i=0; for(i=0;i<N;i++) { real chain_grad = V2.dw[i]; V.dw[switches[i]] = chain_grad; } } else { size_t n=0; size_t x=0,y=0,i=0; for(y=0;y<V2.sy;y++) for(x=0;x<V2.sx;x++) for(i=0;i<N;i++) { real chain_grad = V2.get_grad(x,y,i); V.set_grad(x,y,switches[n],chain_grad); n++; } } } };//struct MaxoutLayer /* // a helper function, since tanh is not yet part of ECMAScript. Will be in v6. function tanh(x) { var y = Math.exp(2 * x); return (y - 1) / (y + 1); } // Implements Tanh nonlinearity elementwise // x -> tanh(x) // so the output is between -1 and 1. var TanhLayer = function(opt) { var opt = opt || {}; // computed this.out_sx = opt.in_sx; this.out_sy = opt.in_sy; this.out_depth = opt.in_depth; this.layer_type = 'tanh'; } TanhLayer.prototype = { forward: function(V, is_training) { this.in_act = V; var V2 = V.cloneAndZero(); var N = V.w.length; for(var i=0;i<N;i++) { V2.w[i] = tanh(V.w[i]); } this.out_act = V2; return this.out_act; }, backward: function() { var V = this.in_act; // we need to set dw of this var V2 = this.out_act; var N = V.w.length; V.dw = global.zeros(N); // zero out gradient wrt data for(var i=0;i<N;i++) { var v2wi = V2.w[i]; V.dw[i] = (1.0 - v2wi * v2wi) * V2.dw[i]; } }, getParamsAndGrads: function() { return []; }, toJSON: function() { var json = {}; json.out_depth = this.out_depth; json.out_sx = this.out_sx; json.out_sy = this.out_sy; json.layer_type = this.layer_type; return json; }, fromJSON: function(json) { this.out_depth = json.out_depth; this.out_sx = json.out_sx; this.out_sy = json.out_sy; this.layer_type = json.layer_type; } } global.TanhLayer = TanhLayer; global.MaxoutLayer = MaxoutLayer; global.ReluLayer = ReluLayer; global.SigmoidLayer = SigmoidLayer; })(convnetjs); */ //inline //real tanh(real _x) //{ // real y = exp(2*_x); // return (y - 1) / (y + 1); //} struct TanhLayer : public Layer { static void init(LayerOpts& _opt) { } TanhLayer(const LayerOpts& _opt) :Layer(_opt) { initialize(_opt); } virtual void initialize(const LayerOpts& _opt) { out_sx = _opt.in_sx; out_sy = _opt.in_sy; out_depth = _opt.in_depth; layer_type = layertype_tanh; out_act.alloc(out_sx,out_sy,out_depth,false,(real)0.0); } TanhLayer(const TanhLayer& _layer) :Layer(_layer) { out_act.alloc_copy(_layer.out_act); } virtual void forward(bool _is_training) { Vol& V = *in_act; Vol& V2 = out_act; size_t N = V.w.size(); Vol::WT& V2w = V2.w; const Vol::WT& Vw = V.w; size_t i=0; for(i=0;i<N;i++) { V2w[i] = tanh(Vw[i]); } } virtual void backward(bool _blearn) { Vol& V = *in_act; Vol& V2 = out_act; size_t N = V.w.size(); V.zero_dw(); size_t i=0; for(i=0;i<N;i++) { real v2wi = V2.w[i]; V.dw[i] = ((real)1.0 - v2wi*v2wi)*V2.dw[i]; } } virtual Layer* clone() const { TanhLayer* layer = trace_alloc(new TanhLayer(*this)); return layer; } };//struct TahnLayer /* // An inefficient dropout layer // Note this is not most efficient implementation since the layer before // computed all these activations and now we're just going to drop them :( // same goes for backward pass. Also, if we wanted to be efficient at test time // we could equivalently be clever and upscale during train and copy pointers during test // todo: make more efficient. var DropoutLayer = function(opt) { var opt = opt || {}; // computed this.out_sx = opt.in_sx; this.out_sy = opt.in_sy; this.out_depth = opt.in_depth; this.layer_type = 'dropout'; this.drop_prob = typeof opt.drop_prob !== 'undefined' ? opt.drop_prob : 0.5; this.dropped = global.zeros(this.out_sx*this.out_sy*this.out_depth); } */ struct DropoutLayer : public Layer { real drop_prob; std::vector<bool> dropped; size_t start_drop; size_t stop_drop; static void init(LayerOpts& _opt) { _opt.drop_prob = (real)0.5; _opt.start_drop = 0; _opt.stop_drop = 0; } DropoutLayer(const LayerOpts& _opt) :Layer(_opt) { initialize(_opt); } virtual void initialize(const LayerOpts& _opt) { out_sx = _opt.in_sx; out_sy = _opt.in_sy; out_depth = _opt.in_depth; layer_type = layertype_dropout; drop_prob = _opt.drop_prob; start_drop = _opt.start_drop; stop_drop = _opt.stop_drop!=0?_opt.stop_drop:out_sx*out_sy*out_depth; dropped.resize(out_sx*out_sy*out_depth); out_act.alloc(out_sx,out_sy,out_depth,false,(real)0.0); } virtual Layer* clone() const { return trace_alloc(new DropoutLayer(*this)); } DropoutLayer(const DropoutLayer& _dl) :Layer(_dl) ,start_drop(_dl.start_drop) ,stop_drop(_dl.stop_drop) ,drop_prob(_dl.drop_prob) { dropped.resize(out_sx*out_sy*out_depth); out_act.alloc_copy(_dl.out_act); } /*DropoutLayer.prototype = { forward: function(V, is_training) { this.in_act = V; if(typeof(is_training)==='undefined') { is_training = false; } // default is prediction mode var V2 = V.clone(); var N = V.w.length; if(is_training) { // do dropout for(var i=0;i<N;i++) { if(Math.random()<this.drop_prob) { V2.w[i]=0; this.dropped[i] = true; } // drop! else {this.dropped[i] = false;} } } else { // scale the activations during prediction for(var i=0;i<N;i++) { V2.w[i]*=this.drop_prob; } } this.out_act = V2; return this.out_act; // dummy identity function for now },*/ virtual void forward(bool _is_training) { Vol& _V = *in_act; out_act.copy(_V); Vol& V2 = out_act; size_t N = _V.w.size(); if(_is_training) { // do dropout size_t i=0; for(i=start_drop;i<stop_drop;i++) { if(::rand((real)1.0)<drop_prob) {V2.w[i] = 0; dropped[i] = true;} // drop! else {dropped[i] = false;} } } else { size_t i=0; for(i=0;i<N;i++) {V2.w[i]*=drop_prob;} } } /*backward: function() { var V = this.in_act; // we need to set dw of this var chain_grad = this.out_act; var N = V.w.length; V.dw = global.zeros(N); // zero out gradient wrt data for(var i=0;i<N;i++) { if(!(this.dropped[i])) { V.dw[i] = chain_grad.dw[i]; // copy over the gradient } } },*/ virtual void backward(bool _blearn) { Vol& V = *in_act; Vol& chain_grad = out_act; size_t N = V.w.size(); V.zero_dw(); size_t i=0; for(i=start_drop;i<stop_drop;i++) { if(!dropped[i]) { V.dw[i] = chain_grad.dw[i]; } } } }; /* // a bit experimental layer for now. I think it works but I'm not 100% // the gradient check is a bit funky. I'll look into this a bit later. // Local Response Normalization in window, along depths of volumes var LocalResponseNormalizationLayer = function(opt) { var opt = opt || {}; // required this.k = opt.k; this.n = opt.n; this.alpha = opt.alpha; this.beta = opt.beta; // computed this.out_sx = opt.in_sx; this.out_sy = opt.in_sy; this.out_depth = opt.in_depth; this.layer_type = 'lrn'; // checks if(this.n%2 === 0) { console.log('WARNING n should be odd for LRN layer'); } }*/ struct LocalResponseNormalizationLayer : public Layer { real k; long n; real alpha; real beta; Vol S_cache; static void init(LayerOpts& _opt) { } LocalResponseNormalizationLayer(const LayerOpts& _opt) :Layer(_opt) ,k(0) ,n(0) ,alpha(0) ,beta(0) { initialize(_opt); } virtual void initialize(const LayerOpts& _opt) { k = _opt.k; n = _opt.n; alpha = _opt.alpha; beta = _opt.beta; out_sx = _opt.out_sx; out_sy = _opt.out_sy; out_depth = _opt.out_depth; layer_type = layertype_lrn; VERIFY_EXIT(n%2!=0); S_cache.alloc(out_sx,out_sy,out_depth,false,(real)0.0); out_act.alloc(out_sx,out_sy,out_depth,false,(real)0.0); } virtual Layer* clone() const { return trace_alloc(new LocalResponseNormalizationLayer(*this)); } LocalResponseNormalizationLayer(const LocalResponseNormalizationLayer& _lrnl) :Layer(_lrnl) { k = _lrnl.k; n = _lrnl.n; alpha = _lrnl.alpha; beta = _lrnl.beta; S_cache.alloc_copy(_lrnl.S_cache); out_act.alloc_copy(_lrnl.out_act); } /*LocalResponseNormalizationLayer.prototype = { forward: function(V, is_training) { this.in_act = V; var A = V.cloneAndZero(); this.S_cache_ = V.cloneAndZero(); var n2 = Math.floor(this.n/2); for(var x=0;x<V.sx;x++) { for(var y=0;y<V.sy;y++) { for(var i=0;i<V.depth;i++) { var ai = V.get(x,y,i); // normalize in a window of size n var den = 0.0; for(var j=Math.max(0,i-n2);j<=Math.min(i+n2,V.depth-1);j++) { var aa = V.get(x,y,j); den += aa*aa; } den *= this.alpha / this.n; den += this.k; this.S_cache_.set(x,y,i,den); // will be useful for backprop den = Math.pow(den, this.beta); A.set(x,y,i,ai/den); } } } this.out_act = A; return this.out_act; // dummy identity function for now },*/ virtual void forward(bool _is_training) { Vol& _V = *in_act; Vol& A = out_act; //S_cache = _V->cloneAndZero(); long n2 = n/2; long x=0,y=0,i=0,j=0; for(y=0;y<(long)_V.sy;y++) for(x=0;x<(long)_V.sx;x++) for(i=0;i<(long)_V.depth;i++) { real ai = _V.get(x,y,i); real den = 0; for(j=max(0,i-n2);j<=min(i+n2,(long)_V.depth-1);j++) { real aa = _V.get(x,y,j); den += aa*aa; } den *= alpha/n; den += k; S_cache.set(x,y,i,den); den = pow(den,beta); A.set(x,y,i,ai/den); } } /*backward: function() { // evaluate gradient wrt data var V = this.in_act; // we need to set dw of this V.dw = global.zeros(V.w.length); // zero out gradient wrt data var A = this.out_act; // computed in forward pass var n2 = Math.floor(this.n/2); for(var x=0;x<V.sx;x++) { for(var y=0;y<V.sy;y++) { for(var i=0;i<V.depth;i++) { var chain_grad = this.out_act.get_grad(x,y,i); var S = this.S_cache_.get(x,y,i); var SB = Math.pow(S, this.beta); var SB2 = SB*SB; // normalize in a window of size n for(var j=Math.max(0,i-n2);j<=Math.min(i+n2,V.depth-1);j++) { var aj = V.get(x,y,j); var g = -aj*this.beta*Math.pow(S,this.beta-1)*this.alpha/this.n*2*aj; if(j===i) g+= SB; g /= SB2; g *= chain_grad; V.add_grad(x,y,j,g); } } } } },*/ virtual void backward(bool _blearn) { Vol& V = *in_act; V.zero_dw(); Vol& A = out_act; long n2 = n/2; long x=0,y=0,i=0,j=0; for(y=0;y<(long)V.sy;y++) for(x=0;x<(long)V.sx;x++) for(i=0;i<(long)V.depth;i++) { real chain_grad = out_act.get_grad(x,y,i); real S = S_cache.get(x,y,i); real SB = pow(S,beta); real SB2 = SB*SB; for(j=max(0,i-n2);j<=min(i+n2,(long)V.depth-1);j++) { real aj = V.get(x,y,j); real g = -aj*beta*pow(S,beta-1)*alpha/n*2*aj; if(j==i) g += SB; g /= SB2; g *= chain_grad; V.add_grad(x,y,j,g); } } } };//struct LocalResponseNormalizationLayer /* var QuadTransformLayer = function(opt) { var opt = opt || {}; // computed this.out_sx = opt.in_sx; this.out_sy = opt.in_sy; // linear terms, and then quadratic terms, of which there are 1/2*n*(n+1), // (offdiagonals and the diagonal total) and arithmetic series. // Actually never mind, lets not be fancy here yet and just include // terms x_ix_j and x_jx_i twice. Half as efficient but much less // headache. this.out_depth = opt.in_depth + opt.in_depth * opt.in_depth; this.layer_type = 'quadtransform'; } */ struct QuadTransformLayer : public Layer { static void init(LayerOpts& _opt) { } QuadTransformLayer(const LayerOpts& _opt) :Layer(_opt) { initialize(_opt); } virtual void initialize(const LayerOpts& _opt) { out_sx = _opt.in_sx; out_sy = _opt.in_sy; out_depth = _opt.in_depth + _opt.in_depth*_opt.in_depth; layer_type = layertype_quadtransform; out_act.alloc(out_sx,out_sy,out_depth,false,(real)0.0); } virtual Layer* clone() const { return trace_alloc(new QuadTransformLayer(*this)); } QuadTransformLayer(const QuadTransformLayer& _qtl) :Layer(_qtl) { out_act.alloc_copy(_qtl.out_act); } /*QuadTransformLayer.prototype = { forward: function(V, is_training) { this.in_act = V; var N = this.out_depth; var Ni = V.depth; var V2 = new Vol(this.out_sx, this.out_sy, this.out_depth, 0.0); for(var x=0;x<V.sx;x++) { for(var y=0;y<V.sy;y++) { for(var i=0;i<N;i++) { if(i<Ni) { V2.set(x,y,i,V.get(x,y,i)); // copy these over (linear terms) } else { var i0 = Math.floor((i-Ni)/Ni); var i1 = (i-Ni) - i0*Ni; V2.set(x,y,i,V.get(x,y,i0) * V.get(x,y,i1)); // quadratic } } } } this.out_act = V2; return this.out_act; // dummy identity function for now },*/ virtual void forward(bool _is_training) { Vol& V = *in_act; size_t N = out_depth; size_t Ni = V.depth; Vol& V2 = out_act; size_t x=0,y=0,i=0; for(y=0;y<V.sy;y++) { for(x=0;x<V.sx;x++) { for(i=0;i<N;i++) { if(i<Ni) { V2.set(x,y,i,V.get(x,y,i)); } else { size_t i0 = (i - Ni)/Ni; size_t i1 = (i - Ni)%Ni; V2.set(x,y,i,V.get(x,y,i0)*V.get(x,y,i1)); } } } } } /*backward: function() { var V = this.in_act; V.dw = global.zeros(V.w.length); // zero out gradient wrt data var V2 = this.out_act; var N = this.out_depth; var Ni = V.depth; for(var x=0;x<V.sx;x++) { for(var y=0;y<V.sy;y++) { for(var i=0;i<N;i++) { var chain_grad = V2.get_grad(x,y,i); if(i<Ni) { V.add_grad(x,y,i,chain_grad); } else { var i0 = Math.floor((i-Ni)/Ni); var i1 = (i-Ni) - i0*Ni; V.add_grad(x,y,i0,V.get(x,y,i1)*chain_grad); V.add_grad(x,y,i1,V.get(x,y,i0)*chain_grad); } } } } },*/ virtual void backward(bool _blearn) { Vol& V = *in_act; V.zero_dw(); Vol& V2 = out_act; size_t N = out_depth; size_t Ni = V.depth; size_t x=0,y=0,i=0; for(y=0;y<V.sy;y++) { for(x=0;x<V.sx;x++) { for(i=0;i<N;i++) { real chain_grad = V2.get_grad(x,y,i); if(i<Ni) { V.add_grad(x,y,i,chain_grad); } else { size_t i0 = (i-Ni)/Ni; size_t i1 = (i-Ni)%Ni; V.add_grad(x,y,i0,V.get(x,y,i1)*chain_grad); V.add_grad(x,y,i1,V.get(x,y,i0)*chain_grad); } } } } } };//struct QuadTransformLayer typedef std::list<LayerOpts> LayerOptsLst; struct NetBase { virtual Vol& get_input() = 0; virtual Vol& get_target() = 0; virtual Vol& get_result() = 0; virtual void forward(bool _is_training = false)= 0; virtual real test() = 0; virtual real backward() = 0; virtual void getParamsAndGrads(ParamsAndGradsVec& _response) const = 0; }; struct LayerFactory { Layer* create(LayerOpts& _opt) { if(NOT_NULL(_opt.original)) return get_original(_opt); return create_new_object(_opt); } protected: Layer* get_original(LayerOpts& _opt) { VERIFY_EXIT1(NOT_NULL(_opt.original),NULL); _opt.original->initialize(_opt); return _opt.original; } Layer* create_clonable(LayerOpts& _opt) { VERIFY_EXIT1(NOT_NULL(_opt.original),NULL); Layer* new_layer = _opt.original->clone(); new_layer->initialize(_opt); return new_layer; } Layer* create_new_object(LayerOpts& _opt) { switch(_opt.type) { case layertype_input: return trace_alloc(new InputLayer(_opt)); case layertype_fc: return trace_alloc(new FullyConnLayer(_opt)); case layertype_relu: return trace_alloc(new ReluLayer(_opt)); case layertype_sigmoid: return trace_alloc(new SigmoidLayer(_opt)); case layertype_regression: return trace_alloc(new RegressionLayer(_opt)); case layertype_conv: return trace_alloc(new ConvLayer(_opt)); case layertype_pool: return trace_alloc(new PoolLayer(_opt)); case layertype_softmax: return trace_alloc(new SoftmaxLayer(_opt)); case layertype_maxout: return trace_alloc(new MaxoutLayer(_opt)); case layertype_dropout: return trace_alloc(new DropoutLayer(_opt)); case layertype_lrn: return trace_alloc(new LocalResponseNormalizationLayer(_opt)); case layertype_quadtransform: return trace_alloc(new QuadTransformLayer(_opt)); case layertype_tanh: return trace_alloc(new TanhLayer(_opt)); case layertype_hidden_input: return trace_alloc(new HiddenInput(_opt)); case layertype_hidden_regression: return trace_alloc(new HiddenRegression(_opt)); } VERIFY_EXIT1(FALSE,NULL); return NULL; } };//struct LayerFactory struct Net : public NetBase { protected: struct LayerInitilizer { Vol* input_vol; LayerInitilizer() :input_vol(NULL) { } void operator()(Layer* _layer) { if(_layer->layer_type==layertype_input) { input_vol = &(_layer->out_act); } else { VERIFY_EXIT(NOT_NULL(input_vol)); _layer->set_input(input_vol); } } };//struct LayerInitilizer public: ptrvector<Layer> m_layers; Vol m_target; protected: LayerFactory m_factory; public: Net() { } ~Net() { free(); } void free() { m_layers.clear(); } Net(const Net& _net) { if(!_net.m_layers.empty()) { LayerInitilizer layer_initializer; m_layers.resize(_net.m_layers.size()); size_t i=0; for(i=0;i<m_layers.size();i++) { m_layers[i] = _net.m_layers[i]->clone(); layer_initializer(m_layers[i]); } } } virtual Vol& get_input() { VERIFY_EXIT1(!m_layers.empty(),Fish<Vol>::get()); return m_layers[0]->get_input(); } virtual Vol& get_target() { return m_target; } bool any_input_nan() const { const Vol& input = const_cast<Net&>(*this).get_input(); size_t i = 0; for(i=0;i<input.w.size();i++) { if(!(input.w[i]==input.w[i])) // test for nan, (input.w[i]==input.w[i]) == false if input.w[i] is nan return true; } return false; } bool any_target_nan() const { const Vol& input = const_cast<Net&>(*this).get_target(); size_t i = 0; for(i=0;i<input.w.size();i++) { if(!(input.w[i]==input.w[i])) // test for nan, (input.w[i]==input.w[i]) == false if input.w[i] is nan return true; } return false; } virtual Vol& get_result() { VERIFY_EXIT1(!m_layers.empty(),Fish<Vol>::get()); return m_layers[m_layers.size()-1]->get_result(); } LayerOptsLst desugar(const LayerOptsLst& _defs) { LayerOptsLst new_defs; LayerOptsLst::const_iterator it = _defs.begin() ,ite = _defs.end() ; for(;it!=ite;++it) { LayerOpts def = *it; if(def.type==layertype_softmax) { LayerOpts opt; opt.type = layertype_fc; opt.num_neurons = def.num_classes; new_defs.push_back(opt); } if(def.type==layertype_regression) { LayerOpts opt; opt.type = layertype_fc; opt.num_neurons = def.num_neurons; new_defs.push_back(opt); } if(def.type==layertype_fc && !def.b_bias_pref) { def.b_bias_pref = true; def.bias_pref = 0; if(def.activation==layertype_relu) { def.bias_pref = (real)0.1; } } if(def.tensor) { LayerOpts opt; opt.type = layertype_quadtransform; new_defs.push_back(opt); } new_defs.push_back(def); if(def.activation==layertype_relu) { LayerOpts opt; opt.type = layertype_relu; new_defs.push_back(opt); } else if(def.activation==layertype_sigmoid) { LayerOpts opt; opt.type = layertype_sigmoid; new_defs.push_back(opt); } else if(def.activation==layertype_tanh) { LayerOpts opt; opt.type = layertype_tanh; new_defs.push_back(opt); } else if(def.activation==layertype_maxout) { LayerOpts opt; opt.type = layertype_maxout; opt.group_size = def.group_size; new_defs.push_back(opt); } else if(def.b_drop_prob && def.type!=layertype_dropout) { LayerOpts opt; opt.type = layertype_dropout; opt.drop_prob = def.drop_prob; opt.start_drop = def.start_drop; opt.stop_drop = def.stop_drop; new_defs.push_back(opt); } } return new_defs; } void makeLayers(const LayerOptsLst& _defs) { m_layers.clear(); LayerOptsLst defs = desugar(_defs); LayerOpts prev; LayerOptsLst::iterator it = defs.begin() ,ite = defs.end() ; bool bfirst = true; LayerInitilizer layer_initializer; for(;it!=ite;++it) { LayerOpts& def = *it; if(!bfirst) { def.in_sx = m_layers[m_layers.size()-1]->out_sx; def.in_sy = m_layers[m_layers.size()-1]->out_sy; def.in_depth = m_layers[m_layers.size()-1]->out_depth; } m_layers.push_back(m_factory.create(def)); layer_initializer(m_layers.back()); if(!bfirst) { m_layers[m_layers.size()-1]->in_act = &(m_layers[m_layers.size()-2]->out_act); } bfirst = false; } if(!m_layers.empty()) { m_layers[m_layers.size()-1]->start_learning = true; m_target.alloc( m_layers[m_layers.size()-1]->out_sx ,m_layers[m_layers.size()-1]->out_sy ,m_layers[m_layers.size()-1]->out_depth ,false ); } } void forward(bool _is_training = false) { VERIFY_EXIT(!any_input_nan()); size_t i=0; for(i=0;i<m_layers.size();i++) { m_layers[i]->forward(_is_training); } } real test() { VERIFY_EXIT1(!any_input_nan(),(real)0); VERIFY_EXIT1(!any_target_nan(),(real)0); long N = (long)m_layers.size(); real loss = m_layers[N-1]->backward(m_target,false); return loss; } real backward() { VERIFY_EXIT1(!any_input_nan(),(real)0); VERIFY_EXIT1(!any_target_nan(),(real)0); long N = (long)m_layers.size(); bool blearn = m_layers[N-1]->start_learning; blearn &= !m_layers[N-1]->stop_learning; real loss = m_layers[N-1]->backward(m_target,blearn); long i=0; for(i=N-2;i>=0;i--) { blearn |= m_layers[i]->start_learning; blearn &= !m_layers[i]->stop_learning; m_layers[i]->backward(blearn); } return loss; } void getParamsAndGrads(ParamsAndGradsVec& _response) const { _response.clear(); size_t i=0; for(i=0;i<m_layers.size();i++) { ParamsAndGradsVec layer_response; m_layers[i]->getParamsAndGrads(layer_response); _response.insert(_response.end(),layer_response.begin(),layer_response.end()); } } void clean_train() { ParamsAndGradsVec pglist; pglist.reserve(m_layers.size()*2); getParamsAndGrads(pglist); size_t i=0; for(i=0;i<pglist.size();i++) { ParamsAndGrads& pg = pglist[i]; Vol::WT& p = *pg.params; // w Vol::WT& g = *pg.grads; // dw std::fill(g.begin(),g.end(),(real)0.0); } } void copy_from(const Net& _net) { ParamsAndGradsVec layer_response_dest; getParamsAndGrads(layer_response_dest); ParamsAndGradsVec layer_response_src; _net.getParamsAndGrads(layer_response_src); VERIFY_EXIT(layer_response_dest.size()==layer_response_src.size()); ParamsAndGradsVec::const_iterator pit_dest = layer_response_dest.begin() ,pite_dest = layer_response_dest.end() ; ParamsAndGradsVec::const_iterator pit_src = layer_response_src.begin() ,pite_src = layer_response_src.end() ; for(;pit_dest!=pite_dest && pit_src!=pite_src;++pit_dest,++pit_src) { const ParamsAndGrads& pdest = *pit_dest; const ParamsAndGrads& psrc = *pit_src; VERIFY_DO(NOT_NULL(pdest.params),continue); VERIFY_DO(pdest.params->size()==psrc.params->size(),continue); std::copy(psrc.params->begin(),psrc.params->end(),pdest.params->begin()); } } template<typename _Stream> void save(_Stream& _out) const { size_t i=0; for(i=0;i<m_layers.size();i++) { ParamsAndGradsVec layer_response; m_layers[i]->getParamsAndGrads(layer_response); ParamsAndGradsVec::const_iterator pit = layer_response.begin() ,pite = layer_response.end() ; for(;pit!=pite;++pit) { const ParamsAndGrads& p = *pit; VERIFY_DO(NOT_NULL(p.params),continue); size_t i=0; for(i=0;i<p.params->size();i++) { CString s; s.Format(_T("%1.18g\t"),(*p.params)[i]); _out << (LPCTSTR)s; } _out << _T("\n"); } } } void binary_save(const CString& _file_name) const { BinFile<real> output; output.open_to_write(_file_name); ParamsAndGradsVec layer_response; getParamsAndGrads(layer_response); ParamsAndGradsVec::const_iterator pit = layer_response.begin() ,pite = layer_response.end() ; for(;pit!=pite;++pit) { const ParamsAndGrads& p = *pit; VERIFY_DO(NOT_NULL(p.params),continue); output.put(p.params->begin(),p.params->end()); } } template<typename _Stream> void load(_Stream& _in) { size_t i=0; for(i=0;i<m_layers.size();i++) { ParamsAndGradsVec layer_response; m_layers[i]->getParamsAndGrads(layer_response); ParamsAndGradsVec::const_iterator pit = layer_response.begin() ,pite = layer_response.end() ; for(;pit!=pite;++pit) { const ParamsAndGrads& p = *pit; VERIFY_DO(NOT_NULL(p.params),continue); size_t j=0; for(j=0;j<p.params->size();j++) { _in >> (*p.params)[j]; //_in >> _T("\t"); } //_in >> _T("\n"); VERIFY_DO(NOT_NULL(p.grads),continue); for(j=0;j<p.grads->size();j++) { (*p.grads)[j] = 0; } } } } void binary_load(const CString& _file_name) { BinFile<real> input; input.open_to_read(_file_name); ParamsAndGradsVec layer_response; getParamsAndGrads(layer_response); ParamsAndGradsVec::const_iterator pit = layer_response.begin() ,pite = layer_response.end() ; for(;pit!=pite;++pit) { const ParamsAndGrads& p = *pit; VERIFY_DO(NOT_NULL(p.params),continue); size_t cnt = input.get(p.params->begin(),p.params->end()); VERIFY_DO(NOT_NULL(p.grads),continue); size_t i = 0; for(i=0;i<p.grads->size();i++) { (*p.grads)[i] = 0; } } } void save_file(const CString& _file_name) { std::tofstream out; out.open(_file_name); save(out); } void load_file(const CString& _file_name) { if(!FileUtils::IsFileExist(_file_name)) return; std::tifstream inp; inp.open(_file_name); load(inp); } }; struct TrainerOptions { real learning_rate; real l1_decay; real l2_decay; size_t batch_size; real momentum; TrainerOptions() :learning_rate((real)0.01) ,l1_decay(0) ,l2_decay(0) ,batch_size(1) ,momentum((real)0.9) { } }; struct SGDTrainer : public TrainerOptions { Net& net; size_t k; std::vector<Vol::WT> last_pg; SGDTrainer(Net& _net,const TrainerOptions& _options = TrainerOptions()) :TrainerOptions(_options) ,net(_net) ,k(0) { } void set_options(const TrainerOptions& _options) { static_cast<TrainerOptions&>(*this) = _options; } Vol& get_input() {return net.get_input();} Vol& get_target() {return net.get_target();} void test_loss(real& _cost_loss) { net.forward(true); _cost_loss = net.test(); } void train( DWORD& _fwd_time,DWORD& _bwd_time ,real& _l2_decay_loss ,real& _l1_decay_loss ,real& _cost_loss ,real& _loss //,real _k = 1.0 ) { DWORD start = GetTickCount(); net.forward(true); DWORD end = GetTickCount(); _fwd_time = end-start; start = GetTickCount(); _cost_loss = net.backward(); _l2_decay_loss = 0.0; _l1_decay_loss = 0.0; end = GetTickCount(); _bwd_time = end-start; batch(_l2_decay_loss,_l1_decay_loss,_cost_loss,_loss); } void batch( real& _l2_decay_loss ,real& _l1_decay_loss ,real& _cost_loss ,real& _loss ) { if(k && k%batch_size==0) { ParamsAndGradsVec pglist; pglist.reserve(net.m_layers.size()*2); net.getParamsAndGrads(pglist); if(last_pg.size()==0 && momentum>0) { size_t i=0; for(i=0;i<pglist.size();i++) { last_pg.push_back(Vol::WT()); last_pg.back().resize(pglist[i].params->size()); } } size_t i=0; for(i=0;i<pglist.size();i++) { ParamsAndGrads& pg = pglist[i]; Vol::WT& p = *pg.params; // w Vol::WT& g = *pg.grads; // dw real l2_decay_mul = pg.l2_decay_mul; real l1_decay_mul = pg.l1_decay_mul; real l2_decay1 = l2_decay*l2_decay_mul; real l1_decay1 = l1_decay*l1_decay_mul; size_t plen = p.size(); size_t j=0; for(j=0;j<plen;j++) { _l2_decay_loss += l2_decay1*p[j]*p[j]/2; _l1_decay_loss += l1_decay1*fabs(p[j]); real l1grad = l1_decay1 * (p[j]>0?1:-1); real l2grad = l2_decay1 * p[j]; if(momentum>0) { real dir = -learning_rate*(l2grad + l1grad + g[j]) / batch_size; real dir_adj = momentum * last_pg[i][j] + ((real)1.0 - momentum)*dir; p[j] += dir_adj; last_pg[i][j] = dir_adj; } else { p[j] -= learning_rate * (l2grad + l1grad + g[j]) / batch_size; } g[j] = 0; } } } k++; _loss = _l2_decay_loss + _l1_decay_loss + _cost_loss; } }; inline void init_layer_options(LayerTypeEn _layer_type,LayerOpts& _def) { switch(_layer_type) { case layertype_input: InputLayer::init(_def); break; case layertype_fc: FullyConnLayer::init(_def); break; case layertype_relu: ReluLayer::init(_def); break; case layertype_sigmoid: SigmoidLayer::init(_def); break; case layertype_regression: RegressionLayer::init(_def); break; case layertype_conv: ConvLayer::init(_def); break; case layertype_pool: PoolLayer::init(_def); break; case layertype_softmax: SoftmaxLayer::init(_def); break; case layertype_maxout: MaxoutLayer::init(_def); break; case layertype_dropout: DropoutLayer::init(_def); break; case layertype_lrn: LocalResponseNormalizationLayer::init(_def); break; case layertype_quadtransform: QuadTransformLayer::init(_def); break; case layertype_tanh: TanhLayer::init(_def); break; default: VERIFY_EXIT(false); // layer not initialized } } namespace common { inline void convert(LayerTypeEn _layer_type,CString& _str) { switch(_layer_type) { case layertype_null: _str = _T("layertype_null"); break; case layertype_input: _str = _T("layertype_input"); break; case layertype_fc: _str = _T("layertype_fc"); break; case layertype_relu: _str = _T("layertype_relu"); break; case layertype_sigmoid: _str = _T("layertype_sigmoid"); break; case layertype_regression: _str = _T("layertype_regression"); break; case layertype_conv: _str = _T("layertype_conv"); break; case layertype_pool: _str = _T("layertype_pool"); break; case layertype_softmax: _str = _T("layertype_softmax"); break; case layertype_maxout: _str = _T("layertype_maxout"); break; case layertype_dropout: _str = _T("layertype_dropout"); break; case layertype_lrn: _str = _T("layertype_lrn"); break; case layertype_quadtransform: _str = _T("layertype_quadtransform"); break; case layertype_tanh: _str = _T("layertype_tanh"); break; case layertype_hidden_input: _str = _T("layertype_hidden_input"); break; case layertype_hidden_regression: _str = _T("layertype_hidden_regression"); break; case layertype_functional: _str = _T("layertype_functional"); break; default: _str = Format(_T("Unknown type (%d)"),(long)_layer_type); break; }; } } #endif//#if !defined(__DLNET_H__259ADFCB_316B_4832_B14E_2928FCCBC10B__)
22.083483
139
0.625921
[ "vector" ]
ef3a3eac12ffa4a6e284bedca6085545cc19dfde
30,597
h
C
xun/xnu-6153.81.5/bsd/net/multi_layer_pkt_log.h
L-Zheng/AppleOpenSource
65fac74ce17dc97404f1aeb8c24625fe82b7d142
[ "MIT" ]
null
null
null
xun/xnu-6153.81.5/bsd/net/multi_layer_pkt_log.h
L-Zheng/AppleOpenSource
65fac74ce17dc97404f1aeb8c24625fe82b7d142
[ "MIT" ]
null
null
null
xun/xnu-6153.81.5/bsd/net/multi_layer_pkt_log.h
L-Zheng/AppleOpenSource
65fac74ce17dc97404f1aeb8c24625fe82b7d142
[ "MIT" ]
null
null
null
/* * Copyright (c) 2019 Apple Inc. All rights reserved. * * @APPLE_OSREFERENCE_LICENSE_HEADER_START@ * * This file contains Original Code and/or Modifications of Original Code * as defined in and that are subject to the Apple Public Source License * Version 2.0 (the 'License'). You may not use this file except in * compliance with the License. The rights granted to you under the License * may not be used to create, or enable the creation or redistribution of, * unlawful or unlicensed copies of an Apple operating system, or to * circumvent, violate, or enable the circumvention or violation of, any * terms of an Apple operating system software license agreement. * * Please obtain a copy of the License at * http://www.opensource.apple.com/apsl/ and read it before using this file. * * The Original Code and all software distributed under the License are * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. * Please see the License for the specific language governing rights and * limitations under the License. * * @APPLE_OSREFERENCE_LICENSE_HEADER_END@ */ #ifndef _NET_MULTI_LAYER_PKT_LOG_H_ #define _NET_MULTI_LAYER_PKT_LOG_H_ #include <os/log.h> /* * Bump this version whenever the format of a log is modified */ #define MPKL_VERSION 1 /* * Protocol ID, use to track inter-layer transitions and direction of data flow. * Watch transport physical layer has lowest numeric value, increases to the highest layer in the system. * Direction is to physical layer, or away from physical layer. * */ #define MPKL_PROTOCOL_PHYSICAL ((uint8_t)0) /* (OTA/serial-port/etc..) */ #define MPKL_PROTOCOL_BT ((uint8_t)20) #define MPKL_PROTOCOL_WIFI ((uint8_t)30) #define MPKL_PROTOCOL_CELLULAR ((uint8_t)40) #define MPKL_PROTOCOL_TERMINUS ((uint8_t)60) #define MPKL_PROTOCOL_IPSEC ((uint8_t)80) #define MPKL_PROTOCOL_TCP ((uint8_t)100) #define MPKL_PROTOCOL_IDS ((uint8_t)120) #define MPKL_PROTOCOL_LIBNETCORE ((uint8_t)140) #define MPKL_PROTOCOL_CFNETWORK ((uint8_t)160) #define MPKL_PROTOCOL_REMOTE_CONNECTION ((uint8_t)200) #define MPKL_TOPMOST_LAYER ((uint8_t)255) /* Top-most layer */ /*! * @macro MPKL_CREATE_LOGOBJECT * @discussion Creates a log object with input category name for the transportpacketlog subsystem * * @param Name string name of os_log_t category * * @return os_log_t object * */ #define MPKL_CREATE_LOGOBJECT(Name) os_log_create("com.apple.magnetpacketlog", Name) /* * Cross-layer association APIs * */ /*! * @macro MPKL_UUID_UUID_ASSOCIATE_PREV * @discussion Associate current layer's packet UUID to previous layer's packet UUID, data is flowing into the current layer * * @param LOGOBJECT os_log_t object to write data into * @param CUR_PROTOCOL_ID uint8_t ID of current layer from MPKL_PROTOCOL_XXX defines above * @param PREV_PROTOCOL_ID uint8_t ID of previous layer being associated * @param CUR_UUID uuid_t Current layer 16-byte UUID of packet * @param PREV_UUID uuid_t Previous layer 16-byte UUID of packet * @param CUR_LEN uint16_t Current layer packet length * @param LOG_SEQ uint8_t Incrementing sequence number to detect logging system drop of messages */ #define MPKL_UUID_UUID_ASSOCIATE_PREV(LOGOBJECT, CUR_PROTOCOL_ID, PREV_PROTOCOL_ID, CUR_UUID, PREV_UUID, CUR_LEN, LOG_SEQN) \ os_log(LOGOBJECT, "1 {curProtocol: %hhu, prevProtocol: %hhu, curUUID: %{public,uuid_t}.16P, prevUUID: %{public,uuid_t}.16P, curPktLen: %hu, logSeqn: %hhu}", CUR_PROTOCOL_ID, PREV_PROTOCOL_ID, CUR_UUID, PREV_UUID, CUR_LEN, LOG_SEQN) /*! * @macro MPKL_UUID_UUID_ASSOCIATE_NEXT * @discussion Associate current layer's packet UUID to next layer's packet UUID, data is flowing out of the current layer * * @param LOGOBJECT os_log_t object to write data into * @param LABEL string optional layer-specific label for readability/debugability, this is ignored by the parser. Can not contain {} * @param CUR_PROTOCOL_ID uint8_t ID of current layer from MPKL_PROTOCOL_XXX defines above * @param NEXT_PROTOCOL_ID uint8_t ID of next layer being associated * @param CUR_UUID uuid_t Current layer 16-byte UUID of packet * @param NEXT_UUID uuid_t Next layer 16-byte UUID of packet * @param CUR_LEN uint16_t Current layer packet length * @param LOG_SEQ uint8_t Incrementing sequence number to detect logging system drop of messages */ #define MPKL_UUID_UUID_ASSOCIATE_NEXT(LOGOBJECT, CUR_PROTOCOL_ID, NEXT_PROTOCOL_ID, CUR_UUID, NEXT_UUID, CUR_LEN, LOG_SEQN) \ os_log(LOGOBJECT, "2 {curProtocol: %hhu, nextProtocol: %hhu, curUUID: %{public,uuid_t}.16P, nextUUID: %{public,uuid_t}.16P, curPktLen: %hu, logSeqn: %hhu}", CUR_PROTOCOL_ID, NEXT_PROTOCOL_ID, CUR_UUID, NEXT_UUID, CUR_LEN, LOG_SEQN) /*! * @macro MPKL_SEQRANGE_UUID_ASSOCIATE * @discussion Associate previous layer's byte sequence range (start/end) to current layer's packet UUID * * @param LOGOBJECT os_log_t object to write data into * @param LABEL string optional layer-specific label for readability/debugability, this is ignored by the parser. Can not contain {} * @param CUR_PROTOCOL_ID uint8_t ID of current layer from MPKL_PROTOCOL_XXX defines above * @param PREV_PROTOCOL_ID uint8_t ID of other layer being associated * @param PREV_RANGE_START uint32_t Previous layer byte sequence range start * @param PREV_RANGE_END uint32_t Previous layer byte sequence range end * @param CUR_UUID uuid_t Other layer 16-byte UUID of packet * @param CUR_LEN uint16_t Current layer packet length * @param LOG_SEQN uint8_t Incrementing sequence number to detect logging system drop of messages */ #define MPKL_SEQRANGE_UUID_ASSOCIATE(LOGOBJECT, CUR_PROTOCOL_ID, PREV_PROTOCOL_ID, PREV_RANGE_START, PREV_RANGE_END, CUR_UUID, CUR_LEN, LOG_SEQN) \ os_log(LOGOBJECT, "3 {curProtocol: %hhu, prevProtocol: %hhu, prevStart: %u, prevEnd: %u, curUUID: %{public,uuid_t}.16P, curPktLen: %hu, logSeqn: %hhu}", CUR_PROTOCOL_ID, PREV_PROTOCOL_ID, PREV_RANGE_START, PREV_RANGE_END, CUR_UUID, CUR_LEN, LOG_SEQN) /*! * @macro MPKL_UUID_SEQRANGE_ASSOCIATE * @discussion Associate previous layer's packet UUID to current layer's byte sequence range (start/end) * * @param LOGOBJECT os_log_t object to write data into * @param LABEL string optional layer-specific label for readability/debugability, this is ignored by the parser. Can not contain {} * @param CUR_PROTOCOL_ID uint8_t ID of current layer from MPKL_PROTOCOL_XXX defines above * @param PREV_PROTOCOL_ID uint8_t ID of other layer being associated * @param PREV_UUID uuid_t Previous layer 16-byte UUID of packet * @param CUR_RANGE_START uint16_t Current layer byte sequence range start * @param CUR_RANGE_END uint16_t Current layer byte sequence range end * @param PREV_LEN uint16_t PRevious layer message length * @param LOG_SEQN uint8_t Incrementing sequence number to detect logging system drop of messages */ #define MPKL_UUID_SEQRANGE_ASSOCIATE(LOGOBJECT, CUR_PROTOCOL_ID, PREV_PROTOCOL_ID, PREV_UUID, CUR_RANGE_START, CUR_RANGE_END, PREV_LEN, LOG_SEQN) \ os_log(LOGOBJECT, "4 {curProtocol: %hhu, prevProtocol: %hhu, prevUUID: %{public,uuid_t}.16P, curStart: %u, curEnd: %u, prevPktLen: %hu, logSeqn: %hhu}", CUR_PROTOCOL_ID, PREV_PROTOCOL_ID, PREV_UUID, CUR_RANGE_START, CUR_RANGE_END, PREV_LEN, LOG_SEQN) /*! * @macro MPKL_BUNDLEID_UUID_ASSOCIATE * @discussion Associate previous layer's packet BUNDLEID to current layer's UUID * * @param LOGOBJECT os_log_t object to write data into * @param LABEL string optional layer-specific label for readability/debugability, this is ignored by the parser. Can not contain {} * @param CUR_PROTOCOL_ID uint8_t ID of current layer from MPKL_PROTOCOL_XXX defines above * @param PREV_PROTOCOL_ID uint8_t ID of other layer being associated * @param PREV_BUNDLE_ID NSString BundleID of previous layer * @param CUR_UUID uuid_t Current layer 16-byte UUID of packet * @param CUR_LEN uint32_t Current layer packet length * @param LOG_SEQ uint8_t Incrementing sequence number to detect logging system drop of messages */ #define MPKL_BUNDLEID_UUID_ASSOCIATE(LOGOBJECT, CUR_PROTOCOL_ID, PREV_PROTOCOL_ID, PREV_BUNDLE_ID, CUR_UUID, CUR_LEN, LOG_SEQN) \ os_log(LOGOBJECT, "5 {curProtocol: %hhu, prevProtocol: %hhu, prevBundleID: %@, curUUID: %{public,uuid_t}.16P, curPktLen: %u, logSeqn: %hhu}", CUR_PROTOCOL_ID, PREV_PROTOCOL_ID, PREV_BUNDLE_ID, CUR_UUID, CUR_LEN, LOG_SEQN) /*! * @macro MPKL_SEQRANGE_UUID_ASSOCIATE_W_BUNDLEID * @discussion Associate previous layer's packet byte sequence range to to current layer's UUID and client's bundle id * * @param LOGOBJECT os_log_t object to write data into * @param LABEL string optional layer-specific label for readability/debugability, this is ignored by the parser. Can not contain {} * @param CUR_PROTOCOL_ID uint8_t ID of current layer from MPKL_PROTOCOL_XXX defines above * @param PREV_PROTOCOL_ID uint8_t ID of other layer being associated * @param PREV_RANGE_START uint32_t Previous layer byte sequence range start * @param PREV_RANGE_END uint32_t Previous layer byte sequence range end * @param CUR_UUID uuid_t Current layer 16-byte UUID of packet * @param PREV_BUNDLE_ID NSString BundleID of previous layer * @param CUR_LEN uint16_t Current layer packet length * @param LOG_SEQ uint8_t Incrementing sequence number to detect logging system drop of messages */ #define MPKL_SEQRANGE_UUID_ASSOCIATE_W_BUNDLEID(LOGOBJECT, CUR_PROTOCOL_ID, PREV_PROTOCOL_ID, PREV_RANGE_START, PREV_RANGE_END, CUR_UUID, CLIENT_BUNDLE_ID, CUR_LEN, LOG_SEQN) \ os_log(LOGOBJECT, "6 {curProtocol: %hhu, prevProtocol: %hhu, prevStart: %u, prevEnd: %u, curUUID: %{public,uuid_t}.16P, curBundleID: %@, curPktLen: %hu, logSeqn: %hhu}", CUR_PROTOCOL_ID, PREV_PROTOCOL_ID, PREV_RANGE_START, PREV_RANGE_END, CUR_UUID, CLIENT_BUNDLE_ID, CUR_LEN, LOG_SEQN) /*! * @macro MPKL_SEQN_UUID_ASSOCIATE_PREV * @discussion Associate current layer's packet unique protocol sequenceNumber to another layer's message UUID * Support fragmentation and re-assembly (for layers like BT), map byte-sequence range (2 byte) of current and other layer data * * @param LOGOBJECT os_log_t object to write data into * @param LABEL string optional layer-specific label for readability/debugability, this is ignored by the parser. Can not contain {} * @param CUR_PROTOCOL_ID uint8_t ID of current layer from MPKL_PROTOCOL_XXX defines above * @param PREV_PROTOCOL_ID uint8_t ID of other layer being associated * @param PREV_UUID uuid_t Other layer 16-byte UUID of message * @param PREV_RANGE_START uint16_t Current layer byte sequence range start * @param PREV_RANGE_END uint16_t Current layer byte sequence range end * @param PREV_LEN uint16_t PRevious layer message length * @param CUR_SEQ_N uint16_t Current layer message length * @param CUR_RANGE_START uint16_t Current layer byte sequence range start * @param CUR_RANGE_END uint16_t Current layer byte sequence range end * @param LOG_SEQN uint8_t Incrementing sequence number to detect logging system drop of messages */ #define MPKL_SEQN_UUID_ASSOCIATE_PREV(LOGOBJECT, CUR_PROTOCOL_ID, PREV_PROTOCOL_ID, PREV_UUID, PREV_RANGE_START, PREV_RANGE_END, PREV_LEN, CUR_SEQ_N, CUR_RANGE_START, CUR_RANGE_END, LOG_SEQN) \ os_log(LOGOBJECT, "7 {Send, curProtocol: %hhu, prevProtocol: %hhu, prevUUID: %{public,uuid_t}.16P, prevStart: %hu, prevEnd: %hu, prevPktLen %hu, curSeqN: %hu, curStart: %hu, curEnd: %hu, logSeqn: %hhu}", CUR_PROTOCOL_ID, PREV_PROTOCOL_ID, PREV_UUID, PREV_RANGE_START, PREV_RANGE_END, PREV_LEN, CUR_SEQ_N, CUR_RANGE_START, CUR_RANGE_END, LOG_SEQN) /*! * @macro MPKL_SEQN_UUID_ASSOCIATE_NEXT * @discussion Associate current layer's packet unique protocol sequenceNumber to another layer's message UUID * Support fragmentation and re-assembly (for layers like BT), map byte-sequence range (2 byte) of current and other layer data * * @param LOGOBJECT os_log_t object to write data into * @param LABEL string optional layer-specific label for readability/debugability, this is ignored by the parser. Can not contain {} * @param CUR_PROTOCOL_ID uint8_t ID of current layer from MPKL_PROTOCOL_XXX defines above * @param NEXT_PROTOCOL_ID uint8_t ID of other layer being associated * @param NEXT_UUID uuid_t Other layer 16-byte UUID of message * @param NEXT_RANGE_START uint16_t Current layer byte sequence range start * @param NEXT_RANGE_END uint16_t Current layer byte sequence range end * @param NEXT_LEN uint16_t Current layer message length * @param CUR_SEQ_N uint16_t Current layer message length * @param CUR_RANGE_START uint16_t Current layer byte sequence range start * @param CUR_RANGE_END uint16_t Current layer byte sequence range end * @param LOG_SEQN uint8_t Incrementing sequence number to detect logging system drop of messages */ #define MPKL_SEQN_UUID_ASSOCIATE_NEXT(LOGOBJECT, CUR_PROTOCOL_ID, NEXT_PROTOCOL_ID, NEXT_UUID, NEXT_RANGE_START, NEXT_RANGE_END, NEXT_LEN, CUR_SEQ_N, CUR_RANGE_START, CUR_RANGE_END, LOG_SEQN) \ os_log(LOGOBJECT, "8 {Receive, curProtocol: %hhu, nextProtocol: %hhu, nextUUID: %{public,uuid_t}.16P, nextStart: %hu, nextEnd: %hu, nextPktLen %hu, curSeqN: %hu, curStart: %hu, curEnd: %hu, logSeqn: %hhu}", CUR_PROTOCOL_ID, NEXT_PROTOCOL_ID, NEXT_UUID, NEXT_RANGE_START, NEXT_RANGE_END, NEXT_LEN, CUR_SEQ_N, CUR_RANGE_START, CUR_RANGE_END, LOG_SEQN) /* * APIs to indicate transitioning of messages; example in/out of a layer */ /*! * @macro MPKL_UUID_NEXT * @discussion Log the transition of current layer's message with UUID to next layer * * @param LOGOBJECT os_log_t object to write data into * @param LABEL string optional layer-specific label for readability/debugability, this is ignored by the parser. Can not contain {} * @param CUR_PROTOCOL_ID uint8_t ID of current layer from MPKL_PROTOCOL_XXX defines above * @param NEXT_PROTOCOL_ID uint8_t ID of next layer * @param CUR_UUID uuid_t Current layer 16-byte UUID of message * @param CUR_LEN uint32_t Current layer message length * @param LOG_SEQN uint8_t Incrementing sequence number to detect logging system drop of messages */ #define MPKL_UUID_NEXT(LOGOBJECT, CUR_PROTOCOL_ID, NEXT_PROTOCOL_ID, CUR_UUID, CUR_LEN, LOG_SEQN) \ os_log(LOGOBJECT, "9 {curProtocol: %hhu, nextProtocol: %hhu, curUUID: %{public,uuid_t}.16P, curPktLen: %u, logSeqn: %hhu}", CUR_PROTOCOL_ID, NEXT_PROTOCOL_ID, CUR_UUID, CUR_LEN, LOG_SEQN) /*! * @macro MPKL_SEQRANGE_NEXT * @discussion Log the transition of current layer's message with UUID to next layer * * @param LOGOBJECT os_log_t object to write data into * @param LABEL string optional layer-specific label for readability/debugability, this is ignored by the parser. Can not contain {} * @param CUR_PROTOCOL_ID uint8_t ID of current layer from MPKL_PROTOCOL_XXX defines above * @param NEXT_PROTOCOL_ID uint8_t ID of next layer * @param CUR_RANGE_START uint16_t Current layer byte sequence range start * @param CUR_RANGE_END uint16_t Current layer byte sequence range end * @param LOG_SEQN uint8_t Incrementing sequence number to detect logging system drop of messages */ #define MPKL_SEQRANGE_NEXT(LOGOBJECT, CUR_PROTOCOL_ID, NEXT_PROTOCOL_ID, CUR_UUID, CUR_LEN, LOG_SEQN) \ os_log(LOGOBJECT, "10 {curProtocol: %hhu, nextProtocol: %hhu, curUUID: %{public,uuid_t}.16P, curPktLen: %hu, logSeqn: %hhu}", CUR_PROTOCOL_ID, NEXT_PROTOCOL_ID, CUR_UUID, CUR_LEN, LOG_SEQN) /*! * @macro MPKL_UUID_PREV * @discussion Log the transition of previous layer's message with UUID to current layer * * @param LOGOBJECT os_log_t object to write data into * @param LABEL string optional layer-specific label for readability/debugability, this is ignored by the parser. Can not contain {} * @param CUR_PROTOCOL_ID uint8_t ID of current layer from MPKL_PROTOCOL_XXX defines above * @param PREV_PROTOCOL_ID uint8_t ID of other layer being associated * @param PREV_UUID uuid_t Previous layer 16-byte UUID of message * @param PREV_LEN uint16_t Previous layer message length * @param LOG_SEQN uint8_t Incrementing sequence number to detect logging system drop of messages */ #define MPKL_UUID_PREV(LOGOBJECT, CUR_PROTOCOL_ID, PREV_PROTOCOL_ID, PREV_UUID, PREV_LEN, LOG_SEQN) \ os_log(LOGOBJECT, "11 {curProtocol: %hhu, prevProtocol: %hhu, prevUUID: %{public,uuid_t}.16P, prevPktLen: %hu, logSeqn: %hhu}", CUR_PROTOCOL_ID, PREV_PROTOCOL_ID, PREV_UUID, PREV_LEN, LOG_SEQN) /* * APIs to indicate a Task Start/End */ /*! * @macro MPKL_TASK_START * @discussion Log the start of a task * * @param LOGOBJECT os_log_t object to write data into * @param LABEL string optional layer-specific label for readability/debugability, this is ignored by the parser. Can not contain {} * @param CLIENT_BUNDLE_ID NSString bundleID of the client * @param TASK_UUID uuid_t 16-byte UUID of NSURL task * @param CONN_UUID uuid_t 16-byte UUID of associated libnetcore connection * @param LOG_SEQN uint8_t Incrementing sequence number to detect logging system drop of messages */ #define MPKL_TASK_START(LOGOBJECT, CLIENT_BUNDLE_ID, TASK_UUID, CONN_UUID, LOG_SEQN) \ os_log(LOGOBJECT, "12 {startBundleID: %@, taskUUID: %{public,uuid_t}.16P, connUUID: %{public,uuid_t}.16P, logSeqn: %hhu}", CLIENT_BUNDLE_ID, TASK_UUID, CONN_UUID, LOG_SEQN) /*! * @macro MPKL_TASK_START * @discussion Log the end of a task * * @param LOGOBJECT os_log_t object to write data into * @param LABEL string optional layer-specific label for readability/debugability, this is ignored by the parser. Can not contain {} * @param CLIENT_BUNDLE_ID NSString bundleID of the client * @param TASK_UUID uuid_t 16-byte UUID of NSURL task * @param CONN_UUID uuid_t 16-byte UUID of associated libnetcore connection * @param LOG_SEQN uint8_t Incrementing sequence number to detect logging system drop of messages */ #define MPKL_TASK_END(LOGOBJECT, CLIENT_BUNDLE_ID, TASK_UUID, CONN_UUID, LOG_SEQN) \ os_log(LOGOBJECT, "13 {endBundleID: %@, taskUUID: %{public,uuid_t}.16P, connUUID: %{public,uuid_t}.16P, logSeqn: %hhu}", CLIENT_BUNDLE_ID, TASK_UUID, CONN_UUID, LOG_SEQN) /*! * @macro MPKL_SEQN_INCOMPLETE_PREV * @discussion An incomplete packet was sent with a given protocol sequence number and couldn't be associated to another protocol. * The incomplete packet is saved, its byte sequence range is logged and it is associated once more data arrives. * */ #define MPKL_SEQN_INCOMPLETE_PREV(LOGOBJECT, CUR_PROTOCOL_ID, PREV_PROTOCOL_ID, CUR_SEQ_N, CUR_RANGE_START, CUR_RANGE_END, PREV_RANGE_START, PREV_RANGE_END, LOG_SEQN) \ os_log(LOGOBJECT, "14 {Send Incomplete. curProtocol: %hhu, prevProtocol: %hhu, curSeqN: %hu, curStart: %hu, curEnd: %hu, prevStart: %hu, prevEnd: %hu, logSeqn: %hhu}", CUR_PROTOCOL_ID, PREV_PROTOCOL_ID, CUR_SEQ_N, CUR_RANGE_START, CUR_RANGE_END, PREV_RANGE_START, PREV_RANGE_END, LOG_SEQN) /*! * @macro MPKL_SEQN_INCOMPLETE_NEXT * @discussion An incomplete packet was sent with a given protocol sequence number and couldn't be associated to another protocol. * The incomplete packet is saved, its byte sequence range is logged and it is associated once more data arrives. * */ #define MPKL_SEQN_INCOMPLETE_NEXT(LOGOBJECT, CUR_PROTOCOL_ID, NEXT_PROTOCOL_ID, CUR_SEQ_N, CUR_RANGE_START, CUR_RANGE_END, NEXT_RANGE_START, NEXT_RANGE_END, LOG_SEQN) \ os_log(LOGOBJECT, "15 {Receive Incomplete. curProtocol: %hhu, nextProtocol: %hhu, curSeqN: %hu, curStart: %hu, curEnd: %hu, nextStart: %hu, nextEnd: %hu, logSeqn: %hhu}", CUR_PROTOCOL_ID, NEXT_PROTOCOL_ID, CUR_SEQ_N, CUR_RANGE_START, CUR_RANGE_END, NEXT_RANGE_START, NEXT_RANGE_END, LOG_SEQN) #ifdef KERNEL /*! * @macro MPKL_TCP_SEND * @discussion Associate data sent by a process with a TCP connection * * @param LOGOBJECT os_log_t object to write data into * @param PREV_PROTOCOL_ID uint8_t Protocol identifier passed by the process (may be 0) * @param PREV_UUID uuid_t UUID passed by the process (may be null UUID) * @param LOCAL_PORT uint16_t Local port of the TCP connection * @param REMOTE_PORT uint16_t Remote port of the TCP connection * @param TCP_SEQ uint32_t TCP sequence number of the first byte of the data being sent by the process * @param TCP_LEN uint32_t Length of the data * @param PID uint16_t pid of the process using the TCP connection * @param LOG_SEQN uint8_t Incrementing sequence number to detect logging system drop of messages */ #define MPKL_TCP_SEND(LOGOBJECT, PREV_PROTOCOL_ID, PREV_UUID, LOCAL_PORT, REMOTE_PORT, TCP_SEQ, TCP_LEN, PID, LOG_SEQN) \ os_log_with_type(LOGOBJECT, net_mpklog_type, \ "16 {curProtocol: 100, prevProtocol: %hhu, " \ "prevUUID: " \ "%02X%02X%02X%02X-%02X%02X-%02X%02X-%02X%02X-%02X%02X%02X%02X%02X%02X, " \ "localPort: %hu, remotePort: %hu, tcpSeq: %u, length: %u, " \ "pid: %hu, logSeqn: %hhu}", \ PREV_PROTOCOL_ID, \ PREV_UUID[0], PREV_UUID[1], PREV_UUID[2], PREV_UUID[3], PREV_UUID[4], PREV_UUID[5], PREV_UUID[6], PREV_UUID[7], \ PREV_UUID[8], PREV_UUID[9], PREV_UUID[10], PREV_UUID[11], PREV_UUID[12], PREV_UUID[13], PREV_UUID[14], PREV_UUID[15], \ LOCAL_PORT, REMOTE_PORT, TCP_SEQ, TCP_LEN, \ (uint16_t)PID, LOG_SEQN) /*! * @macro MPKL_TCP_INPUT * @discussion Associate TCP segment being with a packet received to a TCP connection * * @param LOGOBJECT os_log_t object to write data into * @param LOCAL_PORT uint16_t Local port in the TCP header of the segment * @param REMOTE_PORT uint16_t Remote port in the TCP header of the segment * @param TCP_SEQ uint32_t Sequence number in the TCP header of the segment * @param TCP_ACK uint32_t Acknowledgement number in the TCP header of the segment * @param TCP_LEN uint16_t Length in the TCP header of the segment * @param TCP_FLAGS uint8_t Flags of the TCP header of the segment * @param PID uint16_t pid of the process using the TCP connection * @param LOG_SEQN uint8_t Incrementing sequence number to detect logging system drop of messages */ #define MPKL_TCP_INPUT(LOGOBJECT, LOCAL_PORT, REMOTE_PORT, TCP_SEQ, TCP_ACK, TCP_LEN, TCP_FLAGS, PID, LOG_SEQN) \ os_log_with_type(LOGOBJECT, net_mpklog_type, \ "17 {curProtocol: 100, prevProtocol: 80, " \ "localPort: %hu, remotePort: %hu, tcpSeq: %u, tcpAck: %u, tcpLen: %hu, tcpFlags: 0x%02x, " \ "pid: %hu, logSeqn: %hhu}", \ LOCAL_PORT, REMOTE_PORT, TCP_SEQ, TCP_ACK, (uint16_t)TCP_LEN, TCP_FLAGS, \ (uint16_t)PID, LOG_SEQN) /*! * @macro MPKL_ESP_OUTPUT_TCP * @discussion Associate a packet with a TCP segment being sent to an ESP packet * * @param LOGOBJECT os_log_t object to write data into * @param SPI uint32_t SPI field in the ESP header * @param ESP_SEQ uint32_t Sequence number field in the ESP header * @param LOCAL_PORT uint16_t Local port of the TCP connection * @param REMOTE_PORT uint16_t Remote port of the TCP connection * @param TCP_SEQ uint32_t Sequence number in the TCP header of the segment * @param TCP_ACK uint32_t Acknowledgement number in the TCP header of the segment * @param TCP_LEN uint16_t Length in the TCP header of the segment * @param TCP_FLAGS uint8_t Flags of the TCP header of the segment */ #define MPKL_ESP_OUTPUT_TCP(LOGOBJECT, SPI, ESP_SEQ, LOCAL_PORT, REMOTE_PORT, TCP_SEQ, TCP_ACK, TCP_LEN, TCP_FLAGS) \ os_log_with_type(LOGOBJECT, net_mpklog_type, \ "18 {curProtocol: 80, spi: 0x%X, espSeq: %u, PayloadProtocol: 100, " \ "localPort: %hu, remotePort: %hu, tcpSeq: %u, tcpAck: %u, tcpLen: %hu, tcpFlags: 0x%02x}", \ SPI, ESP_SEQ, \ LOCAL_PORT, REMOTE_PORT, TCP_SEQ, TCP_ACK, (uint16_t)TCP_LEN, TCP_FLAGS) /*! * @macro MPKL_ESP_INPUT_TCP * @discussion Associate an ESP packet for TCP to the TCP segment * * @param LOGOBJECT os_log_t object to write data into * @param SPI uint32_t SPI field in the ESP header * @param ESP_SEQ uint32_t Sequence number field in the ESP header * @param LOCAL_PORT uint16_t Local port of the TCP connection * @param REMOTE_PORT uint16_t Remote port of the TCP connection * @param TCP_SEQ uint32_t Sequence number in the TCP header of the segment * @param TCP_LEN uint16_t Length in the TCP header of the segment */ #define MPKL_ESP_INPUT_TCP(LOGOBJECT, SPI, ESP_SEQ, LOCAL_PORT, REMOTE_PORT, TCP_SEQ, TCP_LEN) \ os_log_with_type(LOGOBJECT, net_mpklog_type, \ "19 {curProtocol: 80 spi: 0x%X, espSeq: %u, PayloadProtocol: 100, " \ "localPort: %hu, remotePort: %hu, tcpSeq: %u, tcpLen: %hu}", \ SPI, ESP_SEQ, \ LOCAL_PORT, REMOTE_PORT, TCP_SEQ, (uint16_t)TCP_LEN) #endif /* KERNEL */ /*! * @macro MPKL_BYTERANGE_UUID_ASSOCIATE * @discussion Associate current layer's byte range (start/end) to current layer's UUID * * @param LOGOBJECT os_log_t object to write data into * @param CUR_PROTOCOL_ID uint8_t ID of current layer from MPKL_PROTOCOL_XXX defines above * @param NEXT_PROTOCOL_ID uint8_t ID of other layer being associated * @param CUR_UUID uuid_t Current layer 16-byte UUID of endpoint handler * @param CUR_RANGE_START uint64_t Current layer byte range start * @param CUR_RANGE_END uint64_t Current layer byte range end * @param LOG_SEQN uint8_t Incrementing sequence number to detect logging system drop of messages */ #define MPKL_BYTERANGE_UUID_ASSOCIATE(LOGOBJECT, CUR_PROTOCOL_ID, NEXT_PROTOCOL_ID, CUR_UUID, CUR_RANGE_START, CUR_RANGE_END, LOG_SEQN) \ os_log(LOGOBJECT, "32 {curProtocol: %hhu, nextProtocol: %hhu, curUUID: %{public}.16P, curStart: %llu, curEnd: %llu, logSeqn: %hhu}", CUR_PROTOCOL_ID, NEXT_PROTOCOL_ID, CUR_UUID, CUR_RANGE_START, CUR_RANGE_END, LOG_SEQN) /*! * @macro MPKL_UUID_ONLY_ASSOCIATE_NEXT * @discussion Associate current layer's UUID to next layer's UUID * * @param LOGOBJECT os_log_t object to write data into * @param LABEL string optional layer-specific label for readability/debugability, this is ignored by the parser. Can not contain {} * @param CUR_PROTOCOL_ID uint8_t ID of current layer from MPKL_PROTOCOL_XXX defines above * @param NEXT_PROTOCOL_ID uint8_t ID of next layer being associated * @param CUR_UUID uuid_t Current layer 16-byte UUID * @param NEXT_UUID uuid_t Next layer 16-byte UUID * @param LOG_SEQ uint8_t Incrementing sequence number to detect logging system drop of messages */ #define MPKL_UUID_ONLY_ASSOCIATE_NEXT(LOGOBJECT, CUR_PROTOCOL_ID, NEXT_PROTOCOL_ID, CUR_UUID, NEXT_UUID, LOG_SEQN) \ os_log(LOGOBJECT, "33 {curProtocol: %hhu, nextProtocol: %hhu, curUUID: %{public}.16P, nextUUID: %{public}.16P, logSeqn: %hhu}", CUR_PROTOCOL_ID, NEXT_PROTOCOL_ID, CUR_UUID, NEXT_UUID, LOG_SEQN) #ifdef KERNEL_PRIVATE extern int net_mpklog_enabled; extern int net_mpklog_type; #endif /* KERNEL_PRIVATE */ #endif /* _NET_MULTI_LAYER_PKT_LOG_H_ */
65.94181
349
0.679707
[ "object" ]
ef3cfd751a2c92f7d9e2a3f850fd3ef7d61a4367
863
h
C
MultiThreadDownload/BrandDownload/Others/DownLoadMission.h
DongDongDongDong/MultiThreadDownload
a2f870d1f53df11d29d4fc4e01101497d6300381
[ "MIT" ]
2
2017-04-07T13:35:15.000Z
2017-10-26T11:38:40.000Z
MultiThreadDownload/BrandDownload/Others/DownLoadMission.h
DongDongDongDong/MultiThreadDownload
a2f870d1f53df11d29d4fc4e01101497d6300381
[ "MIT" ]
1
2016-12-18T08:42:28.000Z
2016-12-18T08:42:28.000Z
MultiThreadDownload/BrandDownload/Others/DownLoadMission.h
DongDongDongDong/MultiThreadDownload
a2f870d1f53df11d29d4fc4e01101497d6300381
[ "MIT" ]
null
null
null
// // DownLoadTask.h // obdDownloader // // Created by andylau on 16/1/25. // Copyright © 2016年 andylau. All rights reserved. // #import <Foundation/Foundation.h> #import "DownListModel.h" typedef void(^downloadProgressBlock)(CGFloat progressValue,DownListModel *model); typedef void(^downloadFinishBlock)(DownListModel *finishModel); @interface DownLoadMission : NSObject @property (nonatomic, strong) DownListModel *model; @property (nonatomic, copy) NSString *UID; @property (nonatomic) CGFloat currentProgress; @property (nonatomic, copy) downloadProgressBlock progressBlock; @property (nonatomic, copy) downloadFinishBlock finishBlock; - (void)changeValueText:(downloadProgressBlock)progressBlock; - (void)didFinishDownload:(downloadFinishBlock)finishBlock; - (instancetype)initWithUID:(NSString *)uid; - (void)download; - (void)pause; @end
23.324324
81
0.776362
[ "model" ]
ef434ce0b875351c1736bb97e882097a4c17defe
586
h
C
src/homework/tic_tac_toe/tic_tac_toe_manager.h
acc-cosc-1337-spring-2021/acc-cosc-1337-spring-2021-Alexandra632
f2f0f76425888350be7480cd8fe9ba151ce572f6
[ "MIT" ]
null
null
null
src/homework/tic_tac_toe/tic_tac_toe_manager.h
acc-cosc-1337-spring-2021/acc-cosc-1337-spring-2021-Alexandra632
f2f0f76425888350be7480cd8fe9ba151ce572f6
[ "MIT" ]
null
null
null
src/homework/tic_tac_toe/tic_tac_toe_manager.h
acc-cosc-1337-spring-2021/acc-cosc-1337-spring-2021-Alexandra632
f2f0f76425888350be7480cd8fe9ba151ce572f6
[ "MIT" ]
1
2021-01-27T04:47:15.000Z
2021-01-27T04:47:15.000Z
#ifndef TIC_TAC_TOE_MANAGER_H #define TIC_TAC_TOE_MANAGER_H #include "tic_tac_toe.h" #include <iostream> #include <string> #include <vector> #include <memory> class TicTacToeManager { private: std::vector <std::unique_ptr<TicTacToe>> games; void update_winner_count(std::string); int x_wins = {0}; int o_wins = {0}; int ties = {0}; public: void save_game(std::unique_ptr<TicTacToe>&); void get_winner_total(int&, int&, int&); friend std::ostream& operator<<(std::ostream&, const TicTacToeManager&); }; #endif
21.703704
80
0.650171
[ "vector" ]
ef46ca6982032aa34a8b631cc3bbac0671e16b6d
18,521
c
C
ext/filter.c
erikaaron/cphalcon7-1.3.3-Stable-0
5f8d996370449421317694534caa7285a286d0b4
[ "BSD-3-Clause" ]
1
2020-04-26T23:16:41.000Z
2020-04-26T23:16:41.000Z
ext/filter.c
erikwang2013/cphalcon7-1.3.3-Stable-0
5f8d996370449421317694534caa7285a286d0b4
[ "BSD-3-Clause" ]
null
null
null
ext/filter.c
erikwang2013/cphalcon7-1.3.3-Stable-0
5f8d996370449421317694534caa7285a286d0b4
[ "BSD-3-Clause" ]
null
null
null
/* +------------------------------------------------------------------------+ | Phalcon Framework | +------------------------------------------------------------------------+ | Copyright (c) 2011-2014 Phalcon Team (http://www.phalconphp.com) | +------------------------------------------------------------------------+ | This source file is subject to the New BSD License that is bundled | | with this package in the file docs/LICENSE.txt. | | | | If you did not receive a copy of the license and are unable to | | obtain it through the world-wide-web, please send an email | | to license@phalconphp.com so we can send you a copy immediately. | +------------------------------------------------------------------------+ | Authors: Andres Gutierrez <andres@phalconphp.com> | | Eduar Carvajal <eduar@phalconphp.com> | | ZhuZongXin <dreamsxin@qq.com> | +------------------------------------------------------------------------+ */ #include "filter.h" #include "filterinterface.h" #include "filter/exception.h" #include "filter/../date.h" #include <Zend/zend_closures.h> #include "kernel/main.h" #include "kernel/memory.h" #include "kernel/exception.h" #include "kernel/hash.h" #include "kernel/fcall.h" #include "kernel/array.h" #include "kernel/object.h" #include "kernel/operators.h" #include "kernel/string.h" #include "kernel/filter.h" #include "kernel/concat.h" /** * Phalcon\Filter * * The Phalcon\Filter component provides a set of commonly needed data filters. It provides * object oriented wrappers to the php filter extension. Also allows the developer to * define his/her own filters * *<code> * $filter = new Phalcon\Filter(); * $filter->sanitize("some(one)@exa\\mple.com", "email"); // returns "someone@example.com" * $filter->sanitize("hello<<", "string"); // returns "hello" * $filter->sanitize("!100a019", "int"); // returns "100019" * $filter->sanitize("!100a019.01a", "float"); // returns "100019.01" *</code> */ zend_class_entry *phalcon_filter_ce; PHP_METHOD(Phalcon_Filter, __construct); PHP_METHOD(Phalcon_Filter, add); PHP_METHOD(Phalcon_Filter, sanitize); PHP_METHOD(Phalcon_Filter, _sanitize); PHP_METHOD(Phalcon_Filter, getFilters); ZEND_BEGIN_ARG_INFO_EX(arginfo_phalcon_filterinterface___construct, 0, 0, 0) ZEND_ARG_TYPE_INFO(0, options, IS_ARRAY, 1) ZEND_ARG_INFO(0, handler) ZEND_END_ARG_INFO() static const zend_function_entry phalcon_filter_method_entry[] = { PHP_ME(Phalcon_Filter, __construct, arginfo_phalcon_filterinterface___construct, ZEND_ACC_PUBLIC|ZEND_ACC_CTOR) PHP_ME(Phalcon_Filter, add, arginfo_phalcon_filterinterface_add, ZEND_ACC_PUBLIC) PHP_ME(Phalcon_Filter, sanitize, arginfo_phalcon_filterinterface_sanitize, ZEND_ACC_PUBLIC) PHP_ME(Phalcon_Filter, _sanitize, NULL, ZEND_ACC_PROTECTED) PHP_ME(Phalcon_Filter, getFilters, NULL, ZEND_ACC_PUBLIC) PHP_FE_END }; /** * Phalcon\Filter initializer */ PHALCON_INIT_CLASS(Phalcon_Filter){ PHALCON_REGISTER_CLASS(Phalcon, Filter, filter, phalcon_filter_method_entry, 0); zend_declare_property_null(phalcon_filter_ce, SL("_filters"), ZEND_ACC_PROTECTED); zend_declare_property_string(phalcon_filter_ce, SL("_dateFormat"), "Y-m-d H:i:s", ZEND_ACC_PROTECTED); zend_declare_property_string(phalcon_filter_ce, SL("FILTER_EMAIL"), "email", ZEND_ACC_PUBLIC|ZEND_ACC_STATIC); zend_declare_property_string(phalcon_filter_ce, SL("FILTER_ABSINT"), "absint", ZEND_ACC_PUBLIC|ZEND_ACC_STATIC); zend_declare_property_string(phalcon_filter_ce, SL("FILTER_INT"), "int", ZEND_ACC_PUBLIC|ZEND_ACC_STATIC); zend_declare_property_string(phalcon_filter_ce, SL("FILTER_INT_CAST"), "int!", ZEND_ACC_PUBLIC|ZEND_ACC_STATIC); zend_declare_property_string(phalcon_filter_ce, SL("FILTER_STRING"), "string", ZEND_ACC_PUBLIC|ZEND_ACC_STATIC); zend_declare_property_string(phalcon_filter_ce, SL("FILTER_FLOAT"), "float", ZEND_ACC_PUBLIC|ZEND_ACC_STATIC); zend_declare_property_string(phalcon_filter_ce, SL("FILTER_FLOAT_CAST"), "float!", ZEND_ACC_PUBLIC|ZEND_ACC_STATIC); zend_declare_property_string(phalcon_filter_ce, SL("FILTER_ALPHANUM"), "alphanum", ZEND_ACC_PUBLIC|ZEND_ACC_STATIC); zend_declare_property_string(phalcon_filter_ce, SL("FILTER_TRIM"), "trim", ZEND_ACC_PUBLIC|ZEND_ACC_STATIC); zend_declare_property_string(phalcon_filter_ce, SL("FILTER_STRIPTAGS"), "striptags", ZEND_ACC_PUBLIC|ZEND_ACC_STATIC); zend_declare_property_string(phalcon_filter_ce, SL("FILTER_LOWER"), "lower", ZEND_ACC_PUBLIC|ZEND_ACC_STATIC); zend_declare_property_string(phalcon_filter_ce, SL("FILTER_UPPER"), "upper", ZEND_ACC_PUBLIC|ZEND_ACC_STATIC); zend_declare_property_string(phalcon_filter_ce, SL("FILTER_XSS"), "xss", ZEND_ACC_PUBLIC|ZEND_ACC_STATIC); zend_declare_property_string(phalcon_filter_ce, SL("FILTER_ARRAY"), "array", ZEND_ACC_PUBLIC|ZEND_ACC_STATIC); zend_class_implements(phalcon_filter_ce, 1, phalcon_filterinterface_ce); return SUCCESS; } /** * Phalcon\Filter constructor */ PHP_METHOD(Phalcon_Filter, __construct){ zval *options = NULL, date_format = {}; phalcon_fetch_params(0, 0, 1, options); if (!options) { options = &PHALCON_GLOBAL(z_null); } if (likely(Z_TYPE_P(options) != IS_ARRAY) && phalcon_array_isset_fetch_str(&date_format, options, SL("dateFormat"), PH_READONLY) && Z_TYPE(date_format) == IS_STRING) { phalcon_update_property(getThis(), SL("_dateFormat"), &date_format); } } /** * Adds a user-defined filter * * @param string $name * @param callable $handler * @return Phalcon\Filter */ PHP_METHOD(Phalcon_Filter, add){ zval *name, *handler; phalcon_fetch_params(0, 2, 0, &name, &handler); if (Z_TYPE_P(handler) != IS_OBJECT && !phalcon_is_callable(handler)) { PHALCON_THROW_EXCEPTION_STR(phalcon_filter_exception_ce, "Filter must be an object or callable"); return; } phalcon_update_property_array(getThis(), SL("_filters"), name, handler); RETURN_THIS(); } /** * Sanitizes a value with a specified single or set of filters * * @param mixed $value * @param mixed $filters * @param boolean $recursive * @param array $options * @param int $recursiveLevel * @return mixed */ PHP_METHOD(Phalcon_Filter, sanitize){ zval *value, *filters, *recursive = NULL, *options = NULL, *_recursive_level = NULL, recursive_level = {}; zval new_value = {}, *item_value, *filter, filter_value = {}, sanizited_value = {}; zend_string *filter_key, *item_key; ulong item_idx; phalcon_fetch_params(0, 2, 3, &value, &filters, &recursive, &options, &_recursive_level); if (!recursive || Z_TYPE_P(recursive) == IS_NULL) { recursive = &PHALCON_GLOBAL(z_true); } if (!options) { options = &PHALCON_GLOBAL(z_null); } if (!_recursive_level || Z_TYPE_P(_recursive_level) != IS_LONG) { ZVAL_LONG(&recursive_level, 0); } else { ZVAL_COPY(&recursive_level, _recursive_level); } /** * Apply an array of filters */ if (Z_TYPE_P(filters) == IS_ARRAY) { ZVAL_DUP(&new_value, value); if (Z_TYPE_P(value) != IS_NULL) { ZEND_HASH_FOREACH_STR_KEY_VAL(Z_ARRVAL_P(filters), filter_key, filter) { zval real_filter = {}, real_options = {}, array_value = {}; if (filter_key) { ZVAL_STR(&real_filter, filter_key); if (Z_TYPE_P(filter) == IS_ARRAY) { if (Z_TYPE_P(options) == IS_ARRAY) { phalcon_fast_array_merge(&real_options, options, filter); } else { ZVAL_COPY(&real_options, filter); } } else { if (Z_TYPE_P(options) == IS_ARRAY) { ZVAL_DUP(&real_options, options); } else { array_init(&real_options); } phalcon_array_update(&real_options, &real_filter, filter, PH_COPY); } } else { ZVAL_COPY(&real_filter, filter); ZVAL_COPY(&real_options, options); } /** * If the value to filter is an array we apply the filters recursively */ if (Z_TYPE(new_value) == IS_ARRAY && zend_is_true(recursive)) { array_init(&array_value); phalcon_decrement(&recursive_level); ZEND_HASH_FOREACH_KEY_VAL(Z_ARRVAL(new_value), item_idx, item_key, item_value) { if (Z_TYPE_P(item_value) == IS_ARRAY && Z_LVAL(recursive_level) > 0) { PHALCON_CALL_METHOD(&filter_value, getThis(), "sanitize", item_value, filters, recursive, options, &recursive_level); } else { PHALCON_CALL_METHOD(&filter_value, getThis(), "_sanitize", item_value, &real_filter, &real_options); } if (item_key) { phalcon_array_update_string(&array_value, item_key, &filter_value, 0); } else { phalcon_array_update_long(&array_value, item_idx, &filter_value, 0); } } ZEND_HASH_FOREACH_END(); zval_ptr_dtor(&new_value); ZVAL_COPY_VALUE(&new_value, &array_value); } else { PHALCON_CALL_METHOD(&filter_value, getThis(), "_sanitize", &new_value, &real_filter, &real_options); zval_ptr_dtor(&new_value); ZVAL_COPY_VALUE(&new_value, &filter_value); } zval_ptr_dtor(&real_filter); zval_ptr_dtor(&real_options); } ZEND_HASH_FOREACH_END(); } RETURN_ZVAL(&new_value, 0, 0); } /** * Apply a single filter value */ if (Z_TYPE_P(value) == IS_ARRAY && zend_is_true(recursive)) { array_init(&sanizited_value); phalcon_decrement(&recursive_level); ZEND_HASH_FOREACH_KEY_VAL(Z_ARRVAL_P(value), item_idx, item_key, item_value) { if (Z_TYPE_P(item_value) == IS_ARRAY && Z_LVAL(recursive_level) > 0) { PHALCON_CALL_METHOD(&filter_value, getThis(), "sanitize", item_value, filters, recursive, options, &recursive_level); } else { PHALCON_CALL_METHOD(&filter_value, getThis(), "_sanitize", item_value, filters, options); } if (item_key) { phalcon_array_update_string(&sanizited_value, item_key, &filter_value, 0); } else { phalcon_array_update_long(&sanizited_value, item_idx, &filter_value, 0); } } ZEND_HASH_FOREACH_END(); } else { PHALCON_CALL_METHOD(&sanizited_value, getThis(), "_sanitize", value, filters, options); } RETURN_ZVAL(&sanizited_value, 0, 0); } /** * Internal sanitize wrapper to filter_var * * @param mixed $value * @param string $filter * @return mixed */ PHP_METHOD(Phalcon_Filter, _sanitize){ zval *value, *filter, *options = NULL, filters = {}, filter_object = {}, arguments = {}, type = {}, quote = {}, empty_str = {}; zval escaped = {}, filtered = {}, allow_fraction = {}, format = {}, exception_message = {}; phalcon_fetch_params(0, 2, 1, &value, &filter, &options); if (!options) { options = &PHALCON_GLOBAL(z_null); } if (Z_TYPE_P(filter) != IS_STRING) { if (Z_TYPE_P(filter) == IS_OBJECT) { if (instanceof_function(Z_OBJCE_P(filter), zend_ce_closure)) { PHALCON_CALL_METHOD(return_value, filter, "call", getThis(), value); return; } PHALCON_RETURN_CALL_METHOD(filter, "filter", value); return; } if (phalcon_is_callable(filter)) { array_init_size(&arguments, 1); phalcon_array_append(&arguments, value, PH_COPY); PHALCON_CALL_USER_FUNC_ARRAY(return_value, filter, &arguments); zval_ptr_dtor(&arguments); return; } PHALCON_THROW_EXCEPTION_STR(phalcon_filter_exception_ce, "Filter must be an object or callable"); return; } phalcon_read_property(&filters, getThis(), SL("_filters"), PH_NOISY|PH_READONLY); if (phalcon_array_isset_fetch(&filter_object, &filters, filter, PH_READONLY) && (Z_TYPE(filter_object) == IS_OBJECT || phalcon_is_callable(&filter_object))) { /** * If the filter is a closure we call it in the PHP userland */ if (Z_TYPE(filter_object) == IS_OBJECT && instanceof_function(Z_OBJCE(filter_object), zend_ce_closure)) { PHALCON_CALL_METHOD(return_value, &filter_object, "call", getThis(), value); return; } else if (phalcon_is_callable(&filter_object)) { array_init_size(&arguments, 1); phalcon_array_append(&arguments, value, PH_COPY); PHALCON_CALL_USER_FUNC_ARRAY(return_value, &filter_object, &arguments); zval_ptr_dtor(&arguments); return; } PHALCON_RETURN_CALL_METHOD(&filter_object, "filter", value); return; } if (PHALCON_IS_STRING(filter, "email")) { /** * The 'email' filter uses the filter extension */ ZVAL_LONG(&type, 517); /* FILTER_SANITIZE_EMAIL */ ZVAL_STRING(&quote, "'"); ZVAL_STRING(&empty_str, ""); PHALCON_STR_REPLACE(&escaped, &quote, &empty_str, value); zval_ptr_dtor(&quote); zval_ptr_dtor(&empty_str); PHALCON_CALL_FUNCTION(&filtered, "filter_var", &escaped, &type); zval_ptr_dtor(&escaped); goto ph_end_0; } if (PHALCON_IS_STRING(filter, "int")) { /** * 'int' filter sanitizes a numeric input */ ZVAL_LONG(&type, 519); /* FILTER_SANITIZE_NUMBER_INT */ PHALCON_CALL_FUNCTION(&filtered, "filter_var", value, &type); goto ph_end_0; } if (PHALCON_IS_STRING(filter, "int!")) { ZVAL_DUP(&filtered, value); convert_to_long_base(&filtered, 10); goto ph_end_0; } if (PHALCON_IS_STRING(filter, "int?")) { if (phalcon_is_numeric(value)) { ZVAL_ZVAL(&filtered, value, 1, 0); convert_to_long_base(&filtered, 10); } else { ZVAL_COPY_VALUE(&filtered, value); } goto ph_end_0; } if (PHALCON_IS_STRING(filter, "abs")) { convert_scalar_to_number_ex(value); if (Z_TYPE_P(value) == IS_DOUBLE) { ZVAL_DOUBLE(&filtered, fabs(Z_DVAL_P(value))); } else if (Z_DVAL_P(value) == IS_LONG) { if (Z_DVAL_P(value) == LONG_MIN) { ZVAL_DOUBLE(&filtered, -(double)LONG_MIN); } else { ZVAL_LONG(&filtered, Z_LVAL_P(value) < 0 ? -Z_LVAL_P(value) : Z_LVAL_P(value)); } } else { ZVAL_FALSE(&filtered); } goto ph_end_0; } if (PHALCON_IS_STRING(filter, "string")) { ZVAL_LONG(&type, 513); /* FILTER_SANITIZE_STRING */ PHALCON_CALL_FUNCTION(&filtered, "filter_var", value, &type); goto ph_end_0; } if (PHALCON_IS_STRING(filter, "float")) { zval opt = {}; /** * The 'float' filter uses the filter extension */ ZVAL_LONG(&allow_fraction, 4096); /* FILTER_FLAG_ALLOW_FRACTION */ array_init_size(&opt, 1); phalcon_array_update_str(&opt, SL("flags"), &allow_fraction, PH_COPY); ZVAL_LONG(&type, 520); /* FILTER_SANITIZE_NUMBER_FLOAT */ PHALCON_CALL_FUNCTION(&filtered, "filter_var", value, &type, &opt); goto ph_end_0; } if (PHALCON_IS_STRING(filter, "float!")) { ZVAL_ZVAL(&filtered, value, 1, 0); convert_to_double(&filtered); goto ph_end_0; } if (PHALCON_IS_STRING(filter, "float?")) { if (phalcon_is_numeric(value)) { ZVAL_ZVAL(&filtered, value, 1, 0); convert_to_double(&filtered); } else { ZVAL_COPY_VALUE(&filtered, value); } goto ph_end_0; } if (PHALCON_IS_STRING(filter, "alphanum")) { phalcon_filter_alphanum(&filtered, value); goto ph_end_0; } if (PHALCON_IS_STRING(filter, "trim")) { ZVAL_STR(&filtered, phalcon_trim(value, NULL, PHALCON_TRIM_BOTH)); goto ph_end_0; } if (PHALCON_IS_STRING(filter, "striptags")) { phalcon_fast_strip_tags(&filtered, value); goto ph_end_0; } if (PHALCON_IS_STRING(filter, "lower")) { if (phalcon_function_exists_ex(SL("mb_strtolower")) == SUCCESS) { /** * 'lower' checks for the mbstring extension to make a correct lowercase * transformation */ PHALCON_CALL_FUNCTION(&filtered, "mb_strtolower", value); } else { phalcon_fast_strtolower(&filtered, value); } goto ph_end_0; } if (PHALCON_IS_STRING(filter, "upper")) { if (phalcon_function_exists_ex(SL("mb_strtoupper")) == SUCCESS) { /** * 'upper' checks for the mbstring extension to make a correct lowercase * transformation */ PHALCON_CALL_FUNCTION(&filtered, "mb_strtoupper", value); } else { phalcon_fast_strtoupper(&filtered, value); } goto ph_end_0; } if (PHALCON_IS_STRING(filter, "daterange")) { zval format = {}, delimiter = {}; if (Z_TYPE_P(options) == IS_ARRAY) { if (!phalcon_array_isset_fetch_str(&format, options, SL("format"), PH_READONLY)) { ZVAL_NULL(&format); } if (!phalcon_array_isset_fetch_str(&delimiter, options, SL("delimiter"), PH_COPY)) { ZVAL_STRING(&delimiter, " - "); } } else { ZVAL_NULL(&format); ZVAL_STRING(&delimiter, " - "); } PHALCON_CALL_CE_STATIC(&filtered, phalcon_date_ce, "filter", value, &format, &delimiter); zval_ptr_dtor(&delimiter); goto ph_end_0; } if (PHALCON_IS_STRING(filter, "date")) { PHALCON_CALL_CE_STATIC(&filtered, phalcon_date_ce, "filter", value); goto ph_end_0; } if (PHALCON_IS_STRING(filter, "datetime")) { if (Z_TYPE_P(options) != IS_ARRAY || !phalcon_array_isset_fetch_str(&format, options, SL("dateFormat"), PH_READONLY)) { phalcon_read_property(&format, getThis(), SL("_dateFormat"), PH_READONLY); } PHALCON_CALL_CE_STATIC(&filtered, phalcon_date_ce, "filter", value, &format); goto ph_end_0; } if (PHALCON_IS_STRING(filter, "url")) { ZVAL_LONG(&type, 518); /* FILTER_SANITIZE_URL */ PHALCON_CALL_FUNCTION(&filtered, "filter_var", value, &type); goto ph_end_0; } if (PHALCON_IS_STRING(filter, "ip")) { ZVAL_LONG(&type, 275); /* FILTER_VALIDATE_IP */ PHALCON_CALL_FUNCTION(&filtered, "filter_var", value, &type); if (PHALCON_IS_FALSE(&filtered)) { ZVAL_NULL(&filtered); } goto ph_end_0; } if (PHALCON_IS_STRING(filter, "in")) { if (Z_TYPE_P(options) != IS_ARRAY || !phalcon_fast_in_array(value, options)) { ZVAL_NULL(&filtered); } else { ZVAL_COPY(&filtered, value); } goto ph_end_0; } if (PHALCON_IS_STRING(filter, "array")) { convert_to_array(value); if (zend_is_true(options)) { if (phalcon_is_callable(options)) { PHALCON_CALL_FUNCTION(&filtered, "array_filter", value, options); } else { PHALCON_CALL_FUNCTION(&filtered, "array_filter", value); } } else { ZVAL_COPY(&filtered, value); } goto ph_end_0; } if (phalcon_is_callable(filter)) { array_init_size(&arguments, 1); phalcon_array_append(&arguments, value, PH_COPY); PHALCON_CALL_USER_FUNC_ARRAY(return_value, filter, &arguments); zval_ptr_dtor(&arguments); return; } PHALCON_CONCAT_SVS(&exception_message, "Sanitize filter ", filter, " is not supported"); PHALCON_THROW_EXCEPTION_ZVAL(phalcon_filter_exception_ce, &exception_message); zval_ptr_dtor(&exception_message); return; ph_end_0: RETURN_ZVAL(&filtered, 0, 0); } /** * Return the user-defined filters in the instance * * @return object[] */ PHP_METHOD(Phalcon_Filter, getFilters){ RETURN_MEMBER(getThis(), "_filters"); }
32.492982
159
0.68965
[ "object" ]
ef47dabb63ec656095a29be7f1eaeb6480cad36f
11,416
h
C
extra/path.h
questor/eastl
750f09706a42acff6c29601ba4942e7edc49a9e6
[ "BSD-3-Clause" ]
16
2015-04-15T02:09:59.000Z
2022-01-31T11:30:29.000Z
extra/path.h
questor/eastl
750f09706a42acff6c29601ba4942e7edc49a9e6
[ "BSD-3-Clause" ]
null
null
null
extra/path.h
questor/eastl
750f09706a42acff6c29601ba4942e7edc49a9e6
[ "BSD-3-Clause" ]
7
2015-08-24T16:15:17.000Z
2021-12-22T02:21:27.000Z
// A simple class for manipulating paths on Linux/Windows/Mac OS // Copyright 2015 Wenzel Jakob. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. /* Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #if !defined(WIN32) path path1("/dir 1/dir 2/"); #else path path1("C:\\dir 1\\dir 2\\"); #endif path path2("dir 3"); cout << path1.exists() << endl; cout << path1 << endl; cout << (path1/path2) << endl; cout << (path1/path2).parent_path() << endl; cout << (path1/path2).parent_path().parent_path() << endl; cout << (path1/path2).parent_path().parent_path().parent_path() << endl; cout << (path1/path2).parent_path().parent_path().parent_path().parent_path() << endl; cout << path().parent_path() << endl; cout << "nonexistant:exists = " << path("nonexistant").exists() << endl; cout << "nonexistant:is_file = " << path("nonexistant").is_file() << endl; cout << "nonexistant:is_directory = " << path("nonexistant").is_directory() << endl; cout << "nonexistant:extension = " << path("nonexistant").extension() << endl; cout << "filesystem/path.h:exists = " << path("filesystem/path.h").exists() << endl; cout << "filesystem/path.h:is_file = " << path("filesystem/path.h").is_file() << endl; cout << "filesystem/path.h:is_directory = " << path("filesystem/path.h").is_directory() << endl; cout << "filesystem/path.h:extension = " << path("filesystem/path.h").extension() << endl; cout << "filesystem/path.h:make_absolute = " << path("filesystem/path.h").make_absolute() << endl; cout << "../filesystem:exists = " << path("../filesystem").exists() << endl; cout << "../filesystem:is_file = " << path("../filesystem").is_file() << endl; cout << "../filesystem:is_directory = " << path("../filesystem").is_directory() << endl; cout << "../filesystem:extension = " << path("../filesystem").extension() << endl; cout << "../filesystem:make_absolute = " << path("../filesystem").make_absolute() << endl; cout << "resolve(filesystem/path.h) = " << resolver().resolve("filesystem/path.h") << endl; cout << "resolve(nonexistant) = " << resolver().resolve("nonexistant") << endl; */ #if !defined(__FILESYSTEM_PATH_H) #define __FILESYSTEM_PATH_H #include <string> #include <vector> #include <stdexcept> #include <sstream> #include <cctype> #include <cstdlib> #include <cerrno> #include <cstring> #if defined(WIN32) # include <windows.h> #else # include <sys/stat.h> # include <unistd.h> #endif #if defined(__linux) # include <linux/limits.h> #endif namespace filesystem { /** * \brief Simple class for manipulating paths on Linux/Windows/Mac OS * * This class is just a temporary workaround to avoid the heavy boost * dependency until boost::filesystem is integrated into the standard template * library at some point in the future. */ class path { public: enum path_type { windows_path = 0, posix_path = 1, #if defined(WIN32) native_path = windows_path #else native_path = posix_path #endif }; path() : m_type(native_path), m_absolute(false) { } path(const path &path) : m_type(path.m_type), m_path(path.m_path), m_absolute(path.m_absolute) {} #if __cplusplus >= 201103L path(path &&path) : m_type(path.m_type), m_path(std::move(path.m_path)), m_absolute(path.m_absolute) {} #endif path(const char *string) { set(string); } path(const std::string &string) { set(string); } #if defined(WIN32) path(const std::wstring &wstring) { set(wstring); } path(const wchar_t *wstring) { set(wstring); } #endif size_t size() const { return m_path.size(); } bool empty() const { return m_path.empty(); } bool is_absolute() const { return m_absolute; } path make_absolute() const { #if !defined(WIN32) char temp[PATH_MAX]; if (realpath(str().c_str(), temp) == NULL) throw std::runtime_error("Internal error in realpath(): " + std::string(strerror(errno))); return path(temp); #else std::wstring value = wstr(), out(MAX_PATH, '\0'); DWORD length = GetFullPathNameW(value.c_str(), MAX_PATH, &out[0], NULL); if (length == 0) throw std::runtime_error("Internal error in realpath(): " + std::to_string(GetLastError())); return path(out.substr(0, length)); #endif } bool exists() const { #if defined(WIN32) return GetFileAttributesW(wstr().c_str()) != INVALID_FILE_ATTRIBUTES; #else struct stat sb; return stat(str().c_str(), &sb) == 0; #endif } bool is_directory() const { #if defined(WIN32) DWORD result = GetFileAttributesW(wstr().c_str()); if (result == INVALID_FILE_ATTRIBUTES) return false; return (result & FILE_ATTRIBUTE_DIRECTORY) != 0; #else struct stat sb; if (stat(str().c_str(), &sb)) return false; return S_ISDIR(sb.st_mode); #endif } bool is_file() const { #if defined(WIN32) DWORD result = GetFileAttributesW(wstr().c_str()); if (result == INVALID_FILE_ATTRIBUTES) return false; return (result & FILE_ATTRIBUTE_NORMAL) != 0; #else struct stat sb; if (stat(str().c_str(), &sb)) return false; return S_ISREG(sb.st_mode); #endif } std::string extension() const { if (empty()) return ""; const std::string &last = m_path[m_path.size()-1]; size_t pos = last.findLastOf("."); if (pos == std::string::npos) return ""; return last.substr(pos+1); } path parent_path() const { path result; result.m_absolute = m_absolute; if (m_path.empty()) { if (!m_absolute) result.m_path.pushBack(".."); } else { size_t until = m_path.size() - 1; for (size_t i = 0; i < until; ++i) result.m_path.pushBack(m_path[i]); } return result; } path operator/(const path &other) const { if (other.m_absolute) throw std::runtime_error("path::operator/(): expected a relative path!"); if (other.m_type != other.m_type) throw std::runtime_error("path::operator/(): expected a path of the same type!"); path result(*this); for (size_t i=0; i<other.m_path.size(); ++i) result.m_path.pushBack(other.m_path[i]); return result; } std::string str(path_type type = native_path) const { std::ostringstream oss; if (m_type == posix_path && m_absolute) oss << "/"; for (size_t i=0; i<m_path.size(); ++i) { oss << m_path[i]; if (i+1 < m_path.size()) { if (type == posix_path) oss << '/'; else oss << '\\'; } } return oss.str(); } static path getcwd() { #if !defined(WIN32) char temp[PATH_MAX]; if (::getcwd(temp, PATH_MAX) == NULL) throw std::runtime_error("Internal error in getcwd(): " + std::string(strerror(errno))); return path(temp); #else std::wstring temp(MAX_PATH, '\0'); if (!_wgetcwd(&temp[0], MAX_PATH)) throw std::runtime_error("Internal error in getcwd(): " + std::to_string(GetLastError())); return path(temp.c_str()); #endif } void set(const std::string &str, path_type type = native_path) { m_type = type; if (type == windows_path) { m_path = tokenize(str, "/\\"); m_absolute = str.size() >= 2 && std::isalpha(str[0]) && str[1] == ':'; } else { m_path = tokenize(str, "/"); m_absolute = !str.empty() && str[0] == '/'; } } path &operator=(const std::string &str) { set(str); return *this; } path &operator=(const path &path) { m_type = path.m_type; m_path = path.m_path; m_absolute = path.m_absolute; return *this; } #if __cplusplus >= 201103L path &operator=(path &&path) { if (this != &path) { m_type = path.m_type; m_path = std::move(path.m_path); m_absolute = path.m_absolute; } return *this; } #endif friend std::ostream &operator<<(std::ostream &os, const path &path) { os << path.str(); return os; } #if defined(WIN32) std::wstring wstr() const { std::string temp = str(); int size = MultiByteToWideChar(CP_UTF8, 0, &temp[0], (int)temp.size(), NULL, 0); std::wstring result(size, 0); MultiByteToWideChar(CP_UTF8, 0, &temp[0], (int)temp.size(), &result[0], size); return result; } void set(const std::wstring &wstring, path_type type = native_path) { std::string string; if (!wstring.empty()) { int size = WideCharToMultiByte(CP_UTF8, 0, &wstring[0], (int)wstring.size(), NULL, 0, NULL, NULL); string.resize(size, 0); WideCharToMultiByte(CP_UTF8, 0, &wstring[0], (int)wstring.size(), &string[0], size, NULL, NULL); } set(string, type); } path &operator=(const std::wstring &str) { set(str); return *this; } #endif protected: static std::vector<std::string> tokenize(const std::string &string, const std::string &delim) { std::string::size_type lastPos = 0, pos = string.findFirstOf(delim, lastPos); std::vector<std::string> tokens; while (lastPos != std::string::npos) { if (pos != lastPos) tokens.pushBack(string.substr(lastPos, pos - lastPos)); lastPos = pos; if (lastPos == std::string::npos || lastPos + 1 == string.length()) break; pos = string.findFirstOf(delim, ++lastPos); } return tokens; } protected: path_type m_type; std::vector<std::string> m_path; bool m_absolute; }; }; /* namespace filesystem */ #endif /* __FILESYSTEM_PATH_H */
33.186047
104
0.601086
[ "vector" ]
ef56e15b0b3a47c11fa373191f8dc2845723e037
47,109
c
C
CG/CG/cg.c
wustl-pctg/NUMA-WS-Benchmarks
579deb56e1c7310624f76b5a8cbb8b66793d6fe0
[ "MIT" ]
null
null
null
CG/CG/cg.c
wustl-pctg/NUMA-WS-Benchmarks
579deb56e1c7310624f76b5a8cbb8b66793d6fe0
[ "MIT" ]
null
null
null
CG/CG/cg.c
wustl-pctg/NUMA-WS-Benchmarks
579deb56e1c7310624f76b5a8cbb8b66793d6fe0
[ "MIT" ]
null
null
null
/*-------------------------------------------------------------------- NAS Parallel Benchmarks 3.0 structured OpenMP C versions - CG This benchmark is an OpenMP C version of the NPB CG code. The OpenMP C 2.3 versions are derived by RWCP from the serial Fortran versions in "NPB 2.3-serial" developed by NAS. 3.0 translation is performed by the UVSQ. Permission to use, copy, distribute and modify this software for any purpose with or without fee is hereby granted. This software is provided "as is" without express or implied warranty. Information on OpenMP activities at RWCP is available at: http://pdplab.trc.rwcp.or.jp/pdperf/Omni/ Information on NAS Parallel Benchmarks 2.3 is available at: http://www.nas.nasa.gov/NAS/NPB/ --------------------------------------------------------------------*/ /*-------------------------------------------------------------------- Authors: M. Yarrow C. Kuszmaul OpenMP C version: S. Satoh 3.0 structure translation: F. Conti --------------------------------------------------------------------*/ /* c--------------------------------------------------------------------- c Note: please observe that in the routine conj_grad three c implementations of the sparse matrix-vector multiply have c been supplied. The default matrix-vector multiply is not c loop unrolled. The alternate implementations are unrolled c to a depth of 2 and unrolled to a depth of 8. Please c experiment with these to find the fastest for your particular c architecture. If reporting timing results, any of these three may c be used without penalty. c--------------------------------------------------------------------- */ #ifndef SERIAL #include <cilk/cilk.h> #include <cilk/cilk_api.h> #else #define cilk_spawn #define cilk_sync #define __cilkrts_accum_timing() #define __cilkrts_set_pinning_info(n) #define __cilkrts_unset_pinning_info() #define __cilkrts_pin_top_level_frame_at_socket(n) #define __cilkrts_init() #define __cilkrts_get_nworkers() 1 #define __cilkrts_num_sockets() 1 #define __cilkrts_reset_timing() #define cilk_for for #endif #include "npb-C.h" #include "npbparams.h" #include "numa_allocate.h" #include <unistd.h> #include <sched.h> #include <numa.h> #include <numaif.h> #ifndef TIMING_COUNT #define TIMING_COUNT 0 #endif #if TIMING_COUNT #include "ktiming.h" clockmark_t begin, end; uint64_t *elapsed; #endif #define NZ NA*(NONZER+1)*(NONZER+1)+NA*(NONZER+2) /* global variables */ /* common /partit_size/ */ static int naa; static int nzz; static int firstrow; static int lastrow; static int firstcol; static int lastcol; /* common /main_int_mem/ */ static int colidx[NZ+1]; /* colidx[1:NZ] */ static int rowstr[NA+1+1]; /* rowstr[1:NA+1] */ static int iv[2*NA+1+1]; /* iv[1:2*NA+1] */ static int arow[NZ+1]; /* arow[1:NZ] */ static int acol[NZ+1]; /* acol[1:NZ] */ /* common /main_flt_mem/ */ static double v[NA+1+1]; /* v[1:NA+1] */ static double aelt[NZ+1]; /* aelt[1:NZ] */ static double a[NZ+1]; /* a[1:NZ] */ static double x[NA+2+1]; /* x[1:NA+2] */ static double z[NA+2+1]; /* z[1:NA+2] */ static double p[NA+2+1]; /* p[1:NA+2] */ static double q[NA+2+1]; /* q[1:NA+2] */ static double r[NA+2+1]; /* r[1:NA+2] */ //static double w[NA+2+1]; /* w[1:NA+2] */ /* common /urando/ */ static double amult; static double tran; /* function declarations */ static void conj_grad (int colidx[], int rowstr[], double x[], double z[], double a[], double p[], double q[], double r[], //double w[], double *rnorm); static void makea(int n, int nz, double a[], int colidx[], int rowstr[], int nonzer, int firstrow, int lastrow, int firstcol, int lastcol, double rcond, int arow[], int acol[], double aelt[], double v[], int iv[], double shift ); static void sparse(double a[], int colidx[], int rowstr[], int n, int arow[], int acol[], double aelt[], int firstrow, int lastrow, double x[], boolean mark[], int nzloc[], int nnza); static void sprnvc(int n, int nz, double v[], int iv[], int nzloc[], int mark[]); static int icnvrt(double x, int ipwr2); const unsigned long BASE_CASE = 512; double reduce_add_mul(double init_sum, double *arr1, double *arr2, unsigned long i, unsigned long e){ if( e - i < BASE_CASE){ for(int j = i; j < e; j++){ init_sum += arr1[j] * arr2[j]; } return init_sum; } unsigned long mid = (i + e) / 2; double k = cilk_spawn reduce_add_mul(init_sum, arr1, arr2, i, mid); double l = reduce_add_mul(init_sum, arr1, arr2, mid, e); cilk_sync; return k+l; } #ifndef NO_PIN void map_mul_scalar(double *res, double *A, double alpha, unsigned long i, unsigned long e){ unsigned long mid = (i + e) / 2; if( e - i < BASE_CASE){ for(int j = i; j < e; j++){ res[j] = A[j] * alpha; } return; } cilk_spawn map_mul_scalar(res, A, alpha, i, mid); map_mul_scalar(res, A, alpha, mid, e); cilk_sync; return; } #endif const unsigned long IDX_MUL_BASE_CASE = BASE_CASE; double reduce_add_mul_idx(double init_sum, double *arr1, double *arr2, int *idx, unsigned long i, unsigned long e){ unsigned long mid = (i + e) / 2; //printf("here: e- i : %d\n", e-i); if( e - i < IDX_MUL_BASE_CASE){ for(int j = i; j < e; j++){ init_sum += arr1[j] * arr2[idx[j]]; } return init_sum; } double k = cilk_spawn reduce_add_mul_idx(init_sum, arr1, arr2, idx, i, mid); double l = reduce_add_mul_idx(init_sum, arr1, arr2, idx, mid, e); cilk_sync; return k+l; } static void vecset(int n, double v[], int iv[], int *nzv, int i, double val); #ifndef NO_PIN static int sockets; static int mem_pattern[] = {0, 0, 0, 0, 0, 0, 0, 0}; static int pin_pattern[] = {0, 0, 0, 0, 0, 0, 0, 0}; #endif /*-------------------------------------------------------------------- program cg --------------------------------------------------------------------*/ #ifndef NO_PIN #define SET_PIN(N) __cilkrts_set_pinning_info(N) #endif int fakemain(int argc, char **argv, int run) { int i, j, k, it; int nthreads = 1; double zeta; double rnorm; double norm_temp11; double norm_temp12; double t, mflops; char class; boolean verified; double zeta_verify_value, epsilon; firstrow = 1; lastrow = NA; firstcol = 1; lastcol = NA; if (NA == 1400 && NONZER == 7 && NITER == 15 && SHIFT == 10.0) { class = 'S'; zeta_verify_value = 8.5971775078648; } else if (NA == 7000 && NONZER == 8 && NITER == 15 && SHIFT == 12.0) { class = 'W'; zeta_verify_value = 10.362595087124; } else if (NA == 14000 && NONZER == 11 && NITER == 15 && SHIFT == 20.0) { class = 'A'; zeta_verify_value = 17.130235054029; } else if (NA == 75000 && NONZER == 13 && NITER == 75 && SHIFT == 60.0) { class = 'B'; zeta_verify_value = 22.712745482631; } else if (NA == 150000 && NONZER == 15 && NITER == 75 && SHIFT == 110.0) { class = 'C'; zeta_verify_value = 28.973605592845; } else { class = 'U'; } //printf("\n\n NAS Parallel Benchmarks 3.0 structured OpenMP C version" // " - CG Benchmark\n"); //printf(" Size: %10d\n", NA); //printf(" Iterations: %5d\n", NITER); naa = NA; nzz = NZ; /*-------------------------------------------------------------------- c Initialize random number generator c-------------------------------------------------------------------*/ tran = 314159265.0; amult = 1220703125.0; zeta = randlc( &tran, amult ); /*-------------------------------------------------------------------- c c-------------------------------------------------------------------*/ //printf("data gen\n"); makea(naa, nzz, a, colidx, rowstr, NONZER, firstrow, lastrow, firstcol, lastcol, RCOND, arow, acol, aelt, v, iv, SHIFT); //printf("data gen end\n"); /*--------------------------------------------------------------------- c Note: as a result of the above call to makea: c values of j used in indexing rowstr go from 1 --> lastrow-firstrow+1 c values of colidx which are col indexes go from firstcol --> lastcol c So: c Shift the col index vals from actual (firstcol --> lastcol ) c to local, i.e., (1 --> lastcol-firstcol+1) c---------------------------------------------------------------------*/ cilk_for (unsigned long j = 1; j <= lastrow - firstrow + 1; j++) { for (unsigned long k = rowstr[j]; k < rowstr[j+1]; k++) { colidx[k] = colidx[k] - firstcol + 1; } } //printf("end colidx\n"); /*-------------------------------------------------------------------- c set starting vector to (1, 1, .... 1) c-------------------------------------------------------------------*/ cilk_for (unsigned long i = 1; i <= NA+1; i++) { x[i] = 1.0; } cilk_for (unsigned long j = 1; j <= lastcol-firstcol+1; j++) { q[j] = 0.0; z[j] = 0.0; r[j] = 0.0; p[j] = 0.0; } zeta = 0.0; /*------------------------------------------------------------------- c----> c Do one iteration untimed to init all code and data page tables c----> (then reinit, start timing, to niter its) c-------------------------------------------------------------------*/ #ifndef NO_PIN int rNZ = rowstr[lastrow-firstrow+2]; int sockets = __cilkrts_num_sockets(); //colidx unsigned long long colidx_pages = (rNZ+1)*sizeof(int)/getpagesize()+1; int *colidx_numa = (int *) pattern_bind_memory_numa(colidx_pages, sockets, mem_pattern); cilk_for(int i =0;i < rNZ+1; i++){ colidx_numa[i] = colidx[i]; } //rowstr unsigned long long rowstr_pages = (NA+1+1)*sizeof(int)/getpagesize()+1; //printf("rowstr pages: %d\n", rowstr_pages); int *rowstr_numa = (int *) pattern_bind_memory_numa(rowstr_pages, sockets, mem_pattern); cilk_for(int i =0;i < NA+1+1; i++){ rowstr_numa[i] = rowstr[i]; } //x unsigned long long x_pages = (NA+2+1)*sizeof(double)/getpagesize()+1; double *x_numa = (double *) pattern_bind_memory_numa(x_pages, sockets, mem_pattern); cilk_for(int i =0;i < NA+2+1; i++){ x_numa[i] = x[i]; } //z unsigned long long z_pages = (NA+2+1)*sizeof(double)/getpagesize()+1; double *z_numa = (double *) pattern_bind_memory_numa(z_pages, sockets, mem_pattern); cilk_for(int i =0;i < NA+2+1; i++){ z_numa[i] = z[i]; } //a unsigned long long a_pages = (rNZ+1)*sizeof(double)/getpagesize()+1; double *a_numa = (double *) pattern_bind_memory_numa(a_pages, sockets, mem_pattern); cilk_for(int i =0;i < rNZ+1; i++){ a_numa[i] = a[i]; } //p unsigned long long p_pages = (NA+2+1)*sizeof(double)/getpagesize()+1; double *p_numa = (double *) pattern_bind_memory_numa(p_pages, sockets, mem_pattern); cilk_for(int i =0;i < NA+2+1; i++){ p_numa[i] = p[i]; } //q unsigned long long q_pages = (NA+2+1)*sizeof(double)/getpagesize()+1; double *q_numa = (double *) pattern_bind_memory_numa(q_pages, sockets, mem_pattern); cilk_for(int i =0;i < NA+2+1; i++){ q_numa[i] = q[i]; } //r unsigned long long r_pages = (NA+2+1)*sizeof(double)/getpagesize()+1; double *r_numa = (double *) pattern_bind_memory_numa(r_pages, sockets, mem_pattern); cilk_for(int i =0;i < NA+2+1; i++){ r_numa[i] = r[i]; } //unsigned long midt1 = (lastcol-firstcol+2)/2; //unsigned long midt11 = (1 + midt1)/2; //unsigned long midt12 = (midt1 + lastcol-firstcol+2)/2; unsigned long unit = (lastcol-firstcol+2)/sockets; #endif for (it = 1; it <= 1; it++) { //printf("in first iter\n"); /*-------------------------------------------------------------------- c The call to the conjugate gradient routine: c-------------------------------------------------------------------*/ #ifndef NO_PIN conj_grad (colidx_numa, rowstr_numa, x_numa, z_numa, a_numa, p_numa, q_numa, r_numa,/* w,*/ &rnorm); #else conj_grad (colidx, rowstr, x, z, a, p, q, r,/* w,*/ &rnorm); #endif //printf("end conj grad\n"); /*-------------------------------------------------------------------- c zeta = shift + 1/(x.z) c So, first: (x.z) c Also, find norm of z c So, first: (z.z) c-------------------------------------------------------------------*/ norm_temp11 = 0.0; norm_temp12 = 0.0; #ifndef NO_PIN double norm_temp11_s[sockets]; double norm_temp12_s[sockets]; int start_spawn0 = 1; for(int i = 0; i < sockets; i++){ if(i != sockets - 1){ norm_temp11_s[i] = cilk_spawn reduce_add_mul(norm_temp11, x_numa, z_numa, start_spawn0, start_spawn0+unit); // @0 SET_PIN(pin_pattern[i+1]); norm_temp12_s[i] = cilk_spawn reduce_add_mul(norm_temp12, z_numa, z_numa, start_spawn0, start_spawn0+unit); // @0 }else{ norm_temp11_s[i] = cilk_spawn reduce_add_mul(norm_temp11, x_numa, z_numa, start_spawn0, lastcol-firstcol+2); // @3 norm_temp12_s[i] = reduce_add_mul(norm_temp12, z_numa, z_numa, start_spawn0, lastcol-firstcol+2); // @3 __cilkrts_unset_pinning_info(); } start_spawn0 += unit; } SET_PIN(pin_pattern[0]); cilk_sync; for(int i = 0; i < sockets; i ++){ norm_temp11 += norm_temp11_s[i]; norm_temp12 += norm_temp12_s[i]; } #else norm_temp11 = cilk_spawn reduce_add_mul(norm_temp11, x, z, 1, lastcol-firstcol+2); norm_temp12 = reduce_add_mul(norm_temp12, z, z, 1, lastcol-firstcol+2); cilk_sync; #endif norm_temp12 = 1.0 / sqrt( norm_temp12 ); /*-------------------------------------------------------------------- c Normalize z to obtain x c-------------------------------------------------------------------*/ cilk_for (unsigned long j = 1; j <= lastcol-firstcol+1; j++) { #ifndef NO_PIN x_numa[j] = norm_temp12*z_numa[j]; #else x[j] = norm_temp12*z[j]; #endif } } /* end of do one iteration untimed */ /*-------------------------------------------------------------------- c set starting vector to (1, 1, .... 1) c-------------------------------------------------------------------*/ cilk_for (unsigned long i = 1; i <= NA+1; i++) { #ifndef NO_PIN x_numa[i] = 1.0; #else x[i] = 1.0; #endif } zeta = 0.0; /*-------------------------------------------------------------------- c----> c Main Iteration for inverse power method c----> c-------------------------------------------------------------------*/ //printf("entering main iter\n"); __cilkrts_reset_timing(); timer_clear( 1 ); //timer_start( 1 ); #if TIMING_COUNT begin = ktiming_getmark(); #endif for (it = 1; it <= NITER; it++) { /*-------------------------------------------------------------------- c The call to the conjugate gradient routine: c-------------------------------------------------------------------*/ #ifndef NO_PIN conj_grad(colidx_numa, rowstr_numa, x_numa, z_numa, a_numa, p_numa, q_numa, r_numa/*, w*/, &rnorm); #else conj_grad(colidx, rowstr, x, z, a, p, q, r/*, w*/, &rnorm); #endif /*-------------------------------------------------------------------- c zeta = shift + 1/(x.z) c So, first: (x.z) c Also, find norm of z c So, first: (z.z) c-------------------------------------------------------------------*/ norm_temp11 = 0.0; norm_temp12 = 0.0; #ifndef NO_PIN double norm_temp11_s[sockets]; double norm_temp12_s[sockets]; int start_spawn1 = 1; for(int i = 0; i < sockets; i++){ if(i != sockets - 1){ norm_temp11_s[i] = cilk_spawn reduce_add_mul(norm_temp11, x_numa, z_numa, start_spawn1, start_spawn1+unit); // @0 SET_PIN(pin_pattern[i+1]); norm_temp12_s[i] = cilk_spawn reduce_add_mul(norm_temp12, z_numa, z_numa, start_spawn1, start_spawn1+unit); // @0 }else{ norm_temp11_s[i] = cilk_spawn reduce_add_mul(norm_temp11, x_numa, z_numa, start_spawn1, lastcol-firstcol+2); // @3 norm_temp12_s[i] = reduce_add_mul(norm_temp12, z_numa, z_numa, start_spawn1, lastcol-firstcol+2); // @3 __cilkrts_unset_pinning_info(); } start_spawn1 += unit; } SET_PIN(pin_pattern[0]); cilk_sync; for(int i = 0; i < sockets; i ++){ norm_temp11 += norm_temp11_s[i]; norm_temp12 += norm_temp12_s[i]; } #else norm_temp11 = cilk_spawn reduce_add_mul(norm_temp11, x, z, 1, lastcol-firstcol+2); norm_temp12 = reduce_add_mul(norm_temp12, z, z, 1, lastcol-firstcol+2); cilk_sync; #endif norm_temp12 = 1.0 / sqrt( norm_temp12 ); zeta = SHIFT + 1.0 / norm_temp11; /* if( it == 1 ) { printf(" iteration ||r|| zeta\n"); } printf(" %5d %20.14e%20.13e\n", it, rnorm, zeta); */ /*-------------------------------------------------------------------- c Normalize z to obtain x c-------------------------------------------------------------------*/ /* cilk_for (unsigned long j = 1; j <= lastcol-firstcol+1; j++) { */ /* x[j] = norm_temp12*z[j]; */ /* } */ #ifndef NO_PIN int start_spawn2 = 1; for(int i = 0; i < sockets; i++){ if(i != sockets - 1){ SET_PIN(pin_pattern[i+1]); cilk_spawn map_mul_scalar(x_numa, z_numa, norm_temp12, start_spawn2, start_spawn2+unit); // @0 }else{ map_mul_scalar(x_numa, z_numa, norm_temp12, start_spawn2, lastcol-firstcol+2); // @3 __cilkrts_unset_pinning_info(); } start_spawn2 += unit; } SET_PIN(pin_pattern[0]); cilk_sync; #else cilk_for (unsigned long j = 1; j <= lastcol-firstcol+1; j++) { x[j] = norm_temp12*z[j]; } #endif } /* end of main iter inv pow meth */ nthreads = __cilkrts_get_nworkers(); //timer_stop( 1 ); #if TIMING_COUNT end = ktiming_getmark(); elapsed[run] = ktiming_diff_usec(&begin, &end); #endif __cilkrts_accum_timing(); /*-------------------------------------------------------------------- c End of timed section c-------------------------------------------------------------------*/ t = timer_read( 1 ); //printf(" Benchmark completed\n"); epsilon = 1.0e-10; if (class != 'U') { if (fabs(zeta - zeta_verify_value) <= epsilon) { verified = TRUE; //printf(" VERIFICATION SUCCESSFUL\n"); //printf(" Zeta is %20.12e\n", zeta); //printf(" Error is %20.12e\n", zeta - zeta_verify_value); } else { verified = FALSE; //printf(" VERIFICATION FAILED\n"); //printf(" Zeta %20.12e\n", zeta); //printf(" The correct zeta is %20.12e\n", zeta_verify_value); } } else { verified = FALSE; //printf(" Problem size unknown\n"); //printf(" NO VERIFICATION PERFORMED\n"); } if ( t != 0.0 ) { mflops = (2.0*NITER*NA) * (3.0+(NONZER*(NONZER+1)) + 25.0*(5.0+(NONZER*(NONZER+1))) + 3.0 ) / t / 1000000.0; } else { mflops = 0.0; } c_print_results("CG", class, NA, 0, 0, NITER, nthreads, t, mflops, " floating point", verified, NPBVERSION, COMPILETIME, CS1, CS2, CS3, CS4, CS5, CS6, CS7); return 0; } const unsigned long INIT_BASE_CASE = BASE_CASE; void initialize(double *q, double *z, double *r, double *p, double *x, unsigned long i, unsigned long e){ unsigned long mid = (i + e) / 2; if(e - i <= INIT_BASE_CASE){ for(int j = i; j < e; j++){ q[j] = 0.0; z[j] = 0.0; r[j] = x[j]; p[j] = r[j]; } return; } cilk_spawn initialize(q, z, r, p, x, i, mid); initialize(q, z, r, p, x, mid, e); cilk_sync; } /* cilk_for (unsigned long j = 1; j <= lastrow-firstrow+1; j++) { */ /* sum = 0.0; */ /* for (k = rowstr[j]; k < rowstr[j+1]; k++) { */ /* sum = sum + a[k]*p[colidx[k]]; */ /* } */ /* //w[j] = sum; */ /* q[j] = sum; */ /* } */ const unsigned long Q_BASE_CASE = 1; void compute_q(int *rowstr, int *colidx, double *p, double *q, double *a, unsigned long i, unsigned long e){ if(e - i >= NA/4-100){ //start = ktiming_getmark(); } unsigned long mid = (i+e)/2; if(e - i <= Q_BASE_CASE){ for(int j = i; j < e; j++){ double sum = 0.0; //printf("j: %d, rowstr: %d, rowstr+1: %d, work: %d\n", j, rowstr[j], rowstr[j+1], rowstr[j+1]-rowstr[j]); /* for (int k = rowstr[j]; k < rowstr[j+1]; k++){ //printf("k: %d, colidx: %d, p: %f, NA: %d\n", k, colidx[k], p[colidx[k]], NA); sum += a[k]* p[colidx[k]]; }*/ /*#ifndef NO_PIN sum = reduce_add_mul_idx(sum, a, p, colidx, rowstr[j], rowstr[j+1]); #else*/ for (int k = rowstr[j]; k < rowstr[j+1]; k++){ sum += a[k] * p[colidx[k]]; } //#endif q[j] = sum; } return; } cilk_spawn compute_q(rowstr, colidx, p, q, a, i, mid); compute_q(rowstr, colidx, p, q, a, mid, e); cilk_sync; if(e - i >= NA/4-100){ //clockmark_t end = ktiming_getmark(); //uint64_t diff = ktiming_diff_usec(&start, &end); //printf("NZ: %d, diff : %lu at i: %d, e: %d, start:%d, end: %d, amount of work: %d, a bind at %d, i am at %d\n", NZ, diff, i, e, rowstr[i], rowstr[e], rowstr[e] - rowstr[i], get_mem_binding(&a[(rowstr[e] + rowstr[i])/2]), numa_node_of_cpu(sched_getcpu())); } } const unsigned long MAP_BASE_CASE = BASE_CASE; void map_add_mul(double *res, double *A, double *B, double alpha, unsigned long i, unsigned long e){ unsigned long mid = (i + e) / 2; if(e - i < MAP_BASE_CASE){ for(int j = i; j < e; j++){ res[j] = A[j] + B[j] * alpha; } return; } cilk_spawn map_add_mul(res, A, B, alpha, i, mid); map_add_mul(res, A, B, alpha, mid, e); cilk_sync; } /*#ifdef NO_PIN const unsigned long IDX_MUL_BASE_CASE = 512; double reduce_add_mul_idx(double init_sum, double *arr1, double *arr2, int *idx, unsigned long i, unsigned long e){ unsigned long mid = (i + e) / 2; //printf("here: e- i : %d\n", e-i); if( e - i < IDX_MUL_BASE_CASE){ for(int j = i; j < e; j++){ init_sum += arr1[j] * arr2[idx[j]]; } return init_sum; } double k = cilk_spawn reduce_add_mul_idx(init_sum, arr1, arr2, idx, i, mid); double l = reduce_add_mul_idx(init_sum, arr1, arr2, idx, mid, e); cilk_sync; return k+l; } #endif*/ /* for (unsigned long j = 1; j <= lastrow-firstrow+1; j++) { */ /* d = 0.0; */ /* for (k = rowstr[j]; k <= rowstr[j+1]-1; k++) { */ /* d = d + a[k]*z[colidx[k]]; */ /* } */ /* r[j] = d; */ /* } */ const unsigned long NORM_BASE_CASE = 1; void compute_norm(int *rowstr, int *colidx, double *a, double *z, double *r, unsigned long i, unsigned long e){ unsigned long mid = (i+e)/2; if(e - i <= NORM_BASE_CASE){ for(int j = i; j < e; j++){ r[j] = reduce_add_mul_idx(0.0, a, z, colidx, rowstr[j], rowstr[j+1]); } return; } cilk_spawn compute_norm(rowstr, colidx, a, z, r, i, mid); compute_norm(rowstr, colidx, a, z, r, mid, e); cilk_sync; } #ifndef NO_PIN long find_num(int *arr, int num, unsigned long i, unsigned long e){ unsigned long mid = (i + e)/2; if(e - i < BASE_CASE){ long idx = -1; for(int j = i; j < e; j++){ if (arr[j] > num){ idx= j-1; break; } } return idx; } long res1= cilk_spawn find_num(arr, num, i, mid); long res2= find_num(arr, num, mid, e); cilk_sync; if(res1 != -1){ return res1; } if(res2 != -1){ return res2; } return -1; } #endif /* #pragma omp for reduction(+:sum) */ /* for (j = 1; j <= lastcol-firstcol+1; j++) { */ /* d = x[j] - r[j]; */ /* sum = sum + d*d; */ /* } */ /* //} //end omp parallel */ /* (*rnorm) = sqrt(sum); */ /* } */ const unsigned long COMPUTE_SUM_BASE_CASE = BASE_CASE; double compute_sum(double *x, double *r, unsigned long i, unsigned long e){ unsigned long mid = (i + e) / 2; if(e - i < COMPUTE_SUM_BASE_CASE){ double sum = 0.0; for(unsigned long j = i; j < e; j++){ double d = x[j] - r[j]; sum += d*d; } return sum; } double v1 = cilk_spawn compute_sum(x, r, i, mid); double v2 = compute_sum(x, r, mid, e); cilk_sync; return v1 + v2; } /*-------------------------------------------------------------------- c-------------------------------------------------------------------*/ static void conj_grad ( int colidx[], /* colidx[1:nzz] */ int rowstr[], /* rowstr[1:naa+1] */ double x[], /* x[*] */ double z[], /* z[*] */ double a[], /* a[1:nzz] */ double p[], /* p[*] */ double q[], /* q[*] */ double r[], /* r[*] */ //double w[], /* w[*] */ double *rnorm ) /*-------------------------------------------------------------------- c-------------------------------------------------------------------*/ /*--------------------------------------------------------------------- c Floaging point arrays here are named as in NPB1 spec discussion of c CG algorithm c---------------------------------------------------------------------*/ { static int callcount = 0; double d, sum, rho, rho0, alpha, beta; int i, j, k; int cgit, cgitmax = 25; rho = 0.0; //#pragma omp parallel default(shared) private(j,sum) shared(rho,naa) /*-------------------------------------------------------------------- c Initialize the CG algorithm: c-------------------------------------------------------------------*/ //{ /* cilk_for (unsigned long j = 1; j <= naa+1; j++) { */ /* q[j] = 0.0; */ /* z[j] = 0.0; */ /* r[j] = x[j]; */ /* p[j] = r[j]; */ /* //w[j] = 0.0; */ /* } */ #ifndef NO_PIN int sockets = __cilkrts_num_sockets(); unsigned long init_unit = (1 + naa+2)/4; int start_spawn1 = 1; for(int i = 0; i < sockets; i++){ if(i != sockets - 1){ SET_PIN(pin_pattern[i+1]); cilk_spawn initialize(q, z, r, p, x, start_spawn1, start_spawn1+init_unit); // @0 }else{ initialize(q, z, r, p, x, start_spawn1, naa+2); // @3 __cilkrts_unset_pinning_info(); } start_spawn1 += init_unit; } SET_PIN(pin_pattern[0]); cilk_sync; #else initialize(q, z, r, p, x, 1, naa+2); #endif /*-------------------------------------------------------------------- c rho = r.r c Now, obtain the norm of r: First, sum squares of r elements locally... c-------------------------------------------------------------------*/ /* #pragma omp for reduction(+:rho) */ /* for (j = 1; j <= lastcol-firstcol+1; j++) { */ /* rho = rho + r[j]*r[j]; */ /* } */ #ifndef NO_PIN unsigned long unit = (lastcol-firstcol+2)/sockets; int start_spawn2 = 1; double rhos[sockets]; for(int i = 0; i < sockets; i++){ if(i != sockets - 1){ SET_PIN(pin_pattern[i+1]); rhos[i] = cilk_spawn reduce_add_mul(rho, r, r, start_spawn2, start_spawn2+unit); }else{ rhos[i] = reduce_add_mul(rho, r, r, start_spawn2, lastrow-firstrow+2); __cilkrts_unset_pinning_info(); } start_spawn2 += unit; } SET_PIN(pin_pattern[0]); cilk_sync; for (int i = 0; i < sockets; i++){ rho += rhos[i]; } #else rho = reduce_add_mul(rho, r, r, 1, lastcol-firstcol+2); #endif //}/* end omp parallel */ /*-------------------------------------------------------------------- c----> c The conj grad iteration loop c----> c-------------------------------------------------------------------*/ for (cgit = 1; cgit <= cgitmax; cgit++) { rho0 = rho; d = 0.0; rho = 0.0; int last_ele = rowstr[lastrow-firstrow+2]; //int rmid1 = cilk_spawn find_num(rowstr, last_ele/4, 0, lastrow-firstrow+2); //int rmid = cilk_spawn find_num(rowstr, last_ele/2, 0, lastrow-firstrow+2); //int rmid2 = find_num(rowstr, last_ele/4*3, 0, lastrow-firstrow+2); //cilk_sync; //printf("rmid1: %d, rmid: %d, rmid2: %d, last: %d\n", rmid1, rmid, rmid2, lastrow-firstrow+2); //printf("%d, %d, %d, %d\n", rowstr[rmid1] - rowstr[1], rowstr[rmid] - rowstr[rmid1], rowstr[rmid2] - rowstr[rmid], last_ele - rowstr[rmid2]); //printf("prev %d, %d, %d, %d\n", rowstr[mid1] - rowstr[1], rowstr[mid] - rowstr[mid1], rowstr[mid2] - rowstr[mid], last_ele - rowstr[mid2]); #ifndef NO_PIN int start_spawn3 = 1; for(int i = 0; i < sockets; i++){ if(i != sockets - 1){ SET_PIN(pin_pattern[i+1]); cilk_spawn compute_q(rowstr, colidx, p, q, a, start_spawn3, start_spawn3+unit); }else{ compute_q(rowstr, colidx, p, q, a, start_spawn3, lastrow-firstrow+2); __cilkrts_unset_pinning_info(); } start_spawn3 += unit; } SET_PIN(pin_pattern[0]); cilk_sync; #else compute_q(rowstr, colidx, p, q, a, 1, lastrow-firstrow+2); #endif /*-------------------------------------------------------------------- c Clear w for reuse... c-------------------------------------------------------------------*/ /* #pragma omp for nowait for (j = 1; j <= lastcol-firstcol+1; j++) { w[j] = 0.0; } */ /*-------------------------------------------------------------------- c Obtain p.q c-------------------------------------------------------------------*/ /* #pragma omp for reduction(+:d) */ /* for (j = 1; j <= lastcol-firstcol+1; j++) { */ /* d = d + p[j]*q[j]; */ /* } */ /* #pragma omp barrier */ #ifndef NO_PIN double ds[sockets]; int start_spawn4 = 1; for(int i = 0; i < sockets; i++){ if(i != sockets - 1){ SET_PIN(pin_pattern[i+1]); ds[i] = cilk_spawn reduce_add_mul(d, p, q, start_spawn4, start_spawn4+unit); }else{ ds[i] = reduce_add_mul(d, p, q, start_spawn4, lastcol-firstcol+2); __cilkrts_unset_pinning_info(); } start_spawn4 += unit; } SET_PIN(pin_pattern[0]); cilk_sync; for(int i = 0; i < sockets; i++){ d+= ds[i]; } #else d = reduce_add_mul(d, p, q, 1, lastcol-firstcol+2); #endif /*-------------------------------------------------------------------- c Obtain alpha = rho / (p.q) c-------------------------------------------------------------------*/ //#pragma omp single alpha = rho0 / d; /*-------------------------------------------------------------------- c Save a temporary of rho c-------------------------------------------------------------------*/ /* rho0 = rho;*/ /*--------------------------------------------------------------------- c Obtain z = z + alpha*p c and r = r - alpha*q c---------------------------------------------------------------------*/ //#pragma omp for reduction(+:rho) //remember we can actually combine the operations here /* cilk_for (unsigned long j = 1; j <= lastcol-firstcol+1; j++) { */ /* z[j] = z[j] + alpha*p[j]; */ /* r[j] = r[j] - alpha*q[j]; */ /* } */ #ifndef NO_PIN int start_spawn5 = 1; for(int i = 0; i < sockets; i++){ if(i != sockets - 1){ cilk_spawn map_add_mul(z, z, p, alpha, start_spawn5, start_spawn5+unit); // @0 SET_PIN(pin_pattern[i+1]); cilk_spawn map_add_mul(r, r, q, -alpha, start_spawn5, start_spawn5+unit); // @0 }else{ cilk_spawn map_add_mul(z, z, p, alpha, start_spawn5, lastcol-firstcol+2); // @3 map_add_mul(r, r, q, -alpha, start_spawn5, lastcol-firstcol+2); // @3 __cilkrts_unset_pinning_info(); } start_spawn5 += unit; } SET_PIN(pin_pattern[0]); #else cilk_spawn map_add_mul(z, z, p, alpha, 1, lastcol-firstcol+2); map_add_mul(r, r, q, -alpha, 1, lastcol-firstcol+2); #endif cilk_sync; /*--------------------------------------------------------------------- c rho = r.r c Now, obtain the norm of r: First, sum squares of r elements locally... c---------------------------------------------------------------------*/ /* #pragma omp for for (j = 1; j <= lastcol-firstcol+1; j++) {*/ //rho = rho + r[j]*r[j]; //} //#pragma omp barrier #ifndef NO_PIN double rhos[sockets]; int start_spawn6 = 1; for(int i = 0; i < sockets; i++){ if(i != sockets - 1){ SET_PIN(pin_pattern[i+1]); rhos[i] = cilk_spawn reduce_add_mul(rho, r, r, start_spawn6, start_spawn6+unit); }else{ rhos[i] = cilk_spawn reduce_add_mul(rho, r, r, start_spawn6, lastcol-firstcol+2); __cilkrts_unset_pinning_info(); } start_spawn6 += unit; } SET_PIN(pin_pattern[0]); cilk_sync; for(int i = 0; i < sockets; i++){ rho += rhos[i]; } #else rho = reduce_add_mul(rho, r, r, 1, lastcol-firstcol+2); #endif /*-------------------------------------------------------------------- c Obtain beta: c-------------------------------------------------------------------*/ //#pragma omp single beta = rho / rho0; /*-------------------------------------------------------------------- c p = r + beta*p c-------------------------------------------------------------------*/ //#pragma omp for nowait /* cilk_for (unsigned long j = 1; j <= lastcol-firstcol+1; j++) { */ /* p[j] = r[j] + beta*p[j]; */ /* } */ #ifndef NO_PIN int start_spawn7 = 1; for(int i = 0; i < sockets; i++){ if(i != sockets - 1){ SET_PIN(pin_pattern[i+1]); cilk_spawn map_add_mul(p, r, p, beta, start_spawn7, start_spawn7+unit); }else{ map_add_mul(p, r, p, beta, start_spawn7, lastcol-firstcol+2); __cilkrts_unset_pinning_info(); } start_spawn7 += unit; } SET_PIN(pin_pattern[0]); cilk_sync; #else map_add_mul(p, r, p, beta, 1, lastcol-firstcol+2); #endif callcount++; //} /* end omp parallel */ } /* end of do cgit=1,cgitmax */ /*--------------------------------------------------------------------- c Compute residual norm explicitly: ||r|| = ||x - A.z|| c First, form A.z c The partition submatrix-vector multiply c---------------------------------------------------------------------*/ sum = 0.0; //#pragma omp parallel default(shared) private(j,d) shared(sum) //{ //#pragma omp for //private(d, k) /* for (unsigned long j = 1; j <= lastrow-firstrow+1; j++) { */ /* d = 0.0; */ /* for (k = rowstr[j]; k <= rowstr[j+1]-1; k++) { */ /* d = d + a[k]*z[colidx[k]]; */ /* } */ /* r[j] = d; */ /* } */ #ifndef NO_PIN int start_spawn8 = 1; for(int i = 0; i < sockets; i++){ if(i != sockets - 1){ SET_PIN(pin_pattern[i+1]); cilk_spawn compute_norm(rowstr, colidx, a, z, r, start_spawn8, start_spawn8+unit); }else{ compute_norm(rowstr, colidx, a, z, r, start_spawn8, lastrow-firstrow+2); __cilkrts_unset_pinning_info(); } start_spawn8 += unit; } SET_PIN(pin_pattern[0]); cilk_sync; #else compute_norm(rowstr, colidx, a, z, r, 1, lastrow-firstrow+2); #endif /*-------------------------------------------------------------------- c At this point, r contains A.z c-------------------------------------------------------------------*/ //todo: finish the reduction here /* #pragma omp for reduction(+:sum) */ /* for (j = 1; j <= lastcol-firstcol+1; j++) { */ /* d = x[j] - r[j]; */ /* sum = sum + d*d; */ /* } */ /* //} //end omp parallel */ /* (*rnorm) = sqrt(sum); */ /* } */ #ifndef NO_PIN double sums[sockets]; int start_spawn9 = 1; for(int i = 0; i < sockets; i++){ if(i != sockets - 1){ SET_PIN(pin_pattern[i+1]); sums[i] = cilk_spawn compute_sum(x, r, start_spawn9, start_spawn9+unit); }else{ sums[i] = compute_sum(x, r, start_spawn9, lastcol-firstcol+2); __cilkrts_unset_pinning_info(); } start_spawn9 += unit; } SET_PIN(pin_pattern[0]); cilk_sync; for(int i = 0; i < sockets; i++){ sum += sums[i]; } #else sum = compute_sum(x, r, 1, lastcol-firstcol+2); #endif (*rnorm) = sqrt(sum); } /*--------------------------------------------------------------------- c generate the test problem for benchmark 6 c makea generates a sparse matrix with a c prescribed sparsity distribution c c parameter type usage c c input c c n i number of cols/rows of matrix c nz i nonzeros as declared array size c rcond r*8 condition number c shift r*8 main diagonal shift c c output c c a r*8 array for nonzeros c colidx i col indices c rowstr i row pointers c c workspace c c iv, arow, acol i c v, aelt r*8 c---------------------------------------------------------------------*/ static void makea( int n, int nz, double a[], /* a[1:nz] */ int colidx[], /* colidx[1:nz] */ int rowstr[], /* rowstr[1:n+1] */ int nonzer, int firstrow, int lastrow, int firstcol, int lastcol, double rcond, int arow[], /* arow[1:nz] */ int acol[], /* acol[1:nz] */ double aelt[], /* aelt[1:nz] */ double v[], /* v[1:n+1] */ int iv[], /* iv[1:2*n+1] */ double shift ) { int i, nnza, iouter, ivelt, ivelt1, irow, nzv; /*-------------------------------------------------------------------- c nonzer is approximately (int(sqrt(nnza /n))); c-------------------------------------------------------------------*/ double size, ratio, scale; int jcol; size = 1.0; ratio = pow(rcond, (1.0 / (double)n)); nnza = 0; /*--------------------------------------------------------------------- c Initialize colidx(n+1 .. 2n) to zero. c Used by sprnvc to mark nonzero positions c---------------------------------------------------------------------*/ //cilkfor for (unsigned long i = 1; i <= n; i++) { colidx[n+i] = 0; } for (iouter = 1; iouter <= n; iouter++) { nzv = nonzer; sprnvc(n, nzv, v, iv, &(colidx[0]), &(colidx[n])); vecset(n, v, iv, &nzv, iouter, 0.5); for (ivelt = 1; ivelt <= nzv; ivelt++) { jcol = iv[ivelt]; if (jcol >= firstcol && jcol <= lastcol) { scale = size * v[ivelt]; for (ivelt1 = 1; ivelt1 <= nzv; ivelt1++) { irow = iv[ivelt1]; if (irow >= firstrow && irow <= lastrow) { nnza = nnza + 1; if (nnza > nz) { //printf("Space for matrix elements exceeded in" // " makea\n"); //printf("nnza, nzmax = %d, %d\n", nnza, nz); //printf("iouter = %d\n", iouter); exit(1); } acol[nnza] = jcol; arow[nnza] = irow; aelt[nnza] = v[ivelt1] * scale; } } } } size = size * ratio; } /*--------------------------------------------------------------------- c ... add the identity * rcond to the generated matrix to bound c the smallest eigenvalue from below by rcond c---------------------------------------------------------------------*/ for (i = firstrow; i <= lastrow; i++) { if (i >= firstcol && i <= lastcol) { iouter = n + i; nnza = nnza + 1; if (nnza > nz) { //printf("Space for matrix elements exceeded in makea\n"); //printf("nnza, nzmax = %d, %d\n", nnza, nz); //printf("iouter = %d\n", iouter); exit(1); } acol[nnza] = i; arow[nnza] = i; aelt[nnza] = rcond - shift; } } /*--------------------------------------------------------------------- c ... make the sparse matrix from list of elements with duplicates c (v and iv are used as workspace) c---------------------------------------------------------------------*/ sparse(a, colidx, rowstr, n, arow, acol, aelt, firstrow, lastrow, v, &(iv[0]), &(iv[n]), nnza); } /*--------------------------------------------------- c generate a sparse matrix from a list of c [col, row, element] tri c---------------------------------------------------*/ static void sparse( double a[], /* a[1:*] */ int colidx[], /* colidx[1:*] */ int rowstr[], /* rowstr[1:*] */ int n, int arow[], /* arow[1:*] */ int acol[], /* acol[1:*] */ double aelt[], /* aelt[1:*] */ int firstrow, int lastrow, double x[], /* x[1:n] */ boolean mark[], /* mark[1:n] */ int nzloc[], /* nzloc[1:n] */ int nnza) /*--------------------------------------------------------------------- c rows range from firstrow to lastrow c the rowstr pointers are defined for nrows = lastrow-firstrow+1 values c---------------------------------------------------------------------*/ { int nrows; int i, j, jajp1, nza, k, nzrow; double xi; /*-------------------------------------------------------------------- c how many rows of result c-------------------------------------------------------------------*/ nrows = lastrow - firstrow + 1; /*-------------------------------------------------------------------- c ...count the number of triples in each row c-------------------------------------------------------------------*/ //cilk_for for (unsigned long j = 1; j <= n; j++) { rowstr[j] = 0; mark[j] = FALSE; } rowstr[n+1] = 0; for (nza = 1; nza <= nnza; nza++) { j = (arow[nza] - firstrow + 1) + 1; rowstr[j] = rowstr[j] + 1; } rowstr[1] = 1; for (j = 2; j <= nrows+1; j++) { rowstr[j] = rowstr[j] + rowstr[j-1]; } /*--------------------------------------------------------------------- c ... rowstr(j) now is the location of the first nonzero c of row j of a c---------------------------------------------------------------------*/ /*--------------------------------------------------------------------- c ... preload data pages c---------------------------------------------------------------------*/ //cilkfor for(unsigned long j = 0;j <= nrows-1;j++) { //cilkfor for(unsigned long k = rowstr[j];k <= rowstr[j+1]-1;k++) a[k] = 0.0; } /*-------------------------------------------------------------------- c ... do a bucket sort of the triples on the row index c-------------------------------------------------------------------*/ for (nza = 1; nza <= nnza; nza++) { j = arow[nza] - firstrow + 1; k = rowstr[j]; a[k] = aelt[nza]; colidx[k] = acol[nza]; rowstr[j] = rowstr[j] + 1; } /*-------------------------------------------------------------------- c ... rowstr(j) now points to the first element of row j+1 c-------------------------------------------------------------------*/ for (j = nrows; j >= 1; j--) { rowstr[j+1] = rowstr[j]; } rowstr[1] = 1; /*-------------------------------------------------------------------- c ... generate the actual output rows by adding elements c-------------------------------------------------------------------*/ nza = 0; //cilkfor for (unsigned long i = 1; i <= n; i++) { x[i] = 0.0; mark[i] = FALSE; } jajp1 = rowstr[1]; for (j = 1; j <= nrows; j++) { nzrow = 0; /*-------------------------------------------------------------------- c ...loop over the jth row of a c-------------------------------------------------------------------*/ for (k = jajp1; k < rowstr[j+1]; k++) { i = colidx[k]; x[i] = x[i] + a[k]; if ( mark[i] == FALSE && x[i] != 0.0) { mark[i] = TRUE; nzrow = nzrow + 1; nzloc[nzrow] = i; } } /*-------------------------------------------------------------------- c ... extract the nonzeros of this row c-------------------------------------------------------------------*/ for (k = 1; k <= nzrow; k++) { i = nzloc[k]; mark[i] = FALSE; xi = x[i]; x[i] = 0.0; if (xi != 0.0) { nza = nza + 1; a[nza] = xi; colidx[nza] = i; } } jajp1 = rowstr[j+1]; rowstr[j+1] = nza + rowstr[1]; } } /*--------------------------------------------------------------------- c generate a sparse n-vector (v, iv) c having nzv nonzeros c c mark(i) is set to 1 if position i is nonzero. c mark is all zero on entry and is reset to all zero before exit c this corrects a performance bug found by John G. Lewis, caused by c reinitialization of mark on every one of the n calls to sprnvc ---------------------------------------------------------------------*/ static void sprnvc( int n, int nz, double v[], /* v[1:*] */ int iv[], /* iv[1:*] */ int nzloc[], /* nzloc[1:n] */ int mark[] ) /* mark[1:n] */ { int nn1; int nzrow, nzv, ii, i; double vecelt, vecloc; nzv = 0; nzrow = 0; nn1 = 1; do { nn1 = 2 * nn1; } while (nn1 < n); /*-------------------------------------------------------------------- c nn1 is the smallest power of two not less than n c-------------------------------------------------------------------*/ while (nzv < nz) { vecelt = randlc(&tran, amult); /*-------------------------------------------------------------------- c generate an integer between 1 and n in a portable manner c-------------------------------------------------------------------*/ vecloc = randlc(&tran, amult); i = icnvrt(vecloc, nn1) + 1; if (i > n) continue; /*-------------------------------------------------------------------- c was this integer generated already? c-------------------------------------------------------------------*/ if (mark[i] == 0) { mark[i] = 1; nzrow = nzrow + 1; nzloc[nzrow] = i; nzv = nzv + 1; v[nzv] = vecelt; iv[nzv] = i; } } for (ii = 1; ii <= nzrow; ii++) { i = nzloc[ii]; mark[i] = 0; } } /*--------------------------------------------------------------------- * scale a double precision number x in (0,1) by a power of 2 and chop it *---------------------------------------------------------------------*/ static int icnvrt(double x, int ipwr2) { return ((int)(ipwr2 * x)); } /*-------------------------------------------------------------------- c set ith element of sparse vector (v, iv) with c nzv nonzeros to val c-------------------------------------------------------------------*/ static void vecset( int n, double v[], /* v[1:*] */ int iv[], /* iv[1:*] */ int *nzv, int i, double val) { int k; boolean set; set = FALSE; for (k = 1; k <= *nzv; k++) { if (iv[k] == i) { v[k] = val; set = TRUE; } } if (set == FALSE) { *nzv = *nzv + 1; v[*nzv] = val; iv[*nzv] = i; } } int main(int argc, char **argv){ __cilkrts_init(); #if TIMING_COUNT elapsed = malloc(TIMING_COUNT * sizeof(uint64_t)); for(int i=0; i < TIMING_COUNT; i++){ begin = 0; end = 0; #else int i = 0; #endif #ifndef NO_PIN __cilkrts_pin_top_level_frame_at_socket(0); sockets = __cilkrts_num_sockets(); if(sockets == 2){ int mem_patternT[] = {0, 1}; int pin_patternT[] = {0, 1}; memcpy(mem_pattern, mem_patternT, 4*sizeof(int)); memcpy(pin_pattern, pin_patternT, 4*sizeof(int)); }else if(sockets == 3){ int mem_patternT[] = {0, 2, 1}; int pin_patternT[] = {0, 2, 1}; memcpy(mem_pattern, mem_patternT, 4*sizeof(int)); memcpy(pin_pattern, pin_patternT, 4*sizeof(int)); }else if(sockets == 4){ int mem_patternT[] = {0, 1, 2, 3}; int pin_patternT[] = {0, 1, 2, 3}; memcpy(mem_pattern, mem_patternT, 4*sizeof(int)); memcpy(pin_pattern, pin_patternT, 4*sizeof(int)); } #else unsigned long nodemask = 0; for(int i = 0; i < __cilkrts_get_nworkers() / CPUS_PER_SOCKET; i++) { nodemask |= (1L << i); } set_mempolicy(MPOL_INTERLEAVE, &nodemask ,sizeof(nodemask)*8); #endif fakemain(argc, argv, i); #if TIMING_COUNT } print_runtime(elapsed, TIMING_COUNT); #endif return 0; }
31.851927
261
0.484324
[ "vector" ]
ef61cd29f14342d81babc4575b99b757259f59d8
885
h
C
scene/3d/instantiation.h
Segs/Engine
754aabfc2708a46f764979a604871633152ce479
[ "CC-BY-3.0", "Apache-2.0", "MIT" ]
8
2019-09-03T19:58:19.000Z
2021-06-18T07:11:26.000Z
scene/3d/instantiation.h
Segs/Engine
754aabfc2708a46f764979a604871633152ce479
[ "CC-BY-3.0", "Apache-2.0", "MIT" ]
24
2019-09-03T17:35:45.000Z
2020-10-27T14:36:02.000Z
scene/3d/instantiation.h
nemerle/SegsEngine
b9dd0b5481b92d956befa72c746758d33a1a08c9
[ "CC-BY-3.0", "Apache-2.0", "MIT" ]
6
2019-09-27T15:44:35.000Z
2021-01-23T18:52:51.000Z
#pragma once #include "scene/3d/visual_instance_3d.h" #include "scene/resources/scene_library.h" class GODOT_EXPORT LibraryEntryInstance : public Node3D { GDCLASS(LibraryEntryInstance, Node3D) OBJ_CATEGORY("3D") String lib_name; String entry_name; Ref<SceneLibrary> resolved_library; Node3D *instantiated_child=nullptr; protected: void _notification(int p_what); // bind helpers static void _bind_methods(); void update_instance(); public: void set_library(const Ref<SceneLibrary> &lib); Ref<SceneLibrary> get_library() const { return resolved_library; } void set_library_path(const String &lib); const String &get_library_path() const { return lib_name; } void set_entry(StringView name); const String &get_entry() const { return entry_name; } LibraryEntryInstance(); ~LibraryEntryInstance() override; };
26.818182
70
0.731073
[ "3d" ]
ef6271975f38736f45c6042e2162f9111df6787f
2,219
h
C
ios/dist/ViroRenderer/x86_64/ViroKit.framework/Headers/VROViewScene.h
yoelhawa/viro
9814acc6a7ac082e31c123526f01ad2b14feec2d
[ "MIT" ]
1,851
2017-03-24T00:08:21.000Z
2022-03-29T21:14:30.000Z
ios/dist/ViroRenderer/x86_64/ViroKit.framework/Headers/VROViewScene.h
yoelhawa/viro
9814acc6a7ac082e31c123526f01ad2b14feec2d
[ "MIT" ]
964
2017-03-24T01:20:31.000Z
2022-03-28T14:18:30.000Z
ios/dist/ViroRenderer/x86_64/ViroKit.framework/Headers/VROViewScene.h
yoelhawa/viro
9814acc6a7ac082e31c123526f01ad2b14feec2d
[ "MIT" ]
458
2017-05-17T09:04:01.000Z
2022-03-31T11:52:07.000Z
// // VROViewScene.h // ViroRenderer // // Created by Raj Advani on 3/1/18. // Copyright © 2018 Viro Media. All rights reserved. // // Permission is hereby granted, free of charge, to any person obtaining // a copy of this software and associated documentation files (the // "Software"), to deal in the Software without restriction, including // without limitation the rights to use, copy, modify, merge, publish, // distribute, sublicense, and/or sell copies of the Software, and to // permit persons to whom the Software is furnished to do so, subject to // the following conditions: // // The above copyright notice and this permission notice shall be included // in all copies or substantial portions of the Software. // // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. // IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY // CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, // TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE // SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #import <Foundation/Foundation.h> #import <GLKit/GLKit.h> #import "VROView.h" class VRORendererConfiguration; @interface VROViewScene : GLKView <VROView, UIGestureRecognizerDelegate> @property (readwrite, nonatomic) BOOL suspended; - (instancetype)initWithFrame:(CGRect)frame config:(VRORendererConfiguration)config context:(EAGLContext *)context; /* Should be invoked before this object gets deallocated, to clean up GL resources on the rendering thread before the underlying EAGLContext used by this view is destroyed. This is required to prevent deadlocks in CVOpenGLTextureCache, which hangs on dealloc if the EAGLContext it's using is already gone. */ - (void)deleteGL; /* Sets the paused state of the underlying CADisplayLink */ - (void)setPaused:(BOOL)paused; /* Set the background color for this view. This is the color that will be rendered behind the scene graph. */ - (void)setBackgroundColor:(UIColor *)color; @end
35.790323
75
0.744029
[ "object" ]
ef6601647724f1b9373fff5bdca40f8952a6884e
5,405
h
C
InterpolationMethods.h
victorlevasseur/Skeleton-Extension
c494f344ee812009932fde38455ad2b53603e7b5
[ "Zlib" ]
1
2016-02-04T13:49:11.000Z
2016-02-04T13:49:11.000Z
InterpolationMethods.h
victorlevasseur/Skeleton-Extension
c494f344ee812009932fde38455ad2b53603e7b5
[ "Zlib" ]
null
null
null
InterpolationMethods.h
victorlevasseur/Skeleton-Extension
c494f344ee812009932fde38455ad2b53603e7b5
[ "Zlib" ]
null
null
null
/* Copyright (C) 2012 Victor Levasseur This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages arising from the use of this software. Permission is granted to anyone to use this software for any purpose, including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions: 1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. 2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. 3. This notice may not be removed or altered from any source distribution. */ #ifndef INTERPOLATIONMETHOD_H #define INTERPOLATIONMETHOD_H #include <string> #include <vector> #include <map> #include <math.h> namespace Sk { namespace Anim { /** Interp namespace contains all stuff related to the different interpolation methods to process bones animation. */ namespace Interp { /** Base class for interpolation methods */ class InterpolationMethod { public: InterpolationMethod() {}; virtual ~InterpolationMethod() {}; /** Function calculating the value depending of the progress \param progress : progression between two keyframes (between 0.f and 1.f) \param firstValue : first keyframe value \param secondValue : second keyframe value \return float value between firstValue and secondValue according to progress . */ virtual float GetResult(float progress, float firstValue, float secondValue) const = 0; virtual std::string& GetName() const = 0; }; class Linear : public InterpolationMethod { public: Linear() : InterpolationMethod() {}; virtual float GetResult(float progress, float firstValue, float secondValue) const { return ((secondValue - firstValue) * progress + firstValue); } virtual std::string& GetName() const {static std::string name("Linear"); return name;}; }; class Sinusoidale : public InterpolationMethod { public: Sinusoidale() : InterpolationMethod() {}; virtual float GetResult(float progress, float firstValue, float secondValue) const { return ((secondValue - firstValue) * ((sin(progress * (M_PI) - M_PI/2) + 1) / 2) + firstValue); } virtual std::string& GetName() const {static std::string name("Sinusoidale"); return name;}; }; class Exponential : public InterpolationMethod { public: Exponential() : InterpolationMethod() {}; virtual float GetResult(float progress, float firstValue, float secondValue) const { return ((secondValue - firstValue) * (1 - exp(-progress * 5)) + firstValue); } virtual std::string& GetName() const {static std::string name("Exponential"); return name;}; }; class InvertedExponential : public InterpolationMethod { public: InvertedExponential() : InterpolationMethod() {}; virtual float GetResult(float progress, float firstValue, float secondValue) const { if(progress == 0) return firstValue; else if(progress == 1) return secondValue; return ((secondValue - firstValue) * (exp(progress * 5 - 5)) + firstValue); } virtual std::string& GetName() const {static std::string name("InvertedExponential"); return name;}; }; class Binary : public InterpolationMethod { public: Binary() : InterpolationMethod() {}; virtual float GetResult(float progress, float firstValue, float secondValue) const { return firstValue; } virtual std::string& GetName() const {static std::string name("Binary"); return name;}; }; class Get { public: static inline InterpolationMethod* Method(const std::string &name) { if(name == "Linear") { if(!linearMethod) linearMethod = new Linear(); return linearMethod; } if(name == "Sinusoidale") { if(!progressiveMethod) progressiveMethod = new Sinusoidale(); return progressiveMethod; } if(name == "Exponential") { if(!exponentialMethod) exponentialMethod = new Exponential(); return exponentialMethod; } if(name == "InvertedExponential") { if(!invertedExponentialMethod) invertedExponentialMethod = new InvertedExponential(); return invertedExponentialMethod; } if(name == "Binary") { if(!binaryMethod) binaryMethod = new Binary(); return binaryMethod; } return 0; } static std::vector<std::string> Methods() { std::vector<std::string> list; list.push_back("Linear"); list.push_back("Sinusoidale"); list.push_back("Exponential"); list.push_back("InvertedExponential"); list.push_back("Binary"); return list; } private: static Linear *linearMethod; static Sinusoidale *progressiveMethod; static Exponential *exponentialMethod; static InvertedExponential *invertedExponentialMethod; static Binary *binaryMethod; }; } } } #endif
27.160804
110
0.663645
[ "vector" ]
ef7c247877f82d30b428e3132eb756154e69dbb4
12,668
h
C
dockerfiles/gaas_tutorial_2/GAAS/software/SLAM/ygz_slam_ros/Thirdparty/PCL/ml/include/pcl/ml/regression_variance_stats_estimator.h
hddxds/scripts_from_gi
afb8977c001b860335f9062464e600d9115ea56e
[ "Apache-2.0" ]
2
2019-04-10T14:04:52.000Z
2019-05-29T03:41:58.000Z
software/SLAM/ygz_slam_ros/Thirdparty/PCL/ml/include/pcl/ml/regression_variance_stats_estimator.h
glider54321/GAAS
5c3b8c684e72fdf7f62c5731a260021e741069e7
[ "BSD-3-Clause" ]
null
null
null
software/SLAM/ygz_slam_ros/Thirdparty/PCL/ml/include/pcl/ml/regression_variance_stats_estimator.h
glider54321/GAAS
5c3b8c684e72fdf7f62c5731a260021e741069e7
[ "BSD-3-Clause" ]
1
2021-12-20T06:54:41.000Z
2021-12-20T06:54:41.000Z
/* * Software License Agreement (BSD License) * * Point Cloud Library (PCL) - www.pointclouds.org * Copyright (c) 2010-2011, Willow Garage, Inc. * * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above * copyright notice, this list of conditions and the following * disclaimer in the documentation and/or other materials provided * with the distribution. * * Neither the name of Willow Garage, Inc. nor the names of its * contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * */ #ifndef PCL_ML_REGRESSION_VARIANCE_STATS_ESTIMATOR_H_ #define PCL_ML_REGRESSION_VARIANCE_STATS_ESTIMATOR_H_ #include <pcl/common/common.h> #include <pcl/ml/stats_estimator.h> #include <pcl/ml/branch_estimator.h> #include <istream> #include <ostream> namespace pcl { /** \brief Node for a regression trees which optimizes variance. */ template <class FeatureType, class LabelType> class PCL_EXPORTS RegressionVarianceNode { public: /** \brief Constructor. */ RegressionVarianceNode () : value(0), variance(0), threshold(0), sub_nodes() {} /** \brief Destructor. */ virtual ~RegressionVarianceNode () {} /** \brief Serializes the node to the specified stream. * \param[out] stream The destination for the serialization. */ inline void serialize (std::ostream & stream) const { feature.serialize (stream); stream.write (reinterpret_cast<const char*> (&threshold), sizeof (threshold)); stream.write (reinterpret_cast<const char*> (&value), sizeof (value)); stream.write (reinterpret_cast<const char*> (&variance), sizeof (variance)); const int num_of_sub_nodes = static_cast<int> (sub_nodes.size ()); stream.write (reinterpret_cast<const char*> (&num_of_sub_nodes), sizeof (num_of_sub_nodes)); for (int sub_node_index = 0; sub_node_index < num_of_sub_nodes; ++sub_node_index) { sub_nodes[sub_node_index].serialize (stream); } } /** \brief Deserializes a node from the specified stream. * \param[in] stream The source for the deserialization. */ inline void deserialize (std::istream & stream) { feature.deserialize (stream); stream.read (reinterpret_cast<char*> (&threshold), sizeof (threshold)); stream.read (reinterpret_cast<char*> (&value), sizeof (value)); stream.read (reinterpret_cast<char*> (&variance), sizeof (variance)); int num_of_sub_nodes; stream.read (reinterpret_cast<char*> (&num_of_sub_nodes), sizeof (num_of_sub_nodes)); sub_nodes.resize (num_of_sub_nodes); if (num_of_sub_nodes > 0) { for (int sub_node_index = 0; sub_node_index < num_of_sub_nodes; ++sub_node_index) { sub_nodes[sub_node_index].deserialize (stream); } } } public: /** \brief The feature associated with the node. */ FeatureType feature; /** \brief The threshold applied on the feature response. */ float threshold; /** \brief The label value of this node. */ LabelType value; /** \brief The variance of the labels that ended up at this node during training. */ LabelType variance; /** \brief The child nodes. */ std::vector<RegressionVarianceNode> sub_nodes; }; /** \brief Statistics estimator for regression trees which optimizes variance. */ template <class LabelDataType, class NodeType, class DataSet, class ExampleIndex> class PCL_EXPORTS RegressionVarianceStatsEstimator : public pcl::StatsEstimator<LabelDataType, NodeType, DataSet, ExampleIndex> { public: /** \brief Constructor. */ RegressionVarianceStatsEstimator (BranchEstimator * branch_estimator) : branch_estimator_ (branch_estimator) {} /** \brief Destructor. */ virtual ~RegressionVarianceStatsEstimator () {} /** \brief Returns the number of branches the corresponding tree has. */ inline size_t getNumOfBranches () const { //return 2; return branch_estimator_->getNumOfBranches (); } /** \brief Returns the label of the specified node. * \param[in] node The node which label is returned. */ inline LabelDataType getLabelOfNode ( NodeType & node) const { return node.value; } /** \brief Computes the information gain obtained by the specified threshold. * \param[in] data_set The data set corresponding to the supplied result data. * \param[in] examples The examples used for extracting the supplied result data. * \param[in] label_data The label data corresponding to the specified examples. * \param[in] results The results computed using the specified examples. * \param[in] flags The flags corresponding to the results. * \param[in] threshold The threshold for which the information gain is computed. */ float computeInformationGain ( DataSet & data_set, std::vector<ExampleIndex> & examples, std::vector<LabelDataType> & label_data, std::vector<float> & results, std::vector<unsigned char> & flags, const float threshold) const { const size_t num_of_examples = examples.size (); const size_t num_of_branches = getNumOfBranches(); // compute variance std::vector<LabelDataType> sums (num_of_branches+1, 0); std::vector<LabelDataType> sqr_sums (num_of_branches+1, 0); std::vector<size_t> branch_element_count (num_of_branches+1, 0); for (size_t branch_index = 0; branch_index < num_of_branches; ++branch_index) { branch_element_count[branch_index] = 1; ++branch_element_count[num_of_branches]; } for (size_t example_index = 0; example_index < num_of_examples; ++example_index) { unsigned char branch_index; computeBranchIndex (results[example_index], flags[example_index], threshold, branch_index); LabelDataType label = label_data[example_index]; sums[branch_index] += label; sums[num_of_branches] += label; sqr_sums[branch_index] += label*label; sqr_sums[num_of_branches] += label*label; ++branch_element_count[branch_index]; ++branch_element_count[num_of_branches]; } std::vector<float> variances (num_of_branches+1, 0); for (size_t branch_index = 0; branch_index < num_of_branches+1; ++branch_index) { const float mean_sum = static_cast<float>(sums[branch_index]) / branch_element_count[branch_index]; const float mean_sqr_sum = static_cast<float>(sqr_sums[branch_index]) / branch_element_count[branch_index]; variances[branch_index] = mean_sqr_sum - mean_sum*mean_sum; } float information_gain = variances[num_of_branches]; for (size_t branch_index = 0; branch_index < num_of_branches; ++branch_index) { //const float weight = static_cast<float>(sums[branchIndex]) / sums[numOfBranches]; const float weight = static_cast<float>(branch_element_count[branch_index]) / static_cast<float>(branch_element_count[num_of_branches]); information_gain -= weight*variances[branch_index]; } return information_gain; } /** \brief Computes the branch indices for all supplied results. * \param[in] results The results the branch indices will be computed for. * \param[in] flags The flags corresponding to the specified results. * \param[in] threshold The threshold used to compute the branch indices. * \param[out] branch_indices The destination for the computed branch indices. */ void computeBranchIndices ( std::vector<float> & results, std::vector<unsigned char> & flags, const float threshold, std::vector<unsigned char> & branch_indices) const { const size_t num_of_results = results.size (); const size_t num_of_branches = getNumOfBranches(); branch_indices.resize (num_of_results); for (size_t result_index = 0; result_index < num_of_results; ++result_index) { unsigned char branch_index; computeBranchIndex (results[result_index], flags[result_index], threshold, branch_index); branch_indices[result_index] = branch_index; } } /** \brief Computes the branch index for the specified result. * \param[in] result The result the branch index will be computed for. * \param[in] flag The flag corresponding to the specified result. * \param[in] threshold The threshold used to compute the branch index. * \param[out] branch_index The destination for the computed branch index. */ inline void computeBranchIndex( const float result, const unsigned char flag, const float threshold, unsigned char & branch_index) const { branch_estimator_->computeBranchIndex (result, flag, threshold, branch_index); //branch_index = (result > threshold) ? 1 : 0; } /** \brief Computes and sets the statistics for a node. * \param[in] data_set The data set which is evaluated. * \param[in] examples The examples which define which parts of the data set are used for evaluation. * \param[in] label_data The label_data corresponding to the examples. * \param[out] node The destination node for the statistics. */ void computeAndSetNodeStats ( DataSet & data_set, std::vector<ExampleIndex> & examples, std::vector<LabelDataType> & label_data, NodeType & node) const { const size_t num_of_examples = examples.size (); LabelDataType sum = 0.0f; LabelDataType sqr_sum = 0.0f; for (size_t example_index = 0; example_index < num_of_examples; ++example_index) { const LabelDataType label = label_data[example_index]; sum += label; sqr_sum += label*label; } sum /= num_of_examples; sqr_sum /= num_of_examples; const float variance = sqr_sum - sum*sum; node.value = sum; node.variance = variance; } /** \brief Generates code for branch index computation. * \param[in] node The node for which code is generated. * \param[out] stream The destination for the generated code. */ void generateCodeForBranchIndexComputation ( NodeType & node, std::ostream & stream) const { stream << "ERROR: RegressionVarianceStatsEstimator does not implement generateCodeForBranchIndex(...)"; } /** \brief Generates code for label output. * \param[in] node The node for which code is generated. * \param[out] stream The destination for the generated code. */ void generateCodeForOutput ( NodeType & node, std::ostream & stream) const { stream << "ERROR: RegressionVarianceStatsEstimator does not implement generateCodeForBranchIndex(...)"; } private: /** \brief The branch estimator. */ pcl::BranchEstimator * branch_estimator_; }; } #endif
38.387879
146
0.659852
[ "vector" ]
ef828678c83dbef30904fa4ab9e656a95ffd1c6b
1,301
h
C
games/nogo_state.h
RemiLacroix-IDRIS/Polygames
513a5f9dfca4253950defdf4080f3925483f2873
[ "MIT" ]
270
2020-01-28T22:53:11.000Z
2022-02-21T07:25:13.000Z
games/nogo_state.h
yichqin/Polygames
3568b031b6e1c3aa4e5f4373798b6b542a1ac0ee
[ "MIT" ]
45
2020-01-29T09:55:23.000Z
2021-06-11T18:05:42.000Z
games/nogo_state.h
yichqin/Polygames
3568b031b6e1c3aa4e5f4373798b6b542a1ac0ee
[ "MIT" ]
50
2020-01-29T08:54:22.000Z
2021-10-20T03:04:46.000Z
/** * Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. */ #pragma once #include "game_state.h" #include "nogo_action.h" #include "nogo_bitboard.h" #include <vector> class NoGoState : public GameState { private: NoGoBitBoard bm_board_[2]; std::vector<Position> neighbor_list_[kNOGO_GRIDS_NUM]; Position parent_[kNOGO_GRIDS_NUM]; NoGoBitBoard liberty_[kNOGO_GRIDS_NUM]; NoGoBitBoard illegal_[2]; NoGoBitBoard warning_[2]; // might be suicide NoGoBitBoard liberty_is_one_; public: NoGoState(); void Reset(); bool PlayAction(NoGoAction action); // return success or not NoGoState& operator=(const NoGoState& rhs); void Rotate(SYMMETRYTYPE type); PLAYER GetPlayer(Position position) const; bool IsLegalAction(NoGoAction action); bool IsLegalAction(PLAYER player, Position position); void ShowBoard() const; void ShowLegalMove(PLAYER turn_player); std::string ToString() const; void PrintNeighborNum() const; void PrintLiberty(); void PrintLibertyIsOne(bool check_again = false); void PrintParent(); private: Position FindParent(Position p); void InitNeighborList(); }; #include "nogo_state.cc"
26.55102
72
0.748655
[ "vector" ]
ef83419742703d96d72d83d84f9087e7474eaaef
5,515
h
C
dockerfiles/gaas_tutorial_2/GAAS/software/SLAM/ygz_slam_ros/Thirdparty/PCL/io/include/pcl/io/fotonic_grabber.h
hddxds/scripts_from_gi
afb8977c001b860335f9062464e600d9115ea56e
[ "Apache-2.0" ]
2
2019-04-10T14:04:52.000Z
2019-05-29T03:41:58.000Z
software/SLAM/ygz_slam_ros/Thirdparty/PCL/io/include/pcl/io/fotonic_grabber.h
glider54321/GAAS
5c3b8c684e72fdf7f62c5731a260021e741069e7
[ "BSD-3-Clause" ]
null
null
null
software/SLAM/ygz_slam_ros/Thirdparty/PCL/io/include/pcl/io/fotonic_grabber.h
glider54321/GAAS
5c3b8c684e72fdf7f62c5731a260021e741069e7
[ "BSD-3-Clause" ]
1
2021-12-20T06:54:41.000Z
2021-12-20T06:54:41.000Z
/* * Software License Agreement (BSD License) * * Point Cloud Library (PCL) - www.pointclouds.org * Copyright (c) 2012-, Open Perception, Inc. * * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above * copyright notice, this list of conditions and the following * disclaimer in the documentation and/or other materials provided * with the distribution. * * Neither the name of the copyright holder(s) nor the names of its * contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * */ #include <pcl/pcl_config.h> #ifdef HAVE_FZAPI #ifndef __PCL_IO_FOTONIC_GRABBER__ #define __PCL_IO_FOTONIC_GRABBER__ #include <pcl/io/eigen.h> #include <pcl/io/boost.h> #include <pcl/io/grabber.h> #include <pcl/common/synchronizer.h> #include <boost/thread.hpp> #include <fz_api.h> #include <string> #include <deque> namespace pcl { struct PointXYZ; struct PointXYZRGB; struct PointXYZRGBA; struct PointXYZI; template <typename T> class PointCloud; /** \brief Grabber for Fotonic devices * \author Stefan Holzer <holzers@in.tum.de> * \ingroup io */ class PCL_EXPORTS FotonicGrabber : public Grabber { public: typedef enum { Fotonic_Default_Mode = 0, // This can depend on the device. For now all devices (PSDK, Xtion, Kinect) its VGA@30Hz } Mode; //define callback signature typedefs typedef void (sig_cb_fotonic_point_cloud) (const boost::shared_ptr<const pcl::PointCloud<pcl::PointXYZ> >&); typedef void (sig_cb_fotonic_point_cloud_rgb) (const boost::shared_ptr<const pcl::PointCloud<pcl::PointXYZRGB> >&); typedef void (sig_cb_fotonic_point_cloud_rgba) (const boost::shared_ptr<const pcl::PointCloud<pcl::PointXYZRGBA> >&); typedef void (sig_cb_fotonic_point_cloud_i) (const boost::shared_ptr<const pcl::PointCloud<pcl::PointXYZI> >&); public: /** \brief Constructor * \param[in] device_id ID of the device, which might be a serial number, bus@address or the index of the device. * \param[in] depth_mode the mode of the depth stream * \param[in] image_mode the mode of the image stream */ FotonicGrabber (const FZ_DEVICE_INFO& device_info, const Mode& depth_mode = Fotonic_Default_Mode, const Mode& image_mode = Fotonic_Default_Mode); /** \brief virtual Destructor inherited from the Grabber interface. It never throws. */ virtual ~FotonicGrabber () throw (); /** \brief Initializes the Fotonic API. */ static void initAPI (); /** \brief Exits the Fotonic API. */ static void exitAPI (); /** \brief Searches for available devices. */ static std::vector<FZ_DEVICE_INFO> enumDevices (); /** \brief Start the data acquisition. */ virtual void start (); /** \brief Stop the data acquisition. */ virtual void stop (); /** \brief Check if the data acquisition is still running. */ virtual bool isRunning () const; virtual std::string getName () const; /** \brief Obtain the number of frames per second (FPS). */ virtual float getFramesPerSecond () const; protected: /** \brief On initialization processing. */ void onInit (const FZ_DEVICE_INFO& device_info, const Mode& depth_mode, const Mode& image_mode); /** \brief Sets up an OpenNI device. */ void setupDevice (const FZ_DEVICE_INFO& device_info, const Mode& depth_mode, const Mode& image_mode); /** \brief Continuously asks for data from the device and publishes it if available. */ void processGrabbing (); boost::signals2::signal<sig_cb_fotonic_point_cloud>* point_cloud_signal_; //boost::signals2::signal<sig_cb_fotonic_point_cloud_i>* point_cloud_i_signal_; boost::signals2::signal<sig_cb_fotonic_point_cloud_rgb>* point_cloud_rgb_signal_; boost::signals2::signal<sig_cb_fotonic_point_cloud_rgba>* point_cloud_rgba_signal_; protected: bool running_; FZ_Device_Handle_t * fotonic_device_handle_; boost::thread grabber_thread_; public: EIGEN_MAKE_ALIGNED_OPERATOR_NEW }; } // namespace pcl #endif // __PCL_IO_FOTONIC_GRABBER__ #endif // HAVE_FOTONIC
34.254658
123
0.697008
[ "vector" ]
ef8c4213b4dfe5a0d1f83bea9ec9dde33641cf1f
2,252
h
C
project/OFEC_sc2/instance/algorithm/global/sade/sade.h
BaiChunhui-9803/bch_sc2_OFEC
d50211b27df5a51a953a2475b6c292d00cbfeff6
[ "MIT" ]
null
null
null
project/OFEC_sc2/instance/algorithm/global/sade/sade.h
BaiChunhui-9803/bch_sc2_OFEC
d50211b27df5a51a953a2475b6c292d00cbfeff6
[ "MIT" ]
null
null
null
project/OFEC_sc2/instance/algorithm/global/sade/sade.h
BaiChunhui-9803/bch_sc2_OFEC
d50211b27df5a51a953a2475b6c292d00cbfeff6
[ "MIT" ]
null
null
null
//Register SaDE "SaDE" GOP,ConOP,SOP /****************************************************************************** * Project:Open Frameworks for Evolutionary Computation (OFEC) ******************************************************************************* * Author: Changhe Li and Li Zhou * Email: changhe.lw@gmail.com, 441837060@qq.com * Language: C++ *------------------------------------------------------------------------------- * This file is part of OFEC. This library is free software; * you can redistribute it and/or modify it under the terms of the * GNU General Public License as published by the Free Software * Foundation; either version 2, or (at your option) any later version. * * see https://github.com/Changhe160/OFEC for more information * *********************************************************************************/ // updated Mar 28, 2018 by Li Zhou /* Paper: A. K. Qin, V. L. Huang and P. N. Suganthan, ��Differential evolution with strategy adaptation for global numerical optimization,�� IEEE Transactions on Evolutionary Computation, 13(2): 398- 417, 2009. */ #ifndef OFEC_SADE_H #define OFEC_SADE_H #include <list> #include "../population.h" #include "../../../../core/algorithm/algorithm.h" namespace OFEC { class SaDE_pop final : public DE::population<DE::individual> { public: SaDE_pop(size_t size_pop); EvalTag evolve() override; protected: void update_F(); void update_CR(); void update_memory(); protected: const size_t m_num_strategy = 4; std::vector<Real> mv_F; std::vector<std::vector<Real>> mvv_CR; std::list<std::vector<std::list<Real>>> m_CRsuc; std::vector<Real> m_CRm, m_probability; std::list<std::vector<int>> m_cnt_success, m_cnt_fail; size_t m_LP = 50; Real m_epsilon = 0.01; std::vector<int> m_strategy_selection; //enum Strategy { DE_rand_1_bin = 0, DE_rand_to_best_2_bin, DE_rand_2_bin, DE_current_to_rand_1 }; violation_type m_mode = violation_type::Boundary; }; class SaDE final : public algorithm { public: SaDE(param_map& v); void initialize() override; void record() override; #ifdef OFEC_DEMO void updateBuffer() override {} #endif protected: void run_() override; protected: SaDE_pop m_pop; }; } #endif // OFEC_SADE_H
30.849315
100
0.619893
[ "vector" ]
ef8d1c2143a338ec41e8f6bb2edf760c41bd2d31
2,872
h
C
LibGraphics/SceneGraph/Wm4Attributes.h
wjezxujian/WildMagic4
249a17f8c447cf57c6283408e01009039810206a
[ "BSL-1.0" ]
3
2021-08-02T04:03:03.000Z
2022-01-04T07:31:20.000Z
LibGraphics/SceneGraph/Wm4Attributes.h
wjezxujian/WildMagic4
249a17f8c447cf57c6283408e01009039810206a
[ "BSL-1.0" ]
null
null
null
LibGraphics/SceneGraph/Wm4Attributes.h
wjezxujian/WildMagic4
249a17f8c447cf57c6283408e01009039810206a
[ "BSL-1.0" ]
5
2019-10-13T02:44:19.000Z
2021-08-02T04:03:10.000Z
// Geometric Tools, Inc. // http://www.geometrictools.com // Copyright (c) 1998-2006. All Rights Reserved // // The Wild Magic Version 4 Restricted Libraries source code is supplied // under the terms of the license agreement // http://www.geometrictools.com/License/Wm4RestrictedLicense.pdf // and may not be copied or disclosed except in accordance with the terms // of that agreement. #ifndef WM4ATTRIBUTES_H #define WM4ATTRIBUTES_H #include "Wm4GraphicsLIB.h" #include "Wm4System.h" namespace Wm4 { class WM4_GRAPHICS_ITEM Attributes { public: Attributes (); ~Attributes (); // Set the attributes you want. The currently supported attributes are // p = position // 3 or 4 channels (xyz,xyzw) // n = normal vector // 3 or 4 channels (xyz,xyzw) // ci = color // 1 to 4 channels (r,rg,rgb,rgba) // ti = texture coordinate // 1 to 4 channels (s,st,str,strq) // The attrbitues are organized internally to have the ordering: // p, n, c0, c1, ..., t0, t1, ... void SetPChannels (int iPChannels); void SetNChannels (int iNChannels); void SetCChannels (int iUnit, int iCChannels); void SetTChannels (int iUnit, int iTChannels); // The number of 'float' channels used by all the attributes. int GetChannelQuantity () const; // Access to position information. int GetPOffset () const; int GetPChannels () const; bool HasPosition () const; // Access to normal information. int GetNOffset () const; int GetNChannels () const; bool HasNormal () const; // Access to color information. int GetMaxColors () const; int GetCOffset (int iUnit) const; int GetCChannels (int iUnit) const; bool HasColor (int iUnit) const; // Access to texture coordinate information. int GetMaxTCoords () const; int GetTOffset (int iUnit) const; int GetTChannels (int iUnit) const; bool HasTCoord (int iUnit) const; // Support for comparing vertex program outputs with pixel program inputs. bool Matches (const Attributes& rkAttr, bool bIncludeP, bool bIncludeN, bool bIncludeC, bool bIncludeT) const; // Support for comparing vertex buffer attributes with vertex program // input attributes. bool operator== (const Attributes& rkAttr) const; bool operator!= (const Attributes& rkAttr) const; private: void UpdateOffsets (); // The number of 'float' channels used by all attributes. int m_iChannelQuantity; // positions int m_iPOffset; int m_iPChannels; // normals int m_iNOffset; int m_iNChannels; // colors std::vector<int> m_kCOffset; std::vector<int> m_kCChannels; // texture coordinates std::vector<int> m_kTOffset; std::vector<int> m_kTChannels; }; #include "Wm4Attributes.inl" } #endif
27.352381
78
0.671657
[ "vector" ]
ef97ddc6c10ac8bab2ca25f2be69e47b7e457e6e
834
h
C
src/shapes/Rectangle.h
liushiqi/cpplight
74b81cda58871e0a59e0943bee4cc7cd50ef7529
[ "BSD-3-Clause" ]
null
null
null
src/shapes/Rectangle.h
liushiqi/cpplight
74b81cda58871e0a59e0943bee4cc7cd50ef7529
[ "BSD-3-Clause" ]
null
null
null
src/shapes/Rectangle.h
liushiqi/cpplight
74b81cda58871e0a59e0943bee4cc7cd50ef7529
[ "BSD-3-Clause" ]
null
null
null
// // Created by liu on 17-12-25. // #ifndef CPPLIGHT_RECTANGLE_H #define CPPLIGHT_RECTANGLE_H #include "../utils/Shape.h" class Rectangle : virtual public Shape { private: Point center; Vector halfWidthVector, halfHeightVector; public: Rectangle(const Point &center, const Vector &halfWidth, const Vector &halfHeight, double emissive); Rectangle(const Point &center, double width, double height, double rotate, double emissive); Rectangle(double centerX, double centerY, double width, double height, double rotate, double emissive); ~Rectangle() override; std::set<IntersectPoint> intersect(const Radial &line) const override; long hashCode() const override; bool isInside(const Point &point) const override; }; #endif //CPPLIGHT_RECTANGLE_H
26.0625
111
0.701439
[ "shape", "vector" ]
ef9b10d0bd48559b2ae45a7cd6fecab15edebe1a
1,186
h
C
Kawakawa/Excalibur/RHI/GraphicsMgr.h
Jiaqidesune/KawaiiDesune
6fd5165e08cc7fa3450fd75c0c15eca3279f519f
[ "MIT" ]
null
null
null
Kawakawa/Excalibur/RHI/GraphicsMgr.h
Jiaqidesune/KawaiiDesune
6fd5165e08cc7fa3450fd75c0c15eca3279f519f
[ "MIT" ]
null
null
null
Kawakawa/Excalibur/RHI/GraphicsMgr.h
Jiaqidesune/KawaiiDesune
6fd5165e08cc7fa3450fd75c0c15eca3279f519f
[ "MIT" ]
null
null
null
#pragma once #include "../Interface/IModule.h" #include "VertexBufferBase.h" #include "IndexBufferBase.h" #include "TexturehBase.h" #include "ShaderBase.h" #include "MeshBase.h" #include "assimp/scene.h" #include "assimp/Importer.hpp" #include "assimp/postprocess.h" namespace Excalibur { class GraphicsManager : public ITickableModule { public: virtual int Initialize() noexcept = 0; virtual void Finalize() noexcept = 0; virtual void Present() = 0; virtual void ClearRenderTarget(float r, float g, float b, float a) = 0; virtual std::shared_ptr<VertexBufferBase> CreateVertexBuffer(void* data, int count, VertexFormat vf) = 0; virtual std::shared_ptr<IndexBufferBase> CreateIndexBuffer(void* data, int count) = 0; virtual std::shared_ptr<TextureBase> CreateTexture2D(const std::string& path) = 0; virtual std::shared_ptr<MeshBase> CreateRenderMesh(aiMesh* mesh, const aiScene* world) = 0; virtual void LoadShader() = 0; virtual void UseShader(std::shared_ptr<ShaderBase> shader) = 0; virtual std::shared_ptr<ShaderBase> GetShader(const std::string& name) = 0; protected: std::unordered_map<std::string, std::shared_ptr<ShaderBase>> m_Shaders; }; }
31.210526
107
0.745363
[ "mesh" ]
ef9c68306705f7954366942f1821d97363a87f40
1,514
h
C
sdk/bin/fpkgtool_src/source/Metadata.h
fincs/FeOS
68258965239f2cd74ab545af2f5f0229d335d49b
[ "WTFPL" ]
55
2015-04-01T20:42:55.000Z
2022-02-16T03:00:06.000Z
sdk/bin/fpkgtool_src/source/Metadata.h
shutterbug2000/FeOS
68258965239f2cd74ab545af2f5f0229d335d49b
[ "WTFPL" ]
8
2017-04-05T18:30:12.000Z
2021-05-19T00:48:48.000Z
sdk/bin/fpkgtool_src/source/Metadata.h
shutterbug2000/FeOS
68258965239f2cd74ab545af2f5f0229d335d49b
[ "WTFPL" ]
4
2017-07-05T01:39:41.000Z
2021-11-26T12:13:43.000Z
#pragma once #include "common.h" class MetadataWriter { struct Entry { std::string key, value; int keyPos, valuePos; Entry() : keyPos(0), valuePos(0) { } bool operator < (const Entry& rhs) const { return strcmp(key.c_str(), rhs.key.c_str()) < 0; } void Fixup(int& off) { keyPos = off; off += key.length() + 1; valuePos = off; off += value.length() + 1; } }; int bufSize; std::vector<Entry> v; public: MetadataWriter() : bufSize(0) { } void AddEntry(const char* key, const char* value) { Entry e; e.key = key; std::transform(e.key.begin(), e.key.end(), e.key.begin(), ::tolower); e.value = value; v.push_back(e); } void Preprocess() { std::sort(v.begin(), v.end()); for (auto e = v.begin(); e != v.end(); e ++) (*e).Fixup(bufSize); } int Size() { return 4 + 8*v.size() + bufSize; } void WriteToFile(FileClass& f) { f.WriteWord(v.size()); int q = 8*v.size(); for (auto _e = v.begin(); _e != v.end(); _e ++) { auto e = *_e; f.WriteWord(q + e.keyPos); f.WriteWord(q + e.valuePos); } for (auto _e = v.begin(); _e != v.end(); _e ++) { auto e = *_e; f.WriteRaw(e.key.c_str(), e.key.length() + 1); f.WriteRaw(e.value.c_str(), e.value.length() + 1); } } }; class MetadataParser { MetadataWriter mw; public: void ParseBlob(char* editableBlob); void Add(const char* key, const char* value) { mw.AddEntry(key, value); } int Size() { return mw.Size(); } void Write(FileClass& f) { mw.WriteToFile(f); } };
18.02381
74
0.579921
[ "vector", "transform" ]
efa24a007402bd6fc6029eb30c88e8c81bb86dae
1,947
h
C
engine tests/source/0007_qvGame_Test.h
drr00t/quanticvortex
b780b0f547cf19bd48198dc43329588d023a9ad9
[ "MIT" ]
null
null
null
engine tests/source/0007_qvGame_Test.h
drr00t/quanticvortex
b780b0f547cf19bd48198dc43329588d023a9ad9
[ "MIT" ]
null
null
null
engine tests/source/0007_qvGame_Test.h
drr00t/quanticvortex
b780b0f547cf19bd48198dc43329588d023a9ad9
[ "MIT" ]
null
null
null
#ifndef __GAME_TEST_H_ #define __GAME_TEST_H_ #include "UnitTest++.h" #include "qvGame.h" class TestOrderGameView: public qv::views::AbstractGameView { public: TestOrderGameView( const qv::c8* commandName, qv::u8 gameViewOrder, const qv::views::GVT_GAME_VIEW_TYPE& gameViewType) : qv::views::AbstractGameView(commandName, gameViewOrder, gameViewType), renderCall(0), updateCall(0) { } virtual void render( qv::u32 currentTimeMs, qv::u32 elapsedTimeMs) { renderCall++; } virtual void update( qv::u32 elapsedTimeMs) { updateCall++; } qv::u32 renderCall; //updated when render method was called qv::u32 updateCall; ///update when update method was called }; class TestGame: public qv::Game { public: TestGame() { } ~TestGame() { } }; SUITE(TestGame) { TEST(TestOrderGameView) { static const qv::views::GVT_GAME_VIEW_TYPE GVT_FIRST("GVT_FIRST"); static const qv::views::GVT_GAME_VIEW_TYPE GVT_SECOND("GVT_SECOND"); static const qv::views::GVT_GAME_VIEW_TYPE GVT_THIRD("GVT_THIRD"); TestGame game; game.addGameView<TestOrderGameView>("view_03", qv::u8(3), GVT_THIRD); game.addGameView<TestOrderGameView>("view_01", qv::u8(1), GVT_FIRST); game.addGameView<TestOrderGameView>("view_02", qv::u8(2), GVT_SECOND); bool ordered = true; qv::views::GameViewsArray gameViews = game.getGameViews(); qv::u8 ind = 1; for(qv::views::GameViewsArray::iterator itr = gameViews.begin(); itr != gameViews.end(); itr++) { if(ind != (*itr)->getOrder()) { ordered = false; break; } ind++; } CHECK(ordered); } } #endif // __SHASHED_STRING_TEST_H_
23.457831
122
0.582948
[ "render" ]
d426c0e39a875e3893bdad5b83801f8e33e359ca
29,380
c
C
iguana/iguana_txidfind.c
who-biz/lightning
1eea5d935c623e26a085129e967298113c337feb
[ "MIT" ]
5
2017-12-30T19:20:16.000Z
2019-06-02T04:47:56.000Z
iguana/iguana_txidfind.c
who-biz/lightning
1eea5d935c623e26a085129e967298113c337feb
[ "MIT" ]
5
2021-02-20T02:41:55.000Z
2021-06-01T20:04:08.000Z
iguana/iguana_txidfind.c
who-biz/lightning
1eea5d935c623e26a085129e967298113c337feb
[ "MIT" ]
7
2017-08-25T01:32:54.000Z
2019-01-02T20:40:42.000Z
/****************************************************************************** * Copyright © 2014-2018 The SuperNET Developers. * * * * See the AUTHORS, DEVELOPER-AGREEMENT and LICENSE files at * * the top-level directory of this distribution for the individual copyright * * holder information and the developer policies on copyright and licensing. * * * * Unless otherwise agreed in a custom licensing agreement, no part of the * * SuperNET software, including this file may be copied, modified, propagated * * or distributed except according to the terms contained in the LICENSE file * * * * Removal or modification of this copyright notice is prohibited. * * * ******************************************************************************/ #include "iguana777.h" int32_t iguana_alloctxbits(struct iguana_info *coin,struct iguana_ramchain *ramchain) { static int64_t total; struct iguana_ramchaindata *rdata; if ( (0) && ramchain->txbits == 0 && (rdata= ramchain->H.data) != 0 ) { int32_t tlen; uint8_t *TXbits; TXbits = RAMCHAIN_PTR(rdata,TXoffset); //TXbits = (uint8_t *)((long)rdata + rdata->TXoffset); tlen = (int32_t)hconv_bitlen(rdata->numtxsparse * rdata->txsparsebits); ramchain->txbits = calloc(1,tlen); memcpy(ramchain->txbits,TXbits,tlen); total += tlen; char str[65]; printf("%s alloc.[%d] txbits.%p[%d] total %s\n",coin->symbol,rdata->height/coin->chain->bundlesize,ramchain->txbits,tlen,mbstr(str,total)); return(tlen); } return(-1); } int32_t iguana_alloccacheT(struct iguana_info *coin,struct iguana_ramchain *ramchain) { static int64_t total; struct iguana_ramchaindata *rdata; if ( ramchain->cacheT == 0 && (rdata= ramchain->H.data) != 0 ) { int32_t i,tlen; struct iguana_txid *T; T = RAMCHAIN_PTR(rdata,Toffset); //T = (void *)((long)rdata + rdata->Toffset); tlen = sizeof(*T) * rdata->numtxids; if ( (ramchain->cacheT= calloc(1,tlen)) != 0 ) { //memcpy(ramchain->cacheT,T,tlen); for (i=0; i<rdata->numtxids; i++) ramchain->cacheT[i] = T[i]; } else ramchain->cacheT = T; total += tlen; char str[65]; printf("alloc.[%d] cacheT.%p[%d] total %s\n",rdata->height/coin->chain->bundlesize,ramchain->cacheT,tlen,mbstr(str,total)); return(tlen); } return(-1); } uint32_t iguana_sparseadd(uint8_t *bits,uint32_t ind,int32_t width,uint32_t tablesize,uint8_t *key,int32_t keylen,uint32_t setind,void *refdata,int32_t refsize,struct iguana_ramchain *ramchain,uint32_t maxitems) { static uint8_t masks[8] = { 1, 2, 4, 8, 16, 32, 64, 128 }; struct iguana_ramchaindata *rdata; int32_t i,j,x,n,modval; int64_t bitoffset; uint8_t *ptr; uint32_t *table,retval = 0; if ( tablesize == 0 ) { printf("iguana_sparseadd tablesize zero illegal\n"); return(0); } if ( (0) && setind == 0 ) { char str[65]; for (i=n=0; i<tablesize; i++) { bitoffset = (i * width); ptr = &bits[bitoffset >> 3]; modval = (bitoffset & 7); for (x=j=0; j<width; j++,modval++) { if ( modval >= 8 ) ptr++, modval = 0; x <<= 1; x |= (*ptr & masks[modval]) >> modval; } if ( x != 0 ) printf("%s ",bits256_str(str,*(bits256 *)((long)refdata + x*refsize))), n++; } printf("tableentries.%d\n",n); } //if ( setind == 0 ) // ramchain->sparsesearches++; //else ramchain->sparseadds++; if ( (0) && (rdata= ramchain->H.data) != 0 && (ramchain->sparsesearches % 1000000) == 0 ) printf("[%3d] %7d.[%-2d %8d] %5.3f adds.(%-10ld %10ld) search.(hits.%-10ld %10ld) %5.2f%% max.%ld\n",ramchain->height/rdata->numblocks,ramchain->height,width,tablesize,(double)(ramchain->sparseadditers + ramchain->sparsesearchiters)/(1+ramchain->sparsesearches+ramchain->sparseadds),ramchain->sparseadds,ramchain->sparseadditers,ramchain->sparsehits,ramchain->sparsesearches,100.*(double)ramchain->sparsehits/(1+ramchain->sparsesearches),ramchain->sparsemax+1); if ( width == 32 ) { table = (uint32_t *)bits; for (i=0; i<tablesize; i++,ind++) { if ( ind >= tablesize ) ind = 0; if ( (x= table[ind]) == 0 ) { //if ( ++i > ramchain->sparsemax ) // ramchain->sparsemax = i; if ( (retval= setind) != 0 ) { //ramchain->sparseadditers += i; table[ind] = setind; } //else ramchain->sparsesearchiters += i; return(setind); } else if ( x < maxitems && memcmp((void *)(long)((long)refdata + x*refsize),key,keylen) == 0 ) { if ( setind != 0 && setind != x ) printf("sparseadd index collision setind.%d != x.%d refsize.%d keylen.%d\n",setind,x,refsize,keylen); //ramchain->sparsehits++; //if ( ++i > ramchain->sparsemax ) // ramchain->sparsemax = i; //ramchain->sparseadditers += i; return(x); } } } else { bitoffset = (ind * width); if ( (0) && setind == 0 ) printf("tablesize.%d width.%d bitoffset.%d\n",tablesize,width,(int32_t)bitoffset); for (i=0; i<tablesize; i++,ind++,bitoffset+=width) { if ( ind >= tablesize ) { ind = 0; bitoffset = 0; } x = 0; if ( width == 32 ) memcpy(&x,&bits[bitoffset >> 3],4); else if ( width == 16 ) memcpy(&x,&bits[bitoffset >> 3],2); else if ( width != 8 ) { ptr = &bits[bitoffset >> 3]; modval = (bitoffset & 7); if ( (0) && setind == 0 ) printf("tablesize.%d width.%d bitoffset.%d modval.%d i.%d\n",tablesize,width,(int32_t)bitoffset,modval,i); for (x=j=0; j<width; j++,modval++) { if ( modval >= 8 ) ptr++, modval = 0; x <<= 1; x |= (*ptr & masks[modval]) >> modval; } } else x = bits[bitoffset >> 3]; if ( (0) && setind == 0 ) printf("x.%d\n",x); if ( x == 0 ) { if ( (x= setind) == 0 ) { //ramchain->sparsesearchiters += (i+1); return(0); } //else ramchain->sparseadditers += (i+1); if ( width == 32 ) memcpy(&bits[bitoffset >> 3],&setind,4); else if ( width == 16 ) memcpy(&bits[bitoffset >> 3],&setind,2); else if ( width != 8 ) { ptr = &bits[(bitoffset+width-1) >> 3]; modval = ((bitoffset+width-1) & 7); for (j=0; j<width; j++,x>>=1,modval--) { if ( modval < 0 ) ptr--, modval = 7; if ( (x & 1) != 0 ) *ptr |= masks[modval]; } } else bits[bitoffset >> 3] = setind; if ( (0) ) { for (x=j=0; j<width; j++) { x <<= 1; x |= GETBIT(bits,bitoffset+width-1-j) != 0; } //if ( x != setind ) printf("x.%u vs setind.%d ind.%d bitoffset.%d, width.%d\n",x,setind,ind,(int32_t)bitoffset,width); } //if ( i > ramchain->sparsemax ) // ramchain->sparsemax = i; return(setind); } // fadedreamz@gmail.com #if defined(_M_X64) /* * calculate the address in a portable manner * in all platform sizeof(char) / sizeof(uchar) == 1 * @author - fadedreamz@gmail.com */ else if (x < maxitems && memcmp((void *)((unsigned char *)refdata + x*refsize), key, keylen) == 0) #else else if ( x < maxitems && memcmp((void *)(long)((long)refdata + x*refsize),key,keylen) == 0 ) #endif { if ( setind == 0 ) ramchain->sparsehits++; else if ( setind != x ) printf("sparseadd index collision setind.%d != x.%d refsize.%d keylen.%d\n",setind,x,refsize,keylen); if ( i > ramchain->sparsemax ) ramchain->sparsemax = i; return(x); } } } return(0); } uint32_t iguana_sparseaddtx(uint8_t *bits,int32_t width,uint32_t tablesize,bits256 txid,struct iguana_txid *T,uint32_t txidind,struct iguana_ramchain *ramchain) { uint32_t ind,retval=0; struct iguana_ramchaindata *rdata = ramchain->H.data; if ( tablesize > 0 ) { //char str[65]; printf("sparseaddtx %s txidind.%d bits.%p\n",bits256_str(str,txid),txidind,bits); ind = (txid.ulongs[0] ^ txid.ulongs[1] ^ txid.ulongs[2] ^ txid.ulongs[3]) % tablesize; if ( rdata != 0 && (retval= iguana_sparseadd(bits,ind,width,tablesize,txid.bytes,sizeof(txid),txidind,T,sizeof(*T),ramchain,rdata->numtxids)) != 0 ) { char str[65]; if ( txidind != 0 && retval != txidind ) printf("sparse tx collision %s %u vs %u\n",bits256_str(str,txid),retval,txidind); return(retval); } } return(retval); } uint32_t iguana_sparseaddpk(uint8_t *bits,int32_t width,uint32_t tablesize,uint8_t rmd160[20],struct iguana_pkhash *P,uint32_t pkind,struct iguana_ramchain *ramchain) { uint32_t ind,key2; uint64_t key0,key1; struct iguana_ramchaindata *rdata; if ( (rdata= ramchain->H.data) != 0 && tablesize > 0 ) { //int32_t i; for (i=0; i<20; i++) // printf("%02x",rmd160[i]); //printf(" sparseaddpk pkind.%d bits.%p\n",pkind,bits); memcpy(&key0,rmd160,sizeof(key0)); memcpy(&key1,&rmd160[sizeof(key0)],sizeof(key1)); memcpy(&key2,&rmd160[sizeof(key0) + sizeof(key1)],sizeof(key2)); ind = (key0 ^ key1 ^ key2) % tablesize; return(iguana_sparseadd(bits,ind,width,tablesize,rmd160,20,pkind,P,sizeof(*P),ramchain,rdata->numpkinds)); } else return(0); } int32_t iguana_ramchain_spendtxid(struct iguana_info *coin,uint32_t *unspentindp,bits256 *txidp,struct iguana_txid *T,int32_t numtxids,bits256 *X,int32_t numexternaltxids,struct iguana_spend *s) { uint32_t ind,external; *unspentindp = 0; memset(txidp,0,sizeof(*txidp)); ind = s->spendtxidind; external = (ind >> 31) & 1; ind &= ~(1 << 31); //printf("s.%p ramchaintxid vout.%x spendtxidind.%d isext.%d ext.%d ind.%d\n",s,s->prevout,ind,s->external,external,ind); if ( s->prevout < 0 ) return(-1); if ( s->external != 0 && s->external == external && ind < numexternaltxids ) { //printf("ind.%d X.%p[%d]\n",ind,X,numexternaltxids); *txidp = X[ind]; return(s->prevout); } else if ( s->external == 0 && s->external == external && ind < numtxids ) { *txidp = T[ind].txid; *unspentindp = T[ind].firstvout + s->prevout; return(s->prevout); } return(-2); } struct iguana_txid *iguana_txidfind(struct iguana_info *coin,int32_t *heightp,struct iguana_txid *tx,bits256 txid,int32_t lasthdrsi) { uint8_t *TXbits; struct iguana_txid *T; uint32_t txidind; int32_t i; struct iguana_bundle *bp; struct iguana_ramchain *ramchain; struct iguana_ramchaindata *rdata; //struct iguana_block *block; *heightp = -1; memset(tx,0,sizeof(*tx)); if ( lasthdrsi < 0 ) return(0); for (i=lasthdrsi; i>=0; i--) { if ( (bp= coin->bundles[i]) != 0 && (bp == coin->current || bp->emitfinish > 1) ) { ramchain = &bp->ramchain;//(bp == coin->current) ? &coin->RTramchain : &bp->ramchain; if ( (rdata= ramchain->H.data) != 0 ) { if ( (TXbits= ramchain->txbits) == 0 ) { if ( coin->fastfind == 0 && bp != coin->current ) iguana_alloctxbits(coin,ramchain); if ( (TXbits= ramchain->txbits) == 0 ) { //printf("use memory mapped.[%d]\n",rdata->height/coin->chain->bundlesize); TXbits = RAMCHAIN_PTR(rdata,TXoffset); //TXbits = (void *)(long)((long)rdata + rdata->TXoffset); } } if ( (T= ramchain->cacheT) == 0 ) { //if ( coin->fastfind == 0 ) // iguana_alloccacheT(coin,ramchain); //if ( (T= ramchain->cacheT) == 0 ) T = RAMCHAIN_PTR(rdata,Toffset); //T = (void *)(long)((long)rdata + rdata->Toffset); } if ( (txidind= iguana_sparseaddtx(TXbits,rdata->txsparsebits,rdata->numtxsparse,txid,T,0,ramchain)) > 0 ) { //printf("found txidind.%d\n",txidind); if ( bits256_cmp(txid,T[txidind].txid) == 0 ) { if ( (0) ) { int32_t j; struct iguana_block *block; for (j=0; j<bp->n; j++) if ( (block= bp->blocks[j]) != 0 && txidind >= block->RO.firsttxidind && txidind < block->RO.firsttxidind+block->RO.txn_count ) break; if ( j < bp->n ) { if ( j != T[txidind].bundlei ) printf("bundlei mismatch j.%d != %u\n",j,(uint32_t)T[txidind].bundlei); else { *heightp = bp->bundleheight + T[txidind].bundlei; //printf("found height.%d\n",*heightp); *tx = T[txidind]; return(tx); } } } else { *heightp = bp->bundleheight + T[txidind].bundlei; //printf("found height.%d\n",*heightp); *tx = T[txidind]; //printf("[%d] txidind.%d 1st.(%d %d)\n",bp->hdrsi,txidind,tx->firstvout,tx->firstvin); return(tx); } } char str[65],str2[65]; printf("iguana_txidfind mismatch.[%d:%u] %d %s vs %s\n",bp->hdrsi,(uint32_t)T[txidind].extraoffset,txidind,bits256_str(str,txid),bits256_str(str2,T[txidind].txid)); return(0); } } } } return(0); } int32_t iguana_txidfastfind(struct iguana_info *coin,int32_t *heightp,bits256 txid,int32_t lasthdrsi) { uint8_t *sorted,*item; int32_t i,j,val,num,tablesize,*hashtable; uint32_t firstvout; if ( (sorted= coin->fast[txid.bytes[31]]) != 0 ) { memcpy(&num,sorted,sizeof(num)); memcpy(&tablesize,&sorted[sizeof(num)],sizeof(tablesize)); if ( (hashtable= coin->fasttables[txid.bytes[31]]) == 0 ) { hashtable = (int32_t *)((long)sorted + (1 + num)*16); //printf("backup hashtable\n"); } val = (txid.uints[4] % tablesize); for (j=0; j<tablesize; j++,val++) { if ( val >= tablesize ) val = 0; if ( (i= hashtable[val]) == 0 ) return(0); else { if ( i > num ) { printf("illegal val.%d vs num.%d tablesize.%d fastfind.%02x\n",i,num,tablesize,txid.bytes[31]); return(0); } else { item = (void *)((long)sorted + i*16); if ( memcmp(&txid.txid,item,sizeof(uint64_t)) == 0 ) { memcpy(&firstvout,&item[sizeof(uint64_t)],sizeof(firstvout)); memcpy(heightp,&item[sizeof(uint64_t) + sizeof(firstvout)],sizeof(*heightp)); //printf("i.%d val.%d height.%d firstvout.%d j.%d\n",i,val,*heightp,firstvout,j); if ( *heightp >= (lasthdrsi+1)*coin->chain->bundlesize ) { printf("txidfastfind: unexpected height.%d with lasthdrsi.%d\n",*heightp,lasthdrsi); return(0); } return(firstvout); } else if ( (0) ) { int32_t k; for (k=-16; k<0; k++) printf("%02x ",item[k]); printf("<"); for (k=0; k<16; k++) printf("%02x ",item[k]); printf(">"); for (k=16; k<32; k++) printf("%02x ",item[k]); printf("\n"); printf("txid.%llx vs item.%llx ht.%d 1st.%d\n",(long long)txid.txid,*(long long *)item,*(int32_t *)&item[sizeof(uint64_t)],*(int32_t *)&item[sizeof(uint64_t)+sizeof(uint32_t)]); } } } } } return(0); } int32_t iguana_fastfindadd(struct iguana_info *coin,bits256 txid,int32_t height,uint32_t firstvout) { FILE *fp; if ( bits256_nonz(txid) != 0 && (fp= coin->fastfps[txid.bytes[31]]) != 0 ) { txid.uints[6] = firstvout; txid.uints[7] = height; if ( fwrite(&txid,1,sizeof(txid),fp) == sizeof(txid) ) return(1); } return(0); } int64_t iguana_fastfindinitbundle(struct iguana_info *coin,struct iguana_bundle *bp,int32_t iter) { int32_t i; struct iguana_txid *T; struct iguana_ramchaindata *rdata; int64_t n = 0; if ( (rdata= bp->ramchain.H.data) != 0 ) { T = RAMCHAIN_PTR(rdata,Toffset); //T = (void *)(long)((long)rdata + rdata->Toffset); n = rdata->numtxids; if ( iter == 1 ) { for (i=0; i<n; i++) iguana_fastfindadd(coin,T[i].txid,bp->bundleheight + T[i].bundlei,T[i].firstvout); fprintf(stderr,"[%d:%u] ",bp->hdrsi,(int32_t)n); } } return(n); } static int _bignum_cmp(const void *a,const void *b) { uint8_t *biga,*bigb; int32_t i,diff; biga = (uint8_t *)a; bigb = (uint8_t *)b; for (i=0; i<32; i++) { if ( (diff= (biga[i] - bigb[i])) > 0 ) return(1); else if ( diff < 0 ) return(-1); } return(0); } int32_t iguana_fastfindreset(struct iguana_info *coin) { int32_t i,n = 0; for (i=0; i<0x100; i++) { if ( coin->fast[i] != 0 ) munmap(coin->fast[i],coin->fastsizes[i]), n++; if( coin->fasttables[i] != 0 ) free(coin->fasttables[i]); coin->fast[i] = 0; coin->fastsizes[i] = 0; coin->fasttables[i] = 0; } coin->fastfind = 0; return(n); } uint32_t iguana_fastfindinit(struct iguana_info *coin) { int32_t i,iter,num,tablesize,*hashtable; uint8_t *sorted; char fname[1024]; //if ( strcmp("BTC",coin->symbol) != 0 ) // return(0); if ( coin->fastfind != 0 ) return(coin->fastfind); for (iter=0; iter<2; iter++) { for (i=0; i<0x100; i++) { sprintf(fname,"DB/%s%s/fastfind/%02x.all",iter!=0?"ro/":"",coin->symbol,i), OS_compatible_path(fname); if ( (coin->fast[i]= OS_mapfile(fname,&coin->fastsizes[i],0)) == 0 ) break; else { fprintf(stderr,"."); sorted = coin->fast[i]; if ( (0) ) { coin->fast[i] = calloc(1,coin->fastsizes[i]); memcpy(coin->fast[i],sorted,coin->fastsizes[i]); munmap(sorted,coin->fastsizes[i]); } sorted = coin->fast[i]; memcpy(&num,sorted,sizeof(num)); memcpy(&tablesize,&sorted[sizeof(num)],sizeof(tablesize)); if ( (num+1)*16 + tablesize*sizeof(*hashtable) == coin->fastsizes[i] ) { hashtable = (int32_t *)((long)sorted + (1 + num)*16); if ( (0) ) { coin->fasttables[i] = calloc(tablesize,sizeof(*hashtable)); memcpy(coin->fasttables[i],hashtable,tablesize * sizeof(*hashtable)); } } else { printf("size error num.%d tablesize.%d -> %u vs %ld\n",num,tablesize,(int32_t)((num+1)*16 + tablesize*sizeof(*hashtable)),coin->fastsizes[i]); break; } } } if ( i == 0x100 ) { coin->fastfind = (uint32_t)time(NULL); printf("initialized fastfind.%s iter.%d\n",coin->symbol,iter); return(coin->fastfind); } else iguana_fastfindreset(coin); } return(0); } int64_t iguana_fastfindcreate(struct iguana_info *coin) { int32_t i,j,val,iter,errs,num,ind,tablesize,*hashtable; bits256 *sortbuf,hash2; long allocsize; struct iguana_bundle *bp; char fname[512]; uint8_t buf[16]; int64_t total = 0; if ( coin->current != 0 && coin->bundlescount == coin->current->hdrsi+1 ) { sprintf(fname,"DB/%s/fastfind",coin->symbol), OS_ensure_directory(fname); for (i=0; i<0x100; i++) { sprintf(fname,"DB/%s/fastfind/%02x",coin->symbol,i), OS_compatible_path(fname); if ( (coin->fastfps[i]= fopen(fname,"wb")) == 0 ) break; } if ( i == 0x100 ) { for (iter=0; iter<2; iter++) { total = 0; for (i=0; i<coin->bundlescount-1; i++) if ( (bp= coin->bundles[i]) != 0 ) total += iguana_fastfindinitbundle(coin,bp,iter); printf("iguana_fastfindinit iter.%d total.%lld\n",iter,(long long)total); } for (i=errs=0; i<0x100; i++) { fclose(coin->fastfps[i]), coin->fastfps[i] = 0; sprintf(fname,"DB/%s/fastfind/%02x",coin->symbol,i), OS_compatible_path(fname); //printf("%s\n",fname); if ( (sortbuf= OS_filestr(&allocsize,fname)) != 0 ) { OS_removefile(fname,0); num = (int32_t)allocsize/sizeof(bits256); qsort(sortbuf,num,sizeof(bits256),_bignum_cmp); strcat(fname,".all"); if ( (coin->fastfps[i]= fopen(fname,"wb")) != 0 ) { tablesize = (num << 1); hashtable = calloc(sizeof(*hashtable),tablesize); for (ind=1; ind<=num; ind++) { hash2 = sortbuf[ind-1]; val = (hash2.uints[4] % tablesize); for (j=0; j<tablesize; j++,val++) { if ( val >= tablesize ) val = 0; if ( hashtable[val] == 0 ) { hashtable[val] = ind; break; } } } memset(&hash2,0,sizeof(hash2)); hash2.uints[0] = num; hash2.uints[1] = tablesize; for (j=0; j<=num; j++) { memcpy(buf,&hash2.txid,sizeof(hash2.txid)); memcpy(&buf[sizeof(hash2.txid)],&hash2.uints[6],sizeof(hash2.uints[6])); memcpy(&buf[sizeof(hash2.txid) + sizeof(hash2.uints[6])],&hash2.uints[7],sizeof(hash2.uints[7])); fwrite(buf,1,sizeof(buf),coin->fastfps[i]); //fwrite(hash2,1,sizeof(hash2),coin->fastfps[i]); if ( j < num ) { hash2 = sortbuf[j]; //char str[65]; printf("%d %s\n",j,bits256_str(str,hash2)); } } if ( fwrite(hashtable,sizeof(*hashtable),tablesize,coin->fastfps[i]) == tablesize ) { fclose(coin->fastfps[i]), coin->fastfps[i] = 0; if ( (coin->fast[i]= OS_mapfile(fname,&coin->fastsizes[i],0)) != 0 ) { } else errs++; printf("%s fastfind.[%02x] num.%d tablesize.%d errs.%d %p[%ld]\n",fname,i,num,tablesize,errs,coin->fast[i],coin->fastsizes[i]); } else { printf("error saving (%s)\n",fname); OS_removefile(fname,0); fclose(coin->fastfps[i]), coin->fastfps[i] = 0; } free(hashtable); } else printf("couldnt overwrite (%s)\n",fname); free(sortbuf); } else printf("couldnt load sortbuf (%s)\n",fname); } printf("initialized with errs.%d\n",errs); if ( errs == 0 ) coin->fastfind = (uint32_t)time(NULL); } } return(total); } struct iguana_monitorinfo *iguana_monitorfind(struct iguana_info *coin,bits256 txid) { int32_t i; for (i=0; i<sizeof(coin->monitoring)/sizeof(*coin->monitoring); i++) if ( bits256_cmp(coin->monitoring[i].txid,txid) == 0 ) return(&coin->monitoring[i]); return(0); } struct iguana_monitorinfo *iguana_txidreport(struct iguana_info *coin,bits256 txid,struct iguana_peer *addr) { struct iguana_monitorinfo *ptr; //char str[65]; if ( (ptr= iguana_monitorfind(coin,txid)) != 0 ) { if ( GETBIT(ptr->peerbits,addr->addrind) == 0 ) { char str[65]; printf("%s reports %s\n",addr->ipaddr,bits256_str(str,txid)); SETBIT(ptr->peerbits,addr->addrind); ptr->numreported++; } } // else printf("%s txid.%s not being monitored\n",coin->symbol,bits256_str(str,txid)); return(0); } struct iguana_monitorinfo *iguana_txidmonitor(struct iguana_info *coin,bits256 txid) { int32_t i; struct iguana_monitorinfo *ptr; if ( (ptr= iguana_monitorfind(coin,txid)) == 0 ) { for (i=0; i<sizeof(coin->monitoring)/sizeof(*coin->monitoring); i++) if ( bits256_nonz(coin->monitoring[i].txid) == 0 ) { memset(&coin->monitoring[i],0,sizeof(coin->monitoring[i])); coin->monitoring[i].txid = txid; return(ptr); } } printf("no monitoring slots left\n"); return(0); } double iguana_txidstatus(struct supernet_info *myinfo,struct iguana_info *coin,bits256 txid) { struct iguana_outpoint outpt; int32_t height,firstvout,numranked; struct iguana_monitorinfo *ptr; char str[65]; if ( coin != 0 && coin->peers != 0 && (numranked= coin->peers->numranked) > 0 ) { if ( iguana_RTunspentindfind(myinfo,coin,&outpt,0,0,0,0,&height,txid,0,coin->bundlescount-1,0) == 0 ) { firstvout = outpt.unspentind; if ( (ptr= iguana_monitorfind(coin,txid)) != 0 ) memset(ptr,0,sizeof(*ptr)); return((double)coin->longestchain - height); } if ( (ptr= iguana_monitorfind(coin,txid)) != 0 ) return((double)ptr->numreported / numranked); else { printf("iguana_txidstatus: unexpected missing %s %s\n",coin->symbol,bits256_str(str,txid)); iguana_txidmonitor(coin,txid); } } return(0.); }
42.334294
469
0.468584
[ "3d" ]
d4499a696d54fbc2ed6b4a1e7f5230fbfc6e8384
6,353
h
C
fregl/fregl_joint_register.h
tostathaina/farsight
7e9d6d15688735f34f7ca272e4e715acd11473ff
[ "Apache-2.0" ]
8
2016-07-22T11:24:19.000Z
2021-04-10T04:22:31.000Z
fregl/fregl_joint_register.h
YanXuHappygela/Farsight
1711b2a1458c7e035edd21fe0019a1f7d23fcafa
[ "Apache-2.0" ]
null
null
null
fregl/fregl_joint_register.h
YanXuHappygela/Farsight
1711b2a1458c7e035edd21fe0019a1f7d23fcafa
[ "Apache-2.0" ]
7
2016-07-21T07:39:17.000Z
2020-01-29T02:03:27.000Z
/*========================================================================= Copyright 2009 Rensselaer Polytechnic Institute Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. =========================================================================*/ //: // \file // \brief The engine for joint registration // \author Charlene Tsai // \date 12/05/2007 // // This class makes sure there exists one transformation between // every image pair if one image can be transformed to another image // via a series of pairwise transforms. At the end, only pairs in the // same joint graph have transformations. It is possible that // multiple sub-graph are found in the given dataset. // #ifndef _fregl_joint_register_ #define _fregl_joint_register_ #include "itkAffineTransform.h" #include "itkPoint.h" #include <vector> #include <string> #include <fregl/fregl_reg_record.h> #include <vbl/vbl_array_2d.h> struct correspondence { typedef itk::Point< double, 3> PointType; PointType from_; PointType to_; }; template < class TPixel > class fregl_joint_register: public vbl_ref_count { public: typedef vbl_smart_ptr< fregl_joint_register > Pointer; typedef itk::AffineTransform< double, 3> TransformType; typedef itk::Size<3> SizeType; typedef std::vector< correspondence > CorrespondenceList; //: Constructor taking only one xml_file fregl_joint_register(std::string const & filename, double scale_multiplier = 0, double error_bound = 1); //: Constructor, taking a list of xml filenames of pairwise registratin records fregl_joint_register( std::vector<std::string> const & filenames, double scale_multiplier = 0, double error_bound = 1); //: Constructor, taking a list of pairwise reg records fregl_joint_register( std::vector<fregl_reg_record::Pointer> const& reg_records, double scale_multiplier = 0, double error_bound = 1 ); //: Destructor ~fregl_joint_register(){}; //: Construct the connected graph // // Every image is treated as a node, and a transform is the // edge. The connected graph provides the capability to transform // every image to any image in the graph. void build_graph(); //: Compute the transformation from every image to the chosen anchor bool build_graph(int i); //: Construct the graph without mutual consistency // // exisiting pairwise links are copied over, and // missing linkes are inferred from the exisiting pairwise transforms. void infer_graph(); //: Return the transform of an image pair // // If the transform does not exist, a NULL is returned TransformType::Pointer get_transform(int from_index, int to_index) const; TransformType::Pointer get_transform(std::string from_name, std::string to_name) const; //: Return the list of image names std::vector<std::string> const & image_names() const; //: Return the name of image i std::string const & image_name(int i) const; //: Return the index of the image name // // If the image is not there, it returns -1 int image_index(std::string name) const; //: Return the list of image sizes std::vector<SizeType> const & image_sizes() const; //: Return the size of image i SizeType const & image_size(int i) const; //: Return the number of images unsigned int number_of_images() const; //: Replace the sub-string of the image names // // This function is needed when transformations of a different // channel are required for mosaicking. The old_str in the image // name is replace by the new_str. void replace_image_name_substr(std::string const & old_str, std::string const & new_str); //: Write the result to an xml file void write_xml(std::string const & filename, int sub_graphs_built, bool gen_temp_stuff = false); //: Read the results from an xml file void read_xml(std::string const & filename); //: Return if two images overlap bool is_overlapped(int from, int to) const; //: Return the obj of an image pair // // If the transform does not exist or doesn't overlap, a -1 is returned double get_obj(int from, int to) const; //: Get the registration record fregl_reg_record::Pointer get_reg_record(int from, int to) const; //: Get the error bound double get_error_bound() const; //: Get the list of adjacent images that overlap with the anchor image void get_adjacent_images(std::string anchor_image, std::vector<std::string>& adjacent_images) const; //: Return the number of subgraphs in the joint transformation file int number_of_subgraphs() const; //: Check if two images iare in the same subgraph bool in_same_subgraph(int image_index1, int image_index2) const; private: void initialize(std::vector<fregl_reg_record::Pointer> const & reg_records); // : Build the graph with mutual consistency bool estimate(int anchor); //: Build the graph without mutual consistency // // Transformations are propagrated in breadth_first_search manner void breadth_first_connect( int anchor ); //: Mark images which belong to the same sub-graph as the anchor // // The computation is in breadth_first_search manner void generate_graph_indices( int anchor, int index ); //: Generate_correspondences // // The correspondences are generated assuming that the pairwise // transormations are correct. Points are sampled at a regular // distance in the overlapping area to generate correspondences. void generate_correspondences(); private: vbl_array_2d<TransformType::Pointer> transforms_; // (from,to) vbl_array_2d<double> overlap_; //initially pairwise, finally updated by joint vbl_array_2d<double> obj_; //values from the pairwise registration std::vector<std::string> image_ids_; std::vector< SizeType > image_sizes_; bool corresp_generated_; double scale_multiplier_; double error_bound_; vbl_array_2d< CorrespondenceList > pairwise_constraints_; std::vector<int> graph_indices_; int num_subgraphs_; }; #endif
34.340541
136
0.735715
[ "vector", "transform" ]
d453331db302a66d3e310d0524a25299b498472a
4,450
h
C
simplemd/configurations/DomainConfiguration.h
HSU-HPC/MaMiCo
d6f8597bd41ac3a5d3929c5eb4f7ecbc1b80e2ee
[ "BSD-4-Clause" ]
6
2021-02-06T17:21:10.000Z
2022-01-27T21:36:55.000Z
simplemd/configurations/DomainConfiguration.h
HSU-HPC/MaMiCo
d6f8597bd41ac3a5d3929c5eb4f7ecbc1b80e2ee
[ "BSD-4-Clause" ]
1
2021-06-24T15:17:46.000Z
2021-06-25T11:54:52.000Z
simplemd/configurations/DomainConfiguration.h
HSU-HPC/MaMiCo
d6f8597bd41ac3a5d3929c5eb4f7ecbc1b80e2ee
[ "BSD-4-Clause" ]
6
2021-12-16T11:39:24.000Z
2022-03-28T07:00:30.000Z
// Copyright (C) 2015 Technische Universitaet Muenchen // This file is part of the Mamico project. For conditions of distribution // and use, please see the copyright notice in Mamico's main folder, or at // www5.in.tum.de/mamico #ifndef _MOLECULARDYNAMICS_CONFIGURATIONS_DOMAINCONFIGURATION_H_ #define _MOLECULARDYNAMICS_CONFIGURATIONS_DOMAINCONFIGURATION_H_ #include "simplemd/MolecularDynamicsDefinitions.h" #include "tarch/configuration/Configuration.h" #include "tarch/la/Vector.h" #include <iostream> #include <fstream> namespace simplemd { namespace configurations { class DomainConfiguration; } } /** configuration input for domain description, including domain offset, domain size, boundary types etc. * @author Philipp Neumann */ class simplemd::configurations::DomainConfiguration: public tarch::configuration::Configuration { public: DomainConfiguration(); virtual ~DomainConfiguration(){} void parseSubtag( tinyxml2::XMLElement* node ); /** * Return name of xml tag that is associated to the configuration. */ std::string getTag() const; /** * Is config valid? * * This operation usually fails, if * * - parseSubtag() hasn't been called, i.e. configuration has not been * used, or * - parseSubtag() failed due to a wrong file. * * If a tag ain't optional and parseSubtag() was not called (first case) */ bool isValid() const; /** getters for all parsed and computed quantities */ const tarch::la::Vector<MD_DIM,unsigned int>& getMoleculesPerDirection() const { return _moleculesPerDirection;} const tarch::la::Vector<MD_DIM,double>& getGlobalDomainSize() const { return _domainSize; } const tarch::la::Vector<MD_DIM,double>& getGlobalDomainOffset() const {return _domainOffset;} const double& getCutoffRadius() const { return _cutoffRadius;} const tarch::la::Vector<MD_DIM,double>& getMeshWidth() const { return _meshWidth; } const double& getKB() const { return _kB;} const unsigned int& getBlockSize() const { return _blockSize;} const tarch::la::Vector<MD_LINKED_CELL_NEIGHBOURS,simplemd::BoundaryType>& getBoundary() const { return _boundary; } const std::string& getCheckpointFilestem() const { return _checkpointFilestem;} const bool& initFromCheckpoint() const { return _initFromCheckpoint;} const bool& initFromSequentialCheckpoint() const { return _initFromSequentialCheckpoint;} unsigned int getNumberOfMolecules() const; private: static const std::string MOLECULES_PER_DIRECTION; static const std::string DOMAIN_SIZE; static const std::string DOMAIN_OFFSET; static const std::string CUTOFF_RADIUS; static const std::string LINKED_CELL_SIZE; static const std::string K_B; static const std::string BLOCK_SIZE; static const std::string BOUNDARY[MD_LINKED_CELL_NEIGHBOURS]; static const std::string PERIODIC_BOUNDARY; static const std::string GEOMETRY_BOUNDARY; static const std::string OPEN_BOUNDARY; static const std::string REFLECTING_BOUNDARY; static const std::string RDF_FILENAME; static const std::string CELLS_PER_LINKED_CELL; static const std::string INIT_FROM_CHECKPOINT; static const std::string INIT_FROM_SEQUENTIAL_CHECKPOINT; static const std::string LINKED_CELLS_PER_NUMBER_DENSITY_EVALUATION; /** number of molecules in each direction */ tarch::la::Vector<MD_DIM,unsigned int> _moleculesPerDirection; /** global domain size */ tarch::la::Vector<MD_DIM,double> _domainSize; /** global domain offset */ tarch::la::Vector<MD_DIM,double> _domainOffset; /** cut off radius for lennard jones potential. Determines the meshsize in the simulation. */ double _cutoffRadius; /** size of linked cells. If not handed over in the config, this parameter will be determined automatically */ tarch::la::Vector<MD_DIM,double> _meshWidth; /** dimensionless Boltzmann's constant */ double _kB; /** blocksize to be used for molecule storage */ unsigned int _blockSize; /** boundary types for all outer boundaries */ tarch::la::Vector<MD_LINKED_CELL_NEIGHBOURS,simplemd::BoundaryType> _boundary; std::string _checkpointFilestem; bool _initFromCheckpoint; bool _initFromSequentialCheckpoint; /** isValid flag */ bool _isValid; }; #endif // _MOLECULARDYNAMICS_CONFIGURATIONS_DOMAINCONFIGURATION_H_
38.034188
116
0.735056
[ "vector" ]
d45c4d2486ccbafb7375b558f6aa693462a020df
1,984
h
C
VSProject/HershelPlus/defines.h
zk7/hershelplus
302d5dd8c46d5806ba5082332a0d2a5a9c559c80
[ "BSD-3-Clause" ]
7
2017-11-01T15:16:56.000Z
2021-11-20T07:06:27.000Z
VSProject/HershelPlus/defines.h
zk7/hershelplus
302d5dd8c46d5806ba5082332a0d2a5a9c559c80
[ "BSD-3-Clause" ]
1
2018-05-26T00:52:31.000Z
2018-06-13T17:55:41.000Z
VSProject/HershelPlus/defines.h
zk7/hershelplus
302d5dd8c46d5806ba5082332a0d2a5a9c559c80
[ "BSD-3-Clause" ]
1
2017-10-09T01:05:59.000Z
2017-10-09T01:05:59.000Z
#ifndef CLASSES_H #define CLASSES_H #define OPT_MSS 1 // max segment size #define OPT_WIN 2 // window scaling #define OPT_TS 3 // timestamps #define OPT_SACK 4 // SACK allowed #define OPT_EOL 5 // end of list (another type of padding?) #define OPT_NOP 6 // padding #define REAL_DATA true #ifdef _DEBUG #define NUM_THREADS 1 #else #define NUM_THREADS GetActiveProcessorCount(ALL_PROCESSOR_GROUPS) #endif #include <WinSock2.h> #include <WS2tcpip.h> #include <Windows.h> #include <vector> #include <map> #include <set> #include <chrono> #include <stdlib.h> #pragma comment(lib, "Ws2_32.lib") using namespace std; extern vector<bool> features_enabled; //booleans describing which features are enabled (RTO, WIN, TTL, DF, OPT, MSS, RST) extern map<int, string> id_to_label_map; class Signature{ public: u_int id_classified; u_int id_int; int win; int ttl; int df; int rst; int rst_ack; int rst_win; int rst_seq; int rst_nonzero; int mss; char options_str[25]; unsigned long long options_int; vector<double> packet_arrival_time; vector<double> rto; double secondprob_norm; double maxprob_norm; //double T; //vector<double> owd; Signature(){ win = 0; ttl = 0; df = 0; mss = 0; rst = 0; rst_ack = 0; rst_win = 0; rst_seq = 0; rst_nonzero = 0; options_int = 0; } }; static int factorial(int n){ return (n == 1 || n == 0) ? 1 : factorial(n - 1) * n; } void HershelPlusOptimized_ST(map <u_int, vector<Signature>> database_sigs, vector<Signature> observations); void HershelPlusOptimized_MT(map <u_int, vector<Signature>> database_sigs, vector<Signature> observations); void HershelPlus_ST(map <u_int, vector<Signature>> database_sigs, vector<Signature> observations); void HershelPlus_MT(map<u_int, vector<Signature>> database_sigs, vector<Signature> observations); double MatchConstantFeatures(Signature& target, Signature& dbsig); #endif /* CLASSES_H */
23.619048
122
0.703629
[ "vector" ]
d45f0078560ead0e32df2cf4190f35fce3f5cc93
33,060
h
C
lib/shet.h
18sg/uSHET
c09e0acafd86720efe42dc15c63e0cc228244c32
[ "MIT" ]
37
2015-01-17T12:29:45.000Z
2022-03-22T01:31:48.000Z
lib/shet.h
18sg/uSHET
c09e0acafd86720efe42dc15c63e0cc228244c32
[ "MIT" ]
4
2016-01-18T20:15:01.000Z
2017-05-03T19:30:50.000Z
lib/shet.h
18sg/uSHET
c09e0acafd86720efe42dc15c63e0cc228244c32
[ "MIT" ]
5
2016-01-18T15:12:18.000Z
2019-06-19T02:35:17.000Z
/** * uSHET a microcontroller-friendly implementation of the SHET client protocol. */ #ifndef SHET_H #define SHET_H #include <stdlib.h> #include <stdbool.h> #include "jsmn.h" #ifdef __cplusplus extern "C" { #endif // Utility macro to "use" a variable to stop GCC complaining. #ifndef USE #define USE(x) (void)(x) #endif //////////////////////////////////////////////////////////////////////////////// // Resource allocation constants //////////////////////////////////////////////////////////////////////////////// /** * The number of JSON tokens to allocate in a shet_state_t for parsing a single * message. */ #ifndef SHET_NUM_TOKENS #define SHET_NUM_TOKENS 30 #endif /** * Number of characters in the buffer used to hold outgoing SHET messages for * the transmit callback to read from. */ #ifndef SHET_BUF_SIZE #define SHET_BUF_SIZE 100 #endif /** * Enable debug messages using printf. */ // #define SHET_DEBUG //////////////////////////////////////////////////////////////////////////////// // Types //////////////////////////////////////////////////////////////////////////////// /** * The global state for SHET. */ struct shet_state; typedef struct shet_state shet_state_t; /** * Storage used by setting up a callback. */ struct shet_deferred; typedef struct shet_deferred shet_deferred_t; /** * Storage used by making an event. */ struct shet_event; typedef struct shet_event shet_event_t; /** * A tokenised JSON value. */ typedef struct { // The underlying JSON string. Users should not rely on the whole of this // string being well formed and should only access the parts of it indicated // by the supplied token. char *line; // The JSMN token for the JSON value passed. This token is part of an array of // tokens such that if this token refers to an array or object, the first // element of the array (or first key in the object) will be at token[1] and // so on. jsmntok_t *token; } shet_json_t; /** * All callbacks should be of this type. * * @param state The SHET state object associated with the callback. * @param json The JSON provided to the callback. This may be undefined and, in * this case, must not be accessed. * @param user_data A user-defined pointer chosen when the callback was * registered. */ typedef void (*shet_callback_t)(shet_state_t *state, shet_json_t json, void *user_data); /** * Success status of shet_process_line. */ typedef enum { // The line was handled successfully SHET_PROC_OK = 0, // The line could not be parsed due to insufficient jsmn tokens being // available. Consider increasing SHET_NUM_TOKENS. SHET_PROC_ERR_OUT_OF_TOKENS, // The line could not be parsed due to a JSON syntax error SHET_PROC_INVALID_JSON, // The command received could not be interpreted, e.g. because it didn't // follow the correct format for [id, command_name, ...]. SHET_PROC_MALFORMED_COMMAND, // The command received was not recognised (in this case a error return will // also be sent to the SHET server). SHET_PROC_UNKNOWN_COMMAND, // A return command featured fields with the incorrect types or lengths SHET_PROC_MALFORMED_RETURN, // A command's arguments were of unexpected types or sizes. SHET_PROC_MALFORMED_ARGUMENTS, } shet_processing_error_t; // Since the above types must be accessible to the compiler to allow users to // allocate storage for them they are defined in the following header. End-users // should, however, consider the types defined in this header otherwise opaque. #include "shet_internal.h" //////////////////////////////////////////////////////////////////////////////// // General Library Functions //////////////////////////////////////////////////////////////////////////////// /** * Initialise the SHET global state. This must be called before any other * functions can take place. * * @param state A pointer to an (unused) shet_state_t which is to be * initialised. * @param connection_name Must be a unique JSON structure (as a string) which * uniquely identifies this device and application within * the SHET network. This string must be live for the * full lifetime of the SHET library. * @param transmit A function which will be called to transmit strings generated * by the library to the SHET server. The data argument is a * null-terminated string to transmit which will be live until * the call returns. The user_data argument is a pointer to the * value defined by transmit_user_data below. Note that the user * is responsible for ensuring reliable delivery. * @param transmit_user_data A user-defined pointer which will be passed to the * transmit callback. */ void shet_state_init(shet_state_t *state, const char *connection_name, void (*transmit)(const char *data, void *user_data), void *transmit_user_data); /** * Set the unhandled error callback. This callback will be called whenever a * callback has been registered but whenever the callback function defined is * NULL. * * Note that this function is intended as a catch-all SHET-reported error * handler. This means that is not called due to actual errors e.g. in the event * of protocol violations, unexpected or unhandled commands. * * @param state The global SHET state. * @param callback The callback function to use for unhandled errors. Set to * NULL to disable. The JSON value is undefined. * @param callback_arg User defined data to be passed to the callback. */ void shet_set_error_callback(shet_state_t *state, shet_callback_t callback, void *callback_arg); /** * Re-register the client with the server. This command should be called * whenever the client re-connects to the SHET server. The command forces the * server to forget all held state for the previous connection and then * re-reigsters all watches, properties, actions and events. * * @param state The global SHET state. */ void shet_reregister(shet_state_t *state); /** * Process a single message from the SHET server. This function expects exactly * one (\n delimited) line of data from the server. Note that the caller is * responsible for ensuring that the data passed to this function has not * suffered any ommisions or corruption. * * @param state The global SHET state. * @param line A buffer containing the line to process. Note that the data in * the buffer may be corrupted by SHET. This string need only remain * live until the call to shet_process_line returns. The string * need not be null-terminated. The string need not contain a * trailing newline. * @param line_length The number of characters in the line (not including an * optional null-terminator). * @return Returns a shet_processing_error_t indicating what, if anything, went * wrong when processing the provided input line. */ shet_processing_error_t shet_process_line(shet_state_t *state, char *line, size_t line_length); /** * Ping the SHET server. * * @param state The global SHET state. * @param args A value to send to the server to echo. A series of * comma-delimited JSON values represented seperated by a string. * Must contain at least one value or be NULL. * @param deferred A pointer to a deferred_t struct responsible for this * callback. This struct must remain live until either a * callback function is called or shet_cancel_deferred is called * by the user. * @param callback Callback function on (successful) ping response. The passed * JSON should be an array containing the ping's args. May be * NULL to ignore the callback. * @param err_callback Callback function on unsuccessful ping response. May be * NULL to ignore the callback. * @param callback_arg User-defined pointer to be passed to the callback and * err_callback functions. */ void shet_ping(shet_state_t *state, const char *args, shet_deferred_t *deferred, shet_callback_t callback, shet_callback_t err_callback, void *callback_arg); /** * For use within (certain) callback functions only. Return a value to SHET, for * example, returing a value from an action's "call" callback. * * Note that this function can only be called from within the callback function * expecting the return response. See shet_return_with_id and shet_get_return_id * if a return must be postponed until later. * * @param state The global SHET state. * @param success Success indicator. 0 for success, anything else for failure. * @param value A valid JSON string containing a single value. If NULL, the * JSON primitive null will be sent. This string need only be live * until shet_return returns. */ void shet_return(shet_state_t *state, int success, const char *value); /** * Return a value to SHET. Unlike shet_return_with_id, this function may be used * at a later time, outside of the relevant callback function. * * See shet_get_return_id for detalis of how to get an ID to pass to this * function. * * @param state The global SHET state. * @param id The ID of the request to be returned. This must be a * (null-terminated) string containing a valid JSON value. This string * need only be live until shet_return_with_id returns. * @param success Success indicator. 0 for success, anything else for failure. * @param value A valid JSON string containing a single value. If NULL, the * JSON primitive null will be sent. This string need only be live * until shet_return_with_id returns. */ void shet_return_with_id(shet_state_t *state, const char *id, int success, const char *value); /** * Get the string containing the JSON for the return ID for the current callback * suitable for use with shet_return_with_id. This should be copied by the user * if this ID is required after the callback function ends. * * @param state The global SHET state. * @return Returns a pointer to a string containg a JSON value repreesnting the * return ID for the current callback. This string is live until the end * of the callback function and should be copied if required afterwards. */ const char *shet_get_return_id(shet_state_t *state); /** * Cancel all future callbacks associated with a shet_deferred_t. This function * is primarily intended use in simple timeout mechanisms. After calling this * function the shet_deferred_t may be reused for another purpose. * * This function should not be used to ignore watched events or remove * registered actions, properties or events. Doing this will result in undefined * behaviour. * * This function can safely be called with deferreds which have never * been used or which no future callbacks are possible. * * @param state The global SHET state. * @param deferred The deferred to unregister. */ void shet_cancel_deferred(shet_state_t *state, shet_deferred_t *deferred); //////////////////////////////////////////////////////////////////////////////// // Action Functions //////////////////////////////////////////////////////////////////////////////// /** * Make a new action in the SHET tree. * * @param state The global SHET state. * @param path A valid, null-terminated SHET path name. This string must remain * live as long as the action remains registered. * @param action_deferred A pointer to a deferred_t struct responsible for * action callbacks. This struct must remain live until * the action is removed. * @param callback Callback function which implements the action. This function * should receive a (possibly empty) JSON array containing * arguments for the call. This function must return success and * optionally a value to SHET e.g. using shet_return. * @param action_arg User-defined pointer to be passed to the callback. * @param mkaction_deferred A pointer to a deferred_t struct responsible for * action creation callbacks. This struct must remain * live until the action is removed. If NULL no * callbacks will be registered for the action's * creation. * @param mkaction_callback Callback function on successful action creation. * This may be called multiple times, for example, * after shet_reregister. NULL if unused. * @param mkaction_err_callback Callback function on unsuccessful action * creation. This may be called multiple times, * for example, after shet_reregister. NULL if * unused. * @param mkaction_arg User-defined pointer to be passed to the action creation * callbacks. */ void shet_make_action(shet_state_t *state, const char *path, shet_deferred_t *action_deferred, shet_callback_t callback, void *action_arg, shet_deferred_t *mkaction_deferred, shet_callback_t mkaction_callback, shet_callback_t mkaction_err_callback, void *mkaction_callback_arg); /** * Remove an action and cancel any associated deferreds. * * @param state The global SHET state. * @param path The null-terminated SHET path name of the action created with * shet_make_action which will be removed. * @param deferred A pointer to a deferred_t struct responsible for action * removal callbacks. This struct must remain live until one of * its callbacks is called or shet_cancel_deferred is called by * the user. The deferreds associated with the creation of the * action may be reused if desired. If NULL no callbacks will be * registered for the action's removal. * @param callback Callback function on successful action removal. After this * occurrs, the deferred can be considered cancelled. NULL if * unused. * @param err_callback Callback function on unsuccessful action removal. After * this occurrs, the deferred can be considered cancelled. * NULL if unused. * @param callback_arg User-defined pointer to be passed to the action removal * callbacks. */ void shet_remove_action(shet_state_t *state, const char *path, shet_deferred_t *deferred, shet_callback_t callback, shet_callback_t err_callback, void *callback_arg); /** * Call an action via SHET. * * @param state The global SHET state. * @param path A valid, null-terminated SHET path name. This string must remain * live until this function returms. * @param args A null-terminated, comma-seperated string of JSON values to use * as arguments to the call. Use NULL if no argument is desired. * Must remain live until this function returns. * @param deferred A pointer to a deferred_t struct responsible for the response * callbacks. This struct must remain live until the call * returns or shet_cancel_deferred is called by the user. * @param callback Callback function on successful execution of the call. The * argument will be a single JSON value representing the value * returned by the call. When this callback occurrs, the * deferred can be considered cancelled. NULL if unused. * @param err_callback Callback function on unsuccessful execution of the call. * When this callback occurrs, the deferred can be * considered cancelled. NULL if unused. * @param callback_arg User-defined pointer to be passed to the callbacks. */ void shet_call_action(shet_state_t *state, const char *path, const char *args, shet_deferred_t *deferred, shet_callback_t callback, shet_callback_t err_callback, void *callback_arg); //////////////////////////////////////////////////////////////////////////////// // Property Functions //////////////////////////////////////////////////////////////////////////////// /** * Make a new property in the SHET tree. * * @param state The global SHET state. * @param path A valid, null-terminated SHET path name. This string must remain * live as long as the property remains registered. * @param prop_deferred A pointer to a deferred_t struct responsible for * property callbacks. This struct must remain live until * the property is removed. * @param get_callback Callback function which gets the value of the property. * This function must return the value to SHET e.g. using * shet_return. The JSON passed is undefined. * @param set_callback Callback function which sets the value of the property. * This should be given a JSON array which contains a single * JSON value to set as the value of the property. This * function must return success to SHET e.g. using * shet_return. * @param prop_arg User-defined pointer to be passed to the get/set callbacks. * @param mkprop_deferred A pointer to a deferred_t struct responsible for * property creation callbacks. This struct must remain * live until the property is removed. If NULL no * callbacks will be registered for the property's * creation. * @param mkprop_callback Callback function on successful property creation. * This may be called multiple times, for example, after * shet_reregister. NULL if unused. * @param mkprop_err_callback Callback function on unsuccessful property * creation. This may be called multiple times, for * example, after shet_reregister. NULL if unused. * @param mkprop_arg User-defined pointer to be passed to the property creation * callbacks. */ void shet_make_prop(shet_state_t *state, const char *path, shet_deferred_t *prop_deferred, shet_callback_t get_callback, shet_callback_t set_callback, void *prop_arg, shet_deferred_t *mkprop_deferred, shet_callback_t mkprop_callback, shet_callback_t mkprop_err_callback, void *mkprop_callback_arg); /** * Remove a property and cancel any associated deferreds. * * @param state The global SHET state. * @param path The null-terminated SHET path name of the property created with * shet_make_prop which will be removed. * @param deferred A pointer to a deferred_t struct responsible for property * removal callbacks. This struct must remain live until one of * its callbacks is called or shet_cancel_deferred is called by * the user. The deferreds associated with the creation of the * property may be reused if desired. If NULL no callbacks will * be registered for the property's removal. * @param callback Callback function on successful property removal. After this * occurrs, the deferred can be considered cancelled. NULL if * unused. * @param err_callback Callback function on unsuccessful property removal. After * this occurrs, the deferred can be considered cancelled. * NULL if unused. * @param callback_arg User-defined pointer to be passed to the property removal * callbacks. */ void shet_remove_prop(shet_state_t *state, const char *path, shet_deferred_t *deferred, shet_callback_t callback, shet_callback_t err_callback, void *callback_arg); /** * Get a property's value via SHET. * * @param state The global SHET state. * @param path A valid, null-terminated SHET path name. This string must remain * live until this function returms. * @param deferred A pointer to a deferred_t struct responsible for the response * callbacks. This struct must remain live until the get * returns or shet_cancel_deferred is called by the user. * @param callback Callback function on successful getting of the property. The * callback should be given a JSON array containing a single * JSON value representing the value of the property. When this * callback occurrs, the deferred can be considered cancelled. * @param err_callback Callback function on unsuccessful getting of the * property. When this callback occurrs, the deferred can be * considered cancelled. NULL if unused. * @param callback_arg User-defined pointer to be passed to the callbacks. */ void shet_get_prop(shet_state_t *state, const char *path, shet_deferred_t *deferred, shet_callback_t callback, shet_callback_t err_callback, void *callback_arg); /** * Set a property's value via SHET. * * @param state The global SHET state. * @param path A valid, null-terminated SHET path name. This string must remain * live until this function returms. * @param value A single JSON value as a null-terminated string to set the value * to. Must remain live until this function returns. * @param deferred A pointer to a deferred_t struct responsible for the response * callbacks. This struct must remain live until the set * returns or shet_cancel_deferred is called by the user. * @param callback Callback function on successful setting of the property. When * this callback occurrs, the deferred can be considered * cancelled. NULL if unused. * @param err_callback Callback function on unsuccessful setting of the * property. When this callback occurrs, the deferred can be * considered cancelled. NULL if unused. * @param callback_arg User-defined pointer to be passed to the callbacks. */ void shet_set_prop(shet_state_t *state, const char *path, const char *value, shet_deferred_t *deferred, shet_callback_t callback, shet_callback_t err_callback, void *callback_arg); //////////////////////////////////////////////////////////////////////////////// // Event Functions //////////////////////////////////////////////////////////////////////////////// /** * Make a new event in the SHET tree. * * @param state The global SHET state. * @param path A valid, null-terminated SHET path name. This string must remain * live as long as the event remains registered. * @param event An unused shet_event_t which represents the registration of the * event. This must remain live as long as th event remains * registered. * @param mkevent_deferred A pointer to a deferred_t struct responsible for * event creation callbacks. This struct must remain * live until the event is removed. If NULL no callbacks * will be registered for the event's creation. * @param mkevent_callback Callback function on successful event creation. This * may be called multiple times, for example, after * shet_reregister. NULL if unused. * @param mkevent_err_callback Callback function on unsuccessful property * creation. This may be called multiple times, for * example, after shet_reregister. NULL if unused. * @param mkevent_arg User-defined pointer to be passed to the property creation * callbacks. */ void shet_make_event(shet_state_t *state, const char *path, shet_event_t *event, shet_deferred_t *mkevent_deferred, shet_callback_t mkevent_callback, shet_callback_t mkevent_error_callback, void *mkevent_callback_arg); /** * Remove an event and cancel any associated deferreds. * * @param state The global SHET state. * @param path The null-terminated SHET path name of the event created with * shet_make_event which will be removed. * @param deferred A pointer to a deferred_t struct responsible for event * removal callbacks. This struct must remain live until one of * its callbacks is called or shet_cancel_deferred is called by * the user. The deferreds associated with the creation of the * event may be reused if desired. If NULL no callbacks will * be registered for the event's removal. * @param callback Callback function on successful event removal. After this * occurrs, the deferred can be considered cancelled. NULL if * unused. * @param err_callback Callback function on unsuccessful event removal. After * this occurrs, the deferred can be considered cancelled. * NULL if unused. * @param callback_arg User-defined pointer to be passed to the event removal * callbacks. */ void shet_remove_event(shet_state_t *state, const char *path, shet_deferred_t *deferred, shet_callback_t callback, shet_callback_t error_callback, void *callback_arg); /** * Raise an event. * * @param state The global SHET state. * @param path The null-terminated SHET path name to raise an event for. This * must remain live until the call returns. * @param value A null-terminated, comman-seperated string of JSON values * representing the event value(s) or NULL if there is no value. * This must remain live until the call returns. * @param deferred A pointer to a deferred_t struct responsible for event * raise callbacks. This struct must remain live until one of * its callbacks is called or shet_cancel_deferred is called by * the user. The deferreds associated with the creation of the * event may be reused if desired. If NULL no callbacks will * be registered for the event's removal. * @param callback Callback function on successful event raise. After this * occurrs, the deferred can be considered cancelled. NULL if * unused. * @param err_callback Callback function on unsuccessful event raise. After * this occurrs, the deferred can be considered cancelled. * NULL if unused. * @param callback_arg User-defined pointer to be passed to the event raise * callbacks. */ void shet_raise_event(shet_state_t *state, const char *path, const char *value, shet_deferred_t *deferred, shet_callback_t callback, shet_callback_t error_callback, void *callback_arg); /** * Watch an event in the SHET tree. * * @param state The global SHET state. * @param path A valid, null-terminated SHET path name. This string must remain * live as long as the event remains watched. * @param event_deferred A pointer to a deferred_t struct responsible for * event callbacks. This struct must remain live until * the event is removed. * @param event_callback Callback function called whenever the event fires. * This is given a (possibly empty) JSON array of values * indicating the value of the event. This function must * return success to SHET e.g. using shet_return. NULL if * unused. * @param created_callback Callback function called whenever the event is * created in the SHET tree. This function must return * success to SHET e.g. using shet_return. NULL if * unused. The passed JSON is undefined. * @param deleted_callback Callback function called whenever the event is * deleted in the SHET tree. This function must return * success to SHET e.g. using shet_return. NULL if * unused. The passed JSON is undefined. * @param event_arg User-defined pointer to be passed to the event callbacks. * @param watch_deferred A pointer to a deferred_t struct responsible for * event watching callbacks. This struct must remain live * until the event is ignored. If NULL no callbacks will * be registered for the events's watching. * @param watch_callback Callback function on successful event watching. * This may be called multiple times, for example, after * shet_reregister. NULL if unused. * @param watch_err_callback Callback function on unsuccessful event watching. * This may be called multiple times, for example, * after shet_reregister. NULL if unused. * @param watch_arg User-defined pointer to be passed to the event watching * callbacks. */ void shet_watch_event(shet_state_t *state, const char *path, shet_deferred_t *event_deferred, shet_callback_t event_callback, shet_callback_t created_callback, shet_callback_t deleted_callback, void *event_arg, shet_deferred_t *watch_deferred, shet_callback_t watch_callback, shet_callback_t watch_error_callback, void *watch_callback_arg); /** * Ignore a watched event and cancel any associated deferreds. * * @param state The global SHET state. * @param path The null-terminated SHET path name of the event watched with * shet_watch_event which will be ignored. * @param deferred A pointer to a deferred_t struct responsible for event ignore * callbacks. This struct must remain live until one of its * callbacks is called or shet_cancel_deferred is called by the * user. The deferreds associated with the creation of the * watch may be reused if desired. If NULL no callbacks will * be registered for the ignore. * @param callback Callback function on successful event ignore. After this * occurrs, the deferred can be considered cancelled. NULL if * unused. * @param err_callback Callback function on unsuccessful event ignore. After * this occurrs, the deferred can be considered cancelled. * NULL if unused. * @param callback_arg User-defined pointer to be passed to the event ignoring * callbacks. */ void shet_ignore_event(shet_state_t *state, const char *path, shet_deferred_t *deferred, shet_callback_t callback, shet_callback_t error_callback, void *callback_arg); #ifdef __cplusplus } #endif #endif
46.044568
95
0.623321
[ "object" ]
d460d0e5442c6a8a6700e60c0f67ebe08836da24
100,929
c
C
iFKO/FKO/src/optreg.c
kevleyski/math-atlas
cc36aa7e0362c577739ac507378068882834825e
[ "BSD-3-Clause-Clear" ]
135
2015-01-08T20:35:35.000Z
2022-03-31T02:26:28.000Z
iFKO/FKO/src/optreg.c
kevleyski/math-atlas
cc36aa7e0362c577739ac507378068882834825e
[ "BSD-3-Clause-Clear" ]
25
2015-01-13T15:19:26.000Z
2021-06-05T20:00:27.000Z
iFKO/FKO/src/optreg.c
kevleyski/math-atlas
cc36aa7e0362c577739ac507378068882834825e
[ "BSD-3-Clause-Clear" ]
34
2015-01-11T01:24:51.000Z
2021-04-19T17:44:02.000Z
/* * Copyright (C) 2003, 2004, 2015 R. Clint Whaley. * Code contributers : R. Clint Whaley, Majedul Sujon. */ #include <fko.h> #include <fko_arch.h> static IGNODE **IG=NULL; static int NIG=0, TNIG=0; void DumpIG(FILE *fpout, int N, IGNODE **igs); int ireg2type(int ireg) { int iret; iret = -1; if (ireg >= IREGBEG && ireg < IREGEND) iret = T_INT; else if (ireg >= FREGBEG && ireg < FREGEND) iret = T_FLOAT; else if (ireg >= DREGBEG && ireg < DREGEND) iret = T_DOUBLE; #ifdef VFREGBEG else if (ireg >= VFREGBEG && ireg < VFREGEND) iret = T_VFLOAT; #endif #ifdef VDREGBEG else if (ireg >= VDREGBEG && ireg < VDREGEND) iret = T_VDOUBLE; #endif #ifdef VIREGBEG else if (ireg >= VIREGBEG && ireg < VIREGEND) iret = T_VINT; #endif return(iret); } short Reg2Int(char *regname) /* * Given a register of regname, returns integer number */ { int i; if (regname[0] == 'P' && regname[1] == 'C' && regname[2] == '\0') return(-PCREG); if (regname[0] == 'S' && regname[1] == 'P' && regname[2] == '\0') return(-REG_SP); for (i=IREGBEG; i < IREGEND; i++) if (!strcmp(archiregs[i-IREGBEG], regname)) return(-i); for (i=FREGBEG; i < FREGEND; i++) if (!strcmp(archfregs[i-FREGBEG], regname)) return(-i); for (i=DREGBEG; i < DREGEND; i++) if (!strcmp(archdregs[i-DREGBEG], regname)) return(-i); #ifdef VFREGBEG for (i=VFREGBEG; i < VFREGEND; i++) if (!strcmp(archvfregs[i-VFREGBEG], regname)) return(-i); #endif #ifdef VDREGBEG for (i=VDREGBEG; i < VDREGEND; i++) if (!strcmp(archvdregs[i-VDREGBEG], regname)) return(-i); #endif #ifdef VIREGBEG for (i=VIREGBEG; i < VIREGEND; i++) if (!strcmp(archviregs[i-VIREGBEG], regname)) return(-i); #endif for (i=ICC0; i < NICC; i++) if (!strcmp(ICCREGS[i], regname)) return(-i); for (i=FCC0; i < NFCC; i++) if (!strcmp(FCCREGS[i], regname)) return(-i); return(0); } int NumberArchRegs() { return(TNREG); } char *Int2Reg0(int i) /* * Translates integral encoding to machine-specific registers */ { static char ln[128]; char *ret=ln; assert (i < 0); i = -i; if (i >= IREGBEG && i < IREGEND) sprintf(ln, "%s", archiregs[i-IREGBEG]); else if (i >= FREGBEG && i < FREGEND) sprintf(ln, "%s", archfregs[i-FREGBEG]); else if (i >= DREGBEG && i < DREGEND) sprintf(ln, "%s", archdregs[i-DREGBEG]); else if (i >= ICCBEG && i < ICCEND) sprintf(ln, "%s", ICCREGS[i-ICCBEG]); else if (i >= FCCBEG && i < FCCEND) sprintf(ln, "%s", FCCREGS[i-FCCBEG]); else if (i == PCREG) sprintf(ln, "%s", "PC"); #ifdef VFREGBEG else if (i >= VFREGBEG && i < VFREGEND) sprintf(ln, "%s", archvfregs[i-VFREGBEG]); #endif #ifdef VDREGBEG else if (i >= VDREGBEG && i < VDREGEND) sprintf(ln, "%s", archvdregs[i-VDREGBEG]); #endif #ifdef VIREGBEG else if (i >= VIREGBEG && i < VIREGEND) sprintf(ln, "%s", archviregs[i-VIREGBEG]); #endif else ret = NULL; return(ret); } char *Int2Reg(int i) /* * Translates integral encoding to machine-specific registers */ { char *ret; ret = Int2Reg0(i); if (!ret) { fprintf(stderr, "I=[%d,%d); F=[%d,%d); D=[%d,%d); ICC=[%d,%d); FCC=[%d,%d); PC=%d\n", IREGBEG, IREGEND,FREGBEG, FREGEND,DREGBEG, DREGEND, ICCBEG, ICCEND, FCCBEG, FCCEND, PCREG); fko_error(__LINE__, "Unknown register index %d, file=%s\n", i, __FILE__); } return(ret); } void SetAllTypeReg(INT_BVI iv, int type) /* * Modify regstate iv to set all registers of type type to 1, leaving the rest * of the state unchanged */ { int i, ibeg, iend; switch(type) { #ifdef X86_64 case T_SHORT: #endif case T_INT: ibeg = IREGBEG; iend = IREGEND; break; case T_FLOAT: ibeg = FREGBEG; iend = FREGEND; break; #ifdef ArchHasVec case T_VFLOAT: ibeg = VFREGBEG; iend = VFREGEND; break; case T_DOUBLE: ibeg = DREGBEG; iend = DREGEND; break; case T_VDOUBLE: ibeg = VDREGBEG; iend = VDREGEND; break; case T_VINT: ibeg = VIREGBEG; iend = VIREGEND; break; #endif default: fko_error(__LINE__, "unknown type %d, file=%s\n", type, __FILE__); } for (i=ibeg; i < iend; i++) SetVecBit(iv, i-1, 1); } int Reg2Regstate(int k) /* * Given register k, set regstate so that all registers used by k are * represented (i.e., on some archs, float and double regs are aliased) * RETURNS: bitvec with appropriate register numbers set */ { static INT_BVI iv=0; #ifdef SPARC int i; #endif if (k <= 0) { if (iv) KillBitVec(iv); iv = 0; } else { if (!iv) iv = NewBitVec(TNREG); SetVecAll(iv, 0); SetVecBit(iv, k-1, 1); if (k >= FREGBEG && k < FREGEND) { #if defined(X86) || defined(PPC) SetVecBit(iv, k-FREGBEG+DREGBEG-1, 1); #ifdef X86 SetVecBit(iv, k-FREGBEG+VDREGBEG-1, 1); SetVecBit(iv, k-FREGBEG+VFREGBEG-1, 1); #ifdef VIREGBEG SetVecBit(iv, k-FREGBEG+VIREGBEG-1, 1); #endif #endif #elif defined(SPARC) SetVecBit(iv, ((k-FREGBEG)>>1)+DREGBEG-1, 1); #endif } else if (k >= DREGBEG && k < DREGEND) { #if defined(X86) || defined(PPC) SetVecBit(iv, k-DREGBEG+FREGBEG-1, 1); #ifdef X86 SetVecBit(iv, k-DREGBEG+VDREGBEG-1, 1); SetVecBit(iv, k-DREGBEG+VFREGBEG-1, 1); #ifdef VIREGBEG SetVecBit(iv, k-DREGBEG+VIREGBEG-1, 1); #endif #endif #elif defined(SPARC) i = k - DREGBEG; if (i < 16) { SetVecBit(iv, FREGBEG+i*2-1, 1); SetVecBit(iv, FREGBEG+i*2, 1); } #endif } #ifdef X86 else if (k >= VFREGBEG && k < VFREGEND) { SetVecBit(iv, k-VFREGBEG+VDREGBEG-1, 1); SetVecBit(iv, k-VFREGBEG+FREGBEG-1, 1); SetVecBit(iv, k-VFREGBEG+DREGBEG-1, 1); #ifdef VIREGBEG SetVecBit(iv, k-VFREGBEG+VIREGBEG-1, 1); #endif } else if (k >= VDREGBEG && k < VDREGEND) { SetVecBit(iv, k-VDREGBEG+VFREGBEG-1, 1); SetVecBit(iv, k-VDREGBEG+FREGBEG-1, 1); SetVecBit(iv, k-VDREGBEG+DREGBEG-1, 1); #ifdef VIREGBEG SetVecBit(iv, k-VDREGBEG+VIREGBEG-1, 1); #endif } #ifdef VIREGBEG else if (k >= VIREGBEG && k < VIREGEND) /* for new type V_INT*/ { SetVecBit(iv, k-VIREGBEG+VDREGBEG-1, 1); SetVecBit(iv, k-VIREGBEG+VFREGBEG-1, 1); SetVecBit(iv, k-VIREGBEG+FREGBEG-1, 1); SetVecBit(iv, k-VIREGBEG+DREGBEG-1, 1); } #endif #endif } #if 0 else if (!(k >= IREGBEG && k < IREGEND)) fko_error(__LINE__, "Unknown register index %d, file=%s\n", k, __FILE__); #endif return(iv); } int FindLiveregs(INSTQ *here) /* * Finds the livereg up to instruction here (here itself is not included * in the analysis) * RETURNS: bitvector with all live regs set */ { INSTQ *ip; int i, k; static INT_BVI liveregs=0, mask, vtmp; if (here) { if (!liveregs) { liveregs = NewBitVec(TNREG); mask = NewBitVec(TNREG); vtmp = NewBitVec(TNREG); /* * Set only those regs we're interested in */ SetVecAll(mask, 0); SetAllTypeReg(mask, T_INT); SetAllTypeReg(mask, T_FLOAT); SetAllTypeReg(mask, T_DOUBLE); SetAllTypeReg(mask, T_VFLOAT); SetAllTypeReg(mask, T_VDOUBLE); #ifdef VIREGBEG SetAllTypeReg(mask, T_VINT); #endif SetVecBit(mask, REG_SP-1, 0); #ifdef X86_32 /* * FIXED: Reg2Int always return -ve index!!! -- Majedul */ SetVecBit(mask, -Reg2Int("@st")-1, 0); #endif } else SetVecAll(liveregs, 0); /* * Add all regs live on block entry to liveregs by adding regs from ins to lr */ BitVecComb(vtmp, here->myblk->ins, mask, '&'); /* * FIXME: Reg2Regstate() always set all the alias regs */ for (i=1; (k = GetSetBitX(vtmp, i)); i++) BitVecComb(liveregs, liveregs, Reg2Regstate(k), '|'); for (ip=here->myblk->inst1; ip != here; ip = ip->next) { /* * Remove all dead regs from livereg * FIXME: Creates problem when we have more than one alias regs is live. * one of them is dead but still it should not be leased. */ if (ip->deads) { BitVecComb(vtmp, ip->deads, mask, '&'); for (i=1; (k = GetSetBitX(vtmp, i)); i++) BitVecComb(liveregs, liveregs, Reg2Regstate(k), '-'); } /* * If a register is set, add it to liveregs */ if (ip->set) { BitVecComb(vtmp, ip->set, mask, '&'); for (i=1; (k = GetSetBitX(vtmp, i)); i++) BitVecComb(liveregs, liveregs, Reg2Regstate(k), '|'); } } } else { if (liveregs) { KillBitVec(liveregs); KillBitVec(mask); KillBitVec(vtmp); } vtmp = mask = liveregs = 0; } return(liveregs); } int GetRegForAsg(int type, INT_BVI iv, INT_BVI livereg) { SetVecAll(iv, 0); SetAllTypeReg(iv, type); BitVecComb(iv, iv, livereg, '-'); SetVecBit(iv, REG_SP-1, 0); /* * Don't use [f,d]retreg (%st) for x86-32 */ #ifdef X86_32 SetVecBit(iv, FRETREG-1, 0); SetVecBit(iv, DRETREG-1, 0); #endif return(AnyBitsSet(iv)); } int GetRegFindLR(int type, INT_BVI iv, INSTQ *here) { return(GetRegForAsg(type, iv, FindLiveregs(here))); } void NewIGTable(int chunk) { int i, n; IGNODE **new; n = TNIG + chunk; new = malloc(n*sizeof(IGNODE*)); assert(new); for (i=0; i != TNIG; i++) new[i] = IG[i]; for (; i != n; i++) new[i] = NULL; if (IG) free(IG); IG = new; TNIG = n; } void KillIGNode(IGNODE *ig) { if (ig->blkbeg) KillBlockList(ig->blkbeg); if (ig->blkend) KillBlockList(ig->blkend); if (ig->blkspan) KillBlockList(ig->blkspan); if (ig->ldhoist) KillBlockList(ig->ldhoist); if (ig->stpush) KillBlockList(ig->stpush); if (ig->myblkvec) KillBitVec(ig->myblkvec); if (ig->liveregs) KillBitVec(ig->liveregs); if (ig->conflicts) KillBitVec(ig->conflicts); IG[ig->ignum] = NULL; free(ig); } void KillIGTableEntries() { int i; for (i=0; i < NIG; i++) { if (IG[i]) { KillIGNode(IG[i]); IG[i] = NULL; } } NIG = 0; } void KillIGTable() { KillIGTableEntries(); free(IG); IG = NULL; TNIG = 0; } int AddIG2Table(IGNODE *node) { if (NIG == TNIG) NewIGTable(64); IG[NIG] = node; node->ignum = NIG; return(NIG++); } IGNODE *NewIGNode(BBLOCK *blk, short var) { IGNODE *new; new = malloc(sizeof(IGNODE)); assert(new); new->blkbeg = new->blkend = new->blkspan = new->ldhoist = new->stpush = NULL; if (blk) { new->myblkvec = NewBitVec(blk->bnum); assert(new->myblkvec); SetVecBit(new->myblkvec, blk->bnum-1, 1); } else new->myblkvec = 0; new->liveregs = NewBitVec(TNREG); new->conflicts = NewBitVec(TNREG); new->nread = new->nwrite = 0; new->var = var; if (var) { if (IS_DEREF(STflag[var-1])) new->deref = var; else { assert(IS_VAR(STflag[var-1])); new->deref = SToff[var-1].sa[2]; assert(new->deref > 0); } } else new->deref = 0; new->ignum = AddIG2Table(new); new->reg = 0; return(new); } INT_BVI AllRegVec(int k) /* * Majedul: this func is changed to add opportunity to reset the static var * k is for reset the static var iv. */ { static INT_BVI iv=0; int i; if (k <= 0) { if (iv) KillBitVec(iv); iv = 0; } else { if (!iv) { iv = NewBitVec(TNREG); for (i=0; i < TNREG; i++) SetVecBit(iv, i, 1); } } return(iv); } void CalcBlockIG(BBLOCK *bp) { int i, j, n, k; IGNODE *node; INSTQ *ip; INT_BVI liveregs, imask, iv; const int chunk = 32; short *vals; IGNODE **myIG = NULL; /* array of this block's IGNODES */ int igN=0, nn=0; short inst; extern INT_BVI FKO_BVTMP; extern BBLOCK *bbbase; if (!CFUSETU2D) CalcInsOuts(bbbase); if (!INDEADU2D) CalcAllDeadVariables(); if (FKO_BVTMP) { liveregs = FKO_BVTMP; SetVecAll(liveregs, 0); } else FKO_BVTMP = liveregs = NewBitVec(TNREG); if (!bp->ignodes) bp->ignodes = NewBitVec(TNREG+64); else SetVecAll(bp->ignodes, 0); if (!bp->conin) bp->conin = NewBitVec(TNREG+64); else SetVecAll(bp->conin, 0); if (!bp->conout) bp->conout = NewBitVec(TNREG+64); else SetVecAll(bp->conout, 0); /* * Mask out unneeded regs from analysis */ imask = NewBitVec(TNREG); SetVecBit(imask, REG_SP-1, 1); SetVecBit(imask, PCREG-1, 1); for (k=ICCBEG; k < ICCEND; k++) SetVecBit(imask, k-1, 1); for (k=FCCBEG; k < FCCEND; k++) SetVecBit(imask, k-1, 1); #ifdef X86_32 SetVecBit(imask, -Reg2Int("@st")-1, 1); #endif /* * Create ignode for all variables live on block entry, and add it * blocks conin, conout, and ignodes */ vals = BitVec2StaticArray(bp->ins); for (n=vals[0], i=1; i <= n; i++) { k = vals[i]; if (k >= TNREG) { node = NewIGNode(bp, k-TNREG+1); if (nn == igN) myIG = NewPtrTable(&igN, myIG, chunk); myIG[nn++] = node; SetVecBit(bp->conin, node->ignum, 1); SetVecBit(bp->conout, node->ignum, 1); SetVecBit(bp->ignodes, node->ignum, 1); } /* * If a register is live on block entry, add it to liveregs */ else if (!BitVecCheck(imask, k)) { iv = Reg2Regstate(k+1); BitVecComb(liveregs, liveregs, iv, '|'); } } /* * For all created IGNODEs, set it to conflict with all other conin, * and init its livereg to conin's livereg * FIXME: ignum can exceed short. So, it can't be hold in vals for large code * Will get seg fault from here. */ vals = BitVec2StaticArray(bp->ignodes); for (n=vals[0], i=1; i <= n; i++) { k = vals[i]; node = IG[k]; node->conflicts = BitVecCopy(node->conflicts, bp->conin); SetVecBit(node->conflicts, node->ignum, 0); node->liveregs = BitVecCopy(node->liveregs, liveregs); } for (ip=bp->ainst1; ip; ip = ip->next) { inst = GET_INST(ip->inst[0]); if (!ACTIVE_INST(inst)) continue; /* * If var is referenced as a use, update nread */ vals = BitVec2StaticArray(ip->use); for (n=vals[0], i=1; i <= n; i++) { k = vals[i]; if (k >= TNREG) { k += 1 - TNREG; for (j=nn-1; j >= 0; j--) if (myIG[j] && myIG[j]->var == k) break; assert(j >= 0); myIG[j]->nread++; } } /* * Handle deads */ vals = BitVec2StaticArray(ip->deads); for (n=vals[0], i=1; i <= n; i++) { k = vals[i]; if (k >= TNREG) /* dead item is a var */ { /* * Find ignode associated with var */ k += 1 - TNREG; for (j=nn-1; j >= 0; j--) if (myIG[j] && myIG[j]->var == k) break; assert(j >= 0); /* * If dying range ends with a write, indicate it */ if (BitVecCheck(ip->set, k+TNREG-1)) { /*fprintf(stderr, "Inst dead on write, block=%d, inst='%s %s %s %s'!\n", bp->bnum, instmnem[ip->inst[0]], op2str(ip->inst[1]), op2str(ip->inst[2]), op2str(ip->inst[3])); fprintf(stderr, "k=%d, STentry=%d\n", k, k+TNREG-1); PrintInst(fopen("err.l", "w"), bbbase); exit(-1);*/ fko_error(__LINE__, "inst dead on write???"); myIG[j]->nwrite++; } /* * If var is dead, delete it from myIG and block's conout, and * indicate that this is a block and instruction where range dies */ SetVecBit(bp->conout, myIG[j]->ignum, 0); node = myIG[j]; myIG[j] = NULL; #if IFKO_DEBUG_LEVEL >= 1 assert(!node->blkend); #endif node->blkend = AddBlockToList(node->blkend, bp); node->blkend->ptr = ip; } /* * If it is a register that's dead, delete it from liveregs * HERE HERE NOTE: shouldn't we use Reg2RegState here? * * FIXME: we can't release all alias registers when more than one alias * register is live !!! */ else BitVecComb(liveregs, liveregs, Reg2Regstate(k+1), '-'); /* SetVecBit(liveregs, k, 0); */ } /* * Handle sets */ vals = BitVec2StaticArray(ip->set); for (n=vals[0], i=1; i <= n; i++) { k = vals[i]; if (k >= TNREG) /* variable is being set */ { k += 1 - TNREG; for (j=nn-1; j >= 0; j--) if (myIG[j] && myIG[j]->var == k) break; /* * If variable is set and not already live, then: * a. create new ignode for it * b. set a conflict between it and all other active ignodes * c. set ignode's liveregs to current liveregs * d. add it to blocks ignodes */ if (j < 0) { node = NewIGNode(bp, k); if (nn == igN) myIG = NewPtrTable(&igN, myIG, chunk); myIG[nn++] = node; for (j=0; j != nn; j++) if (myIG[j]) SetVecBit(myIG[j]->conflicts, node->ignum, 1); node->conflicts = BitVecCopy(node->conflicts, bp->conout); SetVecBit(bp->conout, node->ignum, 1); node->liveregs = BitVecCopy(node->liveregs, liveregs); node->blkbeg = AddBlockToList(node->blkbeg, bp); node->blkbeg->ptr = ip; SetVecBit(bp->ignodes, node->ignum, 1); node->nwrite++; } /* * NOTE: already live but set, there may be no read of the live-range. * When the value is set before being used, node->nread is zero. RegAsg * may incorrectly skip that ig node. * useless expression elimination should delete them. */ else { if (myIG[j]->var && strcmp(STname[myIG[j]->var-1], "_NONLOCDEREF") && !myIG[j]->nread) { fko_error(__LINE__, "Live range of %s(%d) is set again without " "being used! Need to apply useless expression " "elimination first!", STname[myIG[j]->var-1], myIG[j]->var); } } } /* * If it's a register being set, add it to list of live regs as well * as to the regstate of all currently live ranges */ else if (!BitVecCheck(imask, k)) { iv = Reg2Regstate(k+1); BitVecComb(liveregs, liveregs, iv, '|'); for (j=0; j != nn; j++) if (myIG[j]) BitVecComb(myIG[j]->liveregs, myIG[j]->liveregs, iv, '|'); } } } /* * If this block neither begins or ends LR, it is spanned */ for (i=0; i < nn; i++) { node = myIG[i]; if (node && !node->blkbeg && !node->blkend) node->blkspan = AddBlockToList(node->blkspan, bp); } if (myIG) free(myIG); KillBitVec(imask); } void CombineLiveRanges(BLIST *scope, BBLOCK *pred, int pig, BBLOCK *succ, int sig) /* * Merge successor IG (sig) into pred ig (pig); both blocks are known to * be in the register scope. */ { IGNODE *pnode, *snode, *node; BLIST *bl; short *vals; int i, n; pnode = IG[pig]; snode = IG[sig]; assert(pnode->var == snode->var); pnode->blkbeg = MergeBlockLists(pnode->blkbeg, snode->blkbeg); pnode->blkend = MergeBlockLists(snode->blkend, pnode->blkend); pnode->blkspan = MergeBlockLists(pnode->blkspan, snode->blkspan); snode->blkbeg = snode->blkend = snode->blkspan = NULL; /* * If succ block is not ending block, it becomes a spanned block */ if ( !FindBlockInList(pnode->blkend, succ) && !FindBlockInList(pnode->blkspan, succ) ) pnode->blkspan = AddBlockToList(pnode->blkspan, succ); /* * The range ending in succ block may change due to new beginning in pred */ #if 0 bl = FindInList(pnode->blkend, succ); if (bl) { i = pnode->var + TNREG-1; for (ip=bl->blk->ainst1; ip; ip = ip->next) { if (BitVecCheck(ip->deads, i)) { bl->ptr = ip; break; } } } #endif if (snode->ldhoist) { pnode->ldhoist = MergeBlockLists(pnode->ldhoist, snode->ldhoist); snode->ldhoist = NULL; } if (snode->stpush) { pnode->stpush = MergeBlockLists(pnode->stpush, snode->stpush); snode->stpush = NULL; } pnode->nread += snode->nread; pnode->nwrite += snode->nwrite; BitVecComb(pnode->myblkvec, pnode->myblkvec, snode->myblkvec, '|'); BitVecComb(pnode->liveregs, pnode->liveregs, snode->liveregs, '|'); BitVecComb(pnode->conflicts, pnode->conflicts, snode->conflicts, '|'); /* * Change snode conflicts to pnode conflicts */ vals = BitVec2StaticArray(snode->conflicts); for (i=1, n=vals[0]; i <= n; i++) { node = IG[vals[i]]; SetVecBit(node->conflicts, sig, 0); SetVecBit(node->conflicts, pig, 1); } /* * Update block-carried IG info */ for (bl=scope; bl; bl = bl->next) { if (BitVecCheck(bl->blk->ignodes, sig)) { SetVecBit(bl->blk->ignodes, sig, 0); SetVecBit(bl->blk->ignodes, pig, 1); if (BitVecCheck(bl->blk->conin, sig)) { SetVecBit(bl->blk->conin, sig, 0); SetVecBit(bl->blk->conin, pig, 1); } if (BitVecCheck(bl->blk->conout, sig)) { SetVecBit(bl->blk->conout, sig, 0); SetVecBit(bl->blk->conout, pig, 1); } } } KillIGNode(snode); } void CombineBlockIG(BLIST *scope, INT_BVI scopeblks, BBLOCK *pred, BBLOCK *succ) /* * Attempt to combine preds IG with succ */ { IGNODE *node; int i, j, n, nn; short *sig, *pig, svar; short k, kk; BLIST *bl; /* * If both blocks are in scope, attempt to combine their live ranges */ if (BitVecCheck(scopeblks, succ->bnum-1) && BitVecCheck(scopeblks, pred->bnum-1) ) { pig = BitVec2Array(pred->conout, 0); sig = BitVec2Array(succ->conin, 0); for (n=sig[0], i=1; i <= n; i++) { k = sig[i]; if (!IG[k]) continue; svar = IG[k]->var; for (nn=pig[0], j=1; j <= nn; j++) { kk = pig[j]; /* * HERE, HERE: put this in to protect when sig is joined to pig */ if (!IG[kk] || !IG[k]) continue; if (k != kk && svar == IG[kk]->var) CombineLiveRanges(scope, pred, kk, succ, k); } } free(pig); free(sig); } /* * If pred in scope, but successor not, and LR includes a store, must push LR * stores to succ. iff the variable is live on entering succ. * Assign the next inst of the pushed stores to node->stpush->ptr. */ else if (BitVecCheck(scopeblks, pred->bnum-1)) { pig = BitVec2StaticArray(pred->conout); /* * NOTE: successor must be a posttail; that means, successor can't have * predeccessor other than this pred blk. */ if (succ->preds->next) /* has other preds */ fko_error(__LINE__, "Posttail error: posttail has other preds than tail"); for (n=pig[0], i=1; i <= n; i++) { node = IG[pig[i]]; /* * nwrite doesn't reflect the whole scope but just the combining * blks... so, we should not count this now !!! * But if a variable is not set inside the scope, we don't need to * push it outside as the variable is not changed at all! * NOTE: we can consider it for stpush now but scope out after combining * all the IG nodes!!! */ /*if (node->nwrite && BitVecCheck(succ->ins, node->var+TNREG-1) )*/ if (BitVecCheck(succ->ins, node->var+TNREG-1)) { node->stpush = AddBlockToList(node->stpush, succ); if (succ->ainst1) { k = GET_INST(succ->ainst1->inst[0]); node->stpush->ptr = (k == LABEL) ? succ->ainst1->next : succ->ainst1; } else node->stpush->ptr = NULL; } } } /* * If succ in scope but pred not, pred becomes load hoist target * Find the prev of the hoisted loads */ else /* if (BitVecCheck(scopeblks, succ->bnum-1, 1)) */ { sig = BitVec2StaticArray(succ->conin); /* * Preheader: * 1. head should be the only successor * 2. head shouldn't have any pred other than prehead out of the scope */ if ( (pred->csucc && pred->csucc != succ) || (pred->usucc && pred->usucc != succ) ) fko_error(__LINE__, "Prehead error: " "prehead has successor other than head"); for (bl=succ->preds; bl; bl=bl->next) { if (bl->blk != pred && !BitVecCheck(scopeblks, bl->blk->bnum-1)) fko_error(__LINE__, "Prehead error: " "head can't have other predecessor out of scope than prehead"); } for (n=sig[0], i=1; i <= n; i++) { node = IG[sig[i]]; node->ldhoist = AddBlockToList(node->ldhoist, pred); if (pred->ainstN) { k = GET_INST(pred->ainstN->inst[0]); /* * FIXME: if the predecessor has any successor other than this blk, * adding load host before branch would create problem: to load hoist, * we shouldn't use live register on this blk!!!! * NOTE: if we always consider scope as a loop, only head of the loop * has a predecessor which is pre-header. pre-header can never have a * successor other than the head blk of the loop. */ node->ldhoist->ptr = IS_BRANCH(k) ? pred->ainstN->prev : pred->ainstN; } else node->ldhoist->ptr = NULL; } } } int CheckIG(int N, IGNODE **igs) { int i, j, n; short *sp; IGNODE *ig, *ig2; int nerr=0; for (i=0; i < N; i++) { if (igs[i]) { ig = igs[i]; /* * Make sure register is not assigned to conflicting node */ if (ig->reg) { sp = BitVec2StaticArray(ig->conflicts); if (sp) { for (j=1, n=sp[0]; j <= n; j++) { ig2 = IG[sp[j]]; if (ig2->reg == ig->reg) { fprintf(stderr, "Conflicting IG %d and %d both use register %d!!\n", ig->ignum, ig2->ignum, ig->reg); nerr++; } } } } } else fprintf(stderr, "NULL IG %d\n", i); } assert(nerr == 0); return(nerr); } int Scope2BV(BLIST *scope) { static INT_BVI iv=0; BLIST *bl; if (scope) { if (!iv) iv = NewBitVec(32); SetVecAll(iv, 0); for (bl = scope; bl; bl = bl->next) SetVecBit(iv, bl->blk->bnum-1, 1); } else if (iv) { KillBitVec(iv); iv = 0; } return(iv); } int CalcScopeIG(BLIST *scope) /* * RETURNS: total number of IG * Majedul: parameter NULL is used to re-init the static var blkvec. * So, make sure it is not used with NULL ( adding assert ) in normal case */ { static INT_BVI blkvec=0; BLIST *bl, *lp; int i, j; if (scope) { if (!INDEADU2D) CalcAllDeadVariables(); else if (!CFUSETU2D || !CFU2D || !INUSETU2D) CalcInsOuts(bbbase); /* * Set blkvec to reflect all blocks in scope, and calculate each block's IG */ if (blkvec) SetVecAll(blkvec, 0); else blkvec = NewBitVec(32); assert(blkvec); for (bl=scope; bl; bl = bl->next) { SetVecBit(blkvec, bl->blk->bnum-1, 1); CalcBlockIG(bl->blk); } /* DumpIG(stderr, NIG, IG); */ /* * Try to combine live ranges across basic blocks */ for (bl=scope; bl; bl = bl->next) { if (bl->blk->usucc) CombineBlockIG(scope, blkvec, bl->blk, bl->blk->usucc); /* * Majedul: * NOTE: we should not assume any order of execution!!! * stpush depends on the nwrite... which may not be seen in a * specific order!!! FIXED. */ if (bl->blk->csucc) CombineBlockIG(scope, blkvec, bl->blk, bl->blk->csucc); for (lp=bl->blk->preds; lp; lp = lp->next) { if (!BitVecCheck(blkvec, lp->blk->bnum-1) && lp->blk != bl->blk->usucc && lp->blk != bl->blk->csucc) CombineBlockIG(scope, blkvec, lp->blk, bl->blk); } } /* * FIXED: * only !nwrite should have stpush!! * variables, those are not updated inside the scope, are not a candidate * for stpush, but we can't have updated nwrite until all blks are * explored. so, check for the updated nwrite here... It will solve all * issues related with the missing stpush for some cases!!! */ #if 1 for (i=0; i < NIG; i++) { if (IG[i] && !IG[i]->nwrite && IG[i]->stpush) { KillBlockList(IG[i]->stpush); IG[i]->stpush = NULL; } } #endif for (j=i=0; i < NIG; i++) if (IG[i]) j++; return(j); } else { if (blkvec) KillBitVec(blkvec); blkvec = 0; return(0); } } #if 0 int IsConflictMoreThanNRegs(int N, IGNODE **igarr) { int i, j, n, max=0; short *sp; IGNODE *ig, *igv, *igm=NULL; #if 1 extern BBLOCK *bbbase; PrintInst(stdout, bbbase); #endif for (i=0; i < N; i++) { ig = igarr[i]; sp = BitVec2StaticArray(ig->conflicts); #if 1 if (sp) { fprintf(stderr, "[%d]*****%s -> conflicts(%d) = ", sp[0], STname[ig->var-1], sp[0]); for (j=1, n=sp[0]; j <=n; j++) { igv = igarr[j]; fprintf(stderr, "%s(%d), ", STname[igv->var-1]? STname[igv->var-1]:"NULL", igv->var); } fprintf(stderr, "\n\n"); } #endif if (sp && sp[0] > max && FLAG2TYPE(STflag[ig->var-1])==T_DOUBLE ) { max = sp[0]; igm = ig; } } fprintf(stderr, "Max number of conflicts = %d\n", max); if (igm) { fprintf(stderr, " TYPE = %d, var=%s\n", FLAG2TYPE(STflag[igm->var-1]), STname[igm->var-1]? STname[igm->var-1]:"NULL"); sp = BitVec2StaticArray(igm->conflicts); fprintf(stderr, "conflicts = "); for (i=1, n=sp[0]; i <=n; i++) fprintf(stderr, "%s(%d), ", STname[sp[i]-1]? STname[sp[i]-1]:"NULL", sp[i]); fprintf(stderr, "\n"); } exit(0); } #endif void SortUnconstrainedIG(int N, IGNODE **igarr) /* * Given an N-length contiguous array if IGNODEs, sorts them by nref using * a simple selection sort */ { int i, j, nref, maxref, maxi; IGNODE *maxptr; /* * Perform simple selection sort */ for (i=0; i < N-1; i++) { maxref = igarr[i]->nread + igarr[i]->nwrite; maxi = i; for (j=i+1; j < N; j++) { nref = igarr[j]->nread + igarr[j]->nwrite; if (nref > maxref) { maxi = j; maxref = nref; } } if (maxi != i) { maxptr = igarr[maxi]; igarr[maxi] = igarr[i]; igarr[i] = maxptr; } } } #if 0 int FindInstPos(INSTQ *inst) { int i; BBLOCK *bp; INSTQ *ip; extern BBLOCK *bbbase; if (!inst) return(0); for (i=0, bp=bbbase; bp; bp=bp->down) { for (ip=bp->ainst1; ip; ip=ip->next, i++) { if (ip == inst) return(i+1); } } return(0); } INSTQ *FindIpFromIG(IGNODE *ig, int isbeg) { int i, minb; INSTQ *ip; BLIST *bl, *minbl; /* * find bl with min bnum * FIXME: bnum is set by block->down which doesn't always mean it would be a * predecessor! */ ip = NULL; minb = 0; if (isbeg) bl = ig->blkbeg; else bl = ig->blkend; if (bl) { minb = bl->blk->bnum; minbl = bl; while (bl) { i = bl->blk->bnum; if (i < minb) { minb = i; minbl = bl; } bl = bl->next; } /* * now findout the index of the ip of this minbp */ ip = minbl->ptr; } return(ip); } void DoSortIGsByInst(int end, int start, IGNODE **igarr) { int i, j, imin; int iip, iipmin; IGNODE *igp; /* * simple selection sort */ for (i=start; i < end-1; i++) { iipmin = FindInstPos(FindIpFromIG(igarr[i], 0)); imin = i; for (j=i+1; j < end; j++) { iip = FindInstPos(FindIpFromIG(igarr[j], 0)); if (iip < iipmin) { imin = j; iipmin = iip; } } if (imin != i) { igp = igarr[imin]; igarr[imin] = igarr[i]; igarr[i] = igp; } } } void SortIGsByInstPosition(int N, IGNODE **igarr) { int i, j, k, nref; IGNODE *igp; int iip; i= 0; while (i < N-1) { nref = igarr[i]->nread + igarr[i]->nwrite; k = j = i + 1; while (k < N && nref == (igarr[k]->nread + igarr[k]->nwrite) ) k++; if (i != (k+1)) DoSortIGsByInst(i, k, igarr); i = k; } } int FindDistDead2Alive(IGNODE *ig1, IGNODE *ig2) { int dist; INSTQ *iplive, *ipdead; ipdead = FindIpFromIG(ig1, 0); iplive = FindIpFromIG(ig2, 1); if (ipdead && iplive) dist = FindInstPos(iplive) - FindInstPos(ipdead); else dist = -1; /* either one is out of scope */ return(dist); } IGNODE *FindEarliestAliveIGFromThisDead(int N, IGNODE **igarr, IGNODE *tig) { int i, dist, dmin=0; IGNODE *igd=NULL; for (i=0; i < N; i++) { if (tig == igarr[i]) continue; if (FLAG2TYPE(STflag[tig->var-1]) != FLAG2TYPE(STflag[igarr[i]->var-1])) continue; dist = FindDistDead2Alive(tig, igarr[i]); if (dist > 0 && dist < dmin) { dmin = dist; igd = igarr[i]; } } return(igd); } IGNODE *FindEarliestDeadUpFromThisAlive(int N, IGNODE **igarr, IGNODE *tig) { int i, dist, dmin=0; IGNODE *igd=NULL; for (i=0; i < N; i++) { if (tig == igarr[i]) continue; if (FLAG2TYPE(STflag[tig->var-1]) != FLAG2TYPE(STflag[igarr[i]->var-1])) continue; /* * since dead code is on up, dest is negative */ dist = -FindDistDead2Alive(igarr[i], tig); if (dist > 0 && dist < dmin) { dmin = dist; igd = igarr[i]; } } return(igd); } #endif void KeepVarTogether(int N, IGNODE **igarr) /* * Assumption: igarr is already sorted based on nref (nread + nwrite). * this function will keep the live ranges of same variable with same nref * together; this helps register assignment to avoid register spilling for * unrolled code */ { int i, j, k, nref; IGNODE *igp; short var; i = 0; while (i < N-1) { nref = igarr[i]->nread + igarr[i]->nwrite; var = igarr[i]->var; /* * skip if ignode of live range is for same var (and same nref) */ k = i + 1; while (k < N && igarr[k]->var == var && nref == (igarr[k]->nread + igarr[k]->nwrite) ) k++; i = k - 1; /* * find node for same var with same nref and swap it to the next position */ j = i + 1; while(j < N) { /* * ignodes are sorted based on nref.check until number of ref becomes less */ if ( nref > (igarr[j]-> nread + igarr[j]->nwrite) ) { break; } /* * because of previous condition, no need to check the nref */ else if (igarr[j]->var == var) /* && nref == igarr[j]->nread + ig...*/ { /* * swap with next node if not the same */ if (j != i + 1) { igp = igarr[i+1]; igarr[i+1] = igarr[j]; igarr[j] = igp; i++; /* var & nref are same for this position too */ } } j++; } i++; } } void SortConstrainedIG(int N, IGNODE **igs) /* * Right now, this routine just calls the unconstrained sort, but eventually * it should be changed to optimize assignment. For instance, when deciding * between conflicting variables, if one variable's liverange (LR) spans the LR * of multiple conflicting vars, you must compare against the sum of the refs * of the spanned LRs. */ { SortUnconstrainedIG(N, igs); } void KillUnusedIG(int N, IGNODE **igs) /* * Kills all IGNODEs in IG that do not also appear in igs */ { IGNODE *node; int n, i, j; BLIST *bl; short *sp; for (j=0; j < NIG; j++) { node = IG[j]; if (node) { for (i=0; i < N && node != igs[i]; i++); if (i == N) { /* * Delete from block-carried IG */ for (bl=node->blkbeg; bl; bl = bl->next) { SetVecBit(bl->blk->conin, node->ignum, 0); SetVecBit(bl->blk->conout, node->ignum, 0); SetVecBit(bl->blk->ignodes, node->ignum, 0); } for (bl=node->blkend; bl; bl = bl->next) { SetVecBit(bl->blk->conin, node->ignum, 0); SetVecBit(bl->blk->conout, node->ignum, 0); SetVecBit(bl->blk->ignodes, node->ignum, 0); } for (bl=node->blkspan; bl; bl = bl->next) { SetVecBit(bl->blk->conin, node->ignum, 0); SetVecBit(bl->blk->conout, node->ignum, 0); SetVecBit(bl->blk->ignodes, node->ignum, 0); } /* * Delete from conflicts */ sp = BitVec2StaticArray(node->conflicts); for (n=sp[0], i=1; i <= n; i++) SetVecBit(IG[sp[i]]->conflicts, node->ignum, 0); /* * Free node space, and delete from array */ KillIGNode(node); IG[j] = NULL; } } } } IGNODE **SortIG(int *N, int thresh) /* * Sorts IGNODEs by # refs. * RETURNS: N-length contiguous array of sorted IGNODEs * This routine also ignores live ranges (LR) with too few references to * be worth assigning. */ { int n, ncon, i, j; INT_BVI iv; IGNODE *ig; IGNODE **igarr; extern INT_BVI FKO_BVTMP; if (!FKO_BVTMP) FKO_BVTMP = NewBitVec(TNREG); iv = FKO_BVTMP; /* * Find number of IG nodes used, allocate array to store, and copy to * contiguous storage */ for (n=i=0; i < NIG; i++) { if (IG[i] && IG[i]->nwrite + IG[i]->nread >= thresh && (!STname[IG[i]->var-1] || strcmp(STname[IG[i]->var-1], "_NONLOCDEREF"))) n++; } if (n == 0) { *N = 0; return(NULL); } igarr = malloc(n*sizeof(IGNODE *)); assert(igarr); for (j=i=0; i < NIG; i++) if (IG[i] && IG[i]->nwrite + IG[i]->nread >= thresh && (!STname[IG[i]->var-1] || strcmp(STname[IG[i]->var-1], "_NONLOCDEREF"))) igarr[j++] = IG[i]; KillUnusedIG(n, igarr); /* * Now, sort array into two sub arrays, with the contrained nodes in the first * ncon elements of the array. Constrained nodes are those nodes where the # * of conflicts is greater than the number of available registers. Therefore * unconstrained nodes can use any register, so do reg asg on constrained nodes * first */ for (ncon=i=0; i != n; i++) { ig = igarr[i]; SetVecAll(iv, 0); SetAllTypeReg(iv, FLAG2PTYPE(STflag[ig->var-1])); BitVecComb(iv, iv, ig->liveregs, '-'); /* * If # of regs available (j) is less than the number of conflicts, node is * constrained */ j = CountBitsSet(iv); if (j < CountBitsSet(ig->conflicts)) { igarr[i] = igarr[ncon]; igarr[ncon++] = ig; } } SortConstrainedIG(ncon, igarr); /* * keep live ranges of same variable (which access count are same) together */ KeepVarTogether(ncon, igarr); /*SortIGsByInstPosition(ncon, igarr);*/ SortUnconstrainedIG(n-ncon, igarr+ncon); *N = n; return(igarr); } int DoIGRegAsg(int N, IGNODE **igs, int *nspill) /* * Given an N-length array of sorted IGNODEs, perform register assignment * Right now, use simple algorithm for assignment, improve later. * RETURNS: # of IG assigned. * Majedul: nspill saves the number of spilling of the registers */ { int i, j, n; int iret = 0; IGNODE *ig, *ig2; short *sp; INT_BVI iv, ivused; extern INT_BVI FKO_BVTMP; if (!FKO_BVTMP) FKO_BVTMP = NewBitVec(TNREG); iv = FKO_BVTMP; /* * init nspills with 0 */ for (i=0; i < NTYPES; i++) nspill[i] = 0; for (i=0; i < N; i++) { ig = igs[i]; ig->reg = GetRegForAsg(FLAG2PTYPE(STflag[ig->var-1]), iv, ig->liveregs); if (ig->reg) { ivused = Reg2Regstate(ig->reg); ig->reg--; BitVecComb(ig->liveregs, ig->liveregs, ivused, '|'); assert(ig->reg+1 != REG_SP); /* * Add assigned register to liveregs of conflicting IGNODEs */ sp = BitVec2StaticArray(ig->conflicts); if (sp) { for (j=1, n=sp[0]; j <= n; j++) { ig2 = IG[sp[j]]; BitVecComb(ig2->liveregs, ig2->liveregs, ivused, '|'); } } ig->reg++; iret++; } else { fko_warn(__LINE__, "NO FREE REGISTER FOR LR %d of VAR %s!!!\n", ig->ignum, STname[ig->var-1]); nspill[FLAG2PTYPE(STflag[ig->var-1])]++; /* update spilling */ } } return(iret); } #if 0 short FindRegFromEarliestDead(int N, IGNODE **igs, IGNODE *ig) { short reg = 0; IGNODE *iig; iig = FindEarliestDeadUpFromThisAlive(N, igs, ig); if (ig->reg) reg = ig->reg; return(reg); } void UpdateConflicts(short reg, IGNODE *ig) { int j, n; INT_BVI ivused; IGNODE *ig2; short *sp; if (!reg) return; ivused = Reg2Regstate(ig->reg); ig->reg--; BitVecComb(ig->liveregs, ig->liveregs, ivused, '|'); assert(ig->reg+1 != REG_SP); /* * Add assigned register to liveregs of conflicting IGNODEs */ sp = BitVec2StaticArray(ig->conflicts); if (sp) { for (j=1, n=sp[0]; j <= n; j++) { ig2 = IG[sp[j]]; BitVecComb(ig2->liveregs, ig2->liveregs, ivused, '|'); } } ig->reg++; } #endif int VarUse2RegUse(IGNODE *ig, BBLOCK *blk, INSTQ *instbeg, INSTQ *instend) /* * Changes all uses of ig->var to ig->reg in block blk, between the indicated * instructions (inclusive). If either is NULL, we take instbeg/end. */ { INSTQ *ip; int CHANGE=0; short k; assert(INUSETU2D); assert(ig && blk); if (!instbeg) instbeg = blk->ainst1; if (!instend) instend = blk->ainstN; if (!instbeg || !ig->reg) return(0); assert(instend); do { ip = instbeg; /* * Change all uses of this ig->var to ig->reg */ /* * Majedul: * A invalid read is reported here by valgrind! * FIXED: every bitvec is allocated with size of 32 first. ig->var+TNREG-1 * may exceed the size. I fixed this issue by extending the bitvec when * size smaller than the index it is checked. May be it would be used later. */ if (ip && ACTIVE_INST(ip->inst[0]) && BitVecCheck(ip->use, ig->var+TNREG-1)) { SetVecBit(ip->use, ig->var+TNREG-1, 0); SetVecBit(ip->use, ig->reg-1, 0); assert(ip->inst[2] == ig->deref || ip->inst[3] == ig->deref); if (ip->inst[2] == ig->var || ip->inst[2] == ig->deref) ip->inst[2] = -ig->reg; if (ip->inst[3] == ig->var || ip->inst[3] == ig->deref) ip->inst[3] = -ig->reg; switch(GET_INST(ip->inst[0])) { /* * FIXME: nothing about LDS! not works by mov. We will need something to * convert into 32 bit int reg */ case LD: ip->inst[0] = MOV; break; case FLD: ip->inst[0] = FMOV; break; case FLDD: ip->inst[0] = FMOVD; break; case VFLD: ip->inst[0] = VFMOV; break; case VDLD: ip->inst[0] = VDMOV; break; #ifdef VIREGBEG case VLD: ip->inst[0] = VMOV; break; #endif case VDLDS: #ifdef X86 k = ig->reg; if (k >= DREGBEG && k < DREGEND) k = k - DREGBEG + VDREGBEG; if (k != -ip->inst[1]) CalcThisUseSet(InsNewInst(NULL, NULL, ip, VDZERO, ip->inst[1], 0, 0)); #endif ip->inst[0] = VDMOVS; ip->inst[2] = -ig->reg; ip->inst[3] = ip->inst[1]; /* made dest in use too */ break; case VFLDS: #ifdef X86 k = ig->reg; if (k >= FREGBEG && k < FREGEND) k = k - FREGBEG + VFREGBEG; if (k != -ip->inst[1]) CalcThisUseSet(InsNewInst(NULL, NULL, ip, VFZERO, ip->inst[1], 0, 0)); #endif ip->inst[0] = VFMOVS; ip->inst[2] = -ig->reg; ip->inst[3] = ip->inst[1]; /* made dest in use too */ break; #ifdef VIREGBEG /* * We should not use VSLDS directly in LIL. It will always be replaced * with VSMOVS and CVTSI. */ /*case VLDS: #ifdef X86 k = ig->reg; if (k >= IREGBEG && k < IREGEND) k = k - IREGBEG + VIREGBEG; if (k != -ip->inst[1]) CalcThisUseSet(InsNewInst(NULL, NULL, ip, VIZERO, ip->inst[1], 0, 0)); #endif ip->inst[0] = VMOVS; ip->inst[2] = -ig->reg; break;*/ case VSLDS: assert(0); break; case VILDS: #ifdef X86 k = ig->reg; if (k >= IREGBEG && k < IREGEND) k = k - IREGBEG + VIREGBEG; if (k != -ip->inst[1]) CalcThisUseSet(InsNewInst(NULL, NULL, ip, VIZERO, ip->inst[1], 0, 0)); #endif ip->inst[0] = VIMOVS; ip->inst[2] = -ig->reg; ip->inst[3] = ip->inst[1]; break; #endif default: fko_warn(__LINE__,"\n\ninst %d being var2reged!!\n\n", ip->inst[0]); } CalcThisUseSet(ip); CHANGE++; } instbeg = instbeg->next; if (!instbeg) break; } while(ip != instend); if (CHANGE) INDEADU2D = CFUSETU2D = 0; return(CHANGE); } int DoRegAsgTransforms(IGNODE *ig) /* * Given the fully qualified IG, perform all of the code transformations for * register assignment: variable uses to register ref, variable sets become * register moves, and hoist ld and/or push stores for blocks not in scope */ { INSTQ *ip; BLIST *bl; enum inst mov, ld, st, inst, sts, movs; int i, CHANGE=0; if (!ig->reg) /* return if their was no available register */ return(0); /* * NOTE: In vector-to-scalar reduction, scalar value may be stored by a * V2SST (vector to scalar store inst). so, we need sts for scalar value type. */ i = STflag[ig->var-1]; switch(FLAG2PTYPE(i)) { #ifdef X86_64 case T_SHORT: mov = MOVS; ld = LDS; st = STS; sts = VSSTS; movs = VSMOVS; break; #endif case T_INT: mov = MOV; ld = LD; st = ST; sts = VISTS; movs = VIMOVS; break; case T_FLOAT: mov = FMOV; ld = FLD; st = FST; sts = VFSTS; movs = VFMOVS; break; case T_DOUBLE: mov = FMOVD; ld = FLDD; st = FSTD; sts = VDSTS; movs = VDMOVS; break; case T_VDOUBLE: mov = VDMOV; ld = VDLD; st = VDST; break; case T_VFLOAT: mov = VFMOV; ld = VFLD; st = VFST; break; #if 1 case T_VINT: mov = VMOV; ld = VLD; st = VST; break; #endif default: fko_error(__LINE__, "Unknown type %d (flag=%d) in %s\n", FLAG2TYPE(i), i, __FILE__); } /* * Handle initial set of ig->reg required for every blkbeg */ for (bl=ig->blkbeg; bl; bl = bl->next) { /* * If LR begins with a set, change it to a reg-reg move * NOTE: we have no memory-output instructions, so assert set is ST */ ip = bl->ptr; if (ip && BitVecCheck(ip->set, ig->var+TNREG-1)) { inst = GET_INST(ip->inst[0]); #if IFKO_DEBUG_LEVEL >= 1 assert(bl->ptr); #endif CHANGE++; if (!IS_STORE(inst)) { PrintThisInst(stderr, __LINE__, ip); exit(-1); } /* * If Store is of same type as variable, we just change to reg-reg move */ if (inst == st) { ip->inst[0] = mov; ip->inst[1] = -ig->reg; } /* * Majedul: If we have vector to scalar store, we can use movs */ #if 1 else if (IS_V2SST(inst) && inst == sts) { ip->inst[0] = movs; ip->inst[1] = -ig->reg; } #endif /* * If Store is of different type than variable (eg., fpconst init), * we must insert a ld inst to the LR register */ else { ip = PrintComment(bl->blk, ip, NULL, "Inserted LD from %s", STname[ig->var-1] ? STname[ig->var-1] : "NULL"); #if IFKO_DEBUG_LEVEL > 1 fprintf(stderr, "var=%s ireg=%d getting LD ip=%p," "nr=%d, nw=%d!\n\n", STname[ig->var-1], ig->reg, ip, ig->nread, ig->nwrite); #endif ip = InsNewInst(bl->blk, ip, NULL, ld, -ig->reg, ig->deref, 0); if (ip->next) bl->ptr = ip->next; else bl->ptr = InsNewInst(bl->blk, ip, NULL, COMMENT, 0, 0, 0); } CalcThisUseSet(ip); } /* * If LR does not begin with a set, we must add a load to ig->reg, * and so we expect ldhoist to be set */ else assert(0); } /* * If this IG starts and ends in one block, with start before end, handle * seperately */ if ( ig->blkbeg && !ig->blkbeg->next && ig->blkend && !ig->blkend->next && ig->blkbeg->blk == ig->blkend->blk && FindInstNum(ig->blkbeg->blk, ig->blkbeg->ptr) < FindInstNum(ig->blkend->blk, ig->blkend->ptr) ) { assert(!ig->blkspan); CHANGE += VarUse2RegUse(ig, ig->blkbeg->blk, ig->blkbeg->ptr, ig->blkend->ptr); } else { /* * Change all use of var in LR's starting and ending blocks to access * ig->reg instead */ for (bl=ig->blkend; bl; bl = bl->next) CHANGE += VarUse2RegUse(ig, bl->blk, NULL, bl->ptr); for (bl=ig->blkbeg; bl; bl = bl->next) { ip = bl->ptr; if (ip) CHANGE += VarUse2RegUse(ig, bl->blk, ip, NULL); } } /* * Hoist the ld to all extra-scope blocks that may need it */ for (bl=ig->ldhoist; bl; bl = bl->next) { #if IFKO_DEBUG_LEVEL >= 1 assert(bl->ptr); assert(ig->deref > 0); #endif ip = InsNewInst(bl->blk, bl->ptr, NULL, ld, -ig->reg, ig->deref, 0); CalcThisUseSet(ip); CHANGE++; } /* * Push any needed store to extra-scope blocks that require it */ for (bl=ig->stpush; bl; bl = bl->next) { #if IFKO_DEBUG_LEVEL >= 1 assert(bl->ptr); #endif ip = InsNewInst(bl->blk, NULL, bl->ptr, st, ig->deref, -ig->reg, 0); /* * Majedul: * V0_sum should be a candidate for stpush for the modified dasum where * fall-thru path is used as scalar_restart path when speculative * vectorization is applied !!! * imax also should be the candidate for stpush when -p 2 is * applied * FIXED: see CalcScopeIG */ CalcThisUseSet(ip); CHANGE++; } /* * Now we change all use of var in LR span to access ig->reg instead */ for (bl=ig->blkspan; bl; bl = bl->next) CHANGE += VarUse2RegUse(ig, bl->blk, NULL, NULL); if (CHANGE) INDEADU2D = CFUSETU2D = 0; return(CHANGE); } int DoScopeRegAsg(BLIST *scope, int thresh, int *tnig, int *nspill) /* * Performs interference graph-based register assignment on blocks listed in * scope. tnig is output para giving total number of IG we found. * RETURNS: # of IG applied. * Majedul: tnig is unused in caller though I add one parameter to save the * number of spilling. */ { IGNODE **igs; int i, N, nret; extern FILE *fpIG, *fpLIL, *fpST; extern BBLOCK *bbbase; #if 0 static int nc = 0; /* just to debug ... diff cfg */ char file[256]; #endif /* * Majedul: * scope can't be NULL, it shouldn't be. NULL is used to re-init the static * variable used for bitvec. */ assert(scope); *tnig = CalcScopeIG(scope); igs = SortIG(&N, thresh); nret = DoIGRegAsg(N, igs, nspill); CheckIG(N, igs); if (fpIG) { DumpIG(fpIG, N, igs); fclose(fpIG); } if (fpLIL) { PrintInst(fpLIL, bbbase); fclose(fpLIL); fpLIL = NULL; } if (fpST) { PrintST(fpST); fclose(fpST); fpST = NULL; } #if 1 for (i=0; i != N; i++) DoRegAsgTransforms(igs[i]); #endif if (igs) free(igs); KillIGTable(); return(nret); } static void PrintBlockWithNum(FILE *fpout, BLIST *bl) { if (!bl) { fprintf(fpout, "NONE\n"); return; } fprintf(fpout, "%4d(%5d)", bl->blk->bnum, FindInstNum(bl->blk, bl->ptr)); for (bl=bl->next; bl; bl = bl->next) fprintf(fpout, ", %4d(%5d)", bl->blk->bnum, FindInstNum(bl->blk, bl->ptr)); fprintf(fpout, "\n"); } void PrintIGNode (FILE *fpout, IGNODE *ig) { BLIST *bl; fprintf(fpout, "*** IG# = %5d, VAR = %5d(%s), REG = %5d, NREAD = %6d, NWRITE = %3d\n", ig->ignum, ig->var, STname[ig->var-1], ig->reg, ig->nread, ig->nwrite); fprintf(fpout, " begblks : "); PrintBlockWithNum(fpout, ig->blkbeg); fprintf(fpout, " spanblk : "); if (!ig->blkspan) fprintf(fpout, " NONE\n"); else { fprintf(fpout, " %5d", ig->blkspan->blk->bnum); for (bl=ig->blkspan->next; bl; bl = bl->next) fprintf(fpout, ", %5d", bl->blk->bnum); fprintf(fpout, "\n"); } fprintf(fpout, " endblks : "); PrintBlockWithNum(fpout, ig->blkend); fprintf(fpout, " ldhoist : "); PrintBlockWithNum(fpout, ig->ldhoist); fprintf(fpout, " stpush : "); PrintBlockWithNum(fpout, ig->stpush); fprintf(fpout, " conflict: %s\n", PrintVecList(ig->conflicts, 0)); fprintf(fpout, "\n\n"); } void DumpIG(FILE *fpout, int N, IGNODE **igs) /* * Dumps IG information to file */ { int i; IGNODE *ig; BLIST *bl; fprintf(fpout, "Printing information for %d IGNODES:\n\n", N); for (i=0; i < N; i++) { ig = igs[i]; if (!ig) continue; #if 0 fprintf(fpout, "*** IG# = %5d, VAR = %5d, REG = %5d, NREAD = %6d, NWRITE = %3d\n", ig->ignum, ig->var, ig->reg, ig->nread, ig->nwrite); #else fprintf(fpout, "*** IG# = %5d, VAR = %5d(%s), REG = %5d, NREAD = %6d, NWRITE = %3d\n", ig->ignum, ig->var, STname[ig->var-1], ig->reg, ig->nread, ig->nwrite); #endif fprintf(fpout, " begblks : "); PrintBlockWithNum(fpout, ig->blkbeg); fprintf(fpout, " spanblk : "); if (!ig->blkspan) fprintf(fpout, " NONE\n"); else { fprintf(fpout, " %5d", ig->blkspan->blk->bnum); for (bl=ig->blkspan->next; bl; bl = bl->next) fprintf(fpout, ", %5d", bl->blk->bnum); fprintf(fpout, "\n"); } fprintf(fpout, " endblks : "); PrintBlockWithNum(fpout, ig->blkend); fprintf(fpout, " ldhoist : "); PrintBlockWithNum(fpout, ig->ldhoist); fprintf(fpout, " stpush : "); PrintBlockWithNum(fpout, ig->stpush); fprintf(fpout, " conflict: %s\n", PrintVecList(ig->conflicts, 0)); fprintf(fpout, "\n\n"); } } /* * =========================================================================== * For every local live entering or leaving the innermost loop, we globally * assign it to a register for the length of the loop. This is done before * any other asignment, and is part of getting the loop to our normal form. * The following routines are involved in doing this initial global assignment * =========================================================================== */ int AsgGlobalLoopVars(LOOPQ *loop, short *iregs, short *fregs, short *dregs) /* * Finds locals live on loop entry or exit: these locals will be assigned * to registers for the entire loop (i.e., global instead of live range * assignment) so that their load/stores may be moved outside the loop. * For each such local, search through available registers (0 in [i,f,d]regs * entry means reg is available), and assign the appropriate registers. * NOTE: only done on innermost loop * RETURNS: 0 on success, non-zero on failure. */ { int i, k, n, m; BLIST *bl; INSTQ *ip; short *sa, *s; INT_BVI iv; extern INT_BVI FKO_BVTMP; /*int j; */ /* * Find all variables set in list */ if (!loop->sets) loop->sets = NewBitVec(TNREG+32); else SetVecAll(loop->sets, 0); for (bl=loop->blocks; bl; bl = bl->next) { for (ip=bl->blk->inst1; ip; ip = ip->next) if (ip->set) BitVecComb(loop->sets, loop->sets, ip->set, '|'); } /* * Find regs and vars live on loop entry and exit(s) */ if (!loop->outs) loop->outs = NewBitVec(TNREG+32); else SetVecAll(loop->outs, 0); if (!FKO_BVTMP) FKO_BVTMP = NewBitVec(TNREG+32); else SetVecAll(FKO_BVTMP, 0); for (bl=loop->posttails; bl; bl = bl->next) BitVecComb(FKO_BVTMP, FKO_BVTMP, bl->blk->ins, '|'); for (bl=loop->tails; bl; bl = bl->next) BitVecComb(loop->outs, loop->outs, bl->blk->outs, '|'); BitVecComb(loop->outs, loop->outs, FKO_BVTMP, '&'); FKO_BVTMP = iv = BitVecComb(FKO_BVTMP, loop->outs, loop->header->ins, '|'); /* * we will preserve one register */ k = STstrlookup("_NONLOCDEREF"); SetVecBit(iv, k+TNREG-1, 0); sa = BitVec2Array(iv, 1); for (n=0, i=1; i <= sa[0]; i++) { k = sa[i]; /* * For locals (ignore registers), search appropriate type array, and * assign variable to the first available register */ if (k > TNREG) { k = STflag[k-1-TNREG]; k = FLAG2PTYPE(k); #if 0 /* previous implementation*/ if (k == T_INT) { s = iregs; n = NIR; } else if (k == T_DOUBLE) { s = dregs; n = NDR; } else if (k == T_FLOAT) { s = fregs; n = NFR; } else { fko_error(__LINE__, "Unknown type %d, file=%s\n", k, __FILE__); return(1); } for (k=0; k != n && s[k]; k++); if (k != n) s[k] = sa[i] - TNREG; else { fko_error(__LINE__, "Out of regs in global asg, var=%s, file=%s\n", STname[sa[i]-TNREG], __FILE__); return(1); } #else /* * Majedul: for float or double variable, ST index is stored in * appropriate regs array and store -1 to block the other. for * example: if a float variable is assigned, a float register is marked * and corresponding double register is blocked storing -1 */ if (k == T_INT) { s = iregs; n = NIR; } else if (k == T_DOUBLE) { s = dregs; n = NDR; } else if (k == T_FLOAT) { s = fregs; n = NFR; } else { fko_error(__LINE__, "Unknown type %d, file=%s\n", k, __FILE__); return(1); } for (m = 0; m != n && s[m]; m++); if (m != n) { s[m] = sa[i] - TNREG; /* store ST index of the var */ #ifdef X86 /* X86: block the alias regs */ if (k == T_FLOAT) dregs[m] = -1; if (k == T_DOUBLE) fregs[m] = -1; #endif } else { fko_warn(__LINE__, "Out of regs in global asg, id=%d, var=%s, file=%s\n", sa[i]-TNREG, STname[sa[i]-1-TNREG], __FILE__); return(1); } #endif } } free(sa); return(0); } void FindInitRegUsage(BLIST *bp, short *iregs, short *fregs, short *dregs) /* * Finds all registers already being used in blocks * for each data type, return an array of shorts NREG long. 0 means that * register is not used, -1 means it is being used. */ { int i, j, n; INT_BVI iv; extern INT_BVI FKO_BVTMP; short *sp; /* * Init all regs to unused */ for (i=0; i < IREGEND-IREGBEG; i++) iregs[i] = 0; for (i=0; i < FREGEND-FREGBEG; i++) fregs[i] = 0; for (i=0; i < DREGEND-DREGBEG; i++) dregs[i] = 0; /* * Majedul: Should check whether the blk info is updated or not!!! * previous optimization (like: Enforced Load Store) might change the * blk->uses, blk->defs, etc. So, need to recalculate those staffs */ if (!INDEADU2D) CalcAllDeadVariables(); else if (!CFUSETU2D || !CFU2D || !INUSETU2D) CalcInsOuts(bbbase); /* * Find all vars & regs used or defed in all blocks */ if (bp) { FKO_BVTMP = iv = BitVecCopy(FKO_BVTMP, bp->blk->uses); BitVecComb(iv, iv, bp->blk->defs, '|'); for (bp=bp->next; bp; bp = bp->next) { BitVecComb(iv, iv, bp->blk->uses, '|'); BitVecComb(iv, iv, bp->blk->defs, '|'); } } /* * Mark all registers used for unknown purposes */ sp = BitVec2Array(iv, 1); for (n=sp[0], i=0; i <= n; i++) { j = sp[i]; if (j < TNREG) { if (j >= IREGBEG && j < IREGEND) iregs[j-IREGBEG] = -1; else if (j >= FREGBEG && j < FREGEND) fregs[j-FREGBEG] = -1; else if (j >= DREGBEG && j < DREGEND) dregs[j-DREGBEG] = -1; } } free(sp); } int LoadStoreToMove(BLIST *blocks, int n, short *vars, short *regs) /* * Replaces all loads and stores of vars in blocks with MOVs from the * registers indicated in regs */ { int i, changes=0; short is; BLIST *bl; INSTQ *ip; extern INT_BVI FKO_BVTMP; enum inst *movs; /* * Set up n-length array showing what mov instruction to use based on data type */ movs = malloc(n*sizeof(enum inst)); assert(movs); for (i=0; i != n; i++) { is = -regs[i]; if (is >= IREGBEG && is < IREGEND) movs[i] = MOV; else if (is >= FREGBEG && is < FREGEND) movs[i] = FMOV; else if (is >= DREGBEG && is < DREGEND) movs[i] = FMOVD; /* else if (is >= VREGBEG && is < VREGEND) movs[i] = VFMOV; */ } for (bl=blocks; bl; bl = bl->next) { for (ip=bl->blk->ainst1; ip; ip = ip->next) { is = GET_INST(ip->inst[0]); switch(is) { case LD: case FLD: case FLDD: case VFLD: /* * See if variable being loaded from (inst[2]) is one of our targets * change LD instruction to MOV instruction */ is = ip->inst[2]; for (i=0; i != n && is != SToff[vars[i]-1].sa[2]; i++); if (i != n) { changes++; ip->inst[0] = movs[i]; ip->inst[2] = regs[i]; /* * Change var use to reg use */ SetVecBit(ip->use, is-1, 0); BitVecComb(ip->use, ip->use, Reg2Regstate(-regs[i]), '|'); } break; case ST: case FST: case FSTD: case VFST: /* * See if variable being stored to (inst[1]) is one of our targets * change ST instruction to MOV instruction */ is = ip->inst[1]; for (i=0; i != n && is != SToff[vars[i]-1].sa[2]; i++); if (i != n) { changes++; ip->inst[0] = movs[i]; ip->inst[1] = regs[i]; /* * Change var set to reg set */ SetVecBit(ip->set, is-1, 0); BitVecComb(ip->set, ip->set, Reg2Regstate(-regs[i]), '|'); } break; default:; } } } free(movs); /* * This routine keeps the instq set/use up to date, but invalidates * block-level set/use (CFUSETU2D) and deads (INDEADU2D) */ INDEADU2D = CFUSETU2D = 0; return(changes); } int DoLoopGlobalRegAssignment(LOOPQ *loop) /* * This routine does global register assignment for all locals referenced * in the loop, and live on loop entry or exit */ { int i, j, n, iret; short k; short iregs[NIR], fregs[NFR], dregs[NDR]; short *vars, *regs; FindInitRegUsage(loop->blocks, iregs, fregs, dregs); /* * let the code continue though not all variables got a register to assign */ AsgGlobalLoopVars(loop, iregs, fregs, dregs); /* * Find total number of global assignments done, and allocate space to hold * mapping */ for (n=i=0; i < NIR; i++) if (iregs[i] > 0) n++; for (i=0; i < NFR; i++) if (fregs[i] > 0) n++; for (i=0; i < NDR; i++) if (dregs[i] > 0) n++; regs = malloc(2*n*sizeof(short)); assert(regs); vars = regs + n; /* * Setup variable-to-register mapping, and perform register assignment * on body of loop */ for (j=i=0; i < NIR; i++) { if (iregs[i] > 0) { vars[j] = iregs[i]; regs[j++] = -i - IREGBEG; } } for (i=0; i < NFR; i++) { if (fregs[i] > 0) { vars[j] = fregs[i]; regs[j++] = -i - FREGBEG; } } for (i=0; i < NDR; i++) { if (dregs[i] > 0) { vars[j] = dregs[i]; regs[j++] = -i - DREGBEG; } } iret = i = LoadStoreToMove(loop->blocks, n, vars, regs); free(regs); /* * Insert appopriate LD in preheader, and ST in post-tails */ assert(loop->preheader); assert(loop->posttails); PrintComment(loop->preheader, NULL, NULL, "START global asg preheader load"); PrintComment(loop->posttails->blk, NULL, loop->posttails->blk->inst1, "DONE global asg sunk stores"); for (i=0; i < NIR; i++) { if (iregs[i] > 0) { k = SToff[iregs[i]-1].sa[2]; if (BitVecCheck(loop->header->ins, iregs[i]+TNREG-1)) CalcThisUseSet(InsNewInst(loop->preheader, NULL, NULL, LD, -i-IREGBEG, k, 0)); if (BitVecCheck(loop->outs, iregs[i]+TNREG-1) && BitVecCheck(loop->sets, iregs[i]+TNREG-1)) InsInstInBlockList(loop->posttails, 1, ST, k, -i-IREGBEG, 0); } } for (i=0; i < NFR; i++) { if (fregs[i] > 0) { k = SToff[fregs[i]-1].sa[2]; if (BitVecCheck(loop->header->ins, fregs[i]+TNREG-1)) CalcThisUseSet(InsNewInst(loop->preheader, loop->preheader->instN, NULL, FLD, -i-FREGBEG, k, 0)); if (BitVecCheck(loop->outs, fregs[i]+TNREG-1) && BitVecCheck(loop->sets, fregs[i]+TNREG-1)) InsInstInBlockList(loop->posttails, 1, FST, k, -i-FREGBEG, 0); } } for (i=0; i < NDR; i++) { if (dregs[i] > 0) { k = SToff[dregs[i]-1].sa[2]; if (BitVecCheck(loop->header->ins, dregs[i]+TNREG-1)) CalcThisUseSet(InsNewInst(loop->preheader, loop->preheader->instN, NULL, FLDD, -i-DREGBEG, k, 0)); if (BitVecCheck(loop->outs, dregs[i]+TNREG-1) && BitVecCheck(loop->sets, dregs[i]+TNREG-1)) InsInstInBlockList(loop->posttails, 1, FSTD, k, -i-DREGBEG, 0); } } PrintComment(loop->preheader, NULL, NULL, "DONE global asg preheader load"); PrintComment(loop->posttails->blk, NULL, loop->posttails->blk->inst1, "START global asg sunk stores"); CFUSETU2D = INUSETU2D = INDEADU2D = 0; return(iret); } static INSTQ *FindReg2RegMove(BBLOCK *bp, INSTQ *start, INSTQ *end) /* * Finds first register-to-register move in bp, between [start,end] * if start == NULL, start at beginning of block, if end == NULL go to end */ { INSTQ *ip; enum inst inst; if (!bp) return(NULL); if (!start) start = bp->ainst1; if (!start) return(NULL); if (!end) end = bp->ainstN; do { ip = start; inst = GET_INST(ip->inst[0]); if (IS_MOVE(inst) && ip->inst[1] < 0 && ip->inst[2] < 0) return(ip); start = start->next; } while(start && ip != end); return(NULL); } int Dist2RefInBlock(BBLOCK *bp, int var, INSTQ *start, INSTQ *end) /* * Finds number of instructions between start and next ref of var * if start == NULL, start at beginning of block, if end == NULL go to end * RETURNS: # of inst from start otherwise (starting from 1), the negative * # of inst in block from start if not found in block */ { INSTQ *ip; enum inst inst; int i=1; if (!bp) return(0); if (!start) start = bp->ainst1; if (!start) return(0); if (!end) end = bp->ainstN; do { ip = start; inst = GET_INST(ip->inst[0]); if (ACTIVE_INST(inst) && inst != LABEL && inst != NOP && inst != UNIMP) { i++; if (BitVecCheck(ip->use, var) || BitVecCheck(ip->set, var)) return(i); } start = start->next; } while(start && ip != end); return(-i); } int Dist2Ref(BBLOCK *bp, int scopeblks, int var, INSTQ *start, INSTQ *end) { int i, j=0, k=0; i = Dist2RefInBlock(bp, var, start, end); if (i < 0 && BitVecCheck(bp->outs, var)) { if (bp->usucc && BitVecCheck(bp->usucc->ins, var) && BitVecCheck(scopeblks, bp->usucc->bnum-1)) j = Dist2Ref(bp->usucc, scopeblks, var, NULL, NULL); if (bp->csucc && BitVecCheck(bp->csucc->ins, var) && BitVecCheck(scopeblks, bp->csucc->bnum-1)) k = Dist2Ref(bp->csucc, scopeblks,var, NULL, NULL); if (k > j) j = k; i += j; } else if (i < 0) i = -i; return(i); } int SubRegUse(short *op, short reg, short sub) /* * Finds if register reg is used in instruction operand op; if it is, replaces * its use with a use of sub. * RETURNS: 1 if register was found, 0 otherwise. */ { int found=0; short op1 = *op; if (op1 == reg) { *op = sub; found = 1; } else if (op1 > 0 && IS_DEREF(STflag[op1-1])) { if (SToff[op1-1].sa[0] == reg) { found = 1; SToff[op1-1].sa[0] = sub; } if (SToff[op1-1].sa[1] == reg) { found = 1; SToff[op1-1].sa[1] = sub; } } return(found); } static int SuccIsCopyPropTarg(BBLOCK *ob, /* origin block */ BBLOCK *sb, /* successor block */ short dest, /* reg we are replacing */ short src) /* reg we are CopyProping */ /* * Returns: 0 if successor sb rules out cross-block copy prop, 1 otherwise */ { int iret = 1; BLIST *bl; if (sb) { /* * If succ does not have dest live on entry, CopyProp is not ruled out */ if (BitVecCheck(sb->ins, dest-1)) { /* * If succ has source live on entry, CopyProp is ruled out */ iret = !BitVecCheck(sb->ins, src-1); if (iret) { /* * If any pred aside from ob has dest live on exit, rule it out */ for (bl=sb->preds; bl; bl = bl->next) if (BitVecCheck(bl->blk->outs, dest-1) && bl->blk != ob) break; iret = bl ? 0 : 1; } } } return(iret); } int CopyPropTrans0(int SRCLIVE, BLIST *scope, INT_BVI scopeblks, BBLOCK *blk, INSTQ *ipstart, short mov, short dest, short src) /* * Performs copy prop starting from ipret, where src reg is dead * When src is dead, we can replace all use and set of dest with src, until * dest is dead or src is live again. */ { INSTQ *ip; int FoundIt, j, LIVEDONE=0; int change=0; BLIST *bl; INT_BVI ivsrc, ivdst; extern INT_BVI FKO_BVTMP; extern BBLOCK *bbbase; /*int flag = 0;*/ bl = FindInList(scope, blk); if (bl->ptr) change = 1; ivdst = FKO_BVTMP = BitVecCopy(FKO_BVTMP, Reg2Regstate(dest)); ivsrc = Reg2Regstate(src); for (ip=ipstart?ipstart->next:blk->ainst1; ip; ip = ip->next) { j = GET_INST(ip->inst[0]); if (!ACTIVE_INST(j)) continue; /* * If src becomes live again, put move back, and stop copy prop, unless * src becomes live due to a move from dest */ if (BitVecCheckComb(ip->set, ivsrc, '&') && (j != mov || ip->inst[1] != -src || ip->inst[2] != -dest)) goto PUTMOVEBACK; /* * Stop copy prop if we see idiv on x86 */ #ifdef X86 if((j == DIV || j == UDIV) && (BitVecCheckComb(ip->set, ivdst, '&') || BitVecCheckComb(ip->use, ivdst, '&') || BitVecCheckComb(ip->use, ivsrc, '&'))) goto PUTMOVEBACK; #endif /* * If we have a set of dest, change it to a use of src, and keep going with * propogation if this dest updated itself */ if (BitVecCheck(ip->set, dest-1)) { /* * If the src is live, a set of dest ends the CopyProp, but not until * after we have changed this inst use of dest to src */ if (SRCLIVE) { #ifdef X86 if (ip->inst[2] == -dest) goto PUTMOVEBACK; #endif if (BitVecCheck(ip->use, dest-1)) LIVEDONE = 1; else goto PUTMOVEBACK; } else if (ip->inst[1] == -dest) { ip->inst[1] = -src; BitVecComb(ip->set, ip->set, ivdst, '-'); BitVecComb(ip->set, ip->set, ivsrc, '|'); if (BitVecCheck(ip->deads, dest-1)) { BitVecComb(ip->deads, ip->deads, ivdst, '-'); BitVecComb(ip->deads, ip->deads, ivsrc, '|'); } /* * NOTE: for instructions where destination is also in-use (like: FMA) * we need to update the ip->use with dst too. */ if (IS_DEST_INUSE_IMPLICITLY(ip->inst[0])) { /* * FIXED: if we have same register as source and destination too; * updating ip->use would prevent the source to change it later. * so, change the op2 here before updating the liverange */ if (ip->inst[2] == -dest) /* op1 == op2*/ ip->inst[2] = -src; if (ip->inst[3] == -dest) /* op1 == op3*/ ip->inst[3] = -src; BitVecComb(ip->use, ip->use, ivdst, '-'); BitVecComb(ip->use, ip->use, ivsrc, '|'); } change++; } else /* stop copy prop on implicit set */ goto PUTMOVEBACK; } /* * If we have a use of former dest, change it to a use of src */ if (BitVecCheck(ip->use, dest-1)) { FoundIt = 0; if (ip->inst[0] != RET) { FoundIt = SubRegUse(&ip->inst[2], -dest, -src); FoundIt |= SubRegUse(&ip->inst[3], -dest, -src); /* * If we have a store, may be implicit use in memory address */ if (IS_STORE(ip->inst[0]) && 1) { assert(ip->inst[1] > 0); FoundIt |= SubRegUse(&ip->inst[1], -dest, -src); } if (FoundIt) { BitVecComb(ip->use, ip->use, ivdst, '-'); BitVecComb(ip->use, ip->use, ivsrc, '|'); change++; if (LIVEDONE) { ip = ip->next; INDEADU2D = 0; return(change); } } else /* not found, is implicit use, put move back & stop */ goto PUTMOVEBACK; } else /* for implicit use like return, put move back & stop */ goto PUTMOVEBACK; } /* * If dest is dead without updating itself, end copy prop */ if (BitVecCheck(ip->deads, dest-1)) { BitVecComb(ip->deads, ip->deads, ivdst, '-'); BitVecComb(ip->deads, ip->deads, ivsrc, '|'); INDEADU2D = 0; return(change); } /* * If src is live and we see that it dies, change SRCLIVE * NOTE: a dead src by a set is handled as 1st case in loop */ if (SRCLIVE && BitVecCheck(ip->deads, src-1)) SRCLIVE = 0; } /* * If dest was still live on exit, see if cross-block prop is possible * NOTE: if src is live on block entry, we can't do cross-blk CP, so * always say SRCLIVE=0 initially for succ blks */ if ((blk->csucc || blk->usucc) && BitVecCheck(blk->outs, dest-1)) { if (SuccIsCopyPropTarg(blk, blk->usucc, dest, src) && SuccIsCopyPropTarg(blk, blk->csucc, dest, src) && 1) { if (mov == MOV) j = 0; change++; if (blk->usucc && BitVecCheck(blk->usucc->ins, dest-1)) { bl = FindInList(scope, blk->usucc); if (bl && !bl->ptr) /* majedul: bl can be NULL */ { bl->ptr = (void*) 1; change += CopyPropTrans0(0, scope, scopeblks, blk->usucc, NULL, mov, dest, src); bl->ptr = NULL; BitVecComb(blk->usucc->ins, blk->usucc->ins, ivdst, '-'); BitVecComb(blk->usucc->ins, blk->usucc->ins, ivsrc, '|'); } } if (blk->csucc && BitVecCheck(blk->csucc->ins, dest-1)) { bl = FindInList(scope, blk->csucc); if (bl && !bl->ptr) /* majedul: bl can be NULL*/ { bl->ptr = (void*) 1; change += CopyPropTrans0(0, scope, scopeblks, blk->csucc, NULL, mov, dest, src); bl->ptr = NULL; BitVecComb(blk->csucc->ins, blk->csucc->ins, ivdst, '-'); BitVecComb(blk->csucc->ins, blk->csucc->ins, ivsrc, '|'); } } CFUSETU2D = 0; BitVecComb(blk->outs, blk->outs, ivdst, '-'); BitVecComb(blk->outs, blk->outs, ivsrc, '|'); } else { if (blk->ainstN && IS_BRANCH(blk->ainstN->inst[0])) ip = blk->ainstN; else ip = NULL; goto PUTMOVEBACK; } } if (change) INDEADU2D = 0; return(change); PUTMOVEBACK: if (change) { ip = InsNewInst(blk, NULL, ip, mov, -dest, -src, 0); CalcThisUseSet(ip); assert(ip->set > 0 && ip->use > 0); INDEADU2D = 0; } return(change); } INSTQ *CopyPropTrans(BLIST *scope, INT_BVI scopeblks, BBLOCK *blk, INSTQ *ipret) /* * Attempts to do copy prop in block blk starting at ipret * RETURNS: instruction following ipret after transforms or NULL if no * transform is done. */ { int change; short dest, src, mov; /*INSTQ *ip; */ dest = -ipret->inst[1]; src = -ipret->inst[2]; /* * If it's a useless move, simply delete it */ if (dest == src) { /* INDEADU2D = 0; */ CFUSETU2D = INDEADU2D = 0; /* * Majedul: reported error form Valgrind! inst deleted would be accessed * later. FIXED this issue. see DoCopyProp() */ #if 1 return(DelInst(ipret)); #else ip = ipret; fprintf(stderr,"DEL: %p ip->inst = %s\t%d %d %d\n", ip, instmnem[ip->inst[0]], ip->inst[1], ip->inst[2], ip->inst[3]); ipret = DelInst(ipret); if (!ipret) fprintf(stderr, "NULL!!\n"); fflush(stderr); return(ipret); #endif } if (!INDEADU2D) CalcAllDeadVariables(); else if (!CFUSETU2D || !CFU2D || !INUSETU2D) CalcInsOuts(bbbase); mov = ipret->inst[0]; /* * Do not do copy prop if src or dest is x87 reg */ #ifdef X86_320000 sp = Int2Reg(-src); if (sp[1] == 's' && sp[2] == 't') return(NULL); sp = Int2Reg(-dest); if (sp[1] == 's' && sp[2] == 't') return(NULL); #endif /* * Do not do copy prop if src and dest are not registers of the same type */ if (ireg2type(src) != ireg2type(dest)) return(NULL); if (BitVecCheck(ipret->deads, src-1)) change = CopyPropTrans0(0, scope, scopeblks, blk, ipret, mov, dest, src); else change = CopyPropTrans0(1, scope, scopeblks, blk, ipret, mov, dest, src); if (change) { /*PrintThisInst(stderr, -1, ipret );*/ ipret = DelInst(ipret); } else ipret = NULL; return(ipret); } int DoCopyProp(BLIST *scope) /* * Performs copy propogation on scope. */ { int CHANGE=0; INT_BVI scopeblks; INSTQ *ip=NULL, *next, *ipnext; BLIST *bl, *epil=NULL, *lp; extern BBLOCK *bbbase; scopeblks = Scope2BV(scope); for (bl=scope; bl; bl = bl->next) { if (bl != epil) { do { ip = FindReg2RegMove(bl->blk, ip, NULL); if (ip) { /* * Majedul: ip itself may be deleted in CopyPropTrans() * so, why not save the ip->next before */ ipnext = ip->next; next = CopyPropTrans(scope, scopeblks, bl->blk, ip); for (lp=bl; lp; lp = lp->next) lp->ptr = NULL; if (next) { ip = next; CHANGE++; } /* * Majedul: Invalid read reported by valgrind! * FIXED: CopyPropTrans() may change the ip itself but * returning NULL! What if DelInst() delete ip itself!!!! * use ipnext to keep track previous one. * NOTE: if ip->next is deleted and CopyPropTrans returns NULL as * the next inst of ip->next is NULL !!! */ else ip = ipnext; } } while(ip); } } /* fprintf(stderr, "\nCopyProp CHANGE=%d\n", CHANGE); */ if (CHANGE) CFUSETU2D = INDEADU2D = 0; return(CHANGE); } int DoRevCopyPropTrans(INSTQ *ipsrc, /* inst where src is set */ INSTQ *ipdst, /* inst where dest is set */ int nuse) /* # of intervening uses of src */ /* * Actually perform Reverse Copy Prop transform on [ipsrc,ipdst] region of blk * Changes all ref of src to dest */ { INSTQ *ip; int i, nseen=(-1); short src, dest, op; assert(ipsrc && ipdst) src = -ipdst->inst[2]; dest = -ipdst->inst[1]; for (ip = ipsrc; ip && ip != ipdst && nseen < nuse; ip = ip->next) { if (!ACTIVE_INST(ip->inst[0])) continue; if (ip->use && (BitVecCheck(ip->use, src-1)||BitVecCheck(ip->set,src-1))) { for (i=1; i < 4; i++) { op = ip->inst[i]; if (op == -src) ip->inst[i] = -dest; else if (op > 0 && IS_DEREF(STflag[op-1])) { if (SToff[op-1].sa[0] == -src) SToff[op-1].sa[0] = -dest; if (SToff[op-1].sa[1] == -src) SToff[op-1].sa[1] = -dest; } } CalcThisUseSet(ip); nseen++; } } /* ipdst->inst[2] = -dest; CalcThisUseSet(ipdst); */ DelInst(ipdst); return(1); } int DoReverseCopyProp(BLIST *scope) /* * This crippled version does only in-block rcp */ { BLIST *bl; INSTQ *ip, *ipp, *ips, *ipps; int nchanges=0, nuse; enum inst inst; short src, dest; if (!INDEADU2D) CalcAllDeadVariables(); else if (!CFUSETU2D || !CFU2D || !INUSETU2D) CalcInsOuts(bbbase); for (bl=scope; bl; bl = bl->next) { for (ip=bl->blk->ainstN; ip; ip = ipp) { ipp = ip->prev; inst = ip->inst[0]; /* * FIXED: dest is not defined yet!!! * FIXME: need to check for the short int instruction not to use * r8 to r15 instruciton */ /*if (IS_MOVE(inst) && ip->inst[1] < 0 && ip->inst[2] < 0 && ireg2type(-ip->inst[1]) == ireg2type(-dest)) */ if (IS_MOVE(inst) && ip->inst[1] < 0 && ip->inst[2] < 0 && ireg2type(-ip->inst[1]) == ireg2type(-ip->inst[2])) { /* * If src reg is dead on reg2reg move, possible reverseCP candidate * NOTE: leave src==dest moves for CP to clean up */ src = -ip->inst[2]; dest = -ip->inst[1]; if (BitVecCheck(ip->deads, src-1) && src != dest && ireg2type(src) == ireg2type(dest) && src != REG_SP) { /* * Look for inst that set src */ nuse = 0; /* * FIXED: why don't we traverse upward to find out the set of src! * We only check previous inst and go to the next .... !!!! */ for (ips=ip->prev; ips; ips = ipps) { ipps = ips->prev; if (!ips->set) continue; /* * NOTE: We can't update operands of short integer (32 bit in * 64 bit arch) inst with register likes : R8~R15. Specially * in the prologue of the function. */ #if defined (X86_64) if (IS_SHORT_INT_OP(ips->inst[0])) { if (dest >= (IREGBEG+NSR) && (BitVecCheck(ips->set, src-1) || BitVecCheck(ips->use, src-1)) ) { ips = NULL; break; } } #endif /* * FIXED: incase of DIV or UDIV, we have restrictions on register * we can't apply reverse copy prop on them. */ #ifdef X86 if (ips->inst[0] == DIV || ips->inst[0] == UDIV) { /* * for idiv, we can't change dest and src1 (rax, rdx) at all */ #if 1 if (src == -ips->inst[1] || src == -ips->inst[2] || dest == -ips->inst[1] || dest == -ips->inst[2]) #endif { ips = NULL; break; } } #endif if (BitVecCheck(ips->set, src-1) && !BitVecCheck(ips->use, src-1)) break; if (BitVecCheck(ips->use, src-1)) nuse++; if (BitVecCheck(ips->use, dest-1) || BitVecCheck(ips->set, dest-1)) { ips = NULL; break; } /* * NOTE: no need to handle this case specially, since * BitVecCheck(ips->use, src-1) would catch that */ #if 0 if (BitVecCheck(ips->set, src-1) && IS_DEST_INUSE_IMPLICITLY(ips->inst[0])) { nuse++; } #endif } if (ips && ips->inst[1] == -src) { /* * all inst of DEST_INUSE_IMPLICITLY should be catched by * BitVecCheck(ips->use, src-1) conditionals */ #if 0 if (IS_DEST_INUSE_IMPLICITLY(ips->inst[0])) { // fprintf(stderr, "AFTER in use\n"); } else #endif assert(!IS_DEST_INUSE_IMPLICITLY(ips->inst[0])); nchanges += DoRevCopyPropTrans(ips, ip, nuse); } } } } } if (nchanges) CFUSETU2D = INDEADU2D = 0; /*fprintf(stderr, "RCP: nchanges=%d\n", nchanges);*/ return(nchanges); } int DoEnforceLoadStore(BLIST *scope) /* * transforms all instructions that directly access memory to LD/ST followed * by inst operating on registers * NOTE: presently can't do this, because then reg asg deletes store of * absval to mem, which is needed for cleanup; you wind up with * illegal reg move (from VFREG to FREG) * FIXED: called RevealArchMemUses() before starting of any repeatable * optimizations */ { BLIST *bl; INSTQ *ip, *ipN; enum inst inst; int j, ir; int nchanges=0; short op; extern INT_BVI FKO_BVTMP; /*extern int DTabs, DTabsd, DTnzero, DTnzerod;*/ /*extern int DTabss, DTabsds, DTnzeros, DTnzerods;*/ if (!FKO_BVTMP) FKO_BVTMP = NewBitVec(TNREG); if (!INDEADU2D) CalcAllDeadVariables(); else if (!CFUSETU2D || !CFU2D || !INUSETU2D) CalcInsOuts(bbbase); for (bl=scope; bl; bl = bl->next) { for (ip=bl->blk->ainst1; ip; ip = ip->next) { inst = ip->inst[0]; if (ACTIVE_INST(inst) && !IS_LOAD(inst) && !IS_STORE(inst) && inst != LABEL) { op = ip->inst[3]; if (op < 1) op = 0; else if (!IS_DEREF(STflag[op-1])) op = 0; /* * Majedul: I skipped the update of the 2nd src operand * from here, added a new function to reveal this kind of arch event */ #if defined(X86) && 0 if (ip->inst[3] >= 0) { if (inst == FABS) ip->inst[3] = op = SToff[DTabs-1].sa[2]; else if (inst == VFABS) ip->inst[3] = op = SToff[DTabs-1].sa[2]; else if (inst == FABSD) ip->inst[3] = op = SToff[DTabsd-1].sa[2]; else if (inst == VDABS) ip->inst[3] = op = SToff[DTabsd-1].sa[2]; else if (inst == FNEG) ip->inst[3] = op = SToff[DTnzero-1].sa[2]; else if (inst == FNEGD) ip->inst[3] = op = SToff[DTnzerod-1].sa[2]; } #else /* * FIXME: disable this for hybrid ABS/NEG for now. Need to handle * with special case, since they are hybrid now, dest reg * is not same with src regs! */ if (inst == VFSABS || inst == VDSABS || inst == VFSNEG || inst == VDSNEG ) continue; #endif if (!op) { op = ip->inst[2]; /* * Majedul: op can be negative if reg. There may be an invalid read * I corrected this. */ if ( op > 0) if (!IS_DEREF(STflag[op-1])) op = 0; } if (inst == PREFR || inst == PREFW || inst == PREFRS || inst == PREFWS) op = 0; if (op > 0) { assert(ip->inst[1] < 0); /* dest op must be register */ j = ireg2type(-ip->inst[1]); ir = GetRegFindLR(j, FKO_BVTMP, ip); if (ir) { switch(j) { case T_INT: inst = LD; break; case T_FLOAT: inst = FLD; break; case T_DOUBLE: inst = FLDD; break; case T_VFLOAT: inst = VFLD; break; case T_VDOUBLE: inst = VDLD; break; #ifdef VIREGBEG case T_VINT: inst = VLD; break; #endif } ipN = InsNewInst(NULL, NULL, ip, inst, -ir, op, 0); if (op == ip->inst[3]) ip->inst[3] = -ir; else { assert(ip->inst[2] == op); ip->inst[2] = -ir; } CalcThisUseSet(ipN); CalcThisUseSet(ip); nchanges++; } } } } } /* fprintf(stderr, "ELS, NCHANGES=%d\n\n",nchanges); */ if (nchanges) CFUSETU2D = INDEADU2D = 0; return(nchanges); } INSTQ *FindNextUseInBlock(INSTQ *ip0, int var) /* * RETURNS: INSTQ of next instruction that uses all vars set in iv within * block starting at ip0, NULL if not found */ { INSTQ *ip; if (ip0) { for (ip=ip0->next; ip; ip = ip->next) { if (ip->use && BitVecCheck(ip->use, var)) return(ip); } } return(NULL); } int DoRemoveOneUseLoads(BLIST *scope) /* * Changes ld followed by one and only one use to mem-src instruction * (possible only on x86) */ { INSTQ *ip, *ipn, *ipuse; BLIST *bl; int nchanges=0; enum inst inst; short k; /*INT_BVI iv;*/ /*extern INT_BVI FKO_BVTMP;*/ /* * Only x86 has these from-memory operations */ #ifndef X86 return(0); #endif if (!INDEADU2D) CalcAllDeadVariables(); else if (!CFUSETU2D || !CFU2D || !INUSETU2D) CalcInsOuts(bbbase); /*if (!FKO_BVTMP) FKO_BVTMP = NewBitVec(TNREG); iv = FKO_BVTMP;*/ for (bl=scope; bl; bl = bl->next) { for (ip=bl->blk->ainst1; ip; ip = ipn) { ipn = ip->next; inst = ip->inst[0]; /* * FIXED: we can't combine unaligned vector load */ if (IS_LOAD(inst) && inst != VFLDS && inst != VDLDS && inst != VFLDSB && inst != VDLDSB && !IS_UNALIGNED_VLOAD(inst)) { k = -ip->inst[1]; ipuse = FindNextUseInBlock(ip, k-1); if (ipuse) { inst = ipuse->inst[0]; if (ipuse->inst[3] == ip->inst[1] && !IS_NOMEM(inst) && ipuse->inst[2] != -k && BitVecCheck(ipuse->deads, k-1)) { ipuse->inst[3] = ip->inst[2]; DelInst(ip); CalcThisUseSet(ipuse); nchanges++; } } } } } if (nchanges) CFUSETU2D = INDEADU2D = 0; /*fprintf(stderr, "U1: nchanges=%d\n", nchanges);*/ return(nchanges); } int DoOptArchSpecInst(BLIST *scope) /* * we replace SHL/ADD with LEA here, can be extended later */ { int i, k; INSTQ *ip, *ip1, *ipn; BLIST *bl; BBLOCK *bp; enum inst inst; int nchanges = 0; /* * only X86 supports LEA */ #ifndef X86 return(0); #endif if (!INDEADU2D) CalcAllDeadVariables(); else if (!CFUSETU2D || !CFU2D || !INUSETU2D) CalcInsOuts(bbbase); /* * if scope not defined, add all block list */ for (bl=scope; bl; bl = bl->next) { for (ip=bl->blk->ainst1; ip; ip = ipn) { ipn = ip->next; if (ip->inst[0] == SHL && ip->next->inst[0] == ADD) { ip1 = ip->next; assert(ip->inst[1] == ip->inst[2]); k = -ip->inst[2]; if (k == -ip1->inst[3] && BitVecCheck(ip1->deads, k-1) && IS_CONST(STflag[ip->inst[3]-1])) { i = SToff[ip->inst[3]-1].i; if (i ==1 || i == 2 || i == 3 ) { switch(i) { case 1: /* 2 */ ip->inst[0] = LEA2; break; case 2: /* 4 */ ip->inst[0] = LEA4; break; case 3: /* 8 */ ip->inst[0] = LEA8; break; } ip->inst[1] = ip1->inst[1]; ip->inst[2] = ip1->inst[2]; ip->inst[3] = ip1->inst[3]; CalcThisUseSet(ip); ipn = ip1->next; DelInst(ip1); nchanges++; } } } } } if (nchanges) CFUSETU2D = INDEADU2D = 0; return(nchanges); } static enum inst type2move(int type) { enum inst mov; switch(type) { case T_INT : mov = MOV; break; case T_FLOAT : mov = FMOV; break; case T_DOUBLE : mov = FMOVD; break; case T_VFLOAT : mov = VFMOV; break; case T_VDOUBLE: mov = VDMOV; break; #ifdef VIREGBEG case T_VINT: mov = VMOV; break; #endif default: fko_error(__LINE__, "Unknown type %d, file=%s\n", type, __FILE__); } return(mov); } int DoLastUseLoadRemoval(BLIST *scope) /* * If there's a load that can be made implicit, and it's not handled by * RemoveOneUseLoads due to being set, moves it into memory by doing * a register-reg move (which should be cleaned up by CP & RCP) */ { BLIST *bl; INSTQ *ipld, *ip, *ipn, *ipN; int nchanges=0, j, k, typ; enum inst inst; /* * Only x86 has these from-memory operations */ #ifndef X86 return(0); #endif if (!INDEADU2D) CalcAllDeadVariables(); else if (!CFUSETU2D || !CFU2D || !INUSETU2D) CalcInsOuts(bbbase); for (bl=scope; bl; bl = bl->next) { for (ipld=bl->blk->ainst1; ipld; ipld = ipn) { ipn = ipld->next; inst = ipld->inst[0]; /* * Majedul: we can't skip unaligned vector load and combine them * so, we can't do it with unaligned load * FIXED. */ if (IS_LOAD(inst) && inst != VFLDS && inst != VDLDS && inst != VFLDSB && inst != VDLDSB && !IS_UNALIGNED_VLOAD(inst)) { k = -ipld->inst[1]; for (ip=ipld->next; ip; ip = ip->next) { if (!ip->use) continue; if (BitVecCheck(ip->use, k-1) || BitVecCheck(ip->set, k-1)) break; } if (ip) { j = -ip->inst[3]; typ = j > 0 ? ireg2type(j) : 0; inst = ip->inst[0]; if (j > 0 && j != k && ip->inst[1] == -k && ip->inst[2] == -k && BitVecCheck(ip->deads, j-1) && typ == ireg2type(k) && !IS_NOMEM(inst) && IS_REORD(inst)) { ipN = InsNewInst(NULL, NULL, ip, type2move(typ), -k, -j, 0); CalcThisUseSet(ipN); ip->inst[3] = ipld->inst[2]; CalcThisUseSet(ip); DelInst(ipld); nchanges++; } } } } } if (nchanges) CFUSETU2D = INDEADU2D = 0; return(nchanges); } /* * To debug: print NIG and TNIG */ void PrintNIG(FILE *fout) { fprintf(fout,"Total IG :\n"); fprintf(fout, "NIG = %d\n", NIG); fprintf(fout, "TNIG = %d\n", TNIG); }
27.546124
83
0.500986
[ "vector", "transform", "3d" ]
d4658a7362b443b32e2c6959f09802b2b8e77e5b
1,972
h
C
multimedia/danim/src/appel/privinc/cropdimg.h
npocmaka/Windows-Server-2003
5c6fe3db626b63a384230a1aa6b92ac416b0765f
[ "Unlicense" ]
17
2020-11-13T13:42:52.000Z
2021-09-16T09:13:13.000Z
multimedia/danim/src/appel/privinc/cropdimg.h
sancho1952007/Windows-Server-2003
5c6fe3db626b63a384230a1aa6b92ac416b0765f
[ "Unlicense" ]
2
2020-10-19T08:02:06.000Z
2020-10-19T08:23:18.000Z
multimedia/danim/src/appel/privinc/cropdimg.h
sancho1952007/Windows-Server-2003
5c6fe3db626b63a384230a1aa6b92ac416b0765f
[ "Unlicense" ]
14
2020-11-14T09:43:20.000Z
2021-08-28T08:59:57.000Z
#ifndef _CROPDIMG_H #define _CROPDIMG_H /*------------------------------------- Copyright (c) 1996 Microsoft Corporation Abstract: Cropped Image class header -------------------------------------*/ #include "privinc/imagei.h" #include "privinc/bbox2i.h" class CroppedImage : public AttributedImage { public: CroppedImage(const Bbox2 &box, Image *img) : _croppingBox(box), AttributedImage(img) {} void Render(GenericDevice& dev); inline const Bbox2 BoundingBox(void) { return IntersectBbox2Bbox2(_croppingBox, _image->BoundingBox()); } Real DisjointBBoxAreas(DisjointCalcParam &param); void _CollectDirtyRects(DirtyRectCtx &ctx); #if BOUNDINGBOX_TIGHTER const Bbox2 BoundingBoxTighter(Bbox2Ctx &bbctx) { //!!!BBOX: This still may not be the tightest box of the image. Bbox2Ctx bbctxIdentity; Bbox2 bbox = IntersectBbox2Bbox2(_croppingBox, _image->BoundingBoxTighter(bbctxIdentity)); Transform2 *xf = bbctx.GetTransform(); return TransformBbox2(xf, bbox); } #endif // BOUNDINGBOX_TIGHTER #if _USE_PRINT // Print a representation to a stream. ostream& Print(ostream& os) { return os << "CroppedImage" << "<bounding box>" << _image; } #endif const Bbox2 OperateOn(const Bbox2 &box) { return IntersectBbox2Bbox2(_croppingBox, box); } Bool DetectHit(PointIntersectCtx& ctx); const Bbox2& GetBox(void) { return _croppingBox; } virtual VALTYPEID GetValTypeId() { return CROPPEDIMAGE_VTYPEID; } virtual bool CheckImageTypeId(VALTYPEID type) { return (type == CroppedImage::GetValTypeId() || AttributedImage::CheckImageTypeId(type)); } virtual void DoKids(GCFuncObj proc) { AttributedImage::DoKids(proc); } protected: Bbox2 _croppingBox; }; #endif /* _CROPDIMG_H */
25.61039
99
0.625254
[ "render" ]
d465a279264b1727f2f41302250799b40015893a
1,606
h
C
Engine/Source/Runtime/OpenGLDrv/Private/Mac/MacOpenGLContext.h
PopCap/GameIdea
201e1df50b2bc99afc079ce326aa0a44b178a391
[ "BSD-2-Clause" ]
null
null
null
Engine/Source/Runtime/OpenGLDrv/Private/Mac/MacOpenGLContext.h
PopCap/GameIdea
201e1df50b2bc99afc079ce326aa0a44b178a391
[ "BSD-2-Clause" ]
2
2015-06-21T17:38:11.000Z
2015-06-22T20:54:42.000Z
Engine/Source/Runtime/OpenGLDrv/Private/Mac/MacOpenGLContext.h
PopCap/GameIdea
201e1df50b2bc99afc079ce326aa0a44b178a391
[ "BSD-2-Clause" ]
null
null
null
// Copyright 1998-2015 Epic Games, Inc. All Rights Reserved. #pragma once @class FCocoaOpenGLView; class FMacOpenGLQueryEmu; @class NSOpenGLContext; @class NSWindow; struct FPlatformOpenGLContext { FPlatformOpenGLContext(); ~FPlatformOpenGLContext(); void Initialise(NSOpenGLContext* const SharedContext); void Reset(); void MakeCurrent(); static void VerifyCurrentContext(); static void RegisterGraphicsSwitchingCallback(); static void UnregisterGraphicsSwitchingCallback(); /** Underlying OpenGL context and its pixel format. */ NSOpenGLContext* OpenGLContext; NSOpenGLPixelFormat* OpenGLPixelFormat; // Window Management /** Currently bound Cocoa view - nil for offscreen only contexts */ FCocoaOpenGLView* OpenGLView; /** Owning window - nil for offscreen only contexts */ NSWindow* WindowHandle; // Mac OpenGL Timestamp Query emulation /** Emulated queries */ FMacOpenGLQueryEmu* EmulatedQueries; // OpenGL Resources /** Required vertex array object. */ GLuint VertexArrayObject; /** Output Framebuffer */ GLuint ViewportFramebuffer; /** Output render buffer */ GLuint ViewportRenderbuffer; /** Cached viewport render buffer dimensions */ int32 ViewportSize[2]; // Context Settings /** Flush Synchronisation Interval (V-Sync) */ int32 SyncInterval; /** Virtual Screen */ GLint VirtualScreen; // Context Renderer Details /** Device Vendor ID */ uint32 VendorID; /** Renderer ID */ GLint RendererID; /** Whether the renderer supports depth-fetch during depth-test */ bool SupportsDepthFetchDuringDepthTest; };
26.327869
68
0.741594
[ "render", "object" ]
d469278ff4d377ee55a7feef3516407942e2ee5b
441
c
C
examples/mpi/visualization/main.c
FTHPC/FlipIt
02882de89941d83f89c84856e307ec53c99cf7c0
[ "NCSA" ]
7
2017-02-20T21:39:33.000Z
2020-06-05T09:07:15.000Z
examples/mpi/visualization/main.c
FTHPC/FlipIt
02882de89941d83f89c84856e307ec53c99cf7c0
[ "NCSA" ]
3
2016-05-05T13:32:10.000Z
2016-05-29T14:33:07.000Z
examples/mpi/visualization/main.c
FTHPC/FlipIt
02882de89941d83f89c84856e307ec53c99cf7c0
[ "NCSA" ]
4
2015-08-27T11:19:53.000Z
2016-05-03T19:50:35.000Z
#include <stdio.h> #include <math.h> #include <mpi.h> #include "jacobi.h" #include "FlipIt/corrupt/corrupt.h" /* This example handles a 12 x 12 mesh, on 4 processors only. */ int main(int argc, char** argv) { int rank; int seed = 233; MPI_Init(&argc, &argv); MPI_Comm_rank(MPI_COMM_WORLD, &rank); FLIPIT_Init(rank, argc, argv, time(NULL)); jacobi(rank); FLIPIT_Finalize(NULL); MPI_Finalize(); return 0; }
18.375
64
0.653061
[ "mesh" ]
d481b5a960fba4ce13c911d18a6616d98d0a1ca1
1,103
h
C
CocoaGit/Extra/GITDateTime.h
haoran127/igithub
417071e63b99d182f1840ba9fde98164dcf1e9d3
[ "MIT" ]
28
2015-02-27T23:10:32.000Z
2021-09-13T14:05:29.000Z
CocoaGit/Extra/GITDateTime.h
haoran127/igithub
417071e63b99d182f1840ba9fde98164dcf1e9d3
[ "MIT" ]
1
2015-11-03T17:49:17.000Z
2015-11-03T17:49:17.000Z
CocoaGit/Extra/GITDateTime.h
haoran127/igithub
417071e63b99d182f1840ba9fde98164dcf1e9d3
[ "MIT" ]
20
2015-03-30T09:19:33.000Z
2021-07-13T07:21:54.000Z
// // GITDateTime.h // CocoaGit // // Created by Geoffrey Garside on 07/10/2008. // Copyright 2008 ManicPanda.com. All rights reserved. // #import <Foundation/Foundation.h> @interface GITDateTime : NSObject <NSCopying> { NSDate * date; NSTimeZone * timezone; } @property(readonly,copy) NSDate * date; @property(readonly,copy) NSTimeZone * timezone; - (id)initWithDate:(NSDate*)theDate timeZone:(NSTimeZone*)theTimeZone; - (id)initWithTimestamp:(NSTimeInterval)seconds timeZoneOffset:(NSString*)offset; /*! Creates and returns dateTime object given the BSD time (time in seconds since 1970) * and the timeZone offset from GMT in units of hours*100. The units of hours*100, * though bizarre, result from converting a typical timeZone string "-0700" into an * integer. * \param seconds BSD time (in seconds since 1970). * \param tz timeZone offset from GMT in units of hours*100. * \return An actor object with the extracted name and email. */ - (id) initWithBSDTime:(unsigned long)seconds timeZoneOffset:(NSInteger)tz; - (NSComparisonResult)compare:(GITDateTime*)object; @end
31.514286
87
0.741614
[ "object" ]
d485d1b47978c6b0a100c2878d60e034c1112aa6
2,973
h
C
src/QorpseState.h
flipcoder/qorpse
218a92067d66b6a98b949e53c4063d712437b469
[ "MIT" ]
14
2015-03-29T05:04:15.000Z
2021-12-29T14:20:48.000Z
src/QorpseState.h
flipcoder/qorpse
218a92067d66b6a98b949e53c4063d712437b469
[ "MIT" ]
null
null
null
src/QorpseState.h
flipcoder/qorpse
218a92067d66b6a98b949e53c4063d712437b469
[ "MIT" ]
1
2020-11-01T21:16:37.000Z
2020-11-01T21:16:37.000Z
#ifndef _POINTCLICKSTATE_H_VZ3QNB09 #define _POINTCLICKSTATE_H_VZ3QNB09 #include "Qor/State.h" #include "Qor/Input.h" #include "Qor/TileMap.h" #include "Qor/Camera.h" #include "Qor/Pipeline.h" #include "Qor/Mesh.h" #include "Qor/Interpreter.h" #include "Qor/Physics.h" #include "Qor/ViewModel.h" //#include "Qor/BasicPhysics.h" #include "Qor/Sprite.h" #include "CharacterInterface.h" //#include "Qor/PlayerInterface3D.h" #include "TextScroller.h" class BasicPartitioner; #include "HUD.h" #include "Character.h" #include "World.h" class Qor; class QorpseState: public State { public: QorpseState(Qor* engine); virtual ~QorpseState(); virtual void preload() override; virtual void enter() override; virtual void logic(Freq::Time t) override; virtual void render() const override; virtual bool needs_load() const override { return true; } virtual Pipeline* pipeline() { return m_pPipeline; } virtual const Pipeline* pipeline() const { return m_pPipeline; } virtual std::shared_ptr<Node> root() override { return m_pRoot; } virtual std::shared_ptr<const Node> root() const override { return m_pRoot; } virtual std::shared_ptr<Node> camera() override { return m_pCamera; } virtual std::shared_ptr<const Node> camera() const override { return m_pCamera; } virtual void camera(const std::shared_ptr<Node>& camera)override{ m_pCamera = std::dynamic_pointer_cast<Camera>(camera); } void reset_thunder(); private: Qor* m_pQor = nullptr; Input* m_pInput = nullptr; Pipeline* m_pPipeline = nullptr; std::shared_ptr<World> m_pRoot; //Interpreter* m_pInterpreter; //std::shared_ptr<Interpreter::Context> m_pScript; std::shared_ptr<Camera> m_pCamera; std::shared_ptr<Mesh> m_pGun; std::shared_ptr<ViewModel> m_pViewModel; //std::shared_ptr<TileMap> m_pMap; std::shared_ptr<Character> m_pPlayer; std::shared_ptr<Sound> m_pMusic; BasicPartitioner* m_pPartitioner = nullptr; std::shared_ptr<CharacterInterface> m_pPlayerInterface; //std::shared_ptr<PlayerInterface3D> m_pPlayerInterface; std::shared_ptr<TextScroller> m_pTextScroller; std::shared_ptr<HUD> m_pHUD; //std::shared_ptr<Physics> m_pPhysics; // TODO: move to world or scene glm::vec2 m_WrapAccum; Animation<float> m_Thunder; std::shared_ptr<Sound> m_pThunderSound; kit::reactive<Color> m_Ambient; std::string m_Filename; std::shared_ptr<Sound> m_pRain; // Testing level or writing to profile? bool m_bTestMode = false; }; #endif
27.785047
73
0.618903
[ "mesh", "render" ]
d48b345d9d1b3860089c35e11ea97544005b6bd1
5,644
h
C
sycl-gtx/include/SYCL/vectors/base.h
ShalokShalom/sycl-gtx
ee5091f0c7d513b24acdb200417ec01043d7834a
[ "MIT" ]
72
2015-10-21T14:23:21.000Z
2022-02-08T08:07:30.000Z
sycl-gtx/include/SYCL/vectors/base.h
ShalokShalom/sycl-gtx
ee5091f0c7d513b24acdb200417ec01043d7834a
[ "MIT" ]
23
2015-04-19T08:49:53.000Z
2021-06-25T13:36:43.000Z
sycl-gtx/include/SYCL/vectors/base.h
ShalokShalom/sycl-gtx
ee5091f0c7d513b24acdb200417ec01043d7834a
[ "MIT" ]
14
2015-02-09T15:09:34.000Z
2021-03-12T01:04:31.000Z
#pragma once // 3.7.2 Vector types // B.5 vec class base #include "SYCL/detail/common.h" #include "SYCL/detail/counter.h" #include "SYCL/detail/data_ref.h" #include "SYCL/vectors/cl_vec.h" #include "SYCL/vectors/helpers.h" namespace cl { namespace sycl { // Forward declarations template <typename, int> class vec; template <typename dataT, int numElements> using swizzled_vec = vec<dataT, numElements>; namespace detail { namespace vectors { // Forward declaration template <int, int, int...> struct swizzled; #define SYCL_ENABLE_IF_DIM(dim) \ typename std::enable_if<num == dim>::type* = nullptr /** * 3.7.2 Vector types * * B.5 vec class base */ template <typename dataT, int numElements> class base : protected counter<base<dataT, numElements>>, public data_ref { private: template <typename> friend struct ::cl::sycl::detail::type_string; template <typename, int> friend class vec; static const int half_size = (numElements + 1) / 2; static string_class type_name() { return cl_base<dataT, numElements, 0>::type_name(); } string_class generate_name() const { return '_' + type_name() + '_' + get_string<counter_t>::get(this->get_count_id()); } string_class this_name() const { return type_name() + ' ' + this->name; } protected: base(string_class assign, bool generate_new = false) : data_ref(generate_new ? generate_name() : assign) { if (generate_new) { kernel_add(this_name() + " = " + assign); } } public: using element_type = dataT; /** Underlying OpenCL type */ using vector_t = detail::cl_type<dataT, numElements>; base() : data_ref(generate_name()) { kernel_add(this_name()); } base(const base& copy) : data_ref(copy.name) {} base& operator=(const base& copy) { data_ref::operator=(copy.name); return *this; } base& operator=(const data_ref& copy) { data_ref::operator=(copy.name); return *this; } base& operator=(const dataT& n) { data_ref::operator=(n); return *this; } base(base&& move) noexcept : data_ref(static_cast<data_ref&&>(*this)) {} base& operator=(base&& move) noexcept { data_ref::operator=(static_cast<data_ref&&>(*this)); return *this; } ~base() = default; template <int num = numElements> base(const data_ref& x, const data_ref& y, SYCL_ENABLE_IF_DIM(2)) : base(open_parenthesis + type_name() + ")(" + x.name + ", " + y.name + ')', true) {} template <int num = numElements> base(const data_ref& x, const data_ref& y, const data_ref& z, SYCL_ENABLE_IF_DIM(3)) : base(open_parenthesis + type_name() + ")(" + x.name + ", " + y.name + ", " + z.name + ')', true) {} template <int num = numElements> base(const data_ref& x, const data_ref& y, const data_ref& z, const data_ref& w, SYCL_ENABLE_IF_DIM(4)) : base(open_parenthesis + type_name() + ")(" + x.name + ", " + y.name + ", " + z.name + ", " + w.name + ')', true) {} template <int num = numElements> base(const data_ref& s0, const data_ref& s1, const data_ref& s2, const data_ref& s3, const data_ref& s4, const data_ref& s5, const data_ref& s6, const data_ref& s7, SYCL_ENABLE_IF_DIM(8)) : base(open_parenthesis + type_name() + ")(" + s0.name + ", " + s1.name + ", " + s2.name + ", " + s3.name + ", " + s4.name + ", " + s5.name + ", " + s6.name + ", " + s7.name + ')', true) {} template <int num = numElements> base(const data_ref& s0, const data_ref& s1, const data_ref& s2, const data_ref& s3, const data_ref& s4, const data_ref& s5, const data_ref& s6, const data_ref& s7, const data_ref& s8, const data_ref& s9, const data_ref& sA, const data_ref& sB, const data_ref& sC, const data_ref& sD, const data_ref& sE, const data_ref& sF, const data_ref& sG, const data_ref& sH, SYCL_ENABLE_IF_DIM(16)) : base(open_parenthesis + type_name() + ")(" + s0.name + ", " + s1.name + ", " + s2.name + ", " + s3.name + ", " + s4.name + ", " + s5.name + ", " + s6.name + ", " + s7.name + ", " + s8.name + ", " + s9.name + ", " + sA.name + ", " + sB.name + ", " + sC.name + ", " + sD.name + ", " + sE.name + ", " + sF.name + ')', true) {} operator vec<dataT, numElements>&() { return *reinterpret_cast<vec<dataT, numElements>*>(this); // NOLINT } ::size_t get_count() const { return numElements; } ::size_t get_size() const { return numElements * sizeof(typename cl_type<dataT, numElements>::type); } template <int... indices> swizzled_vec<dataT, sizeof...(indices)> swizzle() const { static const auto size = sizeof...(indices); static_assert(size > 0, "Cannot swizzle to zero elements"); // One extra for final null char char access_name[size + 1]; swizzled<0, indices...>::get(access_name); access_name[size] = 0; return swizzled_vec<dataT, size>(this->name + ".s" + access_name); } swizzled_vec<dataT, half_size> lo() const { return swizzled_vec<dataT, half_size>(this->name + ".lo"); } swizzled_vec<dataT, half_size> hi() const { return swizzled_vec<dataT, half_size>(this->name + ".hi"); } // TODO(progtx): Swizzle methods // swizzled_vec<T, out_dims> swizzle<int s1, ...>(); #ifdef SYCL_SIMPLE_SWIZZLES // swizzled_vec<T, 4> xyzw(); //... #endif // #ifdef SYCL_SIMPLE_SWIZZLES }; } // namespace vectors } // namespace detail } // namespace sycl } // namespace cl
31.010989
79
0.605599
[ "vector" ]
d4929df892400e80ac03451d2a1caae778822c83
4,039
h
C
simdpp/detail/insn/shuffle_bytes16.h
RaviGaddipati/libsimdpp
d09298cef781bfd090f61fbf8d9c1c8bf5d4374a
[ "BSL-1.0" ]
null
null
null
simdpp/detail/insn/shuffle_bytes16.h
RaviGaddipati/libsimdpp
d09298cef781bfd090f61fbf8d9c1c8bf5d4374a
[ "BSL-1.0" ]
null
null
null
simdpp/detail/insn/shuffle_bytes16.h
RaviGaddipati/libsimdpp
d09298cef781bfd090f61fbf8d9c1c8bf5d4374a
[ "BSL-1.0" ]
null
null
null
/* Copyright (C) 2013-2014 Povilas Kanapickas <povilas@radix.lt> Distributed under the Boost Software License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) */ #ifndef LIBSIMDPP_SIMDPP_DETAIL_INSN_SHUFFLE_BYTES16_H #define LIBSIMDPP_SIMDPP_DETAIL_INSN_SHUFFLE_BYTES16_H #ifndef LIBSIMDPP_SIMD_H #error "This file must be included through simd.h" #endif #include <simdpp/types.h> #include <simdpp/core/bit_or.h> #include <simdpp/core/cmp_lt.h> #include <simdpp/core/i_add.h> #include <simdpp/detail/not_implemented.h> namespace simdpp { namespace SIMDPP_ARCH_NAMESPACE { namespace detail { namespace insn { SIMDPP_INL uint8x16 i_shuffle_bytes16(const uint8x16& a, const uint8x16& b, const uint8x16& mask) { #if SIMDPP_USE_NULL uint8x16 ai = a; uint8x16 bi = b; uint8x16 mi = mask; uint8x16 r; for (unsigned i = 0; i < 16; i++) { unsigned j = mi.el(i) & 0x0f; unsigned which = mi.el(i) < 0x10; r.el(i) = which ? ai.el(j) : bi.el(j); } return r; #elif SIMDPP_USE_XOP return _mm_perm_epi8(a, b, mask); #elif SIMDPP_USE_SSE4_1 int16x8 sel, ai, bi, r; sel = mask; sel = _mm_slli_epi16(sel, 3); ai = _mm_shuffle_epi8(a, mask); bi = _mm_shuffle_epi8(b, mask); r = _mm_blendv_epi8(ai, bi, sel); return (uint8<16>) r; #elif SIMDPP_USE_SSSE3 uint8x16 m, m1, m2, ai, bi; m = mask; // sets the 7-th bit if we want an element from the other vector m1 = add(m, 0x70); m2 = add(m, 0xf0); ai = _mm_shuffle_epi8(a, m1); bi = _mm_shuffle_epi8(b, m2); return bit_or(ai, bi); #elif SIMDPP_USE_NEON32 uint8x8x4_t table = {{vget_low_u8(a), vget_high_u8(a), vget_low_u8(b), vget_high_u8(b)}}; uint8x8_t lo = vtbl4_u8(table, vget_low_u8(mask)); uint8x8_t hi = vtbl4_u8(table, vget_high_u8(mask)); return vcombine_u8(lo, hi); #elif SIMDPP_USE_NEON64 uint8x16x2_t table; table.val[0] = a; table.val[1] = b; return vqtbl2q_u8(table, mask); #elif SIMDPP_USE_ALTIVEC return vec_perm((__vector uint8_t)a, (__vector uint8_t)b, (__vector uint8_t)mask); #else return SIMDPP_NOT_IMPLEMENTED3(a, b, mask); #endif } #if SIMDPP_USE_AVX2 SIMDPP_INL uint8x32 i_shuffle_bytes16(const uint8x32& a, const uint8x32& b, const uint8x32& mask) { int16x16 sel, ai, bi, r; sel = mask; sel = _mm256_slli_epi16(sel, 3); // the top 3 bits are already clear ai = _mm256_shuffle_epi8(a, mask); bi = _mm256_shuffle_epi8(b, mask); r = _mm256_blendv_epi8(ai, bi, sel); return (uint8<32>) r; } #endif template<unsigned N> SIMDPP_INL uint8<N> i_shuffle_bytes16(const uint8<N>& a, const uint8<N>& b, const uint8<N>& mask) { SIMDPP_VEC_ARRAY_IMPL3(uint8<N>, i_shuffle_bytes16, a, b, mask); } template<unsigned N> SIMDPP_INL uint16<N> i_shuffle_bytes16(const uint16<N>& a, const uint16<N>& b, const uint16<N>& mask) { return (uint16<N>) i_shuffle_bytes16(uint8<N*2>(a), uint8<N*2>(b), uint8<N*2>(mask)); } template<unsigned N> SIMDPP_INL uint32<N> i_shuffle_bytes16(const uint32<N>& a, const uint32<N>& b, const uint32<N>& mask) { return (uint32<N>) i_shuffle_bytes16(uint8<N*4>(a), uint8<N*4>(b), uint8<N*4>(mask)); } template<unsigned N> SIMDPP_INL uint64<N> i_shuffle_bytes16(const uint64<N>& a, const uint64<N>& b, const uint64<N>& mask) { return (uint64<N>) i_shuffle_bytes16(uint8<N*8>(a), uint8<N*8>(b), uint8<N*8>(mask)); } template<unsigned N> SIMDPP_INL float32<N> i_shuffle_bytes16(const float32<N>& a, const float32<N>& b, const uint32<N>& mask) { return float32<N>(i_shuffle_bytes16(uint32<N>(a), uint32<N>(b), mask)); } template<unsigned N> SIMDPP_INL float64<N> i_shuffle_bytes16(const float64<N>& a, const float64<N>& b, const uint64<N>& mask) { return float64<N>(i_shuffle_bytes16(uint64<N>(a), uint64<N>(b), mask)); } } // namespace insn } // namespace detail } // namespace SIMDPP_ARCH_NAMESPACE } // namespace simdpp #endif
29.918519
97
0.680366
[ "vector" ]
d499fcdd5a063d6d493e2a94e9e0830f30c878c7
15,279
h
C
src/WFSTOnTheFlyDecoder.h
idiap/juicer
c1d67eb710c5390d0555deb05428ea11cd5e2bf1
[ "BSD-3-Clause" ]
52
2015-01-23T14:09:06.000Z
2021-06-24T00:19:42.000Z
src/WFSTOnTheFlyDecoder.h
idiap/juicer
c1d67eb710c5390d0555deb05428ea11cd5e2bf1
[ "BSD-3-Clause" ]
null
null
null
src/WFSTOnTheFlyDecoder.h
idiap/juicer
c1d67eb710c5390d0555deb05428ea11cd5e2bf1
[ "BSD-3-Clause" ]
22
2015-01-19T03:03:36.000Z
2020-08-10T05:39:11.000Z
/* * Copyright 2006 by IDIAP Research Institute * http://www.idiap.ch * * See the file COPYING for the licence associated with this software. */ #ifndef WFST_OTFDECODER_INC #define WFST_OTFDECODER_INC #include "WFSTDecoder.h" #include "WFSTModelOnTheFly.h" // Changes Octavian 20060726 // If the following is defined, Caseiro's method is used - ie No label- // matching (ie no control on non-coaccessible paths) and no weight // lookahead in the "suffix" region. See IDIAP RR-06-62 for details. // #define CASEIRO // Changes Octavian 20060809 // If defined, the duplication of G eps transitions is delayed until the // token reaches the end of a non-eps-output transition in CoL. // Otherwise, the duplication of G eps transitions is done when the // intersection between the anticipated output label set and G input // symbols is singleton. #define DELAYPUSHING // Changes Octavian 20060810 // If defined, the semiring used for weight pushing between anticipated // output labels and G input symbols is a log semiring (ie semiring-add = // log-add). Otherwise, the semiring is a tropical semiring (ie semiring- // add = minimum cost (or maximum prob)). #define LOG_ADD_LOOKAHEAD // Changes Octavian 20060823 // If the following is defined, only the acoustic score will be put in the // lattice. No LM score in the lattice. // #define ACOUSTIC_SCORE_ONLY namespace Juicer { // ************************************ // Changes // On-the-fly decoder // Changes Octavian 20060325 #define DEAD_TRANS -4 #define FOLLOWON_TRANS -3 #define NOPUSHING_TRANS -2 #define UNDECIDED_TRANS -1 // Changes Octavian 20060415 20060417 20060508 #define CACHESIZEPERCENTAGE 0.0 #define CACHEMINSIZE 3000000 #define NUMBUCKETS 1024 /** * On the fly decoder by Octavian */ class WFSTOnTheFlyDecoder : public WFSTDecoder { public: // Public Member Variables WFSTSortedInLabelNetwork *gNetwork ; // Pruning // bestHypHist // emitHypsHistogram // Constructors / destructor WFSTOnTheFlyDecoder() ; //PNG WFSTOnTheFlyDecoder( //PNG WFSTNetwork *network_ , WFSTSortedInLabelNetwork *gNetwork_ , //PNG PhoneModels *phoneModels_ , real emitPruneWin_ , //PNG real phoneEndPruneWin_ , int maxEmitHyps_ , //PNG bool doPushingWeightAndLabel_ , bool doPushingWeightCache_ ) ; WFSTOnTheFlyDecoder( WFSTNetwork *network_ , WFSTSortedInLabelNetwork *gNetwork_ , Models *models_ , real emitPruneWin_ , real phoneEndPruneWin_ , int maxEmitHyps_ , bool doModelLevelOutput_ , bool doLatticeGeneration_ , bool doPushingWeightAndLabel_ , bool doPushingWeightCache_ ) ; virtual ~WFSTOnTheFlyDecoder() ; // Public Methods // Changes //PNG virtual DecHyp *decode( real **inputData , int nFrames_ ) ; // Changes virtual void init() ; protected: // Hypothesis Management // Changes by Octavian WFSTModelOnTheFlyPool *modelOnTheFlyPool ; // Changes Octavian 20060627 // DecHypPool *decHypPool ; WFSTModelOnTheFly *activeModelsOnTheFlyList ; WFSTModelOnTheFly **activeModelsOnTheFlyLookup ; WFSTModelOnTheFly *newActiveModelsOnTheFlyList ; WFSTModelOnTheFly *newActiveModelsOnTheFlyListLastElem ; // Changes virtual void processActiveModelsInitStates() ; virtual void processActiveModelsEmitStates() ; virtual void processActiveModelsEndStates() ; WFSTModelOnTheFly *getModel( WFSTTransition *trans ) ; WFSTModelOnTheFly *returnModel( WFSTModelOnTheFly *model , WFSTModelOnTheFly *prevActiveModel ) ; virtual void resetActiveHyps() ; virtual void registerLabel( DecHyp* hyp , int label ) ; virtual void joinNewActiveModelsList() ; virtual void checkActiveNumbers( bool checkPhonePrevHyps ) ; virtual void resetDecHyp( DecHyp* hyp ) ; // Changes Octavian 20060424 20060630 void extendInitMap( WFSTModelOnTheFly *model, bool isPushed, NodeToDecHypOnTheFly *currNode, NodeToDecHypOnTheFly **helper ) ; void extendModelInitState( WFSTModelOnTheFly *model ) ; // Changes Octavian 20060531 void extendDecHypOnTheFlyNonEndState( DecHypOnTheFly *currHyp, int pushedGState, int matchedOutLabel, bool isPushedMap, int hmmStateIndex, WFSTModelOnTheFly *model, NodeToDecHypOnTheFly **helper ) ; void processModelEmitStates( WFSTModelOnTheFly *model ) ; // Changes Octavian 20060531 // Changes Octavian 20060815 void extendModelEndState( DecHypOnTheFly *endHyp , WFSTTransition *trans , WFSTTransition **nextTransBuf , bool isPushedMap, int pushedGState, int thisMatchedOutLabel ) ; // Changes Octavian 20060523 virtual void addLabelHist( DecHyp* hyp , int label ) ; // Changes // Lattice generation virtual int addLatticeEntry( DecHyp *hyp , WFSTTransition *trans , int *fromState ) ; // Enable/disable label and weight pushing bool doPushingWeightAndLabel ; // Find a set of next transitions in the C o L transducer where // there is at least one label in its label set // which is matched with the input labels in the G transducer. // Call this function when label pushing is used in this decoder // Arguments : prev (I) - current C o L transition // nNext (O) - number of next non-dead CoL transitions // next (O) - array of next non-dead CoL transitions // gState (I) - current state number of the G transducer // commonWeights (O) - array corresponding lookahead weights of // next C o L transitions // nextGState (O) - array corresponding lookahead G state of // next C o L transitions. Can have 4 possibilites: // - FOLLOWON_TRANS = this CoL trans has the same label // set as the prev CoL trans. // - UNDECIDED_TRANS = this CoL trans has more than 1 // matches with the input symbols of the G transducer. // - NOPUSHING_TRANS = this CoL trans has a // NONPUSHING_OUTLABEL. No pushing (lookahead) is // allowed. // - Actual lookahead G state = when there's only 1 match // with the input symbol of the G transducer. // nextOutLabel (O) - corresponding lookahead outLabel of next // C o L transitions // matchedOutLabel (O) - the output label in the CoL label set // which matches with one of the input labels of the // G transducer. // For example: Suppose there are 3 CoL transitions after the current one. // Each has a label set. Suppose the first CoL transition has 5 outlabels // in its label set which are matched with the inlabels of the gState. // The commonWeight of this transition will be the max of the LM weights // of those 5 transitions in the G transducer. The nextGState of this // transition will be unknown and set to UNDECIDED_TRANS because there are // 5 possibilites and we don't know where it should go yet. The // nextOutLabel will be UNDECIDED_OUTLABEL. The matchedOutLabel will be // UNDECIDED_OUTLABEL. // // Suppose the second transition has only 1 output label matched. The // commonWeight will be the LM weight of that particular G transition. The // nextGState will be the G state to which that G transition is pointing // to. The nextOutLabel will be the outLabel of that particular G // transition. The matchedOutLabel will be the output label of CoL which // matches with the input label of the G transducer. // // Lastly, for the third CoL transition, suppose there are no // intersections. Then it will not be one of the next CoL transitions and // will not be stored. Hence, nNext will be 2. The "next" array will // contain pointers to the 2 CoL transitions which have intersections. The // "commonWeights", "nextGState", "nextOutLabel" and "matchedOutLabel" // will be the corresponding common weights, next G states, next // outLabels and matched CoL outLabels of the 2 transitions. // // Exception: When a CoL transition is going towards the final state(s), // label-pushing is switched off for that transition since we don't want // the lookahead LM weights to be added to the hypotheses heading towards // the final state(s). In this case, the corresponding nextGState, // commonWeight, nextOutLabel and matchedOutLabel will be NOPUSHING_TRANS, // 0.0, UNDECIDED_OUTLABEL and UNDECIDED_OUTLABEL respectively. // // When the labelSet of the next transition is the same as the labelSet of // this transition, nextGState = FOLLOWON_TRANS. commonWeights, // nextOutLabel and matchedOutLabel are not assigned. Do not try to read // their values. // Changes Octavian 20060531 // Changes Octavian 20060726 // Changes Octavian 20060828 #ifndef CASEIRO void findMatchedTransWithPushing( WFSTTransition *prev, int *nNext, WFSTTransition **next, int gState, real *commonWeights, int *nextGState, int *nextOutLabel, int *matchedOutLabel ) ; #else void findMatchedTransWithPushing( WFSTTransition *prev, int *nNext, WFSTTransition **next, int gState, real *commonWeights, int *nextGState, int *nextOutLabel, int *matchedOutLabel, int nonRegisteredLabels, bool isPushed ) ; #endif // This function finds matching transitions with the G transducer (similar // to findMatchedTransWithPushing). But the difference is it doesn't do any // lookahead. See the function for more detail. // Changes Octavian 20060531 void findMatchedTransNoPushing( WFSTTransition *prev, int *nNext, WFSTTransition **next, int gState, real *commonWeights, int *nextGState, int *nextOutLabel, int *matchedOutLabel ) ; // Helper function for findMatchedTransWithPushing() // Intersection of one label set in CoL with all transitions of one state // in the G transducer // Changes Octavian 20060531 bool findIntersection( const WFSTLabelPushingNetwork::LabelSet *labelSet, const int gState, const int totalNTransInG , real *commonWeight, int *nextGState, int *nextOutLabel, int *matchedOutLabel ) ; // Binary search of one label in a range of G transitions - Only update // weight, nextGState and nextOutLabel when a search is successful. // Always output cloestTransInG regardless of the search result bool binarySearchGTrans( const int outLabelInCL, const int gState, const int startTransInG, const int nTransInG, real *weight, int *nextGState, int *closestTransInG, int *nextOutLabel ) ; // ************* // Enable/disable cache for storing pushing weights bool doPushingWeightCache ; // Cache for storing pushing weights class PushingWeightCache { public: PushingWeightCache() ; // Changes Octavian 20060325 PushingWeightCache( int numCoLTrans_, int numGStates_, const WFSTLabelPushingNetwork::LabelSet **labelSetArray_, int numCoLOutSyms_, int nBucket_ ) ; virtual ~PushingWeightCache() ; // Changes Octavian 20060415 // void reset() ; // Changes Octavian 20060531 // Find a cache record. bool findPushingWeight( int colTransIndex, int gStateIndex, int colOutLabel, real *foundWeight, int *foundNextGState, int *foundNextOutLabel, int *foundMatchedOutLabel ) ; // Changes Octavian 20060531 // Insert a new cache record void insertPushingWeight( int colTransIndex, int gStateIndex, int colOutLabel, real newWeight, int newNextGState, int newNextOutLabel, int newMatchedOutLabel ) ; int numRecords() { return currRecords ; } ; private: // Changes Octavian 20060415 // Changes Octavian 20060531 // Cache record - Each CoL label set will have a hash table storing // these records. A record stores the matching result of its // corresponding labelSet with a gState. // - gState = State number of the G transducer // - pushingWeight = max weights of matches (because it's a prob) // - nextGState = the next G state. If the label set has a // NONPUSHING_OUTLABEL, it means that pushing is not allowed and // nextGState = NOPUSHING_TRANS. If there is no matching, nextGState // = DEAD_TRANS. If there is more than 1 matches, nextGState = // UNDECIDED_TRANS. If there is only 1 match, nextGState = the next G // state. // - nextOutLabel = next output label from the G transducer. If it is // a non-pushing label set or it has more than 1 match or no match, // then the nextOutLabel = UNDECIDED_OUTLABEL. Otherwise, // nextOutLabel is the output label of the matched transitions in // the G transducer. // - matchedOutLabel = the label in the CoL label set which matches // with the input label of the G transducer. If it is a non-pushing // label set or more than one match or no match, matchedOutLabel = // UNDECIDED_OUTLABEL. Otherwise (ie only one match), matchedOutLabel // will be the one which matches with the input label of the G // transducer. // Other attributes: Just for maintaining the hash table and the // Least Recently Used (LRU) linked list. // - prev and next: doubly linked list for LRU // - hashprev and hashnext: doubly linked list for hash chain // - bucket: a pointer pointing to the bucket where this record can // be found. typedef struct _pushingWeightRecord { int gState ; real pushingWeight ; int nextGState ; int nextOutLabel ; int matchedOutLabel ; struct _pushingWeightRecord *prev ; struct _pushingWeightRecord *next ; struct _pushingWeightRecord *hashprev ; struct _pushingWeightRecord *hashnext ; struct _pushingWeightRecord **bucket ; } PushingWeightRecord ; // Pushing weight record pool PushingWeightRecord *recordPool ; // LRU PushingWeightRecord *recordHead ; PushingWeightRecord *recordTail ; // Hash map buckets for all label sets // bucketArray contains the buckets of all effecitve CoL transitions // mapArray[n] points to the first bucket of the nth effective CoL // transition PushingWeightRecord **bucketArray ; PushingWeightRecord ***mapArray ; int nBucket ; int nBucketMinusOne ; // Number of effective C o L trans int numEffCoLTrans ; // This array points to the hash table of a CoL transition. Will // only have an array when pushing is enabled. Each CoL transition // will have an entry. It's possible to have several CoL transition // pointing to a hash table because they have the same label set. // The length of this array is number of CoL transitions. // Will be NULL array if no pushing since the hash table is indexed // with the output label of CoL transition, not by unique label set. int *transLookup ; int numCoLTrans ; int numGStates ; int maxRecords ; int currRecords ; void insert( int nthHashTable, int gStateIndex, PushingWeightRecord *newRecord ) ; PushingWeightRecord *deletePushingWeight() ; // Determine the number of buckets, which will be the next closest // 2^n after nBucket_ int calNBucket( int nBucket_ ) ; PushingWeightRecord *find( int nthHashTable , int gStateIndex ) ; int hash( int gStateIndex ) { return ( gStateIndex & nBucketMinusOne ) ; } ; }; // Cache storing the pushing weight PushingWeightCache *pushingWeightCache ; }; } #endif
40.313984
100
0.718895
[ "model" ]
d49c8ba16a4723dc1994dce6a93e94a95c10afea
4,429
h
C
src/qpid/broker/TxBuffer.h
gcsideal/debian-qpid-cpp
e4d034036f29408f940805f5505ae62ce89650cc
[ "Apache-2.0" ]
null
null
null
src/qpid/broker/TxBuffer.h
gcsideal/debian-qpid-cpp
e4d034036f29408f940805f5505ae62ce89650cc
[ "Apache-2.0" ]
null
null
null
src/qpid/broker/TxBuffer.h
gcsideal/debian-qpid-cpp
e4d034036f29408f940805f5505ae62ce89650cc
[ "Apache-2.0" ]
null
null
null
/* * * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. * */ #ifndef _TxBuffer_ #define _TxBuffer_ #include <algorithm> #include <functional> #include <vector> #include "qpid/broker/BrokerImportExport.h" #include "qpid/broker/TransactionalStore.h" #include "qpid/broker/TxOp.h" /** * Represents a single transaction. As such, an instance of this class * will hold a list of operations representing the workload of the * transaction. This work can be committed or rolled back. Committing * is a two-stage process: first all the operations should be * prepared, then if that succeeds they can be committed. * * In the 2pc case, a successful prepare may be followed by either a * commit or a rollback. * * Atomicity of prepare is ensured by using a lower level * transactional facility. This saves explicitly rolling back all the * successfully prepared ops when one of them fails. i.e. we do not * use 2pc internally, we instead ensure that prepare is atomic at a * lower level. This makes individual prepare operations easier to * code. * * Transactions on a messaging broker effect three types of 'action': * (1) updates to persistent storage (2) updates to transient storage * or cached data (3) network writes. * * Of these, (1) should always occur atomically during prepare to * ensure that if the broker crashes while a transaction is being * completed the persistent state (which is all that then remains) is * consistent. (3) can only be done on commit, after a successful * prepare. There is a little more flexibility with (2) but any * changes made during prepare should be subject to the control of the * TransactionalStore in use. */ namespace qpid { namespace broker { class TxBuffer{ typedef std::vector<TxOp::shared_ptr>::iterator op_iterator; std::vector<TxOp::shared_ptr> ops; protected: public: typedef boost::shared_ptr<TxBuffer> shared_ptr; /** * Adds an operation to the transaction. */ QPID_BROKER_EXTERN void enlist(TxOp::shared_ptr op); /** * Requests that all ops are prepared. This should * primarily involve making sure that a persistent record * of the operations is stored where necessary. * * Once prepared, a transaction can be committed (or in * the 2pc case, rolled back). * * @returns true if all the operations prepared * successfully, false if not. */ QPID_BROKER_EXTERN bool prepare(TransactionContext* const ctxt); /** * Signals that the ops all prepared successfully and can * now commit, i.e. the operation can now be fully carried * out. * * Should only be called after a call to prepare() returns * true. */ QPID_BROKER_EXTERN void commit(); /** * Signals that all ops can be rolled back. * * Should only be called either after a call to prepare() * returns true (2pc) or instead of a prepare call * ('server-local') */ QPID_BROKER_EXTERN void rollback(); /** * Helper method for managing the process of server local * commit */ QPID_BROKER_EXTERN bool commitLocal(TransactionalStore* const store); // Used by cluster to replicate transaction status. void accept(TxOpConstVisitor& v) const; }; } } #endif
36.908333
81
0.651614
[ "vector" ]
d4ad9075d813e0420bea3bb7de618f70bcbb85a4
1,180
h
C
src/ofxPrinter.h
Iwanaka/ofxPrinter
96c58a0288fadbecb19fbfccda4d1274d258fdd7
[ "MIT" ]
6
2018-08-21T12:35:42.000Z
2020-12-15T21:04:43.000Z
src/ofxPrinter.h
Iwanaka/ofxPrinter
96c58a0288fadbecb19fbfccda4d1274d258fdd7
[ "MIT" ]
null
null
null
src/ofxPrinter.h
Iwanaka/ofxPrinter
96c58a0288fadbecb19fbfccda4d1274d258fdd7
[ "MIT" ]
2
2019-03-08T02:51:39.000Z
2019-04-09T02:27:22.000Z
#pragma once #include "ofxImGui.h" #include "ofMain.h" #define IM_TEXT_SIZE 1000 #define ARRAYSIZE(_ARR) ((int)(sizeof(_ARR)/sizeof(*_ARR))) typedef struct OFX_PRINTER { string printerName = "default"; string paperSize = "A4"; ofVec4f margin = ofVec4f(100, 100, 100, 100); bool landscape = false; bool color = true; bool fitToPaper = true; }; class ofxPrinter { public: ofxPrinter(); ~ofxPrinter(); void ImGui(string name); void updatePrinterList(); void simplePrintOut(string imageFilePath, string printerName); void printOut(string imageFilePath, OFX_PRINTER p); bool setPrintFilePath(string filePath); string getCurrentPrintFilePath(); string getCurrentSelectPrinterName(); string getCurrentSelectPaperSize(); vector<string> getPrinterList(); vector<string> getPrinterPaperSizes(string printerName); private: void loadSettings(); void saveSettings(); string getSelectPrinterName(); string getSelectPaperSizeName(); vector<string> printerList; vector<vector<string>> paperSizes; int printerIndex; int paperIndex; string printFilePath; string logMessage; float inputMargin[4]; bool inputLandscape, inputColor, inputFitToPaper; };
19.344262
63
0.760169
[ "vector" ]
d4b45165a6ea3fc2d946e0de245b4e0490420a28
31,023
c
C
slfs/slsfs_vfsops.c
rcslab/aurora
cf310d26bcbea1a6fe65ba5ed19aff4b4a9886e9
[ "BSD-2-Clause" ]
10
2021-10-06T19:48:51.000Z
2022-01-31T01:28:21.000Z
slfs/slsfs_vfsops.c
rcslab/aurora
cf310d26bcbea1a6fe65ba5ed19aff4b4a9886e9
[ "BSD-2-Clause" ]
null
null
null
slfs/slsfs_vfsops.c
rcslab/aurora
cf310d26bcbea1a6fe65ba5ed19aff4b4a9886e9
[ "BSD-2-Clause" ]
2
2021-09-20T01:02:54.000Z
2022-01-07T02:51:32.000Z
#include <sys/param.h> #include <sys/systm.h> #include <sys/bio.h> #include <sys/buf.h> #include <sys/conf.h> #include <sys/dirent.h> #include <sys/extattr.h> #include <sys/fcntl.h> #include <sys/kernel.h> #include <sys/kthread.h> #include <sys/lockf.h> #include <sys/module.h> #include <sys/mount.h> #include <sys/mutex.h> #include <sys/namei.h> #include <sys/pctrie.h> #include <sys/priv.h> #include <sys/proc.h> #include <sys/rwlock.h> #include <sys/stat.h> #include <sys/syscallsubr.h> #include <sys/sysctl.h> #include <sys/taskqueue.h> #include <sys/uio.h> #include <sys/unistd.h> #include <sys/vnode.h> #include <vm/vm.h> #include <vm/vm_extern.h> #include <vm/vm_page.h> #include <machine/param.h> #include <machine/vmparam.h> #include <geom/geom.h> #include <geom/geom_vfs.h> #include <slos.h> #include <slos_btree.h> #include <slos_inode.h> #include <slos_io.h> #include <slsfs.h> #include <btree.h> #include "debug.h" #include "slos_alloc.h" #include "slos_subr.h" #include "slsfs_buf.h" #include "slsfs_dir.h" static MALLOC_DEFINE(M_SLSFS, "slsfs_mount", "SLSFS mount structures"); static vfs_root_t slsfs_root; static vfs_statfs_t slsfs_statfs; static vfs_vget_t slsfs_vget; static vfs_sync_t slsfs_sync; extern struct buf_ops bufops_slsfs; static const char *slsfs_opts[] = { "from" }; // sysctl variables int checksum_enabled = 0; /* * Register the Aurora filesystem type with the kernel. */ static int slsfs_init(struct vfsconf *vfsp) { /* Setup slos structures */ slos_init(); fnode_zone = uma_zcreate("Btree Fnode Slabs", sizeof(struct fnode), &fnode_construct, &fnode_deconstruct, NULL, NULL, UMA_ALIGN_PTR, 0); if (fnode_zone == NULL) { slos_uninit(); return (ENOMEM); } fnode_trie_zone = uma_zcreate("Btree Fnode Trie Slabs", pctrie_node_size(), NULL, NULL, pctrie_zone_init, NULL, UMA_ALIGN_PTR, UMA_ZONE_NOFREE); if (fnode_trie_zone == NULL) { uma_zdestroy(fnode_zone); slos_uninit(); return (ENOMEM); } return (0); } /* * Unregister the Aurora filesystem type from the kernel. */ static int slsfs_uninit(struct vfsconf *vfsp) { /* Wait for anyone who still has the lock. */ SLOS_LOCK(&slos); KASSERT(slos_getstate(&slos) == SLOS_UNMOUNTED, ("destroying SLOS with state %d", slos_getstate(&slos))); SLOS_UNLOCK(&slos); uma_zdestroy(fnode_zone); uma_zdestroy(fnode_trie_zone); slos_uninit(); return (0); } /* * Called after allocator tree and checksum tree have been inited. * This function just checks if the mount is a fresh mount (by checking the * epoch number). * * Then fetches the vnode. Since everything else has been initialized we * can fetch it normally. We then try and create the root directory of the * filesystem and are fine if it fails (means it already exists). */ static int slsfs_inodes_init(struct mount *mp, struct slos *slos) { int error; if (slos->slos_sb->sb_epoch == EPOCH_INVAL) { DEBUG("Initializing root inode"); error = initialize_inode( slos, SLOS_INODES_ROOT, &slos->slos_sb->sb_root); MPASS(error == 0); } /* Create the vnode for the inode root. */ DEBUG1("Initing the root inode %lu", slos->slos_sb->sb_root.offset); error = slsfs_vget(mp, SLOS_INODES_ROOT, 0, &slos->slsfs_inodes); if (error) { panic("Issue trying to find root node on init"); return (error); } VOP_UNLOCK(slos->slsfs_inodes, 0); /* Create the filesystem root. */ error = slos_icreate(slos, SLOS_ROOT_INODE, MAKEIMODE(VDIR, S_IRWXU)); if (error == EEXIST) { DEBUG("Already exists"); } else if (error) { return (error); } return (0); } static int slsfs_checksumtree_init(struct slos *slos) { diskptr_t ptr; int error = 0; size_t offset = ((NUMSBS * slos->slos_sb->sb_ssize) / slos->slos_sb->sb_bsize) + 1; if (slos->slos_sb->sb_epoch == EPOCH_INVAL) { MPASS(error == 0); error = fbtree_sysinit(slos, offset, &ptr); DEBUG1("Initializing checksum tree %lu", ptr.offset); MPASS(error == 0); } else { ptr = slos->slos_sb->sb_cksumtree; } // In case of remounting of a snapshot if (slos->slos_cktree != NULL) { slos_vpfree(slos, slos->slos_cktree); } DEBUG1("Loading Checksum tree %lu", ptr.offset); error = slos_svpimport(slos, ptr.offset, true, &slos->slos_cktree); KASSERT(error == 0, ("importing checksum tree failed with %d", error)); fbtree_init(slos->slos_cktree->sn_fdev, slos->slos_cktree->sn_tree.bt_root, sizeof(uint64_t), sizeof(uint32_t), &uint64_t_comp, "Checksum tree", 0, &slos->slos_cktree->sn_tree); KASSERT( slos->slos_cktree != NULL, ("could not initialize checksum tree")); fbtree_reg_rootchange( &slos->slos_cktree->sn_tree, &slsfs_root_rc, slos->slos_cktree); if (slos->slos_sb->sb_epoch == EPOCH_INVAL) { MPASS(fbtree_size(&slos->slos_cktree->sn_tree) == 0); } return (0); } static int slsfs_startupfs(struct mount *mp) { int error; struct slsfsmount *smp = mp->mnt_data; if (smp->sp_index == (-1)) { DEBUG("SLOS Read in Super"); error = slos_sbread(&slos); if (error != 0) { DEBUG1("ERROR: slos_sbread failed with %d", error); return (error); } } else { if (slos.slos_sb == NULL) slos.slos_sb = malloc( sizeof(struct slos_sb), M_SLOS_SB, M_WAITOK); error = slos_sbat(&slos, smp->sp_index, slos.slos_sb); if (error != 0) { free(slos.slos_sb, M_SLOS_SB); return (error); } } if (slos.slos_tq == NULL) { slos.slos_tq = taskqueue_create("SLOS Taskqueue", M_WAITOK, taskqueue_thread_enqueue, &slos.slos_tq); if (slos.slos_tq == NULL) { panic("Problem creating taskqueue"); } DEBUG1("Creating taskqueue %p", slos.slos_tq); } /* * Initialize in memory the allocator and the vnode used for inode * bookkeeping. */ slsfs_checksumtree_init(&slos); slos_allocator_init(&slos); slsfs_inodes_init(mp, &slos); /* * Start the threads, probably should have a sysctl to define number of * threads here. */ error = taskqueue_start_threads( &slos.slos_tq, 10, PVM, "SLOS Taskqueue Threads"); if (error) { panic("%d issue starting taskqueue", error); } DEBUG("SLOS Loaded."); return (error); } /* * Create an in-memory representation of the SLOS. */ static int slsfs_create_slos(struct mount *mp, struct vnode *devvp) { int error; cv_init(&slos.slsfs_sync_cv, "SLSFS Syncer CV"); mtx_init(&slos.slsfs_sync_lk, "syncer lock", NULL, MTX_DEF); slos.slsfs_dirtybufcnt = 0; slos.slsfs_syncing = 0; slos.slsfs_mount = mp; slos.slos_vp = devvp; /* Hook up the SLOS into the GEOM provider for the backing device. */ g_topology_lock(); error = g_vfs_open(devvp, &slos.slos_cp, "slsfs", 1); if (error) { printf("Error in opening GEOM vfs"); g_topology_unlock(); goto error; } slos.slos_pp = g_dev_getprovider(devvp->v_rdev); g_topology_unlock(); error = slsfs_startupfs(mp); if (error) { g_topology_lock(); g_vfs_close(slos.slos_cp); g_topology_unlock(); goto error; } return (0); error: cv_destroy(&slos.slsfs_sync_cv); mtx_destroy(&slos.slsfs_sync_lk); return (error); } /* * Mount a device as a SLOS, and create an in-memory representation. */ static int slsfs_mount_device( struct vnode *devvp, struct mount *mp, struct slsfs_device **slsfsdev) { struct slsfs_device *sdev; void *vdata; int error; /* * Get a pointer to the device vnode's current private data. * We need to restore it when destroying the SLOS. The field * is overwritten by slsfs_create_slos. */ vdata = devvp->v_data; /* Create the in-memory SLOS. */ error = slsfs_create_slos(mp, devvp); if (error != 0) { DEBUG1("slsfs_create_slos: error %d", error); return (error); } /* * XXX Is the slsfs_device abstraction future-proofing for when we have * an N to M corresponding between SLOSes and devices? Why isn't the * information in the SLOS enough? */ sdev = malloc(sizeof(struct slsfs_device), M_SLSFS, M_WAITOK | M_ZERO); sdev->refcnt = 1; sdev->devvp = slos.slos_vp; sdev->gprovider = slos.slos_pp; sdev->gconsumer = slos.slos_cp; sdev->devsize = slos.slos_pp->mediasize; sdev->devblocksize = slos.slos_pp->sectorsize; sdev->vdata = vdata; mtx_init(&sdev->g_mtx, "slsfsmtx", NULL, MTX_DEF); DEBUG("Mounting Device Done"); *slsfsdev = sdev; return (0); } /* * Vnode allocation * Will create the underlying inode as well and link the data to a newly * allocated vnode. Does not link the allocated vnode to its parent. The * parent is passed in as a structure that gets us the mount point as well as * the slos. * * The mount point is needed to allow us to attach the vnode to it, and slos is * needed for access the device. */ static int slsfs_valloc( struct vnode *dvp, mode_t mode, struct ucred *creds, struct vnode **vpp) { int error; uint64_t pid = 0; struct vnode *vp; /* Create the new inode in the filesystem. */ error = slos_svpalloc(VPSLOS(dvp), mode, &pid); if (error) { return (error); } /* Get a vnode for the newly created inode. */ error = slsfs_vget(dvp->v_mount, pid, LK_EXCLUSIVE, &vp); if (error) { return (error); } /* Inherit group id from parent directory */ SLSVP(vp)->sn_ino.ino_gid = SLSVP(dvp)->sn_ino.ino_gid; if (creds != NULL) { SLSVP(vp)->sn_ino.ino_uid = creds->cr_uid; } DEBUG2("Creating file with gid(%lu) uid(%lu)", SLSVP(vp)->sn_ino.ino_gid, SLSVP(vp)->sn_ino.ino_uid); *vpp = vp; return (0); } /* * Mount the filesystem in the device backing the vnode to the mountpoint. */ static int slsfs_mountfs(struct vnode *devvp, struct mount *mp) { struct slsfsmount *smp = NULL; struct slsfs_device *slsfsdev = NULL; int error, ronly; if (mp->mnt_data == NULL) { ronly = (mp->mnt_flag & MNT_RDONLY) != 0; /* Configure the filesystem to have the IO parameters of the * device. */ if (devvp->v_rdev->si_iosize_max != 0) mp->mnt_iosize_max = devvp->v_rdev->si_iosize_max; if (mp->mnt_iosize_max > MAXPHYS) mp->mnt_iosize_max = MAXPHYS; vfs_getopts(mp->mnt_optnew, "from", &error); if (error) goto error; /* Create the in-memory data for the filesystem instance. */ smp = (struct slsfsmount *)malloc( sizeof(struct slsfsmount), M_SLSFS, M_WAITOK | M_ZERO); smp->sp_index = -1; smp->sp_vfs_mount = mp; smp->sp_ronly = ronly; smp->sls_valloc = &slsfs_valloc; smp->sp_slos = &slos; mp->mnt_data = smp; DEBUG1("slsfs_mountfs(%p)", devvp); /* Create the in-memory data for the backing device. */ DEBUG("Not a snap remount - mount device"); error = slsfs_mount_device(devvp, mp, &slsfsdev); if (error) { free(smp, M_SLSFS); return error; } smp->sp_sdev = slsfsdev; } else { smp = (struct slsfsmount *)mp->mnt_data; error = slsfs_startupfs(mp); if (error) return (error); } KASSERT(smp->sp_slos != NULL, ("Null slos")); mp->mnt_data = smp; MNT_ILOCK(mp); mp->mnt_flag |= MNT_LOCAL; mp->mnt_kern_flag |= MNTK_USES_BCACHE; MNT_IUNLOCK(mp); return (0); error: if (smp != NULL) { free(smp, M_SLSFS); mp->mnt_data = NULL; } if (slsfsdev != NULL) { free(slsfsdev, M_SLSFS); } printf("Error mounting"); return (error); } /* * Flush all dirty buffers related to the SLOS to the backend. * * Checkpointing should follow this procedure * 1. Sync all data - this data is marked with the current snapshot so writes to * the same block during the same epoch don't incur another allocation. * * 2. Mark all BTree buffers CoW - we can do this as we are managing these * buffers so we can mark the buffers as CoW. So the next time we modify the * Btree it will make an allocation then and move the buffer over to the need * logical block. * * Btree's also get the advantage that since logical is physical we can cheat * and actually not copy the data to a new buffer. When the btrees get flushed, * once they get marked for CoW, we simply allocate, then move the buffer to the * correct logical block number within its buffer object (simply removing it * then inserting it with the new logical block number) * * 3. Sync all the Inodes (Syncing the SLOS_INODES_ROOT inode) * * 4. Now we have to sync the allocator btrees this, so we actually have to * preallocate what we will need as this may modify and dirty more data of the * underlying allocator btrees, we then sync the btrees with the pre-allocated * spaces. We don't use the trick above as this causes a circular dependency of * marking a allocator node as CoW, then needed to modify the same CoW btree * node for a new allocation. * * There may be a way to avoid this pre allocation * and deal with it later but I think this would require a secondary path within * the btrees to know that it is the allocator and it would clear the CoW flag * and continue the write but then allocate a new location for itself after the * write is done. * * 5. Retrieve next superblock and update it with the proper information of * where the inodes root is, as well as the new allocation tree roots (these * should aways be dirty in a dirty checkpoint), update epoch and done. */ uint64_t checkpoints = 0; static void slsfs_checkpoint(struct mount *mp, int closing) { struct vnode *vp, *mvp = NULL; struct buf *bp; struct slos_node *svp; struct slos_inode *ino; struct timespec te; diskptr_t ptr; int error; again: /* Go through the list of vnodes attached to the filesystem. */ MNT_VNODE_FOREACH_ACTIVE (vp, mp, mvp) { /* If we can't get a reference, the vnode is probably dead. */ if (vp->v_type == VNON) { VI_UNLOCK(vp); continue; } if (vp == slos.slsfs_inodes) { VI_UNLOCK(vp); continue; } if ((error = vget(vp, LK_EXCLUSIVE | LK_INTERLOCK | LK_NOWAIT, curthread)) != 0) { if (error == ENOENT) { MNT_VNODE_FOREACH_ALL_ABORT(mp, mvp); goto again; } continue; } // Skip over the btrees for now as we will sync them after the // data syncs if ((vp->v_vflag & VV_SYSTEM) || ((vp->v_type != VDIR) && (vp->v_type != VREG) && (vp->v_type != VLNK)) || (vp->v_data == NULL)) { vput(vp); continue; } if (SLSVP(vp)->sn_status & SLOS_DIRTY) { /* Step 1 and 2 Sync data and mark underlying Btree Copy * on write*/ error = slos_sync_vp(vp, closing); if (error) { vput(vp); return; } /* Sync of data and btree complete - unmark them and * update the root and dirty the root*/ error = slos_update(SLSVP(vp)); if (error) { vput(vp); return; } } vput(vp); } // Check if both the underlying Btree needs a sync or the inode itself - // should be a way to make it the same TODO // Just a hack for now to get this thing working XXX Why is it a hack? /* Sync the inode root itself. */ if (slos.slos_sb->sb_data_synced) { error = slos_blkalloc(&slos, BLKSIZE(&slos), &ptr); MPASS(error == 0); DEBUG("Checkpointing the inodes btree"); /* 3 Sync Root Inodes and btree */ error = vn_lock(slos.slsfs_inodes, LK_EXCLUSIVE); if (error) { panic("vn_lock failed"); } svp = SLSVP(slos.slsfs_inodes); ino = &svp->sn_ino; DEBUG2( "Flushing inodes %p %p", slos.slsfs_inodes, svp->sn_fdev); error = slos_sync_vp(slos.slsfs_inodes, closing); if (error) { panic("slos_sync_vp failed to checkpoint"); return; } /* * Allocate a new blk for the root inode write it and give it * to the superblock */ // Write out the root inode DEBUG("Creating the new superblock"); ino->ino_blk = ptr.offset; slos.slos_sb->sb_root.offset = ino->ino_blk; bp = getblk(svp->sn_fdev, ptr.offset, BLKSIZE(&slos), 0, 0, 0); MPASS(bp); memcpy(bp->b_data, ino, sizeof(struct slos_inode)); bawrite(bp); DEBUG("Checkpointing the checksum tree"); // Write out the checksum tree; error = slos_blkalloc(&slos, BLKSIZE(&slos), &ptr); if (error) { panic("Problem with allocation"); } DEBUG1("Flushing checksum %p", slos.slos_cktree->sn_tree.bt_backend); ino = &slos.slos_cktree->sn_ino; MPASS(slos.slos_cktree != SLSVP(slos.slsfs_inodes)); ino->ino_blk = ptr.offset; if (checksum_enabled) fbtree_sync(&slos.slos_cktree->sn_tree); bp = getblk(svp->sn_fdev, ptr.offset, BLKSIZE(&slos), 0, 0, 0); MPASS(bp); memcpy(bp->b_data, ino, sizeof(struct slos_inode)); bawrite(bp); slos.slos_sb->sb_cksumtree = ptr; DEBUG1("Checksum tree at %lu", ptr.offset); DEBUG1("Root Dir at %lu", SLSVP(slos.slsfs_inodes)->sn_ino.ino_blk); DEBUG1("Inodes File at %lu", slos.slos_sb->sb_root.offset); MPASS(ptr.offset != slos.slos_sb->sb_root.offset); slos.slos_sb->sb_index = (slos.slos_sb->sb_epoch) % 100; /* 4 Sync the allocator */ DEBUG("Syncing the allocator"); slos_allocator_sync(&slos, slos.slos_sb); DEBUG2("Epoch %lu done at superblock index %u", slos.slos_sb->sb_epoch, slos.slos_sb->sb_index); SLSVP(slos.slsfs_inodes)->sn_status &= ~(SLOS_DIRTY); /* Flush the current superblock itself. */ bp = getblk(slos.slos_vp, slos.slos_sb->sb_index, slos.slos_sb->sb_ssize, 0, 0, 0); MPASS(bp); memcpy(bp->b_data, slos.slos_sb, sizeof(struct slos_sb)); DEBUG("Flushing the checksum tree again"); if (checksum_enabled) fbtree_sync(&slos.slos_cktree->sn_tree); nanotime(&te); slos.slos_sb->sb_time = te.tv_sec; slos.slos_sb->sb_time_nsec = te.tv_nsec; bbarrierwrite(bp); VOP_UNLOCK(slos.slsfs_inodes, 0); checkpoints++; DEBUG3("Checkpoint: %lu, %lu, %lu", checkpoints, slos.slos_sb->sb_data_synced, slos.slos_sb->sb_meta_synced); slos.slos_sb->sb_data_synced = 0; slos.slos_sb->sb_meta_synced = 0; slos.slos_sb->sb_attempted_checkpoints = 0; slos.slos_sb->sb_epoch += 1; } else { slos.slos_sb->sb_attempted_checkpoints++; } } uint64_t checkpointtime = 100; /* * Daemon that flushes dirty buffers to the device. * * XXX It's very interesting how this combines with * explicit checkpoints */ static void slsfs_syncer(struct slos *slos) { slos->slsfs_sync_exit = 0; struct timespec ts, te; uint64_t elapsed, period; /* Periodically sync until we unmount. */ mtx_lock(&slos->slsfs_sync_lk); while (!slos->slsfs_sync_exit) { slos->slsfs_syncing = 1; mtx_unlock(&slos->slsfs_sync_lk); nanotime(&ts); slsfs_checkpoint(slos->slsfs_mount, 0); nanotime(&te); /* Notify anyone waiting to synchronize. */ mtx_lock(&slos->slsfs_sync_lk); slos->slsfs_syncing = 0; cv_broadcast(&slos->slsfs_sync_cv); mtx_unlock(&slos->slsfs_sync_lk); elapsed = (1000000000ULL * (te.tv_sec - ts.tv_sec)) + (te.tv_nsec - ts.tv_nsec); period = checkpointtime * 1000000ULL; te.tv_sec = 0; if (elapsed < period) { te.tv_nsec = period - elapsed; } else { te.tv_nsec = 0; } /* Wait until it's time to flush again. */ mtx_lock(&slos->slsfs_sync_lk); if (te.tv_nsec > 0) { msleep_sbt(&slos->slsfs_syncing, &slos->slsfs_sync_lk, PRIBIO, "Sync-wait", SBT_1NS * te.tv_nsec, 0, C_HARDCLOCK); } } DEBUG("Syncer exiting"); slos->slsfs_syncing = 1; mtx_unlock(&slos->slsfs_sync_lk); /* One last checkpoint before we exit. */ slsfs_checkpoint(slos->slsfs_mount, 1); mtx_lock(&slos->slsfs_sync_lk); /* Notify anyone else waiting to flush one last time. */ slos->slsfs_syncing = 0; DEBUG("Wake- up external"); cv_broadcast(&slos->slsfs_sync_cv); DEBUG("Syncer exited"); slos->slsfs_syncertd = NULL; mtx_unlock(&slos->slsfs_sync_lk); kthread_exit(); } /* * Initialize the in-memory state of the filesystem instance. */ static int slsfs_init_fs(struct mount *mp) { struct vnode *vp = NULL; int error; /* Get the filesystem root and initialize it if this is the first mount. */ VFS_ROOT(mp, LK_EXCLUSIVE, &vp); if (vp == NULL) { return (EIO); } /* Set up the syncer. */ slos.slsfs_mount = mp; error = kthread_add((void (*)(void *))slsfs_syncer, &slos, NULL, &slos.slsfs_syncertd, 0, 0, "slsfs syncer"); if (error) { panic("Syncer could not start"); } /* Initialize the root directory on first mount */ if (SLSINO(SLSVP(vp)).ino_nlink < 2) { slsfs_init_dir(vp, vp, NULL); } vput(vp); return (0); } /* * Wake up the SLOS syncer. */ int slsfs_wakeup_syncer(int is_exiting) { /* Don't sync again if already in progress. */ /* XXX Maybe exit if it's already in progress? How do we * serialize writes and syncs? (If a write after the last * sync but before this one doesn't get written by the former * then we have to go through with the latter). */ mtx_lock(&slos.slsfs_sync_lk); if (slos.slsfs_syncertd == NULL) { mtx_unlock(&slos.slsfs_sync_lk); return (0); } if (slos.slsfs_syncing) { cv_wait(&slos.slsfs_sync_cv, &slos.slsfs_sync_lk); } slos.slsfs_syncing = 1; if (is_exiting) { slos.slsfs_sync_exit = 1; } /* The actual wakeup. */ wakeup(&slos.slsfs_syncing); if (slos.slsfs_syncertd == NULL) { mtx_unlock(&slos.slsfs_sync_lk); return (0); } /* Wait until the syncer notifies us it's done. */ cv_wait(&slos.slsfs_sync_cv, &slos.slsfs_sync_lk); mtx_unlock(&slos.slsfs_sync_lk); return (0); } static int slsfs_free_system_vnode(struct vnode *vp) { struct slos_node *svp; svp = SLSVP(vp); vrele(vp); VOP_LOCK(vp, LK_EXCLUSIVE); VOP_RECLAIM(vp, curthread); VOP_UNLOCK(vp, 0); return 0; } /* * Mount the filesystem. */ static int slsfs_mount(struct mount *mp) { DEBUG("Mounting slsfs"); struct vnode *devvp = NULL; struct nameidata nd; struct vfsoptlist *opts; int error = 0; enum slos_state oldstate; char *from; DEBUG("Mounting drive"); /* We do nothing on updates. */ if (mp->mnt_flag & MNT_UPDATE) return (0); SLOS_LOCK(&slos); /* Cannot mount twice. */ if ((slos_getstate(&slos) != SLOS_UNMOUNTED) && (slos_getstate(&slos) != SLOS_SNAPCHANGE)) { SLOS_UNLOCK(&slos); return (EBUSY); } oldstate = slos_getstate(&slos); if (oldstate == SLOS_SNAPCHANGE) { KASSERT(mp->mnt_data != NULL, ("Requires mount data for snapshot remount")); struct slsfsmount *smp = mp->mnt_data; // Argument of index -1 means we want the latest snapshot and // we can write at that point if (smp->sp_index != -1) { mp->mnt_flag |= MNT_RDONLY; } else { mp->mnt_flag &= ~(MNT_RDONLY); } } slos_setstate(&slos, SLOS_INFLUX); SLOS_UNLOCK(&slos); if (mp->mnt_data != NULL) { slsfs_wakeup_syncer(1); vflush(mp, 0, FORCECLOSE, curthread); slsfs_free_system_vnode(slos.slsfs_inodes); slos.slsfs_inodes = NULL; VOP_LOCK(slos.slos_vp, LK_EXCLUSIVE); error = slsfs_mountfs(slos.slos_vp, mp); if (error != 0) { VOP_UNLOCK(slos.slos_vp, 0); goto error; } error = slsfs_init_fs(mp); if (error != 0) { VOP_UNLOCK(slos.slos_vp, 0); goto error; } VOP_UNLOCK(slos.slos_vp, 0); } else { opts = mp->mnt_optnew; vfs_filteropt(opts, slsfs_opts); from = vfs_getopts(opts, "from", &error); if (error != 0) goto error; NDINIT(&nd, LOOKUP, FOLLOW | LOCKLEAF, UIO_SYSSPACE, from, curthread); error = namei(&nd); if (error) goto error; NDFREE(&nd, NDF_ONLY_PNBUF); devvp = nd.ni_vp; if (!vn_isdisk(devvp, &error)) { /* XXX Can we make it so we can use a file? */ DEBUG("Is not a disk"); vput(devvp); goto error; } /* Get an ID for the new filesystem. */ vfs_getnewfsid(mp); /* Mount the filesystem and initialize its state. */ error = slsfs_mountfs(devvp, mp); if (error) { vput(devvp); goto error; } VOP_UNLOCK(slos.slos_vp, 0); error = slsfs_init_fs(mp); if (error) { /* XXX Cleanup init'ed state. */ printf("Couldn't init\n"); vrele(devvp); goto error; } /* Get the path where we found the device. */ vfs_mountedfrom(mp, from); } /* Remove the SLOS from the flux state. */ SLOS_LOCK(&slos); slos_setstate(&slos, SLOS_MOUNTED); SLOS_UNLOCK(&slos); return (0); error: /* Remove the SLOS from the flux state. */ SLOS_LOCK(&slos); slos_setstate(&slos, oldstate); SLOS_UNLOCK(&slos); return (error); } /* * Return the vnode for the root of the filesystem. */ static int slsfs_root(struct mount *mp, int flags, struct vnode **vpp) { struct vnode *vp; int error; /* * Use the already implemented VFS method with the * hardcoded value for the filesystem root. */ error = VFS_VGET(mp, SLOS_ROOT_INODE, flags, &vp); if (error) return (error); vp->v_type = VDIR; *vpp = vp; return (0); } /* * Export stats for the filesystem. * XXX Implement eventually */ static int slsfs_statfs(struct mount *mp, struct statfs *sbp) { struct slsfs_device *slsdev; struct slsfsmount *smp; struct slos_sb *sb = slos.slos_sb; smp = TOSMP(mp); slsdev = smp->sp_sdev; sbp->f_bsize = sb->sb_bsize; sbp->f_iosize = sb->sb_bsize; sbp->f_blocks = sb->sb_size; /* XXX We are not accounting for metadata blocks (e.g. trees). */ sbp->f_bfree = sbp->f_bavail = sb->sb_size - sb->sb_used; /* We have no limit on the amount of inodes. */ sbp->f_files = sbp->f_ffree = UINT_MAX; sbp->f_namemax = SLSFS_NAME_LEN; return (0); } /* * Unmount a device from the SLOS system and the kernel. */ static int slsfs_unmount_device(struct slsfs_device *sdev) { int error = 0; SLOS_LOCK(&slos); /* Unhook the SLOS from the GEOM layer. */ if (slos.slos_cp != NULL) { g_topology_lock(); g_vfs_close(slos.slos_cp); dev_ref(slos.slos_vp->v_rdev); g_topology_unlock(); } SLOS_UNLOCK(&slos); slos_allocator_uninit(&slos); free(slos.slos_sb, M_SLOS_SB); /* Destroy the device. */ mtx_destroy(&sdev->g_mtx); /* Restore the node's private data. */ sdev->devvp->v_data = sdev->vdata; free(sdev, M_SLSFS); DEBUG("Device Unmounted"); return error; } /* * Destroy the mounted filesystem data. */ static void slsfs_freemntinfo(struct mount *mp) { DEBUG("Destroying slsmount info"); struct slsfsmount *smp = TOSMP(mp); if (mp == NULL) return; free(smp, M_SLSFS); DEBUG("Destroyed slsmount info"); } /* * Unmount the filesystem from the kernel. */ static int slsfs_unmount(struct mount *mp, int mntflags) { struct slsfs_device *sdev; struct slsfsmount *smp; struct slos *slos; int error; int flags = 0; smp = mp->mnt_data; sdev = smp->sp_sdev; slos = smp->sp_slos; KASSERT(slos->slsfs_mount != NULL, ("no mount")); SLOS_LOCK(slos); if (slos_getstate(slos) != SLOS_MOUNTED && ((mntflags & MNT_FORCE) == 0)) { KASSERT(slos_getstate(slos) != SLOS_UNMOUNTED, ("unmounting nonexistent slsfs")); SLOS_UNLOCK(slos); return (EBUSY); } slos_setstate(slos, SLOS_INFLUX); SLOS_UNLOCK(slos); if (mntflags & MNT_FORCE) { flags |= FORCECLOSE; } /* Free the slos taskqueue, if we have not already done so. */ /* * XXX Can we move this to after we ensure this function succeeds? * If we fail to flush we are stuck with a file system with a * nonexistent taskqueue. If the SLS reattaches and tries to reuse it we * will crash. */ if (slos->slos_tq != NULL) taskqueue_free(slos->slos_tq); slos->slos_tq = NULL; /* * Flush the data to the disk. We have already removed all * vnodes, so this is going to be the last flush we need. */ slsfs_wakeup_syncer(1); error = vflush(mp, 0, flags, curthread); if (error) { printf("vflush failed with %d\n", error); goto error; } /* * Manually destroy the root inode. This works as long as everything * has been flushed above. */ slsfs_free_system_vnode(slos->slsfs_inodes); slos->slsfs_inodes = NULL; // Free the checksum tree slos_vpfree(slos, slos->slos_cktree); slos->slos_cktree = NULL; DEBUG("Flushed all active vnodes"); /* Remove the mounted device. */ error = slsfs_unmount_device(sdev); if (error) goto error; cv_destroy(&slos->slsfs_sync_cv); mtx_destroy(&slos->slsfs_sync_lk); slsfs_freemntinfo(mp); DEBUG("Freeing mount info"); mp->mnt_data = NULL; slos->slsfs_mount = NULL; DEBUG("Changing mount flags"); /* We've removed the local filesystem info. */ MNT_ILOCK(mp); mp->mnt_flag &= ~MNT_LOCAL; MNT_IUNLOCK(mp); /* Couldn't unmount after all. */ SLOS_LOCK(slos); slos_setstate(slos, SLOS_UNMOUNTED); SLOS_UNLOCK(slos); return (0); error: /* Couldn't unmount after all. */ SLOS_LOCK(slos); slos_setstate(slos, SLOS_MOUNTED); SLOS_UNLOCK(slos); printf("WARNING: SLOS failed unmount (error %d)\n", error); return (error); } static void slsfs_init_vnode(struct vnode *vp, uint64_t ino) { struct slos_node *mp = SLSVP(vp); if (ino == SLOS_ROOT_INODE) { vp->v_vflag |= VV_ROOT; vp->v_type = VDIR; SLSVP(vp)->sn_ino.ino_gid = 0; SLSVP(vp)->sn_ino.ino_uid = 0; } else if (ino == SLOS_INODES_ROOT) { vp->v_type = VREG; vp->v_vflag |= VV_SYSTEM; } else { vp->v_type = IFTOVT(mp->sn_ino.ino_mode); } if (vp->v_type == VFIFO) { vp->v_op = &slfs_fifoops; } vnode_create_vobject(vp, 0, curthread); } /* * Get a new vnode for the specified SLOS inode. */ static int slsfs_vget(struct mount *mp, uint64_t ino, int flags, struct vnode **vpp) { int error; struct vnode *vp; struct vnode *none; struct slos_node *svnode; struct thread *td; td = curthread; vp = NULL; none = NULL; ino = OIDTOSLSID(ino); /* Make sure the inode does not already have a vnode. */ error = vfs_hash_get(mp, ino, LK_EXCLUSIVE, td, &vp, NULL, NULL); if (error) { return (error); } /* If we do have a vnode already, return it. */ if (vp != NULL) { *vpp = vp; return (0); } /* Bring the inode in memory. */ error = slos_iopen(&slos, ino, &svnode); if (error) { *vpp = NULL; return (error); } /* Get a new blank vnode. */ error = getnewvnode("slsfs", mp, &slfs_vnodeops, &vp); if (error) { DEBUG("Problem getting new inode"); *vpp = NULL; return (error); } /* * If the vnode is not the root, which is managed directly * by the SLOS, add it to the mountpoint. */ vn_lock(vp, LK_EXCLUSIVE); if (ino != SLOS_INODES_ROOT) { error = insmntque(vp, mp); if (error) { DEBUG("Problem queing root into mount point"); *vpp = NULL; return (error); } } svnode->sn_slos = &slos; vp->v_data = svnode; vp->v_bufobj.bo_ops = &bufops_slsfs; vp->v_bufobj.bo_bsize = IOSIZE(svnode); slsfs_init_vnode(vp, ino); /* Again, if we're not the inode metanode, add bookkeeping. */ /* * XXX Why? This means we would get a different vnode every time * we try to open the metanode. */ *vpp = NULL; if (ino != SLOS_INODES_ROOT) { /* * Try to insert the new node into the table. We might have been * beaten to it by another process, in which case we reuse their * fresh vnode for the inode. */ error = vfs_hash_insert( vp, ino, LK_EXCLUSIVE, td, vpp, NULL, NULL); if (error != 0) { *vpp = NULL; return (error); } } DEBUG2("vget(%p) ino = %ld", vp, ino); /* If we weren't beaten to it, propagate the new node to the caller. */ if (*vpp == NULL) *vpp = vp; return (0); } static int slsfs_sync(struct mount *mp, int waitfor) { return (0); } static struct vfsops slfs_vfsops = { .vfs_init = slsfs_init, .vfs_uninit = slsfs_uninit, .vfs_root = slsfs_root, .vfs_statfs = slsfs_statfs, .vfs_mount = slsfs_mount, .vfs_unmount = slsfs_unmount, .vfs_vget = slsfs_vget, .vfs_sync = slsfs_sync }; VFS_SET(slfs_vfsops, slsfs, 0); MODULE_VERSION(slsfs, 0);
23.863846
80
0.679625
[ "object" ]
d4bbc54a0e86c3cdcee956092894c8015a2ddb06
2,851
c
C
contrib/gnu/gcc/dist/libgcc/config/sh/linux-atomic.c
TheSledgeHammer/2.11BSD
fe61f0b9aaa273783cd027c7b5ec77e95ead2153
[ "BSD-3-Clause" ]
3
2021-05-04T17:09:06.000Z
2021-10-04T07:19:26.000Z
contrib/gnu/gcc/dist/libgcc/config/sh/linux-atomic.c
TheSledgeHammer/2.11BSD
fe61f0b9aaa273783cd027c7b5ec77e95ead2153
[ "BSD-3-Clause" ]
null
null
null
contrib/gnu/gcc/dist/libgcc/config/sh/linux-atomic.c
TheSledgeHammer/2.11BSD
fe61f0b9aaa273783cd027c7b5ec77e95ead2153
[ "BSD-3-Clause" ]
null
null
null
/* Copyright (C) 2012-2020 Free Software Foundation, Inc. This file is part of GCC. GCC is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3, or (at your option) any later version. GCC is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. Under Section 7 of GPL version 3, you are granted additional permissions described in the GCC Runtime Library Exception, version 3.1, as published by the Free Software Foundation. You should have received a copy of the GNU General Public License and a copy of the GCC Runtime Library Exception along with this program; see the files COPYING3 and COPYING.RUNTIME respectively. If not, see <http://www.gnu.org/licenses/>. */ /* Atomic built-in C functions for link compatibility with older code that was compiled to emit function calls for atomic built-ins. Notice that if no atomic model has been selected the functions in this file must not be generated, or else they will result in infinite no-op loops. Notice also, that all the generated functions below take three parameters, which is not actually true for some of the built-in functions. However, on SH this does not matter, since the first four parameters are always passed in call clobbered registers. The return type for the sync_bool_compare_and_swap functions is also actually supposed to be a bool, but this also doesn't matter since any int return type <= 32 bit is returned in R0 on SH. */ #if !__SH_ATOMIC_MODEL_NONE__ typedef unsigned char uint8_t; typedef unsigned short uint16_t; typedef unsigned int uint32_t; #define uint8_t_sz 1 #define uint16_t_sz 2 #define uint32_t_sz 4 #define typesz(x) x##_sz #define concat(x,y) __ ## x ## _ ## y #define eval(x,y) concat (x,y) #define genname(f,t) eval(f, typesz (t)) #define func1(name, type) \ type __attribute__((visibility("hidden"))) \ genname (name, type) (type* x, type y, type z) \ { \ return __##name (x, y, z); \ } #define genfuncs(name) \ func1 (name, uint8_t) \ func1 (name, uint16_t) \ func1 (name, uint32_t) genfuncs (sync_lock_test_and_set) genfuncs (sync_val_compare_and_swap) genfuncs (sync_bool_compare_and_swap) genfuncs (sync_fetch_and_add) genfuncs (sync_fetch_and_or) genfuncs (sync_fetch_and_and) genfuncs (sync_fetch_and_xor) genfuncs (sync_fetch_and_sub) genfuncs (sync_fetch_and_nand) genfuncs (sync_add_and_fetch) genfuncs (sync_or_and_fetch) genfuncs (sync_and_and_fetch) genfuncs (sync_xor_and_fetch) genfuncs (sync_sub_and_fetch) genfuncs (sync_nand_and_fetch) #endif
34.768293
77
0.757278
[ "model" ]
d4bedc3599bd1524e5bc3f6d8ce5f0663a1b57c0
19,494
c
C
sdktools/mep/src/transkey.c
npocmaka/Windows-Server-2003
5c6fe3db626b63a384230a1aa6b92ac416b0765f
[ "Unlicense" ]
17
2020-11-13T13:42:52.000Z
2021-09-16T09:13:13.000Z
sdktools/mep/src/transkey.c
sancho1952007/Windows-Server-2003
5c6fe3db626b63a384230a1aa6b92ac416b0765f
[ "Unlicense" ]
2
2020-10-19T08:02:06.000Z
2020-10-19T08:23:18.000Z
sdktools/mep/src/transkey.c
sancho1952007/Windows-Server-2003
5c6fe3db626b63a384230a1aa6b92ac416b0765f
[ "Unlicense" ]
14
2020-11-14T09:43:20.000Z
2021-08-28T08:59:57.000Z
/*** transkey.c - keyboard translation * * Copyright <C> 1988, Microsoft Corporation * * Revision History: * * 03-Dec-1990 ramonsa createdc * *************************************************************************/ //#define INCL_DOSSEMAPHORES #include "mep.h" #include "keyboard.h" #include "keys.h" #include "cmds.h" WORD GetNumlockIndex (WORD Scan); #define NORMAL_KEY 0 #define ALT_KEY 1 #define CTRL_KEY 2 #define SHIFT_KEY 3 // This table is indexed by a Scan code (as found in the KBDKEY // structure), and contains entries for the corresponding internal // MEP codes. // WORD MapTable[][4] = { // Normal Alt Ctrl Shift Scan code // { 0x0000, 0x0000, 0x0000, 0x0000 }, // 00 { 0x0000, 0x0000, 0x0000, 0x0000 }, // 01 Left mouse { 0x0000, 0x0000, 0x0000, 0x0000 }, // 02 Right mouse { 0x0000, 0x0000, 0x0000, 0x0000 }, // 03 { 0x0000, 0x0000, 0x0000, 0x0000 }, // 04 { 0x0000, 0x0000, 0x0000, 0x0000 }, // 05 { 0x0000, 0x0000, 0x0000, 0x0000 }, // 06 { 0x0000, 0x0000, 0x0000, 0x0000 }, // 07 { 0x012D, 0x01A1, 0x0215, 0x0255 }, // 08 bksp { 0x012E, 0x01A2, 0x0216, 0x0256 }, // 09 tab-bktab { 0x0000, 0x0000, 0x0000, 0x0000 }, // 0A { 0x0000, 0x0000, 0x0000, 0x0000 }, // 0B { 0x0116, 0x018A, 0x01FE, 0x0000 }, // 0C goto { 0x0131, 0x01A5, 0x0219, 0x0259 }, // 0D enter { 0x0000, 0x0000, 0x0000, 0x0000 }, // 0E { 0x0000, 0x0000, 0x0000, 0x0000 }, // 0F { 0x0000, 0x0000, 0x0000, 0x0000 }, // 10 Shift { 0x0000, 0x0000, 0x0000, 0x0000 }, // 11 Ctrl { 0x0000, 0x0000, 0x0000, 0x0000 }, // 12 { 0x0000, 0x0000, 0x0000, 0x0000 }, // 13 Pause { 0x0000, 0x0000, 0x0000, 0x0000 }, // 14 Caps Lock { 0x0000, 0x0000, 0x0000, 0x0000 }, // 15 { 0x0000, 0x0000, 0x0000, 0x0000 }, // 16 { 0x0000, 0x0000, 0x0000, 0x0000 }, // 17 { 0x0000, 0x0000, 0x0000, 0x0000 }, // 18 { 0x0000, 0x0000, 0x0000, 0x0000 }, // 19 { 0x0000, 0x0000, 0x0000, 0x0000 }, // 1A { 0x0130, 0x0000, 0x0218, 0x0258 }, // 1B esc { 0x0000, 0x0000, 0x0000, 0x0000 }, // 1C { 0x0000, 0x0000, 0x0000, 0x0000 }, // 1D { 0x0000, 0x0000, 0x0000, 0x0000 }, // 1E { 0x0000, 0x0000, 0x0000, 0x0000 }, // 1F { 0x0000, 0x01A0, 0x0214, 0x0000 }, // 20 space { 0x0112, 0x0186, 0x01FA, 0x023A }, // 21 pgup { 0x0113, 0x0187, 0x01FB, 0x023B }, // 22 pgdown { 0x010D, 0x0181, 0x01F5, 0x0235 }, // 23 end { 0x010C, 0x0180, 0x01F4, 0x0234 }, // 24 home { 0x010E, 0x0182, 0x01F6, 0x0236 }, // 25 left { 0x0110, 0x0184, 0x01F8, 0x0238 }, // 26 up { 0x010F, 0x0183, 0x01F7, 0x0237 }, // 27 right { 0x0111, 0x0185, 0x01F9, 0x0239 }, // 28 down { 0x0000, 0x0000, 0x0000, 0x0000 }, // 29 { 0x0000, 0x0000, 0x0000, 0x0000 }, // 2A { 0x0000, 0x0000, 0x0000, 0x0000 }, // 2B { 0x0000, 0x0000, 0x0000, 0x0000 }, // 2C Print Scrn { 0x0114, 0x0188, 0x01FC, 0x023C }, // 2D ins { 0x0115, 0x0189, 0x01FD, 0x023D }, // 2E del { 0x0000, 0x0000, 0x0000, 0x0000 }, // 2F { 0x0000, 0x0140, 0x01B4, 0x0000 }, // 30 0 { 0x0000, 0x0141, 0x01B5, 0x0000 }, // 31 1 { 0x0000, 0x0142, 0x01B6, 0x0000 }, // 32 2 { 0x0000, 0x0143, 0x01B7, 0x0000 }, // 33 3 { 0x0000, 0x0144, 0x01B8, 0x0000 }, // 34 4 { 0x0000, 0x0145, 0x01B9, 0x0000 }, // 35 5 { 0x0000, 0x0146, 0x01BA, 0x0000 }, // 36 6 { 0x0000, 0x0147, 0x01BB, 0x0000 }, // 37 7 { 0x0000, 0x0148, 0x01BC, 0x0000 }, // 38 8 { 0x0000, 0x0149, 0x01BD, 0x0000 }, // 39 9 { 0x0000, 0x0000, 0x0000, 0x0000 }, // 3A { 0x0000, 0x0000, 0x0000, 0x0000 }, // 3B { 0x0000, 0x0000, 0x0000, 0x0000 }, // 3C { 0x0000, 0x0000, 0x0000, 0x0000 }, // 3D { 0x0000, 0x0000, 0x0000, 0x0000 }, // 3E { 0x0000, 0x0000, 0x0000, 0x0000 }, // 3F { 0x0000, 0x0000, 0x0000, 0x0000 }, // 40 { 0x0000, 0x014C, 0x01C0, 0x0000 }, // 41 a { 0x0000, 0x014D, 0x01C1, 0x0000 }, // 42 b { 0x0000, 0x014E, 0x01C2, 0x0000 }, // 43 c { 0x0000, 0x014F, 0x01C3, 0x0000 }, // 44 d { 0x0000, 0x0150, 0x01C4, 0x0000 }, // 45 e { 0x0000, 0x0151, 0x01C5, 0x0000 }, // 46 f { 0x0000, 0x0152, 0x01C6, 0x0000 }, // 47 g { 0x0000, 0x0153, 0x01C7, 0x0000 }, // 48 h { 0x0000, 0x0154, 0x01C8, 0x0000 }, // 49 i { 0x0000, 0x0155, 0x01C9, 0x0000 }, // 4A j { 0x0000, 0x0156, 0x01CA, 0x0000 }, // 4B k { 0x0000, 0x0157, 0x01CB, 0x0000 }, // 4C l { 0x0000, 0x0158, 0x01CC, 0x0000 }, // 4D m { 0x0000, 0x0159, 0x01CD, 0x0000 }, // 4E n { 0x0000, 0x015A, 0x01CE, 0x0000 }, // 4F o { 0x0000, 0x015B, 0x01CF, 0x0000 }, // 50 p { 0x0000, 0x015C, 0x01D0, 0x0000 }, // 51 q { 0x0000, 0x015D, 0x01D1, 0x0000 }, // 52 r { 0x0000, 0x015E, 0x01D2, 0x0000 }, // 53 s { 0x0000, 0x015F, 0x01D3, 0x0000 }, // 54 t { 0x0000, 0x0160, 0x01D4, 0x0000 }, // 55 u { 0x0000, 0x0161, 0x01D5, 0x0000 }, // 56 v { 0x0000, 0x0162, 0x01D6, 0x0000 }, // 57 w { 0x0000, 0x0163, 0x01D7, 0x0000 }, // 58 x { 0x0000, 0x0164, 0x01D8, 0x0000 }, // 59 y { 0x0000, 0x0165, 0x01D9, 0x0000 }, // 5A z { 0x0000, 0x0000, 0x0000, 0x0000 }, // 5B { 0x0000, 0x0000, 0x0000, 0x0000 }, // 5C { 0x0000, 0x0000, 0x0000, 0x0000 }, // 5D { 0x0000, 0x0000, 0x0000, 0x0000 }, // 5E { 0x0000, 0x0000, 0x0000, 0x0000 }, // 5F { 0x0000, 0x0000, 0x0000, 0x0000 }, // 60 { 0x0000, 0x0000, 0x0000, 0x0000 }, // 61 { 0x0000, 0x0000, 0x0000, 0x0000 }, // 62 { 0x0000, 0x0000, 0x0000, 0x0000 }, // 63 { 0x0000, 0x0000, 0x0000, 0x0000 }, // 64 { 0x0000, 0x0000, 0x0000, 0x0000 }, // 65 { 0x0000, 0x0000, 0x0000, 0x0000 }, // 66 { 0x0000, 0x0000, 0x0000, 0x0000 }, // 67 { 0x0000, 0x0000, 0x0000, 0x0000 }, // 68 { 0x0000, 0x0000, 0x0000, 0x0000 }, // 69 { 0x0126, 0x019A, 0x020E, 0x024E }, // 6A num* { 0x0125, 0x0199, 0x020D, 0x024D }, // 6B num+ { 0x0128, 0x019C, 0x0210, 0x0250 }, // 6C numenter { 0x0124, 0x0198, 0x020C, 0x024C }, // 6D num- { 0x0000, 0x0000, 0x0000, 0x0000 }, // 6E // { 0x0000, 0x017E, 0x01F2, 0x0000 }, // ?? / { 0x0127, 0x019b, 0x020F, 0x024F }, // 6F num/ { 0x0100, 0x0168, 0x01DC, 0x0228 }, // 70 f1 { 0x0101, 0x0169, 0x01DD, 0x0229 }, // 71 f2 { 0x0102, 0x016A, 0x01DE, 0x022A }, // 72 f3 { 0x0103, 0x016B, 0x01DF, 0x022B }, // 73 f4 { 0x0104, 0x016C, 0x01E0, 0x022C }, // 74 f5 { 0x0105, 0x016D, 0x01E1, 0x022D }, // 75 f6 { 0x0106, 0x016E, 0x01E2, 0x022E }, // 76 f7 { 0x0107, 0x016F, 0x01E3, 0x022F }, // 77 f8 { 0x0108, 0x0170, 0x01E4, 0x0230 }, // 78 f9 { 0x0109, 0x0171, 0x01E5, 0x0231 }, // 79 f10 { 0x010A, 0x0172, 0x01E6, 0x0232 }, // 7A f11 { 0x010B, 0x0173, 0x01E7, 0x0233 }, // 7B f12 { 0x0000, 0x0000, 0x0000, 0x0000 }, // 7C { 0x0000, 0x0000, 0x0000, 0x0000 }, // 7D { 0x0000, 0x0000, 0x0000, 0x0000 }, // 7E { 0x0000, 0x0000, 0x0000, 0x0000 }, // 7F { 0x0000, 0x0000, 0x0000, 0x0000 }, // 80 { 0x0000, 0x0000, 0x0000, 0x0000 }, // 81 { 0x0000, 0x0000, 0x0000, 0x0000 }, // 82 { 0x0000, 0x0000, 0x0000, 0x0000 }, // 83 { 0x0000, 0x0000, 0x0000, 0x0000 }, // 84 { 0x0000, 0x0000, 0x0000, 0x0000 }, // 85 { 0x0000, 0x0000, 0x0000, 0x0000 }, // 86 { 0x0000, 0x0000, 0x0000, 0x0000 }, // 87 { 0x0000, 0x0000, 0x0000, 0x0000 }, // 88 { 0x0000, 0x0000, 0x0000, 0x0000 }, // 89 { 0x0000, 0x0000, 0x0000, 0x0000 }, // 8A { 0x0000, 0x0000, 0x0000, 0x0000 }, // 8B { 0x0000, 0x0000, 0x0000, 0x0000 }, // 8C { 0x0000, 0x0000, 0x0000, 0x0000 }, // 8D { 0x0000, 0x0000, 0x0000, 0x0000 }, // 8E { 0x0000, 0x0000, 0x0000, 0x0000 }, // 8F { 0x0000, 0x0000, 0x0000, 0x0000 }, // 90 Num lock { 0x0000, 0x0000, 0x0000, 0x0000 }, // 91 Scroll Lock { 0x0000, 0x0000, 0x0000, 0x0000 }, // 92 { 0x0000, 0x0000, 0x0000, 0x0000 }, // 93 { 0x0000, 0x0000, 0x0000, 0x0000 }, // 94 { 0x0000, 0x0000, 0x0000, 0x0000 }, // 95 { 0x0000, 0x0000, 0x0000, 0x0000 }, // 96 { 0x0000, 0x0000, 0x0000, 0x0000 }, // 97 { 0x0000, 0x0000, 0x0000, 0x0000 }, // 98 { 0x0000, 0x0000, 0x0000, 0x0000 }, // 99 { 0x0000, 0x0000, 0x0000, 0x0000 }, // 9A { 0x0000, 0x0000, 0x0000, 0x0000 }, // 9B { 0x0000, 0x0000, 0x0000, 0x0000 }, // 9C { 0x0000, 0x0000, 0x0000, 0x0000 }, // 9D { 0x0000, 0x0000, 0x0000, 0x0000 }, // 9E { 0x0000, 0x0000, 0x0000, 0x0000 }, // 9F { 0x0000, 0x0000, 0x0000, 0x0000 }, // A0 { 0x0000, 0x0000, 0x0000, 0x0000 }, // A1 { 0x0000, 0x0000, 0x0000, 0x0000 }, // A2 { 0x0000, 0x0000, 0x0000, 0x0000 }, // A3 { 0x0000, 0x0000, 0x0000, 0x0000 }, // A4 { 0x0000, 0x0000, 0x0000, 0x0000 }, // A5 { 0x0000, 0x0000, 0x0000, 0x0000 }, // A6 { 0x0000, 0x0000, 0x0000, 0x0000 }, // A7 { 0x0000, 0x0000, 0x0000, 0x0000 }, // A8 { 0x0000, 0x0000, 0x0000, 0x0000 }, // A9 { 0x0000, 0x0000, 0x0000, 0x0000 }, // AA { 0x0000, 0x0000, 0x0000, 0x0000 }, // AB { 0x0000, 0x0000, 0x0000, 0x0000 }, // AC { 0x0000, 0x0000, 0x0000, 0x0000 }, // AD { 0x0000, 0x0000, 0x0000, 0x0000 }, // AE { 0x0000, 0x0000, 0x0000, 0x0000 }, // AF { 0x0000, 0x0000, 0x0000, 0x0000 }, // B0 { 0x0000, 0x0000, 0x0000, 0x0000 }, // B1 { 0x0000, 0x0000, 0x0000, 0x0000 }, // B2 { 0x0000, 0x0000, 0x0000, 0x0000 }, // B3 { 0x0000, 0x0000, 0x0000, 0x0000 }, // B4 { 0x0000, 0x0000, 0x0000, 0x0000 }, // B5 { 0x0000, 0x0000, 0x0000, 0x0000 }, // B6 { 0x0000, 0x0000, 0x0000, 0x0000 }, // B7 { 0x0000, 0x0000, 0x0000, 0x0000 }, // B8 { 0x0000, 0x0000, 0x0000, 0x0000 }, // B9 { 0x0000, 0x017A, 0x01EE, 0x0000 }, // BA ; { 0x0000, 0x0176, 0x01EA, 0x0000 }, // BB + { 0x0000, 0x017C, 0x01F0, 0x0000 }, // BC , { 0x0000, 0x0175, 0x01E9, 0x0000 }, // BD - { 0x0000, 0x017D, 0x01F1, 0x0000 }, // BE . { 0x0000, 0x017E, 0x01F2, 0x0000 }, // BF / { 0x0000, 0x0174, 0x01E8, 0x0000 }, // C0 ` { 0x0000, 0x017B, 0x01EF, 0x0000 }, // C1 ' { 0x0000, 0x0000, 0x0000, 0x0000 }, // C2 { 0x0000, 0x0000, 0x0000, 0x0000 }, // C3 { 0x0000, 0x0000, 0x0000, 0x0000 }, // C4 { 0x0000, 0x0000, 0x0000, 0x0000 }, // C5 { 0x0000, 0x0000, 0x0000, 0x0000 }, // C6 { 0x0000, 0x0000, 0x0000, 0x0000 }, // C7 { 0x0000, 0x0000, 0x0000, 0x0000 }, // C8 { 0x0000, 0x0000, 0x0000, 0x0000 }, // C9 { 0x0000, 0x0000, 0x0000, 0x0000 }, // CA { 0x0000, 0x0000, 0x0000, 0x0000 }, // CB { 0x0000, 0x0000, 0x0000, 0x0000 }, // CC { 0x0000, 0x0000, 0x0000, 0x0000 }, // CD { 0x0000, 0x0000, 0x0000, 0x0000 }, // CE { 0x0000, 0x0000, 0x0000, 0x0000 }, // CF { 0x0000, 0x0000, 0x0000, 0x0000 }, // D0 { 0x0000, 0x0000, 0x0000, 0x0000 }, // D1 { 0x0000, 0x0000, 0x0000, 0x0000 }, // D2 { 0x0000, 0x0000, 0x0000, 0x0000 }, // D3 { 0x0000, 0x0000, 0x0000, 0x0000 }, // D4 { 0x0000, 0x0000, 0x0000, 0x0000 }, // D5 { 0x0000, 0x0000, 0x0000, 0x0000 }, // D6 { 0x0000, 0x0000, 0x0000, 0x0000 }, // D7 { 0x0000, 0x0000, 0x0000, 0x0000 }, // D8 { 0x0000, 0x0000, 0x0000, 0x0000 }, // D9 { 0x0000, 0x0000, 0x0000, 0x0000 }, // DA { 0x0000, 0x0177, 0x01EB, 0x0000 }, // DB [ { 0x0000, 0x0179, 0x01ED, 0x0000 }, // DC backslash { 0x0000, 0x0178, 0x01EC, 0x0000 }, // DD ] { 0x0000, 0x017B, 0x01EF, 0x0000 }, // DE ' { 0x0000, 0x0176, 0x01EA, 0x0000 }, // DF = }; #define LAST_SCAN 0xDF // This table contains entries for codes when NUMLOCK is on, // it is not indexed by scan code, but by an index obtain thru the // function GetNumlockIndex function. // WORD MapNumlockTable[][4] = { // Special Alt Ctrl Shift Index Key // { 0x0118, 0x018C, 0x0200, 0x0240 }, // 0 num0 { 0x0119, 0x018D, 0x0201, 0x0241 }, // 1 num1 { 0x011A, 0x018E, 0x0202, 0x0242 }, // 2 num2 { 0x011B, 0x018F, 0x0203, 0x0243 }, // 3 num3 { 0x011C, 0x0190, 0x0204, 0x0244 }, // 4 num4 { 0x011D, 0x0191, 0x0205, 0x0245 }, // 5 num5 { 0x011E, 0x0192, 0x0206, 0x0246 }, // 6 num6 { 0x011F, 0x0193, 0x0207, 0x0247 }, // 7 num7 { 0x0120, 0x0194, 0x0208, 0x0248 }, // 8 num8 { 0x0121, 0x0195, 0x0209, 0x0249 }, // 9 num9 { 0x0124, 0x0198, 0x020C, 0x024C }, // 10 num- { 0x0125, 0x0199, 0x020D, 0x024D }, // 11 num+ { 0x0126, 0x019A, 0x020E, 0x024E }, // 12 num* { 0x0127, 0x019B, 0x020F, 0x024F }, // 13 num/ { 0x0128, 0x019C, 0x0210, 0x0250 }, // 14 numenter { 0x0000, 0x0000, 0x0000, 0x0000 } // 15 }; #define NUMLOCK_NOMAP ((WORD)(-1)) /*** TranslateKey * * Purpose: * * Translates a KBDKEY structure into a KEY_INFO structure. * * This is the only function within the editor that knows about * the scan codes in the KBDKEY structure. All other editor functions * use our own codes (as found in the KEY_INFO structure). * * Input: * KBDKEY structure * * Returns * KEY_INFO structure * * *************************************************************************/ EDITOR_KEY TranslateKey ( KBDKEY kbdi ) { BYTE Ascii = (BYTE)kbdi.Unicode; BYTE Scan = (BYTE)kbdi.Scancode; BYTE Flags = 0x00; DWORD KbdiFlags = kbdi.Flags; EDITOR_KEY k; WORD MepCode = 0; WORD ControlKey = 0; WORD Index; if (Scan <= LAST_SCAN) { if (KbdiFlags & (CONS_LEFT_ALT_PRESSED | CONS_RIGHT_ALT_PRESSED)) { Flags |= FLAG_ALT; ControlKey = ALT_KEY; } if (KbdiFlags & (CONS_LEFT_CTRL_PRESSED | CONS_RIGHT_CTRL_PRESSED)) { Flags |= FLAG_CTRL; //Ascii &= 0x0F; if ( !ControlKey ) { ControlKey = CTRL_KEY; } else { // // Foreign keyboard stuff // if ( Ascii != 0x00 ) { Flags = 0; ControlKey = 0; } } } if (KbdiFlags & CONS_SHIFT_PRESSED) { Flags |= FLAG_SHIFT; if ( !ControlKey ) { ControlKey = SHIFT_KEY; } } if (KbdiFlags & CONS_NUMLOCK_PRESSED) { Flags |= FLAG_NUMLOCK; // // Numlock is set, determine which table to use // Index = GetNumlockIndex(Scan); if (Index == NUMLOCK_NOMAP) { // // Key not affected by Numlock, use normal table // MepCode = MapTable[Scan][ControlKey]; } else { // // Key is affected by Numlock, use special table // MepCode = MapNumlockTable[Index][ControlKey]; } } else { // // Numlock not set, use normal table // MepCode = MapTable[Scan][ControlKey]; } } k.KeyInfo.KeyData.Ascii = Ascii; k.KeyInfo.KeyData.Scan = Scan; k.KeyInfo.KeyData.Flags = Flags; k.KeyInfo.KeyData.Unused = 0x00; if (MepCode) { // // Found an MEP code // k.KeyCode = MepCode; } else { // // Our scan code is within the 256 ASCII characters, form the // KEY_INFO structure and return. // k.KeyCode = Ascii; } return k; } WORD GetNumlockIndex ( WORD Scan ) { switch (Scan) { case 0x60: return 0; // num0 case 0x61: return 1; // num1 case 0x62: return 2; // num2 case 0x63: return 3; // num3 case 0x64: return 4; // num4 case 0x65: return 5; // num5 case 0x66: return 6; // num6 case 0x67: return 7; // num7 case 0x68: return 8; // num8 case 0x69: return 9; // num9 case 0x6D: return 10; // num- case 0x6B: return 11; // num+ case 0x6A: return 12; // num* case 0x6F: return 13; // num/ case 0x6C: return 14; // numenter default: return NUMLOCK_NOMAP; } }
44.004515
78
0.453729
[ "3d" ]
b48abb64375d3f55df471ab7711ab08c876c684f
42,927
c
C
src/simulation.c
stivalaa/EstimNetDirected
ca09165ba85cd68b53897f603944fa61bd1cd997
[ "MIT" ]
21
2018-11-25T22:01:22.000Z
2022-03-24T22:33:11.000Z
src/simulation.c
stivalaa/EstimNetDirected
ca09165ba85cd68b53897f603944fa61bd1cd997
[ "MIT" ]
null
null
null
src/simulation.c
stivalaa/EstimNetDirected
ca09165ba85cd68b53897f603944fa61bd1cd997
[ "MIT" ]
3
2020-06-17T15:46:46.000Z
2021-12-14T22:46:45.000Z
/***************************************************************************** * * File: simulation.c * Author: Alex Stivala * Created: October 2019 * * Draw samples from ERGM distribution of directed graphs. * ****************************************************************************/ #include <stdio.h> #include <stdlib.h> #include <errno.h> #include <string.h> #include <math.h> #include <assert.h> #include <limits.h> #include "utils.h" #include "digraph.h" #include "basicSampler.h" #include "ifdSampler.h" #include "tntSampler.h" #include "simulation.h" #include "loadDigraph.h" /***************************************************************************** * * local functions * ****************************************************************************/ /* * Make an Erdos-Renyi aka Bernoulli directed random graph G(n, m) * with n nodes and m m edges. I.e. the m edges are placed between * dyads chosen uniformly at random. * * Parameters: * g - digraph object. Modifed. * numArcs - number of arcs [m in G(n,m) notation] * n - number of parameters (length of theta vector and total * number of change statistic functions) * n_attr - number of attribute change stats functions * n_dyadic -number of dyadic covariate change stats funcs * n_attr_interaction - number of attribute interaction change stats funcs * change_stats_funcs - array of pointers to change statistics functions * length is n-n_attr-n_dyadic-n_attr_interaction * lambda_values - array of lambda values for change stats funcs * same length as change_stats_funcs * attr_change_stats_funcs - array of pointers to change statistics functions * length is n_attr * dyadic_change_stats_funcs - array of pointers to dyadic change stats funcs * length is n_dyadic * attr_interaction_change_stats_funcs - array of pointers to attribute * interaction (pair) change statistics functions. * length is n_attr_interaction. * attr_indices - array of n_attr attribute indices (index into g->binattr * or g->catattr) corresponding to attr_change_stats_funcs * E.g. for Sender effect on the first binary attribute, * attr_indices[x] = 0 and attr_change_stats_funcs[x] = * changeSender * attr_interaction_pair_indices - array of n_attr_interaction pairs * of attribute inidices similar to above but * for attr_interaction_change_setats_funcs which * requires pairs of indices. * useConditionalEstimation - if True preserve snowball sampling zone * structure. * forbidReciprocity - if True do not allow reciprocated arcs. * addChangeStats - (Out) vector of n change stats for add moves * Allocated by caller. Assuming we start * with the empty graph, this will then * have the counts of statistics in the * graph at the end. * theta - parameter values (required by * calcChangeStats for total but value * not used here) * citationERGM - use cERGM (citation ERGM) estimation conditional * on term (time period) * allowLoops - allow self-edges (loops) * * Return value: * None. The digraph parameter g is updated. */ static void make_erdos_renyi_digraph(digraph_t *g, uint_t numArcs, uint_t n, uint_t n_attr, uint_t n_dyadic, uint_t n_attr_interaction, change_stats_func_t *change_stats_funcs[], double lambda_values[], attr_change_stats_func_t *attr_change_stats_funcs[], dyadic_change_stats_func_t *dyadic_change_stats_funcs[], attr_interaction_change_stats_func_t *attr_interaction_change_stats_funcs[], uint_t attr_indices[], uint_pair_t attr_interaction_pair_indices[], bool useConditionalEstimation, bool forbidReciprocity, double addChangeStats[], double theta[], bool citationERGM, bool allowLoops) { uint_t i, j, k, l; double *changestats = (double *)safe_malloc(n*sizeof(double)); assert(!(citationERGM && useConditionalEstimation)); for (k = 0; k < numArcs; k++) { if (useConditionalEstimation) { assert(!forbidReciprocity); /* TODO not implemented for snowball */ /* Add move for conditional estimation. Find two nodes i, j in inner waves without arc i->j uniformly at random. Because graph is sparse, it is not too inefficient to just pick random nodes until such a pair is found. For conditional estimation we also have the extra constraint that the nodes must be in the same wave or adjacent waves for the tie to be added. */ do { i = g->inner_nodes[int_urand(g->num_inner_nodes)]; do { j = g->inner_nodes[int_urand(g->num_inner_nodes)]; } while (!allowLoops && i == j); assert(g->zone[i] < g->max_zone && g->zone[j] < g->max_zone); } while (isArc(g, i, j) || (labs((long)g->zone[i] - (long)g->zone[j]) > 1)); } else if (citationERGM) { /* cERGM: select random node i in last time period (term) and random * node j (in any term) without arc i->j and add arc i->j between them. * In this way * we have all arcs (citations) in terms earlier than the last fixed, * and we only create citations from nodes in the last term. * Because graph is sparse, it is not too inefficient * to just pick random nodes until such a pair is found */ do { do { i = g->maxterm_nodes[int_urand(g->num_maxterm_nodes)]; do { j = int_urand(g->num_nodes); } while (i == j); } while (isArc(g, i, j)); } while (forbidReciprocity && isArc(g, j, i)); assert(g->term[i] == g->max_term); } else { /* not using conditional estimation */ /* Add move. Find two nodes i, j without arc i->j uniformly at random. Because graph is sparse, it is not too inefficient to just pick random nodes until such a pair is found */ do { do { i = int_urand(g->num_nodes); do { j = int_urand(g->num_nodes); } while (i == j); } while (isArc(g, i, j)); } while (forbidReciprocity && isArc(g, j, i)); } /* add change statistics to addChangeStats array */ (void)calcChangeStats(g, i, j, n, n_attr, n_dyadic, n_attr_interaction, change_stats_funcs, lambda_values, attr_change_stats_funcs, dyadic_change_stats_funcs, attr_interaction_change_stats_funcs, attr_indices, attr_interaction_pair_indices, theta, FALSE, changestats); for (l = 0; l < n; l++) addChangeStats[l] += changestats[l]; /* actually do the move by adding the arc */ if (useConditionalEstimation) { insertArc_allinnerarcs(g, i, j); } else if (citationERGM) { insertArc_all_maxtermsender_arcs(g, i, j); } else { insertArc_allarcs(g, i, j); } } free(changestats); } /***************************************************************************** * * external functions * ****************************************************************************/ /* * Generate digraphs from ERGM distribution with supplied parameters. * * Parameters: * g - (in/out) Initial digraph object (empty graph with N nodes * intiially where N is number of nodes in graphs to simulate). * n - number of parameters (length of theta vector and total * number of change statistics functions) * n_attr - number of attribute change statistics functions * n_dyadic -number of dyadic covariate change stats funcs * n_attr_interaction - number of attribute interaction change stats funcs * change_stats_funcs - array of pointers to change statistics functions * length is n - n_attr - n_dyadic - n_attr_interaction * lambda_values - array of lambda values for change stats funcs * same length as change_stats_funcs * attr_change_stats_funcs - array of pointers to change statistics functions * length is n_attr * dyadic_change_stats_funcs - array of pointers to dyadic change stats funcs * length is n_dyadic * attr_interaction_change_stats_funcs - array of pointers to attribute * interaction (pair) change statistics functions. * length is n_attr_interaction. * attr_indices - array of n_attr attribute indices (index into g->binattr * or g->catattr) corresponding to attr_change_stats_funcs * E.g. for Sender effect on the first binary attribute, * attr_indices[x] = 0 and attr_change_stats_funcs[x] = * changeSender * attr_interaction_pair_indices - array of n_attr_interaction pairs * of attribute inidices similar to above but * for attr_interaction_change_setats_funcs which * requires pairs of indices. * sample_size - number of samples to take from ERGM simulation * interval - sampler iterations between each sample * burnin - number of iterations to discard initially * theta - array of n parameter values corresponding to * change stats funcs. Allocated by caller. * iteration, not just every outer iteration. * useIFDsampler - if true, use the IFD sampler instead of the basic * sampler * ifd_K - consant for multiplying IFD auxiliary parameter * (only used if useIFDsampler is True). * useConditionalSimulation - if True, do conditional simulation of * snowball network samples. * forbidReciprocity - if True, constrain ERGM sampling so that reciprocated * arcs are not allowed to be created (so simulation * is conditional on no reciprocated arcs, should have * none in input observed graph). * sim_net_file_prefix - simulated network output filename prefix * dzA_outfile - open (write) file to write dzA values to. * outputSimulatedNetworks - if True write simulated networks in Pajek format. * arc_param_index - index in theta[] parameter of Arc parameter value. * Only used for useIFDsampler=TRUE * dzA - (in/Out) vector of n change stats * Allocated by caller, set to initial graph values * useTNTsampler - use TNT sampler not IFD or basic. * citationERGM - use cERGM (citation ERGM) estimation conditional * on term (time period) * allowLoops - allow self-edges (loops) * * Return value: * Nonzero on error, 0 if OK. * */ int simulate_ergm(digraph_t *g, uint_t n, uint_t n_attr, uint_t n_dyadic, uint_t n_attr_interaction, change_stats_func_t *change_stats_funcs[], double lambda_values[], attr_change_stats_func_t *attr_change_stats_funcs[], dyadic_change_stats_func_t *dyadic_change_stats_funcs[], attr_interaction_change_stats_func_t *attr_interaction_change_stats_funcs[], uint_t attr_indices[], uint_pair_t attr_interaction_pair_indices[], uint_t sample_size, uint_t interval, uint_t burnin, double theta[], bool useIFDsampler, double ifd_K, bool useConditionalSimulation, bool forbidReciprocity, char *sim_net_file_prefix, FILE *dzA_outfile, bool outputSimulatedNetworks, uint_t arc_param_index, double dzA[], bool useTNTsampler, bool citationERGM, bool allowLoops) { FILE *sim_outfile; char sim_outfilename[PATH_MAX+1]; double acceptance_rate = 0; double *addChangeStats = (double *)safe_malloc(n*sizeof(double)); double *delChangeStats = (double *)safe_malloc(n*sizeof(double)); double dzArc; /* only used for IFD sampler */ double ifd_aux_param; /* auxiliary parameter for IFD sampler */ uint_t l; uint_t samplenum; ulonglong_t iternum; struct timeval start_timeval, end_timeval, elapsed_timeval; int etime; char suffix[16]; /* only has to be large enough for "_x.txt" where fx is iteration number */ assert(!(useIFDsampler && useTNTsampler)); assert(!(citationERGM && useConditionalSimulation)); if (useIFDsampler) ifd_aux_param = theta[arc_param_index] + arcCorrection(g, useConditionalSimulation, citationERGM, forbidReciprocity, allowLoops); printf("sampleSize = %u, interval = %u burnin = %u\n", sample_size, interval, burnin); if (useIFDsampler) printf("IFD sampler ifd_K = %g initial auxiliary parameter V = %g\n", ifd_K, ifd_aux_param); else if (useTNTsampler) printf("TNT sampler\n"); if (useConditionalSimulation) printf("Doing conditional simulation of snowball sample\n"); if (forbidReciprocity) printf("Simulation is conditional on no reciprocated arcs\n"); if (citationERGM) printf("citation ERGM (cERGM) simulation conditional on term\n"); if (allowLoops) printf("allowing self-edges (loops)\n"); if (burnin > 0) { gettimeofday(&start_timeval, NULL); if (useIFDsampler) { acceptance_rate = ifdSampler(g, n, n_attr, n_dyadic, n_attr_interaction, change_stats_funcs, lambda_values, attr_change_stats_funcs, dyadic_change_stats_funcs, attr_interaction_change_stats_funcs, attr_indices, attr_interaction_pair_indices, theta, addChangeStats, delChangeStats, burnin, TRUE, /*actually do moves */ ifd_K, &dzArc, &ifd_aux_param, useConditionalSimulation, forbidReciprocity, citationERGM, allowLoops); } else if (useTNTsampler) { acceptance_rate = tntSampler(g, n, n_attr, n_dyadic, n_attr_interaction, change_stats_funcs, lambda_values, attr_change_stats_funcs, dyadic_change_stats_funcs, attr_interaction_change_stats_funcs, attr_indices, attr_interaction_pair_indices, theta, addChangeStats, delChangeStats, burnin, TRUE,/*actually do moves*/ useConditionalSimulation, forbidReciprocity, citationERGM, allowLoops); } else { acceptance_rate = basicSampler(g, n, n_attr, n_dyadic, n_attr_interaction, change_stats_funcs, lambda_values, attr_change_stats_funcs, dyadic_change_stats_funcs, attr_interaction_change_stats_funcs, attr_indices, attr_interaction_pair_indices, theta, addChangeStats, delChangeStats, burnin, TRUE,/*actually do moves*/ useConditionalSimulation, forbidReciprocity, citationERGM, allowLoops); } for (l = 0; l < n; l++) { dzA[l] += addChangeStats[l] - delChangeStats[l]; /* dzA accumulates */ /* but during burn-in we do not output these values */ } gettimeofday(&end_timeval, NULL); timeval_subtract(&elapsed_timeval, &end_timeval, &start_timeval); etime = 1000 * elapsed_timeval.tv_sec + elapsed_timeval.tv_usec/1000; printf("burnin %u iterations took %.2f s\n", burnin, (double)etime/1000); } for (samplenum = 0; samplenum < sample_size; samplenum++) { if (useIFDsampler) { acceptance_rate = ifdSampler(g, n, n_attr, n_dyadic, n_attr_interaction, change_stats_funcs, lambda_values, attr_change_stats_funcs, dyadic_change_stats_funcs, attr_interaction_change_stats_funcs, attr_indices, attr_interaction_pair_indices, theta, addChangeStats, delChangeStats, interval, TRUE, /*actually do moves */ ifd_K, &dzArc, &ifd_aux_param, useConditionalSimulation, forbidReciprocity, citationERGM, allowLoops); } else if (useTNTsampler) { acceptance_rate = tntSampler(g, n, n_attr, n_dyadic, n_attr_interaction, change_stats_funcs, lambda_values, attr_change_stats_funcs, dyadic_change_stats_funcs, attr_interaction_change_stats_funcs, attr_indices, attr_interaction_pair_indices, theta, addChangeStats, delChangeStats, interval, TRUE,/*actually do moves*/ useConditionalSimulation, forbidReciprocity, citationERGM, allowLoops); } else { acceptance_rate = basicSampler(g, n, n_attr, n_dyadic, n_attr_interaction, change_stats_funcs, lambda_values, attr_change_stats_funcs, dyadic_change_stats_funcs, attr_interaction_change_stats_funcs, attr_indices, attr_interaction_pair_indices, theta, addChangeStats, delChangeStats, interval, TRUE,/*actually do moves*/ useConditionalSimulation, forbidReciprocity, citationERGM, allowLoops); } iternum = burnin + interval*(samplenum+1); fprintf(dzA_outfile, "%llu ", iternum); for (l = 0; l < n; l++) { dzA[l] += addChangeStats[l] - delChangeStats[l]; /* dzA accumulates */ fprintf(dzA_outfile, "%g ", dzA[l]); } fprintf(dzA_outfile, "%g\n", acceptance_rate); fflush(dzA_outfile); if (outputSimulatedNetworks) { strncpy(sim_outfilename, sim_net_file_prefix, sizeof(sim_outfilename)-1); sprintf(suffix, "_%llu.net", iternum); strncat(sim_outfilename, suffix, sizeof(sim_outfilename) - 1 - strlen(suffix)); sim_outfile = fopen(sim_outfilename, "w"); write_digraph_arclist_to_file(sim_outfile, g); fclose(sim_outfile); } } fprintf(stdout, "acceptance rate = %g\n", acceptance_rate); free(addChangeStats); free(delChangeStats); return 0; } /* * Do simulation process using basic or IFD or TNT sampler to draw samples * from ERGM digraph distribution. * * Parameters: * config - (in/out)configuration settings structure - this is modified * by calling build_attr_indices_from_names() etc. * * Return value: * 0 if OK else -ve value for error. */ int do_simulation(sim_config_t * config) { struct timeval start_timeval, end_timeval, elapsed_timeval; int etime; digraph_t *g; uint_t n_struct, n_attr, n_dyadic, n_attr_interaction, num_param; double *theta; uint_t i, theta_i, j, k, m; FILE *dzA_outfile; #define HEADER_MAX 65536 char fileheader[HEADER_MAX]; bool foundArc = FALSE; uint_t arc_param_index = 0; double *dzA = NULL; FILE *arclist_file; uint_t num_nodes = 0; double *changeStats = NULL; uint_t obs_maxtermsender_arcs; if (!config->stats_filename) { fprintf(stderr, "ERROR: statistics output filename statsFile not set\n"); return -1; } g = allocate_digraph(config->numNodes); if (load_attributes(g, config->binattr_filename, config->catattr_filename, config->contattr_filename, config->setattr_filename)) { fprintf(stderr, "ERROR: loading node attributes failed\n"); return -1; } if (config->zone_filename) { if (add_snowball_zones_to_digraph(g, config->zone_filename)) { fprintf(stderr, "ERROR: reading snowball sampling zones from %s failed\n", config->zone_filename); return -1; } #ifdef DEBUG_SNOWBALL dump_zone_info(g); #endif /* DEBUG_SNOWBALL */ } if (config->term_filename) { if (add_cergm_terms_to_digraph(g, config->term_filename)) { fprintf(stderr, "ERROR: reading cERGM terms from %s failed\n", config->term_filename); return -1; } #ifdef DEBUG_CERGM dump_term_info(g); #endif /* DEBUG_CERGM */ } /* now that we have attributes loaded in g, build the attr_indices array in the config struct */ if (build_attr_indices_from_names(&config->param_config, g) != 0) { fprintf(stderr, "ERROR in attribute parameters\n"); return -1; } /* and similary for dyadic covariates */ if (build_dyadic_indices_from_names(&config->param_config, g, TRUE) != 0) { fprintf(stderr, "ERROR in dyadic covariate parameters\n"); return -1; } /* and attribute interaction parameters */ if (build_attr_interaction_pair_indices_from_names(&config->param_config, g) != 0) { fprintf(stderr, "ERROR in attribute interaction parameters\n"); return -1; } /* note num_param is computed here as build_dyadic_indices_from_names() can decrease config->num_dyadic_change_stats_funcs from its initial value */ n_struct = config->param_config.num_change_stats_funcs; n_attr = config->param_config.num_attr_change_stats_funcs; n_dyadic = config->param_config.num_dyadic_change_stats_funcs; n_attr_interaction = config->param_config.num_attr_interaction_change_stats_funcs; num_param = n_struct + n_attr + n_dyadic + n_attr_interaction; /* Ensure that if conditional simulation is to be used, the snowball sampling zone structure was specified */ if (config->useConditionalSimulation) { if (!config->zone_filename) { fprintf(stderr, "ERROR: conditional simulation requested but no zones specified\n"); return -1; } if (g->max_zone < 1) { fprintf(stderr, "ERROR: conditional simulation requested but only one zone\n"); return -1; } } else { if (config->zone_filename) fprintf(stderr, "WARNING: snowball sampling zones are specified" " but conditional simulation is not being used\n"); } /* Ensure that if citation ERGM cERGM is to be used, the time period (term) values were specified, and also a digraph to read for the initial network (from which arcs sent from nodes not in the last term (time period) are fixed */ if (config->citationERGM) { if (config->useConditionalSimulation) { fprintf(stderr, "ERROR: cannot use both snowball sample conditional" " simulation and citation ERGM\n"); return -1; } if (!config->term_filename) { fprintf(stderr, "ERROR: citation ERGM simulation requested but no term file\n"); return -1; } if (g->max_term < 1) { fprintf(stderr, "ERROR: citation ERGM simulation requested but only one time period\n"); return -1; } } if (config->allowLoops) { if (config->useConditionalSimulation) { fprintf(stderr, "ERROR: cannot use allowLoops in conditional simulation\n"); return -1; } if (config->citationERGM) { fprintf(stderr, "ERROR: cannot use allowLoops with citation ERGM\n"); } } /* *set parameter values from the configuration settings and write * parameters and their values to stdout */ theta = (double *)safe_calloc(num_param, sizeof(double)); theta_i = 0; printf("\n"); for (i = 0; i < config->param_config.num_change_stats_funcs; i++, theta_i++){ theta[theta_i] = config->param_config.param_values[i]; if (config->param_config.param_lambdas[i] > 0.0) { printf("%s(%g) = %g\n", config->param_config.param_names[i], config->param_config.param_lambdas[i], theta[theta_i]); } else { printf("%s = %g\n", config->param_config.param_names[i], theta[theta_i]); } } for (i = 0; i < config->param_config.num_attr_change_stats_funcs; i++, theta_i++) { theta[theta_i] = config->param_config.attr_param_values[i]; printf("%s_%s = %g\n", config->param_config.attr_param_names[i], config->param_config.attr_names[i], theta[theta_i]); } for (i = 0; i < config->param_config.num_dyadic_change_stats_funcs; i++, theta_i++) { theta[theta_i] = config->param_config.dyadic_param_values[i]; printf("%s = %g\n", config->param_config.dyadic_param_names[i], theta[theta_i]); } for (i = 0; i < config->param_config.num_attr_interaction_change_stats_funcs; i++, theta_i++) { fprintf(stderr, "TODO: initial values not implemented for interaction effects yet\n");assert(FALSE); /*TODO: theta_theta[i] = config->param_config.attr_interaction_param_values[i]; */ printf("%s_%s_%s = %g\n", config->param_config.attr_interaction_param_names[i], config->param_config.attr_interaction_pair_names[i].first, config->param_config.attr_interaction_pair_names[i].second, theta[theta_i]); } printf("\n"); /* Only one sampler can be used (only binary attributes in config, did not include multiple options (maybe should) */ if (config->useIFDsampler && config->useTNTsampler) { fprintf(stderr, "ERROR: Only one of the useIFDsampler and" " useTNTsampler options may be used\n"); return -1; } /* Ensure that for the IFD sampler the Arc parameter included, and get its index as it is needed to compute the initial value of the IFD sampler auxilliary parameter, and also instead the numArcs parameter is included (fixed density) */ if (config->useIFDsampler) { for (i = 0; i < config->param_config.num_change_stats_funcs; i++) { if (strcasecmp(config->param_config.param_names[i], ARC_PARAM_STR) == 0) { arc_param_index = i; foundArc = TRUE; } } if (!foundArc) { fprintf(stderr, "ERROR: must include %s parameter when using IFD sampler.\n", ARC_PARAM_STR); return -1; } /* numArcs not used with citationERGM though */ if (config->numArcs == 0 && !config->citationERGM) { fprintf(stderr, "ERROR: must specify nonzero numArcs when " "using IFD sampler\n"); return -1; } } else { if (config->numArcs != 0) { fprintf(stderr, "ERROR: numArcs only used for IFD sampler\n"); return -1; } } /* Give warnings if parameters set that are not used in selected algorithm variation */ if (!config->useIFDsampler && !DOUBLE_APPROX_EQ(config->ifd_K, DEFAULT_IFD_K)) { fprintf(stderr, "WARNING: ifd_K is set to %g not default value" " but IFD sampler not used\n", config->ifd_K); } /* allocate change statistics array */ dzA = (double *)safe_calloc(num_param, sizeof(double)); /* set values of graph stats for empty graph; most (but not all) are zero */ empty_graph_stats(g, num_param, n_attr, n_dyadic, n_attr_interaction, config->param_config.change_stats_funcs, config->param_config.param_lambdas, config->param_config.attr_change_stats_funcs, config->param_config.dyadic_change_stats_funcs, config->param_config.attr_interaction_change_stats_funcs, config->param_config.attr_indices, config->param_config.attr_interaction_pair_indices, dzA); if (config->citationERGM) { /* For citation ERGM, initialize the graph from the observed graph specified in the Pajek format arclist file. All arcs sent from nodes in time periods other than the last will be fixed; arcs from the last time period will be deleted in the initialization here, and can be added and deleted in the simulation */ if (!config->arclist_filename) { fprintf(stderr, "ERROR: citation ERGM simulation requested but no arclistFile specified.\n"); return -1; } if (!(arclist_file = fopen(config->arclist_filename, "r"))) { fprintf(stderr, "error opening file %s (%s)\n", config->arclist_filename, strerror(errno)); return -1; } if (config->numArcs != 0) { fprintf(stderr, "WARNING: numArcs is set to %u but using citationERGM" " so numArcs parameter is ignored\n", config->numArcs); } num_nodes = get_num_vertices_from_arclist_file(arclist_file);/* closes file */ if (num_nodes != config->numNodes) { fprintf(stderr, "ERROR: number of nodes specified in config file (%u) does not match number in Pajek file %s (%u)\n", config->numNodes, config->arclist_filename, num_nodes); return 1; } if (!(arclist_file = fopen(config->arclist_filename, "r"))) { fprintf(stderr, "error opening file %s (%s)\n", config->arclist_filename, strerror(errno)); return -1; } g = load_digraph_from_arclist_file(arclist_file, g, TRUE /*computeStats*/, num_param, n_attr, n_dyadic, n_attr_interaction, config->param_config.change_stats_funcs, config->param_config.param_lambdas, config->param_config.attr_change_stats_funcs, config->param_config.dyadic_change_stats_funcs, config->param_config.attr_interaction_change_stats_funcs, config->param_config.attr_indices, config->param_config.attr_interaction_pair_indices, dzA, theta); if (add_cergm_terms_to_digraph(g, config->term_filename)) { fprintf(stderr, "ERROR: reading cERGM terms from %s failed\n", config->term_filename); return -1; } obs_maxtermsender_arcs = g->num_maxtermsender_arcs; SIMULATE_DEBUG_PRINT(("obs_maxtermsender_arcs = %u\n", obs_maxtermsender_arcs)); printf("Number of arcs sent from last term in observed network: %u\n", obs_maxtermsender_arcs); /* Now delete all arcs sent from nodes in the last time period (term) so that we start the simulation with an empty set of these non-fixed potential arcs (all the other arcs and non-arcs, from nodes in previous terms, are fixed). */ changeStats = (double *)safe_calloc(num_param, sizeof(double)); for (k = 0; k < obs_maxtermsender_arcs; k++) { i = g->all_maxtermsender_arcs[k].i; j = g->all_maxtermsender_arcs[k].j; assert(g->term[i] == g->max_term); assert(isArc(g, i, j)); /* Update the statistics for removing this arc */ /* Note must do the computation after actually removing the arc */ removeArc_all_maxtermsender_arcs(g, i, j, k); (void)calcChangeStats(g, i, j, num_param, n_attr, n_dyadic, n_attr_interaction, config->param_config.change_stats_funcs, config->param_config.param_lambdas, config->param_config.attr_change_stats_funcs, config->param_config.dyadic_change_stats_funcs, config->param_config.attr_interaction_change_stats_funcs, config->param_config.attr_indices, config->param_config.attr_interaction_pair_indices, theta, TRUE, /*isDelete*/ changeStats); for (m = 0; m < num_param; m++) { dzA[m] -= changeStats[m]; /* isDelete=TRUE above only changes return value total (not used here)not changestats, so need to subtract change stats here for delete */ } } SIMULATE_DEBUG_PRINT(("After removing maxtermsender arcs: g->num_maxtermsender_arcs = %u, g->num_arcs = %u\n", g->num_maxtermsender_arcs, g->num_arcs)); assert(g->num_maxtermsender_arcs == 0); free(changeStats); if (config->useIFDsampler) { /* Initialize the graph to random graph with specified number of arcs, conditional on the citation ERGM structure, for fixed density simulation (IFD sampler), and also for TNT sampler since it does 50% add/delete moves. This means we add the same number of arcs we just deleted, sent from max temr nodes, but now at random, no thte observed ones.*/ make_erdos_renyi_digraph(g, obs_maxtermsender_arcs, num_param, n_attr, n_dyadic, n_attr_interaction, config->param_config.change_stats_funcs, config->param_config.param_lambdas, config->param_config.attr_change_stats_funcs, config->param_config.dyadic_change_stats_funcs, config->param_config.attr_interaction_change_stats_funcs, config->param_config.attr_indices, config->param_config.attr_interaction_pair_indices, config->useConditionalSimulation, config->forbidReciprocity, dzA, theta, config->citationERGM, config->allowLoops); SIMULATE_DEBUG_PRINT(("After adding %u random maxtermsender arcs: g->num_maxtermsender_arcs = %u, g->num_arcs = %u\n", obs_maxtermsender_arcs, g->num_maxtermsender_arcs, g->num_arcs)); assert(g->num_maxtermsender_arcs == obs_maxtermsender_arcs); } } else { if (config->useIFDsampler) { /* Initialize the graph to random (E-R aka Bernoulli) graph with specified number of arcs for fixed density simulation (IFD sampler) */ make_erdos_renyi_digraph(g, config->numArcs, num_param, n_attr, n_dyadic, n_attr_interaction, config->param_config.change_stats_funcs, config->param_config.param_lambdas, config->param_config.attr_change_stats_funcs, config->param_config.dyadic_change_stats_funcs, config->param_config.attr_interaction_change_stats_funcs, config->param_config.attr_indices, config->param_config.attr_interaction_pair_indices, config->useConditionalSimulation, config->forbidReciprocity, dzA, theta, config->citationERGM, config->allowLoops); } else if (config->numArcs != 0) { fprintf(stderr, "WARNING: numArcs is set to %u but not using IFD sampler" " so numArcs parameter is ignored\n", config->numArcs); } } /* Open the output file for writing */ if (!(dzA_outfile = fopen(config->stats_filename, "w"))) { fprintf(stderr, "ERROR: could not open file %s for writing " "(%s)\n", config->stats_filename, strerror(errno)); return -1; } /* write headers for statistics output file */ sprintf(fileheader, "t"); /* Print the lambda (decay) [hyper-]parameter value for parameters which use it (i.e. for the "alternating" statistics); it is 0 for those for which it is not applicable. Format is to put it in parens after the name e.g. AltTwoPathsTD(2.5) */ for (i = 0; i < config->param_config.num_change_stats_funcs; i++) { if (config->param_config.param_lambdas[i] > 0.0) { snprintf(fileheader+strlen(fileheader), HEADER_MAX," %s(%g)", config->param_config.param_names[i], config->param_config.param_lambdas[i]); } else { snprintf(fileheader+strlen(fileheader), HEADER_MAX," %s", config->param_config.param_names[i]); } } for (i = 0; i < config->param_config.num_attr_change_stats_funcs; i++) snprintf(fileheader+strlen(fileheader), HEADER_MAX, " %s_%s", config->param_config.attr_param_names[i], config->param_config.attr_names[i]); for (i = 0; i < config->param_config.num_dyadic_change_stats_funcs; i++) snprintf(fileheader+strlen(fileheader), HEADER_MAX, " %s", config->param_config.dyadic_param_names[i]); for (i = 0; i < config->param_config.num_attr_interaction_change_stats_funcs; i++) snprintf(fileheader+strlen(fileheader), HEADER_MAX, " %s_%s_%s", config->param_config.attr_interaction_param_names[i], config->param_config.attr_interaction_pair_names[i].first, config->param_config.attr_interaction_pair_names[i].second); fprintf(dzA_outfile, "%s AcceptanceRate\n", fileheader); print_data_summary(g, config->allowLoops); print_zone_summary(g); print_term_summary(g); #ifdef DEBUG_SIMULATE printf("initial graph stats: "); for(i = 0; i < num_param; i++) { printf("%g ", dzA[i]); } printf("\n"); #endif printf("\nrunning simulation...\n"); gettimeofday(&start_timeval, NULL); simulate_ergm(g, num_param, n_attr, n_dyadic, n_attr_interaction, config->param_config.change_stats_funcs, config->param_config.param_lambdas, config->param_config.attr_change_stats_funcs, config->param_config.dyadic_change_stats_funcs, config->param_config.attr_interaction_change_stats_funcs, config->param_config.attr_indices, config->param_config.attr_interaction_pair_indices, config->sampleSize, config->interval, config->burnin, theta, config->useIFDsampler, config->ifd_K, config->useConditionalSimulation, config->forbidReciprocity, config->sim_net_file_prefix, dzA_outfile, config->outputSimulatedNetworks, arc_param_index, dzA, config->useTNTsampler, config->citationERGM, config->allowLoops); gettimeofday(&end_timeval, NULL); timeval_subtract(&elapsed_timeval, &end_timeval, &start_timeval); etime = 1000 * elapsed_timeval.tv_sec + elapsed_timeval.tv_usec/1000; printf("simulation took %.2f s\n", (double)etime/1000); fclose(dzA_outfile); print_data_summary(g, config->allowLoops); free(theta); free(dzA); free_digraph(g); return 0; }
45.618491
190
0.564284
[ "object", "vector" ]
b48aef4188f6b23ba803feedc2b93339cc4eed02
3,172
h
C
datasets/linux-4.11-rc3/arch/s390/include/asm/pkey.h
yijunyu/demo-fast
11c0c84081a3181494b9c469bda42a313c457ad2
[ "BSD-2-Clause" ]
1
2019-05-03T19:27:45.000Z
2019-05-03T19:27:45.000Z
datasets/linux-4.11-rc3/arch/s390/include/asm/pkey.h
yijunyu/demo-vscode-fast
11c0c84081a3181494b9c469bda42a313c457ad2
[ "BSD-2-Clause" ]
null
null
null
datasets/linux-4.11-rc3/arch/s390/include/asm/pkey.h
yijunyu/demo-vscode-fast
11c0c84081a3181494b9c469bda42a313c457ad2
[ "BSD-2-Clause" ]
null
null
null
/* * Kernelspace interface to the pkey device driver * * Copyright IBM Corp. 2016 * * Author: Harald Freudenberger <freude@de.ibm.com> * */ #ifndef _KAPI_PKEY_H #define _KAPI_PKEY_H #include <linux/ioctl.h> #include <linux/types.h> #include <uapi/asm/pkey.h> /* * Generate (AES) random secure key. * @param cardnr may be -1 (use default card) * @param domain may be -1 (use default domain) * @param keytype one of the PKEY_KEYTYPE values * @param seckey pointer to buffer receiving the secure key * @return 0 on success, negative errno value on failure */ int pkey_genseckey(__u16 cardnr, __u16 domain, __u32 keytype, struct pkey_seckey *seckey); /* * Generate (AES) secure key with given key value. * @param cardnr may be -1 (use default card) * @param domain may be -1 (use default domain) * @param keytype one of the PKEY_KEYTYPE values * @param clrkey pointer to buffer with clear key data * @param seckey pointer to buffer receiving the secure key * @return 0 on success, negative errno value on failure */ int pkey_clr2seckey(__u16 cardnr, __u16 domain, __u32 keytype, const struct pkey_clrkey *clrkey, struct pkey_seckey *seckey); /* * Derive (AES) proteced key from the (AES) secure key blob. * @param cardnr may be -1 (use default card) * @param domain may be -1 (use default domain) * @param seckey pointer to buffer with the input secure key * @param protkey pointer to buffer receiving the protected key and * additional info (type, length) * @return 0 on success, negative errno value on failure */ int pkey_sec2protkey(__u16 cardnr, __u16 domain, const struct pkey_seckey *seckey, struct pkey_protkey *protkey); /* * Derive (AES) protected key from a given clear key value. * @param keytype one of the PKEY_KEYTYPE values * @param clrkey pointer to buffer with clear key data * @param protkey pointer to buffer receiving the protected key and * additional info (type, length) * @return 0 on success, negative errno value on failure */ int pkey_clr2protkey(__u32 keytype, const struct pkey_clrkey *clrkey, struct pkey_protkey *protkey); /* * Search for a matching crypto card based on the Master Key * Verification Pattern provided inside a secure key. * @param seckey pointer to buffer with the input secure key * @param cardnr pointer to cardnr, receives the card number on success * @param domain pointer to domain, receives the domain number on success * @param verify if set, always verify by fetching verification pattern * from card * @return 0 on success, negative errno value on failure. If no card could be * found, -ENODEV is returned. */ int pkey_findcard(const struct pkey_seckey *seckey, __u16 *cardnr, __u16 *domain, int verify); /* * Find card and transform secure key to protected key. * @param seckey pointer to buffer with the input secure key * @param protkey pointer to buffer receiving the protected key and * additional info (type, length) * @return 0 on success, negative errno value on failure */ int pkey_skey2pkey(const struct pkey_seckey *seckey, struct pkey_protkey *protkey); #endif /* _KAPI_PKEY_H */
34.857143
77
0.732346
[ "transform" ]
b49dd6c4ac50a0436ee9a50f09e4919ee1118b20
6,410
h
C
platform/windows/Corona.Native.Library.Win32/Interop/Storage/StoredPreferencesChain.h
agramonte/corona
3a6892f14eea92fdab5fa6d41920aa1e97bc22b1
[ "MIT" ]
1,968
2018-12-30T21:14:22.000Z
2022-03-31T23:48:16.000Z
platform/windows/Corona.Native.Library.Win32/Interop/Storage/StoredPreferencesChain.h
agramonte/corona
3a6892f14eea92fdab5fa6d41920aa1e97bc22b1
[ "MIT" ]
303
2019-01-02T19:36:43.000Z
2022-03-31T23:52:45.000Z
platform/windows/Corona.Native.Library.Win32/Interop/Storage/StoredPreferencesChain.h
agramonte/corona
3a6892f14eea92fdab5fa6d41920aa1e97bc22b1
[ "MIT" ]
254
2019-01-02T19:05:52.000Z
2022-03-30T06:32:28.000Z
////////////////////////////////////////////////////////////////////////////// // // This file is part of the Corona game engine. // For overview and more information on licensing please refer to README.md // Home page: https://github.com/coronalabs/corona // Contact: support@coronalabs.com // ////////////////////////////////////////////////////////////////////////////// #pragma once #include "Core\Rtt_Macros.h" #include "MStoredPreferences.h" #include <functional> #include <list> #include <memory> namespace Interop { namespace Storage { /// <summary> /// <para>Stores an ordered collection of MStoredPreferences derived objects.</para> /// <para> /// When requesting a StoredPreferencesChain to read, write, and delete preferences, the chain will attempt /// to perform that operation with all of the MStoredPreferences objects in the collection in order, stopping /// at the first MStoredPreferences to succeed at that operation. /// </para> /// <para> /// The intent of this class is to simulate the Apple NSUserDefaults behavior where application preferences are /// access first, and if not found, it falls-back to accessing the global machine preferences. On Windows, /// this class is expected to be used to access the current user's registry entries first (HKCU) before falling /// back to the machine's (HKLM) registry settings. /// </para> /// </summary> class StoredPreferencesChain : public MStoredPreferences { Rtt_CLASS_NO_COPIES(StoredPreferencesChain) public: /// <summary> /// Collection of stored preference objects to be passed into the StoredPreferencesChain class' constructor. /// </summary> typedef std::list<std::shared_ptr<MStoredPreferences>> ListType; /// <summary> /// Creates a new stored preferences chain object which will use the given collection of /// stored preference accessing objects. /// </summary> /// <param name="collection"> /// <para>Collection of stored preference accessing objects that the StoredPreferencesChain will use.</para> /// <para>Order matters. The first object in this collection will always be invoked first.</para> /// </param> StoredPreferencesChain(const StoredPreferencesChain::ListType& collection); /// <summary>Destroys this object.</summary> virtual ~StoredPreferencesChain(); /// <summary>Fetches a preference's value by its unique key name.</summary> /// <param name="keyName">The unique name of the preference in UTF-8 form.</param> /// <returns> /// <para> /// Returns a success result if the preference was found. /// The result object's GetValue() method will return the fetched preference's value. /// </para> /// <para> /// Returns a failure result if the preference key was not found or if there was a problem accessing storage. /// The result object's GetUtf8Message() method will return a string detailing why it failed. /// </para> /// </returns> virtual Rtt::Preference::ReadValueResult Fetch(const char* keyName) override; /// <summary>Writes the given preference key-value pair to storage.</summary> /// <param name="preference">The preference key name and value.</param> /// <returns> /// <para>Returns a success result if the given preference was written to storage.</para> /// <para> /// Returns a failure result if failed to write the given preference to storage. /// The result object's GetUtf8Message() method will return a string detailing why it failed. /// </para> /// </returns> virtual Rtt::OperationResult UpdateWith(const Rtt::Preference& preference) override; /// <summary>Writes the given collection of preference key-value pairs to storage.</summary> /// <param name="preferences">Collection of preferences to write to storage. Can be empty.</param> /// <returns> /// <para>Returns a success result if all of the given preferences were written to storage.</para> /// <para> /// Returns a failure result if at least 1 preference has failed to write to storage. /// The result object's GetUtf8Message() method will return a string detailing why it failed. /// </para> /// </returns> virtual Rtt::OperationResult UpdateWith(const Rtt::PreferenceCollection& preferences) override; /// <summary>Delete a preference from storage by its unique string key.</summary> /// <param name="keyName">The unique name of the preference to delete in UTF-8 form.</param> /// <returns> /// <para>Returns a success result if the preference was deleted from storage.</para> /// <para> /// Returns a failure result if failed to access storage or unable to delete the preference. /// The result object's GetUtf8Message() method will return a string detailing why it failed. /// </para> /// </returns> virtual Rtt::OperationResult Delete(const char* keyName) override; /// <summary>Delete multiple preferences from storage by their unique string keys.</summary> /// <param name="keyNameArray">Array of unique preference names (in UTF-8 form) to delete from storage.</param> /// <param name="count">The number of keys/elements in the "keyNameArray" argument.</param> /// <returns> /// <para>Returns a success result if all of the given preferences have been deleted from storage.</para> /// <para> /// Returns a failure result if failed to access storage, if unable to delete at least 1 preference, /// or if "keyNameArray" is null. /// The result object's GetUtf8Message() method will return a string detailing why it failed. /// </para> /// </returns> virtual Rtt::OperationResult Delete(const char* keyNameArray[], int count) override; private: template<class TReturnValue> /// <summary> /// Invokes the given callback for each stored preference object in the collection in order. /// Will return immediately upon the first success result returned by the given callback. /// </summary> /// <param name="lambda"> /// Callback to be invoked, passing the next stored preference object in the chain. /// </param> /// <returns>Returns a success or failure result from a stored preference object in the chain.</returns> TReturnValue InvokeChain(const std::function<TReturnValue(MStoredPreferences&)>& lambda); /// <summary>Ordered collection of objects used to access stored preferences.</summary> StoredPreferencesChain::ListType fCollection; }; } } // namespace Interop::Storage
47.132353
113
0.702184
[ "object" ]
b49e9716e2007338b23581c437e6107acf101387
560
c
C
Reference/qpc/doxygen/snippets/qep_qhsm_use.c
Harveyhubbell/Paid-RTOS
e56a1346cce026428c2bfef05b6a4e6bb2ee7f4e
[ "MIT" ]
null
null
null
Reference/qpc/doxygen/snippets/qep_qhsm_use.c
Harveyhubbell/Paid-RTOS
e56a1346cce026428c2bfef05b6a4e6bb2ee7f4e
[ "MIT" ]
null
null
null
Reference/qpc/doxygen/snippets/qep_qhsm_use.c
Harveyhubbell/Paid-RTOS
e56a1346cce026428c2bfef05b6a4e6bb2ee7f4e
[ "MIT" ]
null
null
null
#include "qpc.h" /* QP/C public interface */ #include "calc.h" /* Calc derived from QHsm */ Q_DEFINE_THIS_FILE static Calc l_calc; /* an instance of Calc SM */ int main() { Calc_ctor(&l_calc); /* Calc "constructor" invokes QHsm_ctor() */ QMSM_INIT(&l_calc.super, (QEvt *)0); /* trigger initial transition */ for (;;) { /* event loop */ QEvt e; . . . /* wait for the next event and assign it to the event object e */ . . . QMSM_DISPATCH(&l_calc.super, &e); /* dispatch e */ } return 0; }
25.454545
73
0.569643
[ "object" ]
b4a0345ec4210350b77c6698f7dc0c0f891a3352
690
c
C
d3.c
statonb/shelly1
978f0864b2e64e156e1f01af217875b506eaac5f
[ "MIT" ]
1
2017-02-23T03:01:10.000Z
2017-02-23T03:01:10.000Z
d3.c
statonb/shelly1
978f0864b2e64e156e1f01af217875b506eaac5f
[ "MIT" ]
null
null
null
d3.c
statonb/shelly1
978f0864b2e64e156e1f01af217875b506eaac5f
[ "MIT" ]
null
null
null
#include <stdio.h> #include <stdint.h> #include <string.h> #include <stdlib.h> #include <math.h> #include "const.h" #include "haver_c.h" int main(int argc, char *argv[]) { double lat1 = 40.705498; double lon1 = -74.013357; double d = 500.0; double hdg; double lat2; double lon2; int i; if (argc > 1) { lat1 = strtod(argv[1], NULL); lon1 = strtod(argv[2], NULL); d = strtod(argv[3], NULL); } printf("Center: %lf,%lf\nRadius: %lf\n", lat1, lon1, d); printf("Point,Lat,Lon\n"); for(i=0; i<360; i++) { whereIsThere(lat1, lon1, d, (double)i, &lat2, &lon2); printf("%3d,%lf,%lf\n", i, lat2, lon2); } return 0; }
18.157895
58
0.55942
[ "3d" ]
b4a910c6f410f8259f99cc291b0fe99fbcfbb99a
4,228
h
C
cmds/statsd/src/metrics/CountMetricProducer.h
rio-31/android_frameworks_base-1
091a068a3288d27d77636708679dde58b7b7fd25
[ "Apache-2.0" ]
164
2015-01-05T16:49:11.000Z
2022-03-29T20:40:27.000Z
cmds/statsd/src/metrics/CountMetricProducer.h
rio-31/android_frameworks_base-1
091a068a3288d27d77636708679dde58b7b7fd25
[ "Apache-2.0" ]
127
2015-01-12T12:02:32.000Z
2021-11-28T08:46:25.000Z
cmds/statsd/src/metrics/CountMetricProducer.h
rio-31/android_frameworks_base-1
091a068a3288d27d77636708679dde58b7b7fd25
[ "Apache-2.0" ]
1,141
2015-01-01T22:54:40.000Z
2022-02-09T22:08:26.000Z
/* * Copyright (C) 2017 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #ifndef COUNT_METRIC_PRODUCER_H #define COUNT_METRIC_PRODUCER_H #include <unordered_map> #include <android/util/ProtoOutputStream.h> #include <gtest/gtest_prod.h> #include "../anomaly/AnomalyTracker.h" #include "../condition/ConditionTracker.h" #include "../matchers/matcher_util.h" #include "MetricProducer.h" #include "frameworks/base/cmds/statsd/src/statsd_config.pb.h" #include "stats_util.h" namespace android { namespace os { namespace statsd { struct CountBucket { int64_t mBucketStartNs; int64_t mBucketEndNs; int64_t mCount; }; class CountMetricProducer : public MetricProducer { public: CountMetricProducer(const ConfigKey& key, const CountMetric& countMetric, const int conditionIndex, const sp<ConditionWizard>& wizard, const int64_t timeBaseNs, const int64_t startTimeNs); virtual ~CountMetricProducer(); protected: void onMatchedLogEventInternalLocked( const size_t matcherIndex, const MetricDimensionKey& eventKey, const ConditionKey& conditionKey, bool condition, const LogEvent& event) override; private: void onDumpReportLocked(const int64_t dumpTimeNs, const bool include_current_partial_bucket, const bool erase_data, const DumpLatency dumpLatency, std::set<string> *str_set, android::util::ProtoOutputStream* protoOutput) override; void clearPastBucketsLocked(const int64_t dumpTimeNs) override; // Internal interface to handle condition change. void onConditionChangedLocked(const bool conditionMet, const int64_t eventTime) override; // Internal interface to handle sliced condition change. void onSlicedConditionMayChangeLocked(bool overallCondition, const int64_t eventTime) override; // Internal function to calculate the current used bytes. size_t byteSizeLocked() const override; void dumpStatesLocked(FILE* out, bool verbose) const override; void dropDataLocked(const int64_t dropTimeNs) override; // Util function to flush the old packet. void flushIfNeededLocked(const int64_t& newEventTime) override; void flushCurrentBucketLocked(const int64_t& eventTimeNs, const int64_t& nextBucketStartTimeNs) override; std::unordered_map<MetricDimensionKey, std::vector<CountBucket>> mPastBuckets; // The current bucket (may be a partial bucket). std::shared_ptr<DimToValMap> mCurrentSlicedCounter = std::make_shared<DimToValMap>(); // The sum of previous partial buckets in the current full bucket (excluding the current // partial bucket). This is only updated while flushing the current bucket. std::shared_ptr<DimToValMap> mCurrentFullCounters = std::make_shared<DimToValMap>(); static const size_t kBucketSize = sizeof(CountBucket{}); bool hitGuardRailLocked(const MetricDimensionKey& newKey); FRIEND_TEST(CountMetricProducerTest, TestNonDimensionalEvents); FRIEND_TEST(CountMetricProducerTest, TestEventsWithNonSlicedCondition); FRIEND_TEST(CountMetricProducerTest, TestEventsWithSlicedCondition); FRIEND_TEST(CountMetricProducerTest, TestAnomalyDetectionUnSliced); FRIEND_TEST(CountMetricProducerTest, TestEventWithAppUpgrade); FRIEND_TEST(CountMetricProducerTest, TestEventWithAppUpgradeInNextBucket); FRIEND_TEST(CountMetricProducerTest, TestFirstBucket); }; } // namespace statsd } // namespace os } // namespace android #endif // COUNT_METRIC_PRODUCER_H
38.09009
99
0.735336
[ "vector" ]
b4b5431d2bc0899648d75e057c70db4307c28757
1,039
h
C
src/data/importers/qt/ReBricksImporter.h
danielbui78/reality
7ecd01b71f28e581becfe5093fab3ddcd6d9b2c1
[ "BSD-3-Clause" ]
2
2021-12-25T17:24:03.000Z
2022-03-14T05:07:51.000Z
src/data/importers/qt/ReBricksImporter.h
danielbui78/reality
7ecd01b71f28e581becfe5093fab3ddcd6d9b2c1
[ "BSD-3-Clause" ]
null
null
null
src/data/importers/qt/ReBricksImporter.h
danielbui78/reality
7ecd01b71f28e581becfe5093fab3ddcd6d9b2c1
[ "BSD-3-Clause" ]
2
2021-12-10T05:33:04.000Z
2021-12-10T16:38:54.000Z
/* Reality plug-in Copyright (c) Pret-a-3D/Paolo Ciccone 2012. All rights reserved. */ #ifndef QT_BRICK_IMPORTER_H #define QT_BRICK_IMPORTER_H #include "textures/ReBricks.h" #include "ReQtTextureImporter.h" namespace Reality { /** * Imports a Brick texture from data passed via a QVariantMap */ class RE_LIB_ACCESS ReQtBricksImporter : public ReQtTextureImporter { public: void restoreTexture( ReTexturePtr baseTex, const QVariantMap& data ) { BricksPtr tex = baseTex.staticCast<Bricks>(); restoreBasicProperties(tex, data); tex->setBrickType(static_cast<Bricks::BrickType>(data.value("brickType").toInt())); tex->setWidth(data.value("width").toFloat()); tex->setHeight(data.value("height").toFloat()); tex->setDepth(data.value("depth").toFloat()); tex->setBevel(data.value("bevel").toFloat()); tex->setOffset(data.value("offset").toFloat()); tex->setMortarSize(data.value("mortarSize").toFloat()); restoreChannels(tex,data); restore3DMapping(tex,data); }; }; } #endif
26.641026
87
0.709336
[ "3d" ]
b4b842a1bba34862eeda9286d22b1866d1b5923a
33,759
w
C
dynamics/src/main/abl/ry/obj/rycustpr2v.w
gquerret/OpenEdge_Retired_Products
1358f3d450b65e6b4cfa2236555c54df942a613a
[ "Apache-2.0" ]
1
2021-12-13T12:43:13.000Z
2021-12-13T12:43:13.000Z
dynamics/src/main/abl/ry/obj/rycustpr2v.w
gquerret/OpenEdge_Retired_Products
1358f3d450b65e6b4cfa2236555c54df942a613a
[ "Apache-2.0" ]
null
null
null
dynamics/src/main/abl/ry/obj/rycustpr2v.w
gquerret/OpenEdge_Retired_Products
1358f3d450b65e6b4cfa2236555c54df942a613a
[ "Apache-2.0" ]
2
2021-05-12T06:38:07.000Z
2022-01-20T10:04:46.000Z
&ANALYZE-SUSPEND _VERSION-NUMBER AB_v9r12 GUI ADM2 &ANALYZE-RESUME /* Connected Databases icfdb PROGRESS */ &Scoped-define WINDOW-NAME CURRENT-WINDOW &ANALYZE-SUSPEND _UIB-CODE-BLOCK _XFTR "Update-Object-Version" vTableWin _INLINE /* Actions: ? ? ? ? af/sup/afverxftrp.p */ /* This has to go above the definitions sections, as that is what it modifies. If its not, then the definitions section will have been saved before the XFTR code kicks in and changes it */ /* _UIB-CODE-BLOCK-END */ &ANALYZE-RESUME &ANALYZE-SUSPEND _UIB-CODE-BLOCK _XFTR "Definition Comments Wizard" vTableWin _INLINE /* Actions: ? af/cod/aftemwizcw.w ? ? ? */ /* Program Definition Comment Block Wizard Welcome to the Program Definition Comment Block Wizard. Press Next to proceed. af/cod/aftemwizpw.w */ /* _UIB-CODE-BLOCK-END */ &ANALYZE-RESUME /* Temp-Table and Buffer definitions */ DEFINE TEMP-TABLE RowObject {"ry/obj/rycatfullo.i"}. &ANALYZE-SUSPEND _UIB-CODE-BLOCK _CUSTOM _DEFINITIONS vTableWin /*--------------------------------------------------------------------------------- File: rycsutprpv.w Description: This viewer will read all the class definition files from a specified directory and display them in a dynamic browser. It will then allow the user to create these classes and their attributes in the Repository database. Purpose: Parameters: <none> History: -------- (v:010000) Task: 0 UserRef: MIP Date: 11/05/2002 Author: Mark Davies (MIP) Update Notes: Created from Template rysttviewv.w ---------------------------------------------------------------------------------*/ /* This .W file was created with the Progress UIB. */ /*-------------------------------------------------------------------------------*/ /* Create an unnamed pool to store all the widgets created by this procedure. This is a good default which assures that this procedure's triggers and internal procedures will execute in this procedure's storage, and that proper cleanup will occur on deletion of the procedure. */ CREATE WIDGET-POOL. /* *************************** Definitions ************************** */ /* MIP-GET-OBJECT-VERSION pre-processors The following pre-processors are maintained automatically when the object is saved. They pull the object and version from Roundtable if possible so that it can be displayed in the about window of the container */ &scop object-name rycustpr2v.w DEFINE VARIABLE lv_this_object_name AS CHARACTER INITIAL "{&object-name}":U NO-UNDO. &scop object-version 000000 /* Parameters Definitions --- */ /* Local Variable Definitions --- */ /* object identifying preprocessor */ &glob astra2-staticSmartDataViewer yes {src/adm2/globals.i} {ry/inc/rycustprpt.i} DEFINE VARIABLE ghAttrBrowse AS HANDLE NO-UNDO. DEFINE VARIABLE ghAttrQuery AS HANDLE NO-UNDO. DEFINE VARIABLE ghToolbar AS HANDLE NO-UNDO. DEFINE VARIABLE glTrackChange AS LOGICAL NO-UNDO. DEFINE VARIABLE glChangesMade AS LOGICAL NO-UNDO. DEFINE VARIABLE grLastChangedRowid AS ROWID NO-UNDO. /* _UIB-CODE-BLOCK-END */ &ANALYZE-RESUME &ANALYZE-SUSPEND _UIB-PREPROCESSOR-BLOCK /* ******************** Preprocessor Definitions ******************** */ &Scoped-define PROCEDURE-TYPE SmartDataViewer &Scoped-define DB-AWARE no &Scoped-define ADM-CONTAINER FRAME &Scoped-define ADM-SUPPORTED-LINKS Data-Target,Update-Source,TableIO-Target,GroupAssign-Source,GroupAssign-Target /* Include file with RowObject temp-table definition */ &Scoped-define DATA-FIELD-DEFS "ry/obj/rycatfullo.i" /* Name of designated FRAME-NAME and/or first browse and/or first query */ &Scoped-define FRAME-NAME frMain /* Standard List Definitions */ &Scoped-Define ENABLED-OBJECTS fiTitle &Scoped-Define DISPLAYED-OBJECTS fiTitle /* Custom List Definitions */ /* ADM-ASSIGN-FIELDS,List-2,List-3,List-4,List-5,List-6 */ /* _UIB-PREPROCESSOR-BLOCK-END */ &ANALYZE-RESUME /* ************************ Function Prototypes ********************** */ &ANALYZE-SUSPEND _UIB-CODE-BLOCK _FUNCTION-FORWARD setStatusText vTableWin FUNCTION setStatusText RETURNS LOGICAL ( pcStatusText AS CHARACTER ) FORWARD. /* _UIB-CODE-BLOCK-END */ &ANALYZE-RESUME /* *********************** Control Definitions ********************** */ /* Definitions of the field level widgets */ DEFINE VARIABLE coConstantLevel AS CHARACTER FORMAT "X(10)" LABEL "Constant Level" VIEW-AS COMBO-BOX INNER-LINES 5 LIST-ITEM-PAIRS "Instance Level","", "Class Level","Class", "Master Level","Master" DROP-DOWN-LIST SIZE 24 BY 1 TOOLTIP "Lowest level where the value can be stored and changed (also through instances)". DEFINE VARIABLE fiAttrName AS CHARACTER FORMAT "X(70)":U LABEL "Attribute Label" VIEW-AS FILL-IN SIZE 78.4 BY 1 NO-UNDO. DEFINE VARIABLE fiOverrideTypeLabel AS CHARACTER FORMAT "X(35)":U INITIAL "Override Type" VIEW-AS TEXT SIZE 14 BY .62 NO-UNDO. DEFINE VARIABLE cOverride AS CHARACTER VIEW-AS RADIO-SET VERTICAL RADIO-BUTTONS "None", "" SIZE 64.4 BY 3.24 NO-UNDO. DEFINE RECTANGLE RECT-1 EDGE-PIXELS 2 GRAPHIC-EDGE NO-FILL SIZE 68.8 BY 4.05. DEFINE VARIABLE toDerivedValue AS LOGICAL INITIAL no LABEL "Derived Value" VIEW-AS TOGGLE-BOX SIZE 18.4 BY 1 TOOLTIP "Check if the value is derived from other data and/or attributes". DEFINE VARIABLE toDesignOnly AS LOGICAL INITIAL no LABEL "Design Only" VIEW-AS TOGGLE-BOX SIZE 16.4 BY 1. DEFINE VARIABLE toIsPrivate AS LOGICAL INITIAL no LABEL "Private" VIEW-AS TOGGLE-BOX SIZE 13.6 BY 1. DEFINE VARIABLE toLoad AS LOGICAL INITIAL no LABEL "Load into Repository" VIEW-AS TOGGLE-BOX SIZE 23.2 BY .81 TOOLTIP "Check to load this attribute into the Repository" NO-UNDO. DEFINE VARIABLE toRuntimeOnly AS LOGICAL INITIAL no LABEL "Runtime Only" VIEW-AS TOGGLE-BOX SIZE 17.6 BY 1 TOOLTIP "Check if the value is set by runtime logic and not stored in the Repository" NO-UNDO. DEFINE VARIABLE toSystemOwned AS LOGICAL INITIAL no LABEL "System Owned" VIEW-AS TOGGLE-BOX SIZE 19.2 BY 1. DEFINE VARIABLE fiTitle AS CHARACTER FORMAT "X(500)":U VIEW-AS TEXT SIZE 2 BY .71 BGCOLOR 1 FGCOLOR 15 NO-UNDO. /* ************************ Frame Definitions *********************** */ DEFINE FRAME frMain fiTitle AT ROW 1 COL 1 NO-LABEL SPACE(94.00) SKIP(16.05) WITH 1 DOWN NO-BOX KEEP-TAB-ORDER OVERLAY USE-DICT-EXPS SIDE-LABELS NO-UNDERLINE THREE-D NO-AUTO-VALIDATE AT COL 1 ROW 1 SCROLLABLE . DEFINE FRAME frDetail fiAttrName AT ROW 1 COL 15.4 COLON-ALIGNED coConstantLevel AT ROW 2.05 COL 15.4 COLON-ALIGNED HELP "Constant level" toLoad AT ROW 3.24 COL 17.4 HELP "Load attribute into repository" toRuntimeOnly AT ROW 4.24 COL 17.4 HELP "Runtime only" toDerivedValue AT ROW 5.24 COL 17.4 HELP "Derived value" toIsPrivate AT ROW 3.24 COL 42.2 HELP "Is private" toSystemOwned AT ROW 4.24 COL 42.2 HELP "System owned" toDesignOnly AT ROW 5.24 COL 42.2 HELP "Design only" cOverride AT ROW 7 COL 20.6 HELP "Override type" NO-LABEL fiOverrideTypeLabel AT ROW 6.24 COL 17.4 COLON-ALIGNED NO-LABEL RECT-1 AT ROW 6.48 COL 17.4 WITH 1 DOWN NO-BOX KEEP-TAB-ORDER OVERLAY SIDE-LABELS NO-UNDERLINE THREE-D AT COL 1 ROW 7.95 SIZE 96 BY 9.81. /* *********************** Procedure Settings ************************ */ &ANALYZE-SUSPEND _PROCEDURE-SETTINGS /* Settings for THIS-PROCEDURE Type: SmartDataViewer Data Source: "ry/obj/rycatfullo.w" Allow: Basic,DB-Fields,Smart Container Links: Data-Target,Update-Source,TableIO-Target,GroupAssign-Source,GroupAssign-Target Add Fields to: Neither Other Settings: PERSISTENT-ONLY COMPILE Temp-Tables and Buffers: TABLE: RowObject D "?" ? ADDITIONAL-FIELDS: {ry/obj/rycatfullo.i} END-FIELDS. END-TABLES. */ /* This procedure should always be RUN PERSISTENT. Report the error, */ /* then cleanup and return. */ IF NOT THIS-PROCEDURE:PERSISTENT THEN DO: MESSAGE "{&FILE-NAME} should only be RUN PERSISTENT.":U VIEW-AS ALERT-BOX ERROR BUTTONS OK. RETURN. END. &ANALYZE-RESUME _END-PROCEDURE-SETTINGS /* ************************* Create Window ************************** */ &ANALYZE-SUSPEND _CREATE-WINDOW /* DESIGN Window definition (used by the UIB) CREATE WINDOW vTableWin ASSIGN HEIGHT = 16.81 WIDTH = 96.4. /* END WINDOW DEFINITION */ */ &ANALYZE-RESUME &ANALYZE-SUSPEND _UIB-CODE-BLOCK _CUSTOM _INCLUDED-LIB vTableWin /* ************************* Included-Libraries *********************** */ {src/adm2/viewer.i} /* _UIB-CODE-BLOCK-END */ &ANALYZE-RESUME /* *********** Runtime Attributes and AppBuilder Settings *********** */ &ANALYZE-SUSPEND _RUN-TIME-ATTRIBUTES /* SETTINGS FOR WINDOW vTableWin VISIBLE,,RUN-PERSISTENT */ /* REPARENT FRAME */ ASSIGN FRAME frDetail:FRAME = FRAME frMain:HANDLE. /* SETTINGS FOR FRAME frDetail Custom */ /* SETTINGS FOR FILL-IN fiOverrideTypeLabel IN FRAME frDetail NO-ENABLE */ ASSIGN fiOverrideTypeLabel:PRIVATE-DATA IN FRAME frDetail = "Override Type". /* SETTINGS FOR FRAME frMain NOT-VISIBLE FRAME-NAME Size-to-Fit L-To-R,COLUMNS */ ASSIGN FRAME frMain:SCROLLABLE = FALSE FRAME frMain:HIDDEN = TRUE. /* SETTINGS FOR FILL-IN fiTitle IN FRAME frMain ALIGN-L */ /* _RUN-TIME-ATTRIBUTES-END */ &ANALYZE-RESUME /* Setting information for Queries and Browse Widgets fields */ &ANALYZE-SUSPEND _QUERY-BLOCK FRAME frMain /* Query rebuild information for FRAME frMain _Options = "NO-LOCK" _Query is NOT OPENED */ /* FRAME frMain */ &ANALYZE-RESUME /* ************************ Control Triggers ************************ */ &Scoped-define FRAME-NAME frDetail &Scoped-define SELF-NAME coConstantLevel &ANALYZE-SUSPEND _UIB-CODE-BLOCK _CONTROL coConstantLevel vTableWin ON VALUE-CHANGED OF coConstantLevel IN FRAME frDetail /* Constant Level */ DO: IF glTrackChange THEN RUN changeMade. END. /* _UIB-CODE-BLOCK-END */ &ANALYZE-RESUME &Scoped-define SELF-NAME cOverride &ANALYZE-SUSPEND _UIB-CODE-BLOCK _CONTROL cOverride vTableWin ON VALUE-CHANGED OF cOverride IN FRAME frDetail DO: IF glTrackChange THEN RUN changeMade. END. /* _UIB-CODE-BLOCK-END */ &ANALYZE-RESUME &Scoped-define SELF-NAME toDerivedValue &ANALYZE-SUSPEND _UIB-CODE-BLOCK _CONTROL toDerivedValue vTableWin ON VALUE-CHANGED OF toDerivedValue IN FRAME frDetail /* Derived Value */ DO: IF glTrackChange THEN RUN changeMade. END. /* _UIB-CODE-BLOCK-END */ &ANALYZE-RESUME &Scoped-define SELF-NAME toDesignOnly &ANALYZE-SUSPEND _UIB-CODE-BLOCK _CONTROL toDesignOnly vTableWin ON VALUE-CHANGED OF toDesignOnly IN FRAME frDetail /* Design Only */ DO: IF glTrackChange THEN RUN changeMade. END. /* _UIB-CODE-BLOCK-END */ &ANALYZE-RESUME &Scoped-define SELF-NAME toIsPrivate &ANALYZE-SUSPEND _UIB-CODE-BLOCK _CONTROL toIsPrivate vTableWin ON VALUE-CHANGED OF toIsPrivate IN FRAME frDetail /* Private */ DO: IF glTrackChange THEN RUN changeMade. END. /* _UIB-CODE-BLOCK-END */ &ANALYZE-RESUME &Scoped-define SELF-NAME toLoad &ANALYZE-SUSPEND _UIB-CODE-BLOCK _CONTROL toLoad vTableWin ON VALUE-CHANGED OF toLoad IN FRAME frDetail /* Load into Repository */ DO: IF glTrackChange THEN RUN changeMade. END. /* _UIB-CODE-BLOCK-END */ &ANALYZE-RESUME &Scoped-define SELF-NAME toRuntimeOnly &ANALYZE-SUSPEND _UIB-CODE-BLOCK _CONTROL toRuntimeOnly vTableWin ON VALUE-CHANGED OF toRuntimeOnly IN FRAME frDetail /* Runtime Only */ DO: IF glTrackChange THEN RUN changeMade. END. /* _UIB-CODE-BLOCK-END */ &ANALYZE-RESUME &Scoped-define SELF-NAME toSystemOwned &ANALYZE-SUSPEND _UIB-CODE-BLOCK _CONTROL toSystemOwned vTableWin ON VALUE-CHANGED OF toSystemOwned IN FRAME frDetail /* System Owned */ DO: IF glTrackChange THEN RUN changeMade. END. /* _UIB-CODE-BLOCK-END */ &ANALYZE-RESUME &Scoped-define FRAME-NAME frMain &UNDEFINE SELF-NAME &ANALYZE-SUSPEND _UIB-CODE-BLOCK _CUSTOM _MAIN-BLOCK vTableWin /* *************************** Main Block *************************** */ &IF DEFINED(UIB_IS_RUNNING) <> 0 &THEN RUN initializeObject. &ENDIF /************************ INTERNAL PROCEDURES ********************/ /* _UIB-CODE-BLOCK-END */ &ANALYZE-RESUME /* ********************** Internal Procedures *********************** */ &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE centreText vTableWin PROCEDURE centreText : /*------------------------------------------------------------------------------ Purpose: Parameters: <none> Notes: ------------------------------------------------------------------------------*/ DEFINE VARIABLE iFieldWidth AS INTEGER NO-UNDO. DEFINE VARIABLE iSpaceWidth AS INTEGER NO-UNDO. DEFINE VARIABLE iStringWidth AS INTEGER NO-UNDO. DEFINE VARIABLE iNumSpaces AS INTEGER NO-UNDO. DO WITH FRAME {&FRAME-NAME}: ASSIGN fiTitle:SCREEN-VALUE = TRIM(fiTitle:SCREEN-VALUE) iFieldWidth = fiTitle:WIDTH-PIXELS iSpaceWidth = FONT-TABLE:GET-TEXT-WIDTH-PIXELS(" ":U) iStringWidth = FONT-TABLE:GET-TEXT-WIDTH-PIXELS(fiTitle:SCREEN-VALUE). ASSIGN iNumSpaces = ROUND(((iFieldWidth - iStringWidth) / iSpaceWidth) / 2,0) fiTitle:SCREEN-VALUE = FILL(" ":U,iNumSpaces) + fiTitle:SCREEN-VALUE. END. END PROCEDURE. /* _UIB-CODE-BLOCK-END */ &ANALYZE-RESUME &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE changeMade vTableWin PROCEDURE changeMade : /*------------------------------------------------------------------------------ Purpose: Parameters: <none> Notes: ------------------------------------------------------------------------------*/ RUN setToolbarState (INPUT "Changed"). glChangesMade = TRUE. IF AVAILABLE ttAttribute THEN grLastChangedRowid = ROWID(ttAttribute). END PROCEDURE. /* _UIB-CODE-BLOCK-END */ &ANALYZE-RESUME &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE createAttrBrowser vTableWin PROCEDURE createAttrBrowser : /*------------------------------------------------------------------------------ Purpose: Parameters: <none> Notes: ------------------------------------------------------------------------------*/ DEFINE VARIABLE hBuffer AS HANDLE NO-UNDO. DEFINE VARIABLE hField AS HANDLE NO-UNDO. DEFINE VARIABLE hCurField AS HANDLE NO-UNDO. DEFINE VARIABLE iLoop AS INTEGER NO-UNDO. DEFINE VARIABLE hSortColumn AS HANDLE NO-UNDO. DEFINE VARIABLE cFieldChars AS CHARACTER NO-UNDO. DEFINE VARIABLE iFieldChars AS INTEGER NO-UNDO. CREATE QUERY ghAttrQuery. ghAttrQuery:ADD-BUFFER("ttAttribute"). /* Create the dynamic browser and size it relative to the containing window */ CREATE BROWSE ghAttrBrowse ASSIGN FRAME = FRAME {&FRAME-NAME}:HANDLE ROW = fiTitle:ROW + fiTitle:HEIGHT + .1 COL = 1 WIDTH-CHARS = FRAME {&FRAME-NAME}:WIDTH-CHARS - 3 HEIGHT-CHARS = FRAME {&FRAME-NAME}:HEIGHT-CHARS - (fiTitle:ROW IN FRAME frMain + fiTitle:HEIGHT IN FRAME frMain) - FRAME frDetail:ROW - .5 SEPARATORS = TRUE ROW-MARKERS = FALSE EXPANDABLE = TRUE COLUMN-RESIZABLE = TRUE ALLOW-COLUMN-SEARCHING = FALSE READ-ONLY = FALSE QUERY = ghAttrQuery /* Set procedures to handle browser events */ TRIGGERS: ON VALUE-CHANGED PERSISTENT RUN valueChanged IN THIS-PROCEDURE. END TRIGGERS. /* The frame that the browser is on is hidden during construction, so we don't need to hide the dynamic browser while it is being constructed. When the frame and window is viewed, then the browser will be viewed, too. */ ASSIGN ghAttrBrowse:SENSITIVE = NO. hBuffer = TEMP-TABLE ttAttribute:DEFAULT-BUFFER-HANDLE. /* Add fields to browser using structure of dynamic temp table */ DO iLoop = 1 TO hBuffer:NUM-FIELDS: hCurField = hBuffer:BUFFER-FIELD(iLoop). /* Set Sort Column to first column in browse */ IF NOT VALID-HANDLE(hSortColumn) THEN hSortColumn = hCurField. IF hCurField:LABEL = "NODISPLAY":U THEN NEXT. hField = ghAttrBrowse:ADD-LIKE-COLUMN(hCurField). /* Check that Character format is never bigger than x(50) */ IF hField:DATA-TYPE = "CHARACTER":U THEN DO: ASSIGN cFieldChars = TRIM(hField:FORMAT,"x(":U) cFieldChars = TRIM(hField:FORMAT,")":U). ASSIGN iFieldChars = INTEGER(cFieldChars) NO-ERROR. IF NOT ERROR-STATUS:ERROR THEN IF iFieldChars > 50 THEN hField:FORMAT = "x(50)":U. ERROR-STATUS:ERROR = FALSE. END. END. ASSIGN ghAttrBrowse:SENSITIVE = TRUE. END PROCEDURE. /* _UIB-CODE-BLOCK-END */ &ANALYZE-RESUME &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE disable_UI vTableWin _DEFAULT-DISABLE PROCEDURE disable_UI : /*------------------------------------------------------------------------------ Purpose: DISABLE the User Interface Parameters: <none> Notes: Here we clean-up the user-interface by deleting dynamic widgets we have created and/or hide frames. This procedure is usually called when we are ready to "clean-up" after running. ------------------------------------------------------------------------------*/ /* Hide all frames. */ HIDE FRAME frDetail. HIDE FRAME frMain. IF THIS-PROCEDURE:PERSISTENT THEN DELETE PROCEDURE THIS-PROCEDURE. END PROCEDURE. /* _UIB-CODE-BLOCK-END */ &ANALYZE-RESUME &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE hideObject vTableWin PROCEDURE hideObject : /*------------------------------------------------------------------------------ Purpose: Super Override Parameters: Notes: ------------------------------------------------------------------------------*/ APPLY "ENTRY":U TO ghAttrBrowse. APPLY "VALUE-CHANGED":U TO ghAttrBrowse. /* Code placed here will execute PRIOR to standard behavior. */ RUN SUPER. /* Code placed here will execute AFTER standard behavior. */ END PROCEDURE. /* _UIB-CODE-BLOCK-END */ &ANALYZE-RESUME &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE initializeObject vTableWin PROCEDURE initializeObject : /*------------------------------------------------------------------------------ Purpose: Super Override Parameters: Notes: ------------------------------------------------------------------------------*/ DO WITH FRAME frDetail: ASSIGN cOverride:DELIMITER = CHR(1) cOverride:RADIO-BUTTONS = "None - Allow direct access to attribute value" + CHR(1) + '':U + CHR(1) + "Get - Force value to be retrieved using get function" + CHR(1) + "GET" + CHR(1) + "Set - Force value to be saved using set function" + CHR(1) + "SET" + CHR(1) + "Both - Force use of both set and get functions" + CHR(1) + "GET,SET". END. /* Code placed here will execute PRIOR to standard behavior. */ RUN SUPER. ASSIGN fiOverrideTypeLabel:SCREEN-VALUE IN FRAME frDetail = fiOverrideTypeLabel:PRIVATE-DATA. /* Code placed here will execute AFTER standard behavior. */ RUN createAttrBrowser. IF NOT VALID-HANDLE(ghToolbar) THEN ghToolbar = WIDGET-HANDLE(DYNAMIC-FUNCTION("linkHandles":U, "TableIO-Source":U)). RUN resizeObject (frame {&FRAME-NAME}:height, frame {&FRAME-NAME}:width). END PROCEDURE. /* _UIB-CODE-BLOCK-END */ &ANALYZE-RESUME &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE resetRecord vTableWin PROCEDURE resetRecord : /*------------------------------------------------------------------------------ Purpose: Parameters: <none> Notes: ------------------------------------------------------------------------------*/ glChangesMade = FALSE. APPLY "ENTRY":U TO ghAttrBrowse. APPLY "VALUE-CHANGED":U TO ghAttrBrowse. RUN setToolbarState (INPUT "View"). END PROCEDURE. /* _UIB-CODE-BLOCK-END */ &ANALYZE-RESUME &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE resizeObject vTableWin PROCEDURE resizeObject : /*------------------------------------------------------------------------------ Purpose: Resize the viewer Parameters: pd_height AS DECIMAL - the desired height (in rows) pd_width AS DECIMAL - the desired width (in columns) Notes: Used internally. Calls to resizeObject are generated by the AppBuilder in adm-create-objects for objects which implement it. Having a resizeObject procedure is also the signal to the AppBuilder to allow the object to be resized at design time. ------------------------------------------------------------------------------*/ DEFINE INPUT PARAMETER pdHeight AS DECIMAL NO-UNDO. DEFINE INPUT PARAMETER pdWidth AS DECIMAL NO-UNDO. DEFINE VARIABLE lPreviouslyHidden AS LOGICAL NO-UNDO. DEFINE VARIABLE hWindow AS HANDLE NO-UNDO. DEFINE VARIABLE hContainerSource AS HANDLE NO-UNDO. /* Get container and window handles */ {get ContainerSource hContainerSource}. {get ContainerHandle hWindow hContainerSource}. /* Save hidden state of current frame, then hide it */ ASSIGN FRAME {&FRAME-NAME}:SCROLLABLE = TRUE lPreviouslyHidden = FRAME {&FRAME-NAME}:HIDDEN FRAME {&FRAME-NAME}:HIDDEN = TRUE FRAME {&FRAME-NAME}:SCROLLABLE = FALSE NO-ERROR. ASSIGN FRAME {&FRAME-NAME}:HEIGHT-CHARS = pdHeight FRAME {&FRAME-NAME}:WIDTH-CHARS = pdWidth FRAME frDetail:ROW = FRAME {&FRAME-NAME}:HEIGHT - FRAME frDetail:HEIGHT + 0.9 NO-ERROR. /* Resize dynamic browser (if exists) relative to current frame */ IF VALID-HANDLE(ghAttrBrowse) THEN ASSIGN ghAttrBrowse:WIDTH-CHARS = pdWidth - 1.5 ghAttrBrowse:HEIGHT-CHARS = FRAME frDetail:ROW - ghAttrBrowse:ROW - 0.24 fiTitle:WIDTH = ghAttrBrowse:WIDTH-CHARS NO-ERROR. /* Centre Text */ IF fiTitle:SCREEN-VALUE IN FRAME frMain <> "":U THEN RUN centreText. /* Restore original hidden state of current frame */ APPLY "end-resize":U TO FRAME {&FRAME-NAME}. ASSIGN FRAME {&FRAME-NAME}:HIDDEN = lPreviouslyHidden NO-ERROR. RETURN. END PROCEDURE. /* _UIB-CODE-BLOCK-END */ &ANALYZE-RESUME &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE returnAttributeData vTableWin PROCEDURE returnAttributeData : /*------------------------------------------------------------------------------ Purpose: Parameters: <none> Notes: ------------------------------------------------------------------------------*/ DEFINE OUTPUT PARAMETER TABLE FOR ttAttribute. END PROCEDURE. /* _UIB-CODE-BLOCK-END */ &ANALYZE-RESUME &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE setToolbarState vTableWin PROCEDURE setToolbarState : /*------------------------------------------------------------------------------ Purpose: Parameters: <none> Notes: ------------------------------------------------------------------------------*/ DEFINE INPUT PARAMETER pcState AS CHARACTER NO-UNDO. IF NOT VALID-HANDLE(ghToolbar) THEN RETURN. DYNAMIC-FUNCTION("disableActions":U IN ghToolbar, "save,reset,cancel,folderview,folderupdate":U). CASE pcState: WHEN "Initial" THEN DYNAMIC-FUNCTION("enableActions":U IN ghToolbar, "folderupdate":U). WHEN "modify" THEN DYNAMIC-FUNCTION("enableActions":U IN ghToolbar, "folderview":U). WHEN "changed" THEN DYNAMIC-FUNCTION("enableActions":U IN ghToolbar, "save,reset":U). WHEN "view" THEN DYNAMIC-FUNCTION("enableActions":U IN ghToolbar, "folderupdate":U). END CASE. END PROCEDURE. /* _UIB-CODE-BLOCK-END */ &ANALYZE-RESUME &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE toolbar vTableWin PROCEDURE toolbar : /*------------------------------------------------------------------------------ Purpose: Super Override Parameters: Notes: ------------------------------------------------------------------------------*/ DEFINE INPUT PARAMETER pcValue AS CHARACTER NO-UNDO. RUN setToolbarState (INPUT pcValue). END PROCEDURE. /* _UIB-CODE-BLOCK-END */ &ANALYZE-RESUME &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE updateAttr vTableWin PROCEDURE updateAttr : /*------------------------------------------------------------------------------ Purpose: Parameters: <none> Notes: ------------------------------------------------------------------------------*/ DEFINE INPUT PARAMETER TABLE FOR ttAttribute. END PROCEDURE. /* _UIB-CODE-BLOCK-END */ &ANALYZE-RESUME &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE updateMode vTableWin PROCEDURE updateMode : /*------------------------------------------------------------------------------ Purpose: Super Override Parameters: Notes: ------------------------------------------------------------------------------*/ DEFINE INPUT PARAMETER pcMode AS CHARACTER NO-UNDO. DEFINE VARIABLE cButton AS CHARACTER NO-UNDO. CASE pcMode: WHEN "Modify":U THEN DO: IF AVAILABLE ttAttribute AND ttAttribute.lExistInDB = FALSE THEN DO: ENABLE ALL EXCEPT fiAttrName WITH FRAME frDetail. APPLY "ENTRY":U TO coConstantLevel IN FRAME frDetail. RUN setToolbarState (INPUT "Modify":U). END. ELSE DO: RUN showMessages IN gshSessionManager (INPUT "This Attribute already exists in the Repository and cannot be modified.", INPUT "INF":U, INPUT "OK":U, INPUT "OK":U, INPUT "OK":U, INPUT "Cannot Modify Record", INPUT YES, INPUT ?, OUTPUT cButton). END. END. WHEN "View":U THEN DO: DISABLE ALL WITH FRAME frDetail. APPLY "ENTRY":U TO ghAttrBrowse. RUN setToolbarState (INPUT "View":U). END. END CASE. END PROCEDURE. /* _UIB-CODE-BLOCK-END */ &ANALYZE-RESUME &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE updateRecord vTableWin PROCEDURE updateRecord : /*------------------------------------------------------------------------------ Purpose: Super Override Parameters: Notes: ------------------------------------------------------------------------------*/ DEFINE VARIABLE rRowid AS ROWID NO-UNDO. IF AVAILABLE ttAttribute THEN DO WITH FRAME frDetail: rRowId = ROWID(ttAttribute). ASSIGN coConstantLevel. ASSIGN ttAttribute.cConstantLevel = coConstantLevel ttAttribute.lLoad = toLoad:CHECKED ttAttribute.lRuntimeOnly = toRuntimeOnly:CHECKED ttAttribute.lDerivedValue = toDerivedValue:CHECKED ttAttribute.lPrivate = toIsPrivate:CHECKED ttAttribute.lSystemOwned = toSystemOwned:CHECKED ttAttribute.lDesignOnly = toDesignOnly:CHECKED ttAttribute.cOverrideType = cOverride:SCREEN-VALUE. glChangesMade = FALSE. ghAttrQuery:QUERY-CLOSE(). ghAttrQuery:QUERY-OPEN(). ghAttrQuery:REPOSITION-TO-ROWID(rRowid). END. APPLY "ENTRY":U TO ghAttrBrowse. APPLY "VALUE-CHANGED":U TO ghAttrBrowse. RUN setToolbarState (INPUT "View"). END PROCEDURE. /* _UIB-CODE-BLOCK-END */ &ANALYZE-RESUME &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE valueChanged vTableWin PROCEDURE valueChanged : /*------------------------------------------------------------------------------ Purpose: Parameters: <none> Notes: ------------------------------------------------------------------------------*/ DEFINE VARIABLE cAnswer AS CHARACTER NO-UNDO. DEFINE VARIABLE cButton AS CHARACTER NO-UNDO. DEFINE VARIABLE rRowid AS ROWID NO-UNDO. IF FOCUS:HANDLE <> ghAttrBrowse THEN RETURN. IF glChangesMade THEN DO: rRowid = ROWID(ttAttribute). RUN askQuestion IN gshSessionManager (INPUT "You have made changes to this record that are not saved.~n~nDo you wish to save your changes now?", /* message to display */ INPUT "&YES,&NO":U, /* button list */ INPUT "&YES":U, /* default button */ INPUT "&No":U, /* cancel button */ INPUT "Save Changes":U, /* window title */ INPUT "":U, /* data type of question */ INPUT "":U, /* format mask for question */ INPUT-OUTPUT cAnswer, /* character value of answer to question */ OUTPUT cButton /* button pressed */ ). IF cButton = "&YES":U THEN DO: ghAttrQuery:REPOSITION-TO-ROWID(grLastChangedRowid). RUN updateRecord. ghAttrQuery:REPOSITION-TO-ROWID(rRowid). END. END. DO WITH FRAME frDetail: DISABLE ALL. END. CLEAR FRAME frDetail ALL NO-PAUSE. fiOverrideTypeLabel:SCREEN-VALUE IN FRAME frDetail = fiOverrideTypeLabel:PRIVATE-DATA. IF AVAILABLE ttAttribute AND ghAttrQuery:NUM-RESULTS <> 0 THEN DO WITH FRAME frDetail: ASSIGN glTrackChange = FALSE fiAttrName:SCREEN-VALUE = ttAttribute.cAttrName coConstantLevel:SCREEN-VALUE = ttAttribute.cConstantLevel toLoad:CHECKED = ttAttribute.lLoad toRuntimeOnly:CHECKED = ttAttribute.lRuntimeOnly toDerivedValue:CHECKED = ttAttribute.lDerivedValue toIsPrivate:CHECKED = ttAttribute.lPrivate toSystemOwned:CHECKED = ttAttribute.lSystemOwned toDesignOnly:CHECKED = ttAttribute.lDesignOnly cOverride:SCREEN-VALUE = ttAttribute.cOverrideType. RUN setToolbarState (INPUT "Initial"). glTrackChange = TRUE. END. END PROCEDURE. /* _UIB-CODE-BLOCK-END */ &ANALYZE-RESUME &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE valueChangedClass vTableWin PROCEDURE valueChangedClass : /*------------------------------------------------------------------------------ Purpose: Parameters: <none> Notes: ------------------------------------------------------------------------------*/ DEFINE INPUT PARAMETER pcFileName AS CHARACTER NO-UNDO. DEFINE INPUT PARAMETER phClassBrowse AS HANDLE NO-UNDO. RUN setToolbarState (INPUT "":U). IF phClassBrowse:NUM-SELECTED-ROWS = 1 THEN fiTitle:SCREEN-VALUE IN FRAME {&FRAME-NAME} = "<< Custom Properties for " + pcFileName + " >>":U. ELSE IF phClassBrowse:NUM-SELECTED-ROWS > 0 THEN fiTitle:SCREEN-VALUE IN FRAME {&FRAME-NAME} = "<< Multiple Rows Selected >>". ELSE fiTitle:SCREEN-VALUE IN FRAME {&FRAME-NAME} = "". RUN centreText. ghAttrQuery:QUERY-CLOSE(). IF phClassBrowse:NUM-SELECTED-ROWS = 1 THEN ghAttrQuery:QUERY-PREPARE("FOR EACH ttAttribute WHERE ttAttribute.cFileName = '" + pcFileName + "'"). ELSE ghAttrQuery:QUERY-PREPARE("FOR EACH ttAttribute WHERE ttAttribute.cFileName = 'ZZ9XX9ZZ9XX'"). ghAttrQuery:QUERY-OPEN(). APPLY "ENTRY":U TO ghAttrBrowse. APPLY "VALUE-CHANGED":U TO ghAttrBrowse. END PROCEDURE. /* _UIB-CODE-BLOCK-END */ &ANALYZE-RESUME /* ************************ Function Implementations ***************** */ &ANALYZE-SUSPEND _UIB-CODE-BLOCK _FUNCTION setStatusText vTableWin FUNCTION setStatusText RETURNS LOGICAL ( pcStatusText AS CHARACTER ) : /*------------------------------------------------------------------------------ Purpose: Assigns Status Text Notes: ------------------------------------------------------------------------------*/ STATUS DEFAULT pcStatusText. RETURN TRUE. /* Function return value. */ END FUNCTION. /* _UIB-CODE-BLOCK-END */ &ANALYZE-RESUME
34.169028
183
0.580142
[ "object" ]
b4bf9cc6e85b172bbb9a6bae56ea70204a6a3988
191
h
C
Sensor/Sensor/Sensor.h
EmilRyberg/SSP-Greenhouse
7bc7f1197245983f67e90cd10ad3a981077c39b6
[ "MIT" ]
null
null
null
Sensor/Sensor/Sensor.h
EmilRyberg/SSP-Greenhouse
7bc7f1197245983f67e90cd10ad3a981077c39b6
[ "MIT" ]
null
null
null
Sensor/Sensor/Sensor.h
EmilRyberg/SSP-Greenhouse
7bc7f1197245983f67e90cd10ad3a981077c39b6
[ "MIT" ]
null
null
null
#pragma once #include <vector> class Sensor { public: float ReadValue(); virtual float ParsedValue() = 0; protected: int pinNumber; float lastMeasurement; std::vector<float> buffer; };
14.692308
33
0.727749
[ "vector" ]
b4c6a6e6e97bab21bfcd60622963ec3de72d2380
1,853
h
C
library/drivecontroller/includes/dd/drivecontroller/controller_wrapper.h
darwinbeing/deepdriving-tensorflow
036a83871f3515b2c041bc3cd5e845f6d8f7b3b7
[ "MIT" ]
1
2018-12-13T14:00:03.000Z
2018-12-13T14:00:03.000Z
library/drivecontroller/includes/dd/drivecontroller/controller_wrapper.h
darwinbeing/deepdriving-tensorflow
036a83871f3515b2c041bc3cd5e845f6d8f7b3b7
[ "MIT" ]
null
null
null
library/drivecontroller/includes/dd/drivecontroller/controller_wrapper.h
darwinbeing/deepdriving-tensorflow
036a83871f3515b2c041bc3cd5e845f6d8f7b3b7
[ "MIT" ]
null
null
null
/** * Copyright (C) 2017 Andre Netzeband * * This file is part of "DeepDriving for Speed-Dreams". * * "DeepDriving for Speed-Dreams" is free software: you can redistribute it * and/or modify it under the terms of the GNU General Public License as * published by the Free Software Foundation, either version 3 of the License, * or (at your option) any later version. * * "DeepDriving for Speed-Dreams" is distributed in the hope that it * will be useful, but WITHOUT ANY WARRANTY; without even the implied * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * See the GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with "DeepDriving for Speed-Dreams". * If not, see <http://www.gnu.org/licenses/>. */ /** * @file controller_wrapper.h * @author Andre Netzeband * @date 22.05.2017 * * @brief Wrapper over the drive controller class. * */ #ifndef DD_CONTROLLER_WRAPPER_H #define DD_CONTROLLER_WRAPPER_H // project includes #include <dd/common/settings.h> #include <dd/common/datatypes.h> #ifdef __cplusplus extern "C" { #endif /// @brief Creates a drive controller object. /// @param Lanes Is the number of lanes. /// @return Returns the created object. DLL_API void * CDriveController_create(uint32_t Lanes); /// @brief Destory a drive controller object. /// @param pObject Is the object to destroy. DLL_API void CDriveController_destroy(void * pObject); /// @brief Controls the car. /// @param pObject Is the drive controller object. /// @param pIndicators Are the situation indicators. /// @param pControl Are the control commands. DLL_API void CDriveController_control(void * pObject, Indicators_t const * pIndicators, Control_t * pControl); #ifdef __cplusplus }; #endif #endif //DD_CONTROLLER_WRAPPER_H
29.887097
110
0.735564
[ "object" ]
b4c8e7a5d3e0251803e674034b975c323d4af210
5,771
c
C
kernel/linux-5.4/drivers/hid/hid-creative-sb0540.c
josehu07/SplitFS
d7442fa67a17de7057664f91defbfdbf10dd7f4a
[ "Apache-2.0" ]
44
2022-03-16T08:32:31.000Z
2022-03-31T16:02:35.000Z
src/linux/drivers/hid/hid-creative-sb0540.c
lukedsmalley/oo-kernel-hacking
57161ae3e8a780a72b475b3c27fec8deef83b8e1
[ "MIT" ]
13
2021-07-10T04:36:17.000Z
2022-03-03T10:50:05.000Z
src/linux/drivers/hid/hid-creative-sb0540.c
lukedsmalley/oo-kernel-hacking
57161ae3e8a780a72b475b3c27fec8deef83b8e1
[ "MIT" ]
18
2022-03-19T04:41:04.000Z
2022-03-31T03:32:12.000Z
// SPDX-License-Identifier: GPL-2.0 /* * HID driver for the Creative SB0540 receiver * * Copyright (C) 2019 Red Hat Inc. All Rights Reserved * */ #include <linux/device.h> #include <linux/hid.h> #include <linux/module.h> #include "hid-ids.h" MODULE_AUTHOR("Bastien Nocera <hadess@hadess.net>"); MODULE_DESCRIPTION("HID Creative SB0540 receiver"); MODULE_LICENSE("GPL"); static const unsigned short creative_sb0540_key_table[] = { KEY_POWER, KEY_RESERVED, /* text: 24bit */ KEY_RESERVED, /* 24bit wheel up */ KEY_RESERVED, /* 24bit wheel down */ KEY_RESERVED, /* text: CMSS */ KEY_RESERVED, /* CMSS wheel Up */ KEY_RESERVED, /* CMSS wheel Down */ KEY_RESERVED, /* text: EAX */ KEY_RESERVED, /* EAX wheel up */ KEY_RESERVED, /* EAX wheel down */ KEY_RESERVED, /* text: 3D Midi */ KEY_RESERVED, /* 3D Midi wheel up */ KEY_RESERVED, /* 3D Midi wheel down */ KEY_MUTE, KEY_VOLUMEUP, KEY_VOLUMEDOWN, KEY_UP, KEY_LEFT, KEY_RIGHT, KEY_REWIND, KEY_OK, KEY_FASTFORWARD, KEY_DOWN, KEY_AGAIN, /* text: Return, symbol: Jump to */ KEY_PLAY, /* text: Start */ KEY_ESC, /* text: Cancel */ KEY_RECORD, KEY_OPTION, KEY_MENU, /* text: Display */ KEY_PREVIOUS, KEY_PLAYPAUSE, KEY_NEXT, KEY_SLOW, KEY_STOP, KEY_NUMERIC_1, KEY_NUMERIC_2, KEY_NUMERIC_3, KEY_NUMERIC_4, KEY_NUMERIC_5, KEY_NUMERIC_6, KEY_NUMERIC_7, KEY_NUMERIC_8, KEY_NUMERIC_9, KEY_NUMERIC_0 }; /* * Codes and keys from lirc's * remotes/creative/lircd.conf.alsa_usb * order and size must match creative_sb0540_key_table[] above */ static const unsigned short creative_sb0540_codes[] = { 0x619E, 0x916E, 0x926D, 0x936C, 0x718E, 0x946B, 0x956A, 0x8C73, 0x9669, 0x9768, 0x9867, 0x9966, 0x9A65, 0x6E91, 0x629D, 0x639C, 0x7B84, 0x6B94, 0x728D, 0x8778, 0x817E, 0x758A, 0x8D72, 0x8E71, 0x8877, 0x7C83, 0x738C, 0x827D, 0x7689, 0x7F80, 0x7986, 0x7A85, 0x7D82, 0x857A, 0x8B74, 0x8F70, 0x906F, 0x8A75, 0x847B, 0x7887, 0x8976, 0x837C, 0x7788, 0x807F }; struct creative_sb0540 { struct input_dev *input_dev; struct hid_device *hid; unsigned short keymap[ARRAY_SIZE(creative_sb0540_key_table)]; }; static inline u64 reverse(u64 data, int bits) { int i; u64 c; c = 0; for (i = 0; i < bits; i++) { c |= (u64) (((data & (((u64) 1) << i)) ? 1 : 0)) << (bits - 1 - i); } return (c); } static int get_key(struct creative_sb0540 *creative_sb0540, u64 keycode) { int i; for (i = 0; i < ARRAY_SIZE(creative_sb0540_codes); i++) { if (creative_sb0540_codes[i] == keycode) return creative_sb0540->keymap[i]; } return 0; } static int creative_sb0540_raw_event(struct hid_device *hid, struct hid_report *report, u8 *data, int len) { struct creative_sb0540 *creative_sb0540 = hid_get_drvdata(hid); u64 code, main_code; int key; if (len != 6) return 0; /* From daemons/hw_hiddev.c sb0540_rec() in lirc */ code = reverse(data[5], 8); main_code = (code << 8) + ((~code) & 0xff); /* * Flip to get values in the same format as * remotes/creative/lircd.conf.alsa_usb in lirc */ main_code = ((main_code & 0xff) << 8) + ((main_code & 0xff00) >> 8); key = get_key(creative_sb0540, main_code); if (key == 0 || key == KEY_RESERVED) { hid_err(hid, "Could not get a key for main_code %llX\n", main_code); return 0; } input_report_key(creative_sb0540->input_dev, key, 1); input_report_key(creative_sb0540->input_dev, key, 0); input_sync(creative_sb0540->input_dev); /* let hidraw and hiddev handle the report */ return 0; } static int creative_sb0540_input_configured(struct hid_device *hid, struct hid_input *hidinput) { struct input_dev *input_dev = hidinput->input; struct creative_sb0540 *creative_sb0540 = hid_get_drvdata(hid); int i; creative_sb0540->input_dev = input_dev; input_dev->keycode = creative_sb0540->keymap; input_dev->keycodesize = sizeof(unsigned short); input_dev->keycodemax = ARRAY_SIZE(creative_sb0540->keymap); input_dev->evbit[0] = BIT(EV_KEY) | BIT(EV_REP); memcpy(creative_sb0540->keymap, creative_sb0540_key_table, sizeof(creative_sb0540->keymap)); for (i = 0; i < ARRAY_SIZE(creative_sb0540_key_table); i++) set_bit(creative_sb0540->keymap[i], input_dev->keybit); clear_bit(KEY_RESERVED, input_dev->keybit); return 0; } static int creative_sb0540_input_mapping(struct hid_device *hid, struct hid_input *hi, struct hid_field *field, struct hid_usage *usage, unsigned long **bit, int *max) { /* * We are remapping the keys ourselves, so ignore the hid-input * keymap processing. */ return -1; } static int creative_sb0540_probe(struct hid_device *hid, const struct hid_device_id *id) { int ret; struct creative_sb0540 *creative_sb0540; creative_sb0540 = devm_kzalloc(&hid->dev, sizeof(struct creative_sb0540), GFP_KERNEL); if (!creative_sb0540) return -ENOMEM; creative_sb0540->hid = hid; /* force input as some remotes bypass the input registration */ hid->quirks |= HID_QUIRK_HIDINPUT_FORCE; hid_set_drvdata(hid, creative_sb0540); ret = hid_parse(hid); if (ret) { hid_err(hid, "parse failed\n"); return ret; } ret = hid_hw_start(hid, HID_CONNECT_DEFAULT); if (ret) { hid_err(hid, "hw start failed\n"); return ret; } return ret; } static const struct hid_device_id creative_sb0540_devices[] = { { HID_USB_DEVICE(USB_VENDOR_ID_CREATIVELABS, USB_DEVICE_ID_CREATIVE_SB0540) }, { } }; MODULE_DEVICE_TABLE(hid, creative_sb0540_devices); static struct hid_driver creative_sb0540_driver = { .name = "creative-sb0540", .id_table = creative_sb0540_devices, .raw_event = creative_sb0540_raw_event, .input_configured = creative_sb0540_input_configured, .probe = creative_sb0540_probe, .input_mapping = creative_sb0540_input_mapping, }; module_hid_driver(creative_sb0540_driver);
21.453532
79
0.715474
[ "3d" ]
b4e8f6cc148695c5f2bd5c5d9ea177e0c67d3c7f
1,406
h
C
src/Core/TundraProtocolModule/MsgLoginReply.h
Joosua/tundra
c170c597d9af73a5ef08ea8ef4566665addc6664
[ "Apache-2.0" ]
31
2015-01-12T15:20:29.000Z
2022-02-03T10:04:17.000Z
src/Core/TundraProtocolModule/MsgLoginReply.h
Joosua/tundra
c170c597d9af73a5ef08ea8ef4566665addc6664
[ "Apache-2.0" ]
2
2015-02-04T12:58:05.000Z
2016-01-04T15:46:48.000Z
src/Core/TundraProtocolModule/MsgLoginReply.h
Joosua/tundra
c170c597d9af73a5ef08ea8ef4566665addc6664
[ "Apache-2.0" ]
20
2015-03-04T02:31:33.000Z
2022-02-13T18:12:55.000Z
#pragma once #include "kNet/DataDeserializer.h" #include "kNet/DataSerializer.h" /// Network message for login reply. struct MsgLoginReply { MsgLoginReply() { InitToDefault(); } MsgLoginReply(const char *data, size_t numBytes) { InitToDefault(); kNet::DataDeserializer dd(data, numBytes); DeserializeFrom(dd); } void InitToDefault() { reliable = defaultReliable; inOrder = defaultInOrder; priority = defaultPriority; } enum { messageID = 101 }; static inline const char * Name() { return "LoginReply"; } static const bool defaultReliable = true; static const bool defaultInOrder = true; static const u32 defaultPriority = 100; bool reliable; bool inOrder; u32 priority; u8 success; u32 userID; std::vector<s8> loginReplyData; inline size_t Size() const { return 1 + 1 + 2 + loginReplyData.size()*1; } inline void SerializeTo(kNet::DataSerializer &dst) const { dst.Add<u8>(success); dst.AddVLE<kNet::VLE8_16_32>(userID); dst.Add<u16>((u16)loginReplyData.size()); if (loginReplyData.size() > 0) dst.AddArray<s8>(&loginReplyData[0], (u32)loginReplyData.size()); } inline void DeserializeFrom(kNet::DataDeserializer &src) { success = src.Read<u8>(); userID = src.ReadVLE<kNet::VLE8_16_32>(); loginReplyData.resize(src.Read<u16>()); if (loginReplyData.size() > 0) src.ReadArray<s8>(&loginReplyData[0], loginReplyData.size()); } };
20.676471
68
0.703414
[ "vector" ]
b4eb11150b099e2bff12382c3a391236a276ec71
43,824
h
C
src/ReBarBand.h
TimoKunze/ToolBarControls
409625a0e8541d7cea7a108951699970953af757
[ "MIT" ]
1
2019-12-12T08:12:14.000Z
2019-12-12T08:12:14.000Z
src/ReBarBand.h
TimoKunze/ToolBarControls
409625a0e8541d7cea7a108951699970953af757
[ "MIT" ]
null
null
null
src/ReBarBand.h
TimoKunze/ToolBarControls
409625a0e8541d7cea7a108951699970953af757
[ "MIT" ]
2
2018-05-05T02:30:05.000Z
2021-12-09T18:20:38.000Z
////////////////////////////////////////////////////////////////////// /// \class ReBarBand /// \author Timo "TimoSoft" Kunze /// \brief <em>Wraps an existing rebar band</em> /// /// This class is a wrapper around a rebar band that - unlike a band wrapped by /// \c VirtualReBarBand - really exists in the control. /// /// \if UNICODE /// \sa TBarCtlsLibU::IReBarBand, VirtualReBarBand, ReBarBands, ReBar /// \else /// \sa TBarCtlsLibA::IReBarBand, VirtualReBarBand, ReBarBands, ReBar /// \endif ////////////////////////////////////////////////////////////////////// #pragma once #include "res/resource.h" #ifdef UNICODE #include "TBarCtlsU.h" #else #include "TBarCtlsA.h" #endif #include "_IReBarBandEvents_CP.h" #include "helpers.h" #include "ReBar.h" class ATL_NO_VTABLE ReBarBand : public CComObjectRootEx<CComSingleThreadModel>, public CComCoClass<ReBarBand, &CLSID_ReBarBand>, public ISupportErrorInfo, public IConnectionPointContainerImpl<ReBarBand>, public Proxy_IReBarBandEvents<ReBarBand>, #ifdef UNICODE public IDispatchImpl<IReBarBand, &IID_IReBarBand, &LIBID_TBarCtlsLibU, /*wMajor =*/ VERSION_MAJOR, /*wMinor =*/ VERSION_MINOR> #else public IDispatchImpl<IReBarBand, &IID_IReBarBand, &LIBID_TBarCtlsLibA, /*wMajor =*/ VERSION_MAJOR, /*wMinor =*/ VERSION_MINOR> #endif { friend class ReBar; friend class ReBarBands; friend class ClassFactory; public: #ifndef DOXYGEN_SHOULD_SKIP_THIS DECLARE_REGISTRY_RESOURCEID(IDR_REBARBAND) BEGIN_COM_MAP(ReBarBand) COM_INTERFACE_ENTRY(IReBarBand) COM_INTERFACE_ENTRY(IDispatch) COM_INTERFACE_ENTRY(ISupportErrorInfo) COM_INTERFACE_ENTRY(IConnectionPointContainer) END_COM_MAP() BEGIN_CONNECTION_POINT_MAP(ReBarBand) CONNECTION_POINT_ENTRY(__uuidof(_IReBarBandEvents)) END_CONNECTION_POINT_MAP() DECLARE_PROTECT_FINAL_CONSTRUCT() #endif ////////////////////////////////////////////////////////////////////// /// \name Implementation of ISupportErrorInfo /// //@{ /// \brief <em>Retrieves whether an interface supports the \c IErrorInfo interface</em> /// /// \param[in] interfaceToCheck The IID of the interface to check. /// /// \return \c S_OK if the interface identified by \c interfaceToCheck supports \c IErrorInfo; /// otherwise \c S_FALSE. /// /// \sa <a href="https://msdn.microsoft.com/en-us/library/ms221233.aspx">IErrorInfo</a> virtual HRESULT STDMETHODCALLTYPE InterfaceSupportsErrorInfo(REFIID interfaceToCheck); //@} ////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////// /// \name Implementation of IReBarBand /// //@{ /// \brief <em>Retrieves the current setting of the \c AddMarginsAroundChild property</em> /// /// Retrieves whether the band's height is increased by a small margin. If set to \c VARIANT_TRUE, a /// small margin is inserted at the top and bottom of the band's contained window; otherwise not. /// /// \param[out] pValue The property's current setting. /// /// \return An \c HRESULT error code. /// /// \sa put_AddMarginsAroundChild, get_CurrentHeight, ReBar::GetMargins, ReBar::get_DisplayBandSeparators virtual HRESULT STDMETHODCALLTYPE get_AddMarginsAroundChild(VARIANT_BOOL* pValue); /// \brief <em>Sets the \c AddMarginsAroundChild property</em> /// /// Sets whether the band's height is increased by a small margin. If set to \c VARIANT_TRUE, a /// small margin is inserted at the top and bottom of the band's contained window; otherwise not. /// /// \param[in] newValue The setting to apply. /// /// \return An \c HRESULT error code. /// /// \sa get_AddMarginsAroundChild, put_CurrentHeight, ReBar::GetMargins, ReBar::put_DisplayBandSeparators virtual HRESULT STDMETHODCALLTYPE put_AddMarginsAroundChild(VARIANT_BOOL newValue); /// \brief <em>Retrieves the current setting of the \c BackColor property</em> /// /// Retrieves the band's background color. If set to -1, the control's background color is used. /// /// \param[out] pValue The property's current setting. /// /// \return An \c HRESULT error code. /// /// \remarks This property isn't supported for themed rebars. /// /// \sa put_BackColor, get_hBackgroundBitmap, get_ForeColor, ReBar::get_BackColor virtual HRESULT STDMETHODCALLTYPE get_BackColor(OLE_COLOR* pValue); /// \brief <em>Sets the \c BackColor property</em> /// /// Sets the band's background color. If set to -1, the control's background color is used. /// /// \param[in] newValue The setting to apply. /// /// \return An \c HRESULT error code. /// /// \remarks This property isn't supported for themed rebars. /// /// \sa get_BackColor, put_hBackgroundBitmap, put_ForeColor, ReBar::put_BackColor virtual HRESULT STDMETHODCALLTYPE put_BackColor(OLE_COLOR newValue); /// \brief <em>Retrieves the current setting of the \c BandData property</em> /// /// Retrieves the \c LONG value associated with the band. Use this property to associate any data /// with the band. /// /// \param[out] pValue The property's current setting. /// /// \return An \c HRESULT error code. /// /// \sa put_BandData, ReBar::Raise_FreeBandData virtual HRESULT STDMETHODCALLTYPE get_BandData(LONG* pValue); /// \brief <em>Sets the \c BandData property</em> /// /// Sets the \c LONG value associated with the band. Use this property to associate any data /// with the band. /// /// \param[in] newValue The setting to apply. /// /// \return An \c HRESULT error code. /// /// \sa get_BandData, ReBar::Raise_FreeBandData virtual HRESULT STDMETHODCALLTYPE put_BandData(LONG newValue); /// \brief <em>Retrieves the current setting of the \c ChevronButtonObjectState property</em> /// /// Retrieves the accessibility object state of the band's chevron button. For a list of possible object /// states see the <a href="https://msdn.microsoft.com/en-us/library/ms697270.aspx">MSDN article</a>. /// /// \param[out] pValue The property's current setting. /// /// \return An \c HRESULT error code. /// /// \remarks Requires comctl32.dll version 6.10 or higher.\n /// This property is read-only. /// /// \sa get_UseChevron, /// <a href="https://msdn.microsoft.com/en-us/library/ms697270.aspx">Accessibility Object State Constants</a> virtual HRESULT STDMETHODCALLTYPE get_ChevronButtonObjectState(LONG* pValue); /// \brief <em>Retrieves the current setting of the \c ChevronHot property</em> /// /// Retrieves whether the mouse cursor is located over the band's chevron button. If \c VARIANT_TRUE, the /// chevron button is hot (i.e. below the mouse); otherwise not. /// /// \param[out] pValue The property's current setting. /// /// \return An \c HRESULT error code. /// /// \remarks This property is read-only. /// /// \sa get_UseChevron, get_ChevronVisible, get_ChevronPushed virtual HRESULT STDMETHODCALLTYPE get_ChevronHot(VARIANT_BOOL* pValue); /// \brief <em>Retrieves the current setting of the \c ChevronPushed property</em> /// /// Retrieves whether the band's chevron button currently is pushed. If \c VARIANT_TRUE, the chevron /// button is pushed; otherwise not. /// /// \param[out] pValue The property's current setting. /// /// \return An \c HRESULT error code. /// /// \remarks This property is read-only. /// /// \sa get_UseChevron, get_ChevronVisible, get_ChevronHot virtual HRESULT STDMETHODCALLTYPE get_ChevronPushed(VARIANT_BOOL* pValue); /// \brief <em>Retrieves the current setting of the \c ChevronVisible property</em> /// /// Retrieves whether the band's chevron button is visible. If \c VARIANT_TRUE, the chevron button is /// being displayed; otherwise not. /// /// \param[out] pValue The property's current setting. /// /// \return An \c HRESULT error code. /// /// \remarks This property is read-only. /// /// \sa get_UseChevron, get_IdealWidth, get_ChevronHot, get_ChevronPushed virtual HRESULT STDMETHODCALLTYPE get_ChevronVisible(VARIANT_BOOL* pValue); /// \brief <em>Retrieves the current setting of the \c CurrentHeight property</em> /// /// Retrieves the band's current height in pixels. /// /// \param[out] pValue The property's current setting. /// /// \return An \c HRESULT error code. /// /// \remarks If the \c VariableHeight property is set to \c VARIANT_FALSE, this property is ignored. /// /// \sa put_CurrentHeight, get_CurrentWidth, get_MinimumHeight, get_MaximumHeight, /// get_HeightChangeStepSize, get_VariableHeight virtual HRESULT STDMETHODCALLTYPE get_CurrentHeight(OLE_YSIZE_PIXELS* pValue); /// \brief <em>Sets the \c CurrentHeight property</em> /// /// Sets the band's current height in pixels. /// /// \param[in] newValue The setting to apply. /// /// \return An \c HRESULT error code. /// /// \remarks If the \c VariableHeight property is set to \c VARIANT_FALSE, this property is ignored. /// /// \sa get_CurrentHeight, put_CurrentWidth, put_MinimumHeight, put_MaximumHeight, /// put_HeightChangeStepSize, put_VariableHeight virtual HRESULT STDMETHODCALLTYPE put_CurrentHeight(OLE_YSIZE_PIXELS newValue); /// \brief <em>Retrieves the current setting of the \c CurrentWidth property</em> /// /// Retrieves the band's current width in pixels. /// /// \param[out] pValue The property's current setting. /// /// \return An \c HRESULT error code. /// /// \sa put_CurrentWidth, get_CurrentHeight, get_MinimumWidth, get_IdealWidth, get_TitleWidth, Maximize, /// Minimize virtual HRESULT STDMETHODCALLTYPE get_CurrentWidth(OLE_XSIZE_PIXELS* pValue); /// \brief <em>Sets the \c CurrentWidth property</em> /// /// Sets the band's current width in pixels. /// /// \param[in] newValue The setting to apply. /// /// \return An \c HRESULT error code. /// /// \sa get_CurrentWidth, put_CurrentHeight, put_MinimumWidth, put_IdealWidth, put_TitleWidth, Maximize, /// Minimize virtual HRESULT STDMETHODCALLTYPE put_CurrentWidth(OLE_XSIZE_PIXELS newValue); /// \brief <em>Retrieves the current setting of the \c FixedBackgroundBitmapOrigin property</em> /// /// Retrieves whether the band's background bitmap begins at the control's upper-left corner instead of /// the band's upper-left corner. If set to \c VARIANT_TRUE, the bitmap's origin is the control's /// upper-left corner, so that the background image doesn't move if the band is resized or moved (instead /// the visible part of the background image changes). If set to \c VARIANT_FALSE, the origin is the /// band's upper-left corner, so that the background image moves with the band. /// /// \param[out] pValue The property's current setting. /// /// \return An \c HRESULT error code. /// /// \sa put_FixedBackgroundBitmapOrigin, get_hBackgroundBitmap virtual HRESULT STDMETHODCALLTYPE get_FixedBackgroundBitmapOrigin(VARIANT_BOOL* pValue); /// \brief <em>Sets the \c FixedBackgroundBitmapOrigin property</em> /// /// Sets whether the band's background bitmap begins at the control's upper-left corner instead of /// the band's upper-left corner. If set to \c VARIANT_TRUE, the bitmap's origin is the control's /// upper-left corner, so that the background image doesn't move if the band is resized or moved (instead /// the visible part of the background image changes). If set to \c VARIANT_FALSE, the origin is the /// band's upper-left corner, so that the background image moves with the band. /// /// \param[in] newValue The setting to apply. /// /// \return An \c HRESULT error code. /// /// \sa get_FixedBackgroundBitmapOrigin, put_hBackgroundBitmap virtual HRESULT STDMETHODCALLTYPE put_FixedBackgroundBitmapOrigin(VARIANT_BOOL newValue); /// \brief <em>Retrieves the current setting of the \c ForeColor property</em> /// /// Retrieves the band's text color. If set to -1, the control's text color is used. /// /// \param[out] pValue The property's current setting. /// /// \return An \c HRESULT error code. /// /// \remarks This property isn't supported for themed rebars. /// /// \sa put_ForeColor, get_BackColor, ReBar::get_ForeColor virtual HRESULT STDMETHODCALLTYPE get_ForeColor(OLE_COLOR* pValue); /// \brief <em>Sets the \c ForeColor property</em> /// /// Sets the band's text color. If set to -1, the control's text color is used. /// /// \param[in] newValue The setting to apply. /// /// \return An \c HRESULT error code. /// /// \remarks This property isn't supported for themed rebars. /// /// \sa get_ForeColor, put_BackColor, ReBar::put_ForeColor virtual HRESULT STDMETHODCALLTYPE put_ForeColor(OLE_COLOR newValue); /// \brief <em>Retrieves the current setting of the \c hBackgroundBitmap property</em> /// /// Retrieves the handle of the bitmap used as the background for the band. /// /// \param[out] pValue The property's current setting. /// /// \return An \c HRESULT error code. /// /// \sa put_hBackgroundBitmap, get_BackColor, ReBar::get_hPalette, get_FixedBackgroundBitmapOrigin virtual HRESULT STDMETHODCALLTYPE get_hBackgroundBitmap(OLE_HANDLE* pValue); /// \brief <em>Sets the \c hBackgroundBitmap property</em> /// /// Sets the handle of the bitmap used as the background for the band. /// /// \param[in] newValue The setting to apply. /// /// \return An \c HRESULT error code. /// /// \sa get_hBackgroundBitmap, put_BackColor, ReBar::put_hPalette, put_FixedBackgroundBitmapOrigin virtual HRESULT STDMETHODCALLTYPE put_hBackgroundBitmap(OLE_HANDLE newValue); /// \brief <em>Retrieves the current setting of the \c hContainedWindow property</em> /// /// Retrieves the handle of the window contained in the band. /// /// \param[out] pValue The property's current setting. /// /// \return An \c HRESULT error code. /// /// \sa put_hContainedWindow, get_MinimumHeight, get_CurrentHeight, get_MaximumHeight, get_MinimumWidth, /// get_CurrentWidth virtual HRESULT STDMETHODCALLTYPE get_hContainedWindow(OLE_HANDLE* pValue); /// \brief <em>Sets the \c hContainedWindow property</em> /// /// Sets the handle of the window contained in the band. /// /// \param[in] newValue The setting to apply. /// /// \return An \c HRESULT error code. /// /// \attention Setting this property to zero hides the previously contained window. However, COM might /// still treat the window as visible, so it's best to explicitly set the contained control's /// \c Visible property to \c False (if it is a COM control) after setting the /// \c hContainedWindow property to zero. To make the control visible after setting the /// \c hContainedWindow property to zero set the control's \c Visible property to \c False /// and then to \c True. /// /// \sa get_hContainedWindow, put_MinimumHeight, put_CurrentHeight, put_MaximumHeight, put_MinimumWidth, /// put_CurrentWidth virtual HRESULT STDMETHODCALLTYPE put_hContainedWindow(OLE_HANDLE newValue); /// \brief <em>Retrieves the current setting of the \c HeightChangeStepSize property</em> /// /// Retrieves the number of pixels by which the band's height can be changed in a single step. If the /// control changes the band's height, the difference between old and new height will be a multiple of /// this value. /// /// \param[out] pValue The property's current setting. /// /// \return An \c HRESULT error code. /// /// \remarks If the \c VariableHeight property is set to \c VARIANT_FALSE, this property is ignored. /// /// \sa put_HeightChangeStepSize, get_MinimumHeight, get_CurrentHeight, get_MaximumHeight, /// get_VariableHeight virtual HRESULT STDMETHODCALLTYPE get_HeightChangeStepSize(OLE_YSIZE_PIXELS* pValue); /// \brief <em>Sets the \c HeightChangeStepSize property</em> /// /// Sets the number of pixels by which the band's height can be changed in a single step. If the /// control changes the band's height, the difference between old and new height will be a multiple of /// this value. /// /// \param[in] newValue The setting to apply. /// /// \return An \c HRESULT error code. /// /// \remarks If the \c VariableHeight property is set to \c VARIANT_FALSE, this property is ignored. /// /// \sa get_HeightChangeStepSize, put_MinimumHeight, put_CurrentHeight, put_MaximumHeight, /// put_VariableHeight virtual HRESULT STDMETHODCALLTYPE put_HeightChangeStepSize(OLE_YSIZE_PIXELS newValue); /// \brief <em>Retrieves the current setting of the \c HideIfVertical property</em> /// /// Retrieves whether the band is visible if the control's orientation is vertical. If set to /// \c VARIANT_TRUE, the band is displayed if the control's orientation is vertical; otherwise it is /// displayed on horizontal orientation only. /// /// \param[out] pValue The property's current setting. /// /// \return An \c HRESULT error code. /// /// \sa put_HideIfVertical, get_Visible, ReBar::get_Orientation virtual HRESULT STDMETHODCALLTYPE get_HideIfVertical(VARIANT_BOOL* pValue); /// \brief <em>Sets the \c HideIfVertical property</em> /// /// Sets whether the band is visible if the control's orientation is vertical. If set to /// \c VARIANT_TRUE, the band is displayed if the control's orientation is vertical; otherwise it is /// displayed on horizontal orientation only. /// /// \param[in] newValue The setting to apply. /// /// \return An \c HRESULT error code. /// /// \sa get_HideIfVertical, put_Visible, ReBar::put_Orientation virtual HRESULT STDMETHODCALLTYPE put_HideIfVertical(VARIANT_BOOL newValue); /// \brief <em>Retrieves the current setting of the \c IconIndex property</em> /// /// Retrieves the zero-based index of the band's icon in the control's \c ilBands image list. If set to /// -2, no icon is displayed for this band. /// /// \param[out] pValue The property's current setting. /// /// \return An \c HRESULT error code. /// /// \if UNICODE /// \sa put_IconIndex, ReBar::get_hImageList, TBarCtlsLibU::ImageListConstants /// \else /// \sa put_IconIndex, ReBar::get_hImageList, TBarCtlsLibA::ImageListConstants /// \endif virtual HRESULT STDMETHODCALLTYPE get_IconIndex(LONG* pValue); /// \brief <em>Sets the \c IconIndex property</em> /// /// Sets the zero-based index of the band's icon in the control's \c ilBands image list. If set to /// -2, no icon is displayed for this band. /// /// \param[in] newValue The setting to apply. /// /// \return An \c HRESULT error code. /// /// \if UNICODE /// \sa get_IconIndex, ReBar::put_hImageList, TBarCtlsLibU::ImageListConstants /// \else /// \sa get_IconIndex, ReBar::put_hImageList, TBarCtlsLibA::ImageListConstants /// \endif virtual HRESULT STDMETHODCALLTYPE put_IconIndex(LONG newValue); /// \brief <em>Retrieves the current setting of the \c ID property</em> /// /// Retrieves an unique ID identifying this band. /// /// \param[out] pValue The property's current setting. /// /// \return An \c HRESULT error code. /// /// \remarks A band's ID will never change.\n /// This property is read-only. /// /// \if UNICODE /// \sa get_Index, TBarCtlsLibU::BandIdentifierTypeConstants /// \else /// \sa get_Index, TBarCtlsLibA::BandIdentifierTypeConstants /// \endif virtual HRESULT STDMETHODCALLTYPE get_ID(LONG* pValue); /// \brief <em>Retrieves the current setting of the \c IdealWidth property</em> /// /// Retrieves the width (in pixels), to which the control tries to resize the band, if it auto-sizes it. /// /// \param[out] pValue The property's current setting. /// /// \return An \c HRESULT error code. /// /// \sa put_IdealWidth, get_MinimumWidth, get_CurrentWidth, Maximize virtual HRESULT STDMETHODCALLTYPE get_IdealWidth(OLE_XSIZE_PIXELS* pValue); /// \brief <em>Sets the \c IdealWidth property</em> /// /// Sets the width (in pixels), to which the control tries to resize the band, if it auto-sizes it. /// /// \param[in] newValue The setting to apply. /// /// \return An \c HRESULT error code. /// /// \sa get_IdealWidth, put_MinimumWidth, put_CurrentWidth, Maximize virtual HRESULT STDMETHODCALLTYPE put_IdealWidth(OLE_XSIZE_PIXELS newValue); /// \brief <em>Retrieves the current setting of the \c Index property</em> /// /// Retrieves the zero-based index identifying this band. /// /// \param[out] pValue The property's current setting. /// /// \return An \c HRESULT error code. /// /// \remarks Although adding or removing bands changes other bands' indexes, the index is the best /// (and fastest) option to identify a band. /// /// \if UNICODE /// \sa put_Index, get_ID, TBarCtlsLibU::BandIdentifierTypeConstants /// \else /// \sa put_Index, get_ID, TBarCtlsLibA::BandIdentifierTypeConstants /// \endif virtual HRESULT STDMETHODCALLTYPE get_Index(LONG* pValue); /// \brief <em>Sets the \c Index property</em> /// /// Sets the zero-based index identifying this band. Setting this property moves the band. /// /// \param[in] newValue The setting to apply. /// /// \return An \c HRESULT error code. /// /// \remarks Although adding or removing bands changes other bands' indexes, the index is the best /// (and fastest) option to identify a band. /// /// \if UNICODE /// \sa get_Index, get_ID, TBarCtlsLibU::BandIdentifierTypeConstants /// \else /// \sa get_Index, get_ID, TBarCtlsLibA::BandIdentifierTypeConstants /// \endif virtual HRESULT STDMETHODCALLTYPE put_Index(LONG newValue); /// \brief <em>Retrieves the current setting of the \c KeepInFirstRow property</em> /// /// Retrieves whether the band is always displayed within the first row. If set to \c VARIANT_TRUE, the /// band is locked to the first row; otherwise not. /// /// \param[out] pValue The property's current setting. /// /// \return An \c HRESULT error code. /// /// \sa put_KeepInFirstRow, get_NewLine, ReBar::get_NumberOfRows virtual HRESULT STDMETHODCALLTYPE get_KeepInFirstRow(VARIANT_BOOL* pValue); /// \brief <em>Sets the \c KeepInFirstRow property</em> /// /// Sets whether the band is always displayed within the first row. If set to \c VARIANT_TRUE, the /// band is locked to the first row; otherwise not. /// /// \param[in] newValue The setting to apply. /// /// \return An \c HRESULT error code. /// /// \sa get_KeepInFirstRow, put_NewLine virtual HRESULT STDMETHODCALLTYPE put_KeepInFirstRow(VARIANT_BOOL newValue); /// \brief <em>Retrieves the current setting of the \c MaximumHeight property</em> /// /// Retrieves the band's maximum height in pixels. The band won't be sized larger than that. /// /// \param[out] pValue The property's current setting. /// /// \return An \c HRESULT error code. /// /// \remarks If the \c VariableHeight property is set to \c VARIANT_FALSE, this property is ignored. /// /// \sa put_MaximumHeight, get_MinimumHeight, get_CurrentHeight, get_HeightChangeStepSize, /// get_MinimumWidth, get_VariableHeight virtual HRESULT STDMETHODCALLTYPE get_MaximumHeight(OLE_YSIZE_PIXELS* pValue); /// \brief <em>Sets the \c MaximumHeight property</em> /// /// Sets the band's maximum height in pixels. The band won't be sized larger than that. /// /// \param[in] newValue The setting to apply. /// /// \return An \c HRESULT error code. /// /// \remarks If the \c VariableHeight property is set to \c VARIANT_FALSE, this property is ignored. /// /// \sa get_MaximumHeight, put_MinimumHeight, put_CurrentHeight, put_HeightChangeStepSize, /// put_MinimumWidth, put_VariableHeight virtual HRESULT STDMETHODCALLTYPE put_MaximumHeight(OLE_YSIZE_PIXELS newValue); /// \brief <em>Retrieves the current setting of the \c MinimumHeight property</em> /// /// Retrieves the band's minimum height in pixels. The band won't be sized smaller than that. /// /// \param[out] pValue The property's current setting. /// /// \return An \c HRESULT error code. /// /// \sa put_MinimumHeight, get_MaximumHeight, get_CurrentHeight, get_HeightChangeStepSize, /// get_MinimumWidth virtual HRESULT STDMETHODCALLTYPE get_MinimumHeight(OLE_YSIZE_PIXELS* pValue); /// \brief <em>Sets the \c MinimumHeight property</em> /// /// Sets the band's minimum height in pixels. The band won't be sized smaller than that. /// /// \param[in] newValue The setting to apply. /// /// \return An \c HRESULT error code. /// /// \sa get_MinimumHeight, put_MaximumHeight, put_CurrentHeight, put_HeightChangeStepSize, /// put_MinimumWidth virtual HRESULT STDMETHODCALLTYPE put_MinimumHeight(OLE_YSIZE_PIXELS newValue); /// \brief <em>Retrieves the current setting of the \c MinimumWidth property</em> /// /// Retrieves the band's minimum width in pixels. The band won't be sized smaller than that. /// /// \param[out] pValue The property's current setting. /// /// \return An \c HRESULT error code. /// /// \sa put_MinimumWidth, get_CurrentWidth, get_MinimumHeight, get_MaximumHeight virtual HRESULT STDMETHODCALLTYPE get_MinimumWidth(OLE_XSIZE_PIXELS* pValue); /// \brief <em>Sets the \c MinimumWidth property</em> /// /// Sets the band's minimum width in pixels. The band won't be sized smaller than that. /// /// \param[in] newValue The setting to apply. /// /// \return An \c HRESULT error code. /// /// \sa get_MinimumWidth, put_CurrentWidth, put_MinimumHeight, put_MaximumHeight virtual HRESULT STDMETHODCALLTYPE put_MinimumWidth(OLE_XSIZE_PIXELS newValue); /// \brief <em>Retrieves the current setting of the \c NewLine property</em> /// /// Retrieves whether the band is displayed in a new row within the control. If set to \c VARIANT_TRUE, /// the band is displayed on a new line; otherwise it is displayed in the same row as the previous band. /// /// \param[out] pValue The property's current setting. /// /// \return An \c HRESULT error code. /// /// \sa put_NewLine, get_KeepInFirstRow, get_IdealWidth, get_CurrentWidth, ReBar::get_NumberOfRows, /// ReBar::Raise_AutoBreakingBand virtual HRESULT STDMETHODCALLTYPE get_NewLine(VARIANT_BOOL* pValue); /// \brief <em>Sets the \c NewLine property</em> /// /// Sets whether the band is displayed in a new row within the control. If set to \c VARIANT_TRUE, /// the band is displayed on a new line; otherwise it is displayed in the same row as the previous band. /// /// \param[in] newValue The setting to apply. /// /// \return An \c HRESULT error code. /// /// \sa get_NewLine, put_KeepInFirstRow, put_IdealWidth, put_CurrentWidth, ReBar::Raise_AutoBreakingBand virtual HRESULT STDMETHODCALLTYPE put_NewLine(VARIANT_BOOL newValue); /// \brief <em>Retrieves the current setting of the \c Resizable property</em> /// /// Retrieves whether the band can be resized by the user. If set to \c VARIANT_TRUE, a sizing grip is /// displayed with which the band can be resized; otherwise no such grip is displayed and the band has a /// fixed size. /// /// \param[out] pValue The property's current setting. /// /// \return An \c HRESULT error code. /// /// \sa put_Resizable, get_SizingGripVisibility, get_IdealWidth, get_CurrentWidth, get_VariableHeight virtual HRESULT STDMETHODCALLTYPE get_Resizable(VARIANT_BOOL* pValue); /// \brief <em>Sets the \c Resizable property</em> /// /// Sets whether the band can be resized by the user. If set to \c VARIANT_TRUE, a sizing grip is /// displayed with which the band can be resized; otherwise no such grip is displayed and the band has a /// fixed size. /// /// \param[in] newValue The setting to apply. /// /// \return An \c HRESULT error code. /// /// \sa get_Resizable, put_SizingGripVisibility, put_IdealWidth, put_CurrentWidth, put_VariableHeight virtual HRESULT STDMETHODCALLTYPE put_Resizable(VARIANT_BOOL newValue); /// \brief <em>Retrieves the current setting of the \c RowHeight property</em> /// /// Retrieves the height in pixels of the row that contains this band. /// /// \param[out] pValue The property's current setting. /// /// \return An \c HRESULT error code. /// /// \remarks This property is read-only. /// /// \sa GetRectangle, ReBar::get_NumberOfRows virtual HRESULT STDMETHODCALLTYPE get_RowHeight(OLE_YSIZE_PIXELS* pValue); /// \brief <em>Retrieves the current setting of the \c ShowTitle property</em> /// /// Retrieves whether the band's caption, which may consist of text and an icon, is displayed. If set to /// \c VARIANT_TRUE, the band's caption is displayed; otherwise not. /// /// \param[out] pValue The property's current setting. /// /// \return An \c HRESULT error code. /// /// \sa put_ShowTitle, get_Text, get_IconIndex, get_TitleWidth virtual HRESULT STDMETHODCALLTYPE get_ShowTitle(VARIANT_BOOL* pValue); /// \brief <em>Sets the \c ShowTitle property</em> /// /// Sets whether the band's caption, which may consist of text and an icon, is displayed. If set to /// \c VARIANT_TRUE, the band's caption is displayed; otherwise not. /// /// \param[in] newValue The setting to apply. /// /// \return An \c HRESULT error code. /// /// \sa get_ShowTitle, put_Text, put_IconIndex, put_TitleWidth virtual HRESULT STDMETHODCALLTYPE put_ShowTitle(VARIANT_BOOL newValue); /// \brief <em>Retrieves the current setting of the \c SizingGripVisibility property</em> /// /// Retrieves when the band's sizing grip is displayed. Any of the values defined by the /// \c SizingGripVisibilityConstants enumeration is valid. /// /// \param[out] pValue The property's current setting. /// /// \return An \c HRESULT error code. /// /// \if UNICODE /// \sa put_SizingGripVisibility, get_Resizable, ReBar::get_HighlightColor, ReBar::get_ShadowColor, /// TBarCtlsLibU::SizingGripVisibilityConstants /// \else /// \sa put_SizingGripVisibility, get_Resizable, ReBar::get_HighlightColor, ReBar::get_ShadowColor, /// TBarCtlsLibA::SizingGripVisibilityConstants /// \endif virtual HRESULT STDMETHODCALLTYPE get_SizingGripVisibility(SizingGripVisibilityConstants* pValue); /// \brief <em>Sets the \c SizingGripVisibility property</em> /// /// Sets when the band's sizing grip is displayed. Any of the values defined by the /// \c SizingGripVisibilityConstants enumeration is valid. /// /// \param[in] newValue The setting to apply. /// /// \return An \c HRESULT error code. /// /// \if UNICODE /// \sa get_SizingGripVisibility, put_Resizable, ReBar::put_HighlightColor, ReBar::put_ShadowColor, /// TBarCtlsLibU::SizingGripVisibilityConstants /// \else /// \sa get_SizingGripVisibility, put_Resizable, ReBar::put_HighlightColor, ReBar::put_ShadowColor, /// TBarCtlsLibA::SizingGripVisibilityConstants /// \endif virtual HRESULT STDMETHODCALLTYPE put_SizingGripVisibility(SizingGripVisibilityConstants newValue); /// \brief <em>Retrieves the current setting of the \c Text property</em> /// /// Retrieves the band's text. The maximum number of characters in this text is specified by /// \c MAX_BANDTEXTLENGTH. /// /// \param[out] pValue The property's current setting. /// /// \return An \c HRESULT error code. /// /// \sa put_Text, ReBarBands::Add, MAX_BANDTEXTLENGTH virtual HRESULT STDMETHODCALLTYPE get_Text(BSTR* pValue); /// \brief <em>Sets the \c Text property</em> /// /// Sets the band's text. The maximum number of characters in this text is specified by /// \c MAX_BANDTEXTLENGTH. /// /// \param[in] newValue The setting to apply. /// /// \return An \c HRESULT error code. /// /// \sa get_Text, ReBarBands::Add, MAX_BANDTEXTLENGTH virtual HRESULT STDMETHODCALLTYPE put_Text(BSTR newValue); /// \brief <em>Retrieves the current setting of the \c TitleWidth property</em> /// /// Retrieves the width (in pixels) of the band's caption, which may consist of text and an icon. If set /// to -1, the caption is sized automatically. /// /// \param[out] pValue The property's current setting. /// /// \return An \c HRESULT error code. /// /// \sa put_TitleWidth, get_ShowTitle, get_Text, get_IconIndex, get_CurrentWidth virtual HRESULT STDMETHODCALLTYPE get_TitleWidth(OLE_XSIZE_PIXELS* pValue); /// \brief <em>Sets the \c TitleWidth property</em> /// /// Sets the width (in pixels) of the band's caption, which may consist of text and an icon. If set /// to -1, the caption is sized automatically. /// /// \param[in] newValue The setting to apply. /// /// \return An \c HRESULT error code. /// /// \sa get_TitleWidth, put_ShowTitle, put_Text, put_IconIndex, put_CurrentWidth virtual HRESULT STDMETHODCALLTYPE put_TitleWidth(OLE_XSIZE_PIXELS newValue); /// \brief <em>Retrieves the current setting of the \c UseChevron property</em> /// /// Retrieves whether a chevron button is displayed if the band's current width is smaller than its ideal /// width. If set to \c VARIANT_TRUE, a chevron button is displayed; otherwise not. /// /// \param[out] pValue The property's current setting. /// /// \return An \c HRESULT error code. /// /// \sa put_UseChevron, get_IdealWidth, get_CurrentWidth, get_ChevronVisible, /// get_ChevronButtonObjectState, GetChevronRectangle, ClickChevron virtual HRESULT STDMETHODCALLTYPE get_UseChevron(VARIANT_BOOL* pValue); /// \brief <em>Sets the \c UseChevron property</em> /// /// Sets whether a chevron button is displayed if the band's current width is smaller than its ideal /// width. If set to \c VARIANT_TRUE, a chevron button is displayed; otherwise not. /// /// \param[in] newValue The setting to apply. /// /// \return An \c HRESULT error code. /// /// \sa get_UseChevron, put_IdealWidth, put_CurrentWidth, get_ChevronVisible, /// get_ChevronButtonObjectState, GetChevronRectangle, ClickChevron virtual HRESULT STDMETHODCALLTYPE put_UseChevron(VARIANT_BOOL newValue); /// \brief <em>Retrieves the current setting of the \c VariableHeight property</em> /// /// Retrieves whether the band's height can be changed by the control. If set to \c VARIANT_TRUE, the /// band's height can be changed according to the settings specified by the \c MinimumHeight, /// \c MaximumHeight and \c HeightChangeStepSize properties; otherwise its height is fixed. /// /// \param[out] pValue The property's current setting. /// /// \return An \c HRESULT error code. /// /// \sa put_VariableHeight, get_MinimumHeight, get_MaximumHeight, get_HeightChangeStepSize, get_Resizable virtual HRESULT STDMETHODCALLTYPE get_VariableHeight(VARIANT_BOOL* pValue); /// \brief <em>Sets the \c VariableHeight property</em> /// /// Sets whether the band's height can be changed by the control. If set to \c VARIANT_TRUE, the /// band's height can be changed according to the settings specified by the \c MinimumHeight, /// \c MaximumHeight and \c HeightChangeStepSize properties; otherwise its height is fixed. /// /// \param[in] newValue The setting to apply. /// /// \return An \c HRESULT error code. /// /// \sa get_VariableHeight, put_MinimumHeight, put_MaximumHeight, put_HeightChangeStepSize, put_Resizable virtual HRESULT STDMETHODCALLTYPE put_VariableHeight(VARIANT_BOOL newValue); /// \brief <em>Retrieves the current setting of the \c Visible property</em> /// /// Retrieves whether the band is visible. If set to \c VARIANT_TRUE, the band will be displayed; /// otherwise not. /// /// \param[out] pValue The property's current setting. /// /// \return An \c HRESULT error code. /// /// \sa put_Visible, Hide, Show, get_ChevronVisible, ReBarBands::Remove, ReBarBands::Add virtual HRESULT STDMETHODCALLTYPE get_Visible(VARIANT_BOOL* pValue); /// \brief <em>Sets the \c Visible property</em> /// /// Sets whether the band is visible. If set to \c VARIANT_TRUE, the band will be displayed; /// otherwise not. /// /// \param[in] newValue The setting to apply. /// /// \return An \c HRESULT error code. /// /// \sa get_Visible, Hide, Show, get_ChevronVisible, ReBarBands::Remove, ReBarBands::Add virtual HRESULT STDMETHODCALLTYPE put_Visible(VARIANT_BOOL newValue); /// \brief <em>Clicks the band's chevron programmatically</em> /// /// Clicks the band's chevron programmatically. The \c ChevronClick event will be raised with the /// \c userData parameter being set to the specified value. /// /// \param[in] userData A \c Long value that will be passed to the \c ChevronClick event handler. /// /// \return An \c HRESULT error code. /// /// \sa get_UseChevron, ReBar::Raise_ChevronClick virtual HRESULT STDMETHODCALLTYPE ClickChevron(LONG userData = 0); /// \brief <em>Retrieves the size of the border around the band</em> /// /// Retrieves the width (in pixels) of the border around the band. /// /// \param[out] pLeftBorder The width (in pixels) of the border on the left of the band. /// \param[out] pTopBorder The height (in pixels) of the border on the top of the band. /// \param[out] pRightBorder The width (in pixels) of the border on the right of the band. /// \param[out] pBottomBorder The height (in pixels) of the border on the bottom of the band. /// /// \return An \c HRESULT error code. /// /// \sa GetRectangle, ReBar::get_DisplayBandSeparators, ReBar::GetMargins virtual HRESULT STDMETHODCALLTYPE GetBorderSizes(OLE_XSIZE_PIXELS* pLeftBorder = NULL, OLE_YSIZE_PIXELS* pTopBorder = NULL, OLE_XSIZE_PIXELS* pRightBorder = NULL, OLE_YSIZE_PIXELS* pBottomBorder = NULL); /// \brief <em>Retrieves the bounding rectangle of the band's chevron button</em> /// /// Retrieves the bounding rectangle (in pixels relative to the control's client area) of the band's /// chevron button. /// /// \param[out] pXLeft The x-coordinate (in pixels) of the bounding rectangle's left border /// relative to the control's upper-left corner. /// \param[out] pYTop The y-coordinate (in pixels) of the bounding rectangle's top border /// relative to the control's upper-left corner. /// \param[out] pXRight The x-coordinate (in pixels) of the bounding rectangle's right border /// relative to the control's upper-left corner. /// \param[out] pYBottom The y-coordinate (in pixels) of the bounding rectangle's bottom border /// relative to the control's upper-left corner. /// /// \return An \c HRESULT error code. /// /// \sa get_UseChevron, GetRectangle virtual HRESULT STDMETHODCALLTYPE GetChevronRectangle(OLE_XPOS_PIXELS* pXLeft = NULL, OLE_YPOS_PIXELS* pYTop = NULL, OLE_XPOS_PIXELS* pXRight = NULL, OLE_YPOS_PIXELS* pYBottom = NULL); /// \brief <em>Retrieves the bounding rectangle of either the band or a part of it</em> /// /// Retrieves the bounding rectangle (in pixels relative to the control's client area) of either the /// band or a part of it. /// /// \param[in] rectangleType The rectangle to retrieve. Any of the values defined by the /// \c BandRectangleTypeConstants enumeration is valid. /// \param[out] pXLeft The x-coordinate (in pixels) of the bounding rectangle's left border /// relative to the control's upper-left corner. /// \param[out] pYTop The y-coordinate (in pixels) of the bounding rectangle's top border /// relative to the control's upper-left corner. /// \param[out] pXRight The x-coordinate (in pixels) of the bounding rectangle's right border /// relative to the control's upper-left corner. /// \param[out] pYBottom The y-coordinate (in pixels) of the bounding rectangle's bottom border /// relative to the control's upper-left corner. /// /// \return An \c HRESULT error code. /// /// \if UNICODE /// \sa GetBorderSizes, GetChevronRectangle, ReBar::GetMargins, /// TBarCtlsLibU::BandRectangleTypeConstants /// \else /// \sa GetBorderSizes, GetChevronRectangle, ReBar::GetMargins, /// TBarCtlsLibA::BandRectangleTypeConstants /// \endif virtual HRESULT STDMETHODCALLTYPE GetRectangle(BandRectangleTypeConstants rectangleType, OLE_XPOS_PIXELS* pXLeft = NULL, OLE_YPOS_PIXELS* pYTop = NULL, OLE_XPOS_PIXELS* pXRight = NULL, OLE_YPOS_PIXELS* pYBottom = NULL); /// \brief <em>Hides the band</em> /// /// \return An \c HRESULT error code. /// /// \sa Show, put_Visible virtual HRESULT STDMETHODCALLTYPE Hide(void); /// \brief <em>Maximizes the band's width</em> /// /// Maximizes the band to either its ideal width as specified by the \c IdealWidth property, or to the /// largest possible width. /// /// \param[in] useIdealWidth If set to \c VARIANT_TRUE, the band is maximized to its ideal width, as /// specified by the \c IdealWidth property; otherwise it is made as large as possible. /// /// \return An \c HRESULT error code. /// /// \sa Minimize, get_IdealWidth, get_CurrentWidth virtual HRESULT STDMETHODCALLTYPE Maximize(VARIANT_BOOL useIdealWidth = VARIANT_TRUE); /// \brief <em>Minimizes the band's width</em> /// /// Minimizes the band to its minimum width as specified by the \c MinimumWidth property. /// /// \return An \c HRESULT error code. /// /// \sa Maximize, get_MinimumWidth, get_IdealWidth, get_CurrentWidth virtual HRESULT STDMETHODCALLTYPE Minimize(void); /// \brief <em>Unhides the band</em> /// /// \return An \c HRESULT error code. /// /// \sa Hide, put_Visible virtual HRESULT STDMETHODCALLTYPE Show(void); //@} ////////////////////////////////////////////////////////////////////// /// \brief <em>Attaches this object to a given band</em> /// /// Attaches this object to a given band, so that the band's properties can be retrieved and set /// using this object's methods. /// /// \param[in] bandIndex The band to attach to. /// /// \sa Detach void Attach(int bandIndex); /// \brief <em>Detaches this object from a band</em> /// /// Detaches this object from the band it currently wraps, so that it doesn't wrap any band anymore. /// /// \sa Attach void Detach(void); /// \brief <em>Sets this object's properties to given values</em> /// /// Applies the settings from a given source to the band wrapped by this object. /// /// \param[in] pSource The data source from which to copy the settings. /// /// \return An \c HRESULT error code. /// /// \sa SaveState HRESULT LoadState(LPREBARBANDINFO pSource); /// \brief <em>Sets this object's properties to given values</em> /// /// \overload HRESULT LoadState(VirtualReBarBand* pSource); /// \brief <em>Writes this object's settings to a given target</em> /// /// \param[in] pTarget The target to which to copy the settings. /// \param[in] hWndRBar The rebar window the method will work on. /// /// \return An \c HRESULT error code. /// /// \sa LoadState HRESULT SaveState(LPREBARBANDINFO pTarget, HWND hWndRBar = NULL); /// \brief <em>Writes this object's settings to a given target</em> /// /// \overload HRESULT SaveState(VirtualReBarBand* pTarget); /// \brief <em>Sets the owner of this band</em> /// /// \param[in] pOwner The owner to set. /// /// \sa Properties::pOwnerRBar void SetOwner(__in_opt ReBar* pOwner); protected: /// \brief <em>Holds the object's properties' settings</em> struct Properties { /// \brief <em>The \c ReBar object that owns this band</em> /// /// \sa SetOwner ReBar* pOwnerRBar; /// \brief <em>The index of the band wrapped by this object</em> int bandIndex; Properties() { pOwnerRBar = NULL; bandIndex = -1; } ~Properties(); /// \brief <em>Retrieves the owning rebar's window handle</em> /// /// \return The window handle of the rebar that contains this band. /// /// \sa pOwnerRBar HWND GetRBarHWnd(void); } properties; /// \brief <em>Writes a given object's settings to a given target</em> /// /// \param[in] bandIndex The band for which to save the settings. /// \param[in] pTarget The target to which to copy the settings. /// \param[in] hWndRBar The rebar window the method will work on. /// /// \return An \c HRESULT error code. /// /// \sa LoadState HRESULT SaveState(int bandIndex, LPREBARBANDINFO pTarget, HWND hWndRBar = NULL); }; // ReBarBand OBJECT_ENTRY_AUTO(__uuidof(ReBarBand), ReBarBand)
42.922625
220
0.710684
[ "object" ]
b4f103cf16c1ccf782632147da9880f22f2b1c83
10,003
h
C
src/BTC/connection.h
eXtremal-ik7/bcnode
ed96fea41a093231173656d65c2cc234fe5165f5
[ "MIT" ]
1
2020-06-20T21:00:20.000Z
2020-06-20T21:00:20.000Z
src/BTC/connection.h
eXtremal-ik7/bcnode
ed96fea41a093231173656d65c2cc234fe5165f5
[ "MIT" ]
null
null
null
src/BTC/connection.h
eXtremal-ik7/bcnode
ed96fea41a093231173656d65c2cc234fe5165f5
[ "MIT" ]
1
2022-02-13T17:09:35.000Z
2022-02-13T17:09:35.000Z
#include "BC/bc.h" #include <asyncio/asyncio.h> #include "asyncio/socket.h" #include <asyncioextras/btc.h> #include <p2putils/xmstream.h> #include <chrono> #include <functional> #include <map> #include <unordered_map> namespace BC { namespace Network { template<typename Handler> class Connection { public: Connection(Handler &handler, asyncBase *base, HostAddress address, uint32_t magic) : Handler_(handler), Base_(base), Address_(address) { socketTy socketFd = socketCreate(AF_INET, SOCK_STREAM, IPPROTO_TCP, 1); HostAddress localAddress; localAddress.family = AF_INET; localAddress.ipv4 = INADDR_ANY; localAddress.port = 0; if (socketBind(socketFd, &localAddress) != 0) { socketClose(socketFd); return; } aioObject *object = newSocketIo(base, socketFd); Socket_ = btcSocketNew(base, object); btcSocketSetMagic(Socket_, magic); } void start() { aioConnect(btcGetPlainSocket(Socket_), &Address_, 5*1000000, onConnectCb, this); } void close() { btcSocketDelete(Socket_); } void ping() { char buffer[1024]; xmstream localStream(buffer, sizeof(buffer)); localStream.reset(); uint64_t nonce = rand(); PingMap_[nonce] = std::chrono::steady_clock::now(); BC::Proto::MessagePing ping; ping.nonce = nonce; BC::serialize(localStream, ping); sendMessage(MessageTy::ping, localStream.data(), localStream.sizeOf()); } void getaddr() { sendMessage(MessageTy::getaddr, nullptr, 0); } uint32_t startHeight() { return StartHeight_; } const std::string &userAgent() { return UserAgent_; } private: static void onConnectCb(AsyncOpStatus status, aioObject*, void *arg) { static_cast<Connection*>(arg)->onConnect(status); } static void onMessageCb(AsyncOpStatus status, BTCSocket*, char*, xmstream*, void *arg) { static_cast<Connection*>(arg)->onMessage(status); } private: enum class MessageTy : unsigned { unknown = 0, addr, block, getaddr, getblocks, getdata, getheaders, headers, inv, ping, pong, reject, verack, version, last }; template<typename Msg, typename Fn> inline bool callHandler(const char *cmd, Fn proc) { Msg data; if (unserializeAndCheck(ReceiveStream_, data)) { aioBtcRecv(Socket_, Command_, ReceiveStream_, Limit_, afNone, 0, onMessageCb, this); std::invoke(proc, *this, data); return true; } else { Handler_.onInvalidMessageFormat(this, cmd); return false; } } template<typename Fn> inline bool callHandlerEmpty(Fn proc) { aioBtcRecv(Socket_, Command_, ReceiveStream_, Limit_, afNone, 0, onMessageCb, this); std::invoke(proc, *this); return true; } static constexpr const char *messageName(MessageTy type) { constexpr const char *names[] = { "unknown", "addr", "block", "getaddr", "getblocks", "getdata", "getheaders", "headers", "inv", "ping", "pong", "reject", "verack", "version" }; return names[static_cast<unsigned>(type)]; } std::unordered_map<std::string, MessageTy> MessageTypeMap_ = { {"addr", Connection::MessageTy::addr}, {"block", Connection::MessageTy::block}, {"getaddr", Connection::MessageTy::getaddr}, {"getblocks", Connection::MessageTy::getblocks}, {"getdata", Connection::MessageTy::getdata}, {"getheaders", Connection::MessageTy::getheaders}, {"headers", Connection::MessageTy::headers}, {"inv", Connection::MessageTy::inv}, {"ping", Connection::MessageTy::ping}, {"pong", Connection::MessageTy::pong}, {"reject", Connection::MessageTy::reject}, {"verack", Connection::MessageTy::verack}, {"version", Connection::MessageTy::version} }; void sendMessage(MessageTy type, void *data, size_t size) { aioBtcSend(Socket_, messageName(type), data, size, afNone, 0, nullptr, nullptr); } void onConnect(AsyncOpStatus status) { if (status != aosSuccess) { btcSocketDelete(Socket_); Handler_.onDisconnect(this); return; } // Send version message BC::Proto::MessageVersion msg; msg.version = BC::Configuration::ProtocolVersion; msg.services = 1; // NODE msg.timestamp = static_cast<uint64_t>(time(nullptr)); msg.addr_recv.services = 0; msg.addr_recv.setIpv4(0); msg.addr_recv.port = 0; msg.addr_from.services = 0; // NODE msg.addr_from.reset(); msg.addr_from.port = 0; msg.nonce = rand(); msg.user_agent = BC::Configuration::UserAgent; msg.start_height = 1; msg.relay = 1; char buffer[1024]; xmstream localStream(buffer, sizeof(buffer)); localStream.reset(); BC::serialize(localStream, msg); sendMessage(MessageTy::version, localStream.data(), localStream.sizeOf()); aioBtcRecv(Socket_, Command_, ReceiveStream_, Limit_, afNone, ConnectTimeout_, onMessageCb, this); } void onMessage(AsyncOpStatus status) { if (status != aosSuccess) { btcSocketDelete(Socket_); Handler_.onDisconnect(this); return; } MessageTy command = MessageTypeMap_[Command_]; bool result = true; switch (command) { // "real time" operations case MessageTy::addr : result = callHandler<BC::Proto::MessageAddr>("addr", &Connection::onAddr); break; case MessageTy::getaddr : result = callHandlerEmpty(&Connection::onGetAddr); break; case MessageTy::getheaders : result = callHandler<BC::Proto::MessageGetHeaders>("getheaders", &Connection::onGetHeaders); break; case MessageTy::inv : result = callHandler<BC::Proto::MessageInv>("inv", &Connection::onInv); break; case MessageTy::ping : result = callHandler<BC::Proto::MessagePing>("ping", &Connection::onPing); break; case MessageTy::pong : result = callHandler<BC::Proto::MessagePong>("pong", &Connection::onPong); break; case MessageTy::reject : result = callHandler<BC::Proto::MessageReject>("reject", &Connection::onReject); break; case MessageTy::verack : result = callHandlerEmpty(&Connection::onVerack); break; case MessageTy::version : result = callHandler<BC::Proto::MessageVersion>("version", &Connection::onVersion); break; // Heavy operations case MessageTy::getblocks : result = callHandler<BC::Proto::MessageGetBlocks>("getblocks", &Connection::onGetBlocks); break; case MessageTy::getdata : result = callHandler<BC::Proto::MessageGetData>("getdata", &Connection::onGetData); break; // Special handlers case MessageTy::block : result = callHandler<BC::Proto::MessageBlock>("block", &Connection::onBlock); break; case MessageTy::headers : result = callHandler<BC::Proto::MessageHeaders>("headers", &Connection::onHeaders); break; default : Handler_.onUnknownMessage(this, Command_); aioBtcRecv(Socket_, Command_, ReceiveStream_, Limit_, afNone, 0, onMessageCb, this); break; } if (!result) { btcSocketDelete(Socket_); Handler_.onDisconnect(this); } } void onAddr(BC::Proto::MessageAddr &addr) { Handler_.onAddr(this, addr); } void onGetAddr() { Handler_.onGetAddr(this); } void onGetHeaders(BC::Proto::MessageGetHeaders &getheaders) { Handler_.onGetHeaders(this, getheaders); } void onInv(BC::Proto::MessageInv &inv) { Handler_.onInv(this, inv); } void onPing(BC::Proto::MessagePing &ping) { char buffer[1024]; xmstream localStream(buffer, sizeof(buffer)); localStream.reset(); BC::Proto::MessagePong pong; pong.nonce = ping.nonce; BC::serialize(localStream, pong); sendMessage(MessageTy::pong, localStream.data(), localStream.sizeOf()); Handler_.onPing(this); } void onPong(BC::Proto::MessagePong &pong) { auto It = PingMap_.find(pong.nonce); if (It != PingMap_.end()) { auto pingTime = It->second; auto now = std::chrono::steady_clock::now(); PingMap_.erase(It); Handler_.onPong(this, std::chrono::duration_cast<std::chrono::milliseconds>(now - pingTime).count()); } } void onReject(BC::Proto::MessageReject &reject) { Handler_.onReject(this, reject); } void onVerack() { VerackReceived_ = true; if (!IsConnected_ && (VersionReceived_ & VerackReceived_)) { IsConnected_ = true; Handler_.onConnect(this); ping(); } } void onVersion(BC::Proto::MessageVersion &version) { StartHeight_ = version.start_height; ProtocolVersion_ = version.version; Services_ = version.services; UserAgent_ = version.user_agent; VersionReceived_ = true; if (!IsConnected_ && (VersionReceived_ & VerackReceived_)) { IsConnected_ = true; Handler_.onConnect(this); ping(); } sendMessage(MessageTy::verack, nullptr, 0); } void onGetBlocks(BC::Proto::MessageGetBlocks &getblocks) { Handler_.onGetBlocks(this, getblocks); } void onGetData(BC::Proto::MessageGetData &getdata) { Handler_.onGetData(this, getdata); } void onBlock(BC::Proto::MessageBlock &block) { Handler_.onBlock(this, block); } void onHeaders(BC::Proto::MessageHeaders &headers) { Handler_.onHeaders(this, headers); } private: Handler &Handler_; asyncBase *Base_; HostAddress Address_; BTCSocket *Socket_; char Command_[12]; xmstream ReceiveStream_; bool VersionReceived_ = false; bool VerackReceived_ = false; bool IsConnected_ = false; uint32_t StartHeight_ = 0; uint32_t ProtocolVersion_ = 0; uint64_t Services_ = 0; std::string UserAgent_; std::map<uint64_t, std::chrono::time_point<std::chrono::steady_clock>> PingMap_; static constexpr size_t Limit_ = 67108864; // 64Mb static constexpr uint64_t ConnectTimeout_ = 5*1000000; }; } }
28.33711
142
0.655803
[ "object" ]
b4ffbb170b953f287f9b1aadd43d25ae72efeac5
362
h
C
source/Scene.h
narbys/SoftwareRaytracer
a40894a4900558c77f5ae7fd47fe4a203ae64c48
[ "Unlicense" ]
1
2021-09-29T14:37:33.000Z
2021-09-29T14:37:33.000Z
source/Scene.h
narbys/SoftwareRaytracer
a40894a4900558c77f5ae7fd47fe4a203ae64c48
[ "Unlicense" ]
null
null
null
source/Scene.h
narbys/SoftwareRaytracer
a40894a4900558c77f5ae7fd47fe4a203ae64c48
[ "Unlicense" ]
null
null
null
#pragma once #include <vector> #include "Object.h" #include "Light.h" class Scene { public: Scene(); ~Scene(); void AddObject(Object* pObj); void AddLight(Light* pLight); const std::vector<Object*>& GetObjectsInScene() const; const std::vector<Light*>& GetLightsInScene() const; private: std::vector<Object*> m_pObjects; std::vector<Light*> m_pLights; };
21.294118
55
0.71547
[ "object", "vector" ]
331a2cd85e95da1f903842dc9d30761fd409eb54
3,224
h
C
MMOCoreORB/src/server/zone/objects/creature/commands/StrangulationCommand.h
V-Fib/FlurryClone
40e0ca7245ec31b3815eb6459329fd9e70f88936
[ "Zlib", "OpenSSL" ]
18
2017-02-09T15:36:05.000Z
2021-12-21T04:22:15.000Z
MMOCoreORB/src/server/zone/objects/creature/commands/StrangulationCommand.h
V-Fib/FlurryClone
40e0ca7245ec31b3815eb6459329fd9e70f88936
[ "Zlib", "OpenSSL" ]
61
2016-12-30T21:51:10.000Z
2021-12-10T20:25:56.000Z
MMOCoreORB/src/server/zone/objects/creature/commands/StrangulationCommand.h
V-Fib/FlurryClone
40e0ca7245ec31b3815eb6459329fd9e70f88936
[ "Zlib", "OpenSSL" ]
71
2017-01-01T05:34:38.000Z
2022-03-29T01:04:00.000Z
/* Copyright <SWGEmu> See file COPYING for copying conditions.*/ #ifndef STRANGULATIONCOMMAND_H_ #define STRANGULATIONCOMMAND_H_ #include "server/zone/objects/scene/SceneObject.h" #include "server/zone/objects/creature/commands/CombatQueueCommand.h" class StrangulationCommand : public CombatQueueCommand { public: StrangulationCommand(const String& name, ZoneProcessServer* server) : CombatQueueCommand(name, server) { } int doQueueCommand(CreatureObject* creature, const uint64& target, const UnicodeString& arguments) const { if (!checkStateMask(creature)) return INVALIDSTATE; if (!checkInvalidLocomotions(creature)) return INVALIDLOCOMOTION; ManagedReference<WeaponObject*> weapon = creature->getWeapon(); if (!weapon->isRangedWeapon()) { return INVALIDWEAPON; } CreatureObject* player = cast<CreatureObject*>(creature); ZoneServer* zserv = creature->getZoneServer(); PlayerObject* jedi = creature->getPlayerObject(); // Fail if target is not a player... ManagedReference<SceneObject*> object = server->getZoneServer()->getObject(target); if (object == NULL || !object->isCreatureObject()) return INVALIDTARGET; CreatureObject* creatureTarget = cast<CreatureObject*>( object.get()); PlayerManager* playerManager = server->getPlayerManager(); if (creature != creatureTarget && !CollisionManager::checkLineOfSight(creature, creatureTarget)) { creature->sendSystemMessage("You do not have a clear line of sight to the target."); return INVALIDTARGET; } if (!creature->checkCooldownRecovery("strangulation")) { StringIdChatParameter stringId; Time* cdTime = creature->getCooldownTime("strangulation"); // Returns -time. Multiple by -1 to return positive. int timeLeft = floor((float)cdTime->miliDifference() / 1000) *-1; stringId.setStringId("@innate:equil_wait"); // You are still recovering from your last equilization. Command available in %DI seconds. stringId.setDI(timeLeft); creature->sendSystemMessage(stringId); return GENERALERROR; } if (creatureTarget == NULL) return INVALIDTARGET; Locker clocker(creatureTarget, creature); ManagedReference<PlayerObject*> targetGhost = creatureTarget->getPlayerObject(); ManagedReference<PlayerObject*> playerObject = creature->getPlayerObject(); if (targetGhost == NULL || playerObject == NULL) return GENERALERROR; if (creature->getDistanceTo(creatureTarget) > 10.f){ creature->sendSystemMessage("You are out of range."); return GENERALERROR;} if (creatureTarget->isRidingMount()) { creature->sendSystemMessage("you cannot knockdown a player while they are mounted"); return GENERALERROR; } if (object->isCreatureObject() && creatureTarget->isAttackableBy(creature)) { creatureTarget->setState(CreatureState::PEACE); creatureTarget->playEffect("clienteffect/npe_smoke_bomb.cef", ""); creatureTarget->sendSystemMessage("You have been choked into submission."); creature->setState(CreatureState::PEACE); creature->addCooldown("strangulation", 300 * 1000); } creature->clearQueueActions(); CombatManager::instance()->attemptPeace(creature); return SUCCESS; } }; #endif //STRANGULATIONCOMMAND_H_
30.415094
137
0.745658
[ "object" ]
333d6a541152e33cabb52fbbafddd2960486fd27
10,948
c
C
src/starfitter.c
cosrayjamie/starfitter
cdede69616b4a36997eacdae60f015257c743afc
[ "CC0-1.0" ]
1
2019-04-02T01:30:12.000Z
2019-04-02T01:30:12.000Z
src/starfitter.c
cosrayjamie/starfitter
cdede69616b4a36997eacdae60f015257c743afc
[ "CC0-1.0" ]
1
2019-04-01T18:56:34.000Z
2019-04-01T18:56:34.000Z
src/starfitter.c
cosrayjamie/starfitter
cdede69616b4a36997eacdae60f015257c743afc
[ "CC0-1.0" ]
null
null
null
/* Starfit.c - Stan Thomas 08-16-2011 Routine for photographic surveying. ---------------------------------------------------------------------------- ---------------------------------------------------------------------------- */ #include <stdio.h> #include <stdlib.h> #include <math.h> #include <time.h> #include <string.h> #include "starfitter.h" #include "nrutil.h" void print_chi2(float x[]); int reject_star(float x[]); VECTOR s[NSTARS]; double xmeas[NSTARS], ymeas[NSTARS]; double sigmax[NSTARS], sigmay[NSTARS]; char sname[NSTARS][12]; const int MAXMIR[NSITES] = { 28, 11, 11,8}; const int MINMIR[NSITES] = { 1, 0, 0,1}; #ifdef TAx4 const double CUTX[NSITES] = {12.691, 19.0e0, 19.0e0, 12.691}; // Cut on x position const double CUTY[NSITES] = {11.174, 16.0e0, 16.0e0, 11.174}; // Cut on y position #else const double CUTX[NSITES] = {11.5e0, 19.0e0, 19.0e0, 11.5e0}; // Cut on x position const double CUTY[NSITES] = {10.7e0, 16.0e0, 16.0e0,10.7e0 }; // Cut on y position #endif const double CUTD = 0.5e0; // Absolute cut on initial error double azi[NSITES][NMIRS]; // Cluster azimuth angle double elev[NSITES][NMIRS]; // Cluster elevation angle double rot[NSITES][NMIRS]; // Cluster rotation angle double mcd[NSITES][NMIRS]; // Mirror-cluster distances (meters) double Rmir[NSITES][NMIRS]; // Mirror radius of curvature (meters) int Nstars; int main(int argc, char *argv[]) { FILE *fp, *op; double parms[NPARMS]; int i; double stheta, sphi; double xstar, ystar; double theta, phi, psi, x0, y0, D0; float x[NSTARS+1]; double chi2min; char buffer[1025]; int site, mir, year, month, day, hour, minutes, exposure; double seconds, delta; int iter; int Nstars0 = 0; srand48(time(NULL)); //check if too few arguments were given if(argc<2) { fprintf(stderr,"Usage: %s <*.stars.txt>\7\7\n", argv[0]); exit(-1); } //open the given .stars.txt file if((fp=fopen(argv[1],"r"))==NULL) { fprintf(stderr,"Unable to open %s\7\7\n", argv[1]); exit(-1); } //open the mirror_geometry.dat file if((op=fopen("mirror_geometry.dat","r"))==NULL) { fprintf(stderr,"Unable to open mirror_geometry.dat\7\7\n"); exit(-1); } //read in the mirror_geometry.dat file while(fgets(buffer,1023,op)!=NULL) { //read in the site and mirror numbers if(sscanf(buffer,"%d %d", &site, &mir) != 2) { fprintf(stderr,"Error reading mirror_geometry.dat\7\7\n"); exit(-1); } //read in mirror information if(sscanf(buffer,"%*d %*d %lf %lf %lf %lf %lf", &azi[site][mir], &elev[site][mir], &rot[site][mir], &mcd[site][mir], &Rmir[site][mir])!=5) { fprintf(stderr,"Error reading mirror_geometry.dat\7\7\n"); exit(-1); } } fclose(op); //correct the azimuth angle for(site=0;site<NSITES;site++) { for(mir=0;mir<NMIRS;mir++) { azi[site][mir] = 90.0e0 - azi[site][mir]; if(azi[site][mir] < 0.0e0)azi[site][mir] += 360.0e0; } } //read in the .stars.txt file Nstars = 0; while(fgets(buffer,1023,fp)!=NULL) { //read in star information if(sscanf(buffer," %d %d %d/%d/%d %d:%d:%lf %d %s %lf %lf %lf %lf %lf %lf %lf", &site, &mir, &year, &month, &day, &hour, &minutes, &seconds, &exposure, sname[Nstars], &stheta, &sphi, &xstar, &ystar, &xmeas[Nstars], &ymeas[Nstars], &delta) != 17)continue; site = site-1; //check if site number is wrong if((site<0)||(site>NSITES)) { fprintf(stderr,"Invalid site number\7\7\n"); exit(-1); } //check if mirror number is wrong if((mir<MINMIR[site])||(mir>MAXMIR[site])) { fprintf(stderr,"Invalid mirror number\7\7\n"); exit(-1); } //convert angles to radians stheta *= D2R; sphi *= D2R; //compute star normal vector in east/north/up basis s[Nstars].e = cos(stheta)*cos(sphi); s[Nstars].n = cos(stheta)*sin(sphi); s[Nstars].u = sin(stheta); sigmax[Nstars] = 0.081e0; sigmay[Nstars] = 0.081e0; // Apply quality cuts to throw out stars that are likely to have been poorly measured. // This includes stars that are too close to the edge of the cameras. If part of the // spot is cut off at the edge of the mirror it will cause the centroid to be mis-measured. // These cuts were determined by looking at the residuals in the data. // The cut on delta was determined by looking at the delta distribution for all stars and // all mirrors. Hopefully, this will help to throw out stars where the centroid was mis-measured // because they are partially darkened by Tom's wooden support bars. if(fabs(xstar)>CUTX[site])continue; if(fabs(ystar)>CUTY[site])continue; if(fabs(xmeas[Nstars])>CUTX[site])continue; if(fabs(ymeas[Nstars])>CUTY[site])continue; if(fabs(delta)>CUTD)continue; Nstars++; } fclose(fp); //check if there are enough stars to preform a fit if(Nstars<NPARMS+1) { fprintf(stderr,"Insufficient stars N = %d found.\7\7\n", Nstars); exit(-1); } //set up free parameters and fixed parameters parms[0] = theta = elev[site][mir]*D2R; parms[1] = phi = azi[site][mir]*D2R; parms[2] = psi = drand48()-0.5e0; x0 = 0.0e0; //parms[3] = x0 = drand48()-0.5e0; y0 = 0.0e0; //parms[4] = y0 = drand48()-0.5e0; parms[3] = D0 = (Rmir[site][mir] - mcd[site][mir])*100.0e0/2.54e0; for(i=0;i<NPARMS;i++)x[i+1] = (float)parms[i]; //save fit parameters for(iter=0;iter<100;iter++) { Nstars0 = Nstars; //check if there are enough stars to run the fit if(Nstars<NPARMS+1) { fprintf(stderr,"Insufficient stars N = %d found.\7\7\n", Nstars); exit(-1); } //construct the chi2 function and minimize chi2min = fit_func(NPARMS, parms, chi2_func); //printf("chi2min = %.03f\n",chi2min); for(i=0;i<NPARMS;i++)x[i+1] = (float)parms[i]; //save minimum parameters //check if any stars were rejected. If so repeat. if(Nstars0 == reject_star(x))break; } //run mimimization a few more time with only the good stars for(iter=0;iter<4;iter++) { if(Nstars<NPARMS+1) { fprintf(stderr,"Insufficient stars N = %d found.\7\7\n", Nstars); exit(-1); } chi2min = fit_func(NPARMS, parms, chi2_func); //printf("chi2min = %.03f\n",chi2min); for(i=0;i<NPARMS;i++)x[i+1] = (float)parms[i]; } //convert results to degrees theta = parms[0]*R2D; phi = 90.0e0 - parms[1]*R2D; if(phi<0.0e0)phi += 360.0e0; psi = parms[2]*R2D; x0 = 0.0e0; //x0 = parms[3]; y0 = 0.0e0; //y0 = parms[4]; D0 = parms[3]; //save final updated parameters for(i=0;i<NPARMS;i++)x[i+1] = (float)parms[i]; //print the minimized chi2 value print_chi2(x); //print out the fit results printf("\n\n%d %d ", site, mir); printf("%.3lf ", phi); printf("%.3lf ", theta); printf("%.3lf ", psi); // printf("%.3lf ", x0); // printf("%.3lf ", y0); printf("%.3lf ", mcd[site][mir]); printf("%.3lf ", mcd[site][mir]+D0*2.54e0/100.0e0); printf("%d ", Nstars); printf("%.8lf\n", chi2min); fflush(stdout); return 0; } int reject_star(float x[]) { double derr, xstar, ystar; int i, itmp, ierr = (-1); double maxderr = 0.0e0; //if too few stars don't do anything if(Nstars<NPARMS+1)return Nstars; //find worst error star for(i=0;i<Nstars;i++) { //find star position starpos(i, &xstar, &ystar, x); //compute error derr = pow(xmeas[i] - xstar,2.0e0); derr += pow(ymeas[i] - ystar,2.0e0); derr = sqrt(derr); //record error if bigger then last biggest error if(derr>maxderr) { maxderr = derr; ierr = i; } } // Reject the worst star if the error is greater than 0.235" if(maxderr>0.235e0) { //replace rejected star with the star at the end of the list. Next run will check up to one less then the number checked previously. xmeas[ierr] = xmeas[Nstars-1]; ymeas[ierr] = ymeas[Nstars-1]; s[ierr].e = s[Nstars-1].e; s[ierr].n = s[Nstars-1].n; s[ierr].u = s[Nstars-1].u; sigmax[ierr] = sigmax[Nstars-1]; sigmay[ierr] = sigmay[Nstars-1]; strcpy(sname[ierr], sname[Nstars-1]); Nstars--; fprintf(stderr,"Rejected star\n"); } return Nstars; } void print_chi2(float x[]) { double chi2, xstar, ystar; int i; if(Nstars<NPARMS+1)return; for(i=0;i<Nstars;i++) { starpos(i, &xstar, &ystar, x); chi2 = pow((xmeas[i] - xstar)/sigmax[i],2.0e0); chi2 += pow((ymeas[i] - ystar)/sigmay[i],2.0e0); printf("%d %.3lf %.3lf %.3lf %.3lf %lf\n", i+1, xmeas[i], ymeas[i], xstar, ystar, chi2); } return; } float chi2_func(float x[]) { double chi2, xstar, ystar; int i; if(Nstars<NPARMS+1)return 1.0e0; chi2 = 0.0e0; for(i=0;i<Nstars;i++) { starpos(i, &xstar, &ystar, x); chi2 += pow((xmeas[i] - xstar)/sigmax[i],2.0e0); chi2 += pow((ymeas[i] - ystar)/sigmay[i],2.0e0); } chi2 /= (double)(2*Nstars-NPARMS); return (float)chi2; } double fit_func(int N, double param[], float (*funk)(float [])) { int i, j, imin, nfunc; float *x, *y, **p; double fval; // Allocate memory x = (float *)vector(1,N); y = (float *)vector(1,N+1); p = (float **)matrix(1,N+1,1,N); // Set initial simplex values from the passed values of the parameters for(i=1;i<=N+1;i++) { for(j=1;j<=N;j++) { x[j] = p[i][j] = (float)(param[j-1]*(1.0e0+(0.5e0-drand48())/10000.0e0)); } y[i] = funk(x); } // Use amoeba to minimize nfunc = N+1; // Number of function evaluations amoeba(p, y, N, 1.0e-14, funk, &nfunc); // Find the minimum vertex imin = 1; for(i=2;i<=N+1;i++)if(y[i]<y[imin])imin = i; fval = (double)y[imin]; // Set the parameters to the minimum values for(i=1;i<=N;i++)param[i-1] = (double)p[imin][i]; // Free allocated memory free_matrix(p,1,N+1,1,N); free_vector(y,1,N+1); free_vector(x,1,N); // Return the minimum function value return fval; } void starpos(int istar, double *xstar, double *ystar, float x[]) { VECTOR m, xp, yp; double theta, phi, psi, x0, y0, D0; theta = (double)x[1]; phi = (double)x[2]; psi = (double)x[3]; x0 = 0.0e0; //x0 = (double)x[4]; y0 = 0.0e0; //y0 = (double)x[5]; D0 = (double)x[4]; m.e = cos(theta)*cos(phi); m.n = cos(theta)*sin(phi); m.u = sin(theta); xp.e = cos(psi)*sin(phi) - sin(psi)*sin(theta)*cos(phi); xp.n = -(cos(psi)*cos(phi) + sin(psi)*sin(theta)*sin(phi)); xp.u = sin(psi)*cos(theta); yp.e = -(sin(psi)*sin(phi) + cos(psi)*sin(theta)*cos(phi)); yp.n = sin(psi)*cos(phi) - cos(psi)*sin(theta)*sin(phi); yp.u = cos(psi)*cos(theta); *xstar = D0*dot(s[istar],xp)/dot(s[istar],m)+x0; *ystar = D0*dot(s[istar],yp)/dot(s[istar],m)+y0; return; }
27.09901
139
0.58586
[ "vector" ]
33418160c132221165dc17c951d086ec8e19b3c2
2,842
h
C
Algorithms/MatchedFilter/WorkRequest.h
jwillemsen/sidecar
941d9f3b84d05ca405df1444d4d9fd0bde03887f
[ "MIT" ]
null
null
null
Algorithms/MatchedFilter/WorkRequest.h
jwillemsen/sidecar
941d9f3b84d05ca405df1444d4d9fd0bde03887f
[ "MIT" ]
null
null
null
Algorithms/MatchedFilter/WorkRequest.h
jwillemsen/sidecar
941d9f3b84d05ca405df1444d4d9fd0bde03887f
[ "MIT" ]
null
null
null
#ifndef SIDECAR_ALGORITHMS_MATCHEDFILTER_WORKREQUEST_H // -*- C++ -*- #define SIDECAR_ALGORITHMS_MATCHEDFILTER_WORKREQUEST_H #include <complex> #include <vector> #include "ace/Message_Block.h" #include "ace/Message_Queue_T.h" #include "boost/scoped_ptr.hpp" #include <vsip/matrix.hpp> #include <vsip/vector.hpp> #include "Messages/Video.h" #include "MatchedFilterTypes.h" namespace SideCar { namespace Algorithms { namespace MatchedFilterUtils { /** Collection of data values that will be used for a windowed SLC processing. Encapsulates the values that must not change while in use by a thread. */ class WorkRequest { public: /** Obtain the log device for WorkRequest objects \return Logger::Log reference */ static Logger::Log& Log(); /** Create a new WorkRequest object with memory provided by an ACE_Message_Block. \param enabledSize \param corrSpan \return */ static ACE_Message_Block* Make(VsipComplexVector* txPulseVec, int numFFTThreads, int fftSize); /** Dispose of the WorkRequest object held within an ACE_Message_Block, and release the ACE_Message_Block memory. \param data */ static void Destroy(ACE_Message_Block* data); /** Class method that returns a WorkRequest pointer from an ACE_Message_Block pointer. \param data ACE_Message_Block holding the WorkRequest data \return WorkRequest pointer */ static WorkRequest* FromMessageBlock(ACE_Message_Block* data); /** Reconfigure the work request with new values. Reallocates some VSIPL objects. */ void reconfigure(VsipComplexVector* txPulseVec, int numFFTThreads, int fftSize); /** Initialize a new work request \param name the name of the algorithm \param filterStart the first sample to filter \param filterSpan the numbe of samples to filter \param main the main message to process */ void beginRequest(const Messages::Video::Ref& input, const Messages::Video::Ref& output, size_t offset); /** Perform the work on the given data. */ void process(); private: /** Consturctor. Use the Make() factory method to create new WorkRequest objects. */ WorkRequest(VsipComplexVector* txPulseVec, int numFFTThreads, int fftSize); /** Destructor. Here to keep someone from manually deleting a WorkRequest object; use the Destroy() class method instead. */ ~WorkRequest(); VsipComplexVector* txPulseVec_; int fftSize_; Messages::Video::Ref input_; Messages::Video::Ref output_; size_t offset_; boost::scoped_ptr<VsipComplexVector> rxVec_; boost::scoped_ptr<FwdFFT> fwdFFT_; boost::scoped_ptr<InvFFT> invFFT_; }; } // namespace MatchedFilterUtils } // end namespace Algorithms } // end namespace SideCar #endif
27.862745
112
0.711471
[ "object", "vector" ]
3344ada1b0bfc6ec34557d17d2e566b1fa9254bf
2,550
h
C
EmbeddedTreeDB/Source/SiblingNodesRecordGroup.h
codesmithyide/diplodocusdb-tree-db
e3b670bab0b784159bb0649c43a5f960b7de36a1
[ "MIT" ]
null
null
null
EmbeddedTreeDB/Source/SiblingNodesRecordGroup.h
codesmithyide/diplodocusdb-tree-db
e3b670bab0b784159bb0649c43a5f960b7de36a1
[ "MIT" ]
27
2018-01-12T14:16:26.000Z
2018-02-01T20:56:03.000Z
EmbeddedTreeDB/Source/SiblingNodesRecordGroup.h
codesmithyide/diplodocusdb-tree-db
e3b670bab0b784159bb0649c43a5f960b7de36a1
[ "MIT" ]
1
2019-02-09T17:01:34.000Z
2019-02-09T17:01:34.000Z
/* Copyright (c) 2019 Xavier Leclercq Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ #ifndef _DIPLODOCUSDB_TREEDB_EMBEDDEDTREEDB_SIBLINGNODESRECORDGROUP_H_ #define _DIPLODOCUSDB_TREEDB_EMBEDDEDTREEDB_SIBLINGNODESRECORDGROUP_H_ #include "NodeID.h" #include "EmbeddedTreeDBNodeImpl.h" #include "DiplodocusDB/PhysicalStorage/PageRepository/PageRepositoryWriter.h" #include <vector> namespace DiplodocusDB { /// A list of records storing sibling nodes. /** This class represents a series of records used in the database to store the nodes that have the same parent. */ class SiblingNodesRecordGroup { public: SiblingNodesRecordGroup() = default; explicit SiblingNodesRecordGroup(const NodeID& parentNodeID); explicit SiblingNodesRecordGroup(const EmbeddedTreeDBNodeImpl& node); const NodeID& parentNodeID() const; const EmbeddedTreeDBNodeImpl& operator[](size_t pos) const; /// Returns the number of sibling nodes in the record group. size_t size() const noexcept; void push_back(const EmbeddedTreeDBNodeImpl& value); bool find(const std::string& name, EmbeddedTreeDBNodeImpl& node); void readWithoutType(PageRepositoryReader& reader, Ishiko::Error& error); void write(PageRepositoryWriter& writer, Ishiko::Error& error) const; private: static void writeNode(PageRepositoryWriter& writer, const EmbeddedTreeDBNodeImpl& node, Ishiko::Error& error); private: NodeID m_parentNodeID; std::vector<EmbeddedTreeDBNodeImpl> m_siblings; }; } #endif
38.636364
114
0.772549
[ "vector" ]
3350593f10f27abdbce2f80879b0862bb23767b8
4,568
h
C
src/include/insquery.h
Pointer2VoidStar/CLIPS
f70ef28aca7f1d993071724276d83797998c720a
[ "MIT" ]
2
2020-06-02T23:43:22.000Z
2021-12-30T21:00:00.000Z
src/include/insquery.h
Pointer2VoidStar/CLIPS
f70ef28aca7f1d993071724276d83797998c720a
[ "MIT" ]
4
2017-03-15T23:28:14.000Z
2017-10-29T22:48:28.000Z
src/include/insquery.h
Pointer2VoidStar/CLIPS
f70ef28aca7f1d993071724276d83797998c720a
[ "MIT" ]
1
2020-06-02T23:43:25.000Z
2020-06-02T23:43:25.000Z
/*******************************************************/ /* "C" Language Integrated Production System */ /* */ /* CLIPS Version 6.40 08/25/16 */ /* */ /* */ /*******************************************************/ /*************************************************************/ /* Purpose: */ /* */ /* Principal Programmer(s): */ /* Brian L. Dantes */ /* */ /* Contributing Programmer(s): */ /* */ /* Revision History: */ /* */ /* 6.23: Correction for FalseSymbol/TrueSymbol. DR0859 */ /* */ /* Corrected compilation errors for files */ /* generated by constructs-to-c. DR0861 */ /* */ /* 6.24: Renamed BOOLEAN macro type to intBool. */ /* */ /* 6.30: Changed integer type/precision. */ /* */ /* Changed garbage collection algorithm. */ /* */ /* Added const qualifiers to remove C++ */ /* deprecation warnings. */ /* */ /* 6.40: Removed LOCALE definition. */ /* */ /* Pragma once and other inclusion changes. */ /* */ /* Added support for booleans with <stdbool.h>. */ /* */ /* Removed use of void pointers for specific */ /* data structures. */ /* */ /* UDF redesign. */ /* */ /*************************************************************/ #ifndef _H_insquery #pragma once #define _H_insquery #if INSTANCE_SET_QUERIES #include "object.h" typedef struct query_class { Defclass *cls; Defmodule *theModule; struct query_class *chain,*nxt; } QUERY_CLASS; typedef struct query_soln { Instance **soln; struct query_soln *nxt; } QUERY_SOLN; typedef struct query_core { Instance **solns; Expression *query,*action; QUERY_SOLN *soln_set,*soln_bottom; unsigned soln_size,soln_cnt; UDFValue *result; } QUERY_CORE; typedef struct query_stack { QUERY_CORE *core; struct query_stack *nxt; } QUERY_STACK; #define INSTANCE_QUERY_DATA 31 struct instanceQueryData { CLIPSLexeme *QUERY_DELIMITER_SYMBOL; QUERY_CORE *QueryCore; QUERY_STACK *QueryCoreStack; bool AbortQuery; }; #define InstanceQueryData(theEnv) ((struct instanceQueryData *) GetEnvironmentData(theEnv,INSTANCE_QUERY_DATA)) #define QUERY_DELIMITER_STRING "(QDS)" void SetupQuery(Environment *); void GetQueryInstance(Environment *,UDFContext *,UDFValue *); void GetQueryInstanceSlot(Environment *,UDFContext *,UDFValue *); void AnyInstances(Environment *,UDFContext *,UDFValue *); void QueryFindInstance(Environment *,UDFContext *,UDFValue *); void QueryFindAllInstances(Environment *,UDFContext *,UDFValue *); void QueryDoForInstance(Environment *,UDFContext *,UDFValue *); void QueryDoForAllInstances(Environment *,UDFContext *,UDFValue *); void DelayedQueryDoForAllInstances(Environment *,UDFContext *,UDFValue *); #endif /* INSTANCE_SET_QUERIES */ #endif /* _H_insquery */
39.37931
111
0.378722
[ "object" ]
33514b43112c1b64f4e514fa21666ccf2c8b5d81
429
h
C
src/cpp/Common/Common.h
alexk7/IPG
6a8b28e7fbcc47fcdf9538fc840b2543be2e4834
[ "MIT" ]
1
2017-05-28T15:50:56.000Z
2017-05-28T15:50:56.000Z
src/cpp/Common/Common.h
alexk7/IPG
6a8b28e7fbcc47fcdf9538fc840b2543be2e4834
[ "MIT" ]
null
null
null
src/cpp/Common/Common.h
alexk7/IPG
6a8b28e7fbcc47fcdf9538fc840b2543be2e4834
[ "MIT" ]
null
null
null
#ifndef COMMON_H_ #define COMMON_H_ #include <cstdio> #include <cassert> #include <limits> #include <ostream> #include <iostream> #include <iomanip> #include <fstream> #include <sstream> #include <string> #include <vector> #include <list> #include <map> #include <set> #include <algorithm> #include <iterator> #include <stdexcept> #include <boost/format.hpp> #include <boost/algorithm/string.hpp> #endif /* COMMON_H_ */
13.83871
37
0.722611
[ "vector" ]
33569b37853212e3848a238153b9bc0eb928c808
875
h
C
es-app/src/guis/GuiSetupController.h
tlanks/esbusyness
41ed9e6b552585476c81f2f89b9e3d539c54d4ab
[ "Apache-2.0", "MIT" ]
10
2016-08-08T17:50:18.000Z
2019-03-08T02:54:13.000Z
es-app/src/guis/GuiSetupController.h
tlanks/esbusyness
41ed9e6b552585476c81f2f89b9e3d539c54d4ab
[ "Apache-2.0", "MIT" ]
7
2016-08-10T03:07:30.000Z
2018-10-10T15:24:40.000Z
es-app/src/guis/GuiSetupController.h
tlanks/esbusyness
41ed9e6b552585476c81f2f89b9e3d539c54d4ab
[ "Apache-2.0", "MIT" ]
16
2016-08-09T02:11:02.000Z
2019-09-24T10:17:56.000Z
#pragma once #include "GuiComponent.h" #include "components/MenuComponent.h" #include "components/NetworkInfoComponent.h" #include "components/ComponentGrid.h" #include <string> #include <vector> #include <functional> class GuiSetupController : public GuiComponent { public: GuiSetupController(Window* window, const std::function<void()>& doneCallback); bool input(InputConfig* config, Input input) override; void update(int deltatime) override; void onSizeChanged() override; std::vector<HelpPrompt> getHelpPrompts() override; private: bool loadFile(); int getControllerCount(); void buildControllerGrid(); void createSampleFile(); ComponentGrid mGrid; MenuComponent mMenu; TextComponent mVersion; std::function<void()> mDoneCallback; std::vector<std::vector<std::string>> vDocData; int mControllerCount = 0; bool mFileLoaded = false; };
22.435897
79
0.76
[ "vector" ]
335d0dae4a6a238a1014a31cfcd62024e2cc9001
2,061
h
C
coolc/src/codegen/symtab/SymbolTable.h
xp10rd/Compilers
bd924ba5987167ffd359551c06783c33bfa088aa
[ "MIT" ]
null
null
null
coolc/src/codegen/symtab/SymbolTable.h
xp10rd/Compilers
bd924ba5987167ffd359551c06783c33bfa088aa
[ "MIT" ]
4
2022-02-19T06:45:06.000Z
2022-03-25T19:36:36.000Z
coolc/src/codegen/symtab/SymbolTable.h
gafiyatullin-a/Compilers
e3f61de6588c03505b0bca321d21515e29e1fbef
[ "MIT" ]
null
null
null
#pragma once #include "utils/Utils.h" #include <functional> #include <unordered_map> namespace codegen { /** * @brief Manage symbols in scopes * */ template <class T> class SymbolTable { private: std::vector<std::unordered_map<std::string, T>> _symbols; // class fields and locals offsets #ifdef DEBUG std::function<void(const std::string &, const T &)> _debug; // logging #endif // DEBUG public: /** * @brief Construct a new SymbolTable with initial scope * */ SymbolTable() : _symbols(1) { } /** * @brief Find symbol * * @param symbol Symbol name * @return Symbol object for this symbol */ T &symbol(const std::string &symbol); /** * @brief Create Symbol * * @param name Symbol name * @param symbol Symbol object */ void add_symbol(const std::string &name, const T &symbol); /** * @brief Push new scope * */ inline void push_scope() { _symbols.emplace_back(); } /** * @brief Pop current scope * */ inline void pop_scope() { GUARANTEE_DEBUG(!_symbols.empty()); _symbols.pop_back(); } #ifdef DEBUG void set_printer(const std::function<void(const std::string &, const T &)> &debug_print) { _debug = debug_print; } #endif // DEBUG }; template <class T> void SymbolTable<T>::add_symbol(const std::string &name, const T &symbol) { CODEGEN_VERBOSE_ONLY(_debug(name, symbol)); _symbols.back().emplace(name, symbol); } template <class T> T &SymbolTable<T>::symbol(const std::string &symbol) { // search in reverse order for (auto i = _symbols.size() - 1; i >= 0; i--) { const auto symbol_ptr = _symbols[i].find(symbol); if (symbol_ptr != _symbols[i].end()) { return symbol_ptr->second; } } CODEGEN_VERBOSE_ONLY(LOG("Can't find symbol \"" + symbol + "\"")); SHOULD_NOT_REACH_HERE(); } }; // namespace codegen
22.16129
96
0.576904
[ "object", "vector" ]
335dfd541eb79f7c8d6e24aa6edbc7dd28457933
442
h
C
ExLemmings/Lemmings/02-Lemming/Utils.h
ralucado/VJ
40f49deeb63b45ffbcccd71f12cb1400a86c8129
[ "MIT" ]
1
2020-01-01T09:04:49.000Z
2020-01-01T09:04:49.000Z
ExLemmings/Lemmings/02-Lemming/Utils.h
ralucado/VJ
40f49deeb63b45ffbcccd71f12cb1400a86c8129
[ "MIT" ]
null
null
null
ExLemmings/Lemmings/02-Lemming/Utils.h
ralucado/VJ
40f49deeb63b45ffbcccd71f12cb1400a86c8129
[ "MIT" ]
null
null
null
#ifndef _UTILS_INCLUDE #define _UTILS_INCLUDE #include <algorithm> #include <cmath> #include <iostream> #include <set> #include <string> #include <vector> #include <irrKlang.h> using namespace irrklang; #define NUM_POWERS 8 using namespace std; class Utils { public: Utils(); ~Utils(); static Utils &instance() { static Utils U; return U; } double pit_distance(int x1, int y1, int x2, int y2) const; }; #endif // _UTILS_INCLUDE
14.733333
59
0.717195
[ "vector" ]
3366964270a290cdafcaf44508ea270c05c5ed67
2,153
h
C
Labyrint/labyball/Classes/Native/System_System_Text_RegularExpressions_IntervalColl3008899218MethodDeclarations.h
mimietti/Labyball
c4b03f5b5d5ec1a1cae5831d22391bc2a171230f
[ "MIT" ]
null
null
null
Labyrint/labyball/Classes/Native/System_System_Text_RegularExpressions_IntervalColl3008899218MethodDeclarations.h
mimietti/Labyball
c4b03f5b5d5ec1a1cae5831d22391bc2a171230f
[ "MIT" ]
23
2016-07-21T13:03:02.000Z
2016-10-03T12:43:01.000Z
Labyrint/labyrinti1/Classes/Native/System_System_Text_RegularExpressions_IntervalColl3008899218MethodDeclarations.h
mimietti/Labyball
c4b03f5b5d5ec1a1cae5831d22391bc2a171230f
[ "MIT" ]
1
2019-09-08T17:32:17.000Z
2019-09-08T17:32:17.000Z
#pragma once #include "il2cpp-config.h" #ifndef _MSC_VER # include <alloca.h> #else # include <malloc.h> #endif #include <stdint.h> #include <assert.h> #include <exception> // System.Text.RegularExpressions.IntervalCollection/CostDelegate struct CostDelegate_t3008899218; // System.Object struct Il2CppObject; // System.IAsyncResult struct IAsyncResult_t537683269; // System.AsyncCallback struct AsyncCallback_t1363551830; #include "codegen/il2cpp-codegen.h" #include "mscorlib_System_Object837106420.h" #include "mscorlib_System_IntPtr676692020.h" #include "System_System_Text_RegularExpressions_Interval63637216.h" #include "System_System_Text_RegularExpressions_Interval63637216MethodDeclarations.h" #include "mscorlib_System_AsyncCallback1363551830.h" // System.Void System.Text.RegularExpressions.IntervalCollection/CostDelegate::.ctor(System.Object,System.IntPtr) extern "C" void CostDelegate__ctor_m731467895 (CostDelegate_t3008899218 * __this, Il2CppObject * ___object0, IntPtr_t ___method1, const MethodInfo* method) IL2CPP_METHOD_ATTR; // System.Double System.Text.RegularExpressions.IntervalCollection/CostDelegate::Invoke(System.Text.RegularExpressions.Interval) extern "C" double CostDelegate_Invoke_m212988972 (CostDelegate_t3008899218 * __this, Interval_t63637216 ___i0, const MethodInfo* method) IL2CPP_METHOD_ATTR; extern "C" double pinvoke_delegate_wrapper_CostDelegate_t3008899218(Il2CppObject* delegate, Interval_t63637216 ___i0); // System.IAsyncResult System.Text.RegularExpressions.IntervalCollection/CostDelegate::BeginInvoke(System.Text.RegularExpressions.Interval,System.AsyncCallback,System.Object) extern "C" Il2CppObject * CostDelegate_BeginInvoke_m1041332600 (CostDelegate_t3008899218 * __this, Interval_t63637216 ___i0, AsyncCallback_t1363551830 * ___callback1, Il2CppObject * ___object2, const MethodInfo* method) IL2CPP_METHOD_ATTR; // System.Double System.Text.RegularExpressions.IntervalCollection/CostDelegate::EndInvoke(System.IAsyncResult) extern "C" double CostDelegate_EndInvoke_m917297514 (CostDelegate_t3008899218 * __this, Il2CppObject * ___result0, const MethodInfo* method) IL2CPP_METHOD_ATTR;
53.825
241
0.848119
[ "object" ]
3366e8cad97d74fd34a66947922afdc290fa9a09
27,224
h
C
src/mio.h
swanand-gadre/cortx-mio
78e2f0e10b2452018235265765521fa654c769c5
[ "Apache-2.0" ]
1
2022-01-12T16:35:41.000Z
2022-01-12T16:35:41.000Z
src/mio.h
swanand-gadre/cortx-mio
78e2f0e10b2452018235265765521fa654c769c5
[ "Apache-2.0" ]
14
2021-02-04T16:23:15.000Z
2022-02-24T10:49:49.000Z
src/mio.h
swanand-gadre/cortx-mio
78e2f0e10b2452018235265765521fa654c769c5
[ "Apache-2.0" ]
14
2021-02-07T09:15:28.000Z
2022-03-29T06:30:16.000Z
/* -*- C -*- */ /* * Copyright: (c) 2020 - 2021 Seagate Technology LLC and/or its its Affiliates, * All Rights Reserved * * This software is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ #pragma once #ifndef __MIO_H__ #define __MIO_H__ #include <pthread.h> #include "mio_internal.h" #include "mio_telemetry.h" #include "logger.h" typedef void (*mio_callback)(struct mio_op *op); struct mio_kvs_id; /** * Definitions of MIO operations: * - Data structure (mio_op) to interact with MIO applications. * - Operation codes for object and key-value store (kvs). * - mio_op_state defines operation states. * - operations on ops such as initialisation and finalisation. */ #ifdef __cplusplus enum mio_obj_opcode : int { #else enum mio_obj_opcode { #endif MIO_OBJ_INVALID, MIO_OBJ_CREATE, MIO_OBJ_DELETE, MIO_OBJ_OPEN, MIO_OBJ_CLOSE, MIO_OBJ_SYNC, MIO_OBJ_ATTRS_SET, MIO_OBJ_ATTRS_GET, MIO_OBJ_READ, MIO_OBJ_WRITE, MIO_OBJ_OP_NR }; enum mio_kvs_opcode { MIO_KVS_CREATE_SET = MIO_OBJ_OP_NR + 1, MIO_KVS_DELETE_SET, /** Check a kvs for an existence. */ MIO_KVS_LOOKUP_SET, /** Lookup a value with the given key. */ MIO_KVS_GET, /** Insert or update the value, given a key. */ MIO_KVS_PUT, /** Delete the value, if any, for the given key. */ MIO_KVS_DEL, MIO_KVS_OP_NR }; enum mio_composite_obj_opcode { MIO_COMP_OBJ_CREATE = MIO_KVS_OP_NR + 1, MIO_COMP_OBJ_DELETE, MIO_COMP_OBJ_ADD_LAYERS, MIO_COMP_OBJ_DEL_LAYERS, MIO_COMP_OBJ_LIST_LAYERS, MIO_COMP_OBJ_ADD_EXTENTS, MIO_COMP_OBJ_DEL_EXTENTS, MIO_COMP_OBJ_GET_EXTENTS, MIO_COMP_OBJ_OP_NR }; enum mio_op_state { MIO_OP_ONFLY = 0, MIO_OP_COMPLETED, MIO_OP_FAILED }; /** * Callback functions set by applications which are called when * all actions of an operation are done. */ struct mio_op_app_cbs { mio_callback moc_cb_complete; mio_callback moc_cb_failed; void *moc_cb_data; }; struct mio_op { uint64_t mop_seqno; unsigned int mop_opcode; /* Type of operation. */ union { /* Which object or key-value set. */ struct mio_obj *obj; struct mio_kvs_id *kvs_id; } mop_who; int mop_state; /* Current state of operation. */ int mop_rc; /* == 0 when operation successes, * < 0 the error code if the * operation fails. */ struct mio_op_app_cbs mop_app_cbs; /* See mio_drv_op_chain in mio_inernal.h for explanation. */ struct mio_driver_op_chain mop_drv_op_chain; struct mio_op_ops *mop_op_ops; }; extern pthread_mutex_t mio_op_seqno_lock; extern uint64_t mio_op_seqno; /** * Initialise and finalise an operation. Applications have to allocate * memory for the operation before calling mio_op_init(). */ int mio_op_init(struct mio_op *op); void mio_op_fini(struct mio_op *op); struct mio_op* mio_op_alloc_init(); void mio_op_fini_free(struct mio_op *op); /** * mio_op_poll() is defined similar to POSIX poll() system call * and it waits for one of a set of operations to reach COMPLETED * or FAILED state. * * The set of operations to be monitored is specified in the ops * argument, which is an array of structures of the following form: * * struct mio_pollop { * struct mio_op *mp_op; //Operation to poll. * int mp_retstate; // Returned state. * }; * If none of the operations reach states requested (COMPLETED * or FAILED) and no error has occurred for any of the operations, * then mio_op_poll() blocks until one of the states occurs. * The field retstat is an output parameter, filled by MIO with the * state that actually occurred. * * The timeout argument specifies the number of milliseconds that * mio_op_poll()should block waiting for an operation to reach state * requested. The call will block until either: * - an operation reaches the state requested; * - the timeout expires. * * Specifying a negative value in timeout means an infinite timeout. * Specifying a timeout of zero causes mio_op_poll() to * return immediately, even if no operations reach the states * requested. * * @param ops The pointer to an array of data structure mio_pollop, * containing the operations and states to query on. * @param nr_ops The number of members in array ops. * @param timeout. Timeout value in milliseconds. * @return 0 the operation is completed or failed, < 0 for error. */ struct mio_pollop { struct mio_op *mp_op; /* Operation to poll. */ int mp_retstate; /* Returned state. */ }; int mio_op_poll(struct mio_pollop *ops, int nr_ops, uint64_t timeout); #define MIO_TIME_NEVER (~0ULL) /** * Callbacks provides an alternative way to handle operations * asynchronously. mio_op_set_callbacks() set callbacks for * an operation. * * @param op The pointer to operation. * @cb_complete The callback function is triggered when * the operation reach COMPLETED state. * @cb_complete The callback function is triggered when * the operation turns into FAILED state. * @cb_cb The data passed to callback functions. */ void mio_op_callbacks_set(struct mio_op *op, mio_callback cb_complete, mio_callback cb_failed, void *cb_data); /** * Define the scope of a hint. A hint can be used for an object, * a key-value set or system level parameters. */ enum mio_hint_scope { MIO_HINT_SCOPE_OBJ, MIO_HINT_SCOPE_KVSET, MIO_HINT_SCOPE_SYS }; /** * Hints set to this opened object. MIO differentiates * 2 types of hints: (a) session hints which are set only for * object that are openned and are kept alive only during * the period of openning session. Session hints will be * destroyed when an object is closed and the hints won't * be valid for next session. Example of session hints: cache * and pre-fetching hints. (b) Persistent hints which are persisted * and are retrieved and set when an object is openned. The * persistent hints are valid for the life time of the object. */ enum mio_hint_type { MIO_HINT_SESSION, MIO_HINT_PERSISTENT }; /** Hints for individual object. */ enum mio_obj_hint_key { MIO_HINT_OBJ_LIFETIME, MIO_HINT_OBJ_WHERE, MIO_HINT_OBJ_HOT_INDEX, MIO_HINT_OBJ_KEY_NUM }; /* System wide hints. */ enum mio_sys_hint_key { MIO_HINT_HOT_OBJ_THRESHOLD, MIO_HINT_COLD_OBJ_THRESHOLD, }; enum mio_hint_value { MIO_HINT_VALUE_NULL }; /** * Hints are stored and managed as a map between hint’s key and value. */ struct mio_hints { struct mio_hint_map mh_map; }; extern struct mio_hints mio_sys_hints; /** * Object identifier is defined as a byte array with lower-indexed/big-endian * ordering and the option of Maestro changing to 256 bit later, * with lower-bits-0 indicating legacy IDs (i.e., the ones at bytes[8..15]). */ enum { MIO_OBJ_ID_LEN = 16, MIO_KVS_ID_LEN = 16 }; struct mio_obj_id { uint8_t moi_bytes[MIO_OBJ_ID_LEN]; }; struct mio_kvs_id { uint8_t mki_bytes[MIO_KVS_ID_LEN]; }; struct mio_pool_id { uint64_t mpi_hi; uint64_t mpi_lo; }; /** Some marcos for pools. */ enum { MIO_POOL_ID_AUTO = 0x0, MIO_POOL_GOLD = 0x100, MIO_POOL_SILVER = 0x101, MIO_POOL_BRONZE = 0x102 }; /** * mio_iovec specifies the base address and length of an area in memory * from/to which data should be written. It also specifies byte range of * an object. */ struct mio_iovec { char *miov_base; /* Base address. */ uint64_t miov_off; /* Offset. */ size_t miov_len; /* Length. */ }; enum { MIO_MAX_HINTS_PER_OBJ = 16, }; /** * Object attributes stored to and loaded from storage backend. */ struct mio_obj_attrs { uint64_t moa_size; /** * Object access statistics. MIO shows one usage of * this information to calculate object hotness. */ struct mio_obj_stats moa_stats; /* Persistent hints only. */ struct mio_hints moa_phints; }; /** * In-memory object handler. */ struct mio_obj { struct mio_obj_id mo_id; struct mio_obj_op *mo_op; /** * Sequence number of a opened object session. This sequence * number can be used to associated all operations issued * in this session, which can be used in telemetry data * analysis. */ uint64_t mo_sess_seqno; /** Driver specific object ops. */ struct mio_obj_ops *mo_drv_obj_ops; /** Hints (persistent + session hints) set for this object. */ struct mio_hints mo_hints; /** Associated metadata key-vaule set. */ struct mio_kvs *mo_md_kvs; /** If the object's attributes have been updated. */ bool mo_attrs_updated; struct mio_obj_attrs mo_attrs; /** Pointer to driver specific object structure. */ void *mo_drv_obj; /** Pointer to driver specific object lock. */ void *mo_drv_obj_lock; }; extern pthread_mutex_t mio_obj_session_seqno_lock; extern uint64_t mio_obj_session_seqno; enum mio_pool_type { MIO_POOL_TYPE_NVM = 0, MIO_POOL_TYPE_SSD, MIO_POOL_TYPE_HDD }; enum { MIO_POOL_MAX_NAME_LEN = 32, MIO_POOL_MAX_NR_OPT_BLKSIZES = 16, }; /** * Descriptor of a MIO pool. */ struct mio_pool { /** the name by which this layer is referenced by the user */ char mp_name[MIO_POOL_MAX_NAME_LEN + 1]; /** Pool id. */ struct mio_pool_id mp_id; enum mio_pool_type mp_type; /* Characteristics of the pool. */ /** Capacity of the layer (not necessarily constant or current) */ size_t mp_capacity; /* * Note that the 'available space' is not a slot here, because that * would imply that MIO needs to update it frequently. Instead, the * free space is inquired by passing the pool id to a separate * mio_pool_freespace() function. */ /** Optimised data buffer alignment */ size_t mp_opt_alignment; /** * Preferred block sizes for read and write operations, ordered in * decreasing order of performance. These parameters are initialised * using driver specific experiential `formula`, and could be * updated by monitoring telemetry data. */ size_t mp_nr_opt_blksizes; size_t mp_opt_blksizes[MIO_POOL_MAX_NR_OPT_BLKSIZES]; }; /** * MIO pool information structure. */ struct mio_pools { int mps_default_pool_idx; char mps_default_pool_name[MIO_POOL_MAX_NAME_LEN + 1]; int mps_nr_pools; struct mio_pool *mps_pools; }; extern struct mio_pools mio_pools; /** * Return the available space in pool @arg pool_id. * * Returns a (reasonable approximation to) the free capacity of the given * pool in @param *freespace. * */ int mio_pool_freespace(const struct mio_pool_id *pool_id, size_t *freespace); /** * Return information about a requested pool or all MIO pools. * * This function can only be called after mio_init() returned successfully. * User code is not permitted to modify the content of the @arg config * result. * * @param *pool_id The pool id. * @param *pools will not be NULL on a successful return. If no * pools are configured, this will be visible inside the configinfo * structure itself. * * @param pools may not be NULL on call. * * @param[out] pool The requested pool. * @param[out] pools The list of all pools. * @return 0 for success */ int mio_pool_get(const struct mio_pool_id *pool_id, struct mio_pool **pool); int mio_pool_get_all(struct mio_pools **pools); /** * Return an object's pool id. * * @arg *pool_id The pool id. * @param obj Pointer to the object handle which can be used can be */ int mio_obj_pool_id(const struct mio_obj *obj, struct mio_pool_id *pool_id); bool mio_obj_pool_id_cmp(struct mio_pool_id *pool_id1, struct mio_pool_id *pool_id2); /** * Open an object identified by object identifier oid. * Upon successful completion mio_obj_open() return a ‘obj’ * pointer. Otherwise, NULL is returned with an error code. * @param oid The object identifier. * @param obj Pointer to the object handle which can be used can be * subsequently used to access the object until the object is closed. * Note that the object handle must be pre-allocated by application. * @param op The open operation for progress query. See Table 5 for * mio_op data structure definition * @return 0 for success, < 0 for error. */ int mio_obj_open(const struct mio_obj_id *oid, struct mio_obj *obj, struct mio_op *op); /** * Close an object handle and free resources held by the object. * @param obj Pointer to the object handle. */ void mio_obj_close(struct mio_obj *obj); /** * Create an object with identifier ‘oid’. See mio_obj_open() * above for notes on object identifier. * Note that an internal key-value set will be created when * creating an object, offering a convenient mechanism * for applications to store and query customized object attributes. * * `pool_id` and `hints` together decide which pool to store the object. * When `pool_id` isn't NULL, the object will be created in the explicitly * specified pool. When `pool_id` is set to NULL, the pool is chosen * according to the `hints`. MIO currently offers 2 kinds of hints for * pool selection. {MIO_HINT_OBJ_WHERE, MIO_POOL_GOLD|SILVER|BRONZE} * allows users choose a pool according to performance requirement. * {MIO_HINT_OBJ_HOT_INDEX, hotname} gives MIO information on how * frequent the object will be accessed and MIO then decides which * pool to store the object. See example in examples/mio_hsm.c. * * @param oid The object identifier. * @param pool_id The pool where the object is stored to. * @param hints Hints about which pool to store the object. * @param[out] obj Pointer to the object handle which can be * used can be subsequently used to access the object until * the object is closed. Note that the object handle must be * pre-allocated by application. * @return 0 for success, < 0 for error. * * TODO: hints to create an object such as which pool to store. * Should MIO expose pools to applications? */ int mio_obj_create(const struct mio_obj_id *oid, const struct mio_pool_id *pool_id, struct mio_hints *hints, struct mio_obj *obj, struct mio_op *op); /** * Delete an object. * @param oid The object identifier. * @return 0 for success, < 0 for error. */ int mio_obj_delete(const struct mio_obj_id *oid, struct mio_op *op); /** * mio_obj_writev() writes from a set of buffers specified by * the members of the iov: iov[0], iov[1], ..., iov[iovcnt-1] * to object offsets specified by the members of the offsets: * offsets[0], offsets[1], ..., offsets[iovcnt-1]. * * mio_obj_readv() reads from object offsets specified by * the members of the offsets: * offsets[0], offsets[1], ..., offsets[iovcnt-1] into a set * of buffers of iov: iov[0], iov[1], ..., iov[iovcnt-1]. * * Upon successfully returning, mio_obj_writev() and mio_obj_readv() * return with a launched operation. op can be used to query * the process of the operation. * * @param obj Pointer to the object handle. * @param iov The data buffer array. Each member specifies an * area of memory to write to or read from and an object offset. * @param iovcnt The number of data buffers. The number of * offsets and iov must be equal to iovcnt. * @param op[out]. The returned operation data structure for * state querying. * @return 0 for success, < 0 for error. * */ int mio_obj_writev(struct mio_obj *obj, const struct mio_iovec *iov, int iovcnt, struct mio_op *op); int mio_obj_readv(struct mio_obj *obj, const struct mio_iovec *iov, int iovcnt, struct mio_op *op); /** * mio_obj_sync() flushes all previous writes to obj to be * persisted to the storage device. * * @param obj The object is going to be sync'ed. * @param op[out]. The returned operation data structure for * state querying. * @return 0 for success, anything else for an error. */ int mio_obj_sync(struct mio_obj *obj, struct mio_op *op); /** * Send a request to retrieve object size. When an object is * newly openned, its object attributes are retrieved including * object size (struct mio_obj::mo_attrs::moa_size). Object's * size can later be updated by calling mio_obj_size(). * * @param obj The object in question. * @param op[out]. The returned operation data structure for * state querying. * @return 0 for success, anything else for an error. */ int mio_obj_size(struct mio_obj *obj, struct mio_op *op); /** * Lock and unlock an object. Only exclusive whole object lock * is supported. The usage of an object lock is similar to file * lock flock(). * - open object. * - lock * - do some IOs * - unlock * - close object. * * @param obj The object in question. * @return 0 for success, anything else for an error. */ int mio_obj_lock(struct mio_obj *obj); int mio_obj_unlock(struct mio_obj *obj); /** * Data structure represents a record stored in a key-value set. * MIO key-value set accepts variable lengths of keys and values. */ struct mio_kv_pair { void *mkp_key; size_t mkp_klen; void *mkp_val; size_t mkp_vlen; }; struct mio_kvs { struct mio_kvs_id mk_id; /** Driver specific key-value set data structure. */ void *mk_drv_kvs; struct mio_kvs_ops *mk_ops; }; extern struct mio_kvs mio_obj_attrs_kvs; /** * * For mio_kvs_pair_get() and mio_kvs_pair_del() arguments should be * as follows: * - 'kvps' key-value pairs should set mio_kv_pair::key’s for * records being requested and set mio_kv_pair::val’s to NULLs. * At least one key should be specified. * - After successful operation retrieved record * values are stored in mio_kv_pair::mkp_val. If some value * retrieval has failed, then corresponding element in 'rcs' array * is set to a suitable error code. * * For mio_kvs_pair_put() arguments should be as follows: * - 'kvps' key-value pairs should set mio_kv_pair::key’s * for records being requested and set mio_kv_pair::val’s * to corresponding values. * * For mio_kvs_pair_next(): * - The first element's key of 'kvps' should be set to the starting key * and other keys are set to NULLs. All value parts of `kvps` should * be set to NULLs. * * If the starting key is set to NULL, mio_kvs_pair_next() will return * the required number of key/value pairs starting with the smallest * key. * * If 'exclude_start_key' is set to 'true', mio_kvs_pair_next() will * return pairs starting with the key right after the starting key. * * - After successful operation retrieved record keys and * values are stored in 'kvps'. If some value * retrieval has failed, then corresponding element in 'rcs' array * is set to a suitable error code. If the error code is set to * EOF, meaning that there are no more pairs. An example in * examples/kvs.c::kvs_query_next() shows how to handle returned * error codes. * * Error handling: * 'rcs' holds an array of per-item return codes for the operation. * It should be allocated by user with at least `nr_kvps` elements. * For example, 6 records with keys k0...k5 were requested through * mio_kvs_get(), k3 being absent in the key-value set. * After operation completion rcs[3] will be set to –ENOENT * and rcs[0,1,2,4,5] will be 0. * * Per-item return codes are more fine-grained than global operation * return code (mio_op::mo_rc). On operation completion the global * return code is set to negative value if it's impossible * to process any item . * - If the global return code is 0, then the user should check * per-item return codes. * - If the global return code is not 0, then per-item return codes * are undefined. * * @param kvs_id The key-value set identifier. The format of * key-value set identifier is driver specific and must explicitly * stated in documentation. * @param nr_kvps The number of key-value pairs. * @param rcs. Array for per-item return code. * @param op[out]. The operation pointer for progress query. * @return 0 for success, < 0 for error. */ int mio_kvs_pair_get(struct mio_kvs_id *kvs_id, int nr_kvps, struct mio_kv_pair *kvps, int32_t *rcs, struct mio_op *op); int mio_kvs_pair_next(struct mio_kvs_id *kvs_id, int nr_kvps, struct mio_kv_pair *kvps, bool exclude_start_key, int32_t *rcs, struct mio_op *op); int mio_kvs_pair_put(struct mio_kvs_id *kvs_id, int nr_kvps, struct mio_kv_pair *kvps, int32_t *rcs, struct mio_op *op); int mio_kvs_pair_del(struct mio_kvs_id *kvs_id, int nr_kvps, struct mio_kv_pair *kvps, int32_t *rcs, struct mio_op *op); /** * mio_kvs_create_set() creates a key-value set, * while mio_kvs_del_set() deletes a key-value set. * * @param kvs_id The key-value set identifier. * @return 0 for success, < 0 for error. */ int mio_kvs_create_set(struct mio_kvs_id *kvs_id, struct mio_op *op); int mio_kvs_del_set(struct mio_kvs_id *kvs_id, struct mio_op *op); /** * mio_obj_hints_set() sets new values for the hints of the object * handler associated with object. * mio_obj_hints_get() retrieves object’s hints. * * As potentially there may be many hints for an object, the argument * hints allows us to set or get multiple hints in one single call. * * @param obj Pointer to the object handle. * @param hints Hints to set for an object. * @return 0 for success, < 0 for error. */ int mio_obj_hints_set(struct mio_obj *obj, struct mio_hints *hints); int mio_obj_hints_get(struct mio_obj *obj, struct mio_hints *hints); int mio_obj_hint_set(struct mio_obj *obj, int hint_key, uint64_t hint_value); int mio_obj_hint_get(struct mio_obj *obj, int hint_key, uint64_t *hint_value); int mio_sys_hint_set(int hint_key, uint64_t hint_value); int mio_sys_hint_get(int hint_key, uint64_t *hint_value); /** * Helper functions to set or get individual hint. */ int mio_hints_init(struct mio_hints *hints); void mio_hints_fini(struct mio_hints *hints); int mio_hint_add(struct mio_hints *hints, int hint_key, uint64_t hint_value); int mio_hint_lookup(struct mio_hints *hints, int hint_key, uint64_t *hint_value); enum mio_hint_type mio_hint_type(enum mio_hint_scope scope, int key); char* mio_hint_name(enum mio_hint_scope scope, int key); struct mio_pool_id mio_obj_hotness_to_pool_id(uint64_t hotness); /** * TODO: short description/definition of composite object. * * Data structures and APIs for MIO composite object. * - object extent is defined as a tuple (offset, size). * - Composite layer (sub-object). * - Composite object operations for MIO driver implementation. * - APIs to create/delete/list layers. * - APIs to create/delete/list extents. */ struct mio_obj_ext { off_t moe_off; size_t moe_size; }; struct mio_comp_obj_layer { int mcol_priority; struct mio_obj_id mcol_oid; }; struct mio_comp_obj_layout { int mlo_nr_layers; struct mio_comp_obj_layer *mlo_layers; }; /** * mio_composite_obj_create() crates a composite object. If the * object of identifier `oid` exists this function returns –EEXIST * error code. * mio_composite_obj_del() deletes a composite object. * * @param oid The object identifier. * @return 0 for success, anything else for an error */ int mio_composite_obj_create(const struct mio_obj_id *oid, struct mio_obj *obj, struct mio_op *op); int mio_composite_obj_del(const struct mio_obj_id *oid, struct mio_op *op); /** * mio_composite_obj_add_layer() adds a new layer (sub-object) to a * composite object. mio_composite_obj_del_layer() deletes a layer * from the composite object. All extents in the layer will * be removed as well. * * @param obj The object to add to. * @param layers The layers to be added or deleted. * @param op The operation will be initialised when returned. * @return 0 for success, anything else for an error. */ int mio_composite_obj_add_layers(struct mio_obj *obj, int nr_layers, struct mio_comp_obj_layer *layers, struct mio_op *op); int mio_composite_obj_del_layers(struct mio_obj *obj, int nr_layers_to_del, struct mio_comp_obj_layer *layers_to_del, struct mio_op *op); /** * List layers from highest priority to lowest one. * The memory to store layers and priorities are allocated * inside the function. * * @param object The object to add to. * @param layout[out] The returned composite layout. * @param op The operation will be initialised when returned. * @return 0 for success, anything else for an error. */ int mio_composite_obj_list_layers(struct mio_obj *obj, struct mio_comp_obj_layout *ret_layout, struct mio_op *op); /** * Add/remove extents of the specified layer of a composite object. * * @param object The object to add to. * @param layer The sub-object of the layer. * @param ext The extent in question. * @return 0 for success, anything else for an error. */ int mio_composite_obj_add_extents(struct mio_obj *obj, struct mio_obj_id *layer_id, int nr_exts, struct mio_obj_ext *exts, struct mio_op *op); int mio_composite_obj_del_extents(struct mio_obj *obj, struct mio_obj_id *layer_id, int nr_exts, struct mio_obj_ext *exts, struct mio_op *op); /** * Query `nr_exts` extents of the specified layer whose offsets are * larger than `offset`. The number of extents found is returned. * * @param object The object to add to. * @param layer The sub-object of the layer. * @param offset The returned extents’ offset must be >= this * argument. * @param nr_exts. The number of members in the array `exts`. * @param exts[out] The output array for extents. * @param nr_ret_exts[out] The returned number of extents from query. * @return = 0 for success, anything else for an error. */ int mio_composite_obj_get_extents(struct mio_obj *obj, struct mio_obj_id *layer_id, off_t offset, int nr_exts, struct mio_obj_ext *exts, int *nr_ret_exts, struct mio_op *op); /** * The structure 'mio' holds global information of underlying object store * and key-value set. */ struct mio { enum mio_telemetry_store_type m_telem_store_type; char *m_telem_prefix; enum mio_log_level m_log_level; char *m_log_dir; enum mio_driver_id m_driver_id; struct mio_driver *m_driver; void *m_driver_confs; }; extern struct mio *mio_instance; /** * Initialises Maestro IO interface. * * @param yaml_conf cnfiguration file in Yaml format. * @return 0 for success, anything else for an error. */ int mio_init(const char *yaml_conf); /** * Finalises Maestro IO interface. */ void mio_fini(); /** * Some object stores such as Cortx/motr supports thread-wise functionalities * (such as ADDB) which requires thread to be initialised in a certain way. * Call mio_thread_init() at the beginning of a thread and mio_thread_fini() * at the end of it. */ struct mio_thread { void *mt_drv_thread; }; int mio_thread_init(struct mio_thread *thread); void mio_thread_fini(struct mio_thread *thread); #endif /* * Local variables: * c-indentation-style: "K&R" * c-basic-offset: 8 * tab-width: 8 * fill-column: 80 * scroll-step: 1 * End: */ /* * vim: tabstop=8 shiftwidth=8 noexpandtab textwidth=80 nowrap */
31.006834
81
0.719586
[ "object" ]
3373a794cf1f779ea4479751e23c9a2840c64280
15,220
h
C
source/utils/signalslot/cevent.h
gummikana/poro
70162aca06ca5a1d4f92b8d01728e1764e4c6873
[ "Zlib" ]
3
2015-02-09T15:31:32.000Z
2022-03-06T20:49:48.000Z
source/utils/signalslot/cevent.h
gummikana/poro
70162aca06ca5a1d4f92b8d01728e1764e4c6873
[ "Zlib" ]
null
null
null
source/utils/signalslot/cevent.h
gummikana/poro
70162aca06ca5a1d4f92b8d01728e1764e4c6873
[ "Zlib" ]
2
2019-09-26T22:00:16.000Z
2019-10-03T22:02:43.000Z
/*************************************************************************** * * Copyright (c) 2003 - 2011 Petri Purho * * This software is provided 'as-is', without any express or implied * warranty. In no event will the authors be held liable for any damages * arising from the use of this software. * Permission is granted to anyone to use this software for any purpose, * including commercial applications, and to alter it and redistribute it * freely, subject to the following restrictions: * 1. The origin of this software must not be misrepresented; you must not * claim that you wrote the original software. If you use this software * in a product, an acknowledgment in the product documentation would be * appreciated but is not required. * 2. Altered source versions must be plainly marked as such, and must not be * misrepresented as being the original software. * 3. This notice may not be removed or altered from any source distribution. * ***************************************************************************/ /////////////////////////////////////////////////////////////////////////////// // // Event class is to be used when a event is fired. // // Difference between delegates and events are that events doen't return // return value from the function delegates do. And because of that events // can be used without defining the return value in advance. // //............................................................................. // // 07.01.2005 Pete // Created the Delegate and Event classes. // // //============================================================================= #ifndef INC_CEVENT_H #define INC_CEVENT_H #include <assert.h> #include <algorithm> #include <math.h> #include "signalslot_libs.h" // #include "canycontainer.h" /////////////////////////////////////////////////////////////////////////////// namespace ceng { //! The Base a kinda of private class class CGenericEventBase { public: CGenericEventBase() : myNumberOfParameters( 0 ) { } virtual ~CGenericEventBase() { } //========================================================================= virtual void Call() { assert( false ); // Hasn't been implented, you called the wrong type } virtual void Call( const CAnyContainer& arg1 ) { assert( false ); // Hasn't been implented, you called the wrong type } virtual void Call( const CAnyContainer& arg1, const CAnyContainer& arg2 ) { assert( false ); // Hasn't been implented, you called the wrong type } virtual void Call( const CAnyContainer& arg1, const CAnyContainer& arg2, const CAnyContainer& arg3 ) { assert( false ); // Hasn't been implented, you called the wrong type } //========================================================================= int GetNumberOfParameters() const { return myNumberOfParameters; } //......................................................................... virtual const std::type_info& GetTypeInfo() const = 0; //......................................................................... virtual void* GetPointer() const = 0; //......................................................................... virtual void SetPointer( void* p ) { } //========================================================================= virtual bool CheckEvent( CGenericEventBase* event ) const = 0; //========================================================================= virtual CGenericEventBase* Clone() const = 0; template< class T > bool IsA( const T* pointer ) { void* myPointer = GetPointer(); if ( myPointer == NULL ) return false; if ( myPointer == pointer ) return true; // Just to check for some multiple inheritance shit // that can sometimes cause nasty things to happen assert( abs( (int)myPointer - (int)pointer ) > 8 ); return false; } protected: int myNumberOfParameters; }; /////////////////////////////////////////////////////////////////////////////// //! Generic Event class with zero arguments template< class Class, class Return > class CGenericEvent0 : public CGenericEventBase { public: typedef CGenericEvent0< Class, Return > self_type; CGenericEvent0( Class* object, Return (Class::*func)() ) : myPointer( object ), myFunction( func ) { myNumberOfParameters = 0; } void Call() { (myPointer->*myFunction)(); } CGenericEventBase* Clone() const { return new CGenericEvent0< Class, Return >( myPointer, myFunction ); } void* GetPointer() const { return myPointer; } void SetPointer( void* p ) { myPointer = static_cast< Class* >( p ); } const std::type_info& GetTypeInfo() const { return typeid( this ); } bool CheckEvent( CGenericEventBase* event ) const { if( !( GetTypeInfo() == event->GetTypeInfo() ) ) return false; self_type* tevent = static_cast< self_type* >( event ); return ( tevent->myFunction == this->myFunction ); } private: Return (Class::*myFunction)(); Class* myPointer; }; //----------------------------------------------------------------------------- //! Generic Event class with one parameter template< class Class, class Return, class Arg1 > class CGenericEvent1 : public CGenericEventBase { public: typedef CGenericEvent1< Class, Return, Arg1 > self_type; CGenericEvent1( Class* object, Return (Class::*func)( Arg1 ) ) : myPointer( object ), myFunction( func ) { myNumberOfParameters = 1; } void Call( const CAnyContainer& arg1 ) { (myPointer->*myFunction)( CAnyContainerCast< Arg1 >( arg1 ) ); } CGenericEventBase* Clone() const { return new CGenericEvent1< Class, Return, Arg1 >( myPointer, myFunction ); } void* GetPointer() const { return myPointer; } void SetPointer( void* p ) { myPointer = static_cast< Class* >( p ); } const std::type_info& GetTypeInfo() const { return typeid( this ); } bool CheckEvent( CGenericEventBase* event ) const { if( !( GetTypeInfo() == event->GetTypeInfo() ) ) return false; self_type* tevent = static_cast< self_type* >( event ); return ( tevent->myFunction == this->myFunction ); } private: Return (Class::*myFunction)( Arg1 ); Class* myPointer; }; //----------------------------------------------------------------------------- //! Generic Event class with two parameters template< class Class, class Return, class Arg1, class Arg2 > class CGenericEvent2 : public CGenericEventBase { public: typedef CGenericEvent2< Class, Return, Arg1, Arg2 > self_type; CGenericEvent2( Class* object, Return (Class::*func)( Arg1, Arg2 ) ) : myPointer( object ), myFunction( func ) { myNumberOfParameters = 2; } void Call( const CAnyContainer& arg1, const CAnyContainer& arg2 ) { (myPointer->*myFunction)( CAnyContainerCast< Arg1 >( arg1 ), CAnyContainerCast< Arg2 >( arg2 ) ); } CGenericEventBase* Clone() const { return new CGenericEvent2< Class, Return, Arg1, Arg2 >( myPointer, myFunction ); } void* GetPointer() const { return myPointer; } void SetPointer( void* p ) { myPointer = static_cast< Class* >( p ); } const std::type_info& GetTypeInfo() const { return typeid( this ); } bool CheckEvent( CGenericEventBase* event ) const { if( !( GetTypeInfo() == event->GetTypeInfo() ) ) return false; self_type* tevent = static_cast< self_type* >( event ); return ( tevent->myFunction == this->myFunction ); } private: Return (Class::*myFunction)( Arg1, Arg2 ); Class* myPointer; }; //----------------------------------------------------------------------------- //! Generic Event class with three parameters //! Generic Event class with three parameters template< class Class, class Return, class Arg1, class Arg2, class Arg3 > class CGenericEvent3 : public CGenericEventBase { public: typedef CGenericEvent3< Class, Return, Arg1, Arg2, Arg3 > self_type; CGenericEvent3( Class* object, Return (Class::*func)( Arg1, Arg2, Arg3 ) ) : myPointer( object ), myFunction( func ) { myNumberOfParameters = 3; } void Call( const CAnyContainer& arg1, const CAnyContainer& arg2, const CAnyContainer& arg3 ) { (myPointer->*myFunction)( CAnyContainerCast< Arg1 >( arg1 ), CAnyContainerCast< Arg2 >( arg2 ), CAnyContainerCast< Arg3 >( arg3 ) ); } CGenericEventBase* Clone() const { return new CGenericEvent3< Class, Return, Arg1, Arg2, Arg3 >( myPointer, myFunction ); } void* GetPointer() const { return myPointer; } void SetPointer( void* p ) { myPointer = static_cast< Class* >( p ); } const std::type_info& GetTypeInfo() const { return typeid( this ); } bool CheckEvent( CGenericEventBase* event ) const { if( !( GetTypeInfo() == event->GetTypeInfo() ) ) return false; self_type* tevent = static_cast< self_type* >( event ); return ( tevent->myFunction == this->myFunction ); } private: Return (Class::*myFunction)( Arg1, Arg2, Arg3 ); Class* myPointer; }; /////////////////////////////////////////////////////////////////////////////// //! Generic Event for static functions template< class Return > class CSGenericEvent0 : public CGenericEventBase { public: typedef CSGenericEvent0< Return > self_type; CSGenericEvent0( Return (*func)() ) : myFunction( func ) { myNumberOfParameters = 0; } void Call() { (*myFunction)(); } CGenericEventBase* Clone() const { return new CSGenericEvent0< Return >( myFunction ); } void* GetPointer() const { return NULL; } const std::type_info& GetTypeInfo() const { return typeid( this ); } bool CheckEvent( CGenericEventBase* event ) const { if( !( GetTypeInfo() == event->GetTypeInfo() ) ) return false; self_type* tevent = static_cast< self_type* >( event ); return ( tevent->myFunction == this->myFunction ); } private: Return (*myFunction)() ; // function myFunction; }; //----------------------------------------------------------------------------- //! Generic Event class with zero arguments template< class Return, class Arg1 > class CSGenericEvent1 : public CGenericEventBase { public: typedef CSGenericEvent1< Return, Arg1 > self_type; CSGenericEvent1( Return (*func)( Arg1 ) ) : myFunction( func ) { myNumberOfParameters = 1; } void Call( const CAnyContainer& arg1 ) { (*myFunction)( CAnyContainerCast< Arg1 >( arg1 ) ); } CGenericEventBase* Clone() const { return new CSGenericEvent1< Return, Arg1 >( myFunction ); } void* GetPointer() const { return NULL; } const std::type_info& GetTypeInfo() const { return typeid( this ); } bool CheckEvent( CGenericEventBase* event ) const { if( !( GetTypeInfo() == event->GetTypeInfo() ) ) return false; self_type* tevent = static_cast< self_type* >( event ); return ( tevent->myFunction == this->myFunction ); } private: Return (*myFunction)( Arg1 ); }; //----------------------------------------------------------------------------- //! Generic Event class with zero arguments template< class Return, class Arg1, class Arg2 > class CSGenericEvent2 : public CGenericEventBase { public: typedef CSGenericEvent2< Return, Arg1, Arg2 > self_type; CSGenericEvent2( Return (*func)( Arg1, Arg2 ) ) : myFunction( func ) { myNumberOfParameters = 2; } void Call( const CAnyContainer& arg1, const CAnyContainer& arg2 ) { (*myFunction)( CAnyContainerCast< Arg1 >( arg1 ), CAnyContainerCast< Arg2 >( arg2 ) ); } CGenericEventBase* Clone() const { return new CSGenericEvent2< Return, Arg1, Arg2 >( myFunction ); } void* GetPointer() const { return NULL; } const std::type_info& GetTypeInfo() const { return typeid( this ); } bool CheckEvent( CGenericEventBase* event ) const { if( !( GetTypeInfo() == event->GetTypeInfo() ) ) return false; self_type* tevent = static_cast< self_type* >( event ); return ( tevent->myFunction == this->myFunction ); } private: Return (*myFunction)( Arg1, Arg2 ); }; /////////////////////////////////////////////////////////////////////////////// template< class Class, class Return > CGenericEventBase* CreateGenericEvent( Class* object, Return (Class::*func)() ) { return new CGenericEvent0< Class, Return >( object, func ); } template< class Class, class Return, class Arg1 > CGenericEventBase* CreateGenericEvent( Class* object, Return (Class::*func)(Arg1) ) { return new CGenericEvent1< Class, Return, Arg1 >( object, func ); } template< class Class, class Return, class Arg1, class Arg2 > CGenericEventBase* CreateGenericEvent( Class* object, Return (Class::*func)(Arg1, Arg2) ) { return new CGenericEvent2< Class, Return, Arg1, Arg2 >( object, func ); } template< class Class, class Return, class Arg1, class Arg2, class Arg3 > CGenericEventBase* CreateGenericEvent( Class* object, Return (Class::*func)(Arg1, Arg2, Arg3 ) ) { return new CGenericEvent3< Class, Return, Arg1, Arg2, Arg3 >( object, func ); } template< class Return > CGenericEventBase* CreateGenericEvent( Return (*func)() ) { return new CSGenericEvent0< Return >( func ); } template< class Return, class Arg1 > CGenericEventBase* CreateGenericEvent( Return (*func)( Arg1 ) ) { return new CSGenericEvent1< Return, Arg1 >( func ); } template< class Return, class Arg1, class Arg2 > CGenericEventBase* CreateGenericEvent( Return (*func)( Arg1, Arg2 ) ) { return new CSGenericEvent2< Return, Arg1, Arg2 >( func ); } /////////////////////////////////////////////////////////////////////////////// //! The event class. This reprisents a single function / method class CEvent { public: CEvent() : myEvent( NULL ) { } CEvent( const CEvent& other ) { if ( other.myEvent ) myEvent = other.myEvent->Clone(); else myEvent = NULL; } template< class Class, class Return > CEvent( Class* object, Return (Class::*func)() ) { myEvent = new CGenericEvent0< Class, Return >( object, func ); } template< class Class, class Return, class Arg1 > CEvent( Class* object, Return (Class::*func)(Arg1) ) { myEvent = new CGenericEvent1< Class, Return, Arg1 >( object, func ); } template< class Class, class Return, class Arg1, class Arg2 > CEvent( Class* object, Return (Class::*func)(Arg1, Arg2) ) { myEvent = new CGenericEvent2< Class, Return, Arg1, Arg2 >( object, func ); } template< class Return > CEvent( Return (*func)() ) { myEvent = new CSGenericEvent0< Return >( func ); } template< class Return, class Arg1 > CEvent( Return (*func)( Arg1 ) ) { myEvent = new CSGenericEvent1< Return, Arg1 >( func ); } template< class Return, class Arg1, class Arg2 > CEvent( Return (*func)( Arg1, Arg2 ) ) { myEvent = new CSGenericEvent2< Return, Arg1, Arg2 >( func ); } ~CEvent() { delete myEvent; myEvent = NULL; } CEvent& operator=( const CEvent& other ) { CEvent( other ).Swap( *this ); return *this; } template< class T > bool operator==( const T* pointer ) { return myEvent->IsA( pointer ); } void operator()() { myEvent->Call(); } template< class Arg1 > void operator()( const Arg1& a1 ) { myEvent->Call( a1 ); } template< class Arg1, class Arg2 > void operator()( const Arg1& a1, const Arg2& a2 ) { myEvent->Call( a1, a2 ); } private: CEvent& Swap( CEvent& other) { std::swap( myEvent, other.myEvent ); return *this; } CGenericEventBase* myEvent; }; } // end of namespace ceng #endif
26.843034
135
0.609921
[ "object" ]
3374f14b436609386a46d041e11136df7b5e4ae7
3,350
h
C
src/nmworkerwpa.h
Peter2121/nmdaemon
3edc679d634838b96f83d36644a250980c430f21
[ "BSD-3-Clause" ]
2
2021-12-05T13:44:57.000Z
2021-12-06T19:09:30.000Z
src/nmworkerwpa.h
Peter2121/nmdaemon
3edc679d634838b96f83d36644a250980c430f21
[ "BSD-3-Clause" ]
null
null
null
src/nmworkerwpa.h
Peter2121/nmdaemon
3edc679d634838b96f83d36644a250980c430f21
[ "BSD-3-Clause" ]
null
null
null
#ifndef NMWORKERWPA_H #define NMWORKERWPA_H #include <unistd.h> #include <sys/socket.h> #include <net/route.h> #include <filesystem> #include <sstream> #include <vector> #include <algorithm> #include <string_view> #include <thread> //#define LOGURU_WITH_STREAMS 1 #include "loguru/loguru.hpp" #include "sockpp/socket.h" #include "sockpp/unix_dgram_socket.h" #include "sockpp/version.h" #include "nmworkerbase.h" #include "addressgroup.h" #include "tool.h" namespace fs = std::filesystem; class NmWorkerWpa : public NmWorkerBase { protected: static constexpr NmCommand Cmds[] = { { NmScope::WPA, NmCmd::WPA_LIST_IF }, { NmScope::WPA, NmCmd::WPA_LIST }, { NmScope::WPA, NmCmd::WPA_SCAN }, { NmScope::WPA, NmCmd::WPA_STATUS }, { NmScope::WPA, NmCmd::WPA_SETPSK }, { NmScope::WPA, NmCmd::WPA_CONNECT }, { NmScope::WPA, NmCmd::WPA_DISCONNECT }, { NmScope::WPA, NmCmd::WPA_REASSOC }, { NmScope::WPA, NmCmd::WPA_ADD }, { NmScope::WPA, NmCmd::WPA_REMOVE } }; static inline const std::string COMMAND_LIST = "LIST_NETWORKS"; static inline const std::string COMMAND_SCAN = "SCAN"; static inline const std::string COMMAND_SCAN_RESULTS = "SCAN_RESULTS"; static inline const std::string COMMAND_PING = "PING"; static inline const std::string COMMAND_STATUS = "STATUS"; static inline const std::string COMMAND_ADD = "ADD_NETWORK"; static inline const std::string COMMAND_SET = "SET_NETWORK"; static inline const std::string COMMAND_SELECT = "SELECT_NETWORK"; static inline const std::string COMMAND_REMOVE = "REMOVE_NETWORK"; static inline const std::string COMMAND_ATTACH = "ATTACH"; static inline const std::string COMMAND_DISCONNECT = "DISCONNECT"; static inline const std::string COMMAND_REASSOCIATE = "REASSOCIATE"; static constexpr int BUF_LEN = 4096; static constexpr std::chrono::milliseconds WAIT_TIME = std::chrono::milliseconds(200); static constexpr int WAIT_CYCLES = 10; char* buf = nullptr; const std::string csaPrefix = "/tmp/nmd_wpaw.XXXXX"; const std::string defSsaDir = "/var/run/wpa_supplicant/"; std::string cliSockAddr; std::string srvSockAddrDir; bool wpaCtrlCmd(const std::string, const std::string); bool wpaCtrlCmd(const std::string, const std::string, const std::string); bool isValidWpaIf(std::string); json getJsonFromBufTable(std::string); json getJsonFromBufLines(std::string); std::string getParamFromCommand(NmCommandData*, std::string); bool setNetworkParam(std::string, int, std::string, std::string, bool); char* searchLineInBuf(const char* mask); bool removeNetwork(std::string, int); public: NmWorkerWpa(); NmWorkerWpa(std::string); ~NmWorkerWpa(); NmScope getScope(); json execCmd(NmCommandData*); bool isValidCmd(NmCommandData*); json execCmdWpaListIf(NmCommandData*); json execCmdWpaList(NmCommandData*); json execCmdWpaScan(NmCommandData*); json execCmdWpaStatus(NmCommandData*); json execCmdWpaSetPsk(NmCommandData*); json execCmdWpaConnect(NmCommandData*); json execCmdWpaDisconnect(NmCommandData*); json execCmdWpaReassoc(NmCommandData*); json execCmdWpaAdd(NmCommandData*); json execCmdWpaRemove(NmCommandData*); }; #endif // NMWORKERWPA_H
36.021505
90
0.70806
[ "vector" ]
33776b0940ccc3103198c2f1376c55d953f1f7d3
2,337
h
C
src/atlas/linalg/View.h
twsearle/atlas
a1916fd521f9935f846004e6194f80275de4de83
[ "Apache-2.0" ]
67
2018-03-01T06:56:49.000Z
2022-03-08T18:44:47.000Z
src/atlas/linalg/View.h
twsearle/atlas
a1916fd521f9935f846004e6194f80275de4de83
[ "Apache-2.0" ]
93
2018-12-07T17:38:04.000Z
2022-03-31T10:04:51.000Z
src/atlas/linalg/View.h
twsearle/atlas
a1916fd521f9935f846004e6194f80275de4de83
[ "Apache-2.0" ]
33
2018-02-28T17:06:19.000Z
2022-01-20T12:12:27.000Z
/* * (C) Copyright 2013 ECMWF. * * This software is licensed under the terms of the Apache Licence Version 2.0 * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. * In applying this licence, ECMWF does not waive the privileges and immunities * granted to it by virtue of its status as an intergovernmental organisation * nor does it submit to any jurisdiction. */ #pragma once #include <type_traits> #include "eckit/linalg/Matrix.h" #include "eckit/linalg/Vector.h" #include "atlas/array/LocalView.h" #include "atlas/linalg/Introspection.h" namespace atlas { namespace linalg { template <typename Value, int Rank> using View = array::LocalView<Value, Rank>; namespace view { template <typename View, typename> struct Convert { using value_type = typename std::conditional<std::is_const<View>::value, const introspection::value_type<View>, introspection::value_type<View>>::type; using type = array::LocalView<value_type, introspection::rank<View>()>; static type apply(View& view) { return type(view.data(), view.shape()); } }; template <typename View> struct Convert<View, eckit::linalg::Vector> { using value_type = typename std::conditional<std::is_const<View>::value, const eckit::linalg::Scalar, eckit::linalg::Scalar>::type; using type = array::LocalView<value_type, 1>; static type apply(View& v) { return type(v.data(), array::make_shape(v.size())); } }; template <typename View> struct Convert<View, eckit::linalg::Matrix> { using value_type = typename std::conditional<std::is_const<View>::value, const eckit::linalg::Scalar, eckit::linalg::Scalar>::type; using type = array::LocalView<value_type, 2>; static type apply(View& m) { return type(m.data(), array::make_shape(m.cols(), m.rows())); } }; template <typename View> struct ConvertView { using type = typename Convert<View, introspection::base_type<View>>::type; static type apply(View& v) { return Convert<View, introspection::base_type<View>>::apply(v); } }; } // namespace view template <typename View> using view_type = typename view::ConvertView<View>::type; template <typename T> view_type<T> make_view(T& view) { return view::ConvertView<T>::apply(view); } } // namespace linalg } // namespace atlas
32.915493
120
0.697903
[ "shape", "vector" ]
337c9a0bc48b7b019e5c911ba576332f3271ef25
16,659
h
C
src/lib/storage/AbstractTable.h
jmarten/hyrise
795d8c1c55ed6cbd313d88cee40610006fa85669
[ "MIT" ]
null
null
null
src/lib/storage/AbstractTable.h
jmarten/hyrise
795d8c1c55ed6cbd313d88cee40610006fa85669
[ "MIT" ]
null
null
null
src/lib/storage/AbstractTable.h
jmarten/hyrise
795d8c1c55ed6cbd313d88cee40610006fa85669
[ "MIT" ]
null
null
null
// Copyright (c) 2012 Hasso-Plattner-Institut fuer Softwaresystemtechnik GmbH. All rights reserved. /** @file AbstractTable.h * * Contains the class definition of AbstractTable. * */ #pragma once #include <limits> #include <memory> #include <stdexcept> #include <functional> #include <vector> #include <string> #include "helper/types.h" #include "io/logging.h" #include "helper/locking.h" #include "helper/checked_cast.h" #include "helper/unique_id.h" #include "storage/AbstractResource.h" #include "storage/BaseDictionary.h" #include "storage/storage_types.h" #include <json.h> namespace hyrise { namespace storage { class ColumnMetadata; class AbstractDictionary; class AbstractAttributeVector; typedef struct { std::shared_ptr<AbstractAttributeVector> attribute_vector; size_t attribute_offset; } attr_vector_offset_t; typedef std::vector<attr_vector_offset_t> attr_vectors_t; class StorageException : public std::runtime_error { public: explicit StorageException(const std::string& msg) : std::runtime_error(msg) {} }; class MissingColumnException : public std::runtime_error { public: explicit MissingColumnException(const std::string& what) : std::runtime_error(what) {} }; /** * Abstract table is the magic base class for all data storages, it is used * in many different ways, in containers, plain tables, intermediate results * and more. */ class AbstractTable : public AbstractResource { public: typedef std::shared_ptr<AbstractDictionary> SharedDictionaryPtr; /** * Copy the table's structure. * Returns a pointer to an AbstractTable with a copy of the current table's * structure, containing all fields specified in the first parameter or all * if left empty, as well as the current table's dictionary for those fields * in case reuse_dict is set to true. * * @param fields List of fields to be copied (all if empty or nullptr). * @param reuse_dict Also copy the table's dictionary (default=false). * @param initial_size Initial size of the returned table (default=0). * @param with_containers Only used by derived classes. * @param compressed Sets the compressed storage for the new table */ virtual atable_ptr_t copy_structure(const field_list_t* fields = nullptr, bool reuse_dict = false, size_t initial_size = 0, bool with_containers = true, bool compressed = false) const; /** * Copy the table's structure modifiable. * Returns a pointer to an AbstractTable with a copy of the current table's * structure, containing all fields specified in the first parameter or all * if left empty, as well as the current table's dictionary-type for each * field, without values for future modification. * * @param fields List of fields to be copied (all if empty or nullptr). * @param initial_size Initial size of the returned table (default=0). * @param with_containers Only used by derived classes. */ virtual atable_ptr_t copy_structure_modifiable(const field_list_t* fields = nullptr, size_t initial_size = 0, bool with_containers = true, bool nonvolatile = false) const; typedef std::function<std::shared_ptr<AbstractDictionary>(DataType)> abstract_dictionary_callback; typedef std::function<std::shared_ptr<AbstractAttributeVector>(std::size_t)> abstract_attribute_vector_callback; /** * Copy structure with factory functions to replace attribute vectors and dictionaries * in `Table` instances. May need future enhancement for more fine-grained replacement * (i.e. per column or per main/delta or per partition). */ virtual atable_ptr_t copy_structure(abstract_dictionary_callback, abstract_attribute_vector_callback) const { throw std::runtime_error("not implemented"); } /** * Get the value-IDs for a certain row. * Returns a ValueIdList object containing a vector of ValueIds for all * specified fields in a given row. * * @param row Row from which to extract the ValueIDs. * @param fields List of respected fields (all if empty). */ ValueIdList copyValueIds(size_t row, const field_list_t* fields = nullptr) const; /** * Get the metadata for a certain column. * Returns a pointer to a ColumnMetadata object for a specified column. * @note Must be implemented by any derived class! * * @param column Column for which to return the metadata. * @param row Row in that column (default=0). * @param table_id ID of the table from which to extract (default=0). */ virtual const ColumnMetadata& metadataAt(size_t column, size_t row = 0, table_id_t table_id = 0) const = 0; /** * Returs a list of references to metadata of this table. * * The list is newly created for all calls to this method, but the * references stay the same. Thus calling this method incurrs a * linear cost to the width of the table. */ metadata_vec_t metadata() const; /** * Get the dictionary for a certain column. * @note Must be implemented by any derived class! * * @param column Column from which to extract the dictionary. * @param row Row in that column (default=0). * @param table_id ID of the table from which to extract (default=0). */ virtual const SharedDictionaryPtr& dictionaryAt(size_t column, size_t row = 0, table_id_t table_id = 0) const = 0; /** * Get the dictionary for a certain column by table ID. * @note Must be implemented by any derived class! * * @param column Column from which to extract the dictionary. * @param table_id ID of the table from which to extract. */ virtual const SharedDictionaryPtr& dictionaryByTableId(size_t column, table_id_t table_id) const = 0; /** * Get all dictionaries. * */ std::vector<SharedDictionaryPtr>* dictionaries() const; /** * Sets the dictionary for a certain column. * @note Must be implemented by any derived class! * * @param dict Dictionary to be used. * @param column Column for which to set the dictionary. * @param row Row in that column (default=0). * @param table_id ID of the table (default=0). */ virtual void setDictionaryAt(SharedDictionaryPtr dict, size_t column, size_t row = 0, table_id_t table_id = 0) = 0; /** * Returns the type of the column. * @note Must be implemented by any derived class! * * @param column Column from which to extract the type. */ DataType typeOfColumn(size_t column) const; /** * Returns the number of rows in the table * @note Must be implemented by any derived class! */ virtual size_t size() const = 0; /** * Returns the number of columns. * @note Must be implemented by any derived class! */ virtual size_t columnCount() const = 0; /** * Returns the number of a column by its name. * * @param column Name of the column as String. */ field_t numberOfColumn(const std::string& column) const; /** * Returns the name of a column by its number. * * @param column Number of the column as numeric value. */ const std::string& nameOfColumn(size_t column) const; /** * Returns the value-ID of a cell. * @note Must be implemented by any derived class! * * @param column Column number of the cell. * @param row Row number of the cell. */ virtual ValueId getValueId(size_t column, size_t row) const = 0; /** * Sets the value ID of a cell. * @note Should be implemented in derived classes or throws runtime error! * * @param column Column number of the cell. * @param row Row number of the cell. * @param valueId New value-ID of the cell. */ virtual void setValueId(size_t column, size_t row, const ValueId valueId); /** * Reorganizes the bit vector of a certain column. * @warning Throws runtime error if not implemented! * * @param nr_of_values Total number of values that must fit. */ virtual void reserve(size_t nr_of_values); /** * Resize the table to the given number of rows based on the * parameter * @warning Throws runtime error if not implemented * * @param rows The new number of rows in this table */ virtual void resize(size_t rows); /** * Returns the number of partitions in this table. * @note Must be implemented by any derived class! */ virtual unsigned partitionCount() const = 0; /** * Returns the width of a specified partition in number of attributes. * @note Must be implemented by any derived class! * * @param slice The slice of interest. */ virtual size_t partitionWidth(size_t slice) const = 0; /** * Prints the table */ virtual void print(size_t limit = (size_t) - 1) const; /** * Returns the number of horizontal subtables. * @note Must be implemented by any derived class! */ virtual table_id_t subtableCount() const = 0; /** * Templated method to retrieve the value-ID for a given value. * * @param column Column containing the value. * @param value The value. * @param create Create the value if it is not existing (default=false) * @param table_id ID of the table containing the value (default=0). */ template <typename T> inline ValueId getValueIdForValue(const size_t column, const T value, const bool create = false, const table_id_t table_id = 0) const { // FIXME horizontal containers will go down here, needs a row index, can be default 0 const auto& map = checked_pointer_cast<BaseDictionary<T>>(dictionaryAt(column, 0, table_id)); ValueId valueId; valueId.table = table_id; valueId.valueId = map->getValueId(value, create); return valueId; } /** * Templated method, checks whether or not a value is contained in a column. * * @param column Column to check. * @param value Value to look for. * @param table_id ID of the table (default=0). */ template <typename T> inline bool valueExists(const field_t column, const T value, const table_id_t table_id = 0) const { const auto& map = checked_pointer_cast<BaseDictionary<T>>(dictionaryAt(column, 0, table_id)); return map->valueExists(value); } /** * Templated base method for setting a value. * * @param column Column of the cell. * @param row Row of the cell. * @param value Value to be assigned to the cell. */ template <typename T> void setValue(size_t column, size_t row, const T& value) { const auto& map = checked_pointer_cast<BaseDictionary<T>>(dictionaryAt(column, row)); ValueId valueId; valueId.table = 0; valueId.valueId = map->findValueIdForValue(value); if (valueId.valueId == std::numeric_limits<value_id_t>::max()) { valueId.valueId = map->addValue(value); io::Logger::getInstance().logDictionary<T>(getName(), column, value, valueId.valueId); } setValueId(column, row, valueId); } template <typename T> void setValue(field_name_t column, size_t row, const T& value) { setValue(numberOfColumn(column), row, value); } /** * Templated method for retrieving a value by its ID. * * @param column Column containing the value. * @param valueId ID of the value to be returned. */ template <typename T> inline T getValueForValueId(const field_t column, const ValueId valueId, const size_t row = 0) const { typedef BaseDictionary<T> dict_t; if (valueId.table != 0) { return (static_cast<dict_t*>(dictionaryByTableId(column, valueId.table).get())) ->getValueForValueId(valueId.valueId); } else { return (static_cast<dict_t*>(dictionaryAt(column, row).get()))->getValueForValueId(valueId.valueId); } } /** * Templated method for retrieving a value from a cell. * * @param column Column of the cell. * @param row Row of the cell. */ template <typename T> T getValue(const field_t column, const size_t row) const { ValueId valueId = getValueId(column, row); return getValueForValueId<T>(column, valueId, row); } /** * Templated method for retrieving a value from a cell. * * @param column Column of the cell. * @param row Row of the cell. */ template <typename T> T getValue(const field_name_t& column_name, const size_t row) const { size_t column = numberOfColumn(column_name); return getValue<T>(column, row); } /** * Print the value. * * @param column Column of the cell containing the value. * @param row Row of the cell containing the value. */ std::string printValue(size_t column, size_t row) const; /** * Templated method for copying a value from another table. * * @param source Table from which to copy the value. * @param src_col Column of the source cell. * @param src_row Row of the source cell. * @param dst_col Column of the target cell. * @param dst_row Row of the target cell. */ template <typename T> void copyValueFrom(const c_atable_ptr_t& source, const size_t src_col, const size_t src_row, const size_t dst_col, const size_t dst_row) { T value = source->getValue<T>(src_col, src_row); setValue<T>(dst_col, dst_row, value); } /** * Copies a value from another table by column and row. * * @param source Table from which to copy the value. * @param src_col Column of the source cell. * @param src_row Row of the source cell. * @param dst_col Column of the target cell. * @param dst_row Row of the target cell. */ void copyValueFrom(const c_atable_ptr_t& source, size_t src_col, size_t src_row, size_t dst_col, size_t dst_row); /** * Copies a row from another table with or without values. * * @param source Table from which to copy the value. * @param src_row Row in the source table. * @param dst_row Row in the target table. * @param copy_values Also copy the values (default=true). * @param use_memcpy Use memcpy for the copying (default=true). */ void copyRowFrom(const c_atable_ptr_t& source, size_t src_row, size_t dst_row, bool copy_values = true, bool use_memcpy = true); void copyRowFromJSONVector(const std::vector<Json::Value>& source, size_t dst_row); void copyRowFromStringVector(const std::vector<std::string>& source, size_t dst_row); /** * Write the table data into a file as-is. * * @param filename Name of the file to be written to. */ void write(const std::string& filename) const; /** * Test for equality of this table's content with another table's. * * @param other Table to compare content to. */ bool contentEquals(const c_atable_ptr_t& other) const; /** * Create of copy of this table. * @note Must be implemented by any derived class! */ virtual atable_ptr_t copy() const = 0; /** * get underlying attribute vectors for column * * This method returns a struct containing the reference to the attribute * vector and the offset of the attribut in this vector. This allows a direct * access to the memory and keeping the high-level data structures. */ virtual const attr_vectors_t getAttributeVectors(size_t column) const; virtual void debugStructure(size_t level = 0) const; unique_id getUuid() const; void setUuid(unique_id = unique_id()); virtual void setName(const std::string name); const std::string getName() const; virtual void persist_scattered(const pos_list_t& elements, bool new_elements = true) const = 0; bool loggingEnabled() const { return logging; }; virtual void enableLogging() { logging = true; } size_t _checkpoint_size = std::numeric_limits<size_t>::max(); size_t checkpointSize() { if (_checkpoint_size != std::numeric_limits<size_t>::max()) { return _checkpoint_size; } else { return size(); } }; void prepareCheckpoint() { _checkpoint_size = this->size(); for (size_t i = 0; i < columnCount(); ++i) { this->dictionaryAt(i)->prepareCheckpoint(); } } protected: // Global unique identifier for this object unique_id _uuid; std::string _name; bool logging; }; } } // namespace hyrise::storage
31.975048
117
0.672249
[ "object", "vector" ]
338363e2acad9713bfeccb1b786ab686e84cb529
9,602
h
C
tools/host/openocd/src/flash/nor/core.h
ghsecuritylab/Alios_SDK
edd416e7d2961db42c2100ac2d6237ee527d1aee
[ "Apache-2.0" ]
2
2021-05-28T08:25:33.000Z
2021-11-17T02:58:50.000Z
tools/host/openocd/src/flash/nor/core.h
ghsecuritylab/Alios_SDK
edd416e7d2961db42c2100ac2d6237ee527d1aee
[ "Apache-2.0" ]
null
null
null
tools/host/openocd/src/flash/nor/core.h
ghsecuritylab/Alios_SDK
edd416e7d2961db42c2100ac2d6237ee527d1aee
[ "Apache-2.0" ]
5
2018-05-23T02:56:10.000Z
2021-01-02T16:44:09.000Z
/*************************************************************************** * Copyright (C) 2005 by Dominic Rath <Dominic.Rath@gmx.de> * * Copyright (C) 2007,2008 Øyvind Harboe <oyvind.harboe@zylin.com> * * Copyright (C) 2008 by Spencer Oliver <spen@spen-soft.co.uk> * * Copyright (C) 2009 Zachary T Welch <zw@superlucidity.net> * * Copyright (C) 2010 by Antonio Borneo <borneo.antonio@gmail.com> * * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * * * * This program is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU General Public License for more details. * * * * You should have received a copy of the GNU General Public License * * along with this program. If not, see <http://www.gnu.org/licenses/>. * ***************************************************************************/ #ifndef OPENOCD_FLASH_NOR_CORE_H #define OPENOCD_FLASH_NOR_CORE_H #include <flash/common.h> /** * @file * Upper level NOR flash interfaces. */ struct image; #define FLASH_MAX_ERROR_STR (128) /** * Describes the geometry and status of a single flash sector * within a flash bank. A single bank typically consists of multiple * sectors, each of which can be erased and protected independently. */ struct flash_sector { /** Bus offset from start of the flash chip (in bytes). */ uint32_t offset; /** Number of bytes in this flash sector. */ uint32_t size; /** * Indication of erasure status: 0 = not erased, 1 = erased, * other = unknown. Set by @c flash_driver_s::erase_check. * * Flag is not used in protection block */ int is_erased; /** * Indication of protection status: 0 = unprotected/unlocked, * 1 = protected/locked, other = unknown. Set by * @c flash_driver_s::protect_check. * * This information must be considered stale immediately. * A million things could make it stale: power cycle, * reset of target, code running on target, etc. * * If a flash_bank uses an extra array of protection blocks, * protection flag is not valid in sector array */ int is_protected; }; /** * Provides details of a flash bank, available either on-chip or through * a major interface. * * This structure will be passed as a parameter to the callbacks in the * flash_driver_s structure, some of which may modify the contents of * this structure of the area of flash that it defines. Driver writers * may use the @c driver_priv member to store additional data on a * per-bank basis, if required. */ struct flash_bank { const char *name; struct target *target; /**< Target to which this bank belongs. */ struct flash_driver *driver; /**< Driver for this bank. */ void *driver_priv; /**< Private driver storage pointer */ int bank_number; /**< The 'bank' (or chip number) of this instance. */ uint32_t base; /**< The base address of this bank */ uint32_t size; /**< The size of this chip bank, in bytes */ int chip_width; /**< Width of the chip in bytes (1,2,4 bytes) */ int bus_width; /**< Maximum bus width, in bytes (1,2,4 bytes) */ /** Erased value. Defaults to 0xFF. */ uint8_t erased_value; /** Default padded value used, normally this matches the flash * erased value. Defaults to 0xFF. */ uint8_t default_padded_value; /** * The number of sectors on this chip. This value will * be set intially to 0, and the flash driver must set this to * some non-zero value during "probe()" or "auto_probe()". */ int num_sectors; /** Array of sectors, allocated and initialized by the flash driver */ struct flash_sector *sectors; /** * The number of protection blocks in this bank. This value * is set intially to 0 and sectors are used as protection blocks. * Driver probe can set protection blocks array to work with * protection granularity different than sector size. */ int num_prot_blocks; /** Array of protection blocks, allocated and initilized by the flash driver */ struct flash_sector *prot_blocks; struct flash_bank *next; /**< The next flash bank on this chip */ }; /** Registers the 'flash' subsystem commands */ int flash_register_commands(struct command_context *cmd_ctx); /** * Erases @a length bytes in the @a target flash, starting at @a addr. * The range @a addr to @a addr + @a length - 1 must be strictly * sector aligned, unless @a pad is true. Setting @a pad true extends * the range, at beginning and/or end, if needed for sector alignment. * @returns ERROR_OK if successful; otherwise, an error code. */ int flash_erase_address_range(struct target *target, bool pad, uint32_t addr, uint32_t length); int flash_unlock_address_range(struct target *target, uint32_t addr, uint32_t length); /** * Writes @a image into the @a target flash. The @a written parameter * will contain the * @param target The target with the flash to be programmed. * @param image The image that will be programmed to flash. * @param written On return, contains the number of bytes written. * @param erase If non-zero, indicates the flash driver should first * erase the corresponding banks or sectors before programming. * @returns ERROR_OK if successful; otherwise, an error code. */ int flash_write(struct target *target, struct image *image, uint32_t *written, int erase); /** * Forces targets to re-examine their erase/protection state. * This routine must be called when the system may modify the status. */ void flash_set_dirty(void); /** @returns The number of flash banks currently defined. */ int flash_get_bank_count(void); /** * Provides default read implementation for flash memory. * @param bank The bank to read. * @param buffer The data bytes read. * @param offset The offset into the chip to read. * @param count The number of bytes to read. * @returns ERROR_OK if successful; otherwise, an error code. */ int default_flash_read(struct flash_bank *bank, uint8_t *buffer, uint32_t offset, uint32_t count); /** * Provides default erased-bank check handling. Checks to see if * the flash driver knows they are erased; if things look uncertain, * this routine will call default_flash_mem_blank_check() to confirm. * @returns ERROR_OK if successful; otherwise, an error code. */ int default_flash_blank_check(struct flash_bank *bank); /** * Returns the flash bank specified by @a name, which matches the * driver name and a suffix (option) specify the driver-specific * bank number. The suffix consists of the '.' and the driver-specific * bank number: when two str9x banks are defined, then 'str9x.1' refers * to the second. */ int get_flash_bank_by_name(const char *name, struct flash_bank **bank_result); /** * Returns the flash bank specified by @a name, which matches the * driver name and a suffix (option) specify the driver-specific * bank number. The suffix consists of the '.' and the driver-specific * bank number: when two str9x banks are defined, then 'str9x.1' refers * to the second. */ struct flash_bank *get_flash_bank_by_name_noprobe(const char *name); /** * Returns the flash bank like get_flash_bank_by_name(), without probing. * @param num The flash bank number. * @param bank returned bank if fn returns ERROR_OK * @returns ERROR_OK if successful */ int get_flash_bank_by_num(int num, struct flash_bank **bank); /** * Retreives @a bank from a command argument, reporting errors parsing * the bank identifier or retreiving the specified bank. The bank * may be identified by its bank number or by @c name.instance, where * @a instance is driver-specific. * @param name_index The index to the string in args containing the * bank identifier. * @param bank On output, contians a pointer to the bank or NULL. * @returns ERROR_OK on success, or an error indicating the problem. */ COMMAND_HELPER(flash_command_get_bank, unsigned name_index, struct flash_bank **bank); /** * Returns the flash bank like get_flash_bank_by_num(), without probing. * @param num The flash bank number. * @returns A struct flash_bank for flash bank @a num, or NULL. */ struct flash_bank *get_flash_bank_by_num_noprobe(int num); /** * Returns the flash bank located at a specified address. * @param target The target, presumed to contain one or more banks. * @param addr An address that is within the range of the bank. * @param check return ERROR_OK and result_bank NULL if the bank does not exist * @returns The struct flash_bank located at @a addr, or NULL. */ int get_flash_bank_by_addr(struct target *target, uint32_t addr, bool check, struct flash_bank **result_bank); /** * Allocate and fill an array of sectors or protection blocks. * @param offset Offset of first block. * @param size Size of each block. * @param num_blocks Number of blocks in array. * @returns A struct flash_sector pointer or NULL when allocation failed. */ struct flash_sector *alloc_block_array(uint32_t offset, uint32_t size, int num_blocks); #endif /* OPENOCD_FLASH_NOR_CORE_H */
40.686441
87
0.692252
[ "geometry" ]
338cc8c163c694d076955d24737b08d0088626ec
14,505
h
C
emr/include/tencentcloud/emr/v20190103/model/RunJobFlowRequest.h
suluner/tencentcloud-sdk-cpp
a56c73cc3f488c4d1e10755704107bb15c5e000d
[ "Apache-2.0" ]
43
2019-08-14T08:14:12.000Z
2022-03-30T12:35:09.000Z
emr/include/tencentcloud/emr/v20190103/model/RunJobFlowRequest.h
suluner/tencentcloud-sdk-cpp
a56c73cc3f488c4d1e10755704107bb15c5e000d
[ "Apache-2.0" ]
12
2019-07-15T10:44:59.000Z
2021-11-02T12:35:00.000Z
emr/include/tencentcloud/emr/v20190103/model/RunJobFlowRequest.h
suluner/tencentcloud-sdk-cpp
a56c73cc3f488c4d1e10755704107bb15c5e000d
[ "Apache-2.0" ]
28
2019-07-12T09:06:22.000Z
2022-03-30T08:04:18.000Z
/* * Copyright (c) 2017-2019 THL A29 Limited, a Tencent company. All Rights Reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #ifndef TENCENTCLOUD_EMR_V20190103_MODEL_RUNJOBFLOWREQUEST_H_ #define TENCENTCLOUD_EMR_V20190103_MODEL_RUNJOBFLOWREQUEST_H_ #include <string> #include <vector> #include <map> #include <tencentcloud/core/AbstractModel.h> #include <tencentcloud/emr/v20190103/model/Step.h> #include <tencentcloud/emr/v20190103/model/BootstrapAction.h> #include <tencentcloud/emr/v20190103/model/Configuration.h> #include <tencentcloud/emr/v20190103/model/ClusterSetting.h> namespace TencentCloud { namespace Emr { namespace V20190103 { namespace Model { /** * RunJobFlow请求参数结构体 */ class RunJobFlowRequest : public AbstractModel { public: RunJobFlowRequest(); ~RunJobFlowRequest() = default; std::string ToJsonString() const; /** * 获取作业名称。 * @return Name 作业名称。 */ std::string GetName() const; /** * 设置作业名称。 * @param Name 作业名称。 */ void SetName(const std::string& _name); /** * 判断参数 Name 是否已赋值 * @return Name 是否已赋值 */ bool NameHasBeenSet() const; /** * 获取是否新创建集群。 true,新创建集群,则使用Instance中的参数进行集群创建。 false,使用已有集群,则通过InstanceId传入。 * @return CreateCluster 是否新创建集群。 true,新创建集群,则使用Instance中的参数进行集群创建。 false,使用已有集群,则通过InstanceId传入。 */ bool GetCreateCluster() const; /** * 设置是否新创建集群。 true,新创建集群,则使用Instance中的参数进行集群创建。 false,使用已有集群,则通过InstanceId传入。 * @param CreateCluster 是否新创建集群。 true,新创建集群,则使用Instance中的参数进行集群创建。 false,使用已有集群,则通过InstanceId传入。 */ void SetCreateCluster(const bool& _createCluster); /** * 判断参数 CreateCluster 是否已赋值 * @return CreateCluster 是否已赋值 */ bool CreateClusterHasBeenSet() const; /** * 获取作业流程执行步骤。 * @return Steps 作业流程执行步骤。 */ std::vector<Step> GetSteps() const; /** * 设置作业流程执行步骤。 * @param Steps 作业流程执行步骤。 */ void SetSteps(const std::vector<Step>& _steps); /** * 判断参数 Steps 是否已赋值 * @return Steps 是否已赋值 */ bool StepsHasBeenSet() const; /** * 获取作业流程正常完成时,集群的处理方式,可选择: Terminate 销毁集群。 Reserve 保留集群。 * @return InstancePolicy 作业流程正常完成时,集群的处理方式,可选择: Terminate 销毁集群。 Reserve 保留集群。 */ std::string GetInstancePolicy() const; /** * 设置作业流程正常完成时,集群的处理方式,可选择: Terminate 销毁集群。 Reserve 保留集群。 * @param InstancePolicy 作业流程正常完成时,集群的处理方式,可选择: Terminate 销毁集群。 Reserve 保留集群。 */ void SetInstancePolicy(const std::string& _instancePolicy); /** * 判断参数 InstancePolicy 是否已赋值 * @return InstancePolicy 是否已赋值 */ bool InstancePolicyHasBeenSet() const; /** * 获取只有CreateCluster为true时生效,目前只支持EMR版本,例如EMR-2.2.0,不支持ClickHouse和Druid版本。 * @return ProductVersion 只有CreateCluster为true时生效,目前只支持EMR版本,例如EMR-2.2.0,不支持ClickHouse和Druid版本。 */ std::string GetProductVersion() const; /** * 设置只有CreateCluster为true时生效,目前只支持EMR版本,例如EMR-2.2.0,不支持ClickHouse和Druid版本。 * @param ProductVersion 只有CreateCluster为true时生效,目前只支持EMR版本,例如EMR-2.2.0,不支持ClickHouse和Druid版本。 */ void SetProductVersion(const std::string& _productVersion); /** * 判断参数 ProductVersion 是否已赋值 * @return ProductVersion 是否已赋值 */ bool ProductVersionHasBeenSet() const; /** * 获取只在CreateCluster为true时生效。 true 表示安装kerberos,false表示不安装kerberos。 * @return SecurityClusterFlag 只在CreateCluster为true时生效。 true 表示安装kerberos,false表示不安装kerberos。 */ bool GetSecurityClusterFlag() const; /** * 设置只在CreateCluster为true时生效。 true 表示安装kerberos,false表示不安装kerberos。 * @param SecurityClusterFlag 只在CreateCluster为true时生效。 true 表示安装kerberos,false表示不安装kerberos。 */ void SetSecurityClusterFlag(const bool& _securityClusterFlag); /** * 判断参数 SecurityClusterFlag 是否已赋值 * @return SecurityClusterFlag 是否已赋值 */ bool SecurityClusterFlagHasBeenSet() const; /** * 获取只在CreateCluster为true时生效。 新建集群时,要安装的软件列表。 * @return Software 只在CreateCluster为true时生效。 新建集群时,要安装的软件列表。 */ std::vector<std::string> GetSoftware() const; /** * 设置只在CreateCluster为true时生效。 新建集群时,要安装的软件列表。 * @param Software 只在CreateCluster为true时生效。 新建集群时,要安装的软件列表。 */ void SetSoftware(const std::vector<std::string>& _software); /** * 判断参数 Software 是否已赋值 * @return Software 是否已赋值 */ bool SoftwareHasBeenSet() const; /** * 获取引导脚本。 * @return BootstrapActions 引导脚本。 */ std::vector<BootstrapAction> GetBootstrapActions() const; /** * 设置引导脚本。 * @param BootstrapActions 引导脚本。 */ void SetBootstrapActions(const std::vector<BootstrapAction>& _bootstrapActions); /** * 判断参数 BootstrapActions 是否已赋值 * @return BootstrapActions 是否已赋值 */ bool BootstrapActionsHasBeenSet() const; /** * 获取指定配置创建集群。 * @return Configurations 指定配置创建集群。 */ std::vector<Configuration> GetConfigurations() const; /** * 设置指定配置创建集群。 * @param Configurations 指定配置创建集群。 */ void SetConfigurations(const std::vector<Configuration>& _configurations); /** * 判断参数 Configurations 是否已赋值 * @return Configurations 是否已赋值 */ bool ConfigurationsHasBeenSet() const; /** * 获取作业日志保存地址。 * @return LogUri 作业日志保存地址。 */ std::string GetLogUri() const; /** * 设置作业日志保存地址。 * @param LogUri 作业日志保存地址。 */ void SetLogUri(const std::string& _logUri); /** * 判断参数 LogUri 是否已赋值 * @return LogUri 是否已赋值 */ bool LogUriHasBeenSet() const; /** * 获取只在CreateCluster为false时生效。 * @return InstanceId 只在CreateCluster为false时生效。 */ std::string GetInstanceId() const; /** * 设置只在CreateCluster为false时生效。 * @param InstanceId 只在CreateCluster为false时生效。 */ void SetInstanceId(const std::string& _instanceId); /** * 判断参数 InstanceId 是否已赋值 * @return InstanceId 是否已赋值 */ bool InstanceIdHasBeenSet() const; /** * 获取自定义应用角色,大数据应用访问外部服务时使用的角色,默认为"EME_QCSRole"。 * @return ApplicationRole 自定义应用角色,大数据应用访问外部服务时使用的角色,默认为"EME_QCSRole"。 */ std::string GetApplicationRole() const; /** * 设置自定义应用角色,大数据应用访问外部服务时使用的角色,默认为"EME_QCSRole"。 * @param ApplicationRole 自定义应用角色,大数据应用访问外部服务时使用的角色,默认为"EME_QCSRole"。 */ void SetApplicationRole(const std::string& _applicationRole); /** * 判断参数 ApplicationRole 是否已赋值 * @return ApplicationRole 是否已赋值 */ bool ApplicationRoleHasBeenSet() const; /** * 获取重入标签,用来可重入检查,防止在一段时间内,创建相同的流程作业。 * @return ClientToken 重入标签,用来可重入检查,防止在一段时间内,创建相同的流程作业。 */ std::string GetClientToken() const; /** * 设置重入标签,用来可重入检查,防止在一段时间内,创建相同的流程作业。 * @param ClientToken 重入标签,用来可重入检查,防止在一段时间内,创建相同的流程作业。 */ void SetClientToken(const std::string& _clientToken); /** * 判断参数 ClientToken 是否已赋值 * @return ClientToken 是否已赋值 */ bool ClientTokenHasBeenSet() const; /** * 获取只在CreateCluster为true时生效,使用该配置创建集群。 * @return Instance 只在CreateCluster为true时生效,使用该配置创建集群。 */ ClusterSetting GetInstance() const; /** * 设置只在CreateCluster为true时生效,使用该配置创建集群。 * @param Instance 只在CreateCluster为true时生效,使用该配置创建集群。 */ void SetInstance(const ClusterSetting& _instance); /** * 判断参数 Instance 是否已赋值 * @return Instance 是否已赋值 */ bool InstanceHasBeenSet() const; private: /** * 作业名称。 */ std::string m_name; bool m_nameHasBeenSet; /** * 是否新创建集群。 true,新创建集群,则使用Instance中的参数进行集群创建。 false,使用已有集群,则通过InstanceId传入。 */ bool m_createCluster; bool m_createClusterHasBeenSet; /** * 作业流程执行步骤。 */ std::vector<Step> m_steps; bool m_stepsHasBeenSet; /** * 作业流程正常完成时,集群的处理方式,可选择: Terminate 销毁集群。 Reserve 保留集群。 */ std::string m_instancePolicy; bool m_instancePolicyHasBeenSet; /** * 只有CreateCluster为true时生效,目前只支持EMR版本,例如EMR-2.2.0,不支持ClickHouse和Druid版本。 */ std::string m_productVersion; bool m_productVersionHasBeenSet; /** * 只在CreateCluster为true时生效。 true 表示安装kerberos,false表示不安装kerberos。 */ bool m_securityClusterFlag; bool m_securityClusterFlagHasBeenSet; /** * 只在CreateCluster为true时生效。 新建集群时,要安装的软件列表。 */ std::vector<std::string> m_software; bool m_softwareHasBeenSet; /** * 引导脚本。 */ std::vector<BootstrapAction> m_bootstrapActions; bool m_bootstrapActionsHasBeenSet; /** * 指定配置创建集群。 */ std::vector<Configuration> m_configurations; bool m_configurationsHasBeenSet; /** * 作业日志保存地址。 */ std::string m_logUri; bool m_logUriHasBeenSet; /** * 只在CreateCluster为false时生效。 */ std::string m_instanceId; bool m_instanceIdHasBeenSet; /** * 自定义应用角色,大数据应用访问外部服务时使用的角色,默认为"EME_QCSRole"。 */ std::string m_applicationRole; bool m_applicationRoleHasBeenSet; /** * 重入标签,用来可重入检查,防止在一段时间内,创建相同的流程作业。 */ std::string m_clientToken; bool m_clientTokenHasBeenSet; /** * 只在CreateCluster为true时生效,使用该配置创建集群。 */ ClusterSetting m_instance; bool m_instanceHasBeenSet; }; } } } } #endif // !TENCENTCLOUD_EMR_V20190103_MODEL_RUNJOBFLOWREQUEST_H_
34.209906
115
0.45212
[ "vector", "model" ]
351ade7049ef960df315a90dc9ec80a96c3642ee
3,024
h
C
DynacoeSrc/includes/Dynacoe/Backends/Renderer/ShaderGL/TextureManager.h
jcorks/Dynacoe
2d606620e8072d8ae76aa2ecdc31512ac90362d9
[ "Apache-2.0", "MIT", "Libpng", "FTL", "BSD-3-Clause" ]
1
2015-11-06T18:10:11.000Z
2015-11-06T18:10:11.000Z
DynacoeSrc/includes/Dynacoe/Backends/Renderer/ShaderGL/TextureManager.h
jcorks/Dynacoe
2d606620e8072d8ae76aa2ecdc31512ac90362d9
[ "Apache-2.0", "MIT", "Libpng", "FTL", "BSD-3-Clause" ]
8
2018-01-25T03:54:32.000Z
2018-09-17T01:55:35.000Z
DynacoeSrc/includes/Dynacoe/Backends/Renderer/ShaderGL/TextureManager.h
jcorks/Dynacoe
2d606620e8072d8ae76aa2ecdc31512ac90362d9
[ "Apache-2.0", "MIT", "Libpng", "FTL", "BSD-3-Clause" ]
null
null
null
/* Copyright (c) 2018, Johnathan Corkery. (jcorkery@umich.edu) All rights reserved. This file is part of the Dynacoe project (https://github.com/jcorks/Dynacoe) Dynacoe was released under the MIT License, as detailed below. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ #if ( defined DC_BACKENDS_SHADERGL_X11 || defined DC_BACKENDS_SHADERGL_WIN32 ) #ifndef H_DC_BACKENDS_TEXTUREMANAGER #define H_DC_BACKENDS_TEXTUREMANAGER #include <Dynacoe/Backends/Renderer/ShaderGL_Multi.h> #include <set> class HugeTexture; namespace Dynacoe { class RenderBuffer; class TextureManager { public: TextureManager(); // Add new texture, id is returned int NewTexture(int w, int h, GLubyte * data, int newTex); int NewTexture(int w, int h, GLubyte * data); // Remove texture void DeleteTexture(int tex); // Update data of an existing texture void UpdateTexture(int tex, GLubyte * data); // Filtering options (applicable when rendering) void SetFilter(Renderer::TexFilter f); Renderer::TexFilter GetFilter(); int * GetSubTextureBounds(int id) { return texImageBounds+id * 4; }; float MapTexCoordsToRealCoordsX(float texX, int tex); float MapTexCoordsToRealCoordsY(float texY, int tex); static int GetActiveTextureSlot(); GLuint GetTexture(); int GetTextureW(); int GetTextureH(); void GetTextureData(int tex, uint8_t*); int GetLastNewID() { return lastID; } void ComputeTextureBindingData(const std::vector<std::pair<int, int>> & textures, RenderBuffer * out, RenderBuffer * info); private: void GarbageCollectBang(); HugeTexture * master; int cursorX; int cursorY; int cursorHeight; int getNewTex(); std::set<int> garbageBag; int * texImageBounds; int numTexPhys; int numTexUsed; GLuint subTex; int subTexW; int subTexH; std::set<int> inactiveTex; std::vector<int> lastBindings; int lastID; }; } #endif #endif
24.786885
127
0.722884
[ "vector" ]
351c237a155567fa41e5bcdd4837b4f0490bc324
1,290
h
C
mission/test/DummyCentroidProvider.h
mahsaTaheran/TmTcInterface
64582eb179fd32f9e7060329f996f083dc14b3e8
[ "Apache-2.0" ]
null
null
null
mission/test/DummyCentroidProvider.h
mahsaTaheran/TmTcInterface
64582eb179fd32f9e7060329f996f083dc14b3e8
[ "Apache-2.0" ]
null
null
null
mission/test/DummyCentroidProvider.h
mahsaTaheran/TmTcInterface
64582eb179fd32f9e7060329f996f083dc14b3e8
[ "Apache-2.0" ]
null
null
null
/* * DummyCentroidProvider.h * * Created on: May 1, 2021 * Author: mala */ #ifndef DUMMYCENTROIDPROVIDER_H_ #define DUMMYCENTROIDPROVIDER_H_ #include <vector> #include<fstream> #include <fsfw/tasks/ExecutableObjectIF.h> #include <fsfw/objectmanager/SystemObject.h> #include <bsp_linux/fsfwconfig/returnvalues/classIds.h> #include <bsp_linux/fsfwconfig/events/subsystemIdRanges.h> class DummyCentroidInjector : public ExecutableObjectIF, public SystemObject { public: DummyCentroidInjector(object_id_t objectID, std::string inputPath, uint8_t numberImages); ReturnValue_t initialize(); virtual ~DummyCentroidInjector(); virtual ReturnValue_t performOperation(uint8_t operationCode = 0); static const uint8_t INTERFACE_ID = CLASS_ID::CENTROID_WRITER_CLASS; static const uint8_t SUBSYSTEM_ID = SUBSYSTEM_ID::CENTROID_WRITER; static const Event WRITE_CENTROID = MAKE_EVENT (0, SEVERITY::INFO); static const ReturnValue_t CENTROID_OPS_OK= MAKE_RETURN_CODE(0x010); private: //??? uint8_t numberOfImages; std::ifstream centroidValues; ReturnValue_t PopulateInput(); typedef std::pair<float,float> centroidPair_t; std::vector<centroidPair_t> centroidInput; std::vector<centroidPair_t>::iterator centroidIt; std::string path; }; #endif /* DUMMYCENTROIDPROVIDER_H_ */
31.463415
90
0.797674
[ "vector" ]
352580a7ab89a9654e86e9a36ff996477ac76178
14,756
h
C
src/ofxLeapMotion2.h
fusefactory/ofxLeapMotion2
9875861ee3661edcfde18ed94d36816060217d25
[ "MIT" ]
47
2015-01-11T22:35:55.000Z
2021-09-04T05:41:48.000Z
src/ofxLeapMotion2.h
fusefactory/ofxLeapMotion2
9875861ee3661edcfde18ed94d36816060217d25
[ "MIT" ]
11
2015-02-07T03:08:08.000Z
2021-12-29T07:53:36.000Z
src/ofxLeapMotion2.h
fusefactory/ofxLeapMotion2
9875861ee3661edcfde18ed94d36816060217d25
[ "MIT" ]
36
2015-03-03T21:45:02.000Z
2022-01-01T07:43:22.000Z
#pragma once #include "ofMain.h" #include "Leap.h" enum fingerType { THUMB, INDEX, MIDDLE, RING, PINKY }; using namespace Leap; class ofxLeapMotionSimpleHand{ public: typedef struct{ ofPoint pos; ofPoint vel; ofPoint dip, mcp, pip, tip; int64_t id; }simpleFinger; map<fingerType, simpleFinger> fingers; ofPoint handPos; ofPoint handNormal; ofPoint direction; ofPoint wristPos; float pitch, yaw, roll; bool isLeft; void debugDraw(){ ofPushStyle(); ofSetColor(190); ofSetLineWidth(2); ofEnableLighting(); ofPushMatrix(); ofTranslate(handPos); //rotate the hand by the downwards normal ofQuaternion q; q.makeRotate(ofPoint(0, -1, 0), handNormal); ofMatrix4x4 m; q.get(m); glMultMatrixf(m.getPtr()); //scale it to make it not a box ofScale(1, 0.35, 1.0); #if (OF_VERSION_MAJOR == 0) && (OF_VERSION_MINOR < 8) ofBox(0, 0, 0, 60); #else ofDrawBox(0, 0, 0, 60); #endif ofPopMatrix(); ofDrawArrow(handPos, fingers[THUMB].pos, 10); ofDrawArrow(handPos, fingers[INDEX].pos, 10); ofDrawArrow(handPos, fingers[MIDDLE].pos, 10); ofDrawArrow(handPos, fingers[RING].pos, 10); ofDrawArrow(handPos, fingers[PINKY].pos, 10); ofSetColor(220, 220, 0); ofDrawArrow(fingers[THUMB].pos + fingers[THUMB].vel/20, fingers[THUMB].pos + fingers[THUMB].vel/10, 10); ofDrawArrow(fingers[INDEX].pos + fingers[INDEX].vel/20, fingers[INDEX].pos + fingers[INDEX].vel/10, 10); ofDrawArrow(fingers[MIDDLE].pos + fingers[MIDDLE].vel/20, fingers[MIDDLE].pos + fingers[MIDDLE].vel/10, 10); ofDrawArrow(fingers[RING].pos + fingers[RING].vel/20, fingers[RING].pos + fingers[RING].vel/10, 10); ofDrawArrow(fingers[PINKY].pos + fingers[PINKY].vel/20, fingers[PINKY].pos + fingers[PINKY].vel/10, 10); ofDisableLighting(); ofPopStyle(); } }; class ofxLeapMotion : public Listener{ public: // TODO: adding leap gesture support - JRW int iGestures; ofxLeapMotion(){ reset(); resetMapping(); ourController = new Leap::Controller(); } void reset(){ currentFrameID = 0; preFrameId = -1; } ~ofxLeapMotion(){ //note we don't delete the controller as it causes a crash / mutex exception. /// close(); /// JRW - we do not need this... /// JRW - seems fine in this demo but, when I add /// JRW - threaded objects the Leap controller crashes on exit. } void close(){ if( ourController ){ ourController->removeListener(*this); } /// JRW - let's delete our Leap controller /// call close() on app exit delete ourController; } //-------------------------------------------------------------- void open(){ reset(); ourController->addListener(*this); } // TODO: adding leap gesture support - JRW //-------------------------------------------------------------- void setupGestures(){ // enables screen tap gesture (forward poke / tap) ourController->enableGesture(Gesture::TYPE_SCREEN_TAP); // enables key tap gesture (down tap) ourController->enableGesture(Gesture::TYPE_KEY_TAP); // enables swipe gesture ourController->enableGesture(Gesture::TYPE_SWIPE); // enables circle gesture ourController->enableGesture(Gesture::TYPE_CIRCLE); } // TODO: adding leap gesture support - JRW //-------------------------------------------------------------- void updateGestures(){ Leap::Frame frame = ourController->frame(); if (lastFrame == frame) { return; } Leap::GestureList gestures = lastFrame.isValid() ? frame.gestures(lastFrame) : frame.gestures(); lastFrame = frame; size_t numGestures = gestures.count(); for (size_t i=0; i < numGestures; i++) { // screen tap gesture (forward poke / tap) if (gestures[i].type() == Leap::Gesture::TYPE_SCREEN_TAP) { Leap::ScreenTapGesture tap = gestures[i]; ofVec3f tapLoc = getMappedofPoint(tap.position()); iGestures = 1; } // key tap gesture (down tap) else if (gestures[i].type() == Leap::Gesture::TYPE_KEY_TAP) { Leap::KeyTapGesture tap = gestures[i]; iGestures = 2; } // swipe gesture else if (gestures[i].type() == Leap::Gesture::TYPE_SWIPE) { Leap::SwipeGesture swipe = gestures[i]; Leap::Vector diff = 0.04f*(swipe.position() - swipe.startPosition()); ofVec3f curSwipe(diff.x, -diff.y, diff.z); // swipe left if (curSwipe.x < -3 && curSwipe.x > -20) { iGestures = 4; } // swipe right else if (curSwipe.x > 3 && curSwipe.x < 20) { iGestures = 3; } // swipe up if (curSwipe.y < -3 && curSwipe.y > -20) { iGestures = 6; } // swipe down else if (curSwipe.y > 3 && curSwipe.y < 20) { iGestures = 5; } // 3D swiping // swipe forward if (curSwipe.z < -5) { iGestures = 7; } // swipe back else if (curSwipe.z > 5) { iGestures = 8; } } // circle gesture else if (gestures[i].type() == Leap::Gesture::TYPE_CIRCLE) { Leap::CircleGesture circle = gestures[i]; float progress = circle.progress(); if (progress >= 1.0f) { ofVec3f center = getMappedofPoint(circle.center()); ofVec3f normal(circle.normal().x, circle.normal().y, circle.normal().z); double curAngle = 6.5; if (normal.z < 0) { curAngle *= -1; } if (curAngle < 0) { // clockwise rotation iGestures = 10; } else { // counter-clockwise rotation iGestures = 9; } } } // kill gesture when done // gestures 5 & 6 are always in a STATE_STOP so we exclude if (gestures[i].type() != 5 && gestures[i].type() != 6) { if (gestures[i].state() == Leap::Gesture::STATE_STOP) { iGestures = 0; } } } } //-------------------------------------------------------------- virtual void onInit(const Controller& controller){ ofLogVerbose("ofxLeapMotionApp - onInit"); } //-------------------------------------------------------------- virtual void onConnect(const Controller& contr){ ofLogWarning("ofxLeapMotionApp - onConnect"); } //-------------------------------------------------------------- virtual void onDisconnect(const Controller& contr){ ofLogWarning("ofxLeapMotionApp - onDisconnect"); } //-------------------------------------------------------------- virtual void onExit(const Controller& contr){ ofLogWarning("ofxLeapMotionApp - onExit"); } //if you want to use the Leap Controller directly - inhereit ofxLeapMotion and implement this function //note: this function is called in a seperate thread - so GL commands here will cause the app to crash. //-------------------------------------------------------------- virtual void onFrame(const Controller& contr){ ofLogVerbose("ofxLeapMotionApp - onFrame"); onFrameInternal(contr); // call this if you want to use getHands() / isFrameNew() etc } //Simple access to the hands //-------------------------------------------------------------- vector <Hand> getLeapHands(){ vector <Hand> handsCopy; if( ourMutex.try_lock() ){ handsCopy = hands; ourMutex.unlock(); } return handsCopy; } //-------------------------------------------------------------- vector <ofxLeapMotionSimpleHand> getSimpleHands(){ vector <ofxLeapMotionSimpleHand> simpleHands; vector <Hand> leapHands = getLeapHands(); for(int i = 0; i < leapHands.size(); i++){ ofxLeapMotionSimpleHand curHand; curHand.isLeft = leapHands[i].isLeft(); curHand.handPos = getMappedofPoint( leapHands[i].palmPosition() ); curHand.handNormal = getofPoint( leapHands[i].palmNormal() ); curHand.direction = getofPoint( leapHands[i].direction() ); curHand.wristPos = getMappedofPoint( leapHands[i].wristPosition() ); curHand.yaw = leapHands[i].direction().yaw(); curHand.roll = leapHands[i].palmNormal().roll(); curHand.pitch = leapHands[i].direction().pitch(); fingerType fingerTypes[] = {THUMB, INDEX, MIDDLE, RING, PINKY}; for(int j = 0; j < 5; j++) { const Finger & finger = leapHands[i].fingers()[ fingerTypes[j] ]; ofxLeapMotionSimpleHand::simpleFinger f; f.id = finger.id(); f.pos = getMappedofPoint( finger.tipPosition() ); f.vel = getMappedofPoint( finger.tipVelocity() ); f.dip = getMappedofPoint(finger.jointPosition(finger.JOINT_DIP)); f.mcp = getMappedofPoint(finger.jointPosition(finger.JOINT_MCP)); f.pip = getMappedofPoint(finger.jointPosition(finger.JOINT_PIP)); f.tip = getMappedofPoint(finger.jointPosition(finger.JOINT_TIP)); curHand.fingers[ fingerTypes[j] ] = f; } simpleHands.push_back( curHand ); } return simpleHands; } //-------------------------------------------------------------- bool isConnected() { return (ourController && ourController->isConnected()); } //-------------------------------------------------------------- void setReceiveBackgroundFrames(bool bReceiveBg) { if (ourController) { ourController->setPolicyFlags(bReceiveBg? Leap::Controller::POLICY_BACKGROUND_FRAMES : Leap::Controller::POLICY_DEFAULT); } } //-------------------------------------------------------------- bool isFrameNew(){ return currentFrameID != preFrameId; } //-------------------------------------------------------------- void markFrameAsOld(){ preFrameId = currentFrameID; } //-------------------------------------------------------------- int64_t getCurrentFrameID(){ return currentFrameID; } //-------------------------------------------------------------- void resetMapping(){ xOffsetIn = 0; yOffsetIn = 0; zOffsetIn = 0; xOffsetOut = 0; yOffsetOut = 0; zOffsetOut = 0; xScale = 1; yScale = 1; zScale = 1; } //-------------------------------------------------------------- void setMappingX(float minX, float maxX, float outputMinX, float outputMaxX){ xOffsetIn = minX; xOffsetOut = outputMinX; xScale = ( outputMaxX - outputMinX ) / ( maxX - minX ); } //-------------------------------------------------------------- void setMappingY(float minY, float maxY, float outputMinY, float outputMaxY){ yOffsetIn = minY; yOffsetOut = outputMinY; yScale = ( outputMaxY - outputMinY ) / ( maxY - minY ); } //-------------------------------------------------------------- void setMappingZ(float minZ, float maxZ, float outputMinZ, float outputMaxZ){ zOffsetIn = minZ; zOffsetOut = outputMinZ; zScale = ( outputMaxZ - outputMinZ ) / ( maxZ - minZ ); } //helper function for converting a Leap::Vector to an ofPoint with a mapping //-------------------------------------------------------------- ofPoint getMappedofPoint( Vector v ){ ofPoint p = getofPoint(v); p.x = xOffsetOut + (p.x - xOffsetIn) * xScale; p.y = yOffsetOut + (p.y - yOffsetIn) * yScale; p.z = zOffsetOut + (p.z - zOffsetIn) * zScale; return p; } //helper function for converting a Leap::Vector to an ofPoint //-------------------------------------------------------------- ofPoint getofPoint(Vector v){ return ofPoint(v.x, v.y, v.z); } protected: //if you want to use the Leap Controller directly - inhereit ofxLeapMotion and implement this function //note: this function is called in a seperate thread - so GL commands here will cause the app to crash. //-------------------------------------------------------------- virtual void onFrameInternal(const Controller& contr){ ourMutex.lock(); const Frame & curFrame = contr.frame(); const HandList & handList = curFrame.hands(); hands.clear(); for(int i = 0; i < handList.count(); i++){ hands.push_back( handList[i] ); } currentFrameID = curFrame.id(); ourMutex.unlock(); } int64_t currentFrameID; int64_t preFrameId; float xOffsetIn, xOffsetOut, xScale; float yOffsetIn, yOffsetOut, yScale; float zOffsetIn, zOffsetOut, zScale; vector <Hand> hands; Leap::Controller * ourController; // TODO: added for Gesture support - JRW Leap::Frame lastFrame; std::mutex ourMutex; };
33.460317
133
0.472621
[ "vector", "3d" ]
352786c52172078fb81af1c82b76e8ae1a14b051
810
h
C
Source/Mesh.h
Nickelium/Rasterizer
76673ec0ab9eb472e1bb097a2b98effe8e5668e6
[ "MIT" ]
14
2019-02-08T10:14:36.000Z
2022-02-05T20:37:30.000Z
Source/Mesh.h
dimutch833/Rasterizer
76673ec0ab9eb472e1bb097a2b98effe8e5668e6
[ "MIT" ]
null
null
null
Source/Mesh.h
dimutch833/Rasterizer
76673ec0ab9eb472e1bb097a2b98effe8e5668e6
[ "MIT" ]
1
2019-12-02T17:10:47.000Z
2019-12-02T17:10:47.000Z
#pragma once #include <vector> #include "Vector3.h" #include "Triangle.h" /* * Class Mesh * * - Class representing a mesh * - Contains vertices, normals, texture coordinates and faces * - Is currently resposible to parse obj files * TODO: Remove parsing file depedency to other class */ class Mesh { public: Mesh(const char* fileName); int NbVertices() const; int NbFaces() const; std::vector<Triangle> GetTriangles() const; private: void ParseFile(const char* fileName); void ProcessTriangles(); std::vector<Vector3f> vertices; std::vector<Vector2f> texCoords; std::vector<Vector3f> normals; std::vector<std::vector<int>> faces; std::vector<std::vector<int>> faceTexCoords; std::vector<std::vector<int>> faceNormals; std::vector<Triangle> triangles; static char* s_Location; };
20.25
62
0.722222
[ "mesh", "vector" ]
352eedc6ec2c2370b285af6c7c528efb53753698
2,518
h
C
External/blender-2.79/include/blenkernel/intern/data_transfer_intern.h
sasa42/MeshSyncDCCPlugin
716ed0f2b2dc0e0dbce44f020e5f0fc3197d3283
[ "Apache-2.0" ]
2
2020-03-26T12:50:11.000Z
2020-03-26T12:54:41.000Z
External/blender-2.79/include/blenkernel/intern/data_transfer_intern.h
okokokoksimida/MeshSyncDCCPlugin
716ed0f2b2dc0e0dbce44f020e5f0fc3197d3283
[ "Apache-2.0" ]
null
null
null
External/blender-2.79/include/blenkernel/intern/data_transfer_intern.h
okokokoksimida/MeshSyncDCCPlugin
716ed0f2b2dc0e0dbce44f020e5f0fc3197d3283
[ "Apache-2.0" ]
1
2021-09-27T18:32:52.000Z
2021-09-27T18:32:52.000Z
/* * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software Foundation, * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * * The Original Code is Copyright (C) 2014 Blender Foundation. * All rights reserved. * * * Contributor(s): Bastien Montagne * * ***** END GPL LICENSE BLOCK ***** */ /** \file blender/blenkernel/intern/data_transfer_intern.h * \ingroup bke */ #ifndef __DATA_TRANSFER_INTERN_H__ #define __DATA_TRANSFER_INTERN_H__ #include "BKE_customdata.h" /* For cd_datatransfer_interp */ struct CustomDataTransferLayerMap; struct CustomData; struct ListBase; float data_transfer_interp_float_do( const int mix_mode, const float val_dst, const float val_src, const float mix_factor); void data_transfer_layersmapping_add_item( struct ListBase *r_map, const int data_type, const int mix_mode, const float mix_factor, const float *mix_weights, const void *data_src, void *data_dst, const int data_src_n, const int data_dst_n, const size_t elem_size, const size_t data_size, const size_t data_offset, const uint64_t data_flag, cd_datatransfer_interp interp, void *interp_data); /* Type-specific. */ bool data_transfer_layersmapping_vgroups( struct ListBase *r_map, const int mix_mode, const float mix_factor, const float *mix_weights, const int num_elem_dst, const bool use_create, const bool use_delete, struct Object *ob_src, struct Object *ob_dst, struct CustomData *cd_src, struct CustomData *cd_dst, const bool use_dupref_dst, const int fromlayers, const int tolayers); /* Defined in customdata.c */ void customdata_data_transfer_interp_normal_normals( const CustomDataTransferLayerMap *laymap, void *data_dst, const void **sources, const float *weights, const int count, const float mix_factor); #endif /* __DATA_TRANSFER_INTERN_H__ */
38.738462
107
0.74305
[ "object" ]
352f5555f0e0ca2c7182d0968b178ed0fd034772
4,490
h
C
fwdSimRa/fwdSimRa/Individuals.h
SimRA-ARG/SimRA
c079b17cba77a52ee84dce8950fd40438b597f6b
[ "Apache-2.0" ]
13
2016-03-22T10:34:34.000Z
2021-03-07T13:16:41.000Z
fwdSimRa/fwdSimRa/Individuals.h
SimRA-ARG/SimRA
c079b17cba77a52ee84dce8950fd40438b597f6b
[ "Apache-2.0" ]
null
null
null
fwdSimRa/fwdSimRa/Individuals.h
SimRA-ARG/SimRA
c079b17cba77a52ee84dce8950fd40438b597f6b
[ "Apache-2.0" ]
4
2016-09-28T09:50:26.000Z
2018-01-05T18:00:15.000Z
/* SSimRA: A framework for selection in coalescence with Recombination Author: Aritra Bose Last Update: 08/11/2016 This is a class where everything that relates to one run of a generation is generated and kept It contains the Chromosome Containers for male and female which is referred to while selecting the parents for each individuals in a generation. It contains the Chromsome IDs of each chromosomes and also the chromosome information list for each individual. */ #include<iostream> #include<string.h> #include<vector> #include<algorithm> #include<cstdlib> #include<time.h> #include<iterator> #include<stdio.h> #include<numeric> #include <stdexcept> #include<math.h> #include<limits> #include<gsl/gsl_rng.h> #include<map> #include "GlobalIndivs.h" #include "Events.h" #ifndef indivs #define indivs //using namespace std; class Individuals { //These are private data structures as they are specific to each generation and no other generation can use them. private: std::vector<std::pair<std::pair<string,string>, std::pair<string,string> > > ChromContainer; std::vector<string> SNPlabels; std::vector<string> ChromLabels; std::vector<std::pair<bool,std::pair<AlleleInfo,AlleleInfo> > > ParentInfoList; //All the method used to populate the above data structures are declared public as they are the standard way to get these information public: Individuals() {} //This method reserves space for the chromosome containers void ReserveSpace(int x); //Adding std::pairs to the Chromosome Containers void Addpairs(std::pair<std::pair<string,string>,std::pair<string,string> > x, int y); //This just fetches and returns the Chromosome Container std::vector<std::pair<std::pair<string,string>, std::pair<string,string> > > getChromContainer(); //This is a destructor for ChromContainer void DestroyCC (); //Displays the content of the chromcontainer void DisplayContents(); //This is for adding labels to SNPs (not relevant at this point) void Addlabel(); //This is for adding labels to Chromosomes (very relevant) string AddandGetChromName(int x); //Displaying the Chromosome and SNP labels void DisplayLabels(); //This gets the location segment of each SNP inside the length of the chromosome std::vector<int> GetLocSegment(int x,int y); //This fetches the fitness table for a particular generation and the fitness table remains constant throughout the simulation double *getFitnessTable(int x, double y, double z); //This is for displaying the fitness table (for debugging purposes) void DisplayTable(double* x, int y); //This gets the position of the allele from the fitness table with it's respective fitness value int getPosAllele(std::vector<string> x); //This pushes the parent chromosome info for each individual in the last generation void PushToList(std::pair<bool, std::pair <AlleleInfo,AlleleInfo> > x); //Displaying the List of Parents for each individual in a given generation (not relevant) void DisplayParentList(); void FitnessON(int x); void PopulateEFT(std::vector<int> x, double s1, double s2); void PopulateFT(std::vector<int> x); //This method mutates the SNPs according to mutation rate std::pair<std::vector<string>, int > Mutate(std::vector<string> x,double y, int L); //This fetches the List element containing parent chromosome info for each individual in the last generation //std::pair<bool,std::pair<AlleleInfo,AlleleInfo> > RetrieveListElement(int); //This method gets alleles for the child, when there's no crossover AlleleInfo GetAllelesforChild(int x, std::vector<std::pair<std::pair<string,string>, std::pair<string,string> > > CC, std::vector<int> SNPlocs, double MutationRate, int L, int GenNum, int chromnum); //This method gets alleles for the child, when there's a crossover AlleleInfo GetCrossOverAlleles(int Pidx, std::vector<std::pair<std::pair<string,string>, std::pair<string,string> > > CC, std::vector<int> SNPlocs, double MutationRate, int L, int GenNum, int chromnum); //This method is invoked when the child asks for chromosome from it's parents and depending on the crossover result either of the above two methods is invoked. AlleleInfo AskChromosome (int Pidx, std::vector<std::pair<std::pair<string,string>, std::pair<string,string> > > CC, std::vector<int> SNPlocs, double RecombRate, double MutationRate, int L, int GenNum); }; #endif
51.609195
205
0.743207
[ "vector" ]
3538a369de3d5f416483b8830d90d8475f3e2dae
1,339
h
C
src/front-end/inference/struct-decl.h
lbrugnara/zenit
72cf091e8c392c895adaa7ac623320af92a8b452
[ "MIT" ]
4
2019-04-27T21:09:56.000Z
2022-02-03T21:22:14.000Z
src/front-end/inference/struct-decl.h
lbrugnara/zenit
72cf091e8c392c895adaa7ac623320af92a8b452
[ "MIT" ]
null
null
null
src/front-end/inference/struct-decl.h
lbrugnara/zenit
72cf091e8c392c895adaa7ac623320af92a8b452
[ "MIT" ]
null
null
null
#ifndef ZENIT_INFER_STRUCT_DECL_H #define ZENIT_INFER_STRUCT_DECL_H #include "infer.h" #include "attribute-map.h" #include "../utils.h" /* * Function: zenit_infer_types_in_struct_decl_node * The struct declaration visitor pushes its scope as the current scope in the program and iterates over its members * * Parameters: * <ZenitContext> *ctx: Context object * <ZenitStructDeclNode> *struct_node: Node to visit * <ZenitType> *ctx_type: Contextual type information * <ZenitInferenceKind> *infer_kind: Contextual information about the inference process * * Returns: * <ZenitSymbol>* - The struct delcaration does not have an associated symbol, so this function returns <NULL> */ static inline ZenitSymbol* zenit_infer_types_in_struct_decl_node(ZenitContext *ctx, ZenitStructDeclNode *struct_node, ZenitType **ctx_type, ZenitInferenceKind infer_kind) { // Visit the attributes and its properties zenit_infer_types_in_attribute_node_map(ctx, struct_node->attributes); zenit_program_push_scope(ctx->program, ZENIT_SCOPE_STRUCT, struct_node->name); for (size_t i=0; i < fl_array_length(struct_node->members); i++) zenit_infer_types_in_node(ctx, struct_node->members[i], NULL, ZENIT_INFER_NONE); zenit_program_pop_scope(ctx->program); return NULL; } #endif /* ZENIT_INFER_STRUCT_DECL_H */
36.189189
170
0.772218
[ "object" ]
353a1778623f40878b8f2215af20023f1f8fac91
3,078
c
C
Turtle_Rov_0/Rov_Turtle/Function/turtle_cam_hk.c
XuczSnow/Turtle_Rov_git
3c16e4915dbd47605029dde2bca5df1abb885a07
[ "MIT" ]
null
null
null
Turtle_Rov_0/Rov_Turtle/Function/turtle_cam_hk.c
XuczSnow/Turtle_Rov_git
3c16e4915dbd47605029dde2bca5df1abb885a07
[ "MIT" ]
null
null
null
Turtle_Rov_0/Rov_Turtle/Function/turtle_cam_hk.c
XuczSnow/Turtle_Rov_git
3c16e4915dbd47605029dde2bca5df1abb885a07
[ "MIT" ]
null
null
null
/** ****************************************************************************** * @file turtle_cam_hk.c * @author Xucz(OUC Fab U+/ROV Team) * @brief Turtle 系列 ROV 摄像机管理程序 * ****************************************************************************** * @attention * * ****************************************************************************** */ /* Includes ------------------------------------------------------------------*/ #include "turtle_g.h" #include "stdio.h" #define CAM_ADD 0x81 Cam_RunStateTypeDef cam_run_state = CAM_STBY; void Turtle_Cam_SetFocus(uint8_t dr) { huart[CAM_UART_ID].txBuf[0] = CAM_ADD; huart[CAM_UART_ID].txBuf[1] = 0x01; huart[CAM_UART_ID].txBuf[2] = 0x04; huart[CAM_UART_ID].txBuf[3] = 0x07; huart[CAM_UART_ID].txBuf[4] = dr; huart[CAM_UART_ID].txBuf[5] = 0xFF; huart[CAM_UART_ID].txBufCount = 6; HAL_UART_Transmit(&CAM_UART,huart[CAM_UART_ID].txBuf,huart[CAM_UART_ID].txBufCount,0xFFF); } /****************字符叠加程序****************/ #define OSD_ID 0x81 char osd_l1[21] = "H:111 P:-00 R:+00 \0"; char osd_l2[21] = "Depth:111.1 m \0"; uint8_t osd_cmdxy[] = {OSD_ID,0x01,0x04,0x73,0x11,0x00,0x11,0x11,0x22,0x22,0x00,0x00,0x00,0x00,0x00,0xFF}; uint8_t osd_cmdl1[] = {OSD_ID,0x01,0x04,0x73,0x21,0x31,0x32,0x33,0x34,0x35,0x36,0x37,0x38,0x39,0x30,0xFF}; uint8_t osd_cmdl2[] = {OSD_ID,0x01,0x04,0x73,0x31,0x31,0x32,0x33,0x34,0x35,0x36,0x37,0x38,0x39,0x30,0xFF}; uint8_t osd_cmddsp[] = {OSD_ID,0x01,0x04,0x74,0x2F,0xFF}; uint8_t osd_cmdclr[] = {OSD_ID,0x01,0x04,0x74,0x3F,0xFF}; uint8_t osd_length[] = {sizeof(osd_cmdxy),sizeof(osd_cmdl1),sizeof(osd_cmdl2),sizeof(osd_cmddsp),\ sizeof(osd_cmdxy),sizeof(osd_cmdl1),sizeof(osd_cmdl2),sizeof(osd_cmddsp)}; uint8_t *osd_p[8] = {NULL}; void OSD_Dsp(void) { HAL_UART_Transmit_DMA(&CAM_UART,osd_cmddsp,sizeof(osd_cmddsp)); } void OSD_Clr(void) { HAL_UART_Transmit_DMA(&CAM_UART,osd_cmdclr,sizeof(osd_cmdclr)); } void OSD_ReFresh(void) { static uint8_t line_cnt = 0; if (line_cnt == 0) { sprintf(osd_l1,"H:%3d P:%2d R:%2d ",(int)hRov.yaw,(int)hRov.pitch,(int)hRov.roll); osd_cmdxy[6] = 0x00; osd_cmdxy[7] = 0x02; osd_cmdxy[8] = 0x00; osd_cmdxy[9] = 0x01; osd_cmdxy[4] = 0x11; osd_cmdl1[4] = 0x21; osd_cmdl2[4] = 0x31; for (uint8_t i=0; i<10; i++) osd_cmdl1[5+i] = osd_l1[i], osd_cmdl2[5+i] = osd_l1[10+i]; osd_p[0] = osd_cmdxy; osd_p[1] = osd_cmdl1; osd_p[2] = osd_cmdl2; osd_p[3] = osd_cmddsp; } else if (line_cnt == 4) { sprintf(osd_l2,"Depth:%5.1f m ",(float)hPress.conv_depth[0]/100); osd_cmdxy[6] = 0x00; osd_cmdxy[7] = 0x02; osd_cmdxy[8] = 0x00; osd_cmdxy[9] = 0x02; osd_cmdxy[4] = 0x12; osd_cmdl1[4] = 0x22; osd_cmdl2[4] = 0x32; for (uint8_t i=0; i<10; i++) osd_cmdl1[5+i] = osd_l2[i], osd_cmdl2[5+i] = osd_l2[10+i]; osd_p[4] = osd_cmdxy; osd_p[5] = osd_cmdl1; osd_p[6] = osd_cmdl2; osd_p[7] = osd_cmddsp; } HAL_UART_Transmit_DMA(&CAM_UART,osd_p[line_cnt],osd_length[line_cnt]); line_cnt++; if (line_cnt == 8) line_cnt = 0; }
27.238938
107
0.597791
[ "3d" ]
353a2a2b64903bca2815efa0d2f4a236844cc6dd
13,186
h
C
src/java.desktop/share/native/common/java2d/opengl/OGLSurfaceData.h
1690296356/jdk
eaf668d1510c28d51e26c397b582b66ebdf7e263
[ "Apache-2.0" ]
1
2020-12-26T04:52:15.000Z
2020-12-26T04:52:15.000Z
src/java.desktop/share/native/common/java2d/opengl/OGLSurfaceData.h
1690296356/jdk
eaf668d1510c28d51e26c397b582b66ebdf7e263
[ "Apache-2.0" ]
1
2020-12-26T04:57:19.000Z
2020-12-26T04:57:19.000Z
src/java.desktop/share/native/common/java2d/opengl/OGLSurfaceData.h
1690296356/jdk
eaf668d1510c28d51e26c397b582b66ebdf7e263
[ "Apache-2.0" ]
1
2021-12-06T01:13:18.000Z
2021-12-06T01:13:18.000Z
/* * Copyright (c) 2003, 2019, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ #ifndef OGLSurfaceData_h_Included #define OGLSurfaceData_h_Included #include "java_awt_image_AffineTransformOp.h" #include "sun_java2d_opengl_OGLSurfaceData.h" #include "sun_java2d_pipe_hw_AccelSurface.h" #include "J2D_GL/gl.h" #include "SurfaceData.h" #include "Trace.h" #include "OGLFuncs.h" typedef struct _OGLSDOps OGLSDOps; /** * The OGLPixelFormat structure contains all the information OpenGL needs to * know when copying from or into a particular system memory image buffer (via * glDrawPixels(), glReadPixels, glTexSubImage2D(), etc). * * GLenum format; * The pixel format parameter used in glDrawPixels() and other similar calls. * Indicates the component ordering for each pixel (e.g. GL_BGRA). * * GLenum type; * The pixel data type parameter used in glDrawPixels() and other similar * calls. Indicates the data type for an entire pixel or for each component * in a pixel (e.g. GL_UNSIGNED_BYTE with GL_BGR means a pixel consists of * 3 unsigned byte components, blue first, then green, then red; * GL_UNSIGNED_INT_8_8_8_8_REV with GL_BGRA means a pixel consists of 1 * unsigned integer comprised of four byte components, alpha first, then red, * then green, then blue). * * jint alignment; * The byte alignment parameter used in glPixelStorei(GL_UNPACK_ALIGNMENT). A * value of 4 indicates that each pixel starts on a 4-byte aligned region in * memory, and so on. This alignment parameter helps OpenGL speed up pixel * transfer operations by transferring memory in aligned blocks. * * jboolean hasAlpha; * If true, indicates that this pixel format contains an alpha component. * * jboolean isPremult; * If true, indicates that this pixel format contains color components that * have been pre-multiplied by their corresponding alpha component. */ typedef struct { GLenum format; GLenum type; jint alignment; jboolean hasAlpha; jboolean isPremult; } OGLPixelFormat; /** * The OGLSDOps structure describes a native OpenGL surface and contains all * information pertaining to the native surface. Some information about * the more important/different fields: * * void *privOps; * Pointer to native-specific (GLX, WGL, etc.) SurfaceData info, such as the * native Drawable handle and GraphicsConfig data. * * jobject graphicsConfig;; * Strong reference to the OGLGraphicsConfig used by this OGLSurfaceData. * * jint drawableType; * The surface type; can be any one of the surface type constants defined * below (OGLSD_WINDOW, OGLSD_TEXTURE, etc). * * GLenum activeBuffer; * Can be either GL_FRONT if this is the front buffer surface of an onscreen * window or a pbuffer surface, or GL_BACK if this is the backbuffer surface * of an onscreen window. * * jboolean isOpaque; * If true, the surface should be treated as being fully opaque. If * the underlying surface (e.g. pbuffer) has an alpha channel and isOpaque * is true, then we should take appropriate action (i.e. call glColorMask() * to disable writes into the alpha channel) to ensure that the surface * remains fully opaque. * * jboolean needsInit; * If true, the surface requires some one-time initialization, which should * be performed after a context has been made current to the surface for * the first time. * * jint x/yOffset * The offset in pixels of the OpenGL viewport origin from the lower-left * corner of the heavyweight drawable. For example, a top-level frame on * Windows XP has lower-left insets of (4,4). The OpenGL viewport origin * would typically begin at the lower-left corner of the client region (inside * the frame decorations), but AWT/Swing will take the insets into account * when rendering into that window. So in order to account for this, we * need to adjust the OpenGL viewport origin by an x/yOffset of (-4,-4). On * X11, top-level frames typically don't have this insets issue, so their * x/yOffset would be (0,0) (the same applies to pbuffers). * * jint width/height; * The cached surface bounds. For offscreen surface types (OGLSD_FBOBJECT, * OGLSD_TEXTURE, etc.) these values must remain constant. Onscreen window * surfaces (OGLSD_WINDOW, OGLSD_FLIP_BACKBUFFER, etc.) may have their * bounds changed in response to a programmatic or user-initiated event, so * these values represent the last known dimensions. To determine the true * current bounds of this surface, query the native Drawable through the * privOps field. * * GLuint textureID; * The texture object handle, as generated by glGenTextures(). If this value * is zero, the texture has not yet been initialized. * * jint textureWidth/Height; * The actual bounds of the texture object for this surface. If the * GL_ARB_texture_non_power_of_two extension is not present, the dimensions * of an OpenGL texture object must be a power-of-two (e.g. 64x32 or 128x512). * The texture image that we care about has dimensions specified by the width * and height fields in this OGLSDOps structure. For example, if the image * to be stored in the texture has dimensions 115x47, the actual OpenGL * texture we allocate will have dimensions 128x64 to meet the pow2 * restriction. The image bounds within the texture can be accessed using * floating point texture coordinates in the range [0.0,1.0]. * * GLenum textureTarget; * The texture target of the texture object for this surface. If this * surface is not backed by a texture, this value is set to zero. Otherwise, * this value is GL_TEXTURE_RECTANGLE_ARB when the GL_ARB_texture_rectangle * extension is in use; if not, it is set to GL_TEXTURE_2D. * * GLint textureFilter; * The current filter state for this texture object (can be either GL_NEAREST * or GL_LINEAR). We cache this value here and check it before updating * the filter state to avoid redundant calls to glTexParameteri() when the * filter state remains constant (see the OGLSD_UPDATE_TEXTURE_FILTER() * macro below). * * GLuint fbobjectID, depthID; * The object handles for the framebuffer object and depth renderbuffer * associated with this surface. These fields are only used when * drawableType is OGLSD_FBOBJECT, otherwise they are zero. */ struct _OGLSDOps { SurfaceDataOps sdOps; void *privOps; jobject graphicsConfig; jint drawableType; GLenum activeBuffer; jboolean isOpaque; jboolean needsInit; jint xOffset; jint yOffset; jint width; jint height; GLuint textureID; jint textureWidth; jint textureHeight; GLenum textureTarget; GLint textureFilter; GLuint fbobjectID; GLuint depthID; }; /** * The following convenience macros are used when rendering rectangles (either * a single rectangle, or a whole series of them). To render a single * rectangle, simply invoke the GLRECT() macro. To render a whole series of * rectangles, such as spans in a complex shape, first invoke GLRECT_BEGIN(), * then invoke the appropriate inner loop macro (either XYXY or XYWH) for * each rectangle, and finally invoke GLRECT_END() to notify OpenGL that the * vertex list is complete. Care should be taken to avoid calling OpenGL * commands (besides GLRECT_BODY_*()) inside the BEGIN/END pair. */ #define GLRECT_BEGIN j2d_glBegin(GL_QUADS) #define GLRECT_BODY_XYXY(x1, y1, x2, y2) \ do { \ j2d_glVertex2i(x1, y1); \ j2d_glVertex2i(x2, y1); \ j2d_glVertex2i(x2, y2); \ j2d_glVertex2i(x1, y2); \ } while (0) #define GLRECT_BODY_XYWH(x, y, w, h) \ GLRECT_BODY_XYXY(x, y, (x) + (w), (y) + (h)) #define GLRECT_END j2d_glEnd() #define GLRECT(x, y, w, h) \ do { \ GLRECT_BEGIN; \ GLRECT_BODY_XYWH(x, y, w, h); \ GLRECT_END; \ } while (0) /** * These are shorthand names for the surface type constants defined in * OGLSurfaceData.java. */ #define OGLSD_UNDEFINED sun_java2d_pipe_hw_AccelSurface_UNDEFINED #define OGLSD_WINDOW sun_java2d_pipe_hw_AccelSurface_WINDOW #define OGLSD_TEXTURE sun_java2d_pipe_hw_AccelSurface_TEXTURE #define OGLSD_FLIP_BACKBUFFER sun_java2d_pipe_hw_AccelSurface_FLIP_BACKBUFFER #define OGLSD_FBOBJECT sun_java2d_pipe_hw_AccelSurface_RT_TEXTURE /** * These are shorthand names for the filtering method constants used by * image transform methods. */ #define OGLSD_XFORM_DEFAULT 0 #define OGLSD_XFORM_NEAREST_NEIGHBOR \ java_awt_image_AffineTransformOp_TYPE_NEAREST_NEIGHBOR #define OGLSD_XFORM_BILINEAR \ java_awt_image_AffineTransformOp_TYPE_BILINEAR /** * Helper macros that update the current texture filter state only when * it needs to be changed, which helps reduce overhead for small texturing * operations. The filter state is set on a per-texture (not per-context) * basis; for example, it is possible for one texture to be using GL_NEAREST * while another texture uses GL_LINEAR under the same context. */ #define OGLSD_INIT_TEXTURE_FILTER(oglSDOps, filter) \ do { \ j2d_glTexParameteri((oglSDOps)->textureTarget, \ GL_TEXTURE_MAG_FILTER, (filter)); \ j2d_glTexParameteri((oglSDOps)->textureTarget, \ GL_TEXTURE_MIN_FILTER, (filter)); \ (oglSDOps)->textureFilter = (filter); \ } while (0) #define OGLSD_UPDATE_TEXTURE_FILTER(oglSDOps, filter) \ do { \ if ((oglSDOps)->textureFilter != (filter)) { \ OGLSD_INIT_TEXTURE_FILTER(oglSDOps, filter); \ } \ } while (0) /** * Convenience macros for setting the texture wrap mode for a given target. * The texture wrap mode should be reset to our default value of * GL_CLAMP_TO_EDGE by calling OGLSD_RESET_TEXTURE_WRAP() when a texture * is first created. If another mode is needed (e.g. GL_REPEAT in the case * of TexturePaint acceleration), one can call the OGLSD_UPDATE_TEXTURE_WRAP() * macro to easily set up the new wrap mode. However, it is important to * restore the wrap mode back to its default value (by calling the * OGLSD_RESET_TEXTURE_WRAP() macro) when the operation is finished. */ #define OGLSD_UPDATE_TEXTURE_WRAP(target, wrap) \ do { \ j2d_glTexParameteri((target), GL_TEXTURE_WRAP_S, (wrap)); \ j2d_glTexParameteri((target), GL_TEXTURE_WRAP_T, (wrap)); \ } while (0) #define OGLSD_RESET_TEXTURE_WRAP(target) \ OGLSD_UPDATE_TEXTURE_WRAP(target, GL_CLAMP_TO_EDGE) /** * Exported methods. */ jint OGLSD_Lock(JNIEnv *env, SurfaceDataOps *ops, SurfaceDataRasInfo *pRasInfo, jint lockflags); void OGLSD_GetRasInfo(JNIEnv *env, SurfaceDataOps *ops, SurfaceDataRasInfo *pRasInfo); void OGLSD_Unlock(JNIEnv *env, SurfaceDataOps *ops, SurfaceDataRasInfo *pRasInfo); void OGLSD_Dispose(JNIEnv *env, SurfaceDataOps *ops); void OGLSD_Delete(JNIEnv *env, OGLSDOps *oglsdo); jint OGLSD_NextPowerOfTwo(jint val, jint max); jboolean OGLSD_InitFBObject(GLuint *fbobjectID, GLuint *depthID, GLuint textureID, GLenum textureTarget, jint textureWidth, jint textureHeight); #endif /* OGLSurfaceData_h_Included */
44.100334
79
0.689595
[ "render", "object", "shape", "transform" ]
353af84323b05ecc8eee02a623fa9243d1baf178
8,221
h
C
sdk/sources/OpenAutomate/oatest/inc/oac/Context.h
acidicMercury8/xray-1.5
ae094d82b76a8ce916e196654c163894bbf00146
[ "Linux-OpenIB" ]
5
2021-10-30T09:36:07.000Z
2021-12-30T08:14:32.000Z
sdk/sources/OpenAutomate/oatest/inc/oac/Context.h
Samsuper12/ixray-1.5
8070f833f8216d4ead294a9f19b7cd123bb76ba3
[ "Linux-OpenIB" ]
null
null
null
sdk/sources/OpenAutomate/oatest/inc/oac/Context.h
Samsuper12/ixray-1.5
8070f833f8216d4ead294a9f19b7cd123bb76ba3
[ "Linux-OpenIB" ]
2
2020-05-17T10:01:14.000Z
2020-09-11T20:17:27.000Z
/******************************************************************************* * Copyright 1993-2008 NVIDIA Corporation. All rights reserved. * * NOTICE TO USER: * * This source code is subject to NVIDIA ownership rights under U.S. and * international Copyright laws. * * This software and the information contained herein is PROPRIETARY and * CONFIDENTIAL to NVIDIA and is being provided under the terms and conditions * of a Non-Disclosure Agreement. Any reproduction or disclosure to any third * party without the express written consent of NVIDIA is prohibited. * * NVIDIA MAKES NO REPRESENTATION ABOUT THE SUITABILITY OF THIS SOURCE CODE FOR * ANY PURPOSE. IT IS PROVIDED "AS IS" WITHOUT EXPRESS OR IMPLIED WARRANTY OF * ANY KIND. NVIDIA DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOURCE CODE, * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT, AND * FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL NVIDIA BE LIABLE FOR * ANY SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR * IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOURCE CODE. * * U.S. Government End Users. This source code is a "commercial item" as that * term is defined at 48 C.F.R. 2.101 (OCT 1995), consisting of "commercial * computer software" and "commercial computer software documentation" as such * terms are used in 48 C.F.R. 12.212 (SEPT 1995) and is provided to the U.S. * Government only as a commercial end item. Consistent with 48 C.F.R.12.212 * and 48 C.F.R. 227.7202-1 through 227.7202-4 (JUNE 1995), all U.S. Government * End Users acquire the source code with only those rights set forth herein. * ******************************************************************************/ #ifndef _oac_Context_h #define _oac_Context_h #include <vector> #include <map> #include <string> #include <OpenAutomate.h> #include <OpenAutomate_Internal.h> #include <oaRPC.h> class oacTestBase; //****************************************************************************** //*** class oacContext //****************************************************************************** class oacContext { public: class ClientApp { public: virtual ~ClientApp(); virtual bool Run(void) = 0; virtual long WaitForExit(void) = 0; }; oacContext(oaRPCServer *server, ClientApp *client_app); ~oacContext(); struct OptionValue { OptionValue(); OptionValue(const OptionValue &val); ~OptionValue(); void Set(const oaChar *name, oaOptionDataType value_type, const oaValue *value); oaChar *Name; oaOptionDataType Type; oaValue Value; }; // Makes this context the current one for all calls to the static OA // functions, and runs the client. Returns false if there's a failure bool Run(void); // Adds a test module to the list void AddTest(oacTestBase *test); // Returns the function table containing pointers to static OA functions. // This table should be returned by the Init() function of an OA plugin. static const oaiFunctionTable *GetOAFuncTable(void); //**************************************************************************** //*** Methods to be used from oaTestBase::Run() //**************************************************************************** // Sends an OA command to the application. All subsequent calls made by // the application will be passed to the matching callbacks in the current // test until GetNextCommand() is called. void IssueCommand(oaCommand *command); // Sends the OA_CMD_EXIT command to the application, waits for it to exit, // and restarts it. This is useful for testing that requires persistence // on the application's part between runs. void IssueExitAndRestart(void); // Returns an array of all the available options. If the command // OA_CMD_GET_ALL_OPTIONS was never issued or force_cmd = true, it will // issue it to the and cache the results for future calls to GetAllOptions(). const std::vector<oaNamedOption> &GetAllOptions(bool force_cmd = false); // Returns a map where the key is the key is the option name, and value // is a vector of oaNamedOptions. This is useful when dealing with enum // options, since there will be multiple oaNamedOption objects for each // enum option. typedef std::vector<oaNamedOption> OptionVec; const std::map<std::string, OptionVec *> & GetAllOptionsMap(bool force_cmd = false); // Returns the specified option by name. Semantics are the same as // GetAllOptions(). Returns NULL if no option with that name exists. const OptionVec *GetOption(const oaChar *name, bool force_cmd = false); const OptionVec *GetOption(const std::string &name, bool force_cmd = false); // Similar to GetAllOptions(), but for OA_CMD_GET_CURRENT_OPTIONS const std::vector<OptionValue *> &GetCurrentOptions(bool force_cmd = false); const std::map<std::string, OptionValue *> & GetCurrentOptionsMap(bool force_cmd = false); // Returns the specified option by name. Semantics are the same as // GetCurrentOptions. Returns NULL if no option with that name exists. const OptionValue *GetOptionValue(const oaChar *name, bool force_cmd = false); const OptionValue *GetOptionValue(const std::string &name, bool force_cmd = false); // Similar to GetAllOptions(), but for OA_CMD_GET_BENCHMARKS const std::vector<std::string> &GetBenchmarks(bool force_cmd = false); // returns a random value from 0.0 to 1.0. Tests should use this random // number generator, to ensure determinism in the test results. double Rand(void); void SRand(unsigned long seed); private: enum StateType { STATE_INVALID = 0, STATE_INIT, STATE_RUNNING_TEST, STATE_ISSUING_COMMAND, STATE_FINISHED, }; enum CallbackType { #define OAC_DECLARE_CALLBACK(func_name, func_id) \ OAC_FUNC_##func_name = func_id, #include <oac/OACallbackDefs.h> }; void RunTests(void); StateType State() const; void PushState(StateType state); void PopState(void); void ChangeState(StateType state); std::vector<oacTestBase *> pTests; std::vector<oacTestBase *>::iterator pCurrentTest; bool pHaveBenchmarks; std::vector<std::string> pBenchmarks; void ClearBenchmarks(void); bool pHaveAllOptions; std::vector<oaNamedOption> pAllOptions; std::map<std::string, OptionVec *> pAllOptionsMap; void ClearAllOptions(void); bool pHaveCurrentOptions; std::vector<OptionValue *> pCurrentOptions; std::map<std::string, OptionValue *> pCurrentOptionsMap; void ClearCurrentOptions(void); std::vector<StateType> pState; oaCommandType pCurrentCommand; oaRPCServer *pServer; ClientApp *pClientApp; unsigned long pRandSeed; static oacContext *pCurrent; static oaiFunctionTable pFuncTable; static oaInt pCallCount; //**************************************************************************** //*** OA callbacks //**************************************************************************** static oaCommandType GetNextCommand(oaCommand *command); static oaNamedOption* GetNextOption(void); static void AddOption(const oaNamedOption *option); static void AddOptionValue(const oaChar *name, oaOptionDataType value_type, const oaValue *value); static void AddBenchmark(const oaChar *benchmark_name); static oaBool SendSignal(oaSignalType signal, void *param); static void StartBenchmark(void); static void DisplayFrame(oaFloat t); static void EndBenchmark(void); static void AddResultValue(const oaChar *name, oaOptionDataType value_type, const oaValue *value); static void AddFrameValue(const oaChar *name, oaOptionDataType value_type, const oaValue *value); }; #endif
35.435345
81
0.65357
[ "vector" ]
353f9b3bbff63c53576b33e7e7ddca6917679322
14,461
c
C
hw/xgl/xglxv.c
larsclausen/xglamo
4176d6fdc061553b8366c20890635a464fe7fee2
[ "X11" ]
2
2016-05-08T18:39:05.000Z
2018-11-01T06:58:35.000Z
hw/xgl/xglxv.c
larsclausen/xglamo
4176d6fdc061553b8366c20890635a464fe7fee2
[ "X11" ]
null
null
null
hw/xgl/xglxv.c
larsclausen/xglamo
4176d6fdc061553b8366c20890635a464fe7fee2
[ "X11" ]
1
2021-12-05T20:56:48.000Z
2021-12-05T20:56:48.000Z
/* * Copyright © 2005 Novell, Inc. * * Permission to use, copy, modify, distribute, and sell this software * and its documentation for any purpose is hereby granted without * fee, provided that the above copyright notice appear in all copies * and that both that copyright notice and this permission notice * appear in supporting documentation, and that the name of * Novell, Inc. not be used in advertising or publicity pertaining to * distribution of the software without specific, written prior permission. * Novell, Inc. makes no representations about the suitability of this * software for any purpose. It is provided "as is" without express or * implied warranty. * * NOVELL, INC. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN * NO EVENT SHALL NOVELL, INC. BE LIABLE FOR ANY SPECIAL, INDIRECT OR * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS * OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * * Authors: David Reveman <davidr@novell.com> * Matthias Hopf <mhopf@suse.de> */ #include "xgl.h" #ifdef XV #include "xvdix.h" #include "gcstruct.h" #include "dixstruct.h" #include <X11/extensions/Xv.h> #include <X11/extensions/Xvproto.h> static DevPrivateKey xglXvScreenKey; static unsigned long portResource = 0; #define XGL_GET_XV_SCREEN(pScreen) ((XvScreenPtr) \ dixLookupPrivate(&(pScreen)->devPrivates, xglXvScreenKey)) #define XGL_XV_SCREEN(pScreen) \ XvScreenPtr pXvScreen = XGL_GET_XV_SCREEN (pScreen) #define XGL_GET_XV_SCREEN_PRIV(pScreen) \ ((xglXvScreenPtr) (GET_XV_SCREEN (pScreen)->devPriv.ptr)) #define XGL_XV_SCREEN_PRIV(pScreen) \ xglXvScreenPtr pXvScreenPriv = XGL_GET_XV_SCREEN_PRIV (pScreen) #define XGL_GET_XV_PORT_PRIV(pPort) \ ((xglXvPortPtr) ((pPort)->devPriv.ptr)) #define XGL_XV_PORT_PRIV(pPort) \ xglXvPortPtr pPortPriv = XGL_GET_XV_PORT_PRIV (pPort) #define XGL_XV_NUM_PORTS 32 #define XGL_XV_IMAGE_MAX_WIDTH 2048 #define XGL_XV_IMAGE_MAX_HEIGHT 2048 static XvImageRec xvImages[] = { { GLITZ_FOURCC_YUY2, XvYUV, BITMAP_BIT_ORDER, { 'Y','U','Y','2', 0x00, 0x00, 0x00, 0x10, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71 }, 16, XvPacked, 1, 0, 0, 0, 0, 8, 8, 8, 1, 2, 2, 1, 1, 1, { 'Y', 'U', 'Y', 'V', 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, XvTopToBottom }, { GLITZ_FOURCC_YV12, XvYUV, BITMAP_BIT_ORDER, { 'Y', 'V', '1', '2', 0x00, 0x00, 0x00, 0x10, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71 }, 12, XvPlanar, 3, 0, 0, 0, 0, 8, 8, 8, 1, 2, 2, 1, 2, 2, { 'Y', 'V', 'U', 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, XvTopToBottom }, { GLITZ_FOURCC_RGB, XvRGB, BITMAP_BIT_ORDER, { 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71 }, 32, XvPacked, 1, 24, 0xff0000, 0xff00, 0xff, 0, 0, 0, 0, 0, 0, 0, 0, 0, { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, XvTopToBottom } }; static struct _xglXvFormat { CARD32 format; glitz_fourcc_t fourcc; xglPixelFormatRec pixel; } xglXvFormat[XGL_XV_FORMAT_NUM] = { { PICT_yuy2, GLITZ_FOURCC_YUY2, { 16, 6, { 16, 0x00000000, 0x00000000, 0x00000000, 0x00000000, } } }, { PICT_yv12, GLITZ_FOURCC_YV12, { 12, 4, { 12, 0x00000000, 0x00000000, 0x00000000, 0x00000000, } } }, { PICT_x8r8g8b8, GLITZ_FOURCC_RGB, { 24, 8, { 32, 0x00000000, 0x00ff0000, 0x0000ff00, 0x000000ff, } } } }; static int xglXvQueryAdaptors (ScreenPtr pScreen, XvAdaptorPtr *pAdaptors, int *nAdaptors) { XGL_XV_SCREEN (pScreen); *nAdaptors = pXvScreen->nAdaptors; *pAdaptors = pXvScreen->pAdaptors; return Success; } static int xglXvAllocatePort (unsigned long port, XvPortPtr pPort, XvPortPtr *ppPort) { *ppPort = pPort; return Success; } static int xglXvFreePort (XvPortPtr pPort) { XGL_XV_PORT_PRIV (pPort); if (pPortPriv->pDst) { FreePicture ((pointer) pPortPriv->pDst, 0); pPortPriv->pDst = (PicturePtr) 0; } if (pPortPriv->pSrc) { FreePicture ((pointer) pPortPriv->pSrc, 0); pPortPriv->pSrc = (PicturePtr) 0; } if (pPortPriv->pPixmap) { ScreenPtr pScreen; pScreen = pPortPriv->pPixmap->drawable.pScreen; (*pScreen->DestroyPixmap) (pPortPriv->pPixmap); pPortPriv->pPixmap = (PixmapPtr) 0; } return Success; } static int xglXvQueryBestSize (ClientPtr client, XvPortPtr pPort, CARD8 motion, CARD16 srcWidth, CARD16 srcHeight, CARD16 dstWidth, CARD16 dstHeight, unsigned int *pWidth, unsigned int *pHeight) { *pWidth = dstWidth; *pHeight = dstHeight; return Success; } static int xglXvStopVideo (ClientPtr client, XvPortPtr pPort, DrawablePtr pDrawable) { xglXvFreePort (pPort); return Success; } static int xglXvPutImage (ClientPtr client, DrawablePtr pDrawable, XvPortPtr pPort, GCPtr pGC, INT16 srcX, INT16 srcY, CARD16 srcWidth, CARD16 srcHeight, INT16 dstX, INT16 dstY, CARD16 dstWidth, CARD16 dstHeight, XvImagePtr pImage, unsigned char *data, Bool sync, CARD16 width, CARD16 height) { ScreenPtr pScreen = pDrawable->pScreen; PictTransform transform; int depth, bpp; CARD32 format; XGL_SCREEN_PRIV (pScreen); XGL_XV_PORT_PRIV (pPort); XGL_DRAWABLE_PIXMAP (pDrawable); XGL_PIXMAP_PRIV (pPixmap); switch (pImage->id) { case GLITZ_FOURCC_YUY2: bpp = depth = 16; format = PICT_yuy2; break; case GLITZ_FOURCC_YV12: depth = bpp = 12; format = PICT_yv12; break; case GLITZ_FOURCC_RGB: depth = 24; bpp = 32; format = PICT_x8r8g8b8; break; default: return BadImplementation; } pPort->pDraw = pDrawable; if (!pPortPriv->pPixmap) { pPortPriv->pPixmap = (*pScreen->CreatePixmap) (pScreen, 0, 0, depth, 0); if (!pPortPriv->pPixmap) return BadAlloc; } (*pScreen->ModifyPixmapHeader) (pPortPriv->pPixmap, srcWidth, srcHeight, depth, bpp, -1, (pointer) data); XGL_GET_PIXMAP_PRIV (pPortPriv->pPixmap)->stride = -srcWidth; pPortPriv->pPixmap->drawable.serialNumber = NEXT_SERIAL_NUMBER; if (!pPortPriv->pSrc || pPortPriv->pSrc->format != format) { PictFormatPtr pFormat; int error; static XID value = RepeatPad; pFormat = PictureMatchFormat (pScreen, depth, format); if (!pFormat) return BadImplementation; if (pPortPriv->pSrc) FreePicture ((pointer) pPortPriv->pSrc, 0); pPortPriv->pSrc = CreatePicture (0, &pPortPriv->pPixmap->drawable, pFormat, CPRepeat, &value, serverClient, &error); if (!pPortPriv->pSrc) { xglXvFreePort (pPort); return error; } SetPictureFilter (pPortPriv->pSrc, FilterBilinear, strlen (FilterBilinear), 0, 0); } if (!pPortPriv->pDst || pPortPriv->pDst->pDrawable != pDrawable) { PictFormatPtr pFormat = 0; int i, error; for (i = 0; i < pScreen->numVisuals; i++) { if (pScreen->visuals[i].nplanes == pDrawable->depth) { pFormat = PictureMatchVisual (pScreen, pDrawable->depth, &pScreen->visuals[i]); break; } } if (!pFormat) return BadImplementation; if (pPortPriv->pDst) FreePicture ((pointer) pPortPriv->pDst, 0); pPortPriv->pDst = CreatePicture (0, pDrawable, pFormat, 0, 0, serverClient, &error); if (!pPortPriv->pDst) { xglXvFreePort (pPort); return error; } } transform.matrix[0][0] = ((srcWidth << 16) + (dstWidth >> 1)) / dstWidth; transform.matrix[0][1] = 0; transform.matrix[0][2] = 0; /* flip Y */ transform.matrix[1][0] = 0; transform.matrix[1][1] = -((srcHeight << 16) + (dstHeight >> 1)) / dstHeight; transform.matrix[1][2] = (srcHeight << 16); transform.matrix[2][0] = 0; transform.matrix[2][1] = 0; transform.matrix[2][2] = 1 << 16; SetPictureTransform (pPortPriv->pSrc, &transform); if (pPixmap != pScreenPriv->pScreenPixmap && !pPixmapPriv->target) xglEnablePixmapAccel (pPixmap, &pScreenPriv->accel.xv); CompositePicture (PictOpSrc, pPortPriv->pSrc, (PicturePtr) 0, pPortPriv->pDst, srcX, srcY, 0, 0, dstX, dstY, dstWidth, dstHeight); return Success; } static int xglXvQueryImageAttributes (ClientPtr client, XvPortPtr pPort, XvImagePtr pImage, CARD16 *width, CARD16 *height, int *pitches, int *offsets) { if (*width > XGL_XV_IMAGE_MAX_WIDTH) *width = XGL_XV_IMAGE_MAX_WIDTH; if (*height > XGL_XV_IMAGE_MAX_HEIGHT) *height = XGL_XV_IMAGE_MAX_HEIGHT; *width = (*width + 7) & ~7; switch (pImage->id) { case GLITZ_FOURCC_YUY2: if (offsets) offsets[0] = 0; if (pitches) pitches[0] = *width * 2; return *width * *height * 2; case GLITZ_FOURCC_YV12: *height = (*height + 1) & ~1; if (offsets) { offsets[0] = 0; offsets[1] = *width * *height; offsets[2] = *width * *height + (*width >> 1) * (*height >> 1); } if (pitches) { pitches[0] = *width; pitches[1] = pitches[2] = *width >> 1; } return *width * *height + (*width >> 1) * *height; case GLITZ_FOURCC_RGB: if (offsets) offsets[0] = 0; if (pitches) pitches[0] = *width * 4; return *width * *height * 4; default: return 0; } } static void xglXvFreeAdaptor (XvAdaptorPtr pAdaptor) { xfree (pAdaptor->pEncodings); xfree (pAdaptor->pFormats); if (pAdaptor->pPorts) xfree (pAdaptor->pPorts); } static Bool xglXvInitAdaptors (ScreenPtr pScreen) { XvAdaptorPtr pAdaptor; xglXvPortPtr pPortPriv; XvPortPtr pPort; XvFormatPtr pFormat; XvEncodingPtr pEncoding; int i; XGL_XV_SCREEN (pScreen); pXvScreen->nAdaptors = 0; pXvScreen->pAdaptors = NULL; pAdaptor = xcalloc (1, sizeof (XvAdaptorRec)); if (!pAdaptor) return FALSE; pAdaptor->type = XvInputMask | XvImageMask; pAdaptor->pScreen = pScreen; pAdaptor->ddAllocatePort = xglXvAllocatePort; pAdaptor->ddFreePort = xglXvFreePort; pAdaptor->ddStopVideo = xglXvStopVideo; pAdaptor->ddPutImage = xglXvPutImage; pAdaptor->ddQueryBestSize = xglXvQueryBestSize; pAdaptor->ddQueryImageAttributes = xglXvQueryImageAttributes; pAdaptor->name = "Xgl Generic Texture Video"; pEncoding = xcalloc (1, sizeof (XvEncodingRec)); if (!pEncoding) return FALSE; pEncoding->id = 0; pEncoding->pScreen = pScreen; pEncoding->name = "XV_IMAGE"; pEncoding->width = XGL_XV_IMAGE_MAX_WIDTH; pEncoding->height = XGL_XV_IMAGE_MAX_HEIGHT; pEncoding->rate.numerator = 1; pEncoding->rate.denominator = 1; pAdaptor->nEncodings = 1; pAdaptor->pEncodings = pEncoding; pAdaptor->nImages = sizeof (xvImages) / sizeof (XvImageRec); pAdaptor->pImages = xvImages; /* TODO: Currently no attributes */ pAdaptor->nAttributes = 0; pAdaptor->pAttributes = 0; pFormat = xcalloc (pScreen->numVisuals, sizeof (XvFormatRec)); if (!pFormat) return FALSE; for (i = 0; i < pScreen->numVisuals; i++) { pFormat[i].depth = pScreen->visuals[i].nplanes; pFormat[i].visual = pScreen->visuals[i].vid; } /* All visuals allowed */ pAdaptor->nFormats = pScreen->numVisuals; pAdaptor->pFormats = pFormat; pPort = xcalloc (XGL_XV_NUM_PORTS, sizeof (XvPortRec) + sizeof (xglXvPortRec)); pPortPriv = (xglXvPortPtr) (pPort + XGL_XV_NUM_PORTS); if (!pPort) return FALSE; for (i = 0; i < XGL_XV_NUM_PORTS; i++) { pPort[i].id = FakeClientID (0); if (!pPort[i].id) return FALSE; if (!AddResource (pPort[i].id, portResource, &pPort[i])) return FALSE; pPort[i].pAdaptor = pAdaptor; pPort[i].pNotify = (XvPortNotifyPtr) 0; pPort[i].pDraw = (DrawablePtr) 0; pPort[i].client = (ClientPtr) 0; pPort[i].grab.client = (ClientPtr) 0; pPort[i].time = currentTime; pPort[i].devPriv.ptr = pPortPriv + i; } pAdaptor->nPorts = XGL_XV_NUM_PORTS; pAdaptor->pPorts = pPort; pAdaptor->base_id = pPort->id; pXvScreen->pAdaptors = pAdaptor; pXvScreen->nAdaptors = 1; return TRUE; } static Bool xglXvCloseScreen (int i, ScreenPtr pScreen) { int j; XGL_XV_SCREEN (pScreen); for (j = 0; j < pXvScreen->nAdaptors; j++) xglXvFreeAdaptor (&pXvScreen->pAdaptors[j]); if (pXvScreen->pAdaptors) xfree (pXvScreen->pAdaptors); return TRUE; } Bool xglXvScreenInit (ScreenPtr pScreen) { XvScreenPtr pXvScreen; xglVisualPtr v; int i, status, vid = 0; XGL_SCREEN_PRIV (pScreen); status = XvScreenInit (pScreen); if (status != Success) return FALSE; xglXvScreenKey = XvGetScreenKey (); portResource = XvGetRTPort (); pXvScreen = XGL_GET_XV_SCREEN (pScreen); /* Anyone initializing the Xv layer must provide these two. The Xv di layer calls them without even checking if they exist! */ pXvScreen->ddCloseScreen = xglXvCloseScreen; pXvScreen->ddQueryAdaptors = xglXvQueryAdaptors; pXvScreen->devPriv.ptr = (pointer) 0; if (!xglXvInitAdaptors (pScreen)) return FALSE; for (v = pScreenPriv->pVisual; v; v = v->next) { if (v->vid > vid) vid = v->vid; } memset (pScreenPriv->pXvVisual, 0, sizeof (pScreenPriv->pXvVisual)); for (i = 0; i < XGL_XV_FORMAT_NUM; i++) { glitz_format_t templ; templ.color.fourcc = xglXvFormat[i].fourcc; pScreenPriv->pXvVisual[i].vid = ++vid; pScreenPriv->pXvVisual[i].pPixel = &xglXvFormat[i].pixel; pScreenPriv->pXvVisual[i].format.surface = glitz_find_format (pScreenPriv->drawable, GLITZ_FORMAT_FOURCC_MASK, &templ, 0); } return TRUE; } #endif
22.773228
75
0.631768
[ "transform" ]
35480f77f37d78e5280d41401e981ab5b695608e
368
h
C
src/module/core-modules/napa/napa-binding.h
localh0rzd/napajs
b3f5e67dd20caef5d96ea8c3e3d4c542fcb9a431
[ "MIT" ]
9,088
2017-08-08T22:28:16.000Z
2019-05-05T14:57:12.000Z
src/module/core-modules/napa/napa-binding.h
localh0rzd/napajs
b3f5e67dd20caef5d96ea8c3e3d4c542fcb9a431
[ "MIT" ]
172
2017-08-09T21:32:15.000Z
2019-05-03T21:21:05.000Z
src/module/core-modules/napa/napa-binding.h
localh0rzd/napajs
b3f5e67dd20caef5d96ea8c3e3d4c542fcb9a431
[ "MIT" ]
370
2017-08-09T04:58:14.000Z
2019-04-13T18:59:29.000Z
// Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. #pragma once #include <napa/module.h> namespace napa { namespace module { namespace binding { /// <summary> Initialize and export napa related functions and object wraps. </summary> void Init(v8::Local<v8::Object> exports, v8::Local<v8::Object> module); } } }
21.647059
91
0.714674
[ "object" ]
354c12e7f38f16f15744d75cc3bfd80d64357fc3
128,668
c
C
src/Pgen/src/pg.c
rpuntaie/dpic
307bfbd243ea90bd4f4656e16eed8e15ebfbb5ec
[ "CC-BY-3.0", "Unlicense" ]
1
2020-01-26T16:25:06.000Z
2020-01-26T16:25:06.000Z
src/Pgen/src/pg.c
rpuntaie/dpic
307bfbd243ea90bd4f4656e16eed8e15ebfbb5ec
[ "CC-BY-3.0", "Unlicense" ]
null
null
null
src/Pgen/src/pg.c
rpuntaie/dpic
307bfbd243ea90bd4f4656e16eed8e15ebfbb5ec
[ "CC-BY-3.0", "Unlicense" ]
null
null
null
/* This parser generator reads an input file in extended BNF form and produces language-independent ASCII output that can be converted to lexical tables, parse tables, error messages, and constants suitable for inclusion in a parser. The internal optimizations are adapted from a system available in the 1970s called "BOBS-System" from the University of Aarhus: "http://pure.au.dk/portal/files/32896922/PB_71.pdf" The current version has evolved through several mutations. It could be simplified further. */ #include "p2c.h" #include <time.h> /*F uses sysutils; F*/ /* PG0 ---------------------------------------------------------------*/ /* Machine-dependent constants: -----------------------------------*/ /* smallest and largest char for parser generator machine: */ #define ordminch 0 #define ordmaxch 255 #define ordtabchar 9 #define ordbslchar 92 #define bslchar ((Char)ordbslchar) /* Maximum number of elements in a set */ #define setmax 58 /* constants for produce ----------------------*/ #define METAGOAL1 0 #define ebnfinput1 1 #define ebnfinput2 2 #define ebnfinput3 3 #define heading1 4 #define heading2 5 #define heading3 6 #define heading4 7 #define heading5 8 #define heading6 9 #define heading7 10 #define heading8 11 #define productions1 12 #define terminaldefs1 13 #define optiondefs1 14 #define emptydef1 15 #define emptydef2 16 #define goalsymboldef1 17 #define colon1 18 #define colon2 19 #define optionlist1 20 #define optionlist2 21 #define optionlist3 22 #define optionlist4 23 #define optionlist5 24 #define optionlist6 25 #define termdeflist1 26 #define termdeflist2 27 #define termdeflist3 28 #define termdeflist4 29 #define leftside1 30 #define leftside2 31 #define leftside3 32 #define expression1 33 #define expression2 34 #define expression3 35 #define expression4 36 #define term1 37 #define term2 38 #define term3 39 #define factor1 40 #define factor2 41 #define factor3 42 #define factor4 43 #define primary1 44 #define primary2 45 #define primary3 46 #define repeated1 47 #define repeated2 48 #define repeated3 49 #define repeated4 50 #define rightbrace1 51 #define rightbrace2 52 #define stackmax 50 /* size of attstack and parsestack */ #define stringmax 72 /* size of attribute string */ #define chbufmax 255 /* size of array chbuf */ #define redumax 15 /* size of reduction buffer */ #define recmax 100 /* max input record length */ #define errmax 9 /*max no of error messages per line */ /*include prodcon */ /* parser constants */ #define linemax 81 /* max. logical length of input lines */ #define ordeotchar 0 /* end of file marker */ #define pchain 0 #define pnext 1 #define pkind 2 #define psymb 3 #define perr 4 #define prs 3 #define pprod 4 #define plb 3 /* Constants defining internal table sizes: ----------------------*/ #define maxPRODS 300 /* maximum number of productions */ #define maxRHSterms 15 /* maximum number of RHSterms */ #define maxSYMBS 300 /* maximum no. of terminal and nonterminal symbols*/ #define maxTS 200 /* maximum optimizer counter table size */ #define maxRHSTS 9000 /* maximum table size for production right sides */ #define maxBASIS 63 /* maximum number of elements in a basis set */ #define maxPT 3000 /* maximum size of parser tables */ #define maxLAH 2000 /* maximum number of elements in the lookahead set*/ #define maxLAS 75 /* maximum size of lookahead elements */ #define LRstack 1000 /* maximum size of the lr(0) stack */ #define Nparstb 500 /* maximum number of parser tables */ #define NTtabSZ 100 /* maximum size of table for nonterminals */ #define TtabSZ 1200 /* maximum size of table for terminals */ #define BSarrSZ 6 /* BSarrSZ is maxSYMBS div (setmax+1) + 1 */ #define ParsTBS 30 /* maximum size of a single table in parse table */ #define SYMBCNT 1500 /* notice: SYMBCNT > maxSYMBS */ #define SEGdim 1000 /* size of string buffer segments */ #define blank " " #define DAYMSGlen 40 /* length of console messages */ #define PAGElen 60 /* length of list page */ #define MSTRINGlen 54 /* length of mstrings */ #define SALFAlen 20 /* length of names */ #define symbmax 45 #define prodmax 52 #define lrmax 892 #define lxmax 66 /* finalparser types ----------------------*/ /* symbol = -1..maxSYMBS; */ typedef short errnum; typedef schar rslength; typedef short prodno; typedef short lrinx; typedef struct lrelm { unsigned chain : 11; /*next item in this state*/ unsigned next : 11; /*next state*/ signed int kind : 5, symb : 16; unsigned err : 9; signed int rs : 5; unsigned prodn : 9, lb : 11; } lrelm; typedef short lxinx; typedef char psymbol; typedef uchar salfa[SALFAlen]; typedef long bitset[(setmax >> 5) + 2]; typedef struct rtype { bitset r[BSarrSZ + 1]; } rtype; typedef short stringindex; typedef uchar charset[SEGdim]; typedef struct stringaddress { uchar *seg; stringindex loc; } stringaddress; typedef struct nontelm { stringaddress address; struct nontelm *rlink, *llink; unsigned nontermvalue : 9; } nontelm; typedef short prodtabx; typedef struct termelm { struct termelm *niveaup, *higherp; signed int internv : 10; unsigned tchr : 8, defined_ : 1; } termelm; typedef struct entrytyp { termelm *higherp; signed int internv : 10; unsigned defined_ : 1; } entrytyp; typedef struct prodtype { unsigned leftside : 9, start : 14; struct configtype *lookbackp; unsigned laend : 4; } prodtype; typedef rtype bitmatrix[maxSYMBS + 1]; typedef char modetype; typedef struct configtype { struct configtype *derivp, *nextp; unsigned mode : 4, inf : 9, prodnr : 9; struct configtype *lookbp; } configtype; typedef Char dayfilemsg[DAYMSGlen]; typedef Char mstring[MSTRINGlen]; typedef struct _REC_rhs { unsigned symbol : 9; configtype *parserp; unsigned link : 14, basisl : 6, basis : 1; } _REC_rhs; typedef struct _REC_help { unsigned afledt : 1, overgang : 1, prodindex : 9, rightp : 14; signed int status : 16; unsigned term : 1; } _REC_help; typedef struct _REC_state { unsigned errorno : 9; configtype *oldstart; unsigned newstart : 11; } _REC_state; typedef struct _REC_nonterms { nontelm *nontermp; unsigned isonleft : 1, isonright : 1; } _REC_nonterms; typedef struct _REC_frq { configtype *pexit; unsigned frequency : 12; } _REC_frq; /*H snapfname: mstring; H*/ mstring infilename; int inflen; short plr[lrmax + 1]={ /* 0*/ 0, 5,1, 0, 0, 10, 350,1, 5, 1, 15, 130,1, 10, 13, /* 15*/ 20, 55,1, 7, 14, 0, 25,1, 8, 15, 30, 40,1, 13, 2, /* 30*/ 0, 35,1, 15, 19, 0, 755,3, 0, 19, 0, 755,3, 0, 18, /* 45*/ 0, 50,1, 4, 3, 0, 731,3, 2, 15, 30, 40,1, 13, 2, /* 60*/ 65, 75,1, 3, 4, 0, 70,1, 5, 21, 0, 80,3, 0, 21, /* 75*/ 0, 80,3, 0, 20, 85, 125,2, 3, 22, 90, 105,2, 14, 23, /* 90*/ 95, 100,2, 5, 24, 0, 843,4, 0, 14, 0, 80,3, 1, 24, /* 105*/ 110, 120,1, 3, 4, 0, 115,1, 5, 25, 0, 80,3, 2, 25, /* 120*/ 0, 80,3, 2, 23, 0, 80,3, 1, 22, 30, 40,1, 13, 2, /* 135*/ 0, 140,1, 4, 3, 0, 145,3, 0, 26, 150, 185,2, 4, 27, /* 150*/ 155, 175,2, 14, 28, 160, 165,2, 15, 29, 0, 848,4, 0, 13, /* 165*/ 0, 170,1, 4, 3, 0, 145,3, 2, 29, 0, 180,1, 4, 3, /* 180*/ 0, 145,3, 2, 28, 0, 145,3, 1, 27, 0, 195,1, 25, 5, /* 195*/ 0, 130,1, 10, 6, 0, 205,1, 25, 5, 210, 215,2, 9, 17, /* 210*/ 0, 853,4, 0, 6, 30, 40,1, 13, 2, 0, 225,1, 2, 7, /* 225*/ 0, 739,3, 2, 17, 0, 235,1, 25, 5, 0, 360,3, 5, 10, /* 240*/ 0, 245,1, 25, 5, 250, 130,1, 10, 8, 255, 25,1, 8, 15, /* 255*/ 0, 260,1, 5, 16, 0, 731,3, 0, 16, 0, 270,1, 25, 5, /* 270*/ 0, 130,1, 10, 6, 0, 280,1, 25, 5, 285, 215,2, 9, 17, /* 285*/ 0, 858,4, 0, 7, 0, 295,1, 25, 5, 0, 360,3, 7, 11, /* 300*/ 0, 305,1, 25, 5, 310, 215,2, 9, 17, 0, 863,4, 0, 5, /* 315*/ 0, 320,1, 25, 5, 0, 360,3, 5, 9, 0, 330,1, 25, 5, /* 330*/ 335, 215,2, 9, 17, 0, 868,4, 0, 4, 0, 345,1, 25, 5, /* 345*/ 0, 360,3, 3, 8, 355, 260,4, 25, 16, 0, 873,4, 0, 3, /* 360*/ 365, 700,1, 25, 9, 0, 370,1, 2, 30, 0, 375,3, 0, 30, /* 375*/ 0, 380,1, 15, 10, 385, 470,1, 5, 11, 390, 455,1, 19, 41, /* 390*/ 395, 425,1, 2, 43, 400, 420,1, 4, 45, 405, 415,1, 17, 46, /* 405*/ 0, 410,1, 21, 47, 380, 590,1, 24, 12, 385, 470,1, 5, 11, /* 420*/ 0, 460,3, 0, 45, 430, 40,2, 13, 18, 435, 35,2, 15, 19, /* 435*/ 0, 878,4, 0, 44, 0, 410,1, 21, 13, 0, 807,3, 2, 43, /* 450*/ 0, 807,3, 0, 42, 385, 470,1, 5, 11, 0, 807,3, 0, 40, /* 465*/ 0, 799,3, 0, 37, 0, 775,3, 0, 34, 480, 510,2, 5, 39, /* 480*/ 485, 455,2, 19, 41, 490, 425,2, 2, 43, 495, 420,2, 4, 45, /* 495*/ 500, 415,2, 17, 46, 505, 410,2, 21, 47, 0, 883,4, 0, 33, /* 510*/ 0, 799,3, 1, 39, 0, 799,3, 1, 38, 525, 575,1, 20, 14, /* 525*/ 0, 530,1, 16, 35, 385, 535,1, 5, 11, 0, 775,3, 2, 36, /* 540*/ 545, 510,2, 5, 39, 550, 455,2, 19, 41, 555, 425,2, 2, 43, /* 555*/ 560, 420,2, 4, 45, 565, 415,2, 17, 46, 570, 410,2, 21, 47, /* 570*/ 0, 888,4, 0, 35, 0, 807,3, 2, 41, 525, 585,1, 18, 15, /* 585*/ 0, 460,3, 2, 46, 385, 470,1, 5, 11, 600, 530,1, 16, 16, /* 600*/ 605, 615,1, 22, 51, 0, 610,1, 23, 52, 0, 827,3, 0, 52, /* 615*/ 0, 827,3, 0, 51, 0, 819,3, 3, 50, 595, 630,1, 24, 17, /* 630*/ 635, 615,1, 22, 18, 380, 610,1, 23, 52, 600, 530,1, 16, 16, /* 645*/ 0, 819,3, 4, 49, 0, 819,3, 3, 48, 0, 819,3, 2, 47, /* 660*/ 525, 665,1, 25, 19, 0, 670,3, 3, 12, 675, 695,1, 25, 20, /* 675*/ 680, 690,1, 2, 31, 0, 685,1, 5, 32, 0, 375,3, 1, 32, /* 690*/ 0, 375,3, 1, 31, 0, 705,3, 2, 2, 0, 705,3, 1, 1, /* 705*/ 0, 710,1, 1, 21, 0, 0,0, 2, 0, 719, 200,5, 195 , /* 719*/ 723, 300,5, 245 , 727, 275,5, 270 , 0, 325,5, 0 , /* 731*/ 735, 265,5, 245 , 0, 190,5, 0 , 743, 290,5, 280 , /* 743*/ 747, 315,5, 305 , 751, 340,5, 330 , 0, 230,5, 0 , /* 755*/ 759, 60,5, 55 , 763, 135,5, 130 , 767, 220,5, 215 , /* 767*/ 771, 440,5, 425 , 0, 45,5, 0 , 779, 625,5, 410 , /* 779*/ 783, 580,5, 415 , 787, 520,5, 455 , 791, 595,5, 590 , /* 791*/ 795, 640,5, 630 , 0, 660,5, 0 , 803, 540,5, 530 , /* 803*/ 0, 475,5, 0 , 811, 515,5, 475 , 815, 515,5, 540 , /* 815*/ 0, 465,5, 0 , 823, 445,5, 440 , 0, 450,5, 0 , /* 827*/ 831, 655,5, 625 , 835, 650,5, 630 , 839, 645,5, 640 , /* 839*/ 0, 620,5, 0 , 0, 240,3, 2, 14, 0, 715,3, 2, 13, /* 853*/ 0, 360,3, 3, 6, 0, 360,3, 5, 7, 0, 360,3, 3, 5, /* 868*/ 0, 360,3, 1, 4, 0, 705,3, 0, 3, 0, 460,3, 0, 44, /* 883*/ 0, 775,3, 0, 33, 0, 775,3, 2, 35 }; lxinx pentryhp[ordmaxch + 1]={ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 0, 11, 0, 0, 0, 0, 0, 0, 0, 20, 0, 0, 0, 0, 26, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 34, 0, 42, 0, 0, 0, 0, 0, 0, 0, 51, 0, 0, 0, 0, 57, 0, 0, 0, 0, 0, 0, 0, 0, 65, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; psymbol pentrytv[ordmaxch + 1]={ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 12, 0, 24, 0, 0, 12, 17, 18, 0, 0, 14, 0, 25, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 13, 0, 0, 15, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 19, 0, 20, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 21, 16, 22, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; /* plx: array [0..lxmax] of lxelm; */ /*lexical tables*/ lxinx plxnp[lxmax + 1]={ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 66, 0 }; lxinx plxhp[lxmax + 1]={ 0, 0, 0, 4, 5, 6, 7, 8, 9, 10, 0, 12, 13, 14, 15, 16, 17, 18, 19, 0, 21, 22, 23, 24, 25, 0, 27, 28, 29, 30, 31, 32, 33, 0, 35, 36, 37, 38, 39, 40, 41, 0, 43, 44, 45, 46, 47, 48, 49, 50, 0, 52, 53, 54, 55, 56, 0, 58, 59, 60, 61, 62, 63, 64, 0, 0, 0 }; psymbol plxtv[lxmax + 1]={ 0, 26, 27, 0, 0, 0, 0, 0, 0, 0, 8, 0, 0, 0, 0, 0, 0, 0, 0, 9, 0, 0, 0, 0, 0, 7, 0, 0, 0, 0, 0, 0, 0, 10, 0, 0, 0, 0, 0, 0, 0, 8, 0, 0, 0, 0, 0, 0, 0, 0, 9, 0, 0, 0, 0, 0, 7, 0, 0, 0, 0, 0, 0, 0, 10, 22, 23 }; uchar plxch[lxmax + 1]={ '0', '*', '-', 'M', 'P', 'T', 'Y', 'T', 'E', 'R', 'M', 'O', 'A', 'L', 'S', 'Y', 'M', 'B', 'O', 'L', 'P', 'T', 'I', 'O', 'N', 'S', 'E', 'R', 'M', 'I', 'N', 'A', 'L', 'S', 'm', 'p', 't', 'y', 't', 'e', 'r', 'm', 'o', 'a', 'l', 's', 'y', 'm', 'b', 'o', 'l', 'p', 't', 'i', 'o', 'n', 's', 'e', 'r', 'm', 'i', 'n', 'a', 'l', 's', 'L', 'R' }; uchar *symbtab; stringindex freesp; prodtabx rhsnil; entrytyp entry_[ordmaxch + 1]; _REC_rhs rhs[maxRHSTS + 1]; prodtabx lefthelp[maxSYMBS + 1]; prodtype prod[maxPRODS + 1]; _REC_help help[maxSYMBS + 1]; _REC_state state[Nparstb + 1]; stringaddress stringarray[maxSYMBS + 2]; int symbols[maxSYMBS]; _REC_nonterms nonterms[maxSYMBS + 1]; int emptyvalue; nontelm *last, *first, *dynp, *statp; prodtabx point, symbp, helpp, top; short internv; int prodcount, statecount, lalrend, statenum, lextabcount, lastnont, firstnont, cnt, ntcount, goalsymbol, lasttermval, termrep, symb, termg; boolean firstnonterm, goalknown, emptyinexpr, goalnotentered, errorsininput, leftflag, goalnotdefined, stopflag, isfirst; configtype *rodp, *beginstate, *lqbep, *classtop, *oldp, *freeptr; FILE *input, *output, *list, *console, *logfile; _REC_frq frq[maxTS]; int frqi; bitmatrix pt1s, ph1s; int lineno; /* listing counters*/ /*D trace, debug: boolean; D*/ /* for debug */ lrelm lr[maxLAH + 1]; int smax; /*H function access( var f:mstring; n:integer ): integer; external name 'access'; procedure unlink( var s:mstring ); external name 'unlink'; H*/ void newline(int n) { int i; for (i = n; i >= 1; i--) putc('\n', list); } void bar(Char *mg) { int msglen = DAYMSGlen, i = 0; int asterlen; putc('\n', list); while (msglen > i) { if (mg[msglen-1] == ' ') msglen--; else i = msglen; } asterlen = (77 - msglen) >> 1; putc(' ', list); for (i = 1; i <= asterlen; i++) putc('*', list); if (msglen != 0) putc(' ', list); else putc('*', list); for (i = 0; i < msglen; i++) putc(mg[i], list); if (msglen != 0) putc(' ', list); else putc('*', list); for (i = 1; i <= asterlen; i++) putc('*', list); if (!(msglen & 1)) putc('*', list); fprintf(list, "\n\n"); } void consoleflush(void) { /* causes immediate physical write to console, not needed for most systems. */ fflush(console); P_ioresult = 0; } void listterm(stringaddress a, int *len) { int i, c, FORLIM; *len = a.seg[a.loc - 1]; FORLIM = *len; for (i = 0; i < FORLIM; i++) { c = a.seg[a.loc + i]; if (c >= ' ' && c < 128) putc(c, list); else fprintf(list, "%c%d%d%d", bslchar, c >> 6, (c & 63) >> 3, c & 7); } } void writenont(int i, int *t) { int m; listterm(nonterms[i].nontermp->address, &m); *t += m; } void listgrammar(void); jmp_buf _JL999; void stop(int n) { /* all abnormal termination is through this procedure*/ switch (n) { case 0: /*miscellaneous*/ break; case 1: /*consterror*/ break; case 2: /*error(s) in input*/ break; case 3: /*error(s) in grammar*/ listgrammar(); fprintf(list, " Error(s) in grammar \n"); fprintf(console, " Error(s) in grammar\n"); consoleflush(); break; case 4: /*not slr/lalr(1) */ break; case 5: fprintf(console, " Input file not readable\n"); consoleflush(); break; case 6: fprintf(console, " An input file must be specified\n"); consoleflush(); break; } longjmp(_JL999, 1); /*F halt(1) F*/ } void consterror(uchar *s1, uchar *s2, int cc) { newline(2); fprintf(list, " Errort in %.*s%.*s exceeded", SALFAlen, s1, SALFAlen, s2); fprintf(console, "%.*s exceeded (%d)\n", SALFAlen, s2, cc); consoleflush(); stop(0); } void incrtabx(prodtabx *p) { if (*p >= maxRHSTS) consterror("allocate ", "maxRHSTS ", maxRHSTS); (*p)++; } void writeterm(stringaddress a, int *t) { int j; putc('"', list); listterm(a, &j); putc('"', list); *t += j + 2; } void listgrammar(void) { prodtabx p; int i, k, l, t, tt; int prodno_ = -1; int plocal, FORLIM, FORLIM1; stringaddress *WITH; newline(2); bar("Expanded Grammar "); FORLIM = lastnont; for (i = firstnont; i <= FORLIM; i++) { /*productions*/ p = help[i].rightp; if (p != rhsnil) { /*main production i*/ prodno_++; fprintf(list, "\n%5d ", prodno_); t = 3; if (i == firstnont) { fprintf(list, "METAGOAL"); t += 8; } else writenont(i, &t); plocal = 1; fprintf(list, " = "); t++; while (p != rhsnil) { tt = t; FORLIM1 = rhs[p].basisl; for (k = 1; k <= FORLIM1; k++) { incrtabx(&p); if (i != firstnont || k > 1) { if (tt > 70) { putc('\n', list); tt = t; for (l = 1; l <= t + 7; l++) putc(' ', list); } symb = rhs[p].symbol; if (symb <= termg) writeterm(stringarray[symb+1], &tt); else writenont(symb, &tt); putc(' ', list); tt++; } } p = rhs[p].link; /*alternative productions*/ if (p == rhsnil) { putc('\n', list); continue; } prodno_++; fprintf(list, "\n%5d", prodno_); for (l = 1; l <= t; l++) putc(' ', list); fprintf(list, "| "); plocal++; } } if (!stopflag) { fprintf(output, "%5d ", plocal); if (i == firstnont) fprintf(output, "METAGOAL"); else { WITH = &nonterms[i].nontermp->address; FORLIM1 = WITH->seg[WITH->loc - 1]; for (k = 0; k < FORLIM1; k++) putc(WITH->seg[WITH->loc + k], output); } putc('\n', output); } } if (!stopflag) fprintf(output, "%5d\n", 0); putc('\n', list); bar(" "); } /*H procedure openfiles; begin rewrite(console,'/dev/tty'); if ParamCount<1 then stop(6) else infilename := ParamStr(1); inflen := MSTRINGlen; while infilename[inflen]=' ' do inflen := inflen-1; if inflen >= MSTRINGlen then stop(5) else infilename[inflen+1] := chr(0); if access(infilename,4) < 0 then stop(5) else reset(input,infilename); reset(tables,ParamStr(0) + '.dat'); rewrite(list,'Pgen.list'); H*/ /*DH rewrite(logfile,'logfile') HD*/ /*H end; H*/ void openfiles(void) { output = stdout; input = stdin; console = stderr; if (list != NULL) list = freopen("pg.list", "w", list); else list = fopen("pg.list", "w"); if (list == NULL) _EscIO2(FileNotFound, "pg.list"); if (P_argc < 2) stop(6); else P_sun_argv(infilename, sizeof(mstring), 1); inflen = 1; while (infilename[inflen-1] > ' ' && (infilename[inflen-1] & (~127)) == 0) inflen++; inflen--; if (input != NULL) input = freopen(P_trimname(infilename, sizeof(mstring)), "r", input); else { /*DU rewrite(logfile,'logfile') UD*/ input = fopen(P_trimname(infilename, sizeof(mstring)), "r"); } if (input == NULL) _EscIO2(FileNotFound, P_trimname(infilename, sizeof(mstring))); } /*F procedure openfiles; begin assign(list,'pg.list'); rewrite(list); if IOResult<>0 then halt(1); assign(console,'/dev/tty'); rewrite(console); if IOResult<>0 then halt(1); if ParamCount<1 then stop(6) else begin infilename := ParamStr(1); assign(input,infilename); reset(input); if IOResult<>0 then halt(1) end; F*/ /*DF if debug then begin assign(logfile,'logfile'); rewrite(logfile); if IOResult<>0 then halt(1) end; FD*/ /*F assign(tables,concat(ParamStr(0),'.dat')); reset(tables); if IOResult<>0 then halt(1) end; F*/ void headline(void) { int i = MSTRINGlen, j = 0; /*H t: TimeStamp; H*/ /*F YY,MM,DD: word; F*/ fprintf(list, " Parser Generator (Version 5). File \""); while (i > j) { if (infilename[i-1] == ' ' || infilename[i-1] == '\0') i--; else j = i; } for (i = 0; i < j; i++) putc(infilename[i], list); fprintf(list, "\" \n"); /*H GetTimeStamp(t); dt[1] := Date(t); dt[2] := Time(t); H*/ /* U date(dt[1]); time(dt[2]); U */ /* UH write(list, dt[1]:11,' ',dt[2]:11); HU */ /*H write(list, dt[1]:11,' ',dt[2]:11); H*/ /*F DeCodeDate(Date,YY,MM,DD); write(list,' ',YY,':',MM:1,':',DD); F*/ } void asterline(void) { int i; fprintf(list, "\n "); for (i = 1; i <= 79; i++) putc('*', list); newline(2); } void m(Char *s) { fprintf(list, " %.*s\n", MSTRINGlen, s); fprintf(console, " %.*s\n", MSTRINGlen, s); consoleflush(); } void newelm(prodtabx *top, uchar *rname) { if (*top >= maxRHSTS) consterror(rname, "maxRHSTS ", maxRHSTS); (*top)++; } void gramerror(int i) { fprintf(list, "\n *** "); switch (i) { case 1: fprintf(list, " Too many new names generated"); fprintf(console, "Too many new names generated\n"); consoleflush(); break; case 2: fprintf(list, " The empty terminal must be defined when the right hand side is optional"); fprintf(console, "Definition of 8 required\n"); consoleflush(); break; case 4: fprintf(list, " Empty is not the only right-side symbol"); fprintf(console, "8 appears with other symbols\n"); consoleflush(); break; case 7: consterror("inputgrammar ", "maxSYMBS ", maxSYMBS); fprintf(console, "Installation-dependent constant exceeded\n"); consoleflush(); break; case 9: fprintf(list, " Invalid alternative"); fprintf(console, "Invalid alternative\n"); consoleflush(); break; case 14: consterror("inputgrammar ", "NTtabSZ ", NTtabSZ); fprintf(console, "Installation-dependent constant exceeded\n"); consoleflush(); break; case 16: fprintf(list, " Undefined option number"); fprintf(console, "An option number is not defined\n"); consoleflush(); break; case 18: fprintf(list, " Nonterminal too long "); fprintf(console, "A nonterminal is too long\n"); consoleflush(); break; case 19: fprintf(list, " Right-hand side too long (max 15) "); fprintf(console, "Too many terms in expression\n"); consoleflush(); break; default: fprintf(list, " Error: details unavailable"); fprintf(console, "Error: details unavailable\n"); consoleflush(); break; } fprintf(list, "\n "); errorsininput = true; if (i == 4) stopflag = true; else if (i < 0 || i >= 32 || ((1L << i) & 0xd0200L) == 0) stop(0); } /*---------------------------------------------------------------*/ void consoleterm(stringaddress a, int *len) { int i, FORLIM; *len = a.seg[a.loc - 1]; FORLIM = *len; for (i = 0; i < FORLIM; i++) putc(a.seg[a.loc + i], console); } void listtab(int l, int i) { int hop; hop = i - (i + l - 1) % i - 1; /* p2c: pg.p, line 536: * Note: Using % for possibly-negative arguments [317] */ if (hop > 0) fprintf(list, "%*c", hop, ' '); } void termination(void) { prodtabx p; boolean nonew, termboo, tb1; int i, j, k, FORLIM; _REC_rhs *WITH; FORLIM = lastnont; for (i = firstnont; i <= FORLIM; i++) help[i].term = false; do { nonew = true; FORLIM = lastnont; for (i = firstnont; i <= FORLIM; i++) { if (!help[i].term) { p = help[i].rightp; while (p != rhsnil) { k = rhs[p].basisl; termboo = true; for (j = 1; j <= k; j++) { incrtabx(&p); WITH = &rhs[p]; if (WITH->symbol > termg) { tb1 = help[WITH->symbol].term; termboo = (termboo && tb1); } } if (termboo) { nonew = false; help[i].term = true; p = rhsnil; } else p = rhs[p].link; } } } } while (!nonew); termboo = false; k = 0; FORLIM = lastnont; for (i = firstnont + 1; i <= FORLIM; i++) { if (help[i].rightp != rhsnil && !help[i].term) { newline(2); putc(' ', list); writenont(i, &k); termboo = true; } } if (!termboo) return; newline(2); fprintf(list, " The above nonterminals cannot produce\n"); fprintf(list, " a string of only terminal symbols \n"); stop(3); } void allocp(configtype **p, int m) { if (freeptr != NULL) { *p = freeptr; freeptr = freeptr->derivp; } else { switch (m) { case 1: case 2: case 3: case 4: *p = Malloc(sizeof(configtype)); (*p)->inf = 0; (*p)->prodnr = 0; break; case 5: *p = Malloc(sizeof(configtype)); (*p)->lookbp = NULL; break; } } (*p)->derivp = NULL; (*p)->nextp = NULL; (*p)->mode = m; } void countnextp(configtype *p) { /* countnextp counts the frequency of nextp values in a lookback state */ int i = 0; while (i < frqi) { i++; if (frq[i-1].pexit == p) { frq[i-1].frequency++; i = frqi + 1; } } if (i != frqi) return; frqi++; if (frqi > maxTS) consterror(" remember ", "maxts ", maxTS); frq[frqi-1].pexit = p; frq[frqi-1].frequency = 1; } void optimize(configtype **maxnextp, int *md) { /* optimize finds the nextp that is most often used in the state, and deletes the state elements where it occurs*/ configtype *p; int max, i, v; boolean brk; int FORLIM; _REC_frq *WITH; *maxnextp = frq[0].pexit; max = frq[0].frequency; FORLIM = frqi; for (i = 1; i < FORLIM; i++) { WITH = &frq[i]; if (WITH->frequency > max) { max = WITH->frequency; *maxnextp = WITH->pexit; } } if (*md == 4) { p = beginstate; while (p->nextp != *maxnextp) p = p->derivp; v = p->prodnr; } while (beginstate->nextp == *maxnextp && beginstate->mode == *md) beginstate = beginstate->derivp; p = beginstate; do { oldp = p; brk = false; do { p = p->derivp; if (p == NULL) brk = true; else brk = (p->nextp != *maxnextp || p->mode != *md); } while (!brk); oldp->derivp = p; } while (p != NULL); if (*md == 4) *md = v; } /* PG5----------------------------------------------------------------*/ void emitconstants(void) { lrinx si; int ix = 0; lrinx FORLIM; lrelm *WITH; FORLIM = smax; for (si = 0; si <= FORLIM; si++) { WITH = &lr[si]; if (WITH->kind == 5) ix += 4; else ix += 5; } fprintf(output, "%5d symbmax \n", lastnont); fprintf(output, "%5d prodmax \n", prodcount); fprintf(output, "%5d lrmax \n", smax); fprintf(output, "%5d lrlin \n", ix); fprintf(output, "%5d lxmax \n", lextabcount); newline(2); fprintf(list, " Number of terminal symbols = %5d\n", lastnont); fprintf(list, " Number of productions = %5d\n", prodcount); fprintf(list, " Number of LALR table entries = %5d\n", ix); fprintf(list, " Number of lexical table entries = %5d\n", lextabcount); newline(2); } lxinx incrtinx(lxinx *ttmp) { if (*ttmp >= TtabSZ) consterror("emitlex ", "TtabSZ ", TtabSZ); else (*ttmp)++; return (*ttmp); } typedef struct lxelm { unsigned np : 11, hp : 11; short tv; uchar ch; } lxelm; /* Local variables for emitlex: */ struct LOC_emitlex { lxelm lx[TtabSZ + 257]; lxinx tinx; } ; Local void visit(termelm *p, struct LOC_emitlex *LINK) { termelm *nmin, *tix; lxelm *WITH1; WITH1 = &LINK->lx[LINK->tinx+256]; /* make sure lexigraphic first char is in this node */ tix = p->niveaup; WITH1->ch = p->tchr; nmin = p; while (tix != NULL) { if (tix->tchr < WITH1->ch) { WITH1->ch = tix->tchr; nmin = tix; } tix = tix->niveaup; } if (nmin != p) { nmin->tchr = p->tchr; p->tchr = WITH1->ch; WITH1->tv = nmin->internv; nmin->internv = p->internv; p->internv = WITH1->tv; tix = nmin->higherp; nmin->higherp = p->higherp; p->higherp = tix; } WITH1->tv = p->internv; WITH1->ch = p->tchr; if (p->niveaup != NULL) { WITH1->np = incrtinx(&LINK->tinx); visit(p->niveaup, LINK); } else WITH1->np = 0; if (p->higherp != NULL) { WITH1->hp = incrtinx(&LINK->tinx); visit(p->higherp, LINK); } else WITH1->hp = 0; } Local void convertlex(struct LOC_emitlex *LINK) { int i; lxelm *WITH; entrytyp *WITH1; /*transform class termtree into array lx*/ LINK->tinx = 0; LINK->lx[256].ch = ' '; LINK->lx[256].hp = 0; LINK->lx[256].np = 0; LINK->lx[256].tv = 0; /* lx[0] is not used */ for (i = ordminch; i <= ordmaxch; i++) { WITH = &LINK->lx[i - ordmaxch + 255]; WITH1 = &entry_[i]; WITH->tv = WITH1->internv; WITH->ch = i; WITH->np = 0; if (WITH1->higherp != NULL) { WITH->hp = incrtinx(&LINK->tinx); visit(WITH1->higherp, LINK); } else WITH->hp = 0; } } void emitlex(void) { struct LOC_emitlex V; lxinx t; uchar chlastused = ' '; lxinx FORLIM; lxelm *WITH; convertlex(&V); FORLIM = V.tinx; for (t = ordminch - ordmaxch - 1; t <= FORLIM; t++) { WITH = &V.lx[t+256]; if (t == 0) fprintf(output, " %c0 0 0\n", chlastused); if (t >= 0 || WITH->tv > 0 || WITH->hp > 0) { fprintf(output, " %c%d %d ", WITH->ch, WITH->np, WITH->hp); if (WITH->tv < 0) fprintf(output, "%d\n", 0); else fprintf(output, "%d\n", WITH->tv); chlastused = WITH->ch; } } putc('\n', list); } void writlr(lrinx si) { lrelm *WITH; WITH = &lr[si]; fprintf(list, " %3d%6d%5d%5d", si, WITH->chain, WITH->next, WITH->kind); switch (WITH->kind) { case 1: case 2: case 4: case 6: fprintf(list, "%5d%5d ", WITH->symb, WITH->err); break; case 0: case 3: fprintf(list, "%5d%5d ", WITH->rs, WITH->prodn); break; case 5: fprintf(list, "%5d ", WITH->lb); break; } } void emitpars(void) { lrinx si; int ix = 0; lrinx FORLIM; lrelm *WITH; FORLIM = smax; for (si = 0; si <= FORLIM; si++) { WITH = &lr[si]; fprintf(output, "%d\n", ix); if (WITH->kind == 5) ix += 4; else ix += 5; } FORLIM = smax; for (si = 0; si <= FORLIM; si++) { WITH = &lr[si]; fprintf(output, "%d %d %d ", WITH->chain, WITH->next, WITH->kind); switch (WITH->kind) { case 1: case 2: case 4: case 6: fprintf(output, "%d %d\n", WITH->symb, WITH->err); break; case 0: case 3: fprintf(output, "%d %d\n", WITH->rs, WITH->prodn); break; case 5: fprintf(output, "%d\n", WITH->lb); break; } } } void lapres(configtype **start) { configtype *sp; int m = 4; configtype *WITH; sp = *start; beginstate = sp; frqi = 0; /*beginstate and frqi are used in optimize*/ while (sp != NULL) { WITH = sp; if (WITH->mode == 4) countnextp(WITH->nextp); sp = WITH->derivp; } optimize(&sp, &m); allocp(&classtop, 1); oldp->derivp = classtop; /*oldp is set in optimize*/ WITH = classtop; WITH->inf = 0; WITH->prodnr = m; WITH->mode = 4; WITH->nextp = sp; WITH->derivp = NULL; *start = beginstate; } int stateno(configtype *pt) { int k; if (pt == NULL) return 0; else { k = 0; while (state[k].oldstart != pt) k++; return (state[k].newstart); } } void deletetail(int s, lrinx xstart, lrinx *xsi) { int sinx; int t = 1; int u, v; lrinx tinx, sx, tx, oldsinx; lrinx smatch = maxLAH; configtype *sptr, *tptr, *sp, *tp; boolean maxmatch = false; lrelm *WITH; configtype *WITH1; while (t < s && !maxmatch) { sinx = lr[xstart].chain; oldsinx = xstart; sptr = state[s].oldstart->derivp; while (sinx > 0 && sinx < smatch) { tinx = state[t].newstart; tptr = state[t].oldstart; v = 0; while (tinx > v) { if (lr[sinx].symb == lr[tinx].symb) { sx = sinx; tx = tinx; sp = sptr; tp = tptr; u = 0; while (sx > u && tx > 0) { WITH = &lr[sx]; WITH1 = sp; if (WITH->symb == lr[tx].symb && WITH->kind == lr[tx].kind && WITH1->nextp == tp->nextp) { sx = WITH->chain; sp = WITH1->derivp; tx = lr[tx].chain; tp = tp->derivp; } else u = sx + 1; } if (u == 0 && sx == tx) { /*sx=tx=0*/ /*successful match*/ maxmatch = (oldsinx == xstart); smatch = oldsinx; *xsi = smatch + 1; lr[smatch].chain = tinx; v = tinx + 1; } } if (v == 0) { tinx = lr[tinx].chain; tptr = tptr->derivp; } } /*while tinx>0 do*/ if (v != 0) { sinx = -1; break; } oldsinx = sinx; sinx = lr[sinx].chain; sptr = sptr->derivp; } /*while sinx>0....*/ t++; } } void compress(void) { int i; configtype *statep; lrinx si = 0; lrinx sstart; int FORLIM; configtype *WITH; lrelm *WITH1; FORLIM = statecount; /*copy parser to lr and merge identical tails of states*/ for (i = 0; i <= FORLIM; i++) { statep = state[i].oldstart; sstart = si; state[i].newstart = sstart; if (((1L << statep->mode) & 0x14) != 0) { lapres(&statep); WITH = state[i].oldstart; WITH->derivp = statep->derivp; WITH->nextp = statep->nextp; WITH->mode = statep->mode; WITH->inf = statep->inf; WITH->prodnr = statep->prodnr; } while (statep != NULL) { WITH1 = &lr[si]; WITH = statep; if (WITH->derivp == NULL) WITH1->chain = 0; else WITH1->chain = si + 1; if (((1L << WITH->mode) & 0x18) != 0) { /*prodnr is undef if mode=5*/ if (prod[WITH->prodnr].laend == 0) WITH->mode = 6; } WITH1->kind = WITH->mode; switch (WITH->mode) { case 1: case 2: case 4: case 6: WITH1->symb = WITH->inf; WITH1->err = WITH->prodnr; break; case 3: WITH1->rs = WITH->inf; WITH1->prodn = WITH->prodnr; if (WITH1->prodn == 0) WITH1->kind = 0; break; case 5: /* blank case */ break; } statep = WITH->derivp; if (si >= maxLAH - 1) consterror("compress ", "maxLAH ", maxLAH); si++; } if (lr[sstart].kind >= 0 && lr[sstart].kind < 32 && ((1L << lr[sstart].kind) & 0x16) != 0) deletetail(i, sstart, &si); } smax = si - 1; /*index of last element used in lr*/ FORLIM = statecount; for (i = 0; i <= FORLIM; i++) { sstart = state[i].newstart; statep = state[i].oldstart; si = sstart; while (statep != NULL) { WITH1 = &lr[si]; WITH = statep; WITH1->next = stateno(WITH->nextp); if (WITH->mode == 5) WITH1->lb = stateno(WITH->lookbp); si = WITH1->chain; if (si < sstart) statep = NULL; else statep = WITH->derivp; } } } void errortable(void) { int i, i5, j, kz; int no = 0; int ct, ctmax; lrinx lqbep, testp, gemp; int FORLIM; _REC_state *WITH; lrelm *WITH1; stringaddress *WITH2; int FORLIM1; _REC_state *WITH3; putc('\n', list); bar("Syntax error strings "); fprintf(list, " Error : Expected Symbols"); FORLIM = statecount; for (i = 1; i <= FORLIM; i++) state[i].errorno = 0; FORLIM = statecount; for (i = 1; i <= FORLIM; i++) { WITH = &state[i]; if (lr[WITH->newstart].kind == 1 && WITH->errorno == 0) { if (no < maxPRODS) no++; else consterror("errortable ", "maxprods ", maxPRODS); WITH->errorno = no; lr[WITH->newstart].err = no; newline(2); fprintf(list, "%10d : ", no); kz = 1; i5 = -1; lqbep = WITH->newstart; while (lqbep != 0) { kz++; lqbep = lr[lqbep].chain; } fprintf(output, "%5d%5d\n", no, kz - 1); lqbep = WITH->newstart; while (lqbep != 0) { WITH1 = &lr[lqbep]; listterm(stringarray[WITH1->symb + 1], &j); listtab(j, 10); putc(' ', list); WITH2 = &stringarray[WITH1->symb + 1]; FORLIM1 = WITH2->seg[WITH2->loc - 1]; for (j = 0; j < FORLIM1; j++) putc(WITH2->seg[WITH2->loc + j], output); putc('\n', output); if (i5 == -1) i5 = 0; lqbep = WITH1->chain; i5++; if (i5 == 5) { fprintf(list, "\n%s%s", blank, blank); i5 = 0; } } FORLIM1 = statecount; for (j = i + 1; j <= FORLIM1; j++) { if (lr[state[j].newstart].kind == 1 && state[j].errorno == 0) { lqbep = WITH->newstart; gemp = state[j].newstart; ctmax = 0; i5 = 0; while (lqbep != i5) { WITH1 = &lr[lqbep]; testp = gemp; ct = 2; while (lqbep != i5 && WITH1->symb != lr[testp].symb) { testp = lr[testp].chain; ct++; if (testp == 0) i5 = lqbep; } if (i5 == 0) { lqbep = WITH1->chain; if (lr[testp].chain == 0) ctmax = ct; } } if (i5 == 0 && kz == ctmax) { WITH3 = &state[j]; WITH3->errorno = no; lr[WITH3->newstart].err = no; } } } } } fprintf(output, "%5d%5d\n", 0, 0); newline(4); asterline(); } #define newentry 0 #define newvej 1 #define udenom 2 typedef struct _REC_lookant { unsigned ant : 7; configtype *point; } _REC_lookant; typedef struct _REC_stack { unsigned symb : 9, pnr : 9, token : 4; } _REC_stack; typedef struct _REC_ll { unsigned mrk : 1, lamrk : 1, lnk : 11; configtype *hidep; } _REC_ll; /* Local variables for verify: */ struct LOC_verify { int prodcnt, termcnt; configtype *start, *helpp, *lqbep1, *lastok; _REC_lookant lookant[ParsTBS]; int la[maxLAS + 1]; _REC_stack stack[maxSYMBS]; } ; /* Local variables for lalrlookahead: */ struct LOC_lalrlookahead { struct LOC_verify *LINK; int l, info, lltop; /*lltop is last used element of ll */ _REC_ll ll[SYMBCNT + 1]; prodtabx r; } ; Local void lalr1(configtype *statep, configtype *testp, int prodno_, struct LOC_lalrlookahead *LINK) { int leftinf, plngd, hinx; prodtabx rightp, prodp; /*pointer to rightside */ configtype *runp, *transp, *loopp, *chckp; boolean looping; prodtype *WITH; _REC_ll *WITH1; configtype *WITH2; WITH = &prod[prodno_]; leftinf = WITH->leftside; plngd = WITH->laend; LINK->r = WITH->start; if (WITH->laend > 0) /*rhs not empty*/ LINK->r++; rightp = LINK->r; prodp = rightp; if (testp != NULL && plngd > 0) { plngd--; chckp = testp; } else chckp = statep; while (prodp != rhsnil) { runp = rhs[prodp].parserp; loopp = runp; LINK->r = rightp; for (hinx = 1; hinx <= plngd; hinx++) { LINK->info = rhs[LINK->r].symbol; while (loopp->inf != LINK->info) loopp = loopp->derivp; loopp = loopp->nextp; LINK->r++; } looping = true; if (loopp == chckp) { if (LINK->ll[leftinf].mrk) { hinx = leftinf; do { WITH1 = &LINK->ll[hinx]; if (runp == WITH1->hidep) { looping = false; hinx = 0; } else { LINK->l = hinx; hinx = WITH1->lnk; } } while (hinx != 0); if (looping) { LINK->lltop++; if (LINK->lltop > SYMBCNT) consterror("lalrlookah ", "symbcnt ", SYMBCNT); hinx = LINK->lltop; LINK->ll[LINK->l].lnk = hinx; } } else hinx = leftinf; if (looping) { WITH1 = &LINK->ll[hinx]; WITH1->mrk = true; WITH1->hidep = runp; WITH1->lnk = 0; transp = runp; while (transp->inf != leftinf) transp = transp->derivp; transp = transp->nextp; loopp = transp; while (loopp != NULL) { WITH2 = loopp; if (WITH2->mode == 0) lalr1(transp, runp, WITH2->prodnr, LINK); else LINK->ll[WITH2->inf].lamrk = true; loopp = WITH2->derivp; } } } prodp = rhs[prodp].link; } } Local void lalrlookahead(configtype *pointp, int prodno_, struct LOC_verify *LINK) { struct LOC_lalrlookahead V; int j, FORLIM; _REC_ll *WITH; V.LINK = LINK; V.lltop = maxSYMBS; for (j = 0; j <= maxSYMBS; j++) { WITH = &V.ll[j]; WITH->mrk = false; WITH->lamrk = false; } lalr1(pointp, NULL, prodno_, &V); lalrend = 0; FORLIM = termg; for (j = 0; j <= FORLIM; j++) { if (V.ll[j].lamrk) { LINK->la[lalrend] = j; if (lalrend < maxLAS) lalrend++; else consterror("lalrlookah ", "maxLAS ", maxLAS); } } if (lalrend != 0) return; newline(2); fprintf(list, " ***** prod%12d", prodno_); newline(2); } Local void lookahead(int *a, struct LOC_verify *LINK) { prodtabx begindp, p1, symbp; int i; int j = 0; int k, pnr, cnt, prodnr; int lax = 0; int symbol; int llimit = 1; int stack[maxLAS + 1], buffer[maxLAS + 1]; boolean laloop, repeatla, exitla; int FORLIM; _REC_help *WITH; FORLIM = lastnont; for (pnr = firstnont; pnr <= FORLIM; pnr++) help[pnr].status = 0; for (i = 0; i <= maxLAS; i++) LINK->la[i] = 0; begindp = prod[0].start; lalrend = 0; do { laloop = true; prodnr = 0; i = 1; p1 = begindp; do { repeatla = false; exitla = false; incrtabx(&p1); if (i > prod[prodnr].laend) { prodnr++; i = 1; if (prodnr > prodcount) exitla = true; else { p1 = prod[prodnr].start; incrtabx(&p1); } } if (!exitla) { while (rhs[p1].symbol != *a && p1 < top) { incrtabx(&p1); i++; if (i <= prod[prodnr].laend) continue; prodnr++; i = 1; if (prodnr > prodcount) exitla = true; else { p1 = prod[prodnr].start; incrtabx(&p1); } } if (!exitla) { if (p1 < top) { if (i < prod[prodnr].laend) { incrtabx(&p1); symbol = rhs[p1].symbol; symbp = p1; i++; } else { pnr = prod[prodnr].leftside; /* to stack */ WITH = &help[pnr]; if (WITH->status == 0 && pnr != *a) { if (j < maxLAS) { j++; WITH->status = 1; stack[j] = pnr; } else consterror("lookahead ", "maxLAS ", maxLAS); } i++; repeatla = true; } } else exitla = true; if (!exitla && !repeatla) { if (symbol > termg) { FORLIM = firstnont; for (k = 0; k < FORLIM; k++) { if (P_inset(k % (setmax + 1), ph1s[symbol].r[k / (setmax + 1)])) { /* p2c: pg.p, line 1219: * Note: Using % for possibly-negative arguments [317] */ buffer[lax] = k; lax++; if (lax > maxLAS) consterror("lookahead ", "maxLAS ", maxLAS); lalrend++; } } } else { buffer[lax] = symbol; lalrend++; lax++; if (lax > maxLAS) consterror("lookahead ", "maxLAS ", maxLAS); } p1 = symbp; i++; repeatla = true; } } } } while (repeatla); if (j > 0) { *a = stack[j]; j--; } else laloop = false; } while (laloop); if (lalrend > 0) LINK->la[0] = buffer[0]; j = 1; i = 0; cnt = lalrend; while (j < cnt) { while (LINK->la[i] != buffer[j] && i < llimit) i++; if (i == llimit) { LINK->la[llimit] = buffer[j]; llimit++; } else lalrend--; j++; i = 0; } } Local void voptimize(char x, struct LOC_verify *LINK) { switch (x) { case newentry: LINK->lastok->derivp = LINK->helpp->derivp; LINK->lastok->nextp = LINK->helpp->nextp; LINK->lastok->mode = LINK->helpp->mode; if (LINK->helpp->mode == 5) LINK->lastok->lookbp = LINK->helpp->lookbp; else if (LINK->helpp->mode > 0 && LINK->helpp->mode < 5) { LINK->lastok->inf = LINK->helpp->inf; LINK->lastok->prodnr = LINK->helpp->prodnr; } break; case newvej: LINK->lastok->derivp = LINK->helpp; LINK->lastok = LINK->helpp; break; case udenom: LINK->lastok->derivp = LINK->helpp; break; } } Local void lalrtext(int x, struct LOC_verify *LINK) { asterline(); fprintf(list, " "); switch (x) { case 1: fprintf(list, "The grammar is LALR1 \n"); fprintf(console, " The grammar is LALR1\n"); consoleflush(); asterline(); break; case 2: fprintf(list, "The grammar is not LALR1 \n"); fprintf(list, " "); fprintf(console, " The grammar is not LALR1\n"); consoleflush(); fprintf(list, "Processing stops \n"); asterline(); stop(0); break; } } Local void adeqwrite(int x, struct LOC_verify *LINK) { int i, j, k, l, kk, m; configtype *helpp; int FORLIM; switch (x) { case 1: bar("A list of non-slr1 states "); fprintf(list, " "); fprintf(list, "in each of the following states the \n"); fprintf(list, " "); fprintf(list, "sets of symbols are not disjoint \n"); break; case 2: bar("End of non-slr1 states "); break; case 3: fprintf(list, "\n "); for (j = 1; j <= 61; j++) putc('-', list); putc('\n', list); if (LINK->termcnt > 0) { fprintf(list, " "); fprintf(list, "Reading continues if the next input symbol\n"); fprintf(list, " "); fprintf(list, "is one of the following: \n"); fprintf(list, " "); fprintf(list, "Symbol Production Symbol no.\n"); FORLIM = LINK->termcnt; for (j = 0; j < FORLIM; j++) { kk = LINK->stack[j].pnr; l = LINK->stack[j].token; k = LINK->stack[j].symb; fprintf(list, " "); listterm(stringarray[k+1], &i); fprintf(list, "%12d", kk); fprintf(list, "%12d\n", l); } putc('\n', list); } FORLIM = LINK->prodcnt; for (j = 0; j < FORLIM; j++) { l = LINK->lookant[j].ant; helpp = LINK->lookant[j].point; fprintf(list, " "); fprintf(list, "Reduction no."); m = helpp->prodnr; fprintf(list, "%4d", m); fprintf(list, " is performed if the next input symbol\n"); fprintf(list, " "); fprintf(list, "is one of the following : \n"); kk = 0; do { kk++; fprintf(list, " "); k = helpp->inf; listterm(stringarray[k+1], &i); putc('\n', list); helpp = helpp->derivp; } while (kk != l); putc('\n', list); } break; case 4: /* earlier user for writing warning states */ break; case 5: bar("A list of non-lalr1 states "); fprintf(list, " "); fprintf(list, "In each of the following states the\n"); fprintf(list, " "); fprintf(list, "sets of symbols are not disjoint\n"); break; case 6: bar("End of non-lalr1 states "); break; } } Local int mendcheck(struct LOC_verify *LINK) { int iboo = 0, count = 0; int checksymb, k, step1, step2, l1, l2, j, l; configtype *step1p, *step2p, *stepp1, *stepp2; LINK->helpp = LINK->start; if (LINK->termcnt > 0) { count = 0; while (count < LINK->termcnt) { count++; checksymb = LINK->stack[count-1].symb; j = 0; do { j++; k = LINK->lookant[j-1].ant; LINK->lqbep1 = LINK->lookant[j-1].point; l = 0; do { l++; if (LINK->lqbep1->inf == checksymb) { iboo = 1; l = k; j = LINK->prodcnt; count = LINK->termcnt; } LINK->lqbep1 = LINK->lqbep1->derivp; } while (l != k); } while (j != LINK->prodcnt); } } if (iboo != 0 || LINK->prodcnt <= 1) return iboo; k = 0; do { k++; step1 = LINK->lookant[k-1].ant; step1p = LINK->lookant[k-1].point; j = k; do { stepp1 = step1p; j++; step2 = LINK->lookant[j-1].ant; step2p = LINK->lookant[j-1].point; l1 = 0; do { l1++; l2 = 0; stepp2 = step2p; do { l2++; if (stepp1->inf == stepp2->inf) { l2 = step2; l1 = step1; j = LINK->prodcnt; iboo = 1; k = LINK->prodcnt - 1; } stepp2 = stepp2->derivp; } while (l2 != step2); stepp1 = stepp1->derivp; } while (l1 != step1); } while (j != LINK->prodcnt); } while (k != LINK->prodcnt - 1); return iboo; } Local configtype *findreduce(int pnr, struct LOC_verify *LINK) { prodtabx p1, p2; configtype *pt; prodtype *WITH; WITH = &prod[pnr]; if (WITH->laend == 0) return (WITH->lookbackp); else { p1 = WITH->start; while (rhs[p1].parserp->derivp != NULL) { p2 = p1; p1 = rhs[p1].link; if (p1 != rhsnil) continue; allocp(&pt, 1); pt->mode = 3; pt->inf = WITH->laend - 1; pt->prodnr = pnr; pt->nextp = WITH->lookbackp; pt->derivp = NULL; statecount++; if (statecount > Nparstb) consterror("findreduce ", "Nparstb ", Nparstb); state[statecount].oldstart = pt; newelm(&top, "findreduce "); p1 = top; rhs[p1].parserp = pt; rhs[p1].link = rhsnil; rhs[p2].link = p1; } return (rhs[p1].parserp); } } /* PG4----------------------------------------------------------------*/ void verify(void) { struct LOC_verify V; int iboo, i, j, k, pnr, l, count; boolean slr1 = true, headwrite = true; configtype *lqbep2, *lqbep3, *stopp; int FORLIM; configtype *WITH; prodtype *WITH1; FORLIM = statenum; for (i = 1; i <= FORLIM; i++) { V.start = state[i].oldstart; V.prodcnt = 0; V.termcnt = 0; V.helpp = V.start; do { k = V.helpp->mode; if (k == 0) V.prodcnt++; else if (V.helpp->inf <= termg && V.helpp->nextp != NULL) V.termcnt++; V.helpp = V.helpp->derivp; } while (V.helpp != NULL); if (V.prodcnt > ParsTBS) consterror("verify ", "ParsTBS ", ParsTBS); if (V.prodcnt > 1 || V.prodcnt == 1 && V.termcnt > 0) { V.prodcnt = 0; V.termcnt = 0; V.helpp = V.start; do { k = V.helpp->mode; if (k == 0) { pnr = V.helpp->prodnr; lalrlookahead(V.start, pnr, &V); l = lalrend - 1; allocp(&V.lqbep1, 1); V.helpp->nextp = V.lqbep1; V.prodcnt++; V.lookant[V.prodcnt-1].ant = lalrend; V.lookant[V.prodcnt-1].point = V.lqbep1; lqbep3 = findreduce(pnr, &V); for (j = 0; j <= l; j++) { lqbep2 = V.lqbep1; lqbep2->nextp = lqbep3; lqbep2->inf = V.la[j]; lqbep2->prodnr = pnr; lqbep2->mode = 4; if (j == l) lqbep2->derivp = V.helpp->derivp; else { allocp(&V.lqbep1, 1); lqbep2->derivp = V.lqbep1; } } } else { WITH = V.helpp; if (WITH->inf <= termg && WITH->nextp != NULL) { V.termcnt++; if (V.termcnt > maxSYMBS) consterror("verify ", "maxsymbs ", maxSYMBS); else { V.stack[V.termcnt-1].symb = WITH->inf; V.stack[V.termcnt-1].pnr = WITH->prodnr; V.stack[V.termcnt-1].token = WITH->mode; } } WITH->mode = 2; } V.helpp = V.helpp->derivp; } while (V.helpp != NULL); iboo = mendcheck(&V); if (iboo != 0) { if (slr1 && headwrite) { adeqwrite(5, &V); if (iboo == 1) slr1 = false; else headwrite = false; } adeqwrite(3, &V); } } else if (V.prodcnt == 0) { V.helpp = V.start; while (V.helpp != NULL) { V.helpp->mode = 1; V.helpp = V.helpp->derivp; } } } if (!slr1) { adeqwrite(6, &V); lalrtext(2, &V); stop(0); return; } FORLIM = statenum; for (i = 1; i <= FORLIM; i++) { V.start = state[i].oldstart; V.lastok = V.start; V.prodcnt = 0; V.termcnt = 0; count = 0; V.lqbep1 = V.start; do { V.helpp = V.lqbep1; count++; WITH = V.lqbep1; stopp = WITH->derivp; if (WITH->mode == 0 && WITH->nextp != NULL) { if (V.prodcnt == 0 && V.termcnt == 0) { V.helpp = WITH->nextp; voptimize(newentry, &V); } else { V.helpp = WITH->nextp; voptimize(newvej, &V); } V.prodcnt++; do { lqbep3 = V.lastok->derivp; if (lqbep3 != stopp) V.lastok = lqbep3; } while (lqbep3 != stopp); } else if (WITH->mode == 0) { WITH1 = &prod[WITH->prodnr]; WITH->mode = 3; WITH->nextp = WITH1->lookbackp; V.prodcnt++; if (WITH1->laend == 0) WITH->inf = 0; else WITH->inf = WITH1->laend - 1; if (count > 1) voptimize(newentry, &V); } else if (WITH->inf <= termg) { if (count > 1) { if (WITH->nextp != NULL) { V.helpp = V.lqbep1; if (V.prodcnt == 0 && V.termcnt == 0) voptimize(newentry, &V); else voptimize(newvej, &V); } else { V.helpp = stopp; voptimize(udenom, &V); V.termcnt--; } } V.termcnt++; } else { V.helpp = WITH->derivp; if (V.termcnt == 0 && V.prodcnt == 0) voptimize(newentry, &V); else { V.helpp = stopp; voptimize(udenom, &V); } } V.lqbep1 = stopp; } while (V.lqbep1 != NULL); } lalrtext(1, &V); } #undef newentry #undef newvej #undef udenom /* PG3----------------------------------------------------------------*/ void freelist(configtype **pt) { configtype *p; p = *pt; while (p->derivp != NULL) p = p->derivp; p->derivp = freeptr; freeptr = *pt; *pt = NULL; } typedef struct _REC_stack_ { unsigned symbovg : 9; configtype *stp; } _REC_stack_; /* Local variables for lr0: */ struct LOC_lr0 { _REC_stack_ stack[LRstack]; prodtabx lqbep2; int baslae, stacktop, stacktael; } ; Local void align(configtype *startp, boolean boo, struct LOC_lr0 *LINK) { int i; configtype *WITH; _REC_rhs *WITH1; lqbep = startp; while (lqbep != NULL) { WITH = lqbep; LINK->lqbep2 = prod[WITH->prodnr].start; for (i = WITH->mode; i >= 1; i--) incrtabx(&LINK->lqbep2); if (rhs[LINK->lqbep2].parserp != NULL) { while (rhs[LINK->lqbep2].link != rhsnil) LINK->lqbep2 = rhs[LINK->lqbep2].link; rhs[LINK->lqbep2].link = top; LINK->lqbep2 = top; newelm(&top, "align "); } WITH1 = &rhs[LINK->lqbep2]; WITH1->basis = boo; if (boo) WITH1->basisl = LINK->baslae; WITH1->parserp = beginstate; WITH1->link = rhsnil; lqbep = WITH->derivp; } } Local void stackellerej(struct LOC_lr0 *LINK) { configtype *WITH; _REC_help *WITH1; _REC_stack_ *WITH2; WITH = classtop; WITH1 = &help[WITH->inf]; if (WITH1->overgang) return; LINK->stacktael++; if (LINK->stacktop >= LRstack) consterror("lr0 ", "LRstack ", LRstack); LINK->stacktop++; WITH1->overgang = true; WITH2 = &LINK->stack[LINK->stacktop-1]; WITH2->symbovg = WITH->inf; WITH2->stp = beginstate; } void lr0(void) { struct LOC_lr0 V; configtype *helpp, *closp, *oldp; int modeh, i, symb, prodno_; boolean copy, loopx, finlq; int goalprod = 0; configtype *WITH; _REC_stack_ *WITH1; _REC_help *WITH2; _REC_rhs *WITH3; prodtype *WITH4; configtype *WITH5; top = point; newelm(&top, "lr0 "); statecount = 0; allocp(&rodp, 1); classtop = rodp; WITH = rodp; WITH->prodnr = goalprod; WITH->mode = 1; V.lqbep2 = prod[goalprod].start; incrtabx(&V.lqbep2); WITH->inf = rhs[V.lqbep2].symbol; WITH->derivp = NULL; V.baslae = 1; V.stacktop = 1; WITH1 = V.stack; WITH1->stp = rodp; WITH1->symbovg = rodp->inf; statenum = 0; state[statenum].oldstart = rodp; align(rodp, true, &V); allocp(&classtop, 1); beginstate = classtop; while (V.stacktop > 0) { WITH1 = &V.stack[V.stacktop-1]; oldp = WITH1->stp; symb = WITH1->symbovg; lqbep = oldp; V.stacktael = 0; V.baslae = 0; V.stacktop--; for (i = 0; i <= maxSYMBS; i++) { WITH2 = &help[i]; WITH2->afledt = false; WITH2->overgang = false; } while (lqbep->inf != symb) lqbep = lqbep->derivp; closp = lqbep; loopx = true; while (loopx) { if (V.baslae == maxBASIS) consterror("lr0 ", "maxBASIS ", maxBASIS); V.baslae++; WITH = classtop; WITH->nextp = NULL; WITH->prodnr = lqbep->prodnr; modeh = lqbep->mode + 1; if (prod[WITH->prodnr].laend < modeh) { WITH->mode = 0; WITH->inf = 0; } else { WITH->mode = modeh; V.lqbep2 = prod[WITH->prodnr].start; for (i = WITH->mode; i >= 1; i--) incrtabx(&V.lqbep2); WITH->inf = rhs[V.lqbep2].symbol; stackellerej(&V); } do { lqbep = lqbep->derivp; if (lqbep == NULL) { loopx = false; finlq = true; } else finlq = (lqbep->inf == symb); } while (!finlq); if (!loopx) break; helpp = classtop; allocp(&classtop, 1); helpp->derivp = classtop; } classtop->derivp = NULL; copy = false; V.lqbep2 = prod[beginstate->prodnr].start; for (i = beginstate->mode; i >= 1; i--) incrtabx(&V.lqbep2); if (rhs[V.lqbep2].parserp != NULL) { while (V.lqbep2 != rhsnil && !copy) { WITH3 = &rhs[V.lqbep2]; if (WITH3->basis) { if (V.baslae == WITH3->basisl) { copy = true; lqbep = beginstate; while (lqbep != NULL && copy) { WITH = lqbep; copy = false; helpp = WITH3->parserp; while (helpp != NULL) { copy = ((WITH->prodnr == helpp->prodnr && WITH->mode == helpp->mode) || copy); helpp = helpp->derivp; } lqbep = WITH->derivp; } } } if (!copy) V.lqbep2 = WITH3->link; } } if (copy) { closp->nextp = rhs[V.lqbep2].parserp; V.stacktop -= V.stacktael; freelist(&beginstate); allocp(&classtop, 1); beginstate = classtop; continue; } closp->nextp = beginstate; if (statenum == Nparstb) consterror("lr0 ", "Nparstb ", Nparstb); statenum++; state[statenum].oldstart = beginstate; align(beginstate, true, &V); closp = classtop; lqbep = beginstate; while (lqbep != NULL) { WITH = lqbep; WITH2 = &help[WITH->inf]; if (WITH->mode > 0) { if (WITH->inf > termg) { if (!WITH2->afledt) { WITH2->afledt = true; prodno_ = WITH2->prodindex; while (prod[prodno_].leftside == WITH->inf) { WITH4 = &prod[prodno_]; helpp = classtop; allocp(&classtop, 1); helpp->derivp = classtop; WITH5 = classtop; V.lqbep2 = WITH4->start; incrtabx(&V.lqbep2); WITH5->inf = rhs[V.lqbep2].symbol; if (prod[prodno_].laend == 0) WITH5->mode = 0; else WITH5->mode = 1; WITH5->prodnr = prodno_; WITH5->derivp = NULL; WITH5->nextp = NULL; if (classtop->mode > 0) stackellerej(&V); prodno_++; } } } } lqbep = WITH->derivp; } if (closp->derivp != NULL) align(closp->derivp, false, &V); allocp(&classtop, 1); beginstate = classtop; } } void lookb(void) { int prodnr = 0; int symb, md, r1; prodtabx point; configtype *stp; prodtype *WITH; configtype *WITH1; prod[0].lookbackp = NULL; statecount = statenum; while (prodnr < prodcount) { prodnr++; WITH = &prod[prodnr]; frqi = 0; allocp(&classtop, 5); beginstate = classtop; symb = WITH->leftside; point = WITH->start; if (WITH->laend > 0) incrtabx(&point); while (point != rhsnil) { WITH1 = classtop; WITH1->mode = 5; stp = rhs[point].parserp; if (stp == NULL) { fprintf(console, " Error(s) in grammar\n"); consoleflush(); newline(2); fprintf(list, " The grammar cannot produce a string containing\n"); putc(' ', list); r1 = 1; writenont(WITH->leftside, &r1); newline(2); stop(0); } WITH1->lookbp = stp; while (stp->inf != symb) stp = stp->derivp; stp = stp->nextp; countnextp(stp); WITH1->nextp = stp; oldp = classtop; allocp(&classtop, 5); oldp->derivp = classtop; point = rhs[point].link; } oldp->derivp = NULL; if (frqi == 1) { WITH->lookbackp = beginstate->nextp; freelist(&beginstate); } else { md = 5; optimize(&stp, &md); oldp->derivp = classtop; WITH1 = classtop; WITH1->derivp = NULL; WITH1->nextp = stp; WITH1->lookbp = NULL; WITH1->mode = 5; statecount++; if (statecount > Nparstb) consterror("lookb ", "Nparstb ", Nparstb); state[statecount].oldstart = beginstate; WITH->lookbackp = beginstate; } while (prod[prodnr+1].leftside == symb) { prodnr++; prod[prodnr].lookbackp = WITH->lookbackp; } } } /* PG2----------------------------------------------------------------*/ void initprod(void) { prodtabx p; int k = -1; int i, l, FORLIM; prodtype *WITH; int FORLIM1; FORLIM = lastnont; for (i = firstnont; i <= FORLIM; i++) { p = help[i].rightp; while (p != rhsnil) { k++; if (k > maxPRODS) consterror("initprod ", "maxprods ", maxPRODS); WITH = &prod[k]; WITH->leftside = i; WITH->start = p; WITH->laend = rhs[p].basisl; FORLIM1 = WITH->laend; for (l = 1; l <= FORLIM1; l++) incrtabx(&p); if (WITH->laend == 1 && rhs[WITH->start + 1].symbol == emptyvalue) WITH->laend = 0; p = rhs[p].link; } } prod[k+1].leftside = 0; prodcount = k; i = 0; while (i <= prodcount) { symb = prod[i].leftside; help[symb].prodindex = i; do { i++; } while (symb == prod[i].leftside); } } void iterer(rtype *matrix) { int n, up1, up2, nn, m, k, kk, l, i, j; boolean done; bitset gem, boo; bitmatrix trans; rtype rfresh; int FORLIM; long SET[3]; bitset SET1; rtype *WITH; n = lastnont / (setmax + 1); nn = lastnont - n * (setmax + 1); do { up1 = setmax; done = true; k = -1; for (m = 0; m <= n; m++) { if (m == n) up1 = nn; for (kk = 0; kk <= up1; kk++) { k++; j = -1; up2 = setmax; for (l = 0; l <= n; l++) { P_expset(boo, 0); if (l == n) up2 = nn; for (i = 0; i <= up2; i++) { j++; if (P_inset(kk, matrix[j].r[m])) P_addset(boo, i); } P_setcpy(trans[k].r[l], boo); } } } for (i = 0; i <= BSarrSZ; i++) P_expset(rfresh.r[i], 0); FORLIM = lastnont; for (k = firstnont; k <= FORLIM; k++) { WITH = &matrix[k]; i = -1; up2 = setmax; for (l = 0; l <= n; l++) { P_expset(gem, 0); if (l == n) up2 = nn; for (m = 0; m <= up2; m++) { i++; P_expset(boo, 0); for (j = 0; j <= n; j++) P_setunion(boo, boo, P_setint(SET1, WITH->r[j], trans[i].r[j])); if (*boo != 0) P_addset(gem, m); } P_setcpy(rfresh.r[l], gem); } for (j = 0; j <= n; j++) { P_setunion(gem, WITH->r[j], rfresh.r[j]); if (!P_setequal(gem, WITH->r[j])) { P_setcpy(WITH->r[j], gem); done = false; } } } } while (!done); } void vhrecurs(void) { prodtabx p; boolean boo = false; int ii, j, ll, i, l, start, FORLIM; long SET[3]; bitset SET1, SET2; i = lastnont / (setmax + 1); if (i > BSarrSZ) { newline(2); consterror("vhrecurs ", "BSarrSZ ", BSarrSZ); } for (i = 0; i <= maxSYMBS; i++) { for (j = 0; j <= BSarrSZ; j++) { P_expset(ph1s[i].r[j], 0); P_expset(pt1s[i].r[j], 0); } } FORLIM = lastnont; for (i = firstnont; i <= FORLIM; i++) { p = help[i].rightp; while (p != rhsnil) { l = rhs[p].basisl; ll = rhs[p+1].symbol; ii = ll / (setmax + 1); P_addset(ph1s[i].r[ii], ll % (setmax + 1)); /* p2c: pg.p, line 2012: * Note: Using % for possibly-negative arguments [317] */ ll = rhs[p + l].symbol; ii = ll / (setmax + 1); P_addset(pt1s[i].r[ii], ll % (setmax + 1)); /* p2c: pg.p, line 2015: * Note: Using % for possibly-negative arguments [317] */ p = rhs[p + l].link; } } iterer(ph1s); iterer(pt1s); l = 1; start = firstnont + 1; FORLIM = lastnont; for (ii = start; ii <= FORLIM; ii++) { i = ii / (setmax + 1); if (*P_setint(SET2, P_setint(SET1, ph1s[ii].r[i], pt1s[ii].r[i]), P_addset(P_expset(SET, 0), ii % (setmax + 1))) != 0) { /* p2c: pg.p, line 2026: * Note: Using % for possibly-negative arguments [317] */ boo = true; fprintf(list, "\n "); writenont(ii, &l); } } if (!boo) return; fprintf(list, "\n The above nonterminal(s) is(are) both left and right recursive.\n"); fprintf(console, " A nonterminal is both left and right recursive\n"); stop(3); } /*--------------------------------------------------------------------*/ void writesub(int rem, int ind) { int z = 1; putc(' ', list); writenont(rem, &z); fprintf(list, " has been substituted by "); writenont(ind, &z); putc('\n', list); } boolean removechain(boolean t, boolean *modb) { boolean Result = false; int i, k, l, m, n, s, remove, indsat; prodtabx j; k = lastnont; i = firstnont - 1; do { i++; j = help[i].rightp; if (j != rhsnil && rhs[j].basisl == 1) { incrtabx(&j); if (rhs[j].link == rhsnil && rhs[j].symbol > termg) { indsat = rhs[j].symbol; remove = i; help[i].rightp = rhsnil; Result = true; *modb = true; if (t) writesub(remove, indsat); s = firstnont - 1; do { s++; j = help[s].rightp; if (j != rhsnil) { l = rhs[j].basisl; m = 0; do { for (n = 1; n <= l; n++) { incrtabx(&j); if (rhs[j].symbol == remove) rhs[j].symbol = indsat; } if (rhs[j].link == rhsnil) m = 1; else { j = rhs[j].link; l = rhs[j].basisl; } } while (m != 1); } } while (s != k); } } } while (i != k); return Result; } void writeip(int *x, int ju, int lae, prodtabx stp2) { int l; int jj = 1; int ll; prodtabx stepp3 = stp2; if (*x == 1) { newline(2); fprintf(list, " Duplicate productions occur\n"); fprintf(list, " and the grammar is modified.\n"); fprintf(list, " The following productions exist more than once:\n"); } putc(' ', list); writenont(ju, &jj); fprintf(list, " ::= "); for (l = 1; l <= lae; l++) { incrtabx(&stepp3); ll = rhs[stepp3].symbol; if (ll <= termg) writeterm(stringarray[ll+1], &jj); else writenont(ll, &jj); putc(' ', list); } putc('\n', list); } boolean identprod(boolean *t) { int laend1, laend2, i, j; int kk = 0; boolean ens; boolean idboo = false; prodtabx startp1, startp2, stepp1, stepp2, lastok; int FORLIM; FORLIM = lastnont; for (j = firstnont; j <= FORLIM; j++) { startp1 = help[j].rightp; if (startp1 != rhsnil) { do { laend1 = rhs[startp1].basisl; startp2 = startp1; for (i = 1; i <= laend1; i++) incrtabx(&startp2); lastok = startp2; startp2 = rhs[startp2].link; if (startp2 != rhsnil) { do { ens = false; stepp1 = startp1; stepp2 = startp2; laend2 = rhs[stepp2].basisl; if (laend1 == laend2) { ens = true; for (i = 1; i <= laend1; i++) { incrtabx(&stepp1); incrtabx(&stepp2); if (rhs[stepp1].symbol != rhs[stepp2].symbol) ens = false; } if (ens) { kk++; if (*t) writeip(&kk, j, laend2, startp2); idboo = true; rhs[lastok].link = rhs[stepp2].link; } } else { for (i = 1; i <= laend2; i++) incrtabx(&stepp2); } if (!ens) lastok = stepp2; stepp2 = rhs[stepp2].link; if (stepp2 != rhsnil) startp2 = stepp2; } while (stepp2 != rhsnil); for (i = 1; i <= laend1; i++) incrtabx(&startp1); startp1 = rhs[startp1].link; if (startp1 == rhsnil) startp1 = startp2; } else startp2 = startp1; } while (startp1 != startp2); } } if (*t) newline(2); return idboo; } void removeid(boolean dowrites) { boolean dolist = dowrites, idch = true; boolean idb; boolean hasmods = false; while (idch) { idb = identprod(&dolist); idch = removechain(dowrites, &hasmods); idch = (idch || idb); dolist = false; } if (hasmods && dowrites) { fprintf(list, " The grammar has been modified for simple chains\n"); fprintf(list, " using the above substitutions\n"); } } /* exit label for parser errors */ typedef uchar chbufinx; typedef uchar chbuftype[chbufmax + 1]; typedef char stackinx; typedef struct treenode { int nodetype; stringaddress address; struct treenode *left, *right; } treenode; typedef struct attributes { chbufinx chbufp; int prodint; treenode *node; stringaddress address; } attributes; typedef uchar chstring[stringmax]; typedef char errmsginx; typedef struct _REC_errmsg { int no, col, symb; } _REC_errmsg; /* prodno = 0..prodmax; */ /* rslength = -1..symbmax; */ /* lrinx = 0..lrmax; */ typedef char reduinx; typedef struct reduelem { unsigned oldtop : 6, newtop : 6, prod : 9; } reduelem; typedef struct stackelm { unsigned link : 6, table : 11; } stackelm; /* Local variables for inputgrammar: */ struct LOC_inputgrammar { int symbcount; attributes attstack[stackmax + 1]; chbuftype chbuf; chbufinx chbufi; /* character buffer index */ int integervalue; /* the numerical value of integers read in */ int errcount; /* becomes nonzero when errors found */ int maxerrcount; /* max no or errors before giving up*/ uchar line[recmax]; /*contains current line*/ int linelength; /*length of current input line */ _REC_errmsg errmsg[errmax + 1]; errmsginx errmp; /* index of error messages in errmsg */ boolean stoperror, proderror; stringaddress saddr, niladdress, emptyaddress; treenode *treeroot; uchar suffix; int numberoftermsymbs; } ; Local void produce(stackinx oldtop, stackinx newtop, int prod, struct LOC_inputgrammar *LINK); /*--------------------------------------------------------------------*/ Local void parserstop(int n, struct LOC_inputgrammar *LINK) { newline(2); switch (n) { case 0: /* blank case */ break; case 1: m(" *** Installation-dependent const \"stackmax\" exceeded "); break; case 2: m(" *** End of file encountered on input "); break; case 3: m(" *** Syntax error recovery abandoned "); break; case 4: m(" *** Installation-dependent const \"redumax\" exceeded "); break; case 5: m(" *** Overflow of character buffer: \"chbufmax\" exceeded"); break; case 6: m(" *** Maximum error count exceeded "); break; } switch (n) { case 0: /* blank case */ break; case 1: case 4: case 5: m(" *** Translation stopped by translator error "); break; case 2: case 3: case 6: m(" *** Translation stopped by source error(s) "); break; } /*H goto 10 H*/ /*F halt(1) F*/ /*exit*/ } /* Local variables for writeerror: */ struct LOC_writeerror { struct LOC_inputgrammar *LINK; int inx, emi; } ; Local void e(Char *s, struct LOC_writeerror *LINK) { fprintf(list, " *** ERROR%4d (%d): %.*s\n", LINK->emi, LINK->inx, MSTRINGlen, s); fprintf(console, " *** ERROR%4d (%d): %.*s\n", LINK->emi, LINK->inx, MSTRINGlen, s); } Local void w(Char *s, struct LOC_writeerror *LINK) { fprintf(list, " *** WARNING%4d (%d): %.*s\n", LINK->emi, LINK->inx, MSTRINGlen, s); fprintf(console, " *** WARNING%4d (%d): %.*s\n", LINK->emi, LINK->inx, MSTRINGlen, s); } /*--------------------------------------------------------------------*/ Local void writeerror(struct LOC_inputgrammar *LINK) { struct LOC_writeerror V; int symb, FORLIM, FORLIM1; V.LINK = LINK; FORLIM = LINK->linelength; for (V.emi = 1; V.emi <= FORLIM; V.emi++) putc(LINK->line[V.emi-1], console); putc('\n', console); fprintf(list, " "); V.emi = 1; FORLIM = LINK->errmp; for (V.inx = 1; V.inx <= FORLIM; V.inx++) { for (FORLIM1 = LINK->errmsg[V.inx].col; V.emi < FORLIM1; V.emi++) { putc(' ', list); putc(' ', console); } fprintf(list, "%d", V.inx); fprintf(console, "%d", V.inx); V.emi += 2; } putc('\n', list); putc('\n', console); FORLIM = LINK->errmp; for (V.inx = 1; V.inx <= FORLIM; V.inx++) { V.emi = LINK->errmsg[V.inx].no; if (V.emi < 800) { symb = LINK->errmsg[V.inx].symb; if (symb == 2) e("A name was found but the following were expected: ", &V); else if (symb == 4) e("A string was found but the following were expected: ", &V); else if (symb == 3) e("An integer was found but the following were expected: ", &V); else if (symb == 5) e("An error was found but the following were expected: ", &V); else if (symb > 6 && symb < 11) e("Reserved word found. The following were expected: ", &V); else e("Punctuation characters found; expected symbols were: ", &V); } switch (V.emi) { case 1: m("<ERROR> TERMINALS OPTIONS EMPTYTERM "); break; case 2: m(": = "); break; case 3: m("<STRING> "); break; case 4: m("<INTEGER> <ERROR> "); break; case 5: m(". "); break; case 6: m("TERMINALS "); break; case 7: m("<NAME> "); break; case 8: m("TERMINALS EMPTYTERM <ERROR> "); break; case 9: m(". <NAME> "); break; case 10: m("= "); break; case 11: m("<ERROR> [ <NAME> <STRING> ( "); m("{ "); break; case 12: m("$ <ERROR> [ <NAME> <STRING> "); m("( { "); break; case 13: m("{ "); break; case 14: m("] | "); break; case 15: m(") | "); break; case 16: m("| }L }R "); break; case 17: m("$ | }L }R "); break; case 18: m("}L }R <ERROR> [ <NAME> "); m("<STRING> ( { "); break; case 19: m(". | "); break; case 20: m(". <NAME> <ERROR> "); break; case 21: m("<EOF> "); break; /* lexical error messages */ case 800: e("Character not recognized: ignored ", &V); break; case 801: e("Null string not allowed ", &V); break; /* lexical warning messages */ case 901: w("A pending comment was not terminated ", &V); break; case 902: w("String end character generated at end of line ", &V); break; case 903: w("An identifier must not begin or end with an underscore", &V); break; case 904: w("Input line may exceed maximum alloable length ", &V); break; case 905: w("Incorrect octal character representation ", &V); break; } putc('\n', console); consoleflush(); } if (LINK->errcount > LINK->maxerrcount) parserstop(6, LINK); } /* Local variables for produce: */ struct LOC_produce { struct LOC_inputgrammar *LINK; stackinx oldtop, newtop; int prod, i, wrj; treenode *np; boolean carry, primaryfound; } ; Local void listterminals(struct LOC_produce *LINK) { /* list the internal values of terminals */ int i, j, middle; newline(2); fprintf(list, " Terminal Symbols:\n"); fprintf(list, " Value Terminal Value Terminal"); newline(2); middle = LINK->LINK->numberoftermsymbs >> 1; for (i = 0; i <= middle; i++) { fprintf(list, " %5d ", i); listterm(stringarray[i+1], &j); listtab(j, 10); if (middle + i < LINK->LINK->numberoftermsymbs) { fprintf(list, " %5d ", middle + i + 1); listterm(stringarray[middle + i + 2], &j); } putc('\n', list); } newline(2); } Local chbufinx startofsymbol(int index, struct LOC_produce *LINK) { return (LINK->LINK->attstack[LINK->newtop + index - 2].chbufp); } Local chbufinx endofsymbol(int index, struct LOC_produce *LINK) { return (LINK->LINK->attstack[LINK->newtop + index - 1].chbufp - 1); } Local void getstring(int sy, uchar *st, int *length, struct LOC_produce *LINK) { int i, t, FORLIM; if (sy >= 0) t = LINK->newtop + sy - 1; else t = LINK->oldtop + sy - 1; *length = 0; FORLIM = LINK->LINK->attstack[t].chbufp; for (i = LINK->LINK->attstack[t-1].chbufp; i < FORLIM; i++) { (*length)++; st[*length - 1] = LINK->LINK->chbuf[i]; } } Local void snapprocess(struct LOC_produce *LINK) { chstring s; int i, j, l; Char ch; int FORLIM; if (LINK->prod != 0) { fprintf(logfile, " Prod:%3d oldtop:%3d newtop:%d\n", LINK->prod, LINK->oldtop, LINK->newtop); FORLIM = LINK->oldtop - LINK->newtop + 1; for (i = 1; i <= FORLIM; i++) { getstring(i, s, &l, LINK); if (l > 0) { fprintf(logfile, " symb%d ", i); for (j = 0; j < l; j++) putc(s[j], logfile); fprintf(logfile, "\"\n"); } } return; } putc('\n', logfile); putc('\n', list); if (logfile != NULL) logfile = freopen("logfile", "r", logfile); else logfile = fopen("logfile", "r"); if (logfile == NULL) _EscIO2(FileNotFound, "logfile"); fprintf(list, " Snapshots:\n"); while (!P_eof(logfile)) { while (!P_eoln(logfile)) { ch = getc(logfile); if (ch == '\n') ch = ' '; putc(ch, list); } fscanf(logfile, "%*[^\n]"); getc(logfile); putc('\n', list); } } Local void inputerror(int nr, struct LOC_produce *LINK) { /* error-procedure local for terminput*/ int j, k, kch, FORLIM; if (nr & 1) fprintf(list, "\n "); /*D if debug then begin writeln(logfile); writeln(logfile,'*** Inputerror ',nr) end; D*/ switch (nr) { case 1: fprintf(list, " *** Expression too complicated "); break; case 2: fprintf(console, " *** Terminal \""); k = stringarray[lasttermval+1].loc; FORLIM = symbtab[k-1]; for (j = 0; j < FORLIM; j++) { kch = symbtab[k + j]; if (kch >= ' ' && kch < 128) putc(symbtab[k + j], console); else { putc(bslchar, console); fprintf(console, "%d%d%d", kch >> 6, (kch & 63) >> 3, kch & 7); } } fprintf(console, "\" duplicated.\n"); fprintf(list, "\n *** Terminal \""); FORLIM = symbtab[k-1]; for (j = 0; j < FORLIM; j++) { kch = symbtab[k + j]; if (kch >= ' ' && kch < 128) putc(symbtab[k + j], list); else { putc(bslchar, list); kch = symbtab[k + j]; fprintf(list, "%d%d%d", kch >> 6, (kch & 63) >> 3, kch & 7); } } fprintf(list, "\" duplicated.\n"); break; case 3: consterror("terminput ", "TtabSZ ", TtabSZ); break; case 4: LINK->LINK->stoperror = true; putc('\n', list); fprintf(console, " *** Illegal concatenation.\n"); fprintf(list, " *** Illegal concatenation."); break; case 6: LINK->LINK->stoperror = true; putc('\n', list); fprintf(console, " *** Terminal \""); k = stringarray[lasttermval+1].loc; FORLIM = symbtab[k-1]; for (j = 0; j < FORLIM; j++) putc(symbtab[k + j], console); fprintf(console, "\" more than %2ld characters.\n", (long)ordmaxch); fprintf(list, " *** Terminal \""); k = stringarray[lasttermval+1].loc; FORLIM = symbtab[k-1]; for (j = 0; j < FORLIM; j++) putc(symbtab[k + j], list); fprintf(list, "\" more than %2ld characters.", (long)ordmaxch); putc(' ', list); break; case 7: consterror("terminput ", "maxsymbs ", maxSYMBS); break; } if (nr >= 0 && nr < 32 && ((1L << nr) & 0x56) != 0) { fprintf(console, " Error(s) in input\n"); consoleflush(); } fprintf(list, "\n "); if (nr & 1) stop(0); } Local void writenonterms(nontelm *p, struct LOC_produce *LINK) { int i; nontelm *WITH; while (p != NULL) { WITH = p; writenonterms(WITH->llink, LINK); fprintf(list, " %5d ", WITH->nontermvalue); listterm(WITH->address, &i); if (LINK->wrj & 1) putc('\n', list); else listtab(i, 30); LINK->wrj++; p = WITH->rlink; } } Local void putsym(int start, int fin, stringaddress *add, struct LOC_produce *LINK) { int i, len; len = fin - start + 1; if (freesp + len + 1 > SEGdim) { symbtab = Malloc(sizeof(charset)); freesp = 1; } symbtab[freesp-1] = len; for (i = 0; i < len; i++) symbtab[freesp + i] = LINK->LINK->chbuf[start + i]; add->seg = symbtab; add->loc = freesp; /*D if debug then begin writeln(logfile); write(logfile,'freesp=',freesp:3,' symbol "'); for i := 1 to len do write(logfile,symbtab^[freesp+i]); writeln(logfile,'", len=',len:3) end; D*/ freesp += len + 1; } Local int strcompare(stringaddress str1, stringaddress str2, struct LOC_produce *LINK) { int m; int i = 0; int j; m = str2.seg[str2.loc - 1]; j = m + 1; while (i <= m) { if (str1.seg[str1.loc + i - 1] == str2.seg[str2.loc + i - 1]) i++; else if (str1.seg[str1.loc + i - 1] < str2.seg[str2.loc + i - 1]) m = i - 1; else { m = i - 1; j = m; } } if (i == j) return 0; else if (i < j) return -1; else return 1; } Local void indord(stringaddress addr, struct LOC_produce *LINK) { int scompval; boolean notfound = true; nontelm *WITH; dynp = first; while (dynp != NULL && notfound) { WITH = dynp; scompval = strcompare(addr, WITH->address, LINK); if (scompval != 0) { last = dynp; if (scompval < 0) dynp = WITH->llink; else dynp = WITH->rlink; continue; } notfound = false; ntcount = WITH->nontermvalue; if (!leftflag) continue; LINK->i = 1; while (LINK->i < LINK->LINK->symbcount && symbols[LINK->i-1] != ntcount) LINK->i++; if (LINK->i < LINK->LINK->symbcount) rhs[lefthelp[ntcount]].link = point; } if (!notfound) return; statp = Malloc(sizeof(nontelm)); if (statp == NULL) gramerror(14); WITH = statp; WITH->address = addr; WITH->llink = NULL; WITH->rlink = NULL; WITH->nontermvalue = internv; ntcount = internv; if (internv >= maxSYMBS) gramerror(7); internv++; nonterms[ntcount].nontermp = statp; WITH = last; if (strcompare(WITH->address, addr, LINK) > 0) WITH->llink = statp; else WITH->rlink = statp; } Local void nonterminal(int stringptr, int endmarker, stringaddress addr, struct LOC_produce *LINK) { nontelm *WITH; if (firstnonterm) { if (addr.seg == NULL) putsym(stringptr, endmarker, &addr, LINK); first = Malloc(sizeof(nontelm)); WITH = first; WITH->address = addr; WITH->llink = NULL; WITH->rlink = NULL; ntcount = internv; nonterms[ntcount].nontermp = first; firstnonterm = false; WITH->nontermvalue = internv; internv++; return; } if (addr.seg == NULL) putsym(stringptr, endmarker, &addr, LINK); if (errorsininput == false) indord(addr, LINK); } Local void initialprod(struct LOC_produce *LINK) { int i; entrytyp *WITH; rhsnil = 0; for (i = 0; i <= maxSYMBS; i++) { help[i].rightp = rhsnil; nonterms[i].isonright = false; nonterms[i].isonleft = false; } emptyinexpr = false; errorsininput = false; goalknown = false; LINK->LINK->proderror = false; lextabcount = 0; for (i = ordminch; i <= ordmaxch; i++) { WITH = &entry_[i]; WITH->higherp = NULL; WITH->defined_ = false; WITH->internv = -1; } emptyvalue = 0; lasttermval = 1; LINK->LINK->stoperror = false; putc('\n', list); bar("Input File "); memcpy(LINK->LINK->chbuf, "METAGOAL ", sizeof(chbuftype)); putsym(0, 7, &stringarray[1], LINK); memcpy(LINK->LINK->chbuf, "<EOF> ", sizeof(chbuftype)); putsym(0, 4, &stringarray[2], LINK); } Local void newnode(int leftattr, int rightattr, int localprod, struct LOC_produce *LINK) { treenode *np; np = Malloc(sizeof(treenode)); if (leftattr != 0) np->left = LINK->LINK->attstack[LINK->newtop + leftattr - 1].node; else np->left = NULL; if (rightattr != 0) np->right = LINK->LINK->attstack[LINK->newtop + rightattr - 1].node; else np->right = NULL; np->address.seg = NULL; np->nodetype = localprod; LINK->LINK->attstack[LINK->newtop].node = np; } Local void getnewname(treenode *node, struct LOC_produce *LINK) { uchar *inseg; stringindex inloc; int length, i; attributes *WITH; inseg = node->address.seg; inloc = node->address.loc; length = inseg[inloc-1]; if (freesp + length + 2 > SEGdim) { symbtab = Malloc(sizeof(charset)); freesp = 1; } symbtab[freesp-1] = length + 1; for (i = 0; i < length; i++) symbtab[freesp + i] = inseg[inloc + i]; symbtab[freesp + length] = LINK->LINK->suffix; do { LINK->LINK->suffix++; if (LINK->LINK->suffix > 'Z') gramerror(1); } while (isalnum(LINK->LINK->suffix) == 0 && LINK->LINK->suffix != '_'); WITH = &LINK->LINK->attstack[LINK->newtop]; WITH->address.seg = symbtab; WITH->address.loc = freesp; WITH->node->address = WITH->address; freesp += length + 2; } Local void copytree(treenode *intree, treenode **outtree, struct LOC_produce *LINK) { treenode *WITH; if (intree == NULL) { *outtree = NULL; return; } *outtree = Malloc(sizeof(treenode)); WITH = *outtree; WITH->nodetype = intree->nodetype; WITH->address = intree->address; copytree(intree->left, &WITH->left, LINK); copytree(intree->right, &WITH->right, LINK); } Local void termerror(stringaddress addr, int n, struct LOC_produce *LINK) { int i; errorsininput = true; termrep = 0; fprintf(list, "\n *** Illegal terminal: \""); fprintf(console, " Illegal terminal: \""); listterm(addr, &i); consoleterm(addr, &i); putc('"', list); putc('"', console); switch (n) { case 0: /* blank case */ break; case 1: fprintf(list, " longer than %2ld characters", (long)ordmaxch); fprintf(console, " longer than %2ld characters", (long)ordmaxch); break; case 2: fprintf(list, " not defined"); fprintf(console, " not defined"); break; } putc('\n', list); putc('\n', console); consoleflush(); } Local void terminal(stringaddress addr, struct LOC_produce *LINK) { termelm *currentp = NULL, *runp = NULL; int length; int i = 2; entrytyp *WITH; termelm *WITH1; termrep = -1; if (addr.seg == NULL) { fprintf(list, "nil address given to terminal"); fprintf(console, "nil address given to terminal"); } else length = addr.seg[addr.loc - 1]; while (i <= length && termrep != 0) { if (i == 2) { WITH = &entry_[addr.seg[addr.loc]]; if (WITH->higherp == NULL) termerror(addr, 2, LINK); else runp = WITH->higherp; } else { if (currentp->higherp == NULL) termerror(addr, 2, LINK); else runp = currentp->higherp; } if (runp != NULL) { while (termrep != 0 && runp->tchr != addr.seg[addr.loc + i - 1]) { WITH1 = runp; if (WITH1->niveaup == NULL) termerror(addr, 2, LINK); else runp = WITH1->niveaup; } } currentp = runp; i++; } if (termrep == 0) return; if (length != 1) { if (currentp->defined_) termrep = currentp->internv; else termerror(addr, 0, LINK); return; } WITH = &entry_[addr.seg[addr.loc]]; if (WITH->defined_) termrep = WITH->internv; else termerror(addr, 0, LINK); } Local void workon(treenode *node, struct LOC_produce *LINK) { LINK->primaryfound = true; if (node->nodetype == primary1) { nonterminal(0, 0, node->address, LINK); cnt++; if (cnt > maxRHSterms) { gramerror(19); return; } nonterms[ntcount].isonright = true; rhs[point].parserp = NULL; rhs[point].link = rhsnil; rhs[point].symbol = ntcount; symbp = point; newelm(&point, "inputgrammar "); isfirst = false; return; } terminal(node->address, LINK); if (emptyvalue == termrep) emptyinexpr = true; rhs[point].parserp = NULL; rhs[point].link = rhsnil; cnt++; if (cnt > maxRHSterms) { gramerror(19); return; } rhs[point].symbol = termrep; symbp = point; newelm(&point, "inputgrammar "); isfirst = false; } Local void scan(treenode *node, struct LOC_produce *LINK) { if (node == NULL) return; switch (node->nodetype) { case term2: scan(node->left, LINK); scan(node->right, LINK); break; case expression3: scan(node->left, LINK); if (LINK->carry) { node->nodetype = -expression3; LINK->carry = false; } break; case -expression3: scan(node->right, LINK); if (LINK->carry) node->nodetype = expression3; break; case primary1: case primary2: workon(node, LINK); break; } } Local void outputleftside(treenode *node, struct LOC_produce *LINK) { int i; _REC_rhs *WITH; leftflag = true; nonterminal(0, 0, node->address, LINK); symbols[LINK->LINK->symbcount-1] = ntcount; LINK->LINK->symbcount++; if (goalnotentered) { WITH = &rhs[point]; WITH->basisl = 3; symbp = point; newelm(&point, "Goalprod "); rhs[point].symbol = 0; newelm(&point, "Goalprod "); WITH = &rhs[point]; if (goalknown) WITH->symbol = goalsymbol; else WITH->symbol = ntcount; newelm(&point, "Goalprod "); rhs[point].symbol = 1; for (i = 1; i <= 4; i++) { WITH = &rhs[symbp]; incrtabx(&symbp); WITH->link = rhsnil; WITH->parserp = NULL; } goalnotentered = false; point = symbp; } nonterms[ntcount].isonleft = true; if (help[ntcount].rightp == rhsnil) help[ntcount].rightp = point; rhs[point].parserp = NULL; rhs[point].link = rhsnil; helpp = point; symbp = point; newelm(&point, "inputgrammar "); leftflag = false; } Local void outputoption(struct LOC_produce *LINK) { if (isfirst) { gramerror(9); return; } if (emptyinexpr) { if (cnt > 1) { gramerror(4); emptyinexpr = false; } else if (cnt == 1) emptyinexpr = false; } rhs[helpp].basisl = cnt; cnt = 0; helpp = point; rhs[symbp].link = point; rhs[point].link = rhsnil; rhs[point].parserp = NULL; newelm(&point, "inputgrammar "); } Local void purgetree(treenode **node, struct LOC_produce *LINK) { /* This leaves a potential memory leak of the stringaddress */ if (*node == NULL) return; purgetree(&(*node)->right, LINK); purgetree(&(*node)->left, LINK); Free(*node); } Local void checkbothsides(struct LOC_produce *LINK) { int i, k, m; _REC_nonterms *WITH; nontelm *WITH1; if (goalnotdefined) goalsymbol = symbols[0]; k = internv - 1; for (i = lasttermval; i <= k; i++) { WITH = &nonterms[i]; if (!(WITH->isonleft && WITH->isonright)) { WITH1 = WITH->nontermp; if (WITH1->nontermvalue != goalsymbol) { fprintf(list, "\n "); listterm(WITH1->address, &m); consoleterm(WITH1->address, &m); if (WITH->isonleft) { fprintf(list, " appears only on the left side"); fprintf(console, " appears only on left side\n"); } else { fprintf(list, " appears only on the right side"); fprintf(console, " appears only on right side\n"); } consoleflush(); putc('\n', list); stopflag = true; } } } lastnont = k; if (stopflag) stop(3); } Local void printouttree(treenode *node, int indent, struct LOC_produce *LINK) { int maxlen, i; if (node == NULL) return; fprintf(list, "%3d", node->nodetype); if (node->address.seg == NULL) { if (node->nodetype == expression3) fprintf(list, "16 "); else if (node->nodetype == term2) fprintf(list, "25 "); else fprintf(list, " "); } else { putc(' ', list); maxlen = node->address.seg[node->address.loc - 1]; if (maxlen > 3) maxlen = 3; for (i = 0; i < maxlen; i++) putc(node->address.seg[node->address.loc + i], list); listtab(maxlen, 3); } if (node->right != NULL) printouttree(node->right, indent + 7, LINK); if (node->left == NULL) return; putc('\n', list); for (i = 1; i <= indent; i++) putc(' ', list); printouttree(node->left, indent, LINK); } Local termelm *mknode(uchar ch, int *termcount, struct LOC_produce *LINK) { termelm *t; t = Malloc(sizeof(termelm)); t->defined_ = false; t->tchr = ch; t->internv = -1; t->niveaup = NULL; t->higherp = NULL; (*termcount)++; return t; } Local void readterminal(chbufinx stringptr, chbufinx endmarker, struct LOC_produce *LINK) { termelm *currentp, *runp; int m, i; boolean run, rum; entrytyp *WITH; termelm *WITH1; /* It is a good question why one should complicate things by building a tree of terminals here instead of just listing them separately and checking for equality by other means*/ if (LINK->prod != termdeflist4) { if (lasttermval < maxSYMBS) lasttermval++; else inputerror(7, LINK); } m = endmarker - stringptr + 1; if (m > ordmaxch) m = ordmaxch; putsym(stringptr, stringptr + m - 1, &stringarray[lasttermval+1], LINK); if (endmarker - stringptr + 1 > ordmaxch) inputerror(6, LINK); for (i = 2; i <= m; i++) { run = true; if (i == 2) { WITH = &entry_[LINK->LINK->chbuf[stringptr]]; if (WITH->higherp == NULL) { WITH->higherp = mknode(LINK->LINK->chbuf[stringptr+1], &lextabcount, LINK); currentp = WITH->higherp; run = false; } else runp = WITH->higherp; } else { WITH1 = currentp; if (WITH1->higherp == NULL) { WITH1->higherp = mknode(LINK->LINK->chbuf[stringptr + i - 1], &lextabcount, LINK); currentp = WITH1->higherp; run = false; } else runp = WITH1->higherp; } rum = false; while (run != rum) { if (runp->tchr == LINK->LINK->chbuf[stringptr + i - 1]) { rum = run; continue; } WITH1 = runp; if (WITH1->niveaup == NULL) { WITH1->niveaup = mknode(LINK->LINK->chbuf[stringptr + i - 1], &lextabcount, LINK); currentp = WITH1->niveaup; run = false; } else runp = WITH1->niveaup; } if (run) currentp = runp; } if (m == 1) { WITH = &entry_[LINK->LINK->chbuf[stringptr]]; /* if debug then begin write(list,'stringptr=',stringptr:1, ' entry[ord(',chbuf[stringptr]:1,')]'); writeln(list, ' lasttermval=',lasttermval,' defined=',defined) end; */ WITH->internv = lasttermval; if (WITH->defined_) inputerror(2, LINK); else WITH->defined_ = true; return; } currentp->internv = lasttermval; if (currentp->defined_) inputerror(2, LINK); else currentp->defined_ = true; } Local boolean canbenil(treenode *node, struct LOC_produce *LINK) { /* find out if tree contains a nil right hand side */ boolean Result; if (node == NULL) return true; switch (node->nodetype) { case term2: Result = canbenil(node->left, LINK) & canbenil(node->right, LINK); break; case expression3: Result = canbenil(node->left, LINK) | canbenil(node->right, LINK); break; case primary1: case primary2: Result = false; break; } return Result; } Local void makenonnil(treenode **node, struct LOC_produce *LINK) { /* replace first nil right hand side with 8 */ if (*node == NULL) { if (emptyvalue == 0) { produce(0, 0, 0, LINK->LINK); gramerror(2); return; } newnode(0, 0, primary2, LINK); *node = LINK->LINK->attstack[LINK->newtop].node; (*node)->address = LINK->LINK->emptyaddress; return; } switch ((*node)->nodetype) { case term2: makenonnil(&(*node)->left, LINK); break; case expression3: if (canbenil((*node)->left, LINK)) makenonnil(&(*node)->left, LINK); else makenonnil(&(*node)->right, LINK); break; } } Local void changeref(treenode *node, stringaddress oldaddr, stringaddress newaddr, struct LOC_produce *LINK) { stringaddress *WITH; if (node == NULL) return; changeref(node->left, oldaddr, newaddr, LINK); WITH = &node->address; if (WITH->seg == oldaddr.seg && WITH->loc == oldaddr.loc) node->address = newaddr; changeref(node->right, oldaddr, newaddr, LINK); } Local void testrepeated(struct LOC_produce *LINK) { /* get rid of <NAME> = <NAME1>; <NAME1> = <repeated> */ boolean found = false; treenode *tp; if (LINK->LINK->treeroot->left == NULL) /* break */ return; if (LINK->LINK->treeroot->left->nodetype != primary1) /* break */ return; LINK->np = LINK->LINK->treeroot->right; while (!found && LINK->np != NULL) { if (LINK->LINK->treeroot->left->address.seg != LINK->np->address.seg || LINK->LINK->treeroot->left->address.loc != LINK->np->address.loc) { LINK->np = LINK->np->right; continue; } found = true; changeref(LINK->LINK->treeroot->right, LINK->LINK->treeroot->left->address, LINK->LINK->treeroot->address, LINK); tp = LINK->LINK->treeroot->right; LINK->LINK->treeroot->right = NULL; purgetree(&LINK->LINK->treeroot, LINK); LINK->LINK->treeroot = tp; } if (found) testrepeated(LINK); } /*--------------------------------------------------------------------*/ /*--------------------------------------------------------------------*/ Local void produce(stackinx oldtop_, stackinx newtop_, int prod_, struct LOC_inputgrammar *LINK) { struct LOC_produce V; treenode *saveroot, *WITH; attributes *WITH1; /*D if debug then snapprocess; D*/ V.LINK = LINK; V.oldtop = oldtop_; V.newtop = newtop_; V.prod = prod_; switch (V.prod) { case -1: initialprod(&V); break; /* 0 METAGOAL = ebnfinput "<EOF>" */ case METAGOAL1: /* last production call */ break; /* 1 ebnfinput = heading "." */ /* 2 | heading productions "." */ /* 3 | "<ERROR>" */ case ebnfinput1: case ebnfinput2: newline(3); bar("End of input "); listterminals(&V); if (errorsininput) { fprintf(console, " Error(s) in input\n"); consoleflush(); stop(0); } else { newline(2); fprintf(list, " Non-terminal symbols:\n"); fprintf(list, " Value,non-terminal"); fprintf(list, " "); fprintf(list, " Value,non-terminal"); newline(2); V.wrj = 0; writenonterms(first, &V); checkbothsides(&V); } break; /* 4 heading = terminaldefs "." */ /* 5 | optiondefs "." terminaldefs "." */ /* 6 | emptydef "." terminaldefs "." */ /* 7 | optiondefs "." emptydef "." terminaldefs "." */ /* 8 | terminaldefs "." goalsymboldef "." */ /* 9 | optiondefs "." terminaldefs "." goalsymboldef "." */ /*10 | emptydef "." terminaldefs "." goalsymboldef "." */ /*11 | optiondefs "." emptydef "." terminaldefs "." goalsymboldef "." */ case heading1: case heading2: case heading3: case heading4: case heading5: case heading6: case heading7: case heading8: break; /*12 productions = leftside "=" expression "." */ case productions1: if (LINK->treeroot == NULL) purgetree(&LINK->attstack[V.newtop+2].node, &V); else { LINK->treeroot->left = LINK->attstack[V.newtop+2].node; if (!LINK->proderror) { /*D if debug then begin writeln( list, 'before reduction:' ); printouttree(treeroot,0); writeln(list) end; D*/ testrepeated(&V); V.np = LINK->treeroot; while (V.np != NULL) { if (canbenil(V.np->left, &V)) makenonnil(&V.np->left, &V); V.np = V.np->right; } /*D if debug then begin writeln( list, 'after reduction:' ); printouttree(treeroot,0); writeln(list) end; D*/ V.np = LINK->treeroot; while (V.np != NULL) { isfirst = true; cnt = 0; outputleftside(V.np, &V); do { V.carry = true; V.primaryfound = false; scan(V.np->left, &V); if (V.primaryfound && !V.carry) outputoption(&V); } while (!V.carry); rhs[helpp].basisl = cnt; lefthelp[symbols[LINK->symbcount-2]] = symbp; if (emptyinexpr && cnt > 1) gramerror(4); emptyinexpr = false; V.np = V.np->right; } } purgetree(&LINK->treeroot, &V); } LINK->proderror = false; break; /*13 terminaldefs = "TERMINALS" colon termdeflist */ case terminaldefs1: goalnotentered = true; LINK->numberoftermsymbs = lasttermval; if (LINK->stoperror) { listterminals(&V); fprintf(console, " Error(s) in input\n"); consoleflush(); stop(0); } LINK->symbcount = 1; top = 1; termg = lasttermval; leftflag = false; lasttermval++; firstnont = lasttermval; help[firstnont].rightp = top; lasttermval++; internv = lasttermval; firstnonterm = true; point = top; goalnotdefined = true; stopflag = false; break; /*14 optiondefs = "OPTIONS" colon optionlist */ case optiondefs1: break; /*15 emptydef = "EMPTYTERM" colon "<STRING>" */ /*16 | "<ERROR>" */ case emptydef1: readterminal(startofsymbol(3, &V) + 1, endofsymbol(3, &V), &V); emptyvalue = lasttermval; LINK->emptyaddress = stringarray[emptyvalue+1]; break; /*17 goalsymboldef = "GOALSYMBOL" colon "<NAME>" */ case goalsymboldef1: nonterminal(startofsymbol(3, &V), endofsymbol(3, &V), LINK->niladdress, &V); goalsymbol = ntcount; goalknown = true; goalnotdefined = false; break; /*18 colon = ":" */ /*19 | "=" */ case colon1: case colon2: break; /*20 optionlist = "<INTEGER>" */ /*21 | "<ERROR>" */ /*22 | optionlist "<INTEGER>" */ /*23 | optionlist "," "<INTEGER>" */ /*24 | optionlist "<ERROR>" */ /*25 | optionlist "," "<ERROR>" */ case optionlist1: case optionlist3: case optionlist4: break; /*26 termdeflist = "<STRING>" */ /*27 | termdeflist "<STRING>" */ /*28 | termdeflist "," "<STRING>" */ /*29 | termdeflist "=" "<STRING>" */ case termdeflist1: readterminal(startofsymbol(1, &V) + 1, endofsymbol(1, &V), &V); break; case termdeflist2: readterminal(startofsymbol(2, &V) + 1, endofsymbol(2, &V), &V); break; case termdeflist3: case termdeflist4: readterminal(startofsymbol(3, &V) + 1, endofsymbol(3, &V), &V); break; /*30 leftside = "<NAME>" */ /*31 | productions "<NAME>" */ /*32 | productions "<ERROR>" */ case leftside1: case leftside2: newnode(0, 0, leftside1, &V); if (V.prod == leftside1) V.i = 0; else V.i = 1; LINK->treeroot = LINK->attstack[V.newtop].node; WITH = LINK->treeroot; WITH->address = LINK->attstack[V.newtop + V.i].address; LINK->suffix = 'A'; break; case leftside3: LINK->proderror = true; break; /*33 expression = term */ /*34 | "<ERROR>" */ /*35 | expression "|" term */ /*36 | expression "|" "<ERROR>" */ case expression1: break; case expression2: LINK->proderror = true; break; case expression3: newnode(1, 3, V.prod, &V); break; /*37 term = factor */ /*38 | term factor */ /*39 | term "<ERROR>" */ case term1: break; case term2: newnode(1, 2, V.prod, &V); break; case term3: LINK->proderror = false; break; /*40 factor = primary */ /*41 | "[" expression "]" */ /*42 | repeated */ /*43 | "<NAME>" colon repeated */ case factor1: break; case factor2: newnode(0, 2, expression3, &V); break; case factor3: if (LINK->treeroot == NULL) purgetree(&LINK->attstack[V.newtop].node, &V); else { newnode(1, 0, leftside1, &V); V.np = LINK->treeroot; while (V.np->right != NULL) V.np = V.np->right; V.np->right = LINK->attstack[V.newtop].node; newnode(0, 0, primary1, &V); getnewname(LINK->treeroot, &V); WITH = V.np->right; WITH->address = LINK->attstack[V.newtop].address; V.np = WITH->left->right; copytree(LINK->attstack[V.newtop].node, &V.np->left, &V); if (LINK->attstack[V.newtop].prodint == rightbrace2) { WITH = V.np; V.np = WITH->left; WITH->left = WITH->right; WITH->right = V.np; } } break; case factor4: newnode(3, 0, leftside1, &V); V.np = LINK->treeroot; while (V.np->right != NULL) V.np = V.np->right; V.np->right = LINK->attstack[V.newtop].node; newnode(0, 0, primary1, &V); WITH1 = &LINK->attstack[V.newtop]; WITH1->node->address = WITH1->address; V.np->right->address = WITH1->address; V.np = V.np->right->left->right; copytree(LINK->attstack[V.newtop].node, &V.np->left, &V); if (LINK->attstack[V.newtop+2].prodint == rightbrace2) { WITH = V.np; V.np = WITH->left; WITH->left = WITH->right; WITH->right = V.np; } break; /*44 primary = "<NAME>" */ /*45 | "<STRING>" */ /*46 | "(" expression ")" */ case primary1: case primary2: newnode(0, 0, V.prod, &V); V.np = LINK->attstack[V.newtop].node; V.np->address = LINK->attstack[V.newtop].address; break; case primary3: LINK->attstack[V.newtop] = LINK->attstack[V.newtop+1]; break; /*47 repeated = "{" expression rightbrace */ /*48 | "{" expression "$" rightbrace */ /*49 | "{" expression "$" expression rightbrace */ /*50 | "{" "$" expression rightbrace */ case repeated1: case repeated2: case repeated3: case repeated4: saveroot = LINK->attstack[V.newtop+1].node; switch (V.prod) { case repeated1: LINK->attstack[V.newtop].prodint = LINK->attstack[V.newtop+2].prodint; newnode(0, 2, term2, &V); break; case repeated2: LINK->attstack[V.newtop].prodint = LINK->attstack[V.newtop+3].prodint; newnode(0, 2, term2, &V); break; case repeated3: WITH1 = &LINK->attstack[V.newtop]; LINK->attstack[V.newtop].prodint = LINK->attstack[V.newtop+4].prodint; if (LINK->attstack[V.newtop].prodint == rightbrace1) newnode(4, 2, term2, &V); else newnode(2, 4, term2, &V); newnode(0, 1, term2, &V); break; case repeated4: saveroot = NULL; LINK->attstack[V.newtop].prodint = LINK->attstack[V.newtop+3].prodint; newnode(0, 3, term2, &V); break; } newnode(0, 1, expression3, &V); copytree(saveroot, &LINK->attstack[V.newtop].node->left, &V); break; /*51 rightbrace = "rbraceL" */ /*52 | "rbraceR" */ case rightbrace1: case rightbrace2: LINK->attstack[V.newtop].prodint = V.prod; break; case ebnfinput3: case optionlist2: case optionlist5: case optionlist6: case emptydef2: case expression4: break; } } /* produce */ /* Local variables for parser: */ struct LOC_parser { struct LOC_inputgrammar *LINK; uchar eotchar; stackelm parsestack[stackmax + 1]; /*parse stack*/ /* pentry: array [0..ordmaxch] of lxentry; */ /* pentryhp: array [0..ordmaxch] of lxinx; pentrytv: array [0..ordmaxch] of psymbol; */ /* plx: array [0..lxmax] of lxelm; */ /*lexical tables*/ /* plxnp: array [0..lxmax] of lxinx; plxhp: array [0..lxmax] of lxinx; plxtv: array [0..lxmax] of psymbol; plxch: array [0..lxmax] of {UNSIGNED} char; */ /* exponentchars: set of char; chars in floating point numbers */ psymbol newsymb; /*current terminal symbol*/ int oldsymb; /*last terminal symbol*/ uchar ch; /*current char*/ chbufinx oldbufi; /* first token char in chbuf */ boolean ok, moreinput; /*parser flag */ /* becomes false when input is exhausted */ int reclength, lineinx; /*length of current input record */ reduelem redubuf[redumax + 1]; /* reduction buffer */ reduinx redutop; stackinx stacktop, pseudotop, validtop, top; lrinx startinx, lri, start; } ; /* ----------------------------------------------------------------- */ /* procedures for input/output of characters */ Local void markerror(int n, int offset, struct LOC_parser *LINK) { _REC_errmsg *WITH; LINK->LINK->errcount++; if (LINK->LINK->errmp < errmax) { LINK->LINK->errmp++; WITH = &LINK->LINK->errmsg[LINK->LINK->errmp]; WITH->no = n; WITH->col = LINK->lineinx + offset; WITH->symb = LINK->newsymb; } LINK->LINK->proderror = true; } Local void readline(struct LOC_parser *LINK) { LINK->lineinx = 1; LINK->LINK->linelength = 1; LINK->LINK->errmp = 0; if (P_eof(input)) { LINK->moreinput = false; LINK->ch = LINK->eotchar; LINK->reclength = 0; return; } while (!P_eoln(input) && LINK->LINK->linelength < linemax) { LINK->LINK->line[LINK->LINK->linelength-1] = getc(input); if (LINK->LINK->line[LINK->LINK->linelength-1] == '\n') LINK->LINK->line[LINK->LINK->linelength-1] = ' '; LINK->LINK->linelength++; } LINK->reclength = LINK->LINK->linelength - 1; if (P_eoln(input)) LINK->LINK->line[LINK->LINK->linelength-1] = ' '; else { if (LINK->LINK->linelength == linemax) markerror(904, linemax - 2, LINK); while (!P_eoln(input) && LINK->reclength < recmax) { LINK->reclength++; LINK->LINK->line[LINK->reclength-1] = getc(input); if (LINK->LINK->line[LINK->reclength-1] == '\n') LINK->LINK->line[LINK->reclength-1] = ' '; } } LINK->ch = LINK->LINK->line[LINK->lineinx-1]; fscanf(input, "%*[^\n]"); getc(input); } /*readline*/ Local void printline(struct LOC_parser *LINK) { int i, FORLIM; lineno++; fprintf(list, "%9d | ", lineno); FORLIM = LINK->reclength; for (i = 0; i < FORLIM; i++) putc(LINK->LINK->line[i], list); putc('\n', list); } Local void dumpline(struct LOC_parser *LINK) { printline(LINK); if (LINK->LINK->errmp > 0) writeerror(LINK->LINK); readline(LINK); } Local void inchar(struct LOC_parser *LINK) { if (LINK->lineinx < LINK->LINK->linelength) { LINK->lineinx++; LINK->ch = LINK->LINK->line[LINK->lineinx-1]; } else if (LINK->lineinx == LINK->LINK->linelength) { LINK->lineinx++; LINK->ch = ' '; } else dumpline(LINK); if (LINK->ch == ordtabchar) LINK->ch = ' '; } /*end of input/output procedures ---------------------------------------------------------------------*/ Local void initialize(struct LOC_parser *LINK) { /* var i: integer; */ /*D if trace then debug := true; D*/ LINK->LINK->errcount = 0; /* if debug then begin for i := ordminch to ordmaxch do writeln(list,'pentryhp[',i:1,']=',pentryhp[i]:1); for i := ordminch to ordmaxch do writeln(list,'pentrytv[',i:1,']=',pentrytv[i]:1); for i := 0 to lxmax do writeln(list,'plx ch,np,hp,tv', plxch[i]:2, plxnp[i]:4, plxhp[i]:4, plxtv[i]:4); i := 0; while i <= lrmax do begin write(list, 'plr ', plr[i]:4, plr[i+pnext]:4, plr[i+pkind]:4); case plr[i+pkind] of 1, 2, 4, 6: writeln(list, plr[i+psymb]:4, plr[i+perr]:4); 0, 3: writeln(list, plr[i+prs]:4, plr[i+pprod]:4); 5: begin writeln(list, plr[i+plb]:4); i := i-1 end end; i := i+5 end end; */ /* symbol table */ freesp = SEGdim; LINK->LINK->niladdress.seg = NULL; LINK->moreinput = true; LINK->LINK->chbufi = 0; readline(LINK); LINK->oldsymb = 0; LINK->eotchar = (Char)ordeotchar; LINK->oldsymb = 27; /* parser initializations */ LINK->ok = true; LINK->LINK->maxerrcount = 10; LINK->parsestack[0].table = 0; LINK->LINK->attstack[0].chbufp = 0; LINK->parsestack[0].link = 0; } /*--------------------------------------------------------------------*/ Local void skipcomment(uchar controlchar, struct LOC_parser *LINK) { /* read next char on input until comend is recognized */ uchar endchar; if (controlchar == '{') { while (LINK->ch != '}' && LINK->moreinput) { if (LINK->ch == '{') markerror(901, 0, LINK); inchar(LINK); } } else { if (controlchar == '(') endchar = ')'; else endchar = '/'; do { while (LINK->ch != '*' && LINK->moreinput) { if (LINK->ch == controlchar) { do { inchar(LINK); } while (LINK->ch == controlchar); if (LINK->ch == '*') markerror(901, 0, LINK); } else inchar(LINK); } inchar(LINK); } while (LINK->ch != endchar && LINK->moreinput); } if (!LINK->moreinput) markerror(901, 0, LINK); inchar(LINK); } Local void pushch(struct LOC_parser *LINK) { /* copy ch character into chbuf and get new ch */ LINK->LINK->chbuf[LINK->LINK->chbufi] = LINK->ch; if (LINK->LINK->chbufi < chbufmax) LINK->LINK->chbufi++; else parserstop(5, LINK->LINK); inchar(LINK); } Local void readinteger(struct LOC_parser *LINK) { LINK->LINK->integervalue = LINK->ch - '0'; inchar(LINK); while (isdigit(LINK->ch) != 0) { LINK->LINK->integervalue = LINK->LINK->integervalue * 10 + LINK->ch - '0'; inchar(LINK); } LINK->newsymb = 3; } Local void nextstrchar(int *i, struct LOC_parser *LINK) { int iv, len; if (LINK->ch == bslchar) { inchar(LINK); if (LINK->ch == bslchar) pushch(LINK); else { iv = 0; len = 0; while (isdigit(LINK->ch) != 0 && len < 3) { len++; iv = iv * 8 + LINK->ch - '0'; inchar(LINK); } if (len == 0 || iv < ordminch || iv > ordmaxch) markerror(905, 1, LINK); else { LINK->LINK->chbuf[LINK->LINK->chbufi] = iv; /* if debug then writeln(list,' chbufi=',chbufi:1,' chbuf[chbufi]=', chbuf[chbufi]:1,'(',ord(chbuf[chbufi]):1,')'); */ if (LINK->LINK->chbufi < chbufmax) LINK->LINK->chbufi++; else parserstop(5, LINK->LINK); } } } else pushch(LINK); (*i)++; if (LINK->lineinx > LINK->LINK->linelength) markerror(902, 1, LINK); } Local void readstring(uchar lastch, struct LOC_parser *LINK) { /* puts string terminal into chbuf */ int i = 0; int stop; stop = LINK->LINK->linelength + 1; while (LINK->lineinx < stop) { if (LINK->ch == lastch) { inchar(LINK); if (LINK->ch == lastch) nextstrchar(&i, LINK); else stop = LINK->lineinx; } else nextstrchar(&i, LINK); } if (i == 0) markerror(801, -1, LINK); LINK->newsymb = 4; } Local void installstring(int firstch, int length, stringaddress *symbaddr, struct LOC_parser *LINK) { int i; if (freesp + length + 1 > SEGdim) { symbtab = Malloc(sizeof(charset)); freesp = 1; } symbtab[freesp-1] = length; for (i = 0; i < length; i++) symbtab[freesp + i] = LINK->LINK->chbuf[firstch + i]; symbaddr->seg = symbtab; symbaddr->loc = freesp; freesp += length + 1; } Local void lexical(struct LOC_parser *LINK) { /* sets newsymb to value of next acceptable terminal */ /*D, i D*/ int newi; uchar lastch, firstch; boolean terminalaccepted; do { terminalaccepted = true; while (LINK->ch == ' ') inchar(LINK); LINK->oldbufi = LINK->LINK->chbufi; /*first char of current terminal in chbuf*/ if (!LINK->moreinput) { if (LINK->oldsymb == 0) { dumpline(LINK); parserstop(2, LINK->LINK); } else if (LINK->oldsymb == 1) LINK->newsymb = 0; else LINK->newsymb = 1; } else if (isdigit(LINK->ch) != 0) readinteger(LINK); else { firstch = LINK->ch; pushch(LINK); LINK->newsymb = pentrytv[firstch]; /* search in termtree */ newi = pentryhp[firstch]; while (newi != 0) { /* if trace then writeln(logfile, ' newi=',newi:1,' ch:',ch,':',plxch[newi]); */ if (plxch[newi] == LINK->ch) { LINK->newsymb = plxtv[newi]; newi = plxhp[newi]; pushch(LINK); } else newi = plxnp[newi]; } lastch = LINK->LINK->chbuf[LINK->LINK->chbufi-1]; if ((isalnum(lastch) != 0 || lastch == '_') && (isalnum(LINK->ch) != 0 || LINK->ch == '_')) { /*read trailing characters in name terminals*/ do { pushch(LINK); } while (isalnum(LINK->ch) != 0 || LINK->ch == '_'); if (firstch == '_' || LINK->LINK->chbuf[LINK->LINK->chbufi-1] == '_') markerror(903, -1, LINK); LINK->newsymb = 2; } else if (LINK->newsymb > 0) { if (LINK->newsymb == 12) readstring(lastch, LINK); else if (LINK->newsymb == 26) { if (lastch == '/') { /* -/ */ dumpline(LINK); LINK->oldsymb = 27; } else skipcomment(firstch, LINK); terminalaccepted = false; } else if (LINK->newsymb == 27) { /* if lastch = '-' then dumpline; */ /* -- */ dumpline(LINK); terminalaccepted = false; } } else if (isalnum(lastch) != 0 || lastch == '_') { if (firstch == '_' || lastch == '_') markerror(903, -1, LINK); LINK->newsymb = 2; } /*D else if firstch = '&' then begin D*/ /* switch for logfile */ /*D chbufi := oldbufi; debug := not debug; terminalaccepted := false end D*/ else { markerror(800, -1, LINK); terminalaccepted = false; /* character not recognized */ } } /*lookahead terminals*/ /*D if debug then begin write(logfile, 'Lexical: '); for i := oldbufi to chbufi - 1 do write(logfile, chbuf[i]); writeln(logfile) end; D*/ if (LINK->newsymb == 4) installstring(LINK->oldbufi + 1, LINK->LINK->chbufi - LINK->oldbufi - 1, &LINK->LINK->saddr, LINK); else installstring(LINK->oldbufi, LINK->LINK->chbufi - LINK->oldbufi, &LINK->LINK->saddr, LINK); if (LINK->newsymb < 0 || LINK->newsymb >= 32 || ((1L << LINK->newsymb) & 0x1c) == 0) LINK->LINK->chbufi = LINK->oldbufi; } while (!terminalaccepted); LINK->oldsymb = LINK->newsymb; } /*--------------------------------------------------------------------*/ Local void advance(struct LOC_parser *LINK) { /* perform reductions */ int i, j, FORLIM; reduelem *WITH; attributes *WITH1; FORLIM = LINK->redutop; for (i = 1; i <= FORLIM; i++) { WITH = &LINK->redubuf[i]; produce(WITH->oldtop, WITH->newtop, WITH->prod, LINK->LINK); LINK->LINK->attstack[WITH->newtop].chbufp = LINK->LINK->attstack[WITH->newtop - 1].chbufp; } /*D if debug then writeln(logfile); D*/ /*update stack*/ if (LINK->validtop != LINK->top) { FORLIM = LINK->stacktop - LINK->validtop; for (i = 1; i <= FORLIM; i++) LINK->parsestack[LINK->validtop + i] = LINK->parsestack[LINK->top + i]; } if (LINK->redutop > 0) { j = LINK->LINK->attstack[LINK->stacktop-1].chbufp; FORLIM = LINK->LINK->chbufi - LINK->oldbufi; for (i = 0; i < FORLIM; i++) LINK->LINK->chbuf[j + i] = LINK->LINK->chbuf[LINK->oldbufi + i]; LINK->LINK->chbufi += j - LINK->oldbufi; LINK->oldbufi = j; } /* shift */ if (LINK->stacktop == stackmax) parserstop(1, LINK->LINK); LINK->stacktop++; LINK->parsestack[LINK->stacktop].table = LINK->startinx; WITH1 = &LINK->LINK->attstack[LINK->stacktop]; WITH1->chbufp = LINK->LINK->chbufi; WITH1->address = LINK->LINK->saddr; /* freeze new stack situation, ready for new lookahead */ LINK->top = LINK->stacktop; LINK->pseudotop = LINK->stacktop; LINK->validtop = LINK->stacktop; LINK->start = LINK->lri; LINK->redutop = 0; } Local void backtrack(stackinx btop, lrinx bstart, struct LOC_parser *LINK) { LINK->stacktop = btop; LINK->validtop = btop; LINK->pseudotop = btop; LINK->startinx = bstart; LINK->lri = bstart; LINK->redutop = 0; } Local void pseudoshift(struct LOC_parser *LINK) { attributes *WITH; if (LINK->pseudotop == stackmax) parserstop(1, LINK->LINK); LINK->stacktop++; LINK->pseudotop = LINK->top + LINK->stacktop - LINK->validtop; LINK->parsestack[LINK->pseudotop].table = LINK->startinx; WITH = &LINK->LINK->attstack[LINK->pseudotop]; WITH->chbufp = LINK->LINK->chbufi; WITH->address = LINK->LINK->saddr; } /*--------------------------------------------------------------------*/ Local void queue(rslength rs, prodno p, struct LOC_parser *LINK) { reduelem *WITH; if (p >= 0) { if (LINK->redutop < redumax) LINK->redutop++; else parserstop(4, LINK->LINK); WITH = &LINK->redubuf[LINK->redutop]; WITH->oldtop = LINK->stacktop; LINK->stacktop -= rs; WITH->newtop = LINK->stacktop; WITH->prod = p; } else LINK->stacktop -= rs; if (LINK->stacktop <= LINK->validtop) { LINK->pseudotop = LINK->stacktop; LINK->validtop = LINK->stacktop; } else LINK->pseudotop -= rs; } Local boolean lookahead_(psymbol lsymbol, struct LOC_parser *LINK) { boolean Result; boolean decided = false; lrinx si; /*D if trace then write(logfile, ' lri: ',lri:1); D*/ do { /*D if trace then write(logfile, ' lri ',lri:1); D*/ LINK->startinx = LINK->lri; switch (plr[LINK->lri + pkind]) { case 0: decided = true; Result = true; LINK->ok = false; break; case 1: while (plr[LINK->lri + psymb] != lsymbol && plr[LINK->lri] != 0) LINK->lri = plr[LINK->lri]; decided = true; Result = (plr[LINK->lri + psymb] == lsymbol); break; case 2: case 4: case 6: while (plr[LINK->lri + psymb] != lsymbol && plr[LINK->lri] != 0) LINK->lri = plr[LINK->lri]; if (plr[LINK->lri + pkind] == 2) { decided = true; Result = true; } else if (plr[LINK->lri + pkind] == 6) { pseudoshift(LINK); LINK->stacktop--; LINK->pseudotop--; queue(-1, plr[LINK->lri + perr], LINK); } break; case 3: queue(plr[LINK->lri + prs], plr[LINK->lri + pprod], LINK); break; case 5: si = LINK->parsestack[LINK->pseudotop].table; /*D if trace then write(logfile, ' si(', si: 1, ')'); D*/ while (plr[LINK->lri + plb] != si && plr[LINK->lri] != 0) LINK->lri = plr[LINK->lri]; break; } LINK->lri = plr[LINK->lri + pnext]; /*D; if trace then write(logfile, lri: 4) D*/ } while (!decided); /*D if trace then writeln(logfile) D*/ return Result; } /*--------------------------------------------------------------------*/ Local void syntaxerror(struct LOC_parser *LINK) { boolean success = false; stackinx s = 0; stackinx s1, FORLIM; /*D if debug then write(logfile, ' <---SYNTAXERROR'); D*/ markerror(plr[LINK->startinx + perr], -1, LINK); backtrack(LINK->top, LINK->start, LINK); pseudoshift(LINK); FORLIM = LINK->top; for (s1 = 0; s1 <= FORLIM; s1++) { backtrack(s1, LINK->parsestack[s1+1].table, LINK); if (lookahead_(5, LINK)) { LINK->parsestack[s1].link = s; s = s1; } } do { s1 = s; do { backtrack(s1, LINK->parsestack[s1+1].table, LINK); if (lookahead_(5, LINK)) { pseudoshift(LINK); success = lookahead_(LINK->newsymb, LINK); } s1 = LINK->parsestack[s1].link; } while (!(s1 == 0 || success)); if (!success) { /* mark previous symbol skipped */ /*D if debug then writeln(logfile, ' <---SKIPPED'); D*/ lexical(LINK); } } while (!success && LINK->ok); if (!LINK->ok) parserstop(3, LINK->LINK); } /*--------------------------------------------------------------------*/ Local void parser(struct LOC_inputgrammar *LINK) { struct LOC_parser V; /*--------------------------------------------------------------------*/ V.LINK = LINK; initialize(&V); produce(0, 1, -1, LINK); V.top = 0; V.start = 5; backtrack(V.top, V.start, &V); while (V.ok) { lexical(&V); /*D if trace then write(logfile,' Sym:',newsymb: 3,' State:', lri: 3); D*/ if (!lookahead_(V.newsymb, &V)) syntaxerror(&V); advance(&V); } } /* PG1----------------------------------------------------------------*/ void inputgrammar(void) { struct LOC_inputgrammar V; parser(&V); _L10: produce(2, 0, 0, &V); if (V.errcount == 0) return; fprintf(list, "\n *** %2d Source errors detected\n", V.errcount); fprintf(console, " *** %2d Source errors detected\n", V.errcount); stop(0); } int main(int argc, Char *argv[]) { P_argc = argc; P_argv = argv; __top_jb = NULL; if (setjmp(_JL999)) goto _L999; logfile = NULL; console = NULL; list = NULL; output = NULL; input = NULL; /*D trace := false; D*/ /* change for debugging */ /*D debug := true; if trace then debug := true; D*/ openfiles(); headline(); /*HF writeln(console,' ',ParamStr(0),' (Version 5)'); FH*/ fputc(' ',console); char *cp = P_argv[0]; int len = MSTRINGlen; while (*cp && --len >= 0) fputc(*cp++,console); fprintf(console," (Version 5)\n"); freeptr = NULL; inputgrammar(); removeid(true); termination(); removeid(false); vhrecurs(); initprod(); listgrammar(); lr0(); lookb(); verify(); compress(); emitconstants(); errortable(); emitlex(); emitpars(); _L999: putc('\n', list); if (input != NULL) fclose(input); if (output != NULL) fclose(output); if (list != NULL) fclose(list); if (console != NULL) fclose(console); if (logfile != NULL) fclose(logfile); exit(EXIT_SUCCESS); } /* End. */
24.587808
263
0.534368
[ "transform", "3d" ]
356d02e2c1a53eb825981a048ba0f6f1e993609a
2,583
h
C
blades/xbmc/xbmc/cores/dvdplayer/DVDOverlayRenderer.h
krattai/AEBL
a7b12c97479e1236d5370166b15ca9f29d7d4265
[ "BSD-2-Clause" ]
4
2016-04-26T03:43:54.000Z
2016-11-17T08:09:04.000Z
blades/xbmc/xbmc/cores/dvdplayer/DVDOverlayRenderer.h
krattai/AEBL
a7b12c97479e1236d5370166b15ca9f29d7d4265
[ "BSD-2-Clause" ]
17
2015-01-05T21:06:22.000Z
2015-12-07T20:45:44.000Z
blades/xbmc/xbmc/cores/dvdplayer/DVDOverlayRenderer.h
krattai/AEBL
a7b12c97479e1236d5370166b15ca9f29d7d4265
[ "BSD-2-Clause" ]
3
2016-04-26T03:43:55.000Z
2020-11-06T11:02:08.000Z
#pragma once /* * Copyright (C) 2005-2013 Team XBMC * http://xbmc.org * * This Program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2, or (at your option) * any later version. * * This Program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with XBMC; see the file COPYING. If not, see * <http://www.gnu.org/licenses/>. * */ #include "DVDCodecs/Video/DVDVideoCodec.h" #include "DVDCodecs/Overlay/DVDOverlay.h" #ifdef HAS_VIDEO_PLAYBACK #include "cores/VideoRenderers/RenderManager.h" #endif class CDVDOverlayImage; class CDVDOverlaySSA; typedef struct stDVDPictureRenderer { uint8_t* data[4]; int stride[4]; int width; int height; } DVDPictureRenderer; class CDVDOverlayRenderer { public: static void Render(DVDPictureRenderer* pPicture, CDVDOverlay* pOverlay, double pts); static void Render(DVDPictureRenderer* pPicture, CDVDOverlayImage* pOverlay); static void Render(DVDPictureRenderer* pPicture, CDVDOverlaySSA *pOverlay, double pts); #ifdef HAS_VIDEO_PLAYBACK static void Render(YV12Image* pImage, CDVDOverlay* pOverlay, double pts) { DVDPictureRenderer p; p.data[0] = pImage->plane[0]; p.data[1] = pImage->plane[1]; p.data[2] = pImage->plane[2]; p.data[3] = NULL; p.stride[0] = pImage->stride[0]; p.stride[1] = pImage->stride[1]; p.stride[2] = pImage->stride[2]; p.stride[3] = 0; p.width = pImage->width; p.height = pImage->height; Render(&p, pOverlay, pts); } #endif static void Render(DVDVideoPicture* pPicture, CDVDOverlay* pOverlay, double pts) { if(pPicture->format != RENDER_FMT_YUV420P) return; DVDPictureRenderer p; p.data[0] = pPicture->data[0]; p.data[1] = pPicture->data[1]; p.data[2] = pPicture->data[2]; p.data[3] = pPicture->data[3]; p.stride[0] = pPicture->iLineSize[0]; p.stride[1] = pPicture->iLineSize[1]; p.stride[2] = pPicture->iLineSize[2]; p.stride[3] = pPicture->iLineSize[3]; p.width = pPicture->iWidth; p.height = pPicture->iHeight; Render(&p, pOverlay, pts); } private: static void Render_SPU_YUV(DVDPictureRenderer* pPicture, CDVDOverlay* pOverlaySpu, bool bCrop); };
26.090909
97
0.691831
[ "render" ]
358fbf99efd0b87e8b18754868b47b86502ea40f
935
h
C
LeetCode/C++/2033._Minimum_Operations_to_Uni_Value_Grid/solution.h
icgw/LeetCode
cb70ca87aa4604d1aec83d4224b3489eacebba75
[ "MIT" ]
4
2018-09-12T09:32:17.000Z
2018-12-06T03:17:38.000Z
LeetCode/C++/2033._Minimum_Operations_to_Uni_Value_Grid/solution.h
icgw/algorithm
cb70ca87aa4604d1aec83d4224b3489eacebba75
[ "MIT" ]
null
null
null
LeetCode/C++/2033._Minimum_Operations_to_Uni_Value_Grid/solution.h
icgw/algorithm
cb70ca87aa4604d1aec83d4224b3489eacebba75
[ "MIT" ]
null
null
null
/* * solution.h * Copyright (C) 2021 Guowei Chen <icgw@outlook.com> * * Distributed under terms of the Apache license. */ #ifndef _SOLUTION_H_ #define _SOLUTION_H_ #include <vector> using std::vector; #include <queue> using std::priority_queue; class Solution { public: int minOperations(vector<vector<int>>& grid, int x) { int n = grid.size(); int m = grid[0].size(); priority_queue<int> pq; int k = (n * m + 1) / 2; vector<int> v; for (auto& g : grid) { v.insert(v.end(), g.begin(), g.end()); for (int i : g) { pq.push(i); if (pq.size() > k) { pq.pop(); } } } int mid = pq.top(); int res = 0; for (int i : v) { int diff = abs(i - mid); if (diff % x != 0) { return -1; } res += (diff / x); } return res; } }; #endif /* !_SOLUTION_H_ */
19.479167
57
0.485561
[ "vector" ]
359d593d8e495407b56f544487daafee19b346d2
1,398
h
C
Source/ScillSDK/Public/ScillApiWrapper/ScillApiLeaderboardUpdatePayload.h
Iron-City-Games/scill-unreal
aab925a6acf0faf5e36ec39e568ac4ee920bfaae
[ "MIT" ]
null
null
null
Source/ScillSDK/Public/ScillApiWrapper/ScillApiLeaderboardUpdatePayload.h
Iron-City-Games/scill-unreal
aab925a6acf0faf5e36ec39e568ac4ee920bfaae
[ "MIT" ]
null
null
null
Source/ScillSDK/Public/ScillApiWrapper/ScillApiLeaderboardUpdatePayload.h
Iron-City-Games/scill-unreal
aab925a6acf0faf5e36ec39e568ac4ee920bfaae
[ "MIT" ]
null
null
null
/** * SCILL API * SCILL gives you the tools to activate, retain and grow your user base in your app or game by bringing you features well known in the gaming industry: Gamification. We take care of the services and technology involved so you can focus on your game and content. * * OpenAPI spec version: 1.0.0 * Contact: support@scillgame.com * * NOTE: This class is auto generated by OpenAPI Generator * https://github.com/OpenAPITools/openapi-generator * Do not edit the class manually. */ #pragma once #include "ScillApiBaseModel.h" #include "ScillApiLeaderboardInfo.h" #include "ScillApiLeaderboardRanking.h" #include "ScillApiLeaderboardScore.h" namespace ScillSDK { /* * ScillApiLeaderboardUpdatePayload * * The payload used for realtime updates and webhooks if a leaderboard is updated. */ class SCILLSDK_API ScillApiLeaderboardUpdatePayload : public Model { public: virtual ~ScillApiLeaderboardUpdatePayload() {} bool FromJson(const TSharedPtr<FJsonValue>& JsonValue) final; void WriteJson(JsonWriter& Writer) const final; /* The type of the webhook, in this case it is leaderboard-ranking-changed */ TOptional<FString> WebhookType; TOptional<ScillApiLeaderboardInfo> LeaderboardData; TOptional<ScillApiLeaderboardRanking> MemberData; TOptional<ScillApiLeaderboardScore> OldLeaderboardRanking; TOptional<ScillApiLeaderboardScore> NewLeaderboardRanking; }; }
31.772727
262
0.7897
[ "model" ]
359ea54d63b7d7be58f20894b84cd3658c7a14cc
1,720
h
C
Core/GDCore/IDE/Project/ResourcesRenamer.h
Add00/GDevelop
b341bc5be0426e4902f709d8d0fb9670bae654df
[ "MIT" ]
2
2020-05-23T14:15:30.000Z
2020-06-20T13:23:59.000Z
Core/GDCore/IDE/Project/ResourcesRenamer.h
KairoMartins18/KGE
64e934c15da38c7140abb5e1521321e161d82568
[ "MIT" ]
1
2020-09-15T12:05:05.000Z
2020-09-15T12:05:05.000Z
Core/GDCore/IDE/Project/ResourcesRenamer.h
KairoMartins18/KGE
64e934c15da38c7140abb5e1521321e161d82568
[ "MIT" ]
1
2019-01-14T21:03:06.000Z
2019-01-14T21:03:06.000Z
/* * GDevelop Core * Copyright 2008-2016 Florian Rival (Florian.Rival@gmail.com). All rights * reserved. This project is released under the MIT License. */ #if defined(GD_IDE_ONLY) #ifndef GDCORE_RESOURCESRENAMER_H #define GDCORE_RESOURCESRENAMER_H #include <set> #include <vector> #include "GDCore/IDE/Project/ArbitraryResourceWorker.h" #include "GDCore/String.h" namespace gd { /** * \brief Class used to rename resources (in an object, an entire project, * etc...) * * \ingroup IDE */ class ResourcesRenamer : public gd::ArbitraryResourceWorker { public: /** * @brief Constructor taking the map from old name to new name. * @param oldToNewNames_ A map associating to a resource name the new name to * use. */ ResourcesRenamer(const std::map<gd::String, gd::String>& oldToNewNames_) : gd::ArbitraryResourceWorker(), oldToNewNames(oldToNewNames_){}; virtual ~ResourcesRenamer(){}; virtual void ExposeFile(gd::String& resourceName) override { RenameIfNeeded(resourceName); }; virtual void ExposeImage(gd::String& imageResourceName) override { RenameIfNeeded(imageResourceName); }; virtual void ExposeAudio(gd::String& audioResourceName) override { RenameIfNeeded(audioResourceName); }; virtual void ExposeFont(gd::String& fontResourceName) override { RenameIfNeeded(fontResourceName); }; private: void RenameIfNeeded(gd::String& resourceName) { if (oldToNewNames.find(resourceName) != oldToNewNames.end()) resourceName = oldToNewNames[resourceName]; } std::map<gd::String, gd::String> oldToNewNames; }; } // namespace gd #endif // GDCORE_RESOURCESRENAMER_H #endif
27.741935
80
0.70407
[ "object", "vector" ]
359f13b60a02ad1405c82bc73573ee081cfe45df
5,529
h
C
Source/JavaScriptCore/wasm/WasmBBQPlan.h
ijsf/DeniseEmbeddableWebKit
57dfc6783d60f8f59b7129874e60f84d8c8556c9
[ "BSD-3-Clause" ]
null
null
null
Source/JavaScriptCore/wasm/WasmBBQPlan.h
ijsf/DeniseEmbeddableWebKit
57dfc6783d60f8f59b7129874e60f84d8c8556c9
[ "BSD-3-Clause" ]
9
2020-04-18T18:47:18.000Z
2020-04-18T18:52:41.000Z
Source/JavaScriptCore/wasm/WasmBBQPlan.h
ijsf/DeniseEmbeddableWebKit
57dfc6783d60f8f59b7129874e60f84d8c8556c9
[ "BSD-3-Clause" ]
null
null
null
/* * Copyright (C) 2016-2017 Apple Inc. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #pragma once #if ENABLE(WEBASSEMBLY) #include "CompilationResult.h" #include "VM.h" #include "WasmB3IRGenerator.h" #include "WasmModuleInformation.h" #include "WasmPlan.h" #include "WasmTierUpCount.h" #include <wtf/Bag.h> #include <wtf/SharedTask.h> #include <wtf/ThreadSafeRefCounted.h> #include <wtf/Vector.h> namespace JSC { class CallLinkInfo; class JSGlobalObject; class JSPromiseDeferred; namespace Wasm { class BBQPlan final : public Plan { public: using Base = Plan; enum AsyncWork : uint8_t { FullCompile, Validation }; // Note: CompletionTask should not hold a reference to the Plan otherwise there will be a reference cycle. BBQPlan(VM*, Ref<ModuleInformation>, AsyncWork, CompletionTask&&); JS_EXPORT_PRIVATE BBQPlan(VM*, Vector<uint8_t>&&, AsyncWork, CompletionTask&&); // Note: This constructor should only be used if you are not actually building a module e.g. validation/function tests // FIXME: When we get rid of function tests we should remove AsyncWork from this constructor. JS_EXPORT_PRIVATE BBQPlan(VM*, const uint8_t*, size_t, AsyncWork, CompletionTask&&); bool parseAndValidateModule(); JS_EXPORT_PRIVATE void prepare(); void compileFunctions(CompilationEffort); template<typename Functor> void initializeCallees(const Functor&); Vector<Export>& exports() const { RELEASE_ASSERT(!failed() && !hasWork()); return m_moduleInformation->exports; } size_t internalFunctionCount() const { RELEASE_ASSERT(!failed() && !hasWork()); return m_moduleInformation->internalFunctionCount(); } Ref<ModuleInformation>&& takeModuleInformation() { RELEASE_ASSERT(!failed() && !hasWork()); return WTFMove(m_moduleInformation); } Bag<CallLinkInfo>&& takeCallLinkInfos() { RELEASE_ASSERT(!failed() && !hasWork()); return WTFMove(m_callLinkInfos); } Vector<MacroAssemblerCodeRef>&& takeWasmToWasmExitStubs() { RELEASE_ASSERT(!failed() && !hasWork()); return WTFMove(m_wasmToWasmExitStubs); } Vector<Vector<UnlinkedWasmToWasmCall>> takeWasmToWasmCallsites() { RELEASE_ASSERT(!failed() && !hasWork()); return WTFMove(m_unlinkedWasmToWasmCalls); } Vector<TierUpCount> takeTierUpCounts() { RELEASE_ASSERT(!failed() && !hasWork()); return WTFMove(m_tierUpCounts); } enum class State : uint8_t { Initial, Validated, Prepared, Compiled, Completed // We should only move to Completed if we are holding the lock. }; bool hasWork() const override { if (m_asyncWork == AsyncWork::Validation) return m_state < State::Validated; return m_state < State::Compiled; } void work(CompilationEffort) override; bool hasBeenPrepared() const { return m_state >= State::Prepared; } bool multiThreaded() const override { return hasBeenPrepared(); } private: class ThreadCountHolder; friend class ThreadCountHolder; // For some reason friendship doesn't extend to parent classes... using Base::m_lock; void moveToState(State); bool isComplete() const override { return m_state == State::Completed; } void complete(const AbstractLocker&) override; const char* stateString(State); Bag<CallLinkInfo> m_callLinkInfos; Vector<MacroAssemblerCodeRef> m_wasmToWasmExitStubs; Vector<std::unique_ptr<InternalFunction>> m_wasmInternalFunctions; HashSet<uint32_t, typename DefaultHash<uint32_t>::Hash, WTF::UnsignedWithZeroKeyHashTraits<uint32_t>> m_exportedFunctionIndices; HashMap<uint32_t, std::unique_ptr<InternalFunction>, typename DefaultHash<uint32_t>::Hash, WTF::UnsignedWithZeroKeyHashTraits<uint32_t>> m_jsToWasmInternalFunctions; Vector<CompilationContext> m_compilationContexts; Vector<TierUpCount> m_tierUpCounts; Vector<Vector<UnlinkedWasmToWasmCall>> m_unlinkedWasmToWasmCalls; State m_state; const AsyncWork m_asyncWork; uint8_t m_numberOfActiveThreads { 0 }; uint32_t m_currentIndex { 0 }; }; } } // namespace JSC::Wasm #endif // ENABLE(WEBASSEMBLY)
34.55625
169
0.718213
[ "vector" ]
7713f89e6df6a66dfedf919b9ec0d7d505af31f9
39,894
c
C
RedfishPkg/PrivateLibrary/RedfishLib/edk2libredfish/src/service.c
nicklela/edk2
dfafa8e45382939fb5dc78e9d37b97b500a43613
[ "Python-2.0", "Zlib", "BSD-2-Clause", "MIT", "BSD-2-Clause-Patent", "BSD-3-Clause" ]
31
2019-05-14T09:00:56.000Z
2022-03-16T12:36:49.000Z
RedfishPkg/PrivateLibrary/RedfishLib/edk2libredfish/src/service.c
nicklela/edk2
dfafa8e45382939fb5dc78e9d37b97b500a43613
[ "Python-2.0", "Zlib", "BSD-2-Clause", "MIT", "BSD-2-Clause-Patent", "BSD-3-Clause" ]
21
2020-03-09T18:54:14.000Z
2022-01-01T00:30:53.000Z
RedfishPkg/PrivateLibrary/RedfishLib/edk2libredfish/src/service.c
nicklela/edk2
dfafa8e45382939fb5dc78e9d37b97b500a43613
[ "Python-2.0", "Zlib", "BSD-2-Clause", "MIT", "BSD-2-Clause-Patent", "BSD-3-Clause" ]
25
2018-09-05T02:46:06.000Z
2022-03-20T18:58:40.000Z
/** @file This file is cloned from DMTF libredfish library tag v1.0.0 and maintained by EDKII. //---------------------------------------------------------------------------- // Copyright Notice: // Copyright 2017 Distributed Management Task Force, Inc. All rights reserved. // License: BSD 3-Clause License. For full text see link: https://github.com/DMTF/libredfish/LICENSE.md //---------------------------------------------------------------------------- Copyright (c) 2019, Intel Corporation. All rights reserved.<BR> (C) Copyright 2021 Hewlett Packard Enterprise Development LP<BR> SPDX-License-Identifier: BSD-2-Clause-Patent **/ #include <redfishService.h> #include <redfishPayload.h> #include <redpath.h> static int initRest(redfishService* service, void * restProtocol); static redfishService* createServiceEnumeratorNoAuth(const char* host, const char* rootUri, bool enumerate, unsigned int flags, void * restProtocol); static redfishService* createServiceEnumeratorBasicAuth(const char* host, const char* rootUri, const char* username, const char* password, unsigned int flags, void * restProtocol); static redfishService* createServiceEnumeratorSessionAuth(const char* host, const char* rootUri, const char* username, const char* password, unsigned int flags, void * restProtocol); static char* makeUrlForService(redfishService* service, const char* uri); static json_t* getVersions(redfishService* service, const char* rootUri); static void addStringToJsonObject(json_t* object, const char* key, const char* value); CHAR16* C8ToC16 (CHAR8 *AsciiStr) { CHAR16 *Str; UINTN BufLen; BufLen = (AsciiStrLen (AsciiStr) + 1) * 2; Str = AllocatePool (BufLen); ASSERT (Str != NULL); AsciiStrToUnicodeStrS (AsciiStr, Str, AsciiStrLen (AsciiStr) + 1); return Str; } VOID RestConfigFreeHttpRequestData ( IN EFI_HTTP_REQUEST_DATA *RequestData ) { if (RequestData == NULL) { return ; } if (RequestData->Url != NULL) { FreePool (RequestData->Url); } FreePool (RequestData); } VOID RestConfigFreeHttpMessage ( IN EFI_HTTP_MESSAGE *Message, IN BOOLEAN IsRequest ) { if (Message == NULL) { return ; } if (IsRequest) { RestConfigFreeHttpRequestData (Message->Data.Request); Message->Data.Request = NULL; } else { if (Message->Data.Response != NULL) { FreePool (Message->Data.Response); Message->Data.Response = NULL; } } if (Message->Headers != NULL) { FreePool (Message->Headers); Message->Headers = NULL; } if (Message->Body != NULL) { FreePool (Message->Body); Message->Body = NULL; } } /** Converts the Unicode string to ASCII string to a new allocated buffer. @param[in] String Unicode string to be converted. @return Buffer points to ASCII string, or NULL if error happens. **/ CHAR8 * UnicodeStrDupToAsciiStr ( CONST CHAR16 *String ) { CHAR8 *AsciiStr; UINTN BufLen; EFI_STATUS Status; BufLen = StrLen (String) + 1; AsciiStr = AllocatePool (BufLen); if (AsciiStr == NULL) { return NULL; } Status = UnicodeStrToAsciiStrS (String, AsciiStr, BufLen); if (EFI_ERROR (Status)) { return NULL; } return AsciiStr; } /** This function encodes the content. @param[in] ContentEncodedValue HTTP conent encoded value. @param[in] OriginalContent Original content. @param[out] EncodedContent Pointer to receive encoded content. @param[out] EncodedContentLength Length of encoded content. @retval EFI_SUCCESS Content encoded successfully. @retval EFI_UNSUPPORTED No source encoding funciton, @retval EFI_INVALID_PARAMETER One of the given parameter is invalid. **/ EFI_STATUS EncodeRequestContent ( IN CHAR8 *ContentEncodedValue, IN CHAR8 *OriginalContent, OUT VOID **EncodedContent, OUT UINTN *EncodedContentLength ) { EFI_STATUS Status; VOID *EncodedPointer; UINTN EncodedLength; if (OriginalContent == NULL || EncodedContent == NULL || EncodedContentLength == NULL) { return EFI_INVALID_PARAMETER; } Status = RedfishContentEncode ( ContentEncodedValue, OriginalContent, AsciiStrLen (OriginalContent), &EncodedPointer, &EncodedLength ); if (Status == EFI_SUCCESS) { *EncodedContent = EncodedPointer; *EncodedContentLength = EncodedLength; return EFI_SUCCESS; } return Status; } /** This function decodes the content. The Memory block pointed by ContentPointer would be freed and replaced with the cooked Redfish payload. @param[in] ContentEncodedValue HTTP conent encoded value. @param[in, out] ContentPointer Pointer to encoded content. Pointer of decoded content when out. @param[in, out] ContentLength Pointer to the length of encoded content. Length of decoded content when out. @retval EFI_SUCCESS Functinos found. @retval EFI_UNSUPPORTED No functions found. @retval EFI_INVALID_PARAMETER One of the given parameter is invalid. **/ EFI_STATUS DecodeResponseContent ( IN CHAR8 *ContentEncodedValue, IN OUT VOID **ContentPointer, IN OUT UINTN *ContentLength ) { EFI_STATUS Status; VOID *DecodedPointer; UINTN DecodedLength; if (ContentEncodedValue == NULL) { return EFI_INVALID_PARAMETER; } Status = RedfishContentDecode ( ContentEncodedValue, *ContentPointer, *ContentLength, &DecodedPointer, &DecodedLength ); if (Status == EFI_SUCCESS) { FreePool (*ContentPointer); *ContentPointer = DecodedPointer; *ContentLength = DecodedLength; } return Status; } /** Create a HTTP URL string for specific Redfish resource. This function build a URL string from the Redfish Host interface record and caller specified relative path of the resource. Callers are responsible for freeing the returned string storage pointed by HttpUrl. @param[in] RedfishData Redfish network host interface record. @param[in] RelativePath Relative path of a resource. @param[out] HttpUrl The pointer to store the returned URL string. @retval EFI_SUCCESS Build the URL string successfully. @retval EFI_INVALID_PARAMETER RedfishData or HttpUrl is NULL. @retval EFI_OUT_OF_RESOURCES There are not enough memory resources. **/ EFI_STATUS RedfishBuildUrl ( IN REDFISH_CONFIG_SERVICE_INFORMATION *RedfishConfigServiceInfo, IN CHAR16 *RelativePath, OPTIONAL OUT CHAR16 **HttpUrl ) { CHAR16 *Url; CHAR16 *UrlHead; UINTN UrlLength; UINTN PathLen; if ((RedfishConfigServiceInfo == NULL) || (HttpUrl == NULL)) { return EFI_INVALID_PARAMETER; } // // RFC2616: http_URL = "http(s):" "//" host [ ":" port ] [ abs_path [ "?" query ]] // if (RelativePath == NULL) { PathLen = 0; } else { PathLen = StrLen (RelativePath); } UrlLength = StrLen (HTTPS_FLAG) + StrLen (REDFISH_FIRST_URL) + 1 + StrLen(RedfishConfigServiceInfo->RedfishServiceLocation) + PathLen; Url = AllocateZeroPool (UrlLength * sizeof (CHAR16)); if (Url == NULL) { return EFI_OUT_OF_RESOURCES; } UrlHead = Url; // // Copy "http://" or "https://" according RedfishServiceIpPort. // if (!RedfishConfigServiceInfo->RedfishServiceUseHttps) { StrCpyS (Url, StrLen (HTTPS_FLAG) + 1, HTTP_FLAG); Url = Url + StrLen (HTTP_FLAG); } else { StrCpyS (Url, StrLen (HTTPS_FLAG) + 1, HTTPS_FLAG); Url = Url + StrLen (HTTPS_FLAG); } StrCpyS (Url, StrLen (RedfishConfigServiceInfo->RedfishServiceLocation) + 1, RedfishConfigServiceInfo->RedfishServiceLocation); Url = Url + StrLen (RedfishConfigServiceInfo->RedfishServiceLocation); // // Copy abs_path // if (RelativePath != NULL && PathLen != 0 ) { StrnCpyS (Url, UrlLength, RelativePath, PathLen); } *HttpUrl = UrlHead; return EFI_SUCCESS; } redfishService* createServiceEnumerator(REDFISH_CONFIG_SERVICE_INFORMATION *RedfishConfigServiceInfo, const char* rootUri, enumeratorAuthentication* auth, unsigned int flags) { EFI_STATUS Status; CHAR16 *HttpUrl; CHAR8 *AsciiHost; EFI_REST_EX_PROTOCOL *RestEx; redfishService *ret; HttpUrl = NULL; AsciiHost = NULL; RestEx = NULL; ret = NULL; if (RedfishConfigServiceInfo->RedfishServiceRestExHandle == NULL) { goto ON_EXIT; } Status = RedfishBuildUrl(RedfishConfigServiceInfo, NULL, &HttpUrl); if (EFI_ERROR (Status)) { goto ON_EXIT; } ASSERT (HttpUrl != NULL); AsciiHost = UnicodeStrDupToAsciiStr (HttpUrl); if (AsciiHost == NULL) { goto ON_EXIT; } Status = gBS->HandleProtocol ( RedfishConfigServiceInfo->RedfishServiceRestExHandle, &gEfiRestExProtocolGuid, (VOID **)&RestEx ); if (EFI_ERROR (Status)) { goto ON_EXIT; } if(auth == NULL) { ret = createServiceEnumeratorNoAuth(AsciiHost, rootUri, true, flags, RestEx); } else if(auth->authType == REDFISH_AUTH_BASIC) { ret = createServiceEnumeratorBasicAuth(AsciiHost, rootUri, auth->authCodes.userPass.username, auth->authCodes.userPass.password, flags, RestEx); } else if(auth->authType == REDFISH_AUTH_SESSION) { ret = createServiceEnumeratorSessionAuth(AsciiHost, rootUri, auth->authCodes.userPass.username, auth->authCodes.userPass.password, flags, RestEx); } else { goto ON_EXIT; } ret->RestEx = RestEx; ON_EXIT: if (HttpUrl != NULL) { FreePool (HttpUrl); } if (AsciiHost != NULL) { FreePool (AsciiHost); } return ret; } json_t* getUriFromService(redfishService* service, const char* uri, EFI_HTTP_STATUS_CODE** StatusCode) { char* url; json_t* ret; HTTP_IO_HEADER *HttpIoHeader = NULL; EFI_STATUS Status; EFI_HTTP_REQUEST_DATA *RequestData = NULL; EFI_HTTP_MESSAGE *RequestMsg = NULL; EFI_HTTP_MESSAGE ResponseMsg; EFI_HTTP_HEADER *ContentEncodedHeader; if(service == NULL || uri == NULL || StatusCode == NULL) { return NULL; } *StatusCode = NULL; url = makeUrlForService(service, uri); if(!url) { return NULL; } DEBUG((DEBUG_INFO, "libredfish: getUriFromService(): %a\n", url)); // // Step 1: Create HTTP request message with 4 headers: // HttpIoHeader = HttpIoCreateHeader ((service->sessionToken || service->basicAuthStr) ? 6 : 5); if (HttpIoHeader == NULL) { ret = NULL; goto ON_EXIT; } if(service->sessionToken) { Status = HttpIoSetHeader (HttpIoHeader, "X-Auth-Token", service->sessionToken); ASSERT_EFI_ERROR (Status); } else if (service->basicAuthStr) { Status = HttpIoSetHeader (HttpIoHeader, "Authorization", service->basicAuthStr); ASSERT_EFI_ERROR (Status); } Status = HttpIoSetHeader (HttpIoHeader, "Host", service->HostHeaderValue); ASSERT_EFI_ERROR (Status); Status = HttpIoSetHeader (HttpIoHeader, "OData-Version", "4.0"); ASSERT_EFI_ERROR (Status); Status = HttpIoSetHeader (HttpIoHeader, "Accept", "application/json"); ASSERT_EFI_ERROR (Status); Status = HttpIoSetHeader (HttpIoHeader, "User-Agent", "libredfish"); ASSERT_EFI_ERROR (Status); Status = HttpIoSetHeader (HttpIoHeader, "Connection", "Keep-Alive"); ASSERT_EFI_ERROR (Status); // // Step 2: build the rest of HTTP request info. // RequestData = AllocateZeroPool (sizeof (EFI_HTTP_REQUEST_DATA)); if (RequestData == NULL) { ret = NULL; goto ON_EXIT; } RequestData->Method = HttpMethodGet; RequestData->Url = C8ToC16 (url); // // Step 3: fill in EFI_HTTP_MESSAGE // RequestMsg = AllocateZeroPool (sizeof (EFI_HTTP_MESSAGE)); if (RequestMsg == NULL) { ret = NULL; goto ON_EXIT; } RequestMsg->Data.Request = RequestData; RequestMsg->HeaderCount = HttpIoHeader->HeaderCount; RequestMsg->Headers = HttpIoHeader->Headers; ZeroMem (&ResponseMsg, sizeof (ResponseMsg)); // // Step 4: call RESTEx to get response from REST service. // Status = service->RestEx->SendReceive (service->RestEx, RequestMsg, &ResponseMsg); if (EFI_ERROR (Status)) { ret = NULL; goto ON_EXIT; } // // Step 5: Return the HTTP StatusCode and Body message. // if (ResponseMsg.Data.Response != NULL) { *StatusCode = AllocateZeroPool (sizeof (EFI_HTTP_STATUS_CODE)); if (*StatusCode == NULL) { ret = NULL; goto ON_EXIT; } // // The caller shall take the responsibility to free the buffer. // **StatusCode = ResponseMsg.Data.Response->StatusCode; } if (ResponseMsg.BodyLength != 0 && ResponseMsg.Body != NULL) { // // Check if data is encoded. // ContentEncodedHeader = HttpFindHeader (ResponseMsg.HeaderCount, ResponseMsg.Headers, HTTP_HEADER_CONTENT_ENCODING); if (ContentEncodedHeader != NULL) { // // The content is encoded. // Status = DecodeResponseContent (ContentEncodedHeader->FieldValue, &ResponseMsg.Body, &ResponseMsg.BodyLength); if (EFI_ERROR (Status)) { DEBUG ((DEBUG_ERROR, "%a: Failed to decompress the response content %r\n.", __FUNCTION__, Status)); ret = NULL; goto ON_EXIT; } } ret = json_loadb (ResponseMsg.Body, ResponseMsg.BodyLength, 0, NULL); } else { // // There is no message body returned from server. // ret = NULL; } ON_EXIT: if (url != NULL) { free (url); } if (HttpIoHeader != NULL) { HttpIoFreeHeader (HttpIoHeader); } if (RequestData != NULL) { RestConfigFreeHttpRequestData (RequestData); } if (RequestMsg != NULL) { FreePool (RequestMsg); } RestConfigFreeHttpMessage (&ResponseMsg, FALSE); return ret; } json_t* patchUriFromService(redfishService* service, const char* uri, const char* content, EFI_HTTP_STATUS_CODE** StatusCode) { char* url; json_t* ret; HTTP_IO_HEADER *HttpIoHeader = NULL; EFI_STATUS Status; EFI_HTTP_REQUEST_DATA *RequestData = NULL; EFI_HTTP_MESSAGE *RequestMsg = NULL; EFI_HTTP_MESSAGE ResponseMsg; CHAR8 ContentLengthStr[80]; CHAR8 *EncodedContent; UINTN EncodedContentLen; if(service == NULL || uri == NULL || content == NULL || StatusCode == NULL) { return NULL; } *StatusCode = NULL; url = makeUrlForService(service, uri); if(!url) { return NULL; } DEBUG((DEBUG_INFO, "libredfish: patchUriFromService(): %a\n", url)); // // Step 1: Create HTTP request message with 4 headers: // HttpIoHeader = HttpIoCreateHeader ((service->sessionToken || service->basicAuthStr) ? 9 : 8); if (HttpIoHeader == NULL) { ret = NULL; goto ON_EXIT; } if(service->sessionToken) { Status = HttpIoSetHeader (HttpIoHeader, "X-Auth-Token", service->sessionToken); ASSERT_EFI_ERROR (Status); } else if (service->basicAuthStr) { Status = HttpIoSetHeader (HttpIoHeader, "Authorization", service->basicAuthStr); ASSERT_EFI_ERROR (Status); } Status = HttpIoSetHeader (HttpIoHeader, "Host", service->HostHeaderValue); ASSERT_EFI_ERROR (Status); Status = HttpIoSetHeader (HttpIoHeader, "Content-Type", "application/json"); ASSERT_EFI_ERROR (Status); Status = HttpIoSetHeader (HttpIoHeader, "Accept", "application/json"); ASSERT_EFI_ERROR (Status); Status = HttpIoSetHeader (HttpIoHeader, "User-Agent", "libredfish"); ASSERT_EFI_ERROR (Status); Status = HttpIoSetHeader (HttpIoHeader, "Connection", "Keep-Alive"); ASSERT_EFI_ERROR (Status); AsciiSPrint( ContentLengthStr, sizeof (ContentLengthStr), "%lu", (UINT64) strlen(content) ); Status = HttpIoSetHeader (HttpIoHeader, "Content-Length", ContentLengthStr); ASSERT_EFI_ERROR (Status); Status = HttpIoSetHeader (HttpIoHeader, "OData-Version", "4.0"); ASSERT_EFI_ERROR (Status); // // Step 2: build the rest of HTTP request info. // RequestData = AllocateZeroPool (sizeof (EFI_HTTP_REQUEST_DATA)); if (RequestData == NULL) { ret = NULL; goto ON_EXIT; } RequestData->Method = HttpMethodPatch; RequestData->Url = C8ToC16 (url); // // Step 3: fill in EFI_HTTP_MESSAGE // RequestMsg = AllocateZeroPool (sizeof (EFI_HTTP_MESSAGE)); if (RequestMsg == NULL) { ret = NULL; goto ON_EXIT; } EncodedContent = (CHAR8 *)content; EncodedContentLen = strlen(content); // // We currently only support gzip Content-Encoding. // Status = EncodeRequestContent ((CHAR8 *)HTTP_CONTENT_ENCODING_GZIP, (CHAR8 *)content, (VOID **)&EncodedContent, &EncodedContentLen); if (Status == EFI_INVALID_PARAMETER) { DEBUG((DEBUG_ERROR, "%a: Error to encode content.\n", __FUNCTION__)); ret = NULL; goto ON_EXIT; } else if (Status == EFI_UNSUPPORTED) { DEBUG((DEBUG_INFO, "No content coding for %a! Use raw data instead.\n", HTTP_CONTENT_ENCODING_GZIP)); Status = HttpIoSetHeader (HttpIoHeader, "Content-Encoding", HTTP_CONTENT_ENCODING_IDENTITY); ASSERT_EFI_ERROR (Status); } else { Status = HttpIoSetHeader (HttpIoHeader, "Content-Encoding", HTTP_CONTENT_ENCODING_GZIP); ASSERT_EFI_ERROR (Status); } RequestMsg->Data.Request = RequestData; RequestMsg->HeaderCount = HttpIoHeader->HeaderCount; RequestMsg->Headers = HttpIoHeader->Headers; RequestMsg->BodyLength = EncodedContentLen; RequestMsg->Body = (VOID*) EncodedContent; ZeroMem (&ResponseMsg, sizeof (ResponseMsg)); // // Step 4: call RESTEx to get response from REST service. // Status = service->RestEx->SendReceive (service->RestEx, RequestMsg, &ResponseMsg); if (EFI_ERROR (Status)) { ret = NULL; goto ON_EXIT; } // // Step 5: Return the HTTP StatusCode and Body message. // if (ResponseMsg.Data.Response != NULL) { *StatusCode = AllocateZeroPool (sizeof (EFI_HTTP_STATUS_CODE)); if (*StatusCode == NULL) { ret = NULL; goto ON_EXIT; } // // The caller shall take the responsibility to free the buffer. // **StatusCode = ResponseMsg.Data.Response->StatusCode; } if (EncodedContent != content) { FreePool (EncodedContent); } if (ResponseMsg.BodyLength != 0 && ResponseMsg.Body != NULL) { ret = json_loadb (ResponseMsg.Body, ResponseMsg.BodyLength, 0, NULL); } else { // // There is no message body returned from server. // ret = NULL; } ON_EXIT: if (url != NULL) { free (url); } if (HttpIoHeader != NULL) { HttpIoFreeHeader (HttpIoHeader); } if (RequestData != NULL) { RestConfigFreeHttpRequestData (RequestData); } if (RequestMsg != NULL) { FreePool (RequestMsg); } RestConfigFreeHttpMessage (&ResponseMsg, FALSE); return ret; } json_t* postUriFromService(redfishService* service, const char* uri, const char* content, size_t contentLength, const char* contentType, EFI_HTTP_STATUS_CODE** StatusCode) { char* url = NULL; json_t* ret; HTTP_IO_HEADER *HttpIoHeader = NULL; EFI_STATUS Status; EFI_HTTP_REQUEST_DATA *RequestData = NULL; EFI_HTTP_MESSAGE *RequestMsg = NULL; EFI_HTTP_MESSAGE ResponseMsg; CHAR8 ContentLengthStr[80]; EFI_HTTP_HEADER *HttpHeader = NULL; ret = NULL; if(service == NULL || uri == NULL || content == NULL || StatusCode == NULL) { return NULL; } *StatusCode = NULL; url = makeUrlForService(service, uri); if(!url) { return NULL; } DEBUG((DEBUG_INFO, "libredfish: postUriFromService(): %a\n", url)); if(contentLength == 0) { contentLength = strlen(content); } // // Step 1: Create HTTP request message with 4 headers: // HttpIoHeader = HttpIoCreateHeader ((service->sessionToken || service->basicAuthStr) ? 8 : 7); if (HttpIoHeader == NULL) { goto ON_EXIT; } if(service->sessionToken) { Status = HttpIoSetHeader (HttpIoHeader, "X-Auth-Token", service->sessionToken); ASSERT_EFI_ERROR (Status); } else if (service->basicAuthStr) { Status = HttpIoSetHeader (HttpIoHeader, "Authorization", service->basicAuthStr); ASSERT_EFI_ERROR (Status); } if(contentType == NULL) { Status = HttpIoSetHeader (HttpIoHeader, "Content-Type", "application/json"); ASSERT_EFI_ERROR (Status); } else { Status = HttpIoSetHeader (HttpIoHeader, "Content-Type", (CHAR8 *) contentType); ASSERT_EFI_ERROR (Status); } Status = HttpIoSetHeader (HttpIoHeader, "Host", service->HostHeaderValue); ASSERT_EFI_ERROR (Status); Status = HttpIoSetHeader (HttpIoHeader, "Accept", "application/json"); ASSERT_EFI_ERROR (Status); Status = HttpIoSetHeader (HttpIoHeader, "User-Agent", "libredfish"); ASSERT_EFI_ERROR (Status); Status = HttpIoSetHeader (HttpIoHeader, "Connection", "Keep-Alive"); ASSERT_EFI_ERROR (Status); AsciiSPrint( ContentLengthStr, sizeof (ContentLengthStr), "%lu", (UINT64) contentLength ); Status = HttpIoSetHeader (HttpIoHeader, "Content-Length", ContentLengthStr); ASSERT_EFI_ERROR (Status); Status = HttpIoSetHeader (HttpIoHeader, "OData-Version", "4.0"); ASSERT_EFI_ERROR (Status); // // Step 2: build the rest of HTTP request info. // RequestData = AllocateZeroPool (sizeof (EFI_HTTP_REQUEST_DATA)); if (RequestData == NULL) { goto ON_EXIT; } RequestData->Method = HttpMethodPost; RequestData->Url = C8ToC16 (url); // // Step 3: fill in EFI_HTTP_MESSAGE // RequestMsg = AllocateZeroPool (sizeof (EFI_HTTP_MESSAGE)); if (RequestMsg == NULL) { goto ON_EXIT; } RequestMsg->Data.Request = RequestData; RequestMsg->HeaderCount = HttpIoHeader->HeaderCount; RequestMsg->Headers = HttpIoHeader->Headers; RequestMsg->BodyLength = contentLength; RequestMsg->Body = (VOID*) content; ZeroMem (&ResponseMsg, sizeof (ResponseMsg)); // // Step 4: call RESTEx to get response from REST service. // Status = service->RestEx->SendReceive (service->RestEx, RequestMsg, &ResponseMsg); if (EFI_ERROR (Status)) { goto ON_EXIT; } // // Step 5: Return the HTTP StatusCode and Body message. // if (ResponseMsg.Data.Response != NULL) { *StatusCode = AllocateZeroPool (sizeof (EFI_HTTP_STATUS_CODE)); if (*StatusCode == NULL) { goto ON_EXIT; } // // The caller shall take the responsibility to free the buffer. // **StatusCode = ResponseMsg.Data.Response->StatusCode; } if (ResponseMsg.BodyLength != 0 && ResponseMsg.Body != NULL) { ret = json_loadb (ResponseMsg.Body, ResponseMsg.BodyLength, 0, NULL); } // // Step 6: Parsing the HttpHeader to retrive the X-Auth-Token if the HTTP StatusCode is correct. // if (ResponseMsg.Data.Response->StatusCode == HTTP_STATUS_200_OK || ResponseMsg.Data.Response->StatusCode == HTTP_STATUS_204_NO_CONTENT) { HttpHeader = HttpFindHeader (ResponseMsg.HeaderCount, ResponseMsg.Headers, "X-Auth-Token"); if (HttpHeader != NULL) { if(service->sessionToken) { free(service->sessionToken); } service->sessionToken = AllocateCopyPool (AsciiStrSize (HttpHeader->FieldValue), HttpHeader->FieldValue); } /* // // Below opeation seems to be unnecessary. // Besides, the FieldValue for the Location is the full HTTP URI (Http://0.0.0.0:5000/XXX), so we can't use it as the // parameter of getUriFromService () directly. // HttpHeader = HttpFindHeader (ResponseMsg.HeaderCount, ResponseMsg.Headers, "Location"); if (HttpHeader != NULL) { ret = getUriFromService(service, HttpHeader->FieldValue); goto ON_EXIT; } */ } ON_EXIT: if (url != NULL) { free (url); } if (HttpIoHeader != NULL) { HttpIoFreeHeader (HttpIoHeader); } if (RequestData != NULL) { RestConfigFreeHttpRequestData (RequestData); } if (RequestMsg != NULL) { FreePool (RequestMsg); } RestConfigFreeHttpMessage (&ResponseMsg, FALSE); return ret; } json_t* deleteUriFromService(redfishService* service, const char* uri, EFI_HTTP_STATUS_CODE** StatusCode) { char* url; json_t* ret; HTTP_IO_HEADER *HttpIoHeader = NULL; EFI_STATUS Status; EFI_HTTP_REQUEST_DATA *RequestData = NULL; EFI_HTTP_MESSAGE *RequestMsg = NULL; EFI_HTTP_MESSAGE ResponseMsg; ret = NULL; if(service == NULL || uri == NULL || StatusCode == NULL) { return NULL; } *StatusCode = NULL; url = makeUrlForService(service, uri); if(!url) { return NULL; } DEBUG((DEBUG_INFO, "libredfish: deleteUriFromService(): %a\n", url)); // // Step 1: Create HTTP request message with 4 headers: // HttpIoHeader = HttpIoCreateHeader ((service->sessionToken || service->basicAuthStr) ? 5 : 4); if (HttpIoHeader == NULL) { ret = NULL; goto ON_EXIT; } if(service->sessionToken) { Status = HttpIoSetHeader (HttpIoHeader, "X-Auth-Token", service->sessionToken); ASSERT_EFI_ERROR (Status); } else if (service->basicAuthStr) { Status = HttpIoSetHeader (HttpIoHeader, "Authorization", service->basicAuthStr); ASSERT_EFI_ERROR (Status); } Status = HttpIoSetHeader (HttpIoHeader, "Host", service->HostHeaderValue); ASSERT_EFI_ERROR (Status); Status = HttpIoSetHeader (HttpIoHeader, "User-Agent", "libredfish"); ASSERT_EFI_ERROR (Status); Status = HttpIoSetHeader (HttpIoHeader, "OData-Version", "4.0"); ASSERT_EFI_ERROR (Status); Status = HttpIoSetHeader (HttpIoHeader, "Connection", "Keep-Alive"); ASSERT_EFI_ERROR (Status); // // Step 2: build the rest of HTTP request info. // RequestData = AllocateZeroPool (sizeof (EFI_HTTP_REQUEST_DATA)); if (RequestData == NULL) { ret = NULL; goto ON_EXIT; } RequestData->Method = HttpMethodDelete; RequestData->Url = C8ToC16 (url); // // Step 3: fill in EFI_HTTP_MESSAGE // RequestMsg = AllocateZeroPool (sizeof (EFI_HTTP_MESSAGE)); if (RequestMsg == NULL) { ret = NULL; goto ON_EXIT; } RequestMsg->Data.Request = RequestData; RequestMsg->HeaderCount = HttpIoHeader->HeaderCount; RequestMsg->Headers = HttpIoHeader->Headers; ZeroMem (&ResponseMsg, sizeof (ResponseMsg)); // // Step 4: call RESTEx to get response from REST service. // Status = service->RestEx->SendReceive (service->RestEx, RequestMsg, &ResponseMsg); if (EFI_ERROR (Status)) { ret = NULL; goto ON_EXIT; } // // Step 5: Return the HTTP StatusCode and Body message. // if (ResponseMsg.Data.Response != NULL) { *StatusCode = AllocateZeroPool (sizeof (EFI_HTTP_STATUS_CODE)); if (*StatusCode == NULL) { ret = NULL; goto ON_EXIT; } // // The caller shall take the responsibility to free the buffer. // **StatusCode = ResponseMsg.Data.Response->StatusCode; } if (ResponseMsg.BodyLength != 0 && ResponseMsg.Body != NULL) { ret = json_loadb (ResponseMsg.Body, ResponseMsg.BodyLength, 0, NULL); } ON_EXIT: if (url != NULL) { free (url); } if (HttpIoHeader != NULL) { HttpIoFreeHeader (HttpIoHeader); } if (RequestData != NULL) { RestConfigFreeHttpRequestData (RequestData); } if (RequestMsg != NULL) { FreePool (RequestMsg); } RestConfigFreeHttpMessage (&ResponseMsg, FALSE); return ret; } redfishPayload* getRedfishServiceRoot(redfishService* service, const char* version, EFI_HTTP_STATUS_CODE** StatusCode) { json_t* value; json_t* versionNode; const char* verUrl; if(version == NULL) { versionNode = json_object_get(service->versions, "v1"); } else { versionNode = json_object_get(service->versions, version); } if(versionNode == NULL) { return NULL; } verUrl = json_string_value(versionNode); if(verUrl == NULL) { return NULL; } value = getUriFromService(service, verUrl, StatusCode); if(value == NULL) { if((service->flags & REDFISH_FLAG_SERVICE_NO_VERSION_DOC) == 0) { json_decref(versionNode); } return NULL; } return createRedfishPayload(value, service); } redfishPayload* getPayloadByPath(redfishService* service, const char* path, EFI_HTTP_STATUS_CODE** StatusCode) { redPathNode* redpath; redfishPayload* root; redfishPayload* ret; if(!service || !path || StatusCode == NULL) { return NULL; } *StatusCode = NULL; redpath = parseRedPath(path); if(!redpath) { return NULL; } if(!redpath->isRoot) { cleanupRedPath(redpath); return NULL; } root = getRedfishServiceRoot(service, redpath->version, StatusCode); if (*StatusCode == NULL || **StatusCode < HTTP_STATUS_200_OK || **StatusCode > HTTP_STATUS_206_PARTIAL_CONTENT) { cleanupRedPath(redpath); return root; } if(redpath->next == NULL) { cleanupRedPath(redpath); return root; } FreePool (*StatusCode); *StatusCode = NULL; ret = getPayloadForPath(root, redpath->next, StatusCode); if (*StatusCode == NULL && ret != NULL) { // // In such a case, the Redfish resource is parsed from the input payload (root) directly. // So, we still return HTTP_STATUS_200_OK. // *StatusCode = AllocateZeroPool (sizeof (EFI_HTTP_STATUS_CODE)); if (*StatusCode == NULL) { ret = NULL; } else { **StatusCode = HTTP_STATUS_200_OK; } } cleanupPayload(root); cleanupRedPath(redpath); return ret; } void cleanupServiceEnumerator(redfishService* service) { if(!service) { return; } free(service->host); json_decref(service->versions); if(service->sessionToken != NULL) { ZeroMem (service->sessionToken, (UINTN)strlen(service->sessionToken)); FreePool(service->sessionToken); } if (service->basicAuthStr != NULL) { ZeroMem (service->basicAuthStr, (UINTN)strlen(service->basicAuthStr)); FreePool (service->basicAuthStr); } free(service); } static int initRest(redfishService* service, void * restProtocol) { service->RestEx = restProtocol; return 0; } static redfishService* createServiceEnumeratorNoAuth(const char* host, const char* rootUri, bool enumerate, unsigned int flags, void * restProtocol) { redfishService* ret; char *HostStart; ret = (redfishService*)calloc(1, sizeof(redfishService)); ZeroMem (ret, sizeof(redfishService)); if(initRest(ret, restProtocol) != 0) { free(ret); return NULL; } ret->host = AllocateCopyPool(AsciiStrSize(host), host); ret->flags = flags; if(enumerate) { ret->versions = getVersions(ret, rootUri); } HostStart = strstr (ret->host, "//"); if (HostStart != NULL && (*(HostStart + 2) != '\0')) { ret->HostHeaderValue = HostStart + 2; } return ret; } EFI_STATUS createBasicAuthStr ( IN redfishService* service, IN CONST CHAR8 *UserId, IN CONST CHAR8 *Password ) { EFI_STATUS Status; CHAR8 *RawAuthValue; UINTN RawAuthBufSize; CHAR8 *EnAuthValue; UINTN EnAuthValueSize; CHAR8 *BasicWithEnAuthValue; UINTN BasicBufSize; EnAuthValue = NULL; EnAuthValueSize = 0; RawAuthBufSize = AsciiStrLen (UserId) + AsciiStrLen (Password) + 2; RawAuthValue = AllocatePool (RawAuthBufSize); if (RawAuthValue == NULL) { return EFI_OUT_OF_RESOURCES; } // // Build raw AuthValue (UserId:Password). // AsciiSPrint ( RawAuthValue, RawAuthBufSize, "%a:%a", UserId, Password ); // // Encoding RawAuthValue into Base64 format. // Status = Base64Encode ( (CONST UINT8 *) RawAuthValue, AsciiStrLen (RawAuthValue), EnAuthValue, &EnAuthValueSize ); if (Status == EFI_BUFFER_TOO_SMALL) { EnAuthValue = (CHAR8 *) AllocateZeroPool (EnAuthValueSize); if (EnAuthValue == NULL) { Status = EFI_OUT_OF_RESOURCES; return Status; } Status = Base64Encode ( (CONST UINT8 *) RawAuthValue, AsciiStrLen (RawAuthValue), EnAuthValue, &EnAuthValueSize ); } if (EFI_ERROR (Status)) { goto Exit; } BasicBufSize = AsciiStrLen ("Basic ") + AsciiStrLen(EnAuthValue) + 2; BasicWithEnAuthValue = AllocatePool (BasicBufSize); if (BasicWithEnAuthValue == NULL) { Status = EFI_OUT_OF_RESOURCES; goto Exit; } // // Build encoded EnAuthValue with Basic (Basic EnAuthValue). // AsciiSPrint ( BasicWithEnAuthValue, BasicBufSize, "%a %a", "Basic", EnAuthValue ); service->basicAuthStr = BasicWithEnAuthValue; Exit: if (RawAuthValue != NULL) { ZeroMem (RawAuthValue, RawAuthBufSize); FreePool (RawAuthValue); } if (EnAuthValue != NULL) { ZeroMem (EnAuthValue, EnAuthValueSize); FreePool (EnAuthValue); } return Status; } static redfishService* createServiceEnumeratorBasicAuth(const char* host, const char* rootUri, const char* username, const char* password, unsigned int flags, void * restProtocol) { redfishService* ret; EFI_STATUS Status; ret = createServiceEnumeratorNoAuth(host, rootUri, false, flags, restProtocol); // add basic auth str Status = createBasicAuthStr (ret, username, password); if (EFI_ERROR(Status)) { cleanupServiceEnumerator (ret); return NULL; } ret->versions = getVersions(ret, rootUri); return ret; } static redfishService* createServiceEnumeratorSessionAuth(const char* host, const char* rootUri, const char* username, const char* password, unsigned int flags, void * restProtocol) { redfishService* ret; redfishPayload* payload; redfishPayload* links; json_t* sessionPayload; json_t* session; json_t* odataId; const char* uri; json_t* post; char* content; EFI_HTTP_STATUS_CODE *StatusCode; content = NULL; StatusCode = NULL; ret = createServiceEnumeratorNoAuth(host, rootUri, true, flags, restProtocol); if(ret == NULL) { return NULL; } payload = getRedfishServiceRoot(ret, NULL, &StatusCode); if(StatusCode == NULL || *StatusCode < HTTP_STATUS_200_OK || *StatusCode > HTTP_STATUS_206_PARTIAL_CONTENT) { if (StatusCode != NULL) { FreePool (StatusCode); } if (payload != NULL) { cleanupPayload(payload); } cleanupServiceEnumerator(ret); return NULL; } if (StatusCode != NULL) { FreePool (StatusCode); StatusCode = NULL; } links = getPayloadByNodeName(payload, "Links", &StatusCode); cleanupPayload(payload); if(links == NULL) { cleanupServiceEnumerator(ret); return NULL; } session = json_object_get(links->json, "Sessions"); if(session == NULL) { cleanupPayload(links); cleanupServiceEnumerator(ret); return NULL; } odataId = json_object_get(session, "@odata.id"); if(odataId == NULL) { cleanupPayload(links); cleanupServiceEnumerator(ret); return NULL; } uri = json_string_value(odataId); post = json_object(); addStringToJsonObject(post, "UserName", username); addStringToJsonObject(post, "Password", password); content = json_dumps(post, 0); json_decref(post); sessionPayload = postUriFromService(ret, uri, content, 0, NULL, &StatusCode); if (content != NULL) { ZeroMem (content, (UINTN)strlen(content)); free(content); } if(sessionPayload == NULL || StatusCode == NULL || *StatusCode < HTTP_STATUS_200_OK || *StatusCode > HTTP_STATUS_206_PARTIAL_CONTENT) { //Failed to create session! cleanupPayload(links); cleanupServiceEnumerator(ret); if (StatusCode != NULL) { FreePool (StatusCode); } if (sessionPayload != NULL) { json_decref(sessionPayload); } return NULL; } json_decref(sessionPayload); cleanupPayload(links); FreePool (StatusCode); return ret; } static char* makeUrlForService(redfishService* service, const char* uri) { char* url; if(service->host == NULL) { return NULL; } url = (char*)malloc(strlen(service->host)+strlen(uri)+1); strcpy(url, service->host); strcat(url, uri); return url; } static json_t* getVersions(redfishService* service, const char* rootUri) { json_t* ret = NULL; EFI_HTTP_STATUS_CODE* StatusCode = NULL; if(service->flags & REDFISH_FLAG_SERVICE_NO_VERSION_DOC) { service->versions = json_object(); if(service->versions == NULL) { return NULL; } addStringToJsonObject(service->versions, "v1", "/redfish/v1"); return service->versions; } if(rootUri != NULL) { ret = getUriFromService(service, rootUri, &StatusCode); } else { ret = getUriFromService(service, "/redfish", &StatusCode); } if (ret == NULL || StatusCode == NULL || *StatusCode < HTTP_STATUS_200_OK || *StatusCode > HTTP_STATUS_206_PARTIAL_CONTENT) { if (ret != NULL) { json_decref(ret); } ret = NULL; } if (StatusCode != NULL) { FreePool (StatusCode); } return ret; } static void addStringToJsonObject(json_t* object, const char* key, const char* value) { json_t* jValue = json_string(value); json_object_set(object, key, jValue); json_decref(jValue); }
28.556908
183
0.621397
[ "object" ]
77195bfbe8b4807f903f7b3183600f307953b17e
2,342
h
C
src/gui/object/ComboBox.h
Robograde/Robograde
2c9a7d0b8250ec240102d504127f5c54532cb2b0
[ "Zlib" ]
5
2015-10-11T10:22:39.000Z
2019-07-24T10:09:13.000Z
src/gui/object/ComboBox.h
Robograde/Robograde
2c9a7d0b8250ec240102d504127f5c54532cb2b0
[ "Zlib" ]
null
null
null
src/gui/object/ComboBox.h
Robograde/Robograde
2c9a7d0b8250ec240102d504127f5c54532cb2b0
[ "Zlib" ]
null
null
null
/************************************************** Zlib Copyright 2015 Isak Almgren ***************************************************/ #pragma once #include "Object.h" #include "../graphics2D/SpriteDefinition.h" #include "../graphics2D/TextDefinition.h" #include "Window.h" namespace GUI { struct ComboBoxItem { SpriteDefinition Background; TextDefinition Text; Rectangle BoundingBox; bool Visible = false; }; class ComboBox : public Object { public: ComboBox(); ComboBox( const rString& name, const rString& parent, Rectangle boundingBox ); ~ComboBox(); void Initialize(); void Update( float deltaTime, glm::ivec2 parentPos ); void Click(); void Render( glm::ivec2 parentPos ); //Getters GUI_API TextDefinition& GetTextDefinitionRef(); GUI_API SpriteDefinition& GetBackgroundRef(); GUI_API int GetSelectedIndex(); GUI_API int GetNumItems(); //Setters GUI_API void SetText( const rString& text ); GUI_API void SetTextAlignment( ALIGNMENT textAlign ); GUI_API void SetSelectedIndex( unsigned int index ); GUI_API void SetMaxShownItems( int amount ); GUI_API void SetIndex( unsigned int index ); GUI_API void SetBackgroundImage( const rString& imagePath ); GUI_API void SetItemBackgroundImage( const rString& imagePath ); GUI_API void SetColour( glm::vec4 colour ); GUI_API void SetHighLightColour( glm::vec4 colour ); GUI_API void SetClickScript( const rString& script ); GUI_API void AddItem( const rString& item ); GUI_API ComboBoxItem& GetItem( unsigned int index ); private: TextDefinition m_TextDefinition; TextDefinition m_TextShadow; rString m_Script; bool m_Hover = false; bool m_Down = false; glm::vec4 m_Colour; glm::vec4 m_HighLightColour; SpriteDefinition m_Background; SpriteDefinition m_ScrollBarBackground; SpriteDefinition m_ScrollBar; rString m_ItemTexture; int m_MaxShownItems; int m_ScrollOffset; //ComboBox specific pVector<ComboBoxItem> m_Items; Rectangle m_ItemBoxBounds; unsigned int m_SelectedIndex; bool m_IsOpen = false; bool m_KeepOpen = false; FONT_ID m_FontID; Window m_Window; }; }
24.14433
80
0.65158
[ "render", "object" ]
7719a8a4deadc08f2789a5b321cc06be8d9af9f6
6,208
h
C
Chimera/Source/DirectDigitalSynthesis/DdsCore.h
zzpwahaha/Chimera-Control-Trim
df1bbf6bea0b87b8c7c9a99dce213fdc249118f2
[ "MIT" ]
null
null
null
Chimera/Source/DirectDigitalSynthesis/DdsCore.h
zzpwahaha/Chimera-Control-Trim
df1bbf6bea0b87b8c7c9a99dce213fdc249118f2
[ "MIT" ]
null
null
null
Chimera/Source/DirectDigitalSynthesis/DdsCore.h
zzpwahaha/Chimera-Control-Trim
df1bbf6bea0b87b8c7c9a99dce213fdc249118f2
[ "MIT" ]
null
null
null
#pragma once #include "DdsSystemStructures.h" #include "DdsOutput.h" #include <GeneralObjects/Matrix.h> #include "GeneralObjects/ExpWrap.h" #include "GeneralObjects/IDeviceCore.h" #include "ConfigurationSystems/Version.h" #include "GeneralFlumes/ftdiFlume.h" #include "Scripts/ScriptStream.h" #include "ConfigurationSystems/ConfigStream.h" #include <vector> #include <array> #include "ZynqTCP/ZynqTCP.h" /* This class handles the programming of the DDS and not any of the gui elements associated with the gui system. This is a part of the DdsSystem, and is meant to be subclassed as such. It is used by the gui system itself when the user programms the dds immediately without running an experiment. It is also the only part of the DdsSystem which needs to be passed to the main experiment thread. This is part of a new attempt to better divide the gui functionality from the core functionality and have a more minimal object passed into the main experiment thread. */ struct ddsExpSettings { bool control; std::vector< ddsIndvRampListInfo> ramplist; }; class DdsCore : public IDeviceCore{ public: // THIS CLASS IS NOT COPYABLE. DdsCore& operator=(const DdsCore&) = delete; DdsCore (const DdsCore&) = delete; DdsCore ( bool safemode ); ~DdsCore ( ); ddsExpSettings getSettingsFromConfig (ConfigStream& file ); void writeRampListToConfig ( std::vector<ddsIndvRampListInfo> list, ConfigStream& file ); void programVariation ( unsigned variationNum, std::vector<parameterType>& params, ExpThreadWorker* threadworker) override; void connectasync ( ); void disconnect ( ); void writeOneRamp ( ddsRampFinFullInfo boxRamp, UINT8 rampIndex ); std::vector<ddsRampFinFullInfo> analyzeRampList ( std::vector<ddsIndvRampListInfo> rampList, unsigned variation ); void generateFullExpInfo ( unsigned numVariations ); void assertDdsValuesValid ( std::vector<parameterType>& params ); void evaluateDdsInfo ( std::vector<parameterType> params= std::vector<parameterType>()); void forceRampsConsistent ( ); void calculateVariations (std::vector<parameterType>& params, ExpThreadWorker* threadworker) override; std::string getSystemInfo ( ); void clearDdsRampMemory ( ); void manualLoadExpRampList (std::vector< ddsIndvRampListInfo> ramplist); const std::string configDelim = "DDS_SYSTEM"; std::string getDelim () override { return configDelim; } void logSettings (DataLogger& log, ExpThreadWorker* threadworker) override; void loadExpSettings (ConfigStream& stream) override; void normalFinish () override {}; void errorFinish () override {}; private: std::vector<ddsIndvRampListInfo> expRampList; ExpWrap<std::vector<ddsRampFinFullInfo>> fullExpInfo; ddsConnectionType::type connType; const unsigned MSGLENGTH = 7; const unsigned char WBWRITE = (unsigned char) 161; const unsigned char WBWRITE_ARRAY = (unsigned char) 2; //Add 2 to WBWRITE const double INTERNAL_CLOCK = ( double ) 500.0; //Internal clock in MHz const UINT16 RESET_FREQ_ADDR_OFFSET = 0x0; const UINT16 RESET_AMP_ADDR_OFFSET = 0x100; const UINT16 REPS_ADDRESS_OFFSET = 0x200; const UINT16 RAMP_CHANNEL_ADDR_SPACING = 0x200; const UINT16 RAMP_FREQ_ADDR_OFFSET = 0x400; const UINT16 RAMP_AMP_ADDR_OFFSET = 0x1400; ftdiFlume ftFlume; const double defaultFreq = 10; const double defaultAmp = 100; void longUpdate ( ); void lockPLLs ( ); // get (frequency/amplitude) ? word std::array<UINT8, 4> intTo4Bytes ( int i_ ); void writeDDS ( UINT8 DEVICE, UINT16 ADDRESS, std::array<UINT8, 4> data ); INT getFTW ( double freq ); unsigned getATW ( double amp ); UINT16 getRepsFromTime ( double time ); INT get32bitATW ( double amp ); void channelSelect ( UINT8 device, UINT8 channel ); void writeAmpMultiplier ( UINT8 device ); void writeResetFreq ( UINT8 device, UINT8 channel, double freq ); void writeResetAmp ( UINT8 device, UINT8 channel, double amp ); void writeRampReps ( UINT8 index, UINT16 reps ); void writeRampDeltaFreq ( UINT8 device, UINT8 channel, UINT8 index, double deltafreq ); void writeRampDeltaAmp ( UINT8 device, UINT8 channel, UINT8 index, double deltaamp ); void writeDDS ( UINT8 device, UINT16 address, UINT8 dat1, UINT8 dat2, UINT8 dat3, UINT8 dat4 ); public: bool isValidDDSName(std::string name); int getDDSIdentifier(std::string name); std::string getName(int ddsNumber); std::array<std::string, size_t(DDSGrid::total)> getName(); void setNames(std::array<std::string, size_t(DDSGrid::total)> namesIn); void resetDDSEvents(); void initializeDataObjects(unsigned variationNum); void setDDSCommandForm(DdsCommandForm command); void handleDDSScriptCommand(DdsCommandForm command, std::string name, std::vector<parameterType>& vars); void calculateVariations(std::vector<parameterType>& variables, ExpThreadWorker* threadworker, std::vector<calResult> calibrations); void organizeDDSCommands(UINT variation); void makeFinalDataFormat(UINT variation); void standardExperimentPrep(UINT variation); void writeDDSs(UINT variation, bool loadSkip); void setGUIDdsChange(std::vector<std::vector<DdsChannelSnapshot>> channelSnapShot); private: std::array<std::string, size_t(DDSGrid::total)> names; //std::array <const double, 2> ddsResolution; std::vector<DdsCommandForm> ddsCommandFormList; // the first vector is for each variation. std::vector<std::vector<DdsCommand>> ddsCommandList; std::vector<std::vector<DdsSnapshot>> ddsSnapshots; std::vector<std::vector<DdsChannelSnapshot>> ddsChannelSnapshots; std::vector<std::pair<double, std::vector<DdsCommand>>> timeOrganizer; ZynqTCP zynq_tcp; public: constexpr static double ddsFreqResolution = DdsOutput::ddsFreqResolution; // 500.0 / 0xffffffff; /*32bit, 500MHz clock freq*/ constexpr static double ddsAmplResolution = DdsOutput::ddsAmplResolution; // 10.0 / 0x3ff; /*10bit dac 0b1111111111, 10mA max dac current*/ const int numFreqDigits = static_cast<int>(abs(round(log10(ddsFreqResolution) - 0.49))); const int numAmplDigits = static_cast<int>(abs(round(log10(ddsAmplResolution) - 0.49))); //constexpr static double DDS_TIME_RESOLUTION = 1.6;/*temporary, should be fixed after felix update the dac trigger*/ };
41.112583
140
0.764497
[ "object", "vector" ]
7719dfc4247e1e7c245ca3117fa805f3a3d68d2a
3,612
h
C
src/Connection/SerialPort/Client/QBtSerialPortClient_symbian.h
ftylitak/QBluetoothZero
3e4a018a5e62705b62fa2cbc64a27c3f66059982
[ "Apache-2.0" ]
2
2018-02-05T13:22:49.000Z
2019-01-19T12:04:20.000Z
src/Connection/SerialPort/Client/QBtSerialPortClient_symbian.h
ftylitak/QBluetoothZero
3e4a018a5e62705b62fa2cbc64a27c3f66059982
[ "Apache-2.0" ]
1
2018-02-04T18:37:50.000Z
2018-02-05T23:16:31.000Z
src/Connection/SerialPort/Client/QBtSerialPortClient_symbian.h
ftylitak/QBluetoothZero
3e4a018a5e62705b62fa2cbc64a27c3f66059982
[ "Apache-2.0" ]
3
2018-05-24T02:35:43.000Z
2019-02-28T16:38:52.000Z
/* * QBtSerialPortClient_symbian.h * * * Author: Ftylitakis Nikolaos, Luis Valente * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #ifndef QBTSERIALPORTCLIENT_SYMBIAN_H_ #define QBTSERIALPORTCLIENT_SYMBIAN_H_ #include "QBtSerialPortClient.h" #include <QTimer.h> #include <e32base.h> #include <es_sock.h> #include <btdevice.h> #include <bt_sock.h> class QBtSerialPortClientPrivate : public CActive { public: /*! * NewL() * * Create new QBtSerialPortClientPrivate object * return a pointer to the created instance of QBtSerialPortClientPrivate */ static QBtSerialPortClientPrivate* NewL(QBtSerialPortClient* publicClass); /*! * NewLC() * */ static QBtSerialPortClientPrivate* NewLC(QBtSerialPortClient* publicClass); /*! * ~QBtSerialPortClientPrivate() * * Destroy the object and release all memory objects */ ~QBtSerialPortClientPrivate(); /*! * ConnectL() * * Creates a connection to given remote address on given port. * * param aName the name of the slave to connect to. * param aAddr the address of the slave to connect to. * param aPort the port on slave to connect to. * * return the status of connection attempt */ TBool ConnectL(const QBtDevice& remoteDevice, const QBtService& remoteService); /*! * Disconnect() * * Disconnects connector from slave. */ void Disconnect(); /*! * SendDataL() * * Sends given data to slave. * * param aData the message to send to slave. */ void SendData(const QString& data); void SendData(const QByteArray& data); /*! * IsConnected() * * return the connection state */ TBool IsConnected(); protected: /*! * RunL() * * Handle the active objects request completion. */ void RunL(); /*! * DoCancel() * * Cancels the outstanding request on active object. */ void DoCancel(); private: /*! * QBtSerialPortClientPrivate() * * Perform the first phase of two phase construction * * @param the qt public class */ QBtSerialPortClientPrivate(QBtSerialPortClient* publicClass); /*! * ConstructL() * */ void ConstructL(); /*! * ReceiveData() * * Wait for and receive data from slave. */ void ReceiveData(); private: static TInt ConnectTimerCallBack (TAny* aPtr); void StartConnectionTimer(); void CancelConnectionTimer(); private: // data // remote device QBtDevice device; // remote service QBtService service; // connecting socket RSocket iSock; // buffer holding received data TBuf8<128> iBuffer; // length of received data TSockXfrLength iLen; // socket server handle RSocketServ iSocketServ; // the state of the connector enum TState { ENone = 1, EIdle, EConnecting, EDisconnecting, EWaiting, ESending }; TState iState; QBtSerialPortClient* p_ptr; CPeriodic* iTimer; TBTSockAddr _addr; HBufC8* iMessage; }; #endif /* QBTSERIALPORTCLIENT_SYMBIAN_H_ */
20.178771
81
0.665006
[ "object" ]
77238793d67a1236643fcf6bb91b537f0222bb17
2,568
h
C
device/bluetooth/test/fake_bluetooth_le_manufacturer_data_winrt.h
sarang-apps/darshan_browser
173649bb8a7c656dc60784d19e7bb73e07c20daa
[ "BSD-3-Clause-No-Nuclear-License-2014", "BSD-3-Clause" ]
575
2015-06-18T23:58:20.000Z
2022-03-23T09:32:39.000Z
device/bluetooth/test/fake_bluetooth_le_manufacturer_data_winrt.h
sarang-apps/darshan_browser
173649bb8a7c656dc60784d19e7bb73e07c20daa
[ "BSD-3-Clause-No-Nuclear-License-2014", "BSD-3-Clause" ]
113
2015-05-04T09:58:14.000Z
2022-01-31T19:35:03.000Z
device/bluetooth/test/fake_bluetooth_le_manufacturer_data_winrt.h
sarang-apps/darshan_browser
173649bb8a7c656dc60784d19e7bb73e07c20daa
[ "BSD-3-Clause-No-Nuclear-License-2014", "BSD-3-Clause" ]
52
2015-07-14T10:40:50.000Z
2022-03-15T01:11:49.000Z
// Copyright 2018 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #ifndef DEVICE_BLUETOOTH_TEST_FAKE_BLUETOOTH_LE_MANUFACTURER_DATA_WINRT_H_ #define DEVICE_BLUETOOTH_TEST_FAKE_BLUETOOTH_LE_MANUFACTURER_DATA_WINRT_H_ #include <windows.devices.bluetooth.advertisement.h> #include <wrl/client.h> #include <wrl/implements.h> #include <stdint.h> #include <vector> #include "base/macros.h" namespace device { class FakeBluetoothLEManufacturerData : public Microsoft::WRL::RuntimeClass< Microsoft::WRL::RuntimeClassFlags< Microsoft::WRL::WinRt | Microsoft::WRL::InhibitRoOriginateError>, ABI::Windows::Devices::Bluetooth::Advertisement:: IBluetoothLEManufacturerData> { public: FakeBluetoothLEManufacturerData(uint16_t company_id, std::vector<uint8_t> data); FakeBluetoothLEManufacturerData( uint16_t company_id, Microsoft::WRL::ComPtr<ABI::Windows::Storage::Streams::IBuffer> data); ~FakeBluetoothLEManufacturerData() override; // IBluetoothLEManufacturerData: IFACEMETHODIMP get_CompanyId(uint16_t* value) override; IFACEMETHODIMP put_CompanyId(uint16_t value) override; IFACEMETHODIMP get_Data( ABI::Windows::Storage::Streams::IBuffer** value) override; IFACEMETHODIMP put_Data( ABI::Windows::Storage::Streams::IBuffer* value) override; private: uint16_t company_id_; Microsoft::WRL::ComPtr<ABI::Windows::Storage::Streams::IBuffer> data_; DISALLOW_COPY_AND_ASSIGN(FakeBluetoothLEManufacturerData); }; class FakeBluetoothLEManufacturerDataFactory : public Microsoft::WRL::RuntimeClass< Microsoft::WRL::RuntimeClassFlags< Microsoft::WRL::WinRt | Microsoft::WRL::InhibitRoOriginateError>, ABI::Windows::Devices::Bluetooth::Advertisement:: IBluetoothLEManufacturerDataFactory> { public: FakeBluetoothLEManufacturerDataFactory(); ~FakeBluetoothLEManufacturerDataFactory() override; // IBluetoothLEManufacturerDataFactory: IFACEMETHODIMP Create(uint16_t company_id, ABI::Windows::Storage::Streams::IBuffer* data, ABI::Windows::Devices::Bluetooth::Advertisement:: IBluetoothLEManufacturerData** value) override; private: DISALLOW_COPY_AND_ASSIGN(FakeBluetoothLEManufacturerDataFactory); }; } // namespace device #endif // DEVICE_BLUETOOTH_TEST_FAKE_BLUETOOTH_LE_MANUFACTURER_DATA_WINRT_H_
35.666667
79
0.73715
[ "vector" ]
77268725ce3c9f71c429fcef978e5c6cfe9560b5
628
h
C
inc/movelist.h
jsusaki/schess
5778a8404daa3c4c99d6ab633acb046a61b9ca53
[ "MIT" ]
1
2020-12-16T20:51:59.000Z
2020-12-16T20:51:59.000Z
inc/movelist.h
jsusaki/schess
5778a8404daa3c4c99d6ab633acb046a61b9ca53
[ "MIT" ]
null
null
null
inc/movelist.h
jsusaki/schess
5778a8404daa3c4c99d6ab633acb046a61b9ca53
[ "MIT" ]
null
null
null
#pragma once #include <iostream> #include <vector> #include "move.h" class MoveList { public: friend std::ostream& operator << (std::ostream &os, const MoveList &moves); MoveList() { m_moveList.reserve(100); } void push_back(const Move& move) { m_moveList.push_back(move); } void clear() { m_moveList.clear(); } unsigned int size() const { return m_moveList.size(); } const Move & operator [] (unsigned int ix) const { return m_moveList[ix]; } private: std::vector<Move> m_moveList; };
16.526316
80
0.552548
[ "vector" ]
772ac79634ac1015120dbcab77fd8f00d3f7aa8e
1,150
h
C
CMinus/CMinus/declaration/function_declaration_group.h
benbraide/CMinus
3b845e0bc22840b549f108bf6600f1f34d865e7b
[ "MIT" ]
null
null
null
CMinus/CMinus/declaration/function_declaration_group.h
benbraide/CMinus
3b845e0bc22840b549f108bf6600f1f34d865e7b
[ "MIT" ]
null
null
null
CMinus/CMinus/declaration/function_declaration_group.h
benbraide/CMinus
3b845e0bc22840b549f108bf6600f1f34d865e7b
[ "MIT" ]
null
null
null
#pragma once #include "function_declaration.h" namespace cminus::declaration{ class function_group : public function_group_base{ public: function_group(std::string name, logic::naming::parent *parent); virtual ~function_group(); virtual const logic::attributes::collection &get_attributes() const override; virtual void add(std::shared_ptr<function_base> value) override; virtual void replace(function_base &existing_entry, std::shared_ptr<function_base> new_entry) override; virtual function_base *find(logic::runtime &runtime, const function_base &tmpl) const override; virtual function_base *get_highest_ranked(logic::runtime &runtime, std::shared_ptr<memory::reference> context, const std::vector<std::shared_ptr<memory::reference>> &args, std::size_t *count) const override; virtual std::shared_ptr<memory::reference> call(logic::runtime &runtime, std::shared_ptr<memory::reference> context, const std::vector<std::shared_ptr<memory::reference>> &args) const override; protected: cminus::logic::attributes::collection attributes_; std::unordered_map<function_base *, std::shared_ptr<function_base>> list_; }; }
39.655172
209
0.77913
[ "vector" ]
7730b9e6cc4cc3cbfa7e2858dcd9fc214c139134
12,097
c
C
nitan/quest/quest1/robber.c
cantona/NT6
073f4d491b3cfe6bfbe02fbad12db8983c1b9201
[ "MIT" ]
1
2019-03-27T07:25:16.000Z
2019-03-27T07:25:16.000Z
nitan/quest/quest1/robber.c
cantona/NT6
073f4d491b3cfe6bfbe02fbad12db8983c1b9201
[ "MIT" ]
null
null
null
nitan/quest/quest1/robber.c
cantona/NT6
073f4d491b3cfe6bfbe02fbad12db8983c1b9201
[ "MIT" ]
null
null
null
// 劫鏢NPC // Updated by Lonely inherit CLASS_D("generate") + "/chinese"; #include <ansi.h> #define DIAM_DIR "/clone/tessera/" int do_nod(string arg); int do_fkill(object ob); string *SM_LIST = ({ "rune01", "rune02", "rune03", "rune04", "rune05", "rune06", "rune07", "rune08", "rune09", "rune10", }); void create() { mapping my; int lvl; ::create(); set("gender", "男性" ); set("nickname", "劫匪"); set("age", 30 + random(30)); set("long", ""); set("attitude", "friendly"); set("chat_chance", 30); set("scale", 150); set_temp("apply/armor", 100); set_temp("apply/damage", 50); set_temp("born_time", time()); lvl = 2 + random(2); NPC_D->init_npc_skill(this_object(), lvl); // 初始化NPC的能力 my = query_entire_dbase(); my["max_qi"] = 1000 + lvl * 300 + random(500); my["max_jing"] = my["max_qi"] / 2; my["max_neili"] = 1000 + lvl * 500 + random(500); my["eff_jing"] = my["max_jing"]; my["jing"] = my["max_jing"]; my["eff_qi"] = my["max_qi"]; my["qi"] = my["max_qi"]; my["neili"] = my["max_neili"] * 2; setup(); if (clonep()) keep_heart_beat(); } /* void check_room() { object me = this_object(); object env = environment(me); if (! living(me)) return; if( env && (query("no_quest", env) || query("no_fight", env) || function_exists( "valid_leave", env))) "/cmds/std/go.c"->do_back(me); } */ void init() { object ob,env; object killer = this_object(); string area; add_action("do_nod", "nod"); add_action("do_nod", "好的"); if( !query("area", killer) && !query("found", killer) ) { env = environment(killer); if (objectp(env) && sscanf(file_name(env), "/d/%s/", area) == 1) set("area", area, killer); } ob = this_player(); if( !query("want_kill", this_object()) ) return; if( query("id", ob) == query("want_kill") ) { delete("area"); set("found", 1); } if( query("id", ob) == query("want_kill") ) if (! is_fighting()) { remove_call_out("check_me"); call_out("check_me", 0); } if( query("want_kill", this_object()) != query("id", ob) ) { add_action("do_kill", "team kill"); add_action("do_kill", "touxi"); add_action("do_kill", "kill"); add_action("do_kill", "hit"); add_action("do_kill", "fight"); add_action("do_kill", "steal"); add_action("do_kill", "beg"); add_action("do_kill", "persuade"); } } // 如果接受了賄賂 int do_nod(string arg) { object me = this_player(); object ob = this_object(), obj; int amount; if( !query_temp("lonely/waiting", me) || !arg || arg != query("id", ob) ) return 0; else { me->command("nod"); if( intp(query_temp("lonely/waiting", me)) ) { if( query_temp("lonely/diamond", me) ) { message_vision(HIW "只見$N" HIW "長笑三聲:“哈哈哈,識時務者為俊傑," + RANK_D->query_respect(me) + "果然是明白人,嘿嘿,這區區小寶石" + "就歸你了,哈哈。”\n\n" NOR, ob, me); obj = new(DIAM_DIR + SM_LIST[random(sizeof(SM_LIST))]); tell_object(me, HIR + ob->name() + "遞給了你" + obj->name() + HIR "以後,吐出一口鮮血,揚長而去。\n" NOR); obj->move(me, 1); delete_temp("lonely", me); remove_call_out("escape_me"); remove_call_out("check_me"); destruct(ob); return 1; } amount=query_temp("lonely/waiting", me); message_vision(HIW "只見$N" HIW "長笑三聲:“哈哈哈,識時務者為俊傑," + RANK_D->query_respect(me) + "果然是明白人,嘿嘿,這區區" + chinese_number(amount) + "兩白銀就歸你了,哈哈。”\n\n" NOR, ob, me); // 因為是“兩”為單位,所以要 * 100。 MONEY_D->pay_player(me, amount * 100); tell_object(me, HIR + ob->name() + "遞給了你" + chinese_number(amount) + "兩白銀以後,吐出一口鮮血,揚長而去。\n" NOR ); delete_temp("lonely", me); remove_call_out("escape_me"); remove_call_out("check_me"); destruct(ob); return 1; } else return 0; } } int check_me() { object ob, me = this_object(); if( objectp(ob=present(query("want_kill", me),environment(me)) ) && !query("no_fight", environment(me) ) && interactive(ob) && ! ob->is_fighting(me)) do_fkill(ob); if (! ob) { remove_call_out("escape_me"); destruct(me); return 1; } call_out("check_me", 2); return 1; } int do_fkill(object ob) { if( !query_temp("lonely/waiting", this_object()) ) { if (living(this_object())) message_sort(HIR "$N大喝道:“此山是我開,此樹是我栽!" + query("name", ob)+"識相的話,就把紅貨都交出來!\n"NOR, this_object()); this_object()->kill_ob(ob); ob->kill_ob(this_object()); } return 1; } void start_escape(object ob,object me) { call_out("escape_me", 180, ob, me); } int do_kill(string arg) { string what, who; if (! arg) return 0; if (this_object()->id(arg)) { write("江湖人士,還是少惹為妙。\n"); return 1; } else if (sscanf(arg, "%s from %s", what, who) == 2 && this_object()->id(who)) { write("還是到別處去施展你的本事吧。\n"); return 1; } return 0; } void escape_me(object ob,object me) { message_vision( "$N獰笑了幾聲:“今天心情好," + RANK_D->query_self_rude(ob) + "就放過你,不陪你玩了。”説罷,一個筋斗跳出戰圈,不知去向。\n", ob); destruct(ob); } void unconcious() { object me, ob = this_object(); int amount = 300 + random(300); string *condition = ({ "氣喘吁吁,就要不支", "頭重腳輕,馬上就倒", "嘔血成升,眼冒金星", "傷痕累累,無力招架", }); if (objectp(me = query_last_damage_from()) && environment() == environment(me) && !query_temp("lonely/waiting", me) ) { switch (random(15)) { case 1: { message_vision(HIR "眼見$N" HIR + condition[random(sizeof(condition))] +",突然$N大喝一聲,急退幾步,\n“撲通”給$n跪了下來。" "\n" NOR, ob, me); tell_object(me, HIW + ob->name() + "突然從懷裏掏出一堆白花花的銀子,小聲" "對你道:“這位" + RANK_D->query_respect(me) + ",\n你" "就網開一面(nod)如何,這" + chinese_number(amount) + "兩白銀就歸你了!”\n" NOR); remove_all_enemy(0); set("qi", 1, ob); set("jing", 1, ob); set("jingli", 1, ob); set_temp("lonely/waiting", amount, ob); set_temp("lonely/waiting", amount, me); return; } case 2: { message_vision(HIR "眼見$N" HIR + condition[random(sizeof(condition))] +",突然$N大喝一聲,急退幾步,\n“撲通”給$n跪了下來。" "\n" NOR, ob, me); tell_object(me, HIW + ob->name() + "突然從懷裏掏出一塊寶石,小聲" "對你道:“這位" + RANK_D->query_respect(me) + ",\n你" "就網開一面(nod)如何,這寶石就歸你了!”\n" NOR); remove_all_enemy(0); set("qi", 1, ob); set("jing", 1, ob); set("jingli", 1, ob); set_temp("lonely/waiting", amount, ob); set_temp("lonely/waiting", amount, me); set_temp("lonely/diamond", 1, me); return; } default: { // 獎勵 ::unconcious(); return; } } } if (objectp(me)) delete_temp("lonely", me); ::unconcious(); } varargs void die(object killer) { mixed reward_exp, reward_pot; object killer1, me; me = this_object(); if (! killer) killer = query_last_damage_from(); if (objectp(killer)) killer1=find_player(query("want_kill", me)); message_vision(HIC"$N慘嚎一聲,口噴鮮血,到在地上死了。\n"NOR,me); if (killer1) { if( query("id", killer) == query("want_kill", me) ) { /* // reward_exp = atoi(count_div(me->query("combat_exp"), 50000)); // reward_exp = count_div(me->query("combat_exp"), 50000); // if (killer->query("combat_exp") < 2000000) // if (count_lt(killer->query("combat_exp"), 2000000)) reward_exp -= reward_exp / 5; if (count_gt(reward_exp,100)) reward_exp = 100; */ reward_exp = 80 + random(70); reward_pot = reward_exp / 3; if (! userp(killer1)) { reward_exp = reward_exp / 10; reward_pot = reward_exp / 10; } if (reward_pot < 0) reward_pot = 0; tell_object(killer1, HIM "恭喜你又成功解決一名劫匪!\n" NOR + HIW "在實戰中,你獲得了" + CHINESE_D->chinese_number(reward_exp) + "點的『實戰經驗』" + CHINESE_D->chinese_number(reward_pot) + "點的『潛能』和一些實戰體會!\n" NOR); addn("quest_yunbiao/reward_exp", reward_exp, killer1); addn("quest_yunbiao/reward_potential", reward_pot, killer1); addn("combat_exp", reward_exp, killer1); addn("experience", random(2), killer1); addn("potential", reward_pot, killer1); addn("score", random(25), killer1); delete_temp("lonely", killer1); } } remove_call_out("escape_me"); remove_call_out("check_me"); ::die(); return; }
35.165698
100
0.395966
[ "object" ]
77327d4c5d2ece503c3902ab05a925ff8233118b
2,003
h
C
parser/workflow_parser.h
kirpichik/Workflow
01ded261c4d347db662fcd71c075e1766e712916
[ "MIT" ]
13
2017-12-07T08:23:24.000Z
2022-03-22T15:12:37.000Z
parser/workflow_parser.h
kirpichik/Workflow
01ded261c4d347db662fcd71c075e1766e712916
[ "MIT" ]
null
null
null
parser/workflow_parser.h
kirpichik/Workflow
01ded261c4d347db662fcd71c075e1766e712916
[ "MIT" ]
null
null
null
// // workflow_parser.h // Workflow // // Created by Кирилл on 25.11.17. // Copyright © 2017 Кирилл. All rights reserved. // #ifndef WORKFLOW_PARSER_H_ #define WORKFLOW_PARSER_H_ #include <exception> #include <map> #include <string> #include <vector> #include "lexer.h" #include "parser.hpp" #include "parser_types.h" #include "worker.h" namespace wkfw { /** * Бросается при любых ошибках разбора Workflow. */ class InvalidWorkflowException : public std::exception { public: InvalidWorkflowException(const std::string& desc) : reason(desc) {} const char* what() const throw() override { return reason.c_str(); } private: const std::string reason; }; /** * Разбирает, проверяет на валидность и хранит описание Workflow. */ class WorkflowParser { public: WorkflowParser(std::istream& stream) throw(InvalidWorkflowException); /** * Получает обработчик по его уникальному номеру. * * @param ident Уникальный номер обработчика. * * @return Обработчик по его номеру или nullptr, * если обработчика с данным номером не существует. */ const Worker* getWorkerById(const size_t ident) const; /** * @return Следующая инструкция для исполнения Workflow. */ const Worker* nextInstruction(); /** * Сбрасывает счетчик шагов в начало. */ void resetSteps(); WorkflowParser(); friend class FlexWorkflowLexer; friend class BisonWorkflowParser; private: std::map<size_t, const Worker*> description; std::vector<size_t> instructions; size_t position = 0; std::string errorMsg; /** * Проверяет валидность команды и запоминает ее. * * @param cmd Команда */ void receiveCommand(const WorkflowCommand& cmd) throw( InvalidWorkflowException); /** * Запоминает инструкцию/ */ void receiveInstruction(const size_t num); /** * Бросает исключение из парсера. */ void receiveError(const std::string& msg) throw(InvalidWorkflowException); }; } // namespace wkfw #endif /* WORKFLOW_PARSER_H_ */
20.438776
76
0.701448
[ "vector" ]
77407da2ed7b643279f7e46ee8bed1f74fb36986
583
h
C
src/yamlizer/from_yaml.h
Tosainu/yamlizer
4709825da38af385d1a92667398ab676c1c968da
[ "MIT" ]
null
null
null
src/yamlizer/from_yaml.h
Tosainu/yamlizer
4709825da38af385d1a92667398ab676c1c968da
[ "MIT" ]
null
null
null
src/yamlizer/from_yaml.h
Tosainu/yamlizer
4709825da38af385d1a92667398ab676c1c968da
[ "MIT" ]
null
null
null
#ifndef YAMLIZER_FROM_YAML_H #define YAMLIZER_FROM_YAML_H #include <string_view> #include <vector> #include "detail/read_value.h" #include "yaml++.h" namespace yamlizer { template <class T> T from_yaml(std::string_view yaml) { parser p{yaml}; std::vector<token> ts{}; for (auto prev_token = ::YAML_NO_TOKEN; prev_token != ::YAML_STREAM_END_TOKEN;) { auto t = p.scan(); prev_token = t.type(); ts.emplace_back(std::move(t)); } return std::get<0>(detail::read_value<T>(ts.cbegin(), ts.cend())); } } // namespace yamlizer #endif // YAMLIZER_FROM_YAML_H
20.103448
83
0.684391
[ "vector" ]
7741a675da7b1c5683fe55b05656e8b99dc30871
8,373
h
C
include/corridor/basic_types.h
m-naumann/corridor
2acfdf5781d4fc107a32baf6ef372800a741d2aa
[ "BSD-3-Clause" ]
4
2021-03-24T22:31:48.000Z
2021-12-06T10:41:48.000Z
include/corridor/basic_types.h
m-naumann/corridor
2acfdf5781d4fc107a32baf6ef372800a741d2aa
[ "BSD-3-Clause" ]
4
2021-04-16T13:44:35.000Z
2021-05-25T09:22:54.000Z
include/corridor/basic_types.h
m-naumann/corridor
2acfdf5781d4fc107a32baf6ef372800a741d2aa
[ "BSD-3-Clause" ]
3
2021-04-16T14:31:43.000Z
2021-07-01T15:07:51.000Z
#pragma once #include <Eigen/Core> #include <Eigen/Geometry> #include <boost/optional.hpp> #include <cmath> #include <iostream> #include <memory> #include <vector> namespace corridor { // ///////////////////////////////////////////////////////////////////////////// // Basic types // ///////////////////////////////////////////////////////////////////////////// using IdType = int64_t; constexpr IdType InvalidId = -1; using Ids = std::vector<IdType>; using IdxType = size_t; using RealType = double; // Currently double, lets find a better representation later using TimeStampType = double; constexpr TimeStampType InvalidTimeStamp = -1; // To be replaced by std::optional once c++17 is established template <typename T> using Optional = boost::optional<T>; /** * @brief Limits the value x to the interval [u,o] or [o,u], depending on which * of both limits is greater. * * @tparam T: typename * @param x: value * @param u: first limit * @param o: second limit * @return T: constrained value */ template <typename T> inline T limit(const T x, const T u, const T o) { return (o >= u) ? ((x <= o) ? ((x >= u) ? x : u) : o) : ((x <= u) ? ((x >= o) ? x : o) : u); }; /** * @brief Constraints the provided angle between -pi and pi * * @param angle: unconstrained angle * @return RealType: constrained angle */ inline RealType constrainAngle(RealType angle) { static const RealType two_pi = 2 * M_PI; angle = std::fmod(angle + M_PI, two_pi); if (angle < 0.0) { angle += two_pi; } return angle - M_PI; } // TODO: template! struct UncertainValue { RealType variance() const { return standard_deviation * standard_deviation; } RealType value; // mean value RealType standard_deviation; UncertainValue(const RealType _value = 0.0, const RealType _standard_deviation = 1e-12) : value(_value), standard_deviation(_standard_deviation) {} UncertainValue operator+(const UncertainValue &other) const { return UncertainValue(this->value + other.value, std::sqrt(this->variance() + other.variance())); } UncertainValue operator-(const UncertainValue &other) const { return UncertainValue(this->value - other.value, std::sqrt(this->variance() + other.variance())); } UncertainValue operator*(const RealType factor) const { return UncertainValue(this->value * factor, std::sqrt(this->variance()) * factor); } }; // // Commutative property of the multiplication operator // UncertainValue operator*(const RealType factor, const UncertainValue &uv) { // return uv * factor; // } // introspection inline std::ostream &operator<<(std::ostream &os, const UncertainValue &uv) { os << "value = " << uv.value << "; variance = " << uv.variance(); return os; }; // TODO: maybe add more functionality later and make it an orientated bounding // box if needed. using AlignedBoundingBox2D = Eigen::AlignedBox<RealType, 2>; // ///////////////////////////////////////////////////////////////////////////// // Basic 2D point and vector // ///////////////////////////////////////////////////////////////////////////// struct BasicPoint2D : public Eigen::Matrix<RealType, 2, 1, Eigen::DontAlign> { BasicPoint2D(void) : Eigen::Matrix<RealType, 2, 1, Eigen::DontAlign>() { this->fill(0.0); } BasicPoint2D(const RealType x, const RealType y) { (*this) << x, y; } typedef Eigen::Matrix<RealType, 2, 1, Eigen::DontAlign> Base; // This constructor allows you to construct BasicPoint2D from Eigen // expressions template <typename OtherDerived> BasicPoint2D(const Eigen::MatrixBase<OtherDerived> &other) : Eigen::Matrix<RealType, 2, 1, Eigen::DontAlign>(other) {} // This method allows you to assign Eigen expressions to CartesianPoint2D template <typename OtherDerived> BasicPoint2D &operator=(const Eigen::MatrixBase<OtherDerived> &other) { this->Base::operator=(other); return *this; } }; /** * @brief Vector is a direction, point a position (with respect to a origin) */ using BasicVector2D = BasicPoint2D; // ///////////////////////////////////////////////////////////////////////////// // Uncertainty state representation with mean and covariance matrix // ///////////////////////////////////////////////////////////////////////////// // TODO: template this structure and the whole UT functions struct StateMeanAndCovarianceMatrix { StateMeanAndCovarianceMatrix(const int state_dim = 0) : mean(Eigen::VectorXd(state_dim)), covMat(Eigen::MatrixXd(state_dim, state_dim)) { mean.fill(0.0); covMat.fill(0.0); } StateMeanAndCovarianceMatrix(const Eigen::VectorXd &_mean, const Eigen::MatrixXd &_covMat) : mean(_mean), covMat(_covMat) {} Eigen::VectorXd mean; Eigen::MatrixXd covMat; }; // Introspection inline std::ostream &operator<<(std::ostream &os, const StateMeanAndCovarianceMatrix &state) { os << "StateMeanAndCovarianceMatrix\n"; os << "mean: " << state.mean.transpose() << "\n"; os << state.covMat; return os; } // ///////////////////////////////////////////////////////////////////////////// // Polar 2D coordinates and covariance matrix // ///////////////////////////////////////////////////////////////////////////// struct PolarVector2D : public BasicPoint2D { PolarVector2D(void) : BasicPoint2D() {} PolarVector2D(const RealType abs_value, const RealType orientation) : BasicPoint2D(abs_value, constrainAngle(orientation)) {} // This constructor allows you to construct FrenetPoint2D from Eigen // expressions template <typename OtherDerived> PolarVector2D(const Eigen::MatrixBase<OtherDerived> &other) : BasicPoint2D(other) {} typedef Eigen::Matrix<RealType, 2, 1, Eigen::DontAlign> Base; // This method allows you to assign Eigen expressions to FrenetPoint2D template <typename OtherDerived> PolarVector2D &operator=(const Eigen::MatrixBase<OtherDerived> &other) { this->Base::operator=(other); return *this; } // Easy access to the polar coordinates const RealType abs_value() const { return (*this)[0]; } const RealType orientation() const { return (*this)[1]; } RealType &abs_value() { return (*this)[0]; } RealType &orientation() { return (*this)[1]; } }; struct PolarCovarianceMatrix2D : public Eigen::Matrix<RealType, 2, 2, Eigen::DontAlign> { PolarCovarianceMatrix2D(const RealType var_abs_value = 1e-12, const RealType var_orientation = 1e-12, const RealType cov_value_orientation = 0.0) { (*this) << var_abs_value, cov_value_orientation, cov_value_orientation, var_orientation; } using Base = Eigen::Matrix<RealType, 2, 2, Eigen::DontAlign>; // This constructor allows you to construct CovarianceMatrix2D from Eigen // expressions template <typename OtherDerived> PolarCovarianceMatrix2D(const Eigen::MatrixBase<OtherDerived> &other) : Eigen::Matrix<RealType, 2, 2, Eigen::DontAlign>(other) {} // This method allows you to assign Eigen expressions to CovarianceMatrix2D template <typename OtherDerived> PolarCovarianceMatrix2D &operator=( const Eigen::MatrixBase<OtherDerived> &other) { this->Base::operator=(other); return *this; } // Non-mutable views const RealType var_abs_value() const { return (*this)(0, 0); } const RealType var_orientation() const { return (*this)(1, 1); } const RealType cov_value_orientation() const { return (*this)(0, 1); } }; struct PolarState2D { PolarVector2D mean; PolarCovarianceMatrix2D cov_mat; // Easy access functions: // marginalization of absolute value UncertainValue abs_value() const { return {mean.abs_value(), std::sqrt(cov_mat.var_abs_value())}; } // marginalization of orientation angle UncertainValue orientation() const { return {mean.orientation(), std::sqrt(cov_mat.var_orientation())}; } }; using PolarStatePtr = std::shared_ptr<PolarState2D>; // Introspection inline std::ostream &operator<<(std::ostream &os, const PolarStatePtr state) { using namespace std; os << "Polar State Vector (|r|, phi): "; os << state->mean.transpose() << "\n"; os << "Polar State CovMat:\n"; os << state->cov_mat << "\n"; return os; }; } // namespace corridor
33.22619
80
0.630957
[ "geometry", "vector" ]