?? generic_hal.c
字號:
* GetConnectorID_generic()
*/
static int GetConnectorID_generic(int name)
{
int i;
for (i = 0; i < NUMELS(connectors_generic); i++)
if (name == connectors_generic[i].name)
return connectors_generic[i].cid;
return 0;
}
/*
* GetConnectorAtom_generic()
*/
static int GetConnectorAtom_generic(int name)
{
const ConnectorDescriptor *conn
= LookupConnectorHAL(connectors_generic, name, NUMELS(connectors_generic));
return conn ? conn->name : 0;
} // GetConnectorAtom_generic
/*
* GetConnectorUses_generic()
*/
static int GetConnectorUses_generic(int cid, int pid)
{
const ConnectorDescriptor *conn
= LookupConnectorHAL(connectors_generic, cid, NUMELS(connectors_generic));
return conn ? conn->properties : 0;
} //GetConnectorUses_generic
/*
* GetConnectorRegister_generic()
*/
static int GetConnectorRegister_generic(int cid, int ByIndex, int ratom, Binding *fBind)
{
int i;
ConnectorDescriptor *conn;
ConnectorRegisters *regs;
conn = LookupConnectorHAL(connectors_generic, cid, NUMELS(connectors_generic));
if (! conn)
return 0;
regs = conn->registers;
if (! regs)
return 0;
for (i = 0; i < conn->numregs; i++) {
if (ratom == regs[i].name) {
SetSymbolConnectorBindingHAL(fBind, ®s[i]);
return 1;
}
}
return 0;
} // GetConnectorRegister_generic
/*
* GetCapsBit_generic() - Return an integer value representing the
* capabilities of this profile.
*/
static int GetCapsBit_generic(int bitNumber)
{
switch (bitNumber) {
case CAPS_INDEXED_ARRAYS:
case CAPS_DONT_FLATTEN_IF_STATEMENTS:
return 1;
default:
return 0;
}
} // GetCapsBit_generic
/*
* CheckInternalFunction_generic() - Check for internally implemented
* function.
*/
static int CheckInternalFunction_generic(Symbol *fSymb, int *group)
{
return 1;
} // CheckInternalFunction_generic
/*
* BindUniformUnbound_generic() - Bind an unbound variable to a free
* uniform resource.
*
*/
static int BindUniformUnbound_generic(SourceLoc *loc, Symbol *fSymb,
Binding *fBind)
{
fBind->none.properties |= BIND_IS_BOUND;
return 1;
} // BindUniformUnbound_generic
/*
* BindVaryingSemantic_generic()
*/
static int BindVaryingSemantic_generic(SourceLoc *loc, Symbol *fSymb,
int semantic, Binding *fBind,
int IsOutVal)
{
int ii, index, len, HasSuffix, base, IsFloating;
SemanticsDescriptor *semantics;
char root[128];
const char *pname, *match;
Type *lType;
pname = GetAtomString(atable, semantic);
HasSuffix = HasNumericSuffix(pname, root, 128, &index);
semantics = Cg->theHAL->semantics;
for (ii = 0; ii < Cg->theHAL->numSemantics; ii++, semantics++) {
match = semantics->numregs > 0 ? root : pname;
if (!strcmp(match, semantics->sname)) {
if (semantics->numregs > 0) {
if (index >= semantics->numregs) {
SemanticError(loc, ERROR_S_SEMANTICS_INDEX_TOO_BIG, pname);
return 0;
}
} else {
index = 0;
}
// Found a match. See if the type is compatible:
lType = fSymb->type;
if (IsScalar(lType)) {
len = 1;
} else if (IsVector(lType, &len)) {
} else {
SemanticError(loc, ERROR_S_SEM_VAR_NOT_SCALAR_VECTOR,
GetAtomString(atable, fSymb->name));
return 0;
}
base = GetBase(lType);
IsFloating = (base == TYPE_BASE_FLOAT);
if (!IsFloating)
return 0;
if (semantics->properties & SEM_VARYING) {
fBind->none.kind = BK_CONNECTOR;
fBind->conn.rname = semantic;
fBind->conn.regno = semantics->regno + index;
fSymb->properties |= SYMB_IS_CONNECTOR_REGISTER;
} else {
fBind->none.kind = BK_SEMANTIC;
fBind->sem.sname = semantic;
fBind->sem.sregno = 0;
}
fBind->none.properties |= BIND_IS_BOUND | BIND_VARYING;
if (semantics->properties & SEM_HIDDEN)
fBind->conn.properties |= BIND_HIDDEN;
fSymb->properties |= SYMB_CONNECTOR_CAN_READ; // Obsolete
fSymb->properties |= SYMB_CONNECTOR_CAN_WRITE; // Obsolete
if (semantics->properties & SEM_IN)
fBind->none.properties |= BIND_INPUT;
if (semantics->properties & SEM_OUT)
fBind->none.properties |= BIND_OUTPUT;
if (semantics->properties & SEM_REQUIRED)
fBind->none.properties |= BIND_WRITE_REQUIRED;
// fBind->none,gname set elsewhere
// fBind->none.lname set elsewhere
fBind->none.base = semantics->base;
fBind->none.size = semantics->size;
return 1;
}
}
return 0;
} // BindVaryingSemantic_generic
/*
* PrintCodeHeader_generic()
*/
static int PrintCodeHeader_generic(FILE *out)
{
fprintf(out, "# Generic output by Cg compiler\n");
return 1;
} // PrintCodeHeader_generic
static void PrintFunctions(Symbol *symb)
{
Symbol *fSymb;
if (symb) {
PrintFunctions(symb->left);
if (IsFunction(symb)) {
fSymb = symb;
while (fSymb) {
PrintFunction(fSymb);
BPrintFunction(fSymb);
fSymb = fSymb->details.fun.overload;
}
}
PrintFunctions(symb->right);
}
}
/*
* GenerateCode_generic() - Generates human-readable generic output form of
* source code.
*/
static int GenerateCode_generic(SourceLoc *loc, Scope *fScope, Symbol *program)
{
PrintFunctions(fScope->symbols);
return 1;
} // GenerateCode_generic
///////////////////////////////////////////////////////////////////////////////
//////////////////////// End of generic_hal.c /////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -