Org.Mozilla.Classfile.ClassFileWriter.AddInterface C# (CSharp) Метод

AddInterface() публичный Метод

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. ///
Результат void
		public virtual void AddInterface(string interfaceName)
		{
			short interfaceIndex = itsConstantPool.AddClass(interfaceName);
			itsInterfaces.Add(Sharpen.Extensions.ValueOf(interfaceIndex));
		}

Usage Example

Пример #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();
		}