int StartGlobalScope(CgStruct *Cg) { // Create user's global scope: GlobalScope = NewScopeInPool(mem_CreatePool(0, 0)); PushScope(GlobalScope); return 1; } // StartGlobalScope
int InitCPP(void) { // Add various atoms needed by the CPP line scanner: bindAtom = LookUpAddString(atable, "bind"); constAtom = LookUpAddString(atable, "const"); defaultAtom = LookUpAddString(atable, "default"); defineAtom = LookUpAddString(atable, "define"); definedAtom = LookUpAddString(atable, "defined"); elifAtom = LookUpAddString(atable, "elif"); elseAtom = LookUpAddString(atable, "else"); endifAtom = LookUpAddString(atable, "endif"); ifAtom = LookUpAddString(atable, "if"); ifdefAtom = LookUpAddString(atable, "ifdef"); ifndefAtom = LookUpAddString(atable, "ifndef"); includeAtom = LookUpAddString(atable, "include"); lineAtom = LookUpAddString(atable, "line"); pragmaAtom = LookUpAddString(atable, "pragma"); texunitAtom = LookUpAddString(atable, "texunit"); undefAtom = LookUpAddString(atable, "undef"); errorAtom = LookUpAddString(atable, "error"); __LINE__Atom = LookUpAddString(atable, "__LINE__"); __FILE__Atom = LookUpAddString(atable, "__FILE__"); __VERSION__Atom = LookUpAddString(atable, "__VERSION__"); versionAtom = LookUpAddString(atable, "version"); macros = NewScopeInPool(mem_CreatePool(0, 0)); return 1; } // InitCPP
int InitCPP(void) { char buffer[64], *t; const char *f; // Add various atoms needed by the CPP line scanner: bindAtom = LookUpAddString(atable, "bind"); constAtom = LookUpAddString(atable, "const"); defaultAtom = LookUpAddString(atable, "default"); defineAtom = LookUpAddString(atable, "define"); definedAtom = LookUpAddString(atable, "defined"); elifAtom = LookUpAddString(atable, "elif"); elseAtom = LookUpAddString(atable, "else"); endifAtom = LookUpAddString(atable, "endif"); ifAtom = LookUpAddString(atable, "if"); ifdefAtom = LookUpAddString(atable, "ifdef"); ifndefAtom = LookUpAddString(atable, "ifndef"); includeAtom = LookUpAddString(atable, "include"); lineAtom = LookUpAddString(atable, "line"); pragmaAtom = LookUpAddString(atable, "pragma"); texunitAtom = LookUpAddString(atable, "texunit"); undefAtom = LookUpAddString(atable, "undef"); errorAtom = LookUpAddString(atable, "error"); __LINE__Atom = LookUpAddString(atable, "__LINE__"); __FILE__Atom = LookUpAddString(atable, "__FILE__"); __VERSION__Atom = LookUpAddString(atable, "__VERSION__"); versionAtom = LookUpAddString(atable, "version"); extensionAtom = LookUpAddString(atable, "extension"); macros = NewScopeInPool(mem_CreatePool(0, 0)); strcpy(buffer, "PROFILE_"); t = buffer + strlen(buffer); f = cpp->options.profileString; while ((isalnum(*f) || *f == '_') && t < buffer + sizeof(buffer) - 1) *t++ = toupper(*f++); *t = 0; PredefineIntMacro("GL_ES", 1); PredefineIntMacro("GL_FRAGMENT_PRECISION_HIGH", 1); return 1; } // InitCPP
int InitSymbolTable(CgStruct *Cg) { SourceLoc dummyLoc = { 0, 0 }; int ii, name; // Create the super-global scope and add predefined types and symbols: PushScope(NewScopeInPool(mem_CreatePool(0, 0))); UndefinedType = NewType(TYPE_BASE_UNDEFINED_TYPE | TYPE_CATEGORY_SCALAR, 0); CFloatType = NewType(TYPE_BASE_CFLOAT | TYPE_CATEGORY_SCALAR | TYPE_QUALIFIER_CONST, 1); CIntType = NewType(TYPE_BASE_CINT | TYPE_CATEGORY_SCALAR | TYPE_QUALIFIER_CONST, 1); VoidType = NewType(TYPE_BASE_VOID | TYPE_CATEGORY_SCALAR | TYPE_MISC_VOID, 0); FloatType = NewType(TYPE_BASE_FLOAT | TYPE_CATEGORY_SCALAR, 1); IntType = NewType(TYPE_BASE_INT | TYPE_CATEGORY_SCALAR, 1); BooleanType = NewType(TYPE_BASE_BOOLEAN | TYPE_CATEGORY_SCALAR, 1); CFloat1Type = NewPackedArrayType(CFloatType, 1, TYPE_QUALIFIER_CONST); CFloat2Type = NewPackedArrayType(CFloatType, 2, TYPE_QUALIFIER_CONST); CFloat3Type = NewPackedArrayType(CFloatType, 3, TYPE_QUALIFIER_CONST); CFloat4Type = NewPackedArrayType(CFloatType, 4, TYPE_QUALIFIER_CONST); CInt1Type = NewPackedArrayType(CIntType, 1, TYPE_QUALIFIER_CONST); CInt2Type = NewPackedArrayType(CIntType, 2, TYPE_QUALIFIER_CONST); CInt3Type = NewPackedArrayType(CIntType, 3, TYPE_QUALIFIER_CONST); CInt4Type = NewPackedArrayType(CIntType, 4, TYPE_QUALIFIER_CONST); Float1Type = NewPackedArrayType(FloatType, 1, 0); Float2Type = NewPackedArrayType(FloatType, 2, 0); Float3Type = NewPackedArrayType(FloatType, 3, 0); Float4Type = NewPackedArrayType(FloatType, 4, 0); Int1Type = NewPackedArrayType(IntType, 1, 0); Int2Type = NewPackedArrayType(IntType, 2, 0); Int3Type = NewPackedArrayType(IntType, 3, 0); Int4Type = NewPackedArrayType(IntType, 4, 0); Boolean1Type = NewPackedArrayType(BooleanType, 1, 0); Boolean2Type = NewPackedArrayType(BooleanType, 2, 0); Boolean3Type = NewPackedArrayType(BooleanType, 3, 0); Boolean4Type = NewPackedArrayType(BooleanType, 4, 0); AddSymbol(&dummyLoc, CurrentScope, LookUpAddString(atable, "cfloat"), CFloatType, TYPEDEF_S); AddSymbol(&dummyLoc, CurrentScope, LookUpAddString(atable, "cint"), CIntType, TYPEDEF_S); AddSymbol(&dummyLoc, CurrentScope, VOID_SY, VoidType, TYPEDEF_S); AddSymbol(&dummyLoc, CurrentScope, FLOAT_SY, FloatType, TYPEDEF_S); AddSymbol(&dummyLoc, CurrentScope, INT_SY, IntType, TYPEDEF_S); AddSymbol(&dummyLoc, CurrentScope, BOOLEAN_SY, BooleanType, TYPEDEF_S); AddSymbol(&dummyLoc, CurrentScope, LookUpAddString(atable, "cfloat1"), CFloat1Type, TYPEDEF_S); AddSymbol(&dummyLoc, CurrentScope, LookUpAddString(atable, "cfloat2"), CFloat2Type, TYPEDEF_S); AddSymbol(&dummyLoc, CurrentScope, LookUpAddString(atable, "cfloat3"), CFloat3Type, TYPEDEF_S); AddSymbol(&dummyLoc, CurrentScope, LookUpAddString(atable, "cfloat4"), CFloat4Type, TYPEDEF_S); AddSymbol(&dummyLoc, CurrentScope, LookUpAddString(atable, "cint1"), CInt1Type, TYPEDEF_S); AddSymbol(&dummyLoc, CurrentScope, LookUpAddString(atable, "cint2"), CInt2Type, TYPEDEF_S); AddSymbol(&dummyLoc, CurrentScope, LookUpAddString(atable, "cint3"), CInt3Type, TYPEDEF_S); AddSymbol(&dummyLoc, CurrentScope, LookUpAddString(atable, "cint4"), CInt4Type, TYPEDEF_S); AddSymbol(&dummyLoc, CurrentScope, LookUpAddString(atable, "float1"), Float1Type, TYPEDEF_S); AddSymbol(&dummyLoc, CurrentScope, LookUpAddString(atable, "float2"), Float2Type, TYPEDEF_S); AddSymbol(&dummyLoc, CurrentScope, LookUpAddString(atable, "float3"), Float3Type, TYPEDEF_S); AddSymbol(&dummyLoc, CurrentScope, LookUpAddString(atable, "float4"), Float4Type, TYPEDEF_S); AddSymbol(&dummyLoc, CurrentScope, LookUpAddString(atable, "int1"), Int1Type, TYPEDEF_S); AddSymbol(&dummyLoc, CurrentScope, LookUpAddString(atable, "int2"), Int2Type, TYPEDEF_S); AddSymbol(&dummyLoc, CurrentScope, LookUpAddString(atable, "int3"), Int3Type, TYPEDEF_S); AddSymbol(&dummyLoc, CurrentScope, LookUpAddString(atable, "int4"), Int4Type, TYPEDEF_S); AddSymbol(&dummyLoc, CurrentScope, LookUpAddString(atable, "bool1"), Boolean1Type, TYPEDEF_S); AddSymbol(&dummyLoc, CurrentScope, LookUpAddString(atable, "bool2"), Boolean2Type, TYPEDEF_S); AddSymbol(&dummyLoc, CurrentScope, LookUpAddString(atable, "bool3"), Boolean3Type, TYPEDEF_S); AddSymbol(&dummyLoc, CurrentScope, LookUpAddString(atable, "bool4"), Boolean4Type, TYPEDEF_S); FalseSymb = AddSymbol(&dummyLoc, CurrentScope, LookUpAddString(atable, "false"), BooleanType, CONSTANT_S); TrueSymb = AddSymbol(&dummyLoc, CurrentScope, LookUpAddString(atable, "true"), BooleanType, CONSTANT_S); FalseSymb->details.con.value = 0; TrueSymb->details.con.value = 1; SetScalarTypeName(TYPE_BASE_NO_TYPE, LookUpAddString(atable, "***no-base-type***"), UndefinedType); SetScalarTypeName(TYPE_BASE_UNDEFINED_TYPE, LookUpAddString(atable, "***undefined-base-type***"), UndefinedType); SetScalarTypeName(TYPE_BASE_CFLOAT, LookUpAddString(atable, "cfloat"), CFloatType); SetScalarTypeName(TYPE_BASE_CINT, LookUpAddString(atable, "cint"), CIntType); SetScalarTypeName(TYPE_BASE_VOID, LookUpAddString(atable, "void"), VoidType); SetScalarTypeName(TYPE_BASE_FLOAT, LookUpAddString(atable, "float"), FloatType); SetScalarTypeName(TYPE_BASE_INT, LookUpAddString(atable, "int"), IntType); SetScalarTypeName(TYPE_BASE_BOOLEAN, LookUpAddString(atable, "bool"), BooleanType); name = LookUpAddString(atable, "***unknown-profile-base-type***"); for (ii = TYPE_BASE_FIRST_USER; ii <= TYPE_BASE_LAST_USER; ii++) SetScalarTypeName(ii, name, UndefinedType); // Add profile specific symbols and types: Cg->theHAL->RegisterNames(Cg->theHAL); AddAtom(atable, "<*** end hal specific atoms ***>"); // Initialize misc. other globals: CurrentDeclTypeSpecs.basetype = UndefinedType; CurrentDeclTypeSpecs.IsDerived = 0; CurrentDeclTypeSpecs.type = *UndefinedType; return 1; } // InitSymbolTable