|
My Project
|
A collection of Symbol objects within a single (namespace or functional) scope. More...
#include <database.hh>
Public Member Functions | |
| Scope (const string &nm, Architecture *g) | |
| Construct an empty scope, given a name and Architecture. | |
| virtual | ~Scope (void) |
| Destructor. | |
| virtual MapIterator | begin (void) const =0 |
| Beginning iterator to mapped SymbolEntrys. | |
| virtual MapIterator | end (void) const =0 |
| Ending iterator to mapped SymbolEntrys. | |
| virtual list< SymbolEntry >::const_iterator | beginDynamic (void) const =0 |
| Beginning iterator to dynamic SymbolEntrys. | |
| virtual list< SymbolEntry >::const_iterator | endDynamic (void) const =0 |
| Ending iterator to dynamic SymbolEntrys. | |
| virtual list< SymbolEntry >::iterator | beginDynamic (void)=0 |
| Beginning iterator to dynamic SymbolEntrys. | |
| virtual list< SymbolEntry >::iterator | endDynamic (void)=0 |
| Ending iterator to dynamic SymbolEntrys. | |
| virtual void | clear (void)=0 |
| Clear all symbols from this scope. | |
| virtual void | clearCategory (int4 cat)=0 |
| Clear all symbols of the given category from this scope. | |
| virtual void | clearUnlocked (void)=0 |
| Clear all unlocked symbols from this scope. | |
| virtual void | clearUnlockedCategory (int4 cat)=0 |
| Clear unlocked symbols of the given category from this scope. | |
| virtual bool | inScope (const Address &addr, int4 size, const Address &usepoint) const |
| Query if the given range is owned by this Scope. More... | |
| virtual void | removeSymbolMappings (Symbol *symbol)=0 |
| Remove all SymbolEntrys from the given Symbol. | |
| virtual void | removeSymbol (Symbol *symbol)=0 |
| Remove the given Symbol from this Scope. | |
| virtual void | renameSymbol (Symbol *sym, const string &newname)=0 |
| Rename a Symbol within this Scope. | |
| virtual void | retypeSymbol (Symbol *sym, Datatype *ct)=0 |
| Change the data-type of a Symbol within this Scope. More... | |
| virtual void | setAttribute (Symbol *sym, uint4 attr)=0 |
| Set boolean Varnode properties on a Symbol. | |
| virtual void | clearAttribute (Symbol *sym, uint4 attr)=0 |
| Clear boolean Varnode properties on a Symbol. | |
| virtual void | setDisplayFormat (Symbol *sym, uint4 attr)=0 |
| Set the display format for a Symbol. | |
| virtual SymbolEntry * | findAddr (const Address &addr, const Address &usepoint) const =0 |
| Find a Symbol at a given address and usepoint. More... | |
| virtual SymbolEntry * | findContainer (const Address &addr, int4 size, const Address &usepoint) const =0 |
| Find the smallest Symbol containing the given memory range. More... | |
| virtual SymbolEntry * | findClosestFit (const Address &addr, int4 size, const Address &usepoint) const =0 |
| Find Symbol which is the closest fit to the given memory range. More... | |
| virtual Funcdata * | findFunction (const Address &addr) const =0 |
| Find the function starting at the given address. More... | |
| virtual ExternRefSymbol * | findExternalRef (const Address &addr) const =0 |
| Find an external reference at the given address. More... | |
| virtual LabSymbol * | findCodeLabel (const Address &addr) const =0 |
| Find a label Symbol at the given address. More... | |
| virtual SymbolEntry * | findOverlap (const Address &addr, int4 size) const =0 |
| Find first Symbol overlapping the given memory range. More... | |
| virtual void | findByName (const string &name, vector< Symbol *> &res) const =0 |
| Find a Symbol by name within this Scope. More... | |
| virtual bool | isNameUsed (const string &name) const =0 |
| Check if the given name is used within this scope. More... | |
| virtual Funcdata * | resolveExternalRefFunction (ExternRefSymbol *sym) const =0 |
| Convert an external reference to the referenced function. More... | |
| virtual string | buildVariableName (const Address &addr, const Address &pc, Datatype *ct, int4 &index, uint4 flags) const =0 |
| Given an address and data-type, build a suitable generic symbol name. More... | |
| virtual string | buildUndefinedName (void) const =0 |
| Build a formal undefined name, used internally when a Symbol is not given a name. More... | |
| virtual string | makeNameUnique (const string &nm) const =0 |
| Produce a version of the given symbol name that won't collide with other names in this Scope. More... | |
| virtual void | saveXml (ostream &s) const =0 |
| Write out this as a <scope> XML tag. | |
| virtual void | restoreXml (const Element *el)=0 |
| Restore this Scope from a <scope> XML tag. | |
| virtual void | printEntries (ostream &s) const =0 |
| Dump a description of all SymbolEntry objects to a stream. | |
| virtual int4 | getCategorySize (int4 cat) const =0 |
| Get the number of Symbols in the given category. More... | |
| virtual Symbol * | getCategorySymbol (int4 cat, int4 ind) const =0 |
| Retrieve a Symbol by index within a specific category. More... | |
| virtual void | setCategory (Symbol *sym, int4 cat, int4 ind)=0 |
| Set the category and index for the given Symbol. More... | |
| virtual SymbolEntry * | addSymbol (const string &name, Datatype *ct, const Address &addr, const Address &usepoint) |
| Add a new Symbol to this Scope, given a name, data-type, and a single mapping. More... | |
| const string & | getName (void) const |
| Get the name of the Scope. | |
| bool | isGlobal (void) const |
| Return true if this scope is global. | |
| void | queryByName (const string &name, vector< Symbol *> &res) const |
| Look-up symbols by name. More... | |
| Funcdata * | queryFunction (const string &name) const |
| Look-up a function by name. More... | |
| SymbolEntry * | queryByAddr (const Address &addr, const Address &usepoint) const |
| Get Symbol with matching address. More... | |
| SymbolEntry * | queryContainer (const Address &addr, int4 size, const Address &usepoint) const |
| Find the smallest containing Symbol. More... | |
| SymbolEntry * | queryProperties (const Address &addr, int4 size, const Address &usepoint, uint4 &flags) const |
| Find a Symbol or properties at the given address. More... | |
| Funcdata * | queryFunction (const Address &addr) const |
| Look-up a function by address. More... | |
| Funcdata * | queryExternalRefFunction (const Address &addr) const |
| Look-up a function thru an external reference. More... | |
| LabSymbol * | queryCodeLabel (const Address &addr) const |
| Look-up a code label by address. More... | |
| Scope * | resolveScope (const string &name) const |
| Find a child Scope of this. More... | |
| Scope * | discoverScope (const Address &addr, int4 sz, const Address &usepoint) |
| Find the owning Scope of a given memory range. More... | |
| ScopeMap::const_iterator | childrenBegin () const |
| Beginning iterator of child scopes. | |
| ScopeMap::const_iterator | childrenEnd () const |
| Ending iterator of child scopes. | |
| void | saveXmlRecursive (ostream &s, bool onlyGlobal) const |
| Save all contained scopes as an XML stream. More... | |
| void | overrideSizeLockType (Symbol *sym, Datatype *ct) |
| Change the data-type of a Symbol that is sizelocked. More... | |
| void | resetSizeLockType (Symbol *sym) |
| Clear a Symbol's size-locked data-type. More... | |
| bool | isSubScope (const Scope *scp) const |
| Is this a sub-scope of the given Scope. More... | |
| string | getFullName (void) const |
| Get the full name of this Scope. | |
| void | getNameSegments (vector< string > &vec) const |
| Get the fullname of this in segments. More... | |
| void | getScopePath (vector< Scope *> &vec) const |
| Get the ordered list of parent scopes to this. More... | |
| bool | isNameUsed (const string &nm, const Scope *op2) const |
| Is the given name in use within given scope path. More... | |
| const Scope * | findDistinguishingScope (const Scope *op2) const |
| Find first ancestor of this not shared by given scope. More... | |
| Architecture * | getArch (void) const |
| Get the Architecture associated with this. | |
| Scope * | getParent (void) const |
| Get the parent Scope (or NULL if this is the global Scope) | |
| Symbol * | addSymbol (const string &name, Datatype *ct) |
| Add a new Symbol without mapping it to an address. More... | |
| SymbolEntry * | addMapPoint (Symbol *sym, const Address &addr, const Address &usepoint) |
| Map a Symbol to a specific address. More... | |
| Symbol * | addMapSym (const Element *el) |
| Add a mapped Symbol from a <mapsym> XML tag. More... | |
| FunctionSymbol * | addFunction (const Address &addr, const string &nm) |
| Create a function Symbol at the given address in this Scope. More... | |
| ExternRefSymbol * | addExternalRef (const Address &addr, const Address &refaddr, const string &nm) |
| LabSymbol * | addCodeLabel (const Address &addr, const string &nm) |
| Create a code label at the given address in this Scope. More... | |
| Symbol * | addDynamicSymbol (const string &nm, Datatype *ct, const Address &caddr, uint8 hash) |
| Create a dynamically mapped Symbol attached to a specific data-flow. More... | |
| string | buildDefaultName (Symbol *sym, int4 &base, Varnode *vn) const |
| Create a default name for the given Symbol. More... | |
| bool | isReadOnly (const Address &addr, int4 size, const Address &usepoint) const |
| Is the given memory range marked as read-only. More... | |
| void | printBounds (ostream &s) const |
| Print a description of this Scope's owned memory ranges. | |
Protected Member Functions | |
| const RangeList & | getRangeTree (void) const |
| Access the address ranges owned by this Scope. | |
| virtual void | restrictScope (Funcdata *f) |
| Convert this to a local Scope. More... | |
| virtual void | addRange (AddrSpace *spc, uintb first, uintb last) |
| Add a memory range to the ownership of this Scope. More... | |
| virtual void | removeRange (AddrSpace *spc, uintb first, uintb last) |
| Remove a memory range from the ownership of this Scope. More... | |
| virtual void | addSymbolInternal (Symbol *sym)=0 |
| Put a Symbol into the name map. More... | |
| virtual SymbolEntry * | addMapInternal (Symbol *sym, uint4 exfl, const Address &addr, int4 off, int4 sz, const RangeList &uselim)=0 |
| Create a new SymbolEntry for a Symbol given a memory range. More... | |
| virtual SymbolEntry * | addDynamicMapInternal (Symbol *sym, uint4 exfl, uint8 hash, int4 off, int4 sz, const RangeList &uselim)=0 |
| Create a new SymbolEntry for a Symbol given a dynamic hash. More... | |
| SymbolEntry * | addMap (const SymbolEntry &entry) |
| Integrate a SymbolEntry into the range maps. More... | |
| void | setSymbolId (Symbol *sym, uint8 id) const |
| Adjust the id associated with a symbol. | |
Static Protected Member Functions | |
| static const Scope * | stackAddr (const Scope *scope1, const Scope *scope2, const Address &addr, const Address &usepoint, SymbolEntry **addrmatch) |
| Query for Symbols starting at a given address, which match a given usepoint. More... | |
| static const Scope * | stackContainer (const Scope *scope1, const Scope *scope2, const Address &addr, int4 size, const Address &usepoint, SymbolEntry **addrmatch) |
| static const Scope * | stackClosestFit (const Scope *scope1, const Scope *scope2, const Address &addr, int4 size, const Address &usepoint, SymbolEntry **addrmatch) |
| static const Scope * | stackFunction (const Scope *scope1, const Scope *scope2, const Address &addr, Funcdata **addrmatch) |
| static const Scope * | stackExternalRef (const Scope *scope1, const Scope *scope2, const Address &addr, ExternRefSymbol **addrmatch) |
| static const Scope * | stackCodeLabel (const Scope *scope1, const Scope *scope2, const Address &addr, LabSymbol **addrmatch) |
Protected Attributes | |
| Architecture * | glb |
| Architecture of this scope. | |
| string | name |
| Name of this scope. | |
| Funcdata * | fd |
| (If non-null) the function which this is the local Scope for | |
| uint4 | uniqueId |
| Unique id for the scope, for deduping scope names, assigning symbol ids. | |
Friends | |
| class | Database |
| class | ScopeCompare |
A collection of Symbol objects within a single (namespace or functional) scope.
This acts as a traditional Symbol container, allowing them to be accessed by name, but it also keeps track of how a Symbol is mapped into memory. It allows a Symbol to be looked up by its location in memory, which is sensitive to the address of the code accessing the Symbol.
Capabilities include:
A scope also supports the idea of ownership of memory. In theory, for a Symbol in the scope, at the code locations where the Symbol storage is valid, the scope owns the storage memory. In practice, a Scope object knows about memory ranges where a Symbol might be discovered. For instance, the global Scope usually owns all memory in the ram address space.
|
protectedpure virtual |
Create a new SymbolEntry for a Symbol given a dynamic hash.
The SymbolEntry is specified in terms of a hash and usepoint, which describe how to find the temporary Varnode holding the symbol value.
| sym | is the given Symbol being mapped |
| exfl | are any boolean Varnode properties |
| hash | is the given dynamic hash |
| off | is the byte offset of the new SymbolEntry (relative to the whole Symbol) |
| sz | is the number of bytes occupied by the Varnode |
| uselim | is the given usepoint |
Implemented in ScopeInternal.
| Symbol * Scope::addDynamicSymbol | ( | const string & | nm, |
| Datatype * | ct, | ||
| const Address & | caddr, | ||
| uint8 | hash | ||
| ) |
Create a dynamically mapped Symbol attached to a specific data-flow.
The Symbol is created and mapped to a dynamic hash and a code address where the Symbol is being used.
| nm | is the name of the Symbol |
| ct | is the data-type of the Symbol |
| caddr | is the code address where the Symbol is being used |
| hash | is the dynamic hash |
| ExternRefSymbol * Scope::addExternalRef | ( | const Address & | addr, |
| const Address & | refaddr, | ||
| const string & | nm | ||
| ) |
Create an external reference at the given address in this Scope
An ExternRefSymbol is created and mapped to the given address and stores a reference address to the actual function.
| addr | is the given address to map the Symbol to |
| refaddr | is the reference address |
| nm | is the name of the symbol/function |
| FunctionSymbol * Scope::addFunction | ( | const Address & | addr, |
| const string & | nm | ||
| ) |
Create a function Symbol at the given address in this Scope.
The FunctionSymbol is created and mapped to the given address. A Funcdata object is only created once FunctionSymbol::getFunction() is called.
| addr | is the entry address of the function |
| nm | is the name of the function, within this Scope |
|
protected |
Integrate a SymbolEntry into the range maps.
The mapping is given as an unintegrated SymbolEntry object. Memory may be specified in terms of join addresses, which this method must unravel. The offset, size, and extraflags fields of the SymbolEntry are not used. In particular, the SymbolEntry is assumed to map the entire Symbol.
| entry | is the given SymbolEntry |
|
protectedpure virtual |
Create a new SymbolEntry for a Symbol given a memory range.
The SymbolEntry is specified in terms of a memory range and usepoint
| sym | is the given Symbol being mapped |
| exfl | are any boolean Varnode properties specific to the memory range |
| addr | is the starting address of the given memory range |
| off | is the byte offset of the new SymbolEntry (relative to the whole Symbol) |
| sz | is the number of bytes in the range |
| uselim | is the given usepoint (which may be invalid) |
Implemented in ScopeInternal.
| SymbolEntry * Scope::addMapPoint | ( | Symbol * | sym, |
| const Address & | addr, | ||
| const Address & | usepoint | ||
| ) |
Map a Symbol to a specific address.
Create a new SymbolEntry that maps the whole Symbol to the given address
| sym | is the Symbol |
| addr | is the given address to map to |
| usepoint | is a point at which the Symbol is accessed at that address |
Add a mapped Symbol from a <mapsym> XML tag.
A tag describing the Symbol is parsed first, followed by sequences of <addr> or <hash> and <rangelist> which define 1 or more mappings of the Symbol The new Symbol and SymbolEntry mappings are integrated into this Scope
| el | is the <mapsym> XML element |
|
protectedvirtual |
Add a memory range to the ownership of this Scope.
| spc | is the address space of the range |
| first | is the offset of the first byte in the range |
| last | is the offset of the last byte in the range |
|
virtual |
Add a new Symbol to this Scope, given a name, data-type, and a single mapping.
The Symbol object will be created with the given name and data-type. A single mapping (SymbolEntry) will be created for the Symbol based on a given storage address for the symbol and an address for code that accesses the Symbol at that storage location.
| name | is the new name of the Symbol |
| ct | is the data-type of the new Symbol |
| addr | is the starting address of the Symbol storage |
| usepoint | is the point accessing that storage (may be invalid) |
Reimplemented in ScopeGhidra.
|
protectedpure virtual |
Put a Symbol into the name map.
| sym | is the preconstructed Symbol |
Implemented in ScopeInternal.
Create a default name for the given Symbol.
Create default name given information in the Symbol and possibly a representative Varnode. This method extracts the crucial properties and then uses the buildVariableName method to construct the actual name.
| sym | is the given Symbol to name |
| base | is an index (which may get updated) used to uniquify the name |
| vn | is an optional (may be null) Varnode representative of the Symbol |
|
pure virtual |
Build a formal undefined name, used internally when a Symbol is not given a name.
Implemented in ScopeInternal, and ScopeGhidra.
|
pure virtual |
Given an address and data-type, build a suitable generic symbol name.
| addr | is the given address |
| pc | is the address at which the name is getting used |
| ct | is a data-type used to inform the name |
| index | is a reference to an index used to make the name unique, which will be updated |
| flags | are boolean properties of the variable we need the name for |
Implemented in ScopeInternal, ScopeLocal, and ScopeGhidra.
Find the owning Scope of a given memory range.
Discover a sub-scope or containing Scope of this, that owns the given memory range at a specific usepoint. Note that ownership does not necessarily mean there is a known symbol there.
| addr | is the starting address of the memory range |
| sz | is the number of bytes in the range |
| usepoint | is a point at which the memory is getting accesses |
|
pure virtual |
Find a Symbol at a given address and usepoint.
| addr | is the given address |
| usepoint | is the point at which the Symbol is accessed (may be invalid) |
Implemented in ScopeInternal, and ScopeGhidra.
|
pure virtual |
Find a Symbol by name within this Scope.
If there are multiple Symbols with the same name, all are passed back.
| name | is the name to search for |
| res | will contain any matching Symbols |
Implemented in ScopeInternal, and ScopeGhidra.
|
pure virtual |
Find Symbol which is the closest fit to the given memory range.
| addr | is the starting address of the given memory range |
| size | is the number of bytes in the range |
| usepoint | is the point at which the Symbol is accessed (may be invalid) |
Implemented in ScopeInternal, and ScopeGhidra.
Find a label Symbol at the given address.
| addr | is the given address |
Implemented in ScopeInternal, and ScopeGhidra.
|
pure virtual |
Find the smallest Symbol containing the given memory range.
| addr | is the starting address of the given memory range |
| size | is the number of bytes in the range |
| usepoint | is the point at which the Symbol is accessed (may be invalid) |
Implemented in ScopeInternal, and ScopeGhidra.
Find first ancestor of this not shared by given scope.
Any two scopes share at least the global scope as a common ancestor. We find the first scope that is not in common. The scope returned will always be an ancestor of this. If this is an ancestor of the other given scope, then null is returned.
| op2 | is the other given Scope |
|
pure virtual |
Find an external reference at the given address.
| addr | is the given address |
Implemented in ScopeInternal, and ScopeGhidra.
Find the function starting at the given address.
| addr | is the given starting address |
Implemented in ScopeInternal, and ScopeGhidra.
|
pure virtual |
Find first Symbol overlapping the given memory range.
| addr | is the starting address of the given range |
| size | is the number of bytes in the range |
Implemented in ScopeInternal, and ScopeGhidra.
|
pure virtual |
Get the number of Symbols in the given category.
| cat | is the Symbol category |
Implemented in ScopeInternal, and ScopeGhidra.
|
pure virtual |
Retrieve a Symbol by index within a specific category.
Implemented in ScopeInternal, and ScopeGhidra.
| void Scope::getNameSegments | ( | vector< string > & | vec | ) | const |
Get the fullname of this in segments.
Put the names of this and all its parent Scopes into an array in order. The name of the first entry will generally be the name of the global Scope
| vec | is the array in which to store the names |
| void Scope::getScopePath | ( | vector< Scope *> & | vec | ) | const |
Get the ordered list of parent scopes to this.
Put the parent scopes of this into an array in order, starting with the global scope. This scope itself will not be in the array.
| vec | is storage for the array of scopes |
|
inlinevirtual |
Query if the given range is owned by this Scope.
All bytes in the range must be owned, and ownership can be informed by particular code that is accessing the range.
| addr | is the starting address of the range |
| size | is the number of bytes in the range |
| usepoint | is the code address at which the given range is being accessed (may be invalid) |
|
pure virtual |
Check if the given name is used within this scope.
Only this scope is checked. If one or more symbols exist with the given name, true is returned.
| name | is the given name to check for |
Implemented in ScopeInternal, and ScopeGhidra.
| bool Scope::isNameUsed | ( | const string & | nm, |
| const Scope * | op2 | ||
| ) | const |
Is the given name in use within given scope path.
Test for the presence of a symbol with the given name in either this scope or an ancestor scope up to but not including the given terminating scope. If the name is used true is returned.
| nm | is the given name to test |
| op2 | is the terminating ancestor scope (or null) |
Is the given memory range marked as read-only.
Check for Symbols relative to this Scope that are marked as read-only, and look-up properties of the memory in general.
| addr | is the starting address of the given memory range |
| size | is the number of bytes in the range |
| usepoint | is a point where the range is getting accessed |
| bool Scope::isSubScope | ( | const Scope * | scp | ) | const |
|
pure virtual |
Produce a version of the given symbol name that won't collide with other names in this Scope.
| nm | is the given name |
Implemented in ScopeInternal, and ScopeGhidra.
| SymbolEntry * Scope::queryByAddr | ( | const Address & | addr, |
| const Address & | usepoint | ||
| ) | const |
Get Symbol with matching address.
Within a sub-scope or containing Scope of this, find a Symbol that is mapped to the given address, where the mapping is valid at a specific usepoint.
| addr | is the given address |
| usepoint | is the point at which code accesses that address (may be invalid) |
| void Scope::queryByName | ( | const string & | name, |
| vector< Symbol *> & | res | ||
| ) | const |
Look-up symbols by name.
Starting from this Scope, look for a Symbol with the given name. If there are no Symbols in this Scope, recurse into the parent Scope. If there are 1 (or more) Symbols matching in this Scope, add them to the result list
| name | is the name to search for |
| res | is the result list |
| SymbolEntry * Scope::queryContainer | ( | const Address & | addr, |
| int4 | size, | ||
| const Address & | usepoint | ||
| ) | const |
Find the smallest containing Symbol.
Within a sub-scope or containing Scope of this, find the smallest Symbol that contains a given memory range and can be accessed at a given usepoint.
| addr | is the given starting address of the memory range |
| size | is the number of bytes in the range |
| usepoint | is a point at which the Symbol is accessed (may be invalid) |
Look-up a function thru an external reference.
Given an address, search for an external reference. If no Symbol is found and this Scope does not own the address, recurse searching in the parent Scope. If an external reference is found, try to resolve the function it refers to and return it.
| addr | is the given address where an external reference might be |
| Funcdata * Scope::queryFunction | ( | const string & | name | ) | const |
Look-up a function by name.
Starting with this Scope, find a function with the given name. If there are no Symbols with that name in this Scope at all, recurse into the parent Scope.
| name | if the name to search for |
| SymbolEntry * Scope::queryProperties | ( | const Address & | addr, |
| int4 | size, | ||
| const Address & | usepoint, | ||
| uint4 & | flags | ||
| ) | const |
Find a Symbol or properties at the given address.
Similarly to queryContainer(), this searches for the smallest containing Symbol, but whether a known Symbol is found or not, boolean properties associated with the memory range are also search for and passed back.
| addr | is the starting address of the range |
| size | is the number of bytes in the range |
| usepoint | is a point at which the memory range is accessed (may be invalid) |
| flags | is a reference used to pass back the boolean properties of the memory range |
|
protectedvirtual |
Remove a memory range from the ownership of this Scope.
| spc | is the address space of the range |
| first | is the offset of the first byte in the range |
| last | is the offset of the last byte in the range |
| void Scope::resetSizeLockType | ( | Symbol * | sym | ) |
|
pure virtual |
Convert an external reference to the referenced function.
| sym | is the Symbol marking the external reference |
Implemented in ScopeInternal, and ScopeGhidra.
| Scope * Scope::resolveScope | ( | const string & | name | ) | const |
|
protectedvirtual |
Convert this to a local Scope.
Attach this to the given function, which makes this the local scope for the function
| f | is the given function to attach to |
Reimplemented in ScopeGhidra.
Change the data-type of a Symbol within this Scope.
If the size of the Symbol changes, any mapping (SymbolEntry) is adjusted
| sym | is the given Symbol |
| ct | is the new data-type |
Implemented in ScopeInternal, and ScopeGhidra.
| void Scope::saveXmlRecursive | ( | ostream & | s, |
| bool | onlyGlobal | ||
| ) | const |
|
pure virtual |
Set the category and index for the given Symbol.
| sym | is the given Symbol |
| cat | is the category to set for the Symbol |
| ind | is the index position to set (within the category) |
Implemented in ScopeInternal, and ScopeGhidra.
|
staticprotected |
Query for Symbols starting at a given address, which match a given usepoint.
Searching starts at a first scope, continuing thru parents up to a second scope, which is not queried. If a Scope controls the memory at that address, the Scope object is returned. Additionally, if a symbol matching the criterion is found, the matching SymbolEntry is passed back.
| scope1 | is the first Scope where searching starts |
| scope2 | is the second Scope where searching ends |
| addr | is the given address to search for |
| usepoint | is the given point at which the memory is being accessed (can be an invalid address) |
| addrmatch | is used to pass-back any matching SymbolEntry |
|
staticprotected |
Query for a Symbol which most closely matches a given range and usepoint
Searching starts at a first scope, continuing thru parents up to a second scope, which is not queried. If a Scope controls the memory in the given range, the Scope object is returned. Among symbols that overlap the given range, the SymbolEntry which most closely matches the starting address and size is passed back.
| scope1 | is the first Scope where searching starts |
| scope2 | is the second Scope where searching ends |
| addr | is the starting address of the given range |
| size | is the number of bytes in the given range |
| usepoint | is the point at which the memory is being accessed (can be an invalid address) |
| addrmatch | is used to pass-back any matching SymbolEntry |
|
staticprotected |
Query for a label Symbol for a given address.
Searching starts at a first scope, continuing thru parents up to a second scope, which is not queried. If a Scope controls the memory in the given range, the Scope object is returned. If there is a label at that address, pass back the corresponding LabSymbol object
| scope1 | is the first Scope where searching starts |
| scope2 | is the second Scope where searching ends |
| addr | is the given address |
| addrmatch | is used to pass-back any matching Symbol |
|
staticprotected |
Query for a Symbol containing a given range which is accessed at a given usepoint
Searching starts at a first scope, continuing thru parents up to a second scope, which is not queried. If a Scope controls the memory in the given range, the Scope object is returned. If a known Symbol contains the range, the matching SymbolEntry is passed back.
| scope1 | is the first Scope where searching starts |
| scope2 | is the second Scope where searching ends |
| addr | is the starting address of the given range |
| size | is the number of bytes in the given range |
| usepoint | is the point at which the memory is being accessed (can be an invalid address) |
| addrmatch | is used to pass-back any matching SymbolEntry |
|
staticprotected |
Query for an external reference Symbol starting at the given address
Searching starts at a first scope, continuing thru parents up to a second scope, which is not queried. If a Scope controls the memory in the given range, the Scope object is returned. If an external reference is found at the address, pass back the matching ExternRefSymbol
| scope1 | is the first Scope where searching starts |
| scope2 | is the second Scope where searching ends |
| addr | is the given address |
| addrmatch | is used to pass-back any matching Symbol |
|
staticprotected |
Query for a function Symbol starting at the given address
Searching starts at a first scope, continuing thru parents up to a second scope, which is not queried. If a Scope controls the memory in the given range, the Scope object is returned. If a FunctionSymbol is found at the given address, the corresponding Funcdata object is passed back.
| scope1 | is the first Scope where searching starts |
| scope2 | is the second Scope where searching ends |
| addr | is the given address where the function should start |
| addrmatch | is used to pass-back any matching function |


Deleting a Link
How to delete a link from the Links module.
Prerequisite. The Link module must be set to Links mode to create and manage individual links. See "Setting the Links Mode"
- If links are displayed in a drop down list, select the required link from the drop down list.
- Click the Edit button beside the required link.
- Click the Delete link located at the base on the Edit Links module. This displays the message "Are You Sure You Wish To Delete This Item?"
-
Click the OK button to confirm.


Hot-keys on this page
n s m x c change column sorting
| Module | statements | missing | excluded | coverage |
|---|---|---|---|---|
| Total | 3738 | 1627 | 0 | 56% |
| AIRCAP_Chk_Packet.py | 1599 | 34 | 0 | 98% |
| AIRCAP_Control_StartAirCAP_PTEST.py | 908 | 908 | 0 | 0% |
| chk_wmon.py | 10 | 10 | 0 | 0% |
| common/tx_snd.py | 106 | 86 | 0 | 19% |
| device/AIRCAP/AIRCAP_main.py | 52 | 44 | 0 | 15% |
| device/AIRCAP/sub/Chk_packet.py | 475 | 14 | 0 | 97% |
| device/AIRCAP/sub/Control.py | 419 | 362 | 0 | 14% |
| main.py | 125 | 125 | 0 | 0% |
| test.py | 5 | 5 | 0 | 0% |
| testco.py | 5 | 5 | 0 | 0% |
| testpcapy.py | 34 | 34 | 0 | 0% |
No items found using the specified filter.


Current (mA)
Charging
= S
Discharging
= bo
-0.6 0 05 10 L5
1st 2nd 3rd
2.0 2.5 3.0 486
Potential (V vs. Li/Li*)
489
492
495
498
Binding energy (eV)
s
Intensity (a.u.)


Watching "Le Jetee", the short film of still images that inspired "12 Monkeys." Eerie, and no Brad Pitt. http://tinyurl.com/lajetee
3/19/2009, 7:33:12 PM
Favs: 0
Retweets: 0
link--- layout: tweet ---
Watching "Le Jetee", the short film of still images that inspired "12 Monkeys." Eerie, and no Brad Pitt. http://tinyurl.com/lajetee
3/19/2009, 7:33:12 PM
Favs: 0
Retweets: 0
link


Places You've Been
Input the places you've been to keep track of your trips. Separate with a comma.
Input name of place (required)
Input landmarks seen
Input dates visited
Notes on the visit
Add place
List of Places:
Item Info:


Academics and Projects
Graduation
Guru Nanak Dev University, Amritsar.
Graduated with Honours in Computer Science and Engineering.
Academic Project
Built TimeTable Management Software in ASP.Net using C#. Won first prize in Tech Fest.
Post Graduation
International Institute of Information Technology, Bangalore. Masters in Information Technology (Major in Software Engineering).
Internship
Six months internship in Yahoo. Designed and Implemented an Asynchronous Job Scheduler in LAMP stack.


curl_global_sslset - select SSL backend
NAME
curl_global_sslset - Select SSL backend to use with libcurl
SYNOPSIS
#include <curl/curl.h>
typedef struct { curl_sslbackend id; const char *name; } curl_ssl_backend; typedef enum { CURLSSLBACKEND_NONE = 0, CURLSSLBACKEND_OPENSSL = 1, CURLSSLBACKEND_GNUTLS = 2, CURLSSLBACKEND_NSS = 3, CURLSSLBACKEND_GSKIT = 5, CURLSSLBACKEND_POLARSSL = 6, CURLSSLBACKEND_WOLFSSL = 7, CURLSSLBACKEND_SCHANNEL = 8, CURLSSLBACKEND_DARWINSSL = 9, CURLSSLBACKEND_AXTLS = 10, CURLSSLBACKEND_MBEDTLS = 11 } curl_sslbackend; CURLsslset curl_global_sslset(curl_sslbackend id, const char * name, curl_ssl_backend *** avail );
DESCRIPTION
This function configures at runtime which SSL backend to use with libcurl. This function can only be used to select an SSL backend once, and it must be called before curl_global_init.
The backend can be identified by the id (e.g. CURLSSLBACKEND_OPENSSL). The backend can also be specified via the name parameter for a case insensitive match (passing -1 as id). If both id and name are specified, the name will be ignored.
If neither id nor name are specified, the function will fail with CURLSSLSET_UNKNOWN_BACKEND and set the avail pointer to the NULL-terminated list of available backends. The available backends are those that this particular build of libcurl supports.
Since libcurl 7.60.0, the avail pointer will always be set to the list of alternatives if non-NULL.
Upon success, the function returns CURLSSLSET_OK.
If the specified SSL backend is not available, the function returns CURLSSLSET_UNKNOWN_BACKEND and sets the avail pointer to a NULL-terminated list of available SSL backends. In this case, you may call the function again to try to select a different backend.
The SSL backend can be set only once. If it has already been set, a subsequent attempt to change it will result in a CURLSSLSET_TOO_LATE.
This function is not thread safe. You must not call it when any other thread in the program (i.e. a thread sharing the same memory) is running. This doesn't just mean no other thread that is using libcurl.
AVAILABILITY
This function was added in libcurl 7.56.0. Before this version, there was no support for choosing SSL backends at runtime.
RETURN VALUE
If this function returns CURLSSLSET_OK, the backend was successfully selected.
If the chosen backend is unknown (or support for the chosen backend has not been compiled into libcurl), the function returns CURLSSLSET_UNKNOWN_BACKEND.
If the backend had been configured previously, or if curl_global_init has already been called, the function returns CURLSSLSET_TOO_LATE.
If this libcurl was built completely without SSL support, with no backends at all, this function returns CURLSSLSET_NO_BACKENDS.
SEE ALSO
This HTML page was made with roffit.


BodyCare Bakery
Home
About
Contact
BodyCare Bakery Contact Form
Contact us for custom quote or enquiries
Submit
Designed by
WASPP


