// TEMPLATE -> k_template string // int P_Template() { int nRet; PSTATEDESC pDesc; ObjectType object; pDesc = s_pContext->CreateStatement(State_Template); if (!pDesc) { ErrorReport(Lube_E_OutOfMemory); return Ret_AbortOnError; } if (_GetToken() != Token_string) { ErrorReport(Lube_E_ExpectSymbol, "template name"); return Ret_AbortOnError; } nRet = FindTemplate(s_pContext->m_pLube, g_szCurrentToken); if (nRet < 0) { nRet = DoCompiling(g_szCurrentToken); } if (nRet >= 0) { pDesc->dwExtra = nRet; object = s_pContext->m_pLube->ppTemplates[nRet]->tRoot.object; if (Object_Class == object) { if (s_pContext->m_nClass > 0) { pDesc->object = Object_Class; } else { ErrorReport(Lube_E_NoValidObject, "class"); } } else if (Object_Interface == object) { if (s_pContext->m_nInterface > 0) { pDesc->object = Object_Interface; } else { ErrorReport(Lube_E_NoValidObject, "interface"); } } } s_pContext->LeaveStatement(); return Ret_Continue; }
int main(int argc, char **argv) { char buffer[c_nMaxTextSize]; ParserContext context(buffer); CommandArgs args; if (ParseArgs(argc, argv, &args) < 0) return LUBE_FAIL; InitParser(&context, args.pszSourcePath); DoCompiling(args.pszSource); if (0 != g_nErrorNumber) { fprintf(stderr, "[INFO] lubc (0x1001) : Aborting compilation.\n"); exit(g_nErrorNumber); } if (args.dwAttribs & Command_p_Preview) { PreviewResult(context.m_pLube); } if (args.dwAttribs & Command_o_GenLBO) { SaveLube(context.m_pLube, args.pszLBO); } return LUBE_OK; }
CLSModule * CompileCAR(const char *pszName, DWORD attribs) { CLSModule *pModule; char *psztmp; int len; if (!(attribs & Command_s_NoSys)) { if (LoadSystemLibrary(attribs & Command_e_NoElastos) < 0) { return NULL; } } pModule = CreateCLS(); if (!pModule) { fprintf(stderr, "[ERROR] carc (0x1001) : Out of memory.\n"); return NULL; } if (attribs & Command_w_SuppWarn) SuppressWarning(); if (attribs & Command_t_Warn2Err) TreatWarningAsError(); if (attribs & Command_e_NoElastos) DisableWarning(0x000f); if (attribs & Command_a_Compress) pModule->mAttribs |= CARAttrib_compress; if (attribs & Command_A_FreeModel) SetDefaultThreadModel(ClassAttrib_naked); if (attribs & Command_i_IgrName) s_bLenientNaming = true; if (attribs & Command_k_InKernel) s_bInKernel = true; if (attribs & Command_d_Depend) { s_bMakeDependence = true; len = strlen(pszName); psztmp = new char[len + 1]; if (!psztmp) { fprintf(stderr, "[ERROR] carc (0x1002) : Out of memory.\n"); return NULL; } GetNakedFileName(pszName, psztmp); psztmp[len - 4] = '\0'; strcat(psztmp, ".rsc"); GenCarDependences(psztmp, 0); delete psztmp; } if (attribs & Command_u_WeakRef) s_bSupportWeakRef = true; if (attribs & Command_n_NakedMode) s_bInNakedMode = true; InitNamespace(); // compiling // DoCompiling(pszName, pModule); UninitNamespace(); if (0 != g_nErrorNumber) { fprintf(stderr, "[INFO] carc (0x1003) : Aborting compilation.\n"); DestroyCLS(pModule); return NULL; } len = strlen(pszName); psztmp = new char[len + 1]; if (!psztmp) { fprintf(stderr, "[ERROR] carc (0x1002) : Out of memory.\n"); return NULL; } GetNakedFileName(pszName, psztmp); psztmp[len - 4] = '\0'; strcat(psztmp, ".tmp"); if (CLS2CAR(psztmp, pModule) < 0) { delete[] psztmp; fprintf(stderr, "[ERROR] carc (0x1002) : Generate temp file for generate checksum code error.\n"); return NULL; } if (!GenCarChecksum(psztmp, pModule)) { delete[] psztmp; fprintf(stderr, "[ERROR] carc (0x1002) : Generate Rabin checksum code error.\n"); return NULL; } if (!GenCarBarcode(pModule)) { fprintf(stderr, "[ERROR] carc (0x1002) : Generate barcode error.\n"); return NULL; } delete[] psztmp; return pModule; }