void YpSpecial(int which) { if (!insideFunc && which<14) { /* Special form allows builtins with names the same as range functions to be declared and documented in std.i. */ RecordSource(Globalize(rfNames[which], 0L)); } else { YpError("illegal name in extern statement"); } }
HdmiTimerRecordSources::ExternalSourceDecorator::ExternalSourceDecorator( /* [in] */ IRecordSource* recordSource, /* [in] */ Int32 externalSourceSpecifier) : mRecordSource(recordSource) , mExternalSourceSpecifier(externalSourceSpecifier) { // External source has one byte field for [External Source Specifier]. Int32 size; recordSource->GetDataSize(FALSE, &size); RecordSource(((RecordSource*)recordSource.Get())->mSourceType, size + 1); }
void YpExtern(Literal name) { long literalType= literalTypes[name]; if ((literalType&(L_REFERENCE|L_LOCAL)) == (L_REFERENCE|L_LOCAL)) { YpError("extern variable conflicts with local variable"); } else { /* presume that it WILL be referenced, otherwise it could revert to local without comment */ literalTypes[name] |= L_REFERENCE; literalTypes[name] &= ~L_LOCAL; } if (!insideFunc) { /* Outside a func body, extern is used to point to variables whose definitions are to be accessible via Yorick's help mechanism. This is one part kludge/hack, one part slick. struct and func definitions are automatically accessible (see the end of YpFunc). */ RecordSource(Globalize(literalTable.names[name], 0L)); } }
void YpLocal(Literal name) { long literalType= literalTypes[name]; if (literalType&L_REFERENCE) { if (!(literalType&L_LOCAL)) YpError("local variable conflicts with extern variable"); } else { /* presume that it WILL be referenced -- once nLocal is incremented, the name has to be globalized anyway */ nLocal++; literalTypes[name]|= (L_REFERENCE | L_LOCAL); } if (!insideFunc) { /* Outside a func body, local is used to point to variables whose definitions are to be accessible via Yorick's help mechanism. Unlike extern, local is NOT used by Codger, so it can be used to provide documentation strings for objects which are not built-in functions, functions, or structs. */ RecordSource(Globalize(literalTable.names[name], 0L)); } }
void YpFunc(int isMain, int eol) { long codeSize, i, pc; Function *parsedFunc= 0; DataBlock *oldDB; Symbol *cTable; if (!eol || ypErrors) { if (!eol) YpError("garbage after func or struct definition"); ClearParser((void *)0); return; } if (isMain && nextPC==0) return; /* NOTE- if stackDepth!=0 here, there is a bug in the parser... (unless a previous error involving matrix multiplication?) */ if (previousOp!=&Return) YpReturn(NONE); if (isMain) nLocal= 0; /* end of function marked by code.Action==&Return followed by code.Action==0, followed by code.index==codeSize to enable error recovery to find beginning of function */ if (CheckCodeSpace(2)) { ClearParser((void *)0); return; } vmCode[nextPC++].Action= previousOp= 0; vmCode[nextPC].index= codeSize= 1+nPos+(hasPosList&1)+nKey+nLocal+ nextPC; nextPC++; /* fill in all forward-referenced goto targets */ if (nTarget) { YpError("missing goto label at end of func"); ClearParser((void *)0); return; } for (i=0 ; i<nGotoTargets ; i++) { pc= gotoTargets[i]; SetBranchTarget(pc, (literalTypes[vmCode[pc].index]>>3)); } nGotoTargets= 0; /* shorten constant table to its final size */ if (nConstants) { constantTable= p_realloc(constantTable, nConstants*sizeof(Symbol)); maxConstants= nConstants; } /* fill in all references to constants */ if (!reparsing) cTable= constantTable; else cTable= reparsing->constantTable; for (i=0 ; i<nConstantRefs ; i++) { pc= constantRefs[i]; vmCode[pc].constant= cTable+vmCode[pc].index; } nConstantRefs= 0; /* locate or create all referenced variable names in globTab -- reuse literalTypes array to hold globTab index */ if (CheckCodeSpace(1+nPos+(hasPosList&1)+nKey+nLocal)) { ClearParser((void *)0); return; } if (isMain) { for (i=0 ; i<literalTable.nItems ; i++) if (literalTypes[i]&(L_REFERENCE|L_LOCAL)) literalTypes[i]= Globalize(literalTable.names[i], 0L); vmCode[nextPC++].index= Globalize(isMain==1? "*main*" : literalTable.names[0], 0L); } else { for (i=0 ; i<literalTable.nItems ; i++) { /* Note that function name is first, then positional parameters, then optional *va* parameter, then keyword parameters. */ if (literalTypes[i]&(L_REFERENCE|L_LOCAL)) { if ((literalTypes[i]&(L_REFERENCE|L_LOCAL)) == (L_REFERENCE|L_LOCAL)) vmCode[nextPC++].index= literalTypes[i]= Globalize(literalTable.names[i], 0L); else literalTypes[i]= Globalize(literalTable.names[i], 0L); } } } /* fill in all references to variables */ for (i=0 ; i<nVariableRefs ; i++) { pc= variableRefs[i]; vmCode[pc].index= literalTypes[vmCode[pc].index]; } nVariableRefs= 0; /* done with literal table */ HashClear(&literalTable); /* sets literalTable.maxItems==0 */ p_free(literalTypes); literalTypes= 0; if (!reparsing) parsedFunc= NewFunction(constantTable, nConstants, nPos, nKey, nLocal, hasPosList, maxStackDepth, vmCode, codeSize); else ypReMatch= YpReCompare(reparsing, constantTable, nConstants, nPos, nKey, nLocal, hasPosList, maxStackDepth, vmCode, codeSize); nConstants= maxConstants= 0; constantTable= 0; if (reparsing) return; i= parsedFunc->code[0].index; oldDB= globTab[i].value.db; globTab[i].value.db= (DataBlock *)parsedFunc; if (globTab[i].ops==&dataBlockSym) { Unref(oldDB); } else globTab[i].ops= &dataBlockSym; /* A main function must be pushed onto the stack here; anything else (func or struct definitions) is recorded in the sourceList for the current include file (see also YpExtern). */ if (isMain) PushTask(parsedFunc); else parsedFunc->isrc = RecordSource(i); }