AddInterface() public method

Add an interface implemented by this class.
Add an interface implemented by this class. This method may be called multiple times for classes that implement multiple interfaces.
public AddInterface ( string interfaceName ) : void
interfaceName string /// a name of an interface implemented /// by the class being written, including full package /// qualification. ///
return void
Beispiel #1
0
		private byte[] GenerateCode(string encodedSource)
		{
			bool hasScript = (scriptOrFnNodes[0].GetType() == Token.SCRIPT);
			bool hasFunctions = (scriptOrFnNodes.Length > 1 || !hasScript);
			string sourceFile = null;
			if (compilerEnv.IsGenerateDebugInfo())
			{
				sourceFile = scriptOrFnNodes[0].GetSourceName();
			}
			ClassFileWriter cfw = new ClassFileWriter(mainClassName, SUPER_CLASS_NAME, sourceFile);
			cfw.AddField(ID_FIELD_NAME, "I", ClassFileWriter.ACC_PRIVATE);
			if (hasFunctions)
			{
				GenerateFunctionConstructor(cfw);
			}
			if (hasScript)
			{
				cfw.AddInterface("org/mozilla/javascript/Script");
				GenerateScriptCtor(cfw);
				GenerateMain(cfw);
				GenerateExecute(cfw);
			}
			GenerateCallMethod(cfw);
			GenerateResumeGenerator(cfw);
			GenerateNativeFunctionOverrides(cfw, encodedSource);
			int count = scriptOrFnNodes.Length;
			for (int i = 0; i != count; ++i)
			{
				ScriptNode n = scriptOrFnNodes[i];
				BodyCodegen bodygen = new BodyCodegen();
				bodygen.cfw = cfw;
				bodygen.codegen = this;
				bodygen.compilerEnv = compilerEnv;
				bodygen.scriptOrFn = n;
				bodygen.scriptOrFnIndex = i;
				try
				{
					bodygen.GenerateBodyCode();
				}
				catch (ClassFileWriter.ClassFileFormatException e)
				{
					throw ReportClassFileFormatException(n, e.Message);
				}
				if (n.GetType() == Token.FUNCTION)
				{
					OptFunctionNode ofn = OptFunctionNode.Get(n);
					GenerateFunctionInit(cfw, ofn);
					if (ofn.IsTargetOfDirectCall())
					{
						EmitDirectConstructor(cfw, ofn);
					}
				}
			}
			EmitRegExpInit(cfw);
			EmitConstantDudeInitializers(cfw);
			return cfw.ToByteArray();
		}