/// <summary> /// Initialize a new instance of the <see cref="ScriptConstructor"/> class using the specified parameter. /// </summary> /// <param name="cls">The class that the constructor belongs to.</param> /// <param name="parameters">The parameters of the constructor.</param> /// <param name="statements">The statements in the constructor body.</param> /// <param name="closure">The closure scope of the constructor.</param> /// <exception cref="ArgumentNullException"><paramref name="closure"/> or <paramref name="cls"/> is <see langword="null"/>.</exception> /// <exception cref="ArgumentException"><paramref name="parameters"/> is invalid.</exception> public ScriptConstructor( ScriptClass cls, ParameterCollection parameters, StatementCollection statements, RuntimeContext closure) { if (closure == null || cls == null) { throw new ArgumentNullException(); } FunctionHelper.CheckParameters(parameters); Class = cls; Parameters = parameters; Closure = closure; Statements = statements; if (statements != null && statements.Count > 0) { var expStat = statements[0] as ExpressionStatement; if (expStat != null) { var funcInv = expStat.Expression as FunctionInvokeExpression; if (funcInv != null) { if (funcInv.Target is SuperReferenceExpression) { var list = statements.ToList(); list.RemoveAt(0); Statements = new StatementCollection(list); SuperCall = funcInv.Parameters; } } } } }