Exemplo n.º 1
0
void C4AulScriptEngine::Link(C4DefList *rDefs)
{
	try
	{
		// resolve appends
		for (C4AulScript *s = Child0; s; s = s->Next)
			s->ResolveAppends(rDefs);

		// resolve includes
		for (C4AulScript *s = Child0; s; s = s->Next)
			s->ResolveIncludes(rDefs);

		// parse the scripts to byte code
		for (C4AulScript *s = Child0; s; s = s->Next)
			s->Parse();

		// engine is always parsed (for global funcs)
		State = ASS_PARSED;

		if (rDefs)
			rDefs->CallEveryDefinition();

		// Done modifying the proplists now
		for (C4AulScript *s = Child0; s; s = s->Next)
			s->GetPropList()->Freeze();
		GetPropList()->Freeze();
	}
	catch (C4AulError &err)
	{
		// error??! show it!
		err.show();
	}


}
Exemplo n.º 2
0
// ResolveAppends and ResolveIncludes must be called both
// for each script. ResolveAppends has to be called first!
BOOL C4AulScript::ResolveAppends(C4DefList *rDefs) {
  // resolve children appends
  for (C4AulScript *s = Child0; s; s = s->Next) s->ResolveAppends(rDefs);
  // resolve local appends
  if (State != ASS_PREPARSED) return FALSE;
  for (C4AListEntry *a = Appends; a; a = a->next()) {
    if ((long)a->Var != -1) {
      C4Def *Def = rDefs->ID2Def(C4ID(a->Var));
      if (Def)
        AppendTo(Def->Script, true);
      else {
        // save id in buffer because AulWarn will use the buffer of C4IdText
        // to get the id of the object in which the error occurs...
        // (stupid static buffers...)
        char strID[5];
        *strID = 0;
        strcpy(strID, C4IdText(C4ID(a->Var)));
        Warn("script to #appendto not found: ", strID);
      }
    } else {
      // append to all defs
      for (int i = 0; i < rDefs->GetDefCount(); i++) {
        C4Def *pDef = rDefs->GetDef(i);
        if (!pDef) break;
        if (pDef == Def) continue;
        // append
        AppendTo(pDef->Script, true);
      }
    }
  }
  return TRUE;
}