// JSDoc Wiki: http://en.wikipedia.org/wiki/JSDoc
// jsdoc3 tags: http://usejsdoc.org/#JSDoc3_Tag_Dictionary
// JS Data Types: http://www.w3schools.com/js/js_datatypes.asp
// How to express JS data types: https://developers.google.com/closure/compiler/docs/js-for-compiler#types
// The collision detection is mostly inspired from the article: http://gamedev.tutsplus.com/tutorials/implementation/implementing-tetris-collision-detection/ (by Michael James Williams on Oct 6th 2012)
// The reason why I did not entirely come up with my own algorithms for everything is for the sake of time
// Most of the standards I used for Tetris came from http://en.wikipedia.org/wiki/Tetris
/* Nomenclature:
*
* user: Person playing the game.
* Tet: Short for Tetrimino (http://en.wikipedia.org/wiki/Tetrimino), or the name of our main class. I will try to disambiguate within the comments when necessary.
* living Tet: Tet in free fall controlled by user.
* landed Tet: Tet that has landed and is no longer in control by user.
*/
/**
* This function creates a Game class intended to be instantiated by "new Game()".
* Only one Game per page can work separately at the moment.
*
* @author Jared Gotte<EMAIL_ADDRESS>* @class Represents all of the functions which generate and control the game board. We use the {@link Tet} class to manipulate our Tets.
* @param {string} canvasId - This is the id of the canvas element within the document from which this Game class was created.
* @param {string} highScoresListId - This is the id of the list for which we are going to list out the user's past high scores.
* @param {boolean} [devMode] - This is the option to set the game to be initially in Developer's Mode.
* @property {boolean} devModeOn - If this is true, we can do Developer's Only events.
* @property {number} BOARD_ROW_NUM - Pseudo-constant set to 16, determined by Tetris standards set in place before my game was made.
* @property {number} BOARD_COL_NUM - Pseudo-constant set to 10, determined by Tetris standards set in place before my game was made.
* @property {boolean} newTet - If true, we want to create a new Tet.
* @property {Tet} currentTet - This is the Tet that is falling and controlled by the user.
* @property {Tet} nextTet - This is the Tet that is going to come out after our currentTet lands.
* @property {boolean} updateLanded - If true, we should update our landed array to be used in collision detection.
* @property {Array.<Tet>} allTets - This is the array of all Tets that are in the game.
* @property {Array.<Tet>} tetsToRemove - This is the array of all Tets that need to be removed before being drawn.
* @property {number} score - This is the score that we're going to use to display.
* @property {boolean} updateScore - This is the boolean we check to see if we should update our high score list or not.
* @property {number} dropInterval - This is the interval, in milliseconds, for which our currentTet is going to drop 1 block.
* @property {boolean} gameOver - If this is set to true, we handle the "game over" events.
* @property {number} canvasWidth - This is the width that we set. This width can be adjusted and our game will scale to it.
* @property {number} blockS - This is the length of the side of each "block" on the game, in pixels.
* @property {Element} canvas - This is the DOM element for which we are going to be drawing on.
* @property {number} panelHeight - This is the height of the panel which houses our score, nextTet, and PAUSED/DEV text.
* @property {Array.<Array.<number>>} landed - This is the array of array of numbers which we are going to populate with our allTets to be able to detect Tet collision.
* @property {string} highScoresListId - This is the name of the high score list DOM element for which we are going to show our user their past high scores.
*/
function Game (canvasId, highScoresListId, devMode) {
if (!(this instanceof arguments.callee)) return new Game(canvasId, highScoresListId, devMode); // force instantiation
// Developer's Mode
this.devModeOn = devMode === true ? true : false;
// public vars
this.BOARD_ROW_NUM = 16; // Tetris standard is to have 10 horizontal blocks by 16 vertical blocks
this.BOARD_COL_NUM = 10;
this.newTet = true;
this.currentTet = null;
this.nextTet = null;
this.updateLanded = true;
this.allTets = [];
this.tetsToRemove = [];
this.score = 0;
this.updateScore = true;
// private vars
this.dropInterval = 750; // 750
this.gameOver = false;
this.canvasWidth = 200;
this.blockS = this.canvasWidth / 10; // Assume block width and height will always be the same
this.canvas = document.getElementById(canvasId);
this.canvas.width = this.canvasWidth;
this.canvas.height = 2 * this.canvasWidth;
this.panelHeight = Math.round((2 - this.BOARD_ROW_NUM / this.BOARD_COL_NUM) * this.canvasWidth);
this.landed = [];
this.paused = true;
this.highScoresListId = highScoresListId;
// init functions
this.displayHighScores();
this.createTet();
this.handleEvents();
}
/**
* This method creates 3 event listeners. 2 for the window and 1 for the document.
* The 2 events for the window are onblur and onfocus. These will pause the game when you leave the game window and resume it when you come back.
* The event for the document listens for onkeydown events. These basically allow the user to interact with the game.
*
* @author Jared Gotte<EMAIL_ADDRESS>*/
Game.prototype.handleEvents = function () {
var that = this;
// Pause if we lose focus of the game
// Resume once we get focus back
// We don't care about the Page Visibility API anymore because we don't have a resource intensive game
var pausedBeforeBlur = true;
window.onblur = function () {
if (that.gameOver === false) {
pausedBeforeBlur = that.paused ? true : false;
clearInterval(that.loop);
that.paused = true;
that.draw();
}
};
window.onfocus = function () {
if (!pausedBeforeBlur && that.gameOver === false) {
if (!that.gameOver) that.tetDownLoop();
that.paused = false;
that.draw();
}
};
// Handle key events
document.onkeydown = function(e) { // http://www.javascripter.net/faq/keycodes.htm for keycodes
switch (e.keyCode) {
case 32: // space to move living Tet all the way down
if (that.canTetMove() === true) {
while (!that.newTet) {
that.currentTet.moveDown();
}
that.draw();
that.tetDownLoop();
}
break;
case 38: // up arrow to rotate Tet clockwise
if (that.canTetMove() === true) {
that.currentTet.rotate();
that.draw();
}
break;
case 37: // left arrow to move Tet left
if (that.canTetMove() === true) {
that.currentTet.moveLeft();
that.draw();
}
break;
case 39: // right arrow to move Tet right
if (that.canTetMove() === true) {
that.currentTet.moveRight();
that.draw();
}
break;
case 40: // down arrow to move Tet down
if (that.canTetMove() === true) {
var skip = false;
if (that.newTet) skip = true;
if (!skip) clearInterval(that.loop);
that.currentTet.moveDown();
that.draw();
if (!skip && !that.paused) that.tetDownLoop();
}
break;
case 80: case 83: // p for pause, s for stop (they do same thing)
if (that.gameOver === false) {
if (!that.paused) {
clearInterval(that.loop);
that.paused = true;
that.draw();
}
else {
if (that.gameOver === false) {
that.tetDownLoop();
that.dropOnce = false;
}
that.paused = false;
that.draw();
}
}
break;
case 82: // r for reset
that.allTets = [];
clearInterval(that.loop);
that.currentTet = null;
that.gameOver = false;
that.newTet = true;
that.nextTet = null;
that.paused = true;
that.score = 0;
that.updateScore = true;
that.createTet();
break;
// Developer's Controls
case 35: // end key to move Tet up
if (that.devModeOn) {
if (that.currentTet.topLeft.row > 0) that.currentTet.topLeft.row--;
that.draw();
}
break;
case 48: case 49: case 50: case 51: case 52: // test cases found in TestCase.js
case 53: case 54: case 55: case 56: case 57: // number keys 0 to 9 (not numpad)
if (that.devModeOn) {
that.allTets = [];
that.gameOver = false;
that.score = 0;
that.updateScore = true;
that.testCase(e.keyCode - 48);
that.createTet();
that.tetDownLoop();
}
break;
case 71: // g for game over
if (that.devModeOn) {
that.gameOver = true;
clearInterval(that.loop);
//that.score =<PHONE_NUMBER>999999; // near max
that.score = Math.random() * 100000;
that.updateScore = true;
that.draw();
}
break;
case 72: // h to reset high score to zero
if (that.devModeOn) {
that.setHighScores([0,0,0,0,0,0,0,0,0,0]);
that.displayHighScores();
that.draw();
}
break;
case 192: // tilde key to toggle dev mode
that.devModeOn = that.devModeOn ? false : true;
that.draw();
break;
default:
console.log('unrecognized key: ' + e.keyCode);
}
}
}
/**
* This method is exclusively used in the handleEvents method. We call it every time we want to check if our Tet can be moved with the space bar/up/right/left/down key.
*
* @author Jared Gotte<EMAIL_ADDRESS>* @returns {boolean} If the Tet can move, based on the conditions within the function, then return true.
*/
Game.prototype.canTetMove = function () {
return (this.newTet === false && this.paused === false || this.devModeOn === true) && this.gameOver === false;
}
/**
* This method is used to get a floating point number and separate it with commas. We also round the number to the nearest integer.
*
* @author Jared Gotte<EMAIL_ADDRESS>* @returns {string} This is the comma separated number.
*/
Number.prototype.commaSeparate = function () { // comma separate number
var tmp = Math.floor(this);
if (tmp <=<PHONE_NUMBER>9999) {
while (/(\d+)(\d{3})/.test(tmp.toString())) // from http://stackoverflow.com/a/12947816
tmp = tmp.toString().replace(/(\d+)(\d{3})/, '$1' + ','+'$2');
}
else if (tmp ><PHONE_NUMBER>99999) tmp = tmp.toExponential(10);
return tmp;
}
/**
* This method updates the high score list that is displayed on the web page.
*
* @author Jared Gotte<EMAIL_ADDRESS>*/
Game.prototype.displayHighScores = function () {
var highScores = this.getHighScores(), html = '';
for (var i = 0, len = highScores.length; i < len; i++) {
html += '<li>' + highScores[i].commaSeparate() + '</li>';
}
document.getElementById(this.highScoresListId).innerHTML = html;
}
/**
* This method draws everything to the canvas.
*
* @author Jared Gotte<EMAIL_ADDRESS>*/
Game.prototype.draw = function () {
// Keys respectively reflect the HTML color code of Tets: I, J, L, O, S, T, Z
var tetColor = ['#3cc','#0af','#f90','#ee0','#0c0','#c0c','#c00'];
var c = this.canvas.getContext('2d');
c.clearRect(0, 0, this.canvas.width, 2 * this.canvas.width); // clear canvas
// Draw top panel
// paused
if (this.paused) {
c.fillStyle = '#f00';
c.font = "16px Arial";
c.fillText("PAUSED", 5, 74);
}
// score
c.fillStyle = '#000';
c.font = "16px Arial";
c.fillText("Score: " + this.score.commaSeparate(), 4, 17); // 16 numbers max, or 14 with commas. If beyond, switch to scientific notation.
// next Tet
c.font = "16px Arial";
c.fillText("Next:", 35, 50);
c.beginPath();
c.moveTo((this.nextTet.topLeft.col + this.nextTet.perimeter[0][0]) * this.blockS, (this.nextTet.topLeft.row + this.nextTet.perimeter[0][1]) * this.blockS + 37);
for (var row = 1, len = this.nextTet.perimeter.length; row < len; row++) {
c.lineTo((this.nextTet.topLeft.col + this.nextTet.perimeter[row][0]) * this.blockS, (this.nextTet.topLeft.row + this.nextTet.perimeter[row][1]) * this.blockS + 37);
}
c.closePath();
c.lineWidth = 2;
c.fillStyle = tetColor[this.nextTet.type];
c.fill();
c.strokeStyle = "#000";
c.stroke();
// separator line
c.beginPath();
c.moveTo(0, this.panelHeight);
c.lineTo(this.canvasWidth, this.panelHeight);
c.lineWidth = 2;
c.strokeStyle = "#eee";
c.stroke();
c.beginPath();
c.moveTo(0, this.panelHeight);
c.lineTo(4 * this.blockS - 3, this.panelHeight);
c.lineTo(4 * this.blockS - 3, 2 * this.blockS - 6);
c.lineTo(2 * 4 * this.blockS + 3, 2 * this.blockS - 6);
c.lineTo(2 * 4 * this.blockS + 3, this.panelHeight);
c.lineTo(this.canvasWidth, this.panelHeight);
c.lineWidth = 2;
c.strokeStyle = "#000";
c.stroke();
// dev mode
if (this.devModeOn) {
c.fillStyle = '#0a0';
c.font = "15px Arial";
c.fillText("DEV", 166, 74);
}
// Draw living Tet "shadow" at bottom and rotation
if (!this.newTet) {
var tmpPotTopLeft = { row: this.currentTet.topLeft.row + 1, col: this.currentTet.topLeft.col };
while (!this.currentTet.doesTetCollideBot(tmpPotTopLeft)) {
tmpPotTopLeft.row++;
}
tmpPotTopLeft.row--;
c.beginPath();
c.moveTo((tmpPotTopLeft.col + this.currentTet.perimeter[0][0]) * this.blockS, (tmpPotTopLeft.row + this.currentTet.perimeter[0][1]) * this.blockS + this.panelHeight);
for (var row = 1, len = this.currentTet.perimeter.length; row < len; row++) {
c.lineTo((tmpPotTopLeft.col + this.currentTet.perimeter[row][0]) * this.blockS, (tmpPotTopLeft.row + this.currentTet.perimeter[row][1]) * this.blockS + this.panelHeight);
}
c.closePath();
c.lineWidth = 2;
c.fillStyle = '#eee';
c.fill();
c.strokeStyle = "#ddd";
c.stroke();
// draw pivot shadow
if (this.currentTet.pivot > 0) {
potPerimeter = this.currentTet.doesNotTetPivotCollide();
if (potPerimeter !== false) {
c.beginPath();
c.moveTo((this.currentTet.topLeft.col + potPerimeter[0][0] + this.currentTet.pivot) * this.blockS, (this.currentTet.topLeft.row + potPerimeter[0][1]) * this.blockS + this.panelHeight);
for (var row = 1, len = this.currentTet.perimeter.length; row < len; row++) {
c.lineTo((this.currentTet.topLeft.col + potPerimeter[row][0] + this.currentTet.pivot) * this.blockS, (this.currentTet.topLeft.row + potPerimeter[row][1]) * this.blockS + this.panelHeight);
}
c.closePath();
c.lineWidth = 2;
c.globalAlpha = 0.5;
c.fillStyle = '#eee';
c.fill();
c.strokeStyle = "#ddd";
c.stroke();
c.globalAlpha = 1;
}
}
}
// Draw all Tets
for (var tet = 0, aTLen = this.allTets.length; tet < aTLen; tet++) {
var currTet = this.allTets[tet];
c.beginPath();
c.moveTo((currTet.topLeft.col + currTet.perimeter[0][0]) * this.blockS, (currTet.topLeft.row + currTet.perimeter[0][1]) * this.blockS + this.panelHeight);
for (var row = 1, len = currTet.perimeter.length; row < len; row++) {
c.lineTo((currTet.topLeft.col + currTet.perimeter[row][0]) * this.blockS, (currTet.topLeft.row + currTet.perimeter[row][1]) * this.blockS + this.panelHeight);
}
c.closePath();
c.lineWidth = 2;
c.fillStyle = tetColor[currTet.type];
c.fill();
c.strokeStyle = "#000";
c.stroke();
}
// Draw Game Over text if game is over
if (this.gameOver) {
// gray tint
c.globalAlpha = 0.8;
c.fillStyle = "#333";
c.fillRect(0, 0, this.canvas.width, 2 * this.canvas.width);
c.globalAlpha = 1;
// game over text
c.fillStyle = '#f00'; c.font = "bold 32px Arial";
c.fillText("GAME OVER", 3, 180);
c.strokeStyle = '#000'; c.lineWidth = 1;
c.strokeText("GAME OVER", 3, 180);
// your score
c.fillStyle = '#fff'; c.font = "bold 18px Arial";
c.fillText("Your Score:", 5, 220);
c.fillStyle = '#f00'; c.font = "bold 19px Arial";
c.fillText(this.score.commaSeparate(), 14, 240);
c.globalAlpha = 0.5;
c.strokeStyle = '#000'; c.lineWidth = 1; c.font = "bold 18px Arial";
c.strokeText("Your Score:", 5, 220);
c.font = "bold 19px Arial";
c.strokeText(this.score.commaSeparate(), 14, 240);
c.globalAlpha = 1;
// personal highest score
var highscores = this.checkHighScore();
c.fillStyle = '#fff'; c.font = "bold 17px Arial";
c.fillText("Personal Highest Score:", 5, 270);
c.fillStyle = '#f00'; c.font = "bold 19px Arial";
c.fillText(highscores[0].commaSeparate(), 14, 290);
c.globalAlpha = 0.3;
c.strokeStyle = '#000'; c.lineWidth = 1; c.font = "bold 17px Arial";
c.strokeText("Personal Highest Score:", 5, 270);
c.font = "bold 19px Arial";
c.strokeText(highscores[0].commaSeparate(), 14, 290);
c.globalAlpha = 1;
this.displayHighScores();
}
}
/**
* This method creates Tets. This also causes the Game Over screen to appear when we cannot create a new Tet.
*
* @author Jared Gotte<EMAIL_ADDRESS>*/
Game.prototype.createTet = function () {
// Make sure first Tet is not an S or Z
if (this.nextTet === null) {
var t = parseInt(Math.floor(Math.random() * 7));
if (t === 4 || t === 6) t--;
this.nextTet = new Tet(this, t);
}
// Build first Tet and next Tet
if (this.newTet) {
this.currentTet = this.nextTet;
this.nextTet = new Tet(this);
}
this.newTet = false;
// Display Game Over
if (this.currentTet.doesTetCollideBot(this.currentTet.topLeft)) {
this.nextTet = this.currentTet;
this.gameOver = true;
this.newTet = true;
clearInterval(this.loop);
return;
}
else this.allTets.push(this.currentTet);
this.draw();
}
/**
* This method creates a setInterval loop which moves our currentTet down at each interval.
*
* @author Jared Gotte<EMAIL_ADDRESS>*/
Game.prototype.tetDownLoop = function () {
clearInterval(this.loop); // safe guard to prevent multiple loops from spawning before clearing it out first
var that = this;
this.loop = setInterval(function(){
if (that.dropOnce && that.newTet) clearInterval(that.loop);
if (that.newTet) that.createTet();
else if (!that.paused) that.currentTet.moveDown();
that.draw();
}, that.dropInterval);
}
/**
* This method generates a landed array from allTets to be used to check for Tet/fragment collisions
*
* @author Jared Gotte<EMAIL_ADDRESS>* @param {Tet} [tet] - This parameter basically excludes the given Tet from allTets which are used to generate the landed array.
* @returns {Array.<Array.<number>>} Landed array generated
*/
Game.prototype.getLanded = function (tet) {
if (tet !== undefined) this.updateLanded = true;
if (this.updateLanded) {
for (var i = 0; i < this.BOARD_ROW_NUM; i++) {
this.landed[i] = [0,0,0,0,0,0,0,0,0,0];
}
for (var i = 0, aT = this.allTets, len = aT.length; i < len; i++) {
if (aT[i] === this.currentTet || aT[i] === tet) continue;
for (var row = 0, rLen = aT[i].shape.length; row < rLen; row++) {
for (var col = 0, cLen = aT[i].shape[row].length; col < cLen; col++) {
if (aT[i].shape[row][col] !== 0) {
this.landed[row + aT[i].topLeft.row][col + aT[i].topLeft.col] = 1;
}
}
}
}
this.updateLanded = false;
}
return this.landed;
}
/**
* This method inserts all zeros into the rows of the shape array if they are going to be removed. Once we do this, we call the updateLanded method.
*
* @author Jared Gotte<EMAIL_ADDRESS>* @param {Array.<number>} fullRows - This is the list of all rows that are to be removed from the Tet shapes.
*/
Game.prototype.alterShapes = function (fullRows) {
var firstRow = fullRows[0], lastRow = fullRows[fullRows.length - 1];
for (var tet = 0, len = this.allTets.length; tet < len; tet++) {
if (this.allTets[tet].topLeft.row <= firstRow - 4 || this.allTets[tet].topLeft.row > lastRow) continue;
this.allTets[tet].alterShape(fullRows);
}
//this.tetsToRemove.sort(function(a,b){ return a - b }); // ensures indices are in numeric order
for (var i = 0, len = this.tetsToRemove.length; i < len; i++) {
this.allTets.splice(this.tetsToRemove[i] - i, 1);
}
this.tetsToRemove = [];
this.updateLanded = true;
}
/**
* This method came from {@link http://www.w3schools.com/js/js_cookies.asp|W3Schools}. It allows us to use cookies to retrieve the user's info.
*
* @author Jared Gotte<EMAIL_ADDRESS>* @param {string} cName - This is the name of the cookie we want.
* @returns {string} This is the string extracted from our cookie.
*/
Game.prototype.getCookie = function (cName) {
var c_value = document.cookie, c_start = c_value.indexOf(" " + cName + "=");
if (c_start === -1) c_start = c_value.indexOf(cName + "=");
if (c_start === -1) c_value = null;
else {
c_start = c_value.indexOf("=", c_start) + 1;
var c_end = c_value.indexOf(";", c_start);
if (c_end === -1) c_end = c_value.length;
c_value = unescape(c_value.substring(c_start, c_end));
}
return c_value;
}
/**
* This method came from {@link http://www.w3schools.com/js/js_cookies.asp|W3Schools}. It allows us to use cookies to store the user's info.
*
* @author Jared Gotte<EMAIL_ADDRESS>* @param {string} cName - This is the name of the cookie we want.
* @param {string} value - This is the value of the cookie we want to set.
* @param {number} exDays - This is the expiration date of the cookie.
*/
Game.prototype.setCookie = function (cName, value, exDays) {
var exdate = new Date(), c_value;
exdate.setDate(exdate.getDate() + exDays);
c_value = escape(value) + ((exDays === null) ? "" : "; expires=" + exdate.toUTCString());
document.cookie = cName + "=" + c_value;
}
/**
* This method gets the user's high scores from their cookie.
*
* @author Jared Gotte<EMAIL_ADDRESS>* @returns {Array.<number>} This is the list of the high scores of the user.
*/
Game.prototype.getHighScores = function () {
var tmp = JSON.parse(this.getCookie("highScores"));
if (tmp === null) {
tmp = [this.score,0,0,0,0,0,0,0,0,0];
this.setHighScores(tmp);
}
return tmp;
}
/**
* This method saves the user's high scores into the cookie.
*
* @author Jared Gotte<EMAIL_ADDRESS>* @param {Array.<number>} v - This is the list of the high scores we're going to save in the cookie.
*/
Game.prototype.setHighScores = function (v) {
this.setCookie("highScores", JSON.stringify(v), 365);
}
/**
* This method basically adjusts the user's high scores if they made a higher score than before.
*
* @author Jared Gotte<EMAIL_ADDRESS>* @returns {Array.<number>} This is the list of the high scores of the user.
*/
Game.prototype.checkHighScore = function () {
var highScores = this.getHighScores();
if (this.updateScore === true) {
var hsLen = highScores.length;
for (var i = 0; i < hsLen; i++) {
if (this.score > highScores[i]) {
highScores.splice(i, 0, this.score);
break;
}
}
if (highScores.length > hsLen) highScores.pop();
this.setHighScores(highScores);
this.updateScore = false;
}
return highScores;
}
/**
* This function creates a Tet class intended to be instantiated by "new Tet()". However, upon completing a row in our Tetris game, we will want to remove the blocks in that row.
* In the case that our Tet becomes divided during the row removal, we will want to split the whole Tet into multiple Tet fragments which is when we will use "new Tet(-1)", then set its properties manually.
*
* @author Jared Gotte<EMAIL_ADDRESS>* @class Represents a Tet, both living and landed.
* @param {Game} game - Game object which the Tet will be in
* @param {number} [type] - Shape of Tet desired, determined randomly if undefined.
* @property {Game} game - Game object which the Tet is in
* @property {number} type - Initially only used to determined its shape upon our class being constructed. If in range [0..6] (number of Tets), set its properties appropriately.
* If -1, we will create a Tet with empty properties because we're going to set its topLeft, shape and perimeter manually.
* @property {number} rotation - Rotation is constrained by the range [0..3]. Incrementing the rotation basically rotates the shape clockwise. This rotation decides our this.shape and this.perimeter.
* @property {number} pivot - This is the number of rows we are going to move our tet when we decide to rotate it. Constraints are from [0..this.pivotMax].
* @property {number} pivotMax - This is the maximum amount of times a block can be pivoted.
* @property {{row: number, col: number}} topLeft - This is the (row, column) position the Tet is in with respect to the game board (16 rows by 10 columns); (0, 0) being the most top left position.
* @property {number} topLeft.row - Row position of Tet on board.
* @property {number} topLeft.col - Column position of Tet on board.
* @property {Array.<Array.<number>>} shape - Shape of Tet, e.g. _shape = [[1,1,1,1]] is horizontal I Tetrimino where [[1],[1],[1],[1]] is vertical I Tet. Number of 0 indicates empty space.
* @property {Array.<Array.<number>>} perimeter - Perimeter of Tet, e.g. _perimeter = [[0,0],[0,1],[4,1],[4,0]] is horizontal I Tet perimeter where [[0,0],[0,4],[1,4],[1,0]] is vertical I Tet.
* Imagine Tetriminos being expressed as 4 "blocks," each block's side would be _s pixels in magnitude, where _s is the variable blockS defined in index.php.
* Therefore, we can determine its perimeter by taking the "(x, y) coordinates" in each "row" of _perimeter, and multiplying each x and y value by _s.
*/
function Tet (game, type) {
if (!(this instanceof arguments.callee)) return new Tet(game, type); // force instantiation
this.game = game;
if (type >= -1 && type < 7) this.type = type;
else this.type = parseInt(Math.floor(Math.random() * 7));
if (this.type > -1) {
this.rotation = 0;
this.pivot = 0;
this.topLeft = { row: 0, col: 4 };
this.setShape(this.getShapeMatrix(0));
}
}
/**
* This method takes in a Tet type and rotation then outputs its shape matrix. This method is only needed on a live Tet. I.e. if a Tet is already placed on the landed array, this method will not be used.
*
* @author Jared Gotte<EMAIL_ADDRESS>* @param {number} rotation - Rotation of shape, determined by user input.
* @returns {Array.<Array.<number>>} Number matrix of shape. If type is unexpected, return empty array.
*/
Tet.prototype.getShapeMatrix = function (rotation) {
// Shapes from http://en.wikipedia.org/wiki/Tetris#Colors_of_Tetriminos
// Note that the numbers in these arrays denote their eventual color
var matrixMatrix = [
[ [[1,1,1,1]], [[1],[1],[1],[1]] ], // I
[ [[1,1,1],[0,0,1]], [[0,1],[0,1],[1,1]], [[1 ],[1,1,1]], [[1,1],[1 ],[1 ]] ], // J
[ [[1,1,1],[1 ]], [[1,1],[0,1],[0,1]], [[0,0,1],[1,1,1]], [[1 ],[1 ],[1,1]] ], // L
[ [[1,1],[1,1]] ], // O
[ [[0,1,1],[1,1 ]], [[1 ],[1,1],[0,1]] ], // S
[ [[1,1,1],[0,1 ]], [[0,1],[1,1],[0,1]], [[0,1 ],[1,1,1]], [[1 ],[1,1],[1 ]] ], // T
[ [[1,1 ],[0,1,1]], [[0,1],[1,1],[1 ]] ], // Z
], m = matrixMatrix[this.type];
this.pivotMax = this.type === 0 ? 3 : 1; // I needs 3 pivots where every other Tet needs 1
if (this.type === 3) this.pivotMax = 0; // except O
switch (m.length) {
case 1:
return m[0];
case 2:
return m[rotation % 2];
case 4:
return m[rotation];
default:
//console.log('unexpected array length in function ' + arguments.callee.toString().substr(9, arguments.callee.toString().indexOf('(') - 9));
return [];
}
}
/**
* This method is used any time a living/landed Tet's shape is created/altered.
* Upon breaking up a tet, make sure these conditions are met on its new shape:
* 1) Remove trailing zeros from each row, e.g. [1,0] becomes [1];
* 2) If new shape is one row, remove leading zeros, e.g. [0,1] becomes [1]. Which they are in the Tet.cleanShape() method.
*
* @author Jared Gotte<EMAIL_ADDRESS>* @param {Array.<Array.<number>>} shape - This is the shape of the Tet we care about getting the perimeter from.
* @returns {Array.<Array.<number>>} Perimeter of shape. If shape is unknown, return empty array.
*/
Tet.prototype.getPerimeter = function (shape) {
var periMatrix = [
[ [[1]], [[0,0],[0,1],[1,1],[1,0]] ], // fragments
[ [[1,1]], [[0,0],[0,1],[2,1],[2,0]] ],
[ [[1],[1]], [[0,0],[0,2],[1,2],[1,0]] ],
[ [[1,1,1]], [[0,0],[0,1],[3,1],[3,0]] ],
[ [[1],[1],[1]], [[0,0],[0,3],[1,3],[1,0]] ],
[ [[1,1],[0,1]], [[0,0],[0,1],[1,1],[1,2],[2,2],[2,0]] ],
[ [[0,1],[1,1]], [[1,0],[1,1],[0,1],[0,2],[2,2],[2,0]] ],
[ [[1 ],[1,1]], [[0,0],[0,2],[2,2],[2,1],[1,1],[1,0]] ],
[ [[1,1],[1 ]], [[0,0],[0,2],[1,2],[1,1],[2,1],[2,0]] ],
[ [[1,1,1,1]], [[0,0],[0,1],[4,1],[4,0]] ], // I
[ [[1],[1],[1],[1]], [[0,0],[0,4],[1,4],[1,0]] ],
[ [[1,1,1],[0,0,1]], [[0,0],[0,1],[2,1],[2,2],[3,2],[3,0]] ], // J
[ [[0,1],[0,1],[1,1]], [[1,0],[1,2],[0,2],[0,3],[2,3],[2,0]] ],
[ [[1 ],[1,1,1]], [[0,0],[0,2],[3,2],[3,1],[1,1],[1,0]] ],
[ [[1,1],[1 ],[1 ]], [[0,0],[0,3],[1,3],[1,1],[2,1],[2,0]] ],
[ [[1,1,1],[1 ]], [[0,0],[0,2],[1,2],[1,1],[3,1],[3,0]] ], // L
[ [[1,1],[0,1],[0,1]], [[0,0],[0,1],[1,1],[1,3],[2,3],[2,0]] ],
[ [[0,0,1],[1,1,1]], [[2,0],[2,1],[0,1],[0,2],[3,2],[3,0]] ],
[ [[1 ],[1 ],[1,1]], [[0,0],[0,3],[2,3],[2,2],[1,2],[1,0]] ],
[ [[1,1],[1,1]], [[0,0],[0,2],[2,2],[2,0]] ], // O
[ [[0,1,1],[1,1 ]], [[1,0],[1,1],[0,1],[0,2],[2,2],[2,1],[3,1],[3,0]] ], // S
[ [[1 ],[1,1],[0,1]], [[0,0],[0,2],[1,2],[1,3],[2,3],[2,1],[1,1],[1,0]] ],
[ [[1,1,1],[0,1 ]], [[0,0],[0,1],[1,1],[1,2],[2,2],[2,1],[3,1],[3,0]] ], // T
[ [[0,1],[1,1],[0,1]], [[1,0],[1,1],[0,1],[0,2],[1,2],[1,3],[2,3],[2,0]] ],
[ [[0,1 ],[1,1,1]], [[1,0],[1,1],[0,1],[0,2],[3,2],[3,1],[2,1],[2,0]] ],
[ [[1 ],[1,1],[1 ]], [[0,0],[0,3],[1,3],[1,2],[2,2],[2,1],[1,1],[1,0]] ],
[ [[1,1 ],[0,1,1]], [[0,0],[0,1],[1,1],[1,2],[3,2],[3,1],[2,1],[2,0]] ], // Z
[ [[0,1],[1,1],[1 ]], [[1,0],[1,1],[0,1],[0,3],[1,3],[1,2],[2,2],[2,0]] ]
], checkNextShape;
// Iterate through periMatrix to see if the given shape matches a shape within this array
for (var pRow = 0, pLen = periMatrix.length; pRow < pLen; pRow++) {
checkNextShape = false;
for (var row = 0, rLen = shape.length; row < rLen; row++) {
if (rLen !== periMatrix[pRow][0].length) {
checkNextShape = true;
break;
}
if (checkNextShape) break;
for (var col = 0, cLen = shape[row].length; col < cLen; col++) {
if (shape[row].length !== periMatrix[pRow][0][row].length) {
checkNextShape = true;
break;
}
if (shape[row][col] === periMatrix[pRow][0][row][col]) {
continue;
}
checkNextShape = true;
break;
}
}
if (!checkNextShape) {
// if it gets to this point, we found our point array
return periMatrix[pRow][1];
}
}
return [];
}
/**
* This method actually sets the shape and perimeter of the Tet that's executing this method.
*
* @author Jared Gotte<EMAIL_ADDRESS>* @param {Array.<Array.<number>>} shape - This is the shape of the Tet we care about getting the perimeter from.
*/
Tet.prototype.setShape = function (shape) {
this.shape = shape;
this.perimeter = this.getPerimeter(shape);
}
/**
* This method changes the rotation, if the shape can rotate properly on the game board, and changes the shape and perimeter if it successfully rotates. Otherwise, do nothing.
* We also move the Tet this.pivot blocks to the right, then reset the pivot to zero.
*
* @author Jared Gotte<EMAIL_ADDRESS>* @param {Array.<Array.<number>>} shape - This is the shape of the Tet we care about getting the perimeter from.
* @returns {boolean} Currently, we don't care about the actual return value.
*/
Tet.prototype.rotate = function () { // by default, always clockwise
var landed = this.game.getLanded(), potRot = this.rotation, potShape;
potRot = potRot < 3 ? potRot + 1 : 0;
potShape = this.getShapeMatrix(potRot);
// check for potential collisions
for (var row = 0, rLen = potShape.length; row < rLen; row++) {
for (var col = 0, cLen = potShape[row].length; col < cLen; col++) {
if (potShape[row][col] !== 0) {
if (col + this.topLeft.col < 0) {
//console.log('left beyond playing field');
return false;
}
if (col + this.topLeft.col >= this.game.BOARD_COL_NUM) {
//console.log('right beyond playing field');
return false;
}
if (row + this.topLeft.row >= this.game.BOARD_ROW_NUM) {
//console.log('below playing field');
return false;
}
if (landed[row + this.topLeft.row][col + this.topLeft.col] !== 0) {
//console.log('rotate: space is taken');
return false;
}
}
}
}
this.topLeft.col += this.pivot;
this.pivot = 0;
this.rotation = potRot;
this.setShape(potShape);
return true;
}
/**
* This method checks to see if the pivot shape shadow can display properly.
*
* @author Jared Gotte<EMAIL_ADDRESS>* @returns {Array.<Array.<number>>} This returns the perimeter matrix given by the getPerimeter() method.
*/
Tet.prototype.doesNotTetPivotCollide = function () {
var potRot = this.rotation, potentialTopLeft = { row: this.topLeft.row, col: this.topLeft.col + this.pivot }, potShape, landed = this.game.getLanded(this);
potRot = potRot < 3 ? potRot + 1 : 0;
potShape = this.getShapeMatrix(potRot);
for (var row = 0, rLen = potShape.length; row < rLen; row++) {
for (var col = 0, cLen = potShape[row].length; col < cLen; col++) {
if (potShape[row][col] !== 0) {
if (row + potentialTopLeft.row >= this.game.BOARD_ROW_NUM) {
//console.log('below playing field');
return false;
}
if (landed[row + potentialTopLeft.row][col + potentialTopLeft.col] !== 0) {
//console.log('bot: space taken');
return false;
}
if (col + potentialTopLeft.col < 0) {
//console.log('left beyond playing field');
return false;
}
if (col + potentialTopLeft.col >= this.game.BOARD_COL_NUM) {
//console.log('right beyond playing field');
return false;
}
if (landed[row + potentialTopLeft.row][col + potentialTopLeft.col] !== 0) {
//console.log('side: space taken');
return false;
}
}
}
}
return this.getPerimeter(potShape);
}
/**
* This method checks to see if a Tet will collide with the bottom of the game board or another Tet.
*
* @author Jared Gotte<EMAIL_ADDRESS>* @param {{row: number, col: number}} potentialTopLeft - This object contains a potential row and column which we use to check to see if the Tet will collide if it moves to the coordinate specified by this param.
* @returns {boolean} If Tet colides, return true; else, false.
*/
Tet.prototype.doesTetCollideBot = function (potentialTopLeft) {
var landed = this.game.getLanded(this);
for (var row = 0, rLen = this.shape.length; row < rLen; row++) {
for (var col = 0, cLen = this.shape[row].length; col < cLen; col++) {
if (this.shape[row][col] !== 0) {
if (row + potentialTopLeft.row >= this.game.BOARD_ROW_NUM) {
//console.log('below playing field');
return true;
}
if (landed[row + potentialTopLeft.row][col + potentialTopLeft.col] !== 0) {
//console.log('bot: space taken');
return true;
}
}
}
}
return false;
}
/**
* This method checks to see if a Tet will collide with the side of the game board or another Tet. If it collides on the right side of the Tet, we'll adjust the pivot as necessary.
*
* @author Jared Gotte<EMAIL_ADDRESS>* @param {{row: number, col: number}} potentialTopLeft - This object contains a potential row and column which we use to check to see if the Tet will collide if it moves to the coordinate specified by this param.
* @param {number} [direction] - If value is 1, we are testing the right side and we're going to adjust the pivot.
* @returns {boolean} If Tet colides, return true; else, false.
*/
Tet.prototype.doesTetCollideSide = function (potentialTopLeft, direction) {
var landed = this.game.getLanded();
for (var row = 0, rLen = this.shape.length; row < rLen; row++) {
for (var col = 0, cLen = this.shape[row].length; col < cLen; col++) {
if (this.shape[row][col] !== 0) {
if (col + potentialTopLeft.col < 0) {
//console.log('left beyond playing field');
return true;
}
if (col + potentialTopLeft.col >= this.game.BOARD_COL_NUM) {
//console.log('right beyond playing field');
if (this.pivot < this.pivotMax && this.rotation % 2 === 0) this.pivot++;
return true;
}
if (landed[row + potentialTopLeft.row][col + potentialTopLeft.col] !== 0) {
//console.log('side: space taken');
if (direction === 1) if (this.pivot < this.pivotMax && this.rotation % 2 === 0) this.pivot++;
return true;
}
}
}
}
return false;
}
/**
* This method moves the Tet left by 1 column if it does not collide with the side of the game board or another Tet.
* This method also resets the pivot to zero.
*
* @author Jared Gotte<EMAIL_ADDRESS>*/
Tet.prototype.moveLeft = function () {
this.pivot = 0;
var potentialTopLeft = { row: this.topLeft.row, col: this.topLeft.col - 1 };
if (!this.doesTetCollideSide(potentialTopLeft)) this.topLeft = potentialTopLeft;
}
/**
* This method moves the Tet right by 1 column if it does not collide with the side of the game board or another Tet.
*
* @author Jared Gotte<EMAIL_ADDRESS>*/
Tet.prototype.moveRight = function () {
var potentialTopLeft = { row: this.topLeft.row, col: this.topLeft.col + 1 };
if (!this.doesTetCollideSide(potentialTopLeft, 1)) this.topLeft = potentialTopLeft;
}
/**
* This method moves the Tet down by 1 column if it does not collide with the side of the game board or another Tet.
* If it does collide, the Tet lands, we create another Tet, and we perform the collided method to handle row elimination and Tet fragmentation.
*
* @author Jared Gotte<EMAIL_ADDRESS>*/
Tet.prototype.moveDown = function () {
var potentialTopLeft = { row: this.topLeft.row + 1, col: this.topLeft.col };
if (!this.doesTetCollideBot(potentialTopLeft)) this.topLeft = potentialTopLeft;
else {
this.game.newTet = true;
this.game.currentTet = null;
this.game.updateLanded = true;
this.collided();
}
}
/**
* This method handles row elimination and Tet fragmentation. We also adjust the score depending on how many rows get eliminated.
* The score scales with how many rows get eliminated at once by the following formula:
* score += Math.pow(rows_eliminated, 1 + (rows_eliminated - 1) * 0.1) * 10000
* We then perform the falling animations on the Tets affected by "gravity."
*
* @author Jared Gotte<EMAIL_ADDRESS>*/
Tet.prototype.collided = function () {
var landed = this.game.getLanded(), isFilled, fullRows = [], fRLen;
// Find the rows we're going to eliminate
for (var row = this.topLeft.row; row < this.game.BOARD_ROW_NUM; row++) {
isFilled = true;
for (var col = 0; col < this.game.BOARD_COL_NUM; col++)
if (landed[row][col] === 0) isFilled = false;
if (isFilled) fullRows.push(row);
}
this.game.updateLanded = true;
fRLen = fullRows.length;
if (fRLen === 0) return;
// Adjust score
this.game.score += Math.pow(fRLen, 1 + (fRLen - 1) * 0.1) * 10000; // Scale the point rewarded for filling rows to benefit those that break more at one time.
// Alter the shapes
this.game.alterShapes(fullRows);
this.game.updateLanded = true;
// Perform falling animations
var that = this, movingTets = [0], tetsMoved,
moveLoop = setInterval( function() {
movingTets = [];
tetsMoved = true;
while (tetsMoved) {
tetsMoved = false;
for (tet = 0, aT = that.game.allTets, tLen = aT.length, potTL = null; tet < tLen; tet++) {
if (movingTets.indexOf(aT[tet], 0) > -1 || (aT[tet] === that.game.currentTet && that.game.newTet !== true)) continue;
potTL = { row: aT[tet].topLeft.row + 1, col: aT[tet].topLeft.col };
if (!aT[tet].doesTetCollideBot(potTL)) {
aT[tet].topLeft = potTL;
movingTets.push(aT[tet]);
tetsMoved = true;
}
}
that.game.updateLanded = true;
}
that.game.draw();
if (movingTets.length === 0) {
clearInterval(moveLoop);
that.collided();
}
}, 200);
}
/**
* This method cleans up a Tet or Tet fragment, after being affected the by collided method which affects the shape of Tets located in the rows being eliminated.
* By cleaning, we mean removing extraneous zeros from their shape matrix as well as adjusting their topLeft property.
* We clean them so that we can match its shape against a known Tet/fragment so we can determine its perimeter.
*
* @author Jared Gotte<EMAIL_ADDRESS>* @param {{shape: Array.<Array.<number>>, topLeft: {row: number, col: number}}} o - This is a object which holds a shape and a topLeft property.
* @returns {{shape: Array.<Array.<number>>, topLeft: {row: number, col: number}}} This is the cleaned up shape, without extraneous zeros, and adjusted topLeft.
*/
Tet.prototype.cleanShape = function (o) {
var shape = o.shape, topLeft = o.topLeft, done = false;
// If there exists columns of all zeros on the far left, remove all those columns
while (true) {
for (var row = 0, len = shape.length; row < len; row++)
if (shape[row][0] > 0) {
done = true;
break;
}
if (done) break;
for (var row = 0, len = shape.length; row < len; row++)
shape[row].splice(0,1);
// Adjust topLeft if necessary
topLeft.col += 1;
}
// If there exists zeros at the end of each row array, remove those zeros
for (var row = 0, len = shape.length; row < len; row++) {
for (var col = shape[row].length - 1; col >= 0; col--) {
if (shape[row][col] === 0) {
shape[row].splice(col,1);
continue;
}
break;
}
}
return { shape: shape, topLeft: topLeft };
}
/**
* This method checks to see if itself, an array, is all zeros.
*
* @author Jared Gotte<EMAIL_ADDRESS>* @returns {boolean} If itself is all zeros, return true; else, false.
*/
Array.prototype.allZeros = function () { // Checks if an Array is all zeros or not
for (var col = 0, len = this.length; col < len; col++)
if (this[col] > 0) return false;
return true;
}
/**
* This method parses its own shape to determine if it needs to fragment or not. If it becomes fragmented, we instantiate a new Tet class to add in its fragmented part.
*
* @author Jared Gotte<EMAIL_ADDRESS>*/
Tet.prototype.updateTet = function () {
var currShape = [], topLeft, q = [];
// Iterate through the altered shape to build multiple fragments if necessary
for (var row = 0, len = this.shape.length; row < len; row++) {
// If we do not come across a row with all zeros, continue building our shape
if (!this.shape[row].allZeros()) {
if (currShape.length === 0) topLeft = { row: this.topLeft.row + row, col: this.topLeft.col };
currShape.push(this.shape[row]);
}
// Otherwise, push this current shape only the queue and reset our temporary shape to potentially build another
else {
if (currShape.length === 0) continue;
q.push({ shape: currShape, topLeft: topLeft });
currShape = [];
}
}
if (currShape.length > 0) q.push({ shape: currShape, topLeft: topLeft });
if (q.length === 0) this.game.tetsToRemove.push(this.game.allTets.indexOf(this)); // Remove this Tet from allTets if shape is a zero'd matrix (Tet completely gone)
// Iterate through our queue
for (var qs = 0, len = q.length; qs < len; qs++) {
var tmp = this.cleanShape(q[qs]);
// For the first object in the queue, keep our current Tet and just set the shape
if (qs === 0) {
this.topLeft = tmp.topLeft;
this.setShape(tmp.shape);
}
// For all other objects in the queue, create a new Tet class and set its shape, then push this new Tet onto the allTets Game class property
else {
var newTet = new Tet(this.game, -1);
newTet.type = this.type;
newTet.topLeft = tmp.topLeft;
newTet.setShape(tmp.shape);
this.game.allTets.push(newTet);
}
}
}
/**
* This method sets each row within its shape to zero for each row marked as full.
*
* @author Jared Gotte<EMAIL_ADDRESS>* @param {Array.<number>} fullRows - This is an array of all of the rows that were marked as full in the collided method above.
*/
Tet.prototype.alterShape = function (fullRows) {
for (var i = 0, len = fullRows.length, row; i < len; i++) {
row = fullRows[i] - this.topLeft.row;
if (row < 0 || row > this.shape.length - 1) continue;
for (var col = 0, cLen = this.shape[row].length; col < cLen; col++) {
this.shape[row][col] = 0;
}
}
this.updateTet();
}


