Skip to content
This repository has been archived by the owner on Sep 27, 2023. It is now read-only.

Commit

Permalink
geometry compiler: count(list): bug #48
Browse files Browse the repository at this point in the history
  • Loading branch information
doug-moen committed Dec 24, 2018
1 parent fff5fab commit 01a541d
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
9 changes: 9 additions & 0 deletions libcurv/builtin.cc
Original file line number Diff line number Diff line change
Expand Up @@ -446,6 +446,15 @@ struct Count_Function : public Legacy_Function
}
throw Exception(At_Arg(*this, args), "not a list or string");
}
GL_Value gl_call(GL_Frame& f) const override
{
auto arg = f[0];
if (!arg.type.is_list())
throw Exception(At_GL_Arg(0, f), "count: argument is not a list");
auto result = f.gl.newvalue(GL_Type::Num());
f.gl.out << " float "<<result<<" = "<<arg.type.count()<<";\n";
return result;
}
};
struct Fields_Function : public Legacy_Function
{
Expand Down
5 changes: 2 additions & 3 deletions libcurv/gl_type.h
Original file line number Diff line number Diff line change
Expand Up @@ -88,10 +88,9 @@ struct GL_Type
// first dimension, if type is a list
inline unsigned count() const
{
if (base_type_ >= Base_Type::Vec2)
return base_info().dim1;
else
if (rank_)
return dim1_;
return base_info().dim1;
}
// If this is an array, strip one dimension off of the type.
GL_Type abase()
Expand Down

0 comments on commit 01a541d

Please sign in to comment.