private void InitializeProperties() { foreach (var property in Klass.GetProperties() .Where(x => x.IsStatic == false) .OfType <SSInterpretPropertyInfo>()) { if (property.Initializer != null) { Runner.BindThis(this); property.BackingField.SetValue(this, Runner.RunExpression(property.Initializer.Value)); } } }
internal SSMethodInfo(Runner runner, string id, HybType declaringType, BaseMethodDeclarationSyntax declaration) { this.Id = id; this.Signature = MemberSignature.GetSignature( runner.Resolver, id, declaration); this.DeclaringType = declaringType; this.Target = new Invokable(this, runner, declaration); if (declaration is MethodDeclarationSyntax md) { this.ReturnType = runner.Resolver.GetType($"{md.ReturnType}"); } this.IsVaArg = declaration.ParameterList.Parameters.LastOrDefault() ?.Modifiers.IsParams() ?? false; this.Parameters = new SSParamInfo[declaration.ParameterList.Parameters.Count]; for (int i = 0; i < this.Parameters.Length; i++) { var p = declaration.ParameterList.Parameters[i]; this.Parameters[i] = new SSParamInfo() { Id = p.Identifier.Text, DefaultValue = p.Default != null?runner.RunExpression(p.Default.Value) : null, IsParams = p.Modifiers.IsParams() }; } }
private void ProcessArgumentList(ArgumentListSyntax node) { foreach (var arg in node.Arguments) { if (NodeAnalyzer.IsStaticExpression(arg.Expression) == false) { return; } } var values = new HybInstance[node.Arguments.Count]; var count = 0; foreach (var arg in node.Arguments) { values[count++] = runner.RunExpression(arg.Expression); } /* * new EvaluatedArgumentListSyntax() * { * arguments = values * }; */ }
public int AddMember(EnumMemberDeclarationSyntax node) { AddField(new SSInterpretFieldInfo(this) { Id = node.Identifier.Text, AccessModifier = AccessModifier.Public, IsStatic = true }); var value = NextValue; if (node.EqualsValue != null) { value = Runner.RunExpression(node.EqualsValue.Value).As <int>(); } NextValue = value + 1; return(value); }