I know a guy, who knows a guy...
Open more browsers tabs, other browsers windows and try in your smartphone to view their connecting to each other


Interactive Device Control
Communication Interface
Type
GPIB Options
GPIB Primary Address *
GPIB Secondary Address *
Use Secondary GPIB Address
* Some GPIB controllers do not use a primary or secondary address (i.e. Prologix GPIB TCP/USB)


A Query Engine for Probabilistic Preferences
Cohen, Uzi,
Kenig, Batya,
Ping, Haoyue,
Kimelfeld, Benny,
and
Stoyanovich, JuliaIn Proceedings of the 2018 International Conference on Management of
Data, SIGMOD Conference 2018, Houston, TX, USA, June 10-15, 2018
2018
Probabilistic Inference Over Repeated Insertion Models
Kenig, Batya,
Ilijasic, Lovro,
Ping, Haoyue,
Kimelfeld, Benny,
and
Stoyanovich, JuliaIn Proceedings of the Thirty-Second AAAI Conference on Artificial Intelligence,
New Orleans, Louisiana, USA, February 2-7, 2018
2018
2017
A Database Framework for Probabilistic Preferences
Kenig, Batya,
Kimelfeld, Benny,
Ping, Haoyue,
and
Stoyanovich, JuliaIn Proceedings of the 11th Alberto Mendelzon International Workshop on
Foundations of Data Management and the Web, Montevideo, Uruguay, June
7-9, 2017.
2017
Querying Probabilistic Preferences in Databases
Kenig, Batya,
Kimelfeld, Benny,
Ping, Haoyue,
and
Stoyanovich, JuliaIn Proceedings of the 36th ACM SIGMOD-SIGACT-SIGAI Symposium on Principles
of Database Systems, PODS 2017, Chicago, IL, USA, May 14-19, 2017
2017
DataSynthesizer: Privacy-Preserving Synthetic DatasetsPing, Haoyue,
Stoyanovich, Julia,
and
Howe, BillIn Proceedings of the 29th International Conference on Scientific and
Statistical Database Management, Chicago, IL, USA, June 27-29, 2017
2017
Synthetic Data for Social GoodHowe, Bill,
Stoyanovich, Julia,
Ping, Haoyue,
Herman, Bernease,
and
Gee, Matt
CoRR
2017
2016
Workload-driven learning of mallows mixtures with pairwise preference
dataStoyanovich, Julia,
Ilijasic, Lovro,
and
Ping, HaoyueIn Proceedings of the 19th International Workshop on Web and Databases,
San Francisco, CA, USA, June 26, 2016
2016


