internal static IClass CompileClass(string clsname, string[] varnames, string[] methods, string[] clsmethods)
{
Machine machine = new Machine();
IClass cls = machine.CreateClass(clsname);
if (varnames != null)
{
foreach (string varname in varnames)
{
cls.DefineInstanceVariable(varname);
}
}
if (methods != null)
{
foreach (string method in methods)
{
ModelParser parser = new ModelParser(method);
MethodModel model = parser.ParseMethod();
Method newmethod = new Method(cls, model.Selector, method);
BytecodeCompiler compiler = new BytecodeCompiler(newmethod);
compiler.CompileMethod(model);
cls.DefineInstanceMethod(newmethod);
}
}
if (clsmethods != null)
{
foreach (string method in clsmethods)
{
ModelParser parser = new ModelParser(method);
MethodModel model = parser.ParseMethod();
Method newmethod = new Method(cls, model.Selector, method);
BytecodeCompiler compiler = new BytecodeCompiler(newmethod);
compiler.CompileMethod(model);
cls.DefineClassMethod(newmethod);
}
}
return cls;
}