private void SetupConstructors(){
MemberInfo[] consmem = classob.GetMember(this.name,
BindingFlags.Public|BindingFlags.NonPublic|BindingFlags.Instance|BindingFlags.Static|BindingFlags.DeclaredOnly); //See if the class has a member with the name of the class
if (consmem == null){
this.AllocateImplicitDefaultConstructor();
FieldInfo field = this.classob.AddNewField(this.name, this.implicitDefaultConstructor, FieldAttributes.Literal);
this.classob.constructors = new ConstructorInfo[]{new JSConstructor(this.implicitDefaultConstructor)};
}else{
MemberInfo cmem0 = null;
foreach (MemberInfo cmem in consmem){
if (cmem is JSFieldMethod){
FunctionObject cons = ((JSFieldMethod)cmem).func;
if (cmem0 == null) cmem0 = cmem;
if (cons.return_type_expr != null)
cons.return_type_expr.context.HandleError(JSError.ConstructorMayNotHaveReturnType);
if ((cons.attributes & MethodAttributes.Abstract) != 0 || (cons.attributes & MethodAttributes.Static) != 0){
cons.isStatic = false;
JSVariableField f = (JSVariableField)((JSFieldMethod)cmem).field;
f.attributeFlags &= ~FieldAttributes.Static;
f.originalContext.HandleError(JSError.NotValidForConstructor);
}
cons.return_type_expr = new TypeExpression(new ConstantWrapper(Typeob.Void, context));
cons.own_scope.AddReturnValueField();
}
//The else case can only happen if there is an error in the source code. Messages are generated elsewhere.
}
if (cmem0 != null)
this.classob.constructors = ((JSMemberField)((JSFieldMethod)cmem0).field).GetAsConstructors(this.classob);
else{
this.AllocateImplicitDefaultConstructor();
this.classob.constructors = new ConstructorInfo[]{new JSConstructor(this.implicitDefaultConstructor)};
}
}
}