Interactive 1
GRAPH-212-02 CCA SF Campus, Lab B T/TR 4–7pm Instructor:
Livia Foldes
TA:
Jillian Luo
IA:
Henry Rivera
Syllabus
People
Calendar
Projects
Resources
Library
Menu
Projects
Project 2: CSS Typeface
Project 1: Online Zine
Workshop: Weekly Exercises


| Opcode/Instruction | Op /En | 64/32 bit Mode Support | CPUID Feature Flag | Description |
|---|---|---|---|---|
|
EVEX.128.66.0F38.W0 4E /r VRSQRT14PS xmm1 {k1}{z}, xmm2/m128/m32bcst |
FV | V/V | AVX512VL AVX512F | Computes the approximate reciprocal square roots of the packed single-precision floating-point values in xmm2/m128/m32bcst and stores the results in xmm1. Under writemask. |
|
EVEX.256.66.0F38.W0 4E /r VRSQRT14PS ymm1 {k1}{z}, ymm2/m256/m32bcst |
FV | V/V | AVX512VL AVX512F | Computes the approximate reciprocal square roots of the packed single-precision floating-point values in ymm2/m256/m32bcst and stores the results in ymm1. Under writemask. |
|
EVEX.512.66.0F38.W0 4E /r VRSQRT14PS zmm1 {k1}{z}, zmm2/m512/m32bcst |
FV | V/V | AVX512F | Computes the approximate reciprocal square roots of the packed single-precision floating-point values in zmm2/m512/m32bcst and stores the results in zmm1. Under writemask. |
| Op/En | Operand 1 | Operand 2 | Operand 3 | Operand 4 |
| FV | ModRM:reg (w) | ModRM:r/m (r) | NA | NA |
Description
This instruction performs a SIMD computation of the approximate reciprocals of the square roots of 16 packed single-precision floating-point values in the source operand (the second operand) and stores the packed single-precision floating-point results in the destination operand (the first operand) according to the writemask. The maximum relative error for this approximation is less than 2-14.
EVEX.512 encoded version: The source operand can be a ZMM register, a 512-bit memory location or a 512-bit vector broadcasted from a 32-bit memory location. The destination operand is a ZMM register, conditionally updated using writemask k1.
EVEX.256 encoded version: The source operand is a YMM register, a 256-bit memory location, or a 256-bit vector broadcasted from a 32-bit memory location. The destination operand is a YMM register, conditionally updated using writemask k1.
EVEX.128 encoded version: The source operand is a XMM register, a 128-bit memory location, or a 128-bit vector broadcasted from a 32-bit memory location. The destination operand is a XMM register, conditionally updated using writemask k1.
The VRSQRT14PS instruction is not affected by the rounding control bits in the MXCSR register. When a source value is a 0.0, an ∞ with the sign of the source value is returned. When the source operand is an +∞ then +ZERO value is returned. A denormal source value is treated as zero only if DAZ bit is set in MXCSR. Otherwise it is treated correctly and performs the approximation with the specified masked response. When a source value is a negative value (other than 0.0) a floating-point QNaN_indefinite is returned. When a source value is an SNaN or QNaN, the SNaN is converted to a QNaN or the source QNaN is returned.
MXCSR exception flags are not affected by this instruction and floating-point exceptions are not reported.
Note: EVEX.vvvv is reserved and must be 1111b, otherwise instructions will #UD.
A numerically exact implementation of VRSQRT14xx can be found at https://software.intel.com/en-us/arti-cles/reference-implementations-for-IA-approximation-instructions-vrcp14-vrsqrt14-vrcp28-vrsqrt28-vexp2.
Operation
VRSQRT14PS (EVEX encoded versions)
(KL, VL) = (4, 128), (8, 256), (16, 512)
FOR j (cid:197) 0 TO KL-1
i (cid:197) j * 32
IF k1[j] OR *no writemask* THEN
IF (EVEX.b = 1) AND (SRC *is memory*)
THEN DEST[i+31:i] (cid:197) APPROXIMATE(1.0/ SQRT(SRC[31:0]));
ELSE DEST[i+31:i] (cid:197) APPROXIMATE(1.0/ SQRT(SRC[i+31:i]));
FI;
ELSE
IF *merging-masking*
; merging-masking
THEN *DEST[i+31:i] remains unchanged*
ELSE
; zeroing-masking
DEST[i+31:i] (cid:197) 0
FI;
FI;
ENDFOR;
DEST[MAX_VL-1:VL] (cid:197) 0
| Input value | Result value | Comments |
|---|---|---|
| Any denormal | Normal | Cannot generate overflow |
| X = 2-2n | 2n | |
| X < 0 | QNaN_Indefinite | Including -INF |
| X = -0 | -INF | |
| X = +0 | +INF | |
| X = +INF | +0 |
Intel C/C++ Compiler Intrinsic Equivalent
VRSQRT14PS __m512 _mm512_rsqrt14_ps( __m512 a);
VRSQRT14PS __m512 _mm512_mask_rsqrt14_ps(__m512 s, __mmask16 k, __m512 a);
VRSQRT14PS __m512 _mm512_maskz_rsqrt14_ps( __mmask16 k, __m512 a);
VRSQRT14PS __m256 _mm256_rsqrt14_ps( __m256 a);
VRSQRT14PS __m256 _mm256_mask_rsqrt14_ps(__m256 s, __mmask8 k, __m256 a);
VRSQRT14PS __m256 _mm256_maskz_rsqrt14_ps( __mmask8 k, __m256 a);
VRSQRT14PS __m128 _mm_rsqrt14_ps( __m128 a);
VRSQRT14PS __m128 _mm_mask_rsqrt14_ps(__m128 s, __mmask8 k, __m128 a);
VRSQRT14PS __m128 _mm_maskz_rsqrt14_ps( __mmask8 k, __m128 a);
SIMD Floating-Point Exceptions
None
Other Exceptions
See Exceptions Type 4.


