Skip to content

Commit

Permalink
Add
Browse files Browse the repository at this point in the history
  • Loading branch information
SpGerg committed May 21, 2024
1 parent 9a0c5d0 commit ae6f350
Showing 1 changed file with 30 additions and 6 deletions.
36 changes: 30 additions & 6 deletions Paganism/PParser/Values/StructureValue.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,15 +30,27 @@ public StructureValue(ExpressionInfo info, string name, Dictionary<string, Struc

Values.Add("toString", new FunctionValue(ExpressionInfo, new FunctionDeclarateExpression(ExpressionInfo, "toString",
null, new Argument[0], false, InstanceInfo.Empty,
new TypeValue(ExpressionInfo, TypesType.String, string.Empty))));
new TypeValue(ExpressionInfo, TypesType.String, string.Empty)),
(Argument[] arguments) =>
{
return new StringValue(ExpressionInfo, AsString());
}));

Values.Add("getHashCode", new FunctionValue(ExpressionInfo, new FunctionDeclarateExpression(ExpressionInfo, "getHashCode",
null, new Argument[0], false, InstanceInfo.Empty,
new TypeValue(ExpressionInfo, TypesType.Number, string.Empty))));
new TypeValue(ExpressionInfo, TypesType.Number, string.Empty)),
(Argument[] arguments) =>
{
return new NumberValue(ExpressionInfo, GetHashCode());
}));

Values.Add("equals", new FunctionValue(ExpressionInfo, new FunctionDeclarateExpression(ExpressionInfo, "equals",
null, new Argument[] { new Argument("target", TypesType.Any, null, true) }, false, InstanceInfo.Empty,
new TypeValue(ExpressionInfo, TypesType.Boolean, string.Empty))));
new TypeValue(ExpressionInfo, TypesType.Boolean, string.Empty)),
(Argument[] arguments) =>
{
return new BooleanValue(ExpressionInfo, Is(arguments[0].Value.GetTypeValue()));
}));
}

public StructureValue(ExpressionInfo info, StructureInstance structureInstance) : this(info, structureInstance.Name, structureInstance.Members, structureInstance.StructureDeclarateExpression.Info)
Expand Down Expand Up @@ -68,15 +80,27 @@ public StructureValue(ExpressionInfo info, BlockStatementExpression expression,

Values.Add("toString", new FunctionValue(ExpressionInfo, new FunctionDeclarateExpression(ExpressionInfo, "toString",
null, new Argument[0], false, InstanceInfo.Empty,
new TypeValue(ExpressionInfo, TypesType.String, string.Empty))));
new TypeValue(ExpressionInfo, TypesType.String, string.Empty)),
(Argument[] arguments) =>
{
return new StringValue(ExpressionInfo, AsString());
}));

Values.Add("getHashCode", new FunctionValue(ExpressionInfo, new FunctionDeclarateExpression(ExpressionInfo, "getHashCode",
null, new Argument[0], false, InstanceInfo.Empty,
new TypeValue(ExpressionInfo, TypesType.Number, string.Empty))));
new TypeValue(ExpressionInfo, TypesType.Number, string.Empty)),
(Argument[] arguments) =>
{
return new NumberValue(ExpressionInfo, GetHashCode());
}));

Values.Add("equals", new FunctionValue(ExpressionInfo, new FunctionDeclarateExpression(ExpressionInfo, "equals",
null, new Argument[] { new Argument("target", TypesType.Any, null, true) }, false, InstanceInfo.Empty,
new TypeValue(ExpressionInfo, TypesType.Boolean, string.Empty))));
new TypeValue(ExpressionInfo, TypesType.Boolean, string.Empty)),
(Argument[] arguments) =>
{
return new BooleanValue(ExpressionInfo, Is(arguments[0].Value.GetTypeValue()));
}));
}

public override string Name => "Structure";
Expand Down

0 comments on commit ae6f350

Please sign in to comment.