public InheritanceChecker(string className, Block objectBlock, Parameters parameters, string superClassName, bool isAbstract, string[] traitNames) { this.className = className; this.isAbstract = isAbstract; this.traitNames = traitNames; _superClass = CompilerState.Class(superClassName); if (_superClass.IsSome || traitNames.Length > 0) { signatures = getSignatures(objectBlock, parameters); if (_superClass.If(out var superClass)) { var superObjectBlock = superClass.ObjectBlock; superSignatures = getSignatures(superObjectBlock, superClass.Parameters); abstractSignatures = superObjectBlock.AsAdded .OfType <SpecialAssignment>() .Where(a => a.IsAbstract) .Select(a => ((Abstract)a.Value).Signature) .ToHash(s => s.Name); } else { superSignatures = new Hash <string, Signature>(); abstractSignatures = new Hash <string, Signature>(); } overrides = objectBlock.AsAdded.OfType <CreateFunction>().ToHash(cf => cf.FunctionName, cf => cf.Overriding); foreach (var name in parameters.GetParameters().Select(parameter => parameter.Name)) { overrides[name] = true; overrides[SetterName(name)] = true; } } }
static Value evaluateVariable(string name) { if (name == "_") { return(new Any()); } var possibleClass = CompilerState.Class(name); if (possibleClass.IsSome) { return(possibleClass.Value); } var possibleTrait = CompilerState.Trait(name); if (possibleTrait.IsSome) { return(possibleTrait.Value); } if (IsClassName(name)) { return(new Variable(name)); } return(new Placeholder(name)); }