":"; exec mzscheme -r $0 "$@"
;;; ----------------------------------------------------
;;; Filename: mkstpwdlst.ss
;;; Author: Damir Cavar<EMAIL_ADDRESS>;;;
;;; (C) 2006 by Damir Cavar
;;;
;;; This code is published under the restrictive GPL!
;;; Please find the text of the GPL here:
;;; http://www.gnu.org/licenses/gpl.txt
;;;
;;; It is free for use, change, etc. as long as the copyright
;;; note above is included in any modified version of the code.
;;;
;;; This script assumes that the text is raw and encoded in UTF8.
;;;
;;; Functions:
;;; 1. The text with stop-words is loaded into memory.
;;; 2. The text is tokenized, i.e. converted into a list of tokens.
;;; 3. A list of tokens is displayed, and can be redirected into
;;; a Scheme source file, see Usage.
;;;
;;; Usage:
;;; mzscheme -r mkstpwdlst.ss english.txt > english.ss
;;; ----------------------------------------------------
(require (lib "vector-lib.ss" "srfi" "43")) ; for vector-for-each
(require (lib "string.ss" "srfi" "13")) ; for string-tokenize
;;; load-file
;;; <- string filename
;;; -> string file content
;;; ----------------------------------------------------
;;; Load text from file into a string variable and return it.
(define load-file
(lambda (name)
(let* ((size (file-size name)))
(call-with-input-file name
(lambda (p)
(read-string size p))))))
(begin
(vector-for-each (lambda (i fname)
(let ([text (string-tokenize (load-file fname))])
(display "(define stopwords '")
(write text)
(display ")")
(newline)))
argv))


Interface ISkill
Interface for skills in the game.
Namespace: Fibula.Mechanics.Contracts.Abstractions
Assembly: Fibula.Mechanics.Contracts.dll
Syntax
public interface ISkill
Properties
| Improve this Doc View SourceBaseTargetIncrease
Gets this skill's target base increase level over level.
Declaration
double BaseTargetIncrease { get; }
Property Value
| Type | Description |
|---|---|
| System.Double |
Count
Gets this skill's current count.
Declaration
double Count { get; }
Property Value
| Type | Description |
|---|---|
| System.Double |
DefaultLevel
Gets this skill's default level.
Declaration
uint DefaultLevel { get; }
Property Value
| Type | Description |
|---|---|
| System.UInt32 |
Level
Gets this skill's level.
Declaration
uint Level { get; }
Property Value
| Type | Description |
|---|---|
| System.UInt32 |
MaxLevel
Gets this skill's maximum level.
Declaration
uint MaxLevel { get; }
Property Value
| Type | Description |
|---|---|
| System.UInt32 |
Percent
Gets the current percentual value between current and target counts this skill.
Declaration
byte Percent { get; }
Property Value
| Type | Description |
|---|---|
| System.Byte |
Rate
Gets this skill's rate of target count increase.
Declaration
double Rate { get; }
Property Value
| Type | Description |
|---|---|
| System.Double |
StartingCount
Gets the count at which the current level starts.
Declaration
double StartingCount { get; }
Property Value
| Type | Description |
|---|---|
| System.Double |
TargetCount
Gets this skill's target count.
Declaration
double TargetCount { get; }
Property Value
| Type | Description |
|---|---|
| System.Double |
Type
Gets this skill's type.
Declaration
SkillType Type { get; }
Property Value
| Type | Description |
|---|---|
| SkillType |
Methods
| Improve this Doc View SourceIncreaseCounter(Double)
Increases this skill's counter.
Declaration
void IncreaseCounter(double value)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Double | value | The amount by which to increase this skills counter. |
Events
| Improve this Doc View SourceChanged
Event triggered when this skill changes.
Declaration
event OnSkillChanged Changed
Event Type
| Type | Description |
|---|---|
| OnSkillChanged |


|
404 Circuit Simulator
1.0.0
A CLI clone of SPICE circuit solver
|
2.2 Assumptions and Dependencies
3 System Features and Requirements
3.2 External Interface Requirements
3.4 Nonfunctional Requirements
The purpose of this software is to simulate circuits and solve voltages at every node and currents of every component by using nodal analysis. This software emulates LT Spice, however, using a command line interface.
Our intended audience would be electrical engineers who would prefer a less bloated and cross platform solution than LT Spice. This would also include other developers who would like to fork this project, or testers to ensure our program is bug-free.
Intended use would be to generate output data files using our simulator that can be viewed using our python script, specifically we accept net lists in the exact same format as LT Spice, however, we have yet to implement specific models.
Our circuit simulator uses conductance matrices to calculate voltages and currents using methods such as basic nodal analysis, iteration and equivalent models to certain components. Our goals while pursuing this project, was to create a much more performant alternative, with a nicer UI, compared to LT Spice. The benefits to using our program, is speed, <Insert benchmarks here>, simplicity, control of output format.
Our simulator uses theoretical principles, which may not hold to precision when compared to practical examples, hence we'd recommend not using this to calculate to such a high precision, especially when working with non-linear components.
The user would typically have an existing netlist file, this should start with lines containing component names, connected nodes, and their intrinsic properties, i.e. resistance or capacitance.
We assume ideal characteristics of components, in that for most components there is no parasitic capacitance or inductance, moreover, we also assume that nodal analysis is always true, which also assumes wires and connectors are essentially perfect conductors.
Dependencies: Python3
& install packages from requirements.txt